1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2019 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 #ifndef __IEEE80211_H 16 #define __IEEE80211_H 17 18 #define MGMT_QUEUE_NUM 5 19 #define MAX_RF_PATH 4 20 #define RF_PATH_MAX MAX_RF_PATH 21 22 #define ETH_ALEN 6 23 #define ETH_TYPE_LEN 2 24 #define PAYLOAD_TYPE_LEN 1 25 26 #define NET80211_TU_TO_US 1024 /* unit:us */ 27 #define DEFAULT_BCN_INTERVAL 100 /* 100 ms */ 28 29 #ifdef CONFIG_AP_MODE 30 31 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28) 32 33 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ 34 enum { 35 RTL871X_HOSTAPD_FLUSH = 1, 36 RTL871X_HOSTAPD_ADD_STA = 2, 37 RTL871X_HOSTAPD_REMOVE_STA = 3, 38 RTL871X_HOSTAPD_GET_INFO_STA = 4, 39 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ 40 RTL871X_HOSTAPD_GET_WPAIE_STA = 5, 41 RTL871X_SET_ENCRYPTION = 6, 42 RTL871X_GET_ENCRYPTION = 7, 43 RTL871X_HOSTAPD_SET_FLAGS_STA = 8, 44 RTL871X_HOSTAPD_GET_RID = 9, 45 RTL871X_HOSTAPD_SET_RID = 10, 46 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11, 47 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12, 48 RTL871X_HOSTAPD_MLME = 13, 49 RTL871X_HOSTAPD_SCAN_REQ = 14, 50 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15, 51 RTL871X_HOSTAPD_SET_BEACON = 16, 52 RTL871X_HOSTAPD_SET_WPS_BEACON = 17, 53 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18, 54 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19, 55 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20, 56 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21, 57 RTL871X_HOSTAPD_ACL_ADD_STA = 22, 58 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23, 59 }; 60 61 /* STA flags */ 62 #define WLAN_STA_AUTH BIT(0) 63 #define WLAN_STA_ASSOC BIT(1) 64 #define WLAN_STA_PS BIT(2) 65 #define WLAN_STA_TIM BIT(3) 66 #define WLAN_STA_PERM BIT(4) 67 #define WLAN_STA_AUTHORIZED BIT(5) 68 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ 69 #define WLAN_STA_SHORT_PREAMBLE BIT(7) 70 #define WLAN_STA_PREAUTH BIT(8) 71 #define WLAN_STA_WME BIT(9) 72 #define WLAN_STA_MFP BIT(10) 73 #define WLAN_STA_HT BIT(11) 74 #define WLAN_STA_WPS BIT(12) 75 #define WLAN_STA_MAYBE_WPS BIT(13) 76 #define WLAN_STA_VHT BIT(14) 77 #define WLAN_STA_HE BIT(15) 78 #define WLAN_STA_WDS BIT(16) 79 #define WLAN_STA_MULTI_AP BIT(17) 80 #define WLAN_STA_AMSDU_DISABLE BIT(18) 81 #define WLAN_STA_NONERP BIT(31) 82 83 #endif 84 85 #define IEEE_CMD_SET_WPA_PARAM 1 86 #define IEEE_CMD_SET_WPA_IE 2 87 #define IEEE_CMD_SET_ENCRYPTION 3 88 #define IEEE_CMD_MLME 4 89 90 #define IEEE_PARAM_WPA_ENABLED 1 91 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2 92 #define IEEE_PARAM_DROP_UNENCRYPTED 3 93 #define IEEE_PARAM_PRIVACY_INVOKED 4 94 #define IEEE_PARAM_AUTH_ALGS 5 95 #define IEEE_PARAM_IEEE_802_1X 6 96 #define IEEE_PARAM_WPAX_SELECT 7 97 98 #define AUTH_ALG_OPEN_SYSTEM 0x1 99 #define AUTH_ALG_SHARED_KEY 0x2 100 #define AUTH_ALG_LEAP 0x00000004 101 102 #define IEEE_MLME_STA_DEAUTH 1 103 #define IEEE_MLME_STA_DISASSOC 2 104 105 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 106 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 107 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 108 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 109 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 110 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 111 112 113 #define IEEE_CRYPT_ALG_NAME_LEN 16 114 115 #define WPA_CIPHER_NONE BIT(0) 116 #define WPA_CIPHER_WEP40 BIT(1) 117 #define WPA_CIPHER_WEP104 BIT(2) 118 #define WPA_CIPHER_TKIP BIT(3) 119 #define WPA_CIPHER_CCMP BIT(4) 120 #define WPA_CIPHER_GCMP BIT(5) 121 #define WPA_CIPHER_GCMP_256 BIT(6) 122 #define WPA_CIPHER_CCMP_256 BIT(7) 123 #define WPA_CIPHER_BIP_CMAC_128 BIT(8) 124 #define WPA_CIPHER_BIP_GMAC_128 BIT(9) 125 #define WPA_CIPHER_BIP_GMAC_256 BIT(10) 126 #define WPA_CIPHER_BIP_CMAC_256 BIT(11) 127 128 129 #define WPA_SELECTOR_LEN 4 130 extern u8 RTW_WPA_OUI_TYPE[] ; 131 extern u16 RTW_WPA_VERSION ; 132 extern u8 WPA_AUTH_KEY_MGMT_NONE[]; 133 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; 134 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; 135 extern u8 WPA_CIPHER_SUITE_NONE[]; 136 extern u8 WPA_CIPHER_SUITE_WEP40[]; 137 extern u8 WPA_CIPHER_SUITE_TKIP[]; 138 extern u8 WPA_CIPHER_SUITE_WRAP[]; 139 extern u8 WPA_CIPHER_SUITE_CCMP[]; 140 extern u8 RSN_CIPHER_SUITE_GCMP[]; 141 extern u8 RSN_CIPHER_SUITE_GCMP_256[]; 142 extern u8 RSN_CIPHER_SUITE_CCMP_256[]; 143 extern u8 WPA_CIPHER_SUITE_WEP104[]; 144 145 146 #define RSN_HEADER_LEN 4 147 #define RSN_SELECTOR_LEN 4 148 #define RSN_PMKID_LEN 16 149 150 extern u16 RSN_VERSION_BSD; 151 extern u8 RSN_CIPHER_SUITE_NONE[]; 152 extern u8 RSN_CIPHER_SUITE_WEP40[]; 153 extern u8 RSN_CIPHER_SUITE_TKIP[]; 154 extern u8 RSN_CIPHER_SUITE_WRAP[]; 155 extern u8 RSN_CIPHER_SUITE_CCMP[]; 156 extern u8 RSN_CIPHER_SUITE_WEP104[]; 157 158 /* AKM suite type */ 159 extern u8 WLAN_AKM_8021X[]; 160 extern u8 WLAN_AKM_PSK[]; 161 extern u8 WLAN_AKM_FT_8021X[]; 162 extern u8 WLAN_AKM_FT_PSK[]; 163 extern u8 WLAN_AKM_8021X_SHA256[]; 164 extern u8 WLAN_AKM_PSK_SHA256[]; 165 extern u8 WLAN_AKM_TDLS[]; 166 extern u8 WLAN_AKM_SAE[]; 167 extern u8 WLAN_AKM_FT_OVER_SAE[]; 168 extern u8 WLAN_AKM_8021X_SUITE_B[]; 169 extern u8 WLAN_AKM_8021X_SUITE_B_192[]; 170 extern u8 WLAN_AKM_FILS_SHA256[]; 171 extern u8 WLAN_AKM_FILS_SHA384[]; 172 extern u8 WLAN_AKM_FT_FILS_SHA256[]; 173 extern u8 WLAN_AKM_FT_FILS_SHA384[]; 174 175 #define WLAN_AKM_TYPE_8021X BIT(0) 176 #define WLAN_AKM_TYPE_PSK BIT(1) 177 #define WLAN_AKM_TYPE_FT_8021X BIT(2) 178 #define WLAN_AKM_TYPE_FT_PSK BIT(3) 179 #define WLAN_AKM_TYPE_8021X_SHA256 BIT(4) 180 #define WLAN_AKM_TYPE_PSK_SHA256 BIT(5) 181 #define WLAN_AKM_TYPE_TDLS BIT(6) 182 #define WLAN_AKM_TYPE_SAE BIT(7) 183 #define WLAN_AKM_TYPE_FT_OVER_SAE BIT(8) 184 #define WLAN_AKM_TYPE_8021X_SUITE_B BIT(9) 185 #define WLAN_AKM_TYPE_8021X_SUITE_B_192 BIT(10) 186 #define WLAN_AKM_TYPE_FILS_SHA256 BIT(11) 187 #define WLAN_AKM_TYPE_FILS_SHA384 BIT(12) 188 #define WLAN_AKM_TYPE_FT_FILS_SHA256 BIT(13) 189 #define WLAN_AKM_TYPE_FT_FILS_SHA384 BIT(14) 190 191 /* IEEE 802.11i */ 192 #define PMKID_LEN 16 193 #define PMK_LEN 32 194 #define PMK_LEN_SUITE_B_192 48 195 #define PMK_LEN_MAX 48 196 #define WPA_REPLAY_COUNTER_LEN 8 197 #define WPA_NONCE_LEN 32 198 #define WPA_KEY_RSC_LEN 8 199 #define WPA_GMK_LEN 32 200 #define WPA_GTK_MAX_LEN 32 201 202 /* IEEE 802.11, 8.5.2 EAPOL-Key frames */ 203 #define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2))) 204 #define WPA_KEY_INFO_TYPE_AKM_DEFINED 0 205 #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0) 206 #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1) 207 #define WPA_KEY_INFO_TYPE_AES_128_CMAC 3 208 #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */ 209 /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */ 210 #define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5)) 211 #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4 212 #define WPA_KEY_INFO_INSTALL BIT(6) /* pairwise */ 213 #define WPA_KEY_INFO_TXRX BIT(6) /* group */ 214 #define WPA_KEY_INFO_ACK BIT(7) 215 #define WPA_KEY_INFO_MIC BIT(8) 216 #define WPA_KEY_INFO_SECURE BIT(9) 217 #define WPA_KEY_INFO_ERROR BIT(10) 218 #define WPA_KEY_INFO_REQUEST BIT(11) 219 #define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */ 220 #define WPA_KEY_INFO_SMK_MESSAGE BIT(13) 221 222 struct ieee802_1x_hdr { 223 u8 version; 224 u8 type; 225 u16 length; 226 /* followed by length octets of data */ 227 }; 228 229 struct wpa_eapol_key { 230 u8 type; 231 /* Note: key_info, key_length, and key_data_length are unaligned */ 232 u8 key_info[2]; /* big endian */ 233 u8 key_length[2]; /* big endian */ 234 u8 replay_counter[WPA_REPLAY_COUNTER_LEN]; 235 u8 key_nonce[WPA_NONCE_LEN]; 236 u8 key_iv[16]; 237 u8 key_rsc[WPA_KEY_RSC_LEN]; 238 u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN */ 239 u8 key_mic[16]; 240 u8 key_data_length[2]; /* big endian */ 241 /* followed by key_data_length bytes of key_data */ 242 }; 243 244 #define is_legacy_only(net_type) ((net_type) == ((net_type) & (WLAN_MD_11BG | WLAN_MD_11A))) 245 #define is_supported_24g(band_type) ((band_type) & BAND_CAP_2G ? _TRUE : _FALSE) 246 #define is_supported_5g(band_type) ((band_type) & BAND_CAP_5G ? _TRUE : _FALSE) 247 #define is_supported_6g(band_type) ((band_type) & BAND_CAP_6G ? _TRUE : _FALSE) 248 #define is_supported_tx_cck(net_type) ((net_type) & (WLAN_MD_11B) ? _TRUE : _FALSE) 249 #define is_suuported_tx_ofdm(net_type) ((net_type) & (WLAN_MD_11G | WLAN_MD_11A) ? _TRUE : _FALSE) 250 #define is_supported_ht(net_type) ((net_type) & (WLAN_MD_11N) ? _TRUE : _FALSE) 251 #define is_supported_vht(net_type) ((net_type) & (WLAN_MD_11AC) ? _TRUE : _FALSE) 252 #define is_supported_he(net_type) ((net_type) & (WLAN_MD_11AX) ? _TRUE : _FALSE) 253 254 255 256 typedef struct ieee_param { 257 u32 cmd; 258 u8 sta_addr[ETH_ALEN]; 259 union { 260 struct { 261 u8 name; 262 u32 value; 263 } wpa_param; 264 struct { 265 u32 len; 266 u8 reserved[32]; 267 u8 data[0]; 268 } wpa_ie; 269 struct { 270 int command; 271 int reason_code; 272 } mlme; 273 struct { 274 u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; 275 u8 set_tx; 276 u32 err; 277 u8 idx; 278 u8 seq[8]; /* sequence counter (set: RX, get: TX) */ 279 u16 key_len; 280 u8 key[0]; 281 } crypt; 282 #ifdef CONFIG_AP_MODE 283 struct { 284 u16 aid; 285 u16 capability; 286 int flags; 287 u8 tx_supp_rates[16]; 288 struct rtw_ieee80211_ht_cap ht_cap; 289 } add_sta; 290 struct { 291 u8 reserved[2];/* for set max_num_sta */ 292 u8 buf[0]; 293 } bcn_ie; 294 #endif 295 296 } u; 297 } ieee_param; 298 299 #ifdef CONFIG_AP_MODE 300 typedef struct ieee_param_ex { 301 u32 cmd; 302 u8 sta_addr[ETH_ALEN]; 303 u8 data[0]; 304 } ieee_param_ex; 305 306 struct sta_data { 307 u16 aid; 308 u16 capability; 309 int flags; 310 u32 sta_set; 311 u8 tx_supp_rates[16]; 312 u32 tx_supp_rates_len; 313 struct rtw_ieee80211_ht_cap ht_cap; 314 u64 rx_pkts; 315 u64 rx_bytes; 316 u64 rx_drops; 317 u64 tx_pkts; 318 u64 tx_bytes; 319 u64 tx_drops; 320 }; 321 #endif 322 323 324 #if WIRELESS_EXT < 17 325 #define IW_QUAL_QUAL_INVALID 0x10 326 #define IW_QUAL_LEVEL_INVALID 0x20 327 #define IW_QUAL_NOISE_INVALID 0x40 328 #define IW_QUAL_QUAL_UPDATED 0x1 329 #define IW_QUAL_LEVEL_UPDATED 0x2 330 #define IW_QUAL_NOISE_UPDATED 0x4 331 #endif 332 333 #define IEEE80211_DATA_LEN 2304 334 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 335 6.2.1.1.2. 336 337 The figure in section 7.1.2 suggests a body size of up to 2312 338 bytes is allowed, which is a bit confusing, I suspect this 339 represents the 2304 bytes of real data, plus a possible 8 bytes of 340 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 341 342 343 #define IEEE80211_HLEN 30 344 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) 345 346 347 /* this is stolen from ipw2200 driver */ 348 #define IEEE_IBSS_MAC_HASH_SIZE 31 349 350 struct ieee_ibss_seq { 351 u8 mac[ETH_ALEN]; 352 u16 seq_num; 353 u16 frag_num; 354 unsigned long packet_time; 355 _list list; 356 }; 357 358 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) 359 360 struct rtw_ieee80211_hdr { 361 u16 frame_ctl; 362 u16 duration_id; 363 u8 addr1[ETH_ALEN]; 364 u8 addr2[ETH_ALEN]; 365 u8 addr3[ETH_ALEN]; 366 u16 seq_ctl; 367 u8 addr4[ETH_ALEN]; 368 } __attribute__((packed)); 369 370 struct rtw_ieee80211_hdr_3addr { 371 u16 frame_ctl; 372 u16 duration_id; 373 u8 addr1[ETH_ALEN]; 374 u8 addr2[ETH_ALEN]; 375 u8 addr3[ETH_ALEN]; 376 u16 seq_ctl; 377 } __attribute__((packed)); 378 379 380 struct rtw_ieee80211_hdr_qos { 381 u16 frame_ctl; 382 u16 duration_id; 383 u8 addr1[ETH_ALEN]; 384 u8 addr2[ETH_ALEN]; 385 u8 addr3[ETH_ALEN]; 386 u16 seq_ctl; 387 u8 addr4[ETH_ALEN]; 388 u16 qc; 389 } __attribute__((packed)); 390 391 struct rtw_ieee80211_hdr_3addr_qos { 392 u16 frame_ctl; 393 u16 duration_id; 394 u8 addr1[ETH_ALEN]; 395 u8 addr2[ETH_ALEN]; 396 u8 addr3[ETH_ALEN]; 397 u16 seq_ctl; 398 u16 qc; 399 } __attribute__((packed)); 400 401 struct eapol { 402 u8 snap[6]; 403 u16 ethertype; 404 u8 version; 405 u8 type; 406 u16 length; 407 } __attribute__((packed)); 408 409 struct rtw_ieee80211s_hdr { 410 u8 flags; 411 u8 ttl; 412 u32 seqnum; 413 u8 eaddr1[ETH_ALEN]; 414 u8 eaddr2[ETH_ALEN]; 415 } __attribute__((packed)); 416 417 /** 418 * struct rtw_ieee80211_rann_ie 419 * 420 * This structure refers to "Root Announcement information element" 421 */ 422 struct rtw_ieee80211_rann_ie { 423 u8 rann_flags; 424 u8 rann_hopcount; 425 u8 rann_ttl; 426 u8 rann_addr[ETH_ALEN]; 427 u32 rann_seq; 428 u32 rann_interval; 429 u32 rann_metric; 430 } __attribute__((packed)); 431 #endif 432 433 /* Some IEEE 802.11x packet types are corresponding to parsing_eapol_packet() */ 434 enum eap_type { 435 EAP_PACKET = 0, 436 NON_EAPOL, 437 EAPOL_START, 438 EAPOL_LOGOFF, 439 EAPOL_KEY, 440 EAPOL_ENCAP_ASF_ALERT, 441 EAPOL_PACKET, 442 EAPOL_WPA_GROUP_KEY_1_2, 443 EAPOL_WPA_GROUP_KEY_2_2, 444 EAPOL_1_4, 445 EAPOL_2_4, 446 EAPOL_3_4, 447 EAPOL_4_4, 448 }; 449 450 #define IEEE80211_3ADDR_LEN 24 451 #define IEEE80211_4ADDR_LEN 30 452 #define IEEE80211_FCS_LEN 4 453 454 #define MIN_FRAG_THRESHOLD 256U 455 #define MAX_FRAG_THRESHOLD 2346U 456 457 /* Frame control field constants */ 458 #define RTW_IEEE80211_FCTL_VERS 0x0003 459 #define RTW_IEEE80211_FCTL_FTYPE 0x000c 460 #define RTW_IEEE80211_FCTL_STYPE 0x00f0 461 #define RTW_IEEE80211_FCTL_TODS 0x0100 462 #define RTW_IEEE80211_FCTL_FROMDS 0x0200 463 #define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400 464 #define RTW_IEEE80211_FCTL_RETRY 0x0800 465 #define RTW_IEEE80211_FCTL_PM 0x1000 466 #define RTW_IEEE80211_FCTL_MOREDATA 0x2000 467 #define RTW_IEEE80211_FCTL_PROTECTED 0x4000 468 #define RTW_IEEE80211_FCTL_ORDER 0x8000 469 #define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00 470 471 #define RTW_IEEE80211_FTYPE_MGMT 0x0000 472 #define RTW_IEEE80211_FTYPE_CTL 0x0004 473 #define RTW_IEEE80211_FTYPE_DATA 0x0008 474 #define RTW_IEEE80211_FTYPE_EXT 0x000c 475 476 /* management */ 477 #define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000 478 #define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010 479 #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020 480 #define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030 481 #define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040 482 #define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050 483 #define RTW_IEEE80211_STYPE_BEACON 0x0080 484 #define RTW_IEEE80211_STYPE_ATIM 0x0090 485 #define RTW_IEEE80211_STYPE_DISASSOC 0x00A0 486 #define RTW_IEEE80211_STYPE_AUTH 0x00B0 487 #define RTW_IEEE80211_STYPE_DEAUTH 0x00C0 488 #define RTW_IEEE80211_STYPE_ACTION 0x00D0 489 490 /* control */ 491 #define RTW_IEEE80211_STYPE_CTL_EXT 0x0060 492 #define RTW_IEEE80211_STYPE_BACK_REQ 0x0080 493 #define RTW_IEEE80211_STYPE_BACK 0x0090 494 #define RTW_IEEE80211_STYPE_PSPOLL 0x00A0 495 #define RTW_IEEE80211_STYPE_RTS 0x00B0 496 #define RTW_IEEE80211_STYPE_CTS 0x00C0 497 #define RTW_IEEE80211_STYPE_ACK 0x00D0 498 #define RTW_IEEE80211_STYPE_CFEND 0x00E0 499 #define RTW_IEEE80211_STYPE_CFENDACK 0x00F0 500 501 /* data */ 502 #define RTW_IEEE80211_STYPE_DATA 0x0000 503 #define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010 504 #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020 505 #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 506 #define RTW_IEEE80211_STYPE_NULLFUNC 0x0040 507 #define RTW_IEEE80211_STYPE_CFACK 0x0050 508 #define RTW_IEEE80211_STYPE_CFPOLL 0x0060 509 #define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070 510 #define RTW_IEEE80211_STYPE_QOS_DATA 0x0080 511 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 512 #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 513 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 514 #define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 515 #define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0 516 #define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0 517 #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 518 519 /* sequence control field */ 520 #define RTW_IEEE80211_SCTL_FRAG 0x000F 521 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0 522 523 524 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) 525 #define RTW_ERP_INFO_USE_PROTECTION BIT(1) 526 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) 527 528 /* QoS,QOS */ 529 #define NORMAL_ACK 0 530 #define NO_ACK 1 531 #define NON_EXPLICIT_ACK 2 532 #define BLOCK_ACK 3 533 534 #ifndef ETH_P_PAE 535 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 536 #endif /* ETH_P_PAE */ 537 538 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 539 540 #define ETH_P_ECONET 0x0018 541 542 #ifndef ETH_P_80211_RAW 543 #define ETH_P_80211_RAW (ETH_P_ECONET + 1) 544 #endif 545 546 /* IEEE 802.11 defines */ 547 548 #define P80211_OUI_LEN 3 549 550 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) 551 552 struct ieee80211_snap_hdr { 553 554 u8 dsap; /* always 0xAA */ 555 u8 ssap; /* always 0xAA */ 556 u8 ctrl; /* always 0x03 */ 557 u8 oui[P80211_OUI_LEN]; /* organizational universal id */ 558 559 } __attribute__((packed)); 560 561 #endif 562 563 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) 564 #ifdef CONFIG_CORE_TXSC 565 #define WLHDR_SIZE sizeof(struct rtw_ieee80211_hdr) 566 #endif 567 568 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE) 569 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE) 570 571 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) 572 573 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) 574 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) 575 576 /* Authentication algorithms */ 577 #define WLAN_AUTH_OPEN 0 578 #define WLAN_AUTH_SHARED_KEY 1 579 #define WLAN_AUTH_FT 2 580 #define WLAN_AUTH_SAE 3 581 582 #define WLAN_AUTH_CHALLENGE_LEN 128 583 584 #define WLAN_CAPABILITY_BSS (1<<0) 585 #define WLAN_CAPABILITY_IBSS (1<<1) 586 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 587 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 588 #define WLAN_CAPABILITY_PRIVACY (1<<4) 589 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 590 #define WLAN_CAPABILITY_PBCC (1<<6) 591 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 592 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) 593 594 /* Status codes */ 595 #define WLAN_STATUS_SUCCESS 0 596 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1 597 #define WLAN_STATUS_CAPS_UNSUPPORTED 10 598 #define WLAN_STATUS_REASSOC_NO_ASSOC 11 599 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 600 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 601 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 602 #define WLAN_STATUS_CHALLENGE_FAIL 15 603 #define WLAN_STATUS_AUTH_TIMEOUT 16 604 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 605 #define WLAN_STATUS_ASSOC_DENIED_RATES 18 606 /* 802.11b */ 607 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 608 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 609 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 610 611 /* Reason codes */ 612 #define WLAN_REASON_UNSPECIFIED 1 613 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2 614 #define WLAN_REASON_DEAUTH_LEAVING 3 615 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 616 #define WLAN_REASON_DISASSOC_AP_BUSY 5 617 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 618 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 619 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 620 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 621 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 622 #define WLAN_REASON_MESH_PEER_CANCELED 52 623 #define WLAN_REASON_MESH_MAX_PEERS 53 624 #define WLAN_REASON_MESH_CONFIG 54 625 #define WLAN_REASON_MESH_CLOSE 55 626 #define WLAN_REASON_MESH_MAX_RETRIES 56 627 #define WLAN_REASON_MESH_CONFIRM_TIMEOUT 57 628 #define WLAN_REASON_MESH_INVALID_GTK 58 629 #define WLAN_REASON_MESH_INCONSISTENT_PARAM 59 630 #define WLAN_REASON_MESH_INVALID_SECURITY 60 631 #define WLAN_REASON_MESH_PATH_NOPROXY 61 632 #define WLAN_REASON_MESH_PATH_NOFORWARD 62 633 #define WLAN_REASON_MESH_PATH_DEST_UNREACHABLE 63 634 #define WLAN_REASON_MAC_EXISTS_IN_MBSS 64 635 #define WLAN_REASON_MESH_CHAN_REGULATORY 65 636 #define WLAN_REASON_MESH_CHAN 66 637 #define WLAN_REASON_SA_QUERY_TIMEOUT 65532 638 #define WLAN_REASON_ACTIVE_ROAM 65533 639 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 640 #define WLAN_REASON_EXPIRATION_CHK 65535 641 642 #define WLAN_REASON_IS_PRIVATE(reason) ( \ 643 reason == WLAN_REASON_EXPIRATION_CHK \ 644 || reason == WLAN_REASON_JOIN_WRONG_CHANNEL \ 645 || reason == WLAN_REASON_ACTIVE_ROAM \ 646 || reason == WLAN_REASON_SA_QUERY_TIMEOUT \ 647 ) 648 649 /* Information Element IDs */ 650 #define WLAN_EID_SSID 0 651 #define WLAN_EID_SUPP_RATES 1 652 #define WLAN_EID_FH_PARAMS 2 653 #define WLAN_EID_DS_PARAMS 3 654 #define WLAN_EID_CF_PARAMS 4 655 #define WLAN_EID_TIM 5 656 #define WLAN_EID_IBSS_PARAMS 6 657 #define WLAN_EID_COUNTRY 7 658 #define WLAN_EID_CHALLENGE 16 659 /* EIDs defined by IEEE 802.11h - START */ 660 #define WLAN_EID_PWR_CONSTRAINT 32 661 #define WLAN_EID_PWR_CAPABILITY 33 662 #define WLAN_EID_TPC_REQUEST 34 663 #define WLAN_EID_TPC_REPORT 35 664 #define WLAN_EID_SUPPORTED_CHANNELS 36 665 #define WLAN_EID_CHANNEL_SWITCH 37 666 #define WLAN_EID_MEASURE_REQUEST 38 667 #define WLAN_EID_MEASURE_REPORT 39 668 #define WLAN_EID_QUITE 40 669 #define WLAN_EID_IBSS_DFS 41 670 /* EIDs defined by IEEE 802.11h - END */ 671 #define WLAN_EID_ERP_INFO 42 672 #define WLAN_EID_HT_CAP 45 673 #define WLAN_EID_RSN 48 674 #define WLAN_EID_EXT_SUPP_RATES 50 675 #define WLAN_EID_MOBILITY_DOMAIN 54 676 #define WLAN_EID_FAST_BSS_TRANSITION 55 677 #define WLAN_EID_TIMEOUT_INTERVAL 56 678 #define WLAN_EID_RIC_DATA 57 679 #define WLAN_EID_HT_OPERATION 61 680 #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62 681 #define WLAN_EID_MULTIPLE_BSSID 71 682 #define WLAN_EID_20_40_BSS_COEXISTENCE 72 683 #define WLAN_EID_20_40_BSS_INTOLERANT 73 684 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 685 #define WLAN_EID_MMIE 76 686 #define WLAN_EID_NON_TX_BSSID_CAP 83 687 #define WLAN_EID_MULTI_BSSID_IDX 85 688 #define WLAN_EID_MESH_CONFIG 113 689 #define WLAN_EID_MESH_ID 114 690 #define WLAN_EID_MPM 117 691 #define WLAN_EID_RANN 126 692 #define WLAN_EID_EXT_CAP 127 693 #define WLAN_EID_PREQ 130 694 #define WLAN_EID_PREP 131 695 #define WLAN_EID_PERR 132 696 #define WLAN_EID_AMPE 139 697 #define WLAN_EID_MIC 140 698 #define WLAN_EID_VENDOR_SPECIFIC 221 699 #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) 700 #define WLAN_EID_VHT_CAPABILITY 191 701 #define WLAN_EID_VHT_OPERATION 192 702 #define WLAN_EID_WIDE_BANDWIDTH_CHANNEL_SWITCH 194 703 #define WLAN_EID_CHANNEL_SWITCH_WRAPPER 196 704 #define WLAN_EID_VHT_OP_MODE_NOTIFY 199 705 #define WLAN_EID_EXTENSION 255 706 #define WLAN_EID_EXT_OWE_DH_PARAM 32 707 708 /* EID Extension */ 709 #define WLAN_EID_EXTENSION_HE_CAPABILITY 35 710 #define WLAN_EID_EXTENSION_HE_OPERATION 36 711 #define WLAN_EID_EXTENSION_HE_MU_EDCA 38 712 713 #define WLAN_EID_EXT_CAP_MAX_LEN 10 714 715 #define IEEE80211_MGMT_HDR_LEN 24 716 #define IEEE80211_DATA_HDR3_LEN 24 717 #define IEEE80211_DATA_HDR4_LEN 30 718 719 720 #define IEEE80211_STATMASK_SIGNAL (1<<0) 721 #define IEEE80211_STATMASK_RSSI (1<<1) 722 #define IEEE80211_STATMASK_NOISE (1<<2) 723 #define IEEE80211_STATMASK_RATE (1<<3) 724 #define IEEE80211_STATMASK_WEMASK 0x7 725 726 727 #define IEEE80211_CCK_MODULATION (1<<0) 728 #define IEEE80211_OFDM_MODULATION (1<<1) 729 730 #define IEEE80211_24GHZ_BAND (1<<0) 731 #define IEEE80211_52GHZ_BAND (1<<1) 732 733 #define IEEE80211_CCK_RATE_LEN 4 734 #define IEEE80211_NUM_OFDM_RATESLEN 8 735 736 737 738 #define IEEE80211_CCK_RATE_1MB 0x02 739 #define IEEE80211_CCK_RATE_2MB 0x04 740 #define IEEE80211_CCK_RATE_5MB 0x0B 741 #define IEEE80211_CCK_RATE_11MB 0x16 742 #define IEEE80211_OFDM_RATE_LEN 8 743 #define IEEE80211_OFDM_RATE_6MB 0x0C 744 #define IEEE80211_OFDM_RATE_9MB 0x12 745 #define IEEE80211_OFDM_RATE_12MB 0x18 746 #define IEEE80211_OFDM_RATE_18MB 0x24 747 #define IEEE80211_OFDM_RATE_24MB 0x30 748 #define IEEE80211_PBCC_RATE_22MB 0x2C 749 #define IEEE80211_FREAK_RATE_22_5MB 0x2D 750 #define IEEE80211_OFDM_RATE_36MB 0x48 751 #define IEEE80211_OFDM_RATE_48MB 0x60 752 #define IEEE80211_OFDM_RATE_54MB 0x6C 753 #define IEEE80211_BASIC_RATE_MASK 0x80 754 755 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 756 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 757 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 758 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 759 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 760 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 761 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 762 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 763 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 764 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 765 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 766 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 767 768 #define IEEE80211_CCK_RATES_MASK 0x0000000F 769 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 770 IEEE80211_CCK_RATE_2MB_MASK) 771 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ 772 IEEE80211_CCK_RATE_5MB_MASK | \ 773 IEEE80211_CCK_RATE_11MB_MASK) 774 775 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0 776 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ 777 IEEE80211_OFDM_RATE_12MB_MASK | \ 778 IEEE80211_OFDM_RATE_24MB_MASK) 779 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ 780 IEEE80211_OFDM_RATE_9MB_MASK | \ 781 IEEE80211_OFDM_RATE_18MB_MASK | \ 782 IEEE80211_OFDM_RATE_36MB_MASK | \ 783 IEEE80211_OFDM_RATE_48MB_MASK | \ 784 IEEE80211_OFDM_RATE_54MB_MASK) 785 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ 786 IEEE80211_CCK_DEFAULT_RATES_MASK) 787 788 #define IEEE80211_NUM_OFDM_RATES 8 789 #define IEEE80211_NUM_CCK_RATES 4 790 #define IEEE80211_OFDM_SHIFT_MASK_A 4 791 792 enum subelement_of_multiple_bssid_id { 793 MBSSID_NONTRANSMITTED_BSSID_PROFILE_ID = 0, 794 MBSSID_VENDOR_SPECIFIC_ID = 221 795 }; 796 797 enum MGN_RATE { 798 MGN_1M = 0x02, 799 MGN_2M = 0x04, 800 MGN_5_5M = 0x0B, 801 MGN_6M = 0x0C, 802 MGN_9M = 0x12, 803 MGN_11M = 0x16, 804 MGN_12M = 0x18, 805 MGN_18M = 0x24, 806 MGN_24M = 0x30, 807 MGN_36M = 0x48, 808 MGN_48M = 0x60, 809 MGN_54M = 0x6C, 810 MGN_MCS32 = 0x7F, 811 MGN_MCS0, 812 MGN_MCS1, 813 MGN_MCS2, 814 MGN_MCS3, 815 MGN_MCS4, 816 MGN_MCS5, 817 MGN_MCS6, 818 MGN_MCS7, 819 MGN_MCS8, 820 MGN_MCS9, 821 MGN_MCS10, 822 MGN_MCS11, 823 MGN_MCS12, 824 MGN_MCS13, 825 MGN_MCS14, 826 MGN_MCS15, 827 MGN_MCS16, 828 MGN_MCS17, 829 MGN_MCS18, 830 MGN_MCS19, 831 MGN_MCS20, 832 MGN_MCS21, 833 MGN_MCS22, 834 MGN_MCS23, 835 MGN_MCS24, 836 MGN_MCS25, 837 MGN_MCS26, 838 MGN_MCS27, 839 MGN_MCS28, 840 MGN_MCS29, 841 MGN_MCS30, 842 MGN_MCS31, 843 MGN_VHT1SS_MCS0, 844 MGN_VHT1SS_MCS1, 845 MGN_VHT1SS_MCS2, 846 MGN_VHT1SS_MCS3, 847 MGN_VHT1SS_MCS4, 848 MGN_VHT1SS_MCS5, 849 MGN_VHT1SS_MCS6, 850 MGN_VHT1SS_MCS7, 851 MGN_VHT1SS_MCS8, 852 MGN_VHT1SS_MCS9, 853 MGN_VHT2SS_MCS0, 854 MGN_VHT2SS_MCS1, 855 MGN_VHT2SS_MCS2, 856 MGN_VHT2SS_MCS3, 857 MGN_VHT2SS_MCS4, 858 MGN_VHT2SS_MCS5, 859 MGN_VHT2SS_MCS6, 860 MGN_VHT2SS_MCS7, 861 MGN_VHT2SS_MCS8, 862 MGN_VHT2SS_MCS9, 863 MGN_VHT3SS_MCS0, 864 MGN_VHT3SS_MCS1, 865 MGN_VHT3SS_MCS2, 866 MGN_VHT3SS_MCS3, 867 MGN_VHT3SS_MCS4, 868 MGN_VHT3SS_MCS5, 869 MGN_VHT3SS_MCS6, 870 MGN_VHT3SS_MCS7, 871 MGN_VHT3SS_MCS8, 872 MGN_VHT3SS_MCS9, 873 MGN_VHT4SS_MCS0, 874 MGN_VHT4SS_MCS1, 875 MGN_VHT4SS_MCS2, 876 MGN_VHT4SS_MCS3, 877 MGN_VHT4SS_MCS4, 878 MGN_VHT4SS_MCS5, 879 MGN_VHT4SS_MCS6, 880 MGN_VHT4SS_MCS7, 881 MGN_VHT4SS_MCS8, 882 MGN_VHT4SS_MCS9, 883 MGN_HE1SS_MCS0 = 0xd0, 884 MGN_HE1SS_MCS1, 885 MGN_HE1SS_MCS2, 886 MGN_HE1SS_MCS3, 887 MGN_HE1SS_MCS4, 888 MGN_HE1SS_MCS5, 889 MGN_HE1SS_MCS6, 890 MGN_HE1SS_MCS7, 891 MGN_HE1SS_MCS8, 892 MGN_HE1SS_MCS9, 893 MGN_HE1SS_MCS10, 894 MGN_HE1SS_MCS11, 895 MGN_HE2SS_MCS0, 896 MGN_HE2SS_MCS1, 897 MGN_HE2SS_MCS2, 898 MGN_HE2SS_MCS3, 899 MGN_HE2SS_MCS4, 900 MGN_HE2SS_MCS5, 901 MGN_HE2SS_MCS6, 902 MGN_HE2SS_MCS7, 903 MGN_HE2SS_MCS8, 904 MGN_HE2SS_MCS9, 905 MGN_HE2SS_MCS10, 906 MGN_HE2SS_MCS11, 907 MGN_HE3SS_MCS0, 908 MGN_HE3SS_MCS1, 909 MGN_HE3SS_MCS2, 910 MGN_HE3SS_MCS3, 911 MGN_HE3SS_MCS4, 912 MGN_HE3SS_MCS5, 913 MGN_HE3SS_MCS6, 914 MGN_HE3SS_MCS7, 915 MGN_HE3SS_MCS8, 916 MGN_HE3SS_MCS9, 917 MGN_HE3SS_MCS10, 918 MGN_HE3SS_MCS11, 919 MGN_HE4SS_MCS0, 920 MGN_HE4SS_MCS1, 921 MGN_HE4SS_MCS2, 922 MGN_HE4SS_MCS3, 923 MGN_HE4SS_MCS4, 924 MGN_HE4SS_MCS5, 925 MGN_HE4SS_MCS6, 926 MGN_HE4SS_MCS7, 927 MGN_HE4SS_MCS8, 928 MGN_HE4SS_MCS9, 929 MGN_HE4SS_MCS10, 930 MGN_HE4SS_MCS11 = 0xff, 931 MGN_UNKNOWN = 0xcc 932 }; 933 934 #define IS_HT_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS31) 935 #define IS_VHT_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9) 936 #define IS_CCK_RATE(_rate) ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M) 937 #define IS_OFDM_RATE(_rate) ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M) 938 939 #define IS_HT1SS_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS7) 940 #define IS_HT2SS_RATE(_rate) ((_rate) >= MGN_MCS8 && (_rate) <= MGN_MCS15) 941 #define IS_HT3SS_RATE(_rate) ((_rate) >= MGN_MCS16 && (_rate) <= MGN_MCS23) 942 #define IS_HT4SS_RATE(_rate) ((_rate) >= MGN_MCS24 && (_rate) <= MGN_MCS31) 943 944 #define IS_VHT1SS_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT1SS_MCS9) 945 #define IS_VHT2SS_RATE(_rate) ((_rate) >= MGN_VHT2SS_MCS0 && (_rate) <= MGN_VHT2SS_MCS9) 946 #define IS_VHT3SS_RATE(_rate) ((_rate) >= MGN_VHT3SS_MCS0 && (_rate) <= MGN_VHT3SS_MCS9) 947 #define IS_VHT4SS_RATE(_rate) ((_rate) >= MGN_VHT4SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9) 948 949 #define IS_1T_RATE(_rate) (IS_CCK_RATE((_rate)) || IS_OFDM_RATE((_rate)) || IS_HT1SS_RATE((_rate)) || IS_VHT1SS_RATE((_rate))) 950 #define IS_2T_RATE(_rate) (IS_HT2SS_RATE((_rate)) || IS_VHT2SS_RATE((_rate))) 951 #define IS_3T_RATE(_rate) (IS_HT3SS_RATE((_rate)) || IS_VHT3SS_RATE((_rate))) 952 #define IS_4T_RATE(_rate) (IS_HT4SS_RATE((_rate)) || IS_VHT4SS_RATE((_rate))) 953 954 #define MGN_RATE_STR(_rate) \ 955 (_rate == MGN_1M) ? "CCK_1M" : \ 956 (_rate == MGN_2M) ? "CCK_2M" : \ 957 (_rate == MGN_5_5M) ? "CCK_5.5M" : \ 958 (_rate == MGN_11M) ? "CCK_11M" : \ 959 (_rate == MGN_6M) ? "OFDM_6M" : \ 960 (_rate == MGN_9M) ? "OFDM_9M" : \ 961 (_rate == MGN_12M) ? "OFDM_12M" : \ 962 (_rate == MGN_18M) ? "OFDM_18M" : \ 963 (_rate == MGN_24M) ? "OFDM_24M" : \ 964 (_rate == MGN_36M) ? "OFDM_36M" : \ 965 (_rate == MGN_48M) ? "OFDM_48M" : \ 966 (_rate == MGN_54M) ? "OFDM_54M" : \ 967 (_rate == MGN_MCS32) ? "MCS32" : \ 968 (_rate == MGN_MCS0) ? "MCS0" : \ 969 (_rate == MGN_MCS1) ? "MCS1" : \ 970 (_rate == MGN_MCS2) ? "MCS2" : \ 971 (_rate == MGN_MCS3) ? "MCS3" : \ 972 (_rate == MGN_MCS4) ? "MCS4" : \ 973 (_rate == MGN_MCS5) ? "MCS5" : \ 974 (_rate == MGN_MCS6) ? "MCS6" : \ 975 (_rate == MGN_MCS7) ? "MCS7" : \ 976 (_rate == MGN_MCS8) ? "MCS8" : \ 977 (_rate == MGN_MCS9) ? "MCS9" : \ 978 (_rate == MGN_MCS10) ? "MCS10" : \ 979 (_rate == MGN_MCS11) ? "MCS11" : \ 980 (_rate == MGN_MCS12) ? "MCS12" : \ 981 (_rate == MGN_MCS13) ? "MCS13" : \ 982 (_rate == MGN_MCS14) ? "MCS14" : \ 983 (_rate == MGN_MCS15) ? "MCS15" : \ 984 (_rate == MGN_MCS16) ? "MCS16" : \ 985 (_rate == MGN_MCS17) ? "MCS17" : \ 986 (_rate == MGN_MCS18) ? "MCS18" : \ 987 (_rate == MGN_MCS19) ? "MCS19" : \ 988 (_rate == MGN_MCS20) ? "MCS20" : \ 989 (_rate == MGN_MCS21) ? "MCS21" : \ 990 (_rate == MGN_MCS22) ? "MCS22" : \ 991 (_rate == MGN_MCS23) ? "MCS23" : \ 992 (_rate == MGN_MCS24) ? "MCS24" : \ 993 (_rate == MGN_MCS25) ? "MCS25" : \ 994 (_rate == MGN_MCS26) ? "MCS26" : \ 995 (_rate == MGN_MCS27) ? "MCS27" : \ 996 (_rate == MGN_MCS28) ? "MCS28" : \ 997 (_rate == MGN_MCS29) ? "MCS29" : \ 998 (_rate == MGN_MCS30) ? "MCS30" : \ 999 (_rate == MGN_MCS31) ? "MCS31" : \ 1000 (_rate == MGN_VHT1SS_MCS0) ? "VHT1SMCS0" : \ 1001 (_rate == MGN_VHT1SS_MCS1) ? "VHT1SMCS1" : \ 1002 (_rate == MGN_VHT1SS_MCS2) ? "VHT1SMCS2" : \ 1003 (_rate == MGN_VHT1SS_MCS3) ? "VHT1SMCS3" : \ 1004 (_rate == MGN_VHT1SS_MCS4) ? "VHT1SMCS4" : \ 1005 (_rate == MGN_VHT1SS_MCS5) ? "VHT1SMCS5" : \ 1006 (_rate == MGN_VHT1SS_MCS6) ? "VHT1SMCS6" : \ 1007 (_rate == MGN_VHT1SS_MCS7) ? "VHT1SMCS7" : \ 1008 (_rate == MGN_VHT1SS_MCS8) ? "VHT1SMCS8" : \ 1009 (_rate == MGN_VHT1SS_MCS9) ? "VHT1SMCS9" : \ 1010 (_rate == MGN_VHT2SS_MCS0) ? "VHT2SMCS0" : \ 1011 (_rate == MGN_VHT2SS_MCS1) ? "VHT2SMCS1" : \ 1012 (_rate == MGN_VHT2SS_MCS2) ? "VHT2SMCS2" : \ 1013 (_rate == MGN_VHT2SS_MCS3) ? "VHT2SMCS3" : \ 1014 (_rate == MGN_VHT2SS_MCS4) ? "VHT2SMCS4" : \ 1015 (_rate == MGN_VHT2SS_MCS5) ? "VHT2SMCS5" : \ 1016 (_rate == MGN_VHT2SS_MCS6) ? "VHT2SMCS6" : \ 1017 (_rate == MGN_VHT2SS_MCS7) ? "VHT2SMCS7" : \ 1018 (_rate == MGN_VHT2SS_MCS8) ? "VHT2SMCS8" : \ 1019 (_rate == MGN_VHT2SS_MCS9) ? "VHT2SMCS9" : \ 1020 (_rate == MGN_VHT3SS_MCS0) ? "VHT3SMCS0" : \ 1021 (_rate == MGN_VHT3SS_MCS1) ? "VHT3SMCS1" : \ 1022 (_rate == MGN_VHT3SS_MCS2) ? "VHT3SMCS2" : \ 1023 (_rate == MGN_VHT3SS_MCS3) ? "VHT3SMCS3" : \ 1024 (_rate == MGN_VHT3SS_MCS4) ? "VHT3SMCS4" : \ 1025 (_rate == MGN_VHT3SS_MCS5) ? "VHT3SMCS5" : \ 1026 (_rate == MGN_VHT3SS_MCS6) ? "VHT3SMCS6" : \ 1027 (_rate == MGN_VHT3SS_MCS7) ? "VHT3SMCS7" : \ 1028 (_rate == MGN_VHT3SS_MCS8) ? "VHT3SMCS8" : \ 1029 (_rate == MGN_VHT3SS_MCS9) ? "VHT3SMCS9" : \ 1030 (_rate == MGN_VHT4SS_MCS0) ? "VHT4SMCS0" : \ 1031 (_rate == MGN_VHT4SS_MCS1) ? "VHT4SMCS1" : \ 1032 (_rate == MGN_VHT4SS_MCS2) ? "VHT4SMCS2" : \ 1033 (_rate == MGN_VHT4SS_MCS3) ? "VHT4SMCS3" : \ 1034 (_rate == MGN_VHT4SS_MCS4) ? "VHT4SMCS4" : \ 1035 (_rate == MGN_VHT4SS_MCS5) ? "VHT4SMCS5" : \ 1036 (_rate == MGN_VHT4SS_MCS6) ? "VHT4SMCS6" : \ 1037 (_rate == MGN_VHT4SS_MCS7) ? "VHT4SMCS7" : \ 1038 (_rate == MGN_VHT4SS_MCS8) ? "VHT4SMCS8" : \ 1039 (_rate == MGN_VHT4SS_MCS9) ? "VHT4SMCS9" : "UNKNOWN" 1040 1041 typedef enum _RATE_SECTION { 1042 CCK = 0, 1043 OFDM = 1, 1044 HT_MCS0_MCS7 = 2, 1045 HT_MCS8_MCS15 = 3, 1046 HT_MCS16_MCS23 = 4, 1047 HT_MCS24_MCS31 = 5, 1048 HT_1SS = HT_MCS0_MCS7, 1049 HT_2SS = HT_MCS8_MCS15, 1050 HT_3SS = HT_MCS16_MCS23, 1051 HT_4SS = HT_MCS24_MCS31, 1052 VHT_1SSMCS0_1SSMCS9 = 6, 1053 VHT_2SSMCS0_2SSMCS9 = 7, 1054 VHT_3SSMCS0_3SSMCS9 = 8, 1055 VHT_4SSMCS0_4SSMCS9 = 9, 1056 VHT_1SS = VHT_1SSMCS0_1SSMCS9, 1057 VHT_2SS = VHT_2SSMCS0_2SSMCS9, 1058 VHT_3SS = VHT_3SSMCS0_3SSMCS9, 1059 VHT_4SS = VHT_4SSMCS0_4SSMCS9, 1060 RATE_SECTION_NUM, 1061 } RATE_SECTION; 1062 1063 RATE_SECTION mgn_rate_to_rs(enum MGN_RATE rate); 1064 1065 const char *rate_section_str(u8 section); 1066 1067 #define IS_CCK_RATE_SECTION(section) ((section) == CCK) 1068 #define IS_OFDM_RATE_SECTION(section) ((section) == OFDM) 1069 #define IS_HT_RATE_SECTION(section) ((section) >= HT_1SS && (section) <= HT_4SS) 1070 #define IS_VHT_RATE_SECTION(section) ((section) >= VHT_1SS && (section) <= VHT_4SS) 1071 1072 #define IS_1T_RATE_SECTION(section) ((section) == CCK || (section) == OFDM || (section) == HT_1SS || (section) == VHT_1SS) 1073 #define IS_2T_RATE_SECTION(section) ((section) == HT_2SS || (section) == VHT_2SS) 1074 #define IS_3T_RATE_SECTION(section) ((section) == HT_3SS || (section) == VHT_3SS) 1075 #define IS_4T_RATE_SECTION(section) ((section) == HT_4SS || (section) == VHT_4SS) 1076 1077 extern u8 mgn_rates_cck[]; 1078 extern u8 mgn_rates_ofdm[]; 1079 extern u8 mgn_rates_mcs0_7[]; 1080 extern u8 mgn_rates_mcs8_15[]; 1081 extern u8 mgn_rates_mcs16_23[]; 1082 extern u8 mgn_rates_mcs24_31[]; 1083 extern u8 mgn_rates_vht1ss[]; 1084 extern u8 mgn_rates_vht2ss[]; 1085 extern u8 mgn_rates_vht3ss[]; 1086 extern u8 mgn_rates_vht4ss[]; 1087 1088 struct rate_section_ent { 1089 u8 tx_num; /* value of RF_TX_NUM */ 1090 u8 rate_num; 1091 u8 *rates; 1092 }; 1093 1094 extern struct rate_section_ent rates_by_sections[]; 1095 1096 #define rate_section_to_tx_num(section) (rates_by_sections[(section)].tx_num) 1097 #define rate_section_rate_num(section) (rates_by_sections[(section)].rate_num) 1098 1099 /* NOTE: This data is for statistical purposes; not all hardware provides this 1100 * information for frames received. Not setting these will not cause 1101 * any adverse affects. */ 1102 struct ieee80211_rx_stats { 1103 /* u32 mac_time[2]; */ 1104 s8 rssi; 1105 u8 signal; 1106 u8 noise; 1107 u8 received_channel; 1108 u16 rate; /* in 100 kbps */ 1109 /* u8 control; */ 1110 u8 mask; 1111 u8 freq; 1112 u16 len; 1113 }; 1114 1115 /* IEEE 802.11 requires that STA supports concurrent reception of at least 1116 * three fragmented frames. This define can be increased to support more 1117 * concurrent frames, but it should be noted that each entry can consume about 1118 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 1119 #define IEEE80211_FRAG_CACHE_LEN 4 1120 1121 struct ieee80211_frag_entry { 1122 u32 first_frag_time; 1123 uint seq; 1124 uint last_frag; 1125 uint qos; /* jackson */ 1126 uint tid; /* jackson */ 1127 struct sk_buff *skb; 1128 u8 src_addr[ETH_ALEN]; 1129 u8 dst_addr[ETH_ALEN]; 1130 }; 1131 1132 #define SEC_KEY_1 (1<<0) 1133 #define SEC_KEY_2 (1<<1) 1134 #define SEC_KEY_3 (1<<2) 1135 #define SEC_KEY_4 (1<<3) 1136 #define SEC_ACTIVE_KEY (1<<4) 1137 #define SEC_AUTH_MODE (1<<5) 1138 #define SEC_UNICAST_GROUP (1<<6) 1139 #define SEC_LEVEL (1<<7) 1140 #define SEC_ENABLED (1<<8) 1141 1142 #define SEC_LEVEL_0 0 /* None */ 1143 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 1144 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ 1145 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ 1146 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ 1147 1148 #define WEP_KEYS 4 1149 #define WEP_KEY_LEN 13 1150 #define BIP_MAX_KEYID 5 1151 #define BIP_AAD_SIZE 20 1152 1153 #if defined(PLATFORM_LINUX) 1154 struct ieee80211_security { 1155 u16 active_key:2, 1156 enabled:1, 1157 auth_mode:2, 1158 auth_algo:4, 1159 unicast_uses_group:1; 1160 u8 key_sizes[WEP_KEYS]; 1161 u8 keys[WEP_KEYS][WEP_KEY_LEN]; 1162 u8 level; 1163 u16 flags; 1164 } __attribute__((packed)); 1165 1166 #endif 1167 1168 /* 1169 1170 802.11 data frame from AP 1171 1172 ,-------------------------------------------------------------------. 1173 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | 1174 |------|------|---------|---------|---------|------|---------|------| 1175 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | 1176 | | tion | (BSSID) | | | ence | data | | 1177 `-------------------------------------------------------------------' 1178 1179 Total: 28-2340 bytes 1180 1181 */ 1182 1183 struct ieee80211_header_data { 1184 u16 frame_ctl; 1185 u16 duration_id; 1186 u8 addr1[6]; 1187 u8 addr2[6]; 1188 u8 addr3[6]; 1189 u16 seq_ctrl; 1190 }; 1191 1192 #define BEACON_PROBE_SSID_ID_POSITION 12 1193 1194 /* Management Frame Information Element Types */ 1195 #define MFIE_TYPE_SSID 0 1196 #define MFIE_TYPE_RATES 1 1197 #define MFIE_TYPE_FH_SET 2 1198 #define MFIE_TYPE_DS_SET 3 1199 #define MFIE_TYPE_CF_SET 4 1200 #define MFIE_TYPE_TIM 5 1201 #define MFIE_TYPE_IBSS_SET 6 1202 #define MFIE_TYPE_CHALLENGE 16 1203 #define MFIE_TYPE_ERP 42 1204 #define MFIE_TYPE_RSN 48 1205 #define MFIE_TYPE_RATES_EX 50 1206 #define MFIE_TYPE_GENERIC 221 1207 1208 #if defined(PLATFORM_LINUX) 1209 struct ieee80211_info_element_hdr { 1210 u8 id; 1211 u8 len; 1212 } __attribute__((packed)); 1213 1214 struct ieee80211_info_element { 1215 u8 id; 1216 u8 len; 1217 u8 data[0]; 1218 } __attribute__((packed)); 1219 #endif 1220 1221 1222 /* 1223 * These are the data types that can make up management packets 1224 * 1225 u16 auth_algorithm; 1226 u16 auth_sequence; 1227 u16 beacon_interval; 1228 u16 capability; 1229 u8 current_ap[ETH_ALEN]; 1230 u16 listen_interval; 1231 struct { 1232 u16 association_id:14, reserved:2; 1233 } __attribute__ ((packed)); 1234 u32 time_stamp[2]; 1235 u16 reason; 1236 u16 status; 1237 */ 1238 1239 #define IEEE80211_DEFAULT_TX_ESSID "Penguin" 1240 #define IEEE80211_DEFAULT_BASIC_RATE 10 1241 1242 1243 #if defined(PLATFORM_LINUX) 1244 struct ieee80211_authentication { 1245 struct ieee80211_header_data header; 1246 u16 algorithm; 1247 u16 transaction; 1248 u16 status; 1249 /* struct ieee80211_info_element_hdr info_element; */ 1250 } __attribute__((packed)); 1251 1252 1253 struct ieee80211_probe_response { 1254 struct ieee80211_header_data header; 1255 u32 time_stamp[2]; 1256 u16 beacon_interval; 1257 u16 capability; 1258 struct ieee80211_info_element info_element; 1259 } __attribute__((packed)); 1260 1261 struct ieee80211_probe_request { 1262 struct ieee80211_header_data header; 1263 /*struct ieee80211_info_element info_element;*/ 1264 } __attribute__((packed)); 1265 1266 struct ieee80211_assoc_request_frame { 1267 struct rtw_ieee80211_hdr_3addr header; 1268 u16 capability; 1269 u16 listen_interval; 1270 /* u8 current_ap[ETH_ALEN]; */ 1271 struct ieee80211_info_element_hdr info_element; 1272 } __attribute__((packed)); 1273 1274 struct ieee80211_assoc_response_frame { 1275 struct rtw_ieee80211_hdr_3addr header; 1276 u16 capability; 1277 u16 status; 1278 u16 aid; 1279 /* struct ieee80211_info_element info_element; supported rates */ 1280 } __attribute__((packed)); 1281 #endif 1282 1283 struct ieee80211_txb { 1284 u8 nr_frags; 1285 u8 encrypted; 1286 u16 reserved; 1287 u16 frag_size; 1288 u16 payload_size; 1289 struct sk_buff *fragments[0]; 1290 }; 1291 1292 1293 /* SWEEP TABLE ENTRIES NUMBER*/ 1294 #define MAX_SWEEP_TAB_ENTRIES 42 1295 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 1296 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs 1297 * only use 8, and then use extended rates for the remaining supported 1298 * rates. Other APs, however, stick all of their supported rates on the 1299 * main rates information element... */ 1300 #define MAX_RATES_LENGTH ((u8)12) 1301 #define MAX_RATES_EX_LENGTH ((u8)16) 1302 #define MAX_NETWORK_COUNT 128 1303 #define IEEE80211_SOFTMAC_SCAN_TIME 400 1304 /* (HZ / 2) */ 1305 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) 1306 1307 #define CRC_LENGTH 4U 1308 1309 #define MAX_WPA_IE_LEN (256) 1310 #define MAX_WPS_IE_LEN (512) 1311 #define MAX_OWE_IE_LEN (128) 1312 #define MAX_P2P_IE_LEN (256) 1313 #define MAX_WFD_IE_LEN (128) 1314 1315 #define NETWORK_EMPTY_ESSID (1<<0) 1316 #define NETWORK_HAS_OFDM (1<<1) 1317 #define NETWORK_HAS_CCK (1<<2) 1318 1319 #define IEEE80211_DTIM_MBCAST 4 1320 #define IEEE80211_DTIM_UCAST 2 1321 #define IEEE80211_DTIM_VALID 1 1322 #define IEEE80211_DTIM_INVALID 0 1323 1324 #define IEEE80211_PS_DISABLED 0 1325 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST 1326 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST 1327 #define IW_ESSID_MAX_SIZE 32 1328 1329 1330 #define DEFAULT_MAX_SCAN_AGE (15 * HZ) 1331 #define DEFAULT_FTS 2346 1332 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" 1333 #define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] 1334 #define MAC_SFMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx" 1335 #define MAC_SARG(x) ((u8*)(x)),((u8*)(x)) + 1,((u8*)(x)) + 2,((u8*)(x)) + 3,((u8*)(x)) + 4,((u8*)(x)) + 5 1336 #define IP_FMT "%d.%d.%d.%d" 1337 #define IP_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3] 1338 #define PORT_FMT "%u" 1339 #define PORT_ARG(x) ntohs(*((u16 *)(x))) 1340 1341 #define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff)) 1342 #define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \ 1343 (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ 1344 (((Addr[5]) & 0xff) == 0xff)) 1345 #define is_zero_mac_addr(Addr) ((Addr[0] == 0x00) && (Addr[1] == 0x00) && (Addr[2] == 0x00) && \ 1346 (Addr[3] == 0x00) && (Addr[4] == 0x00) && (Addr[5] == 0x00)) 1347 1348 1349 #define CFG_IEEE80211_RESERVE_FCS (1<<0) 1350 #define CFG_IEEE80211_COMPUTE_FCS (1<<1) 1351 1352 typedef struct tx_pending_t { 1353 int frag; 1354 struct ieee80211_txb *txb; 1355 } tx_pending_t; 1356 1357 1358 1359 #define TID_NUM 16 1360 1361 #define IEEE_A (1<<0) 1362 #define IEEE_B (1<<1) 1363 #define IEEE_G (1<<2) 1364 #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G) 1365 1366 /* Baron move to ieee80211.c */ 1367 int ieee80211_is_empty_essid(const char *essid, int essid_len); 1368 int ieee80211_get_hdrlen(u16 fc); 1369 1370 #if 0 1371 /* Action frame categories (IEEE 802.11-2007, 7.3.1.11, Table 7-24) */ 1372 #define WLAN_ACTION_SPECTRUM_MGMT 0 1373 #define WLAN_ACTION_QOS 1 1374 #define WLAN_ACTION_DLS 2 1375 #define WLAN_ACTION_BLOCK_ACK 3 1376 #define WLAN_ACTION_RADIO_MEASUREMENT 5 1377 #define WLAN_ACTION_FT 6 1378 #define WLAN_ACTION_SA_QUERY 8 1379 #define WLAN_ACTION_WMM 17 1380 #endif 1381 1382 1383 /* Action category code */ 1384 enum rtw_ieee80211_category { 1385 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, 1386 RTW_WLAN_CATEGORY_QOS = 1, 1387 RTW_WLAN_CATEGORY_DLS = 2, 1388 RTW_WLAN_CATEGORY_BACK = 3, 1389 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ 1390 RTW_WLAN_CATEGORY_RADIO_MEAS = 5, 1391 RTW_WLAN_CATEGORY_FT = 6, 1392 RTW_WLAN_CATEGORY_HT = 7, 1393 RTW_WLAN_CATEGORY_SA_QUERY = 8, 1394 RTW_WLAN_CATEGORY_WNM = 10, 1395 RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */ 1396 RTW_WLAN_CATEGORY_TDLS = 12, 1397 RTW_WLAN_CATEGORY_MESH = 13, 1398 RTW_WLAN_CATEGORY_MULTIHOP = 14, 1399 RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, 1400 RTW_WLAN_CATEGORY_WMM = 17, 1401 RTW_WLAN_CATEGORY_VHT = 21, 1402 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1403 RTW_WLAN_CATEGORY_TBTX = 25, 1404 #endif 1405 RTW_WLAN_CATEGORY_HE = 30, 1406 RTW_WLAN_CATEGORY_PROTECTED_HE = 31, 1407 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ 1408 }; 1409 1410 #define CATEGORY_IS_GROUP_PRIVACY(cat) \ 1411 (cat == RTW_WLAN_CATEGORY_MESH || cat == RTW_WLAN_CATEGORY_MULTIHOP) 1412 1413 #define CATEGORY_IS_NON_ROBUST(cat) \ 1414 (cat == RTW_WLAN_CATEGORY_PUBLIC \ 1415 || cat == RTW_WLAN_CATEGORY_HT \ 1416 || cat == RTW_WLAN_CATEGORY_UNPROTECTED_WNM \ 1417 || cat == RTW_WLAN_CATEGORY_SELF_PROTECTED \ 1418 || cat == RTW_WLAN_CATEGORY_VHT \ 1419 || cat == RTW_WLAN_CATEGORY_P2P) 1420 1421 #define CATEGORY_IS_ROBUST(cat) !CATEGORY_IS_NON_ROBUST(cat) 1422 1423 /* SPECTRUM_MGMT action code */ 1424 enum rtw_ieee80211_spectrum_mgmt_actioncode { 1425 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, 1426 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, 1427 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, 1428 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, 1429 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, 1430 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, 1431 }; 1432 1433 /* SELF_PROTECTED action code */ 1434 enum rtw_ieee80211_self_protected_actioncode { 1435 RTW_ACT_SELF_PROTECTED_RSVD = 0, 1436 RTW_ACT_SELF_PROTECTED_MESH_OPEN = 1, 1437 RTW_ACT_SELF_PROTECTED_MESH_CONF = 2, 1438 RTW_ACT_SELF_PROTECTED_MESH_CLOSE = 3, 1439 RTW_ACT_SELF_PROTECTED_MESH_GK_INFORM = 4, 1440 RTW_ACT_SELF_PROTECTED_MESH_GK_ACK = 5, 1441 RTW_ACT_SELF_PROTECTED_NUM, 1442 }; 1443 1444 /* MESH action code */ 1445 enum rtw_ieee80211_mesh_actioncode { 1446 RTW_ACT_MESH_LINK_METRIC_REPORT, 1447 RTW_ACT_MESH_HWMP_PATH_SELECTION, 1448 RTW_ACT_MESH_GATE_ANNOUNCEMENT, 1449 RTW_ACT_MESH_CONGESTION_CONTROL_NOTIFICATION, 1450 RTW_ACT_MESH_MCCA_SETUP_REQUEST, 1451 RTW_ACT_MESH_MCCA_SETUP_REPLY, 1452 RTW_ACT_MESH_MCCA_ADVERTISEMENT_REQUEST, 1453 RTW_ACT_MESH_MCCA_ADVERTISEMENT, 1454 RTW_ACT_MESH_MCCA_TEARDOWN, 1455 RTW_ACT_MESH_TBTT_ADJUSTMENT_REQUEST, 1456 RTW_ACT_MESH_TBTT_ADJUSTMENT_RESPONSE, 1457 }; 1458 1459 enum _PUBLIC_ACTION { 1460 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ 1461 ACT_PUBLIC_DSE_ENABLE = 1, 1462 ACT_PUBLIC_DSE_DEENABLE = 2, 1463 ACT_PUBLIC_DSE_REG_LOCATION = 3, 1464 ACT_PUBLIC_EXT_CHL_SWITCH = 4, 1465 ACT_PUBLIC_DSE_MSR_REQ = 5, 1466 ACT_PUBLIC_DSE_MSR_RPRT = 6, 1467 ACT_PUBLIC_MP = 7, /* Measurement Pilot */ 1468 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, 1469 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ 1470 ACT_PUBLIC_GAS_INITIAL_REQ = 10, 1471 ACT_PUBLIC_GAS_INITIAL_RSP = 11, 1472 ACT_PUBLIC_GAS_COMEBACK_REQ = 12, 1473 ACT_PUBLIC_GAS_COMEBACK_RSP = 13, 1474 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, 1475 ACT_PUBLIC_LOCATION_TRACK = 15, 1476 ACT_PUBLIC_MAX 1477 }; 1478 1479 #ifdef CONFIG_TDLS 1480 enum TDLS_ACTION_FIELD { 1481 TDLS_SETUP_REQUEST = 0, 1482 TDLS_SETUP_RESPONSE = 1, 1483 TDLS_SETUP_CONFIRM = 2, 1484 TDLS_TEARDOWN = 3, 1485 TDLS_PEER_TRAFFIC_INDICATION = 4, 1486 TDLS_CHANNEL_SWITCH_REQUEST = 5, 1487 TDLS_CHANNEL_SWITCH_RESPONSE = 6, 1488 TDLS_PEER_PSM_REQUEST = 7, 1489 TDLS_PEER_PSM_RESPONSE = 8, 1490 TDLS_PEER_TRAFFIC_RESPONSE = 9, 1491 TDLS_DISCOVERY_REQUEST = 10, 1492 TDLS_DISCOVERY_RESPONSE = 14, /* it's used in public action frame */ 1493 }; 1494 1495 #define TUNNELED_PROBE_REQ 15 1496 #define TUNNELED_PROBE_RSP 16 1497 #endif /* CONFIG_TDLS */ 1498 1499 /* BACK action code */ 1500 enum rtw_ieee80211_back_actioncode { 1501 RTW_WLAN_ACTION_ADDBA_REQ = 0, 1502 RTW_WLAN_ACTION_ADDBA_RESP = 1, 1503 RTW_WLAN_ACTION_DELBA = 2, 1504 }; 1505 1506 /* HT features action code */ 1507 enum rtw_ieee80211_ht_actioncode { 1508 RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0, 1509 RTW_WLAN_ACTION_HT_SM_PS = 1, 1510 RTW_WLAN_ACTION_HT_PSMP = 2, 1511 RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3, 1512 RTW_WLAN_ACTION_HT_CSI = 4, 1513 RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5, 1514 RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6, 1515 RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7, 1516 }; 1517 1518 /* BACK (block-ack) parties */ 1519 enum rtw_ieee80211_back_parties { 1520 RTW_WLAN_BACK_RECIPIENT = 0, 1521 RTW_WLAN_BACK_INITIATOR = 1, 1522 RTW_WLAN_BACK_TIMER = 2, 1523 }; 1524 1525 /*20/40 BSS Coexistence element */ 1526 #define RTW_WLAN_20_40_BSS_COEX_INFO_REQ BIT(0) 1527 #define RTW_WLAN_20_40_BSS_COEX_40MHZ_INTOL BIT(1) 1528 #define RTW_WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ BIT(2) 1529 #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_REQ BIT(3) 1530 #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_GRNT BIT(4) 1531 1532 /* VHT features action code */ 1533 enum rtw_ieee80211_vht_actioncode { 1534 RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0, 1535 RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1, 1536 RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2, 1537 }; 1538 1539 enum EXT_CAP_INFO{ 1540 BSS_COEXT = 0, /* 20/40 BSS Coexistence Management Support */ 1541 EXT_CH_SWITCH = 2, /* Extended Channel Switching */ 1542 WNM_SLEEP_MODE = 17, /* WNM Sleep Mode */ 1543 BSS_TRANSITION = 19, /* BSS Transition */ 1544 MULTI_BSSID = 22, /* Multiple BSSID */ 1545 TIME_MEASUREMENT = 23, /* Timing Measurement */ 1546 SSID_LIST = 25, /* SSID List */ 1547 TDLS_PSM = 29, /* TDLS Peer PSM Support */ 1548 TDLS_CH_SWITCH = 30, /* TDLS channel switching */ 1549 INTERWORKING = 31, /* Interworking */ 1550 TDLS_SUPPORT = 37, /* TDLS Support */ 1551 WNM_NOTIFICATION = 46, /* WNM Notification */ 1552 OP_MODE_NOTIFICATION = 62, /* Operating Mode Notification */ 1553 FTM_RESPONDER = 70, /* Fine Timing Measurement Responder */ 1554 FTM_INITIATOR = 71, /* Fine Timing Measurement Initiator */ 1555 }; 1556 1557 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) 1558 * 00:50:F2 */ 1559 #define WME_OUI_TYPE 2 1560 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 1561 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 1562 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 1563 #define WME_VERSION 1 1564 1565 #define WME_ACTION_CODE_SETUP_REQUEST 0 1566 #define WME_ACTION_CODE_SETUP_RESPONSE 1 1567 #define WME_ACTION_CODE_TEARDOWN 2 1568 1569 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 1570 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 1571 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3 1572 1573 #define WME_TSPEC_DIRECTION_UPLINK 0 1574 #define WME_TSPEC_DIRECTION_DOWNLINK 1 1575 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 1576 1577 1578 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ 1579 1580 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1581 #define OUI_REALTEK 0x00e04c /* Realtek */ 1582 #endif 1583 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ 1584 1585 #define MBO_OUI_TYPE 0x16 1586 1587 enum rtw_ieee80211_rann_flags { 1588 RTW_RANN_FLAG_IS_GATE = 1 << 0, 1589 }; 1590 1591 /** 1592 * enum rtw_ieee80211_preq_flags - mesh PREQ element flags 1593 * 1594 * @RTW_IEEE80211_PREQ_IS_GATE_FLAG: Gate Announcement subfield 1595 * @RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield 1596 */ 1597 enum rtw_ieee80211_preq_flags { 1598 RTW_IEEE80211_PREQ_IS_GATE_FLAG = 1 << 0, 1599 RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1 << 2, 1600 }; 1601 1602 /** 1603 * enum rtw_ieee80211_preq_target_flags - mesh PREQ element per target flags 1604 * 1605 * @RTW_IEEE80211_PREQ_TO_FLAG: target only subfield 1606 * @RTW_IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield 1607 */ 1608 enum rtw_ieee80211_preq_target_flags { 1609 RTW_IEEE80211_PREQ_TO_FLAG = 1<<0, 1610 RTW_IEEE80211_PREQ_USN_FLAG = 1<<2, 1611 }; 1612 1613 /** 1614 * enum rtw_ieee80211_root_mode_identifier - root mesh STA mode identifier 1615 * 1616 * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode 1617 * 1618 * @RTW_IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default) 1619 * @RTW_IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than 1620 * this value 1621 * @RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports 1622 * the proactive PREQ with proactive PREP subfield set to 0 1623 * @RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA 1624 * supports the proactive PREQ with proactive PREP subfield set to 1 1625 * @RTW_IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports 1626 * the proactive RANN 1627 */ 1628 enum rtw_ieee80211_root_mode_identifier { 1629 RTW_IEEE80211_ROOTMODE_NO_ROOT = 0, 1630 RTW_IEEE80211_ROOTMODE_ROOT = 1, 1631 RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP = 2, 1632 RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3, 1633 RTW_IEEE80211_PROACTIVE_RANN = 4, 1634 }; 1635 1636 /** 1637 * enum rtw_ieee80211_channel_flags - channel flags 1638 * 1639 * Channel flags set by the regulatory control code. 1640 * 1641 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. 1642 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted 1643 * on this channel. 1644 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. 1645 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. 1646 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel 1647 * is not permitted. 1648 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel 1649 * is not permitted. 1650 */ 1651 enum rtw_ieee80211_channel_flags { 1652 RTW_IEEE80211_CHAN_DISABLED = 1 << 0, 1653 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1 << 1, 1654 RTW_IEEE80211_CHAN_NO_IBSS = 1 << 2, 1655 RTW_IEEE80211_CHAN_RADAR = 1 << 3, 1656 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1 << 4, 1657 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1 << 5, 1658 }; 1659 1660 #define RTW_IEEE80211_CHAN_NO_HT40 \ 1661 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) 1662 1663 /* Represent channel details, subset of ieee80211_channel */ 1664 struct rtw_ieee80211_channel { 1665 /* enum ieee80211_band band; */ 1666 /* u16 center_freq; */ 1667 u16 hw_value; 1668 u32 flags; 1669 /* int max_antenna_gain; */ 1670 /* int max_power; */ 1671 /* int max_reg_power; */ 1672 /* bool beacon_found; */ 1673 /* u32 orig_flags; */ 1674 /* int orig_mag; */ 1675 /* int orig_mpwr; */ 1676 }; 1677 1678 #define CHAN_FMT \ 1679 /*"band:%d, "*/ \ 1680 /*"center_freq:%u, "*/ \ 1681 "hw_value:%u, " \ 1682 "flags:0x%08x" \ 1683 /*"max_antenna_gain:%d\n"*/ \ 1684 /*"max_power:%d\n"*/ \ 1685 /*"max_reg_power:%d\n"*/ \ 1686 /*"beacon_found:%u\n"*/ \ 1687 /*"orig_flags:0x%08x\n"*/ \ 1688 /*"orig_mag:%d\n"*/ \ 1689 /*"orig_mpwr:%d\n"*/ 1690 1691 #define CHAN_ARG(channel) \ 1692 /*(channel)->band*/ \ 1693 /*, (channel)->center_freq*/ \ 1694 (channel)->hw_value \ 1695 , (channel)->flags \ 1696 /*, (channel)->max_antenna_gain*/ \ 1697 /*, (channel)->max_power*/ \ 1698 /*, (channel)->max_reg_power*/ \ 1699 /*, (channel)->beacon_found*/ \ 1700 /*, (channel)->orig_flags*/ \ 1701 /*, (channel)->orig_mag*/ \ 1702 /*, (channel)->orig_mpwr*/ \ 1703 1704 /* Parsed Information Elements */ 1705 struct rtw_ieee802_11_elems { 1706 u8 *ssid; 1707 u8 ssid_len; 1708 u8 *supp_rates; 1709 u8 supp_rates_len; 1710 u8 *fh_params; 1711 u8 fh_params_len; 1712 u8 *ds_params; 1713 u8 ds_params_len; 1714 u8 *cf_params; 1715 u8 cf_params_len; 1716 u8 *tim; 1717 u8 tim_len; 1718 u8 *ibss_params; 1719 u8 ibss_params_len; 1720 u8 *challenge; 1721 u8 challenge_len; 1722 u8 *erp_info; 1723 u8 erp_info_len; 1724 u8 *ext_supp_rates; 1725 u8 ext_supp_rates_len; 1726 u8 *wpa_ie; 1727 u8 wpa_ie_len; 1728 u8 *rsn_ie; 1729 u8 rsn_ie_len; 1730 u8 *wme; 1731 u8 wme_len; 1732 u8 *wme_tspec; 1733 u8 wme_tspec_len; 1734 u8 *wps_ie; 1735 u8 wps_ie_len; 1736 u8 *power_cap; 1737 u8 power_cap_len; 1738 u8 *supp_channels; 1739 u8 supp_channels_len; 1740 u8 *mdie; 1741 u8 mdie_len; 1742 u8 *ftie; 1743 u8 ftie_len; 1744 u8 *timeout_int; 1745 u8 timeout_int_len; 1746 u8 *ht_capabilities; 1747 u8 ht_capabilities_len; 1748 u8 *ht_operation; 1749 u8 ht_operation_len; 1750 u8 *vendor_ht_cap; 1751 u8 vendor_ht_cap_len; 1752 u8 *vht_capabilities; 1753 u8 vht_capabilities_len; 1754 u8 *vht_operation; 1755 u8 vht_operation_len; 1756 u8 *vht_op_mode_notify; 1757 u8 vht_op_mode_notify_len; 1758 u8 *he_capabilities; 1759 u8 he_capabilities_len; 1760 u8 *he_operation; 1761 u8 he_operation_len; 1762 u8 *rm_en_cap; 1763 u8 rm_en_cap_len; 1764 #ifdef CONFIG_RTW_MESH 1765 u8 *preq; 1766 u8 preq_len; 1767 u8 *prep; 1768 u8 prep_len; 1769 u8 *perr; 1770 u8 perr_len; 1771 u8 *rann; 1772 u8 rann_len; 1773 #endif 1774 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1775 u8 *tbtx_cap; 1776 u8 tbtx_cap_len; 1777 #endif 1778 }; 1779 1780 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; 1781 1782 ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, 1783 struct rtw_ieee802_11_elems *elems, 1784 int show_errors); 1785 1786 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); 1787 u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, const u8 *source, uint *frlen); 1788 1789 /* 1790 * Represent Extention Channel Offset in HT Capabilities 1791 * This is available only in 40Mhz mode. 1792 * */ 1793 #if 0 1794 typedef enum _EXTCHNL_OFFSET { 1795 EXTCHNL_OFFSET_NO_EXT = 0, 1796 EXTCHNL_OFFSET_UPPER = 1, 1797 EXTCHNL_OFFSET_NO_DEF = 2, 1798 EXTCHNL_OFFSET_LOWER = 3, 1799 } EXTCHNL_OFFSET, *PEXTCHNL_OFFSET; 1800 #endif 1801 1802 /*enum chan_offset*/ 1803 enum secondary_ch_offset { 1804 IEEE80211_SCN = 0, /* no secondary channel */ 1805 IEEE80211_SCA = 1, /* the secondary channel is above the primary channel */ 1806 IEEE80211_SCB = 3, /* the secondary channel is below the primary channel */ 1807 }; 1808 u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset); 1809 u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset); 1810 u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt); 1811 u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset); 1812 u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence); 1813 1814 u8 *rtw_get_ie(const u8 *pbuf, sint index, sint *len, sint limit); 1815 u8 rtw_update_rate_bymode(WLAN_BSSID_EX *pbss_network, u32 mode); 1816 1817 u8 *rtw_get_ie_ex(const u8 *in_ie, uint in_len, u8 eid, const u8 *oui, u8 oui_len, u8 *ie, uint *ielen); 1818 u8 rtw_ies_update_ie(u8 *ies, uint *ies_len, uint ies_offset, u8 eid, const u8 *content, u8 content_len); 1819 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len); 1820 1821 void rtw_set_supported_rate(u8 *SupportedRates, uint mode, u8 ch) ; 1822 1823 #define GET_RSN_CAP_MFP_OPTION(cap) LE_BITS_TO_2BYTE(((u8 *)(cap)), 6, 2) 1824 1825 #define MFP_NO 0 1826 #define MFP_INVALID 1 1827 #define MFP_OPTIONAL 2 1828 #define MFP_REQUIRED 3 1829 1830 /*For amsdu mode */ 1831 #define GET_RSN_CAP_SPP_OPT(cap) LE_BITS_TO_2BYTE(((u8 *)(cap)), 10, 2) 1832 #define SET_RSN_CAP_SPP(cap, spp) SET_BITS_TO_LE_2BYTE(((u8 *)(cap)), 10, 2, spp) 1833 #define SPP_CAP BIT(0) 1834 #define SPP_REQ BIT(1) 1835 1836 enum rtw_amsdu_mode { 1837 RTW_AMSDU_MODE_NON_SPP = 0, 1838 RTW_AMSDU_MODE_SPP = 1, 1839 RTW_AMSDU_MODE_ALL_DROP = 2, 1840 }; 1841 1842 1843 struct rsne_info { 1844 u8 *gcs; 1845 u16 pcs_cnt; 1846 u8 *pcs_list; 1847 u16 akm_cnt; 1848 u8 *akm_list; 1849 u8 *cap; 1850 u16 pmkid_cnt; 1851 u8 *pmkid_list; 1852 u8 *gmcs; 1853 1854 u8 err; 1855 }; 1856 int rtw_rsne_info_parse(const u8 *ie, uint ie_len, struct rsne_info *info); 1857 1858 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); 1859 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); 1860 int rtw_get_wpa_cipher_suite(u8 *s); 1861 int rtw_get_rsn_cipher_suite(u8 *s); 1862 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); 1863 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, u32 *akm); 1864 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *gmcs, u32 *akm, u8 *mfp_opt, u8* spp_opt); 1865 1866 int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); 1867 1868 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); 1869 u8 *rtw_get_wps_ie_from_scan_queue(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen, enum bss_type frame_type); 1870 u8 *rtw_get_wps_ie(const u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); 1871 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr); 1872 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content); 1873 1874 u8 *rtw_get_owe_ie(const u8 *in_ie, uint in_len, u8 *owe_ie, uint *owe_ielen); 1875 1876 void rtw_add_ext_cap_info(u8 *ext_cap_data, u8 *ext_cap_data_len, u8 cap_info); 1877 void rtw_remove_ext_cap_info(u8 *ext_cap_data, u8 *ext_cap_data_len, u8 cap_info); 1878 u8 rtw_update_ext_cap_ie(u8 *ext_cap_data, u8 ext_cap_data_len, u8 *ies, u32 *ies_len, u8 ies_offset); 1879 void rtw_parse_ext_cap_ie(u8 *ext_cap_data, u8 *ext_cap_data_len, u8 *ies, u32 ies_len, u8 ies_offset); 1880 1881 /** 1882 * for_each_ie - iterate over continuous IEs 1883 * @ie: 1884 * @buf: 1885 * @buf_len: 1886 */ 1887 #define for_each_ie(ie, buf, buf_len) \ 1888 for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2)) 1889 1890 void dump_ies(void *sel, const u8 *buf, u32 buf_len); 1891 1892 #ifdef CONFIG_80211N_HT 1893 #define HT_SC_OFFSET_MAX 4 1894 extern const char *const _ht_sc_offset_str[]; 1895 #define ht_sc_offset_str(sc) (((sc) >= HT_SC_OFFSET_MAX) ? _ht_sc_offset_str[2] : _ht_sc_offset_str[(sc)]) 1896 1897 void dump_ht_cap_ie_content(void *sel, const u8 *buf, u32 buf_len); 1898 #endif 1899 1900 void dump_wps_ie(void *sel, const u8 *ie, u32 ie_len); 1901 1902 void rtw_ies_get_chbw(u8 *ies, int ies_len, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht); 1903 1904 void rtw_bss_get_chbw(WLAN_BSSID_EX *bss, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht); 1905 1906 bool rtw_is_chbw_grouped(u8 ch_a, u8 bw_a, u8 offset_a 1907 , u8 ch_b, u8 bw_b, u8 offset_b); 1908 void rtw_sync_chbw(u8 *req_ch, u8 *req_bw, u8 *req_offset 1909 , u8 *g_ch, u8 *g_bw, u8 *g_offset); 1910 1911 u32 rtw_get_p2p_merged_ies_len(u8 *in_ie, u32 in_len); 1912 int rtw_p2p_merge_ies(u8 *in_ie, u32 in_len, u8 *merge_ie); 1913 void dump_p2p_ie(void *sel, const u8 *ie, u32 ie_len); 1914 u8 *rtw_get_p2p_ie(const u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); 1915 u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr); 1916 u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content); 1917 u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr); 1918 uint rtw_del_p2p_ie(u8 *ies, uint ies_len_ori, const char *msg); 1919 uint rtw_del_p2p_attr(u8 *ie, uint ielen_ori, u8 attr_id); 1920 u8 *rtw_bss_ex_get_p2p_ie(WLAN_BSSID_EX *bss_ex, u8 *p2p_ie, uint *p2p_ielen); 1921 void rtw_bss_ex_del_p2p_ie(WLAN_BSSID_EX *bss_ex); 1922 void rtw_bss_ex_del_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id); 1923 1924 #ifdef CONFIG_IGNORE_GO_AND_LOW_RSSI_IN_SCAN_LIST 1925 int rtw_chk_p2p_wildcard_ssid(WLAN_BSSID_EX *bss_ex); 1926 int rtw_chk_p2p_ie(WLAN_BSSID_EX *bss_ex); 1927 #endif /*CONFIG_IGNORE_GO_AND_LOW_RSSI_IN_SCAN_LIST*/ 1928 1929 void dump_wfd_ie(void *sel, const u8 *ie, u32 ie_len); 1930 u8 *rtw_get_wfd_ie(const u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen); 1931 u8 *rtw_get_wfd_attr(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr); 1932 u8 *rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content); 1933 uint rtw_del_wfd_ie(u8 *ies, uint ies_len_ori, const char *msg); 1934 uint rtw_del_wfd_attr(u8 *ie, uint ielen_ori, u8 attr_id); 1935 u8 *rtw_bss_ex_get_wfd_ie(WLAN_BSSID_EX *bss_ex, u8 *wfd_ie, uint *wfd_ielen); 1936 void rtw_bss_ex_del_wfd_ie(WLAN_BSSID_EX *bss_ex); 1937 void rtw_bss_ex_del_wfd_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id); 1938 1939 #define MULTI_AP_SUB_ELEM_TYPE 0x06 1940 #define MULTI_AP_TEAR_DOWN BIT(4) 1941 #define MULTI_AP_FRONTHAUL_BSS BIT(5) 1942 #define MULTI_AP_BACKHAUL_BSS BIT(6) 1943 #define MULTI_AP_BACKHAUL_STA BIT(7) 1944 #ifdef CONFIG_RTW_MULTI_AP 1945 void dump_multi_ap_ie(void *sel, const u8 *ie, u32 ie_len); 1946 u8 rtw_get_multi_ap_ie_ext(const u8 *ies, int ies_len); 1947 u8 *rtw_set_multi_ap_ie_ext(u8 *pbuf, uint *frlen, u8 val); 1948 #endif 1949 1950 uint rtw_get_rateset_len(u8 *rateset); 1951 1952 struct registry_priv; 1953 int rtw_generate_ie(struct registry_priv *pregistrypriv); 1954 1955 int rtw_get_bit_value_from_ieee_value(u8 val); 1956 1957 uint rtw_is_cckrates_included(u8 *rate); 1958 1959 uint rtw_is_cckratesonly_included(u8 *rate); 1960 uint rtw_get_cckrate_size(u8 *rate,u32 rate_length); 1961 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); 1962 1963 u8 rtw_check_invalid_mac_address(u8 *mac_addr, u8 check_local_bit); 1964 void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr); 1965 1966 u16 rtw_ht_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate); 1967 u8 rtw_ht_mcsset_to_nss(u8 *supp_mcs_set); 1968 u32 rtw_ht_mcs_set_to_bitmap(u8 *mcs_set, u8 nss); 1969 1970 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action); 1971 const char *action_public_str(u8 action); 1972 1973 u8 key_2char2num(u8 hch, u8 lch); 1974 u8 str_2char2num(u8 hch, u8 lch); 1975 void macstr2num(u8 *dst, u8 *src); 1976 u8 convert_ip_addr(u8 hch, u8 mch, u8 lch); 1977 int wifirate2_ratetbl_inx(unsigned char rate); 1978 1979 /* For amsdu mode. */ 1980 /*void rtw_set_spp_amsdu_mode(u8 mode, u8 *rsn_ie, int rsn_ie_len);*/ 1981 u8 rtw_check_amsdu_disable(u8 mode, u8 spp_opt); 1982 1983 1984 #endif /* IEEE80211_H */ 1985