2 * Merged with mainline rtllib.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 #include <linux/interrupt.h>
31 #include <linux/jiffies.h>
32 #include <linux/timer.h>
33 #include <linux/sched.h>
35 #include <linux/delay.h>
36 #include <linux/wireless.h>
38 #include "rtl819x_HT.h"
39 #include "rtl819x_BA.h"
40 #include "rtl819x_TS.h"
42 #include <linux/netdevice.h>
43 #include <linux/if_arp.h> /* ARPHRD_ETHER */
48 #include <net/iw_handler.h>
50 #ifndef IW_MODE_MONITOR
51 #define IW_MODE_MONITOR 6
55 #define IWEVCUSTOM 0x8c02
59 /* Max number of char in custom event - use multiple of them if needed */
60 #define IW_CUSTOM_MAX 256 /* In bytes */
65 * container_of - cast a member of a structure out to the containing structure
67 * @ptr: the pointer to the member.
68 * @type: the type of the container struct this is embedded in.
69 * @member: the name of the member within the struct.
72 #define container_of(ptr, type, member) ({ \
73 const typeof(((type *)0)->member)*__mptr = (ptr); \
74 (type *)((char *)__mptr - offsetof(type, member)); })
77 #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
79 #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
82 #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
83 #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
85 #define queue_work_rsl(x, y) queue_work(x, y)
86 #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
88 #define container_of_work_rsl(x, y, z) container_of(x, y, z)
89 #define container_of_dwork_rsl(x, y, z) \
90 container_of(container_of(x, struct delayed_work, work), y, z)
92 #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
93 iwe_stream_add_event(info, start, stop, iwe, len)
95 #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
96 iwe_stream_add_point(info, start, stop, iwe, p)
98 #define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
99 #define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
101 static inline void *netdev_priv_rsl(struct net_device *dev)
103 return netdev_priv(dev);
106 #define KEY_TYPE_NA 0x0
107 #define KEY_TYPE_WEP40 0x1
108 #define KEY_TYPE_TKIP 0x2
109 #define KEY_TYPE_CCMP 0x4
110 #define KEY_TYPE_WEP104 0x5
111 /* added for rtl819x tx procedure */
112 #define MAX_QUEUE_SIZE 0x10
119 #define TXCMD_QUEUE 5
122 #define BEACON_QUEUE 8
124 #define LOW_QUEUE BE_QUEUE
125 #define NORMAL_QUEUE MGNT_QUEUE
128 #define IW_MODE_MESH 7
130 #define AMSDU_SUBHEADER_LEN 14
131 #define SWRF_TIMEOUT 50
133 #define IE_CISCO_FLAG_POSITION 0x08
134 #define SUPPORT_CKIP_MIC 0x08
135 #define SUPPORT_CKIP_PK 0x10
136 #define RT_RF_OFF_LEVL_ASPM BIT0
137 #define RT_RF_OFF_LEVL_CLK_REQ BIT1
138 #define RT_RF_OFF_LEVL_PCI_D3 BIT2
139 #define RT_RF_OFF_LEVL_HALT_NIC BIT3
140 #define RT_RF_OFF_LEVL_FREE_FW BIT4
141 #define RT_RF_OFF_LEVL_FW_32K BIT5
142 #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
143 #define RT_RF_LPS_DISALBE_2R BIT30
144 #define RT_RF_LPS_LEVEL_ASPM BIT31
145 #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \
146 ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
147 #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \
148 (pPSC->CurPsLevel &= (~(_PS_FLAG)))
149 #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
151 /* defined for skb cb field */
152 /* At most 28 byte */
154 /* Tx Desc Related flags (8-9) */
160 u8 bTxDisableRateFallBack:1;
161 u8 bTxUseDriverAssingedRate:1;
166 /* Tx Firmware Relaged flags (10-11)*/
170 u8 bUseShortPreamble:1;
171 u8 bTxEnableFwCalcDur:1;
178 u8 bRTSUseShortPreamble:1;
185 /* Tx Desc related element(12-19) */
196 /* Tx firmware related element(20-27) */
204 u8 bIsSpecialDataFrame;
210 /*--------------------------Define -------------------------------------------*/
213 #define MGN_5_5M 0x0b
225 #define MGN_MCS0 0x80
226 #define MGN_MCS1 0x81
227 #define MGN_MCS2 0x82
228 #define MGN_MCS3 0x83
229 #define MGN_MCS4 0x84
230 #define MGN_MCS5 0x85
231 #define MGN_MCS6 0x86
232 #define MGN_MCS7 0x87
233 #define MGN_MCS8 0x88
234 #define MGN_MCS9 0x89
235 #define MGN_MCS10 0x8a
236 #define MGN_MCS11 0x8b
237 #define MGN_MCS12 0x8c
238 #define MGN_MCS13 0x8d
239 #define MGN_MCS14 0x8e
240 #define MGN_MCS15 0x8f
241 #define MGN_MCS0_SG 0x90
242 #define MGN_MCS1_SG 0x91
243 #define MGN_MCS2_SG 0x92
244 #define MGN_MCS3_SG 0x93
245 #define MGN_MCS4_SG 0x94
246 #define MGN_MCS5_SG 0x95
247 #define MGN_MCS6_SG 0x96
248 #define MGN_MCS7_SG 0x97
249 #define MGN_MCS8_SG 0x98
250 #define MGN_MCS9_SG 0x99
251 #define MGN_MCS10_SG 0x9a
252 #define MGN_MCS11_SG 0x9b
253 #define MGN_MCS12_SG 0x9c
254 #define MGN_MCS13_SG 0x9d
255 #define MGN_MCS14_SG 0x9e
256 #define MGN_MCS15_SG 0x9f
261 auth_not_valid = 0x2,
273 four_way_tmout = 0x0f,
274 two_way_tmout = 0x10,
276 invalid_Gcipher = 0x12,
277 invalid_Pcipher = 0x13,
279 unsup_RSNIEver = 0x15,
280 invalid_RSNIE = 0x16,
281 auth_802_1x_fail = 0x17,
285 QAP_bandwidth = 0x21,
286 poor_condition = 0x22,
289 invalid_param = 0x26,
290 req_not_honored = 0x27,
291 TS_not_created = 0x2F,
292 DL_not_allowed = 0x30,
293 dest_not_exist = 0x31,
294 dest_not_QSTA = 0x32,
297 enum hal_def_variable {
300 HAL_DEF_PROT_IMP_MODE,
301 HAL_DEF_HIGH_POWER_MECHANISM,
302 HAL_DEF_RATE_ADAPTIVE_MECHANISM,
303 HAL_DEF_ANTENNA_DIVERSITY_MECHANISM,
309 HAL_DEF_MIN_TX_POWER_DBM,
310 HAL_DEF_MAX_TX_POWER_DBM,
311 HW_DEF_EFUSE_REPG_SECTION1_FLAG,
312 HW_DEF_EFUSE_REPG_DATA,
314 HAL_DEF_PCI_SUPPORT_ASPM,
315 HAL_DEF_THERMAL_VALUE,
316 HAL_DEF_USB_IN_TOKEN_REV,
321 HW_VAR_MULTICAST_REG,
325 HW_VAR_SECURITY_CONF,
326 HW_VAR_BEACON_INTERVAL,
328 HW_VAR_LISTEN_INTERVAL,
341 HW_VAR_RATE_FALLBACK_CONTROL,
342 HW_VAR_CONTENTION_WINDOW,
347 HW_VAR_AMPDU_MIN_SPACE,
348 HW_VAR_SHORTGI_DENSITY,
350 HW_VAR_MCS_RATE_AVAILABLE,
353 HW_VAR_DIS_Req_Qsize,
354 HW_VAR_CCX_CHNL_LOAD,
355 HW_VAR_CCX_NOISE_HISTOGRAM,
362 HW_VAR_SET_DEV_POWER,
372 HW_VAR_USER_CONTROL_TURBO_MODE,
378 HW_VAR_AUTOLOAD_STATUS,
379 HW_VAR_RF_2R_DISABLE,
381 HW_VAR_H2C_FW_PWRMODE,
382 HW_VAR_H2C_FW_JOINBSSRPT,
383 HW_VAR_1X1_RECV_COMBINE,
384 HW_VAR_STOP_SEND_BEACON,
389 HW_VAR_H2C_FW_UPDATE_GTK,
392 HW_VAR_WF_IS_MAC_ADDR,
393 HW_VAR_H2C_FW_OFFLOAD,
396 HW_VAR_HANDLE_FW_C2H,
397 HW_VAR_DL_FW_RSVD_PAGE,
399 HW_VAR_HW_SEQ_ENABLE,
404 HW_VAR_SWITCH_EPHY_WoWLAN,
405 HW_VAR_INT_MIGRATION,
412 RT_OP_MODE_INFRASTRUCTURE,
419 (((priv->rtllib->current_network.mode == IEEE_A) \
420 || (priv->rtllib->current_network.mode == IEEE_N_24G) \
421 || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
423 #define MGMT_QUEUE_NUM 5
425 #define IEEE_CMD_SET_WPA_PARAM 1
426 #define IEEE_CMD_SET_WPA_IE 2
427 #define IEEE_CMD_SET_ENCRYPTION 3
428 #define IEEE_CMD_MLME 4
430 #define IEEE_PARAM_WPA_ENABLED 1
431 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
432 #define IEEE_PARAM_DROP_UNENCRYPTED 3
433 #define IEEE_PARAM_PRIVACY_INVOKED 4
434 #define IEEE_PARAM_AUTH_ALGS 5
435 #define IEEE_PARAM_IEEE_802_1X 6
436 #define IEEE_PARAM_WPAX_SELECT 7
437 #define IEEE_PROTO_WPA 1
438 #define IEEE_PROTO_RSN 2
439 #define IEEE_WPAX_USEGROUP 0
440 #define IEEE_WPAX_WEP40 1
441 #define IEEE_WPAX_TKIP 2
442 #define IEEE_WPAX_WRAP 3
443 #define IEEE_WPAX_CCMP 4
444 #define IEEE_WPAX_WEP104 5
446 #define IEEE_KEY_MGMT_IEEE8021X 1
447 #define IEEE_KEY_MGMT_PSK 2
449 #define IEEE_MLME_STA_DEAUTH 1
450 #define IEEE_MLME_STA_DISASSOC 2
453 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
454 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
455 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
456 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
457 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
458 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
459 #define IEEE_CRYPT_ALG_NAME_LEN 16
461 #define MAX_IE_LEN 0xff
462 #define RT_ASSERT_RET(_Exp) do {} while (0)
463 #define RT_ASSERT_RET_VALUE(_Exp, Ret) \
468 u8 sta_addr[ETH_ALEN];
484 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
488 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
496 #if WIRELESS_EXT < 17
497 #define IW_QUAL_QUAL_INVALID 0x10
498 #define IW_QUAL_LEVEL_INVALID 0x20
499 #define IW_QUAL_NOISE_INVALID 0x40
500 #define IW_QUAL_QUAL_UPDATED 0x1
501 #define IW_QUAL_LEVEL_UPDATED 0x2
502 #define IW_QUAL_NOISE_UPDATED 0x4
505 #define MSECS(t) msecs_to_jiffies(t)
506 #define msleep_interruptible_rsl msleep_interruptible
508 #define RTLLIB_DATA_LEN 2304
509 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
512 The figure in section 7.1.2 suggests a body size of up to 2312
513 bytes is allowed, which is a bit confusing, I suspect this
514 represents the 2304 bytes of real data, plus a possible 8 bytes of
515 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
516 #define RTLLIB_1ADDR_LEN 10
517 #define RTLLIB_2ADDR_LEN 16
518 #define RTLLIB_3ADDR_LEN 24
519 #define RTLLIB_4ADDR_LEN 30
520 #define RTLLIB_FCS_LEN 4
521 #define RTLLIB_HLEN (RTLLIB_4ADDR_LEN)
522 #define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN)
523 #define RTLLIB_MGMT_HDR_LEN 24
524 #define RTLLIB_DATA_HDR3_LEN 24
525 #define RTLLIB_DATA_HDR4_LEN 30
527 #define RTLLIB_SKBBUFFER_SIZE 2500
529 #define MIN_FRAG_THRESHOLD 256U
530 #define MAX_FRAG_THRESHOLD 2346U
531 #define MAX_HT_DATA_FRAG_THRESHOLD 0x2000
533 #define HT_AMSDU_SIZE_4K 3839
534 #define HT_AMSDU_SIZE_8K 7935
536 /* Frame control field constants */
537 #define RTLLIB_FCTL_VERS 0x0003
538 #define RTLLIB_FCTL_FTYPE 0x000c
539 #define RTLLIB_FCTL_STYPE 0x00f0
540 #define RTLLIB_FCTL_FRAMETYPE 0x00fc
541 #define RTLLIB_FCTL_TODS 0x0100
542 #define RTLLIB_FCTL_FROMDS 0x0200
543 #define RTLLIB_FCTL_DSTODS 0x0300
544 #define RTLLIB_FCTL_MOREFRAGS 0x0400
545 #define RTLLIB_FCTL_RETRY 0x0800
546 #define RTLLIB_FCTL_PM 0x1000
547 #define RTLLIB_FCTL_MOREDATA 0x2000
548 #define RTLLIB_FCTL_WEP 0x4000
549 #define RTLLIB_FCTL_ORDER 0x8000
551 #define RTLLIB_FTYPE_MGMT 0x0000
552 #define RTLLIB_FTYPE_CTL 0x0004
553 #define RTLLIB_FTYPE_DATA 0x0008
556 #define RTLLIB_STYPE_ASSOC_REQ 0x0000
557 #define RTLLIB_STYPE_ASSOC_RESP 0x0010
558 #define RTLLIB_STYPE_REASSOC_REQ 0x0020
559 #define RTLLIB_STYPE_REASSOC_RESP 0x0030
560 #define RTLLIB_STYPE_PROBE_REQ 0x0040
561 #define RTLLIB_STYPE_PROBE_RESP 0x0050
562 #define RTLLIB_STYPE_BEACON 0x0080
563 #define RTLLIB_STYPE_ATIM 0x0090
564 #define RTLLIB_STYPE_DISASSOC 0x00A0
565 #define RTLLIB_STYPE_AUTH 0x00B0
566 #define RTLLIB_STYPE_DEAUTH 0x00C0
567 #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
570 #define RTLLIB_STYPE_PSPOLL 0x00A0
571 #define RTLLIB_STYPE_RTS 0x00B0
572 #define RTLLIB_STYPE_CTS 0x00C0
573 #define RTLLIB_STYPE_ACK 0x00D0
574 #define RTLLIB_STYPE_CFEND 0x00E0
575 #define RTLLIB_STYPE_CFENDACK 0x00F0
576 #define RTLLIB_STYPE_BLOCKACK 0x0094
579 #define RTLLIB_STYPE_DATA 0x0000
580 #define RTLLIB_STYPE_DATA_CFACK 0x0010
581 #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
582 #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
583 #define RTLLIB_STYPE_NULLFUNC 0x0040
584 #define RTLLIB_STYPE_CFACK 0x0050
585 #define RTLLIB_STYPE_CFPOLL 0x0060
586 #define RTLLIB_STYPE_CFACKPOLL 0x0070
587 #define RTLLIB_STYPE_QOS_DATA 0x0080
588 #define RTLLIB_STYPE_QOS_NULL 0x00C0
590 #define RTLLIB_SCTL_FRAG 0x000F
591 #define RTLLIB_SCTL_SEQ 0xFFF0
594 #define RTLLIB_QCTL_TID 0x000F
596 #define FC_QOS_BIT BIT7
597 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
598 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
599 #define IsQoSDataFrame(pframe) \
600 ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
601 (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
602 #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
603 #define SN_LESS(a, b) (((a-b)&0x800) != 0)
604 #define SN_EQUAL(a, b) (a == b)
605 #define MAX_DEV_ADDR_SIZE 8
628 enum init_gain_op_type {
635 LED_CTL_POWER_ON = 1,
640 LED_CTL_SITE_SURVEY = 6,
641 LED_CTL_POWER_OFF = 7,
642 LED_CTL_START_TO_LINK = 8,
643 LED_CTL_START_WPS = 9,
644 LED_CTL_STOP_WPS = 10,
645 LED_CTL_START_WPS_BOTTON = 11,
646 LED_CTL_STOP_WPS_FAIL = 12,
647 LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
650 enum rt_rf_type_def {
660 WIRELESS_MODE_UNKNOWN = 0x00,
661 WIRELESS_MODE_A = 0x01,
662 WIRELESS_MODE_B = 0x02,
663 WIRELESS_MODE_G = 0x04,
664 WIRELESS_MODE_AUTO = 0x08,
665 WIRELESS_MODE_N_24G = 0x10,
666 WIRELESS_MODE_N_5G = 0x20
669 enum wireless_network_type {
676 #define OUI_SUBTYPE_WMM_INFO 0
677 #define OUI_SUBTYPE_WMM_PARAM 1
678 #define OUI_SUBTYPE_QOS_CAPABI 5
681 extern u32 rtllib_debug_level;
682 #define RTLLIB_DEBUG(level, fmt, args...) \
684 if (rtllib_debug_level & (level)) \
685 printk(KERN_DEBUG "rtllib: " fmt, ## args); \
688 #define RTLLIB_DEBUG_DATA(level, data, datalen) \
690 if ((rtllib_debug_level & (level)) == (level)) { \
692 u8 *pdata = (u8 *)data; \
693 printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
694 for (i = 0; i < (int)(datalen); i++) { \
695 printk("%2.2x ", pdata[i]); \
703 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
704 #define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \
705 ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5]
708 * To use the debug system;
710 * If you are defining a new debug classification, simply add it to the #define
711 * list here in the form of:
713 * #define RTLLIB_DL_xxxx VALUE
715 * shifting value to the left one bit from the previous entry. xxxx should be
716 * the name of the classification (for example, WEP)
718 * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
719 * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
720 * to send output to that classification.
722 * To add your debug level to the list of levels seen when you perform
724 * % cat /proc/net/ipw/debug_level
726 * you simply need to add your entry to the ipw_debug_levels array.
731 #define RTLLIB_DL_INFO (1<<0)
732 #define RTLLIB_DL_WX (1<<1)
733 #define RTLLIB_DL_SCAN (1<<2)
734 #define RTLLIB_DL_STATE (1<<3)
735 #define RTLLIB_DL_MGMT (1<<4)
736 #define RTLLIB_DL_FRAG (1<<5)
737 #define RTLLIB_DL_EAP (1<<6)
738 #define RTLLIB_DL_DROP (1<<7)
740 #define RTLLIB_DL_TX (1<<8)
741 #define RTLLIB_DL_RX (1<<9)
743 #define RTLLIB_DL_HT (1<<10)
744 #define RTLLIB_DL_BA (1<<11)
745 #define RTLLIB_DL_TS (1<<12)
746 #define RTLLIB_DL_QOS (1<<13)
747 #define RTLLIB_DL_REORDER (1<<14)
748 #define RTLLIB_DL_IOT (1<<15)
749 #define RTLLIB_DL_IPS (1<<16)
750 #define RTLLIB_DL_TRACE (1<<29)
751 #define RTLLIB_DL_DATA (1<<30)
752 #define RTLLIB_DL_ERR (1<<31)
753 #define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
754 #define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
755 #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
757 #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
758 #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
759 #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
760 #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
761 #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
762 #define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
763 #define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
764 #define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
765 #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
766 #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
768 /* Added by Annie, 2005-11-22. */
769 #define MAX_STR_LEN 64
770 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
771 #define PRINTABLE(_ch) (_ch > '!' && _ch < '~')
772 #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
773 if ((_Comp) & level) { \
775 u8 struct buffer[MAX_STR_LEN]; \
776 int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\
777 memset(struct buffer, 0, MAX_STR_LEN); \
778 memcpy(struct buffer, (u8 *)_Ptr, length); \
779 for (__i = 0; __i < MAX_STR_LEN; __i++) { \
780 if (!PRINTABLE(struct buffer[__i])) \
781 struct buffer[__i] = '?'; \
783 struct buffer[length] = '\0'; \
784 printk(KERN_INFO "Rtl819x: "); \
785 printk(_TitleString); \
786 printk(": %d, <%s>\n", _Len, struct buffer); \
789 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
790 #define ETH_P_IP 0x0800 /* Internet Protocol packet */
791 #define ETH_P_ARP 0x0806 /* Address Resolution packet */
792 #endif /* ETH_P_PAE */
794 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
796 #ifndef ETH_P_80211_RAW
797 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
800 /* IEEE 802.11 defines */
802 #define P80211_OUI_LEN 3
804 struct rtllib_snap_hdr {
806 u8 dsap; /* always 0xAA */
807 u8 ssap; /* always 0xAA */
808 u8 ctrl; /* always 0x03 */
809 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
813 enum _REG_PREAMBLE_MODE {
819 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
821 #define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS)
822 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
823 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
824 #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
826 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
827 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
828 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
830 /* Authentication algorithms */
831 #define WLAN_AUTH_OPEN 0
832 #define WLAN_AUTH_SHARED_KEY 1
833 #define WLAN_AUTH_LEAP 128
835 #define WLAN_AUTH_CHALLENGE_LEN 128
837 #define WLAN_CAPABILITY_ESS (1<<0)
838 #define WLAN_CAPABILITY_IBSS (1<<1)
839 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
840 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
841 #define WLAN_CAPABILITY_PRIVACY (1<<4)
842 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
843 #define WLAN_CAPABILITY_PBCC (1<<6)
844 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
845 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
846 #define WLAN_CAPABILITY_QOS (1<<9)
847 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
848 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
850 /* 802.11g ERP information element */
851 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
852 #define WLAN_ERP_USE_PROTECTION (1<<1)
853 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
856 enum rtllib_statuscode {
857 WLAN_STATUS_SUCCESS = 0,
858 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
859 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
860 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
861 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
862 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
863 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
864 WLAN_STATUS_CHALLENGE_FAIL = 15,
865 WLAN_STATUS_AUTH_TIMEOUT = 16,
866 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
867 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
869 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
870 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
871 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
873 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
874 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
875 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
877 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
878 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
880 WLAN_STATUS_INVALID_IE = 40,
881 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
882 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
883 WLAN_STATUS_INVALID_AKMP = 43,
884 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
885 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
886 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
890 enum rtllib_reasoncode {
891 WLAN_REASON_UNSPECIFIED = 1,
892 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
893 WLAN_REASON_DEAUTH_LEAVING = 3,
894 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
895 WLAN_REASON_DISASSOC_AP_BUSY = 5,
896 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
897 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
898 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
899 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
901 WLAN_REASON_DISASSOC_BAD_POWER = 10,
902 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
904 WLAN_REASON_INVALID_IE = 13,
905 WLAN_REASON_MIC_FAILURE = 14,
906 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
907 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
908 WLAN_REASON_IE_DIFFERENT = 17,
909 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
910 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
911 WLAN_REASON_INVALID_AKMP = 20,
912 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
913 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
914 WLAN_REASON_IEEE8021X_FAILED = 23,
915 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
918 #define RTLLIB_STATMASK_SIGNAL (1<<0)
919 #define RTLLIB_STATMASK_RSSI (1<<1)
920 #define RTLLIB_STATMASK_NOISE (1<<2)
921 #define RTLLIB_STATMASK_RATE (1<<3)
922 #define RTLLIB_STATMASK_WEMASK 0x7
924 #define RTLLIB_CCK_MODULATION (1<<0)
925 #define RTLLIB_OFDM_MODULATION (1<<1)
927 #define RTLLIB_24GHZ_BAND (1<<0)
928 #define RTLLIB_52GHZ_BAND (1<<1)
930 #define RTLLIB_CCK_RATE_LEN 4
931 #define RTLLIB_CCK_RATE_1MB 0x02
932 #define RTLLIB_CCK_RATE_2MB 0x04
933 #define RTLLIB_CCK_RATE_5MB 0x0B
934 #define RTLLIB_CCK_RATE_11MB 0x16
935 #define RTLLIB_OFDM_RATE_LEN 8
936 #define RTLLIB_OFDM_RATE_6MB 0x0C
937 #define RTLLIB_OFDM_RATE_9MB 0x12
938 #define RTLLIB_OFDM_RATE_12MB 0x18
939 #define RTLLIB_OFDM_RATE_18MB 0x24
940 #define RTLLIB_OFDM_RATE_24MB 0x30
941 #define RTLLIB_OFDM_RATE_36MB 0x48
942 #define RTLLIB_OFDM_RATE_48MB 0x60
943 #define RTLLIB_OFDM_RATE_54MB 0x6C
944 #define RTLLIB_BASIC_RATE_MASK 0x80
946 #define RTLLIB_CCK_RATE_1MB_MASK (1<<0)
947 #define RTLLIB_CCK_RATE_2MB_MASK (1<<1)
948 #define RTLLIB_CCK_RATE_5MB_MASK (1<<2)
949 #define RTLLIB_CCK_RATE_11MB_MASK (1<<3)
950 #define RTLLIB_OFDM_RATE_6MB_MASK (1<<4)
951 #define RTLLIB_OFDM_RATE_9MB_MASK (1<<5)
952 #define RTLLIB_OFDM_RATE_12MB_MASK (1<<6)
953 #define RTLLIB_OFDM_RATE_18MB_MASK (1<<7)
954 #define RTLLIB_OFDM_RATE_24MB_MASK (1<<8)
955 #define RTLLIB_OFDM_RATE_36MB_MASK (1<<9)
956 #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10)
957 #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11)
959 #define RTLLIB_CCK_RATES_MASK 0x0000000F
960 #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \
961 RTLLIB_CCK_RATE_2MB_MASK)
962 #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \
963 RTLLIB_CCK_RATE_5MB_MASK | \
964 RTLLIB_CCK_RATE_11MB_MASK)
966 #define RTLLIB_OFDM_RATES_MASK 0x00000FF0
967 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \
968 RTLLIB_OFDM_RATE_12MB_MASK | \
969 RTLLIB_OFDM_RATE_24MB_MASK)
970 #define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \
971 RTLLIB_OFDM_RATE_9MB_MASK | \
972 RTLLIB_OFDM_RATE_18MB_MASK | \
973 RTLLIB_OFDM_RATE_36MB_MASK | \
974 RTLLIB_OFDM_RATE_48MB_MASK | \
975 RTLLIB_OFDM_RATE_54MB_MASK)
976 #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \
977 RTLLIB_CCK_DEFAULT_RATES_MASK)
979 #define RTLLIB_NUM_OFDM_RATES 8
980 #define RTLLIB_NUM_CCK_RATES 4
981 #define RTLLIB_OFDM_SHIFT_MASK_A 4
984 /* this is stolen and modified from the madwifi driver*/
985 #define RTLLIB_FC0_TYPE_MASK 0x0c
986 #define RTLLIB_FC0_TYPE_DATA 0x08
987 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
988 #define RTLLIB_FC0_SUBTYPE_QOS 0x80
990 #define RTLLIB_QOS_HAS_SEQ(fc) \
991 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
992 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
994 /* this is stolen from ipw2200 driver */
995 #define IEEE_IBSS_MAC_HASH_SIZE 31
996 struct ieee_ibss_seq {
1000 unsigned long packet_time[17];
1001 struct list_head list;
1004 /* NOTE: This data is for statistical purposes; not all hardware provides this
1005 * information for frames received. Not setting these will not cause
1006 * any adverse affects. */
1007 struct rtllib_rx_stats {
1012 u16 rate; /* in 100 kbps */
1013 u8 received_channel;
1023 s32 RecvSignalPower;
1029 u16 bShortPreamble:1;
1046 bool RxIs40MHzPacket;
1048 u8 RxMIMOSignalStrength[4];
1049 s8 RxMIMOSignalQuality[2];
1050 bool bPacketMatchBSSID;
1053 u8 *virtual_address;
1058 bool bisrxaggrsubframe;
1061 char cck_adc_pwdb[4];
1066 /* IEEE 802.11 requires that STA supports concurrent reception of at least
1067 * three fragmented frames. This define can be increased to support more
1068 * concurrent frames, but it should be noted that each entry can consume about
1069 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
1070 #define RTLLIB_FRAG_CACHE_LEN 4
1072 struct rtllib_frag_entry {
1073 unsigned long first_frag_time;
1075 unsigned int last_frag;
1076 struct sk_buff *skb;
1077 u8 src_addr[ETH_ALEN];
1078 u8 dst_addr[ETH_ALEN];
1081 struct rtllib_stats {
1082 unsigned int tx_unicast_frames;
1083 unsigned int tx_multicast_frames;
1084 unsigned int tx_fragments;
1085 unsigned int tx_unicast_octets;
1086 unsigned int tx_multicast_octets;
1087 unsigned int tx_deferred_transmissions;
1088 unsigned int tx_single_retry_frames;
1089 unsigned int tx_multiple_retry_frames;
1090 unsigned int tx_retry_limit_exceeded;
1091 unsigned int tx_discards;
1092 unsigned int rx_unicast_frames;
1093 unsigned int rx_multicast_frames;
1094 unsigned int rx_fragments;
1095 unsigned int rx_unicast_octets;
1096 unsigned int rx_multicast_octets;
1097 unsigned int rx_fcs_errors;
1098 unsigned int rx_discards_no_buffer;
1099 unsigned int tx_discards_wrong_sa;
1100 unsigned int rx_discards_undecryptable;
1101 unsigned int rx_message_in_msg_fragments;
1102 unsigned int rx_message_in_bad_msg_fragments;
1105 struct rtllib_device;
1107 #include "rtllib_crypt.h"
1109 #define SEC_KEY_1 (1<<0)
1110 #define SEC_KEY_2 (1<<1)
1111 #define SEC_KEY_3 (1<<2)
1112 #define SEC_KEY_4 (1<<3)
1113 #define SEC_ACTIVE_KEY (1<<4)
1114 #define SEC_AUTH_MODE (1<<5)
1115 #define SEC_UNICAST_GROUP (1<<6)
1116 #define SEC_LEVEL (1<<7)
1117 #define SEC_ENABLED (1<<8)
1118 #define SEC_ENCRYPT (1<<9)
1120 #define SEC_LEVEL_0 0 /* None */
1121 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
1122 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
1123 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
1124 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
1126 #define SEC_ALG_NONE 0
1127 #define SEC_ALG_WEP 1
1128 #define SEC_ALG_TKIP 2
1129 #define SEC_ALG_CCMP 4
1132 #define WEP_KEY_LEN 13
1133 #define SCM_KEY_LEN 32
1134 #define SCM_TEMPORAL_KEY_LENGTH 16
1136 struct rtllib_security {
1141 unicast_uses_group:1,
1143 u8 key_sizes[WEP_KEYS];
1144 u8 keys[WEP_KEYS][SCM_KEY_LEN];
1151 802.11 data frame from AP
1152 ,-------------------------------------------------------------------.
1153 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1154 |------|------|---------|---------|---------|------|---------|------|
1155 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1156 | | tion | (BSSID) | | | ence | data | |
1157 `-------------------------------------------------------------------'
1158 Total: 28-2340 bytes
1161 /* Management Frame Information Element Types */
1164 MFIE_TYPE_RATES = 1,
1165 MFIE_TYPE_FH_SET = 2,
1166 MFIE_TYPE_DS_SET = 3,
1167 MFIE_TYPE_CF_SET = 4,
1169 MFIE_TYPE_IBSS_SET = 6,
1170 MFIE_TYPE_COUNTRY = 7,
1171 MFIE_TYPE_HOP_PARAMS = 8,
1172 MFIE_TYPE_HOP_TABLE = 9,
1173 MFIE_TYPE_REQUEST = 10,
1174 MFIE_TYPE_CHALLENGE = 16,
1175 MFIE_TYPE_POWER_CONSTRAINT = 32,
1176 MFIE_TYPE_POWER_CAPABILITY = 33,
1177 MFIE_TYPE_TPC_REQUEST = 34,
1178 MFIE_TYPE_TPC_REPORT = 35,
1179 MFIE_TYPE_SUPP_CHANNELS = 36,
1181 MFIE_TYPE_MEASURE_REQUEST = 38,
1182 MFIE_TYPE_MEASURE_REPORT = 39,
1183 MFIE_TYPE_QUIET = 40,
1184 MFIE_TYPE_IBSS_DFS = 41,
1186 MFIE_TYPE_HT_CAP = 45,
1188 MFIE_TYPE_RATES_EX = 50,
1189 MFIE_TYPE_HT_INFO = 61,
1190 MFIE_TYPE_AIRONET = 133,
1191 MFIE_TYPE_GENERIC = 221,
1192 MFIE_TYPE_QOS_PARAMETER = 222,
1195 /* Minimal header; can be used for passing 802.11 frames with sufficient
1196 * information to determine what type of underlying data type is actually
1197 * stored in the data. */
1198 struct rtllib_pspoll_hdr {
1211 struct rtllib_hdr_1addr {
1218 struct rtllib_hdr_2addr {
1226 struct rtllib_hdr_3addr {
1236 struct rtllib_hdr_4addr {
1247 struct rtllib_hdr_3addrqos {
1258 struct rtllib_hdr_4addrqos {
1270 struct rtllib_info_element {
1276 struct rtllib_authentication {
1277 struct rtllib_hdr_3addr header;
1282 struct rtllib_info_element info_element[0];
1285 struct rtllib_disauth {
1286 struct rtllib_hdr_3addr header;
1290 struct rtllib_disassoc {
1291 struct rtllib_hdr_3addr header;
1295 struct rtllib_probe_request {
1296 struct rtllib_hdr_3addr header;
1297 /* SSID, supported rates */
1298 struct rtllib_info_element info_element[0];
1301 struct rtllib_probe_response {
1302 struct rtllib_hdr_3addr header;
1304 __le16 beacon_interval;
1306 /* SSID, supported rates, FH params, DS params,
1307 * CF params, IBSS params, TIM (if beacon), RSN */
1308 struct rtllib_info_element info_element[0];
1311 /* Alias beacon for probe_response */
1312 #define rtllib_beacon rtllib_probe_response
1314 struct rtllib_assoc_request_frame {
1315 struct rtllib_hdr_3addr header;
1317 __le16 listen_interval;
1318 /* SSID, supported rates, RSN */
1319 struct rtllib_info_element info_element[0];
1322 struct rtllib_reassoc_request_frame {
1323 struct rtllib_hdr_3addr header;
1325 __le16 listen_interval;
1326 u8 current_ap[ETH_ALEN];
1327 /* SSID, supported rates, RSN */
1328 struct rtllib_info_element info_element[0];
1331 struct rtllib_assoc_response_frame {
1332 struct rtllib_hdr_3addr header;
1336 struct rtllib_info_element info_element[0]; /* supported rates */
1346 __le16 payload_size;
1347 struct sk_buff *fragments[0];
1350 #define MAX_TX_AGG_COUNT 16
1351 struct rtllib_drv_agg_txb {
1352 u8 nr_drv_agg_frames;
1353 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1356 #define MAX_SUBFRAME_COUNT 64
1359 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1376 /* SWEEP TABLE ENTRIES NUMBER*/
1377 #define MAX_SWEEP_TAB_ENTRIES 42
1378 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1379 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1380 * only use 8, and then use extended rates for the remaining supported
1381 * rates. Other APs, however, stick all of their supported rates on the
1382 * main rates information element... */
1383 #define MAX_RATES_LENGTH ((u8)12)
1384 #define MAX_RATES_EX_LENGTH ((u8)16)
1385 #define MAX_NETWORK_COUNT 96
1387 #define MAX_CHANNEL_NUMBER 161
1388 #define RTLLIB_SOFTMAC_SCAN_TIME 100
1389 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1391 #define CRC_LENGTH 4U
1393 #define MAX_WPA_IE_LEN 64
1394 #define MAX_WZC_IE_LEN 256
1396 #define NETWORK_EMPTY_ESSID (1<<0)
1397 #define NETWORK_HAS_OFDM (1<<1)
1398 #define NETWORK_HAS_CCK (1<<2)
1401 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1402 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
1403 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1404 NETWORK_HAS_QOS_INFORMATION)
1406 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1407 #define NETWORK_HAS_CSA (1<<6)
1408 #define NETWORK_HAS_QUIET (1<<7)
1409 #define NETWORK_HAS_IBSS_DFS (1<<8)
1410 #define NETWORK_HAS_TPC_REPORT (1<<9)
1412 #define NETWORK_HAS_ERP_VALUE (1<<10)
1414 #define QOS_QUEUE_NUM 4
1415 #define QOS_OUI_LEN 3
1416 #define QOS_OUI_TYPE 2
1417 #define QOS_ELEMENT_ID 221
1418 #define QOS_OUI_INFO_SUB_TYPE 0
1419 #define QOS_OUI_PARAM_SUB_TYPE 1
1420 #define QOS_VERSION_1 1
1421 #define QOS_AIFSN_MIN_VALUE 2
1423 struct rtllib_qos_information_element {
1426 u8 qui[QOS_OUI_LEN];
1433 struct rtllib_qos_ac_parameter {
1439 struct rtllib_qos_parameter_info {
1440 struct rtllib_qos_information_element info_element;
1442 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1445 struct rtllib_qos_parameters {
1446 __le16 cw_min[QOS_QUEUE_NUM];
1447 __le16 cw_max[QOS_QUEUE_NUM];
1448 u8 aifs[QOS_QUEUE_NUM];
1449 u8 flag[QOS_QUEUE_NUM];
1450 __le16 tx_op_limit[QOS_QUEUE_NUM];
1453 struct rtllib_qos_data {
1454 struct rtllib_qos_parameters parameters;
1455 unsigned int wmm_acm;
1462 struct rtllib_tim_parameters {
1467 struct rtllib_wmm_ac_param {
1468 u8 ac_aci_acm_aifsn;
1469 u8 ac_ecwmin_ecwmax;
1473 struct rtllib_wmm_ts_info {
1479 struct rtllib_wmm_tspec_elem {
1480 struct rtllib_wmm_ts_info ts_info;
1487 u32 serv_start_time;
1494 u16 surp_band_allow;
1503 EAPOL_ENCAP_ASF_ALERT
1506 static const char *eap_types[] = {
1507 [EAP_PACKET] = "EAP-Packet",
1508 [EAPOL_START] = "EAPOL-Start",
1509 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1510 [EAPOL_KEY] = "EAPOL-Key",
1511 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1514 static inline const char *eap_get_type(int type)
1516 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
1519 static inline u8 Frame_QoSTID(u8 *buf)
1521 struct rtllib_hdr_3addr *hdr;
1523 hdr = (struct rtllib_hdr_3addr *)buf;
1524 fc = le16_to_cpu(hdr->frame_ctl);
1525 return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
1526 (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1538 struct rtllib_softmac_stats {
1539 unsigned int rx_ass_ok;
1540 unsigned int rx_ass_err;
1541 unsigned int rx_probe_rq;
1542 unsigned int tx_probe_rs;
1543 unsigned int tx_beacons;
1544 unsigned int rx_auth_rq;
1545 unsigned int rx_auth_rs_ok;
1546 unsigned int rx_auth_rs_err;
1547 unsigned int tx_auth_rq;
1548 unsigned int no_auth_rs;
1549 unsigned int no_ass_rs;
1550 unsigned int tx_ass_rq;
1551 unsigned int rx_ass_rq;
1552 unsigned int tx_probe_rq;
1553 unsigned int reassoc;
1554 unsigned int swtxstop;
1555 unsigned int swtxawake;
1556 unsigned char CurrentShowTxate;
1557 unsigned char last_packet_rate;
1558 unsigned int txretrycount;
1561 #define BEACON_PROBE_SSID_ID_POSITION 12
1563 struct rtllib_info_element_hdr {
1569 * These are the data types that can make up management packets
1573 u16 beacon_interval;
1575 u8 current_ap[ETH_ALEN];
1576 u16 listen_interval;
1578 u16 association_id:14, reserved:2;
1585 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1586 #define RTLLIB_DEFAULT_BASIC_RATE 2
1588 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1589 #define MAX_SP_Len (WMM_all_frame << 4)
1590 #define RTLLIB_QOS_TID 0x0f
1591 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1593 #define RTLLIB_DTIM_MBCAST 4
1594 #define RTLLIB_DTIM_UCAST 2
1595 #define RTLLIB_DTIM_VALID 1
1596 #define RTLLIB_DTIM_INVALID 0
1598 #define RTLLIB_PS_DISABLED 0
1599 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1600 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1602 #define WME_AC_BK 0x00
1603 #define WME_AC_BE 0x01
1604 #define WME_AC_VI 0x02
1605 #define WME_AC_VO 0x03
1606 #define WME_ACI_MASK 0x03
1607 #define WME_AIFSN_MASK 0x03
1608 #define WME_AC_PRAM_LEN 16
1610 #define MAX_RECEIVE_BUFFER_SIZE 9100
1612 #define UP2AC(up) ( \
1613 ((up) < 1) ? WME_AC_BE : \
1614 ((up) < 3) ? WME_AC_BK : \
1615 ((up) < 4) ? WME_AC_BE : \
1616 ((up) < 6) ? WME_AC_VI : \
1619 #define AC2UP(_ac) ( \
1620 ((_ac) == WME_AC_VO) ? 6 : \
1621 ((_ac) == WME_AC_VI) ? 5 : \
1622 ((_ac) == WME_AC_BK) ? 1 : \
1625 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1626 #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
1629 struct ether_header {
1630 u8 ether_dhost[ETHER_ADDR_LEN];
1631 u8 ether_shost[ETHER_ADDR_LEN];
1635 #ifndef ETHERTYPE_PAE
1636 #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1638 #ifndef ETHERTYPE_IP
1639 #define ETHERTYPE_IP 0x0800 /* IP protocol */
1644 ERP_NonERPpresent = 0x01,
1645 ERP_UseProtection = 0x02,
1646 ERP_BarkerPreambleMode = 0x04,
1649 struct rtllib_network {
1650 /* These entries are used to identify a unique network */
1653 /* Ensure null-terminated for any debug msgs */
1654 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1656 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
1658 struct rtllib_qos_data qos_data;
1660 bool bWithAironetIE;
1661 bool bCkipSupported;
1667 bool bWithCcxVerNum;
1669 /* These are network statistics */
1670 struct rtllib_rx_stats stats;
1672 u8 rates[MAX_RATES_LENGTH];
1674 u8 rates_ex[MAX_RATES_EX_LENGTH];
1676 unsigned long last_scanned;
1681 u16 beacon_interval;
1682 u16 listen_interval;
1685 u8 wpa_ie[MAX_WPA_IE_LEN];
1687 u8 rsn_ie[MAX_WPA_IE_LEN];
1689 u8 wzc_ie[MAX_WZC_IE_LEN];
1692 struct rtllib_tim_parameters tim;
1695 u64 last_dtim_sta_time;
1698 struct rtllib_wmm_ac_param wmm_param[4];
1701 u8 CountryIeBuf[MAX_IE_LEN];
1702 struct bss_ht bssht;
1703 bool broadcom_cap_exist;
1704 bool realtek_cap_exit;
1705 bool marvell_cap_exist;
1706 bool ralink_cap_exist;
1707 bool atheros_cap_exist;
1708 bool cisco_cap_exist;
1709 bool airgo_cap_exist;
1710 bool unknown_cap_exist;
1711 bool berp_info_valid;
1712 bool buseprotection;
1713 bool bIsNetgear854T;
1716 struct list_head list;
1722 /* the card is not linked at all */
1725 /* RTLLIB_ASSOCIATING* are for BSS client mode
1726 * the driver shall not perform RX filtering unless
1727 * the state is LINKED.
1728 * The driver shall just check for the state LINKED and
1729 * defaults to NOLINK for ALL the other states (including
1733 /* the association procedure will start (wq scheduling)*/
1735 RTLLIB_ASSOCIATING_RETRY,
1737 /* the association procedure is sending AUTH request*/
1738 RTLLIB_ASSOCIATING_AUTHENTICATING,
1740 /* the association procedure has successfully authentcated
1741 * and is sending association request
1743 RTLLIB_ASSOCIATING_AUTHENTICATED,
1745 /* the link is ok. the card associated to a BSS or linked
1746 * to a ibss cell or acting as an AP and creating the bss
1750 /* same as LINKED, but the driver shall apply RX filter
1751 * rules as we are in NO_LINK mode. As the card is still
1752 * logically linked, but it is doing a syncro site survey
1753 * then it will be back to LINKED state.
1755 RTLLIB_LINKED_SCANNING,
1759 RTLLIB_UNINITIALIZED = 0,
1763 RTLLIB_AUTHENTICATING,
1764 RTLLIB_AUTHENTICATED,
1769 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1770 #define DEFAULT_FTS 2346
1772 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1773 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1774 #define CFG_RTLLIB_RTS (1<<2)
1776 #define RTLLIB_24GHZ_MIN_CHANNEL 1
1777 #define RTLLIB_24GHZ_MAX_CHANNEL 14
1778 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
1779 RTLLIB_24GHZ_MIN_CHANNEL + 1)
1781 #define RTLLIB_52GHZ_MIN_CHANNEL 34
1782 #define RTLLIB_52GHZ_MAX_CHANNEL 165
1783 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
1784 RTLLIB_52GHZ_MIN_CHANNEL + 1)
1786 #define eqMacAddr(a, b) \
1787 (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \
1788 (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
1792 struct rtllib_txb *txb;
1795 struct bandwidth_autoswitch {
1796 long threshold_20Mhzto40Mhz;
1797 long threshold_40Mhzto20Mhz;
1798 bool bforced_tx20Mhz;
1799 bool bautoswitch_enable;
1804 #define REORDER_WIN_SIZE 128
1805 #define REORDER_ENTRY_NUM 128
1806 struct rx_reorder_entry {
1807 struct list_head List;
1809 struct rtllib_rxb *prxb;
1824 enum ips_callback_function {
1825 IPS_CALLBACK_NONE = 0,
1826 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1827 IPS_CALLBACK_JOIN_REQUEST = 2,
1830 enum rt_join_action {
1840 #define MAX_NUM_RATES 264
1842 enum rt_rf_power_state {
1848 #define MAX_SUPPORT_WOL_PATTERN_NUM 8
1850 #define MAX_WOL_BIT_MASK_SIZE 16
1851 #define MAX_WOL_PATTERN_SIZE 128
1853 enum wol_pattern_type {
1861 struct rt_pm_wol_info {
1866 enum wol_pattern_type PatternType;
1869 struct rt_pwr_save_ctrl {
1872 bool bIPSModeBackup;
1873 bool bHaltAdapterClkRQ;
1874 bool bSwRfProcessing;
1875 enum rt_rf_power_state eInactivePowerState;
1876 struct work_struct InactivePsWorkItem;
1877 struct timer_list InactivePsTimer;
1879 enum ips_callback_function ReturnPoint;
1882 enum rt_join_action tmpJoinAction;
1883 struct rtllib_network tmpBssDesc;
1886 bool bTmpActiveScan;
1887 bool bTmpFilterHiddenAP;
1888 bool bTmpUpdateParms;
1890 struct octet_string tmpSsid2Scan;
1893 u8 tmpChannelNumber;
1897 struct octet_string tmpSuppRateSet;
1898 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1900 struct ibss_parms tmpIbpm;
1906 u8 RegMaxLPSAwakeIntvl;
1915 bool LinkReqInIPSRFOffPgs;
1916 bool BufConnectinfoBefore;
1924 struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM];
1928 #define RT_RF_CHANGE_SOURCE u32
1930 #define RF_CHANGE_BY_SW BIT31
1931 #define RF_CHANGE_BY_HW BIT30
1932 #define RF_CHANGE_BY_PS BIT29
1933 #define RF_CHANGE_BY_IPS BIT28
1934 #define RF_CHANGE_BY_INIT 0
1936 enum country_code_type {
1937 COUNTRY_CODE_FCC = 0,
1938 COUNTRY_CODE_IC = 1,
1939 COUNTRY_CODE_ETSI = 2,
1940 COUNTRY_CODE_SPAIN = 3,
1941 COUNTRY_CODE_FRANCE = 4,
1942 COUNTRY_CODE_MKK = 5,
1943 COUNTRY_CODE_MKK1 = 6,
1944 COUNTRY_CODE_ISRAEL = 7,
1945 COUNTRY_CODE_TELEC = 8,
1946 COUNTRY_CODE_MIC = 9,
1947 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1948 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1949 COUNTRY_CODE_TELEC_NETGEAR = 12,
1953 enum scan_op_backup_opt {
1954 SCAN_OPT_BACKUP = 0,
1959 enum fw_cmd_io_type {
1960 FW_CMD_DIG_ENABLE = 0,
1961 FW_CMD_DIG_DISABLE = 1,
1962 FW_CMD_DIG_HALT = 2,
1963 FW_CMD_DIG_RESUME = 3,
1964 FW_CMD_HIGH_PWR_ENABLE = 4,
1965 FW_CMD_HIGH_PWR_DISABLE = 5,
1966 FW_CMD_RA_RESET = 6,
1967 FW_CMD_RA_ACTIVE = 7,
1968 FW_CMD_RA_REFRESH_N = 8,
1969 FW_CMD_RA_REFRESH_BG = 9,
1970 FW_CMD_RA_INIT = 10,
1971 FW_CMD_IQK_ENABLE = 11,
1972 FW_CMD_TXPWR_TRACK_ENABLE = 12,
1973 FW_CMD_TXPWR_TRACK_DISABLE = 13,
1974 FW_CMD_TXPWR_TRACK_THERMAL = 14,
1975 FW_CMD_PAUSE_DM_BY_SCAN = 15,
1976 FW_CMD_RESUME_DM_BY_SCAN = 16,
1977 FW_CMD_RA_REFRESH_N_COMB = 17,
1978 FW_CMD_RA_REFRESH_BG_COMB = 18,
1979 FW_CMD_ANTENNA_SW_ENABLE = 19,
1980 FW_CMD_ANTENNA_SW_DISABLE = 20,
1981 FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
1982 FW_CMD_LPS_ENTER = 22,
1983 FW_CMD_LPS_LEAVE = 23,
1984 FW_CMD_DIG_MODE_SS = 24,
1985 FW_CMD_DIG_MODE_FA = 25,
1986 FW_CMD_ADD_A2_ENTRY = 26,
1987 FW_CMD_CTRL_DM_BY_DRIVER = 27,
1988 FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28,
1989 FW_CMD_PAPE_CONTROL = 29,
1990 FW_CMD_CHAN_SET = 30,
1993 #define RT_MAX_LD_SLOT_NUM 10
1994 struct rt_link_detect {
1996 u32 NumRecvBcnInPeriod;
1997 u32 NumRecvDataInPeriod;
1999 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
2000 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
2004 u32 NumTxOkInPeriod;
2005 u32 NumRxOkInPeriod;
2006 u32 NumRxUnicastOkInPeriod;
2008 bool bHigherBusyTraffic;
2009 bool bHigherBusyRxTraffic;
2011 u32 NumTxUnicastOkInPeriod;
2012 u32 LastNumTxUnicast;
2013 u32 LastNumRxUnicast;
2016 struct sw_cam_table {
2026 #define TOTAL_CAM_ENTRY 32
2027 struct rate_adaptive {
2028 u8 rate_adaptive_disabled;
2032 u32 high_rssi_thresh_for_ra;
2033 u32 high2low_rssi_thresh_for_ra;
2034 u8 low2high_rssi_thresh_for_ra40M;
2035 u32 low_rssi_thresh_for_ra40M;
2036 u8 low2high_rssi_thresh_for_ra20M;
2037 u32 low_rssi_thresh_for_ra20M;
2038 u32 upper_rssi_threshold_ratr;
2039 u32 middle_rssi_threshold_ratr;
2040 u32 low_rssi_threshold_ratr;
2041 u32 low_rssi_threshold_ratr_40M;
2042 u32 low_rssi_threshold_ratr_20M;
2043 u8 ping_rssi_enable;
2045 u32 ping_rssi_thresh_for_ra;
2050 enum ratr_table_mode_8192s {
2051 RATR_INX_WIRELESS_NGB = 0,
2052 RATR_INX_WIRELESS_NG = 1,
2053 RATR_INX_WIRELESS_NB = 2,
2054 RATR_INX_WIRELESS_N = 3,
2055 RATR_INX_WIRELESS_GB = 4,
2056 RATR_INX_WIRELESS_G = 5,
2057 RATR_INX_WIRELESS_B = 6,
2058 RATR_INX_WIRELESS_MC = 7,
2059 RATR_INX_WIRELESS_A = 8,
2062 #define NUM_PMKID_CACHE 16
2063 struct rt_pmkid_list {
2072 struct rt_intel_promisc_mode {
2073 bool bPromiscuousOn;
2074 bool bFilterSourceStationFrame;
2078 /*************** DRIVER STATUS *****/
2079 #define STATUS_SCANNING 0
2080 #define STATUS_SCAN_HW 1
2081 #define STATUS_SCAN_ABORTING 2
2082 #define STATUS_SETTING_CHAN 3
2083 /*************** DRIVER STATUS *****/
2095 LPS_WAIT_NULL_DATA_SEND = 2,
2098 struct rtllib_device {
2099 struct pci_dev *pdev;
2100 struct net_device *dev;
2101 struct rtllib_security sec;
2103 bool disable_mgnt_queue;
2105 unsigned long status;
2107 enum ht_extchnl_offset chan_offset_bk;
2108 enum ht_channel_width bandwidth_bk;
2112 enum rt_op_mode OpMode;
2115 /* The last AssocReq/Resp IEs */
2116 u8 *assocreq_ies, *assocresp_ies;
2117 size_t assocreq_ies_len, assocresp_ies_len;
2119 bool b_customer_lenovo_id;
2120 bool bForcedShowRxRate;
2121 bool bForcedShowRateStill;
2122 u8 SystemQueryDataRateCount;
2125 bool b1x1RecvCombine;
2130 bool is_silent_reset;
2131 bool force_mic_error;
2135 bool bSupportRemoteWakeUp;
2136 enum rt_ps_mode dot11PowerSaveMode;
2138 bool FirstIe_InScan;
2139 bool be_scan_inprogress;
2141 enum rt_rf_power_state eRFPowerState;
2142 RT_RF_CHANGE_SOURCE RfOffReason;
2145 struct rt_hi_throughput *pHTInfo;
2146 spinlock_t bw_spinlock;
2148 spinlock_t reorder_spinlock;
2149 u8 Regdot11HTOperationalRateSet[16];
2150 u8 Regdot11TxHTOperationalRateSet[16];
2151 u8 dot11HTOperationalRateSet[16];
2152 u8 RegHTSuppRateSet[16];
2153 u8 HTCurrentOperaRate;
2154 u8 HTHighestOperaRate;
2157 u8 bTxDisableRateFallBack;
2158 u8 bTxUseDriverAssingedRate;
2159 u8 bTxEnableFwCalcDur;
2160 atomic_t atm_chnlop;
2163 struct list_head Tx_TS_Admit_List;
2164 struct list_head Tx_TS_Pending_List;
2165 struct list_head Tx_TS_Unused_List;
2166 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
2167 struct list_head Rx_TS_Admit_List;
2168 struct list_head Rx_TS_Pending_List;
2169 struct list_head Rx_TS_Unused_List;
2170 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
2171 struct rx_reorder_entry RxReorderEntry[128];
2172 struct list_head RxReorder_Unused_List;
2176 /* Bookkeeping structures */
2177 struct net_device_stats stats;
2178 struct rtllib_stats ieee_stats;
2179 struct rtllib_softmac_stats softmac_stats;
2181 /* Probe / Beacon management */
2182 struct list_head network_free_list;
2183 struct list_head network_list;
2184 struct rtllib_network *networks;
2188 int iw_mode; /* operating mode (IW_MODE_*) */
2189 bool bNetPromiscuousMode;
2190 struct rt_intel_promisc_mode IntelPromiscuousModeInfo;
2192 struct iw_spy_data spy_data;
2195 spinlock_t wpax_suitlist_lock;
2197 int tx_headroom; /* Set to size of any additional room needed at front
2198 * of allocated Tx SKBs */
2201 /* WEP and other encryption related settings at the device level */
2202 int open_wep; /* Set to 1 to allow unencrypted frames */
2204 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2205 * WEP key changes */
2207 /* If the host performs {en,de}cryption, then set to 1 */
2209 int host_encrypt_msdu;
2211 /* host performs multicast decryption */
2212 int host_mc_decrypt;
2214 /* host should strip IV and ICV from protected frames */
2215 /* meaningful only when hardware decryption is being used */
2216 int host_strip_iv_icv;
2220 int ieee802_1x; /* is IEEE 802.1X used */
2224 bool bHalfWirelessN24GMode;
2226 int drop_unencrypted;
2227 int tkip_countermeasures;
2228 int privacy_invoked;
2234 u16 pairwise_key_type;
2236 struct list_head crypt_deinit_list;
2237 struct rtllib_crypt_data *crypt[WEP_KEYS];
2239 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
2240 struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
2241 struct timer_list crypt_deinit_timer;
2244 int bcrx_sta_key; /* use individual keys to override default keys even
2245 * with RX of broad/multicast frames */
2247 struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
2249 /* Fragmentation structures */
2250 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
2251 unsigned int frag_next_idx[17];
2252 u16 fts; /* Fragmentation Threshold */
2253 #define DEFAULT_RTS_THRESHOLD 2346U
2254 #define MIN_RTS_THRESHOLD 1
2255 #define MAX_RTS_THRESHOLD 2346U
2256 u16 rts; /* RTS threshold */
2258 /* Association info */
2261 /* This stores infos for the current network.
2262 * Either the network we are associated in INFRASTRUCTURE
2263 * or the network that we are creating in MASTER mode.
2264 * ad-hoc is a mixture ;-).
2265 * Note that in infrastructure mode, even when not associated,
2266 * fields bssid and essid may be valid (if wpa_set and essid_set
2267 * are true) as thy carry the value set by the user via iwconfig
2269 struct rtllib_network current_network;
2271 enum rtllib_state state;
2275 int mode; /* A, B, G */
2276 int modulation; /* CCK, OFDM */
2277 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
2278 int abg_true; /* ABG flag */
2280 /* used for forcing the ibss workqueue to terminate
2281 * without wait for the syncro scan to terminate
2283 short sync_scan_hurryup;
2288 u16 prev_seq_ctl; /* used to drop duplicate frames */
2290 /* map of allowed channels. 0 is dummy */
2293 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
2296 u8 ibss_maxjoin_chal;
2298 int rate; /* current rate */
2304 /* this contains flags for selectively enable softmac support */
2305 u16 softmac_features;
2307 /* if the sequence control field is not filled by HW */
2310 /* association procedure transaction sequence number */
2313 /* AID for RTXed association responses */
2316 /* power save mode related*/
2322 struct tasklet_struct ps_task;
2327 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2329 short scanning_continue ;
2330 short proto_started;
2331 short proto_stoppping;
2333 struct semaphore wx_sem;
2334 struct semaphore scan_sem;
2335 struct semaphore ips_sem;
2337 spinlock_t mgmt_tx_lock;
2338 spinlock_t beacon_lock;
2345 /* set on initialization */
2347 unsigned int wmm_acm;
2349 /* for discarding duplicated packets in IBSS */
2350 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
2352 /* for discarding duplicated packets in BSS */
2353 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
2354 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
2355 unsigned long last_packet_time[17];
2358 unsigned long last_rx_ps_time;
2362 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
2363 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
2364 int mgmt_queue_head;
2365 int mgmt_queue_tail;
2366 #define RTLLIB_QUEUE_LIMIT 128
2368 unsigned int hw_header;
2369 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
2370 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
2371 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
2372 u32 sta_edca_param[4];
2374 bool enable_rx_imm_BA;
2375 bool bibsscoordinator;
2377 bool bdynamic_txpower_enable;
2379 bool bCTSToSelfEnable;
2382 u32 fsync_time_interval;
2383 u32 fsync_rate_bitmap;
2384 u8 fsync_rssi_threshold;
2387 u8 fsync_multiple_timeinterval;
2388 u32 fsync_firstdiff_ratethreshold;
2389 u32 fsync_seconddiff_ratethreshold;
2390 enum fsync_state fsync_state;
2391 bool bis_any_nonbepkts;
2392 struct bandwidth_autoswitch bandwidth_auto_switch;
2395 struct rt_link_detect LinkDetectInfo;
2396 bool bIsAggregateFrame;
2397 struct rt_pwr_save_ctrl PowerSaveControl;
2398 u8 amsdu_in_process;
2400 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2401 struct tx_pending tx_pending;
2403 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2404 struct timer_list associate_timer;
2406 /* used if IEEE_SOFTMAC_BEACONS is set */
2407 struct timer_list beacon_timer;
2409 struct work_struct associate_complete_wq;
2410 struct work_struct ips_leave_wq;
2411 struct delayed_work associate_procedure_wq;
2412 struct delayed_work softmac_scan_wq;
2413 struct delayed_work softmac_hint11d_wq;
2414 struct delayed_work associate_retry_wq;
2415 struct delayed_work start_ibss_wq;
2416 struct delayed_work hw_wakeup_wq;
2417 struct delayed_work hw_sleep_wq;
2418 struct delayed_work link_change_wq;
2419 struct work_struct wx_sync_scan_wq;
2421 struct workqueue_struct *wq;
2423 /* Callback functions */
2424 void (*set_security)(struct net_device *dev,
2425 struct rtllib_security *sec);
2427 /* Used to TX data frame by using txb structs.
2428 * this is not used if in the softmac_features
2429 * is set the flag IEEE_SOFTMAC_TX_QUEUE
2431 int (*hard_start_xmit)(struct rtllib_txb *txb,
2432 struct net_device *dev);
2434 int (*reset_port)(struct net_device *dev);
2435 int (*is_queue_full)(struct net_device *dev, int pri);
2437 int (*handle_management)(struct net_device *dev,
2438 struct rtllib_network *network, u16 type);
2439 int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
2441 /* Softmac-generated frames (mamagement) are TXed via this
2442 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
2443 * not set. As some cards may have different HW queues that
2444 * one might want to use for data and management frames
2445 * the option to have two callbacks might be useful.
2446 * This fucntion can't sleep.
2448 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
2449 struct net_device *dev);
2451 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
2452 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
2453 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
2454 * then also management frames are sent via this callback.
2455 * This function can't sleep.
2457 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
2458 struct net_device *dev, int rate);
2460 /* stops the HW queue for DATA frames. Useful to avoid
2461 * waste time to TX data frame when we are reassociating
2462 * This function can sleep.
2464 void (*data_hard_stop)(struct net_device *dev);
2466 /* OK this is complementar to data_poll_hard_stop */
2467 void (*data_hard_resume)(struct net_device *dev);
2469 /* ask to the driver to retune the radio .
2470 * This function can sleep. the driver should ensure
2471 * the radio has been swithced before return.
2473 void (*set_chan)(struct net_device *dev, short ch);
2475 /* These are not used if the ieee stack takes care of
2476 * scanning (IEEE_SOFTMAC_SCAN feature set).
2477 * In this case only the set_chan is used.
2479 * The syncro version is similar to the start_scan but
2480 * does not return until all channels has been scanned.
2481 * this is called in user context and should sleep,
2482 * it is called in a work_queue when swithcing to ad-hoc mode
2483 * or in behalf of iwlist scan when the card is associated
2484 * and root user ask for a scan.
2485 * the fucntion stop_scan should stop both the syncro and
2486 * background scanning and can sleep.
2487 * The fucntion start_scan should initiate the background
2488 * scanning and can't sleep.
2490 void (*scan_syncro)(struct net_device *dev);
2491 void (*start_scan)(struct net_device *dev);
2492 void (*stop_scan)(struct net_device *dev);
2494 void (*rtllib_start_hw_scan)(struct net_device *dev);
2495 void (*rtllib_stop_hw_scan)(struct net_device *dev);
2497 /* indicate the driver that the link state is changed
2498 * for example it may indicate the card is associated now.
2499 * Driver might be interested in this to apply RX filter
2500 * rules or simply light the LINK led
2502 void (*link_change)(struct net_device *dev);
2504 /* these two function indicates to the HW when to start
2505 * and stop to send beacons. This is used when the
2506 * IEEE_SOFTMAC_BEACONS is not set. For now the
2507 * stop_send_bacons is NOT guaranteed to be called only
2508 * after start_send_beacons.
2510 void (*start_send_beacons)(struct net_device *dev);
2511 void (*stop_send_beacons)(struct net_device *dev);
2513 /* power save mode related */
2514 void (*sta_wake_up)(struct net_device *dev);
2515 void (*enter_sleep_state)(struct net_device *dev, u64 time);
2516 short (*ps_is_queue_empty)(struct net_device *dev);
2517 int (*handle_beacon)(struct net_device *dev,
2518 struct rtllib_beacon *beacon,
2519 struct rtllib_network *network);
2520 int (*handle_assoc_response)(struct net_device *dev,
2521 struct rtllib_assoc_response_frame *resp,
2522 struct rtllib_network *network);
2525 /* check whether Tx hw resouce available */
2526 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
2527 short (*get_nic_desc_num)(struct net_device *dev, int queue_index);
2528 void (*SetBWModeHandler)(struct net_device *dev,
2529 enum ht_channel_width Bandwidth,
2530 enum ht_extchnl_offset Offset);
2531 bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
2532 void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
2533 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
2534 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
2535 void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value);
2536 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2537 bool (*SetFwCmdHandler)(struct net_device *dev,
2538 enum fw_cmd_io_type FwCmdIO);
2539 void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast,
2540 u8 macId, u8 MimoPs, u8 WirelessMode,
2541 u8 bCurTxBW40MHz, u8 rssi_level);
2542 void (*UpdateBeaconInterruptHandler)(struct net_device *dev,
2544 void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR,
2546 u16 (*rtl_11n_user_show_rates)(struct net_device *dev);
2547 void (*ScanOperationBackupHandler)(struct net_device *dev,
2549 void (*LedControlHandler)(struct net_device *dev,
2550 enum led_ctl_mode LedAction);
2551 void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
2552 void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
2554 void (*AllowAllDestAddrHandler)(struct net_device *dev,
2555 bool bAllowAllDA, bool WriteIntoReg);
2557 void (*rtllib_ips_leave_wq) (struct net_device *dev);
2558 void (*rtllib_ips_leave)(struct net_device *dev);
2559 void (*LeisurePSLeave)(struct net_device *dev);
2560 void (*rtllib_rfkill_poll)(struct net_device *dev);
2562 /* This must be the last item so that it points to the data
2563 * allocated beyond this structure by alloc_rtllib */
2567 #define IEEE_A (1<<0)
2568 #define IEEE_B (1<<1)
2569 #define IEEE_G (1<<2)
2570 #define IEEE_N_24G (1<<4)
2571 #define IEEE_N_5G (1<<5)
2572 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
2574 /* Generate a 802.11 header */
2576 /* Uses the channel change callback directly
2577 * instead of [start/stop] scan callbacks
2579 #define IEEE_SOFTMAC_SCAN (1<<2)
2581 /* Perform authentication and association handshake */
2582 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2584 /* Generate probe requests */
2585 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2587 /* Generate respones to probe requests */
2588 #define IEEE_SOFTMAC_PROBERS (1<<5)
2590 /* The ieee802.11 stack will manages the netif queue
2591 * wake/stop for the driver, taking care of 802.11
2592 * fragmentation. See softmac.c for details. */
2593 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2595 /* Uses only the softmac_data_hard_start_xmit
2596 * even for TX management frames.
2598 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2600 /* Generate beacons. The stack will enqueue beacons
2603 #define IEEE_SOFTMAC_BEACONS (1<<6)
2606 static inline void *rtllib_priv(struct net_device *dev)
2608 return ((struct rtllib_device *)netdev_priv(dev))->priv;
2611 extern inline int rtllib_is_empty_essid(const char *essid, int essid_len)
2613 /* Single white space is for Linksys APs */
2614 if (essid_len == 1 && essid[0] == ' ')
2617 /* Otherwise, if the entire essid is 0, we assume it is hidden */
2620 if (essid[essid_len] != '\0')
2627 extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
2630 * It is possible for both access points and our device to support
2631 * combinations of modes, so as long as there is one valid combination
2632 * of ap/device supported modes, then return success
2635 if ((mode & IEEE_A) &&
2636 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2637 (ieee->freq_band & RTLLIB_52GHZ_BAND))
2640 if ((mode & IEEE_G) &&
2641 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2642 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2645 if ((mode & IEEE_B) &&
2646 (ieee->modulation & RTLLIB_CCK_MODULATION) &&
2647 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2653 extern inline int rtllib_get_hdrlen(u16 fc)
2655 int hdrlen = RTLLIB_3ADDR_LEN;
2657 switch (WLAN_FC_GET_TYPE(fc)) {
2658 case RTLLIB_FTYPE_DATA:
2659 if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
2660 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
2661 if (RTLLIB_QOS_HAS_SEQ(fc))
2662 hdrlen += 2; /* QOS ctrl*/
2664 case RTLLIB_FTYPE_CTL:
2665 switch (WLAN_FC_GET_STYPE(fc)) {
2666 case RTLLIB_STYPE_CTS:
2667 case RTLLIB_STYPE_ACK:
2668 hdrlen = RTLLIB_1ADDR_LEN;
2671 hdrlen = RTLLIB_2ADDR_LEN;
2680 static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
2682 switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2683 case RTLLIB_1ADDR_LEN:
2684 return ((struct rtllib_hdr_1addr *)hdr)->payload;
2685 case RTLLIB_2ADDR_LEN:
2686 return ((struct rtllib_hdr_2addr *)hdr)->payload;
2687 case RTLLIB_3ADDR_LEN:
2688 return ((struct rtllib_hdr_3addr *)hdr)->payload;
2689 case RTLLIB_4ADDR_LEN:
2690 return ((struct rtllib_hdr_4addr *)hdr)->payload;
2695 static inline int rtllib_is_ofdm_rate(u8 rate)
2697 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2698 case RTLLIB_OFDM_RATE_6MB:
2699 case RTLLIB_OFDM_RATE_9MB:
2700 case RTLLIB_OFDM_RATE_12MB:
2701 case RTLLIB_OFDM_RATE_18MB:
2702 case RTLLIB_OFDM_RATE_24MB:
2703 case RTLLIB_OFDM_RATE_36MB:
2704 case RTLLIB_OFDM_RATE_48MB:
2705 case RTLLIB_OFDM_RATE_54MB:
2711 static inline int rtllib_is_cck_rate(u8 rate)
2713 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2714 case RTLLIB_CCK_RATE_1MB:
2715 case RTLLIB_CCK_RATE_2MB:
2716 case RTLLIB_CCK_RATE_5MB:
2717 case RTLLIB_CCK_RATE_11MB:
2725 extern void free_rtllib(struct net_device *dev);
2726 extern struct net_device *alloc_rtllib(int sizeof_priv);
2728 extern int rtllib_set_encryption(struct rtllib_device *ieee);
2732 extern int rtllib_encrypt_fragment(
2733 struct rtllib_device *ieee,
2734 struct sk_buff *frag,
2737 extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
2738 extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
2739 extern void rtllib_txb_free(struct rtllib_txb *);
2742 extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
2743 struct rtllib_rx_stats *rx_stats);
2744 extern void rtllib_rx_mgt(struct rtllib_device *ieee,
2745 struct sk_buff *skb,
2746 struct rtllib_rx_stats *stats);
2747 extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
2748 struct sk_buff *skb);
2749 extern int IsLegalChannel(struct rtllib_device *rtllib, u8 channel);
2752 extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
2753 struct iw_request_info *info,
2754 union iwreq_data *wrqu, char *key);
2755 extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
2756 struct iw_request_info *info,
2757 union iwreq_data *wrqu, char *key);
2758 extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
2759 struct iw_request_info *info,
2760 union iwreq_data *wrqu, char *key);
2761 #if WIRELESS_EXT >= 18
2762 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
2763 struct iw_request_info *info,
2764 union iwreq_data *wrqu, char *extra);
2765 extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
2766 struct iw_request_info *info,
2767 union iwreq_data *wrqu, char *extra);
2769 extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
2770 struct iw_request_info *info,
2771 struct iw_param *data, char *extra);
2772 extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
2773 struct iw_request_info *info,
2774 union iwreq_data *wrqu, char *extra);
2775 extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
2777 /* rtllib_softmac.c */
2778 extern short rtllib_is_54g(struct rtllib_network *net);
2779 extern short rtllib_is_shortslot(struct rtllib_network net);
2780 extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
2781 struct sk_buff *skb,
2782 struct rtllib_rx_stats *rx_stats, u16 type,
2784 extern void rtllib_softmac_new_net(struct rtllib_device *ieee,
2785 struct rtllib_network *net);
2787 void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
2788 extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
2789 struct rtllib_device *ieee);
2791 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2792 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2793 extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
2794 extern void rtllib_start_bss(struct rtllib_device *ieee);
2795 extern void rtllib_start_master_bss(struct rtllib_device *ieee);
2796 extern void rtllib_start_ibss(struct rtllib_device *ieee);
2797 extern void rtllib_softmac_init(struct rtllib_device *ieee);
2798 extern void rtllib_softmac_free(struct rtllib_device *ieee);
2799 extern void rtllib_associate_abort(struct rtllib_device *ieee);
2800 extern void rtllib_disassociate(struct rtllib_device *ieee);
2801 extern void rtllib_stop_scan(struct rtllib_device *ieee);
2802 extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
2803 extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
2804 extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2805 extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
2806 extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
2807 extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
2809 extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
2810 extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
2811 extern void rtllib_check_all_nets(struct rtllib_device *ieee);
2812 extern void rtllib_start_protocol(struct rtllib_device *ieee);
2813 extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
2815 extern void rtllib_EnableNetMonitorMode(struct net_device *dev,
2817 extern void rtllib_DisableNetMonitorMode(struct net_device *dev,
2819 extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
2821 extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
2823 extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
2825 extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
2826 u8 mesh_flag, u8 shutdown);
2827 extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
2830 extern void rtllib_reset_queue(struct rtllib_device *ieee);
2831 extern void rtllib_wake_queue(struct rtllib_device *ieee);
2832 extern void rtllib_stop_queue(struct rtllib_device *ieee);
2833 extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
2834 extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
2835 extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
2836 extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
2837 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2838 extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee,
2839 struct iw_point *p, u8 is_mesh);
2841 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2842 extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
2844 extern void softmac_mgmt_xmit(struct sk_buff *skb,
2845 struct rtllib_device *ieee);
2846 extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
2847 struct sk_buff *skb, u8 *dst);
2848 extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
2850 /* rtllib_crypt_ccmp&tkip&wep.c */
2851 extern void rtllib_tkip_null(void);
2852 extern void rtllib_wep_null(void);
2853 extern void rtllib_ccmp_null(void);
2855 /* rtllib_softmac_wx.c */
2857 extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
2858 struct iw_request_info *info,
2859 union iwreq_data *wrqu, char *ext);
2861 extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
2862 struct iw_request_info *info,
2863 union iwreq_data *awrq,
2866 extern int rtllib_wx_get_essid(struct rtllib_device *ieee,
2867 struct iw_request_info *a,
2868 union iwreq_data *wrqu, char *b);
2870 extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
2871 struct iw_request_info *info,
2872 union iwreq_data *wrqu, char *extra);
2874 extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
2875 struct iw_request_info *info,
2876 union iwreq_data *wrqu, char *extra);
2878 extern int rtllib_wx_set_mode(struct rtllib_device *ieee,
2879 struct iw_request_info *a,
2880 union iwreq_data *wrqu, char *b);
2882 extern int rtllib_wx_set_scan(struct rtllib_device *ieee,
2883 struct iw_request_info *a,
2884 union iwreq_data *wrqu, char *b);
2886 extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
2887 struct iw_request_info *a,
2888 union iwreq_data *wrqu, char *extra);
2890 extern int rtllib_wx_get_mode(struct rtllib_device *ieee,
2891 struct iw_request_info *a,
2892 union iwreq_data *wrqu, char *b);
2894 extern int rtllib_wx_set_freq(struct rtllib_device *ieee,
2895 struct iw_request_info *a,
2896 union iwreq_data *wrqu, char *b);
2898 extern int rtllib_wx_get_freq(struct rtllib_device *ieee,
2899 struct iw_request_info *a,
2900 union iwreq_data *wrqu, char *b);
2901 extern void rtllib_wx_sync_scan_wq(void *data);
2903 extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
2904 struct iw_request_info *info,
2905 union iwreq_data *wrqu, char *extra);
2907 extern int rtllib_wx_get_name(struct rtllib_device *ieee,
2908 struct iw_request_info *info,
2909 union iwreq_data *wrqu, char *extra);
2911 extern int rtllib_wx_set_power(struct rtllib_device *ieee,
2912 struct iw_request_info *info,
2913 union iwreq_data *wrqu, char *extra);
2915 extern int rtllib_wx_get_power(struct rtllib_device *ieee,
2916 struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra);
2919 extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
2920 struct iw_request_info *info,
2921 union iwreq_data *wrqu, char *extra);
2923 extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
2924 struct iw_request_info *info,
2925 union iwreq_data *wrqu, char *extra);
2926 #define MAX_RECEIVE_BUFFER_SIZE 9100
2927 extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
2928 extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
2930 void HTSetConnectBwMode(struct rtllib_device *ieee,
2931 enum ht_channel_width Bandwidth,
2932 enum ht_extchnl_offset Offset);
2933 extern void HTUpdateDefaultSetting(struct rtllib_device *ieee);
2934 extern void HTConstructCapabilityElement(struct rtllib_device *ieee,
2935 u8 *posHTCap, u8 *len,
2936 u8 isEncrypt, bool bAssoc);
2937 extern void HTConstructInfoElement(struct rtllib_device *ieee,
2938 u8 *posHTInfo, u8 *len, u8 isEncrypt);
2939 extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
2940 u8 *posRT2RTAgg, u8* len);
2941 extern void HTOnAssocRsp(struct rtllib_device *ieee);
2942 extern void HTInitializeHTInfo(struct rtllib_device *ieee);
2943 extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
2944 extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
2945 struct rtllib_network *pNetwork);
2946 extern void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee,
2947 struct rtllib_network *pNetwork);
2948 extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
2950 extern u8 MCS_FILTER_ALL[];
2951 extern u16 MCS_DATA_RATE[2][2][77] ;
2952 extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
2953 extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
2954 extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
2955 extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
2956 extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
2957 extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
2958 extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
2959 extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
2960 extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
2961 extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
2962 u8 Policy, u8 bOverwritePending);
2963 extern void TsInitDelBA(struct rtllib_device *ieee,
2964 struct ts_common_info *pTsCommonInfo,
2965 enum tr_select TxRxSelect);
2966 extern void BaSetupTimeOut(unsigned long data);
2967 extern void TxBaInactTimeout(unsigned long data);
2968 extern void RxBaInactTimeout(unsigned long data);
2969 extern void ResetBaEntry(struct ba_record *pBA);
2971 struct rtllib_device *ieee,
2972 struct ts_common_info **ppTS,
2975 enum tr_select TxRxSelect,
2978 extern void TSInitialize(struct rtllib_device *ieee);
2979 extern void TsStartAddBaProcess(struct rtllib_device *ieee,
2980 struct tx_ts_record *pTxTS);
2981 extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
2982 extern void RemoveAllTS(struct rtllib_device *ieee);
2983 void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2985 extern const long rtllib_wlan_frequencies[];
2987 extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
2992 extern inline int rtllib_get_scans(struct rtllib_device *ieee)
2997 static inline const char *escape_essid(const char *essid, u8 essid_len)
2999 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
3000 const char *s = essid;
3003 if (rtllib_is_empty_essid(essid, essid_len)) {
3004 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
3008 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
3009 while (essid_len--) {
3022 #define CONVERT_RATE(_ieee, _MGN_RATE) \
3023 ((_MGN_RATE < MGN_MCS0) ? (_MGN_RATE) : \
3024 (HTMcsToDataRate(_ieee, (u8)_MGN_RATE)))
3026 /* fun with the built-in rtllib stack... */
3027 int rtllib_init(void);
3028 void rtllib_exit(void);
3029 int rtllib_crypto_init(void);
3030 void rtllib_crypto_deinit(void);
3031 int rtllib_crypto_tkip_init(void);
3032 void rtllib_crypto_tkip_exit(void);
3033 int rtllib_crypto_ccmp_init(void);
3034 void rtllib_crypto_ccmp_exit(void);
3035 int rtllib_crypto_wep_init(void);
3036 void rtllib_crypto_wep_exit(void);
3038 void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib);
3039 void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta,
3041 void rtllib_MgntDisconnectAP(struct rtllib_device *rtllib, u8 asRsn);
3042 bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
3045 /* For the function is more related to hardware setting, it's better to use the
3046 * ieee handler to refer to it.
3048 extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
3049 extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
3050 struct rx_ts_record *pTS);
3051 extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev);
3052 extern int rtllib_parse_info_param(struct rtllib_device *ieee,
3053 struct rtllib_info_element *info_element,
3055 struct rtllib_network *network,
3056 struct rtllib_rx_stats *stats);
3058 void rtllib_indicate_packets(struct rtllib_device *ieee,
3059 struct rtllib_rxb **prxbIndicateArray, u8 index);
3060 extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
3062 extern void HTUseDefaultSetting(struct rtllib_device *ieee);
3063 #define RT_ASOC_RETRY_LIMIT 5
3064 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
3065 extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
3066 #ifndef ENABLE_LOCK_DEBUG
3067 #define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags)
3068 #define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags)
3069 #define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags)
3070 #define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags)
3071 #define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags)
3072 #define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags)
3073 #define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags)
3074 #define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags)
3075 #define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags)
3076 #define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags)
3077 #define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags)
3078 #define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags)
3079 #define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags)
3080 #define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags)
3081 #define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags)
3082 #define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags)
3083 #define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags)
3084 #define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags)
3085 #define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags)
3086 #define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags)
3087 #define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags)
3088 #define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags)
3089 #define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags)
3090 #define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags)
3091 #define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags)
3092 #define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags)
3093 #define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags)
3094 #define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags)
3095 #define SEM_DOWN_IEEE_WX(psem) down(psem)
3096 #define SEM_UP_IEEE_WX(psem) up(psem)
3097 #define SEM_DOWN_IEEE_SCAN(psem) down(psem)
3098 #define SEM_UP_IEEE_SCAN(psem) up(psem)
3099 #define SEM_DOWN_IEEE_IPS(psem) down(psem)
3100 #define SEM_UP_IEEE_IPS(psem) up(psem)
3101 #define SEM_DOWN_PRIV_WX(psem) down(psem)
3102 #define SEM_UP_PRIV_WX(psem) up(psem)
3103 #define SEM_DOWN_PRIV_RF(psem) down(psem)
3104 #define SEM_UP_PRIV_RF(psem) up(psem)
3105 #define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
3106 #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
3108 static inline void dump_buf(u8 *buf, u32 len)
3111 printk(KERN_INFO "-----------------Len %d----------------\n", len);
3112 for (i = 0; i < len; i++)
3113 printk("%2.2x-", *(buf+i));
3116 #endif /* RTLLIB_H */