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