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