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