orinoco.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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_SEQ_LEN 8
  21. #define ORINOCO_MAX_KEY_SIZE 14
  22. #define ORINOCO_MAX_KEYS 4
  23. struct orinoco_key {
  24. __le16 len; /* always stored as little-endian */
  25. char data[ORINOCO_MAX_KEY_SIZE];
  26. } __packed;
  27. #define TKIP_KEYLEN 16
  28. #define MIC_KEYLEN 8
  29. struct orinoco_tkip_key {
  30. u8 tkip[TKIP_KEYLEN];
  31. u8 tx_mic[MIC_KEYLEN];
  32. u8 rx_mic[MIC_KEYLEN];
  33. };
  34. enum orinoco_alg {
  35. ORINOCO_ALG_NONE,
  36. ORINOCO_ALG_WEP,
  37. ORINOCO_ALG_TKIP
  38. };
  39. enum fwtype {
  40. FIRMWARE_TYPE_AGERE,
  41. FIRMWARE_TYPE_INTERSIL,
  42. FIRMWARE_TYPE_SYMBOL
  43. };
  44. struct firmware;
  45. struct orinoco_private {
  46. void *card; /* Pointer to card dependent structure */
  47. struct device *dev;
  48. int (*hard_reset)(struct orinoco_private *);
  49. int (*stop_fw)(struct orinoco_private *, int);
  50. struct ieee80211_supported_band band;
  51. struct ieee80211_channel channels[14];
  52. u32 cipher_suites[3];
  53. /* Synchronisation stuff */
  54. spinlock_t lock;
  55. int hw_unavailable;
  56. struct work_struct reset_work;
  57. /* Interrupt tasklets */
  58. struct tasklet_struct rx_tasklet;
  59. struct list_head rx_list;
  60. /* driver state */
  61. int open;
  62. u16 last_linkstatus;
  63. struct work_struct join_work;
  64. struct work_struct wevent_work;
  65. /* Net device stuff */
  66. struct net_device *ndev;
  67. struct iw_statistics wstats;
  68. /* Hardware control variables */
  69. struct hermes hw;
  70. u16 txfid;
  71. /* Capabilities of the hardware/firmware */
  72. enum fwtype firmware_type;
  73. int ibss_port;
  74. int nicbuf_size;
  75. u16 channel_mask;
  76. /* Boolean capabilities */
  77. unsigned int has_ibss:1;
  78. unsigned int has_port3:1;
  79. unsigned int has_wep:1;
  80. unsigned int has_big_wep:1;
  81. unsigned int has_mwo:1;
  82. unsigned int has_pm:1;
  83. unsigned int has_preamble:1;
  84. unsigned int has_sensitivity:1;
  85. unsigned int has_hostscan:1;
  86. unsigned int has_alt_txcntl:1;
  87. unsigned int has_ext_scan:1;
  88. unsigned int has_wpa:1;
  89. unsigned int do_fw_download:1;
  90. unsigned int broken_disableport:1;
  91. unsigned int broken_monitor:1;
  92. unsigned int prefer_port3:1;
  93. /* Configuration paramaters */
  94. enum nl80211_iftype iw_mode;
  95. enum orinoco_alg encode_alg;
  96. u16 wep_restrict, tx_key;
  97. struct key_params keys[ORINOCO_MAX_KEYS];
  98. int bitratemode;
  99. char nick[IW_ESSID_MAX_SIZE + 1];
  100. char desired_essid[IW_ESSID_MAX_SIZE + 1];
  101. char desired_bssid[ETH_ALEN];
  102. int bssid_fixed;
  103. u16 frag_thresh, mwo_robust;
  104. u16 channel;
  105. u16 ap_density, rts_thresh;
  106. u16 pm_on, pm_mcast, pm_period, pm_timeout;
  107. u16 preamble;
  108. u16 short_retry_limit, long_retry_limit;
  109. u16 retry_lifetime;
  110. #ifdef WIRELESS_SPY
  111. struct iw_spy_data spy_data; /* iwspy support */
  112. struct iw_public_data wireless_data;
  113. #endif
  114. /* Configuration dependent variables */
  115. int port_type, createibss;
  116. int promiscuous, mc_count;
  117. /* Scanning support */
  118. struct cfg80211_scan_request *scan_request;
  119. struct work_struct process_scan;
  120. struct list_head scan_list;
  121. spinlock_t scan_lock; /* protects the scan list */
  122. /* WPA support */
  123. u8 *wpa_ie;
  124. int wpa_ie_len;
  125. struct crypto_shash *rx_tfm_mic;
  126. struct crypto_shash *tx_tfm_mic;
  127. unsigned int wpa_enabled:1;
  128. unsigned int tkip_cm_active:1;
  129. unsigned int key_mgmt:3;
  130. #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
  131. /* Cached in memory firmware to use during ->resume. */
  132. const struct firmware *cached_pri_fw;
  133. const struct firmware *cached_fw;
  134. #endif
  135. struct notifier_block pm_notifier;
  136. };
  137. #ifdef ORINOCO_DEBUG
  138. extern int orinoco_debug;
  139. #define DEBUG(n, args...) do { \
  140. if (orinoco_debug > (n)) \
  141. printk(KERN_DEBUG args); \
  142. } while (0)
  143. #else
  144. #define DEBUG(n, args...) do { } while (0)
  145. #endif /* ORINOCO_DEBUG */
  146. /********************************************************************/
  147. /* Exported prototypes */
  148. /********************************************************************/
  149. struct orinoco_private *alloc_orinocodev(int sizeof_card, struct device *device,
  150. int (*hard_reset)(struct orinoco_private *),
  151. int (*stop_fw)(struct orinoco_private *, int));
  152. void free_orinocodev(struct orinoco_private *priv);
  153. int orinoco_init(struct orinoco_private *priv);
  154. int orinoco_if_add(struct orinoco_private *priv, unsigned long base_addr,
  155. unsigned int irq, const struct net_device_ops *ops);
  156. void orinoco_if_del(struct orinoco_private *priv);
  157. int orinoco_up(struct orinoco_private *priv);
  158. void orinoco_down(struct orinoco_private *priv);
  159. irqreturn_t orinoco_interrupt(int irq, void *dev_id);
  160. void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
  161. void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
  162. int orinoco_process_xmit_skb(struct sk_buff *skb,
  163. struct net_device *dev,
  164. struct orinoco_private *priv,
  165. int *tx_control,
  166. u8 *mic);
  167. /* Common ndo functions exported for reuse by orinoco_usb */
  168. int orinoco_open(struct net_device *dev);
  169. int orinoco_stop(struct net_device *dev);
  170. void orinoco_set_multicast_list(struct net_device *dev);
  171. int orinoco_change_mtu(struct net_device *dev, int new_mtu);
  172. void orinoco_tx_timeout(struct net_device *dev);
  173. /********************************************************************/
  174. /* Locking and synchronization functions */
  175. /********************************************************************/
  176. static inline int orinoco_lock(struct orinoco_private *priv,
  177. unsigned long *flags)
  178. {
  179. priv->hw.ops->lock_irqsave(&priv->lock, flags);
  180. if (priv->hw_unavailable) {
  181. DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
  182. priv->ndev);
  183. priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
  184. return -EBUSY;
  185. }
  186. return 0;
  187. }
  188. static inline void orinoco_unlock(struct orinoco_private *priv,
  189. unsigned long *flags)
  190. {
  191. priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
  192. }
  193. static inline void orinoco_lock_irq(struct orinoco_private *priv)
  194. {
  195. priv->hw.ops->lock_irq(&priv->lock);
  196. }
  197. static inline void orinoco_unlock_irq(struct orinoco_private *priv)
  198. {
  199. priv->hw.ops->unlock_irq(&priv->lock);
  200. }
  201. /*** Navigate from net_device to orinoco_private ***/
  202. static inline struct orinoco_private *ndev_priv(struct net_device *dev)
  203. {
  204. struct wireless_dev *wdev = netdev_priv(dev);
  205. return wdev_priv(wdev);
  206. }
  207. #endif /* _ORINOCO_H */