1 /* 2 * Copyright (c) 2017-2019 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 12 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_MAX_CHAN_SWITCH_TIME: Maximum Channel Switch Time IE 361 * @WLAN_EXTN_ELEMID_HECAP: HE capabilities IE 362 * @WLAN_EXTN_ELEMID_HEOP: HE Operation IE 363 * @WLAN_EXTN_ELEMID_MUEDCA: MU-EDCA IE 364 * @WLAN_EXTN_ELEMID_SRP: spatial reuse parameter IE 365 */ 366 enum extn_element_ie { 367 WLAN_EXTN_ELEMID_MAX_CHAN_SWITCH_TIME = 34, 368 WLAN_EXTN_ELEMID_HECAP = 35, 369 WLAN_EXTN_ELEMID_HEOP = 36, 370 WLAN_EXTN_ELEMID_MUEDCA = 38, 371 WLAN_EXTN_ELEMID_SRP = 39, 372 WLAN_EXTN_ELEMID_ESP = 11, 373 }; 374 375 #define WLAN_OUI_SIZE 4 376 #define WLAN_MAX_CIPHER 6 377 #define WLAN_RSN_SELECTOR_LEN 4 378 #define WLAN_WPA_SELECTOR_LEN 4 379 #define PMKID_LEN 16 380 #define MAX_PMKID 4 381 382 #define WLAN_WPA_OUI 0xf25000 383 #define WLAN_WPA_OUI_TYPE 0x01 384 #define WPA_VERSION 1 385 #define WLAN_WPA_SEL(x) (((x) << 24) | WLAN_WPA_OUI) 386 387 #define WLAN_RSN_OUI 0xac0f00 388 #define WLAN_CCKM_OUI 0x964000 389 #define WLAN_CCKM_ASE_UNSPEC 0 390 #define WLAN_WPA_CCKM_AKM 0x00964000 391 #define WLAN_RSN_CCKM_AKM 0x00964000 392 #define WLAN_RSN_DPP_AKM 0x029A6F50 393 #define WLAN_RSN_OSEN_AKM 0x019A6F50 394 395 #define RSN_VERSION 1 396 #define WLAN_RSN_SEL(x) (((x) << 24) | WLAN_RSN_OUI) 397 #define WLAN_CCKM_SEL(x) (((x) << 24) | WLAN_CCKM_OUI) 398 399 #define WLAN_CSE_NONE 0x00 400 #define WLAN_CSE_WEP40 0x01 401 #define WLAN_CSE_TKIP 0x02 402 #define WLAN_CSE_RESERVED 0x03 403 #define WLAN_CSE_CCMP 0x04 404 #define WLAN_CSE_WEP104 0x05 405 #define WLAN_CSE_AES_CMAC 0x06 406 #define WLAN_CSE_GCMP_128 0x08 407 #define WLAN_CSE_GCMP_256 0x09 408 #define WLAN_CSE_CCMP_256 0x0A 409 #define WLAN_CSE_BIP_GMAC_128 0x0B 410 #define WLAN_CSE_BIP_GMAC_256 0x0C 411 #define WLAN_CSE_BIP_CMAC_256 0x0D 412 413 #define WLAN_AKM_IEEE8021X 0x01 414 #define WLAN_AKM_PSK 0x02 415 #define WLAN_AKM_FT_IEEE8021X 0x03 416 #define WLAN_AKM_FT_PSK 0x04 417 #define WLAN_AKM_SHA256_IEEE8021X 0x05 418 #define WLAN_AKM_SHA256_PSK 0x06 419 #define WLAN_AKM_SAE 0x08 420 #define WLAN_AKM_FT_SAE 0x09 421 #define WLAN_AKM_SUITEB_EAP_SHA256 0x0B 422 #define WLAN_AKM_SUITEB_EAP_SHA384 0x0C 423 #define WLAN_AKM_FT_SUITEB_EAP_SHA384 0x0D 424 #define WLAN_AKM_FILS_SHA256 0x0E 425 #define WLAN_AKM_FILS_SHA384 0x0F 426 #define WLAN_AKM_FILS_FT_SHA256 0x10 427 #define WLAN_AKM_FILS_FT_SHA384 0x11 428 #define WLAN_AKM_OWE 0x12 429 430 #define WLAN_ASE_NONE 0x00 431 #define WLAN_ASE_8021X_UNSPEC 0x01 432 #define WLAN_ASE_8021X_PSK 0x02 433 #define WLAN_ASE_FT_IEEE8021X 0x20 434 #define WLAN_ASE_FT_PSK 0x40 435 #define WLAN_ASE_SHA256_IEEE8021X 0x80 436 #define WLAN_ASE_SHA256_PSK 0x100 437 #define WLAN_ASE_WPS 0x200 438 439 #define RSN_CAP_MFP_CAPABLE 0x80 440 #define RSN_CAP_MFP_REQUIRED 0x40 441 442 /** 443 * struct wlan_rsn_ie_hdr: rsn ie header 444 * @elem_id: RSN element id WLAN_ELEMID_RSN. 445 * @len: rsn ie length 446 * @version: RSN ver 447 */ 448 struct wlan_rsn_ie_hdr { 449 u8 elem_id; 450 u8 len; 451 u8 version[2]; 452 }; 453 454 #define WLAN_RSN_IE_MIN_LEN 2 455 456 /** 457 * struct wlan_rsn_ie: rsn ie info 458 * @ver: RSN ver 459 * @gp_cipher_suite: group cipher 460 * @pwise_cipher_count: number of pw cipher 461 * @pwise_cipher_suites: pair wise cipher list 462 * @akm_suite_count: Number of akm suite 463 * @akm_suites: akm suites list 464 * @cap: RSN capability 465 * @pmkid_count: number of PMKID 466 * @pmkid: PMKID list 467 * @mgmt_cipher_suite: management (11w) cipher suite 468 */ 469 struct wlan_rsn_ie { 470 uint16_t ver; 471 uint32_t gp_cipher_suite; 472 uint16_t pwise_cipher_count; 473 uint32_t pwise_cipher_suites[WLAN_MAX_CIPHER]; 474 uint16_t akm_suite_count; 475 uint32_t akm_suites[WLAN_MAX_CIPHER]; 476 uint16_t cap; 477 uint16_t pmkid_count; 478 uint8_t pmkid[MAX_PMKID][PMKID_LEN]; 479 uint32_t mgmt_cipher_suite; 480 }; 481 482 #define WLAN_WAPI_IE_MIN_LEN 20 483 484 /** 485 * struct wlan_wpa_ie_hdr: wpa ie header 486 * @elem_id: Wpa element id, vender specific. 487 * @len: wpa ie length 488 * @oui: 24-bit OUI followed by 8-bit OUI type 489 * @version: wpa ver 490 */ 491 struct wlan_wpa_ie_hdr { 492 u8 elem_id; 493 u8 len; 494 u8 oui[4]; 495 u8 version[2]; 496 }; 497 498 /** 499 * struct wlan_wpa_ie: WPA ie info 500 * @ver: WPA ver 501 * @mc_cipher: multicast cipher 502 * @uc_cipher_count: number of unicast cipher 503 * @uc_ciphers: unicast cipher list 504 * @auth_suite_count: Number of akm suite 505 * @auth_suites: akm suites list 506 * @cap: WPA capability 507 */ 508 struct wlan_wpa_ie { 509 uint16_t ver; 510 uint32_t mc_cipher; 511 uint16_t uc_cipher_count; 512 uint32_t uc_ciphers[WLAN_MAX_CIPHER]; 513 uint16_t auth_suite_count; 514 uint32_t auth_suites[WLAN_MAX_CIPHER]; 515 uint16_t cap; 516 }; 517 518 #define WAPI_VERSION 1 519 #define WLAN_WAPI_OUI 0x721400 520 521 #define WLAN_WAPI_SEL(x) (((x) << 24) | WLAN_WAPI_OUI) 522 523 #define WLAN_WAI_CERT_OR_SMS4 0x01 524 #define WLAN_WAI_PSK 0x02 525 526 /** 527 * struct wlan_wapi_ie: WAPI ie info 528 * @ver: WAPI ver 529 * @akm_suite_count: Number of akm suite 530 * @akm_suites: akm suites list 531 * @uc_cipher_suites:unicast cipher count 532 * @uc_cipher_suites: unicast cipher suite 533 * @mc_cipher_suite: mc cipher suite 534 */ 535 struct wlan_wapi_ie { 536 uint16_t ver; 537 uint16_t akm_suite_count; 538 uint32_t akm_suites[WLAN_MAX_CIPHER]; 539 uint16_t uc_cipher_count; 540 uint32_t uc_cipher_suites[WLAN_MAX_CIPHER]; 541 uint32_t mc_cipher_suite; 542 }; 543 544 /** 545 * struct wlan_frame_hdr: generic IEEE 802.11 frames 546 * @i_fc: frame control 547 * @i_dur: duration field 548 * @i_addr1: mac address 1 549 * @i_addr2: mac address 2 550 * @i_addr3: mac address 3 551 * @i_seq: seq info 552 */ 553 struct wlan_frame_hdr { 554 uint8_t i_fc[2]; 555 uint8_t i_dur[2]; 556 union { 557 struct { 558 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 559 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 560 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 561 }; 562 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 563 }; 564 uint8_t i_seq[2]; 565 } qdf_packed; 566 567 struct wlan_frame_hdr_qos { 568 uint8_t i_fc[2]; 569 uint8_t i_dur[2]; 570 union { 571 struct { 572 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 573 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 574 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 575 }; 576 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 577 }; 578 uint8_t i_seq[2]; 579 uint8_t i_qos[2]; 580 } qdf_packed; 581 582 struct wlan_frame_hdr_qos_addr4 { 583 uint8_t i_fc[2]; 584 uint8_t i_dur[2]; 585 union { 586 struct { 587 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 588 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 589 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 590 }; 591 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 592 }; 593 uint8_t i_seq[2]; 594 uint8_t i_addr4[QDF_MAC_ADDR_SIZE]; 595 uint8_t i_qos[2]; 596 } qdf_packed; 597 598 /* sequence number offset base on begin of mac header */ 599 #define WLAN_SEQ_CTL_OFFSET 22 600 #define WLAN_LOW_SEQ_NUM_MASK 0x000F 601 #define WLAN_HIGH_SEQ_NUM_MASK 0x0FF0 602 #define WLAN_HIGH_SEQ_NUM_OFFSET 4 603 604 /** 605 * struct wlan_seq_ctl: sequence number control 606 * @frag_num: frag number 607 * @seq_num_lo: sequence number low byte 608 * @seq_num_hi: sequence number high byte 609 */ 610 struct wlan_seq_ctl { 611 uint8_t frag_num:4; 612 uint8_t seq_num_lo:4; 613 uint8_t seq_num_hi:8; 614 } qdf_packed; 615 616 /** 617 * union wlan_capability : wlan_capability info 618 * @value: capability value 619 */ 620 union wlan_capability { 621 struct caps { 622 uint16_t ess:1; 623 uint16_t ibss:1; 624 uint16_t cf_pollable:1; 625 uint16_t cf_poll_request:1; 626 uint16_t privacy:1; 627 uint16_t short_preamble:1; 628 uint16_t pbcc:1; 629 uint16_t channel_agility:1; 630 uint16_t spectrum_management:1; 631 uint16_t qos:1; 632 uint16_t short_slot_time:1; 633 uint16_t apsd:1; 634 uint16_t reserved2:1; 635 uint16_t dsss_ofdm:1; 636 uint16_t del_block_ack:1; 637 uint16_t immed_block_ack:1; 638 } wlan_caps; 639 uint16_t value; 640 } qdf_packed; 641 642 /** 643 * struct ie_header : IE header 644 * @ie_id: Element Id 645 * @ie_len: IE Length 646 */ 647 struct ie_header { 648 uint8_t ie_id; 649 uint8_t ie_len; 650 } qdf_packed; 651 652 /** 653 * struct extn_ie_header : Extension IE header 654 * @ie_id: Element Id 655 * @ie_len: IE Length 656 * @ie_extn_id: extension id 657 */ 658 struct extn_ie_header { 659 uint8_t ie_id; 660 uint8_t ie_len; 661 uint8_t ie_extn_id; 662 } qdf_packed; 663 664 665 /** 666 * struct ie_ssid : ssid IE 667 * @ssid_id: SSID Element Id 668 * @ssid_len: SSID IE Length 669 * @ssid: ssid value 670 */ 671 struct ie_ssid { 672 uint8_t ssid_id; 673 uint8_t ssid_len; 674 uint8_t ssid[WLAN_SSID_MAX_LEN]; 675 } qdf_packed; 676 677 /** 678 * struct ds_ie : ds IE 679 * @ie: DS Element Id 680 * @len: DS IE Length 681 * @cur_chan: channel info 682 */ 683 struct ds_ie { 684 uint8_t ie; 685 uint8_t len; 686 uint8_t cur_chan; 687 } qdf_packed; 688 689 /** 690 * struct erp_ie: ERP IE 691 * @ie: ERP Element Id 692 * @len: ERP IE Length 693 * @value: EP Info 694 */ 695 struct erp_ie { 696 uint8_t ie; 697 uint8_t len; 698 uint8_t value; 699 } qdf_packed; 700 701 /** 702 * struct htcap_cmn_ie: HT common IE info 703 * @hc_cap: HT capabilities 704 * @ampdu_param: ampdu params 705 * @mcsset: supported MCS set 706 * @extcap: extended HT capabilities 707 * @txbf_cap: txbf capabilities 708 * @antenna: antenna capabilities 709 */ 710 struct htcap_cmn_ie { 711 uint16_t hc_cap; 712 uint8_t ampdu_param; 713 uint8_t mcsset[16]; 714 uint16_t extcap; 715 uint32_t txbf_cap; 716 uint8_t antenna; 717 } qdf_packed; 718 719 /** 720 * struct htcap_ie: HT Capability IE 721 * @id: HT IE 722 * @len: HT IE LEN 723 * @ie: HT cap info 724 */ 725 struct htcap_ie { 726 uint8_t id; 727 uint8_t len; 728 struct htcap_cmn_ie ie; 729 } qdf_packed; 730 731 /** 732 * struct fils_indication_ie: FILS indication IE element 733 * @id: id 734 * @len: len 735 * @public_key_identifiers_cnt: public key identifiers count 736 * @realm_identifiers_cnt: realm identifiers count 737 * @is_ip_config_supported: whether ip config is supported in AP 738 * @is_cache_id_present: whether cache identifier is present 739 * @is_hessid_present: whether hessid is present 740 * @is_fils_sk_auth_supported: FILS shared key authentication is supported 741 * @is_fils_sk_auth_pfs_supported: FILS shared key auth with PFS is supported 742 * @is_pk_auth_supported: FILS public key authentication is supported 743 * @reserved: reserved 744 * @variable_data: pointer to data depends on initial variables 745 */ 746 struct fils_indication_ie { 747 uint8_t id; 748 uint8_t len; 749 uint16_t public_key_identifiers_cnt:3; 750 uint16_t realm_identifiers_cnt:3; 751 uint16_t is_ip_config_supported:1; 752 uint16_t is_cache_id_present:1; 753 uint16_t is_hessid_present:1; 754 uint16_t is_fils_sk_auth_supported:1; 755 uint16_t is_fils_sk_auth_pfs_supported:1; 756 uint16_t is_pk_auth_supported:1; 757 uint16_t reserved:4; 758 uint8_t variable_data[253]; 759 } qdf_packed; 760 761 #define WLAN_VENDOR_HT_IE_OFFSET_LEN 4 762 763 /** 764 * struct wlan_vendor_ie_htcap: vendor private HT Capability IE 765 * @id: HT IE 766 * @hlen: HT IE len 767 * @oui: vendor OUI 768 * @oui_type: Oui type 769 * @ie: HT cap info 770 */ 771 struct wlan_vendor_ie_htcap { 772 uint8_t id; 773 uint8_t hlen; 774 uint8_t oui[3]; 775 uint8_t oui_type; 776 struct htcap_cmn_ie ie; 777 } qdf_packed; 778 779 /** 780 * struct wlan_ie_htinfo_cmn: ht info comman 781 * @hi_ctrlchannel: control channel 782 * @hi_extchoff: B0-1 extension channel offset 783 * @hi_txchwidth: B2 recommended xmiss width set 784 * @hi_rifsmode: rifs mode 785 * @hi_ctrlaccess: controlled access only 786 * @hi_serviceinterval: B5-7 svc interval granularity 787 * @uhi_opmode: B0-1 operating mode 788 * @hi_nongfpresent: B2 non greenfield devices present 789 * @hi_txburstlimit: B3 transmit burst limit 790 * @hi_obssnonhtpresent: B4 OBSS non-HT STA present 791 * @hi_reserved0: B5-15 reserved 792 * @hi_reserved2: B0-5 reserved 793 * @hi_dualbeacon: B6 dual beacon 794 * @hi_dualctsprot: B7 dual CTS protection 795 * @hi_stbcbeacon: B8 STBC beacon 796 * @hi_lsigtxopprot: B9 l-sig txop protection full support 797 * @hi_pcoactive: B10 pco active 798 * @hi_pcophase: B11 pco phase 799 * @hi_reserved1: B12-15 reserved 800 * @hi_basicmcsset[16]: basic MCS set 801 */ 802 struct wlan_ie_htinfo_cmn { 803 uint8_t hi_ctrlchannel; 804 uint8_t hi_extchoff:2, 805 hi_txchwidth:1, 806 hi_rifsmode:1, 807 hi_ctrlaccess:1, 808 hi_serviceinterval:3; 809 uint16_t hi_opmode:2, 810 hi_nongfpresent:1, 811 hi_txburstlimit:1, 812 hi_obssnonhtpresent:1, 813 hi_reserved0:11; 814 uint16_t hi_reserved2:6, 815 hi_dualbeacon:1, 816 hi_dualctsprot:1, 817 hi_stbcbeacon:1, 818 hi_lsigtxopprot:1, 819 hi_pcoactive:1, 820 hi_pcophase:1, 821 hi_reserved1:4; 822 uint8_t hi_basicmcsset[16]; 823 } qdf_packed; 824 825 /** 826 * struct wlan_ie_htinfo: HT info IE 827 * @hi_id: HT info IE 828 * @hi_len: HT info IE len 829 * @hi_ie: HT info info 830 */ 831 struct wlan_ie_htinfo { 832 uint8_t hi_id; 833 uint8_t hi_len; 834 struct wlan_ie_htinfo_cmn hi_ie; 835 } qdf_packed; 836 837 /** 838 * struct wlan_ie_htinfo: vendor private HT info IE 839 * @hi_id: HT info IE 840 * @hi_len: HT info IE len 841 * @hi_oui: vendor OUI 842 * @hi_ouitype: Oui type 843 * @hi_ie: HT info info 844 */ 845 struct wlan_vendor_ie_htinfo { 846 uint8_t hi_id; 847 uint8_t hi_len; 848 uint8_t hi_oui[3]; 849 uint8_t hi_ouitype; 850 struct wlan_ie_htinfo_cmn hi_ie; 851 } qdf_packed; 852 853 #define WLAN_VENDOR_VHTCAP_IE_OFFSET 7 854 #define WLAN_VENDOR_VHTOP_IE_OFFSET 21 855 856 /** 857 * struct wlan_ie_vhtcaps - VHT capabilities 858 * @elem_id: VHT caps IE 859 * @elem_len: VHT caps IE len 860 * @max_mpdu_len: MPDU length 861 * @supported_channel_widthset: channel width set 862 * @ldpc_coding: LDPC coding capability 863 * @shortgi80: short GI 80 support 864 * @shortgi160and80plus80: short Gi 160 & 80+80 support 865 * @tx_stbc; Tx STBC cap 866 * @tx_stbc: Rx STBC cap 867 * @su_beam_former: SU beam former cap 868 * @su_beam_formee: SU beam formee cap 869 * @csnof_beamformer_antSup: Antenna support for beamforming 870 * @num_soundingdim: Sound dimensions 871 * @mu_beam_former: MU beam former cap 872 * @mu_beam_formee: MU beam formee cap 873 * @vht_txops: TXOP power save 874 * @htc_vhtcap: HTC VHT capability 875 * @max_ampdu_lenexp: AMPDU length 876 * @vht_link_adapt: VHT link adapatation capable 877 * @rx_antpattern: Rx Antenna pattern 878 * @tx_antpattern: Tx Antenna pattern 879 * @rx_mcs_map: RX MCS map 880 * @rx_high_sup_data_rate : highest RX supported data rate 881 * @tx_mcs_map: TX MCS map 882 * @tx_sup_data_rate: highest TX supported data rate 883 */ 884 struct wlan_ie_vhtcaps { 885 uint8_t elem_id; 886 uint8_t elem_len; 887 uint32_t max_mpdu_len:2; 888 uint32_t supported_channel_widthset:2; 889 uint32_t ldpc_coding:1; 890 uint32_t shortgi80:1; 891 uint32_t shortgi160and80plus80:1; 892 uint32_t tx_stbc:1; 893 uint32_t rx_stbc:3; 894 uint32_t su_beam_former:1; 895 uint32_t su_beam_formee:1; 896 uint32_t csnof_beamformer_antSup:3; 897 uint32_t num_soundingdim:3; 898 uint32_t mu_beam_former:1; 899 uint32_t mu_beam_formee:1; 900 uint32_t vht_txops:1; 901 uint32_t htc_vhtcap:1; 902 uint32_t max_ampdu_lenexp:3; 903 uint32_t vht_link_adapt:2; 904 uint32_t rx_antpattern:1; 905 uint32_t tx_antpattern:1; 906 uint32_t unused:2; 907 uint16_t rx_mcs_map; 908 uint16_t rx_high_sup_data_rate:13; 909 uint16_t reserved2:3; 910 uint16_t tx_mcs_map; 911 uint16_t tx_sup_data_rate:13; 912 uint16_t reserved3:3; 913 } qdf_packed; 914 915 /** 916 * struct wlan_ie_vhtop: VHT op IE 917 * @elem_id: VHT op IE 918 * @elem_len: VHT op IE len 919 * @vht_op_chwidth: BSS Operational Channel width 920 * @vht_op_ch_freq_seg1: Channel Center frequency 921 * @vht_op_ch_freq_seg2: Channel Center frequency for 80+80MHz 922 * @vhtop_basic_mcs_set: Basic MCS set 923 */ 924 struct wlan_ie_vhtop { 925 uint8_t elem_id; 926 uint8_t elem_len; 927 uint8_t vht_op_chwidth; 928 uint8_t vht_op_ch_freq_seg1; 929 uint8_t vht_op_ch_freq_seg2; 930 uint16_t vhtop_basic_mcs_set; 931 } qdf_packed; 932 933 /** 934 * struct wlan_country_ie: country IE 935 * @ie: country IE 936 * @len: IE len 937 * @cc: country code 938 */ 939 struct wlan_country_ie { 940 uint8_t ie; 941 uint8_t len; 942 uint8_t cc[3]; 943 } qdf_packed; 944 945 /** 946 * struct wlan_country_ie: country IE 947 * @ie: QBSS IE 948 * @len: IE len 949 * @station_count: number of station associated 950 * @qbss_chan_load: qbss channel load 951 * @qbss_load_avail: qbss_load_avail 952 */ 953 struct qbss_load_ie { 954 uint8_t ie; 955 uint8_t len; 956 uint16_t station_count; 957 uint8_t qbss_chan_load; 958 uint16_t qbss_load_avail; 959 } qdf_packed; 960 961 /** 962 * struct wlan_bcn_frame: beacon frame fixed params 963 * @timestamp: the value of sender's TSFTIMER 964 * @beacon_interval: beacon interval 965 * @capability: capability 966 * @ie: variable IE 967 */ 968 struct wlan_bcn_frame { 969 uint8_t timestamp[8]; 970 uint16_t beacon_interval; 971 union wlan_capability capability; 972 struct ie_header ie; 973 } qdf_packed; 974 975 #define WLAN_TIM_IE_MIN_LENGTH 4 976 977 /** 978 * struct wlan_tim_ie: tim IE 979 * @tim_ie: Time IE 980 * @tim_len: TIM IE len 981 * @tim_count: dtim count 982 * @tim_period: dtim period 983 * @tim_bitctl: bitmap control 984 * @tim_bitmap: variable length bitmap 985 */ 986 struct wlan_tim_ie { 987 uint8_t tim_ie; /* WLAN_ELEMID_TIM */ 988 uint8_t tim_len; 989 uint8_t tim_count; /* DTIM count */ 990 uint8_t tim_period; /* DTIM period */ 991 uint8_t tim_bitctl; /* bitmap control */ 992 uint8_t tim_bitmap[251]; /* variable-length bitmap */ 993 } qdf_packed; 994 995 /** 996 * struct rsn_mdie: mobility domain IE 997 * @rsn_id: RSN IE id 998 * @rsn_len: RSN IE len 999 * @mobility_domain: mobility domain info 1000 * @ft_capab: ft capability 1001 * 1002 * Reference 9.4.2.47 Mobility Domain element (MDE) of 802.11-2016 1003 */ 1004 struct rsn_mdie { 1005 uint8_t rsn_id; 1006 uint8_t rsn_len; 1007 uint8_t mobility_domain[2]; 1008 uint8_t ft_capab; 1009 } qdf_packed; 1010 1011 /** 1012 * struct srp_ie: Spatial reuse parameter IE 1013 * @srp_id: SRP IE id 1014 * @srp_len: SRP IE len 1015 * @srp_id_extn: SRP Extension ID 1016 * @sr_control: sr control 1017 * @non_srg_obsspd_max_offset: non srg obsspd max offset 1018 * @srg_obss_pd_min_offset: srg obss pd min offset 1019 * @srg_obss_pd_max_offset: srg obss pd max offset 1020 * @srg_bss_color_bitmap: srg bss color bitmap 1021 * @srg_partial_bssid_bitmap: srg partial bssid bitmap 1022 */ 1023 struct wlan_srp_ie { 1024 uint8_t srp_id; 1025 uint8_t srp_len; 1026 uint8_t srp_id_extn; 1027 uint8_t sr_control; 1028 union { 1029 struct { 1030 uint8_t non_srg_obsspd_max_offset; 1031 uint8_t srg_obss_pd_min_offset; 1032 uint8_t srg_obss_pd_max_offset; 1033 uint8_t srg_bss_color_bitmap[8]; 1034 uint8_t srg_partial_bssid_bitmap[8]; 1035 } qdf_packed nonsrg_srg_info; 1036 struct { 1037 uint8_t non_srg_obsspd_max_offset; 1038 } qdf_packed nonsrg_info; 1039 struct { 1040 uint8_t srg_obss_pd_min_offset; 1041 uint8_t srg_obss_pd_max_offset; 1042 uint8_t srg_bss_color_bitmap[8]; 1043 uint8_t srg_partial_bssid_bitmap[8]; 1044 } qdf_packed srg_info; 1045 }; 1046 } qdf_packed; 1047 1048 #define ESP_INFORMATION_LIST_LENGTH 3 1049 #define MAX_ESP_INFORMATION_FIELD 4 1050 /* 1051 * enum access_category: tells about access category in ESP paramameter 1052 * @ESP_AC_BK: ESP access category for background 1053 * @ESP_AC_BE: ESP access category for best effort 1054 * @ESP_AC_VI: ESP access category for video 1055 * @ESP_AC_VO: ESP access category for Voice 1056 */ 1057 enum access_category { 1058 ESP_AC_BK, 1059 ESP_AC_BE, 1060 ESP_AC_VI, 1061 ESP_AC_VO, 1062 1063 }; 1064 /* 1065 * struct wlan_esp_info: structure for Esp information parameter 1066 * @access_category: access category info 1067 * @reserved: reserved 1068 * @data_format: two bits in length and tells about data format 1069 * i.e. 0 = No aggregation is expected to be performed for MSDUs or MPDUs with 1070 * the Type subfield equal to Data for the corresponding AC 1071 * 1 = A-MSDU aggregation is expected to be performed for MSDUs for the 1072 * corresponding AC, but A-MPDU aggregation is not expected to be performed 1073 * for MPDUs with the Type subfield equal to Data for the corresponding AC 1074 * 2 = A-MPDU aggregation is expected to be performed for MPDUs with the Type 1075 * subfield equal to Data for the corresponding AC, but A-MSDU aggregation is 1076 * not expected to be performed for MSDUs for the corresponding AC 1077 * 3 = A-MSDU aggregation is expected to be performed for MSDUs for the 1078 * corresponding AC and A-MPDU aggregation is expected to be performed for 1079 * MPDUs with the Type subfield equal to Data for the corresponding AC 1080 * @ba_window_size: BA Window Size subfield is three bits in length and 1081 * indicates the size of the Block Ack window that is 1082 * expected for the corresponding access category 1083 * @estimated_air_fraction: Estimated Air Time Fraction subfield is 8 bits in 1084 * length and contains an unsigned integer that represents 1085 * the predicted percentage of time, linearly scaled with 255 representing 1086 * 100%, that a new STA joining the 1087 * BSS will be allocated for PPDUs that contain only 1088 * MPDUs with the Type 1089 * subfield equal to Data of the 1090 * corresponding access category for that STA. 1091 * @ppdu_duration: Data PPDU Duration Target field 1092 * is 8 bits in length and is 1093 * an unsigned integer that indicates the 1094 * expected target duration of PPDUs that contain only MPDUs with the Type 1095 * subfield equal to Data for the 1096 * corresponding access category in units of 50 μs 1097 */ 1098 struct wlan_esp_info { 1099 uint8_t access_category:2; 1100 uint8_t reserved:1; 1101 uint8_t data_format:2; 1102 uint8_t ba_window_size:3; 1103 uint8_t estimated_air_fraction; 1104 uint8_t ppdu_duration; 1105 }; 1106 1107 /** 1108 * struct wlan_esp_ie: struct for ESP information 1109 * @esp_id: ESP IE id 1110 * @esp_len: ESP IE len 1111 * @esp_id_extn: ESP Extension ID 1112 * @esp_info_AC_BK: ESP information related to BK category 1113 * @esp_info_AC_BE: ESP information related to BE category 1114 * @esp_info_AC_VI: ESP information related to VI category 1115 * @esp_info_AC_VO: ESP information related to VO category 1116 */ 1117 struct wlan_esp_ie { 1118 uint8_t esp_id; 1119 uint8_t esp_len; 1120 uint8_t esp_id_extn; 1121 struct wlan_esp_info esp_info_AC_BK; 1122 struct wlan_esp_info esp_info_AC_BE; 1123 struct wlan_esp_info esp_info_AC_VI; 1124 struct wlan_esp_info esp_info_AC_VO; 1125 } qdf_packed; 1126 1127 /** 1128 * struct wlan_ext_cap_ie - struct for extended capabilities information 1129 * @ext_cap_id: Extended capabilities id 1130 * @ext_cap_len: Extended capabilities IE len 1131 * @ext_caps: Variable length extended capabilities information 1132 */ 1133 struct wlan_ext_cap_ie { 1134 uint8_t ext_cap_id; 1135 uint8_t ext_cap_len; 1136 uint8_t ext_caps[]; 1137 } qdf_packed; 1138 1139 /** 1140 * struct oce_reduced_wan_metrics: struct for oce wan metrics 1141 * @downlink_av_cap: Download available capacity 1142 * @uplink_av_cap: Upload available capacity 1143 */ 1144 struct oce_reduced_wan_metrics { 1145 uint8_t downlink_av_cap:4; 1146 uint8_t uplink_av_cap:4; 1147 }; 1148 1149 /** 1150 * is_wpa_oui() - If vendor IE is WPA type 1151 * @frm: vendor IE pointer 1152 * 1153 * API to check if vendor IE is WPA 1154 * 1155 * Return: true if its WPA IE 1156 */ 1157 static inline bool 1158 is_wpa_oui(uint8_t *frm) 1159 { 1160 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1161 ((WLAN_WPA_OUI_TYPE << 24) | WLAN_WPA_OUI)); 1162 } 1163 1164 /** 1165 * is_wps_oui() - If vendor IE is WPS type 1166 * @frm: vendor IE pointer 1167 * 1168 * API to check if vendor IE is WPS 1169 * 1170 * Return: true if its WPS IE 1171 */ 1172 static inline bool 1173 is_wps_oui(const uint8_t *frm) 1174 { 1175 return frm[1] > 3 && BE_READ_4(frm + 2) == WSC_OUI; 1176 } 1177 1178 /** 1179 * is_mbo_oce_oui() - If vendor IE is MBO/OCE type 1180 * @frm: vendor IE pointer 1181 * 1182 * API to check if vendor IE is MBO/OCE 1183 * 1184 * Return: true if its MBO/OCE IE 1185 */ 1186 static inline bool 1187 is_mbo_oce_oui(const uint8_t *frm) 1188 { 1189 return frm[1] > 3 && BE_READ_4(frm + 2) == MBO_OCE_OUI; 1190 } 1191 1192 /** 1193 * is_wcn_oui() - If vendor IE is WCN type 1194 * @frm: vendor IE pointer 1195 * 1196 * API to check if vendor IE is WCN 1197 * 1198 * Return: true if its WCN IE 1199 */ 1200 static inline bool 1201 is_wcn_oui(uint8_t *frm) 1202 { 1203 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1204 ((WCN_OUI_TYPE << 24) | WCN_OUI)); 1205 } 1206 1207 /** 1208 * is_wme_param() - If vendor IE is WME param type 1209 * @frm: vendor IE pointer 1210 * 1211 * API to check if vendor IE is WME param 1212 * 1213 * Return: true if its WME param IE 1214 */ 1215 static inline bool 1216 is_wme_param(const uint8_t *frm) 1217 { 1218 return (frm[1] > 5) && (LE_READ_4(frm + 2) == 1219 ((WME_OUI_TYPE << 24) | WME_OUI)) && 1220 (frm[6] == WME_PARAM_OUI_SUBTYPE); 1221 } 1222 1223 /** 1224 * is_wme_info() - If vendor IE is WME info type 1225 * @frm: vendor IE pointer 1226 * 1227 * API to check if vendor IE is WME info 1228 * 1229 * Return: true if its WME info IE 1230 */ 1231 static inline bool 1232 is_wme_info(const uint8_t *frm) 1233 { 1234 return (frm[1] > 5) && (LE_READ_4(frm + 2) == 1235 ((WME_OUI_TYPE << 24) | WME_OUI)) && 1236 (frm[6] == WME_INFO_OUI_SUBTYPE); 1237 } 1238 1239 /** 1240 * is_atheros_oui() - If vendor IE is Atheros type 1241 * @frm: vendor IE pointer 1242 * 1243 * API to check if vendor IE is Atheros 1244 * 1245 * Return: true if its Atheros IE 1246 */ 1247 static inline bool 1248 is_atheros_oui(const uint8_t *frm) 1249 { 1250 return (frm[1] > 3) && LE_READ_4(frm + 2) == 1251 ((ATH_OUI_TYPE << 24) | ATH_OUI); 1252 } 1253 1254 /** 1255 * is_atheros_extcap_oui() - If vendor IE is Atheros ext cap 1256 * @frm: vendor IE pointer 1257 * 1258 * API to check if vendor IE is Atheros ext cap 1259 * 1260 * Return: true if its Atheros ext cap IE 1261 */ 1262 static inline int 1263 is_atheros_extcap_oui(uint8_t *frm) 1264 { 1265 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1266 ((ATH_OUI_EXTCAP_TYPE << 24) | ATH_OUI)); 1267 } 1268 1269 /** 1270 * is_sfa_oui() - If vendor IE is SFA type 1271 * @frm: vendor IE pointer 1272 * 1273 * API to check if vendor IE is SFA 1274 * 1275 * Return: true if its SFA IE 1276 */ 1277 static inline bool 1278 is_sfa_oui(uint8_t *frm) 1279 { 1280 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1281 ((SFA_OUI_TYPE << 24) | SFA_OUI)); 1282 } 1283 1284 /** 1285 * is_p2p_oui() - If vendor IE is P2P type 1286 * @frm: vendor IE pointer 1287 * 1288 * API to check if vendor IE is P2P 1289 * 1290 * Return: true if its P2P IE 1291 */ 1292 static inline bool 1293 is_p2p_oui(const uint8_t *frm) 1294 { 1295 const uint8_t wfa_oui[3] = P2P_WFA_OUI; 1296 1297 return (frm[1] >= 4) && 1298 (frm[2] == wfa_oui[0]) && 1299 (frm[3] == wfa_oui[1]) && 1300 (frm[4] == wfa_oui[2]) && 1301 (frm[5] == P2P_WFA_VER); 1302 } 1303 1304 /** 1305 * is_qca_son_oui() - If vendor IE is QCA WHC type 1306 * @frm: vendor IE pointer 1307 * @whc_subtype: subtype 1308 * 1309 * API to check if vendor IE is QCA WHC 1310 * 1311 * Return: true if its QCA WHC IE 1312 */ 1313 static inline bool 1314 is_qca_son_oui(uint8_t *frm, uint8_t whc_subtype) 1315 { 1316 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1317 ((QCA_OUI_WHC_TYPE << 24) | QCA_OUI)) && 1318 (*(frm + 6) == whc_subtype); 1319 } 1320 1321 /** 1322 * is_ht_cap() - If vendor IE is vendor HT cap type 1323 * @frm: vendor IE pointer 1324 * 1325 * API to check if vendor IE is vendor HT cap 1326 * 1327 * Return: true if its vendor HT cap IE 1328 */ 1329 static inline bool 1330 is_ht_cap(uint8_t *frm) 1331 { 1332 return (frm[1] > 3) && (BE_READ_4(frm + 2) == 1333 ((VENDOR_HT_OUI << 8) | VENDOR_HT_CAP_ID)); 1334 } 1335 1336 /** 1337 * is_ht_info() - If vendor IE is vendor HT info type 1338 * @frm: vendor IE pointer 1339 * 1340 * API to check if vendor IE is vendor HT info 1341 * 1342 * Return: true if its vendor HT info IE 1343 */ 1344 static inline bool 1345 is_ht_info(uint8_t *frm) 1346 { 1347 return (frm[1] > 3) && (BE_READ_4(frm + 2) == 1348 ((VENDOR_HT_OUI << 8) | VENDOR_HT_INFO_ID)); 1349 } 1350 1351 /** 1352 * is_interop_vht() - If vendor IE is VHT interop 1353 * @frm: vendor IE pointer 1354 * 1355 * API to check if vendor IE is VHT interop 1356 * 1357 * Return: true if its VHT interop IE 1358 */ 1359 static inline bool 1360 is_interop_vht(uint8_t *frm) 1361 { 1362 return (frm[1] > 12) && (BE_READ_4(frm + 2) == 1363 ((VHT_INTEROP_OUI << 8) | VHT_INTEROP_TYPE)) && 1364 ((*(frm + 6) == VHT_INTEROP_OUI_SUBTYPE) || 1365 (*(frm + 6) == VHT_INTEROP_OUI_SUBTYPE_VENDORSPEC)); 1366 } 1367 1368 /** 1369 * is_bwnss_oui() - If vendor IE is BW NSS type 1370 * @frm: vendor IE pointer 1371 * 1372 * API to check if vendor IE is BW NSS 1373 * 1374 * Return: true if its BW NSS IE 1375 */ 1376 static inline bool 1377 is_bwnss_oui(uint8_t *frm) 1378 { 1379 return (frm[1] > 3) && (LE_READ_4(frm + 2) == 1380 ((ATH_OUI_BW_NSS_MAP_TYPE << 24) | ATH_OUI)); 1381 } 1382 1383 /** 1384 * is_he_cap_oui() - If vendor IE is HE CAP OUI 1385 * @frm: vendor IE pointer 1386 * 1387 * API to check if vendor IE is HE CAP 1388 * 1389 * Return: true if its HE CAP IE 1390 */ 1391 static inline bool 1392 is_he_cap_oui(uint8_t *frm) 1393 { 1394 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1395 ((ATH_HE_CAP_SUBTYPE << 24) | ATH_HE_OUI)); 1396 } 1397 1398 /** 1399 * is_he_op_oui() - If vendor IE is HE OP OUI 1400 * @frm: vendor IE pointer 1401 * 1402 * API to check if vendor IE is HE OP OUT 1403 * 1404 * Return: true if its HE OP OUI 1405 */ 1406 static inline bool 1407 is_he_op_oui(uint8_t *frm) 1408 { 1409 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1410 ((ATH_HE_OP_SUBTYPE << 24) | ATH_HE_OUI)); 1411 } 1412 1413 /** 1414 * is_extender_oui() - If vendor IE is EXTENDER OUI 1415 * @frm: vendor IE pointer 1416 * 1417 * API to check if vendor IE is EXTENDER OUI 1418 * 1419 * Return: true if its EXTENDER OUI 1420 */ 1421 static inline bool 1422 is_extender_oui(uint8_t *frm) 1423 { 1424 return (frm[1] > 4) && (LE_READ_4(frm + 2) == 1425 ((QCA_OUI_EXTENDER_TYPE << 24) | QCA_OUI)); 1426 } 1427 1428 /** 1429 * wlan_parse_rsn_ie() - parse rsn ie 1430 * @rsn_ie: rsn ie ptr 1431 * @rsn: out structure for the parsed ie 1432 * 1433 * API, function to parse rsn ie, if optional fields are not present use the 1434 * default values defined by standard. 1435 * 1436 * Return: QDF_STATUS 1437 */ 1438 static inline QDF_STATUS wlan_parse_rsn_ie(uint8_t *rsn_ie, 1439 struct wlan_rsn_ie *rsn) 1440 { 1441 uint8_t rsn_ie_len, i; 1442 uint8_t *ie; 1443 int rem_len; 1444 const struct wlan_rsn_ie_hdr *hdr; 1445 1446 if (!rsn_ie) 1447 return QDF_STATUS_E_NULL_VALUE; 1448 1449 ie = rsn_ie; 1450 rsn_ie_len = ie[1] + 2; 1451 1452 /* 1453 * Check the length once for fixed parts: 1454 * element id, len and version. Other, variable-length data, 1455 * must be checked separately. 1456 */ 1457 if (rsn_ie_len < sizeof(struct wlan_rsn_ie_hdr)) 1458 return QDF_STATUS_E_INVAL; 1459 1460 hdr = (struct wlan_rsn_ie_hdr *) rsn_ie; 1461 1462 if (hdr->elem_id != WLAN_ELEMID_RSN || 1463 LE_READ_2(hdr->version) != RSN_VERSION) 1464 return QDF_STATUS_E_INVAL; 1465 1466 /* Set default values for optional field. */ 1467 rsn->gp_cipher_suite = WLAN_RSN_SEL(WLAN_CSE_CCMP); 1468 rsn->pwise_cipher_count = 1; 1469 rsn->pwise_cipher_suites[0] = WLAN_RSN_SEL(WLAN_CSE_CCMP); 1470 rsn->akm_suite_count = 1; 1471 rsn->akm_suites[0] = WLAN_RSN_SEL(WLAN_AKM_IEEE8021X); 1472 1473 rsn->ver = LE_READ_2(hdr->version); 1474 1475 ie = (uint8_t *) (hdr + 1); 1476 rem_len = rsn_ie_len - sizeof(*hdr); 1477 1478 /* Check if optional group cipher is present */ 1479 if (rem_len >= WLAN_RSN_SELECTOR_LEN) { 1480 rsn->gp_cipher_suite = LE_READ_4(ie); 1481 ie += WLAN_RSN_SELECTOR_LEN; 1482 rem_len -= WLAN_RSN_SELECTOR_LEN; 1483 } else if (rem_len > 0) { 1484 /* RSN IE is invalid as group cipher is of invalid length */ 1485 return QDF_STATUS_E_INVAL; 1486 } 1487 1488 /* Check if optional pairwise cipher is present */ 1489 if (rem_len >= 2) { 1490 rsn->pwise_cipher_count = LE_READ_2(ie); 1491 ie += 2; 1492 rem_len -= 2; 1493 if (rsn->pwise_cipher_count == 0 || 1494 rsn->pwise_cipher_count > WLAN_MAX_CIPHER || 1495 rsn->pwise_cipher_count > rem_len / WLAN_RSN_SELECTOR_LEN) 1496 return QDF_STATUS_E_INVAL; 1497 for (i = 0; i < rsn->pwise_cipher_count; i++) { 1498 rsn->pwise_cipher_suites[i] = LE_READ_4(ie); 1499 ie += WLAN_RSN_SELECTOR_LEN; 1500 rem_len -= WLAN_RSN_SELECTOR_LEN; 1501 } 1502 } else if (rem_len == 1) { 1503 /* RSN IE is invalid as pairwise cipher is of invalid length */ 1504 return QDF_STATUS_E_INVAL; 1505 } 1506 1507 /* Check if optional akm suite is present */ 1508 if (rem_len >= 2) { 1509 rsn->akm_suite_count = LE_READ_2(ie); 1510 ie += 2; 1511 rem_len -= 2; 1512 if (rsn->akm_suite_count == 0 || 1513 rsn->akm_suite_count > WLAN_MAX_CIPHER || 1514 rsn->akm_suite_count > rem_len / WLAN_RSN_SELECTOR_LEN) 1515 return QDF_STATUS_E_INVAL; 1516 for (i = 0; i < rsn->akm_suite_count; i++) { 1517 rsn->akm_suites[i] = LE_READ_4(ie); 1518 ie += WLAN_RSN_SELECTOR_LEN; 1519 rem_len -= WLAN_RSN_SELECTOR_LEN; 1520 } 1521 } else if (rem_len == 1) { 1522 /* RSN IE is invalid as akm suite is of invalid length */ 1523 return QDF_STATUS_E_INVAL; 1524 } 1525 1526 /* Update capabilty if present */ 1527 if (rem_len >= 2) { 1528 rsn->cap = LE_READ_2(ie); 1529 ie += 2; 1530 rem_len -= 2; 1531 } else if (rem_len == 1) { 1532 /* RSN IE is invalid as cap field is truncated */ 1533 return QDF_STATUS_E_INVAL; 1534 } 1535 1536 /* Update PMKID if present */ 1537 if (rem_len >= 2) { 1538 rsn->pmkid_count = LE_READ_2(ie); 1539 ie += 2; 1540 rem_len -= 2; 1541 if (rsn->pmkid_count > (unsigned int) rem_len / PMKID_LEN) { 1542 rsn->pmkid_count = 0; 1543 return QDF_STATUS_E_INVAL; 1544 } 1545 1546 qdf_mem_copy(rsn->pmkid, ie, 1547 rsn->pmkid_count * PMKID_LEN); 1548 ie += rsn->pmkid_count * PMKID_LEN; 1549 rem_len -= rsn->pmkid_count * PMKID_LEN; 1550 } else if (rem_len == 1) { 1551 /* RSN IE is invalid as pmkid count field is truncated */ 1552 return QDF_STATUS_E_INVAL; 1553 } 1554 1555 /* Update mgmt cipher if present */ 1556 if (rem_len >= WLAN_RSN_SELECTOR_LEN) { 1557 rsn->mgmt_cipher_suite = LE_READ_4(ie); 1558 ie += WLAN_RSN_SELECTOR_LEN; 1559 rem_len -= WLAN_RSN_SELECTOR_LEN; 1560 } else if (rem_len > 0) { 1561 /* RSN IE is invalid as mgmt cipher is truncated */ 1562 return QDF_STATUS_E_INVAL; 1563 } 1564 1565 return QDF_STATUS_SUCCESS; 1566 } 1567 1568 /** 1569 * wlan_parse_wpa_ie() - parse wpa ie 1570 * @wpa_ie: wpa ie ptr 1571 * @wpa: out structure for the parsed ie 1572 * 1573 * API, function to parse wpa ie, if optional fields are not present use the 1574 * default values defined by standard. 1575 * 1576 * Return: QDF_STATUS 1577 */ 1578 static inline QDF_STATUS wlan_parse_wpa_ie(uint8_t *wpa_ie, 1579 struct wlan_wpa_ie *wpa) 1580 { 1581 uint8_t wpa_ie_len, i; 1582 uint8_t *ie; 1583 int rem_len; 1584 struct wlan_wpa_ie_hdr *hdr; 1585 1586 if (!wpa_ie) 1587 return QDF_STATUS_E_NULL_VALUE; 1588 1589 ie = wpa_ie; 1590 wpa_ie_len = ie[1] + 2; 1591 1592 /* 1593 * Check the length once for fixed parts: 1594 * element id, len, oui and version. Other, variable-length data, 1595 * must be checked separately. 1596 */ 1597 if (wpa_ie_len < sizeof(struct wlan_wpa_ie_hdr)) 1598 return QDF_STATUS_E_INVAL; 1599 1600 hdr = (struct wlan_wpa_ie_hdr *) wpa_ie; 1601 1602 if (hdr->elem_id != WLAN_ELEMID_VENDOR || 1603 !is_wpa_oui(wpa_ie) || 1604 LE_READ_2(hdr->version) != WPA_VERSION) 1605 return QDF_STATUS_E_INVAL; 1606 1607 /* Set default values for optional field. */ 1608 wpa->mc_cipher = WLAN_WPA_SEL(WLAN_CSE_TKIP); 1609 wpa->uc_cipher_count = 1; 1610 wpa->uc_ciphers[0] = WLAN_WPA_SEL(WLAN_CSE_TKIP); 1611 wpa->auth_suite_count = 1; 1612 wpa->auth_suites[0] = WLAN_WPA_SEL(WLAN_ASE_8021X_UNSPEC); 1613 1614 wpa->ver = LE_READ_2(hdr->version); 1615 ie = (uint8_t *) (hdr + 1); 1616 rem_len = wpa_ie_len - sizeof(*hdr); 1617 1618 /* Check if optional group cipher is present */ 1619 if (rem_len >= WLAN_WPA_SELECTOR_LEN) { 1620 wpa->mc_cipher = LE_READ_4(ie); 1621 ie += WLAN_WPA_SELECTOR_LEN; 1622 rem_len -= WLAN_WPA_SELECTOR_LEN; 1623 } else if (rem_len > 0) { 1624 /* WPA IE is invalid as group cipher is of invalid length */ 1625 return QDF_STATUS_E_INVAL; 1626 } 1627 1628 /* Check if optional pairwise cipher is present */ 1629 if (rem_len >= 2) { 1630 wpa->uc_cipher_count = LE_READ_2(ie); 1631 ie += 2; 1632 rem_len -= 2; 1633 if (wpa->uc_cipher_count == 0 || 1634 wpa->uc_cipher_count > WLAN_MAX_CIPHER || 1635 wpa->uc_cipher_count > rem_len / WLAN_WPA_SELECTOR_LEN) 1636 return QDF_STATUS_E_INVAL; 1637 for (i = 0; i < wpa->uc_cipher_count; i++) { 1638 wpa->uc_ciphers[i] = LE_READ_4(ie); 1639 ie += WLAN_WPA_SELECTOR_LEN; 1640 rem_len -= WLAN_WPA_SELECTOR_LEN; 1641 } 1642 } else if (rem_len == 1) { 1643 /* WPA IE is invalid as pairwise cipher is of invalid length */ 1644 return QDF_STATUS_E_INVAL; 1645 } 1646 1647 /* Check if optional akm suite is present */ 1648 if (rem_len >= 2) { 1649 wpa->auth_suite_count = LE_READ_2(ie); 1650 ie += 2; 1651 rem_len -= 2; 1652 if (wpa->auth_suite_count == 0 || 1653 wpa->auth_suite_count > WLAN_MAX_CIPHER || 1654 wpa->auth_suite_count > rem_len / WLAN_WPA_SELECTOR_LEN) 1655 return QDF_STATUS_E_INVAL; 1656 for (i = 0; i < wpa->auth_suite_count; i++) { 1657 wpa->auth_suites[i] = LE_READ_4(ie); 1658 ie += WLAN_WPA_SELECTOR_LEN; 1659 rem_len -= WLAN_WPA_SELECTOR_LEN; 1660 } 1661 } else if (rem_len == 1) { 1662 /* WPA IE is invalid as akm suite is of invalid length */ 1663 return QDF_STATUS_E_INVAL; 1664 } 1665 1666 /* Update capabilty if optional capabilty is present */ 1667 if (rem_len >= 2) { 1668 wpa->cap = LE_READ_2(ie); 1669 ie += 2; 1670 rem_len -= 2; 1671 } 1672 1673 return QDF_STATUS_SUCCESS; 1674 } 1675 1676 /** 1677 * wlan_parse_wapi_ie() - parse wapi ie 1678 * @wapi_ie: wpa ie ptr 1679 * @wapi: out structure for the parsed IE 1680 * 1681 * API, function to parse wapi ie 1682 * 1683 * Return: void 1684 */ 1685 static inline void wlan_parse_wapi_ie(uint8_t *wapi_ie, 1686 struct wlan_wapi_ie *wapi) 1687 { 1688 uint8_t len, i; 1689 uint8_t *ie; 1690 1691 if (!wapi_ie) 1692 return; 1693 1694 ie = wapi_ie; 1695 len = ie[1]; 1696 /* 1697 * Check the length once for fixed parts: OUI, type, 1698 * version, mcast cipher, and 2 selector counts. 1699 * Other, variable-length data, must be checked separately. 1700 */ 1701 if (len < 20) 1702 return; 1703 1704 ie += 2; 1705 1706 wapi->ver = LE_READ_2(ie); 1707 if (wapi->ver != WAPI_VERSION) 1708 return; 1709 1710 ie += 2; 1711 len -= 2; 1712 1713 /* akm */ 1714 wapi->akm_suite_count = LE_READ_2(ie); 1715 1716 ie += 2; 1717 len -= 2; 1718 1719 if ((wapi->akm_suite_count > WLAN_MAX_CIPHER) || 1720 len < (wapi->akm_suite_count * WLAN_OUI_SIZE)) 1721 return; 1722 for (i = 0 ; i < wapi->akm_suite_count; i++) { 1723 wapi->akm_suites[i] = LE_READ_4(ie); 1724 ie += WLAN_OUI_SIZE; 1725 len -= WLAN_OUI_SIZE; 1726 } 1727 1728 wapi->uc_cipher_count = LE_READ_2(ie); 1729 ie += 2; 1730 len -= 2; 1731 if ((wapi->uc_cipher_count > WLAN_MAX_CIPHER) || 1732 len < (wapi->uc_cipher_count * WLAN_OUI_SIZE + 2)) 1733 return; 1734 for (i = 0 ; i < wapi->uc_cipher_count; i++) { 1735 wapi->uc_cipher_suites[i] = LE_READ_4(ie); 1736 ie += WLAN_OUI_SIZE; 1737 len -= WLAN_OUI_SIZE; 1738 } 1739 1740 if (len >= WLAN_OUI_SIZE) 1741 wapi->mc_cipher_suite = LE_READ_4(ie); 1742 } 1743 1744 /** 1745 * wlan_parse_oce_reduced_wan_metrics_ie() - parse oce wan metrics 1746 * @mbo_oce_ie: MBO/OCE ie ptr 1747 * @wan_metrics: out structure for the reduced wan metric 1748 * 1749 * API, function to parse reduced wan metric 1750 * 1751 * Return: true if oce wan metrics is present 1752 */ 1753 static inline bool 1754 wlan_parse_oce_reduced_wan_metrics_ie(uint8_t *mbo_oce_ie, 1755 struct oce_reduced_wan_metrics *wan_metrics) 1756 { 1757 uint8_t len, attribute_len, attribute_id; 1758 uint8_t *ie; 1759 1760 if (!mbo_oce_ie) 1761 return false; 1762 1763 ie = mbo_oce_ie; 1764 len = ie[1]; 1765 ie += 2; 1766 1767 if (len <= MBO_OCE_OUI_SIZE) 1768 return false; 1769 1770 ie += MBO_OCE_OUI_SIZE; 1771 len -= MBO_OCE_OUI_SIZE; 1772 1773 while (len > 2) { 1774 attribute_id = ie[0]; 1775 attribute_len = ie[1]; 1776 len -= 2; 1777 if (attribute_len > len) 1778 return false; 1779 1780 if (attribute_id == REDUCED_WAN_METRICS_ATTR) { 1781 wan_metrics->downlink_av_cap = ie[2] & 0xff; 1782 wan_metrics->uplink_av_cap = ie[2] >> 4; 1783 return true; 1784 } 1785 1786 ie += (attribute_len + 2); 1787 len -= attribute_len; 1788 } 1789 1790 return false; 1791 } 1792 1793 #endif /* _WLAN_CMN_IEEE80211_DEFS_H_ */ 1794