blob: 295e7d00f9521db4b045755a20bd5e021cf265b7 [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;
60 enum WLAN_802_11_WEP_STATUS WEPstatus;
61 enum WLAN_802_11_AUTHENTICATION_MODE authmode;
62 enum WLAN_802_1X_AUTH_ALG auth1xalg;
63 enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode;
64};
65
66/** Current Basic Service Set State Structure */
67struct current_bss_params {
68 struct bss_descriptor bssdescriptor;
69 /** bssid */
70 u8 bssid[ETH_ALEN];
71 /** ssid */
72 struct WLAN_802_11_SSID ssid;
73
74 /** band */
75 u8 band;
76 /** channel */
77 u8 channel;
78 /** number of rates supported */
79 int numofrates;
80 /** supported rates*/
81 u8 datarates[WLAN_SUPPORTED_RATES];
82};
83
84/** sleep_params */
85struct sleep_params {
86 u16 sp_error;
87 u16 sp_offset;
88 u16 sp_stabletime;
89 u8 sp_calcontrol;
90 u8 sp_extsleepclk;
91 u16 sp_reserved;
92};
93
94/** Data structure for the Marvell WLAN device */
95typedef struct _wlan_dev {
96 /** device name */
97 char name[DEV_NAME_LEN];
98 /** card pointer */
99 void *card;
100 /** IO port */
101 u32 ioport;
102 /** Upload received */
103 u32 upld_rcv;
104 /** Upload type */
105 u32 upld_typ;
106 /** Upload length */
107 u32 upld_len;
108 /** netdev pointer */
109 struct net_device *netdev;
110 /* Upload buffer */
111 u8 upld_buf[WLAN_UPLD_SIZE];
112 /* Download sent:
113 bit0 1/0=data_sent/data_tx_done,
114 bit1 1/0=cmd_sent/cmd_tx_done,
115 all other bits reserved 0 */
116 u8 dnld_sent;
117} wlan_dev_t, *pwlan_dev_t;
118
119/* Mesh statistics */
120struct wlan_mesh_stats {
121 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
122 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
123 u32 fwd_drop_ttl; /* Fwd: TTL zero */
124 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
125 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
126 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
127 u32 drop_blind; /* Rx: Dropped by blinding table */
128};
129
130/** Private structure for the MV device */
131struct _wlan_private {
132 int open;
133 int mesh_open;
134 int infra_open;
135
136 wlan_adapter *adapter;
137 wlan_dev_t wlan_dev;
138
139 struct net_device_stats stats;
140 struct net_device *mesh_dev ; /* Virtual device */
141
142 struct iw_statistics wstats;
143 struct wlan_mesh_stats mstats;
144 struct dentry *debugfs_dir;
145 struct dentry *debugfs_debug;
146 struct dentry *debugfs_files[6];
147
148 struct dentry *events_dir;
149 struct dentry *debugfs_events_files[6];
150
151 struct dentry *regs_dir;
152 struct dentry *debugfs_regs_files[6];
153
154 u32 mac_offset;
155 u32 bbp_offset;
156 u32 rf_offset;
157
158 const struct firmware *firmware;
159 struct device *hotplug_device;
160
161 /** thread to service interrupts */
162 struct wlan_thread mainthread;
163
164 struct delayed_work assoc_work;
165 struct workqueue_struct *assoc_thread;
166};
167
168/** Association request
169 *
170 * Encapsulates all the options that describe a specific assocation request
171 * or configuration of the wireless card's radio, mode, and security settings.
172 */
173struct assoc_request {
174#define ASSOC_FLAG_SSID 1
175#define ASSOC_FLAG_CHANNEL 2
176#define ASSOC_FLAG_MODE 3
177#define ASSOC_FLAG_BSSID 4
178#define ASSOC_FLAG_WEP_KEYS 5
179#define ASSOC_FLAG_WEP_TX_KEYIDX 6
180#define ASSOC_FLAG_WPA_MCAST_KEY 7
181#define ASSOC_FLAG_WPA_UCAST_KEY 8
182#define ASSOC_FLAG_SECINFO 9
183#define ASSOC_FLAG_WPA_IE 10
184 unsigned long flags;
185
186 struct WLAN_802_11_SSID ssid;
187 u8 channel;
188 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode;
189 u8 bssid[ETH_ALEN];
190
191 /** WEP keys */
192 struct WLAN_802_11_KEY wep_keys[4];
193 u16 wep_tx_keyidx;
194
195 /** WPA keys */
196 struct WLAN_802_11_KEY wpa_mcast_key;
197 struct WLAN_802_11_KEY wpa_unicast_key;
198
199 struct wlan_802_11_security secinfo;
200
201 /** WPA Information Elements*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200202 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*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200342 u8 wpa_ie[MAX_WPA_IE_LEN];
343 u8 wpa_ie_len;
344
345 u16 rxantennamode;
346 u16 txantennamode;
347
348 /** Requested Signal Strength*/
349 u16 bcn_avg_factor;
350 u16 data_avg_factor;
351 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
352 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
353 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
354 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
355 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
356 u16 nextSNRNF;
357 u16 numSNRNF;
358 u16 rxpd_rate;
359
360 u8 radioon;
361 u32 preamble;
362
363 /** Multi bands Parameter*/
364 u8 libertas_supported_rates[G_SUPPORTED_RATES];
365
366 /** Blue Tooth Co-existence Arbitration */
367
368 /** sleep_params */
369 struct sleep_params sp;
370
371 /** RF calibration data */
372
373#define MAX_REGION_CHANNEL_NUM 2
374 /** region channel data */
375 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
376
377 struct region_channel universal_channel[MAX_REGION_CHANNEL_NUM];
378
379 /** 11D and Domain Regulatory Data */
380 struct wlan_802_11d_domain_reg domainreg;
381 struct parsed_region_chan_11d parsed_region_chan;
382
383 /** FSM variable for 11d support */
384 u32 enable11d;
385
386 /** MISCELLANEOUS */
387 u8 *prdeeprom;
388 struct wlan_offset_value offsetvalue;
389
390 struct cmd_ds_802_11_get_log logmsg;
391 u16 scanprobes;
392
393 u32 pkttxctrl;
394
395 u16 txrate;
396 u32 linkmode;
397 u32 radiomode;
398 u32 debugmode;
399 u8 fw_ready;
400};
401
402#endif /* _WLAN_DEV_H_ */