]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/net/wireless/orinoco/orinoco.h
c653816ef5fe343ba416929731d1df5b8205d08e
[mv-sheeva.git] / drivers / net / wireless / orinoco / orinoco.h
1 /* 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
10 #define DRIVER_VERSION "0.15"
11
12 #include <linux/interrupt.h>
13 #include <linux/suspend.h>
14 #include <linux/netdevice.h>
15 #include <linux/wireless.h>
16 #include <net/iw_handler.h>
17
18 #include "hermes.h"
19
20 /* To enable debug messages */
21 //#define ORINOCO_DEBUG         3
22
23 #define WIRELESS_SPY            // enable iwspy support
24
25 #define MAX_SCAN_LEN            4096
26
27 #define ORINOCO_MAX_KEY_SIZE    14
28 #define ORINOCO_MAX_KEYS        4
29
30 struct orinoco_key {
31         __le16 len;     /* always stored as little-endian */
32         char data[ORINOCO_MAX_KEY_SIZE];
33 } __attribute__ ((packed));
34
35 #define TKIP_KEYLEN     16
36 #define MIC_KEYLEN      8
37
38 struct orinoco_tkip_key {
39         u8 tkip[TKIP_KEYLEN];
40         u8 tx_mic[MIC_KEYLEN];
41         u8 rx_mic[MIC_KEYLEN];
42 };
43
44 typedef enum {
45         FIRMWARE_TYPE_AGERE,
46         FIRMWARE_TYPE_INTERSIL,
47         FIRMWARE_TYPE_SYMBOL
48 } fwtype_t;
49
50 struct bss_element {
51         union hermes_scan_info bss;
52         unsigned long last_scanned;
53         struct list_head list;
54 };
55
56 struct xbss_element {
57         struct agere_ext_scan_info bss;
58         unsigned long last_scanned;
59         struct list_head list;
60 };
61
62 struct firmware;
63
64 struct orinoco_private {
65         void *card;     /* Pointer to card dependent structure */
66         struct device *dev;
67         int (*hard_reset)(struct orinoco_private *);
68         int (*stop_fw)(struct orinoco_private *, int);
69
70         /* Synchronisation stuff */
71         spinlock_t lock;
72         int hw_unavailable;
73         struct work_struct reset_work;
74
75         /* Interrupt tasklets */
76         struct tasklet_struct rx_tasklet;
77         struct list_head rx_list;
78
79         /* driver state */
80         int open;
81         u16 last_linkstatus;
82         struct work_struct join_work;
83         struct work_struct wevent_work;
84
85         /* Net device stuff */
86         struct net_device *ndev;
87         struct net_device_stats stats;
88         struct iw_statistics wstats;
89
90         /* Hardware control variables */
91         hermes_t hw;
92         u16 txfid;
93
94         /* Capabilities of the hardware/firmware */
95         fwtype_t firmware_type;
96         char fw_name[32];
97         int ibss_port;
98         int nicbuf_size;
99         u16 channel_mask;
100
101         /* Boolean capabilities */
102         unsigned int has_ibss:1;
103         unsigned int has_port3:1;
104         unsigned int has_wep:1;
105         unsigned int has_big_wep:1;
106         unsigned int has_mwo:1;
107         unsigned int has_pm:1;
108         unsigned int has_preamble:1;
109         unsigned int has_sensitivity:1;
110         unsigned int has_hostscan:1;
111         unsigned int has_alt_txcntl:1;
112         unsigned int has_ext_scan:1;
113         unsigned int has_wpa:1;
114         unsigned int do_fw_download:1;
115         unsigned int broken_disableport:1;
116         unsigned int broken_monitor:1;
117
118         /* Configuration paramaters */
119         u32 iw_mode;
120         int prefer_port3;
121         u16 encode_alg, wep_restrict, tx_key;
122         struct orinoco_key keys[ORINOCO_MAX_KEYS];
123         int bitratemode;
124         char nick[IW_ESSID_MAX_SIZE+1];
125         char desired_essid[IW_ESSID_MAX_SIZE+1];
126         char desired_bssid[ETH_ALEN];
127         int bssid_fixed;
128         u16 frag_thresh, mwo_robust;
129         u16 channel;
130         u16 ap_density, rts_thresh;
131         u16 pm_on, pm_mcast, pm_period, pm_timeout;
132         u16 preamble;
133 #ifdef WIRELESS_SPY
134         struct iw_spy_data spy_data; /* iwspy support */
135         struct iw_public_data   wireless_data;
136 #endif
137
138         /* Configuration dependent variables */
139         int port_type, createibss;
140         int promiscuous, mc_count;
141
142         /* Scanning support */
143         struct list_head bss_list;
144         struct list_head bss_free_list;
145         void *bss_xbss_data;
146
147         int     scan_inprogress;        /* Scan pending... */
148         u32     scan_mode;              /* Type of scan done */
149
150         /* WPA support */
151         u8 *wpa_ie;
152         int wpa_ie_len;
153
154         struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
155         struct crypto_hash *rx_tfm_mic;
156         struct crypto_hash *tx_tfm_mic;
157
158         unsigned int wpa_enabled:1;
159         unsigned int tkip_cm_active:1;
160         unsigned int key_mgmt:3;
161
162         /* Cached in memory firmware to use during ->resume. */
163         const struct firmware *cached_pri_fw;
164         const struct firmware *cached_fw;
165
166         struct notifier_block pm_notifier;
167 };
168
169 #ifdef ORINOCO_DEBUG
170 extern int orinoco_debug;
171 #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
172 #else
173 #define DEBUG(n, args...) do { } while (0)
174 #endif  /* ORINOCO_DEBUG */
175
176 /********************************************************************/
177 /* Exported prototypes                                              */
178 /********************************************************************/
179
180 extern struct net_device *alloc_orinocodev(
181         int sizeof_card, struct device *device,
182         int (*hard_reset)(struct orinoco_private *),
183         int (*stop_fw)(struct orinoco_private *, int));
184 extern void free_orinocodev(struct net_device *dev);
185 extern int __orinoco_up(struct net_device *dev);
186 extern int __orinoco_down(struct net_device *dev);
187 extern int orinoco_reinit_firmware(struct net_device *dev);
188 extern irqreturn_t orinoco_interrupt(int irq, void * dev_id);
189
190 /********************************************************************/
191 /* Locking and synchronization functions                            */
192 /********************************************************************/
193
194 static inline int orinoco_lock(struct orinoco_private *priv,
195                                unsigned long *flags)
196 {
197         spin_lock_irqsave(&priv->lock, *flags);
198         if (priv->hw_unavailable) {
199                 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
200                        priv->ndev);
201                 spin_unlock_irqrestore(&priv->lock, *flags);
202                 return -EBUSY;
203         }
204         return 0;
205 }
206
207 static inline void orinoco_unlock(struct orinoco_private *priv,
208                                   unsigned long *flags)
209 {
210         spin_unlock_irqrestore(&priv->lock, *flags);
211 }
212
213 #endif /* _ORINOCO_H */