1 /*- 2 * Copyright (c) 2020-2021 The FreeBSD Foundation 3 * 4 * This software was developed by Björn Zeeb under sponsorship from 5 * the FreeBSD Foundation. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 #ifndef _LINUXKPI_LINUX_IEEE80211_H 32 #define _LINUXKPI_LINUX_IEEE80211_H 33 34 #include <sys/types.h> 35 #include <net80211/ieee80211.h> 36 37 #include <asm/unaligned.h> 38 #include <linux/bitops.h> 39 #include <linux/if_ether.h> 40 41 42 /* 9.4.2.55 Management MIC element (CMAC-256, GMAC-128, and GMAC-256). */ 43 struct ieee80211_mmie_16 { 44 uint8_t element_id; 45 uint8_t length; 46 uint16_t key_id; 47 uint8_t ipn[6]; 48 uint8_t mic[16]; 49 }; 50 51 #define IEEE80211_CCMP_HDR_LEN 8 /* 802.11i .. net80211 comment */ 52 #define IEEE80211_CCMP_PN_LEN 6 53 #define IEEE80211_CCMP_MIC_LEN 8 /* || 16 */ 54 #define IEEE80211_CCMP_256_HDR_LEN 8 55 #define IEEE80211_CCMP_256_MIC_LEN 16 56 #define IEEE80211_GCMP_HDR_LEN 8 57 #define IEEE80211_GCMP_MIC_LEN 16 58 #define IEEE80211_GCMP_PN_LEN 6 59 #define IEEE80211_GMAC_PN_LEN 6 60 61 #define IEEE80211_MAX_PN_LEN 16 62 63 #define IEEE80211_INVAL_HW_QUEUE ((uint8_t)-1) 64 65 #define IEEE80211_MAX_AMPDU_BUF_HT 0x40 66 #define IEEE80211_MAX_AMPDU_BUF 256 /* for HE? */ 67 #define IEEE80211_MAX_AMPDU_BUF_HE 256 68 69 #define IEEE80211_MAX_FRAME_LEN 2352 70 #define IEEE80211_MAX_DATA_LEN (2300 + IEEE80211_CRC_LEN) 71 72 #define IEEE80211_MAX_MPDU_LEN_HT_BA 4095 /* 9.3.2.1 Format of Data frames; non-VHT non-DMG STA */ 73 #define IEEE80211_MAX_MPDU_LEN_HT_3839 3839 74 #define IEEE80211_MAX_MPDU_LEN_VHT_3895 3895 75 #define IEEE80211_MAX_MPDU_LEN_VHT_7991 7991 76 #define IEEE80211_MAX_MPDU_LEN_VHT_11454 11454 77 78 #define IEEE80211_MAX_RTS_THRESHOLD 2346 /* net80211::IEEE80211_RTS_MAX */ 79 80 #define IEEE80211_MIN_ACTION_SIZE 23 /* ? */ 81 82 /* Wi-Fi Peer-to-Peer (P2P) Technical Specification */ 83 #define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7f 84 #define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7) 85 86 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007 87 #define IEEE80211_QOS_CTL_TID_MASK IEEE80211_QOS_TID 88 #define IEEE80211_QOS_CTL_EOSP 0x0010 89 #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080 /* 9.2.4.5.1, Table 9-6 QoS Control Field */ 90 91 #define IEEE80211_RATE_SHORT_PREAMBLE BIT(0) 92 93 enum ieee80211_rate_control_changed_flags { 94 IEEE80211_RC_BW_CHANGED = BIT(0), 95 IEEE80211_RC_NSS_CHANGED = BIT(1), 96 IEEE80211_RC_SUPP_RATES_CHANGED = BIT(2), 97 IEEE80211_RC_SMPS_CHANGED = BIT(3), 98 }; 99 100 #define IEEE80211_SCTL_FRAG IEEE80211_SEQ_FRAG_MASK 101 #define IEEE80211_SCTL_SEQ IEEE80211_SEQ_SEQ_MASK 102 103 #define IEEE80211_TKIP_ICV_LEN 4 104 #define IEEE80211_TKIP_IV_LEN 8 /* WEP + KID + EXT */ 105 106 #define IEEE80211_VHT_EXT_NSS_BW_CAPABLE (1 << 13) /* assigned to tx_highest */ 107 108 #define IEEE80211_VHT_MAX_AMPDU_1024K 7 /* 9.4.2.56.3 A-MPDU Parameters field, Table 9-163 */ 109 110 #define IEEE80211_WEP_IV_LEN 3 /* net80211: IEEE80211_WEP_IVLEN */ 111 #define IEEE80211_WEP_ICV_LEN 4 112 113 #define WLAN_AUTH_OPEN __LINE__ /* TODO FIXME brcmfmac */ 114 #define WLAN_CAPABILITY_IBSS __LINE__ /* TODO FIXME no longer used? */ 115 #define WLAN_CAPABILITY_SHORT_PREAMBLE __LINE__ /* TODO FIXME brcmfmac */ 116 #define WLAN_CAPABILITY_SHORT_SLOT_TIME __LINE__ /* TODO FIXME brcmfmac */ 117 118 enum wlan_ht_cap_sm_ps { 119 WLAN_HT_CAP_SM_PS_STATIC = 0, 120 WLAN_HT_CAP_SM_PS_DYNAMIC, 121 WLAN_HT_CAP_SM_PS_INVALID, 122 WLAN_HT_CAP_SM_PS_DISABLED, 123 }; 124 125 #define WLAN_MAX_KEY_LEN 32 /* TODO FIXME brcmfmac */ 126 #define WLAN_PMKID_LEN 16 /* TODO FIXME brcmfmac */ 127 128 #define WLAN_KEY_LEN_WEP40 5 129 #define WLAN_KEY_LEN_WEP104 13 130 #define WLAN_KEY_LEN_CCMP 16 131 #define WLAN_KEY_LEN_GCMP_256 32 132 133 /* 802.11-2020, 9.4.2.55.3, Table 9-185 Subfields of the A-MPDU Parameters field */ 134 enum ieee80211_min_mpdu_start_spacing { 135 IEEE80211_HT_MPDU_DENSITY_NONE = 0, 136 #if 0 137 IEEE80211_HT_MPDU_DENSITY_XXX = 1, /* 1/4 us */ 138 IEEE80211_HT_MPDU_DENSITY_YYY = 2, /* 1/2 us */ 139 #endif 140 IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 us */ 141 IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 us */ 142 IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4us */ 143 IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8us */ 144 IEEE80211_HT_MPDU_DENSITY_16 = 7, /* 16us */ 145 }; 146 147 /* 9.4.2.57, Table 9-168, HT Operation element fields and subfields */ 148 #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080 /* B24.. */ 149 150 #define IEEE80211_FCTL_FTYPE IEEE80211_FC0_TYPE_MASK 151 #define IEEE80211_FCTL_STYPE IEEE80211_FC0_SUBTYPE_MASK 152 #define IEEE80211_FCTL_ORDER (IEEE80211_FC1_ORDER << 8) 153 #define IEEE80211_FCTL_PROTECTED (IEEE80211_FC1_PROTECTED << 8) 154 155 #define IEEE80211_STYPE_ASSOC_REQ IEEE80211_FC0_SUBTYPE_ASSOC_REQ 156 #define IEEE80211_STYPE_REASSOC_REQ IEEE80211_FC0_SUBTYPE_REASSOC_REQ 157 #define IEEE80211_STYPE_PROBE_REQ IEEE80211_FC0_SUBTYPE_PROBE_REQ 158 #define IEEE80211_STYPE_DISASSOC IEEE80211_FC0_SUBTYPE_DISASSOC 159 #define IEEE80211_STYPE_AUTH IEEE80211_FC0_SUBTYPE_AUTH 160 #define IEEE80211_STYPE_DEAUTH IEEE80211_FC0_SUBTYPE_DEAUTH 161 #define IEEE80211_STYPE_ACTION IEEE80211_FC0_SUBTYPE_ACTION 162 #define IEEE80211_STYPE_QOS_DATA IEEE80211_FC0_SUBTYPE_QOS 163 164 #define IEEE80211_NUM_ACS 4 /* net8021::WME_NUM_AC */ 165 166 #define IEEE80211_MAX_SSID_LEN 32 /* 9.4.2.2 SSID element, net80211: IEEE80211_NWID_LEN */ 167 168 169 /* Figure 9-27, BAR Control field */ 170 #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000 171 #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12 172 173 #define IEEE80211_PPE_THRES_INFO_PPET_SIZE 1 /* TODO FIXME ax? */ 174 #define IEEE80211_PPE_THRES_NSS_MASK 2 /* TODO FIXME ax? */ 175 #define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_POS 3 /* TODO FIXME ax? */ 176 #define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK 8 /* TODO FIXME ax? */ 177 #define IEEE80211_HE_PPE_THRES_INFO_HEADER_SIZE 16 /* TODO FIXME ax? */ 178 179 #define IEEE80211_HT_OP_MODE_PROTECTION 0x03 /* MASK */ 180 #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0x00 181 #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 0x01 182 #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 0x02 183 #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 0x03 184 185 186 /* 9.6.13.1, Table 9-342 TDLS Action field values. */ 187 enum ieee80211_tdls_action_code { 188 WLAN_TDLS_SETUP_REQUEST = 0, 189 WLAN_TDLS_SETUP_RESPONSE = 1, 190 WLAN_TDLS_SETUP_CONFIRM = 2, 191 WLAN_TDLS_TEARDOWN = 3, 192 WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4, 193 WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5, 194 WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6, 195 WLAN_TDLS_PEER_PSM_REQUEST = 7, 196 WLAN_TDLS_PEER_PSM_RESPONSE = 8, 197 WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9, 198 WLAN_TDLS_DISCOVERY_REQUEST = 10, 199 /* 11-255 reserved */ 200 }; 201 202 /* 9.4.2.27, Table 9-135. Extended Capabilities field. */ 203 /* This is split up into octets CAPA1 = octet 1, ... */ 204 #define WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING BIT(2 % 8) 205 #define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT BIT(22 % 8) 206 #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(62 % 8) 207 #define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT BIT(5) /* XXX */ 208 #define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7) /* XXX */ 209 210 211 /* iwlwifi/mvm/utils:: for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_VI; ac++) */ 212 /* Would be so much easier if we'd define constants to the same. */ 213 enum ieee80211_ac_numbers { 214 IEEE80211_AC_VO = 0, /* net80211::WME_AC_VO */ 215 IEEE80211_AC_VI = 1, /* net80211::WME_AC_VI */ 216 IEEE80211_AC_BE = 2, /* net80211::WME_AC_BE */ 217 IEEE80211_AC_BK = 3, /* net80211::WME_AC_BK */ 218 }; 219 220 #define IEEE80211_MAX_QUEUES 16 /* Assume IEEE80211_NUM_TIDS for the moment. */ 221 222 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO 1 223 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI 2 224 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK 4 225 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE 8 226 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0xf 227 228 struct vht_mcs { 229 uint16_t rx_mcs_map; 230 uint16_t rx_highest; 231 uint16_t tx_mcs_map; 232 uint16_t tx_highest; 233 }; 234 235 struct ieee80211_vht_cap { 236 struct vht_mcs supp_mcs;; 237 __le32 vht_cap_info; 238 }; 239 240 #define IEEE80211_HT_MAX_AMPDU_FACTOR 13 241 242 enum ieee80211_ht_max_ampdu_len { 243 IEEE80211_HT_MAX_AMPDU_64K 244 }; 245 246 enum ieee80211_ampdu_mlme_action { 247 IEEE80211_AMPDU_RX_START, 248 IEEE80211_AMPDU_RX_STOP, 249 IEEE80211_AMPDU_TX_OPERATIONAL, 250 IEEE80211_AMPDU_TX_START, 251 IEEE80211_AMPDU_TX_START_DELAY_ADDBA, 252 IEEE80211_AMPDU_TX_START_IMMEDIATE, 253 IEEE80211_AMPDU_TX_STOP_CONT, 254 IEEE80211_AMPDU_TX_STOP_FLUSH, 255 IEEE80211_AMPDU_TX_STOP_FLUSH_CONT 256 }; 257 258 enum ieee80211_chanctx_switch_mode { 259 CHANCTX_SWMODE_REASSIGN_VIF, 260 CHANCTX_SWMODE_SWAP_CONTEXTS, 261 }; 262 263 enum ieee80211_chanctx_change_flags { 264 IEEE80211_CHANCTX_CHANGE_MIN_WIDTH = BIT(0), 265 IEEE80211_CHANCTX_CHANGE_RADAR = BIT(1), 266 IEEE80211_CHANCTX_CHANGE_RX_CHAINS = BIT(2), 267 IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(3), 268 IEEE80211_CHANCTX_CHANGE_CHANNEL = BIT(4), 269 }; 270 271 enum ieee80211_frame_release_type { 272 IEEE80211_FRAME_RELEASE_PSPOLL = 1, 273 IEEE80211_FRAME_RELEASE_UAPSD = 2, 274 }; 275 276 enum ieee80211_p2p_attr_ids { 277 IEEE80211_P2P_ATTR_DEVICE_ID, 278 IEEE80211_P2P_ATTR_DEVICE_INFO, 279 IEEE80211_P2P_ATTR_GROUP_ID, 280 IEEE80211_P2P_ATTR_LISTEN_CHANNEL, 281 IEEE80211_P2P_ATTR_ABSENCE_NOTICE, 282 }; 283 284 enum ieee80211_reconfig_type { 285 IEEE80211_RECONFIG_TYPE_RESTART, 286 IEEE80211_RECONFIG_TYPE_SUSPEND, 287 }; 288 289 enum ieee80211_roc_type { 290 IEEE80211_ROC_TYPE_MGMT_TX, 291 IEEE80211_ROC_TYPE_NORMAL, 292 }; 293 294 enum ieee80211_smps_mode { 295 IEEE80211_SMPS_OFF, 296 IEEE80211_SMPS_STATIC, 297 IEEE80211_SMPS_DYNAMIC, 298 IEEE80211_SMPS_AUTOMATIC, 299 IEEE80211_SMPS_NUM_MODES, 300 }; 301 302 /* net80211::IEEE80211_S_* different but represents the state machine. */ 303 /* Note: order here is important! */ 304 enum ieee80211_sta_state { 305 IEEE80211_STA_NOTEXIST, 306 IEEE80211_STA_NONE, 307 IEEE80211_STA_AUTH, 308 IEEE80211_STA_ASSOC, 309 IEEE80211_STA_AUTHORIZED, /* 802.1x */ 310 }; 311 312 enum ieee80211_sta_rx_bw { 313 IEEE80211_STA_RX_BW_20, 314 IEEE80211_STA_RX_BW_40, 315 IEEE80211_STA_RX_BW_80, 316 IEEE80211_STA_RX_BW_160, 317 IEEE80211_STA_RX_BW_320, 318 }; 319 320 enum ieee80211_tx_info_flags { 321 /* XXX TODO .. right shift numbers - not sure where that came from? */ 322 IEEE80211_TX_CTL_AMPDU = BIT(0), 323 IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1), 324 IEEE80211_TX_CTL_NO_ACK = BIT(2), 325 IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(3), 326 IEEE80211_TX_CTL_TX_OFFCHAN = BIT(4), 327 IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(5), 328 IEEE80211_TX_STATUS_EOSP = BIT(6), 329 IEEE80211_TX_STAT_ACK = BIT(7), 330 IEEE80211_TX_STAT_AMPDU = BIT(8), 331 IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(9), 332 IEEE80211_TX_STAT_TX_FILTERED = BIT(10), 333 IEEE80211_TX_STAT_NOACK_TRANSMITTED = BIT(11), 334 IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(12), 335 IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(13), 336 IEEE80211_TX_CTL_NO_CCK_RATE = BIT(14), 337 IEEE80211_TX_CTL_INJECTED = BIT(15), 338 }; 339 340 enum ieee80211_tx_control_flags { 341 /* XXX TODO .. right shift numbers */ 342 IEEE80211_TX_CTRL_PORT_CTRL_PROTO = BIT(0), 343 }; 344 345 enum ieee80211_tx_rate_flags { 346 /* XXX TODO .. right shift numbers */ 347 IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(0), 348 IEEE80211_TX_RC_80_MHZ_WIDTH = BIT(1), 349 IEEE80211_TX_RC_160_MHZ_WIDTH = BIT(2), 350 IEEE80211_TX_RC_GREEN_FIELD = BIT(3), 351 IEEE80211_TX_RC_MCS = BIT(4), 352 IEEE80211_TX_RC_SHORT_GI = BIT(5), 353 IEEE80211_TX_RC_VHT_MCS = BIT(6), 354 IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(7), 355 }; 356 357 #define IEEE80211_HT_CTL_LEN 4 358 359 struct ieee80211_hdr { /* net80211::ieee80211_frame_addr4 */ 360 __le16 frame_control; 361 __le16 duration_id; 362 uint8_t addr1[ETH_ALEN]; 363 uint8_t addr2[ETH_ALEN]; 364 uint8_t addr3[ETH_ALEN]; 365 __le16 seq_ctrl; 366 uint8_t addr4[ETH_ALEN]; 367 }; 368 369 struct ieee80211_hdr_3addr { /* net80211::ieee80211_frame */ 370 __le16 frame_control; 371 __le16 duration_id; 372 uint8_t addr1[ETH_ALEN]; 373 uint8_t addr2[ETH_ALEN]; 374 uint8_t addr3[ETH_ALEN]; 375 __le16 seq_ctrl; 376 }; 377 378 struct ieee80211_vendor_ie { 379 }; 380 381 /* 9.3.3.2 Format of Management frames */ 382 struct ieee80211_mgmt { 383 __le16 frame_control; 384 __le16 duration_id; 385 uint8_t da[ETH_ALEN]; 386 uint8_t sa[ETH_ALEN]; 387 uint8_t bssid[ETH_ALEN]; 388 __le16 seq_ctrl; 389 union { 390 /* 9.3.3.3 Beacon frame format */ 391 struct { 392 uint64_t timestamp; 393 uint16_t beacon_int; 394 uint16_t capab_info; 395 uint8_t variable[0]; 396 } beacon; 397 /* 9.3.3.10 Probe Request frame format */ 398 struct { 399 uint8_t variable[0]; 400 } probe_req; 401 /* 9.3.3.11 Probe Response frame format */ 402 struct { 403 uint64_t timestamp; 404 uint16_t beacon_int; 405 uint16_t capab_info; 406 uint8_t variable[0]; 407 } probe_resp; 408 /* 9.3.3.14 Action frame format */ 409 struct { 410 /* 9.4.1.11 Action field */ 411 uint8_t category; 412 /* 9.6.8 Public Action details */ 413 union { 414 /* 9.6.8.33 Fine Timing Measurement frame format */ 415 struct { 416 uint8_t dialog_token; 417 uint8_t follow_up; 418 uint8_t tod[6]; 419 uint8_t toa[6]; 420 uint16_t tod_error; 421 uint16_t toa_error; 422 uint8_t variable[0]; 423 } ftm; 424 } u; 425 } action; 426 } u; 427 }; 428 429 #define MHZ_TO_KHZ(_f) ((_f) * 1000) 430 #define DBI_TO_MBI(_g) ((_g) * 100) 431 #define MBI_TO_DBI(_x) ((_x) / 100) 432 #define DBM_TO_MBM(_g) ((_g) * 100) 433 #define MBM_TO_DBM(_x) ((_x) / 100) 434 435 #define IEEE80211_SEQ_TO_SN(_seqn) (((_seqn) & IEEE80211_SEQ_SEQ_MASK) >> \ 436 IEEE80211_SEQ_SEQ_SHIFT) 437 438 /* Time unit (TU) to .. See net80211: IEEE80211_DUR_TU */ 439 #define TU_TO_JIFFIES(_tu) (usecs_to_jiffies(_tu) * 1024) 440 #define TU_TO_EXP_TIME(_tu) (jiffies + TU_TO_JIFFIES(_tu)) 441 442 /* 9.4.2.21.1, Table 9-82. */ 443 #define IEEE80211_SPCT_MSR_RPRT_TYPE_LCI 8 444 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC 11 445 446 /* 9.4.2.1, Table 9-77. Element IDs. */ 447 enum ieee80211_eid { 448 WLAN_EID_SSID = 0, 449 WLAN_EID_SUPP_RATES = 1, 450 WLAN_EID_DS_PARAMS = 3, 451 WLAN_EID_TIM = 5, 452 WLAN_EID_COUNTRY = 7, /* IEEE80211_ELEMID_COUNTRY */ 453 WLAN_EID_REQUEST = 10, 454 WLAN_EID_CHANNEL_SWITCH = 37, 455 WLAN_EID_MEASURE_REPORT = 39, 456 WLAN_EID_RSN = 48, /* IEEE80211_ELEMID_RSN */ 457 WLAN_EID_EXT_SUPP_RATES = 50, 458 WLAN_EID_EXT_CHANSWITCH_ANN = 60, 459 WLAN_EID_EXT_CAPABILITY = 127, 460 WLAN_EID_VENDOR_SPECIFIC = 221, 461 }; 462 463 /* 9.4.1.7, Table 9-45. Reason codes. */ 464 enum ieee80211_reason_code { 465 /* reserved = 0, */ 466 WLAN_REASON_UNSPECIFIED = 1, 467 WLAN_REASON_DEAUTH_LEAVING = 3, /* LEAVING_NETWORK_DEAUTH */ 468 WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25, 469 WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26, 470 }; 471 472 /* 9.4.1.9, Table 9-46. Status codes. */ 473 enum ieee80211_status_code { 474 WLAN_STATUS_SUCCESS = 0, 475 WLAN_STATUS_AUTH_TIMEOUT = 16, /* REJECTED_SEQUENCE_TIMEOUT */ 476 }; 477 478 /* 9.3.1.22 Trigger frame format; 80211ax-2021 */ 479 struct ieee80211_trigger { 480 __le16 frame_control; 481 __le16 duration_id; 482 uint8_t ra[ETH_ALEN]; 483 uint8_t ta[ETH_ALEN]; 484 __le64 common_info; /* 8+ really */ 485 uint8_t variable[]; 486 }; 487 488 /* Table 9-29c-Trigger Type subfield encoding */ 489 enum { 490 IEEE80211_TRIGGER_TYPE_BASIC = 0x0, 491 #if 0 492 /* Not seen yet. */ 493 BFRP = 0x1, 494 MU-BAR = 0x2, 495 MU-RTS = 0x3, 496 BSRP = 0x4, 497 GCR MU-BAR = 0x5, 498 BQRP = 0x6, 499 NFRP = 0x7, 500 /* 0x8..0xf reserved */ 501 #endif 502 IEEE80211_TRIGGER_TYPE_MASK = 0xf 503 }; 504 505 /* net80211: IEEE80211_IS_CTL() */ 506 static __inline bool 507 ieee80211_is_ctl(__le16 fc) 508 { 509 __le16 v; 510 511 fc &= htole16(IEEE80211_FC0_TYPE_MASK); 512 v = htole16(IEEE80211_FC0_TYPE_CTL); 513 514 return (fc == v); 515 } 516 517 /* net80211: IEEE80211_IS_DATA() */ 518 static __inline bool 519 ieee80211_is_data(__le16 fc) 520 { 521 __le16 v; 522 523 fc &= htole16(IEEE80211_FC0_TYPE_MASK); 524 v = htole16(IEEE80211_FC0_TYPE_DATA); 525 526 return (fc == v); 527 } 528 529 /* net80211: IEEE80211_IS_QOSDATA() */ 530 static __inline bool 531 ieee80211_is_data_qos(__le16 fc) 532 { 533 __le16 v; 534 535 fc &= htole16(IEEE80211_FC0_SUBTYPE_QOS | IEEE80211_FC0_TYPE_MASK | 536 IEEE80211_FC0_VERSION_MASK); 537 v = htole16(IEEE80211_FC0_QOSDATA); 538 539 return (fc == v); 540 } 541 542 /* net80211: IEEE80211_IS_MGMT() */ 543 static __inline bool 544 ieee80211_is_mgmt(__le16 fc) 545 { 546 __le16 v; 547 548 fc &= htole16(IEEE80211_FC0_TYPE_MASK); 549 v = htole16(IEEE80211_FC0_TYPE_MGT); 550 551 return (fc == v); 552 } 553 554 555 /* Derived from net80211::ieee80211_anyhdrsize. */ 556 static __inline unsigned int 557 ieee80211_hdrlen(__le16 fc) 558 { 559 unsigned int size; 560 561 if (ieee80211_is_ctl(fc)) { 562 switch (fc & htole16(IEEE80211_FC0_SUBTYPE_MASK)) { 563 case htole16(IEEE80211_FC0_SUBTYPE_CTS): 564 case htole16(IEEE80211_FC0_SUBTYPE_ACK): 565 return sizeof(struct ieee80211_frame_ack); 566 case htole16(IEEE80211_FC0_SUBTYPE_BAR): 567 return sizeof(struct ieee80211_frame_bar); 568 } 569 return (sizeof(struct ieee80211_frame_min)); 570 } 571 572 size = sizeof(struct ieee80211_frame); 573 if (ieee80211_is_data(fc)) { 574 if ((fc & htole16(IEEE80211_FC1_DIR_MASK << 8)) == 575 htole16(IEEE80211_FC1_DIR_DSTODS << 8)) 576 size += IEEE80211_ADDR_LEN; 577 if ((fc & htole16(IEEE80211_FC0_SUBTYPE_QOS | 578 IEEE80211_FC0_TYPE_MASK)) == 579 htole16(IEEE80211_FC0_SUBTYPE_QOS | 580 IEEE80211_FC0_TYPE_DATA)) 581 size += sizeof(uint16_t); 582 } 583 584 if (ieee80211_is_mgmt(fc)) { 585 #ifdef __notyet__ 586 printf("XXX-BZ %s: TODO? fc %#04x size %u\n", 587 __func__, fc, size); 588 #endif 589 ; 590 } 591 592 return (size); 593 } 594 595 static inline bool 596 ieee80211_is_trigger(__le16 fc) 597 { 598 __le16 v; 599 600 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 601 v = htole16(IEEE80211_FC0_SUBTYPE_TRIGGER | IEEE80211_FC0_TYPE_CTL); 602 603 return (fc == v); 604 } 605 606 #endif /* _LINUXKPI_LINUX_IEEE80211_H */ 607