1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Merged with mainline ieee80211.h in Aug 2004.  Original ieee802_11
4  * remains copyright by the original authors
5  *
6  * Portions of the merged code are based on Host AP (software wireless
7  * LAN access point) driver for Intersil Prism2/2.5/3.
8  *
9  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10  * <jkmaline@cc.hut.fi>
11  * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
12  *
13  * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14  * <jketreno@linux.intel.com>
15  * Copyright (c) 2004, Intel Corporation
16  *
17  * Modified for Realtek's wi-fi cards by Andrea Merello
18  * <andrea.merello@gmail.com>
19  */
20 #ifndef IEEE80211_H
21 #define IEEE80211_H
22 #include <linux/if_ether.h> /* ETH_ALEN */
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/jiffies.h>
26 #include <linux/timer.h>
27 #include <linux/sched.h>
28 #include <linux/semaphore.h>
29 #include <linux/interrupt.h>
30 
31 #include <linux/delay.h>
32 #include <linux/wireless.h>
33 #include <linux/ieee80211.h>
34 
35 #include "rtl819x_HT.h"
36 #include "rtl819x_BA.h"
37 #include "rtl819x_TS.h"
38 
39 
40 #ifndef IW_MODE_MONITOR
41 #define IW_MODE_MONITOR 6
42 #endif
43 
44 #ifndef IWEVCUSTOM
45 #define IWEVCUSTOM 0x8c02
46 #endif
47 
48 #define KEY_TYPE_NA		0x0
49 #define KEY_TYPE_WEP40		0x1
50 #define KEY_TYPE_TKIP		0x2
51 #define KEY_TYPE_CCMP		0x4
52 #define KEY_TYPE_WEP104		0x5
53 
54 /* added for rtl819x tx procedure */
55 #define MAX_QUEUE_SIZE		0x10
56 
57 //
58 // 8190 queue mapping
59 //
60 #define BK_QUEUE                               0
61 #define BE_QUEUE                               1
62 #define VI_QUEUE                               2
63 #define VO_QUEUE                               3
64 #define HCCA_QUEUE                             4
65 #define TXCMD_QUEUE                            5
66 #define MGNT_QUEUE                             6
67 #define HIGH_QUEUE                             7
68 #define BEACON_QUEUE                           8
69 
70 #define LOW_QUEUE                              BE_QUEUE
71 #define NORMAL_QUEUE                           MGNT_QUEUE
72 
73 //added by amy for ps
74 #define SWRF_TIMEOUT				50
75 
76 //added by amy for LEAP related
77 #define IE_CISCO_FLAG_POSITION		0x08	// Flag byte: byte 8, numbered from 0.
78 #define SUPPORT_CKIP_MIC			0x08	// bit3
79 #define SUPPORT_CKIP_PK			0x10	// bit4
80 /* defined for skb cb field */
81 /* At most 28 byte */
82 struct cb_desc {
83 	/* Tx Desc Related flags (8-9) */
84 	u8 bLastIniPkt:1;
85 	u8 bCmdOrInit:1;
86 	u8 bFirstSeg:1;
87 	u8 bLastSeg:1;
88 	u8 bEncrypt:1;
89 	u8 bTxDisableRateFallBack:1;
90 	u8 bTxUseDriverAssingedRate:1;
91 	u8 bHwSec:1; //indicate whether use Hw security. WB
92 
93 	u8 reserved1;
94 
95 	/* Tx Firmware Relaged flags (10-11)*/
96 	u8 bCTSEnable:1;
97 	u8 bRTSEnable:1;
98 	u8 bUseShortGI:1;
99 	u8 bUseShortPreamble:1;
100 	u8 bTxEnableFwCalcDur:1;
101 	u8 bAMPDUEnable:1;
102 	u8 bRTSSTBC:1;
103 	u8 RTSSC:1;
104 
105 	u8 bRTSBW:1;
106 	u8 bPacketBW:1;
107 	u8 bRTSUseShortPreamble:1;
108 	u8 bRTSUseShortGI:1;
109 	u8 bMulticast:1;
110 	u8 bBroadcast:1;
111 	//u8 reserved2:2;
112 	u8 drv_agg_enable:1;
113 	u8 reserved2:1;
114 
115 	/* Tx Desc related element(12-19) */
116 	u8 rata_index;
117 	u8 queue_index;
118 	//u8 reserved3;
119 	//u8 reserved4;
120 	u16 txbuf_size;
121 	//u8 reserved5;
122 	u8 RATRIndex;
123 	u8 reserved6;
124 	u8 reserved7;
125 	u8 reserved8;
126 
127 	/* Tx firmware related element(20-27) */
128 	u8 data_rate;
129 	u8 rts_rate;
130 	u8 ampdu_factor;
131 	u8 ampdu_density;
132 	//u8 reserved9;
133 	//u8 reserved10;
134 	//u8 reserved11;
135 	u8 DrvAggrNum;
136 	u16 pkt_size;
137 	u8 reserved12;
138 };
139 
140 /*--------------------------Define -------------------------------------------*/
141 #define MGN_1M                  0x02
142 #define MGN_2M                  0x04
143 #define MGN_5_5M                0x0b
144 #define MGN_11M                 0x16
145 
146 #define MGN_6M                  0x0c
147 #define MGN_9M                  0x12
148 #define MGN_12M                 0x18
149 #define MGN_18M                 0x24
150 #define MGN_24M                 0x30
151 #define MGN_36M                 0x48
152 #define MGN_48M                 0x60
153 #define MGN_54M                 0x6c
154 
155 #define MGN_MCS0                0x80
156 #define MGN_MCS1                0x81
157 #define MGN_MCS2                0x82
158 #define MGN_MCS3                0x83
159 #define MGN_MCS4                0x84
160 #define MGN_MCS5                0x85
161 #define MGN_MCS6                0x86
162 #define MGN_MCS7                0x87
163 #define MGN_MCS8                0x88
164 #define MGN_MCS9                0x89
165 #define MGN_MCS10               0x8a
166 #define MGN_MCS11               0x8b
167 #define MGN_MCS12               0x8c
168 #define MGN_MCS13               0x8d
169 #define MGN_MCS14               0x8e
170 #define MGN_MCS15               0x8f
171 
172 #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A ||     \
173 		    priv->ieee80211->current_network.mode == IEEE_N_24G || \
174 		    priv->ieee80211->current_network.mode == IEEE_N_5G) ?  \
175 		   16 : 10)
176 
177 #define MGMT_QUEUE_NUM 5
178 
179 #define IEEE_CMD_SET_WPA_PARAM			1
180 #define	IEEE_CMD_SET_WPA_IE			2
181 #define IEEE_CMD_SET_ENCRYPTION			3
182 #define IEEE_CMD_MLME				4
183 
184 #define IEEE_PARAM_WPA_ENABLED			1
185 #define IEEE_PARAM_TKIP_COUNTERMEASURES		2
186 #define IEEE_PARAM_DROP_UNENCRYPTED		3
187 #define IEEE_PARAM_PRIVACY_INVOKED		4
188 #define IEEE_PARAM_AUTH_ALGS			5
189 #define IEEE_PARAM_IEEE_802_1X			6
190 //It should consistent with the driver_XXX.c
191 //   David, 2006.9.26
192 #define IEEE_PARAM_WPAX_SELECT			7
193 //Added for notify the encryption type selection
194 //   David, 2006.9.26
195 #define IEEE_PROTO_WPA				1
196 #define IEEE_PROTO_RSN				2
197 //Added for notify the encryption type selection
198 //   David, 2006.9.26
199 #define IEEE_WPAX_USEGROUP			0
200 #define IEEE_WPAX_WEP40				1
201 #define IEEE_WPAX_TKIP				2
202 #define IEEE_WPAX_WRAP				3
203 #define IEEE_WPAX_CCMP				4
204 #define IEEE_WPAX_WEP104			5
205 
206 #define IEEE_KEY_MGMT_IEEE8021X			1
207 #define IEEE_KEY_MGMT_PSK			2
208 
209 #define IEEE_MLME_STA_DEAUTH			1
210 #define IEEE_MLME_STA_DISASSOC			2
211 
212 
213 #define IEEE_CRYPT_ERR_UNKNOWN_ALG		2
214 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR		3
215 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED	4
216 #define IEEE_CRYPT_ERR_KEY_SET_FAILED		5
217 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED	6
218 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED		7
219 
220 
221 #define	IEEE_CRYPT_ALG_NAME_LEN			16
222 
223 #define MAX_IE_LEN  0xff
224 
225 // added for kernel conflict
226 #define ieee80211_wake_queue		ieee80211_wake_queue_rsl
227 #define ieee80211_stop_queue		ieee80211_stop_queue_rsl
228 #define notify_wx_assoc_event		notify_wx_assoc_event_rsl
229 #define SendDisassociation		SendDisassociation_rsl
230 
231 
232 struct ieee_param {
233 	u32 cmd;
234 	u8 sta_addr[ETH_ALEN];
235 	union {
236 		struct {
237 			u8 name;
238 			u32 value;
239 		} wpa_param;
240 		struct {
241 			u32 len;
242 			u8 reserved[32];
243 			u8 data[];
244 		} wpa_ie;
245 		struct{
246 			int command;
247 			int reason_code;
248 		} mlme;
249 		struct {
250 			u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
251 			u8 set_tx;
252 			u32 err;
253 			u8 idx;
254 			u8 seq[8]; /* sequence counter (set: RX, get: TX) */
255 			u16 key_len;
256 			u8 key[];
257 		} crypt;
258 	} u;
259 };
260 
261 
262 // linux under 2.6.9 release may not support it, so modify it for common use
263 #define IEEE80211_DATA_LEN		2304
264 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
265  *   6.2.1.1.2.
266  *
267  *   The figure in section 7.1.2 suggests a body size of up to 2312
268  *   bytes is allowed, which is a bit confusing, I suspect this
269  *   represents the 2304 bytes of real data, plus a possible 8 bytes of
270  *   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
271  */
272 #define IEEE80211_1ADDR_LEN 10
273 #define IEEE80211_2ADDR_LEN 16
274 #define IEEE80211_3ADDR_LEN 24
275 #define IEEE80211_4ADDR_LEN 30
276 #define IEEE80211_FCS_LEN    4
277 #define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
278 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
279 #define IEEE80211_MGMT_HDR_LEN 24
280 #define IEEE80211_DATA_HDR3_LEN 24
281 #define IEEE80211_DATA_HDR4_LEN 30
282 
283 #define MIN_FRAG_THRESHOLD     256U
284 #define MAX_FRAG_THRESHOLD     2346U
285 
286 
287 /* Frame control field constants */
288 #define IEEE80211_FCTL_VERS		0x0003
289 #define IEEE80211_FCTL_FTYPE		0x000c
290 #define IEEE80211_FCTL_STYPE		0x00f0
291 #define IEEE80211_FCTL_FRAMETYPE	0x00fc
292 #define IEEE80211_FCTL_TODS		0x0100
293 #define IEEE80211_FCTL_FROMDS		0x0200
294 #define IEEE80211_FCTL_DSTODS		0x0300 //added by david
295 #define IEEE80211_FCTL_MOREFRAGS	0x0400
296 #define IEEE80211_FCTL_RETRY		0x0800
297 #define IEEE80211_FCTL_PM		0x1000
298 #define IEEE80211_FCTL_MOREDATA		0x2000
299 #define IEEE80211_FCTL_WEP		0x4000
300 #define IEEE80211_FCTL_ORDER		0x8000
301 
302 #define IEEE80211_FTYPE_MGMT		0x0000
303 #define IEEE80211_FTYPE_CTL		0x0004
304 #define IEEE80211_FTYPE_DATA		0x0008
305 
306 /* management */
307 #define IEEE80211_STYPE_ASSOC_REQ	0x0000
308 #define IEEE80211_STYPE_ASSOC_RESP	0x0010
309 #define IEEE80211_STYPE_REASSOC_REQ	0x0020
310 #define IEEE80211_STYPE_REASSOC_RESP	0x0030
311 #define IEEE80211_STYPE_PROBE_REQ	0x0040
312 #define IEEE80211_STYPE_PROBE_RESP	0x0050
313 #define IEEE80211_STYPE_BEACON		0x0080
314 #define IEEE80211_STYPE_ATIM		0x0090
315 #define IEEE80211_STYPE_DISASSOC	0x00A0
316 #define IEEE80211_STYPE_AUTH		0x00B0
317 #define IEEE80211_STYPE_DEAUTH		0x00C0
318 #define IEEE80211_STYPE_MANAGE_ACT	0x00D0
319 
320 /* control */
321 #define IEEE80211_STYPE_PSPOLL		0x00A0
322 #define IEEE80211_STYPE_RTS		0x00B0
323 #define IEEE80211_STYPE_CTS		0x00C0
324 #define IEEE80211_STYPE_ACK		0x00D0
325 #define IEEE80211_STYPE_CFEND		0x00E0
326 #define IEEE80211_STYPE_CFENDACK	0x00F0
327 #define IEEE80211_STYPE_BLOCKACK	0x0094
328 
329 /* data */
330 #define IEEE80211_STYPE_DATA		0x0000
331 #define IEEE80211_STYPE_DATA_CFACK	0x0010
332 #define IEEE80211_STYPE_DATA_CFPOLL	0x0020
333 #define IEEE80211_STYPE_DATA_CFACKPOLL	0x0030
334 #define IEEE80211_STYPE_NULLFUNC	0x0040
335 #define IEEE80211_STYPE_CFACK		0x0050
336 #define IEEE80211_STYPE_CFPOLL		0x0060
337 #define IEEE80211_STYPE_CFACKPOLL	0x0070
338 #define IEEE80211_STYPE_QOS_DATA	0x0080 //added for WMM 2006/8/2
339 #define IEEE80211_STYPE_QOS_NULL	0x00C0
340 
341 #define IEEE80211_SCTL_FRAG		0x000F
342 #define IEEE80211_SCTL_SEQ		0xFFF0
343 
344 /* QOS control */
345 #define IEEE80211_QCTL_TID              0x000F
346 
347 #define	FC_QOS_BIT					BIT(7)
348 #define IsDataFrame(pdu)			(((pdu[0] & 0x0C) == 0x08) ? true : false)
349 #define	IsLegacyDataFrame(pdu)	(IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT)))
350 //added by wb. Is this right?
351 #define IsQoSDataFrame(pframe)  ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA))
352 #define Frame_Order(pframe)     (*(u16 *)pframe & IEEE80211_FCTL_ORDER)
353 #define SN_LESS(a, b)		(((a - b) & 0x800) != 0)
354 #define SN_EQUAL(a, b)	(a == b)
355 #define MAX_DEV_ADDR_SIZE 8
356 typedef enum _ACT_CATEGORY {
357 	ACT_CAT_QOS = 1,
358 	ACT_CAT_DLS = 2,
359 	ACT_CAT_BA  = 3,
360 	ACT_CAT_HT  = 7,
361 	ACT_CAT_WMM = 17,
362 } ACT_CATEGORY, *PACT_CATEGORY;
363 
364 typedef enum _TS_ACTION {
365 	ACT_ADDTSREQ = 0,
366 	ACT_ADDTSRSP = 1,
367 	ACT_DELTS    = 2,
368 	ACT_SCHEDULE = 3,
369 } TS_ACTION, *PTS_ACTION;
370 
371 typedef enum _BA_ACTION {
372 	ACT_ADDBAREQ = 0,
373 	ACT_ADDBARSP = 1,
374 	ACT_DELBA    = 2,
375 } BA_ACTION, *PBA_ACTION;
376 
377 typedef enum _InitialGainOpType {
378 	IG_Backup = 0,
379 	IG_Restore,
380 	IG_Max
381 } InitialGainOpType;
382 
383 /* debug macros */
384 #define CONFIG_IEEE80211_DEBUG
385 #ifdef CONFIG_IEEE80211_DEBUG
386 extern u32 ieee80211_debug_level;
387 #define IEEE80211_DEBUG(level, fmt, args...) \
388 do { if (ieee80211_debug_level & (level)) \
389   printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
390 //wb added to debug out data buf
391 //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
392 #define IEEE80211_DEBUG_DATA(level, data, datalen)                             \
393 	do { if ((ieee80211_debug_level & (level)) == (level))                 \
394 		{                                                              \
395 			int i;                                                 \
396 			u8 *pdata = (u8 *)data;                                \
397 			printk(KERN_DEBUG "ieee80211: %s()\n", __func__);      \
398 			for (i = 0; i < (int)(datalen); i++) {                 \
399 				printk("%2x ", pdata[i]);                      \
400 				if ((i + 1) % 16 == 0)                         \
401 					printk("\n");                          \
402 			}                                                      \
403 			printk("\n");                                          \
404 		}                                                              \
405 	} while (0)
406 #else
407 #define IEEE80211_DEBUG(level, fmt, args...)
408 #define IEEE80211_DEBUG_DATA(level, data, datalen)
409 #endif	/* CONFIG_IEEE80211_DEBUG */
410 
411 /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
412 
413 /*
414  * To use the debug system;
415  *
416  * If you are defining a new debug classification, simply add it to the #define
417  * list here in the form of:
418  *
419  * #define IEEE80211_DL_xxxx VALUE
420  *
421  * shifting value to the left one bit from the previous entry.  xxxx should be
422  * the name of the classification (for example, WEP)
423  *
424  * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
425  * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
426  * to send output to that classification.
427  *
428  * To add your debug level to the list of levels seen when you perform
429  *
430  * % cat /proc/net/ipw/debug_level
431  *
432  * you simply need to add your entry to the ipw_debug_levels array.
433  *
434  * If you do not see debug_level in /proc/net/ipw then you do not have
435  * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
436  *
437  */
438 
439 #define IEEE80211_DL_INFO          (1<<0)
440 #define IEEE80211_DL_WX            (1<<1)
441 #define IEEE80211_DL_SCAN          (1<<2)
442 #define IEEE80211_DL_STATE         (1<<3)
443 #define IEEE80211_DL_MGMT          (1<<4)
444 #define IEEE80211_DL_FRAG          (1<<5)
445 #define IEEE80211_DL_EAP           (1<<6)
446 #define IEEE80211_DL_DROP          (1<<7)
447 
448 #define IEEE80211_DL_TX            (1<<8)
449 #define IEEE80211_DL_RX            (1<<9)
450 
451 #define IEEE80211_DL_HT		   (1<<10)  //HT
452 #define IEEE80211_DL_BA		   (1<<11)  //ba
453 #define IEEE80211_DL_TS		   (1<<12)  //TS
454 #define IEEE80211_DL_QOS           (1<<13)
455 #define IEEE80211_DL_REORDER	   (1<<14)
456 #define IEEE80211_DL_IOT	   (1<<15)
457 #define IEEE80211_DL_IPS	   (1<<16)
458 #define IEEE80211_DL_TRACE	   (1<<29)  //trace function, need to user net_ratelimit() together in order not to print too much to the screen
459 #define IEEE80211_DL_DATA	   (1<<30)   //use this flag to control whether print data buf out.
460 #define IEEE80211_DL_ERR	   (1<<31)   //always open
461 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
462 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
463 #define IEEE80211_DEBUG_INFO(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
464 
465 #define IEEE80211_DEBUG_WX(f, a...)     IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
466 #define IEEE80211_DEBUG_SCAN(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
467 #define IEEE80211_DEBUG_STATE(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
468 #define IEEE80211_DEBUG_MGMT(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
469 #define IEEE80211_DEBUG_FRAG(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
470 #define IEEE80211_DEBUG_EAP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
471 #define IEEE80211_DEBUG_DROP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
472 #define IEEE80211_DEBUG_TX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
473 #define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
474 #define IEEE80211_DEBUG_QOS(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
475 
476 #include <linux/if_arp.h> /* ARPHRD_ETHER */
477 
478 #ifndef WIRELESS_SPY
479 #define WIRELESS_SPY		// enable iwspy support
480 #endif
481 #include <net/iw_handler.h>	// new driver API
482 
483 #ifndef ETH_P_PAE
484 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
485 #endif /* ETH_P_PAE */
486 
487 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
488 
489 #ifndef ETH_P_80211_RAW
490 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
491 #endif
492 
493 /* IEEE 802.11 defines */
494 
495 #define P80211_OUI_LEN 3
496 
497 struct ieee80211_snap_hdr {
498 
499 	u8    dsap;   /* always 0xAA */
500 	u8    ssap;   /* always 0xAA */
501 	u8    ctrl;   /* always 0x03 */
502 	u8    oui[P80211_OUI_LEN];    /* organizational universal id */
503 
504 } __packed;
505 
506 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
507 
508 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
509 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
510 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
511 
512 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
513 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
514 #define WLAN_GET_SEQ_SEQ(seq)  (((seq) & IEEE80211_SCTL_SEQ) >> 4)
515 
516 #define WLAN_CAPABILITY_BSS (1<<0)
517 #define WLAN_CAPABILITY_IBSS (1<<1)
518 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
519 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
520 #define WLAN_CAPABILITY_PRIVACY (1<<4)
521 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
522 #define WLAN_CAPABILITY_PBCC (1<<6)
523 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
524 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
525 #define WLAN_CAPABILITY_QOS (1<<9)
526 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
527 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
528 
529 /* 802.11g ERP information element */
530 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
531 #define WLAN_ERP_USE_PROTECTION (1<<1)
532 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
533 
534 #define IEEE80211_STATMASK_SIGNAL (1<<0)
535 #define IEEE80211_STATMASK_RSSI (1<<1)
536 #define IEEE80211_STATMASK_NOISE (1<<2)
537 #define IEEE80211_STATMASK_RATE (1<<3)
538 #define IEEE80211_STATMASK_WEMASK 0x7
539 
540 #define IEEE80211_CCK_MODULATION    (1<<0)
541 #define IEEE80211_OFDM_MODULATION   (1<<1)
542 
543 #define IEEE80211_24GHZ_BAND     (1<<0)
544 #define IEEE80211_52GHZ_BAND     (1<<1)
545 
546 #define IEEE80211_CCK_RATE_LEN			4
547 #define IEEE80211_CCK_RATE_1MB			0x02
548 #define IEEE80211_CCK_RATE_2MB			0x04
549 #define IEEE80211_CCK_RATE_5MB			0x0B
550 #define IEEE80211_CCK_RATE_11MB			0x16
551 #define IEEE80211_OFDM_RATE_LEN			8
552 #define IEEE80211_OFDM_RATE_6MB			0x0C
553 #define IEEE80211_OFDM_RATE_9MB			0x12
554 #define IEEE80211_OFDM_RATE_12MB		0x18
555 #define IEEE80211_OFDM_RATE_18MB		0x24
556 #define IEEE80211_OFDM_RATE_24MB		0x30
557 #define IEEE80211_OFDM_RATE_36MB		0x48
558 #define IEEE80211_OFDM_RATE_48MB		0x60
559 #define IEEE80211_OFDM_RATE_54MB		0x6C
560 #define IEEE80211_BASIC_RATE_MASK		0x80
561 
562 #define IEEE80211_CCK_RATE_1MB_MASK		(1<<0)
563 #define IEEE80211_CCK_RATE_2MB_MASK		(1<<1)
564 #define IEEE80211_CCK_RATE_5MB_MASK		(1<<2)
565 #define IEEE80211_CCK_RATE_11MB_MASK		(1<<3)
566 #define IEEE80211_OFDM_RATE_6MB_MASK		(1<<4)
567 #define IEEE80211_OFDM_RATE_9MB_MASK		(1<<5)
568 #define IEEE80211_OFDM_RATE_12MB_MASK		(1<<6)
569 #define IEEE80211_OFDM_RATE_18MB_MASK		(1<<7)
570 #define IEEE80211_OFDM_RATE_24MB_MASK		(1<<8)
571 #define IEEE80211_OFDM_RATE_36MB_MASK		(1<<9)
572 #define IEEE80211_OFDM_RATE_48MB_MASK		(1<<10)
573 #define IEEE80211_OFDM_RATE_54MB_MASK		(1<<11)
574 
575 #define IEEE80211_CCK_RATES_MASK		0x0000000F
576 #define IEEE80211_CCK_BASIC_RATES_MASK	(IEEE80211_CCK_RATE_1MB_MASK | \
577 	IEEE80211_CCK_RATE_2MB_MASK)
578 #define IEEE80211_CCK_DEFAULT_RATES_MASK	(IEEE80211_CCK_BASIC_RATES_MASK | \
579 	IEEE80211_CCK_RATE_5MB_MASK | \
580 	IEEE80211_CCK_RATE_11MB_MASK)
581 
582 #define IEEE80211_OFDM_RATES_MASK		0x00000FF0
583 #define IEEE80211_OFDM_BASIC_RATES_MASK	(IEEE80211_OFDM_RATE_6MB_MASK | \
584 	IEEE80211_OFDM_RATE_12MB_MASK | \
585 	IEEE80211_OFDM_RATE_24MB_MASK)
586 #define IEEE80211_OFDM_DEFAULT_RATES_MASK	(IEEE80211_OFDM_BASIC_RATES_MASK | \
587 	IEEE80211_OFDM_RATE_9MB_MASK  | \
588 	IEEE80211_OFDM_RATE_18MB_MASK | \
589 	IEEE80211_OFDM_RATE_36MB_MASK | \
590 	IEEE80211_OFDM_RATE_48MB_MASK | \
591 	IEEE80211_OFDM_RATE_54MB_MASK)
592 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
593 				IEEE80211_CCK_DEFAULT_RATES_MASK)
594 
595 #define IEEE80211_NUM_OFDM_RATES	    8
596 #define IEEE80211_NUM_CCK_RATES		    4
597 #define IEEE80211_OFDM_SHIFT_MASK_A         4
598 
599 
600 /* this is stolen and modified from the madwifi driver*/
601 #define IEEE80211_FC0_TYPE_MASK		0x0c
602 #define IEEE80211_FC0_TYPE_DATA		0x08
603 #define IEEE80211_FC0_SUBTYPE_MASK	0xB0
604 #define IEEE80211_FC0_SUBTYPE_QOS	0x80
605 
606 #define IEEE80211_QOS_HAS_SEQ(fc) \
607 	(((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
608 	 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
609 
610 /* this is stolen from ipw2200 driver */
611 #define IEEE_IBSS_MAC_HASH_SIZE 31
612 struct ieee_ibss_seq {
613 	u8 mac[ETH_ALEN];
614 	u16 seq_num[17];
615 	u16 frag_num[17];
616 	unsigned long packet_time[17];
617 	struct list_head list;
618 };
619 
620 /* NOTE: This data is for statistical purposes; not all hardware provides this
621  *       information for frames received.  Not setting these will not cause
622  *       any adverse affects.
623  */
624 struct ieee80211_rx_stats {
625 	u32 mac_time[2];
626 	s8 rssi;
627 	u8 signal;
628 	u8 noise;
629 	u16 rate; /* in 100 kbps */
630 	u8 received_channel;
631 	u8 control;
632 	u8 mask;
633 	u8 freq;
634 	u16 len;
635 	u64 tsf;
636 	u32 beacon_time;
637 	u8 nic_type;
638 	u16       Length;
639 	//      u8        DataRate;      // In 0.5 Mbps
640 	u8        SignalQuality; // in 0-100 index.
641 	s32       RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation.
642 	s8        RxPower; // in dBm Translate from PWdB
643 	u8        SignalStrength; // in 0-100 index.
644 	u16       bHwError:1;
645 	u16       bCRC:1;
646 	u16       bICV:1;
647 	u16       bShortPreamble:1;
648 	u16       Antenna:1;      //for rtl8185
649 	u16       Decrypted:1;    //for rtl8185, rtl8187
650 	u16       Wakeup:1;       //for rtl8185
651 	u16       Reserved0:1;    //for rtl8185
652 	u8        AGC;
653 	u32       TimeStampLow;
654 	u32       TimeStampHigh;
655 	bool      bShift;
656 	bool      bIsQosData;             // Added by Annie, 2005-12-22.
657 	u8        UserPriority;
658 
659 	//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
660 	//1Attention Please!!!<11n or 8190 specific code should be put below this line>
661 	//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
662 
663 	u8        RxDrvInfoSize;
664 	u8        RxBufShift;
665 	bool      bIsAMPDU;
666 	bool      bFirstMPDU;
667 	bool      bContainHTC;
668 	bool      RxIs40MHzPacket;
669 	u32       RxPWDBAll;
670 	u8        RxMIMOSignalStrength[4];        // in 0~100 index
671 	s8        RxMIMOSignalQuality[2];
672 	bool      bPacketMatchBSSID;
673 	bool      bIsCCK;
674 	bool      bPacketToSelf;
675 	//added by amy
676 	u8        *virtual_address;
677 	u16          packetlength;              // Total packet length: Must equal to sum of all FragLength
678 	u16          fraglength;                        // FragLength should equal to PacketLength in non-fragment case
679 	u16          fragoffset;                        // Data offset for this fragment
680 	u16          ntotalfrag;
681 	bool		  bisrxaggrsubframe;
682 	bool		  bPacketBeacon;	//cosa add for rssi
683 	bool		  bToSelfBA;		//cosa add for rssi
684 	s8		  cck_adc_pwdb[4];	//cosa add for rx path selection
685 	u16		  Seq_Num;
686 
687 };
688 
689 /* IEEE 802.11 requires that STA supports concurrent reception of at least
690  * three fragmented frames. This define can be increased to support more
691  * concurrent frames, but it should be noted that each entry can consume about
692  * 2 kB of RAM and increasing cache size will slow down frame reassembly.
693  */
694 #define IEEE80211_FRAG_CACHE_LEN 4
695 
696 struct ieee80211_frag_entry {
697 	unsigned long first_frag_time;
698 	unsigned int seq;
699 	unsigned int last_frag;
700 	struct sk_buff *skb;
701 	u8 src_addr[ETH_ALEN];
702 	u8 dst_addr[ETH_ALEN];
703 };
704 
705 struct ieee80211_stats {
706 	unsigned int tx_unicast_frames;
707 	unsigned int tx_multicast_frames;
708 	unsigned int tx_fragments;
709 	unsigned int tx_unicast_octets;
710 	unsigned int tx_multicast_octets;
711 	unsigned int tx_deferred_transmissions;
712 	unsigned int tx_single_retry_frames;
713 	unsigned int tx_multiple_retry_frames;
714 	unsigned int tx_retry_limit_exceeded;
715 	unsigned int tx_discards;
716 	unsigned int rx_unicast_frames;
717 	unsigned int rx_multicast_frames;
718 	unsigned int rx_fragments;
719 	unsigned int rx_unicast_octets;
720 	unsigned int rx_multicast_octets;
721 	unsigned int rx_fcs_errors;
722 	unsigned int rx_discards_no_buffer;
723 	unsigned int tx_discards_wrong_sa;
724 	unsigned int rx_discards_undecryptable;
725 	unsigned int rx_message_in_msg_fragments;
726 	unsigned int rx_message_in_bad_msg_fragments;
727 };
728 
729 struct ieee80211_device;
730 
731 #include "ieee80211_crypt.h"
732 
733 #define SEC_KEY_1         (1<<0)
734 #define SEC_KEY_2         (1<<1)
735 #define SEC_KEY_3         (1<<2)
736 #define SEC_KEY_4         (1<<3)
737 #define SEC_ACTIVE_KEY    (1<<4)
738 #define SEC_AUTH_MODE     (1<<5)
739 #define SEC_UNICAST_GROUP (1<<6)
740 #define SEC_LEVEL         (1<<7)
741 #define SEC_ENABLED       (1<<8)
742 #define SEC_ENCRYPT       (1<<9)
743 
744 #define SEC_LEVEL_0      0 /* None */
745 #define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
746 #define SEC_LEVEL_2      2 /* Level 1 + TKIP */
747 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
748 #define SEC_LEVEL_3      4 /* Level 2 + CCMP */
749 
750 #define SEC_ALG_NONE            0
751 #define SEC_ALG_WEP             1
752 #define SEC_ALG_TKIP            2
753 #define SEC_ALG_CCMP            3
754 
755 #define WEP_KEYS		4
756 #define WEP_KEY_LEN		13
757 #define SCM_KEY_LEN             32
758 #define SCM_TEMPORAL_KEY_LENGTH 16
759 
760 struct ieee80211_security {
761 	u16 active_key:2,
762 	    enabled:1,
763 	    auth_algo:4,
764 	    unicast_uses_group:1,
765 	    encrypt:1;
766 	u8 auth_mode;
767 	u8 key_sizes[WEP_KEYS];
768 	u8 keys[WEP_KEYS][SCM_KEY_LEN];
769 	u8 level;
770 	u16 flags;
771 } __packed;
772 
773 
774 /*
775  *  802.11 data frame from AP
776  *       ,-------------------------------------------------------------------.
777  * Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
778  *       |------|------|---------|---------|---------|------|---------|------|
779  * Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
780  *       |      | tion | (BSSID) |         |         | ence |  data   |      |
781  *       `-------------------------------------------------------------------'
782  *  Total: 28-2340 bytes
783  */
784 
785 /* Management Frame Information Element Types */
786 enum ieee80211_mfie {
787 	MFIE_TYPE_SSID = 0,
788 	MFIE_TYPE_RATES = 1,
789 	MFIE_TYPE_FH_SET = 2,
790 	MFIE_TYPE_DS_SET = 3,
791 	MFIE_TYPE_CF_SET = 4,
792 	MFIE_TYPE_TIM = 5,
793 	MFIE_TYPE_IBSS_SET = 6,
794 	MFIE_TYPE_COUNTRY = 7,
795 	MFIE_TYPE_HOP_PARAMS = 8,
796 	MFIE_TYPE_HOP_TABLE = 9,
797 	MFIE_TYPE_REQUEST = 10,
798 	MFIE_TYPE_CHALLENGE = 16,
799 	MFIE_TYPE_POWER_CONSTRAINT = 32,
800 	MFIE_TYPE_POWER_CAPABILITY = 33,
801 	MFIE_TYPE_TPC_REQUEST = 34,
802 	MFIE_TYPE_TPC_REPORT = 35,
803 	MFIE_TYPE_SUPP_CHANNELS = 36,
804 	MFIE_TYPE_CSA = 37,
805 	MFIE_TYPE_MEASURE_REQUEST = 38,
806 	MFIE_TYPE_MEASURE_REPORT = 39,
807 	MFIE_TYPE_QUIET = 40,
808 	MFIE_TYPE_IBSS_DFS = 41,
809 	MFIE_TYPE_ERP = 42,
810 	MFIE_TYPE_RSN = 48,
811 	MFIE_TYPE_RATES_EX = 50,
812 	MFIE_TYPE_HT_CAP = 45,
813 	 MFIE_TYPE_HT_INFO = 61,
814 	 MFIE_TYPE_AIRONET = 133,
815 	MFIE_TYPE_GENERIC = 221,
816 	MFIE_TYPE_QOS_PARAMETER = 222,
817 };
818 
819 /* Minimal header; can be used for passing 802.11 frames with sufficient
820  * information to determine what type of underlying data type is actually
821  * stored in the data.
822  */
823 struct rtl_80211_hdr {
824 	__le16 frame_ctl;
825 	__le16 duration_id;
826 	u8 payload[];
827 } __packed;
828 
829 struct rtl_80211_hdr_1addr {
830 	__le16 frame_ctl;
831 	__le16 duration_id;
832 	u8 addr1[ETH_ALEN];
833 	u8 payload[];
834 } __packed;
835 
836 struct rtl_80211_hdr_2addr {
837 	__le16 frame_ctl;
838 	__le16 duration_id;
839 	u8 addr1[ETH_ALEN];
840 	u8 addr2[ETH_ALEN];
841 	u8 payload[];
842 } __packed;
843 
844 struct rtl_80211_hdr_3addr {
845 	__le16 frame_ctl;
846 	__le16 duration_id;
847 	u8 addr1[ETH_ALEN];
848 	u8 addr2[ETH_ALEN];
849 	u8 addr3[ETH_ALEN];
850 	__le16 seq_ctl;
851 	u8 payload[];
852 } __packed;
853 
854 struct rtl_80211_hdr_4addr {
855 	__le16 frame_ctl;
856 	__le16 duration_id;
857 	u8 addr1[ETH_ALEN];
858 	u8 addr2[ETH_ALEN];
859 	u8 addr3[ETH_ALEN];
860 	__le16 seq_ctl;
861 	u8 addr4[ETH_ALEN];
862 	u8 payload[];
863 } __packed;
864 
865 struct rtl_80211_hdr_3addrqos {
866 	__le16 frame_ctl;
867 	__le16 duration_id;
868 	u8 addr1[ETH_ALEN];
869 	u8 addr2[ETH_ALEN];
870 	u8 addr3[ETH_ALEN];
871 	__le16 seq_ctl;
872 	u8 payload[0];
873 	__le16 qos_ctl;
874 } __packed;
875 
876 struct rtl_80211_hdr_4addrqos {
877 	__le16 frame_ctl;
878 	__le16 duration_id;
879 	u8 addr1[ETH_ALEN];
880 	u8 addr2[ETH_ALEN];
881 	u8 addr3[ETH_ALEN];
882 	__le16 seq_ctl;
883 	u8 addr4[ETH_ALEN];
884 	u8 payload[0];
885 	__le16 qos_ctl;
886 } __packed;
887 
888 struct ieee80211_info_element {
889 	u8 id;
890 	u8 len;
891 	u8 data[];
892 } __packed;
893 
894 struct ieee80211_authentication {
895 	struct rtl_80211_hdr_3addr header;
896 	__le16 algorithm;
897 	__le16 transaction;
898 	__le16 status;
899 	/*challenge*/
900 	struct ieee80211_info_element info_element[];
901 } __packed;
902 
903 struct ieee80211_disassoc {
904 	struct rtl_80211_hdr_3addr header;
905 	__le16 reason;
906 } __packed;
907 
908 struct ieee80211_probe_request {
909 	struct rtl_80211_hdr_3addr header;
910 	/* SSID, supported rates */
911 	struct ieee80211_info_element info_element[];
912 } __packed;
913 
914 struct ieee80211_probe_response {
915 	struct rtl_80211_hdr_3addr header;
916 	__le32 time_stamp[2];
917 	__le16 beacon_interval;
918 	__le16 capability;
919 	/* SSID, supported rates, FH params, DS params,
920 	 * CF params, IBSS params, TIM (if beacon), RSN
921 	 */
922 	struct ieee80211_info_element info_element[];
923 } __packed;
924 
925 /* Alias beacon for probe_response */
926 #define ieee80211_beacon ieee80211_probe_response
927 
928 struct ieee80211_assoc_request_frame {
929 	struct rtl_80211_hdr_3addr header;
930 	__le16 capability;
931 	__le16 listen_interval;
932 	/* SSID, supported rates, RSN */
933 	struct ieee80211_info_element info_element[];
934 } __packed;
935 
936 struct ieee80211_reassoc_request_frame {
937 	struct rtl_80211_hdr_3addr header;
938 	__le16 capability;
939 	__le16 listen_interval;
940 	u8 current_ap[ETH_ALEN];
941 	/* SSID, supported rates, RSN */
942 	struct ieee80211_info_element info_element[];
943 } __packed;
944 
945 struct ieee80211_assoc_response_frame {
946 	struct rtl_80211_hdr_3addr header;
947 	__le16 capability;
948 	__le16 status;
949 	__le16 aid;
950 	struct ieee80211_info_element info_element[]; /* supported rates */
951 } __packed;
952 
953 struct ieee80211_txb {
954 	u8 nr_frags;
955 	u8 encrypted;
956 	u8 queue_index;
957 	u8 rts_included;
958 	u16 reserved;
959 	__le16 frag_size;
960 	__le16 payload_size;
961 	struct sk_buff *fragments[];
962 };
963 
964 #define MAX_TX_AGG_COUNT		  16
965 struct ieee80211_drv_agg_txb {
966 	u8 nr_drv_agg_frames;
967 	struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
968 } __packed;
969 
970 #define MAX_SUBFRAME_COUNT		  64
971 struct ieee80211_rxb {
972 	u8 nr_subframes;
973 	struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
974 	u8 dst[ETH_ALEN];
975 	u8 src[ETH_ALEN];
976 } __packed;
977 
978 typedef union _frameqos {
979 	u16 shortdata;
980 	u8  chardata[2];
981 	struct {
982 		u16 tid:4;
983 		u16 eosp:1;
984 		u16 ack_policy:2;
985 		u16 reserved:1;
986 		u16 txop:8;
987 	} field;
988 } frameqos, *pframeqos;
989 
990 /* SWEEP TABLE ENTRIES NUMBER*/
991 #define MAX_SWEEP_TAB_ENTRIES		  42
992 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
993 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
994  * only use 8, and then use extended rates for the remaining supported
995  * rates.  Other APs, however, stick all of their supported rates on the
996  * main rates information element...
997  */
998 #define MAX_RATES_LENGTH                  ((u8)12)
999 #define MAX_RATES_EX_LENGTH               ((u8)16)
1000 #define MAX_NETWORK_COUNT                  128
1001 
1002 #define MAX_CHANNEL_NUMBER                 161
1003 #define IEEE80211_SOFTMAC_SCAN_TIME	   100
1004 //(HZ / 2)
1005 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1006 
1007 #define CRC_LENGTH                 4U
1008 
1009 #define MAX_WPA_IE_LEN 64
1010 
1011 #define NETWORK_EMPTY_ESSID (1<<0)
1012 #define NETWORK_HAS_OFDM    (1<<1)
1013 #define NETWORK_HAS_CCK     (1<<2)
1014 
1015 /* QoS structure */
1016 #define NETWORK_HAS_QOS_PARAMETERS      (1<<3)
1017 #define NETWORK_HAS_QOS_INFORMATION     (1<<4)
1018 #define NETWORK_HAS_QOS_MASK            (NETWORK_HAS_QOS_PARAMETERS | \
1019 					 NETWORK_HAS_QOS_INFORMATION)
1020 /* 802.11h */
1021 #define NETWORK_HAS_POWER_CONSTRAINT    (1<<5)
1022 #define NETWORK_HAS_CSA                 (1<<6)
1023 #define NETWORK_HAS_QUIET               (1<<7)
1024 #define NETWORK_HAS_IBSS_DFS            (1<<8)
1025 #define NETWORK_HAS_TPC_REPORT          (1<<9)
1026 
1027 #define NETWORK_HAS_ERP_VALUE           (1<<10)
1028 
1029 #define QOS_QUEUE_NUM                   4
1030 #define QOS_OUI_LEN                     3
1031 #define QOS_OUI_TYPE                    2
1032 #define QOS_ELEMENT_ID                  221
1033 #define QOS_OUI_INFO_SUB_TYPE           0
1034 #define QOS_OUI_PARAM_SUB_TYPE          1
1035 #define QOS_VERSION_1                   1
1036 #define QOS_AIFSN_MIN_VALUE             2
1037 struct ieee80211_qos_information_element {
1038 	u8 elementID;
1039 	u8 length;
1040 	u8 qui[QOS_OUI_LEN];
1041 	u8 qui_type;
1042 	u8 qui_subtype;
1043 	u8 version;
1044 	u8 ac_info;
1045 } __packed;
1046 
1047 struct ieee80211_qos_ac_parameter {
1048 	u8 aci_aifsn;
1049 	u8 ecw_min_max;
1050 	__le16 tx_op_limit;
1051 } __packed;
1052 
1053 struct ieee80211_qos_parameter_info {
1054 	struct ieee80211_qos_information_element info_element;
1055 	u8 reserved;
1056 	struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1057 } __packed;
1058 
1059 struct ieee80211_qos_parameters {
1060 	__le16 cw_min[QOS_QUEUE_NUM];
1061 	__le16 cw_max[QOS_QUEUE_NUM];
1062 	u8 aifs[QOS_QUEUE_NUM];
1063 	u8 flag[QOS_QUEUE_NUM];
1064 	__le16 tx_op_limit[QOS_QUEUE_NUM];
1065 } __packed;
1066 
1067 struct ieee80211_qos_data {
1068 	struct ieee80211_qos_parameters parameters;
1069 	int active;
1070 	int supported;
1071 	u8 param_count;
1072 	u8 old_param_count;
1073 };
1074 
1075 struct ieee80211_tim_parameters {
1076 	u8 tim_count;
1077 	u8 tim_period;
1078 } __packed;
1079 
1080 //#else
1081 struct ieee80211_wmm_ts_info {
1082 	u8 ac_dir_tid;
1083 	u8 ac_up_psb;
1084 	u8 reserved;
1085 } __packed;
1086 
1087 struct ieee80211_wmm_tspec_elem {
1088 	struct ieee80211_wmm_ts_info ts_info;
1089 	u16 norm_msdu_size;
1090 	u16 max_msdu_size;
1091 	u32 min_serv_inter;
1092 	u32 max_serv_inter;
1093 	u32 inact_inter;
1094 	u32 suspen_inter;
1095 	u32 serv_start_time;
1096 	u32 min_data_rate;
1097 	u32 mean_data_rate;
1098 	u32 peak_data_rate;
1099 	u32 max_burst_size;
1100 	u32 delay_bound;
1101 	u32 min_phy_rate;
1102 	u16 surp_band_allow;
1103 	u16 medium_time;
1104 } __packed;
1105 enum eap_type {
1106 	EAP_PACKET = 0,
1107 	EAPOL_START,
1108 	EAPOL_LOGOFF,
1109 	EAPOL_KEY,
1110 	EAPOL_ENCAP_ASF_ALERT
1111 };
1112 
1113 static const char *eap_types[] = {
1114 	[EAP_PACKET]		= "EAP-Packet",
1115 	[EAPOL_START]		= "EAPOL-Start",
1116 	[EAPOL_LOGOFF]		= "EAPOL-Logoff",
1117 	[EAPOL_KEY]		= "EAPOL-Key",
1118 	[EAPOL_ENCAP_ASF_ALERT]	= "EAPOL-Encap-ASF-Alert"
1119 };
1120 
eap_get_type(int type)1121 static inline const char *eap_get_type(int type)
1122 {
1123 	return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1124 }
1125 //added by amy for reorder
Frame_QoSTID(u8 * buf)1126 static inline u8 Frame_QoSTID(u8 *buf)
1127 {
1128 	struct rtl_80211_hdr_3addr *hdr;
1129 	u16 fc;
1130 	hdr = (struct rtl_80211_hdr_3addr *)buf;
1131 	fc = le16_to_cpu(hdr->frame_ctl);
1132 	return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1133 }
1134 
1135 //added by amy for reorder
1136 
1137 struct eapol {
1138 	u8 snap[6];
1139 	u16 ethertype;
1140 	u8 version;
1141 	u8 type;
1142 	u16 length;
1143 } __packed;
1144 
1145 struct ieee80211_softmac_stats {
1146 	unsigned int rx_ass_ok;
1147 	unsigned int rx_ass_err;
1148 	unsigned int rx_probe_rq;
1149 	unsigned int tx_probe_rs;
1150 	unsigned int tx_beacons;
1151 	unsigned int rx_auth_rq;
1152 	unsigned int rx_auth_rs_ok;
1153 	unsigned int rx_auth_rs_err;
1154 	unsigned int tx_auth_rq;
1155 	unsigned int no_auth_rs;
1156 	unsigned int no_ass_rs;
1157 	unsigned int tx_ass_rq;
1158 	unsigned int rx_ass_rq;
1159 	unsigned int tx_probe_rq;
1160 	unsigned int reassoc;
1161 	unsigned int swtxstop;
1162 	unsigned int swtxawake;
1163 	unsigned char CurrentShowTxate;
1164 	unsigned char last_packet_rate;
1165 	unsigned int txretrycount;
1166 };
1167 
1168 #define BEACON_PROBE_SSID_ID_POSITION 12
1169 
1170 struct ieee80211_info_element_hdr {
1171 	u8 id;
1172 	u8 len;
1173 } __packed;
1174 
1175 /*
1176  * These are the data types that can make up management packets
1177  *
1178 	u16 auth_algorithm;
1179 	u16 auth_sequence;
1180 	u16 beacon_interval;
1181 	u16 capability;
1182 	u8 current_ap[ETH_ALEN];
1183 	u16 listen_interval;
1184 	struct {
1185 		u16 association_id:14, reserved:2;
1186 	} __packed;
1187 	u32 time_stamp[2];
1188 	u16 reason;
1189 	u16 status;
1190 */
1191 
1192 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
1193 #define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
1194 
1195 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1196 #define MAX_SP_Len  (WMM_all_frame << 4)
1197 #define IEEE80211_QOS_TID 0x0f
1198 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1199 
1200 #define IEEE80211_DTIM_MBCAST 4
1201 #define IEEE80211_DTIM_UCAST 2
1202 #define IEEE80211_DTIM_VALID 1
1203 #define IEEE80211_DTIM_INVALID 0
1204 
1205 #define IEEE80211_PS_DISABLED 0
1206 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
1207 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
1208 
1209 //added by David for QoS 2006/6/30
1210 //#define WMM_Hang_8187
1211 #ifdef WMM_Hang_8187
1212 #undef WMM_Hang_8187
1213 #endif
1214 
1215 #define WME_AC_BK   0x00
1216 #define WME_AC_BE   0x01
1217 #define WME_AC_VI   0x02
1218 #define WME_AC_VO   0x03
1219 #define WME_ACI_MASK 0x03
1220 #define WME_AIFSN_MASK 0x03
1221 #define WME_AC_PRAM_LEN 16
1222 
1223 #define MAX_RECEIVE_BUFFER_SIZE 9100
1224 
1225 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
1226 //#define UP2AC(up)	((up<3) ? ((up==0)?1:0) : (up>>1))
1227 #define UP2AC(up) (		   \
1228 	((up) < 1) ? WME_AC_BE : \
1229 	((up) < 3) ? WME_AC_BK : \
1230 	((up) < 4) ? WME_AC_BE : \
1231 	((up) < 6) ? WME_AC_VI : \
1232 	WME_AC_VO)
1233 //AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
1234 #define AC2UP(_ac)	(       \
1235 	((_ac) == WME_AC_VO) ? 6 : \
1236 	((_ac) == WME_AC_VI) ? 5 : \
1237 	((_ac) == WME_AC_BK) ? 1 : \
1238 	0)
1239 
1240 #define	ETHER_ADDR_LEN		6	/* length of an Ethernet address */
1241 #define ETHERNET_HEADER_SIZE    14      /* length of two Ethernet address plus ether type*/
1242 
1243 struct	ether_header {
1244 	u8 ether_dhost[ETHER_ADDR_LEN];
1245 	u8 ether_shost[ETHER_ADDR_LEN];
1246 	u16 ether_type;
1247 } __packed;
1248 
1249 #ifndef ETHERTYPE_PAE
1250 #define	ETHERTYPE_PAE	0x888e		/* EAPOL PAE/802.1x */
1251 #endif
1252 #ifndef ETHERTYPE_IP
1253 #define	ETHERTYPE_IP	0x0800		/* IP protocol */
1254 #endif
1255 
1256 typedef enum _erp_t {
1257 	ERP_NonERPpresent	= 0x01,
1258 	ERP_UseProtection	= 0x02,
1259 	ERP_BarkerPreambleMode = 0x04,
1260 } erp_t;
1261 
1262 
1263 struct ieee80211_network {
1264 	/* These entries are used to identify a unique network */
1265 	u8 bssid[ETH_ALEN];   /* u16 aligned! */
1266 	u8 channel;
1267 
1268 	// CCXv4 S59, MBSSID.
1269 	bool	bMBssidValid;
1270 	u8	MBssid[ETH_ALEN];    /* u16 aligned! */
1271 	u8	MBssidMask;
1272 	/* Ensure null-terminated for any debug msgs */
1273 	u8 ssid[IW_ESSID_MAX_SIZE + 1];
1274 	u8 ssid_len;
1275 	struct ieee80211_qos_data qos_data;
1276 
1277 	//added by amy for LEAP
1278 	bool	bWithAironetIE;
1279 	bool	bCkipSupported;
1280 	bool	bCcxRmEnable;
1281 	u16	CcxRmState[2];
1282 	// CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
1283 	bool	bWithCcxVerNum;
1284 	u8	BssCcxVerNumber;
1285 	/* These are network statistics */
1286 	struct ieee80211_rx_stats stats;
1287 	u16 capability;
1288 	u8  rates[MAX_RATES_LENGTH];
1289 	u8  rates_len;
1290 	u8  rates_ex[MAX_RATES_EX_LENGTH];
1291 	u8  rates_ex_len;
1292 	unsigned long last_scanned;
1293 	u8  mode;
1294 	u32 flags;
1295 	u32 last_associate;
1296 	u32 time_stamp[2];
1297 	u16 beacon_interval;
1298 	u16 listen_interval;
1299 	u16 atim_window;
1300 	u8  erp_value;
1301 	u8  wpa_ie[MAX_WPA_IE_LEN];
1302 	size_t wpa_ie_len;
1303 	u8  rsn_ie[MAX_WPA_IE_LEN];
1304 	size_t rsn_ie_len;
1305 
1306 	struct ieee80211_tim_parameters tim;
1307 	u8  dtim_period;
1308 	u8  dtim_data;
1309 	u32 last_dtim_sta_time[2];
1310 
1311 	//appeded for QoS
1312 	u8 wmm_info;
1313 	struct ieee80211_wmm_ac_param wmm_param[4];
1314 	u8 QoS_Enable;
1315 #ifdef THOMAS_TURBO
1316 	u8 Turbo_Enable;//enable turbo mode, added by thomas
1317 #endif
1318 	u16 CountryIeLen;
1319 	u8 CountryIeBuf[MAX_IE_LEN];
1320 	// HT Related, by amy, 2008.04.29
1321 	BSS_HT	bssht;
1322 	// Add to handle broadcom AP management frame CCK rate.
1323 	bool broadcom_cap_exist;
1324 	bool ralink_cap_exist;
1325 	bool atheros_cap_exist;
1326 	bool cisco_cap_exist;
1327 	bool unknown_cap_exist;
1328 //	u8	berp_info;
1329 	bool	berp_info_valid;
1330 	bool buseprotection;
1331 	//put at the end of the structure.
1332 	struct list_head list;
1333 };
1334 
1335 enum ieee80211_state {
1336 
1337 	/* the card is not linked at all */
1338 	IEEE80211_NOLINK = 0,
1339 
1340 	/* IEEE80211_ASSOCIATING* are for BSS client mode
1341 	 * the driver shall not perform RX filtering unless
1342 	 * the state is LINKED.
1343 	 * The driver shall just check for the state LINKED and
1344 	 * defaults to NOLINK for ALL the other states (including
1345 	 * LINKED_SCANNING)
1346 	 */
1347 
1348 	/* the association procedure will start (wq scheduling)*/
1349 	IEEE80211_ASSOCIATING,
1350 	IEEE80211_ASSOCIATING_RETRY,
1351 
1352 	/* the association procedure is sending AUTH request*/
1353 	IEEE80211_ASSOCIATING_AUTHENTICATING,
1354 
1355 	/* the association procedure has successfully authentcated
1356 	 * and is sending association request
1357 	 */
1358 	IEEE80211_ASSOCIATING_AUTHENTICATED,
1359 
1360 	/* the link is ok. the card associated to a BSS or linked
1361 	 * to a ibss cell or acting as an AP and creating the bss
1362 	 */
1363 	IEEE80211_LINKED,
1364 
1365 	/* same as LINKED, but the driver shall apply RX filter
1366 	 * rules as we are in NO_LINK mode. As the card is still
1367 	 * logically linked, but it is doing a syncro site survey
1368 	 * then it will be back to LINKED state.
1369 	 */
1370 	IEEE80211_LINKED_SCANNING,
1371 
1372 };
1373 
1374 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1375 #define DEFAULT_FTS 2346
1376 
1377 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1378 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1379 #define CFG_IEEE80211_RTS (1<<2)
1380 
1381 #define IEEE80211_24GHZ_MIN_CHANNEL 1
1382 #define IEEE80211_24GHZ_MAX_CHANNEL 14
1383 #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1384 				  IEEE80211_24GHZ_MIN_CHANNEL + 1)
1385 
1386 #define IEEE80211_52GHZ_MIN_CHANNEL 34
1387 #define IEEE80211_52GHZ_MAX_CHANNEL 165
1388 #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1389 				  IEEE80211_52GHZ_MIN_CHANNEL + 1)
1390 
1391 
1392 
1393 struct tx_pending {
1394 	int frag;
1395 	struct ieee80211_txb *txb;
1396 };
1397 
1398 struct bandwidth_autoswitch {
1399 	long threshold_20Mhzto40Mhz;
1400 	long	threshold_40Mhzto20Mhz;
1401 	bool bforced_tx20Mhz;
1402 	bool bautoswitch_enable;
1403 };
1404 
1405 
1406 //added by amy for order
1407 
1408 #define REORDER_WIN_SIZE	128
1409 #define REORDER_ENTRY_NUM	128
1410 struct rx_reorder_entry {
1411 	struct list_head	List;
1412 	u16			SeqNum;
1413 	struct ieee80211_rxb *prxb;
1414 };
1415 //added by amy for order
1416 typedef enum _Fsync_State {
1417 	Default_Fsync,
1418 	HW_Fsync,
1419 	SW_Fsync
1420 } Fsync_State;
1421 
1422 // Power save mode configured.
1423 typedef	enum _RT_PS_MODE {
1424 	eActive,	// Active/Continuous access.
1425 	eMaxPs,		// Max power save mode.
1426 	eFastPs		// Fast power save mode.
1427 } RT_PS_MODE;
1428 
1429 typedef enum _IPS_CALLBACK_FUNCION {
1430 	IPS_CALLBACK_NONE = 0,
1431 	IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1432 	IPS_CALLBACK_JOIN_REQUEST = 2,
1433 } IPS_CALLBACK_FUNCION;
1434 
1435 typedef enum _RT_JOIN_ACTION {
1436 	RT_JOIN_INFRA   = 1,
1437 	RT_JOIN_IBSS  = 2,
1438 	RT_START_IBSS = 3,
1439 	RT_NO_ACTION  = 4,
1440 } RT_JOIN_ACTION;
1441 
1442 struct ibss_parms {
1443 	u16   atimWin;
1444 };
1445 #define MAX_NUM_RATES	264 // Max num of support rates element: 8,  Max num of ext. support rate: 255. 061122, by rcnjko.
1446 
1447 // RF state.
1448 typedef	enum _RT_RF_POWER_STATE {
1449 	eRfOn,
1450 	eRfSleep,
1451 	eRfOff
1452 } RT_RF_POWER_STATE;
1453 
1454 struct rt_power_save_control {
1455 
1456 	//
1457 	// Inactive Power Save(IPS) : Disable RF when disconnected
1458 	//
1459 	bool				bInactivePs;
1460 	bool				bIPSModeBackup;
1461 	bool				bSwRfProcessing;
1462 	RT_RF_POWER_STATE	eInactivePowerState;
1463 	struct work_struct	InactivePsWorkItem;
1464 	struct timer_list	InactivePsTimer;
1465 
1466 	// Return point for join action
1467 	IPS_CALLBACK_FUNCION	ReturnPoint;
1468 
1469 	// Recored Parameters for rescheduled JoinRequest
1470 	bool				bTmpBssDesc;
1471 	RT_JOIN_ACTION		tmpJoinAction;
1472 	struct ieee80211_network tmpBssDesc;
1473 
1474 	// Recored Parameters for rescheduled MgntLinkRequest
1475 	bool				bTmpScanOnly;
1476 	bool				bTmpActiveScan;
1477 	bool				bTmpFilterHiddenAP;
1478 	bool				bTmpUpdateParms;
1479 	u8					tmpSsidBuf[33];
1480 	struct octet_string			tmpSsid2Scan;
1481 	bool				bTmpSsid2Scan;
1482 	u8					tmpNetworkType;
1483 	u8					tmpChannelNumber;
1484 	u16					tmpBcnPeriod;
1485 	u8					tmpDtimPeriod;
1486 	u16					tmpmCap;
1487 	struct octet_string			tmpSuppRateSet;
1488 	u8					tmpSuppRateBuf[MAX_NUM_RATES];
1489 	bool				bTmpSuppRate;
1490 	struct ibss_parms			tmpIbpm;
1491 	bool				bTmpIbpm;
1492 
1493 	//
1494 	// Leisre Poswer Save : Disable RF if connected but traffic is not busy
1495 	//
1496 	bool				bLeisurePs;
1497 
1498 };
1499 
1500 typedef u32 RT_RF_CHANGE_SOURCE;
1501 #define RF_CHANGE_BY_SW		BIT(31)
1502 #define RF_CHANGE_BY_HW		BIT(30)
1503 #define RF_CHANGE_BY_PS		BIT(29)
1504 #define RF_CHANGE_BY_IPS	BIT(28)
1505 #define RF_CHANGE_BY_INIT	0	// Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
1506 
1507 typedef enum {
1508 	COUNTRY_CODE_FCC = 0,
1509 	COUNTRY_CODE_IC = 1,
1510 	COUNTRY_CODE_ETSI = 2,
1511 	COUNTRY_CODE_SPAIN = 3,
1512 	COUNTRY_CODE_FRANCE = 4,
1513 	COUNTRY_CODE_MKK = 5,
1514 	COUNTRY_CODE_MKK1 = 6,
1515 	COUNTRY_CODE_ISRAEL = 7,
1516 	COUNTRY_CODE_TELEC,
1517 	COUNTRY_CODE_MIC,
1518 	COUNTRY_CODE_GLOBAL_DOMAIN
1519 } country_code_type_t;
1520 
1521 #define RT_MAX_LD_SLOT_NUM	10
1522 struct rt_link_detect {
1523 
1524 	u32				NumRecvBcnInPeriod;
1525 	u32				NumRecvDataInPeriod;
1526 
1527 	u32				RxBcnNum[RT_MAX_LD_SLOT_NUM];	// number of Rx beacon / CheckForHang_period  to determine link status
1528 	u32				RxDataNum[RT_MAX_LD_SLOT_NUM];	// number of Rx data / CheckForHang_period  to determine link status
1529 	u16				SlotNum;	// number of CheckForHang period to determine link status
1530 	u16				SlotIndex;
1531 
1532 	u32				NumTxOkInPeriod;
1533 	u32				NumRxOkInPeriod;
1534 	bool				bBusyTraffic;
1535 };
1536 
1537 
1538 struct ieee80211_device {
1539 	struct net_device *dev;
1540 	struct ieee80211_security sec;
1541 
1542 	//hw security related
1543 //	u8 hwsec_support; //support?
1544 	u8 hwsec_active;  //hw security active.
1545 	bool is_silent_reset;
1546 	bool ieee_up;
1547 	//added by amy
1548 	bool bSupportRemoteWakeUp;
1549 	RT_PS_MODE	dot11PowerSaveMode; // Power save mode configured.
1550 	bool actscanning;
1551 	bool beinretry;
1552 	RT_RF_POWER_STATE		eRFPowerState;
1553 	RT_RF_CHANGE_SOURCE	RfOffReason;
1554 	bool is_set_key;
1555 	//11n spec related I wonder if These info structure need to be moved out of ieee80211_device
1556 
1557 	//11n HT below
1558 	PRT_HIGH_THROUGHPUT	pHTInfo;
1559 	//struct timer_list		SwBwTimer;
1560 //	spinlock_t chnlop_spinlock;
1561 	spinlock_t bw_spinlock;
1562 
1563 	spinlock_t reorder_spinlock;
1564 	// for HT operation rate set.  we use this one for HT data rate to separate different descriptors
1565 	//the way fill this is the same as in the IE
1566 	u8	Regdot11HTOperationalRateSet[16];		//use RATR format
1567 	u8	dot11HTOperationalRateSet[16];		//use RATR format
1568 	u8	RegHTSuppRateSet[16];
1569 	u8				HTCurrentOperaRate;
1570 	u8				HTHighestOperaRate;
1571 	//wb added for rate operation mode to firmware
1572 	u8	bTxDisableRateFallBack;
1573 	u8	bTxUseDriverAssingedRate;
1574 	atomic_t	atm_chnlop;
1575 	atomic_t	atm_swbw;
1576 //	u8	HTHighestOperaRate;
1577 //	u8	HTCurrentOperaRate;
1578 
1579 	// 802.11e and WMM Traffic Stream Info (TX)
1580 	struct list_head		Tx_TS_Admit_List;
1581 	struct list_head		Tx_TS_Pending_List;
1582 	struct list_head		Tx_TS_Unused_List;
1583 	struct tx_ts_record		TxTsRecord[TOTAL_TS_NUM];
1584 	// 802.11e and WMM Traffic Stream Info (RX)
1585 	struct list_head		Rx_TS_Admit_List;
1586 	struct list_head		Rx_TS_Pending_List;
1587 	struct list_head		Rx_TS_Unused_List;
1588 	struct rx_ts_record		RxTsRecord[TOTAL_TS_NUM];
1589 	struct rx_reorder_entry	RxReorderEntry[128];
1590 	struct list_head		RxReorder_Unused_List;
1591 	// Qos related. Added by Annie, 2005-11-01.
1592 //	PSTA_QOS			pStaQos;
1593 	u8				ForcedPriority;		// Force per-packet priority 1~7. (default: 0, not to force it.)
1594 
1595 
1596 	/* Bookkeeping structures */
1597 	struct net_device_stats stats;
1598 	struct ieee80211_stats ieee_stats;
1599 	struct ieee80211_softmac_stats softmac_stats;
1600 
1601 	/* Probe / Beacon management */
1602 	struct list_head network_free_list;
1603 	struct list_head network_list;
1604 	struct ieee80211_network *networks;
1605 	int scans;
1606 	int scan_age;
1607 
1608 	int iw_mode; /* operating mode (IW_MODE_*) */
1609 	struct iw_spy_data spy_data;
1610 
1611 	spinlock_t lock;
1612 	spinlock_t wpax_suitlist_lock;
1613 
1614 	int tx_headroom; /* Set to size of any additional room needed at front
1615 			  * of allocated Tx SKBs
1616 			  */
1617 	u32 config;
1618 
1619 	/* WEP and other encryption related settings at the device level */
1620 	int open_wep; /* Set to 1 to allow unencrypted frames */
1621 	int auth_mode;
1622 	int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1623 				 * WEP key changes
1624 				 */
1625 
1626 	/* If the host performs {en,de}cryption, then set to 1 */
1627 	int host_encrypt;
1628 	int host_encrypt_msdu;
1629 	int host_decrypt;
1630 	/* host performs multicast decryption */
1631 	int host_mc_decrypt;
1632 
1633 	/* host should strip IV and ICV from protected frames */
1634 	/* meaningful only when hardware decryption is being used */
1635 	int host_strip_iv_icv;
1636 
1637 	int host_open_frag;
1638 	int host_build_iv;
1639 	int ieee802_1x; /* is IEEE 802.1X used */
1640 
1641 	/* WPA data */
1642 	bool bHalfWirelessN24GMode;
1643 	int wpa_enabled;
1644 	int drop_unencrypted;
1645 	int tkip_countermeasures;
1646 	int privacy_invoked;
1647 	size_t wpa_ie_len;
1648 	u8 *wpa_ie;
1649 	u8 ap_mac_addr[6];
1650 	u16 pairwise_key_type;
1651 	u16 group_key_type;
1652 	struct list_head crypt_deinit_list;
1653 	struct ieee80211_crypt_data *crypt[WEP_KEYS];
1654 	int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
1655 	struct timer_list crypt_deinit_timer;
1656 	int crypt_quiesced;
1657 
1658 	int bcrx_sta_key; /* use individual keys to override default keys even
1659 			   * with RX of broad/multicast frames
1660 			   */
1661 
1662 	/* Fragmentation structures */
1663 	// each streaming contain a entry
1664 	struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1665 	unsigned int frag_next_idx[17];
1666 	u16 fts; /* Fragmentation Threshold */
1667 #define DEFAULT_RTS_THRESHOLD 2346U
1668 #define MIN_RTS_THRESHOLD 1
1669 #define MAX_RTS_THRESHOLD 2346U
1670 	u16 rts; /* RTS threshold */
1671 
1672 	/* Association info */
1673 	u8 bssid[ETH_ALEN];
1674 
1675 	/* This stores infos for the current network.
1676 	 * Either the network we are associated in INFRASTRUCTURE
1677 	 * or the network that we are creating in MASTER mode.
1678 	 * ad-hoc is a mixture ;-).
1679 	 * Note that in infrastructure mode, even when not associated,
1680 	 * fields bssid and essid may be valid (if wpa_set and essid_set
1681 	 * are true) as thy carry the value set by the user via iwconfig
1682 	 */
1683 	struct ieee80211_network current_network;
1684 
1685 	enum ieee80211_state state;
1686 
1687 	int short_slot;
1688 	int reg_mode;
1689 	int mode;       /* A, B, G */
1690 	int modulation; /* CCK, OFDM */
1691 	int freq_band;  /* 2.4Ghz, 5.2Ghz, Mixed */
1692 	int abg_true;   /* ABG flag              */
1693 
1694 	/* used for forcing the ibss workqueue to terminate
1695 	 * without wait for the syncro scan to terminate
1696 	 */
1697 	short sync_scan_hurryup;
1698 
1699 	int perfect_rssi;
1700 	int worst_rssi;
1701 
1702 	u16 prev_seq_ctl;       /* used to drop duplicate frames */
1703 
1704 	/* map of allowed channels. 0 is dummy */
1705 	// FIXME: remember to default to a basic channel plan depending of the PHY type
1706 	void *dot11d_info;
1707 	bool bGlobalDomain;
1708 	int rate;       /* current rate */
1709 	int basic_rate;
1710 	//FIXME: pleace callback, see if redundant with softmac_features
1711 	short active_scan;
1712 
1713 	/* this contains flags for selectively enable softmac support */
1714 	u16 softmac_features;
1715 
1716 	/* if the sequence control field is not filled by HW */
1717 	u16 seq_ctrl[5];
1718 
1719 	/* association procedure transaction sequence number */
1720 	u16 associate_seq;
1721 
1722 	/* AID for RTXed association responses */
1723 	u16 assoc_id;
1724 
1725 	/* power save mode related*/
1726 	short ps;
1727 	short sta_sleep;
1728 	int ps_timeout;
1729 	int ps_period;
1730 	struct work_struct ps_task;
1731 	u32 ps_th;
1732 	u32 ps_tl;
1733 
1734 	short raw_tx;
1735 	/* used if IEEE_SOFTMAC_TX_QUEUE is set */
1736 	short queue_stop;
1737 	short scanning;
1738 	short proto_started;
1739 
1740 	struct mutex wx_mutex;
1741 	struct mutex scan_mutex;
1742 
1743 	spinlock_t mgmt_tx_lock;
1744 	spinlock_t beacon_lock;
1745 
1746 	short beacon_txing;
1747 
1748 	short wap_set;
1749 	short ssid_set;
1750 
1751 	u8  wpax_type_set;    //{added by David, 2006.9.28}
1752 	u32 wpax_type_notify; //{added by David, 2006.9.26}
1753 
1754 	/* QoS related flag */
1755 	s8  init_wmmparam_flag;
1756 	/* set on initialization */
1757 	u8  qos_support;
1758 
1759 	/* for discarding duplicated packets in IBSS */
1760 	struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1761 
1762 	/* for discarding duplicated packets in BSS */
1763 	u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1764 	u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1765 	unsigned long last_packet_time[17];
1766 
1767 	/* for PS mode */
1768 	unsigned long last_rx_ps_time;
1769 
1770 	/* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1771 	struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1772 	int mgmt_queue_head;
1773 	int mgmt_queue_tail;
1774 //{ added for rtl819x
1775 #define IEEE80211_QUEUE_LIMIT 128
1776 	u8 AsocRetryCount;
1777 	unsigned int hw_header;
1778 	struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1779 	struct sk_buff_head  skb_aggQ[MAX_QUEUE_SIZE];
1780 	struct sk_buff_head  skb_drv_aggQ[MAX_QUEUE_SIZE];
1781 	u32	sta_edca_param[4];
1782 	bool aggregation;
1783 	// Enable/Disable Rx immediate BA capability.
1784 	bool enable_rx_imm_BA;
1785 	bool bibsscoordinator;
1786 
1787 	//+by amy for DM ,080515
1788 	//Dynamic Tx power for near/far range enable/Disable  , by amy , 2008-05-15
1789 	bool	bdynamic_txpower_enable;
1790 
1791 	bool bCTSToSelfEnable;
1792 	u8	CTSToSelfTH;
1793 
1794 	u32	fsync_time_interval;
1795 	u32	fsync_rate_bitmap;
1796 	u8	fsync_rssi_threshold;
1797 	bool	bfsync_enable;
1798 
1799 	u8	fsync_multiple_timeinterval;		// FsyncMultipleTimeInterval * FsyncTimeInterval
1800 	u32	fsync_firstdiff_ratethreshold;		// low threshold
1801 	u32	fsync_seconddiff_ratethreshold;	 // decrease threshold
1802 	Fsync_State			fsync_state;
1803 	bool		bis_any_nonbepkts;
1804 	//20Mhz 40Mhz AutoSwitch Threshold
1805 	struct bandwidth_autoswitch bandwidth_auto_switch;
1806 	//for txpower tracking
1807 	bool FwRWRF;
1808 
1809 	//added by amy for AP roaming
1810 	struct rt_link_detect LinkDetectInfo;
1811 	//added by amy for ps
1812 	struct rt_power_save_control PowerSaveControl;
1813 //}
1814 	/* used if IEEE_SOFTMAC_TX_QUEUE is set */
1815 	struct  tx_pending tx_pending;
1816 
1817 	/* used if IEEE_SOFTMAC_ASSOCIATE is set */
1818 	struct timer_list associate_timer;
1819 
1820 	/* used if IEEE_SOFTMAC_BEACONS is set */
1821 	struct timer_list beacon_timer;
1822 	struct work_struct associate_complete_wq;
1823 	struct work_struct associate_procedure_wq;
1824 	struct delayed_work softmac_scan_wq;
1825 	struct delayed_work associate_retry_wq;
1826 	struct delayed_work start_ibss_wq;
1827 	struct work_struct wx_sync_scan_wq;
1828 	struct workqueue_struct *wq;
1829 	// Qos related. Added by Annie, 2005-11-01.
1830 	//STA_QOS  StaQos;
1831 
1832 	//u32 STA_EDCA_PARAM[4];
1833 	//CHANNEL_ACCESS_SETTING ChannelAccessSetting;
1834 
1835 	struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1836 
1837 	/* Callback functions */
1838 	void (*set_security)(struct net_device *dev,
1839 			     struct ieee80211_security *sec);
1840 
1841 	/* Used to TX data frame by using txb structs.
1842 	 * this is not used if in the softmac_features
1843 	 * is set the flag IEEE_SOFTMAC_TX_QUEUE
1844 	 */
1845 	int (*hard_start_xmit)(struct ieee80211_txb *txb,
1846 			       struct net_device *dev);
1847 
1848 	int (*reset_port)(struct net_device *dev);
1849 	int (*is_queue_full)(struct net_device *dev, int pri);
1850 
1851 	int (*handle_management)(struct net_device *dev,
1852 				  struct ieee80211_network *network, u16 type);
1853 	int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1854 
1855 	/* Softmac-generated frames (management) are TXed via this
1856 	 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1857 	 * not set. As some cards may have different HW queues that
1858 	 * one might want to use for data and management frames
1859 	 * the option to have two callbacks might be useful.
1860 	 * This function can't sleep.
1861 	 */
1862 	int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1863 			       struct net_device *dev);
1864 
1865 	/* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1866 	 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1867 	 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1868 	 * then also management frames are sent via this callback.
1869 	 * This function can't sleep.
1870 	 */
1871 	void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1872 			       struct net_device *dev, int rate);
1873 
1874 	/* stops the HW queue for DATA frames. Useful to avoid
1875 	 * waste time to TX data frame when we are reassociating
1876 	 * This function can sleep.
1877 	 */
1878 	void (*data_hard_stop)(struct net_device *dev);
1879 
1880 	/* OK this is complementar to data_poll_hard_stop */
1881 	void (*data_hard_resume)(struct net_device *dev);
1882 
1883 	/* ask to the driver to retune the radio .
1884 	 * This function can sleep. the driver should ensure
1885 	 * the radio has been switched before return.
1886 	 */
1887 	void (*set_chan)(struct net_device *dev, short ch);
1888 
1889 	/* These are not used if the ieee stack takes care of
1890 	 * scanning (IEEE_SOFTMAC_SCAN feature set).
1891 	 * In this case only the set_chan is used.
1892 	 *
1893 	 * The syncro version is similar to the start_scan but
1894 	 * does not return until all channels has been scanned.
1895 	 * this is called in user context and should sleep,
1896 	 * it is called in a work_queue when switching to ad-hoc mode
1897 	 * or in behalf of iwlist scan when the card is associated
1898 	 * and root user ask for a scan.
1899 	 * the function stop_scan should stop both the syncro and
1900 	 * background scanning and can sleep.
1901 	 * The function start_scan should initiate the background
1902 	 * scanning and can't sleep.
1903 	 */
1904 	void (*scan_syncro)(struct net_device *dev);
1905 	void (*start_scan)(struct net_device *dev);
1906 	void (*stop_scan)(struct net_device *dev);
1907 
1908 	/* indicate the driver that the link state is changed
1909 	 * for example it may indicate the card is associated now.
1910 	 * Driver might be interested in this to apply RX filter
1911 	 * rules or simply light the LINK led
1912 	 */
1913 	void (*link_change)(struct net_device *dev);
1914 
1915 	/* these two function indicates to the HW when to start
1916 	 * and stop to send beacons. This is used when the
1917 	 * IEEE_SOFTMAC_BEACONS is not set. For now the
1918 	 * stop_send_bacons is NOT guaranteed to be called only
1919 	 * after start_send_beacons.
1920 	 */
1921 	void (*start_send_beacons)(struct net_device *dev, u16 tx_rate);
1922 	void (*stop_send_beacons)(struct net_device *dev);
1923 
1924 	/* power save mode related */
1925 	void (*sta_wake_up)(struct net_device *dev);
1926 	void (*ps_request_tx_ack)(struct net_device *dev);
1927 	void (*enter_sleep_state)(struct net_device *dev, u32 th, u32 tl);
1928 	short (*ps_is_queue_empty)(struct net_device *dev);
1929 	int (*handle_beacon)(struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network);
1930 	int (*handle_assoc_response)(struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network);
1931 
1932 
1933 	/* check whether Tx hw resource available */
1934 	short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1935 	//added by wb for HT related
1936 //	void (*SwChnlByTimerHandler)(struct net_device *dev, int channel);
1937 	void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
1938 //	void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate);
1939 	bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
1940 	void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
1941 	bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
1942 	void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
1943 
1944 	/* This must be the last item so that it points to the data
1945 	 * allocated beyond this structure by alloc_ieee80211
1946 	 */
1947 	u8 priv[];
1948 };
1949 
1950 #define IEEE_A            (1<<0)
1951 #define IEEE_B            (1<<1)
1952 #define IEEE_G            (1<<2)
1953 #define IEEE_N_24G        (1<<4)
1954 #define IEEE_N_5G         (1<<5)
1955 #define IEEE_MODE_MASK    (IEEE_A | IEEE_B | IEEE_G)
1956 
1957 /* Generate a 802.11 header */
1958 
1959 /* Uses the channel change callback directly
1960  * instead of [start/stop] scan callbacks
1961  */
1962 #define IEEE_SOFTMAC_SCAN (1<<2)
1963 
1964 /* Perform authentication and association handshake */
1965 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1966 
1967 /* Generate probe requests */
1968 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1969 
1970 /* Generate respones to probe requests */
1971 #define IEEE_SOFTMAC_PROBERS (1<<5)
1972 
1973 /* The ieee802.11 stack will manages the netif queue
1974  * wake/stop for the driver, taking care of 802.11
1975  * fragmentation. See softmac.c for details.
1976  */
1977 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1978 
1979 /* Uses only the softmac_data_hard_start_xmit
1980  * even for TX management frames.
1981  */
1982 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1983 
1984 /* Generate beacons.  The stack will enqueue beacons
1985  * to the card
1986  */
1987 #define IEEE_SOFTMAC_BEACONS (1<<6)
1988 
ieee80211_priv(struct net_device * dev)1989 static inline void *ieee80211_priv(struct net_device *dev)
1990 {
1991 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
1992 }
1993 
ieee80211_is_empty_essid(const char * essid,int essid_len)1994 static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
1995 {
1996 	/* Single white space is for Linksys APs */
1997 	if (essid_len == 1 && essid[0] == ' ')
1998 		return 1;
1999 
2000 	/* Otherwise, if the entire essid is 0, we assume it is hidden */
2001 	while (essid_len) {
2002 		essid_len--;
2003 		if (essid[essid_len] != '\0')
2004 			return 0;
2005 	}
2006 
2007 	return 1;
2008 }
2009 
ieee80211_is_valid_mode(struct ieee80211_device * ieee,int mode)2010 static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
2011 {
2012 	/*
2013 	 * It is possible for both access points and our device to support
2014 	 * combinations of modes, so as long as there is one valid combination
2015 	 * of ap/device supported modes, then return success
2016 	 *
2017 	 */
2018 	if ((mode & IEEE_A) &&
2019 	    (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2020 	    (ieee->freq_band & IEEE80211_52GHZ_BAND))
2021 		return 1;
2022 
2023 	if ((mode & IEEE_G) &&
2024 	    (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2025 	    (ieee->freq_band & IEEE80211_24GHZ_BAND))
2026 		return 1;
2027 
2028 	if ((mode & IEEE_B) &&
2029 	    (ieee->modulation & IEEE80211_CCK_MODULATION) &&
2030 	    (ieee->freq_band & IEEE80211_24GHZ_BAND))
2031 		return 1;
2032 
2033 	return 0;
2034 }
2035 
ieee80211_get_hdrlen(u16 fc)2036 static inline int ieee80211_get_hdrlen(u16 fc)
2037 {
2038 	int hdrlen = IEEE80211_3ADDR_LEN;
2039 
2040 	switch (WLAN_FC_GET_TYPE(fc)) {
2041 	case IEEE80211_FTYPE_DATA:
2042 		if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
2043 			hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
2044 		if (IEEE80211_QOS_HAS_SEQ(fc))
2045 			hdrlen += 2; /* QOS ctrl*/
2046 		break;
2047 	case IEEE80211_FTYPE_CTL:
2048 		switch (WLAN_FC_GET_STYPE(fc)) {
2049 		case IEEE80211_STYPE_CTS:
2050 		case IEEE80211_STYPE_ACK:
2051 			hdrlen = IEEE80211_1ADDR_LEN;
2052 			break;
2053 		default:
2054 			hdrlen = IEEE80211_2ADDR_LEN;
2055 			break;
2056 		}
2057 		break;
2058 	}
2059 
2060 	return hdrlen;
2061 }
2062 
ieee80211_get_payload(struct rtl_80211_hdr * hdr)2063 static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr)
2064 {
2065 	switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2066 	case IEEE80211_1ADDR_LEN:
2067 		return ((struct rtl_80211_hdr_1addr *)hdr)->payload;
2068 	case IEEE80211_2ADDR_LEN:
2069 		return ((struct rtl_80211_hdr_2addr *)hdr)->payload;
2070 	case IEEE80211_3ADDR_LEN:
2071 		return ((struct rtl_80211_hdr_3addr *)hdr)->payload;
2072 	case IEEE80211_4ADDR_LEN:
2073 		return ((struct rtl_80211_hdr_4addr *)hdr)->payload;
2074 	}
2075 	return NULL;
2076 }
2077 
ieee80211_is_ofdm_rate(u8 rate)2078 static inline int ieee80211_is_ofdm_rate(u8 rate)
2079 {
2080 	switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2081 	case IEEE80211_OFDM_RATE_6MB:
2082 	case IEEE80211_OFDM_RATE_9MB:
2083 	case IEEE80211_OFDM_RATE_12MB:
2084 	case IEEE80211_OFDM_RATE_18MB:
2085 	case IEEE80211_OFDM_RATE_24MB:
2086 	case IEEE80211_OFDM_RATE_36MB:
2087 	case IEEE80211_OFDM_RATE_48MB:
2088 	case IEEE80211_OFDM_RATE_54MB:
2089 		return 1;
2090 	}
2091 	return 0;
2092 }
2093 
ieee80211_is_cck_rate(u8 rate)2094 static inline int ieee80211_is_cck_rate(u8 rate)
2095 {
2096 	switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2097 	case IEEE80211_CCK_RATE_1MB:
2098 	case IEEE80211_CCK_RATE_2MB:
2099 	case IEEE80211_CCK_RATE_5MB:
2100 	case IEEE80211_CCK_RATE_11MB:
2101 		return 1;
2102 	}
2103 	return 0;
2104 }
2105 
2106 
2107 /* ieee80211.c */
2108 void free_ieee80211(struct net_device *dev);
2109 struct net_device *alloc_ieee80211(int sizeof_priv);
2110 
2111 int ieee80211_set_encryption(struct ieee80211_device *ieee);
2112 
2113 /* ieee80211_tx.c */
2114 
2115 int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
2116 			       struct sk_buff *frag, int hdr_len);
2117 
2118 netdev_tx_t ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
2119 void ieee80211_txb_free(struct ieee80211_txb *txb);
2120 
2121 
2122 /* ieee80211_rx.c */
2123 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
2124 		 struct ieee80211_rx_stats *rx_stats);
2125 void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2126 		      struct rtl_80211_hdr_4addr *header,
2127 		      struct ieee80211_rx_stats *stats);
2128 
2129 /* ieee80211_wx.c */
2130 int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2131 			  struct iw_request_info *info,
2132 			  union iwreq_data *wrqu, char *key);
2133 int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2134 			    struct iw_request_info *info,
2135 			    union iwreq_data *wrqu, char *key);
2136 int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
2137 			    struct iw_request_info *info,
2138 			    union iwreq_data *wrqu, char *key);
2139 int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
2140 				struct iw_request_info *info,
2141 				union iwreq_data *wrqu, char *extra);
2142 int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
2143 				struct iw_request_info *info,
2144 				union iwreq_data *wrqu, char *extra);
2145 int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
2146 			  struct iw_request_info *info,
2147 			  struct iw_param *data, char *extra);
2148 int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
2149 			  struct iw_request_info *info,
2150 			  union iwreq_data *wrqu, char *extra);
2151 int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
2152 
2153 /* ieee80211_softmac.c */
2154 short ieee80211_is_54g(const struct ieee80211_network *net);
2155 short ieee80211_is_shortslot(const struct ieee80211_network *net);
2156 int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee,
2157 			       struct sk_buff *skb,
2158 			       struct ieee80211_rx_stats *rx_stats,
2159 			       u16 type, u16 stype);
2160 void ieee80211_softmac_new_net(struct ieee80211_device *ieee,
2161 			       struct ieee80211_network *net);
2162 
2163 void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn);
2164 void ieee80211_softmac_xmit(struct ieee80211_txb *txb,
2165 			    struct ieee80211_device *ieee);
2166 
2167 void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2168 void notify_wx_assoc_event(struct ieee80211_device *ieee);
2169 void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2170 void ieee80211_start_bss(struct ieee80211_device *ieee);
2171 void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2172 void ieee80211_start_ibss(struct ieee80211_device *ieee);
2173 void ieee80211_softmac_init(struct ieee80211_device *ieee);
2174 void ieee80211_softmac_free(struct ieee80211_device *ieee);
2175 void ieee80211_associate_abort(struct ieee80211_device *ieee);
2176 void ieee80211_disassociate(struct ieee80211_device *ieee);
2177 void ieee80211_stop_scan(struct ieee80211_device *ieee);
2178 void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2179 void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2180 void ieee80211_start_protocol(struct ieee80211_device *ieee);
2181 void ieee80211_stop_protocol(struct ieee80211_device *ieee);
2182 void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
2183 void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
2184 void ieee80211_reset_queue(struct ieee80211_device *ieee);
2185 void ieee80211_wake_queue(struct ieee80211_device *ieee);
2186 void ieee80211_stop_queue(struct ieee80211_device *ieee);
2187 struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2188 void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2189 int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee,
2190 				   struct iw_point *p);
2191 void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2192 
2193 void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
2194 
2195 /* ieee80211_crypt_ccmp&tkip&wep.c */
2196 
2197 int ieee80211_crypto_init(void);
2198 void ieee80211_crypto_deinit(void);
2199 int ieee80211_crypto_tkip_init(void);
2200 void ieee80211_crypto_tkip_exit(void);
2201 int ieee80211_crypto_ccmp_init(void);
2202 void ieee80211_crypto_ccmp_exit(void);
2203 int ieee80211_crypto_wep_init(void);
2204 void ieee80211_crypto_wep_exit(void);
2205 
2206 /* ieee80211_softmac_wx.c */
2207 
2208 int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2209 			 struct iw_request_info *info,
2210 			 union iwreq_data *wrqu, char *ext);
2211 
2212 int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2213 			 struct iw_request_info *info,
2214 			 union iwreq_data *awrq,
2215 			 char *extra);
2216 
2217 int ieee80211_wx_get_essid(struct ieee80211_device *ieee,
2218 			   struct iw_request_info *a,
2219 			   union iwreq_data *wrqu, char *b);
2220 
2221 int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2222 			  struct iw_request_info *info,
2223 			  union iwreq_data *wrqu, char *extra);
2224 
2225 int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2226 			  struct iw_request_info *info,
2227 			  union iwreq_data *wrqu, char *extra);
2228 
2229 int ieee80211_wx_set_mode(struct ieee80211_device *ieee,
2230 			  struct iw_request_info *a,
2231 			  union iwreq_data *wrqu, char *b);
2232 
2233 int ieee80211_wx_set_scan(struct ieee80211_device *ieee,
2234 			  struct iw_request_info *a,
2235 			  union iwreq_data *wrqu, char *b);
2236 
2237 int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2238 			   struct iw_request_info *a,
2239 			   union iwreq_data *wrqu, char *extra);
2240 
2241 int ieee80211_wx_get_mode(struct ieee80211_device *ieee,
2242 			  struct iw_request_info *a,
2243 			  union iwreq_data *wrqu, char *b);
2244 
2245 int ieee80211_wx_set_freq(struct ieee80211_device *ieee,
2246 			  struct iw_request_info *a,
2247 			  union iwreq_data *wrqu, char *b);
2248 
2249 int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
2250 			  struct iw_request_info *a,
2251 			  union iwreq_data *wrqu, char *b);
2252 
2253 /* ieee80211_module.c */
2254 #ifdef CONFIG_IEEE80211_DEBUG
2255 int ieee80211_debug_init(void);
2256 void ieee80211_debug_exit(void);
2257 #else
ieee80211_debug_init(void)2258 static inline int ieee80211_debug_init(void) { return 0; }
ieee80211_debug_exit(void)2259 static inline void ieee80211_debug_exit(void) { }
2260 #endif
2261 
2262 //extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2263 void ieee80211_wx_sync_scan_wq(struct work_struct *work);
2264 
2265 
2266 int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2267 			   struct iw_request_info *info,
2268 			       union iwreq_data *wrqu, char *extra);
2269 
2270 int ieee80211_wx_get_name(struct ieee80211_device *ieee,
2271 			  struct iw_request_info *info,
2272 			  union iwreq_data *wrqu, char *extra);
2273 
2274 int ieee80211_wx_set_power(struct ieee80211_device *ieee,
2275 			   struct iw_request_info *info,
2276 			   union iwreq_data *wrqu, char *extra);
2277 
2278 int ieee80211_wx_get_power(struct ieee80211_device *ieee,
2279 			   struct iw_request_info *info,
2280 			   union iwreq_data *wrqu, char *extra);
2281 
2282 int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
2283 			 struct iw_request_info *info,
2284 			 union iwreq_data *wrqu, char *extra);
2285 
2286 int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
2287 			 struct iw_request_info *info,
2288 			 union iwreq_data *wrqu, char *extra);
2289 //HT
2290 #define MAX_RECEIVE_BUFFER_SIZE 9100  //
2291 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
2292 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
2293 
2294 void HTSetConnectBwMode(struct ieee80211_device *ieee,
2295 			enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
2296 void HTUpdateDefaultSetting(struct ieee80211_device *ieee);
2297 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap,
2298 				  u8 *len, u8 isEncrypt);
2299 void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo,
2300 			    u8 *len, u8 isEncrypt);
2301 void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg,
2302 				u8 *len);
2303 void HTOnAssocRsp(struct ieee80211_device *ieee);
2304 void HTInitializeHTInfo(struct ieee80211_device *ieee);
2305 void HTInitializeBssDesc(PBSS_HT pBssHT);
2306 void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee,
2307 				   struct ieee80211_network *pNetwork);
2308 void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
2309 				struct ieee80211_network *pNetwork);
2310 u8 HTGetHighestMCSRate(struct ieee80211_device *ieee,
2311 		       u8 *pMCSRateSet, u8 *pMCSFilter);
2312 extern u8 MCS_FILTER_ALL[];
2313 extern u16 MCS_DATA_RATE[2][2][77];
2314 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
2315 void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
2316 bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee);
2317 u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate);
2318 //function in BAPROC.c
2319 int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb);
2320 int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb);
2321 int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb);
2322 void TsInitAddBA(struct ieee80211_device *ieee, struct tx_ts_record *pTS,
2323 		 u8 Policy, u8 bOverwritePending);
2324 void TsInitDelBA(struct ieee80211_device *ieee,
2325 		 struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect);
2326 void BaSetupTimeOut(struct timer_list *t);
2327 void TxBaInactTimeout(struct timer_list *t);
2328 void RxBaInactTimeout(struct timer_list *t);
2329 void ResetBaEntry(struct ba_record *pBA);
2330 //function in TS.c
2331 bool GetTs(
2332 	struct ieee80211_device		*ieee,
2333 	struct ts_common_info           **ppTS,
2334 	u8                              *Addr,
2335 	u8                              TID,
2336 	enum tr_select                  TxRxSelect,  //Rx:1, Tx:0
2337 	bool                            bAddNewTs
2338 	);
2339 void TSInitialize(struct ieee80211_device *ieee);
2340 void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record   *pTxTS);
2341 void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr);
2342 void RemoveAllTS(struct ieee80211_device *ieee);
2343 void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
2344 
2345 extern const long ieee80211_wlan_frequencies[];
2346 
ieee80211_increment_scans(struct ieee80211_device * ieee)2347 static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
2348 {
2349 	ieee->scans++;
2350 }
2351 
ieee80211_get_scans(struct ieee80211_device * ieee)2352 static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2353 {
2354 	return ieee->scans;
2355 }
2356 
escape_essid(const char * essid,u8 essid_len)2357 static inline const char *escape_essid(const char *essid, u8 essid_len)
2358 {
2359 	static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2360 
2361 	if (ieee80211_is_empty_essid(essid, essid_len)) {
2362 		memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2363 		return escaped;
2364 	}
2365 
2366 	snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
2367 	return escaped;
2368 }
2369 
2370 /* For the function is more related to hardware setting, it's better to use the
2371  * ieee handler to refer to it.
2372  */
2373 short check_nic_enough_desc(struct net_device *dev, int queue_index);
2374 int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
2375 int ieee80211_parse_info_param(struct ieee80211_device *ieee,
2376 			       struct ieee80211_info_element *info_element,
2377 			       u16 length,
2378 			       struct ieee80211_network *network,
2379 			       struct ieee80211_rx_stats *stats);
2380 
2381 void ieee80211_indicate_packets(struct ieee80211_device *ieee,
2382 				struct ieee80211_rxb **prxbIndicateArray,
2383 				u8 index);
2384 #define RT_ASOC_RETRY_LIMIT	5
2385 #endif /* IEEE80211_H */
2386