orinoco.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 firmware;
  39. struct orinoco_private {
  40. void *card; /* Pointer to card dependent structure */
  41. struct device *dev;
  42. int (*hard_reset)(struct orinoco_private *);
  43. int (*stop_fw)(struct orinoco_private *, int);
  44. struct ieee80211_supported_band band;
  45. struct ieee80211_channel channels[14];
  46. u32 cipher_suites[3];
  47. /* Synchronisation stuff */
  48. spinlock_t lock;
  49. int hw_unavailable;
  50. struct work_struct reset_work;
  51. /* Interrupt tasklets */
  52. struct tasklet_struct rx_tasklet;
  53. struct list_head rx_list;
  54. /* driver state */
  55. int open;
  56. u16 last_linkstatus;
  57. struct work_struct join_work;
  58. struct work_struct wevent_work;
  59. /* Net device stuff */
  60. struct net_device *ndev;
  61. struct net_device_stats stats;
  62. struct iw_statistics wstats;
  63. /* Hardware control variables */
  64. hermes_t hw;
  65. u16 txfid;
  66. /* Capabilities of the hardware/firmware */
  67. fwtype_t firmware_type;
  68. char fw_name[32];
  69. int ibss_port;
  70. int nicbuf_size;
  71. u16 channel_mask;
  72. /* Boolean capabilities */
  73. unsigned int has_ibss:1;
  74. unsigned int has_port3:1;
  75. unsigned int has_wep:1;
  76. unsigned int has_big_wep:1;
  77. unsigned int has_mwo:1;
  78. unsigned int has_pm:1;
  79. unsigned int has_preamble:1;
  80. unsigned int has_sensitivity:1;
  81. unsigned int has_hostscan:1;
  82. unsigned int has_alt_txcntl:1;
  83. unsigned int has_ext_scan:1;
  84. unsigned int has_wpa:1;
  85. unsigned int do_fw_download:1;
  86. unsigned int broken_disableport:1;
  87. unsigned int broken_monitor:1;
  88. /* Configuration paramaters */
  89. enum nl80211_iftype iw_mode;
  90. int prefer_port3;
  91. u16 encode_alg, wep_restrict, tx_key;
  92. struct orinoco_key keys[ORINOCO_MAX_KEYS];
  93. int bitratemode;
  94. char nick[IW_ESSID_MAX_SIZE+1];
  95. char desired_essid[IW_ESSID_MAX_SIZE+1];
  96. char desired_bssid[ETH_ALEN];
  97. int bssid_fixed;
  98. u16 frag_thresh, mwo_robust;
  99. u16 channel;
  100. u16 ap_density, rts_thresh;
  101. u16 pm_on, pm_mcast, pm_period, pm_timeout;
  102. u16 preamble;
  103. #ifdef WIRELESS_SPY
  104. struct iw_spy_data spy_data; /* iwspy support */
  105. struct iw_public_data wireless_data;
  106. #endif
  107. /* Configuration dependent variables */
  108. int port_type, createibss;
  109. int promiscuous, mc_count;
  110. /* Scanning support */
  111. struct cfg80211_scan_request *scan_request;
  112. struct work_struct process_scan;
  113. struct list_head scan_list;
  114. spinlock_t scan_lock; /* protects the scan list */
  115. /* WPA support */
  116. u8 *wpa_ie;
  117. int wpa_ie_len;
  118. struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
  119. struct crypto_hash *rx_tfm_mic;
  120. struct crypto_hash *tx_tfm_mic;
  121. unsigned int wpa_enabled:1;
  122. unsigned int tkip_cm_active:1;
  123. unsigned int key_mgmt:3;
  124. #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
  125. /* Cached in memory firmware to use during ->resume. */
  126. const struct firmware *cached_pri_fw;
  127. const struct firmware *cached_fw;
  128. #endif
  129. struct notifier_block pm_notifier;
  130. };
  131. #ifdef ORINOCO_DEBUG
  132. extern int orinoco_debug;
  133. #define DEBUG(n, args...) do { \
  134. if (orinoco_debug > (n)) \
  135. printk(KERN_DEBUG args); \
  136. } while (0)
  137. #else
  138. #define DEBUG(n, args...) do { } while (0)
  139. #endif /* ORINOCO_DEBUG */
  140. /********************************************************************/
  141. /* Exported prototypes */
  142. /********************************************************************/
  143. extern struct orinoco_private *alloc_orinocodev(
  144. int sizeof_card, struct device *device,
  145. int (*hard_reset)(struct orinoco_private *),
  146. int (*stop_fw)(struct orinoco_private *, int));
  147. extern void free_orinocodev(struct orinoco_private *priv);
  148. extern int orinoco_init(struct orinoco_private *priv);
  149. extern int orinoco_if_add(struct orinoco_private *priv,
  150. unsigned long base_addr,
  151. unsigned int irq);
  152. extern void orinoco_if_del(struct orinoco_private *priv);
  153. extern int orinoco_up(struct orinoco_private *priv);
  154. extern void orinoco_down(struct orinoco_private *priv);
  155. extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
  156. /********************************************************************/
  157. /* Locking and synchronization functions */
  158. /********************************************************************/
  159. static inline int orinoco_lock(struct orinoco_private *priv,
  160. unsigned long *flags)
  161. {
  162. spin_lock_irqsave(&priv->lock, *flags);
  163. if (priv->hw_unavailable) {
  164. DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
  165. priv->ndev);
  166. spin_unlock_irqrestore(&priv->lock, *flags);
  167. return -EBUSY;
  168. }
  169. return 0;
  170. }
  171. static inline void orinoco_unlock(struct orinoco_private *priv,
  172. unsigned long *flags)
  173. {
  174. spin_unlock_irqrestore(&priv->lock, *flags);
  175. }
  176. /*** Navigate from net_device to orinoco_private ***/
  177. static inline struct orinoco_private *ndev_priv(struct net_device *dev)
  178. {
  179. struct wireless_dev *wdev = netdev_priv(dev);
  180. return wdev_priv(wdev);
  181. }
  182. #endif /* _ORINOCO_H */