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