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