1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
10 #include <linux/ieee80211.h>
12 #define MGMT_QUEUE_NUM 5
15 #define ETH_TYPE_LEN 2
16 #define PAYLOAD_TYPE_LEN 1
18 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
20 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
22 RTL871X_HOSTAPD_FLUSH = 1,
23 RTL871X_HOSTAPD_ADD_STA = 2,
24 RTL871X_HOSTAPD_REMOVE_STA = 3,
25 RTL871X_HOSTAPD_GET_INFO_STA = 4,
26 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
27 RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
28 RTL871X_SET_ENCRYPTION = 6,
29 RTL871X_GET_ENCRYPTION = 7,
30 RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
31 RTL871X_HOSTAPD_GET_RID = 9,
32 RTL871X_HOSTAPD_SET_RID = 10,
33 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
34 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
35 RTL871X_HOSTAPD_MLME = 13,
36 RTL871X_HOSTAPD_SCAN_REQ = 14,
37 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
38 RTL871X_HOSTAPD_SET_BEACON = 16,
39 RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
40 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
41 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
42 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
43 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
44 RTL871X_HOSTAPD_ACL_ADD_STA = 22,
45 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
49 #define WLAN_STA_AUTH BIT(0)
50 #define WLAN_STA_ASSOC BIT(1)
51 #define WLAN_STA_PS BIT(2)
52 #define WLAN_STA_TIM BIT(3)
53 #define WLAN_STA_PERM BIT(4)
54 #define WLAN_STA_AUTHORIZED BIT(5)
55 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
56 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
57 #define WLAN_STA_PREAUTH BIT(8)
58 #define WLAN_STA_WME BIT(9)
59 #define WLAN_STA_MFP BIT(10)
60 #define WLAN_STA_HT BIT(11)
61 #define WLAN_STA_WPS BIT(12)
62 #define WLAN_STA_MAYBE_WPS BIT(13)
63 #define WLAN_STA_VHT BIT(14)
64 #define WLAN_STA_NONERP BIT(31)
66 #define IEEE_CMD_SET_WPA_PARAM 1
67 #define IEEE_CMD_SET_WPA_IE 2
68 #define IEEE_CMD_SET_ENCRYPTION 3
69 #define IEEE_CMD_MLME 4
71 #define IEEE_PARAM_WPA_ENABLED 1
72 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
73 #define IEEE_PARAM_DROP_UNENCRYPTED 3
74 #define IEEE_PARAM_PRIVACY_INVOKED 4
75 #define IEEE_PARAM_AUTH_ALGS 5
76 #define IEEE_PARAM_IEEE_802_1X 6
77 #define IEEE_PARAM_WPAX_SELECT 7
79 #define IEEE_MLME_STA_DEAUTH 1
80 #define IEEE_MLME_STA_DISASSOC 2
82 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
83 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
84 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
85 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
86 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
87 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
90 #define IEEE_CRYPT_ALG_NAME_LEN 16
92 #define WPA_CIPHER_NONE BIT(0)
93 #define WPA_CIPHER_WEP40 BIT(1)
94 #define WPA_CIPHER_WEP104 BIT(2)
95 #define WPA_CIPHER_TKIP BIT(3)
96 #define WPA_CIPHER_CCMP BIT(4)
100 #define WPA_SELECTOR_LEN 4
101 extern u8 RTW_WPA_OUI_TYPE[];
102 extern u16 RTW_WPA_VERSION;
103 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
104 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
105 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
106 extern u8 WPA_CIPHER_SUITE_NONE[];
107 extern u8 WPA_CIPHER_SUITE_WEP40[];
108 extern u8 WPA_CIPHER_SUITE_TKIP[];
109 extern u8 WPA_CIPHER_SUITE_WRAP[];
110 extern u8 WPA_CIPHER_SUITE_CCMP[];
111 extern u8 WPA_CIPHER_SUITE_WEP104[];
114 #define RSN_HEADER_LEN 4
115 #define RSN_SELECTOR_LEN 4
117 extern u16 RSN_VERSION_BSD;
118 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
119 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
120 extern u8 RSN_CIPHER_SUITE_NONE[];
121 extern u8 RSN_CIPHER_SUITE_WEP40[];
122 extern u8 RSN_CIPHER_SUITE_TKIP[];
123 extern u8 RSN_CIPHER_SUITE_WRAP[];
124 extern u8 RSN_CIPHER_SUITE_CCMP[];
125 extern u8 RSN_CIPHER_SUITE_WEP104[];
128 typedef enum _RATEID_IDX_ {
129 RATEID_IDX_BGN_40M_2SS = 0,
130 RATEID_IDX_BGN_40M_1SS = 1,
131 RATEID_IDX_BGN_20M_2SS_BN = 2,
132 RATEID_IDX_BGN_20M_1SS_BN = 3,
133 RATEID_IDX_GN_N2SS = 4,
134 RATEID_IDX_GN_N1SS = 5,
138 RATEID_IDX_VHT_2SS = 9,
139 RATEID_IDX_VHT_1SS = 10,
140 } RATEID_IDX, *PRATEID_IDX;
142 typedef enum _RATR_TABLE_MODE {
143 RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */
144 RATR_INX_WIRELESS_NG = 1, /* GN or N */
145 RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */
146 RATR_INX_WIRELESS_N = 3,
147 RATR_INX_WIRELESS_GB = 4,
148 RATR_INX_WIRELESS_G = 5,
149 RATR_INX_WIRELESS_B = 6,
150 RATR_INX_WIRELESS_MC = 7,
151 RATR_INX_WIRELESS_AC_N = 8,
152 } RATR_TABLE_MODE, *PRATR_TABLE_MODE;
156 WIRELESS_INVALID = 0,
158 WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */
159 WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */
160 WIRELESS_11A = BIT(2), /* tx: ofdm only, rx: ofdm only, hw: ofdm only */
161 WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */
162 WIRELESS_11_5N = BIT(4), /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */
163 WIRELESS_AUTO = BIT(5),
164 WIRELESS_11AC = BIT(6),
167 /* Type for current wireless mode */
168 WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
169 WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
170 WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
171 WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
172 WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
173 WIRELESS_11_24AC = (WIRELESS_11G|WIRELESS_11AC),
174 WIRELESS_11_5AC = (WIRELESS_11A|WIRELESS_11AC),
177 /* Type for registry default wireless mode */
178 WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
179 WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
180 WIRELESS_MODE_24G = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11AC),
181 WIRELESS_MODE_MAX = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N|WIRELESS_11AC),
184 #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
186 #define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG|WIRELESS_11A)))
188 #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
190 #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
191 #define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false)
193 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
194 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
195 #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType)
197 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
198 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11A)) ? true : false)
199 #define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N)) ? true : false)
201 #define IsSupportedVHT(NetType) (((NetType) & (WIRELESS_11AC)) ? true : false)
206 u8 sta_addr[ETH_ALEN];
222 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
226 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
234 u8 tx_supp_rates[16];
235 struct ieee80211_ht_cap ht_cap;
238 u8 reserved[2];/* for set max_num_sta */
244 struct ieee_param_ex {
246 u8 sta_addr[ETH_ALEN];
255 u8 tx_supp_rates[16];
256 u32 tx_supp_rates_len;
257 struct ieee80211_ht_cap ht_cap;
266 /* this is stolen from ipw2200 driver */
267 #define IEEE_IBSS_MAC_HASH_SIZE 31
269 struct ieee_ibss_seq {
273 unsigned long packet_time;
274 struct list_head list;
283 } __attribute__ ((packed));
290 EAPOL_ENCAP_ASF_ALERT
293 #define IEEE80211_FCS_LEN 4
295 #define MIN_FRAG_THRESHOLD 256U
296 #define MAX_FRAG_THRESHOLD 2346U
298 /* sequence control field */
299 #define RTW_IEEE80211_SCTL_FRAG 0x000F
300 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
303 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
304 #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
305 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
310 #define NON_EXPLICIT_ACK 2
314 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
315 #endif /* ETH_P_PAE */
317 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
319 #define ETH_P_ECONET 0x0018
321 #ifndef ETH_P_80211_RAW
322 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
325 /* IEEE 802.11 defines */
327 #define P80211_OUI_LEN 3
329 struct ieee80211_snap_hdr {
330 u8 dsap; /* always 0xAA */
331 u8 ssap; /* always 0xAA */
332 u8 ctrl; /* always 0x03 */
333 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
334 } __attribute__ ((packed));
336 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
338 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
339 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
341 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
343 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
344 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
347 #define WLAN_REASON_ACTIVE_ROAM 65533
348 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
349 #define WLAN_REASON_EXPIRATION_CHK 65535
351 #define IEEE80211_MGMT_HDR_LEN 24
352 #define IEEE80211_DATA_HDR3_LEN 24
353 #define IEEE80211_DATA_HDR4_LEN 30
356 #define IEEE80211_STATMASK_SIGNAL (1<<0)
357 #define IEEE80211_STATMASK_RSSI (1<<1)
358 #define IEEE80211_STATMASK_NOISE (1<<2)
359 #define IEEE80211_STATMASK_RATE (1<<3)
360 #define IEEE80211_STATMASK_WEMASK 0x7
363 #define IEEE80211_CCK_MODULATION (1<<0)
364 #define IEEE80211_OFDM_MODULATION (1<<1)
366 #define IEEE80211_24GHZ_BAND (1<<0)
367 #define IEEE80211_52GHZ_BAND (1<<1)
369 #define IEEE80211_CCK_RATE_LEN 4
370 #define IEEE80211_NUM_OFDM_RATESLEN 8
373 #define IEEE80211_CCK_RATE_1MB 0x02
374 #define IEEE80211_CCK_RATE_2MB 0x04
375 #define IEEE80211_CCK_RATE_5MB 0x0B
376 #define IEEE80211_CCK_RATE_11MB 0x16
377 #define IEEE80211_OFDM_RATE_LEN 8
378 #define IEEE80211_OFDM_RATE_6MB 0x0C
379 #define IEEE80211_OFDM_RATE_9MB 0x12
380 #define IEEE80211_OFDM_RATE_12MB 0x18
381 #define IEEE80211_OFDM_RATE_18MB 0x24
382 #define IEEE80211_OFDM_RATE_24MB 0x30
383 #define IEEE80211_OFDM_RATE_36MB 0x48
384 #define IEEE80211_OFDM_RATE_48MB 0x60
385 #define IEEE80211_OFDM_RATE_54MB 0x6C
386 #define IEEE80211_BASIC_RATE_MASK 0x80
388 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
389 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
390 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
391 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
392 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
393 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
394 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
395 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
396 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
397 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
398 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
399 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
401 #define IEEE80211_CCK_RATES_MASK 0x0000000F
402 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
403 IEEE80211_CCK_RATE_2MB_MASK)
404 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
405 IEEE80211_CCK_RATE_5MB_MASK | \
406 IEEE80211_CCK_RATE_11MB_MASK)
408 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
409 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
410 IEEE80211_OFDM_RATE_12MB_MASK | \
411 IEEE80211_OFDM_RATE_24MB_MASK)
412 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
413 IEEE80211_OFDM_RATE_9MB_MASK | \
414 IEEE80211_OFDM_RATE_18MB_MASK | \
415 IEEE80211_OFDM_RATE_36MB_MASK | \
416 IEEE80211_OFDM_RATE_48MB_MASK | \
417 IEEE80211_OFDM_RATE_54MB_MASK)
418 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
419 IEEE80211_CCK_DEFAULT_RATES_MASK)
421 #define IEEE80211_NUM_OFDM_RATES 8
422 #define IEEE80211_NUM_CCK_RATES 4
423 #define IEEE80211_OFDM_SHIFT_MASK_A 4
515 #define IS_HT_RATE(_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
516 #define IS_VHT_RATE(_rate) (_rate >= MGN_VHT1SS_MCS0 && _rate <= MGN_VHT4SS_MCS9)
517 #define IS_CCK_RATE(_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
518 #define IS_OFDM_RATE(_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M)
521 /* NOTE: This data is for statistical purposes; not all hardware provides this
522 * information for frames received. Not setting these will not cause
523 * any adverse affects. */
524 struct ieee80211_rx_stats {
529 u16 rate; /* in 100 kbps */
535 /* IEEE 802.11 requires that STA supports concurrent reception of at least
536 * three fragmented frames. This define can be increased to support more
537 * concurrent frames, but it should be noted that each entry can consume about
538 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
539 #define IEEE80211_FRAG_CACHE_LEN 4
541 struct ieee80211_frag_entry {
545 uint qos; /* jackson */
546 uint tid; /* jackson */
548 u8 src_addr[ETH_ALEN];
549 u8 dst_addr[ETH_ALEN];
552 struct ieee80211_stats {
553 uint tx_unicast_frames;
554 uint tx_multicast_frames;
556 uint tx_unicast_octets;
557 uint tx_multicast_octets;
558 uint tx_deferred_transmissions;
559 uint tx_single_retry_frames;
560 uint tx_multiple_retry_frames;
561 uint tx_retry_limit_exceeded;
563 uint rx_unicast_frames;
564 uint rx_multicast_frames;
566 uint rx_unicast_octets;
567 uint rx_multicast_octets;
569 uint rx_discards_no_buffer;
570 uint tx_discards_wrong_sa;
571 uint rx_discards_undecryptable;
572 uint rx_message_in_msg_fragments;
573 uint rx_message_in_bad_msg_fragments;
576 struct ieee80211_softmac_stats {
596 #define SEC_KEY_1 (1<<0)
597 #define SEC_KEY_2 (1<<1)
598 #define SEC_KEY_3 (1<<2)
599 #define SEC_KEY_4 (1<<3)
600 #define SEC_ACTIVE_KEY (1<<4)
601 #define SEC_AUTH_MODE (1<<5)
602 #define SEC_UNICAST_GROUP (1<<6)
603 #define SEC_LEVEL (1<<7)
604 #define SEC_ENABLED (1<<8)
606 #define SEC_LEVEL_0 0 /* None */
607 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
608 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
609 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
610 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
613 #define WEP_KEY_LEN 13
615 #define BIP_MAX_KEYID 5
616 #define BIP_AAD_SIZE 20
618 struct ieee80211_security {
623 unicast_uses_group:1;
624 u8 key_sizes[WEP_KEYS];
625 u8 keys[WEP_KEYS][WEP_KEY_LEN];
628 } __attribute__ ((packed));
632 802.11 data frame from AP
634 ,-------------------------------------------------------------------.
635 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
636 |------|------|---------|---------|---------|------|---------|------|
637 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
638 | | tion | (BSSID) | | | ence | data | |
639 `-------------------------------------------------------------------'
645 struct ieee80211_header_data {
654 #define BEACON_PROBE_SSID_ID_POSITION 12
656 /* Management Frame Information Element Types */
657 #define MFIE_TYPE_SSID 0
658 #define MFIE_TYPE_RATES 1
659 #define MFIE_TYPE_FH_SET 2
660 #define MFIE_TYPE_DS_SET 3
661 #define MFIE_TYPE_CF_SET 4
662 #define MFIE_TYPE_TIM 5
663 #define MFIE_TYPE_IBSS_SET 6
664 #define MFIE_TYPE_CHALLENGE 16
665 #define MFIE_TYPE_ERP 42
666 #define MFIE_TYPE_RSN 48
667 #define MFIE_TYPE_RATES_EX 50
668 #define MFIE_TYPE_GENERIC 221
670 /* SWEEP TABLE ENTRIES NUMBER*/
671 #define MAX_SWEEP_TAB_ENTRIES 42
672 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
673 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
674 * only use 8, and then use extended rates for the remaining supported
675 * rates. Other APs, however, stick all of their supported rates on the
676 * main rates information element... */
677 #define MAX_RATES_LENGTH ((u8)12)
678 #define MAX_RATES_EX_LENGTH ((u8)16)
679 #define MAX_NETWORK_COUNT 128
680 #define MAX_CHANNEL_NUMBER 161
681 #define IEEE80211_SOFTMAC_SCAN_TIME 400
683 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
685 #define CRC_LENGTH 4U
687 #define MAX_WPA_IE_LEN (256)
688 #define MAX_WPS_IE_LEN (512)
689 #define MAX_P2P_IE_LEN (256)
690 #define MAX_WFD_IE_LEN (128)
692 #define NETWORK_EMPTY_ESSID (1<<0)
693 #define NETWORK_HAS_OFDM (1<<1)
694 #define NETWORK_HAS_CCK (1<<2)
696 #define IEEE80211_DTIM_MBCAST 4
697 #define IEEE80211_DTIM_UCAST 2
698 #define IEEE80211_DTIM_VALID 1
699 #define IEEE80211_DTIM_INVALID 0
701 #define IEEE80211_PS_DISABLED 0
702 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
703 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
704 #define IW_ESSID_MAX_SIZE 32
707 -1: authentication fail
712 enum ieee80211_state {
714 /* the card is not linked at all */
715 IEEE80211_NOLINK = 0,
717 /* IEEE80211_ASSOCIATING* are for BSS client mode
718 * the driver shall not perform RX filtering unless
719 * the state is LINKED.
720 * The driver shall just check for the state LINKED and
721 * defaults to NOLINK for ALL the other states (including
725 /* the association procedure will start (wq scheduling)*/
726 IEEE80211_ASSOCIATING,
727 IEEE80211_ASSOCIATING_RETRY,
729 /* the association procedure is sending AUTH request*/
730 IEEE80211_ASSOCIATING_AUTHENTICATING,
732 /* the association procedure has successfully authentcated
733 * and is sending association request
735 IEEE80211_ASSOCIATING_AUTHENTICATED,
737 /* the link is ok. the card associated to a BSS or linked
738 * to a ibss cell or acting as an AP and creating the bss
742 /* same as LINKED, but the driver shall apply RX filter
743 * rules as we are in NO_LINK mode. As the card is still
744 * logically linked, but it is doing a syncro site survey
745 * then it will be back to LINKED state.
747 IEEE80211_LINKED_SCANNING,
751 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
752 #define DEFAULT_FTS 2346
753 #define MAC_ARG(x) (x)
754 #define IP_ARG(x) (x)
756 static inline int is_multicast_mac_addr(const u8 *addr)
758 return ((addr[0] != 0xff) && (0x01 & addr[0]));
761 static inline int is_broadcast_mac_addr(const u8 *addr)
763 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
764 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
767 static inline int is_zero_mac_addr(const u8 *addr)
769 return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \
770 (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
773 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
774 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
778 #define IEEE_A (1<<0)
779 #define IEEE_B (1<<1)
780 #define IEEE_G (1<<2)
781 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
783 /* Action category code */
784 enum rtw_ieee80211_category {
785 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
786 RTW_WLAN_CATEGORY_QOS = 1,
787 RTW_WLAN_CATEGORY_DLS = 2,
788 RTW_WLAN_CATEGORY_BACK = 3,
789 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
790 RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
791 RTW_WLAN_CATEGORY_FT = 6,
792 RTW_WLAN_CATEGORY_HT = 7,
793 RTW_WLAN_CATEGORY_SA_QUERY = 8,
794 RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */
795 RTW_WLAN_CATEGORY_TDLS = 12,
796 RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, /* add for CONFIG_IEEE80211W, none 11w also can use */
797 RTW_WLAN_CATEGORY_WMM = 17,
798 RTW_WLAN_CATEGORY_VHT = 21,
799 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
802 enum _PUBLIC_ACTION {
803 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */
804 ACT_PUBLIC_DSE_ENABLE = 1,
805 ACT_PUBLIC_DSE_DEENABLE = 2,
806 ACT_PUBLIC_DSE_REG_LOCATION = 3,
807 ACT_PUBLIC_EXT_CHL_SWITCH = 4,
808 ACT_PUBLIC_DSE_MSR_REQ = 5,
809 ACT_PUBLIC_DSE_MSR_RPRT = 6,
810 ACT_PUBLIC_MP = 7, /* Measurement Pilot */
811 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
812 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */
813 ACT_PUBLIC_GAS_INITIAL_REQ = 10,
814 ACT_PUBLIC_GAS_INITIAL_RSP = 11,
815 ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
816 ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
817 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
818 ACT_PUBLIC_LOCATION_TRACK = 15,
822 /* BACK (block-ack) parties */
823 enum rtw_ieee80211_back_parties {
824 RTW_WLAN_BACK_RECIPIENT = 0,
825 RTW_WLAN_BACK_INITIATOR = 1,
826 RTW_WLAN_BACK_TIMER = 2,
829 /* VHT features action code */
830 enum rtw_ieee80211_vht_actioncode {
831 RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0,
832 RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1,
833 RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2,
837 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
839 #define WME_OUI_TYPE 2
840 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
841 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
842 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
843 #define WME_VERSION 1
845 #define WME_ACTION_CODE_SETUP_REQUEST 0
846 #define WME_ACTION_CODE_SETUP_RESPONSE 1
847 #define WME_ACTION_CODE_TEARDOWN 2
849 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
850 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
851 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
853 #define WME_TSPEC_DIRECTION_UPLINK 0
854 #define WME_TSPEC_DIRECTION_DOWNLINK 1
855 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
858 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
860 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
863 * enum rtw_ieee80211_channel_flags - channel flags
865 * Channel flags set by the regulatory control code.
867 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
868 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
870 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
871 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
872 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
874 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
877 enum rtw_ieee80211_channel_flags {
878 RTW_IEEE80211_CHAN_DISABLED = 1<<0,
879 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
880 RTW_IEEE80211_CHAN_NO_IBSS = 1<<2,
881 RTW_IEEE80211_CHAN_RADAR = 1<<3,
882 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
883 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
886 #define RTW_IEEE80211_CHAN_NO_HT40 \
887 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
889 /* Represent channel details, subset of ieee80211_channel */
890 struct rtw_ieee80211_channel {
891 /* enum nl80211_band band; */
892 /* u16 center_freq; */
895 /* int max_antenna_gain; */
897 /* int max_reg_power; */
898 /* bool beacon_found; */
899 /* u32 orig_flags; */
906 /*"center_freq:%u, "*/ \
909 /*"max_antenna_gain:%d\n"*/ \
910 /*"max_power:%d\n"*/ \
911 /*"max_reg_power:%d\n"*/ \
912 /*"beacon_found:%u\n"*/ \
913 /*"orig_flags:0x%08x\n"*/ \
914 /*"orig_mag:%d\n"*/ \
917 #define CHAN_ARG(channel) \
918 /*(channel)->band*/ \
919 /*, (channel)->center_freq*/ \
920 (channel)->hw_value \
922 /*, (channel)->max_antenna_gain*/ \
923 /*, (channel)->max_power*/ \
924 /*, (channel)->max_reg_power*/ \
925 /*, (channel)->beacon_found*/ \
926 /*, (channel)->orig_flags*/ \
927 /*, (channel)->orig_mag*/ \
928 /*, (channel)->orig_mpwr*/ \
930 /* Parsed Information Elements */
931 struct rtw_ieee802_11_elems {
951 u8 ext_supp_rates_len;
965 u8 supp_channels_len;
973 u8 ht_capabilities_len;
977 u8 vendor_ht_cap_len;
978 u8 *vht_capabilities;
979 u8 vht_capabilities_len;
981 u8 vht_operation_len;
982 u8 *vht_op_mode_notify;
983 u8 vht_op_mode_notify_len;
986 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
988 ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
989 struct rtw_ieee802_11_elems *elems,
992 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
993 u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
995 enum secondary_ch_offset {
996 SCN = 0, /* no secondary channel */
997 SCA = 1, /* secondary channel above */
998 SCB = 3, /* secondary channel below */
1001 u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
1002 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
1003 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
1005 void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
1007 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1008 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1009 int rtw_get_wpa_cipher_suite(u8 *s);
1010 int rtw_get_wpa2_cipher_suite(u8 *s);
1011 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1012 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1013 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1015 void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len);
1017 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1018 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1019 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr);
1020 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content);
1023 * for_each_ie - iterate over continuous IEs
1028 #define for_each_ie(ie, buf, buf_len) \
1029 for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1031 uint rtw_get_rateset_len(u8 *rateset);
1033 struct registry_priv;
1034 int rtw_generate_ie(struct registry_priv *pregistrypriv);
1037 int rtw_get_bit_value_from_ieee_value(u8 val);
1039 bool rtw_is_cckrates_included(u8 *rate);
1041 bool rtw_is_cckratesonly_included(u8 *rate);
1043 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1045 void rtw_get_bcn_info(struct wlan_network *pnetwork);
1047 void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr);
1049 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate);
1051 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
1052 const char *action_public_str(u8 action);
1054 #endif /* IEEE80211_H */