blob: 8c2953834923e31c323038aa98ae06124444de2a [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/netdevice.h>
14#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040015#include <net/iw_handler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
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 Hellwig16739b02005-06-19 01:27:51 +020024#define MAX_SCAN_LEN 4096
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define ORINOCO_MAX_KEY_SIZE 14
27#define ORINOCO_MAX_KEYS 4
28
29struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040030 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 char data[ORINOCO_MAX_KEY_SIZE];
32} __attribute__ ((packed));
33
David Kilroyd03032a2008-08-21 23:28:02 +010034#define TKIP_KEYLEN 16
35#define MIC_KEYLEN 8
36
37struct orinoco_tkip_key {
38 u8 tkip[TKIP_KEYLEN];
39 u8 tx_mic[MIC_KEYLEN];
40 u8 rx_mic[MIC_KEYLEN];
41};
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043typedef enum {
44 FIRMWARE_TYPE_AGERE,
45 FIRMWARE_TYPE_INTERSIL,
46 FIRMWARE_TYPE_SYMBOL
47} fwtype_t;
48
David Kilroy3056c402008-08-21 23:27:57 +010049struct bss_element {
Dan Williams1e3428e2007-10-10 23:56:25 -040050 union hermes_scan_info bss;
51 unsigned long last_scanned;
52 struct list_head list;
David Kilroy3056c402008-08-21 23:27:57 +010053};
Dan Williams1e3428e2007-10-10 23:56:25 -040054
David Kilroy01632fa2008-08-21 23:27:58 +010055struct xbss_element {
56 struct agere_ext_scan_info bss;
57 unsigned long last_scanned;
58 struct list_head list;
59};
60
David Kilroy31afcef2008-08-21 23:28:04 +010061struct hermes_rx_descriptor;
62
63struct orinoco_rx_data {
64 struct hermes_rx_descriptor *desc;
65 struct sk_buff *skb;
66 struct list_head list;
67};
68
Andrey Borzenkov4fb30782008-10-19 12:06:11 +040069struct firmware;
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071struct orinoco_private {
72 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010073 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010075 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77 /* Synchronisation stuff */
78 spinlock_t lock;
79 int hw_unavailable;
80 struct work_struct reset_work;
81
David Kilroy31afcef2008-08-21 23:28:04 +010082 /* Interrupt tasklets */
83 struct tasklet_struct rx_tasklet;
84 struct list_head rx_list;
85 struct orinoco_rx_data *rx_data;
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 /* driver state */
88 int open;
89 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020090 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020091 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 /* Net device stuff */
94 struct net_device *ndev;
95 struct net_device_stats stats;
96 struct iw_statistics wstats;
97
98 /* Hardware control variables */
99 hermes_t hw;
100 u16 txfid;
101
102 /* Capabilities of the hardware/firmware */
103 fwtype_t firmware_type;
104 char fw_name[32];
105 int ibss_port;
106 int nicbuf_size;
107 u16 channel_mask;
108
109 /* Boolean capabilities */
110 unsigned int has_ibss:1;
111 unsigned int has_port3:1;
112 unsigned int has_wep:1;
113 unsigned int has_big_wep:1;
114 unsigned int has_mwo:1;
115 unsigned int has_pm:1;
116 unsigned int has_preamble:1;
117 unsigned int has_sensitivity:1;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200118 unsigned int has_hostscan:1;
David Kilroy6eecad72008-08-21 23:27:56 +0100119 unsigned int has_alt_txcntl:1;
David Kilroy01632fa2008-08-21 23:27:58 +0100120 unsigned int has_ext_scan:1;
David Kilroyd03032a2008-08-21 23:28:02 +0100121 unsigned int has_wpa:1;
David Kilroy3994d502008-08-21 23:27:54 +0100122 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +0200124 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126 /* Configuration paramaters */
127 u32 iw_mode;
128 int prefer_port3;
David Kilroy4ae6ee22008-08-21 23:27:59 +0100129 u16 encode_alg, wep_restrict, tx_key;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 struct orinoco_key keys[ORINOCO_MAX_KEYS];
131 int bitratemode;
132 char nick[IW_ESSID_MAX_SIZE+1];
133 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200134 char desired_bssid[ETH_ALEN];
135 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 u16 frag_thresh, mwo_robust;
137 u16 channel;
138 u16 ap_density, rts_thresh;
139 u16 pm_on, pm_mcast, pm_period, pm_timeout;
140 u16 preamble;
141#ifdef WIRELESS_SPY
Pavel Roskin343c6862005-09-09 18:43:02 -0400142 struct iw_spy_data spy_data; /* iwspy support */
143 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#endif
145
146 /* Configuration dependent variables */
147 int port_type, createibss;
148 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200149
150 /* Scanning support */
Dan Williams1e3428e2007-10-10 23:56:25 -0400151 struct list_head bss_list;
152 struct list_head bss_free_list;
David Kilroy01632fa2008-08-21 23:27:58 +0100153 void *bss_xbss_data;
Dan Williams1e3428e2007-10-10 23:56:25 -0400154
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200155 int scan_inprogress; /* Scan pending... */
156 u32 scan_mode; /* Type of scan done */
David Kilroyd03032a2008-08-21 23:28:02 +0100157
158 /* WPA support */
159 u8 *wpa_ie;
160 int wpa_ie_len;
161
162 struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
David Kilroy23edcc42008-08-21 23:28:05 +0100163 struct crypto_hash *rx_tfm_mic;
164 struct crypto_hash *tx_tfm_mic;
David Kilroyd03032a2008-08-21 23:28:02 +0100165
166 unsigned int wpa_enabled:1;
167 unsigned int tkip_cm_active:1;
168 unsigned int key_mgmt:3;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400169
170 /* Cached in memory firmware to use in ->resume */
171 const struct firmware *cached_fw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172};
173
174#ifdef ORINOCO_DEBUG
175extern int orinoco_debug;
176#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
177#else
178#define DEBUG(n, args...) do { } while (0)
179#endif /* ORINOCO_DEBUG */
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181/********************************************************************/
182/* Exported prototypes */
183/********************************************************************/
184
David Kilroy3994d502008-08-21 23:27:54 +0100185extern struct net_device *alloc_orinocodev(
186 int sizeof_card, struct device *device,
187 int (*hard_reset)(struct orinoco_private *),
188 int (*stop_fw)(struct orinoco_private *, int));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189extern void free_orinocodev(struct net_device *dev);
190extern int __orinoco_up(struct net_device *dev);
191extern int __orinoco_down(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192extern int orinoco_reinit_firmware(struct net_device *dev);
David Howells7d12e782006-10-05 14:55:46 +0100193extern irqreturn_t orinoco_interrupt(int irq, void * dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195/********************************************************************/
196/* Locking and synchronization functions */
197/********************************************************************/
198
Pavel Roskin821fe682006-08-15 20:45:00 -0400199static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 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 Roskin821fe682006-08-15 20:45:00 -0400212static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 unsigned long *flags)
214{
215 spin_unlock_irqrestore(&priv->lock, *flags);
216}
217
218#endif /* _ORINOCO_H */