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