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