blob: 00750c8ba7db4019a5ea36a6c46632cbd1aad1db [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#include "hermes.h"
19
20/* To enable debug messages */
21//#define ORINOCO_DEBUG 3
22
23#define WIRELESS_SPY // enable iwspy support
24
Christoph Hellwig16739b02005-06-19 01:27:51 +020025#define MAX_SCAN_LEN 4096
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#define ORINOCO_MAX_KEY_SIZE 14
28#define ORINOCO_MAX_KEYS 4
29
30struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040031 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 char data[ORINOCO_MAX_KEY_SIZE];
33} __attribute__ ((packed));
34
David Kilroyd03032a2008-08-21 23:28:02 +010035#define TKIP_KEYLEN 16
36#define MIC_KEYLEN 8
37
38struct orinoco_tkip_key {
39 u8 tkip[TKIP_KEYLEN];
40 u8 tx_mic[MIC_KEYLEN];
41 u8 rx_mic[MIC_KEYLEN];
42};
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044typedef enum {
45 FIRMWARE_TYPE_AGERE,
46 FIRMWARE_TYPE_INTERSIL,
47 FIRMWARE_TYPE_SYMBOL
48} fwtype_t;
49
David Kilroy3056c402008-08-21 23:27:57 +010050struct bss_element {
Dan Williams1e3428e2007-10-10 23:56:25 -040051 union hermes_scan_info bss;
52 unsigned long last_scanned;
53 struct list_head list;
David Kilroy3056c402008-08-21 23:27:57 +010054};
Dan Williams1e3428e2007-10-10 23:56:25 -040055
David Kilroy01632fa2008-08-21 23:27:58 +010056struct xbss_element {
57 struct agere_ext_scan_info bss;
58 unsigned long last_scanned;
59 struct list_head list;
60};
61
David Kilroy31afcef2008-08-21 23:28:04 +010062struct hermes_rx_descriptor;
63
64struct orinoco_rx_data {
65 struct hermes_rx_descriptor *desc;
66 struct sk_buff *skb;
67 struct list_head list;
68};
69
Andrey Borzenkov4fb30782008-10-19 12:06:11 +040070struct firmware;
71
Linus Torvalds1da177e2005-04-16 15:20:36 -070072struct orinoco_private {
73 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010074 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010076 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 /* Synchronisation stuff */
79 spinlock_t lock;
80 int hw_unavailable;
81 struct work_struct reset_work;
82
David Kilroy31afcef2008-08-21 23:28:04 +010083 /* Interrupt tasklets */
84 struct tasklet_struct rx_tasklet;
85 struct list_head rx_list;
86 struct orinoco_rx_data *rx_data;
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 /* driver state */
89 int open;
90 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020091 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020092 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94 /* Net device stuff */
95 struct net_device *ndev;
96 struct net_device_stats stats;
97 struct iw_statistics wstats;
98
99 /* Hardware control variables */
100 hermes_t hw;
101 u16 txfid;
102
103 /* Capabilities of the hardware/firmware */
104 fwtype_t firmware_type;
105 char fw_name[32];
106 int ibss_port;
107 int nicbuf_size;
108 u16 channel_mask;
109
110 /* Boolean capabilities */
111 unsigned int has_ibss:1;
112 unsigned int has_port3:1;
113 unsigned int has_wep:1;
114 unsigned int has_big_wep:1;
115 unsigned int has_mwo:1;
116 unsigned int has_pm:1;
117 unsigned int has_preamble:1;
118 unsigned int has_sensitivity:1;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200119 unsigned int has_hostscan:1;
David Kilroy6eecad72008-08-21 23:27:56 +0100120 unsigned int has_alt_txcntl:1;
David Kilroy01632fa2008-08-21 23:27:58 +0100121 unsigned int has_ext_scan:1;
David Kilroyd03032a2008-08-21 23:28:02 +0100122 unsigned int has_wpa:1;
David Kilroy3994d502008-08-21 23:27:54 +0100123 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +0200125 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127 /* Configuration paramaters */
128 u32 iw_mode;
129 int prefer_port3;
David Kilroy4ae6ee22008-08-21 23:27:59 +0100130 u16 encode_alg, wep_restrict, tx_key;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 struct orinoco_key keys[ORINOCO_MAX_KEYS];
132 int bitratemode;
133 char nick[IW_ESSID_MAX_SIZE+1];
134 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200135 char desired_bssid[ETH_ALEN];
136 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 u16 frag_thresh, mwo_robust;
138 u16 channel;
139 u16 ap_density, rts_thresh;
140 u16 pm_on, pm_mcast, pm_period, pm_timeout;
141 u16 preamble;
142#ifdef WIRELESS_SPY
Pavel Roskin343c6862005-09-09 18:43:02 -0400143 struct iw_spy_data spy_data; /* iwspy support */
144 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#endif
146
147 /* Configuration dependent variables */
148 int port_type, createibss;
149 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200150
151 /* Scanning support */
Dan Williams1e3428e2007-10-10 23:56:25 -0400152 struct list_head bss_list;
153 struct list_head bss_free_list;
David Kilroy01632fa2008-08-21 23:27:58 +0100154 void *bss_xbss_data;
Dan Williams1e3428e2007-10-10 23:56:25 -0400155
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200156 int scan_inprogress; /* Scan pending... */
157 u32 scan_mode; /* Type of scan done */
David Kilroyd03032a2008-08-21 23:28:02 +0100158
159 /* WPA support */
160 u8 *wpa_ie;
161 int wpa_ie_len;
162
163 struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
David Kilroy23edcc42008-08-21 23:28:05 +0100164 struct crypto_hash *rx_tfm_mic;
165 struct crypto_hash *tx_tfm_mic;
David Kilroyd03032a2008-08-21 23:28:02 +0100166
167 unsigned int wpa_enabled:1;
168 unsigned int tkip_cm_active:1;
169 unsigned int key_mgmt:3;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400170
David Kilroy2cea7b22008-11-22 10:37:26 +0000171 /* Cached in memory firmware to use during ->resume. */
172 const struct firmware *cached_pri_fw;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400173 const struct firmware *cached_fw;
David Kilroy39d1ffe2008-11-22 10:37:28 +0000174
175 struct notifier_block pm_notifier;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176};
177
178#ifdef ORINOCO_DEBUG
179extern int orinoco_debug;
180#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
181#else
182#define DEBUG(n, args...) do { } while (0)
183#endif /* ORINOCO_DEBUG */
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185/********************************************************************/
186/* Exported prototypes */
187/********************************************************************/
188
David Kilroy3994d502008-08-21 23:27:54 +0100189extern struct net_device *alloc_orinocodev(
190 int sizeof_card, struct device *device,
191 int (*hard_reset)(struct orinoco_private *),
192 int (*stop_fw)(struct orinoco_private *, int));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193extern void free_orinocodev(struct net_device *dev);
194extern int __orinoco_up(struct net_device *dev);
195extern int __orinoco_down(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196extern int orinoco_reinit_firmware(struct net_device *dev);
David Howells7d12e782006-10-05 14:55:46 +0100197extern irqreturn_t orinoco_interrupt(int irq, void * dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199/********************************************************************/
200/* Locking and synchronization functions */
201/********************************************************************/
202
Pavel Roskin821fe682006-08-15 20:45:00 -0400203static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 unsigned long *flags)
205{
206 spin_lock_irqsave(&priv->lock, *flags);
207 if (priv->hw_unavailable) {
208 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
209 priv->ndev);
210 spin_unlock_irqrestore(&priv->lock, *flags);
211 return -EBUSY;
212 }
213 return 0;
214}
215
Pavel Roskin821fe682006-08-15 20:45:00 -0400216static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 unsigned long *flags)
218{
219 spin_unlock_irqrestore(&priv->lock, *flags);
220}
221
222#endif /* _ORINOCO_H */