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