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
10 * <jkmaline@cc.hut.fi>
11 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
13 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14 * <jketreno@linux.intel.com>
15 * Copyright (c) 2004, Intel Corporation
17 * Modified for Realtek's wi-fi cards by Andrea Merello
18 * <andrea.merello@gmail.com>
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 "rtl819x_HT.h"
35 #include "rtl819x_BA.h"
36 #include "rtl819x_TS.h"
38 #include <linux/netdevice.h>
39 #include <linux/if_arp.h> /* ARPHRD_ETHER */
40 #include <net/cfg80211.h>
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 container_of_dwork_rsl(x, y, z) \
66 container_of(to_delayed_work(x), y, z)
68 static inline void *netdev_priv_rsl(struct net_device *dev)
70 return netdev_priv(dev);
73 #define KEY_TYPE_NA 0x0
74 #define KEY_TYPE_WEP40 0x1
75 #define KEY_TYPE_TKIP 0x2
76 #define KEY_TYPE_CCMP 0x4
77 #define KEY_TYPE_WEP104 0x5
78 /* added for rtl819x tx procedure */
79 #define MAX_QUEUE_SIZE 0x10
89 #define BEACON_QUEUE 8
91 #define IE_CISCO_FLAG_POSITION 0x08
92 #define SUPPORT_CKIP_MIC 0x08
93 #define SUPPORT_CKIP_PK 0x10
94 #define RT_RF_OFF_LEVL_HALT_NIC BIT(3)
95 #define RT_IN_PS_LEVEL(psc, _PS_FLAG) \
96 ((psc->CurPsLevel & _PS_FLAG) ? true : false)
97 #define RT_CLEAR_PS_LEVEL(psc, _PS_FLAG) \
98 (psc->CurPsLevel &= (~(_PS_FLAG)))
100 /* defined for skb cb field */
101 /* At most 28 byte */
103 /* Tx Desc Related flags (8-9) */
106 u8 tx_dis_rate_fallback:1;
107 u8 tx_use_drv_assinged_rate:1;
112 /* Tx Firmware Related flags (10-11)*/
116 u8 bUseShortPreamble:1;
117 u8 tx_enable_fw_calc_dur:1;
124 u8 bRTSUseShortPreamble:1;
131 /* Tx Desc related element(12-19) */
141 /* Tx firmware related element(20-27) */
149 u8 bIsSpecialDataFrame;
155 enum sw_chnl_cmd_id {
157 CmdID_SetTxPowerLevel,
159 CmdID_WritePortUlong,
160 CmdID_WritePortUshort,
161 CmdID_WritePortUchar,
166 enum sw_chnl_cmd_id CmdID;
172 /*--------------------------Define -------------------------------------------*/
175 #define MGN_5_5M 0x0b
187 #define MGN_MCS0 0x80
188 #define MGN_MCS1 0x81
189 #define MGN_MCS2 0x82
190 #define MGN_MCS3 0x83
191 #define MGN_MCS4 0x84
192 #define MGN_MCS5 0x85
193 #define MGN_MCS6 0x86
194 #define MGN_MCS7 0x87
195 #define MGN_MCS8 0x88
196 #define MGN_MCS9 0x89
197 #define MGN_MCS10 0x8a
198 #define MGN_MCS11 0x8b
199 #define MGN_MCS12 0x8c
200 #define MGN_MCS13 0x8d
201 #define MGN_MCS14 0x8e
202 #define MGN_MCS15 0x8f
206 HW_VAR_MULTICAST_REG,
210 HW_VAR_SECURITY_CONF,
211 HW_VAR_BEACON_INTERVAL,
213 HW_VAR_LISTEN_INTERVAL,
226 HW_VAR_RATE_FALLBACK_CONTROL,
227 HW_VAR_CONTENTION_WINDOW,
232 HW_VAR_AMPDU_MIN_SPACE,
233 HW_VAR_SHORTGI_DENSITY,
235 HW_VAR_MCS_RATE_AVAILABLE,
238 HW_VAR_DIS_Req_Qsize,
239 HW_VAR_CCX_CHNL_LOAD,
240 HW_VAR_CCX_NOISE_HISTOGRAM,
247 HW_VAR_SET_DEV_POWER,
257 HW_VAR_USER_CONTROL_TURBO_MODE,
263 HW_VAR_AUTOLOAD_STATUS,
264 HW_VAR_RF_2R_DISABLE,
266 HW_VAR_H2C_FW_PWRMODE,
267 HW_VAR_H2C_FW_JOINBSSRPT,
268 HW_VAR_1X1_RECV_COMBINE,
269 HW_VAR_STOP_SEND_BEACON,
274 HW_VAR_H2C_FW_UPDATE_GTK,
277 HW_VAR_WF_IS_MAC_ADDR,
278 HW_VAR_H2C_FW_OFFLOAD,
281 HW_VAR_HANDLE_FW_C2H,
282 HW_VAR_DL_FW_RSVD_PAGE,
284 HW_VAR_HW_SEQ_ENABLE,
289 HW_VAR_SWITCH_EPHY_WoWLAN,
290 HW_VAR_INT_MIGRATION,
297 RT_OP_MODE_INFRASTRUCTURE,
303 ((priv->rtllib->current_network.mode == WIRELESS_MODE_N_24G) ? 16 : 10)
305 #define MGMT_QUEUE_NUM 5
307 #define MAX_IE_LEN 0xff
309 #define msleep_interruptible_rsl msleep_interruptible
311 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
314 * The figure in section 7.1.2 suggests a body size of up to 2312
315 * bytes is allowed, which is a bit confusing, I suspect this
316 * represents the 2304 bytes of real data, plus a possible 8 bytes of
317 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
319 #define RTLLIB_1ADDR_LEN 10
320 #define RTLLIB_2ADDR_LEN 16
321 #define RTLLIB_3ADDR_LEN 24
322 #define RTLLIB_4ADDR_LEN 30
323 #define RTLLIB_FCS_LEN 4
325 #define RTLLIB_SKBBUFFER_SIZE 2500
327 #define MIN_FRAG_THRESHOLD 256U
328 #define MAX_FRAG_THRESHOLD 2346U
330 #define RTLLIB_FTYPE_MGMT 0x0000
331 #define RTLLIB_FTYPE_CTL 0x0004
332 #define RTLLIB_FTYPE_DATA 0x0008
334 #define RTLLIB_SCTL_FRAG 0x000F
335 #define RTLLIB_SCTL_SEQ 0xFFF0
338 #define RTLLIB_QCTL_TID 0x000F
340 #define FC_QOS_BIT BIT(7)
341 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
342 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
343 #define IsQoSDataFrame(pframe) \
344 ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
345 (IEEE80211_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
346 #define Frame_Order(pframe) (*(u16 *)pframe&IEEE80211_FCTL_ORDER)
347 #define SN_LESS(a, b) (((a-b)&0x800) != 0)
348 #define SN_EQUAL(a, b) (a == b)
349 #define MAX_DEV_ADDR_SIZE 8
365 enum init_gain_op_type {
372 WIRELESS_MODE_UNKNOWN = 0x00,
373 WIRELESS_MODE_A = 0x01,
374 WIRELESS_MODE_B = 0x02,
375 WIRELESS_MODE_G = 0x04,
376 WIRELESS_MODE_AUTO = 0x08,
377 WIRELESS_MODE_N_24G = 0x10,
381 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
382 #define ETH_P_IP 0x0800 /* Internet Protocol packet */
383 #define ETH_P_ARP 0x0806 /* Address Resolution packet */
384 #endif /* ETH_P_PAE */
386 #ifndef ETH_P_80211_RAW
387 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
390 /* IEEE 802.11 defines */
392 #define P80211_OUI_LEN 3
394 struct rtllib_snap_hdr {
395 u8 dsap; /* always 0xAA */
396 u8 ssap; /* always 0xAA */
397 u8 ctrl; /* always 0x03 */
398 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
402 enum _REG_PREAMBLE_MODE {
408 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
410 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
411 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
412 #define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA)
414 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
415 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
417 /* Authentication algorithms */
418 #define WLAN_AUTH_OPEN 0
419 #define WLAN_AUTH_SHARED_KEY 1
420 #define WLAN_AUTH_LEAP 128
422 #define WLAN_CAPABILITY_ESS (1<<0)
423 #define WLAN_CAPABILITY_IBSS (1<<1)
424 #define WLAN_CAPABILITY_PRIVACY (1<<4)
425 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
426 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
428 #define RTLLIB_STATMASK_SIGNAL (1<<0)
429 #define RTLLIB_STATMASK_RSSI (1<<1)
430 #define RTLLIB_STATMASK_NOISE (1<<2)
431 #define RTLLIB_STATMASK_WEMASK 0x7
433 #define RTLLIB_CCK_MODULATION (1<<0)
434 #define RTLLIB_OFDM_MODULATION (1<<1)
436 #define RTLLIB_CCK_RATE_LEN 4
437 #define RTLLIB_CCK_RATE_1MB 0x02
438 #define RTLLIB_CCK_RATE_2MB 0x04
439 #define RTLLIB_CCK_RATE_5MB 0x0B
440 #define RTLLIB_CCK_RATE_11MB 0x16
441 #define RTLLIB_OFDM_RATE_LEN 8
442 #define RTLLIB_OFDM_RATE_6MB 0x0C
443 #define RTLLIB_OFDM_RATE_9MB 0x12
444 #define RTLLIB_OFDM_RATE_12MB 0x18
445 #define RTLLIB_OFDM_RATE_18MB 0x24
446 #define RTLLIB_OFDM_RATE_24MB 0x30
447 #define RTLLIB_OFDM_RATE_36MB 0x48
448 #define RTLLIB_OFDM_RATE_48MB 0x60
449 #define RTLLIB_OFDM_RATE_54MB 0x6C
450 #define RTLLIB_BASIC_RATE_MASK 0x80
452 /* this is stolen and modified from the madwifi driver*/
453 #define RTLLIB_FC0_TYPE_MASK 0x0c
454 #define RTLLIB_FC0_TYPE_DATA 0x08
455 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
456 #define RTLLIB_FC0_SUBTYPE_QOS 0x80
458 #define RTLLIB_QOS_HAS_SEQ(fc) \
459 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
460 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
462 /* this is stolen from ipw2200 driver */
463 #define IEEE_IBSS_MAC_HASH_SIZE 31
465 /* NOTE: This data is for statistical purposes; not all hardware provides this
466 * information for frames received. Not setting these will not cause
467 * any adverse affects.
469 struct rtllib_rx_stats {
473 u16 rate; /* in 100 kbps */
494 u8 RxMIMOSignalStrength[4];
495 s8 RxMIMOSignalQuality[2];
496 bool bPacketMatchBSSID;
503 /* IEEE 802.11 requires that STA supports concurrent reception of at least
504 * three fragmented frames. This define can be increased to support more
505 * concurrent frames, but it should be noted that each entry can consume about
506 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
508 #define RTLLIB_FRAG_CACHE_LEN 4
510 struct rtllib_frag_entry {
511 unsigned long first_frag_time;
513 unsigned int last_frag;
515 u8 src_addr[ETH_ALEN];
516 u8 dst_addr[ETH_ALEN];
519 struct rtllib_device;
521 #define SEC_ACTIVE_KEY (1<<4)
522 #define SEC_AUTH_MODE (1<<5)
523 #define SEC_UNICAST_GROUP (1<<6)
524 #define SEC_LEVEL (1<<7)
525 #define SEC_ENABLED (1<<8)
527 #define SEC_LEVEL_0 0 /* None */
528 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
529 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
530 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
531 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
533 #define SEC_ALG_NONE 0
534 #define SEC_ALG_WEP 1
535 #define SEC_ALG_TKIP 2
536 #define SEC_ALG_CCMP 4
538 #define WEP_KEY_LEN 13
539 #define SCM_KEY_LEN 32
541 struct rtllib_security {
546 unicast_uses_group:1,
548 u8 key_sizes[NUM_WEP_KEYS];
549 u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
554 /* 802.11 data frame from AP
555 * ,-------------------------------------------------------------------.
556 * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
557 * |------|------|---------|---------|---------|------|---------|------|
558 * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
559 * | | tion | (BSSID) | | | ence | data | |
560 * `-------------------------------------------------------------------'
561 * Total: 28-2340 bytes
564 /* Management Frame Information Element Types */
568 MFIE_TYPE_FH_SET = 2,
569 MFIE_TYPE_DS_SET = 3,
570 MFIE_TYPE_CF_SET = 4,
572 MFIE_TYPE_IBSS_SET = 6,
573 MFIE_TYPE_COUNTRY = 7,
574 MFIE_TYPE_HOP_PARAMS = 8,
575 MFIE_TYPE_HOP_TABLE = 9,
576 MFIE_TYPE_REQUEST = 10,
577 MFIE_TYPE_CHALLENGE = 16,
578 MFIE_TYPE_POWER_CONSTRAINT = 32,
579 MFIE_TYPE_POWER_CAPABILITY = 33,
580 MFIE_TYPE_TPC_REQUEST = 34,
581 MFIE_TYPE_TPC_REPORT = 35,
582 MFIE_TYPE_SUPP_CHANNELS = 36,
584 MFIE_TYPE_MEASURE_REQUEST = 38,
585 MFIE_TYPE_MEASURE_REPORT = 39,
586 MFIE_TYPE_QUIET = 40,
587 MFIE_TYPE_IBSS_DFS = 41,
589 MFIE_TYPE_HT_CAP = 45,
591 MFIE_TYPE_RATES_EX = 50,
592 MFIE_TYPE_HT_INFO = 61,
593 MFIE_TYPE_AIRONET = 133,
594 MFIE_TYPE_GENERIC = 221,
595 MFIE_TYPE_QOS_PARAMETER = 222,
598 /* Minimal header; can be used for passing 802.11 frames with sufficient
599 * information to determine what type of underlying data type is actually
600 * stored in the data.
602 struct rtllib_info_element {
608 struct rtllib_authentication {
609 struct ieee80211_hdr_3addr header;
614 struct rtllib_info_element info_element[];
615 } __packed __aligned(2);
617 struct rtllib_disauth {
618 struct ieee80211_hdr_3addr header;
620 } __packed __aligned(2);
622 struct rtllib_disassoc {
623 struct ieee80211_hdr_3addr header;
625 } __packed __aligned(2);
627 struct rtllib_probe_request {
628 struct ieee80211_hdr_3addr header;
629 /* SSID, supported rates */
630 struct rtllib_info_element info_element[];
631 } __packed __aligned(2);
633 struct rtllib_probe_response {
634 struct ieee80211_hdr_3addr header;
636 __le16 beacon_interval;
638 /* SSID, supported rates, FH params, DS params,
639 * CF params, IBSS params, TIM (if beacon), RSN
641 struct rtllib_info_element info_element[];
642 } __packed __aligned(2);
644 /* Alias beacon for probe_response */
645 #define rtllib_beacon rtllib_probe_response
647 struct rtllib_assoc_request_frame {
648 struct ieee80211_hdr_3addr header;
650 __le16 listen_interval;
651 /* SSID, supported rates, RSN */
652 struct rtllib_info_element info_element[];
653 } __packed __aligned(2);
655 struct rtllib_assoc_response_frame {
656 struct ieee80211_hdr_3addr header;
660 struct rtllib_info_element info_element[]; /* supported rates */
661 } __packed __aligned(2);
671 struct sk_buff *fragments[] __counted_by(nr_frags);
674 #define MAX_SUBFRAME_COUNT 64
677 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
694 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
695 * only use 8, and then use extended rates for the remaining supported
696 * rates. Other APs, however, stick all of their supported rates on the
697 * main rates information element...
699 #define MAX_RATES_LENGTH ((u8)12)
700 #define MAX_RATES_EX_LENGTH ((u8)16)
701 #define MAX_NETWORK_COUNT 96
703 #define MAX_CHANNEL_NUMBER 161
704 #define RTLLIB_SOFTMAC_SCAN_TIME 100
705 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
707 #define MAX_WPA_IE_LEN 64
708 #define MAX_WZC_IE_LEN 256
710 #define NETWORK_EMPTY_ESSID (1<<0)
711 #define NETWORK_HAS_OFDM (1<<1)
712 #define NETWORK_HAS_CCK (1<<2)
715 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
716 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
717 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
718 NETWORK_HAS_QOS_INFORMATION)
720 #define NETWORK_HAS_ERP_VALUE (1<<10)
722 #define QOS_QUEUE_NUM 4
723 #define QOS_OUI_LEN 3
724 #define QOS_OUI_TYPE 2
725 #define QOS_ELEMENT_ID 221
726 #define QOS_OUI_INFO_SUB_TYPE 0
727 #define QOS_OUI_PARAM_SUB_TYPE 1
728 #define QOS_VERSION_1 1
730 struct rtllib_qos_information_element {
740 struct rtllib_qos_ac_parameter {
746 struct rtllib_qos_parameter_info {
747 struct rtllib_qos_information_element info_element;
749 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
752 struct rtllib_qos_parameters {
753 __le16 cw_min[QOS_QUEUE_NUM];
754 __le16 cw_max[QOS_QUEUE_NUM];
755 u8 aifs[QOS_QUEUE_NUM];
756 u8 flag[QOS_QUEUE_NUM];
757 __le16 tx_op_limit[QOS_QUEUE_NUM];
760 struct rtllib_qos_data {
761 struct rtllib_qos_parameters parameters;
762 unsigned int wmm_acm;
769 struct rtllib_tim_parameters {
774 struct rtllib_wmm_ac_param {
785 EAPOL_ENCAP_ASF_ALERT
788 static const char * const eap_types[] = {
789 [EAP_PACKET] = "EAP-Packet",
790 [EAPOL_START] = "EAPOL-Start",
791 [EAPOL_LOGOFF] = "EAPOL-Logoff",
792 [EAPOL_KEY] = "EAPOL-Key",
793 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
796 static inline const char *eap_get_type(int type)
798 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
802 static inline u8 Frame_QoSTID(u8 *buf)
804 struct ieee80211_hdr_3addr *hdr;
807 hdr = (struct ieee80211_hdr_3addr *)buf;
808 fc = le16_to_cpu(hdr->frame_control);
809 return (u8)((union frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) &&
810 (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
821 struct rtllib_softmac_stats {
822 unsigned int rx_ass_ok;
823 unsigned int rx_ass_err;
824 unsigned int rx_probe_rq;
825 unsigned int tx_probe_rs;
826 unsigned int tx_beacons;
827 unsigned int rx_auth_rq;
828 unsigned int rx_auth_rs_ok;
829 unsigned int rx_auth_rs_err;
830 unsigned int tx_auth_rq;
831 unsigned int no_auth_rs;
832 unsigned int no_ass_rs;
833 unsigned int tx_ass_rq;
834 unsigned int rx_ass_rq;
835 unsigned int tx_probe_rq;
836 unsigned int reassoc;
837 unsigned int swtxstop;
838 unsigned int swtxawake;
839 unsigned char CurrentShowTxate;
840 unsigned char last_packet_rate;
841 unsigned int txretrycount;
844 /* These are the data types that can make up management packets
846 * u16 auth_algorithm;
848 * u16 beacon_interval;
850 * u8 current_ap[ETH_ALEN];
851 * u16 listen_interval;
853 * u16 association_id:14, reserved:2;
860 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
861 #define RTLLIB_DEFAULT_BASIC_RATE 2
863 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
864 #define MAX_SP_Len (WMM_all_frame << 4)
865 #define RTLLIB_QOS_TID 0x0f
866 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
868 #define RTLLIB_DTIM_MBCAST 4
869 #define RTLLIB_DTIM_UCAST 2
870 #define RTLLIB_DTIM_VALID 1
871 #define RTLLIB_DTIM_INVALID 0
873 #define RTLLIB_PS_DISABLED 0
874 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
875 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
877 #define WME_AC_BK 0x00
878 #define WME_AC_BE 0x01
879 #define WME_AC_VI 0x02
880 #define WME_AC_VO 0x03
881 #define WME_AC_PRAM_LEN 16
883 #define MAX_RECEIVE_BUFFER_SIZE 9100
885 #define UP2AC(up) ( \
886 ((up) < 1) ? WME_AC_BE : \
887 ((up) < 3) ? WME_AC_BK : \
888 ((up) < 4) ? WME_AC_BE : \
889 ((up) < 6) ? WME_AC_VI : \
892 #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
897 ERP_NonERPpresent = 0x01,
898 ERP_UseProtection = 0x02,
899 ERP_BarkerPreambleMode = 0x04,
902 struct rtllib_network {
903 /* These entries are used to identify a unique network */
906 /* Ensure null-terminated for any debug msgs */
907 u8 ssid[IW_ESSID_MAX_SIZE + 1];
909 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
911 struct rtllib_qos_data qos_data;
921 u8 bss_ccx_ver_number;
922 /* These are network statistics */
923 struct rtllib_rx_stats stats;
925 u8 rates[MAX_RATES_LENGTH];
927 u8 rates_ex[MAX_RATES_EX_LENGTH];
929 unsigned long last_scanned;
937 u8 wpa_ie[MAX_WPA_IE_LEN];
939 u8 rsn_ie[MAX_WPA_IE_LEN];
941 u8 wzc_ie[MAX_WZC_IE_LEN];
944 struct rtllib_tim_parameters tim;
947 u64 last_dtim_sta_time;
950 struct rtllib_wmm_ac_param wmm_param[4];
953 u8 CountryIeBuf[MAX_IE_LEN];
955 bool broadcom_cap_exist;
956 bool realtek_cap_exit;
957 bool marvell_cap_exist;
958 bool ralink_cap_exist;
959 bool atheros_cap_exist;
960 bool cisco_cap_exist;
961 bool airgo_cap_exist;
962 bool unknown_cap_exist;
963 bool berp_info_valid;
967 struct list_head list;
970 enum rtl_link_state {
971 /* the card is not linked at all */
974 /* RTLLIB_ASSOCIATING* are for BSS client mode
975 * the driver shall not perform RX filtering unless
976 * the state is LINKED.
977 * The driver shall just check for the state LINKED and
978 * defaults to NOLINK for ALL the other states (including
982 /* the association procedure will start (wq scheduling)*/
984 RTLLIB_ASSOCIATING_RETRY,
986 /* the association procedure is sending AUTH request*/
987 RTLLIB_ASSOCIATING_AUTHENTICATING,
989 /* the association procedure has successfully authenticated
990 * and is sending association request
992 RTLLIB_ASSOCIATING_AUTHENTICATED,
994 /* the link is ok. the card associated to a BSS or linked
995 * to a ibss cell or acting as an AP and creating the bss
999 /* same as LINKED, but the driver shall apply RX filter
1000 * rules as we are in NO_LINK mode. As the card is still
1001 * logically linked, but it is doing a syncro site survey
1002 * then it will be back to LINKED state.
1004 MAC80211_LINKED_SCANNING,
1007 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1008 #define DEFAULT_FTS 2346
1010 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1011 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1015 struct rtllib_txb *txb;
1018 struct bandwidth_autoswitch {
1019 long threshold_20Mhzto40Mhz;
1020 long threshold_40Mhzto20Mhz;
1021 bool bforced_tx20Mhz;
1022 bool bautoswitch_enable;
1025 #define REORDER_WIN_SIZE 128
1026 #define REORDER_ENTRY_NUM 128
1027 struct rx_reorder_entry {
1028 struct list_head list;
1030 struct rtllib_rxb *prxb;
1039 enum ips_callback_function {
1040 IPS_CALLBACK_NONE = 0,
1041 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1042 IPS_CALLBACK_JOIN_REQUEST = 2,
1045 enum rt_rf_power_state {
1051 struct rt_pwr_save_ctrl {
1052 bool bSwRfProcessing;
1053 enum rt_rf_power_state eInactivePowerState;
1054 enum ips_callback_function ReturnPoint;
1063 #define RT_RF_CHANGE_SOURCE u32
1065 #define RF_CHANGE_BY_SW BIT(31)
1066 #define RF_CHANGE_BY_HW BIT(30)
1067 #define RF_CHANGE_BY_PS BIT(29)
1068 #define RF_CHANGE_BY_IPS BIT(28)
1069 #define RF_CHANGE_BY_INIT 0
1071 enum country_code_type {
1072 COUNTRY_CODE_FCC = 0,
1073 COUNTRY_CODE_IC = 1,
1074 COUNTRY_CODE_ETSI = 2,
1075 COUNTRY_CODE_SPAIN = 3,
1076 COUNTRY_CODE_FRANCE = 4,
1077 COUNTRY_CODE_MKK = 5,
1078 COUNTRY_CODE_MKK1 = 6,
1079 COUNTRY_CODE_ISRAEL = 7,
1080 COUNTRY_CODE_TELEC = 8,
1081 COUNTRY_CODE_MIC = 9,
1082 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1083 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1084 COUNTRY_CODE_TELEC_NETGEAR = 12,
1088 enum scan_op_backup_opt {
1089 SCAN_OPT_BACKUP = 0,
1094 #define RT_MAX_LD_SLOT_NUM 10
1095 struct rt_link_detect {
1096 u32 num_recv_bcn_in_period;
1097 u32 num_recv_data_in_period;
1099 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1100 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1104 u32 num_tx_ok_in_period;
1105 u32 num_rx_ok_in_period;
1106 u32 num_rx_unicast_ok_in_period;
1108 bool bHigherBusyTraffic;
1109 bool bHigherBusyRxTraffic;
1112 struct sw_cam_table {
1113 u8 macaddr[ETH_ALEN];
1122 #define TOTAL_CAM_ENTRY 32
1123 struct rate_adaptive {
1127 u32 high_rssi_thresh_for_ra;
1128 u32 high2low_rssi_thresh_for_ra;
1129 u8 low2high_rssi_thresh_for_ra40M;
1130 u32 low_rssi_thresh_for_ra40M;
1131 u8 low2high_rssi_thresh_for_ra20M;
1132 u32 low_rssi_thresh_for_ra20M;
1133 u32 upper_rssi_threshold_ratr;
1134 u32 middle_rssi_threshold_ratr;
1135 u32 low_rssi_threshold_ratr;
1136 u32 low_rssi_threshold_ratr_40M;
1137 u32 low_rssi_threshold_ratr_20M;
1138 u8 ping_rssi_enable;
1140 u32 ping_rssi_thresh_for_ra;
1145 #define NUM_PMKID_CACHE 16
1146 struct rt_pmkid_list {
1153 /*************** DRIVER STATUS *****/
1154 #define STATUS_SCANNING 0
1155 /*************** DRIVER STATUS *****/
1160 LPS_WAIT_NULL_DATA_SEND = 2,
1163 struct rtllib_device {
1164 struct pci_dev *pdev;
1165 struct net_device *dev;
1166 struct rtllib_security sec;
1168 bool disable_mgnt_queue;
1170 unsigned long status;
1173 enum rt_op_mode op_mode;
1175 /* The last AssocReq/Resp IEs */
1176 u8 *assocreq_ies, *assocresp_ies;
1177 size_t assocreq_ies_len, assocresp_ies_len;
1179 bool forced_bg_mode;
1185 bool bSupportRemoteWakeUp;
1187 bool first_ie_in_scan;
1188 bool be_scan_inprogress;
1190 enum rt_rf_power_state rf_power_state;
1191 RT_RF_CHANGE_SOURCE rf_off_reason;
1194 struct rt_hi_throughput *ht_info;
1196 spinlock_t reorder_spinlock;
1197 u8 reg_dot11ht_oper_rate_set[16];
1198 u8 reg_dot11tx_ht_oper_rate_set[16];
1199 u8 dot11ht_oper_rate_set[16];
1200 u8 reg_ht_supp_rate_set[16];
1201 u8 HTCurrentOperaRate;
1202 u8 HTHighestOperaRate;
1203 u8 tx_dis_rate_fallback;
1204 u8 tx_use_drv_assinged_rate;
1205 u8 tx_enable_fw_calc_dur;
1208 struct list_head Tx_TS_Admit_List;
1209 struct list_head Tx_TS_Pending_List;
1210 struct list_head Tx_TS_Unused_List;
1211 struct tx_ts_record tx_ts_records[TOTAL_TS_NUM];
1212 struct list_head Rx_TS_Admit_List;
1213 struct list_head Rx_TS_Pending_List;
1214 struct list_head Rx_TS_Unused_List;
1215 struct rx_ts_record rx_ts_records[TOTAL_TS_NUM];
1216 struct rx_reorder_entry RxReorderEntry[128];
1217 struct list_head RxReorder_Unused_List;
1219 /* Bookkeeping structures */
1220 struct net_device_stats stats;
1221 struct rtllib_softmac_stats softmac_stats;
1223 /* Probe / Beacon management */
1224 struct list_head network_free_list;
1225 struct list_head network_list;
1226 struct rtllib_network *networks;
1230 int iw_mode; /* operating mode (IW_MODE_*) */
1233 spinlock_t wpax_suitlist_lock;
1235 int tx_headroom; /* Set to size of any additional room needed at front
1236 * of allocated Tx SKBs
1240 /* WEP and other encryption related settings at the device level */
1241 int open_wep; /* Set to 1 to allow unencrypted frames */
1243 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1247 int ieee802_1x; /* is IEEE 802.1X used */
1250 bool half_wireless_n24g_mode;
1252 int drop_unencrypted;
1253 int tkip_countermeasures;
1254 int privacy_invoked;
1259 u8 ap_mac_addr[ETH_ALEN];
1260 u16 pairwise_key_type;
1263 struct lib80211_crypt_info crypt_info;
1265 struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
1267 struct rt_pmkid_list pmkid_list[NUM_PMKID_CACHE];
1269 /* Fragmentation structures */
1270 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
1271 unsigned int frag_next_idx[17];
1272 u16 fts; /* Fragmentation Threshold */
1273 #define DEFAULT_RTS_THRESHOLD 2346U
1274 #define MIN_RTS_THRESHOLD 1
1275 #define MAX_RTS_THRESHOLD 2346U
1276 u16 rts; /* RTS threshold */
1278 /* Association info */
1281 /* This stores infos for the current network.
1282 * Either the network we are associated in INFRASTRUCTURE
1283 * or the network that we are creating in MASTER mode.
1284 * ad-hoc is a mixture ;-).
1285 * Note that in infrastructure mode, even when not associated,
1286 * fields bssid and essid may be valid (if wpa_set and essid_set
1287 * are true) as thy carry the value set by the user via iwconfig
1289 struct rtllib_network current_network;
1291 enum rtl_link_state link_state;
1293 int mode; /* A, B, G */
1295 /* used for forcing the ibss workqueue to terminate
1296 * without wait for the syncro scan to terminate
1298 short sync_scan_hurryup;
1301 /* map of allowed channels. 0 is dummy */
1302 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
1304 int rate; /* current rate */
1307 /* this contains flags for selectively enable softmac support */
1308 u16 softmac_features;
1310 /* if the sequence control field is not filled by HW */
1313 /* association procedure transaction sequence number */
1316 /* AID for RTXed association responses */
1319 /* power save mode related*/
1325 struct work_struct ps_task;
1329 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1331 short scanning_continue;
1332 short proto_started;
1333 short proto_stoppping;
1335 struct mutex wx_mutex;
1336 struct mutex scan_mutex;
1337 struct mutex ips_mutex;
1339 spinlock_t mgmt_tx_lock;
1340 spinlock_t beacon_lock;
1347 /* set on initialization */
1348 unsigned int wmm_acm;
1350 /* for discarding duplicated packets in IBSS */
1351 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1353 /* for discarding duplicated packets in BSS */
1354 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1355 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1356 unsigned long last_packet_time[17];
1359 unsigned long last_rx_ps_time;
1360 bool awake_pkt_sent;
1363 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1364 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1365 int mgmt_queue_head;
1366 int mgmt_queue_tail;
1367 u8 asoc_retry_count;
1368 struct sk_buff_head skb_waitq[MAX_QUEUE_SIZE];
1370 bool bdynamic_txpower_enable;
1372 bool bCTSToSelfEnable;
1374 u32 fsync_time_interval;
1375 u32 fsync_rate_bitmap;
1376 u8 fsync_rssi_threshold;
1379 u8 fsync_multiple_timeinterval;
1380 u32 fsync_firstdiff_ratethreshold;
1381 u32 fsync_seconddiff_ratethreshold;
1382 enum fsync_state fsync_state;
1383 bool bis_any_nonbepkts;
1384 struct bandwidth_autoswitch bandwidth_auto_switch;
1387 struct rt_link_detect link_detect_info;
1388 bool is_aggregate_frame;
1389 struct rt_pwr_save_ctrl pwr_save_ctrl;
1391 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1392 struct tx_pending tx_pending;
1394 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1395 struct timer_list associate_timer;
1397 /* used if IEEE_SOFTMAC_BEACONS is set */
1399 struct work_struct associate_complete_wq;
1400 struct work_struct ips_leave_wq;
1401 struct delayed_work associate_procedure_wq;
1402 struct delayed_work softmac_scan_wq;
1403 struct delayed_work associate_retry_wq;
1404 struct delayed_work hw_wakeup_wq;
1405 struct delayed_work hw_sleep_wq;
1406 struct delayed_work link_change_wq;
1407 struct work_struct wx_sync_scan_wq;
1410 struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
1411 struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1412 struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
1414 struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
1415 struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
1416 struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
1420 /* Callback functions */
1422 /* Softmac-generated frames (management) are TXed via this
1423 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1424 * not set. As some cards may have different HW queues that
1425 * one might want to use for data and management frames
1426 * the option to have two callbacks might be useful.
1427 * This function can't sleep.
1429 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1430 struct net_device *dev);
1432 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1433 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1434 * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1435 * then also management frames are sent via this callback.
1436 * This function can't sleep.
1438 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1439 struct net_device *dev, int rate);
1441 /* ask to the driver to retune the radio.
1442 * This function can sleep. the driver should ensure
1443 * the radio has been switched before return.
1445 void (*set_chan)(struct net_device *dev, u8 ch);
1447 /* indicate the driver that the link state is changed
1448 * for example it may indicate the card is associated now.
1449 * Driver might be interested in this to apply RX filter
1450 * rules or simply light the LINK led
1452 void (*link_change)(struct net_device *dev);
1454 /* power save mode related */
1455 void (*sta_wake_up)(struct net_device *dev);
1456 void (*enter_sleep_state)(struct net_device *dev, u64 time);
1457 short (*ps_is_queue_empty)(struct net_device *dev);
1458 int (*handle_beacon)(struct net_device *dev,
1459 struct rtllib_beacon *beacon,
1460 struct rtllib_network *network);
1461 int (*handle_assoc_response)(struct net_device *dev,
1462 struct rtllib_assoc_response_frame *resp,
1463 struct rtllib_network *network);
1465 /* check whether Tx hw resource available */
1466 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1467 void (*set_bw_mode_handler)(struct net_device *dev,
1468 enum ht_channel_width bandwidth,
1469 enum ht_extchnl_offset Offset);
1470 bool (*get_nmode_support_by_sec_cfg)(struct net_device *dev);
1471 void (*set_wireless_mode)(struct net_device *dev, u8 wireless_mode);
1472 bool (*get_half_nmode_support_by_aps_handler)(struct net_device *dev);
1473 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
1474 void (*init_gain_handler)(struct net_device *dev, u8 Operation);
1475 void (*ScanOperationBackupHandler)(struct net_device *dev,
1477 void (*set_hw_reg_handler)(struct net_device *dev, u8 variable, u8 *val);
1479 void (*allow_all_dest_addr_handler)(struct net_device *dev,
1483 void (*rtllib_ips_leave_wq)(struct net_device *dev);
1484 void (*rtllib_ips_leave)(struct net_device *dev);
1485 void (*leisure_ps_leave)(struct net_device *dev);
1487 /* This must be the last item so that it points to the data
1488 * allocated beyond this structure by alloc_rtllib
1493 #define IEEE_MODE_MASK (WIRELESS_MODE_B | WIRELESS_MODE_G)
1495 /* Generate a 802.11 header */
1497 /* Uses the channel change callback directly
1498 * instead of [start/stop] scan callbacks
1500 #define IEEE_SOFTMAC_SCAN (1<<2)
1502 /* Perform authentication and association handshake */
1503 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1505 /* Generate probe requests */
1506 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1508 /* Generate response to probe requests */
1509 #define IEEE_SOFTMAC_PROBERS (1<<5)
1511 /* The ieee802.11 stack will manage the netif queue
1512 * wake/stop for the driver, taking care of 802.11
1513 * fragmentation. See softmac.c for details.
1515 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1517 /* Uses only the softmac_data_hard_start_xmit
1518 * even for TX management frames.
1520 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1522 /* Generate beacons. The stack will enqueue beacons
1525 #define IEEE_SOFTMAC_BEACONS (1<<6)
1527 static inline void *rtllib_priv(struct net_device *dev)
1529 return ((struct rtllib_device *)netdev_priv(dev))->priv;
1532 static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
1534 /* Single white space is for Linksys APs */
1535 if (essid_len == 1 && essid[0] == ' ')
1538 /* Otherwise, if the entire essid is 0, we assume it is hidden */
1541 if (essid[essid_len] != '\0')
1548 static inline int rtllib_get_hdrlen(u16 fc)
1550 int hdrlen = RTLLIB_3ADDR_LEN;
1552 switch (WLAN_FC_GET_TYPE(fc)) {
1553 case RTLLIB_FTYPE_DATA:
1554 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1555 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
1556 if (RTLLIB_QOS_HAS_SEQ(fc))
1557 hdrlen += 2; /* QOS ctrl*/
1559 case RTLLIB_FTYPE_CTL:
1560 switch (WLAN_FC_GET_STYPE(fc)) {
1561 case IEEE80211_STYPE_CTS:
1562 case IEEE80211_STYPE_ACK:
1563 hdrlen = RTLLIB_1ADDR_LEN;
1566 hdrlen = RTLLIB_2ADDR_LEN;
1575 static inline int rtllib_is_ofdm_rate(u8 rate)
1577 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1578 case RTLLIB_OFDM_RATE_6MB:
1579 case RTLLIB_OFDM_RATE_9MB:
1580 case RTLLIB_OFDM_RATE_12MB:
1581 case RTLLIB_OFDM_RATE_18MB:
1582 case RTLLIB_OFDM_RATE_24MB:
1583 case RTLLIB_OFDM_RATE_36MB:
1584 case RTLLIB_OFDM_RATE_48MB:
1585 case RTLLIB_OFDM_RATE_54MB:
1591 static inline int rtllib_is_cck_rate(u8 rate)
1593 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1594 case RTLLIB_CCK_RATE_1MB:
1595 case RTLLIB_CCK_RATE_2MB:
1596 case RTLLIB_CCK_RATE_5MB:
1597 case RTLLIB_CCK_RATE_11MB:
1604 void free_rtllib(struct net_device *dev);
1605 struct net_device *alloc_rtllib(int sizeof_priv);
1609 int rtllib_encrypt_fragment(struct rtllib_device *ieee,
1610 struct sk_buff *frag,
1613 netdev_tx_t rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
1614 void rtllib_txb_free(struct rtllib_txb *txb);
1617 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
1618 struct rtllib_rx_stats *rx_stats);
1619 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
1622 int rtllib_wx_get_scan(struct rtllib_device *ieee,
1623 struct iw_request_info *info,
1624 union iwreq_data *wrqu, char *key);
1625 int rtllib_wx_set_encode(struct rtllib_device *ieee,
1626 struct iw_request_info *info,
1627 union iwreq_data *wrqu, char *key);
1628 int rtllib_wx_get_encode(struct rtllib_device *ieee,
1629 struct iw_request_info *info,
1630 union iwreq_data *wrqu, char *key);
1631 int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
1632 struct iw_request_info *info,
1633 union iwreq_data *wrqu, char *extra);
1634 int rtllib_wx_set_auth(struct rtllib_device *ieee,
1635 struct iw_request_info *info,
1636 struct iw_param *data, char *extra);
1637 int rtllib_wx_set_mlme(struct rtllib_device *ieee,
1638 struct iw_request_info *info,
1639 union iwreq_data *wrqu, char *extra);
1640 int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
1642 /* rtllib_softmac.c */
1643 int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb,
1644 struct rtllib_rx_stats *rx_stats, u16 type,
1646 void rtllib_softmac_new_net(struct rtllib_device *ieee,
1647 struct rtllib_network *net);
1649 void send_disassociation(struct rtllib_device *ieee, bool deauth, u16 rsn);
1650 void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
1652 int rtllib_softmac_init(struct rtllib_device *ieee);
1653 void rtllib_softmac_free(struct rtllib_device *ieee);
1654 void rtllib_disassociate(struct rtllib_device *ieee);
1655 void rtllib_stop_scan(struct rtllib_device *ieee);
1656 bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
1657 void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
1658 void rtllib_start_scan_syncro(struct rtllib_device *ieee);
1659 void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr);
1660 void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
1661 void rtllib_start_protocol(struct rtllib_device *ieee);
1662 void rtllib_stop_protocol(struct rtllib_device *ieee);
1664 void rtllib_enable_net_monitor_mode(struct net_device *dev, bool init_state);
1665 void rtllib_disable_net_monitor_mode(struct net_device *dev, bool init_state);
1667 void rtllib_softmac_stop_protocol(struct rtllib_device *ieee);
1668 void rtllib_softmac_start_protocol(struct rtllib_device *ieee);
1670 void rtllib_reset_queue(struct rtllib_device *ieee);
1671 void rtllib_wake_all_queues(struct rtllib_device *ieee);
1672 void rtllib_stop_all_queues(struct rtllib_device *ieee);
1674 void notify_wx_assoc_event(struct rtllib_device *ieee);
1675 void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
1677 void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee);
1678 u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
1680 /* rtllib_softmac_wx.c */
1682 int rtllib_wx_get_wap(struct rtllib_device *ieee, struct iw_request_info *info,
1683 union iwreq_data *wrqu, char *ext);
1685 int rtllib_wx_set_wap(struct rtllib_device *ieee, struct iw_request_info *info,
1686 union iwreq_data *awrq, char *extra);
1688 int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,
1689 union iwreq_data *wrqu, char *b);
1691 int rtllib_wx_set_rate(struct rtllib_device *ieee, struct iw_request_info *info,
1692 union iwreq_data *wrqu, char *extra);
1694 int rtllib_wx_get_rate(struct rtllib_device *ieee, struct iw_request_info *info,
1695 union iwreq_data *wrqu, char *extra);
1697 int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a,
1698 union iwreq_data *wrqu, char *b);
1700 int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a,
1701 union iwreq_data *wrqu, char *b);
1703 int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a,
1704 union iwreq_data *wrqu, char *extra);
1706 int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a,
1707 union iwreq_data *wrqu, char *b);
1709 int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
1710 union iwreq_data *wrqu, char *b);
1712 int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a,
1713 union iwreq_data *wrqu, char *b);
1714 void rtllib_wx_sync_scan_wq(void *data);
1716 int rtllib_wx_get_name(struct rtllib_device *ieee, struct iw_request_info *info,
1717 union iwreq_data *wrqu, char *extra);
1719 int rtllib_wx_set_power(struct rtllib_device *ieee,
1720 struct iw_request_info *info,
1721 union iwreq_data *wrqu, char *extra);
1723 int rtllib_wx_get_power(struct rtllib_device *ieee,
1724 struct iw_request_info *info,
1725 union iwreq_data *wrqu, char *extra);
1727 int rtllib_wx_set_rts(struct rtllib_device *ieee, struct iw_request_info *info,
1728 union iwreq_data *wrqu, char *extra);
1730 int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info,
1731 union iwreq_data *wrqu, char *extra);
1732 #define MAX_RECEIVE_BUFFER_SIZE 9100
1734 void ht_set_connect_bw_mode(struct rtllib_device *ieee,
1735 enum ht_channel_width bandwidth,
1736 enum ht_extchnl_offset Offset);
1737 void ht_update_default_setting(struct rtllib_device *ieee);
1738 void ht_construct_capability_element(struct rtllib_device *ieee,
1739 u8 *posHTCap, u8 *len,
1740 u8 isEncrypt, bool bAssoc);
1741 void ht_construct_rt2rt_agg_element(struct rtllib_device *ieee,
1742 u8 *posRT2RTAgg, u8 *len);
1743 void ht_on_assoc_rsp(struct rtllib_device *ieee);
1744 void ht_initialize_ht_info(struct rtllib_device *ieee);
1745 void ht_initialize_bss_desc(struct bss_ht *pBssHT);
1746 void ht_reset_self_and_save_peer_setting(struct rtllib_device *ieee,
1747 struct rtllib_network *pNetwork);
1748 void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
1749 struct rtllib_network *pNetwork);
1750 u8 ht_get_highest_mcs_rate(struct rtllib_device *ieee, u8 *pMCSRateSet,
1752 extern u8 MCS_FILTER_ALL[];
1753 extern u16 MCS_DATA_RATE[2][2][77];
1754 u8 ht_c_check(struct rtllib_device *ieee, u8 *pFrame);
1755 void ht_reset_iot_setting(struct rt_hi_throughput *ht_info);
1756 bool is_ht_half_nmode_aps(struct rtllib_device *ieee);
1757 u16 tx_count_to_data_rate(struct rtllib_device *ieee, u8 nDataRate);
1758 int rtllib_rx_add_ba_req(struct rtllib_device *ieee, struct sk_buff *skb);
1759 int rtllib_rx_add_ba_rsp(struct rtllib_device *ieee, struct sk_buff *skb);
1760 int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
1761 void rtllib_ts_init_add_ba(struct rtllib_device *ieee, struct tx_ts_record *ts,
1762 u8 policy, u8 overwrite_pending);
1763 void rtllib_ts_init_del_ba(struct rtllib_device *ieee,
1764 struct ts_common_info *ts_common_info,
1765 enum tr_select tx_rx_select);
1766 void rtllib_ba_setup_timeout(struct timer_list *t);
1767 void rtllib_tx_ba_inact_timeout(struct timer_list *t);
1768 void rtllib_rx_ba_inact_timeout(struct timer_list *t);
1769 void rtllib_reset_ba_entry(struct ba_record *ba);
1770 bool rtllib_get_ts(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 *addr,
1771 u8 TID, enum tr_select tx_rx_select, bool bAddNewTs);
1772 void rtllib_ts_init(struct rtllib_device *ieee);
1773 void TsStartAddBaProcess(struct rtllib_device *ieee,
1774 struct tx_ts_record *pTxTS);
1775 void remove_peer_ts(struct rtllib_device *ieee, u8 *addr);
1776 void remove_all_ts(struct rtllib_device *ieee);
1778 static inline const char *escape_essid(const char *essid, u8 essid_len)
1780 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1782 if (rtllib_is_empty_essid(essid, essid_len)) {
1783 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1787 snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
1791 /* fun with the built-in rtllib stack... */
1792 bool rtllib_mgnt_disconnect(struct rtllib_device *rtllib, u8 rsn);
1794 /* For the function is more related to hardware setting, it's better to use the
1795 * ieee handler to refer to it.
1797 void rtllib_flush_rx_ts_pending_pkts(struct rtllib_device *ieee,
1798 struct rx_ts_record *ts);
1799 int rtllib_parse_info_param(struct rtllib_device *ieee,
1800 struct rtllib_info_element *info_element,
1802 struct rtllib_network *network,
1803 struct rtllib_rx_stats *stats);
1805 void rtllib_indicate_packets(struct rtllib_device *ieee,
1806 struct rtllib_rxb **prxbIndicateArray, u8 index);
1807 #define RT_ASOC_RETRY_LIMIT 5
1808 u8 mgnt_query_tx_rate_exclude_cck_rates(struct rtllib_device *ieee);
1810 #endif /* RTLLIB_H */