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