1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: contains commnon ieee80211 definitions 21 */ 22 23 #ifndef _WLAN_CMN_IEEE80211_H_ 24 #define _WLAN_CMN_IEEE80211_H_ 25 #include <qdf_types.h> 26 #include <osdep.h> 27 28 #define IEEE80211_CCMP_HEADERLEN 8 29 #define IEEE80211_CCMP_MICLEN 8 30 #define WLAN_IEEE80211_GCMP_HEADERLEN 8 31 #define WLAN_IEEE80211_GCMP_MICLEN 16 32 #define IEEE80211_FC1_WEP 0x40 33 #define WLAN_HDR_IV_LEN 3 34 #define WLAN_HDR_EXT_IV_BIT 0x20 35 #define WLAN_HDR_EXT_IV_LEN 4 36 37 #define WLAN_SEQ_SEQ_SHIFT 4 38 39 #define P2P_WFA_OUI {0x50, 0x6f, 0x9a} 40 #define P2P_WFA_VER 0x09 41 42 #define WSC_OUI 0x0050f204 43 #define MBO_OCE_OUI 0x506f9a16 44 #define MBO_OCE_OUI_SIZE 4 45 #define REDUCED_WAN_METRICS_ATTR 103 46 47 /* WCN IE */ 48 /* Microsoft OUI */ 49 #define WCN_OUI 0xf25000 50 /* WCN */ 51 #define WCN_OUI_TYPE 0x04 52 #define WME_OUI 0xf25000 53 #define WME_OUI_TYPE 0x02 54 #define WME_PARAM_OUI_SUBTYPE 0x01 55 #define WME_INFO_OUI_SUBTYPE 0x00 56 /* Atheros OUI */ 57 #define ATH_OUI 0x7f0300 58 #define ATH_OUI_TYPE 0x01 59 /* Atheros Extended Cap Type */ 60 #define ATH_OUI_EXTCAP_TYPE 0x04 61 /* QCA Bandwidth NSS Mapping Type */ 62 #define ATH_OUI_BW_NSS_MAP_TYPE 0x05 63 #define SFA_OUI 0x964000 64 #define SFA_OUI_TYPE 0x14 65 /* QCA OUI (in little endian) */ 66 #define QCA_OUI 0xf0fd8c 67 #define QCA_OUI_WHC_TYPE 0x00 68 69 /* Extender vendor specific IE */ 70 #define QCA_OUI_EXTENDER_TYPE 0x03 71 72 /* Temporary vendor specific IE for 11n pre-standard interoperability */ 73 #define VENDOR_HT_OUI 0x00904c 74 #define VENDOR_HT_CAP_ID 51 75 #define VENDOR_HT_INFO_ID 52 76 77 #define VHT_INTEROP_OUI 0x00904c 78 #define VHT_INTEROP_TYPE 0x04 79 #define VHT_INTEROP_OUI_SUBTYPE 0x08 80 #define VHT_INTEROP_OUI_SUBTYPE_VENDORSPEC 0x18 81 82 /* ATH HE OUI ( in little endian) */ 83 #define ATH_HE_OUI 0x741300 84 #define ATH_HE_CAP_SUBTYPE 0x01 85 #define ATH_HE_OP_SUBTYPE 0x02 86 87 /* EPR information element flags */ 88 #define ERP_NON_ERP_PRESENT 0x01 89 #define ERP_USE_PROTECTION 0x02 90 #define ERP_LONG_PREAMBLE 0x04 91 92 #define QCA_OUI_WHC_AP_INFO_SUBTYPE 0x00 93 94 #define WLAN_MAX_IE_LEN 255 95 #define WLAN_RSN_IE_LEN 22 96 97 /* Individual element IEs length checks */ 98 99 #define WLAN_SUPPORTED_RATES_IE_MAX_LEN 8 100 #define WLAN_DS_PARAM_IE_MAX_LEN 1 101 #define WLAN_COUNTRY_IE_MIN_LEN 3 102 #define WLAN_QUIET_IE_MAX_LEN 6 103 #define WLAN_CSA_IE_MAX_LEN 3 104 #define WLAN_XCSA_IE_MAX_LEN 4 105 #define WLAN_SECCHANOFF_IE_MAX_LEN 1 106 #define WLAN_EXT_SUPPORTED_RATES_IE_MAX_LEN 12 107 #define WLAN_EXTCAP_IE_MAX_LEN 15 108 #define WLAN_FILS_INDICATION_IE_MIN_LEN 2 109 #define WLAN_MOBILITY_DOMAIN_IE_MAX_LEN 3 110 #define WLAN_OPMODE_IE_MAX_LEN 1 111 #define WLAN_IBSSDFS_IE_MIN_LEN 7 112 113 /* HT capability flags */ 114 #define WLAN_HTCAP_C_ADVCODING 0x0001 115 #define WLAN_HTCAP_C_CHWIDTH40 0x0002 116 /* Capable of SM Power Save (Static) */ 117 #define WLAN_HTCAP_C_SMPOWERSAVE_STATIC 0x0000 118 /* Capable of SM Power Save (Dynamic) */ 119 #define WLAN_HTCAP_C_SMPOWERSAVE_DYNAMIC 0x0004 120 /* Reserved */ 121 #define WLAN_HTCAP_C_SM_RESERVED 0x0008 122 /* SM enabled, no SM Power Save */ 123 #define WLAN_HTCAP_C_SMPOWERSAVE_DISABLED 0x000c 124 #define WLAN_HTCAP_C_GREENFIELD 0x0010 125 #define WLAN_HTCAP_C_SHORTGI20 0x0020 126 #define WLAN_HTCAP_C_SHORTGI40 0x0040 127 #define WLAN_HTCAP_C_TXSTBC 0x0080 128 #define WLAN_HTCAP_C_TXSTBC_S 7 129 /* 2 bits */ 130 #define WLAN_HTCAP_C_RXSTBC 0x0300 131 #define WLAN_HTCAP_C_RXSTBC_S 8 132 #define WLAN_HTCAP_C_DELAYEDBLKACK 0x0400 133 /* 1 = 8K, 0 = 3839B */ 134 #define WLAN_HTCAP_C_MAXAMSDUSIZE 0x0800 135 #define WLAN_HTCAP_C_DSSSCCK40 0x1000 136 #define WLAN_HTCAP_C_PSMP 0x2000 137 #define WLAN_HTCAP_C_INTOLERANT40 0x4000 138 #define WLAN_HTCAP_C_LSIGTXOPPROT 0x8000 139 /* Spatial Multiplexing (SM) capabitlity bitmask */ 140 #define WLAN_HTCAP_C_SM_MASK 0x000c 141 142 /* VHT Operation */ 143 /* 20/40 MHz Operating Channel */ 144 #define WLAN_VHTOP_CHWIDTH_2040 0 145 /* 80 MHz Operating Channel */ 146 #define WLAN_VHTOP_CHWIDTH_80 1 147 /* 160 MHz Operating Channel */ 148 #define WLAN_VHTOP_CHWIDTH_160 2 149 /* 80 + 80 MHz Operating Channel */ 150 #define WLAN_VHTOP_CHWIDTH_80_80 3 151 /* 160 MHz Operating Channel (revised signalling) */ 152 #define WLAN_VHTOP_CHWIDTH_REVSIG_160 1 153 /* 80 + 80 MHz Operating Channel (revised signalling) */ 154 #define WLAN_VHTOP_CHWIDTH_REVSIG_80_80 1 155 156 #define WLAN_RATE_VAL 0x7f 157 158 #define WLAN_RV(v) ((v) & WLAN_RATE_VAL) 159 160 #define WLAN_CHAN_IS_5GHZ(chanidx) \ 161 ((chanidx > 30) ? true : false) 162 #define WLAN_CHAN_IS_2GHZ(chanidx) \ 163 (((chanidx > 0) && (chanidx < 15)) ? true : false) 164 165 /* Check if revised signalling is being used for VHT160 in vhtop */ 166 #define WLAN_IS_REVSIG_VHT160(vhtop) (((vhtop)->vht_op_chwidth == \ 167 WLAN_VHTOP_CHWIDTH_REVSIG_160) && \ 168 ((vhtop)->vht_op_ch_freq_seg2 != 0) && \ 169 (abs((vhtop)->vht_op_ch_freq_seg2 - (vhtop)->vht_op_ch_freq_seg1) == 8)) 170 171 /* Check if revised signalling is being used for VHT80p80 in vhtop */ 172 #define WLAN_IS_REVSIG_VHT80_80(vhtop) (((vhtop)->vht_op_chwidth == \ 173 WLAN_VHTOP_CHWIDTH_REVSIG_80_80) && \ 174 ((vhtop)->vht_op_ch_freq_seg2 != 0) && \ 175 (abs((vhtop)->vht_op_ch_freq_seg2 - (vhtop)->vht_op_ch_freq_seg1) > 8)) 176 177 #define LE_READ_2(p) \ 178 ((uint16_t)\ 179 ((((const uint8_t *)(p))[0]) |\ 180 (((const uint8_t *)(p))[1] << 8))) 181 182 #define LE_READ_4(p) \ 183 ((uint32_t)\ 184 ((((const uint8_t *)(p))[0]) |\ 185 (((const uint8_t *)(p))[1] << 8) | \ 186 (((const uint8_t *)(p))[2] << 16) |\ 187 (((const uint8_t *)(p))[3] << 24))) 188 189 #define BE_READ_4(p) \ 190 ((uint32_t)\ 191 ((((const uint8_t *)(p))[0] << 24) |\ 192 (((const uint8_t *)(p))[1] << 16) |\ 193 (((const uint8_t *)(p))[2] << 8) |\ 194 (((const uint8_t *)(p))[3]))) 195 196 /** 197 * enum ext_chan_offset: extension channel offset 198 * @WLAN_HTINFO_EXTOFFSET_NA: no extension channel is present 199 * @WLAN_HTINFO_EXTOFFSET_ABOVE: above control channel 200 * @WLAN_HTINFO_EXTOFFSET_UNDEF: undefined 201 * @WLAN_HTINFO_EXTOFFSET_BELOW: below control channel 202 */ 203 enum ext_chan_offset { 204 WLAN_HTINFO_EXTOFFSET_NA = 0, 205 WLAN_HTINFO_EXTOFFSET_ABOVE = 1, 206 WLAN_HTINFO_EXTOFFSET_UNDEF = 2, 207 WLAN_HTINFO_EXTOFFSET_BELOW = 3 208 }; 209 210 /** 211 * enum element_ie :- Management information element 212 * @WLAN_ELEMID_SSID: ssid IE 213 * @WLAN_ELEMID_RATES: Rates IE 214 * @WLAN_ELEMID_FHPARMS: FH param IE 215 * @WLAN_ELEMID_DSPARMS: DS Param IE 216 * @WLAN_ELEMID_CFPARMS : CF Param IE 217 * @WLAN_ELEMID_TIM: TIM IE 218 * @WLAN_ELEMID_IBSSPARMS: Ibss params IE 219 * @WLAN_ELEMID_COUNTRY: Country code IE 220 * @WLAN_ELEMID_REQINFO: Req Info IE 221 * @WLAN_ELEMID_QBSS_LOAD: Qbss load IE 222 * @WLAN_ELEMID_TCLAS: TCLAS IE 223 * @WLAN_ELEMID_CHALLENGE: Challenge IE 224 * @WLAN_ELEMID_PWRCNSTR: Power cn IE 225 * @WLAN_ELEMID_PWRCAP: power cap IE 226 * @WLAN_ELEMID_TPCREQ: TPC req IE 227 * @WLAN_ELEMID_TPCREP: TPC rsp IE 228 * @WLAN_ELEMID_SUPPCHAN: Supported channel IE 229 * @WLAN_ELEMID_CHANSWITCHANN: Channel switch IE 230 * @WLAN_ELEMID_MEASREQ: Measurement request IE 231 * @WLAN_ELEMID_MEASREP: Measurement Resp IE 232 * @WLAN_ELEMID_QUIET: Quiet IE 233 * @WLAN_ELEMID_IBSSDFS: IBSS DFS IE 234 * @WLAN_ELEMID_ERP: ERP IE 235 * @WLAN_ELEMID_TCLAS_PROCESS: TCLAS process IE 236 * @WLAN_ELEMID_HTCAP_ANA: HTT Capability IE 237 * @WLAN_ELEMID_RSN: RSN IE 238 * @WLAN_ELEMID_XRATES: Extended rate IE 239 * @WLAN_ELEMID_HTCAP_VENDOR: HT cap vendor IE 240 * @WLAN_ELEMID_HTINFO_VENDOR: HT info vendor IE 241 * @WLAN_ELEMID_MOBILITY_DOMAIN: MD IE 242 * @WLAN_ELEMID_FT: FT IE 243 * @WLAN_ELEMID_TIMEOUT_INTERVAL: Timeout interval IE 244 * @WLAN_ELEMID_SUPP_OP_CLASS: OP class IE 245 * @WLAN_ELEMID_EXTCHANSWITCHANN: Extended Channel switch IE 246 * @WLAN_ELEMID_HTINFO_ANA: HT info IE 247 * @WLAN_ELEMID_SECCHANOFFSET: Sec channel Offset IE 248 * @WLAN_ELEMID_WAPI: WAPI IE 249 * @WLAN_ELEMID_TIME_ADVERTISEMENT: Time IE 250 * @WLAN_ELEMID_RRM: Radio resource measurement IE 251 * @WLAN_ELEMID_MULTIPLE_BSSID: Multiple BSSID IE 252 * @WLAN_ELEMID_2040_COEXT: 20-40 COext ext IE 253 * @WLAN_ELEMID_2040_INTOL:20-40 INT OL IE 254 * @WLAN_ELEMID_OBSS_SCAN: OBSS scan IE 255 * @WLAN_ELEMID_MMIE: 802.11w Management MIC IE 256 * @WLAN_ELEMID_NONTX_BSSID_CAP: Nontransmitted BSSID Capability IE 257 * @WLAN_ELEMID_MULTI_BSSID_IDX: Multiple BSSID index 258 * @WLAN_ELEMID_FMS_DESCRIPTOR: 802.11v FMS descriptor IE 259 * @WLAN_ELEMID_FMS_REQUEST: 802.11v FMS request IE 260 * @WLAN_ELEMID_FMS_RESPONSE: 802.11v FMS response IE 261 * @WLAN_ELEMID_BSSMAX_IDLE_PERIOD = 90: BSS MAX IDLE PERIOD 262 * @WLAN_ELEMID_TFS_REQUEST: TFS req IE 263 * @WLAN_ELEMID_TFS_RESPONSE: TFS resp IE 264 * @WLAN_ELEMID_TIM_BCAST_REQUEST: TIM bcast req IE 265 * @WLAN_ELEMID_TIM_BCAST_RESPONSE: TIM bcast resp IE 266 * @WLAN_ELEMID_INTERWORKING: Interworking IE 267 * @WLAN_ELEMID_QOS_MAP: QOS MAP IE 268 * @WLAN_ELEMID_XCAPS: Extended capability IE 269 * @WLAN_ELEMID_TPC: TPC IE 270 * @WLAN_ELEMID_CCKM: CCKM IE 271 * @WLAN_ELEMID_VHTCAP: VHT Capabilities 272 * @WLAN_ELEMID_VHTOP: VHT Operation 273 * @WLAN_ELEMID_EXT_BSS_LOAD: Extended BSS Load 274 * @WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH: Wide Band Channel Switch 275 * @WLAN_ELEMID_VHT_TX_PWR_ENVLP: VHT Transmit Power Envelope 276 * @WLAN_ELEMID_CHAN_SWITCH_WRAP: Channel Switch Wrapper 277 * @WLAN_ELEMID_AID: AID 278 * @WLAN_ELEMID_QUIET_CHANNEL: Quiet Channel 279 * @WLAN_ELEMID_OP_MODE_NOTIFY: Operating Mode Notification 280 * @WLAN_ELEMID_VENDOR: vendor private 281 * @WLAN_ELEMID_EXTN_ELEM: extended IE 282 */ 283 enum element_ie { 284 WLAN_ELEMID_SSID = 0, 285 WLAN_ELEMID_RATES = 1, 286 WLAN_ELEMID_FHPARMS = 2, 287 WLAN_ELEMID_DSPARMS = 3, 288 WLAN_ELEMID_CFPARMS = 4, 289 WLAN_ELEMID_TIM = 5, 290 WLAN_ELEMID_IBSSPARMS = 6, 291 WLAN_ELEMID_COUNTRY = 7, 292 WLAN_ELEMID_REQINFO = 10, 293 WLAN_ELEMID_QBSS_LOAD = 11, 294 WLAN_ELEMID_TCLAS = 14, 295 WLAN_ELEMID_CHALLENGE = 16, 296 /* 17-31 reserved for challenge text extension */ 297 WLAN_ELEMID_PWRCNSTR = 32, 298 WLAN_ELEMID_PWRCAP = 33, 299 WLAN_ELEMID_TPCREQ = 34, 300 WLAN_ELEMID_TPCREP = 35, 301 WLAN_ELEMID_SUPPCHAN = 36, 302 WLAN_ELEMID_CHANSWITCHANN = 37, 303 WLAN_ELEMID_MEASREQ = 38, 304 WLAN_ELEMID_MEASREP = 39, 305 WLAN_ELEMID_QUIET = 40, 306 WLAN_ELEMID_IBSSDFS = 41, 307 WLAN_ELEMID_ERP = 42, 308 WLAN_ELEMID_TCLAS_PROCESS = 44, 309 WLAN_ELEMID_HTCAP_ANA = 45, 310 WLAN_ELEMID_RSN = 48, 311 WLAN_ELEMID_XRATES = 50, 312 WLAN_ELEMID_HTCAP_VENDOR = 51, 313 WLAN_ELEMID_HTINFO_VENDOR = 52, 314 WLAN_ELEMID_MOBILITY_DOMAIN = 54, 315 WLAN_ELEMID_FT = 55, 316 WLAN_ELEMID_TIMEOUT_INTERVAL = 56, 317 WLAN_ELEMID_SUPP_OP_CLASS = 59, 318 WLAN_ELEMID_EXTCHANSWITCHANN = 60, 319 WLAN_ELEMID_HTINFO_ANA = 61, 320 WLAN_ELEMID_SECCHANOFFSET = 62, 321 WLAN_ELEMID_WAPI = 68, 322 WLAN_ELEMID_TIME_ADVERTISEMENT = 69, 323 WLAN_ELEMID_RRM = 70, 324 WLAN_ELEMID_MULTIPLE_BSSID = 71, 325 WLAN_ELEMID_2040_COEXT = 72, 326 WLAN_ELEMID_2040_INTOL = 73, 327 WLAN_ELEMID_OBSS_SCAN = 74, 328 WLAN_ELEMID_MMIE = 76, 329 WLAN_ELEMID_NONTX_BSSID_CAP = 83, 330 WLAN_ELEMID_MULTI_BSSID_IDX = 85, 331 WLAN_ELEMID_FMS_DESCRIPTOR = 86, 332 WLAN_ELEMID_FMS_REQUEST = 87, 333 WLAN_ELEMID_FMS_RESPONSE = 88, 334 WLAN_ELEMID_BSSMAX_IDLE_PERIOD = 90, 335 WLAN_ELEMID_TFS_REQUEST = 91, 336 WLAN_ELEMID_TFS_RESPONSE = 92, 337 WLAN_ELEMID_TIM_BCAST_REQUEST = 94, 338 WLAN_ELEMID_TIM_BCAST_RESPONSE = 95, 339 WLAN_ELEMID_INTERWORKING = 107, 340 WLAN_ELEMID_QOS_MAP = 110, 341 WLAN_ELEMID_XCAPS = 127, 342 WLAN_ELEMID_TPC = 150, 343 WLAN_ELEMID_CCKM = 156, 344 WLAN_ELEMID_VHTCAP = 191, 345 WLAN_ELEMID_VHTOP = 192, 346 WLAN_ELEMID_EXT_BSS_LOAD = 193, 347 WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH = 194, 348 WLAN_ELEMID_VHT_TX_PWR_ENVLP = 195, 349 WLAN_ELEMID_CHAN_SWITCH_WRAP = 196, 350 WLAN_ELEMID_AID = 197, 351 WLAN_ELEMID_QUIET_CHANNEL = 198, 352 WLAN_ELEMID_OP_MODE_NOTIFY = 199, 353 WLAN_ELEMID_VENDOR = 221, 354 WLAN_ELEMID_FILS_INDICATION = 240, 355 WLAN_ELEMID_EXTN_ELEM = 255, 356 }; 357 358 /** 359 * enum extn_element_ie :- extended management information element 360 * @WLAN_EXTN_ELEMID_HECAP: HE capabilities IE 361 * @WLAN_EXTN_ELEMID_HEOP: HE Operation IE 362 * @WLAN_EXTN_ELEMID_MUEDCA: MU-EDCA IE 363 * @WLAN_EXTN_ELEMID_SRP: spatial reuse parameter IE 364 */ 365 enum extn_element_ie { 366 WLAN_EXTN_ELEMID_HECAP = 35, 367 WLAN_EXTN_ELEMID_HEOP = 36, 368 WLAN_EXTN_ELEMID_MUEDCA = 38, 369 WLAN_EXTN_ELEMID_SRP = 39, 370 WLAN_EXTN_ELEMID_ESP = 11, 371 }; 372 373 #define WLAN_OUI_SIZE 4 374 #define WLAN_MAX_CIPHER 6 375 #define WLAN_RSN_SELECTOR_LEN 4 376 #define WLAN_WPA_SELECTOR_LEN 4 377 #define PMKID_LEN 16 378 #define MAX_PMKID 4 379 380 #define WLAN_WPA_OUI 0xf25000 381 #define WLAN_WPA_OUI_TYPE 0x01 382 #define WPA_VERSION 1 383 #define WLAN_WPA_SEL(x) (((x) << 24) | WLAN_WPA_OUI) 384 385 #define WLAN_RSN_OUI 0xac0f00 386 #define WLAN_CCKM_OUI 0x964000 387 #define WLAN_CCKM_ASE_UNSPEC 0 388 #define WLAN_WPA_CCKM_AKM 0x00964000 389 #define WLAN_RSN_CCKM_AKM 0x00964000 390 #define WLAN_RSN_DPP_AKM 0x029A6F50 391 392 #define RSN_VERSION 1 393 #define WLAN_RSN_SEL(x) (((x) << 24) | WLAN_RSN_OUI) 394 #define WLAN_CCKM_SEL(x) (((x) << 24) | WLAN_CCKM_OUI) 395 396 #define WLAN_CSE_NONE 0x00 397 #define WLAN_CSE_WEP40 0x01 398 #define WLAN_CSE_TKIP 0x02 399 #define WLAN_CSE_RESERVED 0x03 400 #define WLAN_CSE_CCMP 0x04 401 #define WLAN_CSE_WEP104 0x05 402 #define WLAN_CSE_AES_CMAC 0x06 403 #define WLAN_CSE_GCMP_128 0x08 404 #define WLAN_CSE_GCMP_256 0x09 405 #define WLAN_CSE_CCMP_256 0x0A 406 #define WLAN_CSE_BIP_GMAC_128 0x0B 407 #define WLAN_CSE_BIP_GMAC_256 0x0C 408 #define WLAN_CSE_BIP_CMAC_256 0x0D 409 410 #define WLAN_AKM_IEEE8021X 0x01 411 #define WLAN_AKM_PSK 0x02 412 #define WLAN_AKM_FT_IEEE8021X 0x03 413 #define WLAN_AKM_FT_PSK 0x04 414 #define WLAN_AKM_SHA256_IEEE8021X 0x05 415 #define WLAN_AKM_SHA256_PSK 0x06 416 #define WLAN_AKM_SAE 0x08 417 #define WLAN_AKM_SUITEB_EAP_SHA256 0x0B 418 #define WLAN_AKM_SUITEB_EAP_SHA384 0x0C 419 #define WLAN_AKM_FILS_SHA256 0x0E 420 #define WLAN_AKM_FILS_SHA384 0x0F 421 #define WLAN_AKM_FILS_FT_SHA256 0x10 422 #define WLAN_AKM_FILS_FT_SHA384 0x11 423 #define WLAN_AKM_OWE 0x12 424 425 #define WLAN_ASE_NONE 0x00 426 #define WLAN_ASE_8021X_UNSPEC 0x01 427 #define WLAN_ASE_8021X_PSK 0x02 428 #define WLAN_ASE_FT_IEEE8021X 0x20 429 #define WLAN_ASE_FT_PSK 0x40 430 #define WLAN_ASE_SHA256_IEEE8021X 0x80 431 #define WLAN_ASE_SHA256_PSK 0x100 432 #define WLAN_ASE_WPS 0x200 433 434 #define RSN_CAP_MFP_CAPABLE 0x80 435 #define RSN_CAP_MFP_REQUIRED 0x40 436 437 /** 438 * struct wlan_rsn_ie_hdr: rsn ie header 439 * @elem_id: RSN element id WLAN_ELEMID_RSN. 440 * @len: rsn ie length 441 * @version: RSN ver 442 */ 443 struct wlan_rsn_ie_hdr { 444 u8 elem_id; 445 u8 len; 446 u8 version[2]; 447 }; 448 449 #define WLAN_RSN_IE_MIN_LEN 2 450 451 /** 452 * struct wlan_rsn_ie: rsn ie info 453 * @ver: RSN ver 454 * @gp_cipher_suite: group cipher 455 * @pwise_cipher_count: number of pw cipher 456 * @pwise_cipher_suites: pair wise cipher list 457 * @akm_suite_count: Number of akm suite 458 * @akm_suites: akm suites list 459 * @cap: RSN capability 460 * @pmkid_count: number of PMKID 461 * @pmkid: PMKID list 462 * @mgmt_cipher_suite: management (11w) cipher suite 463 */ 464 struct wlan_rsn_ie { 465 uint16_t ver; 466 uint32_t gp_cipher_suite; 467 uint16_t pwise_cipher_count; 468 uint32_t pwise_cipher_suites[WLAN_MAX_CIPHER]; 469 uint16_t akm_suite_count; 470 uint32_t akm_suites[WLAN_MAX_CIPHER]; 471 uint16_t cap; 472 uint16_t pmkid_count; 473 uint8_t pmkid[MAX_PMKID][PMKID_LEN]; 474 uint32_t mgmt_cipher_suite; 475 }; 476 477 #define WLAN_WAPI_IE_MIN_LEN 20 478 479 /** 480 * struct wlan_wpa_ie_hdr: wpa ie header 481 * @elem_id: Wpa element id, vender specific. 482 * @len: wpa ie length 483 * @oui: 24-bit OUI followed by 8-bit OUI type 484 * @version: wpa ver 485 */ 486 struct wlan_wpa_ie_hdr { 487 u8 elem_id; 488 u8 len; 489 u8 oui[4]; 490 u8 version[2]; 491 }; 492 493 /** 494 * struct wlan_wpa_ie: WPA ie info 495 * @ver: WPA ver 496 * @mc_cipher: multicast cipher 497 * @uc_cipher_count: number of unicast cipher 498 * @uc_ciphers: unicast cipher list 499 * @auth_suite_count: Number of akm suite 500 * @auth_suites: akm suites list 501 * @cap: WPA capability 502 */ 503 struct wlan_wpa_ie { 504 uint16_t ver; 505 uint32_t mc_cipher; 506 uint16_t uc_cipher_count; 507 uint32_t uc_ciphers[WLAN_MAX_CIPHER]; 508 uint16_t auth_suite_count; 509 uint32_t auth_suites[WLAN_MAX_CIPHER]; 510 uint16_t cap; 511 }; 512 513 #define WAPI_VERSION 1 514 #define WLAN_WAPI_OUI 0x721400 515 516 #define WLAN_WAPI_SEL(x) (((x) << 24) | WLAN_WAPI_OUI) 517 518 #define WLAN_WAI_CERT_OR_SMS4 0x01 519 #define WLAN_WAI_PSK 0x02 520 521 /** 522 * struct wlan_wapi_ie: WAPI ie info 523 * @ver: WAPI ver 524 * @akm_suite_count: Number of akm suite 525 * @akm_suites: akm suites list 526 * @uc_cipher_suites:unicast cipher count 527 * @uc_cipher_suites: unicast cipher suite 528 * @mc_cipher_suite: mc cipher suite 529 */ 530 struct wlan_wapi_ie { 531 uint16_t ver; 532 uint16_t akm_suite_count; 533 uint32_t akm_suites[WLAN_MAX_CIPHER]; 534 uint16_t uc_cipher_count; 535 uint32_t uc_cipher_suites[WLAN_MAX_CIPHER]; 536 uint32_t mc_cipher_suite; 537 }; 538 539 /** 540 * struct wlan_frame_hdr: generic IEEE 802.11 frames 541 * @i_fc: frame control 542 * @i_dur: duration field 543 * @i_addr1: mac address 1 544 * @i_addr2: mac address 2 545 * @i_addr3: mac address 3 546 * @i_seq: seq info 547 */ 548 struct wlan_frame_hdr { 549 uint8_t i_fc[2]; 550 uint8_t i_dur[2]; 551 union { 552 struct { 553 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 554 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 555 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 556 }; 557 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 558 }; 559 uint8_t i_seq[2]; 560 } qdf_packed; 561 562 /* sequence number offset base on begin of mac header */ 563 #define WLAN_SEQ_CTL_OFFSET 22 564 #define WLAN_LOW_SEQ_NUM_MASK 0x000F 565 #define WLAN_HIGH_SEQ_NUM_MASK 0x0FF0 566 #define WLAN_HIGH_SEQ_NUM_OFFSET 4 567 568 /** 569 * struct wlan_seq_ctl: sequence number control 570 * @frag_num: frag number 571 * @seq_num_lo: sequence number low byte 572 * @seq_num_hi: sequence number high byte 573 */ 574 struct wlan_seq_ctl { 575 uint8_t frag_num:4; 576 uint8_t seq_num_lo:4; 577 uint8_t seq_num_hi:8; 578 } qdf_packed; 579 580 /** 581 * union wlan_capability : wlan_capability info 582 * @value: capability value 583 */ 584 union wlan_capability { 585 struct caps { 586 uint16_t ess:1; 587 uint16_t ibss:1; 588 uint16_t cf_pollable:1; 589 uint16_t cf_poll_request:1; 590 uint16_t privacy:1; 591 uint16_t short_preamble:1; 592 uint16_t pbcc:1; 593 uint16_t channel_agility:1; 594 uint16_t spectrum_management:1; 595 uint16_t qos:1; 596 uint16_t short_slot_time:1; 597 uint16_t apsd:1; 598 uint16_t reserved2:1; 599 uint16_t dsss_ofdm:1; 600 uint16_t del_block_ack:1; 601 uint16_t immed_block_ack:1; 602 } wlan_caps; 603 uint16_t value; 604 } qdf_packed; 605 606 /** 607 * struct ie_header : IE header 608 * @ie_id: Element Id 609 * @ie_len: IE Length 610 */ 611 struct ie_header { 612 uint8_t ie_id; 613 uint8_t ie_len; 614 } qdf_packed; 615 616 /** 617 * struct extn_ie_header : Extension IE header 618 * @ie_id: Element Id 619 * @ie_len: IE Length 620 * @ie_extn_id: extension id 621 */ 622 struct extn_ie_header { 623 uint8_t ie_id; 624 uint8_t ie_len; 625 uint8_t ie_extn_id; 626 } qdf_packed; 627 628 629 /** 630 * struct ie_ssid : ssid IE 631 * @ssid_id: SSID Element Id 632 * @ssid_len: SSID IE Length 633 * @ssid: ssid value 634 */ 635 struct ie_ssid { 636 uint8_t ssid_id; 637 uint8_t ssid_len; 638 uint8_t ssid[WLAN_SSID_MAX_LEN]; 639 } qdf_packed; 640 641 /** 642 * struct ds_ie : ds IE 643 * @ie: DS Element Id 644 * @len: DS IE Length 645 * @cur_chan: channel info 646 */ 647 struct ds_ie { 648 uint8_t ie; 649 uint8_t len; 650 uint8_t cur_chan; 651 } qdf_packed; 652 653 /** 654 * struct erp_ie: ERP IE 655 * @ie: ERP Element Id 656 * @len: ERP IE Length 657 * @value: EP Info 658 */ 659 struct erp_ie { 660 uint8_t ie; 661 uint8_t len; 662 uint8_t value; 663 } qdf_packed; 664 665 /** 666 * struct htcap_cmn_ie: HT common IE info 667 * @hc_cap: HT capabilities 668 * @ampdu_param: ampdu params 669 * @mcsset: supported MCS set 670 * @extcap: extended HT capabilities 671 * @txbf_cap: txbf capabilities 672 * @antenna: antenna capabilities 673 */ 674 struct htcap_cmn_ie { 675 uint16_t hc_cap; 676 uint8_t ampdu_param; 677 uint8_t mcsset[16]; 678 uint16_t extcap; 679 uint32_t txbf_cap; 680 uint8_t antenna; 681 } qdf_packed; 682 683 /** 684 * struct htcap_ie: HT Capability IE 685 * @id: HT IE 686 * @len: HT IE LEN 687 * @ie: HT cap info 688 */ 689 struct htcap_ie { 690 uint8_t id; 691 uint8_t len; 692 struct htcap_cmn_ie ie; 693 } qdf_packed; 694 695 /** 696 * struct fils_indication_ie: FILS indication IE element 697 * @id: id 698 * @len: len 699 * @public_key_identifiers_cnt: public key identifiers count 700 * @realm_identifiers_cnt: realm identifiers count 701 * @is_ip_config_supported: whether ip config is supported in AP 702 * @is_cache_id_present: whether cache identifier is present 703 * @is_hessid_present: whether hessid is present 704 * @is_fils_sk_auth_supported: FILS shared key authentication is supported 705 * @is_fils_sk_auth_pfs_supported: FILS shared key auth with PFS is supported 706 * @is_pk_auth_supported: FILS public key authentication is supported 707 * @reserved: reserved 708 * @variable_data: pointer to data depends on initial variables 709 */ 710 struct fils_indication_ie { 711 uint8_t id; 712 uint8_t len; 713 uint16_t public_key_identifiers_cnt:3; 714 uint16_t realm_identifiers_cnt:3; 715 uint16_t is_ip_config_supported:1; 716 uint16_t is_cache_id_present:1; 717 uint16_t is_hessid_present:1; 718 uint16_t is_fils_sk_auth_supported:1; 719 uint16_t is_fils_sk_auth_pfs_supported:1; 720 uint16_t is_pk_auth_supported:1; 721 uint16_t reserved:4; 722 uint8_t variable_data[253]; 723 } qdf_packed; 724 725 #define WLAN_VENDOR_HT_IE_OFFSET_LEN 4 726 727 /** 728 * struct wlan_vendor_ie_htcap: vendor private HT Capability IE 729 * @id: HT IE 730 * @hlen: HT IE len 731 * @oui: vendor OUI 732 * @oui_type: Oui type 733 * @ie: HT cap info 734 */ 735 struct wlan_vendor_ie_htcap { 736 uint8_t id; 737 uint8_t hlen; 738 uint8_t oui[3]; 739 uint8_t oui_type; 740 struct htcap_cmn_ie ie; 741 } qdf_packed; 742 743 /** 744 * struct wlan_ie_htinfo_cmn: ht info comman 745 * @hi_ctrlchannel: control channel 746 * @hi_extchoff: B0-1 extension channel offset 747 * @hi_txchwidth: B2 recommended xmiss width set 748 * @hi_rifsmode: rifs mode 749 * @hi_ctrlaccess: controlled access only 750 * @hi_serviceinterval: B5-7 svc interval granularity 751 * @uhi_opmode: B0-1 operating mode 752 * @hi_nongfpresent: B2 non greenfield devices present 753 * @hi_txburstlimit: B3 transmit burst limit 754 * @hi_obssnonhtpresent: B4 OBSS non-HT STA present 755 * @hi_reserved0: B5-15 reserved 756 * @hi_reserved2: B0-5 reserved 757 * @hi_dualbeacon: B6 dual beacon 758 * @hi_dualctsprot: B7 dual CTS protection 759 * @hi_stbcbeacon: B8 STBC beacon 760 * @hi_lsigtxopprot: B9 l-sig txop protection full support 761 * @hi_pcoactive: B10 pco active 762 * @hi_pcophase: B11 pco phase 763 * @hi_reserved1: B12-15 reserved 764 * @hi_basicmcsset[16]: basic MCS set 765 */ 766 struct wlan_ie_htinfo_cmn { 767 uint8_t hi_ctrlchannel; 768 uint8_t hi_extchoff:2, 769 hi_txchwidth:1, 770 hi_rifsmode:1, 771 hi_ctrlaccess:1, 772 hi_serviceinterval:3; 773 uint16_t hi_opmode:2, 774 hi_nongfpresent:1, 775 hi_txburstlimit:1, 776 hi_obssnonhtpresent:1, 777 hi_reserved0:11; 778 uint16_t hi_reserved2:6, 779 hi_dualbeacon:1, 780 hi_dualctsprot:1, 781 hi_stbcbeacon:1, 782 hi_lsigtxopprot:1, 783 hi_pcoactive:1, 784 hi_pcophase:1, 785 hi_reserved1:4; 786 uint8_t hi_basicmcsset[16]; 787 } qdf_packed; 788 789 /** 790 * struct wlan_ie_htinfo: HT info IE 791 * @hi_id: HT info IE 792 * @hi_len: HT info IE len 793 * @hi_ie: HT info info 794 */ 795 struct wlan_ie_htinfo { 796 uint8_t hi_id; 797 uint8_t hi_len; 798 struct wlan_ie_htinfo_cmn hi_ie; 799 } qdf_packed; 800 801 /** 802 * struct wlan_ie_htinfo: vendor private HT info IE 803 * @hi_id: HT info IE 804 * @hi_len: HT info IE len 805 * @hi_oui: vendor OUI 806 * @hi_ouitype: Oui type 807 * @hi_ie: HT info info 808 */ 809 struct wlan_vendor_ie_htinfo { 810 uint8_t hi_id; 811 uint8_t hi_len; 812 uint8_t hi_oui[3]; 813 uint8_t hi_ouitype; 814 struct wlan_ie_htinfo_cmn hi_ie; 815 } qdf_packed; 816 817 #define WLAN_VENDOR_VHTCAP_IE_OFFSET 7 818 #define WLAN_VENDOR_VHTOP_IE_OFFSET 21 819 820 /** 821 * struct wlan_ie_vhtcaps - VHT capabilities 822 * @elem_id: VHT caps IE 823 * @elem_len: VHT caps IE len 824 * @max_mpdu_len: MPDU length 825 * @supported_channel_widthset: channel width set 826 * @ldpc_coding: LDPC coding capability 827 * @shortgi80: short GI 80 support 828 * @shortgi160and80plus80: short Gi 160 & 80+80 support 829 * @tx_stbc; Tx STBC cap 830 * @tx_stbc: Rx STBC cap 831 * @su_beam_former: SU beam former cap 832 * @su_beam_formee: SU beam formee cap 833 * @csnof_beamformer_antSup: Antenna support for beamforming 834 * @num_soundingdim: Sound dimensions 835 * @mu_beam_former: MU beam former cap 836 * @mu_beam_formee: MU beam formee cap 837 * @vht_txops: TXOP power save 838 * @htc_vhtcap: HTC VHT capability 839 * @max_ampdu_lenexp: AMPDU length 840 * @vht_link_adapt: VHT link adapatation capable 841 * @rx_antpattern: Rx Antenna pattern 842 * @tx_antpattern: Tx Antenna pattern 843 * @rx_mcs_map: RX MCS map 844 * @rx_high_sup_data_rate : highest RX supported data rate 845 * @tx_mcs_map: TX MCS map 846 * @tx_sup_data_rate: highest TX supported data rate 847 */ 848 struct wlan_ie_vhtcaps { 849 uint8_t elem_id; 850 uint8_t elem_len; 851 uint32_t max_mpdu_len:2; 852 uint32_t supported_channel_widthset:2; 853 uint32_t ldpc_coding:1; 854 uint32_t shortgi80:1; 855 uint32_t shortgi160and80plus80:1; 856 uint32_t tx_stbc:1; 857 uint32_t rx_stbc:3; 858 uint32_t su_beam_former:1; 859 uint32_t su_beam_formee:1; 860 uint32_t csnof_beamformer_antSup:3; 861 uint32_t num_soundingdim:3; 862 uint32_t mu_beam_former:1; 863 uint32_t mu_beam_formee:1; 864 uint32_t vht_txops:1; 865 uint32_t htc_vhtcap:1; 866 uint32_t max_ampdu_lenexp:3; 867 uint32_t vht_link_adapt:2; 868 uint32_t rx_antpattern:1; 869 uint32_t tx_antpattern:1; 870 uint32_t unused:2; 871 uint16_t rx_mcs_map; 872 uint16_t rx_high_sup_data_rate:13; 873 uint16_t reserved2:3; 874 uint16_t tx_mcs_map; 875 uint16_t tx_sup_data_rate:13; 876 uint16_t reserved3:3; 877 } qdf_packed; 878 879 /** 880 * struct wlan_ie_vhtop: VHT op IE 881 * @elem_id: VHT op IE 882 * @elem_len: VHT op IE len 883 * @vht_op_chwidth: BSS Operational Channel width 884 * @vht_op_ch_freq_seg1: Channel Center frequency 885 * @vht_op_ch_freq_seg2: Channel Center frequency for 80+80MHz 886 * @vhtop_basic_mcs_set: Basic MCS set 887 */ 888 struct wlan_ie_vhtop { 889 uint8_t elem_id; 890 uint8_t elem_len; 891 uint8_t vht_op_chwidth; 892 uint8_t vht_op_ch_freq_seg1; 893 uint8_t vht_op_ch_freq_seg2; 894 uint16_t vhtop_basic_mcs_set; 895 } qdf_packed; 896 897 /** 898 * struct wlan_country_ie: country IE 899 * @ie: country IE 900 * @len: IE len 901 * @cc: country code 902 */ 903 struct wlan_country_ie { 904 uint8_t ie; 905 uint8_t len; 906 uint8_t cc[3]; 907 } qdf_packed; 908 909 /** 910 * struct wlan_country_ie: country IE 911 * @ie: QBSS IE 912 * @len: IE len 913 * @station_count: number of station associated 914 * @qbss_chan_load: qbss channel load 915 * @qbss_load_avail: qbss_load_avail 916 */ 917 struct qbss_load_ie { 918 uint8_t ie; 919 uint8_t len; 920 uint16_t station_count; 921 uint8_t qbss_chan_load; 922 uint16_t qbss_load_avail; 923 } qdf_packed; 924 925 /** 926 * struct wlan_bcn_frame: beacon frame fixed params 927 * @timestamp: the value of sender's TSFTIMER 928 * @beacon_interval: beacon interval 929 * @capability: capability 930 * @ie: variable IE 931 */ 932 struct wlan_bcn_frame { 933 uint8_t timestamp[8]; 934 uint16_t beacon_interval; 935 union wlan_capability capability; 936 struct ie_header ie; 937 } qdf_packed; 938 939 #define WLAN_TIM_IE_MIN_LENGTH 4 940 941 /** 942 * struct wlan_tim_ie: tim IE 943 * @tim_ie: Time IE 944 * @tim_len: TIM IE len 945 * @tim_count: dtim count 946 * @tim_period: dtim period 947 * @tim_bitctl: bitmap control 948 * @tim_bitmap: variable length bitmap 949 */ 950 struct wlan_tim_ie { 951 uint8_t tim_ie; /* WLAN_ELEMID_TIM */ 952 uint8_t tim_len; 953 uint8_t tim_count; /* DTIM count */ 954 uint8_t tim_period; /* DTIM period */ 955 uint8_t tim_bitctl; /* bitmap control */ 956 uint8_t tim_bitmap[251]; /* variable-length bitmap */ 957 } qdf_packed; 958 959 /** 960 * struct rsn_mdie: mobility domain IE 961 * @rsn_id: RSN IE id 962 * @rsn_len: RSN IE len 963 * @mobility_domain: mobility domain info 964 * @ft_capab: ft capability 965 * 966 * Reference 9.4.2.47 Mobility Domain element (MDE) of 802.11-2016 967 */ 968 struct rsn_mdie { 969 uint8_t rsn_id; 970 uint8_t rsn_len; 971 uint8_t mobility_domain[2]; 972 uint8_t ft_capab; 973 } qdf_packed; 974 975 /** 976 * struct srp_ie: Spatial reuse parameter IE 977 * @srp_id: SRP IE id 978 * @srp_len: SRP IE len 979 * @srp_id_extn: SRP Extension ID 980 * @sr_control: sr control 981 * @non_srg_obsspd_max_offset: non srg obsspd max offset 982 * @srg_obss_pd_min_offset: srg obss pd min offset 983 * @srg_obss_pd_max_offset: srg obss pd max offset 984 * @srg_bss_color_bitmap: srg bss color bitmap 985 * @srg_partial_bssid_bitmap: srg partial bssid bitmap 986 */ 987 struct wlan_srp_ie { 988 uint8_t srp_id; 989 uint8_t srp_len; 990 uint8_t srp_id_extn; 991 uint8_t sr_control; 992 union { 993 struct { 994 uint8_t non_srg_obsspd_max_offset; 995 uint8_t srg_obss_pd_min_offset; 996 uint8_t srg_obss_pd_max_offset; 997 uint8_t srg_bss_color_bitmap[8]; 998 uint8_t srg_partial_bssid_bitmap[8]; 999 } qdf_packed nonsrg_srg_info; 1000 struct { 1001 uint8_t non_srg_obsspd_max_offset; 1002 } qdf_packed nonsrg_info; 1003 struct { 1004 uint8_t srg_obss_pd_min_offset; 1005 uint8_t srg_obss_pd_max_offset; 1006 uint8_t srg_bss_color_bitmap[8]; 1007 uint8_t srg_partial_bssid_bitmap[8]; 1008 } qdf_packed srg_info; 1009 }; 1010 } qdf_packed; 1011 1012 #define ESP_INFORMATION_LIST_LENGTH 3 1013 #define MAX_ESP_INFORMATION_FIELD 4 1014 /* 1015 * enum access_category: tells about access category in ESP paramameter 1016 * @ESP_AC_BK: ESP access category for background 1017 * @ESP_AC_BE: ESP access category for best effort 1018 * @ESP_AC_VI: ESP access category for video 1019 * @ESP_AC_VO: ESP access category for Voice 1020 */ 1021 enum access_category { 1022 ESP_AC_BK, 1023 ESP_AC_BE, 1024 ESP_AC_VI, 1025 ESP_AC_VO, 1026 1027 }; 1028 /* 1029 * struct wlan_esp_info: structure for Esp information parameter 1030 * @access_category: access category info 1031 * @reserved: reserved 1032 * @data_format: two bits in length and tells about data format 1033 * i.e. 0 = No aggregation is expected to be performed for MSDUs or MPDUs with 1034 * the Type subfield equal to Data for the corresponding AC 1035 * 1 = A-MSDU aggregation is expected to be performed for MSDUs for the 1036 * corresponding AC, but A-MPDU aggregation is not expected to be performed 1037 * for MPDUs with the Type subfield equal to Data for the corresponding AC 1038 * 2 = A-MPDU aggregation is expected to be performed for MPDUs with the Type 1039 * subfield equal to Data for the corresponding AC, but A-MSDU aggregation is 1040 * not expected to be performed for MSDUs for the corresponding AC 1041 * 3 = A-MSDU aggregation is expected to be performed for MSDUs for the 1042 * corresponding AC and A-MPDU aggregation is expected to be performed for 1043 * MPDUs with the Type subfield equal to Data for the corresponding AC 1044 * @ba_window_size: BA Window Size subfield is three bits in length and 1045 * indicates the size of the Block Ack window that is 1046 * expected for the corresponding access category 1047 * @estimated_air_fraction: Estimated Air Time Fraction subfield is 8 bits in 1048 * length and contains an unsigned integer that represents 1049 * the predicted percentage of time, linearly scaled with 255 representing 1050 * 100%, that a new STA joining the 1051 * BSS will be allocated for PPDUs that contain only 1052 * MPDUs with the Type 1053 * subfield equal to Data of the 1054 * corresponding access category for that STA. 1055 * @ppdu_duration: Data PPDU Duration Target field 1056 * is 8 bits in length and is 1057 * an unsigned integer that indicates the 1058 * expected target duration of PPDUs that contain only MPDUs with the Type 1059 * subfield equal to Data for the 1060 * corresponding access category in units of 50 μs 1061 */ 1062 struct wlan_esp_info { 1063 uint8_t access_category:2; 1064 uint8_t reserved:1; 1065 uint8_t data_format:2; 1066 uint8_t ba_window_size:3; 1067 uint8_t estimated_air_fraction; 1068 uint8_t ppdu_duration; 1069 }; 1070 1071 /** 1072 * struct wlan_esp_ie: struct for ESP information 1073 * @esp_id: ESP IE id 1074 * @esp_len: ESP IE len 1075 * @esp_id_extn: ESP Extension ID 1076 * @esp_info_AC_BK: ESP information related to BK category 1077 * @esp_info_AC_BE: ESP information related to BE category 1078 * @esp_info_AC_VI: ESP information related to VI category 1079 * @esp_info_AC_VO: ESP information related to VO category 1080 */ 1081 struct wlan_esp_ie { 1082 uint8_t esp_id; 1083 uint8_t esp_len; 1084 uint8_t esp_id_extn; 1085 struct wlan_esp_info esp_info_AC_BK; 1086 struct wlan_esp_info esp_info_AC_BE; 1087 struct wlan_esp_info esp_info_AC_VI; 1088 struct wlan_esp_info esp_info_AC_VO; 1089 } qdf_packed; 1090 1091 /** 1092 * struct wlan_ext_cap_ie - struct for extended capabilities information 1093 * @ext_cap_id: Extended capabilities id 1094 * @ext_cap_len: Extended capabilities IE len 1095 * @ext_caps: Variable length extended capabilities information 1096 */ 1097 struct wlan_ext_cap_ie { 1098 uint8_t ext_cap_id; 1099 uint8_t ext_cap_len; 1100 uint8_t ext_caps[]; 1101 } qdf_packed; 1102 1103 /** 1104 * struct oce_reduced_wan_metrics: struct for oce wan metrics 1105 * @downlink_av_cap: Download available capacity 1106 * @uplink_av_cap: Upload available capacity 1107 */ 1108 struct oce_reduced_wan_metrics { 1109 uint8_t downlink_av_cap:4; 1110 uint8_t uplink_av_cap:4; 1111 }; 1112 1113 /** 1114 * is_wpa_oui() - If vendor IE is WPA type 1115 * @frm: vendor IE pointer 1116 * 1117 * API to check if vendor IE is WPA 1118 * 1119 * Return: true if its WPA IE 1120 */ 1121 static inline bool 1122 is_wpa_oui(uint8_t *frm) 1123 { 1124 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1125 ((WLAN_WPA_OUI_TYPE << 24) | WLAN_WPA_OUI)); 1126 } 1127 1128 /** 1129 * is_wps_oui() - If vendor IE is WPS type 1130 * @frm: vendor IE pointer 1131 * 1132 * API to check if vendor IE is WPS 1133 * 1134 * Return: true if its WPS IE 1135 */ 1136 static inline bool 1137 is_wps_oui(const uint8_t *frm) 1138 { 1139 return frm[1] > 3 && BE_READ_4(frm + 2) == WSC_OUI; 1140 } 1141 1142 /** 1143 * is_mbo_oce_oui() - If vendor IE is MBO/OCE type 1144 * @frm: vendor IE pointer 1145 * 1146 * API to check if vendor IE is MBO/OCE 1147 * 1148 * Return: true if its MBO/OCE IE 1149 */ 1150 static inline bool 1151 is_mbo_oce_oui(const uint8_t *frm) 1152 { 1153 return frm[1] > 3 && BE_READ_4(frm + 2) == MBO_OCE_OUI; 1154 } 1155 1156 /** 1157 * is_wcn_oui() - If vendor IE is WCN type 1158 * @frm: vendor IE pointer 1159 * 1160 * API to check if vendor IE is WCN 1161 * 1162 * Return: true if its WCN IE 1163 */ 1164 static inline bool 1165 is_wcn_oui(uint8_t *frm) 1166 { 1167 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1168 ((WCN_OUI_TYPE << 24) | WCN_OUI)); 1169 } 1170 1171 /** 1172 * is_wme_param() - If vendor IE is WME param type 1173 * @frm: vendor IE pointer 1174 * 1175 * API to check if vendor IE is WME param 1176 * 1177 * Return: true if its WME param IE 1178 */ 1179 static inline bool 1180 is_wme_param(const uint8_t *frm) 1181 { 1182 return (frm[1] > 5) && (LE_READ_4(frm + 2) == 1183 ((WME_OUI_TYPE << 24) | WME_OUI)) && 1184 (frm[6] == WME_PARAM_OUI_SUBTYPE); 1185 } 1186 1187 /** 1188 * is_wme_info() - If vendor IE is WME info type 1189 * @frm: vendor IE pointer 1190 * 1191 * API to check if vendor IE is WME info 1192 * 1193 * Return: true if its WME info IE 1194 */ 1195 static inline bool 1196 is_wme_info(const uint8_t *frm) 1197 { 1198 return (frm[1] > 5) && (LE_READ_4(frm + 2) == 1199 ((WME_OUI_TYPE << 24) | WME_OUI)) && 1200 (frm[6] == WME_INFO_OUI_SUBTYPE); 1201 } 1202 1203 /** 1204 * is_atheros_oui() - If vendor IE is Atheros type 1205 * @frm: vendor IE pointer 1206 * 1207 * API to check if vendor IE is Atheros 1208 * 1209 * Return: true if its Atheros IE 1210 */ 1211 static inline bool 1212 is_atheros_oui(const uint8_t *frm) 1213 { 1214 return (frm[1] > 3) && LE_READ_4(frm + 2) == 1215 ((ATH_OUI_TYPE << 24) | ATH_OUI); 1216 } 1217 1218 /** 1219 * is_atheros_extcap_oui() - If vendor IE is Atheros ext cap 1220 * @frm: vendor IE pointer 1221 * 1222 * API to check if vendor IE is Atheros ext cap 1223 * 1224 * Return: true if its Atheros ext cap IE 1225 */ 1226 static inline int 1227 is_atheros_extcap_oui(uint8_t *frm) 1228 { 1229 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1230 ((ATH_OUI_EXTCAP_TYPE << 24) | ATH_OUI)); 1231 } 1232 1233 /** 1234 * is_sfa_oui() - If vendor IE is SFA type 1235 * @frm: vendor IE pointer 1236 * 1237 * API to check if vendor IE is SFA 1238 * 1239 * Return: true if its SFA IE 1240 */ 1241 static inline bool 1242 is_sfa_oui(uint8_t *frm) 1243 { 1244 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1245 ((SFA_OUI_TYPE << 24) | SFA_OUI)); 1246 } 1247 1248 /** 1249 * is_p2p_oui() - If vendor IE is P2P type 1250 * @frm: vendor IE pointer 1251 * 1252 * API to check if vendor IE is P2P 1253 * 1254 * Return: true if its P2P IE 1255 */ 1256 static inline bool 1257 is_p2p_oui(const uint8_t *frm) 1258 { 1259 const uint8_t wfa_oui[3] = P2P_WFA_OUI; 1260 1261 return (frm[1] >= 4) && 1262 (frm[2] == wfa_oui[0]) && 1263 (frm[3] == wfa_oui[1]) && 1264 (frm[4] == wfa_oui[2]) && 1265 (frm[5] == P2P_WFA_VER); 1266 } 1267 1268 /** 1269 * is_qca_son_oui() - If vendor IE is QCA WHC type 1270 * @frm: vendor IE pointer 1271 * @whc_subtype: subtype 1272 * 1273 * API to check if vendor IE is QCA WHC 1274 * 1275 * Return: true if its QCA WHC IE 1276 */ 1277 static inline bool 1278 is_qca_son_oui(uint8_t *frm, uint8_t whc_subtype) 1279 { 1280 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1281 ((QCA_OUI_WHC_TYPE << 24) | QCA_OUI)) && 1282 (*(frm + 6) == whc_subtype); 1283 } 1284 1285 /** 1286 * is_ht_cap() - If vendor IE is vendor HT cap type 1287 * @frm: vendor IE pointer 1288 * 1289 * API to check if vendor IE is vendor HT cap 1290 * 1291 * Return: true if its vendor HT cap IE 1292 */ 1293 static inline bool 1294 is_ht_cap(uint8_t *frm) 1295 { 1296 return (frm[1] > 3) && (BE_READ_4(frm + 2) == 1297 ((VENDOR_HT_OUI << 8) | VENDOR_HT_CAP_ID)); 1298 } 1299 1300 /** 1301 * is_ht_info() - If vendor IE is vendor HT info type 1302 * @frm: vendor IE pointer 1303 * 1304 * API to check if vendor IE is vendor HT info 1305 * 1306 * Return: true if its vendor HT info IE 1307 */ 1308 static inline bool 1309 is_ht_info(uint8_t *frm) 1310 { 1311 return (frm[1] > 3) && (BE_READ_4(frm + 2) == 1312 ((VENDOR_HT_OUI << 8) | VENDOR_HT_INFO_ID)); 1313 } 1314 1315 /** 1316 * is_interop_vht() - If vendor IE is VHT interop 1317 * @frm: vendor IE pointer 1318 * 1319 * API to check if vendor IE is VHT interop 1320 * 1321 * Return: true if its VHT interop IE 1322 */ 1323 static inline bool 1324 is_interop_vht(uint8_t *frm) 1325 { 1326 return (frm[1] > 12) && (BE_READ_4(frm + 2) == 1327 ((VHT_INTEROP_OUI << 8) | VHT_INTEROP_TYPE)) && 1328 ((*(frm + 6) == VHT_INTEROP_OUI_SUBTYPE) || 1329 (*(frm + 6) == VHT_INTEROP_OUI_SUBTYPE_VENDORSPEC)); 1330 } 1331 1332 /** 1333 * is_bwnss_oui() - If vendor IE is BW NSS type 1334 * @frm: vendor IE pointer 1335 * 1336 * API to check if vendor IE is BW NSS 1337 * 1338 * Return: true if its BW NSS IE 1339 */ 1340 static inline bool 1341 is_bwnss_oui(uint8_t *frm) 1342 { 1343 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1344 ((ATH_OUI_BW_NSS_MAP_TYPE << 24) | ATH_OUI)); 1345 } 1346 1347 /** 1348 * is_he_cap_oui() - If vendor IE is HE CAP OUI 1349 * @frm: vendor IE pointer 1350 * 1351 * API to check if vendor IE is HE CAP 1352 * 1353 * Return: true if its HE CAP IE 1354 */ 1355 static inline bool 1356 is_he_cap_oui(uint8_t *frm) 1357 { 1358 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1359 ((ATH_HE_CAP_SUBTYPE << 24) | ATH_HE_OUI)); 1360 } 1361 1362 /** 1363 * is_he_op_oui() - If vendor IE is HE OP OUI 1364 * @frm: vendor IE pointer 1365 * 1366 * API to check if vendor IE is HE OP OUT 1367 * 1368 * Return: true if its HE OP OUI 1369 */ 1370 static inline bool 1371 is_he_op_oui(uint8_t *frm) 1372 { 1373 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1374 ((ATH_HE_OP_SUBTYPE << 24) | ATH_HE_OUI)); 1375 } 1376 1377 /** 1378 * is_extender_oui() - If vendor IE is EXTENDER OUI 1379 * @frm: vendor IE pointer 1380 * 1381 * API to check if vendor IE is EXTENDER OUI 1382 * 1383 * Return: true if its EXTENDER OUI 1384 */ 1385 static inline bool 1386 is_extender_oui(uint8_t *frm) 1387 { 1388 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1389 ((QCA_OUI_EXTENDER_TYPE << 24) | QCA_OUI)); 1390 } 1391 1392 /** 1393 * wlan_parse_rsn_ie() - parse rsn ie 1394 * @rsn_ie: rsn ie ptr 1395 * @rsn: out structure for the parsed ie 1396 * 1397 * API, function to parse rsn ie, if optional fields are not present use the 1398 * default values defined by standard. 1399 * 1400 * Return: QDF_STATUS 1401 */ 1402 static inline QDF_STATUS wlan_parse_rsn_ie(uint8_t *rsn_ie, 1403 struct wlan_rsn_ie *rsn) 1404 { 1405 uint8_t rsn_ie_len, i; 1406 uint8_t *ie; 1407 int rem_len; 1408 const struct wlan_rsn_ie_hdr *hdr; 1409 1410 if (!rsn_ie) 1411 return QDF_STATUS_E_NULL_VALUE; 1412 1413 ie = rsn_ie; 1414 rsn_ie_len = ie[1] + 2; 1415 1416 /* 1417 * Check the length once for fixed parts: 1418 * element id, len and version. Other, variable-length data, 1419 * must be checked separately. 1420 */ 1421 if (rsn_ie_len < sizeof(struct wlan_rsn_ie_hdr)) 1422 return QDF_STATUS_E_INVAL; 1423 1424 hdr = (struct wlan_rsn_ie_hdr *) rsn_ie; 1425 1426 if (hdr->elem_id != WLAN_ELEMID_RSN || 1427 LE_READ_2(hdr->version) != RSN_VERSION) 1428 return QDF_STATUS_E_INVAL; 1429 1430 /* Set default values for optional field. */ 1431 rsn->gp_cipher_suite = WLAN_RSN_SEL(WLAN_CSE_CCMP); 1432 rsn->pwise_cipher_count = 1; 1433 rsn->pwise_cipher_suites[0] = WLAN_RSN_SEL(WLAN_CSE_CCMP); 1434 rsn->akm_suite_count = 1; 1435 rsn->akm_suites[0] = WLAN_RSN_SEL(WLAN_AKM_IEEE8021X); 1436 1437 rsn->ver = LE_READ_2(hdr->version); 1438 1439 ie = (uint8_t *) (hdr + 1); 1440 rem_len = rsn_ie_len - sizeof(*hdr); 1441 1442 /* Check if optional group cipher is present */ 1443 if (rem_len >= WLAN_RSN_SELECTOR_LEN) { 1444 rsn->gp_cipher_suite = LE_READ_4(ie); 1445 ie += WLAN_RSN_SELECTOR_LEN; 1446 rem_len -= WLAN_RSN_SELECTOR_LEN; 1447 } else if (rem_len > 0) { 1448 /* RSN IE is invalid as group cipher is of invalid length */ 1449 return QDF_STATUS_E_INVAL; 1450 } 1451 1452 /* Check if optional pairwise cipher is present */ 1453 if (rem_len >= 2) { 1454 rsn->pwise_cipher_count = LE_READ_2(ie); 1455 ie += 2; 1456 rem_len -= 2; 1457 if (rsn->pwise_cipher_count == 0 || 1458 rsn->pwise_cipher_count > WLAN_MAX_CIPHER || 1459 rsn->pwise_cipher_count > rem_len / WLAN_RSN_SELECTOR_LEN) 1460 return QDF_STATUS_E_INVAL; 1461 for (i = 0; i < rsn->pwise_cipher_count; i++) { 1462 rsn->pwise_cipher_suites[i] = LE_READ_4(ie); 1463 ie += WLAN_RSN_SELECTOR_LEN; 1464 rem_len -= WLAN_RSN_SELECTOR_LEN; 1465 } 1466 } else if (rem_len == 1) { 1467 /* RSN IE is invalid as pairwise cipher is of invalid length */ 1468 return QDF_STATUS_E_INVAL; 1469 } 1470 1471 /* Check if optional akm suite is present */ 1472 if (rem_len >= 2) { 1473 rsn->akm_suite_count = LE_READ_2(ie); 1474 ie += 2; 1475 rem_len -= 2; 1476 if (rsn->akm_suite_count == 0 || 1477 rsn->akm_suite_count > WLAN_MAX_CIPHER || 1478 rsn->akm_suite_count > rem_len / WLAN_RSN_SELECTOR_LEN) 1479 return QDF_STATUS_E_INVAL; 1480 for (i = 0; i < rsn->akm_suite_count; i++) { 1481 rsn->akm_suites[i] = LE_READ_4(ie); 1482 ie += WLAN_RSN_SELECTOR_LEN; 1483 rem_len -= WLAN_RSN_SELECTOR_LEN; 1484 } 1485 } else if (rem_len == 1) { 1486 /* RSN IE is invalid as akm suite is of invalid length */ 1487 return QDF_STATUS_E_INVAL; 1488 } 1489 1490 /* Update capabilty if present */ 1491 if (rem_len >= 2) { 1492 rsn->cap = LE_READ_2(ie); 1493 ie += 2; 1494 rem_len -= 2; 1495 } else if (rem_len == 1) { 1496 /* RSN IE is invalid as cap field is truncated */ 1497 return QDF_STATUS_E_INVAL; 1498 } 1499 1500 /* Update PMKID if present */ 1501 if (rem_len >= 2) { 1502 rsn->pmkid_count = LE_READ_2(ie); 1503 ie += 2; 1504 rem_len -= 2; 1505 if (rsn->pmkid_count > (unsigned int) rem_len / PMKID_LEN) { 1506 rsn->pmkid_count = 0; 1507 return QDF_STATUS_E_INVAL; 1508 } 1509 1510 qdf_mem_copy(rsn->pmkid, ie, 1511 rsn->pmkid_count * PMKID_LEN); 1512 ie += rsn->pmkid_count * PMKID_LEN; 1513 rem_len -= rsn->pmkid_count * PMKID_LEN; 1514 } else if (rem_len == 1) { 1515 /* RSN IE is invalid as pmkid count field is truncated */ 1516 return QDF_STATUS_E_INVAL; 1517 } 1518 1519 /* Update mgmt cipher if present */ 1520 if (rem_len >= WLAN_RSN_SELECTOR_LEN) { 1521 rsn->mgmt_cipher_suite = LE_READ_4(ie); 1522 ie += WLAN_RSN_SELECTOR_LEN; 1523 rem_len -= WLAN_RSN_SELECTOR_LEN; 1524 } else if (rem_len > 0) { 1525 /* RSN IE is invalid as mgmt cipher is truncated */ 1526 return QDF_STATUS_E_INVAL; 1527 } 1528 1529 return QDF_STATUS_SUCCESS; 1530 } 1531 1532 /** 1533 * wlan_parse_wpa_ie() - parse wpa ie 1534 * @wpa_ie: wpa ie ptr 1535 * @wpa: out structure for the parsed ie 1536 * 1537 * API, function to parse wpa ie, if optional fields are not present use the 1538 * default values defined by standard. 1539 * 1540 * Return: QDF_STATUS 1541 */ 1542 static inline QDF_STATUS wlan_parse_wpa_ie(uint8_t *wpa_ie, 1543 struct wlan_wpa_ie *wpa) 1544 { 1545 uint8_t wpa_ie_len, i; 1546 uint8_t *ie; 1547 int rem_len; 1548 struct wlan_wpa_ie_hdr *hdr; 1549 1550 if (!wpa_ie) 1551 return QDF_STATUS_E_NULL_VALUE; 1552 1553 ie = wpa_ie; 1554 wpa_ie_len = ie[1] + 2; 1555 1556 /* 1557 * Check the length once for fixed parts: 1558 * element id, len, oui and version. Other, variable-length data, 1559 * must be checked separately. 1560 */ 1561 if (wpa_ie_len < sizeof(struct wlan_wpa_ie_hdr)) 1562 return QDF_STATUS_E_INVAL; 1563 1564 hdr = (struct wlan_wpa_ie_hdr *) wpa_ie; 1565 1566 if (hdr->elem_id != WLAN_ELEMID_VENDOR || 1567 !is_wpa_oui(wpa_ie) || 1568 LE_READ_2(hdr->version) != WPA_VERSION) 1569 return QDF_STATUS_E_INVAL; 1570 1571 /* Set default values for optional field. */ 1572 wpa->mc_cipher = WLAN_WPA_SEL(WLAN_CSE_TKIP); 1573 wpa->uc_cipher_count = 1; 1574 wpa->uc_ciphers[0] = WLAN_WPA_SEL(WLAN_CSE_TKIP); 1575 wpa->auth_suite_count = 1; 1576 wpa->auth_suites[0] = WLAN_WPA_SEL(WLAN_ASE_8021X_UNSPEC); 1577 1578 wpa->ver = LE_READ_2(hdr->version); 1579 ie = (uint8_t *) (hdr + 1); 1580 rem_len = wpa_ie_len - sizeof(*hdr); 1581 1582 /* Check if optional group cipher is present */ 1583 if (rem_len >= WLAN_WPA_SELECTOR_LEN) { 1584 wpa->mc_cipher = LE_READ_4(ie); 1585 ie += WLAN_WPA_SELECTOR_LEN; 1586 rem_len -= WLAN_WPA_SELECTOR_LEN; 1587 } else if (rem_len > 0) { 1588 /* WPA IE is invalid as group cipher is of invalid length */ 1589 return QDF_STATUS_E_INVAL; 1590 } 1591 1592 /* Check if optional pairwise cipher is present */ 1593 if (rem_len >= 2) { 1594 wpa->uc_cipher_count = LE_READ_2(ie); 1595 ie += 2; 1596 rem_len -= 2; 1597 if (wpa->uc_cipher_count == 0 || 1598 wpa->uc_cipher_count > WLAN_MAX_CIPHER || 1599 wpa->uc_cipher_count > rem_len / WLAN_WPA_SELECTOR_LEN) 1600 return QDF_STATUS_E_INVAL; 1601 for (i = 0; i < wpa->uc_cipher_count; i++) { 1602 wpa->uc_ciphers[i] = LE_READ_4(ie); 1603 ie += WLAN_WPA_SELECTOR_LEN; 1604 rem_len -= WLAN_WPA_SELECTOR_LEN; 1605 } 1606 } else if (rem_len == 1) { 1607 /* WPA IE is invalid as pairwise cipher is of invalid length */ 1608 return QDF_STATUS_E_INVAL; 1609 } 1610 1611 /* Check if optional akm suite is present */ 1612 if (rem_len >= 2) { 1613 wpa->auth_suite_count = LE_READ_2(ie); 1614 ie += 2; 1615 rem_len -= 2; 1616 if (wpa->auth_suite_count == 0 || 1617 wpa->auth_suite_count > WLAN_MAX_CIPHER || 1618 wpa->auth_suite_count > rem_len / WLAN_WPA_SELECTOR_LEN) 1619 return QDF_STATUS_E_INVAL; 1620 for (i = 0; i < wpa->auth_suite_count; i++) { 1621 wpa->auth_suites[i] = LE_READ_4(ie); 1622 ie += WLAN_WPA_SELECTOR_LEN; 1623 rem_len -= WLAN_WPA_SELECTOR_LEN; 1624 } 1625 } else if (rem_len == 1) { 1626 /* WPA IE is invalid as akm suite is of invalid length */ 1627 return QDF_STATUS_E_INVAL; 1628 } 1629 1630 /* Update capabilty if optional capabilty is present */ 1631 if (rem_len >= 2) { 1632 wpa->cap = LE_READ_2(ie); 1633 ie += 2; 1634 rem_len -= 2; 1635 } 1636 1637 return QDF_STATUS_SUCCESS; 1638 } 1639 1640 /** 1641 * wlan_parse_wapi_ie() - parse wapi ie 1642 * @wapi_ie: wpa ie ptr 1643 * @wapi: out structure for the parsed IE 1644 * 1645 * API, function to parse wapi ie 1646 * 1647 * Return: void 1648 */ 1649 static inline void wlan_parse_wapi_ie(uint8_t *wapi_ie, 1650 struct wlan_wapi_ie *wapi) 1651 { 1652 uint8_t len, i; 1653 uint8_t *ie; 1654 1655 if (!wapi_ie) 1656 return; 1657 1658 ie = wapi_ie; 1659 len = ie[1]; 1660 /* 1661 * Check the length once for fixed parts: OUI, type, 1662 * version, mcast cipher, and 2 selector counts. 1663 * Other, variable-length data, must be checked separately. 1664 */ 1665 if (len < 20) 1666 return; 1667 1668 ie += 2; 1669 1670 wapi->ver = LE_READ_2(ie); 1671 if (wapi->ver != WAPI_VERSION) 1672 return; 1673 1674 ie += 2; 1675 len -= 2; 1676 1677 /* akm */ 1678 wapi->akm_suite_count = LE_READ_2(ie); 1679 1680 ie += 2; 1681 len -= 2; 1682 1683 if ((wapi->akm_suite_count > WLAN_MAX_CIPHER) || 1684 len < (wapi->akm_suite_count * WLAN_OUI_SIZE)) 1685 return; 1686 for (i = 0 ; i < wapi->akm_suite_count; i++) { 1687 wapi->akm_suites[i] = LE_READ_4(ie); 1688 ie += WLAN_OUI_SIZE; 1689 len -= WLAN_OUI_SIZE; 1690 } 1691 1692 wapi->uc_cipher_count = LE_READ_2(ie); 1693 ie += 2; 1694 len -= 2; 1695 if ((wapi->uc_cipher_count > WLAN_MAX_CIPHER) || 1696 len < (wapi->uc_cipher_count * WLAN_OUI_SIZE + 2)) 1697 return; 1698 for (i = 0 ; i < wapi->uc_cipher_count; i++) { 1699 wapi->uc_cipher_suites[i] = LE_READ_4(ie); 1700 ie += WLAN_OUI_SIZE; 1701 len -= WLAN_OUI_SIZE; 1702 } 1703 1704 if (len >= WLAN_OUI_SIZE) 1705 wapi->mc_cipher_suite = LE_READ_4(ie); 1706 } 1707 1708 /** 1709 * wlan_parse_oce_reduced_wan_metrics_ie() - parse oce wan metrics 1710 * @mbo_oce_ie: MBO/OCE ie ptr 1711 * @wan_metrics: out structure for the reduced wan metric 1712 * 1713 * API, function to parse reduced wan metric 1714 * 1715 * Return: true if oce wan metrics is present 1716 */ 1717 static inline bool 1718 wlan_parse_oce_reduced_wan_metrics_ie(uint8_t *mbo_oce_ie, 1719 struct oce_reduced_wan_metrics *wan_metrics) 1720 { 1721 uint8_t len, attribute_len, attribute_id; 1722 uint8_t *ie; 1723 1724 if (!mbo_oce_ie) 1725 return false; 1726 1727 ie = mbo_oce_ie; 1728 len = ie[1]; 1729 ie += 2; 1730 1731 if (len <= MBO_OCE_OUI_SIZE) 1732 return false; 1733 1734 ie += MBO_OCE_OUI_SIZE; 1735 len -= MBO_OCE_OUI_SIZE; 1736 1737 while (len > 2) { 1738 attribute_id = ie[0]; 1739 attribute_len = ie[1]; 1740 len -= 2; 1741 if (attribute_len > len) 1742 return false; 1743 1744 if (attribute_id == REDUCED_WAN_METRICS_ATTR) { 1745 wan_metrics->downlink_av_cap = ie[2] & 0xff; 1746 wan_metrics->uplink_av_cap = ie[2] >> 4; 1747 return true; 1748 } 1749 1750 ie += (attribute_len + 2); 1751 len -= attribute_len; 1752 } 1753 1754 return false; 1755 } 1756 1757 #endif /* _WLAN_CMN_IEEE80211_DEFS_H_ */ 1758