2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation
16 * Modified for Realtek's wi-fi cards by Andrea Merello
17 * <andreamrl@tiscali.it>
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
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>
33 #include <linux/jffs.h>
34 #include <linux/tqueue.h>
36 #include <linux/timer.h>
37 #include <linux/sched.h>
38 #include <linux/semaphore.h>
40 #include <linux/delay.h>
41 #include <linux/wireless.h>
43 #include "rtl819x_HT.h"
44 #include "rtl819x_BA.h"
45 #include "rtl819x_TS.h"
47 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
49 typedef enum{false = 0, true} bool;
53 #ifndef IW_MODE_MONITOR
54 #define IW_MODE_MONITOR 6
58 #define IWEVCUSTOM 0x8c02
61 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
63 #define __bitwise __attribute__((bitwise))
66 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27))
68 /* --- Standard spy support --- */
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];
82 * container_of - cast a member of a structure out to the containing structure
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.
89 #define container_of(ptr, type, member) ({ \
90 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
91 (type *)( (char *)__mptr - offsetof(type,member) );})
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
100 /* added for rtl819x tx procedure */
101 #define MAX_QUEUE_SIZE 0x10
104 // 8190 queue mapping
111 #define TXCMD_QUEUE 5
114 #define BEACON_QUEUE 8
116 #define LOW_QUEUE BE_QUEUE
117 #define NORMAL_QUEUE MGNT_QUEUE
119 //added by amy for ps
120 #define SWRF_TIMEOUT 50
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 */
128 typedef struct cb_desc {
129 /* Tx Desc Related flags (8-9) */
135 u8 bTxDisableRateFallBack:1;
136 u8 bTxUseDriverAssingedRate:1;
137 u8 bHwSec:1; //indicate whether use Hw security. WB
141 /* Tx Firmware Relaged flags (10-11)*/
145 u8 bUseShortPreamble:1;
146 u8 bTxEnableFwCalcDur:1;
153 u8 bRTSUseShortPreamble:1;
161 /* Tx Desc related element(12-19) */
173 /* Tx firmware related element(20-27) */
188 /*--------------------------Define -------------------------------------------*/
191 #define MGN_5_5M 0x0b
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
220 //----------------------------------------------------------------------------
221 // 802.11 Management frame Reason Code field
222 //----------------------------------------------------------------------------
225 auth_not_valid = 0x2,
238 // Reason code defined in 802.11i D10.0 p.28.
240 four_way_tmout = 0x0f,
241 two_way_tmout = 0x10,
243 invalid_Gcipher = 0x12,
244 invalid_Pcipher = 0x13,
246 unsup_RSNIEver = 0x15,
247 invalid_RSNIE = 0x16,
248 auth_802_1x_fail= 0x17,
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
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
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)
270 #define MGMT_QUEUE_NUM 5
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
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
285 #define IEEE_PARAM_WPAX_SELECT 7
286 //Added for notify the encryption type selection
288 #define IEEE_PROTO_WPA 1
289 #define IEEE_PROTO_RSN 2
290 //Added for notify the encryption type selection
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
299 #define IEEE_KEY_MGMT_IEEE8021X 1
300 #define IEEE_KEY_MGMT_PSK 2
302 #define IEEE_MLME_STA_DEAUTH 1
303 #define IEEE_MLME_STA_DISASSOC 2
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
314 #define IEEE_CRYPT_ALG_NAME_LEN 16
316 #define MAX_IE_LEN 0xff
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
326 #define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
328 #define ieee80211_tkip_null ieee80211_tkip_null_rsl
330 #define ieee80211_wep_null ieee80211_wep_null_rsl
332 #define free_ieee80211 free_ieee80211_rsl
333 #define alloc_ieee80211 alloc_ieee80211_rsl
335 #define ieee80211_rx ieee80211_rx_rsl
336 #define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
338 #define ieee80211_get_beacon ieee80211_get_beacon_rsl
339 #define ieee80211_rtl_wake_queue ieee80211_rtl_wake_queue_rsl
340 #define ieee80211_rtl_stop_queue ieee80211_rtl_stop_queue_rsl
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
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
378 #define ieee80211_txb_free ieee80211_txb_free_rsl
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
392 typedef struct ieee_param {
394 u8 sta_addr[ETH_ALEN];
410 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
414 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
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
431 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
432 static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data)
434 task->routine = func;
437 INIT_LIST_HEAD(&task->list);
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)
446 static inline unsigned long msleep_interruptible_rsl(unsigned int msecs)
448 unsigned long timeout = MSECS(msecs) + 1;
451 set_current_state(TASK_INTERRUPTIBLE);
452 timeout = schedule_timeout(timeout);
456 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
457 static inline void msleep(unsigned int msecs)
459 unsigned long timeout = MSECS(msecs) + 1;
462 set_current_state(TASK_UNINTERRUPTIBLE);
463 timeout = schedule_timeout(timeout);
468 #define MSECS(t) msecs_to_jiffies(t)
469 #define msleep_interruptible_rsl msleep_interruptible
472 #define IEEE80211_DATA_LEN 2304
473 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
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
491 #define MIN_FRAG_THRESHOLD 256U
492 #define MAX_FRAG_THRESHOLD 2346U
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
510 #define IEEE80211_FTYPE_MGMT 0x0000
511 #define IEEE80211_FTYPE_CTL 0x0004
512 #define IEEE80211_FTYPE_DATA 0x0008
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
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
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
549 #define IEEE80211_SCTL_FRAG 0x000F
550 #define IEEE80211_SCTL_SEQ 0xFFF0
553 #define IEEE80211_QCTL_TID 0x000F
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
564 typedef enum _ACT_CATEGORY{
570 } ACT_CATEGORY, *PACT_CATEGORY;
572 typedef enum _TS_ACTION{
577 } TS_ACTION, *PTS_ACTION;
579 typedef enum _BA_ACTION{
583 } BA_ACTION, *PBA_ACTION;
585 typedef enum _InitialGainOpType{
592 #define CONFIG_IEEE80211_DEBUG
593 #ifdef CONFIG_IEEE80211_DEBUG
594 extern u32 ieee80211_debug_level;
595 #define IEEE80211_DEBUG(level, fmt, args...) \
596 do { 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)) \
604 u8* pdata = (u8*) data; \
605 printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \
606 for(i=0; i<(int)(datalen); i++) \
608 printk("%2x ", pdata[i]); \
609 if ((i+1)%16 == 0) printk("\n"); \
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 */
619 /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
622 * To use the debug system;
624 * If you are defining a new debug classification, simply add it to the #define
625 * list here in the form of:
627 * #define IEEE80211_DL_xxxx VALUE
629 * shifting value to the left one bit from the previous entry. xxxx should be
630 * the name of the classification (for example, WEP)
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.
636 * To add your debug level to the list of levels seen when you perform
638 * % cat /proc/net/ipw/debug_level
640 * you simply need to add your entry to the ipw_debug_levels array.
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
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)
656 #define IEEE80211_DL_TX (1<<8)
657 #define IEEE80211_DL_RX (1<<9)
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)
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)
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) \
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++ ) \
699 if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
701 buffer[length] = '\0'; \
702 printk("Rtl819x: "); \
703 printk(_TitleString); \
704 printk(": %d, <%s>\n", _Len, buffer); \
707 #define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0)
710 #include <linux/netdevice.h>
711 #include <linux/if_arp.h> /* ARPHRD_ETHER */
714 #define WIRELESS_SPY // enable iwspy support
716 #include <net/iw_handler.h> // new driver API
719 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
720 #endif /* ETH_P_PAE */
722 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
724 #ifndef ETH_P_80211_RAW
725 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
728 /* IEEE 802.11 defines */
730 #define P80211_OUI_LEN 3
732 struct ieee80211_snap_hdr {
734 u8 dsap; /* always 0xAA */
735 u8 ssap; /* always 0xAA */
736 u8 ctrl; /* always 0x03 */
737 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
739 } __attribute__ ((packed));
741 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
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)
746 #define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA)
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)
753 /* Authentication algorithms */
754 #define WLAN_AUTH_OPEN 0
755 #define WLAN_AUTH_SHARED_KEY 1
756 #define WLAN_AUTH_LEAP 2
758 #define WLAN_AUTH_CHALLENGE_LEN 128
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)
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)
779 enum 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,
792 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
793 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
794 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
796 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
797 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
798 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
800 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
801 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
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,
813 enum 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,
824 WLAN_REASON_DISASSOC_BAD_POWER = 10,
825 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
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,
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
847 #define IEEE80211_CCK_MODULATION (1<<0)
848 #define IEEE80211_OFDM_MODULATION (1<<1)
850 #define IEEE80211_24GHZ_BAND (1<<0)
851 #define IEEE80211_52GHZ_BAND (1<<1)
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
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)
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)
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)
902 #define IEEE80211_NUM_OFDM_RATES 8
903 #define IEEE80211_NUM_CCK_RATES 4
904 #define IEEE80211_OFDM_SHIFT_MASK_A 4
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
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))
917 /* this is stolen from ipw2200 driver */
918 #define IEEE_IBSS_MAC_HASH_SIZE 31
919 struct ieee_ibss_seq {
923 unsigned long packet_time[17];
924 struct list_head list;
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. */
930 struct ieee80211_rx_stats {
936 u16 rate; /* in 100 kbps */
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.
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
963 bool bIsQosData; // Added by Annie, 2005-12-22.
966 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
967 //1Attention Please!!!<11n or 8190 specific code should be put below this line>
968 //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
975 bool RxIs40MHzPacket;
977 u8 RxMIMOSignalStrength[4]; // in 0~100 index
978 s8 RxMIMOSignalQuality[2];
979 bool bPacketMatchBSSID;
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
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
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
1003 struct ieee80211_frag_entry {
1004 unsigned long first_frag_time;
1006 unsigned int last_frag;
1007 struct sk_buff *skb;
1008 u8 src_addr[ETH_ALEN];
1009 u8 dst_addr[ETH_ALEN];
1012 struct 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;
1036 struct ieee80211_device;
1038 #include "ieee80211_crypt.h"
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)
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 */
1057 #define SEC_ALG_NONE 0
1058 #define SEC_ALG_WEP 1
1059 #define SEC_ALG_TKIP 2
1060 #define SEC_ALG_CCMP 4
1063 #define WEP_KEY_LEN 13
1064 #define SCM_KEY_LEN 32
1065 #define SCM_TEMPORAL_KEY_LENGTH 16
1067 struct ieee80211_security {
1072 unicast_uses_group:1,
1074 u8 key_sizes[WEP_KEYS];
1075 u8 keys[WEP_KEYS][SCM_KEY_LEN];
1078 } __attribute__ ((packed));
1082 802.11 data frame from AP
1083 ,-------------------------------------------------------------------.
1084 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1085 |------|------|---------|---------|---------|------|---------|------|
1086 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1087 | | tion | (BSSID) | | | ence | data | |
1088 `-------------------------------------------------------------------'
1089 Total: 28-2340 bytes
1092 /* Management Frame Information Element Types */
1093 enum ieee80211_mfie {
1095 MFIE_TYPE_RATES = 1,
1096 MFIE_TYPE_FH_SET = 2,
1097 MFIE_TYPE_DS_SET = 3,
1098 MFIE_TYPE_CF_SET = 4,
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,
1112 MFIE_TYPE_MEASURE_REQUEST = 38,
1113 MFIE_TYPE_MEASURE_REPORT = 39,
1114 MFIE_TYPE_QUIET = 40,
1115 MFIE_TYPE_IBSS_DFS = 41,
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,
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. */
1129 struct ieee80211_pspoll_hdr {
1135 } __attribute__ ((packed));
1137 struct ieee80211_hdr {
1141 } __attribute__ ((packed));
1143 struct ieee80211_hdr_1addr {
1148 } __attribute__ ((packed));
1150 struct ieee80211_hdr_2addr {
1156 } __attribute__ ((packed));
1158 struct ieee80211_hdr_3addr {
1166 } __attribute__ ((packed));
1168 struct ieee80211_hdr_4addr {
1177 } __attribute__ ((packed));
1179 struct ieee80211_hdr_3addrqos {
1188 } __attribute__ ((packed));
1190 struct ieee80211_hdr_4addrqos {
1200 } __attribute__ ((packed));
1202 struct ieee80211_info_element {
1206 } __attribute__ ((packed));
1208 struct ieee80211_authentication {
1209 struct ieee80211_hdr_3addr header;
1214 struct ieee80211_info_element info_element[0];
1215 } __attribute__ ((packed));
1217 struct ieee80211_disassoc {
1218 struct ieee80211_hdr_3addr header;
1220 } __attribute__ ((packed));
1222 struct ieee80211_probe_request {
1223 struct ieee80211_hdr_3addr header;
1224 /* SSID, supported rates */
1225 struct ieee80211_info_element info_element[0];
1226 } __attribute__ ((packed));
1228 struct ieee80211_probe_response {
1229 struct ieee80211_hdr_3addr header;
1231 __le16 beacon_interval;
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));
1238 /* Alias beacon for probe_response */
1239 #define ieee80211_beacon ieee80211_probe_response
1241 struct ieee80211_assoc_request_frame {
1242 struct ieee80211_hdr_3addr header;
1244 __le16 listen_interval;
1245 /* SSID, supported rates, RSN */
1246 struct ieee80211_info_element info_element[0];
1247 } __attribute__ ((packed));
1249 struct ieee80211_reassoc_request_frame {
1250 struct ieee80211_hdr_3addr header;
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));
1258 struct ieee80211_assoc_response_frame {
1259 struct ieee80211_hdr_3addr header;
1263 struct ieee80211_info_element info_element[0]; /* supported rates */
1264 } __attribute__ ((packed));
1266 struct ieee80211_txb {
1273 __le16 payload_size;
1274 struct sk_buff *fragments[0];
1277 #define MAX_TX_AGG_COUNT 16
1278 struct ieee80211_drv_agg_txb {
1279 u8 nr_drv_agg_frames;
1280 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1281 }__attribute__((packed));
1283 #define MAX_SUBFRAME_COUNT 64
1284 struct ieee80211_rxb {
1286 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1289 }__attribute__((packed));
1291 typedef union _frameqos {
1301 }frameqos,*pframeqos;
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
1314 #define MAX_CHANNEL_NUMBER 161
1315 #define IEEE80211_SOFTMAC_SCAN_TIME 100
1317 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1319 #define CRC_LENGTH 4U
1321 #define MAX_WPA_IE_LEN 64
1323 #define NETWORK_EMPTY_ESSID (1<<0)
1324 #define NETWORK_HAS_OFDM (1<<1)
1325 #define NETWORK_HAS_CCK (1<<2)
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)
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)
1339 #define NETWORK_HAS_ERP_VALUE (1<<10)
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
1350 struct ieee80211_qos_information_element {
1353 u8 qui[QOS_OUI_LEN];
1358 } __attribute__ ((packed));
1360 struct ieee80211_qos_ac_parameter {
1364 } __attribute__ ((packed));
1366 struct ieee80211_qos_parameter_info {
1367 struct ieee80211_qos_information_element info_element;
1369 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1370 } __attribute__ ((packed));
1372 struct 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));
1380 struct ieee80211_qos_data {
1381 struct ieee80211_qos_parameters parameters;
1388 struct ieee80211_tim_parameters {
1391 } __attribute__ ((packed));
1394 struct ieee80211_wmm_ac_param {
1395 u8 ac_aci_acm_aifsn;
1396 u8 ac_ecwmin_ecwmax;
1400 struct ieee80211_wmm_ts_info {
1404 } __attribute__ ((packed));
1406 struct ieee80211_wmm_tspec_elem {
1407 struct ieee80211_wmm_ts_info ts_info;
1414 u32 serv_start_time;
1421 u16 surp_band_allow;
1423 }__attribute__((packed));
1430 EAPOL_ENCAP_ASF_ALERT
1433 static 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"
1441 static inline const char *eap_get_type(int type)
1443 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1445 //added by amy for reorder
1446 static inline u8 Frame_QoSTID(u8* buf)
1448 struct ieee80211_hdr_3addr *hdr;
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;
1455 //added by amy for reorder
1463 } __attribute__ ((packed));
1465 struct 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;
1488 #define BEACON_PROBE_SSID_ID_POSITION 12
1490 struct ieee80211_info_element_hdr {
1493 } __attribute__ ((packed));
1496 * These are the data types that can make up management packets
1500 u16 beacon_interval;
1502 u8 current_ap[ETH_ALEN];
1503 u16 listen_interval;
1505 u16 association_id:14, reserved:2;
1506 } __attribute__ ((packed));
1512 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
1513 #define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
1515 enum {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)
1520 #define IEEE80211_DTIM_MBCAST 4
1521 #define IEEE80211_DTIM_UCAST 2
1522 #define IEEE80211_DTIM_VALID 1
1523 #define IEEE80211_DTIM_INVALID 0
1525 #define IEEE80211_PS_DISABLED 0
1526 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
1527 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
1529 //added by David for QoS 2006/6/30
1530 //#define WMM_Hang_8187
1531 #ifdef WMM_Hang_8187
1532 #undef WMM_Hang_8187
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
1543 #define MAX_RECEIVE_BUFFER_SIZE 9100
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))
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 : \
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 : \
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*/
1565 struct ether_header {
1566 u8 ether_dhost[ETHER_ADDR_LEN];
1567 u8 ether_shost[ETHER_ADDR_LEN];
1569 } __attribute__((packed));
1571 #ifndef ETHERTYPE_PAE
1572 #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1574 #ifndef ETHERTYPE_IP
1575 #define ETHERTYPE_IP 0x0800 /* IP protocol */
1578 typedef struct _bss_ht{
1582 // HT related elements
1588 HT_SPEC_VER ht_spec_ver;
1589 //HT_CAPABILITY_ELE bdHTCapEle;
1590 //HT_INFORMATION_ELE bdHTInfoEle;
1593 bool long_slot_time;
1596 typedef enum _erp_t{
1597 ERP_NonERPpresent = 0x01,
1598 ERP_UseProtection = 0x02,
1599 ERP_BarkerPreambleMode = 0x04,
1603 struct ieee80211_network {
1604 /* These entries are used to identify a unique network */
1607 /* Ensure null-terminated for any debug msgs */
1608 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1611 struct ieee80211_qos_data qos_data;
1613 // Qos related. Added by Annie, 2005-11-01.
1617 //added by amy for LEAP
1618 bool bWithAironetIE;
1619 bool bCkipSupported;
1622 // CCXv4 S59, MBSSID.
1626 // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
1627 bool bWithCcxVerNum;
1629 /* These are network statistics */
1630 struct ieee80211_rx_stats stats;
1632 u8 rates[MAX_RATES_LENGTH];
1634 u8 rates_ex[MAX_RATES_EX_LENGTH];
1636 unsigned long last_scanned;
1641 u16 beacon_interval;
1642 u16 listen_interval;
1645 u8 wpa_ie[MAX_WPA_IE_LEN];
1647 u8 rsn_ie[MAX_WPA_IE_LEN];
1650 struct ieee80211_tim_parameters tim;
1653 u32 last_dtim_sta_time[2];
1657 struct ieee80211_wmm_ac_param wmm_param[4];
1660 u8 Turbo_Enable;//enable turbo mode, added by thomas
1662 #ifdef ENABLE_DOT11D
1664 u8 CountryIeBuf[MAX_IE_LEN];
1666 // HT Related, by amy, 2008.04.29
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;
1673 bool marvell_cap_exist;
1674 bool unknown_cap_exist;
1676 bool berp_info_valid;
1677 bool buseprotection;
1678 //put at the end of the structure.
1679 struct list_head list;
1683 enum ieee80211_state {
1685 /* the card is not linked at all */
1686 IEEE80211_NOLINK = 0,
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
1696 /* the association procedure will start (wq scheduling)*/
1697 IEEE80211_ASSOCIATING,
1698 IEEE80211_ASSOCIATING_RETRY,
1700 /* the association procedure is sending AUTH request*/
1701 IEEE80211_ASSOCIATING_AUTHENTICATING,
1703 /* the association procedure has successfully authentcated
1704 * and is sending association request
1706 IEEE80211_ASSOCIATING_AUTHENTICATED,
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
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.
1718 IEEE80211_LINKED_SCANNING,
1722 enum ieee80211_state {
1723 IEEE80211_UNINITIALIZED = 0,
1724 IEEE80211_INITIALIZED,
1725 IEEE80211_ASSOCIATING,
1726 IEEE80211_ASSOCIATED,
1727 IEEE80211_AUTHENTICATING,
1728 IEEE80211_AUTHENTICATED,
1733 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1734 #define DEFAULT_FTS 2346
1736 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1737 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1738 #define CFG_IEEE80211_RTS (1<<2)
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)
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)
1750 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
1751 extern inline int is_multicast_ether_addr(const u8 *addr)
1753 return ((addr[0] != 0xff) && (0x01 & addr[0]));
1757 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
1758 extern inline int is_broadcast_ether_addr(const u8 *addr)
1760 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
1761 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
1765 typedef struct tx_pending_t{
1767 struct ieee80211_txb *txb;
1770 typedef struct _bandwidth_autoswitch
1772 long threshold_20Mhzto40Mhz;
1773 long threshold_40Mhzto20Mhz;
1774 bool bforced_tx20Mhz;
1775 bool bautoswitch_enable;
1776 }bandwidth_autoswitch,*pbandwidth_autoswitch;
1779 //added by amy for order
1781 #define REORDER_WIN_SIZE 128
1782 #define REORDER_ENTRY_NUM 128
1783 typedef struct _RX_REORDER_ENTRY
1785 struct list_head List;
1787 struct ieee80211_rxb* prxb;
1788 } RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
1789 //added by amy for order
1790 typedef enum _Fsync_State{
1796 // Power save mode configured.
1797 typedef enum _RT_PS_MODE
1799 eActive, // Active/Continuous access.
1800 eMaxPs, // Max power save mode.
1801 eFastPs // Fast power save mode.
1804 typedef enum _IPS_CALLBACK_FUNCION
1806 IPS_CALLBACK_NONE = 0,
1807 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1808 IPS_CALLBACK_JOIN_REQUEST = 2,
1809 }IPS_CALLBACK_FUNCION;
1811 typedef enum _RT_JOIN_ACTION{
1818 typedef struct _IbssParms{
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.
1824 typedef enum _RT_RF_POWER_STATE
1831 typedef struct _RT_POWER_SAVE_CONTROL
1835 // Inactive Power Save(IPS) : Disable RF when disconnected
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;
1844 struct tq_struct InactivePsWorkItem;
1846 struct timer_list InactivePsTimer;
1848 // Return point for join action
1849 IPS_CALLBACK_FUNCION ReturnPoint;
1851 // Recored Parameters for rescheduled JoinRequest
1853 RT_JOIN_ACTION tmpJoinAction;
1854 struct ieee80211_network tmpBssDesc;
1856 // Recored Parameters for rescheduled MgntLinkRequest
1858 bool bTmpActiveScan;
1859 bool bTmpFilterHiddenAP;
1860 bool bTmpUpdateParms;
1862 OCTET_STRING tmpSsid2Scan;
1865 u8 tmpChannelNumber;
1869 OCTET_STRING tmpSuppRateSet;
1870 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1876 // Leisre Poswer Save : Disable RF if connected but traffic is not busy
1881 u8 RegMaxLPSAwakeIntvl;
1890 bool LinkReqInIPSRFOffPgs;
1891 bool BufConnectinfoBefore;
1893 }RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;
1895 typedef 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.
1902 #ifdef ENABLE_DOT11D
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,
1915 COUNTRY_CODE_GLOBAL_DOMAIN
1916 }country_code_type_t;
1919 #define RT_MAX_LD_SLOT_NUM 10
1920 typedef struct _RT_LINK_DETECT_T{
1922 u32 NumRecvBcnInPeriod;
1923 u32 NumRecvDataInPeriod;
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
1930 u32 NumTxOkInPeriod;
1931 u32 NumRxOkInPeriod;
1932 u32 NumRxUnicastOkInPeriod;
1934 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
1936 //added by amy 090330
1937 typedef enum _HW_VARIABLES{
1939 HW_VAR_MULTICAST_REG,
1942 HW_VAR_MEDIA_STATUS,
1943 HW_VAR_SECURITY_CONF,
1944 HW_VAR_BEACON_INTERVAL,
1946 HW_VAR_LISTEN_INTERVAL,
1956 HW_VAR_ACK_PREAMBLE,
1959 HW_VAR_RATE_FALLBACK_CONTROL,
1960 HW_VAR_CONTENTION_WINDOW,
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.
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
1990 HW_VAR_LBK_MODE, // Set lookback mode, 2008.06.11. added by Roger.
1991 // Set HW related setting for 11N AES bug.
1993 // Set Usb Rx Aggregation
1995 HW_VAR_USER_CONTROL_TURBO_MODE,
1997 #ifndef _RTL8192_EXT_PATCH_
1998 HW_VAR_INIT_TX_RATE, //Get Current Tx rate register. 2008.12.10. Added by tynli
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.
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
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.
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.
2021 #define RT_CHECK_FOR_HANG_PERIOD 2
2023 struct ieee80211_device {
2024 struct net_device *dev;
2025 struct ieee80211_security sec;
2031 bool bIsAggregateFrame;
2033 void (*LeisurePSLeave)(struct net_device *dev);
2037 bool proto_stoppping;
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);
2044 void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2045 u8 (*rtllib_ap_sec_type)(struct ieee80211_device *ieee);
2047 //hw security related
2048 // u8 hwsec_support; //support?
2049 u8 hwsec_active; //hw security active.
2050 bool is_silent_reset;
2054 bool bSupportRemoteWakeUp;
2055 RT_PS_MODE dot11PowerSaveMode; // Power save mode configured.
2058 RT_RF_POWER_STATE eRFPowerState;
2059 RT_RF_CHANGE_SOURCE RfOffReason;
2061 //11n spec related I wonder if These info structure need to be moved out of ieee80211_device
2064 PRT_HIGH_THROUGHPUT pHTInfo;
2065 //struct timer_list SwBwTimer;
2066 // spinlock_t chnlop_spinlock;
2067 spinlock_t bw_spinlock;
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;
2082 // u8 HTHighestOperaRate;
2083 // u8 HTCurrentOperaRate;
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];
2096 RX_REORDER_ENTRY RxReorderEntry[128];
2097 struct list_head RxReorder_Unused_List;
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.)
2104 /* Bookkeeping structures */
2105 struct net_device_stats stats;
2106 struct ieee80211_stats ieee_stats;
2107 struct ieee80211_softmac_stats softmac_stats;
2109 /* Probe / Beacon management */
2110 struct list_head network_free_list;
2111 struct list_head network_list;
2112 struct ieee80211_network *networks;
2116 int iw_mode; /* operating mode (IW_MODE_*) */
2117 struct iw_spy_data spy_data;
2120 spinlock_t wpax_suitlist_lock;
2122 int tx_headroom; /* Set to size of any additional room needed at front
2123 * of allocated Tx SKBs */
2126 /* WEP and other encryption related settings at the device level */
2127 int open_wep; /* Set to 1 to allow unencrypted frames */
2129 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2130 * WEP key changes */
2132 /* If the host performs {en,de}cryption, then set to 1 */
2134 int host_encrypt_msdu;
2136 /* host performs multicast decryption */
2137 int host_mc_decrypt;
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;
2145 int ieee802_1x; /* is IEEE 802.1X used */
2148 bool bHalfWirelessN24GMode;
2150 int drop_unencrypted;
2151 int tkip_countermeasures;
2152 int privacy_invoked;
2156 u16 pairwise_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;
2164 int bcrx_sta_key; /* use individual keys to override default keys even
2165 * with RX of broad/multicast frames */
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 */
2177 /* Association info */
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
2188 struct ieee80211_network current_network;
2190 enum ieee80211_state state;
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 */
2199 /* used for forcing the ibss workqueue to terminate
2200 * without wait for the syncro scan to terminate
2202 short sync_scan_hurryup;
2207 u16 prev_seq_ctl; /* used to drop duplicate frames */
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
2215 int channel_map[MAX_CHANNEL_NUMBER+1];
2217 int rate; /* current rate */
2219 //FIXME: pleace callback, see if redundant with softmac_features
2222 /* this contains flags for selectively enable softmac support */
2223 u16 softmac_features;
2225 /* if the sequence control field is not filled by HW */
2228 /* association procedure transaction sequence number */
2231 /* AID for RTXed association responses */
2234 /* power save mode related*/
2240 struct tasklet_struct ps_task;
2245 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2248 short proto_started;
2250 struct semaphore wx_sem;
2251 struct semaphore scan_sem;
2253 spinlock_t mgmt_tx_lock;
2254 spinlock_t beacon_lock;
2261 u8 wpax_type_set; //{added by David, 2006.9.28}
2262 u32 wpax_type_notify; //{added by David, 2006.9.26}
2264 /* QoS related flag */
2265 char init_wmmparam_flag;
2266 /* set on initialization */
2269 /* for discarding duplicated packets in IBSS */
2270 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
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];
2278 unsigned long last_rx_ps_time;
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
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];
2293 // Enable/Disable Rx immediate BA capability.
2294 bool enable_rx_imm_BA;
2295 bool bibsscoordinator;
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;
2301 bool bCTSToSelfEnable;
2304 u32 fsync_time_interval;
2305 u32 fsync_rate_bitmap;
2306 u8 fsync_rssi_threshold;
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
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;
2324 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2325 struct tx_pending_t tx_pending;
2327 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2328 struct timer_list associate_timer;
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;
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;
2348 struct work_struct wx_sync_scan_wq;
2349 struct workqueue_struct *wq;
2351 /* used for periodly scan */
2352 struct timer_list scan_timer;
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;
2362 // Qos related. Added by Annie, 2005-11-01.
2365 //u32 STA_EDCA_PARAM[4];
2366 //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
2369 /* Callback functions */
2370 void (*set_security)(struct net_device *dev,
2371 struct ieee80211_security *sec);
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
2377 int (*hard_start_xmit)(struct ieee80211_txb *txb,
2378 struct net_device *dev);
2380 int (*reset_port)(struct net_device *dev);
2381 int (*is_queue_full) (struct net_device * dev, int pri);
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);
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.
2394 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
2395 struct net_device *dev);
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.
2403 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
2404 struct net_device *dev,int rate);
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.
2410 void (*data_hard_stop)(struct net_device *dev);
2412 /* OK this is complementar to data_poll_hard_stop */
2413 void (*data_hard_resume)(struct net_device *dev);
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.
2419 void (*set_chan)(struct net_device *dev,short ch);
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.
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.
2436 void (*scan_syncro)(struct net_device *dev);
2437 void (*start_scan)(struct net_device *dev);
2438 void (*stop_scan)(struct net_device *dev);
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
2445 void (*link_change)(struct net_device *dev);
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.
2453 void (*start_send_beacons) (struct net_device *dev);
2454 void (*stop_send_beacons) (struct net_device *dev);
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);
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);
2473 int (*handle_beacon) (struct net_device * dev, struct ieee80211_beacon * beacon, struct ieee80211_network * network);
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);
2482 int (*handle_assoc_response) (struct net_device * dev, struct ieee80211_assoc_response_frame * resp, struct ieee80211_network * network);
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);
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);
2502 /* This must be the last item so that it points to the data
2503 * allocated beyond this structure by alloc_ieee80211 */
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)
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)
2527 /* Generate a 802.11 header */
2529 /* Uses the channel change callback directly
2530 * instead of [start/stop] scan callbacks
2532 #define IEEE_SOFTMAC_SCAN (1<<2)
2534 /* Perform authentication and association handshake */
2535 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2537 /* Generate probe requests */
2538 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2540 /* Generate respones to probe requests */
2541 #define IEEE_SOFTMAC_PROBERS (1<<5)
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)
2548 /* Uses only the softmac_data_hard_start_xmit
2549 * even for TX management frames.
2551 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2553 /* Generate beacons. The stack will enqueue beacons
2556 #define IEEE_SOFTMAC_BEACONS (1<<6)
2558 static inline void *ieee80211_priv(struct net_device *dev)
2560 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
2561 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
2563 return ((struct ieee80211_device *)dev->priv)->priv;
2567 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
2569 /* Single white space is for Linksys APs */
2570 if (essid_len == 1 && essid[0] == ' ')
2573 /* Otherwise, if the entire essid is 0, we assume it is hidden */
2576 if (essid[essid_len] != '\0')
2583 extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
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
2591 if ((mode & IEEE_A) &&
2592 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2593 (ieee->freq_band & IEEE80211_52GHZ_BAND))
2596 if ((mode & IEEE_G) &&
2597 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2598 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2601 if ((mode & IEEE_B) &&
2602 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
2603 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2609 extern inline int ieee80211_get_hdrlen(u16 fc)
2611 int hdrlen = IEEE80211_3ADDR_LEN;
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*/
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;
2627 hdrlen = IEEE80211_2ADDR_LEN;
2636 static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
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;
2651 static inline int ieee80211_is_ofdm_rate(u8 rate)
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:
2667 static inline int ieee80211_is_cck_rate(u8 rate)
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:
2681 extern void free_ieee80211(struct net_device *dev);
2682 extern struct net_device *alloc_ieee80211(int sizeof_priv);
2684 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
2686 /* ieee80211_tx.c */
2688 extern int ieee80211_encrypt_fragment(
2689 struct ieee80211_device *ieee,
2690 struct sk_buff *frag,
2693 extern int ieee80211_rtl_xmit(struct sk_buff *skb,
2694 struct net_device *dev);
2695 extern void ieee80211_txb_free(struct ieee80211_txb *);
2698 /* ieee80211_rx.c */
2699 extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
2700 struct ieee80211_rx_stats *rx_stats);
2701 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2702 struct ieee80211_hdr_4addr *header,
2703 struct ieee80211_rx_stats *stats);
2705 /* ieee80211_wx.c */
2706 extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2707 struct iw_request_info *info,
2708 union iwreq_data *wrqu, char *key);
2709 extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *key);
2712 extern 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
2716 extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
2717 struct iw_request_info *info,
2718 union iwreq_data* wrqu, char *extra);
2719 extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
2720 struct iw_request_info *info,
2721 union iwreq_data* wrqu, char *extra);
2722 extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
2723 struct iw_request_info *info,
2724 struct iw_param *data, char *extra);
2725 extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
2726 struct iw_request_info *info,
2727 union iwreq_data *wrqu, char *extra);
2729 extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
2731 /* ieee80211_softmac.c */
2732 extern short ieee80211_is_54g(struct ieee80211_network net);
2733 extern short ieee80211_is_shortslot(struct ieee80211_network net);
2734 extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
2735 struct ieee80211_rx_stats *rx_stats, u16 type,
2737 extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
2739 void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
2740 extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
2742 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2743 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
2744 extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2745 extern void ieee80211_start_bss(struct ieee80211_device *ieee);
2746 extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2747 extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
2748 extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
2749 extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
2750 extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
2751 extern void ieee80211_disassociate(struct ieee80211_device *ieee);
2752 extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
2753 extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2754 extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2755 extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
2756 extern void ieee80211_stop_protocol(struct ieee80211_device *ieee,u8 shutdown);
2757 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
2758 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee,u8 shutdown);
2759 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
2760 extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
2761 extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
2762 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2763 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2764 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2765 extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
2766 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
2767 extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2769 extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
2771 /* ieee80211_crypt_ccmp&tkip&wep.c */
2772 extern void ieee80211_tkip_null(void);
2773 extern void ieee80211_wep_null(void);
2774 extern void ieee80211_ccmp_null(void);
2776 /* ieee80211_softmac_wx.c */
2778 extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2779 struct iw_request_info *info,
2780 union iwreq_data *wrqu, char *ext);
2782 extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2783 struct iw_request_info *info,
2784 union iwreq_data *awrq,
2787 extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
2789 extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra);
2793 extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2794 struct iw_request_info *info,
2795 union iwreq_data *wrqu, char *extra);
2797 extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2798 union iwreq_data *wrqu, char *b);
2800 extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
2801 union iwreq_data *wrqu, char *b);
2803 extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2804 struct iw_request_info *a,
2805 union iwreq_data *wrqu, char *extra);
2807 extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2808 union iwreq_data *wrqu, char *b);
2810 extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2811 union iwreq_data *wrqu, char *b);
2813 extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2814 union iwreq_data *wrqu, char *b);
2816 //extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2817 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2818 extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
2820 extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2824 extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2825 struct iw_request_info *info,
2826 union iwreq_data *wrqu, char *extra);
2828 extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
2829 struct iw_request_info *info,
2830 union iwreq_data *wrqu, char *extra);
2832 extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
2833 struct iw_request_info *info,
2834 union iwreq_data *wrqu, char *extra);
2836 extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
2837 struct iw_request_info *info,
2838 union iwreq_data *wrqu, char *extra);
2840 extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
2841 struct iw_request_info *info,
2842 union iwreq_data *wrqu, char *extra);
2844 extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
2845 struct iw_request_info *info,
2846 union iwreq_data *wrqu, char *extra);
2848 #define MAX_RECEIVE_BUFFER_SIZE 9100 //
2849 extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
2850 extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
2852 void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
2853 extern void HTUpdateDefaultSetting(struct ieee80211_device* ieee);
2854 extern void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt);
2855 extern void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
2856 extern void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len);
2857 extern void HTOnAssocRsp(struct ieee80211_device *ieee);
2858 extern void HTInitializeHTInfo(struct ieee80211_device* ieee);
2859 extern void HTInitializeBssDesc(PBSS_HT pBssHT);
2860 extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
2861 extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
2862 extern u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
2863 extern u8 MCS_FILTER_ALL[];
2864 extern u16 MCS_DATA_RATE[2][2][77] ;
2865 extern u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame);
2866 //extern void HTSetConnectBwModeCallback(unsigned long data);
2867 extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
2868 extern bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee);
2869 extern u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate);
2870 extern u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate);
2871 extern u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate);
2872 //function in BAPROC.c
2873 extern int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb);
2874 extern int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb);
2875 extern int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb);
2876 extern void TsInitAddBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending);
2877 extern void TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
2878 extern void BaSetupTimeOut(unsigned long data);
2879 extern void TxBaInactTimeout(unsigned long data);
2880 extern void RxBaInactTimeout(unsigned long data);
2881 extern void ResetBaEntry( PBA_RECORD pBA);
2884 struct ieee80211_device* ieee,
2885 PTS_COMMON_INFO *ppTS,
2888 TR_SELECT TxRxSelect, //Rx:1, Tx:0
2891 extern void TSInitialize(struct ieee80211_device *ieee);
2892 extern void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS);
2893 extern void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr);
2894 extern void RemoveAllTS(struct ieee80211_device* ieee);
2895 void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
2897 extern const long ieee80211_wlan_frequencies[];
2899 extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
2904 extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2909 static 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;
2914 if (ieee80211_is_empty_essid(essid, essid_len)) {
2915 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2919 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
2920 while (essid_len--) {
2933 /* For the function is more related to hardware setting, it's better to use the
2934 * ieee handler to refer to it.
2936 extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
2937 extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
2938 extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
2939 struct ieee80211_info_element *info_element,
2941 struct ieee80211_network *network,
2942 struct ieee80211_rx_stats *stats);
2944 void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index);
2945 void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
2946 void ieee80211_sta_ps_send_pspoll_frame(struct ieee80211_device *ieee);
2947 #define RT_ASOC_RETRY_LIMIT 5
2948 #endif /* IEEE80211_H */