Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* orinoco.h |
| 2 | * |
| 3 | * Common definitions to all pieces of the various orinoco |
| 4 | * drivers |
| 5 | */ |
| 6 | |
| 7 | #ifndef _ORINOCO_H |
| 8 | #define _ORINOCO_H |
| 9 | |
Pavel Roskin | f298a2e | 2006-04-07 04:11:02 -0400 | [diff] [blame] | 10 | #define DRIVER_VERSION "0.15" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
David Kilroy | 31afcef | 2008-08-21 23:28:04 +0100 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/netdevice.h> |
| 14 | #include <linux/wireless.h> |
Pavel Roskin | 343c686 | 2005-09-09 18:43:02 -0400 | [diff] [blame] | 15 | #include <net/iw_handler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | #include "hermes.h" |
| 18 | |
| 19 | /* To enable debug messages */ |
| 20 | //#define ORINOCO_DEBUG 3 |
| 21 | |
| 22 | #define WIRELESS_SPY // enable iwspy support |
| 23 | |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 24 | #define MAX_SCAN_LEN 4096 |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #define ORINOCO_MAX_KEY_SIZE 14 |
| 27 | #define ORINOCO_MAX_KEYS 4 |
| 28 | |
| 29 | struct orinoco_key { |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 30 | __le16 len; /* always stored as little-endian */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | char data[ORINOCO_MAX_KEY_SIZE]; |
| 32 | } __attribute__ ((packed)); |
| 33 | |
David Kilroy | d03032a | 2008-08-21 23:28:02 +0100 | [diff] [blame] | 34 | #define TKIP_KEYLEN 16 |
| 35 | #define MIC_KEYLEN 8 |
| 36 | |
| 37 | struct orinoco_tkip_key { |
| 38 | u8 tkip[TKIP_KEYLEN]; |
| 39 | u8 tx_mic[MIC_KEYLEN]; |
| 40 | u8 rx_mic[MIC_KEYLEN]; |
| 41 | }; |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | typedef enum { |
| 44 | FIRMWARE_TYPE_AGERE, |
| 45 | FIRMWARE_TYPE_INTERSIL, |
| 46 | FIRMWARE_TYPE_SYMBOL |
| 47 | } fwtype_t; |
| 48 | |
David Kilroy | 3056c40 | 2008-08-21 23:27:57 +0100 | [diff] [blame] | 49 | struct bss_element { |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 50 | union hermes_scan_info bss; |
| 51 | unsigned long last_scanned; |
| 52 | struct list_head list; |
David Kilroy | 3056c40 | 2008-08-21 23:27:57 +0100 | [diff] [blame] | 53 | }; |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 54 | |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame] | 55 | struct xbss_element { |
| 56 | struct agere_ext_scan_info bss; |
| 57 | unsigned long last_scanned; |
| 58 | struct list_head list; |
| 59 | }; |
| 60 | |
David Kilroy | 31afcef | 2008-08-21 23:28:04 +0100 | [diff] [blame] | 61 | struct hermes_rx_descriptor; |
| 62 | |
| 63 | struct orinoco_rx_data { |
| 64 | struct hermes_rx_descriptor *desc; |
| 65 | struct sk_buff *skb; |
| 66 | struct list_head list; |
| 67 | }; |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | struct orinoco_private { |
| 70 | void *card; /* Pointer to card dependent structure */ |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 71 | struct device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | int (*hard_reset)(struct orinoco_private *); |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 73 | int (*stop_fw)(struct orinoco_private *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | /* Synchronisation stuff */ |
| 76 | spinlock_t lock; |
| 77 | int hw_unavailable; |
| 78 | struct work_struct reset_work; |
| 79 | |
David Kilroy | 31afcef | 2008-08-21 23:28:04 +0100 | [diff] [blame] | 80 | /* Interrupt tasklets */ |
| 81 | struct tasklet_struct rx_tasklet; |
| 82 | struct list_head rx_list; |
| 83 | struct orinoco_rx_data *rx_data; |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* driver state */ |
| 86 | int open; |
| 87 | u16 last_linkstatus; |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 88 | struct work_struct join_work; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 89 | struct work_struct wevent_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | /* Net device stuff */ |
| 92 | struct net_device *ndev; |
| 93 | struct net_device_stats stats; |
| 94 | struct iw_statistics wstats; |
| 95 | |
| 96 | /* Hardware control variables */ |
| 97 | hermes_t hw; |
| 98 | u16 txfid; |
| 99 | |
| 100 | /* Capabilities of the hardware/firmware */ |
| 101 | fwtype_t firmware_type; |
| 102 | char fw_name[32]; |
| 103 | int ibss_port; |
| 104 | int nicbuf_size; |
| 105 | u16 channel_mask; |
| 106 | |
| 107 | /* Boolean capabilities */ |
| 108 | unsigned int has_ibss:1; |
| 109 | unsigned int has_port3:1; |
| 110 | unsigned int has_wep:1; |
| 111 | unsigned int has_big_wep:1; |
| 112 | unsigned int has_mwo:1; |
| 113 | unsigned int has_pm:1; |
| 114 | unsigned int has_preamble:1; |
| 115 | unsigned int has_sensitivity:1; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 116 | unsigned int has_hostscan:1; |
David Kilroy | 6eecad7 | 2008-08-21 23:27:56 +0100 | [diff] [blame] | 117 | unsigned int has_alt_txcntl:1; |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame] | 118 | unsigned int has_ext_scan:1; |
David Kilroy | d03032a | 2008-08-21 23:28:02 +0100 | [diff] [blame] | 119 | unsigned int has_wpa:1; |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 120 | unsigned int do_fw_download:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | unsigned int broken_disableport:1; |
Christoph Hellwig | 98c4cae | 2005-06-19 01:28:06 +0200 | [diff] [blame] | 122 | unsigned int broken_monitor:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
| 124 | /* Configuration paramaters */ |
| 125 | u32 iw_mode; |
| 126 | int prefer_port3; |
David Kilroy | 4ae6ee2 | 2008-08-21 23:27:59 +0100 | [diff] [blame] | 127 | u16 encode_alg, wep_restrict, tx_key; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | struct orinoco_key keys[ORINOCO_MAX_KEYS]; |
| 129 | int bitratemode; |
| 130 | char nick[IW_ESSID_MAX_SIZE+1]; |
| 131 | char desired_essid[IW_ESSID_MAX_SIZE+1]; |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 132 | char desired_bssid[ETH_ALEN]; |
| 133 | int bssid_fixed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | u16 frag_thresh, mwo_robust; |
| 135 | u16 channel; |
| 136 | u16 ap_density, rts_thresh; |
| 137 | u16 pm_on, pm_mcast, pm_period, pm_timeout; |
| 138 | u16 preamble; |
| 139 | #ifdef WIRELESS_SPY |
Pavel Roskin | 343c686 | 2005-09-09 18:43:02 -0400 | [diff] [blame] | 140 | struct iw_spy_data spy_data; /* iwspy support */ |
| 141 | struct iw_public_data wireless_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | #endif |
| 143 | |
| 144 | /* Configuration dependent variables */ |
| 145 | int port_type, createibss; |
| 146 | int promiscuous, mc_count; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 147 | |
| 148 | /* Scanning support */ |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 149 | struct list_head bss_list; |
| 150 | struct list_head bss_free_list; |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame] | 151 | void *bss_xbss_data; |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 152 | |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 153 | int scan_inprogress; /* Scan pending... */ |
| 154 | u32 scan_mode; /* Type of scan done */ |
David Kilroy | d03032a | 2008-08-21 23:28:02 +0100 | [diff] [blame] | 155 | |
| 156 | /* WPA support */ |
| 157 | u8 *wpa_ie; |
| 158 | int wpa_ie_len; |
| 159 | |
| 160 | struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS]; |
David Kilroy | 23edcc4 | 2008-08-21 23:28:05 +0100 | [diff] [blame] | 161 | struct crypto_hash *rx_tfm_mic; |
| 162 | struct crypto_hash *tx_tfm_mic; |
David Kilroy | d03032a | 2008-08-21 23:28:02 +0100 | [diff] [blame] | 163 | |
| 164 | unsigned int wpa_enabled:1; |
| 165 | unsigned int tkip_cm_active:1; |
| 166 | unsigned int key_mgmt:3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | #ifdef ORINOCO_DEBUG |
| 170 | extern int orinoco_debug; |
| 171 | #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0) |
| 172 | #else |
| 173 | #define DEBUG(n, args...) do { } while (0) |
| 174 | #endif /* ORINOCO_DEBUG */ |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /********************************************************************/ |
| 177 | /* Exported prototypes */ |
| 178 | /********************************************************************/ |
| 179 | |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 180 | extern struct net_device *alloc_orinocodev( |
| 181 | int sizeof_card, struct device *device, |
| 182 | int (*hard_reset)(struct orinoco_private *), |
| 183 | int (*stop_fw)(struct orinoco_private *, int)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | extern void free_orinocodev(struct net_device *dev); |
| 185 | extern int __orinoco_up(struct net_device *dev); |
| 186 | extern int __orinoco_down(struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | extern int orinoco_reinit_firmware(struct net_device *dev); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 188 | extern irqreturn_t orinoco_interrupt(int irq, void * dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | /********************************************************************/ |
| 191 | /* Locking and synchronization functions */ |
| 192 | /********************************************************************/ |
| 193 | |
Pavel Roskin | 821fe68 | 2006-08-15 20:45:00 -0400 | [diff] [blame] | 194 | static inline int orinoco_lock(struct orinoco_private *priv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | unsigned long *flags) |
| 196 | { |
| 197 | spin_lock_irqsave(&priv->lock, *flags); |
| 198 | if (priv->hw_unavailable) { |
| 199 | DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n", |
| 200 | priv->ndev); |
| 201 | spin_unlock_irqrestore(&priv->lock, *flags); |
| 202 | return -EBUSY; |
| 203 | } |
| 204 | return 0; |
| 205 | } |
| 206 | |
Pavel Roskin | 821fe68 | 2006-08-15 20:45:00 -0400 | [diff] [blame] | 207 | static inline void orinoco_unlock(struct orinoco_private *priv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | unsigned long *flags) |
| 209 | { |
| 210 | spin_unlock_irqrestore(&priv->lock, *flags); |
| 211 | } |
| 212 | |
| 213 | #endif /* _ORINOCO_H */ |