5f4f5c9eef79ba79dc8e83fac19f4b0d2c5237ec
[pandora-kernel.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 #include <net/cfg80211.h>
18
19 #include "hermes.h"
20
21 /* To enable debug messages */
22 /*#define ORINOCO_DEBUG         3*/
23
24 #define WIRELESS_SPY            /* enable iwspy support */
25
26 #define MAX_SCAN_LEN            4096
27
28 #define ORINOCO_MAX_KEY_SIZE    14
29 #define ORINOCO_MAX_KEYS        4
30
31 struct orinoco_key {
32         __le16 len;     /* always stored as little-endian */
33         char data[ORINOCO_MAX_KEY_SIZE];
34 } __attribute__ ((packed));
35
36 #define TKIP_KEYLEN     16
37 #define MIC_KEYLEN      8
38
39 struct orinoco_tkip_key {
40         u8 tkip[TKIP_KEYLEN];
41         u8 tx_mic[MIC_KEYLEN];
42         u8 rx_mic[MIC_KEYLEN];
43 };
44
45 typedef enum {
46         FIRMWARE_TYPE_AGERE,
47         FIRMWARE_TYPE_INTERSIL,
48         FIRMWARE_TYPE_SYMBOL
49 } fwtype_t;
50
51 struct firmware;
52
53 struct orinoco_private {
54         void *card;     /* Pointer to card dependent structure */
55         struct device *dev;
56         int (*hard_reset)(struct orinoco_private *);
57         int (*stop_fw)(struct orinoco_private *, int);
58
59         struct ieee80211_supported_band band;
60         struct ieee80211_channel channels[14];
61         u32 cipher_suites[3];
62
63         /* Synchronisation stuff */
64         spinlock_t lock;
65         int hw_unavailable;
66         struct work_struct reset_work;
67
68         /* Interrupt tasklets */
69         struct tasklet_struct rx_tasklet;
70         struct list_head rx_list;
71
72         /* driver state */
73         int open;
74         u16 last_linkstatus;
75         struct work_struct join_work;
76         struct work_struct wevent_work;
77
78         /* Net device stuff */
79         struct net_device *ndev;
80         struct net_device_stats stats;
81         struct iw_statistics wstats;
82
83         /* Hardware control variables */
84         hermes_t hw;
85         u16 txfid;
86
87         /* Capabilities of the hardware/firmware */
88         fwtype_t firmware_type;
89         char fw_name[32];
90         int ibss_port;
91         int nicbuf_size;
92         u16 channel_mask;
93
94         /* Boolean capabilities */
95         unsigned int has_ibss:1;
96         unsigned int has_port3:1;
97         unsigned int has_wep:1;
98         unsigned int has_big_wep:1;
99         unsigned int has_mwo:1;
100         unsigned int has_pm:1;
101         unsigned int has_preamble:1;
102         unsigned int has_sensitivity:1;
103         unsigned int has_hostscan:1;
104         unsigned int has_alt_txcntl:1;
105         unsigned int has_ext_scan:1;
106         unsigned int has_wpa:1;
107         unsigned int do_fw_download:1;
108         unsigned int broken_disableport:1;
109         unsigned int broken_monitor:1;
110
111         /* Configuration paramaters */
112         enum nl80211_iftype iw_mode;
113         int prefer_port3;
114         u16 encode_alg, wep_restrict, tx_key;
115         struct orinoco_key keys[ORINOCO_MAX_KEYS];
116         int bitratemode;
117         char nick[IW_ESSID_MAX_SIZE+1];
118         char desired_essid[IW_ESSID_MAX_SIZE+1];
119         char desired_bssid[ETH_ALEN];
120         int bssid_fixed;
121         u16 frag_thresh, mwo_robust;
122         u16 channel;
123         u16 ap_density, rts_thresh;
124         u16 pm_on, pm_mcast, pm_period, pm_timeout;
125         u16 preamble;
126 #ifdef WIRELESS_SPY
127         struct iw_spy_data spy_data; /* iwspy support */
128         struct iw_public_data   wireless_data;
129 #endif
130
131         /* Configuration dependent variables */
132         int port_type, createibss;
133         int promiscuous, mc_count;
134
135         /* Scanning support */
136         struct cfg80211_scan_request *scan_request;
137         struct work_struct process_scan;
138         struct list_head scan_list;
139         spinlock_t scan_lock; /* protects the scan list */
140
141         /* WPA support */
142         u8 *wpa_ie;
143         int wpa_ie_len;
144
145         struct orinoco_tkip_key tkip_key[ORINOCO_MAX_KEYS];
146         struct crypto_hash *rx_tfm_mic;
147         struct crypto_hash *tx_tfm_mic;
148
149         unsigned int wpa_enabled:1;
150         unsigned int tkip_cm_active:1;
151         unsigned int key_mgmt:3;
152
153 #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
154         /* Cached in memory firmware to use during ->resume. */
155         const struct firmware *cached_pri_fw;
156         const struct firmware *cached_fw;
157 #endif
158
159         struct notifier_block pm_notifier;
160 };
161
162 #ifdef ORINOCO_DEBUG
163 extern int orinoco_debug;
164 #define DEBUG(n, args...) do { \
165         if (orinoco_debug > (n)) \
166                 printk(KERN_DEBUG args); \
167 } while (0)
168 #else
169 #define DEBUG(n, args...) do { } while (0)
170 #endif  /* ORINOCO_DEBUG */
171
172 /********************************************************************/
173 /* Exported prototypes                                              */
174 /********************************************************************/
175
176 extern struct orinoco_private *alloc_orinocodev(
177         int sizeof_card, struct device *device,
178         int (*hard_reset)(struct orinoco_private *),
179         int (*stop_fw)(struct orinoco_private *, int));
180 extern void free_orinocodev(struct orinoco_private *priv);
181 extern int orinoco_init(struct orinoco_private *priv);
182 extern int orinoco_if_add(struct orinoco_private *priv,
183                           unsigned long base_addr,
184                           unsigned int irq);
185 extern void orinoco_if_del(struct orinoco_private *priv);
186 extern int orinoco_up(struct orinoco_private *priv);
187 extern void orinoco_down(struct orinoco_private *priv);
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 /*** Navigate from net_device to orinoco_private ***/
214 static inline struct orinoco_private *ndev_priv(struct net_device *dev)
215 {
216         struct wireless_dev *wdev = netdev_priv(dev);
217         return wdev_priv(wdev);
218 }
219 #endif /* _ORINOCO_H */