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