blob: 608cc5e1bd9a5ac854cee2c0a59dbb28ede462b7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* orinoco.h
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +03002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Common definitions to all pieces of the various orinoco
4 * drivers
5 */
6
7#ifndef _ORINOCO_H
8#define _ORINOCO_H
9
Pavel Roskinf298a2e2006-04-07 04:11:02 -040010#define DRIVER_VERSION "0.15"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
David Kilroy31afcef2008-08-21 23:28:04 +010012#include <linux/interrupt.h>
David Kilroy39d1ffe2008-11-22 10:37:28 +000013#include <linux/suspend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/netdevice.h>
15#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040016#include <net/iw_handler.h>
David Kilroyea60a6a2009-06-18 23:21:26 +010017#include <net/cfg80211.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#include "hermes.h"
20
21/* To enable debug messages */
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +030022/*#define ORINOCO_DEBUG 3*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +030024#define WIRELESS_SPY /* enable iwspy support */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Christoph Hellwig16739b02005-06-19 01:27:51 +020026#define MAX_SCAN_LEN 4096
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#define ORINOCO_MAX_KEY_SIZE 14
29#define ORINOCO_MAX_KEYS 4
30
31struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040032 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 char data[ORINOCO_MAX_KEY_SIZE];
34} __attribute__ ((packed));
35
David Kilroyd03032a2008-08-21 23:28:02 +010036#define TKIP_KEYLEN 16
37#define MIC_KEYLEN 8
38
39struct orinoco_tkip_key {
40 u8 tkip[TKIP_KEYLEN];
41 u8 tx_mic[MIC_KEYLEN];
42 u8 rx_mic[MIC_KEYLEN];
43};
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045typedef enum {
46 FIRMWARE_TYPE_AGERE,
47 FIRMWARE_TYPE_INTERSIL,
48 FIRMWARE_TYPE_SYMBOL
49} fwtype_t;
50
David Kilroy3056c402008-08-21 23:27:57 +010051struct bss_element {
Dan Williams1e3428e2007-10-10 23:56:25 -040052 union hermes_scan_info bss;
53 unsigned long last_scanned;
54 struct list_head list;
David Kilroy3056c402008-08-21 23:27:57 +010055};
Dan Williams1e3428e2007-10-10 23:56:25 -040056
David Kilroy01632fa2008-08-21 23:27:58 +010057struct xbss_element {
58 struct agere_ext_scan_info bss;
59 unsigned long last_scanned;
60 struct list_head list;
61};
62
Andrey Borzenkov4fb30782008-10-19 12:06:11 +040063struct firmware;
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065struct orinoco_private {
66 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010067 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010069 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
David Kilroyea60a6a2009-06-18 23:21:26 +010071 struct ieee80211_supported_band band;
72 struct ieee80211_channel channels[14];
73 u32 cipher_suites[3];
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 /* Synchronisation stuff */
76 spinlock_t lock;
77 int hw_unavailable;
78 struct work_struct reset_work;
79
David Kilroy31afcef2008-08-21 23:28:04 +010080 /* Interrupt tasklets */
81 struct tasklet_struct rx_tasklet;
82 struct list_head rx_list;
David Kilroy31afcef2008-08-21 23:28:04 +010083
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 /* driver state */
85 int open;
86 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020087 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020088 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
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 Hellwig95dd91f2005-06-19 01:27:56 +0200115 unsigned int has_hostscan:1;
David Kilroy6eecad72008-08-21 23:27:56 +0100116 unsigned int has_alt_txcntl:1;
David Kilroy01632fa2008-08-21 23:27:58 +0100117 unsigned int has_ext_scan:1;
David Kilroyd03032a2008-08-21 23:28:02 +0100118 unsigned int has_wpa:1;
David Kilroy3994d502008-08-21 23:27:54 +0100119 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +0200121 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 /* Configuration paramaters */
124 u32 iw_mode;
125 int prefer_port3;
David Kilroy4ae6ee22008-08-21 23:27:59 +0100126 u16 encode_alg, wep_restrict, tx_key;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 struct orinoco_key keys[ORINOCO_MAX_KEYS];
128 int bitratemode;
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +0300129 char nick[IW_ESSID_MAX_SIZE+1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200131 char desired_bssid[ETH_ALEN];
132 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 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 Borzenkovd14c7c12009-01-25 23:08:43 +0300139 struct iw_spy_data spy_data; /* iwspy support */
Pavel Roskin343c6862005-09-09 18:43:02 -0400140 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#endif
142
143 /* Configuration dependent variables */
144 int port_type, createibss;
145 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200146
147 /* Scanning support */
Dan Williams1e3428e2007-10-10 23:56:25 -0400148 struct list_head bss_list;
149 struct list_head bss_free_list;
David Kilroy01632fa2008-08-21 23:27:58 +0100150 void *bss_xbss_data;
Dan Williams1e3428e2007-10-10 23:56:25 -0400151
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200152 int scan_inprogress; /* Scan pending... */
153 u32 scan_mode; /* Type of scan done */
David Kilroyd03032a2008-08-21 23:28:02 +0100154
155 /* WPA support */
156 u8 *wpa_ie;
157 int wpa_ie_len;
158
159 struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
David Kilroy23edcc42008-08-21 23:28:05 +0100160 struct crypto_hash *rx_tfm_mic;
161 struct crypto_hash *tx_tfm_mic;
David Kilroyd03032a2008-08-21 23:28:02 +0100162
163 unsigned int wpa_enabled:1;
164 unsigned int tkip_cm_active:1;
165 unsigned int key_mgmt:3;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400166
Andrey Borzenkov2bfc5cb2009-02-28 23:09:09 +0300167#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
David Kilroy2cea7b22008-11-22 10:37:26 +0000168 /* Cached in memory firmware to use during ->resume. */
169 const struct firmware *cached_pri_fw;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400170 const struct firmware *cached_fw;
Andrey Borzenkov2bfc5cb2009-02-28 23:09:09 +0300171#endif
David Kilroy39d1ffe2008-11-22 10:37:28 +0000172
173 struct notifier_block pm_notifier;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174};
175
176#ifdef ORINOCO_DEBUG
177extern int orinoco_debug;
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +0300178#define DEBUG(n, args...) do { \
179 if (orinoco_debug > (n)) \
180 printk(KERN_DEBUG args); \
181} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182#else
183#define DEBUG(n, args...) do { } while (0)
184#endif /* ORINOCO_DEBUG */
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186/********************************************************************/
187/* Exported prototypes */
188/********************************************************************/
189
David Kilroya2608362009-06-18 23:21:23 +0100190extern struct orinoco_private *alloc_orinocodev(
David Kilroy3994d502008-08-21 23:27:54 +0100191 int sizeof_card, struct device *device,
192 int (*hard_reset)(struct orinoco_private *),
193 int (*stop_fw)(struct orinoco_private *, int));
David Kilroya2608362009-06-18 23:21:23 +0100194extern void free_orinocodev(struct orinoco_private *priv);
David Kilroy8e638262009-06-18 23:21:24 +0100195extern int orinoco_init(struct orinoco_private *priv);
David Kilroya2608362009-06-18 23:21:23 +0100196extern int __orinoco_up(struct orinoco_private *priv);
197extern int __orinoco_down(struct orinoco_private *priv);
198extern int orinoco_reinit_firmware(struct orinoco_private *priv);
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +0300199extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201/********************************************************************/
202/* Locking and synchronization functions */
203/********************************************************************/
204
Pavel Roskin821fe682006-08-15 20:45:00 -0400205static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 unsigned long *flags)
207{
208 spin_lock_irqsave(&priv->lock, *flags);
209 if (priv->hw_unavailable) {
210 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
211 priv->ndev);
212 spin_unlock_irqrestore(&priv->lock, *flags);
213 return -EBUSY;
214 }
215 return 0;
216}
217
Pavel Roskin821fe682006-08-15 20:45:00 -0400218static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 unsigned long *flags)
220{
221 spin_unlock_irqrestore(&priv->lock, *flags);
222}
223
David Kilroyea60a6a2009-06-18 23:21:26 +0100224/*** Navigate from net_device to orinoco_private ***/
225static inline struct orinoco_private *ndev_priv(struct net_device *dev)
226{
227 struct wireless_dev *wdev = netdev_priv(dev);
228 return wdev_priv(wdev);
229}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230#endif /* _ORINOCO_H */