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