orinoco.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /* orinoco.h
  2. *
  3. * Common definitions to all pieces of the various orinoco
  4. * drivers
  5. */
  6. #ifndef _ORINOCO_H
  7. #define _ORINOCO_H
  8. #define DRIVER_VERSION "0.15"
  9. #include <linux/interrupt.h>
  10. #include <linux/suspend.h>
  11. #include <linux/netdevice.h>
  12. #include <linux/wireless.h>
  13. #include <net/iw_handler.h>
  14. #include <net/cfg80211.h>
  15. #include "hermes.h"
  16. /* To enable debug messages */
  17. /*#define ORINOCO_DEBUG 3*/
  18. #define WIRELESS_SPY /* enable iwspy support */
  19. #define MAX_SCAN_LEN 4096
  20. #define ORINOCO_MAX_KEY_SIZE 14
  21. #define ORINOCO_MAX_KEYS 4
  22. struct orinoco_key {
  23. __le16 len; /* always stored as little-endian */
  24. char data[ORINOCO_MAX_KEY_SIZE];
  25. } __attribute__ ((packed));
  26. #define TKIP_KEYLEN 16
  27. #define MIC_KEYLEN 8
  28. struct orinoco_tkip_key {
  29. u8 tkip[TKIP_KEYLEN];
  30. u8 tx_mic[MIC_KEYLEN];
  31. u8 rx_mic[MIC_KEYLEN];
  32. };
  33. typedef enum {
  34. FIRMWARE_TYPE_AGERE,
  35. FIRMWARE_TYPE_INTERSIL,
  36. FIRMWARE_TYPE_SYMBOL
  37. } fwtype_t;
  38. struct bss_element {
  39. union hermes_scan_info bss;
  40. unsigned long last_scanned;
  41. struct list_head list;
  42. };
  43. struct xbss_element {
  44. struct agere_ext_scan_info bss;
  45. unsigned long last_scanned;
  46. struct list_head list;
  47. };
  48. struct firmware;
  49. struct orinoco_private {
  50. void *card; /* Pointer to card dependent structure */
  51. struct device *dev;
  52. int (*hard_reset)(struct orinoco_private *);
  53. int (*stop_fw)(struct orinoco_private *, int);
  54. struct ieee80211_supported_band band;
  55. struct ieee80211_channel channels[14];
  56. u32 cipher_suites[3];
  57. /* Synchronisation stuff */
  58. spinlock_t lock;
  59. int hw_unavailable;
  60. struct work_struct reset_work;
  61. /* Interrupt tasklets */
  62. struct tasklet_struct rx_tasklet;
  63. struct list_head rx_list;
  64. /* driver state */
  65. int open;
  66. u16 last_linkstatus;
  67. struct work_struct join_work;
  68. struct work_struct wevent_work;
  69. /* Net device stuff */
  70. struct net_device *ndev;
  71. struct net_device_stats stats;
  72. struct iw_statistics wstats;
  73. /* Hardware control variables */
  74. hermes_t hw;
  75. u16 txfid;
  76. /* Capabilities of the hardware/firmware */
  77. fwtype_t firmware_type;
  78. char fw_name[32];
  79. int ibss_port;
  80. int nicbuf_size;
  81. u16 channel_mask;
  82. /* Boolean capabilities */
  83. unsigned int has_ibss:1;
  84. unsigned int has_port3:1;
  85. unsigned int has_wep:1;
  86. unsigned int has_big_wep:1;
  87. unsigned int has_mwo:1;
  88. unsigned int has_pm:1;
  89. unsigned int has_preamble:1;
  90. unsigned int has_sensitivity:1;
  91. unsigned int has_hostscan:1;
  92. unsigned int has_alt_txcntl:1;
  93. unsigned int has_ext_scan:1;
  94. unsigned int has_wpa:1;
  95. unsigned int do_fw_download:1;
  96. unsigned int broken_disableport:1;
  97. unsigned int broken_monitor:1;
  98. /* Configuration paramaters */
  99. enum nl80211_iftype iw_mode;
  100. int prefer_port3;
  101. u16 encode_alg, wep_restrict, tx_key;
  102. struct orinoco_key keys[ORINOCO_MAX_KEYS];
  103. int bitratemode;
  104. char nick[IW_ESSID_MAX_SIZE+1];
  105. char desired_essid[IW_ESSID_MAX_SIZE+1];
  106. char desired_bssid[ETH_ALEN];
  107. int bssid_fixed;
  108. u16 frag_thresh, mwo_robust;
  109. u16 channel;
  110. u16 ap_density, rts_thresh;
  111. u16 pm_on, pm_mcast, pm_period, pm_timeout;
  112. u16 preamble;
  113. #ifdef WIRELESS_SPY
  114. struct iw_spy_data spy_data; /* iwspy support */
  115. struct iw_public_data wireless_data;
  116. #endif
  117. /* Configuration dependent variables */
  118. int port_type, createibss;
  119. int promiscuous, mc_count;
  120. /* Scanning support */
  121. struct list_head bss_list;
  122. struct list_head bss_free_list;
  123. void *bss_xbss_data;
  124. int scan_inprogress; /* Scan pending... */
  125. u32 scan_mode; /* Type of scan done */
  126. /* WPA support */
  127. u8 *wpa_ie;
  128. int wpa_ie_len;
  129. struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
  130. struct crypto_hash *rx_tfm_mic;
  131. struct crypto_hash *tx_tfm_mic;
  132. unsigned int wpa_enabled:1;
  133. unsigned int tkip_cm_active:1;
  134. unsigned int key_mgmt:3;
  135. #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
  136. /* Cached in memory firmware to use during ->resume. */
  137. const struct firmware *cached_pri_fw;
  138. const struct firmware *cached_fw;
  139. #endif
  140. struct notifier_block pm_notifier;
  141. };
  142. #ifdef ORINOCO_DEBUG
  143. extern int orinoco_debug;
  144. #define DEBUG(n, args...) do { \
  145. if (orinoco_debug > (n)) \
  146. printk(KERN_DEBUG args); \
  147. } while (0)
  148. #else
  149. #define DEBUG(n, args...) do { } while (0)
  150. #endif /* ORINOCO_DEBUG */
  151. /********************************************************************/
  152. /* Exported prototypes */
  153. /********************************************************************/
  154. extern struct orinoco_private *alloc_orinocodev(
  155. int sizeof_card, struct device *device,
  156. int (*hard_reset)(struct orinoco_private *),
  157. int (*stop_fw)(struct orinoco_private *, int));
  158. extern void free_orinocodev(struct orinoco_private *priv);
  159. extern int orinoco_init(struct orinoco_private *priv);
  160. extern int orinoco_if_add(struct orinoco_private *priv,
  161. unsigned long base_addr,
  162. unsigned int irq);
  163. extern void orinoco_if_del(struct orinoco_private *priv);
  164. extern int orinoco_up(struct orinoco_private *priv);
  165. extern void orinoco_down(struct orinoco_private *priv);
  166. extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
  167. /********************************************************************/
  168. /* Locking and synchronization functions */
  169. /********************************************************************/
  170. static inline int orinoco_lock(struct orinoco_private *priv,
  171. unsigned long *flags)
  172. {
  173. spin_lock_irqsave(&priv->lock, *flags);
  174. if (priv->hw_unavailable) {
  175. DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
  176. priv->ndev);
  177. spin_unlock_irqrestore(&priv->lock, *flags);
  178. return -EBUSY;
  179. }
  180. return 0;
  181. }
  182. static inline void orinoco_unlock(struct orinoco_private *priv,
  183. unsigned long *flags)
  184. {
  185. spin_unlock_irqrestore(&priv->lock, *flags);
  186. }
  187. /*** Navigate from net_device to orinoco_private ***/
  188. static inline struct orinoco_private *ndev_priv(struct net_device *dev)
  189. {
  190. struct wireless_dev *wdev = netdev_priv(dev);
  191. return wdev_priv(wdev);
  192. }
  193. #endif /* _ORINOCO_H */