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 #ifdef CONFIG_CFG_80211
39 #include <net/cfg80211.h>
42 #include "rtl819x_HT.h"
43 #include "rtl819x_BA.h"
44 #include "rtl819x_TS.h"
46 #include <linux/netdevice.h>
47 #include <linux/if_arp.h> /* ARPHRD_ETHER */
52 #include <net/iw_handler.h>
54 #ifndef IEEE80211_RADIOTAP_F_BADFCS
55 #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */
58 #ifndef IW_MODE_MONITOR
59 #define IW_MODE_MONITOR 6
63 #define IWEVCUSTOM 0x8c02
67 /* Max number of char in custom event - use multiple of them if needed */
68 #define IW_CUSTOM_MAX 256 /* In bytes */
73 * container_of - cast a member of a structure out to the containing structure
75 * @ptr: the pointer to the member.
76 * @type: the type of the container struct this is embedded in.
77 * @member: the name of the member within the struct.
80 #define container_of(ptr, type, member) ({ \
81 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
82 (type *)( (char *)__mptr - offsetof(type,member) );})
85 #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
87 #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
90 typedef struct delayed_work delayed_work_struct_rsl;
91 #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z)
92 #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y)
94 typedef struct work_struct work_struct_rsl;
95 #define queue_work_rsl(x,y) queue_work(x,y)
96 #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y)
98 #define container_of_work_rsl(x,y,z) container_of(x,y,z)
99 #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z)
101 #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len)
103 #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p)
105 #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y)
106 #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y)
108 static inline void *netdev_priv_rsl(struct net_device *dev)
110 return netdev_priv(dev);
113 #define KEY_TYPE_NA 0x0
114 #define KEY_TYPE_WEP40 0x1
115 #define KEY_TYPE_TKIP 0x2
116 #define KEY_TYPE_CCMP 0x4
117 #define KEY_TYPE_WEP104 0x5
118 /* added for rtl819x tx procedure */
119 #define MAX_QUEUE_SIZE 0x10
126 #define TXCMD_QUEUE 5
129 #define BEACON_QUEUE 8
131 #define LOW_QUEUE BE_QUEUE
132 #define NORMAL_QUEUE MGNT_QUEUE
135 #define IW_MODE_MESH 7
137 #define AMSDU_SUBHEADER_LEN 14
138 #define SWRF_TIMEOUT 50
140 #define IE_CISCO_FLAG_POSITION 0x08
141 #define SUPPORT_CKIP_MIC 0x08
142 #define SUPPORT_CKIP_PK 0x10
143 #define RT_RF_OFF_LEVL_ASPM BIT0
144 #define RT_RF_OFF_LEVL_CLK_REQ BIT1
145 #define RT_RF_OFF_LEVL_PCI_D3 BIT2
146 #define RT_RF_OFF_LEVL_HALT_NIC BIT3
147 #define RT_RF_OFF_LEVL_FREE_FW BIT4
148 #define RT_RF_OFF_LEVL_FW_32K BIT5
149 #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
150 #define RT_RF_LPS_DISALBE_2R BIT30
151 #define RT_RF_LPS_LEVEL_ASPM BIT31
152 #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
153 #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG)))
154 #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
156 /* defined for skb cb field */
157 /* At most 28 byte */
158 typedef struct cb_desc {
159 /* Tx Desc Related flags (8-9) */
165 u8 bTxDisableRateFallBack:1;
166 u8 bTxUseDriverAssingedRate:1;
171 /* Tx Firmware Relaged flags (10-11)*/
175 u8 bUseShortPreamble:1;
176 u8 bTxEnableFwCalcDur:1;
183 u8 bRTSUseShortPreamble:1;
190 /* Tx Desc related element(12-19) */
201 /* Tx firmware related element(20-27) */
209 u8 bIsSpecialDataFrame;
215 /*--------------------------Define -------------------------------------------*/
218 #define MGN_5_5M 0x0b
230 #define MGN_MCS0 0x80
231 #define MGN_MCS1 0x81
232 #define MGN_MCS2 0x82
233 #define MGN_MCS3 0x83
234 #define MGN_MCS4 0x84
235 #define MGN_MCS5 0x85
236 #define MGN_MCS6 0x86
237 #define MGN_MCS7 0x87
238 #define MGN_MCS8 0x88
239 #define MGN_MCS9 0x89
240 #define MGN_MCS10 0x8a
241 #define MGN_MCS11 0x8b
242 #define MGN_MCS12 0x8c
243 #define MGN_MCS13 0x8d
244 #define MGN_MCS14 0x8e
245 #define MGN_MCS15 0x8f
246 #define MGN_MCS0_SG 0x90
247 #define MGN_MCS1_SG 0x91
248 #define MGN_MCS2_SG 0x92
249 #define MGN_MCS3_SG 0x93
250 #define MGN_MCS4_SG 0x94
251 #define MGN_MCS5_SG 0x95
252 #define MGN_MCS6_SG 0x96
253 #define MGN_MCS7_SG 0x97
254 #define MGN_MCS8_SG 0x98
255 #define MGN_MCS9_SG 0x99
256 #define MGN_MCS10_SG 0x9a
257 #define MGN_MCS11_SG 0x9b
258 #define MGN_MCS12_SG 0x9c
259 #define MGN_MCS13_SG 0x9d
260 #define MGN_MCS14_SG 0x9e
261 #define MGN_MCS15_SG 0x9f
266 auth_not_valid = 0x2,
278 four_way_tmout = 0x0f,
279 two_way_tmout = 0x10,
281 invalid_Gcipher = 0x12,
282 invalid_Pcipher = 0x13,
284 unsup_RSNIEver = 0x15,
285 invalid_RSNIE = 0x16,
286 auth_802_1x_fail= 0x17,
290 QAP_bandwidth = 0x21,
291 poor_condition = 0x22,
294 invalid_param = 0x26,
295 req_not_honored= 0x27,
296 TS_not_created = 0x2F,
297 DL_not_allowed = 0x30,
298 dest_not_exist = 0x31,
299 dest_not_QSTA = 0x32,
302 typedef enum _HAL_DEF_VARIABLE{
305 HAL_DEF_PROT_IMP_MODE,
306 HAL_DEF_HIGH_POWER_MECHANISM,
307 HAL_DEF_RATE_ADAPTIVE_MECHANISM,
308 HAL_DEF_ANTENNA_DIVERSITY_MECHANISM,
314 HAL_DEF_MIN_TX_POWER_DBM,
315 HAL_DEF_MAX_TX_POWER_DBM,
316 HW_DEF_EFUSE_REPG_SECTION1_FLAG,
317 HW_DEF_EFUSE_REPG_DATA,
319 HAL_DEF_PCI_SUPPORT_ASPM,
320 HAL_DEF_THERMAL_VALUE,
321 HAL_DEF_USB_IN_TOKEN_REV,
325 typedef enum _HW_VARIABLES{
327 HW_VAR_MULTICAST_REG,
331 HW_VAR_SECURITY_CONF,
332 HW_VAR_BEACON_INTERVAL,
334 HW_VAR_LISTEN_INTERVAL,
347 HW_VAR_RATE_FALLBACK_CONTROL,
348 HW_VAR_CONTENTION_WINDOW,
353 HW_VAR_AMPDU_MIN_SPACE,
354 HW_VAR_SHORTGI_DENSITY,
356 HW_VAR_MCS_RATE_AVAILABLE,
359 HW_VAR_DIS_Req_Qsize,
360 HW_VAR_CCX_CHNL_LOAD,
361 HW_VAR_CCX_NOISE_HISTOGRAM,
368 HW_VAR_SET_DEV_POWER,
378 HW_VAR_USER_CONTROL_TURBO_MODE,
384 HW_VAR_AUTOLOAD_STATUS,
385 HW_VAR_RF_2R_DISABLE,
387 HW_VAR_H2C_FW_PWRMODE,
388 HW_VAR_H2C_FW_JOINBSSRPT,
389 HW_VAR_1X1_RECV_COMBINE,
390 HW_VAR_STOP_SEND_BEACON,
395 HW_VAR_H2C_FW_UPDATE_GTK,
398 HW_VAR_WF_IS_MAC_ADDR,
399 HW_VAR_H2C_FW_OFFLOAD,
402 HW_VAR_HANDLE_FW_C2H,
403 HW_VAR_DL_FW_RSVD_PAGE,
405 HW_VAR_HW_SEQ_ENABLE,
410 HW_VAR_SWITCH_EPHY_WoWLAN,
411 HW_VAR_INT_MIGRATION,
416 typedef enum _RT_OP_MODE{
418 RT_OP_MODE_INFRASTRUCTURE,
421 }RT_OP_MODE, *PRT_OP_MODE;
424 #define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10)
426 #define MGMT_QUEUE_NUM 5
428 #define IEEE_CMD_SET_WPA_PARAM 1
429 #define IEEE_CMD_SET_WPA_IE 2
430 #define IEEE_CMD_SET_ENCRYPTION 3
431 #define IEEE_CMD_MLME 4
433 #define IEEE_PARAM_WPA_ENABLED 1
434 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
435 #define IEEE_PARAM_DROP_UNENCRYPTED 3
436 #define IEEE_PARAM_PRIVACY_INVOKED 4
437 #define IEEE_PARAM_AUTH_ALGS 5
438 #define IEEE_PARAM_IEEE_802_1X 6
439 #define IEEE_PARAM_WPAX_SELECT 7
440 #define IEEE_PROTO_WPA 1
441 #define IEEE_PROTO_RSN 2
442 #define IEEE_WPAX_USEGROUP 0
443 #define IEEE_WPAX_WEP40 1
444 #define IEEE_WPAX_TKIP 2
445 #define IEEE_WPAX_WRAP 3
446 #define IEEE_WPAX_CCMP 4
447 #define IEEE_WPAX_WEP104 5
449 #define IEEE_KEY_MGMT_IEEE8021X 1
450 #define IEEE_KEY_MGMT_PSK 2
452 #define IEEE_MLME_STA_DEAUTH 1
453 #define IEEE_MLME_STA_DISASSOC 2
456 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
457 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
458 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
459 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
460 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
461 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
462 #define IEEE_CRYPT_ALG_NAME_LEN 16
464 #define MAX_IE_LEN 0xff
465 #ifdef ENABLE_NULL_PT_DEBUG
466 #define RT_ASSERT_RET(_Exp) \
469 printk("Rtl819x: "); \
470 printk( "Assertion failed! %s,%s,line=%d\n", \
471 #_Exp,__func__,__LINE__); \
474 #define RT_ASSERT_RET_VALUE(_Exp,Ret) \
477 printk("Rtl819x: "); \
478 printk( "Assertion failed! %s,%s,line=%d\n", \
479 #_Exp,__func__,__LINE__); \
483 #define RT_ASSERT_RET(_Exp) do {} while(0)
484 #define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0)
487 typedef struct ieee_param {
489 u8 sta_addr[ETH_ALEN];
505 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
509 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
517 #if WIRELESS_EXT < 17
518 #define IW_QUAL_QUAL_INVALID 0x10
519 #define IW_QUAL_LEVEL_INVALID 0x20
520 #define IW_QUAL_NOISE_INVALID 0x40
521 #define IW_QUAL_QUAL_UPDATED 0x1
522 #define IW_QUAL_LEVEL_UPDATED 0x2
523 #define IW_QUAL_NOISE_UPDATED 0x4
526 #define MSECS(t) msecs_to_jiffies(t)
527 #define msleep_interruptible_rsl msleep_interruptible
529 #define RTLLIB_DATA_LEN 2304
530 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
533 The figure in section 7.1.2 suggests a body size of up to 2312
534 bytes is allowed, which is a bit confusing, I suspect this
535 represents the 2304 bytes of real data, plus a possible 8 bytes of
536 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
537 #define RTLLIB_1ADDR_LEN 10
538 #define RTLLIB_2ADDR_LEN 16
539 #define RTLLIB_3ADDR_LEN 24
540 #define RTLLIB_4ADDR_LEN 30
541 #define RTLLIB_FCS_LEN 4
542 #define RTLLIB_HLEN (RTLLIB_4ADDR_LEN)
543 #define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN)
544 #define RTLLIB_MGMT_HDR_LEN 24
545 #define RTLLIB_DATA_HDR3_LEN 24
546 #define RTLLIB_DATA_HDR4_LEN 30
548 #define RTLLIB_SKBBUFFER_SIZE 2500
550 #define MIN_FRAG_THRESHOLD 256U
551 #define MAX_FRAG_THRESHOLD 2346U
552 #define MAX_HT_DATA_FRAG_THRESHOLD 0x2000
554 #define HT_AMSDU_SIZE_4K 3839
555 #define HT_AMSDU_SIZE_8K 7935
557 /* Frame control field constants */
558 #define RTLLIB_FCTL_VERS 0x0003
559 #define RTLLIB_FCTL_FTYPE 0x000c
560 #define RTLLIB_FCTL_STYPE 0x00f0
561 #define RTLLIB_FCTL_FRAMETYPE 0x00fc
562 #define RTLLIB_FCTL_TODS 0x0100
563 #define RTLLIB_FCTL_FROMDS 0x0200
564 #define RTLLIB_FCTL_DSTODS 0x0300
565 #define RTLLIB_FCTL_MOREFRAGS 0x0400
566 #define RTLLIB_FCTL_RETRY 0x0800
567 #define RTLLIB_FCTL_PM 0x1000
568 #define RTLLIB_FCTL_MOREDATA 0x2000
569 #define RTLLIB_FCTL_WEP 0x4000
570 #define RTLLIB_FCTL_ORDER 0x8000
572 #define RTLLIB_FTYPE_MGMT 0x0000
573 #define RTLLIB_FTYPE_CTL 0x0004
574 #define RTLLIB_FTYPE_DATA 0x0008
577 #define RTLLIB_STYPE_ASSOC_REQ 0x0000
578 #define RTLLIB_STYPE_ASSOC_RESP 0x0010
579 #define RTLLIB_STYPE_REASSOC_REQ 0x0020
580 #define RTLLIB_STYPE_REASSOC_RESP 0x0030
581 #define RTLLIB_STYPE_PROBE_REQ 0x0040
582 #define RTLLIB_STYPE_PROBE_RESP 0x0050
583 #define RTLLIB_STYPE_BEACON 0x0080
584 #define RTLLIB_STYPE_ATIM 0x0090
585 #define RTLLIB_STYPE_DISASSOC 0x00A0
586 #define RTLLIB_STYPE_AUTH 0x00B0
587 #define RTLLIB_STYPE_DEAUTH 0x00C0
588 #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
591 #define RTLLIB_STYPE_PSPOLL 0x00A0
592 #define RTLLIB_STYPE_RTS 0x00B0
593 #define RTLLIB_STYPE_CTS 0x00C0
594 #define RTLLIB_STYPE_ACK 0x00D0
595 #define RTLLIB_STYPE_CFEND 0x00E0
596 #define RTLLIB_STYPE_CFENDACK 0x00F0
597 #define RTLLIB_STYPE_BLOCKACK 0x0094
600 #define RTLLIB_STYPE_DATA 0x0000
601 #define RTLLIB_STYPE_DATA_CFACK 0x0010
602 #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
603 #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
604 #define RTLLIB_STYPE_NULLFUNC 0x0040
605 #define RTLLIB_STYPE_CFACK 0x0050
606 #define RTLLIB_STYPE_CFPOLL 0x0060
607 #define RTLLIB_STYPE_CFACKPOLL 0x0070
608 #define RTLLIB_STYPE_QOS_DATA 0x0080
609 #define RTLLIB_STYPE_QOS_NULL 0x00C0
611 #define RTLLIB_SCTL_FRAG 0x000F
612 #define RTLLIB_SCTL_SEQ 0xFFF0
615 #define RTLLIB_QCTL_TID 0x000F
617 #define FC_QOS_BIT BIT7
618 #define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
619 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
620 #define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
621 #define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER)
622 #define SN_LESS(a, b) (((a-b)&0x800)!=0)
623 #define SN_EQUAL(a, b) (a == b)
624 #define MAX_DEV_ADDR_SIZE 8
626 typedef enum _ACT_CATEGORY{
632 } ACT_CATEGORY, *PACT_CATEGORY;
634 typedef enum _TS_ACTION{
639 } TS_ACTION, *PTS_ACTION;
641 typedef enum _BA_ACTION{
645 } BA_ACTION, *PBA_ACTION;
647 typedef enum _InitialGainOpType{
652 typedef enum _LED_CTL_MODE{
653 LED_CTL_POWER_ON = 1,
658 LED_CTL_SITE_SURVEY = 6,
659 LED_CTL_POWER_OFF = 7,
660 LED_CTL_START_TO_LINK = 8,
661 LED_CTL_START_WPS = 9,
662 LED_CTL_STOP_WPS = 10,
663 LED_CTL_START_WPS_BOTTON = 11,
664 LED_CTL_STOP_WPS_FAIL = 12,
665 LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
668 typedef enum _RT_RF_TYPE_DEF
678 typedef enum _WIRELESS_MODE {
679 WIRELESS_MODE_UNKNOWN = 0x00,
680 WIRELESS_MODE_A = 0x01,
681 WIRELESS_MODE_B = 0x02,
682 WIRELESS_MODE_G = 0x04,
683 WIRELESS_MODE_AUTO = 0x08,
684 WIRELESS_MODE_N_24G = 0x10,
685 WIRELESS_MODE_N_5G = 0x20
688 typedef enum _NETWORK_TYPE{
693 } WIRELESS_NETWORK_TYPE;
695 #define OUI_SUBTYPE_WMM_INFO 0
696 #define OUI_SUBTYPE_WMM_PARAM 1
697 #define OUI_SUBTYPE_QOS_CAPABI 5
700 #define CONFIG_RTLLIB_DEBUG
701 #ifdef CONFIG_RTLLIB_DEBUG
702 extern u32 rtllib_debug_level;
703 #define RTLLIB_DEBUG(level, fmt, args...) \
704 do { if (rtllib_debug_level & (level)) \
705 printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0)
706 #define RTLLIB_DEBUG_DATA(level, data, datalen) \
707 do{ if ((rtllib_debug_level & (level)) == (level)) \
710 u8* pdata = (u8*) data; \
711 printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
712 for (i=0; i<(int)(datalen); i++) \
714 printk("%2.2x ", pdata[i]); \
715 if ((i+1)%16 == 0) printk("\n"); \
721 #define RTLLIB_DEBUG(level, fmt, args...) do {} while (0)
722 #define RTLLIB_DEBUG_DATA(level, data, datalen) do {} while(0)
723 #endif /* CONFIG_RTLLIB_DEBUG */
725 /* debug macros not dependent on CONFIG_RTLLIB_DEBUG */
727 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
728 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
731 * To use the debug system;
733 * If you are defining a new debug classification, simply add it to the #define
734 * list here in the form of:
736 * #define RTLLIB_DL_xxxx VALUE
738 * shifting value to the left one bit from the previous entry. xxxx should be
739 * the name of the classification (for example, WEP)
741 * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
742 * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
743 * to send output to that classification.
745 * To add your debug level to the list of levels seen when you perform
747 * % cat /proc/net/ipw/debug_level
749 * you simply need to add your entry to the ipw_debug_levels array.
751 * If you do not see debug_level in /proc/net/ipw then you do not have
752 * CONFIG_RTLLIB_DEBUG defined in your kernel configuration
756 #define RTLLIB_DL_INFO (1<<0)
757 #define RTLLIB_DL_WX (1<<1)
758 #define RTLLIB_DL_SCAN (1<<2)
759 #define RTLLIB_DL_STATE (1<<3)
760 #define RTLLIB_DL_MGMT (1<<4)
761 #define RTLLIB_DL_FRAG (1<<5)
762 #define RTLLIB_DL_EAP (1<<6)
763 #define RTLLIB_DL_DROP (1<<7)
765 #define RTLLIB_DL_TX (1<<8)
766 #define RTLLIB_DL_RX (1<<9)
768 #define RTLLIB_DL_HT (1<<10)
769 #define RTLLIB_DL_BA (1<<11)
770 #define RTLLIB_DL_TS (1<<12)
771 #define RTLLIB_DL_QOS (1<<13)
772 #define RTLLIB_DL_REORDER (1<<14)
773 #define RTLLIB_DL_IOT (1<<15)
774 #define RTLLIB_DL_IPS (1<<16)
775 #define RTLLIB_DL_TRACE (1<<29)
776 #define RTLLIB_DL_DATA (1<<30)
777 #define RTLLIB_DL_ERR (1<<31)
778 #define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
779 #define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
780 #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
782 #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
783 #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
784 #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
785 #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
786 #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
787 #define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
788 #define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
789 #define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
790 #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
791 #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
793 #ifdef CONFIG_RTLLIB_DEBUG
794 /* Added by Annie, 2005-11-22. */
795 #define MAX_STR_LEN 64
796 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
797 #define PRINTABLE(_ch) (_ch>'!' && _ch<'~')
798 #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
799 if ((_Comp) & level) \
802 u8 buffer[MAX_STR_LEN]; \
803 int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
804 memset(buffer, 0, MAX_STR_LEN); \
805 memcpy(buffer, (u8 *)_Ptr, length ); \
806 for ( __i=0; __i<MAX_STR_LEN; __i++ ) \
808 if ( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
810 buffer[length] = '\0'; \
811 printk("Rtl819x: "); \
812 printk(_TitleString); \
813 printk(": %d, <%s>\n", _Len, buffer); \
816 #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0)
820 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
821 #define ETH_P_IP 0x0800 /* Internet Protocol packet */
822 #define ETH_P_ARP 0x0806 /* Address Resolution packet */
823 #endif /* ETH_P_PAE */
825 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
827 #ifndef ETH_P_80211_RAW
828 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
831 /* IEEE 802.11 defines */
833 #define P80211_OUI_LEN 3
835 struct rtllib_snap_hdr {
837 u8 dsap; /* always 0xAA */
838 u8 ssap; /* always 0xAA */
839 u8 ctrl; /* always 0x03 */
840 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
842 } __attribute__ ((packed));
844 enum _REG_PREAMBLE_MODE{
850 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
852 #define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS)
853 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
854 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
855 #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
857 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
858 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
859 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
861 #ifndef CONFIG_CFG_80211
862 /* Authentication algorithms */
863 #define WLAN_AUTH_OPEN 0
864 #define WLAN_AUTH_SHARED_KEY 1
865 #define WLAN_AUTH_LEAP 128
867 #define WLAN_AUTH_CHALLENGE_LEN 128
869 #define WLAN_CAPABILITY_ESS (1<<0)
870 #define WLAN_CAPABILITY_IBSS (1<<1)
871 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
872 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
873 #define WLAN_CAPABILITY_PRIVACY (1<<4)
874 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
875 #define WLAN_CAPABILITY_PBCC (1<<6)
876 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
877 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
878 #define WLAN_CAPABILITY_QOS (1<<9)
879 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
880 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
882 /* 802.11g ERP information element */
883 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
884 #define WLAN_ERP_USE_PROTECTION (1<<1)
885 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
888 enum rtllib_statuscode {
889 WLAN_STATUS_SUCCESS = 0,
890 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
891 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
892 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
893 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
894 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
895 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
896 WLAN_STATUS_CHALLENGE_FAIL = 15,
897 WLAN_STATUS_AUTH_TIMEOUT = 16,
898 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
899 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
901 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
902 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
903 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
905 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
906 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
907 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
909 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
910 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
912 WLAN_STATUS_INVALID_IE = 40,
913 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
914 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
915 WLAN_STATUS_INVALID_AKMP = 43,
916 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
917 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
918 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
922 enum rtllib_reasoncode {
923 WLAN_REASON_UNSPECIFIED = 1,
924 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
925 WLAN_REASON_DEAUTH_LEAVING = 3,
926 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
927 WLAN_REASON_DISASSOC_AP_BUSY = 5,
928 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
929 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
930 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
931 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
933 WLAN_REASON_DISASSOC_BAD_POWER = 10,
934 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
936 WLAN_REASON_INVALID_IE = 13,
937 WLAN_REASON_MIC_FAILURE = 14,
938 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
939 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
940 WLAN_REASON_IE_DIFFERENT = 17,
941 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
942 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
943 WLAN_REASON_INVALID_AKMP = 20,
944 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
945 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
946 WLAN_REASON_IEEE8021X_FAILED = 23,
947 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
951 #define RTLLIB_STATMASK_SIGNAL (1<<0)
952 #define RTLLIB_STATMASK_RSSI (1<<1)
953 #define RTLLIB_STATMASK_NOISE (1<<2)
954 #define RTLLIB_STATMASK_RATE (1<<3)
955 #define RTLLIB_STATMASK_WEMASK 0x7
957 #define RTLLIB_CCK_MODULATION (1<<0)
958 #define RTLLIB_OFDM_MODULATION (1<<1)
960 #define RTLLIB_24GHZ_BAND (1<<0)
961 #define RTLLIB_52GHZ_BAND (1<<1)
963 #define RTLLIB_CCK_RATE_LEN 4
964 #define RTLLIB_CCK_RATE_1MB 0x02
965 #define RTLLIB_CCK_RATE_2MB 0x04
966 #define RTLLIB_CCK_RATE_5MB 0x0B
967 #define RTLLIB_CCK_RATE_11MB 0x16
968 #define RTLLIB_OFDM_RATE_LEN 8
969 #define RTLLIB_OFDM_RATE_6MB 0x0C
970 #define RTLLIB_OFDM_RATE_9MB 0x12
971 #define RTLLIB_OFDM_RATE_12MB 0x18
972 #define RTLLIB_OFDM_RATE_18MB 0x24
973 #define RTLLIB_OFDM_RATE_24MB 0x30
974 #define RTLLIB_OFDM_RATE_36MB 0x48
975 #define RTLLIB_OFDM_RATE_48MB 0x60
976 #define RTLLIB_OFDM_RATE_54MB 0x6C
977 #define RTLLIB_BASIC_RATE_MASK 0x80
979 #define RTLLIB_CCK_RATE_1MB_MASK (1<<0)
980 #define RTLLIB_CCK_RATE_2MB_MASK (1<<1)
981 #define RTLLIB_CCK_RATE_5MB_MASK (1<<2)
982 #define RTLLIB_CCK_RATE_11MB_MASK (1<<3)
983 #define RTLLIB_OFDM_RATE_6MB_MASK (1<<4)
984 #define RTLLIB_OFDM_RATE_9MB_MASK (1<<5)
985 #define RTLLIB_OFDM_RATE_12MB_MASK (1<<6)
986 #define RTLLIB_OFDM_RATE_18MB_MASK (1<<7)
987 #define RTLLIB_OFDM_RATE_24MB_MASK (1<<8)
988 #define RTLLIB_OFDM_RATE_36MB_MASK (1<<9)
989 #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10)
990 #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11)
992 #define RTLLIB_CCK_RATES_MASK 0x0000000F
993 #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \
994 RTLLIB_CCK_RATE_2MB_MASK)
995 #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \
996 RTLLIB_CCK_RATE_5MB_MASK | \
997 RTLLIB_CCK_RATE_11MB_MASK)
999 #define RTLLIB_OFDM_RATES_MASK 0x00000FF0
1000 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \
1001 RTLLIB_OFDM_RATE_12MB_MASK | \
1002 RTLLIB_OFDM_RATE_24MB_MASK)
1003 #define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \
1004 RTLLIB_OFDM_RATE_9MB_MASK | \
1005 RTLLIB_OFDM_RATE_18MB_MASK | \
1006 RTLLIB_OFDM_RATE_36MB_MASK | \
1007 RTLLIB_OFDM_RATE_48MB_MASK | \
1008 RTLLIB_OFDM_RATE_54MB_MASK)
1009 #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \
1010 RTLLIB_CCK_DEFAULT_RATES_MASK)
1012 #define RTLLIB_NUM_OFDM_RATES 8
1013 #define RTLLIB_NUM_CCK_RATES 4
1014 #define RTLLIB_OFDM_SHIFT_MASK_A 4
1017 /* this is stolen and modified from the madwifi driver*/
1018 #define RTLLIB_FC0_TYPE_MASK 0x0c
1019 #define RTLLIB_FC0_TYPE_DATA 0x08
1020 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
1021 #define RTLLIB_FC0_SUBTYPE_QOS 0x80
1023 #define RTLLIB_QOS_HAS_SEQ(fc) \
1024 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
1025 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
1027 /* this is stolen from ipw2200 driver */
1028 #define IEEE_IBSS_MAC_HASH_SIZE 31
1029 struct ieee_ibss_seq {
1033 unsigned long packet_time[17];
1034 struct list_head list;
1037 /* NOTE: This data is for statistical purposes; not all hardware provides this
1038 * information for frames received. Not setting these will not cause
1039 * any adverse affects. */
1040 struct rtllib_rx_stats {
1046 u16 rate; /* in 100 kbps */
1047 u8 received_channel;
1057 s32 RecvSignalPower;
1063 u16 bShortPreamble:1;
1080 bool RxIs40MHzPacket;
1082 u8 RxMIMOSignalStrength[4];
1083 s8 RxMIMOSignalQuality[2];
1084 bool bPacketMatchBSSID;
1087 u8* virtual_address;
1092 bool bisrxaggrsubframe;
1095 char cck_adc_pwdb[4];
1098 #ifdef TCP_CSUM_OFFLOAD_RX
1105 /* IEEE 802.11 requires that STA supports concurrent reception of at least
1106 * three fragmented frames. This define can be increased to support more
1107 * concurrent frames, but it should be noted that each entry can consume about
1108 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
1109 #define RTLLIB_FRAG_CACHE_LEN 4
1111 struct rtllib_frag_entry {
1112 unsigned long first_frag_time;
1114 unsigned int last_frag;
1115 struct sk_buff *skb;
1116 u8 src_addr[ETH_ALEN];
1117 u8 dst_addr[ETH_ALEN];
1120 struct rtllib_stats {
1121 unsigned int tx_unicast_frames;
1122 unsigned int tx_multicast_frames;
1123 unsigned int tx_fragments;
1124 unsigned int tx_unicast_octets;
1125 unsigned int tx_multicast_octets;
1126 unsigned int tx_deferred_transmissions;
1127 unsigned int tx_single_retry_frames;
1128 unsigned int tx_multiple_retry_frames;
1129 unsigned int tx_retry_limit_exceeded;
1130 unsigned int tx_discards;
1131 unsigned int rx_unicast_frames;
1132 unsigned int rx_multicast_frames;
1133 unsigned int rx_fragments;
1134 unsigned int rx_unicast_octets;
1135 unsigned int rx_multicast_octets;
1136 unsigned int rx_fcs_errors;
1137 unsigned int rx_discards_no_buffer;
1138 unsigned int tx_discards_wrong_sa;
1139 unsigned int rx_discards_undecryptable;
1140 unsigned int rx_message_in_msg_fragments;
1141 unsigned int rx_message_in_bad_msg_fragments;
1144 struct rtllib_device;
1146 #include "rtllib_crypt.h"
1148 #define SEC_KEY_1 (1<<0)
1149 #define SEC_KEY_2 (1<<1)
1150 #define SEC_KEY_3 (1<<2)
1151 #define SEC_KEY_4 (1<<3)
1152 #define SEC_ACTIVE_KEY (1<<4)
1153 #define SEC_AUTH_MODE (1<<5)
1154 #define SEC_UNICAST_GROUP (1<<6)
1155 #define SEC_LEVEL (1<<7)
1156 #define SEC_ENABLED (1<<8)
1157 #define SEC_ENCRYPT (1<<9)
1159 #define SEC_LEVEL_0 0 /* None */
1160 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
1161 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
1162 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
1163 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
1165 #define SEC_ALG_NONE 0
1166 #define SEC_ALG_WEP 1
1167 #define SEC_ALG_TKIP 2
1168 #define SEC_ALG_CCMP 4
1171 #define WEP_KEY_LEN 13
1172 #define SCM_KEY_LEN 32
1173 #define SCM_TEMPORAL_KEY_LENGTH 16
1175 struct rtllib_security {
1180 unicast_uses_group:1,
1182 u8 key_sizes[WEP_KEYS];
1183 u8 keys[WEP_KEYS][SCM_KEY_LEN];
1186 } __attribute__ ((packed));
1190 802.11 data frame from AP
1191 ,-------------------------------------------------------------------.
1192 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1193 |------|------|---------|---------|---------|------|---------|------|
1194 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1195 | | tion | (BSSID) | | | ence | data | |
1196 `-------------------------------------------------------------------'
1197 Total: 28-2340 bytes
1200 /* Management Frame Information Element Types */
1203 MFIE_TYPE_RATES = 1,
1204 MFIE_TYPE_FH_SET = 2,
1205 MFIE_TYPE_DS_SET = 3,
1206 MFIE_TYPE_CF_SET = 4,
1208 MFIE_TYPE_IBSS_SET = 6,
1209 MFIE_TYPE_COUNTRY = 7,
1210 MFIE_TYPE_HOP_PARAMS = 8,
1211 MFIE_TYPE_HOP_TABLE = 9,
1212 MFIE_TYPE_REQUEST = 10,
1213 MFIE_TYPE_CHALLENGE = 16,
1214 MFIE_TYPE_POWER_CONSTRAINT = 32,
1215 MFIE_TYPE_POWER_CAPABILITY = 33,
1216 MFIE_TYPE_TPC_REQUEST = 34,
1217 MFIE_TYPE_TPC_REPORT = 35,
1218 MFIE_TYPE_SUPP_CHANNELS = 36,
1220 MFIE_TYPE_MEASURE_REQUEST = 38,
1221 MFIE_TYPE_MEASURE_REPORT = 39,
1222 MFIE_TYPE_QUIET = 40,
1223 MFIE_TYPE_IBSS_DFS = 41,
1225 MFIE_TYPE_HT_CAP= 45,
1227 MFIE_TYPE_RATES_EX = 50,
1228 MFIE_TYPE_HT_INFO= 61,
1229 MFIE_TYPE_AIRONET=133,
1230 MFIE_TYPE_GENERIC = 221,
1231 MFIE_TYPE_QOS_PARAMETER = 222,
1234 /* Minimal header; can be used for passing 802.11 frames with sufficient
1235 * information to determine what type of underlying data type is actually
1236 * stored in the data. */
1237 struct rtllib_pspoll_hdr {
1242 } __attribute__ ((packed));
1248 } __attribute__ ((packed));
1250 struct rtllib_hdr_1addr {
1255 } __attribute__ ((packed));
1257 struct rtllib_hdr_2addr {
1263 } __attribute__ ((packed));
1265 struct rtllib_hdr_3addr {
1273 } __attribute__ ((packed));
1275 struct rtllib_hdr_4addr {
1284 } __attribute__ ((packed));
1286 struct rtllib_hdr_3addrqos {
1295 } __attribute__ ((packed));
1297 struct rtllib_hdr_4addrqos {
1307 } __attribute__ ((packed));
1309 struct rtllib_info_element {
1313 } __attribute__ ((packed));
1315 struct rtllib_authentication {
1316 struct rtllib_hdr_3addr header;
1321 struct rtllib_info_element info_element[0];
1322 } __attribute__ ((packed));
1324 struct rtllib_disauth {
1325 struct rtllib_hdr_3addr header;
1327 } __attribute__ ((packed));
1329 struct rtllib_disassoc {
1330 struct rtllib_hdr_3addr header;
1332 } __attribute__ ((packed));
1334 struct rtllib_probe_request {
1335 struct rtllib_hdr_3addr header;
1336 /* SSID, supported rates */
1337 struct rtllib_info_element info_element[0];
1338 } __attribute__ ((packed));
1340 struct rtllib_probe_response {
1341 struct rtllib_hdr_3addr header;
1343 __le16 beacon_interval;
1345 /* SSID, supported rates, FH params, DS params,
1346 * CF params, IBSS params, TIM (if beacon), RSN */
1347 struct rtllib_info_element info_element[0];
1348 } __attribute__ ((packed));
1350 /* Alias beacon for probe_response */
1351 #define rtllib_beacon rtllib_probe_response
1353 struct rtllib_assoc_request_frame {
1354 struct rtllib_hdr_3addr header;
1356 __le16 listen_interval;
1357 /* SSID, supported rates, RSN */
1358 struct rtllib_info_element info_element[0];
1359 } __attribute__ ((packed));
1361 struct rtllib_reassoc_request_frame {
1362 struct rtllib_hdr_3addr header;
1364 __le16 listen_interval;
1365 u8 current_ap[ETH_ALEN];
1366 /* SSID, supported rates, RSN */
1367 struct rtllib_info_element info_element[0];
1368 } __attribute__ ((packed));
1370 struct rtllib_assoc_response_frame {
1371 struct rtllib_hdr_3addr header;
1375 struct rtllib_info_element info_element[0]; /* supported rates */
1376 } __attribute__ ((packed));
1385 __le16 payload_size;
1386 struct sk_buff *fragments[0];
1389 #define MAX_TX_AGG_COUNT 16
1390 struct rtllib_drv_agg_txb {
1391 u8 nr_drv_agg_frames;
1392 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1393 }__attribute__((packed));
1395 #define MAX_SUBFRAME_COUNT 64
1398 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1401 #ifdef TCP_CSUM_OFFLOAD_RX
1404 }__attribute__((packed));
1406 typedef union _frameqos {
1416 }frameqos,*pframeqos;
1418 /* SWEEP TABLE ENTRIES NUMBER*/
1419 #define MAX_SWEEP_TAB_ENTRIES 42
1420 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1421 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1422 * only use 8, and then use extended rates for the remaining supported
1423 * rates. Other APs, however, stick all of their supported rates on the
1424 * main rates information element... */
1425 #define MAX_RATES_LENGTH ((u8)12)
1426 #define MAX_RATES_EX_LENGTH ((u8)16)
1427 #define MAX_NETWORK_COUNT 96
1429 #define MAX_CHANNEL_NUMBER 161
1430 #define RTLLIB_SOFTMAC_SCAN_TIME 100
1431 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1433 #define CRC_LENGTH 4U
1435 #define MAX_WPA_IE_LEN 64
1436 #define MAX_WZC_IE_LEN 256
1438 #define NETWORK_EMPTY_ESSID (1<<0)
1439 #define NETWORK_HAS_OFDM (1<<1)
1440 #define NETWORK_HAS_CCK (1<<2)
1443 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1444 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
1445 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1446 NETWORK_HAS_QOS_INFORMATION)
1448 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1449 #define NETWORK_HAS_CSA (1<<6)
1450 #define NETWORK_HAS_QUIET (1<<7)
1451 #define NETWORK_HAS_IBSS_DFS (1<<8)
1452 #define NETWORK_HAS_TPC_REPORT (1<<9)
1454 #define NETWORK_HAS_ERP_VALUE (1<<10)
1456 #define QOS_QUEUE_NUM 4
1457 #define QOS_OUI_LEN 3
1458 #define QOS_OUI_TYPE 2
1459 #define QOS_ELEMENT_ID 221
1460 #define QOS_OUI_INFO_SUB_TYPE 0
1461 #define QOS_OUI_PARAM_SUB_TYPE 1
1462 #define QOS_VERSION_1 1
1463 #define QOS_AIFSN_MIN_VALUE 2
1465 struct rtllib_qos_information_element {
1468 u8 qui[QOS_OUI_LEN];
1473 } __attribute__ ((packed));
1475 struct rtllib_qos_ac_parameter {
1479 } __attribute__ ((packed));
1481 struct rtllib_qos_parameter_info {
1482 struct rtllib_qos_information_element info_element;
1484 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1485 } __attribute__ ((packed));
1487 struct rtllib_qos_parameters {
1488 __le16 cw_min[QOS_QUEUE_NUM];
1489 __le16 cw_max[QOS_QUEUE_NUM];
1490 u8 aifs[QOS_QUEUE_NUM];
1491 u8 flag[QOS_QUEUE_NUM];
1492 __le16 tx_op_limit[QOS_QUEUE_NUM];
1493 } __attribute__ ((packed));
1495 struct rtllib_qos_data {
1496 struct rtllib_qos_parameters parameters;
1497 unsigned int wmm_acm;
1504 struct rtllib_tim_parameters {
1507 } __attribute__ ((packed));
1509 struct rtllib_wmm_ac_param {
1510 u8 ac_aci_acm_aifsn;
1511 u8 ac_ecwmin_ecwmax;
1515 struct rtllib_wmm_ts_info {
1519 } __attribute__ ((packed));
1521 struct rtllib_wmm_tspec_elem {
1522 struct rtllib_wmm_ts_info ts_info;
1529 u32 serv_start_time;
1536 u16 surp_band_allow;
1538 }__attribute__((packed));
1545 EAPOL_ENCAP_ASF_ALERT
1548 static const char *eap_types[] = {
1549 [EAP_PACKET] = "EAP-Packet",
1550 [EAPOL_START] = "EAPOL-Start",
1551 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1552 [EAPOL_KEY] = "EAPOL-Key",
1553 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1556 static inline const char *eap_get_type(int type)
1558 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1560 static inline u8 Frame_QoSTID(u8* buf)
1562 struct rtllib_hdr_3addr *hdr;
1564 hdr = (struct rtllib_hdr_3addr *)buf;
1565 fc = le16_to_cpu(hdr->frame_ctl);
1566 return (u8)((frameqos*)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid;
1576 } __attribute__ ((packed));
1578 struct rtllib_softmac_stats{
1579 unsigned int rx_ass_ok;
1580 unsigned int rx_ass_err;
1581 unsigned int rx_probe_rq;
1582 unsigned int tx_probe_rs;
1583 unsigned int tx_beacons;
1584 unsigned int rx_auth_rq;
1585 unsigned int rx_auth_rs_ok;
1586 unsigned int rx_auth_rs_err;
1587 unsigned int tx_auth_rq;
1588 unsigned int no_auth_rs;
1589 unsigned int no_ass_rs;
1590 unsigned int tx_ass_rq;
1591 unsigned int rx_ass_rq;
1592 unsigned int tx_probe_rq;
1593 unsigned int reassoc;
1594 unsigned int swtxstop;
1595 unsigned int swtxawake;
1596 unsigned char CurrentShowTxate;
1597 unsigned char last_packet_rate;
1598 unsigned int txretrycount;
1601 #define BEACON_PROBE_SSID_ID_POSITION 12
1603 struct rtllib_info_element_hdr {
1606 } __attribute__ ((packed));
1609 * These are the data types that can make up management packets
1613 u16 beacon_interval;
1615 u8 current_ap[ETH_ALEN];
1616 u16 listen_interval;
1618 u16 association_id:14, reserved:2;
1619 } __attribute__ ((packed));
1625 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1626 #define RTLLIB_DEFAULT_BASIC_RATE 2
1628 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1629 #define MAX_SP_Len (WMM_all_frame << 4)
1630 #define RTLLIB_QOS_TID 0x0f
1631 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1633 #define RTLLIB_DTIM_MBCAST 4
1634 #define RTLLIB_DTIM_UCAST 2
1635 #define RTLLIB_DTIM_VALID 1
1636 #define RTLLIB_DTIM_INVALID 0
1638 #define RTLLIB_PS_DISABLED 0
1639 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1640 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1642 #ifdef WMM_Hang_8187
1643 #undef WMM_Hang_8187
1646 #define WME_AC_BK 0x00
1647 #define WME_AC_BE 0x01
1648 #define WME_AC_VI 0x02
1649 #define WME_AC_VO 0x03
1650 #define WME_ACI_MASK 0x03
1651 #define WME_AIFSN_MASK 0x03
1652 #define WME_AC_PRAM_LEN 16
1654 #define MAX_RECEIVE_BUFFER_SIZE 9100
1657 #define UP2AC(up) ( \
1658 ((up) < 1) ? WME_AC_BE : \
1659 ((up) < 3) ? WME_AC_BK : \
1660 ((up) < 4) ? WME_AC_BE : \
1661 ((up) < 6) ? WME_AC_VI : \
1664 #define AC2UP(_ac) ( \
1665 ((_ac) == WME_AC_VO) ? 6 : \
1666 ((_ac) == WME_AC_VI) ? 5 : \
1667 ((_ac) == WME_AC_BK) ? 1 : \
1670 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1671 #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
1673 struct ether_header {
1674 u8 ether_dhost[ETHER_ADDR_LEN];
1675 u8 ether_shost[ETHER_ADDR_LEN];
1677 } __attribute__((packed));
1679 #ifndef ETHERTYPE_PAE
1680 #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1682 #ifndef ETHERTYPE_IP
1683 #define ETHERTYPE_IP 0x0800 /* IP protocol */
1687 typedef enum _erp_t{
1688 ERP_NonERPpresent = 0x01,
1689 ERP_UseProtection = 0x02,
1690 ERP_BarkerPreambleMode = 0x04,
1693 struct rtllib_network {
1694 /* These entries are used to identify a unique network */
1697 /* Ensure null-terminated for any debug msgs */
1698 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1700 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
1702 struct rtllib_qos_data qos_data;
1704 bool bWithAironetIE;
1705 bool bCkipSupported;
1711 bool bWithCcxVerNum;
1713 /* These are network statistics */
1714 struct rtllib_rx_stats stats;
1716 u8 rates[MAX_RATES_LENGTH];
1718 u8 rates_ex[MAX_RATES_EX_LENGTH];
1720 unsigned long last_scanned;
1725 u16 beacon_interval;
1726 u16 listen_interval;
1729 u8 wpa_ie[MAX_WPA_IE_LEN];
1731 u8 rsn_ie[MAX_WPA_IE_LEN];
1733 u8 wzc_ie[MAX_WZC_IE_LEN];
1736 struct rtllib_tim_parameters tim;
1739 u32 last_dtim_sta_time[2];
1742 struct rtllib_wmm_ac_param wmm_param[4];
1744 #ifdef ENABLE_DOT11D
1746 u8 CountryIeBuf[MAX_IE_LEN];
1749 bool broadcom_cap_exist;
1750 bool realtek_cap_exit;
1751 bool marvell_cap_exist;
1752 bool ralink_cap_exist;
1753 bool atheros_cap_exist;
1754 bool cisco_cap_exist;
1755 bool airgo_cap_exist;
1756 bool unknown_cap_exist;
1757 bool berp_info_valid;
1758 bool buseprotection;
1759 bool bIsNetgear854T;
1762 struct list_head list;
1768 /* the card is not linked at all */
1771 /* RTLLIB_ASSOCIATING* are for BSS client mode
1772 * the driver shall not perform RX filtering unless
1773 * the state is LINKED.
1774 * The driver shall just check for the state LINKED and
1775 * defaults to NOLINK for ALL the other states (including
1779 /* the association procedure will start (wq scheduling)*/
1781 RTLLIB_ASSOCIATING_RETRY,
1783 /* the association procedure is sending AUTH request*/
1784 RTLLIB_ASSOCIATING_AUTHENTICATING,
1786 /* the association procedure has successfully authentcated
1787 * and is sending association request
1789 RTLLIB_ASSOCIATING_AUTHENTICATED,
1791 /* the link is ok. the card associated to a BSS or linked
1792 * to a ibss cell or acting as an AP and creating the bss
1796 /* same as LINKED, but the driver shall apply RX filter
1797 * rules as we are in NO_LINK mode. As the card is still
1798 * logically linked, but it is doing a syncro site survey
1799 * then it will be back to LINKED state.
1801 RTLLIB_LINKED_SCANNING,
1805 RTLLIB_UNINITIALIZED = 0,
1809 RTLLIB_AUTHENTICATING,
1810 RTLLIB_AUTHENTICATED,
1815 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1816 #define DEFAULT_FTS 2346
1818 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1819 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1820 #define CFG_RTLLIB_RTS (1<<2)
1822 #define RTLLIB_24GHZ_MIN_CHANNEL 1
1823 #define RTLLIB_24GHZ_MAX_CHANNEL 14
1824 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
1825 RTLLIB_24GHZ_MIN_CHANNEL + 1)
1827 #define RTLLIB_52GHZ_MIN_CHANNEL 34
1828 #define RTLLIB_52GHZ_MAX_CHANNEL 165
1829 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
1830 RTLLIB_52GHZ_MIN_CHANNEL + 1)
1832 #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
1834 typedef struct tx_pending_t{
1836 struct rtllib_txb *txb;
1839 typedef struct _bandwidth_autoswitch
1841 long threshold_20Mhzto40Mhz;
1842 long threshold_40Mhzto20Mhz;
1843 bool bforced_tx20Mhz;
1844 bool bautoswitch_enable;
1845 }bandwidth_autoswitch,*pbandwidth_autoswitch;
1849 #define REORDER_WIN_SIZE 128
1850 #define REORDER_ENTRY_NUM 128
1851 typedef struct _RX_REORDER_ENTRY
1853 struct list_head List;
1855 struct rtllib_rxb* prxb;
1856 } RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
1857 typedef enum _Fsync_State{
1863 typedef enum _RT_PS_MODE
1871 typedef enum _IPS_CALLBACK_FUNCION
1873 IPS_CALLBACK_NONE = 0,
1874 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1875 IPS_CALLBACK_JOIN_REQUEST = 2,
1876 }IPS_CALLBACK_FUNCION;
1878 typedef enum _RT_JOIN_ACTION{
1885 typedef struct _IbssParms{
1887 }IbssParms, *PIbssParms;
1888 #define MAX_NUM_RATES 264
1890 typedef enum _RT_RF_POWER_STATE
1897 #define MAX_SUPPORT_WOL_PATTERN_NUM 8
1899 #define MAX_WOL_BIT_MASK_SIZE 16
1900 #define MAX_WOL_PATTERN_SIZE 128
1902 typedef enum _WOLPATTERN_TYPE
1911 typedef struct _RT_PM_WOL_PATTERN_INFO
1917 WOLPATTERN_TYPE PatternType;
1918 }RT_PM_WOL_PATTERN_INFO, *PRT_PM_WOL_PATTERN_INFO;
1920 typedef struct _RT_POWER_SAVE_CONTROL
1924 bool bIPSModeBackup;
1925 bool bHaltAdapterClkRQ;
1926 bool bSwRfProcessing;
1927 RT_RF_POWER_STATE eInactivePowerState;
1928 work_struct_rsl InactivePsWorkItem;
1929 struct timer_list InactivePsTimer;
1931 IPS_CALLBACK_FUNCION ReturnPoint;
1934 RT_JOIN_ACTION tmpJoinAction;
1935 struct rtllib_network tmpBssDesc;
1938 bool bTmpActiveScan;
1939 bool bTmpFilterHiddenAP;
1940 bool bTmpUpdateParms;
1942 OCTET_STRING tmpSsid2Scan;
1945 u8 tmpChannelNumber;
1949 OCTET_STRING tmpSuppRateSet;
1950 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1958 u8 RegMaxLPSAwakeIntvl;
1967 bool LinkReqInIPSRFOffPgs;
1968 bool BufConnectinfoBefore;
1976 RT_PM_WOL_PATTERN_INFO PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM];
1978 }RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;
1980 typedef u32 RT_RF_CHANGE_SOURCE;
1981 #define RF_CHANGE_BY_SW BIT31
1982 #define RF_CHANGE_BY_HW BIT30
1983 #define RF_CHANGE_BY_PS BIT29
1984 #define RF_CHANGE_BY_IPS BIT28
1985 #define RF_CHANGE_BY_INIT 0
1989 COUNTRY_CODE_FCC = 0,
1990 COUNTRY_CODE_IC = 1,
1991 COUNTRY_CODE_ETSI = 2,
1992 COUNTRY_CODE_SPAIN = 3,
1993 COUNTRY_CODE_FRANCE = 4,
1994 COUNTRY_CODE_MKK = 5,
1995 COUNTRY_CODE_MKK1 = 6,
1996 COUNTRY_CODE_ISRAEL = 7,
1997 COUNTRY_CODE_TELEC = 8,
1998 COUNTRY_CODE_MIC = 9,
1999 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
2000 COUNTRY_CODE_WORLD_WIDE_13 = 11,
2001 COUNTRY_CODE_TELEC_NETGEAR = 12,
2003 }country_code_type_t;
2005 typedef enum _SCAN_OPERATION_BACKUP_OPT{
2009 }SCAN_OPERATION_BACKUP_OPT;
2011 typedef enum _FW_CMD_IO_TYPE{
2012 FW_CMD_DIG_ENABLE = 0,
2013 FW_CMD_DIG_DISABLE = 1,
2014 FW_CMD_DIG_HALT = 2,
2015 FW_CMD_DIG_RESUME = 3,
2016 FW_CMD_HIGH_PWR_ENABLE = 4,
2017 FW_CMD_HIGH_PWR_DISABLE = 5,
2018 FW_CMD_RA_RESET = 6,
2019 FW_CMD_RA_ACTIVE= 7,
2020 FW_CMD_RA_REFRESH_N= 8,
2021 FW_CMD_RA_REFRESH_BG= 9,
2023 FW_CMD_IQK_ENABLE = 11,
2024 FW_CMD_TXPWR_TRACK_ENABLE = 12,
2025 FW_CMD_TXPWR_TRACK_DISABLE = 13,
2026 FW_CMD_TXPWR_TRACK_THERMAL = 14,
2027 FW_CMD_PAUSE_DM_BY_SCAN = 15,
2028 FW_CMD_RESUME_DM_BY_SCAN = 16,
2029 FW_CMD_RA_REFRESH_N_COMB = 17,
2030 FW_CMD_RA_REFRESH_BG_COMB = 18,
2031 FW_CMD_ANTENNA_SW_ENABLE = 19,
2032 FW_CMD_ANTENNA_SW_DISABLE = 20,
2033 FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
2034 FW_CMD_LPS_ENTER = 22,
2035 FW_CMD_LPS_LEAVE = 23,
2036 FW_CMD_DIG_MODE_SS = 24,
2037 FW_CMD_DIG_MODE_FA = 25,
2038 FW_CMD_ADD_A2_ENTRY = 26,
2039 FW_CMD_CTRL_DM_BY_DRIVER = 27,
2040 FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28,
2041 FW_CMD_PAPE_CONTROL = 29,
2042 FW_CMD_CHAN_SET = 30,
2043 }FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE;
2045 #define RT_MAX_LD_SLOT_NUM 10
2046 typedef struct _RT_LINK_DETECT_T{
2048 u32 NumRecvBcnInPeriod;
2049 u32 NumRecvDataInPeriod;
2051 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
2052 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
2056 u32 NumTxOkInPeriod;
2057 u32 NumRxOkInPeriod;
2058 u32 NumRxUnicastOkInPeriod;
2060 bool bHigherBusyTraffic;
2061 bool bHigherBusyRxTraffic;
2063 u32 NumTxUnicastOkInPeriod;
2064 u32 LastNumTxUnicast;
2065 u32 LastNumRxUnicast;
2066 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
2068 typedef struct _SW_CAM_TABLE{
2077 }SW_CAM_TABLE,*PSW_CAM_TABLE;
2078 #define TOTAL_CAM_ENTRY 32
2079 typedef struct _rate_adaptive
2081 u8 rate_adaptive_disabled;
2085 u32 high_rssi_thresh_for_ra;
2086 u32 high2low_rssi_thresh_for_ra;
2087 u8 low2high_rssi_thresh_for_ra40M;
2088 u32 low_rssi_thresh_for_ra40M;
2089 u8 low2high_rssi_thresh_for_ra20M;
2090 u32 low_rssi_thresh_for_ra20M;
2091 u32 upper_rssi_threshold_ratr;
2092 u32 middle_rssi_threshold_ratr;
2093 u32 low_rssi_threshold_ratr;
2094 u32 low_rssi_threshold_ratr_40M;
2095 u32 low_rssi_threshold_ratr_20M;
2096 u8 ping_rssi_enable;
2098 u32 ping_rssi_thresh_for_ra;
2102 } rate_adaptive, *prate_adaptive;
2103 typedef enum _RATR_TABLE_MODE_8192S{
2104 RATR_INX_WIRELESS_NGB = 0,
2105 RATR_INX_WIRELESS_NG = 1,
2106 RATR_INX_WIRELESS_NB = 2,
2107 RATR_INX_WIRELESS_N = 3,
2108 RATR_INX_WIRELESS_GB = 4,
2109 RATR_INX_WIRELESS_G = 5,
2110 RATR_INX_WIRELESS_B = 6,
2111 RATR_INX_WIRELESS_MC = 7,
2112 RATR_INX_WIRELESS_A = 8,
2113 }RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S;
2115 #define NUM_PMKID_CACHE 16
2116 typedef struct _RT_PMKID_LIST
2124 } RT_PMKID_LIST, *PRT_PMKID_LIST;
2126 #ifdef CONFIG_CFG_80211
2128 LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
2129 LIBIPW_CH_80211H_RULES = (1 << 1),
2130 LIBIPW_CH_B_ONLY = (1 << 2),
2131 LIBIPW_CH_NO_IBSS = (1 << 3),
2132 LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
2133 LIBIPW_CH_RADAR_DETECT = (1 << 5),
2134 LIBIPW_CH_INVALID = (1 << 6),
2136 struct rtllib_channel {
2143 #define RTLLIB_24GHZ_MIN_CHANNEL 1
2144 #define RTLLIB_24GHZ_MAX_CHANNEL 14
2145 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
2146 RTLLIB_24GHZ_MIN_CHANNEL + 1)
2148 struct reg_dmn_pair_mapping {
2154 struct rtl_regulatory {
2157 u16 max_power_level;
2161 int16_t power_limit;
2162 struct reg_dmn_pair_mapping *regpair;
2165 struct ieee80211_bss {
2166 /* Yes, this is a hack */
2167 struct cfg80211_bss cbss;
2169 /* don't want to look up all the time */
2171 u8 ssid[IEEE80211_MAX_SSID_LEN];
2177 unsigned long last_probe_resp;
2179 #ifdef CONFIG_MAC80211_MESH
2185 #define IEEE80211_MAX_SUPP_RATES 32
2186 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
2187 size_t supp_rates_len;
2190 * During assocation, we save an ERP value from a probe response so
2191 * that we can feed ERP info to the driver when handling the
2192 * association completes. these fields probably won't be up-to-date
2193 * otherwise, you probably don't want to use them.
2199 /* Parsed Information Elements */
2200 struct ieee802_11_elems {
2204 /* pointers to IEs */
2210 struct ieee80211_tim_ie *tim;
2219 struct ieee80211_ht_cap *ht_cap_elem;
2220 struct ieee80211_ht_info *ht_info_elem;
2229 u8 *pwr_constr_elem;
2230 u8 *quiet_elem; /* first quite element */
2233 /* length of them, respectively */
2245 u8 ext_supp_rates_len;
2254 u8 ch_switch_elem_len;
2255 u8 country_elem_len;
2256 u8 pwr_constr_elem_len;
2258 u8 num_of_quiet_elem; /* can be more the one */
2265 typedef struct _RT_INTEL_PROMISCUOUS_MODE_INFO {
2266 bool bPromiscuousOn;
2267 bool bFilterSourceStationFrame;
2268 } RT_INTEL_PROMISCUOUS_MODE_INFO, *PRT_INTEL_PROMISCUOUS_MODE_INFO;
2271 /*************** DRIVER STATUS *****/
2272 #define STATUS_SCANNING 0
2273 #define STATUS_SCAN_HW 1
2274 #define STATUS_SCAN_ABORTING 2
2275 #define STATUS_SETTING_CHAN 3
2276 /*************** DRIVER STATUS *****/
2288 LPS_WAIT_NULL_DATA_SEND =2,
2291 struct rtllib_device {
2292 struct pci_dev *pdev;
2293 struct net_device *dev;
2294 struct rtllib_security sec;
2296 bool disable_mgnt_queue;
2298 unsigned long status;
2300 HT_EXTCHNL_OFFSET chan_offset_bk;
2301 HT_CHANNEL_WIDTH bandwidth_bk;
2303 #ifdef CONFIG_CFG_80211
2304 struct wireless_dev wdev;
2305 struct rtl_regulatory regulatory;
2312 /* The last AssocReq/Resp IEs */
2313 u8 *assocreq_ies, *assocresp_ies;
2314 size_t assocreq_ies_len, assocresp_ies_len;
2316 bool b_customer_lenovo_id;
2317 bool bForcedShowRxRate;
2318 bool bForcedShowRateStill;
2319 u8 SystemQueryDataRateCount;
2322 bool b1x1RecvCombine;
2327 bool is_silent_reset;
2328 bool force_mic_error;
2332 bool bSupportRemoteWakeUp;
2333 RT_PS_MODE dot11PowerSaveMode;
2335 bool FirstIe_InScan;
2336 bool be_scan_inprogress;
2338 RT_RF_POWER_STATE eRFPowerState;
2339 RT_RF_CHANGE_SOURCE RfOffReason;
2342 PRT_HIGH_THROUGHPUT pHTInfo;
2343 spinlock_t bw_spinlock;
2345 spinlock_t reorder_spinlock;
2346 u8 Regdot11HTOperationalRateSet[16];
2347 u8 Regdot11TxHTOperationalRateSet[16];
2348 u8 dot11HTOperationalRateSet[16];
2349 u8 RegHTSuppRateSet[16];
2350 u8 HTCurrentOperaRate;
2351 u8 HTHighestOperaRate;
2354 u8 bTxDisableRateFallBack;
2355 u8 bTxUseDriverAssingedRate;
2356 u8 bTxEnableFwCalcDur;
2357 atomic_t atm_chnlop;
2360 struct list_head Tx_TS_Admit_List;
2361 struct list_head Tx_TS_Pending_List;
2362 struct list_head Tx_TS_Unused_List;
2363 TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
2364 struct list_head Rx_TS_Admit_List;
2365 struct list_head Rx_TS_Pending_List;
2366 struct list_head Rx_TS_Unused_List;
2367 RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
2368 RX_REORDER_ENTRY RxReorderEntry[128];
2369 struct list_head RxReorder_Unused_List;
2373 /* Bookkeeping structures */
2374 struct net_device_stats stats;
2375 struct rtllib_stats ieee_stats;
2376 struct rtllib_softmac_stats softmac_stats;
2378 /* Probe / Beacon management */
2379 struct list_head network_free_list;
2380 struct list_head network_list;
2382 struct list_head network_bssid_free_list;
2383 struct list_head network_bssid_list;
2385 struct rtllib_network *networks;
2389 int iw_mode; /* operating mode (IW_MODE_*) */
2390 bool bNetPromiscuousMode;
2391 RT_INTEL_PROMISCUOUS_MODE_INFO IntelPromiscuousModeInfo;
2393 struct iw_spy_data spy_data;
2396 spinlock_t wpax_suitlist_lock;
2398 int tx_headroom; /* Set to size of any additional room needed at front
2399 * of allocated Tx SKBs */
2402 /* WEP and other encryption related settings at the device level */
2403 int open_wep; /* Set to 1 to allow unencrypted frames */
2405 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2406 * WEP key changes */
2408 /* If the host performs {en,de}cryption, then set to 1 */
2410 int host_encrypt_msdu;
2412 /* host performs multicast decryption */
2413 int host_mc_decrypt;
2415 /* host should strip IV and ICV from protected frames */
2416 /* meaningful only when hardware decryption is being used */
2417 int host_strip_iv_icv;
2421 int ieee802_1x; /* is IEEE 802.1X used */
2425 bool bHalfWirelessN24GMode;
2427 int drop_unencrypted;
2428 int tkip_countermeasures;
2429 int privacy_invoked;
2435 u16 pairwise_key_type;
2437 struct list_head crypt_deinit_list;
2438 struct rtllib_crypt_data *crypt[WEP_KEYS];
2440 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
2441 SW_CAM_TABLE swcamtable[TOTAL_CAM_ENTRY];
2442 struct timer_list crypt_deinit_timer;
2445 int bcrx_sta_key; /* use individual keys to override default keys even
2446 * with RX of broad/multicast frames */
2448 RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
2450 /* Fragmentation structures */
2451 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
2452 unsigned int frag_next_idx[17];
2453 u16 fts; /* Fragmentation Threshold */
2454 #define DEFAULT_RTS_THRESHOLD 2346U
2455 #define MIN_RTS_THRESHOLD 1
2456 #define MAX_RTS_THRESHOLD 2346U
2457 u16 rts; /* RTS threshold */
2459 /* Association info */
2462 /* This stores infos for the current network.
2463 * Either the network we are associated in INFRASTRUCTURE
2464 * or the network that we are creating in MASTER mode.
2465 * ad-hoc is a mixture ;-).
2466 * Note that in infrastructure mode, even when not associated,
2467 * fields bssid and essid may be valid (if wpa_set and essid_set
2468 * are true) as thy carry the value set by the user via iwconfig
2470 struct rtllib_network current_network;
2472 enum rtllib_state state;
2476 int mode; /* A, B, G */
2477 int modulation; /* CCK, OFDM */
2478 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
2479 int abg_true; /* ABG flag */
2481 /* used for forcing the ibss workqueue to terminate
2482 * without wait for the syncro scan to terminate
2484 short sync_scan_hurryup;
2489 u16 prev_seq_ctl; /* used to drop duplicate frames */
2491 /* map of allowed channels. 0 is dummy */
2492 #ifdef ENABLE_DOT11D
2496 u8 channel_map[MAX_CHANNEL_NUMBER+1];
2498 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
2501 u8 ibss_maxjoin_chal;
2503 int rate; /* current rate */
2509 /* this contains flags for selectively enable softmac support */
2510 u16 softmac_features;
2512 /* if the sequence control field is not filled by HW */
2515 /* association procedure transaction sequence number */
2518 /* AID for RTXed association responses */
2521 /* power save mode related*/
2527 struct tasklet_struct ps_task;
2533 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2535 short scanning_continue ;
2536 short proto_started;
2537 short proto_stoppping;
2539 struct semaphore wx_sem;
2540 struct semaphore scan_sem;
2541 struct semaphore ips_sem;
2543 spinlock_t mgmt_tx_lock;
2544 spinlock_t beacon_lock;
2551 /* set on initialization */
2553 unsigned int wmm_acm;
2555 /* for discarding duplicated packets in IBSS */
2556 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
2558 /* for discarding duplicated packets in BSS */
2559 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
2560 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
2561 unsigned long last_packet_time[17];
2564 unsigned long last_rx_ps_time;
2568 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
2569 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
2570 int mgmt_queue_head;
2571 int mgmt_queue_tail;
2572 #define RTLLIB_QUEUE_LIMIT 128
2574 unsigned int hw_header;
2575 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
2576 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
2577 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
2578 u32 sta_edca_param[4];
2580 bool enable_rx_imm_BA;
2581 bool bibsscoordinator;
2583 bool bdynamic_txpower_enable;
2585 bool bCTSToSelfEnable;
2588 u32 fsync_time_interval;
2589 u32 fsync_rate_bitmap;
2590 u8 fsync_rssi_threshold;
2593 u8 fsync_multiple_timeinterval;
2594 u32 fsync_firstdiff_ratethreshold;
2595 u32 fsync_seconddiff_ratethreshold;
2596 Fsync_State fsync_state;
2597 bool bis_any_nonbepkts;
2598 bandwidth_autoswitch bandwidth_auto_switch;
2601 RT_LINK_DETECT_T LinkDetectInfo;
2602 bool bIsAggregateFrame;
2603 RT_POWER_SAVE_CONTROL PowerSaveControl;
2604 u8 amsdu_in_process;
2606 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2607 struct tx_pending_t tx_pending;
2609 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2610 struct timer_list associate_timer;
2612 /* used if IEEE_SOFTMAC_BEACONS is set */
2613 struct timer_list beacon_timer;
2615 work_struct_rsl associate_complete_wq;
2616 work_struct_rsl ips_leave_wq;
2617 delayed_work_struct_rsl associate_procedure_wq;
2618 delayed_work_struct_rsl softmac_scan_wq;
2619 delayed_work_struct_rsl softmac_hint11d_wq;
2620 delayed_work_struct_rsl associate_retry_wq;
2621 delayed_work_struct_rsl start_ibss_wq;
2622 delayed_work_struct_rsl hw_wakeup_wq;
2623 delayed_work_struct_rsl hw_sleep_wq;
2624 delayed_work_struct_rsl link_change_wq;
2625 work_struct_rsl wx_sync_scan_wq;
2627 struct workqueue_struct *wq;
2629 /* Callback functions */
2630 void (*set_security)(struct net_device *dev,
2631 struct rtllib_security *sec);
2633 /* Used to TX data frame by using txb structs.
2634 * this is not used if in the softmac_features
2635 * is set the flag IEEE_SOFTMAC_TX_QUEUE
2637 int (*hard_start_xmit)(struct rtllib_txb *txb,
2638 struct net_device *dev);
2640 int (*reset_port)(struct net_device *dev);
2641 int (*is_queue_full) (struct net_device * dev, int pri);
2643 int (*handle_management) (struct net_device * dev,
2644 struct rtllib_network * network, u16 type);
2645 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
2647 /* Softmac-generated frames (mamagement) are TXed via this
2648 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
2649 * not set. As some cards may have different HW queues that
2650 * one might want to use for data and management frames
2651 * the option to have two callbacks might be useful.
2652 * This fucntion can't sleep.
2654 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
2655 struct net_device *dev);
2657 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
2658 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
2659 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
2660 * then also management frames are sent via this callback.
2661 * This function can't sleep.
2663 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
2664 struct net_device *dev,int rate);
2666 /* stops the HW queue for DATA frames. Useful to avoid
2667 * waste time to TX data frame when we are reassociating
2668 * This function can sleep.
2670 void (*data_hard_stop)(struct net_device *dev);
2672 /* OK this is complementar to data_poll_hard_stop */
2673 void (*data_hard_resume)(struct net_device *dev);
2675 /* ask to the driver to retune the radio .
2676 * This function can sleep. the driver should ensure
2677 * the radio has been swithced before return.
2679 void (*set_chan)(struct net_device *dev,short ch);
2681 /* These are not used if the ieee stack takes care of
2682 * scanning (IEEE_SOFTMAC_SCAN feature set).
2683 * In this case only the set_chan is used.
2685 * The syncro version is similar to the start_scan but
2686 * does not return until all channels has been scanned.
2687 * this is called in user context and should sleep,
2688 * it is called in a work_queue when swithcing to ad-hoc mode
2689 * or in behalf of iwlist scan when the card is associated
2690 * and root user ask for a scan.
2691 * the fucntion stop_scan should stop both the syncro and
2692 * background scanning and can sleep.
2693 * The fucntion start_scan should initiate the background
2694 * scanning and can't sleep.
2696 void (*scan_syncro)(struct net_device *dev);
2697 void (*start_scan)(struct net_device *dev);
2698 void (*stop_scan)(struct net_device *dev);
2700 void (*rtllib_start_hw_scan)(struct net_device *dev);
2701 void (*rtllib_stop_hw_scan)(struct net_device *dev);
2703 /* indicate the driver that the link state is changed
2704 * for example it may indicate the card is associated now.
2705 * Driver might be interested in this to apply RX filter
2706 * rules or simply light the LINK led
2708 void (*link_change)(struct net_device *dev);
2710 /* these two function indicates to the HW when to start
2711 * and stop to send beacons. This is used when the
2712 * IEEE_SOFTMAC_BEACONS is not set. For now the
2713 * stop_send_bacons is NOT guaranteed to be called only
2714 * after start_send_beacons.
2716 void (*start_send_beacons) (struct net_device *dev);
2717 void (*stop_send_beacons) (struct net_device *dev);
2719 /* power save mode related */
2720 void (*sta_wake_up) (struct net_device *dev);
2721 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
2722 short (*ps_is_queue_empty) (struct net_device *dev);
2723 int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network);
2724 int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network);
2727 /* check whether Tx hw resouce available */
2728 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
2729 short (*get_nic_desc_num)(struct net_device *dev, int queue_index);
2730 void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
2731 bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
2732 void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
2733 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
2734 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
2735 void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value);
2736 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2737 bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
2738 void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level);
2739 void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start);
2740 void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR);
2741 u16 (*rtl_11n_user_show_rates)(struct net_device *dev);
2742 void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation);
2743 void (*LedControlHandler)(struct net_device * dev, LED_CTL_MODE LedAction);
2744 void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2745 void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2747 void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg);
2749 void (*rtllib_ips_leave_wq) (struct net_device *dev);
2750 void (*rtllib_ips_leave)(struct net_device *dev);
2751 void (*LeisurePSLeave)(struct net_device *dev);
2752 void (*rtllib_rfkill_poll)(struct net_device *dev);
2754 /* This must be the last item so that it points to the data
2755 * allocated beyond this structure by alloc_rtllib */
2759 #define IEEE_A (1<<0)
2760 #define IEEE_B (1<<1)
2761 #define IEEE_G (1<<2)
2762 #define IEEE_N_24G (1<<4)
2763 #define IEEE_N_5G (1<<5)
2764 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
2766 /* Generate a 802.11 header */
2768 /* Uses the channel change callback directly
2769 * instead of [start/stop] scan callbacks
2771 #define IEEE_SOFTMAC_SCAN (1<<2)
2773 /* Perform authentication and association handshake */
2774 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2776 /* Generate probe requests */
2777 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2779 /* Generate respones to probe requests */
2780 #define IEEE_SOFTMAC_PROBERS (1<<5)
2782 /* The ieee802.11 stack will manages the netif queue
2783 * wake/stop for the driver, taking care of 802.11
2784 * fragmentation. See softmac.c for details. */
2785 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2787 /* Uses only the softmac_data_hard_start_xmit
2788 * even for TX management frames.
2790 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2792 /* Generate beacons. The stack will enqueue beacons
2795 #define IEEE_SOFTMAC_BEACONS (1<<6)
2798 static inline void *rtllib_priv(struct net_device *dev)
2800 return ((struct rtllib_device *)netdev_priv(dev))->priv;
2803 extern inline int rtllib_is_empty_essid(const char *essid, int essid_len)
2805 /* Single white space is for Linksys APs */
2806 if (essid_len == 1 && essid[0] == ' ')
2809 /* Otherwise, if the entire essid is 0, we assume it is hidden */
2812 if (essid[essid_len] != '\0')
2819 extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
2822 * It is possible for both access points and our device to support
2823 * combinations of modes, so as long as there is one valid combination
2824 * of ap/device supported modes, then return success
2827 if ((mode & IEEE_A) &&
2828 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2829 (ieee->freq_band & RTLLIB_52GHZ_BAND))
2832 if ((mode & IEEE_G) &&
2833 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2834 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2837 if ((mode & IEEE_B) &&
2838 (ieee->modulation & RTLLIB_CCK_MODULATION) &&
2839 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2845 extern inline int rtllib_get_hdrlen(u16 fc)
2847 int hdrlen = RTLLIB_3ADDR_LEN;
2849 switch (WLAN_FC_GET_TYPE(fc)) {
2850 case RTLLIB_FTYPE_DATA:
2851 if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
2852 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
2853 if (RTLLIB_QOS_HAS_SEQ(fc))
2854 hdrlen += 2; /* QOS ctrl*/
2856 case RTLLIB_FTYPE_CTL:
2857 switch (WLAN_FC_GET_STYPE(fc)) {
2858 case RTLLIB_STYPE_CTS:
2859 case RTLLIB_STYPE_ACK:
2860 hdrlen = RTLLIB_1ADDR_LEN;
2863 hdrlen = RTLLIB_2ADDR_LEN;
2872 static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
2874 switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2875 case RTLLIB_1ADDR_LEN:
2876 return ((struct rtllib_hdr_1addr *)hdr)->payload;
2877 case RTLLIB_2ADDR_LEN:
2878 return ((struct rtllib_hdr_2addr *)hdr)->payload;
2879 case RTLLIB_3ADDR_LEN:
2880 return ((struct rtllib_hdr_3addr *)hdr)->payload;
2881 case RTLLIB_4ADDR_LEN:
2882 return ((struct rtllib_hdr_4addr *)hdr)->payload;
2887 static inline int rtllib_is_ofdm_rate(u8 rate)
2889 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2890 case RTLLIB_OFDM_RATE_6MB:
2891 case RTLLIB_OFDM_RATE_9MB:
2892 case RTLLIB_OFDM_RATE_12MB:
2893 case RTLLIB_OFDM_RATE_18MB:
2894 case RTLLIB_OFDM_RATE_24MB:
2895 case RTLLIB_OFDM_RATE_36MB:
2896 case RTLLIB_OFDM_RATE_48MB:
2897 case RTLLIB_OFDM_RATE_54MB:
2903 static inline int rtllib_is_cck_rate(u8 rate)
2905 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2906 case RTLLIB_CCK_RATE_1MB:
2907 case RTLLIB_CCK_RATE_2MB:
2908 case RTLLIB_CCK_RATE_5MB:
2909 case RTLLIB_CCK_RATE_11MB:
2917 extern void free_rtllib(struct net_device *dev);
2918 extern struct net_device *alloc_rtllib(int sizeof_priv);
2920 extern int rtllib_set_encryption(struct rtllib_device *ieee);
2924 extern int rtllib_encrypt_fragment(
2925 struct rtllib_device *ieee,
2926 struct sk_buff *frag,
2929 extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
2930 extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
2931 extern void rtllib_txb_free(struct rtllib_txb *);
2934 extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
2935 struct rtllib_rx_stats *rx_stats);
2936 extern void rtllib_rx_mgt(struct rtllib_device *ieee,
2937 struct sk_buff *skb,
2938 struct rtllib_rx_stats *stats);
2939 extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
2940 struct sk_buff *skb);
2941 extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel);
2944 extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
2945 struct iw_request_info *info,
2946 union iwreq_data *wrqu, char *key);
2947 extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
2948 struct iw_request_info *info,
2949 union iwreq_data *wrqu, char *key);
2950 extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
2951 struct iw_request_info *info,
2952 union iwreq_data *wrqu, char *key);
2953 #if WIRELESS_EXT >= 18
2954 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
2955 struct iw_request_info *info,
2956 union iwreq_data* wrqu, char *extra);
2957 extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
2958 struct iw_request_info *info,
2959 union iwreq_data* wrqu, char *extra);
2961 extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
2962 struct iw_request_info *info,
2963 struct iw_param *data, char *extra);
2964 extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
2965 struct iw_request_info *info,
2966 union iwreq_data *wrqu, char *extra);
2967 extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
2969 /* rtllib_softmac.c */
2970 extern short rtllib_is_54g(struct rtllib_network *net);
2971 extern short rtllib_is_shortslot(struct rtllib_network net);
2972 extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb,
2973 struct rtllib_rx_stats *rx_stats, u16 type,
2975 extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net);
2977 void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
2978 extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
2980 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2981 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2982 extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
2983 extern void rtllib_start_bss(struct rtllib_device *ieee);
2984 extern void rtllib_start_master_bss(struct rtllib_device *ieee);
2985 extern void rtllib_start_ibss(struct rtllib_device *ieee);
2986 extern void rtllib_softmac_init(struct rtllib_device *ieee);
2987 extern void rtllib_softmac_free(struct rtllib_device *ieee);
2988 extern void rtllib_associate_abort(struct rtllib_device *ieee);
2989 extern void rtllib_disassociate(struct rtllib_device *ieee);
2990 extern void rtllib_stop_scan(struct rtllib_device *ieee);
2991 extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
2992 extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
2993 extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2994 extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
2995 extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
2996 extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr);
2997 extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
2998 extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
2999 extern void rtllib_check_all_nets(struct rtllib_device *ieee);
3000 extern void rtllib_start_protocol(struct rtllib_device *ieee);
3001 extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
3003 extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState);
3004 extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState);
3005 extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState);
3006 extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState);
3007 extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
3009 extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown);
3010 extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag);
3012 extern void rtllib_reset_queue(struct rtllib_device *ieee);
3013 extern void rtllib_wake_queue(struct rtllib_device *ieee);
3014 extern void rtllib_stop_queue(struct rtllib_device *ieee);
3015 extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
3016 extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
3017 extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
3018 extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
3019 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
3020 extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh);
3022 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
3023 extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
3025 extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee);
3026 extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst);
3027 extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
3029 /* rtllib_crypt_ccmp&tkip&wep.c */
3030 extern void rtllib_tkip_null(void);
3031 extern void rtllib_wep_null(void);
3032 extern void rtllib_ccmp_null(void);
3034 /* rtllib_softmac_wx.c */
3036 extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
3037 struct iw_request_info *info,
3038 union iwreq_data *wrqu, char *ext);
3040 extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
3041 struct iw_request_info *info,
3042 union iwreq_data *awrq,
3045 extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
3047 extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
3048 struct iw_request_info *info,
3049 union iwreq_data *wrqu, char *extra);
3051 extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
3052 struct iw_request_info *info,
3053 union iwreq_data *wrqu, char *extra);
3055 extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a,
3056 union iwreq_data *wrqu, char *b);
3058 extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a,
3059 union iwreq_data *wrqu, char *b);
3061 extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
3062 struct iw_request_info *a,
3063 union iwreq_data *wrqu, char *extra);
3065 extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a,
3066 union iwreq_data *wrqu, char *b);
3068 extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
3069 union iwreq_data *wrqu, char *b);
3071 extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a,
3072 union iwreq_data *wrqu, char *b);
3073 extern void rtllib_wx_sync_scan_wq(void *data);
3075 extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
3076 struct iw_request_info *info,
3077 union iwreq_data *wrqu, char *extra);
3079 extern int rtllib_wx_get_name(struct rtllib_device *ieee,
3080 struct iw_request_info *info,
3081 union iwreq_data *wrqu, char *extra);
3083 extern int rtllib_wx_set_power(struct rtllib_device *ieee,
3084 struct iw_request_info *info,
3085 union iwreq_data *wrqu, char *extra);
3087 extern int rtllib_wx_get_power(struct rtllib_device *ieee,
3088 struct iw_request_info *info,
3089 union iwreq_data *wrqu, char *extra);
3091 extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
3092 struct iw_request_info *info,
3093 union iwreq_data *wrqu, char *extra);
3095 extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
3096 struct iw_request_info *info,
3097 union iwreq_data *wrqu, char *extra);
3098 #define MAX_RECEIVE_BUFFER_SIZE 9100
3099 extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
3100 extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
3102 void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
3103 extern void HTUpdateDefaultSetting(struct rtllib_device* ieee);
3104 extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc);
3105 extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
3106 extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len);
3107 extern void HTOnAssocRsp(struct rtllib_device *ieee);
3108 extern void HTInitializeHTInfo(struct rtllib_device* ieee);
3109 extern void HTInitializeBssDesc(PBSS_HT pBssHT);
3110 extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork);
3111 extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork);
3112 extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
3113 extern u8 MCS_FILTER_ALL[];
3114 extern u16 MCS_DATA_RATE[2][2][77] ;
3115 extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame);
3116 extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
3117 extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee);
3118 extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate);
3119 extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate);
3120 extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate);
3121 extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb);
3122 extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb);
3123 extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb);
3124 extern void TsInitAddBA( struct rtllib_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending);
3125 extern void TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
3126 extern void BaSetupTimeOut(unsigned long data);
3127 extern void TxBaInactTimeout(unsigned long data);
3128 extern void RxBaInactTimeout(unsigned long data);
3129 extern void ResetBaEntry( PBA_RECORD pBA);
3131 struct rtllib_device* ieee,
3132 PTS_COMMON_INFO *ppTS,
3135 TR_SELECT TxRxSelect,
3138 extern void TSInitialize(struct rtllib_device *ieee);
3139 extern void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS);
3140 extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr);
3141 extern void RemoveAllTS(struct rtllib_device* ieee);
3142 void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
3144 extern const long rtllib_wlan_frequencies[];
3146 extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
3151 extern inline int rtllib_get_scans(struct rtllib_device *ieee)
3156 static inline const char *escape_essid(const char *essid, u8 essid_len) {
3157 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
3158 const char *s = essid;
3161 if (rtllib_is_empty_essid(essid, essid_len)) {
3162 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
3166 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
3167 while (essid_len--) {
3180 #define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE<MGN_MCS0)?(_MGN_RATE):(HTMcsToDataRate(_ieee, (u8)_MGN_RATE))
3182 /* fun with the built-in rtllib stack... */
3183 int rtllib_init(void);
3184 void rtllib_exit(void);
3185 int rtllib_crypto_init(void);
3186 void rtllib_crypto_deinit(void);
3187 int rtllib_crypto_tkip_init(void);
3188 void rtllib_crypto_tkip_exit(void);
3189 int rtllib_crypto_ccmp_init(void);
3190 void rtllib_crypto_ccmp_exit(void);
3191 int rtllib_crypto_wep_init(void);
3192 void rtllib_crypto_wep_exit(void);
3194 void rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib);
3195 void rtllib_MlmeDisassociateRequest(struct rtllib_device* rtllib, u8* asSta,u8 asRsn);
3196 void rtllib_MgntDisconnectAP(struct rtllib_device* rtllib, u8 asRsn);
3197 bool rtllib_MgntDisconnect(struct rtllib_device* rtllib,u8 asRsn);
3200 /* For the function is more related to hardware setting, it's better to use the
3201 * ieee handler to refer to it.
3203 extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
3204 extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS);
3205 extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev);
3206 extern int rtllib_parse_info_param(struct rtllib_device *ieee,
3207 struct rtllib_info_element *info_element,
3209 struct rtllib_network *network,
3210 struct rtllib_rx_stats *stats);
3212 void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index);
3213 #if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE)
3214 extern void IbssAgeFunction(struct rtllib_device *ieee);
3215 extern struct sta_info *GetStaInfo(struct rtllib_device *ieee, u8 *addr);
3216 extern void DelStaInfoList(struct rtllib_device *ieee);
3217 extern void DelStaInfo(struct rtllib_device *ieee, u8 *addr);
3219 extern u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS);
3220 extern void HTUseDefaultSetting(struct rtllib_device* ieee);
3221 #define RT_ASOC_RETRY_LIMIT 5
3222 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
3223 extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
3224 #ifndef ENABLE_LOCK_DEBUG
3225 #define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags)
3226 #define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags)
3227 #define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags)
3228 #define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags)
3229 #define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags)
3230 #define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags)
3231 #define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags)
3232 #define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags)
3233 #define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags)
3234 #define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags)
3235 #define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags)
3236 #define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags)
3237 #define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags)
3238 #define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags)
3239 #define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags)
3240 #define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags)
3241 #define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags)
3242 #define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags)
3243 #define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags)
3244 #define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags)
3245 #define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags)
3246 #define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags)
3247 #define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags)
3248 #define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags)
3249 #define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags)
3250 #define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags)
3251 #define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags)
3252 #define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags)
3253 #define SEM_DOWN_IEEE_WX(psem) down(psem)
3254 #define SEM_UP_IEEE_WX(psem) up(psem)
3255 #define SEM_DOWN_IEEE_SCAN(psem) down(psem)
3256 #define SEM_UP_IEEE_SCAN(psem) up(psem)
3257 #define SEM_DOWN_IEEE_IPS(psem) down(psem)
3258 #define SEM_UP_IEEE_IPS(psem) up(psem)
3259 #define SEM_DOWN_PRIV_WX(psem) down(psem)
3260 #define SEM_UP_PRIV_WX(psem) up(psem)
3261 #define SEM_DOWN_PRIV_RF(psem) down(psem)
3262 #define SEM_UP_PRIV_RF(psem) up(psem)
3263 #define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
3264 #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
3266 static inline void dump_buf(u8 *buf, u32 len)
3269 printk("-----------------Len %d----------------\n", len);
3270 for (i=0; i<len; i++)
3271 printk("%2.2x-", *(buf+i));
3274 #endif /* RTLLIB_H */