islpci_dev.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * Copyright (C) 2002 Intersil Americas Inc.
  3. * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
  4. * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
  5. * Copyright (C) 2003 Aurelien Alleaume <slts@free.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef _ISLPCI_DEV_H
  21. #define _ISLPCI_DEV_H
  22. #include <linux/irqreturn.h>
  23. #include <linux/netdevice.h>
  24. #include <linux/wireless.h>
  25. #include <net/iw_handler.h>
  26. #include <linux/list.h>
  27. #include <linux/mutex.h>
  28. #include "isl_38xx.h"
  29. #include "isl_oid.h"
  30. #include "islpci_mgt.h"
  31. /* some states might not be superflous and may be removed when
  32. design is finalized (hvr) */
  33. typedef enum {
  34. PRV_STATE_OFF = 0, /* this means hw_unavailable is != 0 */
  35. PRV_STATE_PREBOOT, /* we are in a pre-boot state (empty RAM) */
  36. PRV_STATE_BOOT, /* boot state (fw upload, run fw) */
  37. PRV_STATE_POSTBOOT, /* after boot state, need reset now */
  38. PRV_STATE_PREINIT, /* pre-init state */
  39. PRV_STATE_INIT, /* init state (restore MIB backup to device) */
  40. PRV_STATE_READY, /* driver&device are in operational state */
  41. PRV_STATE_SLEEP /* device in sleep mode */
  42. } islpci_state_t;
  43. /* ACL using MAC address */
  44. struct mac_entry {
  45. struct list_head _list;
  46. char addr[ETH_ALEN];
  47. };
  48. struct islpci_acl {
  49. enum { MAC_POLICY_OPEN=0, MAC_POLICY_ACCEPT=1, MAC_POLICY_REJECT=2 } policy;
  50. struct list_head mac_list; /* a list of mac_entry */
  51. int size; /* size of queue */
  52. struct mutex lock; /* accessed in ioctls and trap_work */
  53. };
  54. struct islpci_membuf {
  55. int size; /* size of memory */
  56. void *mem; /* address of memory as seen by CPU */
  57. dma_addr_t pci_addr; /* address of memory as seen by device */
  58. };
  59. #define MAX_BSS_WPA_IE_COUNT 64
  60. #define MAX_WPA_IE_LEN 64
  61. struct islpci_bss_wpa_ie {
  62. struct list_head list;
  63. unsigned long last_update;
  64. u8 bssid[ETH_ALEN];
  65. u8 wpa_ie[MAX_WPA_IE_LEN];
  66. size_t wpa_ie_len;
  67. };
  68. typedef struct {
  69. spinlock_t slock; /* generic spinlock; */
  70. u32 priv_oid;
  71. /* our mib cache */
  72. u32 iw_mode;
  73. struct rw_semaphore mib_sem;
  74. void **mib;
  75. char nickname[IW_ESSID_MAX_SIZE+1];
  76. /* Take care of the wireless stats */
  77. struct work_struct stats_work;
  78. struct mutex stats_lock;
  79. /* remember when we last updated the stats */
  80. unsigned long stats_timestamp;
  81. /* The first is accessed under semaphore locking.
  82. * The second is the clean one we return to iwconfig.
  83. */
  84. struct iw_statistics local_iwstatistics;
  85. struct iw_statistics iwstatistics;
  86. struct iw_spy_data spy_data; /* iwspy support */
  87. struct iw_public_data wireless_data;
  88. int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */
  89. struct islpci_acl acl;
  90. /* PCI bus allocation & configuration members */
  91. struct pci_dev *pdev; /* PCI structure information */
  92. char firmware[33];
  93. void __iomem *device_base; /* ioremapped device base address */
  94. /* consistent DMA region */
  95. void *driver_mem_address; /* base DMA address */
  96. dma_addr_t device_host_address; /* base DMA address (bus address) */
  97. dma_addr_t device_psm_buffer; /* host memory for PSM buffering (bus address) */
  98. /* our network_device structure */
  99. struct net_device *ndev;
  100. /* device queue interface members */
  101. struct isl38xx_cb *control_block; /* device control block
  102. (== driver_mem_address!) */
  103. /* Each queue has three indexes:
  104. * free/index_mgmt/data_rx/tx (called index, see below),
  105. * driver_curr_frag, and device_curr_frag (in the control block)
  106. * All indexes are ever-increasing, but interpreted modulo the
  107. * device queue size when used.
  108. * index <= device_curr_frag <= driver_curr_frag at all times
  109. * For rx queues, [index, device_curr_frag) contains fragments
  110. * that the interrupt processing needs to handle (owned by driver).
  111. * [device_curr_frag, driver_curr_frag) is the free space in the
  112. * rx queue, waiting for data (owned by device). The driver
  113. * increments driver_curr_frag to indicate to the device that more
  114. * buffers are available.
  115. * If device_curr_frag == driver_curr_frag, no more rx buffers are
  116. * available, and the rx DMA engine of the device is halted.
  117. * For tx queues, [index, device_curr_frag) contains fragments
  118. * where tx is done; they need to be freed (owned by driver).
  119. * [device_curr_frag, driver_curr_frag) contains the frames
  120. * that are being transferred (owned by device). The driver
  121. * increments driver_curr_frag to indicate that more tx work
  122. * needs to be done.
  123. */
  124. u32 index_mgmt_rx; /* real index mgmt rx queue */
  125. u32 index_mgmt_tx; /* read index mgmt tx queue */
  126. u32 free_data_rx; /* free pointer data rx queue */
  127. u32 free_data_tx; /* free pointer data tx queue */
  128. u32 data_low_tx_full; /* full detected flag */
  129. /* frame memory buffers for the device queues */
  130. struct islpci_membuf mgmt_tx[ISL38XX_CB_MGMT_QSIZE];
  131. struct islpci_membuf mgmt_rx[ISL38XX_CB_MGMT_QSIZE];
  132. struct sk_buff *data_low_tx[ISL38XX_CB_TX_QSIZE];
  133. struct sk_buff *data_low_rx[ISL38XX_CB_RX_QSIZE];
  134. dma_addr_t pci_map_tx_address[ISL38XX_CB_TX_QSIZE];
  135. dma_addr_t pci_map_rx_address[ISL38XX_CB_RX_QSIZE];
  136. /* wait for a reset interrupt */
  137. wait_queue_head_t reset_done;
  138. /* used by islpci_mgt_transaction */
  139. struct mutex mgmt_lock; /* serialize access to mailbox and wqueue */
  140. struct islpci_mgmtframe *mgmt_received; /* mbox for incoming frame */
  141. wait_queue_head_t mgmt_wqueue; /* waitqueue for mbox */
  142. /* state machine */
  143. islpci_state_t state;
  144. int state_off; /* enumeration of off-state, if 0 then
  145. * we're not in any off-state */
  146. /* WPA stuff */
  147. int wpa; /* WPA mode enabled */
  148. struct list_head bss_wpa_list;
  149. int num_bss_wpa;
  150. struct mutex wpa_lock;
  151. u8 wpa_ie[MAX_WPA_IE_LEN];
  152. size_t wpa_ie_len;
  153. struct work_struct reset_task;
  154. int reset_task_pending;
  155. } islpci_private;
  156. static inline islpci_state_t
  157. islpci_get_state(islpci_private *priv)
  158. {
  159. /* lock */
  160. return priv->state;
  161. /* unlock */
  162. }
  163. islpci_state_t islpci_set_state(islpci_private *priv, islpci_state_t new_state);
  164. #define ISLPCI_TX_TIMEOUT (2*HZ)
  165. irqreturn_t islpci_interrupt(int, void *);
  166. int prism54_post_setup(islpci_private *, int);
  167. int islpci_reset(islpci_private *, int);
  168. static inline void
  169. islpci_trigger(islpci_private *priv)
  170. {
  171. isl38xx_trigger_device(islpci_get_state(priv) == PRV_STATE_SLEEP,
  172. priv->device_base);
  173. }
  174. int islpci_free_memory(islpci_private *);
  175. struct net_device *islpci_setup(struct pci_dev *);
  176. #define DRV_NAME "prism54"
  177. #define DRV_VERSION "1.2"
  178. #endif /* _ISLPCI_DEV_H */