1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11
4 * remains copyright by the original authors
6 * Portions of the merged code are based on Host AP (software wireless
7 * LAN access point) driver for Intersil Prism2/2.5/3.
9 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
13 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
15 * Copyright (c) 2004, Intel Corporation
17 * Modified for Realtek's wi-fi cards by Andrea Merello
22 #include <linux/if_ether.h> /* ETH_ALEN */
23 #include <linux/kernel.h> /* ARRAY_SIZE */
24 #include <linux/module.h>
25 #include <linux/interrupt.h>
26 #include <linux/jiffies.h>
27 #include <linux/timer.h>
28 #include <linux/sched.h>
29 #include <linux/mutex.h>
31 #include <linux/delay.h>
32 #include <linux/wireless.h>
34 #include "rtllib_debug.h"
35 #include "rtl819x_HT.h"
36 #include "rtl819x_BA.h"
37 #include "rtl819x_TS.h"
39 #include <linux/netdevice.h>
40 #include <linux/if_arp.h> /* ARPHRD_ETHER */
41 #include <net/lib80211.h>
43 #define MAX_PRECMD_CNT 16
44 #define MAX_RFDEPENDCMD_CNT 16
45 #define MAX_POSTCMD_CNT 16
50 #include <net/iw_handler.h>
52 #ifndef IW_MODE_MONITOR
53 #define IW_MODE_MONITOR 6
57 #define IWEVCUSTOM 0x8c02
61 /* Max number of char in custom event - use multiple of them if needed */
62 #define IW_CUSTOM_MAX 256 /* In bytes */
65 #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
67 #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
68 #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
70 #define queue_work_rsl(x, y) queue_work(x, y)
71 #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
73 #define container_of_work_rsl(x, y, z) container_of(x, y, z)
74 #define container_of_dwork_rsl(x, y, z) \
75 container_of(to_delayed_work(x), y, z)
77 #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
78 iwe_stream_add_event(info, start, stop, iwe, len)
80 #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
81 iwe_stream_add_point(info, start, stop, iwe, p)
83 static inline void *netdev_priv_rsl(struct net_device *dev)
85 return netdev_priv(dev);
88 #define KEY_TYPE_NA 0x0
89 #define KEY_TYPE_WEP40 0x1
90 #define KEY_TYPE_TKIP 0x2
91 #define KEY_TYPE_CCMP 0x4
92 #define KEY_TYPE_WEP104 0x5
93 /* added for rtl819x tx procedure */
94 #define MAX_QUEUE_SIZE 0x10
101 #define TXCMD_QUEUE 5
104 #define BEACON_QUEUE 8
107 #define IW_MODE_MESH 7
110 #define IE_CISCO_FLAG_POSITION 0x08
111 #define SUPPORT_CKIP_MIC 0x08
112 #define SUPPORT_CKIP_PK 0x10
113 #define RT_RF_OFF_LEVL_HALT_NIC BIT3
114 #define RT_IN_PS_LEVEL(psc, _PS_FLAG) \
115 ((psc->CurPsLevel & _PS_FLAG) ? true : false)
116 #define RT_CLEAR_PS_LEVEL(psc, _PS_FLAG) \
117 (psc->CurPsLevel &= (~(_PS_FLAG)))
118 #define RT_SET_PS_LEVEL(psc, _PS_FLAG) (psc->CurPsLevel |= _PS_FLAG)
120 /* defined for skb cb field */
121 /* At most 28 byte */
123 /* Tx Desc Related flags (8-9) */
129 u8 tx_dis_rate_fallback:1;
130 u8 tx_use_drv_assinged_rate:1;
135 /* Tx Firmware Related flags (10-11)*/
139 u8 bUseShortPreamble:1;
140 u8 bTxEnableFwCalcDur:1;
147 u8 bRTSUseShortPreamble:1;
154 /* Tx Desc related element(12-19) */
165 /* Tx firmware related element(20-27) */
173 u8 bIsSpecialDataFrame;
179 enum sw_chnl_cmd_id {
181 CmdID_SetTxPowerLevel,
183 CmdID_WritePortUlong,
184 CmdID_WritePortUshort,
185 CmdID_WritePortUchar,
190 enum sw_chnl_cmd_id CmdID;
196 /*--------------------------Define -------------------------------------------*/
199 #define MGN_5_5M 0x0b
211 #define MGN_MCS0 0x80
212 #define MGN_MCS1 0x81
213 #define MGN_MCS2 0x82
214 #define MGN_MCS3 0x83
215 #define MGN_MCS4 0x84
216 #define MGN_MCS5 0x85
217 #define MGN_MCS6 0x86
218 #define MGN_MCS7 0x87
219 #define MGN_MCS8 0x88
220 #define MGN_MCS9 0x89
221 #define MGN_MCS10 0x8a
222 #define MGN_MCS11 0x8b
223 #define MGN_MCS12 0x8c
224 #define MGN_MCS13 0x8d
225 #define MGN_MCS14 0x8e
226 #define MGN_MCS15 0x8f
230 HW_VAR_MULTICAST_REG,
234 HW_VAR_SECURITY_CONF,
235 HW_VAR_BEACON_INTERVAL,
237 HW_VAR_LISTEN_INTERVAL,
250 HW_VAR_RATE_FALLBACK_CONTROL,
251 HW_VAR_CONTENTION_WINDOW,
256 HW_VAR_AMPDU_MIN_SPACE,
257 HW_VAR_SHORTGI_DENSITY,
259 HW_VAR_MCS_RATE_AVAILABLE,
262 HW_VAR_DIS_Req_Qsize,
263 HW_VAR_CCX_CHNL_LOAD,
264 HW_VAR_CCX_NOISE_HISTOGRAM,
271 HW_VAR_SET_DEV_POWER,
281 HW_VAR_USER_CONTROL_TURBO_MODE,
287 HW_VAR_AUTOLOAD_STATUS,
288 HW_VAR_RF_2R_DISABLE,
290 HW_VAR_H2C_FW_PWRMODE,
291 HW_VAR_H2C_FW_JOINBSSRPT,
292 HW_VAR_1X1_RECV_COMBINE,
293 HW_VAR_STOP_SEND_BEACON,
298 HW_VAR_H2C_FW_UPDATE_GTK,
301 HW_VAR_WF_IS_MAC_ADDR,
302 HW_VAR_H2C_FW_OFFLOAD,
305 HW_VAR_HANDLE_FW_C2H,
306 HW_VAR_DL_FW_RSVD_PAGE,
308 HW_VAR_HW_SEQ_ENABLE,
313 HW_VAR_SWITCH_EPHY_WoWLAN,
314 HW_VAR_INT_MIGRATION,
321 RT_OP_MODE_INFRASTRUCTURE,
328 (((priv->rtllib->current_network.mode == IEEE_A) \
329 || (priv->rtllib->current_network.mode == IEEE_N_24G) \
330 || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
332 #define MGMT_QUEUE_NUM 5
334 #define MAX_IE_LEN 0xff
336 #define msleep_interruptible_rsl msleep_interruptible
338 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
341 * The figure in section 7.1.2 suggests a body size of up to 2312
342 * bytes is allowed, which is a bit confusing, I suspect this
343 * represents the 2304 bytes of real data, plus a possible 8 bytes of
344 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
346 #define RTLLIB_1ADDR_LEN 10
347 #define RTLLIB_2ADDR_LEN 16
348 #define RTLLIB_3ADDR_LEN 24
349 #define RTLLIB_4ADDR_LEN 30
350 #define RTLLIB_FCS_LEN 4
352 #define RTLLIB_SKBBUFFER_SIZE 2500
354 #define MIN_FRAG_THRESHOLD 256U
355 #define MAX_FRAG_THRESHOLD 2346U
357 /* Frame control field constants */
358 #define RTLLIB_FCTL_FTYPE 0x000c
359 #define RTLLIB_FCTL_STYPE 0x00f0
360 #define RTLLIB_FCTL_FRAMETYPE 0x00fc
361 #define RTLLIB_FCTL_TODS 0x0100
362 #define RTLLIB_FCTL_FROMDS 0x0200
363 #define RTLLIB_FCTL_DSTODS 0x0300
364 #define RTLLIB_FCTL_MOREFRAGS 0x0400
365 #define RTLLIB_FCTL_RETRY 0x0800
366 #define RTLLIB_FCTL_PM 0x1000
367 #define RTLLIB_FCTL_MOREDATA 0x2000
368 #define RTLLIB_FCTL_WEP 0x4000
369 #define RTLLIB_FCTL_ORDER 0x8000
371 #define RTLLIB_FTYPE_MGMT 0x0000
372 #define RTLLIB_FTYPE_CTL 0x0004
373 #define RTLLIB_FTYPE_DATA 0x0008
376 #define RTLLIB_STYPE_ASSOC_REQ 0x0000
377 #define RTLLIB_STYPE_ASSOC_RESP 0x0010
378 #define RTLLIB_STYPE_REASSOC_REQ 0x0020
379 #define RTLLIB_STYPE_REASSOC_RESP 0x0030
380 #define RTLLIB_STYPE_PROBE_REQ 0x0040
381 #define RTLLIB_STYPE_PROBE_RESP 0x0050
382 #define RTLLIB_STYPE_BEACON 0x0080
383 #define RTLLIB_STYPE_ATIM 0x0090
384 #define RTLLIB_STYPE_DISASSOC 0x00A0
385 #define RTLLIB_STYPE_AUTH 0x00B0
386 #define RTLLIB_STYPE_DEAUTH 0x00C0
387 #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
390 #define RTLLIB_STYPE_PSPOLL 0x00A0
391 #define RTLLIB_STYPE_RTS 0x00B0
392 #define RTLLIB_STYPE_CTS 0x00C0
393 #define RTLLIB_STYPE_ACK 0x00D0
396 #define RTLLIB_STYPE_DATA 0x0000
397 #define RTLLIB_STYPE_DATA_CFACK 0x0010
398 #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
399 #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
400 #define RTLLIB_STYPE_NULLFUNC 0x0040
401 #define RTLLIB_STYPE_QOS_DATA 0x0080
402 #define RTLLIB_STYPE_QOS_NULL 0x00C0
404 #define RTLLIB_SCTL_FRAG 0x000F
405 #define RTLLIB_SCTL_SEQ 0xFFF0
408 #define RTLLIB_QCTL_TID 0x000F
410 #define FC_QOS_BIT BIT7
411 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
412 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
413 #define IsQoSDataFrame(pframe) \
414 ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
415 (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
416 #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
417 #define SN_LESS(a, b) (((a-b)&0x800) != 0)
418 #define SN_EQUAL(a, b) (a == b)
419 #define MAX_DEV_ADDR_SIZE 8
435 enum init_gain_op_type {
442 LED_CTL_POWER_ON = 1,
447 LED_CTL_SITE_SURVEY = 6,
448 LED_CTL_POWER_OFF = 7,
449 LED_CTL_START_TO_LINK = 8,
452 enum rt_rf_type_def {
458 WIRELESS_MODE_UNKNOWN = 0x00,
459 WIRELESS_MODE_A = 0x01,
460 WIRELESS_MODE_B = 0x02,
461 WIRELESS_MODE_G = 0x04,
462 WIRELESS_MODE_AUTO = 0x08,
463 WIRELESS_MODE_N_24G = 0x10,
464 WIRELESS_MODE_N_5G = 0x20
468 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
469 #define ETH_P_IP 0x0800 /* Internet Protocol packet */
470 #define ETH_P_ARP 0x0806 /* Address Resolution packet */
471 #endif /* ETH_P_PAE */
473 #ifndef ETH_P_80211_RAW
474 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
477 /* IEEE 802.11 defines */
479 #define P80211_OUI_LEN 3
481 struct rtllib_snap_hdr {
482 u8 dsap; /* always 0xAA */
483 u8 ssap; /* always 0xAA */
484 u8 ctrl; /* always 0x03 */
485 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
489 enum _REG_PREAMBLE_MODE {
495 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
497 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
498 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
499 #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
501 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
502 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
503 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
505 /* Authentication algorithms */
506 #define WLAN_AUTH_OPEN 0
507 #define WLAN_AUTH_SHARED_KEY 1
508 #define WLAN_AUTH_LEAP 128
510 #define WLAN_CAPABILITY_ESS (1<<0)
511 #define WLAN_CAPABILITY_IBSS (1<<1)
512 #define WLAN_CAPABILITY_PRIVACY (1<<4)
513 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
514 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
516 #define RTLLIB_STATMASK_SIGNAL (1<<0)
517 #define RTLLIB_STATMASK_RSSI (1<<1)
518 #define RTLLIB_STATMASK_NOISE (1<<2)
519 #define RTLLIB_STATMASK_WEMASK 0x7
521 #define RTLLIB_CCK_MODULATION (1<<0)
522 #define RTLLIB_OFDM_MODULATION (1<<1)
524 #define RTLLIB_24GHZ_BAND (1<<0)
525 #define RTLLIB_52GHZ_BAND (1<<1)
527 #define RTLLIB_CCK_RATE_LEN 4
528 #define RTLLIB_CCK_RATE_1MB 0x02
529 #define RTLLIB_CCK_RATE_2MB 0x04
530 #define RTLLIB_CCK_RATE_5MB 0x0B
531 #define RTLLIB_CCK_RATE_11MB 0x16
532 #define RTLLIB_OFDM_RATE_LEN 8
533 #define RTLLIB_OFDM_RATE_6MB 0x0C
534 #define RTLLIB_OFDM_RATE_9MB 0x12
535 #define RTLLIB_OFDM_RATE_12MB 0x18
536 #define RTLLIB_OFDM_RATE_18MB 0x24
537 #define RTLLIB_OFDM_RATE_24MB 0x30
538 #define RTLLIB_OFDM_RATE_36MB 0x48
539 #define RTLLIB_OFDM_RATE_48MB 0x60
540 #define RTLLIB_OFDM_RATE_54MB 0x6C
541 #define RTLLIB_BASIC_RATE_MASK 0x80
543 /* this is stolen and modified from the madwifi driver*/
544 #define RTLLIB_FC0_TYPE_MASK 0x0c
545 #define RTLLIB_FC0_TYPE_DATA 0x08
546 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
547 #define RTLLIB_FC0_SUBTYPE_QOS 0x80
549 #define RTLLIB_QOS_HAS_SEQ(fc) \
550 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
551 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
553 /* this is stolen from ipw2200 driver */
554 #define IEEE_IBSS_MAC_HASH_SIZE 31
555 struct ieee_ibss_seq {
559 unsigned long packet_time[17];
560 struct list_head list;
563 /* NOTE: This data is for statistical purposes; not all hardware provides this
564 * information for frames received. Not setting these will not cause
565 * any adverse affects.
567 struct rtllib_rx_stats {
572 u16 rate; /* in 100 kbps */
589 u16 bShortPreamble:1;
605 bool RxIs40MHzPacket;
607 u8 RxMIMOSignalStrength[4];
608 s8 RxMIMOSignalQuality[2];
609 bool bPacketMatchBSSID;
621 /* IEEE 802.11 requires that STA supports concurrent reception of at least
622 * three fragmented frames. This define can be increased to support more
623 * concurrent frames, but it should be noted that each entry can consume about
624 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
626 #define RTLLIB_FRAG_CACHE_LEN 4
628 struct rtllib_frag_entry {
629 unsigned long first_frag_time;
631 unsigned int last_frag;
633 u8 src_addr[ETH_ALEN];
634 u8 dst_addr[ETH_ALEN];
637 struct rtllib_device;
639 #define SEC_ACTIVE_KEY (1<<4)
640 #define SEC_AUTH_MODE (1<<5)
641 #define SEC_UNICAST_GROUP (1<<6)
642 #define SEC_LEVEL (1<<7)
643 #define SEC_ENABLED (1<<8)
645 #define SEC_LEVEL_0 0 /* None */
646 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
647 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
648 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
649 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
651 #define SEC_ALG_NONE 0
652 #define SEC_ALG_WEP 1
653 #define SEC_ALG_TKIP 2
654 #define SEC_ALG_CCMP 4
656 #define WEP_KEY_LEN 13
657 #define SCM_KEY_LEN 32
659 struct rtllib_security {
664 unicast_uses_group:1,
666 u8 key_sizes[NUM_WEP_KEYS];
667 u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
673 /* 802.11 data frame from AP
674 * ,-------------------------------------------------------------------.
675 * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
676 * |------|------|---------|---------|---------|------|---------|------|
677 * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
678 * | | tion | (BSSID) | | | ence | data | |
679 * `-------------------------------------------------------------------'
680 * Total: 28-2340 bytes
683 /* Management Frame Information Element Types */
687 MFIE_TYPE_FH_SET = 2,
688 MFIE_TYPE_DS_SET = 3,
689 MFIE_TYPE_CF_SET = 4,
691 MFIE_TYPE_IBSS_SET = 6,
692 MFIE_TYPE_COUNTRY = 7,
693 MFIE_TYPE_HOP_PARAMS = 8,
694 MFIE_TYPE_HOP_TABLE = 9,
695 MFIE_TYPE_REQUEST = 10,
696 MFIE_TYPE_CHALLENGE = 16,
697 MFIE_TYPE_POWER_CONSTRAINT = 32,
698 MFIE_TYPE_POWER_CAPABILITY = 33,
699 MFIE_TYPE_TPC_REQUEST = 34,
700 MFIE_TYPE_TPC_REPORT = 35,
701 MFIE_TYPE_SUPP_CHANNELS = 36,
703 MFIE_TYPE_MEASURE_REQUEST = 38,
704 MFIE_TYPE_MEASURE_REPORT = 39,
705 MFIE_TYPE_QUIET = 40,
706 MFIE_TYPE_IBSS_DFS = 41,
708 MFIE_TYPE_HT_CAP = 45,
710 MFIE_TYPE_RATES_EX = 50,
711 MFIE_TYPE_HT_INFO = 61,
712 MFIE_TYPE_AIRONET = 133,
713 MFIE_TYPE_GENERIC = 221,
714 MFIE_TYPE_QOS_PARAMETER = 222,
717 /* Minimal header; can be used for passing 802.11 frames with sufficient
718 * information to determine what type of underlying data type is actually
719 * stored in the data.
721 struct rtllib_pspoll_hdr {
734 struct rtllib_hdr_1addr {
741 struct rtllib_hdr_2addr {
749 struct rtllib_hdr_3addr {
759 struct rtllib_hdr_4addr {
770 struct rtllib_hdr_3addrqos {
781 struct rtllib_hdr_4addrqos {
793 struct rtllib_info_element {
799 struct rtllib_authentication {
800 struct rtllib_hdr_3addr header;
805 struct rtllib_info_element info_element[];
808 struct rtllib_disauth {
809 struct rtllib_hdr_3addr header;
813 struct rtllib_disassoc {
814 struct rtllib_hdr_3addr header;
818 struct rtllib_probe_request {
819 struct rtllib_hdr_3addr header;
820 /* SSID, supported rates */
821 struct rtllib_info_element info_element[];
824 struct rtllib_probe_response {
825 struct rtllib_hdr_3addr header;
827 __le16 beacon_interval;
829 /* SSID, supported rates, FH params, DS params,
830 * CF params, IBSS params, TIM (if beacon), RSN
832 struct rtllib_info_element info_element[];
835 /* Alias beacon for probe_response */
836 #define rtllib_beacon rtllib_probe_response
838 struct rtllib_assoc_request_frame {
839 struct rtllib_hdr_3addr header;
841 __le16 listen_interval;
842 /* SSID, supported rates, RSN */
843 struct rtllib_info_element info_element[];
846 struct rtllib_assoc_response_frame {
847 struct rtllib_hdr_3addr header;
851 struct rtllib_info_element info_element[]; /* supported rates */
862 struct sk_buff *fragments[];
865 #define MAX_SUBFRAME_COUNT 64
868 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
885 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
886 * only use 8, and then use extended rates for the remaining supported
887 * rates. Other APs, however, stick all of their supported rates on the
888 * main rates information element...
890 #define MAX_RATES_LENGTH ((u8)12)
891 #define MAX_RATES_EX_LENGTH ((u8)16)
892 #define MAX_NETWORK_COUNT 96
894 #define MAX_CHANNEL_NUMBER 161
895 #define RTLLIB_SOFTMAC_SCAN_TIME 100
896 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
898 #define MAX_WPA_IE_LEN 64
899 #define MAX_WZC_IE_LEN 256
901 #define NETWORK_EMPTY_ESSID (1<<0)
902 #define NETWORK_HAS_OFDM (1<<1)
903 #define NETWORK_HAS_CCK (1<<2)
906 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
907 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
908 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
909 NETWORK_HAS_QOS_INFORMATION)
911 #define NETWORK_HAS_ERP_VALUE (1<<10)
913 #define QOS_QUEUE_NUM 4
914 #define QOS_OUI_LEN 3
915 #define QOS_OUI_TYPE 2
916 #define QOS_ELEMENT_ID 221
917 #define QOS_OUI_INFO_SUB_TYPE 0
918 #define QOS_OUI_PARAM_SUB_TYPE 1
919 #define QOS_VERSION_1 1
921 struct rtllib_qos_information_element {
931 struct rtllib_qos_ac_parameter {
937 struct rtllib_qos_parameter_info {
938 struct rtllib_qos_information_element info_element;
940 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
943 struct rtllib_qos_parameters {
944 __le16 cw_min[QOS_QUEUE_NUM];
945 __le16 cw_max[QOS_QUEUE_NUM];
946 u8 aifs[QOS_QUEUE_NUM];
947 u8 flag[QOS_QUEUE_NUM];
948 __le16 tx_op_limit[QOS_QUEUE_NUM];
951 struct rtllib_qos_data {
952 struct rtllib_qos_parameters parameters;
953 unsigned int wmm_acm;
960 struct rtllib_tim_parameters {
965 struct rtllib_wmm_ac_param {
976 EAPOL_ENCAP_ASF_ALERT
979 static const char * const eap_types[] = {
980 [EAP_PACKET] = "EAP-Packet",
981 [EAPOL_START] = "EAPOL-Start",
982 [EAPOL_LOGOFF] = "EAPOL-Logoff",
983 [EAPOL_KEY] = "EAPOL-Key",
984 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
987 static inline const char *eap_get_type(int type)
989 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
992 static inline u8 Frame_QoSTID(u8 *buf)
994 struct rtllib_hdr_3addr *hdr;
997 hdr = (struct rtllib_hdr_3addr *)buf;
998 fc = le16_to_cpu(hdr->frame_ctl);
999 return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
1000 (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1012 struct rtllib_softmac_stats {
1013 unsigned int rx_ass_ok;
1014 unsigned int rx_ass_err;
1015 unsigned int rx_probe_rq;
1016 unsigned int tx_probe_rs;
1017 unsigned int tx_beacons;
1018 unsigned int rx_auth_rq;
1019 unsigned int rx_auth_rs_ok;
1020 unsigned int rx_auth_rs_err;
1021 unsigned int tx_auth_rq;
1022 unsigned int no_auth_rs;
1023 unsigned int no_ass_rs;
1024 unsigned int tx_ass_rq;
1025 unsigned int rx_ass_rq;
1026 unsigned int tx_probe_rq;
1027 unsigned int reassoc;
1028 unsigned int swtxstop;
1029 unsigned int swtxawake;
1030 unsigned char CurrentShowTxate;
1031 unsigned char last_packet_rate;
1032 unsigned int txretrycount;
1035 /* These are the data types that can make up management packets
1037 * u16 auth_algorithm;
1038 * u16 auth_sequence;
1039 * u16 beacon_interval;
1041 * u8 current_ap[ETH_ALEN];
1042 * u16 listen_interval;
1044 * u16 association_id:14, reserved:2;
1046 * u32 time_stamp[2];
1051 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1052 #define RTLLIB_DEFAULT_BASIC_RATE 2
1054 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1055 #define MAX_SP_Len (WMM_all_frame << 4)
1056 #define RTLLIB_QOS_TID 0x0f
1057 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1059 #define RTLLIB_DTIM_MBCAST 4
1060 #define RTLLIB_DTIM_UCAST 2
1061 #define RTLLIB_DTIM_VALID 1
1062 #define RTLLIB_DTIM_INVALID 0
1064 #define RTLLIB_PS_DISABLED 0
1065 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1066 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1068 #define WME_AC_BK 0x00
1069 #define WME_AC_BE 0x01
1070 #define WME_AC_VI 0x02
1071 #define WME_AC_VO 0x03
1072 #define WME_AC_PRAM_LEN 16
1074 #define MAX_RECEIVE_BUFFER_SIZE 9100
1076 #define UP2AC(up) ( \
1077 ((up) < 1) ? WME_AC_BE : \
1078 ((up) < 3) ? WME_AC_BK : \
1079 ((up) < 4) ? WME_AC_BE : \
1080 ((up) < 6) ? WME_AC_VI : \
1083 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1084 #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
1089 ERP_NonERPpresent = 0x01,
1090 ERP_UseProtection = 0x02,
1091 ERP_BarkerPreambleMode = 0x04,
1094 struct rtllib_network {
1095 /* These entries are used to identify a unique network */
1098 /* Ensure null-terminated for any debug msgs */
1099 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1101 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
1103 struct rtllib_qos_data qos_data;
1105 bool bWithAironetIE;
1106 bool bCkipSupported;
1111 u8 MBssid[ETH_ALEN];
1112 bool bWithCcxVerNum;
1114 /* These are network statistics */
1115 struct rtllib_rx_stats stats;
1117 u8 rates[MAX_RATES_LENGTH];
1119 u8 rates_ex[MAX_RATES_EX_LENGTH];
1121 unsigned long last_scanned;
1125 u16 beacon_interval;
1126 u16 listen_interval;
1129 u8 wpa_ie[MAX_WPA_IE_LEN];
1131 u8 rsn_ie[MAX_WPA_IE_LEN];
1133 u8 wzc_ie[MAX_WZC_IE_LEN];
1136 struct rtllib_tim_parameters tim;
1139 u64 last_dtim_sta_time;
1142 struct rtllib_wmm_ac_param wmm_param[4];
1145 u8 CountryIeBuf[MAX_IE_LEN];
1146 struct bss_ht bssht;
1147 bool broadcom_cap_exist;
1148 bool realtek_cap_exit;
1149 bool marvell_cap_exist;
1150 bool ralink_cap_exist;
1151 bool atheros_cap_exist;
1152 bool cisco_cap_exist;
1153 bool airgo_cap_exist;
1154 bool unknown_cap_exist;
1155 bool berp_info_valid;
1156 bool buseprotection;
1159 struct list_head list;
1164 /* the card is not linked at all */
1167 /* RTLLIB_ASSOCIATING* are for BSS client mode
1168 * the driver shall not perform RX filtering unless
1169 * the state is LINKED.
1170 * The driver shall just check for the state LINKED and
1171 * defaults to NOLINK for ALL the other states (including
1175 /* the association procedure will start (wq scheduling)*/
1177 RTLLIB_ASSOCIATING_RETRY,
1179 /* the association procedure is sending AUTH request*/
1180 RTLLIB_ASSOCIATING_AUTHENTICATING,
1182 /* the association procedure has successfully authenticated
1183 * and is sending association request
1185 RTLLIB_ASSOCIATING_AUTHENTICATED,
1187 /* the link is ok. the card associated to a BSS or linked
1188 * to a ibss cell or acting as an AP and creating the bss
1192 /* same as LINKED, but the driver shall apply RX filter
1193 * rules as we are in NO_LINK mode. As the card is still
1194 * logically linked, but it is doing a syncro site survey
1195 * then it will be back to LINKED state.
1197 RTLLIB_LINKED_SCANNING,
1200 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1201 #define DEFAULT_FTS 2346
1203 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1204 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1208 struct rtllib_txb *txb;
1211 struct bandwidth_autoswitch {
1212 long threshold_20Mhzto40Mhz;
1213 long threshold_40Mhzto20Mhz;
1214 bool bforced_tx20Mhz;
1215 bool bautoswitch_enable;
1220 #define REORDER_WIN_SIZE 128
1221 #define REORDER_ENTRY_NUM 128
1222 struct rx_reorder_entry {
1223 struct list_head List;
1225 struct rtllib_rxb *prxb;
1240 enum ips_callback_function {
1241 IPS_CALLBACK_NONE = 0,
1242 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1243 IPS_CALLBACK_JOIN_REQUEST = 2,
1246 enum rt_rf_power_state {
1252 struct rt_pwr_save_ctrl {
1253 bool bSwRfProcessing;
1254 enum rt_rf_power_state eInactivePowerState;
1255 enum ips_callback_function ReturnPoint;
1259 u8 reg_max_lps_awake_intvl;
1266 #define RT_RF_CHANGE_SOURCE u32
1268 #define RF_CHANGE_BY_SW BIT31
1269 #define RF_CHANGE_BY_HW BIT30
1270 #define RF_CHANGE_BY_PS BIT29
1271 #define RF_CHANGE_BY_IPS BIT28
1272 #define RF_CHANGE_BY_INIT 0
1274 enum country_code_type {
1275 COUNTRY_CODE_FCC = 0,
1276 COUNTRY_CODE_IC = 1,
1277 COUNTRY_CODE_ETSI = 2,
1278 COUNTRY_CODE_SPAIN = 3,
1279 COUNTRY_CODE_FRANCE = 4,
1280 COUNTRY_CODE_MKK = 5,
1281 COUNTRY_CODE_MKK1 = 6,
1282 COUNTRY_CODE_ISRAEL = 7,
1283 COUNTRY_CODE_TELEC = 8,
1284 COUNTRY_CODE_MIC = 9,
1285 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1286 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1287 COUNTRY_CODE_TELEC_NETGEAR = 12,
1291 enum scan_op_backup_opt {
1292 SCAN_OPT_BACKUP = 0,
1297 enum fw_cmd_io_type {
1298 FW_CMD_DIG_ENABLE = 0,
1299 FW_CMD_DIG_DISABLE = 1,
1300 FW_CMD_DIG_HALT = 2,
1301 FW_CMD_DIG_RESUME = 3,
1302 FW_CMD_HIGH_PWR_ENABLE = 4,
1303 FW_CMD_HIGH_PWR_DISABLE = 5,
1304 FW_CMD_RA_RESET = 6,
1305 FW_CMD_RA_ACTIVE = 7,
1306 FW_CMD_RA_REFRESH_N = 8,
1307 FW_CMD_RA_REFRESH_BG = 9,
1308 FW_CMD_RA_INIT = 10,
1309 FW_CMD_IQK_ENABLE = 11,
1310 FW_CMD_TXPWR_TRACK_ENABLE = 12,
1311 FW_CMD_TXPWR_TRACK_DISABLE = 13,
1312 FW_CMD_TXPWR_TRACK_THERMAL = 14,
1313 FW_CMD_PAUSE_DM_BY_SCAN = 15,
1314 FW_CMD_RESUME_DM_BY_SCAN = 16,
1315 FW_CMD_RA_REFRESH_N_COMB = 17,
1316 FW_CMD_RA_REFRESH_BG_COMB = 18,
1317 FW_CMD_ANTENNA_SW_ENABLE = 19,
1318 FW_CMD_ANTENNA_SW_DISABLE = 20,
1319 FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
1320 FW_CMD_LPS_ENTER = 22,
1321 FW_CMD_LPS_LEAVE = 23,
1324 #define RT_MAX_LD_SLOT_NUM 10
1325 struct rt_link_detect {
1327 u32 NumRecvBcnInPeriod;
1328 u32 NumRecvDataInPeriod;
1330 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1331 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1335 u32 NumTxOkInPeriod;
1336 u32 NumRxOkInPeriod;
1337 u32 NumRxUnicastOkInPeriod;
1339 bool bHigherBusyTraffic;
1340 bool bHigherBusyRxTraffic;
1343 struct sw_cam_table {
1345 u8 macaddr[ETH_ALEN];
1353 #define TOTAL_CAM_ENTRY 32
1354 struct rate_adaptive {
1355 u8 rate_adaptive_disabled;
1359 u32 high_rssi_thresh_for_ra;
1360 u32 high2low_rssi_thresh_for_ra;
1361 u8 low2high_rssi_thresh_for_ra40M;
1362 u32 low_rssi_thresh_for_ra40M;
1363 u8 low2high_rssi_thresh_for_ra20M;
1364 u32 low_rssi_thresh_for_ra20M;
1365 u32 upper_rssi_threshold_ratr;
1366 u32 middle_rssi_threshold_ratr;
1367 u32 low_rssi_threshold_ratr;
1368 u32 low_rssi_threshold_ratr_40M;
1369 u32 low_rssi_threshold_ratr_20M;
1370 u8 ping_rssi_enable;
1372 u32 ping_rssi_thresh_for_ra;
1378 #define NUM_PMKID_CACHE 16
1379 struct rt_pmkid_list {
1386 struct rt_intel_promisc_mode {
1387 bool promiscuous_on;
1388 bool fltr_src_sta_frame;
1392 /*************** DRIVER STATUS *****/
1393 #define STATUS_SCANNING 0
1394 /*************** DRIVER STATUS *****/
1399 LPS_WAIT_NULL_DATA_SEND = 2,
1402 struct rtllib_device {
1403 struct pci_dev *pdev;
1404 struct net_device *dev;
1405 struct rtllib_security sec;
1407 bool disable_mgnt_queue;
1409 unsigned long status;
1412 enum rt_op_mode OpMode;
1414 /* The last AssocReq/Resp IEs */
1415 u8 *assocreq_ies, *assocresp_ies;
1416 size_t assocreq_ies_len, assocresp_ies_len;
1422 bool is_silent_reset;
1426 bool bSupportRemoteWakeUp;
1428 bool FirstIe_InScan;
1429 bool be_scan_inprogress;
1431 enum rt_rf_power_state rf_power_state;
1432 RT_RF_CHANGE_SOURCE rf_off_reason;
1435 struct rt_hi_throughput *ht_info;
1437 spinlock_t reorder_spinlock;
1438 u8 reg_dot11ht_oper_rate_set[16];
1439 u8 reg_dot11tx_ht_oper_rate_set[16];
1440 u8 dot11ht_oper_rate_set[16];
1441 u8 reg_ht_supp_rate_set[16];
1442 u8 HTCurrentOperaRate;
1443 u8 HTHighestOperaRate;
1444 u8 tx_dis_rate_fallback;
1445 u8 tx_use_drv_assinged_rate;
1446 u8 bTxEnableFwCalcDur;
1449 struct list_head Tx_TS_Admit_List;
1450 struct list_head Tx_TS_Pending_List;
1451 struct list_head Tx_TS_Unused_List;
1452 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
1453 struct list_head Rx_TS_Admit_List;
1454 struct list_head Rx_TS_Pending_List;
1455 struct list_head Rx_TS_Unused_List;
1456 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
1457 struct rx_reorder_entry RxReorderEntry[128];
1458 struct list_head RxReorder_Unused_List;
1461 /* Bookkeeping structures */
1462 struct net_device_stats stats;
1463 struct rtllib_softmac_stats softmac_stats;
1465 /* Probe / Beacon management */
1466 struct list_head network_free_list;
1467 struct list_head network_list;
1468 struct rtllib_network *networks;
1472 int iw_mode; /* operating mode (IW_MODE_*) */
1473 bool net_promiscuous_md;
1474 struct rt_intel_promisc_mode intel_promiscuous_md_info;
1477 spinlock_t wpax_suitlist_lock;
1479 int tx_headroom; /* Set to size of any additional room needed at front
1480 * of allocated Tx SKBs
1484 /* WEP and other encryption related settings at the device level */
1485 int open_wep; /* Set to 1 to allow unencrypted frames */
1487 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1491 /* If the host performs {en,de}cryption, then set to 1 */
1495 int ieee802_1x; /* is IEEE 802.1X used */
1498 bool bHalfWirelessN24GMode;
1500 int drop_unencrypted;
1501 int tkip_countermeasures;
1502 int privacy_invoked;
1507 u8 ap_mac_addr[ETH_ALEN];
1508 u16 pairwise_key_type;
1511 struct lib80211_crypt_info crypt_info;
1513 struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
1515 struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
1517 /* Fragmentation structures */
1518 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
1519 unsigned int frag_next_idx[17];
1520 u16 fts; /* Fragmentation Threshold */
1521 #define DEFAULT_RTS_THRESHOLD 2346U
1522 #define MIN_RTS_THRESHOLD 1
1523 #define MAX_RTS_THRESHOLD 2346U
1524 u16 rts; /* RTS threshold */
1526 /* Association info */
1529 /* This stores infos for the current network.
1530 * Either the network we are associated in INFRASTRUCTURE
1531 * or the network that we are creating in MASTER mode.
1532 * ad-hoc is a mixture ;-).
1533 * Note that in infrastructure mode, even when not associated,
1534 * fields bssid and essid may be valid (if wpa_set and essid_set
1535 * are true) as thy carry the value set by the user via iwconfig
1537 struct rtllib_network current_network;
1539 enum rtllib_state state;
1542 int mode; /* A, B, G */
1543 int modulation; /* CCK, OFDM */
1545 /* used for forcing the ibss workqueue to terminate
1546 * without wait for the syncro scan to terminate
1548 short sync_scan_hurryup;
1551 /* map of allowed channels. 0 is dummy */
1554 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
1556 u8 bss_start_channel;
1557 u8 ibss_maxjoin_chal;
1559 int rate; /* current rate */
1564 /* this contains flags for selectively enable softmac support */
1565 u16 softmac_features;
1567 /* if the sequence control field is not filled by HW */
1570 /* association procedure transaction sequence number */
1573 /* AID for RTXed association responses */
1576 /* power save mode related*/
1582 struct work_struct ps_task;
1587 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1589 short scanning_continue;
1590 short proto_started;
1591 short proto_stoppping;
1593 struct mutex wx_mutex;
1594 struct mutex scan_mutex;
1595 struct mutex ips_mutex;
1597 spinlock_t mgmt_tx_lock;
1598 spinlock_t beacon_lock;
1605 /* set on initialization */
1606 unsigned int wmm_acm;
1608 /* for discarding duplicated packets in IBSS */
1609 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1611 /* for discarding duplicated packets in BSS */
1612 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1613 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1614 unsigned long last_packet_time[17];
1617 unsigned long last_rx_ps_time;
1621 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1622 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1623 int mgmt_queue_head;
1624 int mgmt_queue_tail;
1626 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1628 bool bdynamic_txpower_enable;
1630 bool bCTSToSelfEnable;
1632 u32 fsync_time_interval;
1633 u32 fsync_rate_bitmap;
1634 u8 fsync_rssi_threshold;
1637 u8 fsync_multiple_timeinterval;
1638 u32 fsync_firstdiff_ratethreshold;
1639 u32 fsync_seconddiff_ratethreshold;
1640 enum fsync_state fsync_state;
1641 bool bis_any_nonbepkts;
1642 struct bandwidth_autoswitch bandwidth_auto_switch;
1645 struct rt_link_detect link_detect_info;
1646 bool bIsAggregateFrame;
1647 struct rt_pwr_save_ctrl pwr_save_ctrl;
1649 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1650 struct tx_pending tx_pending;
1652 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1653 struct timer_list associate_timer;
1655 /* used if IEEE_SOFTMAC_BEACONS is set */
1656 struct timer_list beacon_timer;
1658 struct work_struct associate_complete_wq;
1659 struct work_struct ips_leave_wq;
1660 struct delayed_work associate_procedure_wq;
1661 struct delayed_work softmac_scan_wq;
1662 struct delayed_work associate_retry_wq;
1663 struct delayed_work start_ibss_wq;
1664 struct delayed_work hw_wakeup_wq;
1665 struct delayed_work hw_sleep_wq;
1666 struct delayed_work link_change_wq;
1667 struct work_struct wx_sync_scan_wq;
1670 struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
1671 struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1672 struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
1674 struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
1675 struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
1676 struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
1680 /* Callback functions */
1681 void (*set_security)(struct net_device *dev,
1682 struct rtllib_security *sec);
1684 /* Used to TX data frame by using txb structs.
1685 * this is not used if in the softmac_features
1686 * is set the flag IEEE_SOFTMAC_TX_QUEUE
1688 int (*hard_start_xmit)(struct rtllib_txb *txb,
1689 struct net_device *dev);
1691 int (*reset_port)(struct net_device *dev);
1693 /* Softmac-generated frames (management) are TXed via this
1694 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1695 * not set. As some cards may have different HW queues that
1696 * one might want to use for data and management frames
1697 * the option to have two callbacks might be useful.
1698 * This function can't sleep.
1700 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1701 struct net_device *dev);
1703 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1704 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1705 * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1706 * then also management frames are sent via this callback.
1707 * This function can't sleep.
1709 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1710 struct net_device *dev, int rate);
1712 /* stops the HW queue for DATA frames. Useful to avoid
1713 * waste time to TX data frame when we are reassociating
1714 * This function can sleep.
1716 void (*data_hard_stop)(struct net_device *dev);
1718 /* OK this is complementing to data_poll_hard_stop */
1719 void (*data_hard_resume)(struct net_device *dev);
1721 /* ask to the driver to retune the radio.
1722 * This function can sleep. the driver should ensure
1723 * the radio has been switched before return.
1725 void (*set_chan)(struct net_device *dev, short ch);
1727 void (*rtllib_start_hw_scan)(struct net_device *dev);
1728 void (*rtllib_stop_hw_scan)(struct net_device *dev);
1730 /* indicate the driver that the link state is changed
1731 * for example it may indicate the card is associated now.
1732 * Driver might be interested in this to apply RX filter
1733 * rules or simply light the LINK led
1735 void (*link_change)(struct net_device *dev);
1737 /* these two function indicates to the HW when to start
1738 * and stop to send beacons. This is used when the
1739 * IEEE_SOFTMAC_BEACONS is not set. For now the
1740 * stop_send_bacons is NOT guaranteed to be called only
1741 * after start_send_beacons.
1743 void (*start_send_beacons)(struct net_device *dev);
1744 void (*stop_send_beacons)(struct net_device *dev);
1746 /* power save mode related */
1747 void (*sta_wake_up)(struct net_device *dev);
1748 void (*enter_sleep_state)(struct net_device *dev, u64 time);
1749 short (*ps_is_queue_empty)(struct net_device *dev);
1750 int (*handle_beacon)(struct net_device *dev,
1751 struct rtllib_beacon *beacon,
1752 struct rtllib_network *network);
1753 int (*handle_assoc_response)(struct net_device *dev,
1754 struct rtllib_assoc_response_frame *resp,
1755 struct rtllib_network *network);
1758 /* check whether Tx hw resource available */
1759 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1760 void (*SetBWModeHandler)(struct net_device *dev,
1761 enum ht_channel_width bandwidth,
1762 enum ht_extchnl_offset Offset);
1763 bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
1764 void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
1765 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
1766 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
1767 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
1768 bool (*SetFwCmdHandler)(struct net_device *dev,
1769 enum fw_cmd_io_type FwCmdIO);
1770 void (*UpdateBeaconInterruptHandler)(struct net_device *dev,
1772 void (*ScanOperationBackupHandler)(struct net_device *dev,
1774 void (*LedControlHandler)(struct net_device *dev,
1775 enum led_ctl_mode LedAction);
1776 void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
1778 void (*AllowAllDestAddrHandler)(struct net_device *dev,
1779 bool bAllowAllDA, bool WriteIntoReg);
1781 void (*rtllib_ips_leave_wq)(struct net_device *dev);
1782 void (*rtllib_ips_leave)(struct net_device *dev);
1783 void (*LeisurePSLeave)(struct net_device *dev);
1785 /* This must be the last item so that it points to the data
1786 * allocated beyond this structure by alloc_rtllib
1791 #define IEEE_A (1<<0)
1792 #define IEEE_B (1<<1)
1793 #define IEEE_G (1<<2)
1794 #define IEEE_N_24G (1<<4)
1795 #define IEEE_N_5G (1<<5)
1796 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
1798 /* Generate a 802.11 header */
1800 /* Uses the channel change callback directly
1801 * instead of [start/stop] scan callbacks
1803 #define IEEE_SOFTMAC_SCAN (1<<2)
1805 /* Perform authentication and association handshake */
1806 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1808 /* Generate probe requests */
1809 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1811 /* Generate response to probe requests */
1812 #define IEEE_SOFTMAC_PROBERS (1<<5)
1814 /* The ieee802.11 stack will manage the netif queue
1815 * wake/stop for the driver, taking care of 802.11
1816 * fragmentation. See softmac.c for details.
1818 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1820 /* Uses only the softmac_data_hard_start_xmit
1821 * even for TX management frames.
1823 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1825 /* Generate beacons. The stack will enqueue beacons
1828 #define IEEE_SOFTMAC_BEACONS (1<<6)
1831 static inline void *rtllib_priv(struct net_device *dev)
1833 return ((struct rtllib_device *)netdev_priv(dev))->priv;
1836 static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
1838 /* Single white space is for Linksys APs */
1839 if (essid_len == 1 && essid[0] == ' ')
1842 /* Otherwise, if the entire essid is 0, we assume it is hidden */
1845 if (essid[essid_len] != '\0')
1852 static inline int rtllib_get_hdrlen(u16 fc)
1854 int hdrlen = RTLLIB_3ADDR_LEN;
1856 switch (WLAN_FC_GET_TYPE(fc)) {
1857 case RTLLIB_FTYPE_DATA:
1858 if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
1859 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
1860 if (RTLLIB_QOS_HAS_SEQ(fc))
1861 hdrlen += 2; /* QOS ctrl*/
1863 case RTLLIB_FTYPE_CTL:
1864 switch (WLAN_FC_GET_STYPE(fc)) {
1865 case RTLLIB_STYPE_CTS:
1866 case RTLLIB_STYPE_ACK:
1867 hdrlen = RTLLIB_1ADDR_LEN;
1870 hdrlen = RTLLIB_2ADDR_LEN;
1879 static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
1881 switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
1882 case RTLLIB_1ADDR_LEN:
1883 return ((struct rtllib_hdr_1addr *)hdr)->payload;
1884 case RTLLIB_2ADDR_LEN:
1885 return ((struct rtllib_hdr_2addr *)hdr)->payload;
1886 case RTLLIB_3ADDR_LEN:
1887 return ((struct rtllib_hdr_3addr *)hdr)->payload;
1888 case RTLLIB_4ADDR_LEN:
1889 return ((struct rtllib_hdr_4addr *)hdr)->payload;
1894 static inline int rtllib_is_ofdm_rate(u8 rate)
1896 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1897 case RTLLIB_OFDM_RATE_6MB:
1898 case RTLLIB_OFDM_RATE_9MB:
1899 case RTLLIB_OFDM_RATE_12MB:
1900 case RTLLIB_OFDM_RATE_18MB:
1901 case RTLLIB_OFDM_RATE_24MB:
1902 case RTLLIB_OFDM_RATE_36MB:
1903 case RTLLIB_OFDM_RATE_48MB:
1904 case RTLLIB_OFDM_RATE_54MB:
1910 static inline int rtllib_is_cck_rate(u8 rate)
1912 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1913 case RTLLIB_CCK_RATE_1MB:
1914 case RTLLIB_CCK_RATE_2MB:
1915 case RTLLIB_CCK_RATE_5MB:
1916 case RTLLIB_CCK_RATE_11MB:
1924 void free_rtllib(struct net_device *dev);
1925 struct net_device *alloc_rtllib(int sizeof_priv);
1929 int rtllib_encrypt_fragment(
1930 struct rtllib_device *ieee,
1931 struct sk_buff *frag,
1934 netdev_tx_t rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
1935 void rtllib_txb_free(struct rtllib_txb *txb);
1938 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
1939 struct rtllib_rx_stats *rx_stats);
1940 void rtllib_rx_probe_rq(struct rtllib_device *ieee,
1941 struct sk_buff *skb);
1942 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
1945 int rtllib_wx_get_scan(struct rtllib_device *ieee,
1946 struct iw_request_info *info,
1947 union iwreq_data *wrqu, char *key);
1948 int rtllib_wx_set_encode(struct rtllib_device *ieee,
1949 struct iw_request_info *info,
1950 union iwreq_data *wrqu, char *key);
1951 int rtllib_wx_get_encode(struct rtllib_device *ieee,
1952 struct iw_request_info *info,
1953 union iwreq_data *wrqu, char *key);
1954 int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
1955 struct iw_request_info *info,
1956 union iwreq_data *wrqu, char *extra);
1957 int rtllib_wx_set_auth(struct rtllib_device *ieee,
1958 struct iw_request_info *info,
1959 struct iw_param *data, char *extra);
1960 int rtllib_wx_set_mlme(struct rtllib_device *ieee,
1961 struct iw_request_info *info,
1962 union iwreq_data *wrqu, char *extra);
1963 int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
1965 /* rtllib_softmac.c */
1966 int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb,
1967 struct rtllib_rx_stats *rx_stats, u16 type,
1969 void rtllib_softmac_new_net(struct rtllib_device *ieee,
1970 struct rtllib_network *net);
1972 void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
1973 void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
1975 void rtllib_start_ibss(struct rtllib_device *ieee);
1976 int rtllib_softmac_init(struct rtllib_device *ieee);
1977 void rtllib_softmac_free(struct rtllib_device *ieee);
1978 void rtllib_disassociate(struct rtllib_device *ieee);
1979 void rtllib_stop_scan(struct rtllib_device *ieee);
1980 bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
1981 void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
1982 void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
1983 void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr);
1984 void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
1985 void rtllib_start_protocol(struct rtllib_device *ieee);
1986 void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
1988 void rtllib_EnableNetMonitorMode(struct net_device *dev, bool bInitState);
1989 void rtllib_DisableNetMonitorMode(struct net_device *dev, bool bInitState);
1990 void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, bool bInitState);
1991 void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
1993 void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
1994 u8 mesh_flag, u8 shutdown);
1995 void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag);
1997 void rtllib_reset_queue(struct rtllib_device *ieee);
1998 void rtllib_wake_all_queues(struct rtllib_device *ieee);
1999 void rtllib_stop_all_queues(struct rtllib_device *ieee);
2000 struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
2001 void rtllib_start_send_beacons(struct rtllib_device *ieee);
2002 void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2004 void notify_wx_assoc_event(struct rtllib_device *ieee);
2005 void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
2007 void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee);
2008 u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
2010 /* rtllib_softmac_wx.c */
2012 int rtllib_wx_get_wap(struct rtllib_device *ieee, struct iw_request_info *info,
2013 union iwreq_data *wrqu, char *ext);
2015 int rtllib_wx_set_wap(struct rtllib_device *ieee, struct iw_request_info *info,
2016 union iwreq_data *awrq, char *extra);
2018 int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,
2019 union iwreq_data *wrqu, char *b);
2021 int rtllib_wx_set_rate(struct rtllib_device *ieee, struct iw_request_info *info,
2022 union iwreq_data *wrqu, char *extra);
2024 int rtllib_wx_get_rate(struct rtllib_device *ieee, struct iw_request_info *info,
2025 union iwreq_data *wrqu, char *extra);
2027 int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a,
2028 union iwreq_data *wrqu, char *b);
2030 int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a,
2031 union iwreq_data *wrqu, char *b);
2033 int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a,
2034 union iwreq_data *wrqu, char *extra);
2036 int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a,
2037 union iwreq_data *wrqu, char *b);
2039 int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
2040 union iwreq_data *wrqu, char *b);
2042 int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a,
2043 union iwreq_data *wrqu, char *b);
2044 void rtllib_wx_sync_scan_wq(void *data);
2046 int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
2047 struct iw_request_info *info,
2048 union iwreq_data *wrqu, char *extra);
2050 int rtllib_wx_get_name(struct rtllib_device *ieee, struct iw_request_info *info,
2051 union iwreq_data *wrqu, char *extra);
2053 int rtllib_wx_set_power(struct rtllib_device *ieee,
2054 struct iw_request_info *info,
2055 union iwreq_data *wrqu, char *extra);
2057 int rtllib_wx_get_power(struct rtllib_device *ieee,
2058 struct iw_request_info *info,
2059 union iwreq_data *wrqu, char *extra);
2061 int rtllib_wx_set_rts(struct rtllib_device *ieee, struct iw_request_info *info,
2062 union iwreq_data *wrqu, char *extra);
2064 int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info,
2065 union iwreq_data *wrqu, char *extra);
2066 #define MAX_RECEIVE_BUFFER_SIZE 9100
2068 void HTSetConnectBwMode(struct rtllib_device *ieee,
2069 enum ht_channel_width bandwidth,
2070 enum ht_extchnl_offset Offset);
2071 void HTUpdateDefaultSetting(struct rtllib_device *ieee);
2072 void HTConstructCapabilityElement(struct rtllib_device *ieee,
2073 u8 *posHTCap, u8 *len,
2074 u8 isEncrypt, bool bAssoc);
2075 void HTConstructInfoElement(struct rtllib_device *ieee,
2076 u8 *posHTInfo, u8 *len, u8 isEncrypt);
2077 void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
2078 u8 *posRT2RTAgg, u8 *len);
2079 void HTOnAssocRsp(struct rtllib_device *ieee);
2080 void HTInitializeHTInfo(struct rtllib_device *ieee);
2081 void HTInitializeBssDesc(struct bss_ht *pBssHT);
2082 void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
2083 struct rtllib_network *pNetwork);
2084 void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
2085 struct rtllib_network *pNetwork);
2086 u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
2088 extern u8 MCS_FILTER_ALL[];
2089 extern u16 MCS_DATA_RATE[2][2][77];
2090 u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
2091 void HTResetIOTSetting(struct rt_hi_throughput *ht_info);
2092 bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
2093 u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
2094 int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
2095 int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
2096 int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
2097 void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
2098 u8 Policy, u8 bOverwritePending);
2099 void TsInitDelBA(struct rtllib_device *ieee,
2100 struct ts_common_info *pTsCommonInfo,
2101 enum tr_select TxRxSelect);
2102 void BaSetupTimeOut(struct timer_list *t);
2103 void TxBaInactTimeout(struct timer_list *t);
2104 void RxBaInactTimeout(struct timer_list *t);
2105 void ResetBaEntry(struct ba_record *pBA);
2106 bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 *Addr,
2107 u8 TID, enum tr_select TxRxSelect, bool bAddNewTs);
2108 void TSInitialize(struct rtllib_device *ieee);
2109 void TsStartAddBaProcess(struct rtllib_device *ieee,
2110 struct tx_ts_record *pTxTS);
2111 void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
2112 void RemoveAllTS(struct rtllib_device *ieee);
2114 extern const long rtllib_wlan_frequencies[];
2116 static inline const char *escape_essid(const char *essid, u8 essid_len)
2118 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2120 if (rtllib_is_empty_essid(essid, essid_len)) {
2121 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2125 snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
2129 /* fun with the built-in rtllib stack... */
2130 bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
2133 /* For the function is more related to hardware setting, it's better to use the
2134 * ieee handler to refer to it.
2136 void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
2137 struct rx_ts_record *pTS);
2138 int rtllib_parse_info_param(struct rtllib_device *ieee,
2139 struct rtllib_info_element *info_element,
2141 struct rtllib_network *network,
2142 struct rtllib_rx_stats *stats);
2144 void rtllib_indicate_packets(struct rtllib_device *ieee,
2145 struct rtllib_rxb **prxbIndicateArray, u8 index);
2146 void HTUseDefaultSetting(struct rtllib_device *ieee);
2147 #define RT_ASOC_RETRY_LIMIT 5
2148 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
2150 #endif /* RTLLIB_H */