8abb28af5afa0d1a220473248161f7f536de8599
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / dev.h
1 /**
2   * This file contains definitions and data structures specific
3   * to Marvell 802.11 NIC. It contains the Device Information
4   * structure struct lbs_private..
5   */
6 #ifndef _LBS_DEV_H_
7 #define _LBS_DEV_H_
8
9 #include <linux/netdevice.h>
10 #include <linux/wireless.h>
11 #include <linux/ethtool.h>
12 #include <linux/debugfs.h>
13
14 #include "defs.h"
15 #include "hostcmd.h"
16
17 extern const struct ethtool_ops lbs_ethtool_ops;
18
19 #define MAX_BSSID_PER_CHANNEL           16
20
21 #define NR_TX_QUEUE                     3
22
23 /* For the extended Scan */
24 #define MAX_EXTENDED_SCAN_BSSID_LIST    MAX_BSSID_PER_CHANNEL * \
25                                                 MRVDRV_MAX_CHANNEL_SIZE + 1
26
27 #define MAX_REGION_CHANNEL_NUM  2
28
29 /** Chan-freq-TxPower mapping table*/
30 struct chan_freq_power {
31         /** channel Number              */
32         u16 channel;
33         /** frequency of this channel   */
34         u32 freq;
35         /** Max allowed Tx power level  */
36         u16 maxtxpower;
37         /** TRUE:channel unsupported;  FLASE:supported*/
38         u8 unsupported;
39 };
40
41 /** region-band mapping table*/
42 struct region_channel {
43         /** TRUE if this entry is valid              */
44         u8 valid;
45         /** region code for US, Japan ...            */
46         u8 region;
47         /** band B/G/A, used for BAND_CONFIG cmd             */
48         u8 band;
49         /** Actual No. of elements in the array below */
50         u8 nrcfp;
51         /** chan-freq-txpower mapping table*/
52         struct chan_freq_power *CFP;
53 };
54
55 struct lbs_802_11_security {
56         u8 WPAenabled;
57         u8 WPA2enabled;
58         u8 wep_enabled;
59         u8 auth_mode;
60         u32 key_mgmt;
61 };
62
63 /** Current Basic Service Set State Structure */
64 struct current_bss_params {
65         /** bssid */
66         u8 bssid[ETH_ALEN];
67         /** ssid */
68         u8 ssid[IW_ESSID_MAX_SIZE + 1];
69         u8 ssid_len;
70
71         /** band */
72         u8 band;
73         /** channel */
74         u8 channel;
75         /** zero-terminated array of supported data rates */
76         u8 rates[MAX_RATES + 1];
77 };
78
79 /** sleep_params */
80 struct sleep_params {
81         uint16_t sp_error;
82         uint16_t sp_offset;
83         uint16_t sp_stabletime;
84         uint8_t  sp_calcontrol;
85         uint8_t  sp_extsleepclk;
86         uint16_t sp_reserved;
87 };
88
89 /* Mesh statistics */
90 struct lbs_mesh_stats {
91         u32     fwd_bcast_cnt;          /* Fwd: Broadcast counter */
92         u32     fwd_unicast_cnt;        /* Fwd: Unicast counter */
93         u32     fwd_drop_ttl;           /* Fwd: TTL zero */
94         u32     fwd_drop_rbt;           /* Fwd: Recently Broadcasted */
95         u32     fwd_drop_noroute;       /* Fwd: No route to Destination */
96         u32     fwd_drop_nobuf;         /* Fwd: Run out of internal buffers */
97         u32     drop_blind;             /* Rx:  Dropped by blinding table */
98         u32     tx_failed_cnt;          /* Tx:  Failed transmissions */
99 };
100
101 /** Private structure for the MV device */
102 struct lbs_private {
103         struct wireless_dev *wdev;
104         int mesh_open;
105         int mesh_fw_ver;
106         int infra_open;
107         int mesh_autostart_enabled;
108
109         char name[DEV_NAME_LEN];
110
111         void *card;
112         struct net_device *dev;
113
114         struct net_device *mesh_dev; /* Virtual device */
115         struct net_device *rtap_net_dev;
116
117         struct iw_statistics wstats;
118         struct lbs_mesh_stats mstats;
119         struct dentry *debugfs_dir;
120         struct dentry *debugfs_debug;
121         struct dentry *debugfs_files[6];
122
123         struct dentry *events_dir;
124         struct dentry *debugfs_events_files[6];
125
126         struct dentry *regs_dir;
127         struct dentry *debugfs_regs_files[6];
128
129         u32 mac_offset;
130         u32 bbp_offset;
131         u32 rf_offset;
132
133         /** Deep sleep flag */
134         int is_deep_sleep;
135         /** Auto deep sleep enabled flag */
136         int is_auto_deep_sleep_enabled;
137         /** Device wakeup required flag */
138         int wakeup_dev_required;
139         /** Auto deep sleep flag*/
140         int is_activity_detected;
141         /** Auto deep sleep timeout (in miliseconds) */
142         int auto_deep_sleep_timeout;
143
144         /** Deep sleep wait queue */
145         wait_queue_head_t       ds_awake_q;
146
147         /* Download sent:
148            bit0 1/0=data_sent/data_tx_done,
149            bit1 1/0=cmd_sent/cmd_tx_done,
150            all other bits reserved 0 */
151         u8 dnld_sent;
152
153         /** thread to service interrupts */
154         struct task_struct *main_thread;
155         wait_queue_head_t waitq;
156         struct workqueue_struct *work_thread;
157
158         struct work_struct mcast_work;
159
160         /** Scanning */
161         struct delayed_work scan_work;
162         struct delayed_work assoc_work;
163         struct work_struct sync_channel;
164         /* remember which channel was scanned last, != 0 if currently scanning */
165         int scan_channel;
166         u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
167         u8 scan_ssid_len;
168
169         /** Hardware access */
170         int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
171         void (*reset_card) (struct lbs_private *priv);
172         int (*enter_deep_sleep) (struct lbs_private *priv);
173         int (*exit_deep_sleep) (struct lbs_private *priv);
174         int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
175
176         /* Wake On LAN */
177         uint32_t wol_criteria;
178         uint8_t wol_gpio;
179         uint8_t wol_gap;
180
181         /** Wlan adapter data structure*/
182         /** STATUS variables */
183         u32 fwrelease;
184         u32 fwcapinfo;
185
186         struct mutex lock;
187
188         /* TX packet ready to be sent... */
189         int tx_pending_len;             /* -1 while building packet */
190
191         u8 tx_pending_buf[LBS_UPLD_SIZE];
192         /* protected by hard_start_xmit serialization */
193
194         /** command-related variables */
195         u16 seqnum;
196
197         struct cmd_ctrl_node *cmd_array;
198         /** Current command */
199         struct cmd_ctrl_node *cur_cmd;
200         int cur_cmd_retcode;
201         /** command Queues */
202         /** Free command buffers */
203         struct list_head cmdfreeq;
204         /** Pending command buffers */
205         struct list_head cmdpendingq;
206
207         wait_queue_head_t cmd_pending;
208
209         /* Command responses sent from the hardware to the driver */
210         u8 resp_idx;
211         u8 resp_buf[2][LBS_UPLD_SIZE];
212         u32 resp_len[2];
213
214         /* Events sent from hardware to driver */
215         struct kfifo *event_fifo;
216
217         /* nickname */
218         u8 nodename[16];
219
220         /** spin locks */
221         spinlock_t driver_lock;
222
223         /** Timers */
224         struct timer_list command_timer;
225         struct timer_list auto_deepsleep_timer;
226         int nr_retries;
227         int cmd_timed_out;
228
229         /** current ssid/bssid related parameters*/
230         struct current_bss_params curbssparams;
231
232         uint16_t mesh_tlv;
233         u8 mesh_ssid[IW_ESSID_MAX_SIZE + 1];
234         u8 mesh_ssid_len;
235
236         /* IW_MODE_* */
237         u8 mode;
238
239         /* Scan results list */
240         struct list_head network_list;
241         struct list_head network_free_list;
242         struct bss_descriptor *networks;
243
244         u16 beacon_period;
245         u8 beacon_enable;
246         u8 adhoccreate;
247
248         /** capability Info used in Association, start, join */
249         u16 capability;
250
251         /** MAC address information */
252         u8 current_addr[ETH_ALEN];
253         u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
254         u32 nr_of_multicastmacaddr;
255
256         /** 802.11 statistics */
257 //      struct cmd_DS_802_11_GET_STAT wlan802_11Stat;
258
259         uint16_t enablehwauto;
260         uint16_t ratebitmap;
261
262         u8 txretrycount;
263
264         /** Tx-related variables (for single packet tx) */
265         struct sk_buff *currenttxskb;
266
267         /** NIC Operation characteristics */
268         u16 mac_control;
269         u32 connect_status;
270         u32 mesh_connect_status;
271         u16 regioncode;
272         s16 txpower_cur;
273         s16 txpower_min;
274         s16 txpower_max;
275
276         /** POWER MANAGEMENT AND PnP SUPPORT */
277         u8 surpriseremoved;
278
279         u16 psmode;             /* Wlan802_11PowermodeCAM=disable
280                                    Wlan802_11PowermodeMAX_PSP=enable */
281         u32 psstate;
282         u8 needtowakeup;
283
284         struct assoc_request * pending_assoc_req;
285         struct assoc_request * in_progress_assoc_req;
286
287         /** Encryption parameter */
288         struct lbs_802_11_security secinfo;
289
290         /** WEP keys */
291         struct enc_key wep_keys[4];
292         u16 wep_tx_keyidx;
293
294         /** WPA keys */
295         struct enc_key wpa_mcast_key;
296         struct enc_key wpa_unicast_key;
297
298 /*
299  * In theory, the IE is limited to the IE length, 255,
300  * but in practice 64 bytes are enough.
301  */
302 #define MAX_WPA_IE_LEN 64
303
304         /** WPA Information Elements*/
305         u8 wpa_ie[MAX_WPA_IE_LEN];
306         u8 wpa_ie_len;
307
308         /** Requested Signal Strength*/
309         u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
310         u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
311         u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
312         u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
313         u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
314         u16 nextSNRNF;
315         u16 numSNRNF;
316
317         u8 radio_on;
318
319         /** data rate stuff */
320         u8 cur_rate;
321
322         /** RF calibration data */
323
324 #define MAX_REGION_CHANNEL_NUM  2
325         /** region channel data */
326         struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
327
328         struct region_channel universal_channel[MAX_REGION_CHANNEL_NUM];
329
330         /** 11D and Domain Regulatory Data */
331         struct lbs_802_11d_domain_reg domainreg;
332         struct parsed_region_chan_11d parsed_region_chan;
333
334         /** FSM variable for 11d support */
335         u32 enable11d;
336
337         /**     MISCELLANEOUS */
338         struct lbs_offset_value offsetvalue;
339
340         u32 monitormode;
341         u8 fw_ready;
342 };
343
344 extern struct cmd_confirm_sleep confirm_sleep;
345
346 /**
347  *  @brief Structure used to store information for each beacon/probe response
348  */
349 struct bss_descriptor {
350         u8 bssid[ETH_ALEN];
351
352         u8 ssid[IW_ESSID_MAX_SIZE + 1];
353         u8 ssid_len;
354
355         u16 capability;
356         u32 rssi;
357         u32 channel;
358         u16 beaconperiod;
359         __le16 atimwindow;
360
361         /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
362         u8 mode;
363
364         /* zero-terminated array of supported data rates */
365         u8 rates[MAX_RATES + 1];
366
367         unsigned long last_scanned;
368
369         union ieee_phy_param_set phy;
370         union ieee_ss_param_set ss;
371
372         struct ieee_ie_country_info_full_set countryinfo;
373
374         u8 wpa_ie[MAX_WPA_IE_LEN];
375         size_t wpa_ie_len;
376         u8 rsn_ie[MAX_WPA_IE_LEN];
377         size_t rsn_ie_len;
378
379         u8 mesh;
380
381         struct list_head list;
382 };
383
384 /** Association request
385  *
386  * Encapsulates all the options that describe a specific assocation request
387  * or configuration of the wireless card's radio, mode, and security settings.
388  */
389 struct assoc_request {
390 #define ASSOC_FLAG_SSID                 1
391 #define ASSOC_FLAG_CHANNEL              2
392 #define ASSOC_FLAG_BAND                 3
393 #define ASSOC_FLAG_MODE                 4
394 #define ASSOC_FLAG_BSSID                5
395 #define ASSOC_FLAG_WEP_KEYS             6
396 #define ASSOC_FLAG_WEP_TX_KEYIDX        7
397 #define ASSOC_FLAG_WPA_MCAST_KEY        8
398 #define ASSOC_FLAG_WPA_UCAST_KEY        9
399 #define ASSOC_FLAG_SECINFO              10
400 #define ASSOC_FLAG_WPA_IE               11
401         unsigned long flags;
402
403         u8 ssid[IW_ESSID_MAX_SIZE + 1];
404         u8 ssid_len;
405         u8 channel;
406         u8 band;
407         u8 mode;
408         u8 bssid[ETH_ALEN] __attribute__ ((aligned (2)));
409
410         /** WEP keys */
411         struct enc_key wep_keys[4];
412         u16 wep_tx_keyidx;
413
414         /** WPA keys */
415         struct enc_key wpa_mcast_key;
416         struct enc_key wpa_unicast_key;
417
418         struct lbs_802_11_security secinfo;
419
420         /** WPA Information Elements*/
421         u8 wpa_ie[MAX_WPA_IE_LEN];
422         u8 wpa_ie_len;
423
424         /* BSS to associate with for infrastructure of Ad-Hoc join */
425         struct bss_descriptor bss;
426 };
427
428 #endif