blob: b1f876f9693bf93fc24f222b59f97bdd06677be1 [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains definitions and data structures specific
3 * to Marvell 802.11 NIC. It contains the Device Information
4 * structure wlan_adapter.
5 */
6#ifndef _WLAN_DEV_H_
7#define _WLAN_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 "scan.h"
16#include "thread.h"
17
18extern struct ethtool_ops libertas_ethtool_ops;
19
20#define MAX_BSSID_PER_CHANNEL 16
21
22#define NR_TX_QUEUE 3
23
24/* For the extended Scan */
25#define MAX_EXTENDED_SCAN_BSSID_LIST MAX_BSSID_PER_CHANNEL * \
26 MRVDRV_MAX_CHANNEL_SIZE + 1
27
28#define MAX_REGION_CHANNEL_NUM 2
29
30/** Chan-freq-TxPower mapping table*/
31struct chan_freq_power {
32 /** channel Number */
33 u16 channel;
34 /** frequency of this channel */
35 u32 freq;
36 /** Max allowed Tx power level */
37 u16 maxtxpower;
38 /** TRUE:channel unsupported; FLASE:supported*/
39 u8 unsupported;
40};
41
42/** region-band mapping table*/
43struct region_channel {
44 /** TRUE if this entry is valid */
45 u8 valid;
46 /** region code for US, Japan ... */
47 u8 region;
48 /** band B/G/A, used for BAND_CONFIG cmd */
49 u8 band;
50 /** Actual No. of elements in the array below */
51 u8 nrcfp;
52 /** chan-freq-txpower mapping table*/
53 struct chan_freq_power *CFP;
54};
55
56struct wlan_802_11_security {
57 u8 WPAenabled;
58 u8 WPA2enabled;
59 enum WLAN_802_11_WEP_STATUS WEPstatus;
60 enum WLAN_802_11_AUTHENTICATION_MODE authmode;
61 enum WLAN_802_1X_AUTH_ALG auth1xalg;
62 enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode;
63};
64
65/** Current Basic Service Set State Structure */
66struct current_bss_params {
67 struct bss_descriptor bssdescriptor;
68 /** bssid */
69 u8 bssid[ETH_ALEN];
70 /** ssid */
71 struct WLAN_802_11_SSID ssid;
72
73 /** band */
74 u8 band;
75 /** channel */
76 u8 channel;
77 /** number of rates supported */
78 int numofrates;
79 /** supported rates*/
80 u8 datarates[WLAN_SUPPORTED_RATES];
81};
82
83/** sleep_params */
84struct sleep_params {
85 u16 sp_error;
86 u16 sp_offset;
87 u16 sp_stabletime;
88 u8 sp_calcontrol;
89 u8 sp_extsleepclk;
90 u16 sp_reserved;
91};
92
93/** Data structure for the Marvell WLAN device */
94typedef struct _wlan_dev {
95 /** device name */
96 char name[DEV_NAME_LEN];
97 /** card pointer */
98 void *card;
99 /** IO port */
100 u32 ioport;
101 /** Upload received */
102 u32 upld_rcv;
103 /** Upload type */
104 u32 upld_typ;
105 /** Upload length */
106 u32 upld_len;
107 /** netdev pointer */
108 struct net_device *netdev;
109 /* Upload buffer */
110 u8 upld_buf[WLAN_UPLD_SIZE];
111 /* Download sent:
112 bit0 1/0=data_sent/data_tx_done,
113 bit1 1/0=cmd_sent/cmd_tx_done,
114 all other bits reserved 0 */
115 u8 dnld_sent;
116} wlan_dev_t, *pwlan_dev_t;
117
118/* Mesh statistics */
119struct wlan_mesh_stats {
120 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
121 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
122 u32 fwd_drop_ttl; /* Fwd: TTL zero */
123 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
124 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
125 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
126 u32 drop_blind; /* Rx: Dropped by blinding table */
127};
128
129/** Private structure for the MV device */
130struct _wlan_private {
131 int open;
132 int mesh_open;
133 int infra_open;
134
135 wlan_adapter *adapter;
136 wlan_dev_t wlan_dev;
137
138 struct net_device_stats stats;
139 struct net_device *mesh_dev ; /* Virtual device */
140
141 struct iw_statistics wstats;
142 struct wlan_mesh_stats mstats;
143 struct dentry *debugfs_dir;
144 struct dentry *debugfs_debug;
145 struct dentry *debugfs_files[6];
146
147 struct dentry *events_dir;
148 struct dentry *debugfs_events_files[6];
149
150 struct dentry *regs_dir;
151 struct dentry *debugfs_regs_files[6];
152
153 u32 mac_offset;
154 u32 bbp_offset;
155 u32 rf_offset;
156
157 const struct firmware *firmware;
158 struct device *hotplug_device;
159
160 /** thread to service interrupts */
161 struct wlan_thread mainthread;
162
163 struct delayed_work assoc_work;
164 struct workqueue_struct *assoc_thread;
165};
166
167/** Association request
168 *
169 * Encapsulates all the options that describe a specific assocation request
170 * or configuration of the wireless card's radio, mode, and security settings.
171 */
172struct assoc_request {
173#define ASSOC_FLAG_SSID 1
174#define ASSOC_FLAG_CHANNEL 2
175#define ASSOC_FLAG_MODE 3
176#define ASSOC_FLAG_BSSID 4
177#define ASSOC_FLAG_WEP_KEYS 5
178#define ASSOC_FLAG_WEP_TX_KEYIDX 6
179#define ASSOC_FLAG_WPA_MCAST_KEY 7
180#define ASSOC_FLAG_WPA_UCAST_KEY 8
181#define ASSOC_FLAG_SECINFO 9
182#define ASSOC_FLAG_WPA_IE 10
183 unsigned long flags;
184
185 struct WLAN_802_11_SSID ssid;
186 u8 channel;
187 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode;
188 u8 bssid[ETH_ALEN];
189
190 /** WEP keys */
191 struct WLAN_802_11_KEY wep_keys[4];
192 u16 wep_tx_keyidx;
193
194 /** WPA keys */
195 struct WLAN_802_11_KEY wpa_mcast_key;
196 struct WLAN_802_11_KEY wpa_unicast_key;
197
198 struct wlan_802_11_security secinfo;
199
200 /** WPA Information Elements*/
201#define MAX_WPA_IE_LEN 64
202 u8 wpa_ie[MAX_WPA_IE_LEN];
203 u8 wpa_ie_len;
204};
205
206/** Wlan adapter data structure*/
207struct _wlan_adapter {
208 /** STATUS variables */
209 u32 fwreleasenumber;
210 u32 fwcapinfo;
211 /* protected with big lock */
212
213 struct mutex lock;
214
215 u8 tmptxbuf[WLAN_UPLD_SIZE];
216 /* protected by hard_start_xmit serialization */
217
218 /** command-related variables */
219 u16 seqnum;
220 /* protected by big lock */
221
222 struct cmd_ctrl_node *cmd_array;
223 /** Current command */
224 struct cmd_ctrl_node *cur_cmd;
225 int cur_cmd_retcode;
226 /** command Queues */
227 /** Free command buffers */
228 struct list_head cmdfreeq;
229 /** Pending command buffers */
230 struct list_head cmdpendingq;
231
232 wait_queue_head_t cmd_pending;
233 u8 nr_cmd_pending;
234 /* command related variables protected by adapter->driver_lock */
235
236 /** Async and Sync Event variables */
237 u32 intcounter;
238 u32 eventcause;
239 u8 nodename[16]; /* nickname */
240
241 /** spin locks */
242 spinlock_t driver_lock;
243
244 /** Timers */
245 struct timer_list command_timer;
246
247 /* TX queue used in PS mode */
248 spinlock_t txqueue_lock;
249 struct sk_buff *tx_queue_ps[NR_TX_QUEUE];
250 unsigned int tx_queue_idx;
251
252 u8 hisregcpy;
253
254 /** current ssid/bssid related parameters*/
255 struct current_bss_params curbssparams;
256
257 enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode;
258
259 struct bss_descriptor *pattemptedbssdesc;
260
261 struct WLAN_802_11_SSID previousssid;
262 u8 previousbssid[ETH_ALEN];
263
264 struct bss_descriptor *scantable;
265 u32 numinscantable;
266
267 u8 scantype;
268 u32 scanmode;
269
270 u16 beaconperiod;
271 u8 adhoccreate;
272
273 /** capability Info used in Association, start, join */
274 struct ieeetypes_capinfo capinfo;
275
276 /** MAC address information */
277 u8 current_addr[ETH_ALEN];
278 u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
279 u32 nr_of_multicastmacaddr;
280
281 /** 802.11 statistics */
282// struct cmd_DS_802_11_GET_STAT wlan802_11Stat;
283
284 u16 enablehwauto;
285 u16 ratebitmap;
286 /** control G rates */
287 u8 adhoc_grate_enabled;
288
289 u32 txantenna;
290 u32 rxantenna;
291
292 u8 adhocchannel;
293 u32 fragthsd;
294 u32 rtsthsd;
295
296 u32 datarate;
297 u8 is_datarate_auto;
298
299 u16 listeninterval;
300 u16 prescan;
301 u8 txretrycount;
302
303 /** Tx-related variables (for single packet tx) */
304 struct sk_buff *currenttxskb;
305 u16 TxLockFlag;
306
307 /** NIC Operation characteristics */
308 u16 currentpacketfilter;
309 u32 connect_status;
310 u16 regioncode;
311 u16 regiontableindex;
312 u16 txpowerlevel;
313
314 /** POWER MANAGEMENT AND PnP SUPPORT */
315 u8 surpriseremoved;
316 u16 atimwindow;
317
318 u16 psmode; /* Wlan802_11PowermodeCAM=disable
319 Wlan802_11PowermodeMAX_PSP=enable */
320 u16 multipledtim;
321 u32 psstate;
322 u8 needtowakeup;
323
324 struct PS_CMD_ConfirmSleep libertas_ps_confirm_sleep;
325 u16 locallisteninterval;
326 u16 nullpktinterval;
327
328 struct assoc_request * assoc_req;
329
330 /** Encryption parameter */
331 struct wlan_802_11_security secinfo;
332
333 /** WEP keys */
334 struct WLAN_802_11_KEY wep_keys[4];
335 u16 wep_tx_keyidx;
336
337 /** WPA keys */
338 struct WLAN_802_11_KEY wpa_mcast_key;
339 struct WLAN_802_11_KEY wpa_unicast_key;
340
341 /** WPA Information Elements*/
342#define MAX_WPA_IE_LEN 64
343 u8 wpa_ie[MAX_WPA_IE_LEN];
344 u8 wpa_ie_len;
345
346 u16 rxantennamode;
347 u16 txantennamode;
348
349 /** Requested Signal Strength*/
350 u16 bcn_avg_factor;
351 u16 data_avg_factor;
352 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
353 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
354 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
355 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
356 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
357 u16 nextSNRNF;
358 u16 numSNRNF;
359 u16 rxpd_rate;
360
361 u8 radioon;
362 u32 preamble;
363
364 /** Multi bands Parameter*/
365 u8 libertas_supported_rates[G_SUPPORTED_RATES];
366
367 /** Blue Tooth Co-existence Arbitration */
368
369 /** sleep_params */
370 struct sleep_params sp;
371
372 /** RF calibration data */
373
374#define MAX_REGION_CHANNEL_NUM 2
375 /** region channel data */
376 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
377
378 struct region_channel universal_channel[MAX_REGION_CHANNEL_NUM];
379
380 /** 11D and Domain Regulatory Data */
381 struct wlan_802_11d_domain_reg domainreg;
382 struct parsed_region_chan_11d parsed_region_chan;
383
384 /** FSM variable for 11d support */
385 u32 enable11d;
386
387 /** MISCELLANEOUS */
388 u8 *prdeeprom;
389 struct wlan_offset_value offsetvalue;
390
391 struct cmd_ds_802_11_get_log logmsg;
392 u16 scanprobes;
393
394 u32 pkttxctrl;
395
396 u16 txrate;
397 u32 linkmode;
398 u32 radiomode;
399 u32 debugmode;
400 u8 fw_ready;
401};
402
403#endif /* _WLAN_DEV_H_ */