blob: bfab88f513625f335772060d41da0b9454005fb5 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/netdevice.h>
13#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040014#include <net/iw_handler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#include "hermes.h"
17
18/* To enable debug messages */
19//#define ORINOCO_DEBUG 3
20
21#define WIRELESS_SPY // enable iwspy support
22
Christoph Hellwig16739b02005-06-19 01:27:51 +020023#define MAX_SCAN_LEN 4096
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define ORINOCO_MAX_KEY_SIZE 14
26#define ORINOCO_MAX_KEYS 4
27
28struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040029 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 char data[ORINOCO_MAX_KEY_SIZE];
31} __attribute__ ((packed));
32
David Kilroyd03032a2008-08-21 23:28:02 +010033#define TKIP_KEYLEN 16
34#define MIC_KEYLEN 8
35
36struct orinoco_tkip_key {
37 u8 tkip[TKIP_KEYLEN];
38 u8 tx_mic[MIC_KEYLEN];
39 u8 rx_mic[MIC_KEYLEN];
40};
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042typedef enum {
43 FIRMWARE_TYPE_AGERE,
44 FIRMWARE_TYPE_INTERSIL,
45 FIRMWARE_TYPE_SYMBOL
46} fwtype_t;
47
David Kilroy3056c402008-08-21 23:27:57 +010048struct bss_element {
Dan Williams1e3428e2007-10-10 23:56:25 -040049 union hermes_scan_info bss;
50 unsigned long last_scanned;
51 struct list_head list;
David Kilroy3056c402008-08-21 23:27:57 +010052};
Dan Williams1e3428e2007-10-10 23:56:25 -040053
David Kilroy01632fa2008-08-21 23:27:58 +010054struct xbss_element {
55 struct agere_ext_scan_info bss;
56 unsigned long last_scanned;
57 struct list_head list;
58};
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060struct orinoco_private {
61 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010062 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010064 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66 /* Synchronisation stuff */
67 spinlock_t lock;
68 int hw_unavailable;
69 struct work_struct reset_work;
70
71 /* driver state */
72 int open;
73 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020074 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020075 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77 /* Net device stuff */
78 struct net_device *ndev;
79 struct net_device_stats stats;
80 struct iw_statistics wstats;
81
82 /* Hardware control variables */
83 hermes_t hw;
84 u16 txfid;
85
86 /* Capabilities of the hardware/firmware */
87 fwtype_t firmware_type;
88 char fw_name[32];
89 int ibss_port;
90 int nicbuf_size;
91 u16 channel_mask;
92
93 /* Boolean capabilities */
94 unsigned int has_ibss:1;
95 unsigned int has_port3:1;
96 unsigned int has_wep:1;
97 unsigned int has_big_wep:1;
98 unsigned int has_mwo:1;
99 unsigned int has_pm:1;
100 unsigned int has_preamble:1;
101 unsigned int has_sensitivity:1;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200102 unsigned int has_hostscan:1;
David Kilroy6eecad72008-08-21 23:27:56 +0100103 unsigned int has_alt_txcntl:1;
David Kilroy01632fa2008-08-21 23:27:58 +0100104 unsigned int has_ext_scan:1;
David Kilroyd03032a2008-08-21 23:28:02 +0100105 unsigned int has_wpa:1;
David Kilroy3994d502008-08-21 23:27:54 +0100106 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +0200108 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110 /* Configuration paramaters */
111 u32 iw_mode;
112 int prefer_port3;
David Kilroy4ae6ee22008-08-21 23:27:59 +0100113 u16 encode_alg, wep_restrict, tx_key;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 struct orinoco_key keys[ORINOCO_MAX_KEYS];
115 int bitratemode;
116 char nick[IW_ESSID_MAX_SIZE+1];
117 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200118 char desired_bssid[ETH_ALEN];
119 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 u16 frag_thresh, mwo_robust;
121 u16 channel;
122 u16 ap_density, rts_thresh;
123 u16 pm_on, pm_mcast, pm_period, pm_timeout;
124 u16 preamble;
125#ifdef WIRELESS_SPY
Pavel Roskin343c6862005-09-09 18:43:02 -0400126 struct iw_spy_data spy_data; /* iwspy support */
127 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128#endif
129
130 /* Configuration dependent variables */
131 int port_type, createibss;
132 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200133
134 /* Scanning support */
Dan Williams1e3428e2007-10-10 23:56:25 -0400135 struct list_head bss_list;
136 struct list_head bss_free_list;
David Kilroy01632fa2008-08-21 23:27:58 +0100137 void *bss_xbss_data;
Dan Williams1e3428e2007-10-10 23:56:25 -0400138
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200139 int scan_inprogress; /* Scan pending... */
140 u32 scan_mode; /* Type of scan done */
David Kilroyd03032a2008-08-21 23:28:02 +0100141
142 /* WPA support */
143 u8 *wpa_ie;
144 int wpa_ie_len;
145
146 struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
147
148 unsigned int wpa_enabled:1;
149 unsigned int tkip_cm_active:1;
150 unsigned int key_mgmt:3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151};
152
153#ifdef ORINOCO_DEBUG
154extern int orinoco_debug;
155#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
156#else
157#define DEBUG(n, args...) do { } while (0)
158#endif /* ORINOCO_DEBUG */
159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160/********************************************************************/
161/* Exported prototypes */
162/********************************************************************/
163
David Kilroy3994d502008-08-21 23:27:54 +0100164extern struct net_device *alloc_orinocodev(
165 int sizeof_card, struct device *device,
166 int (*hard_reset)(struct orinoco_private *),
167 int (*stop_fw)(struct orinoco_private *, int));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168extern void free_orinocodev(struct net_device *dev);
169extern int __orinoco_up(struct net_device *dev);
170extern int __orinoco_down(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171extern int orinoco_reinit_firmware(struct net_device *dev);
David Howells7d12e782006-10-05 14:55:46 +0100172extern irqreturn_t orinoco_interrupt(int irq, void * dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174/********************************************************************/
175/* Locking and synchronization functions */
176/********************************************************************/
177
Pavel Roskin821fe682006-08-15 20:45:00 -0400178static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 unsigned long *flags)
180{
181 spin_lock_irqsave(&priv->lock, *flags);
182 if (priv->hw_unavailable) {
183 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
184 priv->ndev);
185 spin_unlock_irqrestore(&priv->lock, *flags);
186 return -EBUSY;
187 }
188 return 0;
189}
190
Pavel Roskin821fe682006-08-15 20:45:00 -0400191static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 unsigned long *flags)
193{
194 spin_unlock_irqrestore(&priv->lock, *flags);
195}
196
197#endif /* _ORINOCO_H */