1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
10 #include <osdep_service.h>
11 #include <drv_types.h>
13 #include <linux/wireless.h>
15 #ifdef CONFIG_88EU_AP_MODE
17 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
19 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
21 RTL871X_HOSTAPD_FLUSH = 1,
22 RTL871X_HOSTAPD_ADD_STA = 2,
23 RTL871X_HOSTAPD_REMOVE_STA = 3,
24 RTL871X_HOSTAPD_GET_INFO_STA = 4,
25 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
26 RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
27 RTL871X_SET_ENCRYPTION = 6,
28 RTL871X_GET_ENCRYPTION = 7,
29 RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
30 RTL871X_HOSTAPD_GET_RID = 9,
31 RTL871X_HOSTAPD_SET_RID = 10,
32 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
33 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
34 RTL871X_HOSTAPD_MLME = 13,
35 RTL871X_HOSTAPD_SCAN_REQ = 14,
36 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
37 RTL871X_HOSTAPD_SET_BEACON = 16,
38 RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
39 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
40 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
41 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
42 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
43 RTL871X_HOSTAPD_ACL_ADD_STA = 22,
44 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
48 #define WLAN_STA_AUTH BIT(0)
49 #define WLAN_STA_ASSOC BIT(1)
50 #define WLAN_STA_PS BIT(2)
51 #define WLAN_STA_TIM BIT(3)
52 #define WLAN_STA_PERM BIT(4)
53 #define WLAN_STA_AUTHORIZED BIT(5)
54 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
55 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
56 #define WLAN_STA_PREAUTH BIT(8)
57 #define WLAN_STA_WME BIT(9)
58 #define WLAN_STA_MFP BIT(10)
59 #define WLAN_STA_HT BIT(11)
60 #define WLAN_STA_WPS BIT(12)
61 #define WLAN_STA_MAYBE_WPS BIT(13)
62 #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 AUTH_ALG_OPEN_SYSTEM 0x1
80 #define AUTH_ALG_SHARED_KEY 0x2
81 #define AUTH_ALG_LEAP 0x00000004
83 #define IEEE_MLME_STA_DEAUTH 1
84 #define IEEE_MLME_STA_DISASSOC 2
86 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
87 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
88 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
89 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
90 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
91 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
94 #define IEEE_CRYPT_ALG_NAME_LEN 16
96 #define WPA_CIPHER_NONE BIT(0)
97 #define WPA_CIPHER_WEP40 BIT(1)
98 #define WPA_CIPHER_WEP104 BIT(2)
99 #define WPA_CIPHER_TKIP BIT(3)
100 #define WPA_CIPHER_CCMP BIT(4)
104 #define WPA_SELECTOR_LEN 4
105 extern u8 RTW_WPA_OUI_TYPE[];
106 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
107 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
108 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
109 extern u8 WPA_CIPHER_SUITE_NONE[];
110 extern u8 WPA_CIPHER_SUITE_WEP40[];
111 extern u8 WPA_CIPHER_SUITE_TKIP[];
112 extern u8 WPA_CIPHER_SUITE_WRAP[];
113 extern u8 WPA_CIPHER_SUITE_CCMP[];
114 extern u8 WPA_CIPHER_SUITE_WEP104[];
117 #define RSN_HEADER_LEN 4
118 #define RSN_SELECTOR_LEN 4
120 extern u16 RSN_VERSION_BSD;
121 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
122 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
123 extern u8 RSN_CIPHER_SUITE_NONE[];
124 extern u8 RSN_CIPHER_SUITE_WEP40[];
125 extern u8 RSN_CIPHER_SUITE_TKIP[];
126 extern u8 RSN_CIPHER_SUITE_WRAP[];
127 extern u8 RSN_CIPHER_SUITE_CCMP[];
128 extern u8 RSN_CIPHER_SUITE_WEP104[];
130 enum ratr_table_mode {
131 RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */
132 RATR_INX_WIRELESS_NG = 1, /* GN or N */
133 RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */
134 RATR_INX_WIRELESS_N = 3,
135 RATR_INX_WIRELESS_GB = 4,
136 RATR_INX_WIRELESS_G = 5,
137 RATR_INX_WIRELESS_B = 6,
138 RATR_INX_WIRELESS_MC = 7,
139 RATR_INX_WIRELESS_AC_N = 8,
143 WIRELESS_INVALID = 0,
145 WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */
146 WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/
147 WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */
148 WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */
149 WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */
150 WIRELESS_AC = BIT(6),
153 /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
154 WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
155 /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
156 WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N),
157 /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
158 WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N),
159 /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
160 WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
161 /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
162 WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N |
164 WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G |
165 WIRELESS_11_24N | WIRELESS_11_5N),
168 #define SUPPORTED_24G_NETTYPE_MSK \
169 (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
170 #define SUPPORTED_5G_NETTYPE_MSK \
171 (WIRELESS_11A | WIRELESS_11_5N)
173 #define IsSupported24G(NetType) \
174 ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
175 #define IsSupported5G(NetType) \
176 ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false)
178 #define IsEnableHWCCK(NetType) \
179 IsSupported24G(NetType)
180 #define IsEnableHWOFDM(NetType) \
181 ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \
182 SUPPORTED_5G_NETTYPE_MSK) ? true : false)
184 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
185 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
186 #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
188 #define IsSupportedTxCCK(NetType) \
189 ((NetType) & (WIRELESS_11B) ? true : false)
190 #define IsSupportedTxOFDM(NetType) \
191 ((NetType) & (WIRELESS_11G | WIRELESS_11A) ? true : false)
192 #define IsSupportedTxMCS(NetType) \
193 ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? true : false)
198 u8 sta_addr[ETH_ALEN];
214 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
218 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
222 #ifdef CONFIG_88EU_AP_MODE
227 u8 tx_supp_rates[16];
228 struct ieee80211_ht_cap ht_cap;
231 u8 reserved[2];/* for set max_num_sta */
239 #ifdef CONFIG_88EU_AP_MODE
240 struct ieee_param_ex {
242 u8 sta_addr[ETH_ALEN];
251 u8 tx_supp_rates[16];
252 u32 tx_supp_rates_len;
253 struct ieee80211_ht_cap ht_cap;
263 #define IEEE80211_DATA_LEN 2304
264 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
267 * The figure in section 7.1.2 suggests a body size of up to 2312
268 * bytes is allowed, which is a bit confusing, I suspect this
269 * represents the 2304 bytes of real data, plus a possible 8 bytes of
270 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
274 #define IEEE80211_HLEN 30
275 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
278 /* this is stolen from ipw2200 driver */
279 #define IEEE_IBSS_MAC_HASH_SIZE 31
286 EAPOL_ENCAP_ASF_ALERT
289 #define IEEE80211_3ADDR_LEN 24
290 #define IEEE80211_4ADDR_LEN 30
291 #define IEEE80211_FCS_LEN 4
293 #define MIN_FRAG_THRESHOLD 256U
294 #define MAX_FRAG_THRESHOLD 2346U
296 /* sequence control field */
297 #define RTW_IEEE80211_SCTL_FRAG 0x000F
298 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
301 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
302 #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
303 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
308 #define NON_EXPLICIT_ACK 2
312 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
313 #endif /* ETH_P_PAE */
315 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
317 #define ETH_P_ECONET 0x0018
319 #ifndef ETH_P_80211_RAW
320 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
323 /* IEEE 802.11 defines */
325 #define P80211_OUI_LEN 3
327 struct ieee80211_snap_hdr {
328 u8 dsap; /* always 0xAA */
329 u8 ssap; /* always 0xAA */
330 u8 ctrl; /* always 0x03 */
331 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
334 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
336 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
338 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
339 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
341 /* Non standard? Not in <linux/ieee80211.h> */
342 #define WLAN_REASON_EXPIRATION_CHK 65535
344 #define IEEE80211_MGMT_HDR_LEN 24
345 #define IEEE80211_DATA_HDR3_LEN 24
346 #define IEEE80211_DATA_HDR4_LEN 30
348 #define IEEE80211_CCK_MODULATION BIT(0)
349 #define IEEE80211_OFDM_MODULATION BIT(1)
351 #define IEEE80211_24GHZ_BAND BIT(0)
352 #define IEEE80211_52GHZ_BAND BIT(1)
354 #define IEEE80211_CCK_RATE_LEN 4
355 #define IEEE80211_NUM_OFDM_RATESLEN 8
358 #define IEEE80211_CCK_RATE_1MB 0x02
359 #define IEEE80211_CCK_RATE_2MB 0x04
360 #define IEEE80211_CCK_RATE_5MB 0x0B
361 #define IEEE80211_CCK_RATE_11MB 0x16
362 #define IEEE80211_OFDM_RATE_LEN 8
363 #define IEEE80211_OFDM_RATE_6MB 0x0C
364 #define IEEE80211_OFDM_RATE_9MB 0x12
365 #define IEEE80211_OFDM_RATE_12MB 0x18
366 #define IEEE80211_OFDM_RATE_18MB 0x24
367 #define IEEE80211_OFDM_RATE_24MB 0x30
368 #define IEEE80211_OFDM_RATE_36MB 0x48
369 #define IEEE80211_OFDM_RATE_48MB 0x60
370 #define IEEE80211_OFDM_RATE_54MB 0x6C
371 #define IEEE80211_BASIC_RATE_MASK 0x80
373 #define IEEE80211_CCK_RATE_1MB_MASK BIT(0)
374 #define IEEE80211_CCK_RATE_2MB_MASK BIT(1)
375 #define IEEE80211_CCK_RATE_5MB_MASK BIT(2)
376 #define IEEE80211_CCK_RATE_11MB_MASK BIT(3)
377 #define IEEE80211_OFDM_RATE_6MB_MASK BIT(4)
378 #define IEEE80211_OFDM_RATE_9MB_MASK BIT(5)
379 #define IEEE80211_OFDM_RATE_12MB_MASK BIT(6)
380 #define IEEE80211_OFDM_RATE_18MB_MASK BIT(7)
381 #define IEEE80211_OFDM_RATE_24MB_MASK BIT(8)
382 #define IEEE80211_OFDM_RATE_36MB_MASK BIT(9)
383 #define IEEE80211_OFDM_RATE_48MB_MASK BIT(10)
384 #define IEEE80211_OFDM_RATE_54MB_MASK BIT(11)
386 #define IEEE80211_CCK_RATES_MASK 0x0000000F
387 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
388 IEEE80211_CCK_RATE_2MB_MASK)
389 #define IEEE80211_CCK_DEFAULT_RATES_MASK \
390 (IEEE80211_CCK_BASIC_RATES_MASK | \
391 IEEE80211_CCK_RATE_5MB_MASK | \
392 IEEE80211_CCK_RATE_11MB_MASK)
394 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
395 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
396 IEEE80211_OFDM_RATE_12MB_MASK | \
397 IEEE80211_OFDM_RATE_24MB_MASK)
398 #define IEEE80211_OFDM_DEFAULT_RATES_MASK \
399 (IEEE80211_OFDM_BASIC_RATES_MASK | \
400 IEEE80211_OFDM_RATE_9MB_MASK | \
401 IEEE80211_OFDM_RATE_18MB_MASK | \
402 IEEE80211_OFDM_RATE_36MB_MASK | \
403 IEEE80211_OFDM_RATE_48MB_MASK | \
404 IEEE80211_OFDM_RATE_54MB_MASK)
406 #define IEEE80211_NUM_OFDM_RATES 8
407 #define IEEE80211_NUM_CCK_RATES 4
408 #define IEEE80211_OFDM_SHIFT_MASK_A 4
410 /* IEEE 802.11 requires that STA supports concurrent reception of at least
411 * three fragmented frames. This define can be increased to support more
412 * concurrent frames, but it should be noted that each entry can consume about
413 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
415 #define IEEE80211_FRAG_CACHE_LEN 4
417 #define SEC_KEY_1 BIT(0)
418 #define SEC_KEY_2 BIT(1)
419 #define SEC_KEY_3 BIT(2)
420 #define SEC_KEY_4 BIT(3)
421 #define SEC_ACTIVE_KEY BIT(4)
422 #define SEC_AUTH_MODE BIT(5)
423 #define SEC_UNICAST_GROUP BIT(6)
424 #define SEC_LEVEL BIT(7)
425 #define SEC_ENABLED BIT(8)
427 #define SEC_LEVEL_0 0 /* None */
428 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
429 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
430 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
431 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
434 #define WEP_KEY_LEN 13
436 /* SWEEP TABLE ENTRIES NUMBER*/
437 #define MAX_SWEEP_TAB_ENTRIES 42
438 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
439 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
440 * only use 8, and then use extended rates for the remaining supported
441 * rates. Other APs, however, stick all of their supported rates on the
442 * main rates information element...
444 #define MAX_RATES_LENGTH ((u8)12)
445 #define MAX_RATES_EX_LENGTH ((u8)16)
446 #define MAX_NETWORK_COUNT 128
447 #define MAX_CHANNEL_NUMBER 161
448 #define IEEE80211_SOFTMAC_SCAN_TIME 400
450 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
452 #define CRC_LENGTH 4U
454 #define MAX_WPA_IE_LEN (256)
455 #define MAX_WPS_IE_LEN (512)
456 #define MAX_P2P_IE_LEN (256)
457 #define MAX_WFD_IE_LEN (128)
459 #define NETWORK_EMPTY_ESSID BIT(0)
460 #define NETWORK_HAS_OFDM BIT(1)
461 #define NETWORK_HAS_CCK BIT(2)
463 #define IW_ESSID_MAX_SIZE 32
466 * -1: authentication fail
467 * -2: association fail
471 enum ieee80211_state {
472 /* the card is not linked at all */
473 IEEE80211_NOLINK = 0,
475 /* IEEE80211_ASSOCIATING* are for BSS client mode
476 * the driver shall not perform RX filtering unless
477 * the state is LINKED.
478 * The driver shall just check for the state LINKED and
479 * defaults to NOLINK for ALL the other states (including
483 /* the association procedure will start (wq scheduling)*/
484 IEEE80211_ASSOCIATING,
485 IEEE80211_ASSOCIATING_RETRY,
487 /* the association procedure is sending AUTH request*/
488 IEEE80211_ASSOCIATING_AUTHENTICATING,
490 /* the association procedure has successfully authentcated
491 * and is sending association request
493 IEEE80211_ASSOCIATING_AUTHENTICATED,
495 /* the link is ok. the card associated to a BSS or linked
496 * to a ibss cell or acting as an AP and creating the bss
500 /* same as LINKED, but the driver shall apply RX filter
501 * rules as we are in NO_LINK mode. As the card is still
502 * logically linked, but it is doing a syncro site survey
503 * then it will be back to LINKED state.
505 IEEE80211_LINKED_SCANNING,
509 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
510 #define DEFAULT_FTS 2346
512 #define CFG_IEEE80211_RESERVE_FCS BIT(0)
513 #define CFG_IEEE80211_COMPUTE_FCS BIT(1)
517 #define IEEE_A BIT(0)
518 #define IEEE_B BIT(1)
519 #define IEEE_G BIT(2)
520 #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
522 /* Action category code */
523 enum rtw_ieee80211_category {
524 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
525 RTW_WLAN_CATEGORY_QOS = 1,
526 RTW_WLAN_CATEGORY_DLS = 2,
527 RTW_WLAN_CATEGORY_BACK = 3,
528 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
529 RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
530 RTW_WLAN_CATEGORY_FT = 6,
531 RTW_WLAN_CATEGORY_HT = 7,
532 RTW_WLAN_CATEGORY_SA_QUERY = 8,
533 RTW_WLAN_CATEGORY_TDLS = 12,
534 RTW_WLAN_CATEGORY_WMM = 17,
535 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
538 /* SPECTRUM_MGMT action code */
539 enum rtw_ieee80211_spectrum_mgmt_actioncode {
540 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
541 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
542 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
543 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
544 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
545 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
548 enum _PUBLIC_ACTION {
549 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */
550 ACT_PUBLIC_DSE_ENABLE = 1,
551 ACT_PUBLIC_DSE_DEENABLE = 2,
552 ACT_PUBLIC_DSE_REG_LOCATION = 3,
553 ACT_PUBLIC_EXT_CHL_SWITCH = 4,
554 ACT_PUBLIC_DSE_MSR_REQ = 5,
555 ACT_PUBLIC_DSE_MSR_RPRT = 6,
556 ACT_PUBLIC_MP = 7, /* Measurement Pilot */
557 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
558 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */
559 ACT_PUBLIC_GAS_INITIAL_REQ = 10,
560 ACT_PUBLIC_GAS_INITIAL_RSP = 11,
561 ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
562 ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
563 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
564 ACT_PUBLIC_LOCATION_TRACK = 15,
568 /* BACK action code */
569 enum rtw_ieee80211_back_actioncode {
570 RTW_WLAN_ACTION_ADDBA_REQ = 0,
571 RTW_WLAN_ACTION_ADDBA_RESP = 1,
572 RTW_WLAN_ACTION_DELBA = 2,
575 /* HT features action code */
576 enum rtw_ieee80211_ht_actioncode {
577 RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
578 RTW_WLAN_ACTION_SM_PS = 1,
579 RTW_WLAN_ACTION_PSPM = 2,
580 RTW_WLAN_ACTION_PCO_PHASE = 3,
581 RTW_WLAN_ACTION_MIMO_CSI_MX = 4,
582 RTW_WLAN_ACTION_MIMO_NONCP_BF = 5,
583 RTW_WLAN_ACTION_MIMP_CP_BF = 6,
584 RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7,
585 RTW_WLAN_ACTION_HI_INFO_EXCHG = 8,
588 /* BACK (block-ack) parties */
589 enum rtw_ieee80211_back_parties {
590 RTW_WLAN_BACK_RECIPIENT = 0,
591 RTW_WLAN_BACK_INITIATOR = 1,
592 RTW_WLAN_BACK_TIMER = 2,
595 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
598 #define WME_OUI_TYPE 2
599 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
600 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
601 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
602 #define WME_VERSION 1
604 #define WME_ACTION_CODE_SETUP_REQUEST 0
605 #define WME_ACTION_CODE_SETUP_RESPONSE 1
606 #define WME_ACTION_CODE_TEARDOWN 2
608 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
609 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
610 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
612 #define WME_TSPEC_DIRECTION_UPLINK 0
613 #define WME_TSPEC_DIRECTION_DOWNLINK 1
614 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
617 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
619 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
622 * enum rtw_ieee80211_channel_flags - channel flags
624 * Channel flags set by the regulatory control code.
626 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
627 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
629 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
630 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
631 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
633 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
636 enum rtw_ieee80211_channel_flags {
637 RTW_IEEE80211_CHAN_DISABLED = BIT(0),
638 RTW_IEEE80211_CHAN_PASSIVE_SCAN = BIT(1),
639 RTW_IEEE80211_CHAN_NO_IBSS = BIT(2),
640 RTW_IEEE80211_CHAN_RADAR = BIT(3),
641 RTW_IEEE80211_CHAN_NO_HT40PLUS = BIT(4),
642 RTW_IEEE80211_CHAN_NO_HT40MINUS = BIT(5),
645 #define RTW_IEEE80211_CHAN_NO_HT40 \
646 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
648 /* Represent channel details, subset of ieee80211_channel */
649 struct rtw_ieee80211_channel {
658 #define CHAN_ARG(channel) \
659 (channel)->hw_value \
662 /* Parsed Information Elements */
663 struct rtw_ieee802_11_elems {
683 u8 ext_supp_rates_len;
697 u8 supp_channels_len;
705 u8 ht_capabilities_len;
709 u8 vendor_ht_cap_len;
718 enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
719 struct rtw_ieee802_11_elems *elems,
722 u8 *rtw_set_fixed_ie(void *pbuf, unsigned int len,
723 void *source, unsigned int *frlen);
724 u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
726 enum secondary_ch_offset {
727 SCN = 0, /* no secondary channel */
728 SCA = 1, /* secondary channel above */
729 SCB = 3, /* secondary channel below */
732 u8 *rtw_get_ie(u8 *pbuf, int index, uint *len, int limit);
734 void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
736 unsigned char *rtw_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit);
737 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit);
738 int rtw_get_wpa_cipher_suite(u8 *s);
739 int rtw_get_wpa2_cipher_suite(u8 *s);
740 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
741 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
742 int *pairwise_cipher, int *is_8021x);
743 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
744 int *pairwise_cipher, int *is_8021x);
746 void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
747 u8 *wpa_ie, u16 *wpa_len);
749 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
750 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
751 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
752 u8 *buf_attr, u32 *len_attr);
753 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
754 u8 *buf_content, uint *len_content);
756 uint rtw_get_rateset_len(u8 *rateset);
758 struct registry_priv;
759 int rtw_generate_ie(struct registry_priv *pregistrypriv);
762 int rtw_get_bit_value_from_ieee_value(u8 val);
764 bool rtw_is_cckrates_included(u8 *rate);
766 bool rtw_is_cckratesonly_included(u8 *rate);
768 int rtw_check_network_type(unsigned char *rate);
770 void rtw_get_bcn_info(struct wlan_network *pnetwork);
772 void rtw_macaddr_cfg(u8 *mac_addr);
774 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
775 unsigned char *MCS_rate);
777 #endif /* IEEE80211_H */