staging: batman: remove all rcu head initializations
[linux-block.git] / drivers / staging / rtl8192e / ieee80211 / ieee80211.h
CommitLineData
ecdfa446
GKH
1/*
2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
4 *
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
7 *
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
9 * <jkmaline@cc.hut.fi>
10 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
11 *
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation
15 *
16 * Modified for Realtek's wi-fi cards by Andrea Merello
17 * <andreamrl@tiscali.it>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License version 2 as
21 * published by the Free Software Foundation. See README and COPYING for
22 * more details.
23 */
24#ifndef IEEE80211_H
25#define IEEE80211_H
26#include <linux/if_ether.h> /* ETH_ALEN */
27#include <linux/kernel.h> /* ARRAY_SIZE */
28#include <linux/version.h>
29#include <linux/module.h>
30#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
31#include <linux/jiffies.h>
32#else
33#include <linux/jffs.h>
34#include <linux/tqueue.h>
35#endif
36#include <linux/timer.h>
37#include <linux/sched.h>
128a5d02 38#include <linux/semaphore.h>
ecdfa446
GKH
39
40#include <linux/delay.h>
41#include <linux/wireless.h>
42
43#include "rtl819x_HT.h"
44#include "rtl819x_BA.h"
45#include "rtl819x_TS.h"
46
47#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
48#ifndef bool
49typedef enum{false = 0, true} bool;
50#endif
51#endif
52
53#ifndef IW_MODE_MONITOR
54#define IW_MODE_MONITOR 6
55#endif
56
57#ifndef IWEVCUSTOM
58#define IWEVCUSTOM 0x8c02
59#endif
60
61#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
62#ifndef __bitwise
63#define __bitwise __attribute__((bitwise))
64#endif
65typedef __u16 __le16;
66#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27))
67struct iw_spy_data{
68 /* --- Standard spy support --- */
69 int spy_number;
70 u_char spy_address[IW_MAX_SPY][ETH_ALEN];
71 struct iw_quality spy_stat[IW_MAX_SPY];
72 /* --- Enhanced spy support (event) */
73 struct iw_quality spy_thr_low; /* Low threshold */
74 struct iw_quality spy_thr_high; /* High threshold */
75 u_char spy_thr_under[IW_MAX_SPY];
76};
77#endif
78#endif
79
80#ifndef container_of
81/**
82 * container_of - cast a member of a structure out to the containing structure
83 *
84 * @ptr: the pointer to the member.
85 * @type: the type of the container struct this is embedded in.
86 * @member: the name of the member within the struct.
87 *
88 */
89#define container_of(ptr, type, member) ({ \
90 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
91 (type *)( (char *)__mptr - offsetof(type,member) );})
92#endif
93
94#define KEY_TYPE_NA 0x0
95#define KEY_TYPE_WEP40 0x1
96#define KEY_TYPE_TKIP 0x2
97#define KEY_TYPE_CCMP 0x4
98#define KEY_TYPE_WEP104 0x5
99
100/* added for rtl819x tx procedure */
101#define MAX_QUEUE_SIZE 0x10
102
103//
104// 8190 queue mapping
105//
106#define BK_QUEUE 0
107#define BE_QUEUE 1
108#define VI_QUEUE 2
109#define VO_QUEUE 3
110#define HCCA_QUEUE 4
111#define TXCMD_QUEUE 5
112#define MGNT_QUEUE 6
113#define HIGH_QUEUE 7
114#define BEACON_QUEUE 8
115
116#define LOW_QUEUE BE_QUEUE
117#define NORMAL_QUEUE MGNT_QUEUE
118
119//added by amy for ps
120#define SWRF_TIMEOUT 50
121
122//added by amy for LEAP related
123#define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0.
124#define SUPPORT_CKIP_MIC 0x08 // bit3
125#define SUPPORT_CKIP_PK 0x10 // bit4
126/* defined for skb cb field */
127/* At most 28 byte */
128typedef struct cb_desc {
129 /* Tx Desc Related flags (8-9) */
130 u8 bLastIniPkt:1;
131 u8 bCmdOrInit:1;
132 u8 bFirstSeg:1;
133 u8 bLastSeg:1;
134 u8 bEncrypt:1;
135 u8 bTxDisableRateFallBack:1;
136 u8 bTxUseDriverAssingedRate:1;
137 u8 bHwSec:1; //indicate whether use Hw security. WB
138
139 u8 reserved1;
140
141 /* Tx Firmware Relaged flags (10-11)*/
142 u8 bCTSEnable:1;
143 u8 bRTSEnable:1;
144 u8 bUseShortGI:1;
145 u8 bUseShortPreamble:1;
146 u8 bTxEnableFwCalcDur:1;
147 u8 bAMPDUEnable:1;
148 u8 bRTSSTBC:1;
149 u8 RTSSC:1;
150
151 u8 bRTSBW:1;
152 u8 bPacketBW:1;
153 u8 bRTSUseShortPreamble:1;
154 u8 bRTSUseShortGI:1;
155 u8 bMulticast:1;
156 u8 bBroadcast:1;
157 //u8 reserved2:2;
158 u8 drv_agg_enable:1;
159 u8 reserved2:1;
160
161 /* Tx Desc related element(12-19) */
162 u8 rata_index;
163 u8 queue_index;
164 //u8 reserved3;
165 //u8 reserved4;
166 u16 txbuf_size;
167 //u8 reserved5;
168 u8 RATRIndex;
169 u8 reserved6;
170 u8 reserved7;
171 u8 reserved8;
172
173 /* Tx firmware related element(20-27) */
174 u8 data_rate;
175 u8 rts_rate;
176 u8 ampdu_factor;
177 u8 ampdu_density;
178 //u8 reserved9;
179 //u8 reserved10;
180 //u8 reserved11;
181 u8 DrvAggrNum;
182 u16 pkt_size;
183 u8 reserved12;
65a43784 184
185 u8 bdhcp;
ecdfa446
GKH
186}cb_desc, *pcb_desc;
187
188/*--------------------------Define -------------------------------------------*/
189#define MGN_1M 0x02
190#define MGN_2M 0x04
191#define MGN_5_5M 0x0b
192#define MGN_11M 0x16
193
194#define MGN_6M 0x0c
195#define MGN_9M 0x12
196#define MGN_12M 0x18
197#define MGN_18M 0x24
198#define MGN_24M 0x30
199#define MGN_36M 0x48
200#define MGN_48M 0x60
201#define MGN_54M 0x6c
202
203#define MGN_MCS0 0x80
204#define MGN_MCS1 0x81
205#define MGN_MCS2 0x82
206#define MGN_MCS3 0x83
207#define MGN_MCS4 0x84
208#define MGN_MCS5 0x85
209#define MGN_MCS6 0x86
210#define MGN_MCS7 0x87
211#define MGN_MCS8 0x88
212#define MGN_MCS9 0x89
213#define MGN_MCS10 0x8a
214#define MGN_MCS11 0x8b
215#define MGN_MCS12 0x8c
216#define MGN_MCS13 0x8d
217#define MGN_MCS14 0x8e
218#define MGN_MCS15 0x8f
219
220//----------------------------------------------------------------------------
221// 802.11 Management frame Reason Code field
222//----------------------------------------------------------------------------
223enum _ReasonCode{
224 unspec_reason = 0x1,
225 auth_not_valid = 0x2,
226 deauth_lv_ss = 0x3,
227 inactivity = 0x4,
228 ap_overload = 0x5,
229 class2_err = 0x6,
230 class3_err = 0x7,
231 disas_lv_ss = 0x8,
232 asoc_not_auth = 0x9,
233
234 //----MIC_CHECK
235 mic_failure = 0xe,
236 //----END MIC_CHECK
237
238 // Reason code defined in 802.11i D10.0 p.28.
239 invalid_IE = 0x0d,
240 four_way_tmout = 0x0f,
241 two_way_tmout = 0x10,
242 IE_dismatch = 0x11,
243 invalid_Gcipher = 0x12,
244 invalid_Pcipher = 0x13,
245 invalid_AKMP = 0x14,
246 unsup_RSNIEver = 0x15,
247 invalid_RSNIE = 0x16,
248 auth_802_1x_fail= 0x17,
249 ciper_reject = 0x18,
250
251 // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15.
252 QoS_unspec = 0x20, // 32
253 QAP_bandwidth = 0x21, // 33
254 poor_condition = 0x22, // 34
255 no_facility = 0x23, // 35
256 // Where is 36???
257 req_declined = 0x25, // 37
258 invalid_param = 0x26, // 38
259 req_not_honored= 0x27, // 39
260 TS_not_created = 0x2F, // 47
261 DL_not_allowed = 0x30, // 48
262 dest_not_exist = 0x31, // 49
263 dest_not_QSTA = 0x32, // 50
264};
265
266
267
268#define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A)||(priv->ieee80211->current_network.mode == IEEE_N_24G)||(priv->ieee80211->current_network.mode == IEEE_N_5G))? 16 : 10)
269
270#define MGMT_QUEUE_NUM 5
271
272#define IEEE_CMD_SET_WPA_PARAM 1
273#define IEEE_CMD_SET_WPA_IE 2
274#define IEEE_CMD_SET_ENCRYPTION 3
275#define IEEE_CMD_MLME 4
276
277#define IEEE_PARAM_WPA_ENABLED 1
278#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
279#define IEEE_PARAM_DROP_UNENCRYPTED 3
280#define IEEE_PARAM_PRIVACY_INVOKED 4
281#define IEEE_PARAM_AUTH_ALGS 5
282#define IEEE_PARAM_IEEE_802_1X 6
283//It should consistent with the driver_XXX.c
284// David, 2006.9.26
285#define IEEE_PARAM_WPAX_SELECT 7
286//Added for notify the encryption type selection
287// David, 2006.9.26
288#define IEEE_PROTO_WPA 1
289#define IEEE_PROTO_RSN 2
290//Added for notify the encryption type selection
291// David, 2006.9.26
292#define IEEE_WPAX_USEGROUP 0
293#define IEEE_WPAX_WEP40 1
294#define IEEE_WPAX_TKIP 2
295#define IEEE_WPAX_WRAP 3
296#define IEEE_WPAX_CCMP 4
297#define IEEE_WPAX_WEP104 5
298
299#define IEEE_KEY_MGMT_IEEE8021X 1
300#define IEEE_KEY_MGMT_PSK 2
301
302#define IEEE_MLME_STA_DEAUTH 1
303#define IEEE_MLME_STA_DISASSOC 2
304
305
306#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
307#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
308#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
309#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
310#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
311#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
312
313
314#define IEEE_CRYPT_ALG_NAME_LEN 16
315
316#define MAX_IE_LEN 0xff
317
318// added for kernel conflict
319#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
320#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
321#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
322#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
323#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
324#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
325
326#define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
327
328#define ieee80211_tkip_null ieee80211_tkip_null_rsl
329
330#define ieee80211_wep_null ieee80211_wep_null_rsl
331
332#define free_ieee80211 free_ieee80211_rsl
333#define alloc_ieee80211 alloc_ieee80211_rsl
334
335#define ieee80211_rx ieee80211_rx_rsl
336#define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
337
338#define ieee80211_get_beacon ieee80211_get_beacon_rsl
fb5fe277
GK
339#define ieee80211_rtl_wake_queue ieee80211_rtl_wake_queue_rsl
340#define ieee80211_rtl_stop_queue ieee80211_rtl_stop_queue_rsl
ecdfa446
GKH
341#define ieee80211_reset_queue ieee80211_reset_queue_rsl
342#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
343#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
344#define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
345#define ieee80211_is_54g ieee80211_is_54g_rsl
346#define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
347#define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
348#define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
349#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
350#define notify_wx_assoc_event notify_wx_assoc_event_rsl
351#define SendDisassociation SendDisassociation_rsl
352#define ieee80211_disassociate ieee80211_disassociate_rsl
353#define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
354#define ieee80211_stop_scan ieee80211_stop_scan_rsl
355#define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
356#define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
357#define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
358
359#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
360#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
361#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
362#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
363#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
364#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
365#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
366#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
367#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
368#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
369#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
370#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
371#define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
372#define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
373#define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
374#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
375#define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
376#define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
377
378#define ieee80211_txb_free ieee80211_txb_free_rsl
379
380#define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
381#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
382#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
383#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
384#if WIRELESS_EXT >= 18
385#define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
386#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
387#define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
388#define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
389#endif
390
391
392typedef struct ieee_param {
393 u32 cmd;
394 u8 sta_addr[ETH_ALEN];
395 union {
396 struct {
397 u8 name;
398 u32 value;
399 } wpa_param;
400 struct {
401 u32 len;
402 u8 reserved[32];
403 u8 data[0];
404 } wpa_ie;
405 struct{
406 int command;
407 int reason_code;
408 } mlme;
409 struct {
410 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
411 u8 set_tx;
412 u32 err;
413 u8 idx;
414 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
415 u16 key_len;
416 u8 key[0];
417 } crypt;
418 } u;
419}ieee_param;
420
421
422#if WIRELESS_EXT < 17
423#define IW_QUAL_QUAL_INVALID 0x10
424#define IW_QUAL_LEVEL_INVALID 0x20
425#define IW_QUAL_NOISE_INVALID 0x40
426#define IW_QUAL_QUAL_UPDATED 0x1
427#define IW_QUAL_LEVEL_UPDATED 0x2
428#define IW_QUAL_NOISE_UPDATED 0x4
429#endif
430
431#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
432static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data)
433{
434 task->routine = func;
435 task->data = data;
436 //task->next = NULL;
437 INIT_LIST_HEAD(&task->list);
438 task->sync = 0;
439}
440#endif
441
442// linux under 2.6.9 release may not support it, so modify it for common use
443#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
444//#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
445#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
446static inline unsigned long msleep_interruptible_rsl(unsigned int msecs)
447{
448 unsigned long timeout = MSECS(msecs) + 1;
449
450 while (timeout) {
451 set_current_state(TASK_INTERRUPTIBLE);
452 timeout = schedule_timeout(timeout);
453 }
454 return timeout;
455}
456#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
457static inline void msleep(unsigned int msecs)
458{
459 unsigned long timeout = MSECS(msecs) + 1;
460
461 while (timeout) {
462 set_current_state(TASK_UNINTERRUPTIBLE);
463 timeout = schedule_timeout(timeout);
464 }
465}
466#endif
467#else
468#define MSECS(t) msecs_to_jiffies(t)
469#define msleep_interruptible_rsl msleep_interruptible
470#endif
471
472#define IEEE80211_DATA_LEN 2304
473/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
474 6.2.1.1.2.
475
476 The figure in section 7.1.2 suggests a body size of up to 2312
477 bytes is allowed, which is a bit confusing, I suspect this
478 represents the 2304 bytes of real data, plus a possible 8 bytes of
479 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
480#define IEEE80211_1ADDR_LEN 10
481#define IEEE80211_2ADDR_LEN 16
482#define IEEE80211_3ADDR_LEN 24
483#define IEEE80211_4ADDR_LEN 30
484#define IEEE80211_FCS_LEN 4
485#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
486#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
487#define IEEE80211_MGMT_HDR_LEN 24
488#define IEEE80211_DATA_HDR3_LEN 24
489#define IEEE80211_DATA_HDR4_LEN 30
490
491#define MIN_FRAG_THRESHOLD 256U
492#define MAX_FRAG_THRESHOLD 2346U
493
494
495/* Frame control field constants */
496#define IEEE80211_FCTL_VERS 0x0003
497#define IEEE80211_FCTL_FTYPE 0x000c
498#define IEEE80211_FCTL_STYPE 0x00f0
499#define IEEE80211_FCTL_FRAMETYPE 0x00fc
500#define IEEE80211_FCTL_TODS 0x0100
501#define IEEE80211_FCTL_FROMDS 0x0200
502#define IEEE80211_FCTL_DSTODS 0x0300 //added by david
503#define IEEE80211_FCTL_MOREFRAGS 0x0400
504#define IEEE80211_FCTL_RETRY 0x0800
505#define IEEE80211_FCTL_PM 0x1000
506#define IEEE80211_FCTL_MOREDATA 0x2000
507#define IEEE80211_FCTL_WEP 0x4000
508#define IEEE80211_FCTL_ORDER 0x8000
509
510#define IEEE80211_FTYPE_MGMT 0x0000
511#define IEEE80211_FTYPE_CTL 0x0004
512#define IEEE80211_FTYPE_DATA 0x0008
513
514/* management */
515#define IEEE80211_STYPE_ASSOC_REQ 0x0000
516#define IEEE80211_STYPE_ASSOC_RESP 0x0010
517#define IEEE80211_STYPE_REASSOC_REQ 0x0020
518#define IEEE80211_STYPE_REASSOC_RESP 0x0030
519#define IEEE80211_STYPE_PROBE_REQ 0x0040
520#define IEEE80211_STYPE_PROBE_RESP 0x0050
521#define IEEE80211_STYPE_BEACON 0x0080
522#define IEEE80211_STYPE_ATIM 0x0090
523#define IEEE80211_STYPE_DISASSOC 0x00A0
524#define IEEE80211_STYPE_AUTH 0x00B0
525#define IEEE80211_STYPE_DEAUTH 0x00C0
526#define IEEE80211_STYPE_MANAGE_ACT 0x00D0
527
528/* control */
529#define IEEE80211_STYPE_PSPOLL 0x00A0
530#define IEEE80211_STYPE_RTS 0x00B0
531#define IEEE80211_STYPE_CTS 0x00C0
532#define IEEE80211_STYPE_ACK 0x00D0
533#define IEEE80211_STYPE_CFEND 0x00E0
534#define IEEE80211_STYPE_CFENDACK 0x00F0
535#define IEEE80211_STYPE_BLOCKACK 0x0094
536
537/* data */
538#define IEEE80211_STYPE_DATA 0x0000
539#define IEEE80211_STYPE_DATA_CFACK 0x0010
540#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
541#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
542#define IEEE80211_STYPE_NULLFUNC 0x0040
543#define IEEE80211_STYPE_CFACK 0x0050
544#define IEEE80211_STYPE_CFPOLL 0x0060
545#define IEEE80211_STYPE_CFACKPOLL 0x0070
546#define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2
547#define IEEE80211_STYPE_QOS_NULL 0x00C0
548
549#define IEEE80211_SCTL_FRAG 0x000F
550#define IEEE80211_SCTL_SEQ 0xFFF0
551
552/* QOS control */
553#define IEEE80211_QCTL_TID 0x000F
554
555#define FC_QOS_BIT BIT7
556#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
557#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
558//added by wb. Is this right?
559#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA))
560#define Frame_Order(pframe) (*(u16*)pframe&IEEE80211_FCTL_ORDER)
561#define SN_LESS(a, b) (((a-b)&0x800)!=0)
562#define SN_EQUAL(a, b) (a == b)
563#define MAX_DEV_ADDR_SIZE 8
564typedef enum _ACT_CATEGORY{
565 ACT_CAT_QOS = 1,
566 ACT_CAT_DLS = 2,
567 ACT_CAT_BA = 3,
568 ACT_CAT_HT = 7,
569 ACT_CAT_WMM = 17,
570} ACT_CATEGORY, *PACT_CATEGORY;
571
572typedef enum _TS_ACTION{
573 ACT_ADDTSREQ = 0,
574 ACT_ADDTSRSP = 1,
575 ACT_DELTS = 2,
576 ACT_SCHEDULE = 3,
577} TS_ACTION, *PTS_ACTION;
578
579typedef enum _BA_ACTION{
580 ACT_ADDBAREQ = 0,
581 ACT_ADDBARSP = 1,
582 ACT_DELBA = 2,
583} BA_ACTION, *PBA_ACTION;
584
585typedef enum _InitialGainOpType{
586 IG_Backup=0,
587 IG_Restore,
588 IG_Max
589}InitialGainOpType;
590
591/* debug macros */
592#define CONFIG_IEEE80211_DEBUG
593#ifdef CONFIG_IEEE80211_DEBUG
594extern u32 ieee80211_debug_level;
595#define IEEE80211_DEBUG(level, fmt, args...) \
596do { if (ieee80211_debug_level & (level)) \
597 printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
598//wb added to debug out data buf
599//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
600#define IEEE80211_DEBUG_DATA(level, data, datalen) \
601 do{ if ((ieee80211_debug_level & (level)) == (level)) \
602 { \
603 int i; \
604 u8* pdata = (u8*) data; \
605 printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \
606 for(i=0; i<(int)(datalen); i++) \
607 { \
608 printk("%2x ", pdata[i]); \
609 if ((i+1)%16 == 0) printk("\n"); \
610 } \
611 printk("\n"); \
612 } \
613 } while (0)
614#else
615#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
616#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
617#endif /* CONFIG_IEEE80211_DEBUG */
618
619/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
620
ecdfa446
GKH
621/*
622 * To use the debug system;
623 *
624 * If you are defining a new debug classification, simply add it to the #define
625 * list here in the form of:
626 *
627 * #define IEEE80211_DL_xxxx VALUE
628 *
629 * shifting value to the left one bit from the previous entry. xxxx should be
630 * the name of the classification (for example, WEP)
631 *
632 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
633 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
634 * to send output to that classification.
635 *
636 * To add your debug level to the list of levels seen when you perform
637 *
638 * % cat /proc/net/ipw/debug_level
639 *
640 * you simply need to add your entry to the ipw_debug_levels array.
641 *
642 * If you do not see debug_level in /proc/net/ipw then you do not have
643 * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
644 *
645 */
646
647#define IEEE80211_DL_INFO (1<<0)
648#define IEEE80211_DL_WX (1<<1)
649#define IEEE80211_DL_SCAN (1<<2)
650#define IEEE80211_DL_STATE (1<<3)
651#define IEEE80211_DL_MGMT (1<<4)
652#define IEEE80211_DL_FRAG (1<<5)
653#define IEEE80211_DL_EAP (1<<6)
654#define IEEE80211_DL_DROP (1<<7)
655
656#define IEEE80211_DL_TX (1<<8)
657#define IEEE80211_DL_RX (1<<9)
658
659#define IEEE80211_DL_HT (1<<10) //HT
660#define IEEE80211_DL_BA (1<<11) //ba
661#define IEEE80211_DL_TS (1<<12) //TS
662#define IEEE80211_DL_QOS (1<<13)
663#define IEEE80211_DL_REORDER (1<<14)
664#define IEEE80211_DL_IOT (1<<15)
665#define IEEE80211_DL_IPS (1<<16)
666#define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen
667#define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out.
668#define IEEE80211_DL_ERR (1<<31) //always open
669#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
670#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
671#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
672
673#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
674#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
675#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
676#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
677#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
678#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
679#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
680#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
681#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
682#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
683
684#ifdef CONFIG_IEEE80211_DEBUG
685/* Added by Annie, 2005-11-22. */
686#define MAX_STR_LEN 64
687/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
688#define PRINTABLE(_ch) (_ch>'!' && _ch<'~')
689#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
690 if((_Comp) & level) \
691 { \
692 int __i; \
693 u8 buffer[MAX_STR_LEN]; \
694 int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
695 memset(buffer, 0, MAX_STR_LEN); \
696 memcpy(buffer, (u8 *)_Ptr, length ); \
697 for( __i=0; __i<MAX_STR_LEN; __i++ ) \
698 { \
699 if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
700 } \
701 buffer[length] = '\0'; \
702 printk("Rtl819x: "); \
703 printk(_TitleString); \
704 printk(": %d, <%s>\n", _Len, buffer); \
705 }
706#else
707#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0)
708#endif
709
710#include <linux/netdevice.h>
711#include <linux/if_arp.h> /* ARPHRD_ETHER */
712
713#ifndef WIRELESS_SPY
714#define WIRELESS_SPY // enable iwspy support
715#endif
716#include <net/iw_handler.h> // new driver API
717
718#ifndef ETH_P_PAE
719#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
720#endif /* ETH_P_PAE */
721
722#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
723
724#ifndef ETH_P_80211_RAW
725#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
726#endif
727
728/* IEEE 802.11 defines */
729
730#define P80211_OUI_LEN 3
731
732struct ieee80211_snap_hdr {
733
734 u8 dsap; /* always 0xAA */
735 u8 ssap; /* always 0xAA */
736 u8 ctrl; /* always 0x03 */
737 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
738
739} __attribute__ ((packed));
740
741#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
742
743#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
744#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
745#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
65a43784 746#define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA)
747
ecdfa446
GKH
748
749#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
750#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
751#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
752
753/* Authentication algorithms */
754#define WLAN_AUTH_OPEN 0
755#define WLAN_AUTH_SHARED_KEY 1
756#define WLAN_AUTH_LEAP 2
757
758#define WLAN_AUTH_CHALLENGE_LEN 128
759
760#define WLAN_CAPABILITY_BSS (1<<0)
761#define WLAN_CAPABILITY_IBSS (1<<1)
762#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
763#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
764#define WLAN_CAPABILITY_PRIVACY (1<<4)
765#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
766#define WLAN_CAPABILITY_PBCC (1<<6)
767#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
768#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
769#define WLAN_CAPABILITY_QOS (1<<9)
770#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
771#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
772
773/* 802.11g ERP information element */
774#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
775#define WLAN_ERP_USE_PROTECTION (1<<1)
776#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
777
778/* Status codes */
779enum ieee80211_statuscode {
780 WLAN_STATUS_SUCCESS = 0,
781 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
782 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
783 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
784 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
785 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
786 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
787 WLAN_STATUS_CHALLENGE_FAIL = 15,
788 WLAN_STATUS_AUTH_TIMEOUT = 16,
789 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
790 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
791 /* 802.11b */
792 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
793 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
794 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
795 /* 802.11h */
796 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
797 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
798 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
799 /* 802.11g */
800 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
801 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
802 /* 802.11i */
803 WLAN_STATUS_INVALID_IE = 40,
804 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
805 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
806 WLAN_STATUS_INVALID_AKMP = 43,
807 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
808 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
809 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
810};
811
812/* Reason codes */
813enum ieee80211_reasoncode {
814 WLAN_REASON_UNSPECIFIED = 1,
815 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
816 WLAN_REASON_DEAUTH_LEAVING = 3,
817 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
818 WLAN_REASON_DISASSOC_AP_BUSY = 5,
819 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
820 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
821 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
822 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
823 /* 802.11h */
824 WLAN_REASON_DISASSOC_BAD_POWER = 10,
825 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
826 /* 802.11i */
827 WLAN_REASON_INVALID_IE = 13,
828 WLAN_REASON_MIC_FAILURE = 14,
829 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
830 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
831 WLAN_REASON_IE_DIFFERENT = 17,
832 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
833 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
834 WLAN_REASON_INVALID_AKMP = 20,
835 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
836 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
837 WLAN_REASON_IEEE8021X_FAILED = 23,
838 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
839};
840
841#define IEEE80211_STATMASK_SIGNAL (1<<0)
842#define IEEE80211_STATMASK_RSSI (1<<1)
843#define IEEE80211_STATMASK_NOISE (1<<2)
844#define IEEE80211_STATMASK_RATE (1<<3)
845#define IEEE80211_STATMASK_WEMASK 0x7
846
847#define IEEE80211_CCK_MODULATION (1<<0)
848#define IEEE80211_OFDM_MODULATION (1<<1)
849
850#define IEEE80211_24GHZ_BAND (1<<0)
851#define IEEE80211_52GHZ_BAND (1<<1)
852
853#define IEEE80211_CCK_RATE_LEN 4
854#define IEEE80211_CCK_RATE_1MB 0x02
855#define IEEE80211_CCK_RATE_2MB 0x04
856#define IEEE80211_CCK_RATE_5MB 0x0B
857#define IEEE80211_CCK_RATE_11MB 0x16
858#define IEEE80211_OFDM_RATE_LEN 8
859#define IEEE80211_OFDM_RATE_6MB 0x0C
860#define IEEE80211_OFDM_RATE_9MB 0x12
861#define IEEE80211_OFDM_RATE_12MB 0x18
862#define IEEE80211_OFDM_RATE_18MB 0x24
863#define IEEE80211_OFDM_RATE_24MB 0x30
864#define IEEE80211_OFDM_RATE_36MB 0x48
865#define IEEE80211_OFDM_RATE_48MB 0x60
866#define IEEE80211_OFDM_RATE_54MB 0x6C
867#define IEEE80211_BASIC_RATE_MASK 0x80
868
869#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
870#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
871#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
872#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
873#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
874#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
875#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
876#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
877#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
878#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
879#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
880#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
881
882#define IEEE80211_CCK_RATES_MASK 0x0000000F
883#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
884 IEEE80211_CCK_RATE_2MB_MASK)
885#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
886 IEEE80211_CCK_RATE_5MB_MASK | \
887 IEEE80211_CCK_RATE_11MB_MASK)
888
889#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
890#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
891 IEEE80211_OFDM_RATE_12MB_MASK | \
892 IEEE80211_OFDM_RATE_24MB_MASK)
893#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
894 IEEE80211_OFDM_RATE_9MB_MASK | \
895 IEEE80211_OFDM_RATE_18MB_MASK | \
896 IEEE80211_OFDM_RATE_36MB_MASK | \
897 IEEE80211_OFDM_RATE_48MB_MASK | \
898 IEEE80211_OFDM_RATE_54MB_MASK)
899#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
900 IEEE80211_CCK_DEFAULT_RATES_MASK)
901
902#define IEEE80211_NUM_OFDM_RATES 8
903#define IEEE80211_NUM_CCK_RATES 4
904#define IEEE80211_OFDM_SHIFT_MASK_A 4
905
906
907/* this is stolen and modified from the madwifi driver*/
908#define IEEE80211_FC0_TYPE_MASK 0x0c
909#define IEEE80211_FC0_TYPE_DATA 0x08
910#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
911#define IEEE80211_FC0_SUBTYPE_QOS 0x80
912
913#define IEEE80211_QOS_HAS_SEQ(fc) \
914 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
915 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
916
917/* this is stolen from ipw2200 driver */
918#define IEEE_IBSS_MAC_HASH_SIZE 31
919struct ieee_ibss_seq {
920 u8 mac[ETH_ALEN];
921 u16 seq_num[17];
922 u16 frag_num[17];
923 unsigned long packet_time[17];
924 struct list_head list;
925};
926
927/* NOTE: This data is for statistical purposes; not all hardware provides this
928 * information for frames received. Not setting these will not cause
929 * any adverse affects. */
930struct ieee80211_rx_stats {
931#if 1
932 u32 mac_time[2];
933 s8 rssi;
934 u8 signal;
935 u8 noise;
936 u16 rate; /* in 100 kbps */
937 u8 received_channel;
938 u8 control;
939 u8 mask;
940 u8 freq;
941 u16 len;
942 u64 tsf;
943 u32 beacon_time;
944 u8 nic_type;
945 u16 Length;
946 // u8 DataRate; // In 0.5 Mbps
947 u8 SignalQuality; // in 0-100 index.
948 s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation.
949 s8 RxPower; // in dBm Translate from PWdB
950 u8 SignalStrength; // in 0-100 index.
951 u16 bHwError:1;
952 u16 bCRC:1;
953 u16 bICV:1;
954 u16 bShortPreamble:1;
955 u16 Antenna:1; //for rtl8185
956 u16 Decrypted:1; //for rtl8185, rtl8187
957 u16 Wakeup:1; //for rtl8185
958 u16 Reserved0:1; //for rtl8185
959 u8 AGC;
960 u32 TimeStampLow;
961 u32 TimeStampHigh;
962 bool bShift;
963 bool bIsQosData; // Added by Annie, 2005-12-22.
964 u8 UserPriority;
965
966 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
967 //1Attention Please!!!<11n or 8190 specific code should be put below this line>
968 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
969
970 u8 RxDrvInfoSize;
971 u8 RxBufShift;
972 bool bIsAMPDU;
973 bool bFirstMPDU;
974 bool bContainHTC;
975 bool RxIs40MHzPacket;
976 u32 RxPWDBAll;
977 u8 RxMIMOSignalStrength[4]; // in 0~100 index
978 s8 RxMIMOSignalQuality[2];
979 bool bPacketMatchBSSID;
980 bool bIsCCK;
981 bool bPacketToSelf;
982 //added by amy
983 u8* virtual_address;
984 u16 packetlength; // Total packet length: Must equal to sum of all FragLength
985 u16 fraglength; // FragLength should equal to PacketLength in non-fragment case
986 u16 fragoffset; // Data offset for this fragment
987 u16 ntotalfrag;
988 bool bisrxaggrsubframe;
989 bool bPacketBeacon; //cosa add for rssi
990 bool bToSelfBA; //cosa add for rssi
991 char cck_adc_pwdb[4]; //cosa add for rx path selection
992 u16 Seq_Num;
993#endif
994
995};
996
997/* IEEE 802.11 requires that STA supports concurrent reception of at least
998 * three fragmented frames. This define can be increased to support more
999 * concurrent frames, but it should be noted that each entry can consume about
1000 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
1001#define IEEE80211_FRAG_CACHE_LEN 4
1002
1003struct ieee80211_frag_entry {
1004 unsigned long first_frag_time;
1005 unsigned int seq;
1006 unsigned int last_frag;
1007 struct sk_buff *skb;
1008 u8 src_addr[ETH_ALEN];
1009 u8 dst_addr[ETH_ALEN];
1010};
1011
1012struct ieee80211_stats {
1013 unsigned int tx_unicast_frames;
1014 unsigned int tx_multicast_frames;
1015 unsigned int tx_fragments;
1016 unsigned int tx_unicast_octets;
1017 unsigned int tx_multicast_octets;
1018 unsigned int tx_deferred_transmissions;
1019 unsigned int tx_single_retry_frames;
1020 unsigned int tx_multiple_retry_frames;
1021 unsigned int tx_retry_limit_exceeded;
1022 unsigned int tx_discards;
1023 unsigned int rx_unicast_frames;
1024 unsigned int rx_multicast_frames;
1025 unsigned int rx_fragments;
1026 unsigned int rx_unicast_octets;
1027 unsigned int rx_multicast_octets;
1028 unsigned int rx_fcs_errors;
1029 unsigned int rx_discards_no_buffer;
1030 unsigned int tx_discards_wrong_sa;
1031 unsigned int rx_discards_undecryptable;
1032 unsigned int rx_message_in_msg_fragments;
1033 unsigned int rx_message_in_bad_msg_fragments;
1034};
1035
1036struct ieee80211_device;
1037
1038#include "ieee80211_crypt.h"
1039
1040#define SEC_KEY_1 (1<<0)
1041#define SEC_KEY_2 (1<<1)
1042#define SEC_KEY_3 (1<<2)
1043#define SEC_KEY_4 (1<<3)
1044#define SEC_ACTIVE_KEY (1<<4)
1045#define SEC_AUTH_MODE (1<<5)
1046#define SEC_UNICAST_GROUP (1<<6)
1047#define SEC_LEVEL (1<<7)
1048#define SEC_ENABLED (1<<8)
1049#define SEC_ENCRYPT (1<<9)
1050
1051#define SEC_LEVEL_0 0 /* None */
1052#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
1053#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
1054#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
1055#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
1056
1057#define SEC_ALG_NONE 0
1058#define SEC_ALG_WEP 1
1059#define SEC_ALG_TKIP 2
65a43784 1060#define SEC_ALG_CCMP 4
ecdfa446
GKH
1061
1062#define WEP_KEYS 4
1063#define WEP_KEY_LEN 13
1064#define SCM_KEY_LEN 32
1065#define SCM_TEMPORAL_KEY_LENGTH 16
1066
1067struct ieee80211_security {
1068 u16 active_key:2,
1069 enabled:1,
1070 auth_mode:2,
1071 auth_algo:4,
1072 unicast_uses_group:1,
1073 encrypt:1;
1074 u8 key_sizes[WEP_KEYS];
1075 u8 keys[WEP_KEYS][SCM_KEY_LEN];
1076 u8 level;
1077 u16 flags;
1078} __attribute__ ((packed));
1079
1080
1081/*
1082 802.11 data frame from AP
1083 ,-------------------------------------------------------------------.
1084Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1085 |------|------|---------|---------|---------|------|---------|------|
1086Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1087 | | tion | (BSSID) | | | ence | data | |
1088 `-------------------------------------------------------------------'
1089Total: 28-2340 bytes
1090*/
1091
1092/* Management Frame Information Element Types */
1093enum ieee80211_mfie {
1094 MFIE_TYPE_SSID = 0,
1095 MFIE_TYPE_RATES = 1,
1096 MFIE_TYPE_FH_SET = 2,
1097 MFIE_TYPE_DS_SET = 3,
1098 MFIE_TYPE_CF_SET = 4,
1099 MFIE_TYPE_TIM = 5,
1100 MFIE_TYPE_IBSS_SET = 6,
1101 MFIE_TYPE_COUNTRY = 7,
1102 MFIE_TYPE_HOP_PARAMS = 8,
1103 MFIE_TYPE_HOP_TABLE = 9,
1104 MFIE_TYPE_REQUEST = 10,
1105 MFIE_TYPE_CHALLENGE = 16,
1106 MFIE_TYPE_POWER_CONSTRAINT = 32,
1107 MFIE_TYPE_POWER_CAPABILITY = 33,
1108 MFIE_TYPE_TPC_REQUEST = 34,
1109 MFIE_TYPE_TPC_REPORT = 35,
1110 MFIE_TYPE_SUPP_CHANNELS = 36,
1111 MFIE_TYPE_CSA = 37,
1112 MFIE_TYPE_MEASURE_REQUEST = 38,
1113 MFIE_TYPE_MEASURE_REPORT = 39,
1114 MFIE_TYPE_QUIET = 40,
1115 MFIE_TYPE_IBSS_DFS = 41,
1116 MFIE_TYPE_ERP = 42,
1117 MFIE_TYPE_RSN = 48,
1118 MFIE_TYPE_RATES_EX = 50,
1119 MFIE_TYPE_HT_CAP= 45,
1120 MFIE_TYPE_HT_INFO= 61,
1121 MFIE_TYPE_AIRONET=133,
1122 MFIE_TYPE_GENERIC = 221,
1123 MFIE_TYPE_QOS_PARAMETER = 222,
1124};
1125
1126/* Minimal header; can be used for passing 802.11 frames with sufficient
1127 * information to determine what type of underlying data type is actually
1128 * stored in the data. */
65a43784 1129 struct ieee80211_pspoll_hdr {
1130 __le16 frame_ctl;
1131 __le16 aid;
1132 u8 bssid[ETH_ALEN];
1133 u8 ta[ETH_ALEN];
1134 //u8 payload[0];
1135} __attribute__ ((packed));
1136
ecdfa446
GKH
1137struct ieee80211_hdr {
1138 __le16 frame_ctl;
1139 __le16 duration_id;
1140 u8 payload[0];
1141} __attribute__ ((packed));
1142
1143struct ieee80211_hdr_1addr {
1144 __le16 frame_ctl;
1145 __le16 duration_id;
1146 u8 addr1[ETH_ALEN];
1147 u8 payload[0];
1148} __attribute__ ((packed));
1149
1150struct ieee80211_hdr_2addr {
1151 __le16 frame_ctl;
1152 __le16 duration_id;
1153 u8 addr1[ETH_ALEN];
1154 u8 addr2[ETH_ALEN];
1155 u8 payload[0];
1156} __attribute__ ((packed));
1157
1158struct ieee80211_hdr_3addr {
1159 __le16 frame_ctl;
1160 __le16 duration_id;
1161 u8 addr1[ETH_ALEN];
1162 u8 addr2[ETH_ALEN];
1163 u8 addr3[ETH_ALEN];
1164 __le16 seq_ctl;
1165 u8 payload[0];
1166} __attribute__ ((packed));
1167
1168struct ieee80211_hdr_4addr {
1169 __le16 frame_ctl;
1170 __le16 duration_id;
1171 u8 addr1[ETH_ALEN];
1172 u8 addr2[ETH_ALEN];
1173 u8 addr3[ETH_ALEN];
1174 __le16 seq_ctl;
1175 u8 addr4[ETH_ALEN];
1176 u8 payload[0];
1177} __attribute__ ((packed));
1178
1179struct ieee80211_hdr_3addrqos {
1180 __le16 frame_ctl;
1181 __le16 duration_id;
1182 u8 addr1[ETH_ALEN];
1183 u8 addr2[ETH_ALEN];
1184 u8 addr3[ETH_ALEN];
1185 __le16 seq_ctl;
1186 u8 payload[0];
1187 __le16 qos_ctl;
1188} __attribute__ ((packed));
1189
1190struct ieee80211_hdr_4addrqos {
1191 __le16 frame_ctl;
1192 __le16 duration_id;
1193 u8 addr1[ETH_ALEN];
1194 u8 addr2[ETH_ALEN];
1195 u8 addr3[ETH_ALEN];
1196 __le16 seq_ctl;
1197 u8 addr4[ETH_ALEN];
1198 u8 payload[0];
1199 __le16 qos_ctl;
1200} __attribute__ ((packed));
1201
1202struct ieee80211_info_element {
1203 u8 id;
1204 u8 len;
1205 u8 data[0];
1206} __attribute__ ((packed));
1207
1208struct ieee80211_authentication {
1209 struct ieee80211_hdr_3addr header;
1210 __le16 algorithm;
1211 __le16 transaction;
1212 __le16 status;
1213 /*challenge*/
1214 struct ieee80211_info_element info_element[0];
1215} __attribute__ ((packed));
1216
1217struct ieee80211_disassoc {
1218 struct ieee80211_hdr_3addr header;
1219 __le16 reason;
1220} __attribute__ ((packed));
1221
1222struct ieee80211_probe_request {
1223 struct ieee80211_hdr_3addr header;
1224 /* SSID, supported rates */
1225 struct ieee80211_info_element info_element[0];
1226} __attribute__ ((packed));
1227
1228struct ieee80211_probe_response {
1229 struct ieee80211_hdr_3addr header;
1230 u32 time_stamp[2];
1231 __le16 beacon_interval;
1232 __le16 capability;
1233 /* SSID, supported rates, FH params, DS params,
1234 * CF params, IBSS params, TIM (if beacon), RSN */
1235 struct ieee80211_info_element info_element[0];
1236} __attribute__ ((packed));
1237
1238/* Alias beacon for probe_response */
1239#define ieee80211_beacon ieee80211_probe_response
1240
1241struct ieee80211_assoc_request_frame {
1242 struct ieee80211_hdr_3addr header;
1243 __le16 capability;
1244 __le16 listen_interval;
1245 /* SSID, supported rates, RSN */
1246 struct ieee80211_info_element info_element[0];
1247} __attribute__ ((packed));
1248
1249struct ieee80211_reassoc_request_frame {
1250 struct ieee80211_hdr_3addr header;
1251 __le16 capability;
1252 __le16 listen_interval;
1253 u8 current_ap[ETH_ALEN];
1254 /* SSID, supported rates, RSN */
1255 struct ieee80211_info_element info_element[0];
1256} __attribute__ ((packed));
1257
1258struct ieee80211_assoc_response_frame {
1259 struct ieee80211_hdr_3addr header;
1260 __le16 capability;
1261 __le16 status;
1262 __le16 aid;
1263 struct ieee80211_info_element info_element[0]; /* supported rates */
1264} __attribute__ ((packed));
1265
1266struct ieee80211_txb {
1267 u8 nr_frags;
1268 u8 encrypted;
1269 u8 queue_index;
1270 u8 rts_included;
1271 u16 reserved;
1272 __le16 frag_size;
1273 __le16 payload_size;
1274 struct sk_buff *fragments[0];
1275};
1276
1277#define MAX_TX_AGG_COUNT 16
1278struct ieee80211_drv_agg_txb {
1279 u8 nr_drv_agg_frames;
1280 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1281}__attribute__((packed));
1282
1283#define MAX_SUBFRAME_COUNT 64
1284struct ieee80211_rxb {
1285 u8 nr_subframes;
1286 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1287 u8 dst[ETH_ALEN];
1288 u8 src[ETH_ALEN];
1289}__attribute__((packed));
1290
1291typedef union _frameqos {
1292 u16 shortdata;
1293 u8 chardata[2];
1294 struct {
1295 u16 tid:4;
1296 u16 eosp:1;
1297 u16 ack_policy:2;
1298 u16 reserved:1;
1299 u16 txop:8;
1300 }field;
1301}frameqos,*pframeqos;
1302
1303/* SWEEP TABLE ENTRIES NUMBER*/
1304#define MAX_SWEEP_TAB_ENTRIES 42
1305#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1306/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1307 * only use 8, and then use extended rates for the remaining supported
1308 * rates. Other APs, however, stick all of their supported rates on the
1309 * main rates information element... */
1310#define MAX_RATES_LENGTH ((u8)12)
1311#define MAX_RATES_EX_LENGTH ((u8)16)
1312#define MAX_NETWORK_COUNT 128
1313
1314#define MAX_CHANNEL_NUMBER 161
1315#define IEEE80211_SOFTMAC_SCAN_TIME 100
1316//(HZ / 2)
1317#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1318
1319#define CRC_LENGTH 4U
1320
1321#define MAX_WPA_IE_LEN 64
1322
1323#define NETWORK_EMPTY_ESSID (1<<0)
1324#define NETWORK_HAS_OFDM (1<<1)
1325#define NETWORK_HAS_CCK (1<<2)
1326
1327/* QoS structure */
1328#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1329#define NETWORK_HAS_QOS_INFORMATION (1<<4)
1330#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1331 NETWORK_HAS_QOS_INFORMATION)
1332/* 802.11h */
1333#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1334#define NETWORK_HAS_CSA (1<<6)
1335#define NETWORK_HAS_QUIET (1<<7)
1336#define NETWORK_HAS_IBSS_DFS (1<<8)
1337#define NETWORK_HAS_TPC_REPORT (1<<9)
1338
1339#define NETWORK_HAS_ERP_VALUE (1<<10)
1340
1341#define QOS_QUEUE_NUM 4
1342#define QOS_OUI_LEN 3
1343#define QOS_OUI_TYPE 2
1344#define QOS_ELEMENT_ID 221
1345#define QOS_OUI_INFO_SUB_TYPE 0
1346#define QOS_OUI_PARAM_SUB_TYPE 1
1347#define QOS_VERSION_1 1
1348#define QOS_AIFSN_MIN_VALUE 2
1349#if 1
1350struct ieee80211_qos_information_element {
1351 u8 elementID;
1352 u8 length;
1353 u8 qui[QOS_OUI_LEN];
1354 u8 qui_type;
1355 u8 qui_subtype;
1356 u8 version;
1357 u8 ac_info;
1358} __attribute__ ((packed));
1359
1360struct ieee80211_qos_ac_parameter {
1361 u8 aci_aifsn;
1362 u8 ecw_min_max;
1363 __le16 tx_op_limit;
1364} __attribute__ ((packed));
1365
1366struct ieee80211_qos_parameter_info {
1367 struct ieee80211_qos_information_element info_element;
1368 u8 reserved;
1369 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1370} __attribute__ ((packed));
1371
1372struct ieee80211_qos_parameters {
1373 __le16 cw_min[QOS_QUEUE_NUM];
1374 __le16 cw_max[QOS_QUEUE_NUM];
1375 u8 aifs[QOS_QUEUE_NUM];
1376 u8 flag[QOS_QUEUE_NUM];
1377 __le16 tx_op_limit[QOS_QUEUE_NUM];
1378} __attribute__ ((packed));
1379
1380struct ieee80211_qos_data {
1381 struct ieee80211_qos_parameters parameters;
1382 int active;
1383 int supported;
1384 u8 param_count;
1385 u8 old_param_count;
1386};
1387
1388struct ieee80211_tim_parameters {
1389 u8 tim_count;
1390 u8 tim_period;
1391} __attribute__ ((packed));
1392
1393//#else
1394struct ieee80211_wmm_ac_param {
1395 u8 ac_aci_acm_aifsn;
1396 u8 ac_ecwmin_ecwmax;
1397 u16 ac_txop_limit;
1398};
1399
1400struct ieee80211_wmm_ts_info {
1401 u8 ac_dir_tid;
1402 u8 ac_up_psb;
1403 u8 reserved;
1404} __attribute__ ((packed));
1405
1406struct ieee80211_wmm_tspec_elem {
1407 struct ieee80211_wmm_ts_info ts_info;
1408 u16 norm_msdu_size;
1409 u16 max_msdu_size;
1410 u32 min_serv_inter;
1411 u32 max_serv_inter;
1412 u32 inact_inter;
1413 u32 suspen_inter;
1414 u32 serv_start_time;
1415 u32 min_data_rate;
1416 u32 mean_data_rate;
1417 u32 peak_data_rate;
1418 u32 max_burst_size;
1419 u32 delay_bound;
1420 u32 min_phy_rate;
1421 u16 surp_band_allow;
1422 u16 medium_time;
1423}__attribute__((packed));
1424#endif
1425enum eap_type {
1426 EAP_PACKET = 0,
1427 EAPOL_START,
1428 EAPOL_LOGOFF,
1429 EAPOL_KEY,
1430 EAPOL_ENCAP_ASF_ALERT
1431};
1432
1433static const char *eap_types[] = {
1434 [EAP_PACKET] = "EAP-Packet",
1435 [EAPOL_START] = "EAPOL-Start",
1436 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1437 [EAPOL_KEY] = "EAPOL-Key",
1438 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1439};
1440
1441static inline const char *eap_get_type(int type)
1442{
1443 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1444}
1445//added by amy for reorder
1446static inline u8 Frame_QoSTID(u8* buf)
1447{
1448 struct ieee80211_hdr_3addr *hdr;
1449 u16 fc;
1450 hdr = (struct ieee80211_hdr_3addr *)buf;
1451 fc = le16_to_cpu(hdr->frame_ctl);
1452 return (u8)((frameqos*)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid;
1453}
1454
1455//added by amy for reorder
1456
1457struct eapol {
1458 u8 snap[6];
1459 u16 ethertype;
1460 u8 version;
1461 u8 type;
1462 u16 length;
1463} __attribute__ ((packed));
1464
1465struct ieee80211_softmac_stats{
1466 unsigned int rx_ass_ok;
1467 unsigned int rx_ass_err;
1468 unsigned int rx_probe_rq;
1469 unsigned int tx_probe_rs;
1470 unsigned int tx_beacons;
1471 unsigned int rx_auth_rq;
1472 unsigned int rx_auth_rs_ok;
1473 unsigned int rx_auth_rs_err;
1474 unsigned int tx_auth_rq;
1475 unsigned int no_auth_rs;
1476 unsigned int no_ass_rs;
1477 unsigned int tx_ass_rq;
1478 unsigned int rx_ass_rq;
1479 unsigned int tx_probe_rq;
1480 unsigned int reassoc;
1481 unsigned int swtxstop;
1482 unsigned int swtxawake;
1483 unsigned char CurrentShowTxate;
1484 unsigned char last_packet_rate;
1485 unsigned int txretrycount;
1486};
1487
1488#define BEACON_PROBE_SSID_ID_POSITION 12
1489
1490struct ieee80211_info_element_hdr {
1491 u8 id;
1492 u8 len;
1493} __attribute__ ((packed));
1494
1495/*
1496 * These are the data types that can make up management packets
1497 *
1498 u16 auth_algorithm;
1499 u16 auth_sequence;
1500 u16 beacon_interval;
1501 u16 capability;
1502 u8 current_ap[ETH_ALEN];
1503 u16 listen_interval;
1504 struct {
1505 u16 association_id:14, reserved:2;
1506 } __attribute__ ((packed));
1507 u32 time_stamp[2];
1508 u16 reason;
1509 u16 status;
1510*/
1511
1512#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
1513#define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
1514
1515enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1516#define MAX_SP_Len (WMM_all_frame << 4)
1517#define IEEE80211_QOS_TID 0x0f
1518#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1519
1520#define IEEE80211_DTIM_MBCAST 4
1521#define IEEE80211_DTIM_UCAST 2
1522#define IEEE80211_DTIM_VALID 1
1523#define IEEE80211_DTIM_INVALID 0
1524
1525#define IEEE80211_PS_DISABLED 0
1526#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
1527#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
1528
1529//added by David for QoS 2006/6/30
1530//#define WMM_Hang_8187
1531#ifdef WMM_Hang_8187
1532#undef WMM_Hang_8187
1533#endif
1534
1535#define WME_AC_BK 0x00
1536#define WME_AC_BE 0x01
1537#define WME_AC_VI 0x02
1538#define WME_AC_VO 0x03
1539#define WME_ACI_MASK 0x03
1540#define WME_AIFSN_MASK 0x03
1541#define WME_AC_PRAM_LEN 16
1542
1543#define MAX_RECEIVE_BUFFER_SIZE 9100
1544
1545//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
1546//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
1547#if 1
1548#define UP2AC(up) ( \
1549 ((up) < 1) ? WME_AC_BE : \
1550 ((up) < 3) ? WME_AC_BK : \
1551 ((up) < 4) ? WME_AC_BE : \
1552 ((up) < 6) ? WME_AC_VI : \
1553 WME_AC_VO)
1554#endif
1555//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
1556#define AC2UP(_ac) ( \
1557 ((_ac) == WME_AC_VO) ? 6 : \
1558 ((_ac) == WME_AC_VI) ? 5 : \
1559 ((_ac) == WME_AC_BK) ? 1 : \
1560 0)
1561
1562#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1563#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
1564
1565struct ether_header {
1566 u8 ether_dhost[ETHER_ADDR_LEN];
1567 u8 ether_shost[ETHER_ADDR_LEN];
1568 u16 ether_type;
1569} __attribute__((packed));
1570
1571#ifndef ETHERTYPE_PAE
1572#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1573#endif
1574#ifndef ETHERTYPE_IP
1575#define ETHERTYPE_IP 0x0800 /* IP protocol */
1576#endif
1577
1578typedef struct _bss_ht{
1579
1580 bool support_ht;
1581
1582 // HT related elements
1583 u8 ht_cap_buf[32];
1584 u16 ht_cap_len;
1585 u8 ht_info_buf[32];
1586 u16 ht_info_len;
1587
1588 HT_SPEC_VER ht_spec_ver;
1589 //HT_CAPABILITY_ELE bdHTCapEle;
1590 //HT_INFORMATION_ELE bdHTInfoEle;
1591
1592 bool aggregation;
1593 bool long_slot_time;
1594}bss_ht, *pbss_ht;
1595
1596typedef enum _erp_t{
1597 ERP_NonERPpresent = 0x01,
1598 ERP_UseProtection = 0x02,
1599 ERP_BarkerPreambleMode = 0x04,
1600} erp_t;
1601
1602
1603struct ieee80211_network {
1604 /* These entries are used to identify a unique network */
1605 u8 bssid[ETH_ALEN];
1606 u8 channel;
1607 /* Ensure null-terminated for any debug msgs */
1608 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1609 u8 ssid_len;
1610#if 1
1611 struct ieee80211_qos_data qos_data;
1612#else
1613 // Qos related. Added by Annie, 2005-11-01.
1614 BSS_QOS BssQos;
1615#endif
1616
1617 //added by amy for LEAP
1618 bool bWithAironetIE;
1619 bool bCkipSupported;
1620 bool bCcxRmEnable;
1621 u16 CcxRmState[2];
1622 // CCXv4 S59, MBSSID.
1623 bool bMBssidValid;
1624 u8 MBssidMask;
1625 u8 MBssid[6];
1626 // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
1627 bool bWithCcxVerNum;
1628 u8 BssCcxVerNumber;
1629 /* These are network statistics */
1630 struct ieee80211_rx_stats stats;
1631 u16 capability;
1632 u8 rates[MAX_RATES_LENGTH];
1633 u8 rates_len;
1634 u8 rates_ex[MAX_RATES_EX_LENGTH];
1635 u8 rates_ex_len;
1636 unsigned long last_scanned;
1637 u8 mode;
1638 u32 flags;
1639 u32 last_associate;
1640 u32 time_stamp[2];
1641 u16 beacon_interval;
1642 u16 listen_interval;
1643 u16 atim_window;
1644 u8 erp_value;
1645 u8 wpa_ie[MAX_WPA_IE_LEN];
1646 size_t wpa_ie_len;
1647 u8 rsn_ie[MAX_WPA_IE_LEN];
1648 size_t rsn_ie_len;
1649
1650 struct ieee80211_tim_parameters tim;
1651 u8 dtim_period;
1652 u8 dtim_data;
1653 u32 last_dtim_sta_time[2];
1654
1655 //appeded for QoS
1656 u8 wmm_info;
1657 struct ieee80211_wmm_ac_param wmm_param[4];
1658 u8 QoS_Enable;
1659#ifdef THOMAS_TURBO
1660 u8 Turbo_Enable;//enable turbo mode, added by thomas
1661#endif
1662#ifdef ENABLE_DOT11D
1663 u16 CountryIeLen;
1664 u8 CountryIeBuf[MAX_IE_LEN];
1665#endif
1666 // HT Related, by amy, 2008.04.29
1667 BSS_HT bssht;
1668 // Add to handle broadcom AP management frame CCK rate.
1669 bool broadcom_cap_exist;
1670 bool ralink_cap_exist;
1671 bool atheros_cap_exist;
1672 bool cisco_cap_exist;
65a43784 1673 bool marvell_cap_exist;
ecdfa446
GKH
1674 bool unknown_cap_exist;
1675// u8 berp_info;
1676 bool berp_info_valid;
1677 bool buseprotection;
1678 //put at the end of the structure.
1679 struct list_head list;
1680};
1681
1682#if 1
1683enum ieee80211_state {
1684
1685 /* the card is not linked at all */
1686 IEEE80211_NOLINK = 0,
1687
1688 /* IEEE80211_ASSOCIATING* are for BSS client mode
1689 * the driver shall not perform RX filtering unless
1690 * the state is LINKED.
1691 * The driver shall just check for the state LINKED and
1692 * defaults to NOLINK for ALL the other states (including
1693 * LINKED_SCANNING)
1694 */
1695
1696 /* the association procedure will start (wq scheduling)*/
1697 IEEE80211_ASSOCIATING,
1698 IEEE80211_ASSOCIATING_RETRY,
1699
1700 /* the association procedure is sending AUTH request*/
1701 IEEE80211_ASSOCIATING_AUTHENTICATING,
1702
1703 /* the association procedure has successfully authentcated
1704 * and is sending association request
1705 */
1706 IEEE80211_ASSOCIATING_AUTHENTICATED,
1707
1708 /* the link is ok. the card associated to a BSS or linked
1709 * to a ibss cell or acting as an AP and creating the bss
1710 */
1711 IEEE80211_LINKED,
1712
1713 /* same as LINKED, but the driver shall apply RX filter
1714 * rules as we are in NO_LINK mode. As the card is still
1715 * logically linked, but it is doing a syncro site survey
1716 * then it will be back to LINKED state.
1717 */
1718 IEEE80211_LINKED_SCANNING,
1719
1720};
1721#else
1722enum ieee80211_state {
1723 IEEE80211_UNINITIALIZED = 0,
1724 IEEE80211_INITIALIZED,
1725 IEEE80211_ASSOCIATING,
1726 IEEE80211_ASSOCIATED,
1727 IEEE80211_AUTHENTICATING,
1728 IEEE80211_AUTHENTICATED,
1729 IEEE80211_SHUTDOWN
1730};
1731#endif
1732
1733#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1734#define DEFAULT_FTS 2346
1735
1736#define CFG_IEEE80211_RESERVE_FCS (1<<0)
1737#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1738#define CFG_IEEE80211_RTS (1<<2)
1739
1740#define IEEE80211_24GHZ_MIN_CHANNEL 1
1741#define IEEE80211_24GHZ_MAX_CHANNEL 14
1742#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1743 IEEE80211_24GHZ_MIN_CHANNEL + 1)
1744
1745#define IEEE80211_52GHZ_MIN_CHANNEL 34
1746#define IEEE80211_52GHZ_MAX_CHANNEL 165
1747#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1748 IEEE80211_52GHZ_MIN_CHANNEL + 1)
1749
1750#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
1751extern inline int is_multicast_ether_addr(const u8 *addr)
1752{
1753 return ((addr[0] != 0xff) && (0x01 & addr[0]));
1754}
1755#endif
1756
1757#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
1758extern inline int is_broadcast_ether_addr(const u8 *addr)
1759{
1760 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
1761 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
1762}
1763#endif
1764
1765typedef struct tx_pending_t{
1766 int frag;
1767 struct ieee80211_txb *txb;
1768}tx_pending_t;
1769
1770typedef struct _bandwidth_autoswitch
1771{
1772 long threshold_20Mhzto40Mhz;
1773 long threshold_40Mhzto20Mhz;
1774 bool bforced_tx20Mhz;
1775 bool bautoswitch_enable;
1776}bandwidth_autoswitch,*pbandwidth_autoswitch;
1777
1778
1779//added by amy for order
1780
1781#define REORDER_WIN_SIZE 128
1782#define REORDER_ENTRY_NUM 128
1783typedef struct _RX_REORDER_ENTRY
1784{
1785 struct list_head List;
1786 u16 SeqNum;
1787 struct ieee80211_rxb* prxb;
1788} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
1789//added by amy for order
1790typedef enum _Fsync_State{
1791 Default_Fsync,
1792 HW_Fsync,
1793 SW_Fsync
1794}Fsync_State;
1795
1796// Power save mode configured.
1797typedef enum _RT_PS_MODE
1798{
1799 eActive, // Active/Continuous access.
1800 eMaxPs, // Max power save mode.
1801 eFastPs // Fast power save mode.
1802}RT_PS_MODE;
1803
1804typedef enum _IPS_CALLBACK_FUNCION
1805{
1806 IPS_CALLBACK_NONE = 0,
1807 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1808 IPS_CALLBACK_JOIN_REQUEST = 2,
1809}IPS_CALLBACK_FUNCION;
1810
1811typedef enum _RT_JOIN_ACTION{
1812 RT_JOIN_INFRA = 1,
1813 RT_JOIN_IBSS = 2,
1814 RT_START_IBSS = 3,
1815 RT_NO_ACTION = 4,
1816}RT_JOIN_ACTION;
1817
1818typedef struct _IbssParms{
1819 u16 atimWin;
1820}IbssParms, *PIbssParms;
1821#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko.
1822
1823// RF state.
1824typedef enum _RT_RF_POWER_STATE
1825{
1826 eRfOn,
1827 eRfSleep,
1828 eRfOff
1829}RT_RF_POWER_STATE;
1830
1831typedef struct _RT_POWER_SAVE_CONTROL
1832{
1833
1834 //
1835 // Inactive Power Save(IPS) : Disable RF when disconnected
1836 //
1837 bool bInactivePs;
1838 bool bIPSModeBackup;
1839 bool bSwRfProcessing;
1840 RT_RF_POWER_STATE eInactivePowerState;
1841#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
1842 struct work_struct InactivePsWorkItem;
1843#else
1844 struct tq_struct InactivePsWorkItem;
1845#endif
1846 struct timer_list InactivePsTimer;
1847
1848 // Return point for join action
1849 IPS_CALLBACK_FUNCION ReturnPoint;
1850
1851 // Recored Parameters for rescheduled JoinRequest
1852 bool bTmpBssDesc;
1853 RT_JOIN_ACTION tmpJoinAction;
1854 struct ieee80211_network tmpBssDesc;
1855
1856 // Recored Parameters for rescheduled MgntLinkRequest
1857 bool bTmpScanOnly;
1858 bool bTmpActiveScan;
1859 bool bTmpFilterHiddenAP;
1860 bool bTmpUpdateParms;
1861 u8 tmpSsidBuf[33];
1862 OCTET_STRING tmpSsid2Scan;
1863 bool bTmpSsid2Scan;
1864 u8 tmpNetworkType;
1865 u8 tmpChannelNumber;
1866 u16 tmpBcnPeriod;
1867 u8 tmpDtimPeriod;
1868 u16 tmpmCap;
1869 OCTET_STRING tmpSuppRateSet;
1870 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1871 bool bTmpSuppRate;
1872 IbssParms tmpIbpm;
1873 bool bTmpIbpm;
1874
1875 //
1876 // Leisre Poswer Save : Disable RF if connected but traffic is not busy
1877 //
1878 bool bLeisurePs;
65a43784 1879 u32 PowerProfile;
1880 u8 LpsIdleCount;
1881 u8 RegMaxLPSAwakeIntvl;
1882 u8 LPSAwakeIntvl;
1883
1884 u32 CurPsLevel;
1885 u32 RegRfPsLevel;
1886
1887 bool bFwCtrlLPS;
1888 u8 FWCtrlPSMode;
1889
1890 bool LinkReqInIPSRFOffPgs;
1891 bool BufConnectinfoBefore;
ecdfa446
GKH
1892
1893}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;
1894
1895typedef u32 RT_RF_CHANGE_SOURCE;
1896#define RF_CHANGE_BY_SW BIT31
1897#define RF_CHANGE_BY_HW BIT30
1898#define RF_CHANGE_BY_PS BIT29
1899#define RF_CHANGE_BY_IPS BIT28
1900#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
1901
1902#ifdef ENABLE_DOT11D
1903typedef enum
1904{
1905 COUNTRY_CODE_FCC = 0,
1906 COUNTRY_CODE_IC = 1,
1907 COUNTRY_CODE_ETSI = 2,
1908 COUNTRY_CODE_SPAIN = 3,
1909 COUNTRY_CODE_FRANCE = 4,
1910 COUNTRY_CODE_MKK = 5,
1911 COUNTRY_CODE_MKK1 = 6,
1912 COUNTRY_CODE_ISRAEL = 7,
1913 COUNTRY_CODE_TELEC,
1914 COUNTRY_CODE_MIC,
1915 COUNTRY_CODE_GLOBAL_DOMAIN
1916}country_code_type_t;
1917#endif
1918
1919#define RT_MAX_LD_SLOT_NUM 10
1920typedef struct _RT_LINK_DETECT_T{
1921
1922 u32 NumRecvBcnInPeriod;
1923 u32 NumRecvDataInPeriod;
1924
1925 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status
1926 u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status
1927 u16 SlotNum; // number of CheckForHang period to determine link status
1928 u16 SlotIndex;
1929
1930 u32 NumTxOkInPeriod;
1931 u32 NumRxOkInPeriod;
65a43784 1932 u32 NumRxUnicastOkInPeriod;
ecdfa446
GKH
1933 bool bBusyTraffic;
1934}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
1935
65a43784 1936//added by amy 090330
1937typedef enum _HW_VARIABLES{
1938 HW_VAR_ETHER_ADDR,
1939 HW_VAR_MULTICAST_REG,
1940 HW_VAR_BASIC_RATE,
1941 HW_VAR_BSSID,
1942 HW_VAR_MEDIA_STATUS,
1943 HW_VAR_SECURITY_CONF,
1944 HW_VAR_BEACON_INTERVAL,
1945 HW_VAR_ATIM_WINDOW,
1946 HW_VAR_LISTEN_INTERVAL,
1947 HW_VAR_CS_COUNTER,
1948 HW_VAR_DEFAULTKEY0,
1949 HW_VAR_DEFAULTKEY1,
1950 HW_VAR_DEFAULTKEY2,
1951 HW_VAR_DEFAULTKEY3,
1952 HW_VAR_SIFS,
1953 HW_VAR_DIFS,
1954 HW_VAR_EIFS,
1955 HW_VAR_SLOT_TIME,
1956 HW_VAR_ACK_PREAMBLE,
1957 HW_VAR_CW_CONFIG,
1958 HW_VAR_CW_VALUES,
1959 HW_VAR_RATE_FALLBACK_CONTROL,
1960 HW_VAR_CONTENTION_WINDOW,
1961 HW_VAR_RETRY_COUNT,
1962 HW_VAR_TR_SWITCH,
1963 HW_VAR_COMMAND, // For Command Register, Annie, 2006-04-07.
1964 HW_VAR_WPA_CONFIG, //2004/08/23, kcwu, for 8187 Security config
1965 HW_VAR_AMPDU_MIN_SPACE, // The spacing between sub-frame. Roger, 2008.07.04.
1966 HW_VAR_SHORTGI_DENSITY, // The density for shortGI. Roger, 2008.07.04.
1967 HW_VAR_AMPDU_FACTOR,
1968 HW_VAR_MCS_RATE_AVAILABLE,
1969 HW_VAR_AC_PARAM, // For AC Parameters, 2005.12.01, by rcnjko.
1970 HW_VAR_ACM_CTRL, // For ACM Control, Annie, 2005-12-13.
1971 HW_VAR_DIS_Req_Qsize, // For DIS_Reg_Qsize, Joseph
1972 HW_VAR_CCX_CHNL_LOAD, // For CCX 2 channel load request, 2006.05.04.
1973 HW_VAR_CCX_NOISE_HISTOGRAM, // For CCX 2 noise histogram request, 2006.05.04.
1974 HW_VAR_CCX_CLM_NHM, // For CCX 2 parallel channel load request and noise histogram request, 2006.05.12.
1975 HW_VAR_TxOPLimit, // For turbo mode related settings, added by Roger, 2006.12.07
1976 HW_VAR_TURBO_MODE, // For turbo mode related settings, added by Roger, 2006.12.15.
1977 HW_VAR_RF_STATE, // For change or query RF power state, 061214, rcnjko.
1978 HW_VAR_RF_OFF_BY_HW, // For UI to query if external HW signal disable RF, 061229, rcnjko.
1979 HW_VAR_BUS_SPEED, // In unit of bps. 2006.07.03, by rcnjko.
1980 HW_VAR_SET_DEV_POWER, // Set to low power, added by LanHsin, 2007.
1981
1982 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
1983 //1Attention Please!!!<11n or 8190 specific code should be put below this line>
1984 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
1985 HW_VAR_RCR, //for RCR, David 2006,05,11
1986 HW_VAR_RATR_0,
1987 HW_VAR_RRSR,
1988 HW_VAR_CPU_RST,
1989 HW_VAR_CECHK_BSSID,
1990 HW_VAR_LBK_MODE, // Set lookback mode, 2008.06.11. added by Roger.
1991 // Set HW related setting for 11N AES bug.
1992 HW_VAR_AES_11N_FIX,
1993 // Set Usb Rx Aggregation
1994 HW_VAR_USB_RX_AGGR,
1995 HW_VAR_USER_CONTROL_TURBO_MODE,
1996 HW_VAR_RETRY_LIMIT,
1997#ifndef _RTL8192_EXT_PATCH_
1998 HW_VAR_INIT_TX_RATE, //Get Current Tx rate register. 2008.12.10. Added by tynli
1999#endif
2000 HW_VAR_TX_RATE_REG, //Get Current Tx rate register. 2008.12.10. Added by tynli
2001 HW_VAR_EFUSE_USAGE, //Get current EFUSE utilization. 2008.12.19. Added by Roger.
2002 HW_VAR_EFUSE_BYTES,
2003 HW_VAR_AUTOLOAD_STATUS, //Get current autoload status, 0: autoload success, 1: autoload fail. 2008.12.19. Added by Roger.
2004 HW_VAR_RF_2R_DISABLE, // 2R disable
2005 HW_VAR_SET_RPWM,
2006 HW_VAR_H2C_FW_PWRMODE, // For setting FW related H2C cmd structure. by tynli. 2009.2.18
2007 HW_VAR_H2C_FW_JOINBSSRPT, // For setting FW related H2C cmd structure. by tynli. 2009.2.18
2008 HW_VAR_1X1_RECV_COMBINE, // For 1T2R but only 1SS, Add by hpfan 2009.04.16 hpfan
2009 HW_VAR_STOP_SEND_BEACON,
2010 HW_VAR_TSF_TIMER, // Read from TSF register to get the current TSF timer, by Bruce, 2009-07-22.
2011 HW_VAR_IO_CMD,
2012 HW_VAR_HANDLE_FW_C2H, //Added by tynli. For handling FW C2H command. 2009.10.07.
2013 HW_VAR_DL_FW_RSVD_PAGE, //Added by tynli. Download the packets that FW will use to RSVD page. 2009.10.14.
2014 HW_VAR_AID, //Added by tynli.
2015 HW_VAR_HW_SEQ_ENABLE, //Added by tynli. 2009.10.20.
2016 HW_VAR_UPDATE_TSF, //Added by tynli. 2009.10.22. For Hw count TBTT time.
2017 HW_VAR_BCN_VALID, //Added by tynli.
2018 HW_VAR_FWLPS_RF_ON //Added by tynli. 2009.11.09. For checking if Fw finishs RF on sequence.
2019}HW_VARIABLES;
2020
2021#define RT_CHECK_FOR_HANG_PERIOD 2
ecdfa446
GKH
2022
2023struct ieee80211_device {
2024 struct net_device *dev;
2025 struct ieee80211_security sec;
2026
65a43784 2027 bool need_sw_enc;
2028#ifdef ENABLE_LPS
2029 bool bAwakePktSent;
2030 u8 LPSDelayCnt;
2031 bool bIsAggregateFrame;
2032 bool polling;
2033 void (*LeisurePSLeave)(struct net_device *dev);
2034#endif
2035
2036#ifdef ENABLE_IPS
2037 bool proto_stoppping;
2038 bool wx_set_enc;
2039 struct semaphore ips_sem;
2040 struct work_struct ips_leave_wq;
2041 void (*ieee80211_ips_leave_wq) (struct net_device *dev);
2042 void (*ieee80211_ips_leave)(struct net_device *dev);
2043#endif
2044 void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2045 u8 (*rtllib_ap_sec_type)(struct ieee80211_device *ieee);
2046
ecdfa446
GKH
2047 //hw security related
2048// u8 hwsec_support; //support?
2049 u8 hwsec_active; //hw security active.
2050 bool is_silent_reset;
2051 bool is_roaming;
2052 bool ieee_up;
2053 //added by amy
2054 bool bSupportRemoteWakeUp;
2055 RT_PS_MODE dot11PowerSaveMode; // Power save mode configured.
2056 bool actscanning;
2057 bool beinretry;
2058 RT_RF_POWER_STATE eRFPowerState;
2059 RT_RF_CHANGE_SOURCE RfOffReason;
2060 bool is_set_key;
2061 //11n spec related I wonder if These info structure need to be moved out of ieee80211_device
2062
2063 //11n HT below
2064 PRT_HIGH_THROUGHPUT pHTInfo;
2065 //struct timer_list SwBwTimer;
2066// spinlock_t chnlop_spinlock;
2067 spinlock_t bw_spinlock;
2068
2069 spinlock_t reorder_spinlock;
2070 // for HT operation rate set. we use this one for HT data rate to seperate different descriptors
2071 //the way fill this is the same as in the IE
2072 u8 Regdot11HTOperationalRateSet[16]; //use RATR format
2073 u8 dot11HTOperationalRateSet[16]; //use RATR format
2074 u8 RegHTSuppRateSet[16];
2075 u8 HTCurrentOperaRate;
2076 u8 HTHighestOperaRate;
2077 //wb added for rate operation mode to firmware
2078 u8 bTxDisableRateFallBack;
2079 u8 bTxUseDriverAssingedRate;
2080 atomic_t atm_chnlop;
2081 atomic_t atm_swbw;
2082// u8 HTHighestOperaRate;
2083// u8 HTCurrentOperaRate;
2084
2085 // 802.11e and WMM Traffic Stream Info (TX)
2086 struct list_head Tx_TS_Admit_List;
2087 struct list_head Tx_TS_Pending_List;
2088 struct list_head Tx_TS_Unused_List;
2089 TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
2090 // 802.11e and WMM Traffic Stream Info (RX)
2091 struct list_head Rx_TS_Admit_List;
2092 struct list_head Rx_TS_Pending_List;
2093 struct list_head Rx_TS_Unused_List;
2094 RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
2095//#ifdef TO_DO_LIST
2096 RX_REORDER_ENTRY RxReorderEntry[128];
2097 struct list_head RxReorder_Unused_List;
2098//#endif
2099 // Qos related. Added by Annie, 2005-11-01.
2100// PSTA_QOS pStaQos;
2101 u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.)
2102
2103
2104 /* Bookkeeping structures */
2105 struct net_device_stats stats;
2106 struct ieee80211_stats ieee_stats;
2107 struct ieee80211_softmac_stats softmac_stats;
2108
2109 /* Probe / Beacon management */
2110 struct list_head network_free_list;
2111 struct list_head network_list;
2112 struct ieee80211_network *networks;
2113 int scans;
2114 int scan_age;
2115
2116 int iw_mode; /* operating mode (IW_MODE_*) */
2117 struct iw_spy_data spy_data;
2118
2119 spinlock_t lock;
2120 spinlock_t wpax_suitlist_lock;
2121
2122 int tx_headroom; /* Set to size of any additional room needed at front
2123 * of allocated Tx SKBs */
2124 u32 config;
2125
2126 /* WEP and other encryption related settings at the device level */
2127 int open_wep; /* Set to 1 to allow unencrypted frames */
2128 int auth_mode;
2129 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2130 * WEP key changes */
2131
2132 /* If the host performs {en,de}cryption, then set to 1 */
2133 int host_encrypt;
2134 int host_encrypt_msdu;
2135 int host_decrypt;
2136 /* host performs multicast decryption */
2137 int host_mc_decrypt;
2138
2139 /* host should strip IV and ICV from protected frames */
2140 /* meaningful only when hardware decryption is being used */
2141 int host_strip_iv_icv;
2142
2143 int host_open_frag;
2144 int host_build_iv;
2145 int ieee802_1x; /* is IEEE 802.1X used */
2146
2147 /* WPA data */
2148 bool bHalfWirelessN24GMode;
2149 int wpa_enabled;
2150 int drop_unencrypted;
2151 int tkip_countermeasures;
2152 int privacy_invoked;
2153 size_t wpa_ie_len;
2154 u8 *wpa_ie;
2155 u8 ap_mac_addr[6];
2156 u16 pairwise_key_type;
2157 u16 group_key_type;
2158 struct list_head crypt_deinit_list;
2159 struct ieee80211_crypt_data *crypt[WEP_KEYS];
2160 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
2161 struct timer_list crypt_deinit_timer;
2162 int crypt_quiesced;
2163
2164 int bcrx_sta_key; /* use individual keys to override default keys even
2165 * with RX of broad/multicast frames */
2166
2167 /* Fragmentation structures */
2168 // each streaming contain a entry
2169 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
2170 unsigned int frag_next_idx[17];
2171 u16 fts; /* Fragmentation Threshold */
2172#define DEFAULT_RTS_THRESHOLD 2346U
2173#define MIN_RTS_THRESHOLD 1
2174#define MAX_RTS_THRESHOLD 2346U
2175 u16 rts; /* RTS threshold */
2176
2177 /* Association info */
2178 u8 bssid[ETH_ALEN];
2179
2180 /* This stores infos for the current network.
2181 * Either the network we are associated in INFRASTRUCTURE
2182 * or the network that we are creating in MASTER mode.
2183 * ad-hoc is a mixture ;-).
2184 * Note that in infrastructure mode, even when not associated,
2185 * fields bssid and essid may be valid (if wpa_set and essid_set
2186 * are true) as thy carry the value set by the user via iwconfig
2187 */
2188 struct ieee80211_network current_network;
2189
2190 enum ieee80211_state state;
2191
2192 int short_slot;
2193 int reg_mode;
2194 int mode; /* A, B, G */
2195 int modulation; /* CCK, OFDM */
2196 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
2197 int abg_true; /* ABG flag */
2198
2199 /* used for forcing the ibss workqueue to terminate
2200 * without wait for the syncro scan to terminate
2201 */
2202 short sync_scan_hurryup;
2203
2204 int perfect_rssi;
2205 int worst_rssi;
2206
2207 u16 prev_seq_ctl; /* used to drop duplicate frames */
2208
2209 /* map of allowed channels. 0 is dummy */
2210 // FIXME: remeber to default to a basic channel plan depending of the PHY type
2211#ifdef ENABLE_DOT11D
2212 void* pDot11dInfo;
2213 bool bGlobalDomain;
2214#else
2215 int channel_map[MAX_CHANNEL_NUMBER+1];
2216#endif
2217 int rate; /* current rate */
2218 int basic_rate;
2219 //FIXME: pleace callback, see if redundant with softmac_features
2220 short active_scan;
2221
2222 /* this contains flags for selectively enable softmac support */
2223 u16 softmac_features;
2224
2225 /* if the sequence control field is not filled by HW */
2226 u16 seq_ctrl[5];
2227
2228 /* association procedure transaction sequence number */
2229 u16 associate_seq;
2230
2231 /* AID for RTXed association responses */
2232 u16 assoc_id;
2233
2234 /* power save mode related*/
2235 u8 ack_tx_to_ieee;
2236 short ps;
2237 short sta_sleep;
2238 int ps_timeout;
2239 int ps_period;
2240 struct tasklet_struct ps_task;
2241 u32 ps_th;
2242 u32 ps_tl;
2243
2244 short raw_tx;
2245 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2246 short queue_stop;
2247 short scanning;
2248 short proto_started;
2249
2250 struct semaphore wx_sem;
2251 struct semaphore scan_sem;
2252
2253 spinlock_t mgmt_tx_lock;
2254 spinlock_t beacon_lock;
2255
2256 short beacon_txing;
2257
2258 short wap_set;
2259 short ssid_set;
2260
2261 u8 wpax_type_set; //{added by David, 2006.9.28}
2262 u32 wpax_type_notify; //{added by David, 2006.9.26}
2263
2264 /* QoS related flag */
2265 char init_wmmparam_flag;
2266 /* set on initialization */
2267 u8 qos_support;
2268
2269 /* for discarding duplicated packets in IBSS */
2270 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
2271
2272 /* for discarding duplicated packets in BSS */
2273 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
2274 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
2275 unsigned long last_packet_time[17];
2276
2277 /* for PS mode */
2278 unsigned long last_rx_ps_time;
2279
2280 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
2281 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
2282 int mgmt_queue_head;
2283 int mgmt_queue_tail;
2284//{ added for rtl819x
2285#define IEEE80211_QUEUE_LIMIT 128
2286 u8 AsocRetryCount;
2287 unsigned int hw_header;
2288 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
2289 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
2290 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
2291 u32 sta_edca_param[4];
2292 bool aggregation;
2293 // Enable/Disable Rx immediate BA capability.
2294 bool enable_rx_imm_BA;
2295 bool bibsscoordinator;
2296
2297 //+by amy for DM ,080515
2298 //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15
2299 bool bdynamic_txpower_enable;
2300
2301 bool bCTSToSelfEnable;
2302 u8 CTSToSelfTH;
2303
2304 u32 fsync_time_interval;
2305 u32 fsync_rate_bitmap;
2306 u8 fsync_rssi_threshold;
2307 bool bfsync_enable;
2308
2309 u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval
2310 u32 fsync_firstdiff_ratethreshold; // low threshold
2311 u32 fsync_seconddiff_ratethreshold; // decrease threshold
2312 Fsync_State fsync_state;
2313 bool bis_any_nonbepkts;
2314 //20Mhz 40Mhz AutoSwitch Threshold
2315 bandwidth_autoswitch bandwidth_auto_switch;
2316 //for txpower tracking
2317 bool FwRWRF;
2318
2319 //added by amy for AP roaming
2320 RT_LINK_DETECT_T LinkDetectInfo;
2321 //added by amy for ps
2322 RT_POWER_SAVE_CONTROL PowerSaveControl;
2323//}
2324 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2325 struct tx_pending_t tx_pending;
2326
2327 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2328 struct timer_list associate_timer;
2329
2330 /* used if IEEE_SOFTMAC_BEACONS is set */
2331 struct timer_list beacon_timer;
2332#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
2333 struct work_struct associate_complete_wq;
2334 struct work_struct associate_procedure_wq;
2335#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2336 struct delayed_work softmac_scan_wq;
2337 struct delayed_work associate_retry_wq;
2338 struct delayed_work start_ibss_wq;
2339 struct delayed_work hw_wakeup_wq;
2340 struct delayed_work hw_sleep_wq;
2341#else
2342 struct work_struct softmac_scan_wq;
2343 struct work_struct associate_retry_wq;
2344 struct work_struct start_ibss_wq;
2345 struct work_struct hw_wakeup_wq;
2346 struct work_struct hw_sleep_wq;
2347#endif
2348 struct work_struct wx_sync_scan_wq;
2349 struct workqueue_struct *wq;
2350#else
2351 /* used for periodly scan */
2352 struct timer_list scan_timer;
2353
2354 struct tq_struct associate_complete_wq;
2355 struct tq_struct associate_retry_wq;
2356 struct tq_struct start_ibss_wq;
2357 struct tq_struct associate_procedure_wq;
2358 struct tq_struct softmac_scan_wq;
2359 struct tq_struct wx_sync_scan_wq;
2360
2361#endif
2362 // Qos related. Added by Annie, 2005-11-01.
2363 //STA_QOS StaQos;
2364
2365 //u32 STA_EDCA_PARAM[4];
2366 //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
2367
2368
2369 /* Callback functions */
2370 void (*set_security)(struct net_device *dev,
2371 struct ieee80211_security *sec);
2372
2373 /* Used to TX data frame by using txb structs.
2374 * this is not used if in the softmac_features
2375 * is set the flag IEEE_SOFTMAC_TX_QUEUE
2376 */
2377 int (*hard_start_xmit)(struct ieee80211_txb *txb,
2378 struct net_device *dev);
2379
2380 int (*reset_port)(struct net_device *dev);
2381 int (*is_queue_full) (struct net_device * dev, int pri);
2382
2383 int (*handle_management) (struct net_device * dev,
2384 struct ieee80211_network * network, u16 type);
2385 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
2386
2387 /* Softmac-generated frames (mamagement) are TXed via this
2388 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
2389 * not set. As some cards may have different HW queues that
2390 * one might want to use for data and management frames
2391 * the option to have two callbacks might be useful.
2392 * This fucntion can't sleep.
2393 */
2394 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
2395 struct net_device *dev);
2396
2397 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
2398 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
2399 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
2400 * then also management frames are sent via this callback.
2401 * This function can't sleep.
2402 */
2403 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
2404 struct net_device *dev,int rate);
2405
2406 /* stops the HW queue for DATA frames. Useful to avoid
2407 * waste time to TX data frame when we are reassociating
2408 * This function can sleep.
2409 */
2410 void (*data_hard_stop)(struct net_device *dev);
2411
2412 /* OK this is complementar to data_poll_hard_stop */
2413 void (*data_hard_resume)(struct net_device *dev);
2414
2415 /* ask to the driver to retune the radio .
2416 * This function can sleep. the driver should ensure
2417 * the radio has been swithced before return.
2418 */
2419 void (*set_chan)(struct net_device *dev,short ch);
2420
2421 /* These are not used if the ieee stack takes care of
2422 * scanning (IEEE_SOFTMAC_SCAN feature set).
2423 * In this case only the set_chan is used.
2424 *
2425 * The syncro version is similar to the start_scan but
2426 * does not return until all channels has been scanned.
2427 * this is called in user context and should sleep,
2428 * it is called in a work_queue when swithcing to ad-hoc mode
2429 * or in behalf of iwlist scan when the card is associated
2430 * and root user ask for a scan.
2431 * the fucntion stop_scan should stop both the syncro and
2432 * background scanning and can sleep.
2433 * The fucntion start_scan should initiate the background
2434 * scanning and can't sleep.
2435 */
2436 void (*scan_syncro)(struct net_device *dev);
2437 void (*start_scan)(struct net_device *dev);
2438 void (*stop_scan)(struct net_device *dev);
2439
2440 /* indicate the driver that the link state is changed
2441 * for example it may indicate the card is associated now.
2442 * Driver might be interested in this to apply RX filter
2443 * rules or simply light the LINK led
2444 */
2445 void (*link_change)(struct net_device *dev);
2446
2447 /* these two function indicates to the HW when to start
2448 * and stop to send beacons. This is used when the
2449 * IEEE_SOFTMAC_BEACONS is not set. For now the
2450 * stop_send_bacons is NOT guaranteed to be called only
2451 * after start_send_beacons.
2452 */
65a43784 2453 void (*start_send_beacons) (struct net_device *dev);
ecdfa446
GKH
2454 void (*stop_send_beacons) (struct net_device *dev);
2455
2456 /* power save mode related */
2457 void (*sta_wake_up) (struct net_device *dev);
2458// void (*ps_request_tx_ack) (struct net_device *dev);
2459 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
2460 short (*ps_is_queue_empty) (struct net_device *dev);
2461#if 0
2462 /* Typical STA methods */
2463 int (*handle_auth) (struct net_device * dev,
2464 struct ieee80211_auth * auth);
2465 int (*handle_deauth) (struct net_device * dev,
2466 struct ieee80211_deauth * auth);
2467 int (*handle_action) (struct net_device * dev,
2468 struct ieee80211_action * action,
2469 struct ieee80211_rx_stats * stats);
2470 int (*handle_disassoc) (struct net_device * dev,
2471 struct ieee80211_disassoc * assoc);
2472#endif
2473 int (*handle_beacon) (struct net_device * dev, struct ieee80211_beacon * beacon, struct ieee80211_network * network);
2474#if 0
2475 int (*handle_probe_response) (struct net_device * dev,
2476 struct ieee80211_probe_response * resp,
2477 struct ieee80211_network * network);
2478 int (*handle_probe_request) (struct net_device * dev,
2479 struct ieee80211_probe_request * req,
2480 struct ieee80211_rx_stats * stats);
2481#endif
2482 int (*handle_assoc_response) (struct net_device * dev, struct ieee80211_assoc_response_frame * resp, struct ieee80211_network * network);
2483
2484#if 0
2485 /* Typical AP methods */
2486 int (*handle_assoc_request) (struct net_device * dev);
2487 int (*handle_reassoc_request) (struct net_device * dev,
2488 struct ieee80211_reassoc_request * req);
2489#endif
2490
2491 /* check whether Tx hw resouce available */
2492 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
2493 //added by wb for HT related
2494// void (*SwChnlByTimerHandler)(struct net_device *dev, int channel);
2495 void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
2496// void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate);
2497 bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
2498 void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
2499 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
2500 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2501
2502 /* This must be the last item so that it points to the data
2503 * allocated beyond this structure by alloc_ieee80211 */
2504 u8 priv[0];
2505};
2506
65a43784 2507#define RT_RF_OFF_LEVL_ASPM BIT0 // PCI ASPM
2508#define RT_RF_OFF_LEVL_CLK_REQ BIT1 // PCI clock request
2509#define RT_RF_OFF_LEVL_PCI_D3 BIT2 // PCI D3 mode
2510#define RT_RF_OFF_LEVL_HALT_NIC BIT3 // NIC halt, re-initialize hw parameters
2511#define RT_RF_OFF_LEVL_FREE_FW BIT4 // FW free, re-download the FW
2512#define RT_RF_OFF_LEVL_FW_32K BIT5 // FW in 32k
2513#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 // Always enable ASPM and Clock Req in initialization.
2514#define RT_RF_LPS_DISALBE_2R BIT30 // When LPS is on, disable 2R if no packet is received or transmittd.
2515#define RT_RF_LPS_LEVEL_ASPM BIT31 // LPS with ASPM
2516#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
2517#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG)))
2518#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
2519
ecdfa446
GKH
2520#define IEEE_A (1<<0)
2521#define IEEE_B (1<<1)
2522#define IEEE_G (1<<2)
2523#define IEEE_N_24G (1<<4)
2524#define IEEE_N_5G (1<<5)
2525#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
2526
2527/* Generate a 802.11 header */
2528
2529/* Uses the channel change callback directly
2530 * instead of [start/stop] scan callbacks
2531 */
2532#define IEEE_SOFTMAC_SCAN (1<<2)
2533
2534/* Perform authentication and association handshake */
2535#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2536
2537/* Generate probe requests */
2538#define IEEE_SOFTMAC_PROBERQ (1<<4)
2539
2540/* Generate respones to probe requests */
2541#define IEEE_SOFTMAC_PROBERS (1<<5)
2542
2543/* The ieee802.11 stack will manages the netif queue
2544 * wake/stop for the driver, taking care of 802.11
2545 * fragmentation. See softmac.c for details. */
2546#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2547
2548/* Uses only the softmac_data_hard_start_xmit
2549 * even for TX management frames.
2550 */
2551#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2552
2553/* Generate beacons. The stack will enqueue beacons
2554 * to the card
2555 */
2556#define IEEE_SOFTMAC_BEACONS (1<<6)
2557
2558static inline void *ieee80211_priv(struct net_device *dev)
2559{
2560#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
2561 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
2562#else
2563 return ((struct ieee80211_device *)dev->priv)->priv;
2564#endif
2565}
2566
2567extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
2568{
2569 /* Single white space is for Linksys APs */
2570 if (essid_len == 1 && essid[0] == ' ')
2571 return 1;
2572
2573 /* Otherwise, if the entire essid is 0, we assume it is hidden */
2574 while (essid_len) {
2575 essid_len--;
2576 if (essid[essid_len] != '\0')
2577 return 0;
2578 }
2579
2580 return 1;
2581}
2582
2583extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
2584{
2585 /*
2586 * It is possible for both access points and our device to support
2587 * combinations of modes, so as long as there is one valid combination
2588 * of ap/device supported modes, then return success
2589 *
2590 */
2591 if ((mode & IEEE_A) &&
2592 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2593 (ieee->freq_band & IEEE80211_52GHZ_BAND))
2594 return 1;
2595
2596 if ((mode & IEEE_G) &&
2597 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2598 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2599 return 1;
2600
2601 if ((mode & IEEE_B) &&
2602 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
2603 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2604 return 1;
2605
2606 return 0;
2607}
2608
2609extern inline int ieee80211_get_hdrlen(u16 fc)
2610{
2611 int hdrlen = IEEE80211_3ADDR_LEN;
2612
2613 switch (WLAN_FC_GET_TYPE(fc)) {
2614 case IEEE80211_FTYPE_DATA:
2615 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
2616 hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
2617 if(IEEE80211_QOS_HAS_SEQ(fc))
2618 hdrlen += 2; /* QOS ctrl*/
2619 break;
2620 case IEEE80211_FTYPE_CTL:
2621 switch (WLAN_FC_GET_STYPE(fc)) {
2622 case IEEE80211_STYPE_CTS:
2623 case IEEE80211_STYPE_ACK:
2624 hdrlen = IEEE80211_1ADDR_LEN;
2625 break;
2626 default:
2627 hdrlen = IEEE80211_2ADDR_LEN;
2628 break;
2629 }
2630 break;
2631 }
2632
2633 return hdrlen;
2634}
2635
2636static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
2637{
2638 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2639 case IEEE80211_1ADDR_LEN:
2640 return ((struct ieee80211_hdr_1addr *)hdr)->payload;
2641 case IEEE80211_2ADDR_LEN:
2642 return ((struct ieee80211_hdr_2addr *)hdr)->payload;
2643 case IEEE80211_3ADDR_LEN:
2644 return ((struct ieee80211_hdr_3addr *)hdr)->payload;
2645 case IEEE80211_4ADDR_LEN:
2646 return ((struct ieee80211_hdr_4addr *)hdr)->payload;
2647 }
2648 return NULL;
2649}
2650
2651static inline int ieee80211_is_ofdm_rate(u8 rate)
2652{
2653 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2654 case IEEE80211_OFDM_RATE_6MB:
2655 case IEEE80211_OFDM_RATE_9MB:
2656 case IEEE80211_OFDM_RATE_12MB:
2657 case IEEE80211_OFDM_RATE_18MB:
2658 case IEEE80211_OFDM_RATE_24MB:
2659 case IEEE80211_OFDM_RATE_36MB:
2660 case IEEE80211_OFDM_RATE_48MB:
2661 case IEEE80211_OFDM_RATE_54MB:
2662 return 1;
2663 }
2664 return 0;
2665}
2666
2667static inline int ieee80211_is_cck_rate(u8 rate)
2668{
2669 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2670 case IEEE80211_CCK_RATE_1MB:
2671 case IEEE80211_CCK_RATE_2MB:
2672 case IEEE80211_CCK_RATE_5MB:
2673 case IEEE80211_CCK_RATE_11MB:
2674 return 1;
2675 }
2676 return 0;
2677}
2678
2679
2680/* ieee80211.c */
2681extern void free_ieee80211(struct net_device *dev);
2682extern struct net_device *alloc_ieee80211(int sizeof_priv);
2683
2684extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
2685
2686/* ieee80211_tx.c */
2687
2688extern int ieee80211_encrypt_fragment(
2689 struct ieee80211_device *ieee,
2690 struct sk_buff *frag,
2691 int hdr_len);
2692
fb5fe277 2693extern int ieee80211_rtl_xmit(struct sk_buff *skb,
ecdfa446
GKH
2694 struct net_device *dev);
2695extern void ieee80211_txb_free(struct ieee80211_txb *);
2696
2697
2698/* ieee80211_rx.c */
fb5fe277 2699extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
ecdfa446
GKH
2700 struct ieee80211_rx_stats *rx_stats);
2701extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2702 struct ieee80211_hdr_4addr *header,
2703 struct ieee80211_rx_stats *stats);
2704
2705/* ieee80211_wx.c */
2706extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2707 struct iw_request_info *info,
2708 union iwreq_data *wrqu, char *key);
2709extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *key);
2712extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
2713 struct iw_request_info *info,
2714 union iwreq_data *wrqu, char *key);
2715#if WIRELESS_EXT >= 18
2716extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
2717 struct iw_request_info *info,
2718 union iwreq_data* wrqu, char *extra);
2719extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
2720 struct iw_request_info *info,
2721 union iwreq_data* wrqu, char *extra);
2722extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
2723 struct iw_request_info *info,
2724 struct iw_param *data, char *extra);
2725extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
2726 struct iw_request_info *info,
2727 union iwreq_data *wrqu, char *extra);
2728#endif
2729extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
2730
2731/* ieee80211_softmac.c */
2732extern short ieee80211_is_54g(struct ieee80211_network net);
2733extern short ieee80211_is_shortslot(struct ieee80211_network net);
2734extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
2735 struct ieee80211_rx_stats *rx_stats, u16 type,
2736 u16 stype);
2737extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
2738
2739void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
2740extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
2741
2742extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2743extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
2744extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2745extern void ieee80211_start_bss(struct ieee80211_device *ieee);
2746extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2747extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
2748extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
2749extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
2750extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
2751extern void ieee80211_disassociate(struct ieee80211_device *ieee);
2752extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
2753extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2754extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2755extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
65a43784 2756extern void ieee80211_stop_protocol(struct ieee80211_device *ieee,u8 shutdown);
ecdfa446 2757extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
65a43784 2758extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee,u8 shutdown);
ecdfa446 2759extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
fb5fe277
GK
2760extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
2761extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
ecdfa446
GKH
2762extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2763extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2764extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2765extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
2766extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
2767extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2768
2769extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
2770
2771/* ieee80211_crypt_ccmp&tkip&wep.c */
2772extern void ieee80211_tkip_null(void);
2773extern void ieee80211_wep_null(void);
2774extern void ieee80211_ccmp_null(void);
2775
2776/* ieee80211_softmac_wx.c */
2777
2778extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2779 struct iw_request_info *info,
2780 union iwreq_data *wrqu, char *ext);
2781
2782extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2783 struct iw_request_info *info,
2784 union iwreq_data *awrq,
2785 char *extra);
2786
2787extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
2788
2789extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra);
2792
2793extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2794 struct iw_request_info *info,
2795 union iwreq_data *wrqu, char *extra);
2796
2797extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2798 union iwreq_data *wrqu, char *b);
2799
2800extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
2801 union iwreq_data *wrqu, char *b);
2802
2803extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2804 struct iw_request_info *a,
2805 union iwreq_data *wrqu, char *extra);
2806
2807extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2808 union iwreq_data *wrqu, char *b);
2809
2810extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2811 union iwreq_data *wrqu, char *b);
2812
2813extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2814 union iwreq_data *wrqu, char *b);
2815
2816//extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2817#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2818extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
2819#else
2820 extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2821#endif
2822
2823
2824extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2825 struct iw_request_info *info,
2826 union iwreq_data *wrqu, char *extra);
2827
2828extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
2829 struct iw_request_info *info,
2830 union iwreq_data *wrqu, char *extra);
2831
2832extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
2833 struct iw_request_info *info,
2834 union iwreq_data *wrqu, char *extra);
2835
2836extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
2837 struct iw_request_info *info,
2838 union iwreq_data *wrqu, char *extra);
2839
2840extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
2841 struct iw_request_info *info,
2842 union iwreq_data *wrqu, char *extra);
2843
2844extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
2845 struct iw_request_info *info,
2846 union iwreq_data *wrqu, char *extra);
2847//HT
2848#define MAX_RECEIVE_BUFFER_SIZE 9100 //
2849extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
2850extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
2851
2852void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
2853extern void HTUpdateDefaultSetting(struct ieee80211_device* ieee);
2854extern void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt);
2855extern void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
2856extern void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len);
2857extern void HTOnAssocRsp(struct ieee80211_device *ieee);
2858extern void HTInitializeHTInfo(struct ieee80211_device* ieee);
2859extern void HTInitializeBssDesc(PBSS_HT pBssHT);
2860extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
2861extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
2862extern u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
2863extern u8 MCS_FILTER_ALL[];
2864extern u16 MCS_DATA_RATE[2][2][77] ;
2865extern u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame);
2866//extern void HTSetConnectBwModeCallback(unsigned long data);
2867extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
2868extern bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee);
2869extern u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate);
2870extern u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate);
2871extern u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate);
2872//function in BAPROC.c
2873extern int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb);
2874extern int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb);
2875extern int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb);
2876extern void TsInitAddBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending);
2877extern void TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
2878extern void BaSetupTimeOut(unsigned long data);
2879extern void TxBaInactTimeout(unsigned long data);
2880extern void RxBaInactTimeout(unsigned long data);
2881extern void ResetBaEntry( PBA_RECORD pBA);
2882//function in TS.c
2883extern bool GetTs(
2884 struct ieee80211_device* ieee,
2885 PTS_COMMON_INFO *ppTS,
2886 u8* Addr,
2887 u8 TID,
2888 TR_SELECT TxRxSelect, //Rx:1, Tx:0
2889 bool bAddNewTs
2890 );
2891extern void TSInitialize(struct ieee80211_device *ieee);
2892extern void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS);
2893extern void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr);
2894extern void RemoveAllTS(struct ieee80211_device* ieee);
2895void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
2896
2897extern const long ieee80211_wlan_frequencies[];
2898
2899extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
2900{
2901 ieee->scans++;
2902}
2903
2904extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2905{
2906 return ieee->scans;
2907}
2908
2909static inline const char *escape_essid(const char *essid, u8 essid_len) {
2910 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2911 const char *s = essid;
2912 char *d = escaped;
2913
2914 if (ieee80211_is_empty_essid(essid, essid_len)) {
2915 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2916 return escaped;
2917 }
2918
2919 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
2920 while (essid_len--) {
2921 if (*s == '\0') {
2922 *d++ = '\\';
2923 *d++ = '0';
2924 s++;
2925 } else {
2926 *d++ = *s++;
2927 }
2928 }
2929 *d = '\0';
2930 return escaped;
2931}
2932
2933/* For the function is more related to hardware setting, it's better to use the
2934 * ieee handler to refer to it.
2935 */
2936extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
2937extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
2938extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
2939 struct ieee80211_info_element *info_element,
2940 u16 length,
2941 struct ieee80211_network *network,
2942 struct ieee80211_rx_stats *stats);
2943
2944void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index);
65a43784 2945void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
2946void ieee80211_sta_ps_send_pspoll_frame(struct ieee80211_device *ieee);
ecdfa446
GKH
2947#define RT_ASOC_RETRY_LIMIT 5
2948#endif /* IEEE80211_H */