xref: /linux/include/linux/ieee80211.h (revision 37a93dd5c49b5fda807fd204edf2547c3493319c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * IEEE 802.11 defines
4  *
5  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
6  * <jkmaline@cc.hut.fi>
7  * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8  * Copyright (c) 2005, Devicescape Software, Inc.
9  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
10  * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
11  * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
12  * Copyright (c) 2018 - 2026 Intel Corporation
13  */
14 
15 #ifndef LINUX_IEEE80211_H
16 #define LINUX_IEEE80211_H
17 
18 #include <linux/types.h>
19 #include <linux/if_ether.h>
20 #include <linux/etherdevice.h>
21 #include <linux/bitfield.h>
22 #include <asm/byteorder.h>
23 #include <linux/unaligned.h>
24 
25 /*
26  * DS bit usage
27  *
28  * TA = transmitter address
29  * RA = receiver address
30  * DA = destination address
31  * SA = source address
32  *
33  * ToDS    FromDS  A1(RA)  A2(TA)  A3      A4      Use
34  * -----------------------------------------------------------------
35  *  0       0       DA      SA      BSSID   -       IBSS/DLS
36  *  0       1       DA      BSSID   SA      -       AP -> STA
37  *  1       0       BSSID   SA      DA      -       AP <- STA
38  *  1       1       RA      TA      DA      SA      unspecified (WDS)
39  */
40 
41 #define FCS_LEN 4
42 
43 #define IEEE80211_FCTL_VERS		0x0003
44 #define IEEE80211_FCTL_FTYPE		0x000c
45 #define IEEE80211_FCTL_STYPE		0x00f0
46 #define IEEE80211_FCTL_TYPE		(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)
47 #define IEEE80211_FCTL_TODS		0x0100
48 #define IEEE80211_FCTL_FROMDS		0x0200
49 #define IEEE80211_FCTL_MOREFRAGS	0x0400
50 #define IEEE80211_FCTL_RETRY		0x0800
51 #define IEEE80211_FCTL_PM		0x1000
52 #define IEEE80211_FCTL_MOREDATA		0x2000
53 #define IEEE80211_FCTL_PROTECTED	0x4000
54 #define IEEE80211_FCTL_ORDER		0x8000
55 #define IEEE80211_FCTL_CTL_EXT		0x0f00
56 
57 #define IEEE80211_SCTL_FRAG		0x000F
58 #define IEEE80211_SCTL_SEQ		0xFFF0
59 
60 #define IEEE80211_FTYPE_MGMT		0x0000
61 #define IEEE80211_FTYPE_CTL		0x0004
62 #define IEEE80211_FTYPE_DATA		0x0008
63 #define IEEE80211_FTYPE_EXT		0x000c
64 
65 /* management */
66 #define IEEE80211_STYPE_ASSOC_REQ	0x0000
67 #define IEEE80211_STYPE_ASSOC_RESP	0x0010
68 #define IEEE80211_STYPE_REASSOC_REQ	0x0020
69 #define IEEE80211_STYPE_REASSOC_RESP	0x0030
70 #define IEEE80211_STYPE_PROBE_REQ	0x0040
71 #define IEEE80211_STYPE_PROBE_RESP	0x0050
72 #define IEEE80211_STYPE_BEACON		0x0080
73 #define IEEE80211_STYPE_ATIM		0x0090
74 #define IEEE80211_STYPE_DISASSOC	0x00A0
75 #define IEEE80211_STYPE_AUTH		0x00B0
76 #define IEEE80211_STYPE_DEAUTH		0x00C0
77 #define IEEE80211_STYPE_ACTION		0x00D0
78 
79 /* control */
80 #define IEEE80211_STYPE_TRIGGER		0x0020
81 #define IEEE80211_STYPE_CTL_EXT		0x0060
82 #define IEEE80211_STYPE_BACK_REQ	0x0080
83 #define IEEE80211_STYPE_BACK		0x0090
84 #define IEEE80211_STYPE_PSPOLL		0x00A0
85 #define IEEE80211_STYPE_RTS		0x00B0
86 #define IEEE80211_STYPE_CTS		0x00C0
87 #define IEEE80211_STYPE_ACK		0x00D0
88 #define IEEE80211_STYPE_CFEND		0x00E0
89 #define IEEE80211_STYPE_CFENDACK	0x00F0
90 
91 /* data */
92 #define IEEE80211_STYPE_DATA			0x0000
93 #define IEEE80211_STYPE_DATA_CFACK		0x0010
94 #define IEEE80211_STYPE_DATA_CFPOLL		0x0020
95 #define IEEE80211_STYPE_DATA_CFACKPOLL		0x0030
96 #define IEEE80211_STYPE_NULLFUNC		0x0040
97 #define IEEE80211_STYPE_CFACK			0x0050
98 #define IEEE80211_STYPE_CFPOLL			0x0060
99 #define IEEE80211_STYPE_CFACKPOLL		0x0070
100 #define IEEE80211_STYPE_QOS_DATA		0x0080
101 #define IEEE80211_STYPE_QOS_DATA_CFACK		0x0090
102 #define IEEE80211_STYPE_QOS_DATA_CFPOLL		0x00A0
103 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL	0x00B0
104 #define IEEE80211_STYPE_QOS_NULLFUNC		0x00C0
105 #define IEEE80211_STYPE_QOS_CFACK		0x00D0
106 #define IEEE80211_STYPE_QOS_CFPOLL		0x00E0
107 #define IEEE80211_STYPE_QOS_CFACKPOLL		0x00F0
108 
109 /* extension, added by 802.11ad */
110 #define IEEE80211_STYPE_DMG_BEACON		0x0000
111 #define IEEE80211_STYPE_S1G_BEACON		0x0010
112 
113 #define IEEE80211_NDP_FTYPE_CTS			0
114 #define IEEE80211_NDP_FTYPE_CF_END		0
115 #define IEEE80211_NDP_FTYPE_PS_POLL		1
116 #define IEEE80211_NDP_FTYPE_ACK			2
117 #define IEEE80211_NDP_FTYPE_PS_POLL_ACK		3
118 #define IEEE80211_NDP_FTYPE_BA			4
119 #define IEEE80211_NDP_FTYPE_BF_REPORT_POLL	5
120 #define IEEE80211_NDP_FTYPE_PAGING		6
121 #define IEEE80211_NDP_FTYPE_PREQ		7
122 
123 #define SM64(f, v)	((((u64)v) << f##_S) & f)
124 
125 /* NDP CMAC frame fields */
126 #define IEEE80211_NDP_FTYPE                    0x0000000000000007
127 #define IEEE80211_NDP_FTYPE_S                  0x0000000000000000
128 
129 /* 1M Probe Request 11ah 9.9.3.1.1 */
130 #define IEEE80211_NDP_1M_PREQ_ANO      0x0000000000000008
131 #define IEEE80211_NDP_1M_PREQ_ANO_S                     3
132 #define IEEE80211_NDP_1M_PREQ_CSSID    0x00000000000FFFF0
133 #define IEEE80211_NDP_1M_PREQ_CSSID_S                   4
134 #define IEEE80211_NDP_1M_PREQ_RTYPE    0x0000000000100000
135 #define IEEE80211_NDP_1M_PREQ_RTYPE_S                  20
136 #define IEEE80211_NDP_1M_PREQ_RSV      0x0000000001E00000
137 #define IEEE80211_NDP_1M_PREQ_RSV      0x0000000001E00000
138 /* 2M Probe Request 11ah 9.9.3.1.2 */
139 #define IEEE80211_NDP_2M_PREQ_ANO      0x0000000000000008
140 #define IEEE80211_NDP_2M_PREQ_ANO_S                     3
141 #define IEEE80211_NDP_2M_PREQ_CSSID    0x0000000FFFFFFFF0
142 #define IEEE80211_NDP_2M_PREQ_CSSID_S                   4
143 #define IEEE80211_NDP_2M_PREQ_RTYPE    0x0000001000000000
144 #define IEEE80211_NDP_2M_PREQ_RTYPE_S                  36
145 
146 #define IEEE80211_ANO_NETTYPE_WILD              15
147 
148 /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
149 #define IEEE80211_CTL_EXT_POLL		0x2000
150 #define IEEE80211_CTL_EXT_SPR		0x3000
151 #define IEEE80211_CTL_EXT_GRANT	0x4000
152 #define IEEE80211_CTL_EXT_DMG_CTS	0x5000
153 #define IEEE80211_CTL_EXT_DMG_DTS	0x6000
154 #define IEEE80211_CTL_EXT_SSW		0x8000
155 #define IEEE80211_CTL_EXT_SSW_FBACK	0x9000
156 #define IEEE80211_CTL_EXT_SSW_ACK	0xa000
157 
158 
159 #define IEEE80211_SN_MASK		((IEEE80211_SCTL_SEQ) >> 4)
160 #define IEEE80211_MAX_SN		IEEE80211_SN_MASK
161 #define IEEE80211_SN_MODULO		(IEEE80211_MAX_SN + 1)
162 
163 
164 /* PV1 Layout IEEE 802.11-2020 9.8.3.1 */
165 #define IEEE80211_PV1_FCTL_VERS		0x0003
166 #define IEEE80211_PV1_FCTL_FTYPE	0x001c
167 #define IEEE80211_PV1_FCTL_STYPE	0x00e0
168 #define IEEE80211_PV1_FCTL_FROMDS		0x0100
169 #define IEEE80211_PV1_FCTL_MOREFRAGS	0x0200
170 #define IEEE80211_PV1_FCTL_PM		0x0400
171 #define IEEE80211_PV1_FCTL_MOREDATA	0x0800
172 #define IEEE80211_PV1_FCTL_PROTECTED	0x1000
173 #define IEEE80211_PV1_FCTL_END_SP       0x2000
174 #define IEEE80211_PV1_FCTL_RELAYED      0x4000
175 #define IEEE80211_PV1_FCTL_ACK_POLICY   0x8000
176 #define IEEE80211_PV1_FCTL_CTL_EXT	0x0f00
177 
ieee80211_sn_less(u16 sn1,u16 sn2)178 static inline bool ieee80211_sn_less(u16 sn1, u16 sn2)
179 {
180 	return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
181 }
182 
ieee80211_sn_less_eq(u16 sn1,u16 sn2)183 static inline bool ieee80211_sn_less_eq(u16 sn1, u16 sn2)
184 {
185 	return ((sn2 - sn1) & IEEE80211_SN_MASK) <= (IEEE80211_SN_MODULO >> 1);
186 }
187 
ieee80211_sn_add(u16 sn1,u16 sn2)188 static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2)
189 {
190 	return (sn1 + sn2) & IEEE80211_SN_MASK;
191 }
192 
ieee80211_sn_inc(u16 sn)193 static inline u16 ieee80211_sn_inc(u16 sn)
194 {
195 	return ieee80211_sn_add(sn, 1);
196 }
197 
ieee80211_sn_sub(u16 sn1,u16 sn2)198 static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
199 {
200 	return (sn1 - sn2) & IEEE80211_SN_MASK;
201 }
202 
203 #define IEEE80211_SEQ_TO_SN(seq)	(((seq) & IEEE80211_SCTL_SEQ) >> 4)
204 #define IEEE80211_SN_TO_SEQ(ssn)	(((ssn) << 4) & IEEE80211_SCTL_SEQ)
205 
206 /* miscellaneous IEEE 802.11 constants */
207 #define IEEE80211_MAX_FRAG_THRESHOLD	2352
208 #define IEEE80211_MAX_RTS_THRESHOLD	2353
209 #define IEEE80211_MAX_AID		2007
210 #define IEEE80211_MAX_AID_S1G		8191
211 #define IEEE80211_MAX_TIM_LEN		251
212 #define IEEE80211_MAX_MESH_PEERINGS	63
213 
214 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
215    6.2.1.1.2.
216 
217    802.11e clarifies the figure in section 7.1.2. The frame body is
218    up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
219 #define IEEE80211_MAX_DATA_LEN		2304
220 /* 802.11ad extends maximum MSDU size for DMG (freq > 40Ghz) networks
221  * to 7920 bytes, see 8.2.3 General frame format
222  */
223 #define IEEE80211_MAX_DATA_LEN_DMG	7920
224 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
225 #define IEEE80211_MAX_FRAME_LEN		2352
226 
227 #define IEEE80211_MAX_SSID_LEN		32
228 
229 #define IEEE80211_FIRST_TSPEC_TSID	8
230 #define IEEE80211_NUM_TIDS		16
231 
232 /* number of user priorities 802.11 uses */
233 #define IEEE80211_NUM_UPS		8
234 /* number of ACs */
235 #define IEEE80211_NUM_ACS		4
236 
237 #define IEEE80211_QOS_CTL_LEN		2
238 /* 1d tag mask */
239 #define IEEE80211_QOS_CTL_TAG1D_MASK		0x0007
240 /* TID mask */
241 #define IEEE80211_QOS_CTL_TID_MASK		0x000f
242 /* EOSP */
243 #define IEEE80211_QOS_CTL_EOSP			0x0010
244 /* ACK policy */
245 #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL	0x0000
246 #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK	0x0020
247 #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL	0x0040
248 #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK	0x0060
249 #define IEEE80211_QOS_CTL_ACK_POLICY_MASK	0x0060
250 /* A-MSDU 802.11n */
251 #define IEEE80211_QOS_CTL_A_MSDU_PRESENT	0x0080
252 /* Mesh Control 802.11s */
253 #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT  0x0100
254 
255 /* Mesh Power Save Level */
256 #define IEEE80211_QOS_CTL_MESH_PS_LEVEL		0x0200
257 /* Mesh Receiver Service Period Initiated */
258 #define IEEE80211_QOS_CTL_RSPI			0x0400
259 
260 /* U-APSD queue for WMM IEs sent by AP */
261 #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD	(1<<7)
262 #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK	0x0f
263 
264 /* U-APSD queues for WMM IEs sent by STA */
265 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO	(1<<0)
266 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI	(1<<1)
267 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK	(1<<2)
268 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE	(1<<3)
269 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK	0x0f
270 
271 /* U-APSD max SP length for WMM IEs sent by STA */
272 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL	0x00
273 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2	0x01
274 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4	0x02
275 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6	0x03
276 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK	0x03
277 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT	5
278 
279 /* trigger type within common_info of trigger frame */
280 #define IEEE80211_TRIGGER_TYPE_MASK		0xf
281 #define IEEE80211_TRIGGER_TYPE_BASIC		0x0
282 #define IEEE80211_TRIGGER_TYPE_BFRP		0x1
283 #define IEEE80211_TRIGGER_TYPE_MU_BAR		0x2
284 #define IEEE80211_TRIGGER_TYPE_MU_RTS		0x3
285 #define IEEE80211_TRIGGER_TYPE_BSRP		0x4
286 #define IEEE80211_TRIGGER_TYPE_GCR_MU_BAR	0x5
287 #define IEEE80211_TRIGGER_TYPE_BQRP		0x6
288 #define IEEE80211_TRIGGER_TYPE_NFRP		0x7
289 
290 /* UL-bandwidth within common_info of trigger frame */
291 #define IEEE80211_TRIGGER_ULBW_MASK		0xc0000
292 #define IEEE80211_TRIGGER_ULBW_20MHZ		0x0
293 #define IEEE80211_TRIGGER_ULBW_40MHZ		0x1
294 #define IEEE80211_TRIGGER_ULBW_80MHZ		0x2
295 #define IEEE80211_TRIGGER_ULBW_160_80P80MHZ	0x3
296 
297 struct ieee80211_hdr {
298 	__le16 frame_control;
299 	__le16 duration_id;
300 	struct_group(addrs,
301 		u8 addr1[ETH_ALEN];
302 		u8 addr2[ETH_ALEN];
303 		u8 addr3[ETH_ALEN];
304 	);
305 	__le16 seq_ctrl;
306 	u8 addr4[ETH_ALEN];
307 } __packed __aligned(2);
308 
309 struct ieee80211_hdr_3addr {
310 	__le16 frame_control;
311 	__le16 duration_id;
312 	u8 addr1[ETH_ALEN];
313 	u8 addr2[ETH_ALEN];
314 	u8 addr3[ETH_ALEN];
315 	__le16 seq_ctrl;
316 } __packed __aligned(2);
317 
318 struct ieee80211_qos_hdr {
319 	__le16 frame_control;
320 	__le16 duration_id;
321 	u8 addr1[ETH_ALEN];
322 	u8 addr2[ETH_ALEN];
323 	u8 addr3[ETH_ALEN];
324 	__le16 seq_ctrl;
325 	__le16 qos_ctrl;
326 } __packed __aligned(2);
327 
328 struct ieee80211_qos_hdr_4addr {
329 	__le16 frame_control;
330 	__le16 duration_id;
331 	u8 addr1[ETH_ALEN];
332 	u8 addr2[ETH_ALEN];
333 	u8 addr3[ETH_ALEN];
334 	__le16 seq_ctrl;
335 	u8 addr4[ETH_ALEN];
336 	__le16 qos_ctrl;
337 } __packed __aligned(2);
338 
339 struct ieee80211_trigger {
340 	__le16 frame_control;
341 	__le16 duration;
342 	u8 ra[ETH_ALEN];
343 	u8 ta[ETH_ALEN];
344 	__le64 common_info;
345 	u8 variable[];
346 } __packed __aligned(2);
347 
348 /**
349  * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
350  * @fc: frame control bytes in little-endian byteorder
351  * Return: whether or not the frame has to-DS set
352  */
ieee80211_has_tods(__le16 fc)353 static inline bool ieee80211_has_tods(__le16 fc)
354 {
355 	return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
356 }
357 
358 /**
359  * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
360  * @fc: frame control bytes in little-endian byteorder
361  * Return: whether or not the frame has from-DS set
362  */
ieee80211_has_fromds(__le16 fc)363 static inline bool ieee80211_has_fromds(__le16 fc)
364 {
365 	return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
366 }
367 
368 /**
369  * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
370  * @fc: frame control bytes in little-endian byteorder
371  * Return: whether or not it's a 4-address frame (from-DS and to-DS set)
372  */
ieee80211_has_a4(__le16 fc)373 static inline bool ieee80211_has_a4(__le16 fc)
374 {
375 	__le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
376 	return (fc & tmp) == tmp;
377 }
378 
379 /**
380  * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
381  * @fc: frame control bytes in little-endian byteorder
382  * Return: whether or not the frame has more fragments (more frags bit set)
383  */
ieee80211_has_morefrags(__le16 fc)384 static inline bool ieee80211_has_morefrags(__le16 fc)
385 {
386 	return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
387 }
388 
389 /**
390  * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
391  * @fc: frame control bytes in little-endian byteorder
392  * Return: whether or not the retry flag is set
393  */
ieee80211_has_retry(__le16 fc)394 static inline bool ieee80211_has_retry(__le16 fc)
395 {
396 	return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
397 }
398 
399 /**
400  * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
401  * @fc: frame control bytes in little-endian byteorder
402  * Return: whether or not the power management flag is set
403  */
ieee80211_has_pm(__le16 fc)404 static inline bool ieee80211_has_pm(__le16 fc)
405 {
406 	return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
407 }
408 
409 /**
410  * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
411  * @fc: frame control bytes in little-endian byteorder
412  * Return: whether or not the more data flag is set
413  */
ieee80211_has_moredata(__le16 fc)414 static inline bool ieee80211_has_moredata(__le16 fc)
415 {
416 	return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
417 }
418 
419 /**
420  * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
421  * @fc: frame control bytes in little-endian byteorder
422  * Return: whether or not the protected flag is set
423  */
ieee80211_has_protected(__le16 fc)424 static inline bool ieee80211_has_protected(__le16 fc)
425 {
426 	return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
427 }
428 
429 /**
430  * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
431  * @fc: frame control bytes in little-endian byteorder
432  * Return: whether or not the order flag is set
433  */
ieee80211_has_order(__le16 fc)434 static inline bool ieee80211_has_order(__le16 fc)
435 {
436 	return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
437 }
438 
439 /**
440  * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
441  * @fc: frame control bytes in little-endian byteorder
442  * Return: whether or not the frame type is management
443  */
ieee80211_is_mgmt(__le16 fc)444 static inline bool ieee80211_is_mgmt(__le16 fc)
445 {
446 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
447 	       cpu_to_le16(IEEE80211_FTYPE_MGMT);
448 }
449 
450 /**
451  * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
452  * @fc: frame control bytes in little-endian byteorder
453  * Return: whether or not the frame type is control
454  */
ieee80211_is_ctl(__le16 fc)455 static inline bool ieee80211_is_ctl(__le16 fc)
456 {
457 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
458 	       cpu_to_le16(IEEE80211_FTYPE_CTL);
459 }
460 
461 /**
462  * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
463  * @fc: frame control bytes in little-endian byteorder
464  * Return: whether or not the frame is a data frame
465  */
ieee80211_is_data(__le16 fc)466 static inline bool ieee80211_is_data(__le16 fc)
467 {
468 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
469 	       cpu_to_le16(IEEE80211_FTYPE_DATA);
470 }
471 
472 /**
473  * ieee80211_is_ext - check if type is IEEE80211_FTYPE_EXT
474  * @fc: frame control bytes in little-endian byteorder
475  * Return: whether or not the frame type is extended
476  */
ieee80211_is_ext(__le16 fc)477 static inline bool ieee80211_is_ext(__le16 fc)
478 {
479 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
480 	       cpu_to_le16(IEEE80211_FTYPE_EXT);
481 }
482 
483 
484 /**
485  * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
486  * @fc: frame control bytes in little-endian byteorder
487  * Return: whether or not the frame is a QoS data frame
488  */
ieee80211_is_data_qos(__le16 fc)489 static inline bool ieee80211_is_data_qos(__le16 fc)
490 {
491 	/*
492 	 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
493 	 * to check the one bit
494 	 */
495 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
496 	       cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
497 }
498 
499 /**
500  * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
501  * @fc: frame control bytes in little-endian byteorder
502  * Return: whether or not the frame is a QoS data frame that has data
503  *	(i.e. is not null data)
504  */
ieee80211_is_data_present(__le16 fc)505 static inline bool ieee80211_is_data_present(__le16 fc)
506 {
507 	/*
508 	 * mask with 0x40 and test that that bit is clear to only return true
509 	 * for the data-containing substypes.
510 	 */
511 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
512 	       cpu_to_le16(IEEE80211_FTYPE_DATA);
513 }
514 
515 /**
516  * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
517  * @fc: frame control bytes in little-endian byteorder
518  * Return: whether or not the frame is an association request
519  */
ieee80211_is_assoc_req(__le16 fc)520 static inline bool ieee80211_is_assoc_req(__le16 fc)
521 {
522 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
523 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
524 }
525 
526 /**
527  * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
528  * @fc: frame control bytes in little-endian byteorder
529  * Return: whether or not the frame is an association response
530  */
ieee80211_is_assoc_resp(__le16 fc)531 static inline bool ieee80211_is_assoc_resp(__le16 fc)
532 {
533 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
534 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
535 }
536 
537 /**
538  * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
539  * @fc: frame control bytes in little-endian byteorder
540  * Return: whether or not the frame is a reassociation request
541  */
ieee80211_is_reassoc_req(__le16 fc)542 static inline bool ieee80211_is_reassoc_req(__le16 fc)
543 {
544 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
545 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
546 }
547 
548 /**
549  * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
550  * @fc: frame control bytes in little-endian byteorder
551  * Return: whether or not the frame is a reassociation response
552  */
ieee80211_is_reassoc_resp(__le16 fc)553 static inline bool ieee80211_is_reassoc_resp(__le16 fc)
554 {
555 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
556 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
557 }
558 
559 /**
560  * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
561  * @fc: frame control bytes in little-endian byteorder
562  * Return: whether or not the frame is a probe request
563  */
ieee80211_is_probe_req(__le16 fc)564 static inline bool ieee80211_is_probe_req(__le16 fc)
565 {
566 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
567 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
568 }
569 
570 /**
571  * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
572  * @fc: frame control bytes in little-endian byteorder
573  * Return: whether or not the frame is a probe response
574  */
ieee80211_is_probe_resp(__le16 fc)575 static inline bool ieee80211_is_probe_resp(__le16 fc)
576 {
577 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
578 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
579 }
580 
581 /**
582  * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
583  * @fc: frame control bytes in little-endian byteorder
584  * Return: whether or not the frame is a (regular, not S1G) beacon
585  */
ieee80211_is_beacon(__le16 fc)586 static inline bool ieee80211_is_beacon(__le16 fc)
587 {
588 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
589 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
590 }
591 
592 /**
593  * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
594  * @fc: frame control bytes in little-endian byteorder
595  * Return: whether or not the frame is an ATIM frame
596  */
ieee80211_is_atim(__le16 fc)597 static inline bool ieee80211_is_atim(__le16 fc)
598 {
599 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
600 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
601 }
602 
603 /**
604  * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
605  * @fc: frame control bytes in little-endian byteorder
606  * Return: whether or not the frame is a disassociation frame
607  */
ieee80211_is_disassoc(__le16 fc)608 static inline bool ieee80211_is_disassoc(__le16 fc)
609 {
610 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
611 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
612 }
613 
614 /**
615  * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
616  * @fc: frame control bytes in little-endian byteorder
617  * Return: whether or not the frame is an authentication frame
618  */
ieee80211_is_auth(__le16 fc)619 static inline bool ieee80211_is_auth(__le16 fc)
620 {
621 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
622 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
623 }
624 
625 /**
626  * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
627  * @fc: frame control bytes in little-endian byteorder
628  * Return: whether or not the frame is a deauthentication frame
629  */
ieee80211_is_deauth(__le16 fc)630 static inline bool ieee80211_is_deauth(__le16 fc)
631 {
632 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
633 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
634 }
635 
636 /**
637  * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
638  * @fc: frame control bytes in little-endian byteorder
639  * Return: whether or not the frame is an action frame
640  */
ieee80211_is_action(__le16 fc)641 static inline bool ieee80211_is_action(__le16 fc)
642 {
643 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
644 	       cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
645 }
646 
647 /**
648  * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
649  * @fc: frame control bytes in little-endian byteorder
650  * Return: whether or not the frame is a block-ACK request frame
651  */
ieee80211_is_back_req(__le16 fc)652 static inline bool ieee80211_is_back_req(__le16 fc)
653 {
654 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
655 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
656 }
657 
658 /**
659  * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
660  * @fc: frame control bytes in little-endian byteorder
661  * Return: whether or not the frame is a block-ACK frame
662  */
ieee80211_is_back(__le16 fc)663 static inline bool ieee80211_is_back(__le16 fc)
664 {
665 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
666 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
667 }
668 
669 /**
670  * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
671  * @fc: frame control bytes in little-endian byteorder
672  * Return: whether or not the frame is a PS-poll frame
673  */
ieee80211_is_pspoll(__le16 fc)674 static inline bool ieee80211_is_pspoll(__le16 fc)
675 {
676 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
677 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
678 }
679 
680 /**
681  * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
682  * @fc: frame control bytes in little-endian byteorder
683  * Return: whether or not the frame is an RTS frame
684  */
ieee80211_is_rts(__le16 fc)685 static inline bool ieee80211_is_rts(__le16 fc)
686 {
687 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
688 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
689 }
690 
691 /**
692  * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
693  * @fc: frame control bytes in little-endian byteorder
694  * Return: whether or not the frame is a CTS frame
695  */
ieee80211_is_cts(__le16 fc)696 static inline bool ieee80211_is_cts(__le16 fc)
697 {
698 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
699 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
700 }
701 
702 /**
703  * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
704  * @fc: frame control bytes in little-endian byteorder
705  * Return: whether or not the frame is an ACK frame
706  */
ieee80211_is_ack(__le16 fc)707 static inline bool ieee80211_is_ack(__le16 fc)
708 {
709 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
710 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
711 }
712 
713 /**
714  * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
715  * @fc: frame control bytes in little-endian byteorder
716  * Return: whether or not the frame is a CF-end frame
717  */
ieee80211_is_cfend(__le16 fc)718 static inline bool ieee80211_is_cfend(__le16 fc)
719 {
720 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
721 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
722 }
723 
724 /**
725  * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
726  * @fc: frame control bytes in little-endian byteorder
727  * Return: whether or not the frame is a CF-end-ack frame
728  */
ieee80211_is_cfendack(__le16 fc)729 static inline bool ieee80211_is_cfendack(__le16 fc)
730 {
731 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
732 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
733 }
734 
735 /**
736  * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
737  * @fc: frame control bytes in little-endian byteorder
738  * Return: whether or not the frame is a nullfunc frame
739  */
ieee80211_is_nullfunc(__le16 fc)740 static inline bool ieee80211_is_nullfunc(__le16 fc)
741 {
742 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
743 	       cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
744 }
745 
746 /**
747  * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
748  * @fc: frame control bytes in little-endian byteorder
749  * Return: whether or not the frame is a QoS nullfunc frame
750  */
ieee80211_is_qos_nullfunc(__le16 fc)751 static inline bool ieee80211_is_qos_nullfunc(__le16 fc)
752 {
753 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
754 	       cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
755 }
756 
757 /**
758  * ieee80211_is_trigger - check if frame is trigger frame
759  * @fc: frame control field in little-endian byteorder
760  * Return: whether or not the frame is a trigger frame
761  */
ieee80211_is_trigger(__le16 fc)762 static inline bool ieee80211_is_trigger(__le16 fc)
763 {
764 	return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
765 	       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_TRIGGER);
766 }
767 
768 /**
769  * ieee80211_is_any_nullfunc - check if frame is regular or QoS nullfunc frame
770  * @fc: frame control bytes in little-endian byteorder
771  * Return: whether or not the frame is a nullfunc or QoS nullfunc frame
772  */
ieee80211_is_any_nullfunc(__le16 fc)773 static inline bool ieee80211_is_any_nullfunc(__le16 fc)
774 {
775 	return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
776 }
777 
778 /**
779  * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
780  * @seq_ctrl: frame sequence control bytes in little-endian byteorder
781  * Return: whether or not the frame is the first fragment (also true if
782  *	it's not fragmented at all)
783  */
ieee80211_is_first_frag(__le16 seq_ctrl)784 static inline bool ieee80211_is_first_frag(__le16 seq_ctrl)
785 {
786 	return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0;
787 }
788 
789 /**
790  * ieee80211_is_frag - check if a frame is a fragment
791  * @hdr: 802.11 header of the frame
792  * Return: whether or not the frame is a fragment
793  */
ieee80211_is_frag(struct ieee80211_hdr * hdr)794 static inline bool ieee80211_is_frag(struct ieee80211_hdr *hdr)
795 {
796 	return ieee80211_has_morefrags(hdr->frame_control) ||
797 	       hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG);
798 }
799 
ieee80211_get_sn(struct ieee80211_hdr * hdr)800 static inline u16 ieee80211_get_sn(struct ieee80211_hdr *hdr)
801 {
802 	return le16_get_bits(hdr->seq_ctrl, IEEE80211_SCTL_SEQ);
803 }
804 
805 /**
806  * struct ieee80211_quiet_ie - Quiet element
807  * @count: Quiet Count
808  * @period: Quiet Period
809  * @duration: Quiet Duration
810  * @offset: Quiet Offset
811  *
812  * This structure represents the payload of the "Quiet element" as
813  * described in IEEE Std 802.11-2020 section 9.4.2.22.
814  */
815 struct ieee80211_quiet_ie {
816 	u8 count;
817 	u8 period;
818 	__le16 duration;
819 	__le16 offset;
820 } __packed;
821 
822 /**
823  * struct ieee80211_msrment_ie - Measurement element
824  * @token: Measurement Token
825  * @mode: Measurement Report Mode
826  * @type: Measurement Type
827  * @request: Measurement Request or Measurement Report
828  *
829  * This structure represents the payload of both the "Measurement
830  * Request element" and the "Measurement Report element" as described
831  * in IEEE Std 802.11-2020 sections 9.4.2.20 and 9.4.2.21.
832  */
833 struct ieee80211_msrment_ie {
834 	u8 token;
835 	u8 mode;
836 	u8 type;
837 	u8 request[];
838 } __packed;
839 
840 /**
841  * struct ieee80211_channel_sw_ie - Channel Switch Announcement element
842  * @mode: Channel Switch Mode
843  * @new_ch_num: New Channel Number
844  * @count: Channel Switch Count
845  *
846  * This structure represents the payload of the "Channel Switch
847  * Announcement element" as described in IEEE Std 802.11-2020 section
848  * 9.4.2.18.
849  */
850 struct ieee80211_channel_sw_ie {
851 	u8 mode;
852 	u8 new_ch_num;
853 	u8 count;
854 } __packed;
855 
856 /**
857  * struct ieee80211_ext_chansw_ie - Extended Channel Switch Announcement element
858  * @mode: Channel Switch Mode
859  * @new_operating_class: New Operating Class
860  * @new_ch_num: New Channel Number
861  * @count: Channel Switch Count
862  *
863  * This structure represents the "Extended Channel Switch Announcement
864  * element" as described in IEEE Std 802.11-2020 section 9.4.2.52.
865  */
866 struct ieee80211_ext_chansw_ie {
867 	u8 mode;
868 	u8 new_operating_class;
869 	u8 new_ch_num;
870 	u8 count;
871 } __packed;
872 
873 /**
874  * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
875  * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
876  *	values here
877  * This structure represents the "Secondary Channel Offset element"
878  */
879 struct ieee80211_sec_chan_offs_ie {
880 	u8 sec_chan_offs;
881 } __packed;
882 
883 /**
884  * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
885  * @new_channel_width: New Channel Width
886  * @new_center_freq_seg0: New Channel Center Frequency Segment 0
887  * @new_center_freq_seg1: New Channel Center Frequency Segment 1
888  *
889  * This structure represents the payload of the "Wide Bandwidth
890  * Channel Switch element" as described in IEEE Std 802.11-2020
891  * section 9.4.2.160.
892  */
893 struct ieee80211_wide_bw_chansw_ie {
894 	u8 new_channel_width;
895 	u8 new_center_freq_seg0, new_center_freq_seg1;
896 } __packed;
897 
898 /**
899  * struct ieee80211_tim_ie - Traffic Indication Map information element
900  * @dtim_count: DTIM Count
901  * @dtim_period: DTIM Period
902  * @bitmap_ctrl: Bitmap Control
903  * @required_octet: "Syntatic sugar" to force the struct size to the
904  *                  minimum valid size when carried in a non-S1G PPDU
905  * @virtual_map: Partial Virtual Bitmap
906  *
907  * This structure represents the payload of the "TIM element" as
908  * described in IEEE Std 802.11-2020 section 9.4.2.5. Note that this
909  * definition is only applicable when the element is carried in a
910  * non-S1G PPDU. When the TIM is carried in an S1G PPDU, the Bitmap
911  * Control and Partial Virtual Bitmap may not be present.
912  */
913 struct ieee80211_tim_ie {
914 	u8 dtim_count;
915 	u8 dtim_period;
916 	u8 bitmap_ctrl;
917 	union {
918 		u8 required_octet;
919 		DECLARE_FLEX_ARRAY(u8, virtual_map);
920 	};
921 } __packed;
922 
923 #define WLAN_SA_QUERY_TR_ID_LEN 2
924 #define WLAN_MEMBERSHIP_LEN 8
925 #define WLAN_USER_POSITION_LEN 16
926 
927 /**
928  * struct ieee80211_tpc_report_ie - TPC Report element
929  * @tx_power: Transmit Power
930  * @link_margin: Link Margin
931  *
932  * This structure represents the payload of the "TPC Report element" as
933  * described in IEEE Std 802.11-2020 section 9.4.2.16.
934  */
935 struct ieee80211_tpc_report_ie {
936 	u8 tx_power;
937 	u8 link_margin;
938 } __packed;
939 
940 #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK	GENMASK(2, 1)
941 #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_SHIFT	1
942 #define IEEE80211_ADDBA_EXT_NO_FRAG		BIT(0)
943 #define IEEE80211_ADDBA_EXT_BUF_SIZE_MASK	GENMASK(7, 5)
944 #define IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT	10
945 
946 struct ieee80211_addba_ext_ie {
947 	u8 data;
948 } __packed;
949 
950 struct ieee80211_ext {
951 	__le16 frame_control;
952 	__le16 duration;
953 	union {
954 		struct {
955 			u8 sa[ETH_ALEN];
956 			__le32 timestamp;
957 			u8 change_seq;
958 			u8 variable[];
959 		} __packed s1g_beacon;
960 	} u;
961 } __packed __aligned(2);
962 
963 /**
964  * struct ieee80211_bss_load_elem - BSS Load elemen
965  *
966  * Defined in section 9.4.2.26 in IEEE 802.11-REVme D4.1
967  *
968  * @sta_count: total number of STAs currently associated with the AP.
969  * @channel_util: Percentage of time that the access point sensed the channel
970  *	was busy. This value is in range [0, 255], the highest value means
971  *	100% busy.
972  * @avail_admission_capa: remaining amount of medium time used for admission
973  *	control.
974  */
975 struct ieee80211_bss_load_elem {
976 	__le16 sta_count;
977 	u8 channel_util;
978 	__le16 avail_admission_capa;
979 } __packed;
980 
981 struct ieee80211_mgmt {
982 	__le16 frame_control;
983 	__le16 duration;
984 	u8 da[ETH_ALEN];
985 	u8 sa[ETH_ALEN];
986 	u8 bssid[ETH_ALEN];
987 	__le16 seq_ctrl;
988 	union {
989 		struct {
990 			__le16 auth_alg;
991 			__le16 auth_transaction;
992 			__le16 status_code;
993 			/* possibly followed by Challenge text */
994 			u8 variable[];
995 		} __packed auth;
996 		struct {
997 			__le16 reason_code;
998 		} __packed deauth;
999 		struct {
1000 			__le16 capab_info;
1001 			__le16 listen_interval;
1002 			/* followed by SSID and Supported rates */
1003 			u8 variable[];
1004 		} __packed assoc_req;
1005 		struct {
1006 			__le16 capab_info;
1007 			__le16 status_code;
1008 			__le16 aid;
1009 			/* followed by Supported rates */
1010 			u8 variable[];
1011 		} __packed assoc_resp, reassoc_resp;
1012 		struct {
1013 			__le16 capab_info;
1014 			__le16 status_code;
1015 			u8 variable[];
1016 		} __packed s1g_assoc_resp, s1g_reassoc_resp;
1017 		struct {
1018 			__le16 capab_info;
1019 			__le16 listen_interval;
1020 			u8 current_ap[ETH_ALEN];
1021 			/* followed by SSID and Supported rates */
1022 			u8 variable[];
1023 		} __packed reassoc_req;
1024 		struct {
1025 			__le16 reason_code;
1026 		} __packed disassoc;
1027 		struct {
1028 			__le64 timestamp;
1029 			__le16 beacon_int;
1030 			__le16 capab_info;
1031 			/* followed by some of SSID, Supported rates,
1032 			 * FH Params, DS Params, CF Params, IBSS Params, TIM */
1033 			u8 variable[];
1034 		} __packed beacon;
1035 		struct {
1036 			/* only variable items: SSID, Supported rates */
1037 			DECLARE_FLEX_ARRAY(u8, variable);
1038 		} __packed probe_req;
1039 		struct {
1040 			__le64 timestamp;
1041 			__le16 beacon_int;
1042 			__le16 capab_info;
1043 			/* followed by some of SSID, Supported rates,
1044 			 * FH Params, DS Params, CF Params, IBSS Params */
1045 			u8 variable[];
1046 		} __packed probe_resp;
1047 		struct {
1048 			u8 category;
1049 			union {
1050 				struct {
1051 					u8 action_code;
1052 					u8 dialog_token;
1053 					u8 status_code;
1054 					u8 variable[];
1055 				} __packed wme_action;
1056 				struct{
1057 					u8 action_code;
1058 					u8 variable[];
1059 				} __packed chan_switch;
1060 				struct{
1061 					u8 action_code;
1062 					struct ieee80211_ext_chansw_ie data;
1063 					u8 variable[];
1064 				} __packed ext_chan_switch;
1065 				struct{
1066 					u8 action_code;
1067 					u8 dialog_token;
1068 					u8 element_id;
1069 					u8 length;
1070 					struct ieee80211_msrment_ie msr_elem;
1071 				} __packed measurement;
1072 				struct{
1073 					u8 action_code;
1074 					u8 dialog_token;
1075 					__le16 capab;
1076 					__le16 timeout;
1077 					__le16 start_seq_num;
1078 					/* followed by BA Extension */
1079 					u8 variable[];
1080 				} __packed addba_req;
1081 				struct{
1082 					u8 action_code;
1083 					u8 dialog_token;
1084 					__le16 status;
1085 					__le16 capab;
1086 					__le16 timeout;
1087 					/* followed by BA Extension */
1088 					u8 variable[];
1089 				} __packed addba_resp;
1090 				struct{
1091 					u8 action_code;
1092 					__le16 params;
1093 					__le16 reason_code;
1094 				} __packed delba;
1095 				struct {
1096 					u8 action_code;
1097 					u8 variable[];
1098 				} __packed self_prot;
1099 				struct{
1100 					u8 action_code;
1101 					u8 variable[];
1102 				} __packed mesh_action;
1103 				struct {
1104 					u8 action;
1105 					u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
1106 				} __packed sa_query;
1107 				struct {
1108 					u8 action;
1109 					u8 smps_control;
1110 				} __packed ht_smps;
1111 				struct {
1112 					u8 action_code;
1113 					u8 chanwidth;
1114 				} __packed ht_notify_cw;
1115 				struct {
1116 					u8 action_code;
1117 					u8 dialog_token;
1118 					__le16 capability;
1119 					u8 variable[];
1120 				} __packed tdls_discover_resp;
1121 				struct {
1122 					u8 action_code;
1123 					u8 operating_mode;
1124 				} __packed vht_opmode_notif;
1125 				struct {
1126 					u8 action_code;
1127 					u8 membership[WLAN_MEMBERSHIP_LEN];
1128 					u8 position[WLAN_USER_POSITION_LEN];
1129 				} __packed vht_group_notif;
1130 				struct {
1131 					u8 action_code;
1132 					u8 dialog_token;
1133 					u8 tpc_elem_id;
1134 					u8 tpc_elem_length;
1135 					struct ieee80211_tpc_report_ie tpc;
1136 				} __packed tpc_report;
1137 				struct {
1138 					u8 action_code;
1139 					u8 dialog_token;
1140 					u8 follow_up;
1141 					u8 tod[6];
1142 					u8 toa[6];
1143 					__le16 tod_error;
1144 					__le16 toa_error;
1145 					u8 variable[];
1146 				} __packed ftm;
1147 				struct {
1148 					u8 action_code;
1149 					u8 variable[];
1150 				} __packed s1g;
1151 				struct {
1152 					u8 action_code;
1153 					u8 dialog_token;
1154 					u8 follow_up;
1155 					u32 tod;
1156 					u32 toa;
1157 					u8 max_tod_error;
1158 					u8 max_toa_error;
1159 				} __packed wnm_timing_msr;
1160 				struct {
1161 					u8 action_code;
1162 					u8 dialog_token;
1163 					u8 variable[];
1164 				} __packed ttlm_req;
1165 				struct {
1166 					u8 action_code;
1167 					u8 dialog_token;
1168 					__le16 status_code;
1169 					u8 variable[];
1170 				} __packed ttlm_res;
1171 				struct {
1172 					u8 action_code;
1173 				} __packed ttlm_tear_down;
1174 				struct {
1175 					u8 action_code;
1176 					u8 dialog_token;
1177 					u8 variable[];
1178 				} __packed ml_reconf_req;
1179 				struct {
1180 					u8 action_code;
1181 					u8 dialog_token;
1182 					u8 count;
1183 					u8 variable[];
1184 				} __packed ml_reconf_resp;
1185 				struct {
1186 					u8 action_code;
1187 					u8 variable[];
1188 				} __packed epcs;
1189 				struct {
1190 					u8 action_code;
1191 					u8 dialog_token;
1192 					u8 control;
1193 					u8 variable[];
1194 				} __packed eml_omn;
1195 			} u;
1196 		} __packed action;
1197 		DECLARE_FLEX_ARRAY(u8, body); /* Generic frame body */
1198 	} u;
1199 } __packed __aligned(2);
1200 
1201 /* Supported rates membership selectors */
1202 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY	127
1203 #define BSS_MEMBERSHIP_SELECTOR_VHT_PHY	126
1204 #define BSS_MEMBERSHIP_SELECTOR_GLK	125
1205 #define BSS_MEMBERSHIP_SELECTOR_EPD	124
1206 #define BSS_MEMBERSHIP_SELECTOR_SAE_H2E 123
1207 #define BSS_MEMBERSHIP_SELECTOR_HE_PHY	122
1208 #define BSS_MEMBERSHIP_SELECTOR_EHT_PHY	121
1209 #define BSS_MEMBERSHIP_SELECTOR_UHR_PHY	120
1210 
1211 #define BSS_MEMBERSHIP_SELECTOR_MIN	BSS_MEMBERSHIP_SELECTOR_UHR_PHY
1212 
1213 /* mgmt header + 1 byte category code */
1214 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
1215 
1216 
1217 /* Management MIC information element (IEEE 802.11w) for CMAC */
1218 struct ieee80211_mmie {
1219 	u8 element_id;
1220 	u8 length;
1221 	__le16 key_id;
1222 	u8 sequence_number[6];
1223 	u8 mic[8];
1224 } __packed;
1225 
1226 /* Management MIC information element (IEEE 802.11w) for GMAC and CMAC-256 */
1227 struct ieee80211_mmie_16 {
1228 	u8 element_id;
1229 	u8 length;
1230 	__le16 key_id;
1231 	u8 sequence_number[6];
1232 	u8 mic[16];
1233 } __packed;
1234 
1235 /* Management MIC information element (IEEE 802.11w) for all variants */
1236 struct ieee80211_mmie_var {
1237 	u8 element_id;
1238 	u8 length;
1239 	__le16 key_id;
1240 	u8 sequence_number[6];
1241 	u8 mic[]; /* 8 or 16 bytes */
1242 } __packed;
1243 
1244 struct ieee80211_vendor_ie {
1245 	u8 element_id;
1246 	u8 len;
1247 	u8 oui[3];
1248 	u8 oui_type;
1249 } __packed;
1250 
1251 struct ieee80211_wmm_ac_param {
1252 	u8 aci_aifsn; /* AIFSN, ACM, ACI */
1253 	u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
1254 	__le16 txop_limit;
1255 } __packed;
1256 
1257 struct ieee80211_wmm_param_ie {
1258 	u8 element_id; /* Element ID: 221 (0xdd); */
1259 	u8 len; /* Length: 24 */
1260 	/* required fields for WMM version 1 */
1261 	u8 oui[3]; /* 00:50:f2 */
1262 	u8 oui_type; /* 2 */
1263 	u8 oui_subtype; /* 1 */
1264 	u8 version; /* 1 for WMM version 1.0 */
1265 	u8 qos_info; /* AP/STA specific QoS info */
1266 	u8 reserved; /* 0 */
1267 	/* AC_BE, AC_BK, AC_VI, AC_VO */
1268 	struct ieee80211_wmm_ac_param ac[4];
1269 } __packed;
1270 
1271 /* Control frames */
1272 struct ieee80211_rts {
1273 	__le16 frame_control;
1274 	__le16 duration;
1275 	u8 ra[ETH_ALEN];
1276 	u8 ta[ETH_ALEN];
1277 } __packed __aligned(2);
1278 
1279 struct ieee80211_cts {
1280 	__le16 frame_control;
1281 	__le16 duration;
1282 	u8 ra[ETH_ALEN];
1283 } __packed __aligned(2);
1284 
1285 struct ieee80211_pspoll {
1286 	__le16 frame_control;
1287 	__le16 aid;
1288 	u8 bssid[ETH_ALEN];
1289 	u8 ta[ETH_ALEN];
1290 } __packed __aligned(2);
1291 
1292 /* TDLS */
1293 
1294 /* Channel switch timing */
1295 struct ieee80211_ch_switch_timing {
1296 	__le16 switch_time;
1297 	__le16 switch_timeout;
1298 } __packed;
1299 
1300 /* Link-id information element */
1301 struct ieee80211_tdls_lnkie {
1302 	u8 ie_type; /* Link Identifier IE */
1303 	u8 ie_len;
1304 	u8 bssid[ETH_ALEN];
1305 	u8 init_sta[ETH_ALEN];
1306 	u8 resp_sta[ETH_ALEN];
1307 } __packed;
1308 
1309 struct ieee80211_tdls_data {
1310 	u8 da[ETH_ALEN];
1311 	u8 sa[ETH_ALEN];
1312 	__be16 ether_type;
1313 	u8 payload_type;
1314 	u8 category;
1315 	u8 action_code;
1316 	union {
1317 		struct {
1318 			u8 dialog_token;
1319 			__le16 capability;
1320 			u8 variable[];
1321 		} __packed setup_req;
1322 		struct {
1323 			__le16 status_code;
1324 			u8 dialog_token;
1325 			__le16 capability;
1326 			u8 variable[];
1327 		} __packed setup_resp;
1328 		struct {
1329 			__le16 status_code;
1330 			u8 dialog_token;
1331 			u8 variable[];
1332 		} __packed setup_cfm;
1333 		struct {
1334 			__le16 reason_code;
1335 			u8 variable[];
1336 		} __packed teardown;
1337 		struct {
1338 			u8 dialog_token;
1339 			u8 variable[];
1340 		} __packed discover_req;
1341 		struct {
1342 			u8 target_channel;
1343 			u8 oper_class;
1344 			u8 variable[];
1345 		} __packed chan_switch_req;
1346 		struct {
1347 			__le16 status_code;
1348 			u8 variable[];
1349 		} __packed chan_switch_resp;
1350 	} u;
1351 } __packed;
1352 
1353 /* Authentication algorithms */
1354 #define WLAN_AUTH_OPEN 0
1355 #define WLAN_AUTH_SHARED_KEY 1
1356 #define WLAN_AUTH_FT 2
1357 #define WLAN_AUTH_SAE 3
1358 #define WLAN_AUTH_FILS_SK 4
1359 #define WLAN_AUTH_FILS_SK_PFS 5
1360 #define WLAN_AUTH_FILS_PK 6
1361 #define WLAN_AUTH_EPPKE 9
1362 #define WLAN_AUTH_LEAP 128
1363 
1364 #define WLAN_AUTH_CHALLENGE_LEN 128
1365 
1366 #define WLAN_CAPABILITY_ESS		(1<<0)
1367 #define WLAN_CAPABILITY_IBSS		(1<<1)
1368 
1369 /*
1370  * A mesh STA sets the ESS and IBSS capability bits to zero.
1371  * however, this holds true for p2p probe responses (in the p2p_find
1372  * phase) as well.
1373  */
1374 #define WLAN_CAPABILITY_IS_STA_BSS(cap)	\
1375 	(!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
1376 
1377 #define WLAN_CAPABILITY_CF_POLLABLE	(1<<2)
1378 #define WLAN_CAPABILITY_CF_POLL_REQUEST	(1<<3)
1379 #define WLAN_CAPABILITY_PRIVACY		(1<<4)
1380 #define WLAN_CAPABILITY_SHORT_PREAMBLE	(1<<5)
1381 #define WLAN_CAPABILITY_PBCC		(1<<6)
1382 #define WLAN_CAPABILITY_CHANNEL_AGILITY	(1<<7)
1383 
1384 /* 802.11h */
1385 #define WLAN_CAPABILITY_SPECTRUM_MGMT	(1<<8)
1386 #define WLAN_CAPABILITY_QOS		(1<<9)
1387 #define WLAN_CAPABILITY_SHORT_SLOT_TIME	(1<<10)
1388 #define WLAN_CAPABILITY_APSD		(1<<11)
1389 #define WLAN_CAPABILITY_RADIO_MEASURE	(1<<12)
1390 #define WLAN_CAPABILITY_DSSS_OFDM	(1<<13)
1391 #define WLAN_CAPABILITY_DEL_BACK	(1<<14)
1392 #define WLAN_CAPABILITY_IMM_BACK	(1<<15)
1393 
1394 /* DMG (60gHz) 802.11ad */
1395 /* type - bits 0..1 */
1396 #define WLAN_CAPABILITY_DMG_TYPE_MASK		(3<<0)
1397 #define WLAN_CAPABILITY_DMG_TYPE_IBSS		(1<<0) /* Tx by: STA */
1398 #define WLAN_CAPABILITY_DMG_TYPE_PBSS		(2<<0) /* Tx by: PCP */
1399 #define WLAN_CAPABILITY_DMG_TYPE_AP		(3<<0) /* Tx by: AP */
1400 
1401 #define WLAN_CAPABILITY_DMG_CBAP_ONLY		(1<<2)
1402 #define WLAN_CAPABILITY_DMG_CBAP_SOURCE		(1<<3)
1403 #define WLAN_CAPABILITY_DMG_PRIVACY		(1<<4)
1404 #define WLAN_CAPABILITY_DMG_ECPAC		(1<<5)
1405 
1406 #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT	(1<<8)
1407 #define WLAN_CAPABILITY_DMG_RADIO_MEASURE	(1<<12)
1408 
1409 /* measurement */
1410 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE	(1<<0)
1411 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE	(1<<1)
1412 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED	(1<<2)
1413 
1414 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC	0
1415 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA	1
1416 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI	2
1417 #define IEEE80211_SPCT_MSR_RPRT_TYPE_LCI	8
1418 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC	11
1419 
1420 /* 802.11g ERP information element */
1421 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
1422 #define WLAN_ERP_USE_PROTECTION (1<<1)
1423 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
1424 
1425 /* WLAN_ERP_BARKER_PREAMBLE values */
1426 enum {
1427 	WLAN_ERP_PREAMBLE_SHORT = 0,
1428 	WLAN_ERP_PREAMBLE_LONG = 1,
1429 };
1430 
1431 /* Band ID, 802.11ad #8.4.1.45 */
1432 enum {
1433 	IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
1434 	IEEE80211_BANDID_SUB1  = 1, /* Sub-1 GHz (excluding TV white spaces) */
1435 	IEEE80211_BANDID_2G    = 2, /* 2.4 GHz */
1436 	IEEE80211_BANDID_3G    = 3, /* 3.6 GHz */
1437 	IEEE80211_BANDID_5G    = 4, /* 4.9 and 5 GHz */
1438 	IEEE80211_BANDID_60G   = 5, /* 60 GHz */
1439 };
1440 
1441 /* Status codes */
1442 enum ieee80211_statuscode {
1443 	WLAN_STATUS_SUCCESS = 0,
1444 	WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
1445 	WLAN_STATUS_CAPS_UNSUPPORTED = 10,
1446 	WLAN_STATUS_REASSOC_NO_ASSOC = 11,
1447 	WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
1448 	WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
1449 	WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
1450 	WLAN_STATUS_CHALLENGE_FAIL = 15,
1451 	WLAN_STATUS_AUTH_TIMEOUT = 16,
1452 	WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
1453 	WLAN_STATUS_ASSOC_DENIED_RATES = 18,
1454 	/* 802.11b */
1455 	WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
1456 	WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
1457 	WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
1458 	/* 802.11h */
1459 	WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
1460 	WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
1461 	WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
1462 	/* 802.11g */
1463 	WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
1464 	WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
1465 	/* 802.11w */
1466 	WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
1467 	WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
1468 	/* 802.11i */
1469 	WLAN_STATUS_INVALID_IE = 40,
1470 	WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
1471 	WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
1472 	WLAN_STATUS_INVALID_AKMP = 43,
1473 	WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
1474 	WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
1475 	WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
1476 	/* 802.11e */
1477 	WLAN_STATUS_UNSPECIFIED_QOS = 32,
1478 	WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
1479 	WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
1480 	WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
1481 	WLAN_STATUS_REQUEST_DECLINED = 37,
1482 	WLAN_STATUS_INVALID_QOS_PARAM = 38,
1483 	WLAN_STATUS_CHANGE_TSPEC = 39,
1484 	WLAN_STATUS_WAIT_TS_DELAY = 47,
1485 	WLAN_STATUS_NO_DIRECT_LINK = 48,
1486 	WLAN_STATUS_STA_NOT_PRESENT = 49,
1487 	WLAN_STATUS_STA_NOT_QSTA = 50,
1488 	/* 802.11s */
1489 	WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
1490 	WLAN_STATUS_FCG_NOT_SUPP = 78,
1491 	WLAN_STATUS_STA_NO_TBTT = 78,
1492 	/* 802.11ad */
1493 	WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39,
1494 	WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47,
1495 	WLAN_STATUS_REJECT_WITH_SCHEDULE = 83,
1496 	WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86,
1497 	WLAN_STATUS_PERFORMING_FST_NOW = 87,
1498 	WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88,
1499 	WLAN_STATUS_REJECT_U_PID_SETTING = 89,
1500 	WLAN_STATUS_REJECT_DSE_BAND = 96,
1501 	WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99,
1502 	WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103,
1503 	/* 802.11ai */
1504 	WLAN_STATUS_FILS_AUTHENTICATION_FAILURE = 112,
1505 	WLAN_STATUS_UNKNOWN_AUTHENTICATION_SERVER = 113,
1506 	WLAN_STATUS_SAE_HASH_TO_ELEMENT = 126,
1507 	WLAN_STATUS_SAE_PK = 127,
1508 	WLAN_STATUS_DENIED_TID_TO_LINK_MAPPING = 133,
1509 	WLAN_STATUS_PREF_TID_TO_LINK_MAPPING_SUGGESTED = 134,
1510 };
1511 
1512 
1513 /* Reason codes */
1514 enum ieee80211_reasoncode {
1515 	WLAN_REASON_UNSPECIFIED = 1,
1516 	WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
1517 	WLAN_REASON_DEAUTH_LEAVING = 3,
1518 	WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
1519 	WLAN_REASON_DISASSOC_AP_BUSY = 5,
1520 	WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
1521 	WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
1522 	WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
1523 	WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
1524 	/* 802.11h */
1525 	WLAN_REASON_DISASSOC_BAD_POWER = 10,
1526 	WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
1527 	/* 802.11i */
1528 	WLAN_REASON_INVALID_IE = 13,
1529 	WLAN_REASON_MIC_FAILURE = 14,
1530 	WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
1531 	WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
1532 	WLAN_REASON_IE_DIFFERENT = 17,
1533 	WLAN_REASON_INVALID_GROUP_CIPHER = 18,
1534 	WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
1535 	WLAN_REASON_INVALID_AKMP = 20,
1536 	WLAN_REASON_UNSUPP_RSN_VERSION = 21,
1537 	WLAN_REASON_INVALID_RSN_IE_CAP = 22,
1538 	WLAN_REASON_IEEE8021X_FAILED = 23,
1539 	WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
1540 	/* TDLS (802.11z) */
1541 	WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25,
1542 	WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26,
1543 	/* 802.11e */
1544 	WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
1545 	WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
1546 	WLAN_REASON_DISASSOC_LOW_ACK = 34,
1547 	WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
1548 	WLAN_REASON_QSTA_LEAVE_QBSS = 36,
1549 	WLAN_REASON_QSTA_NOT_USE = 37,
1550 	WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
1551 	WLAN_REASON_QSTA_TIMEOUT = 39,
1552 	WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
1553 	/* 802.11s */
1554 	WLAN_REASON_MESH_PEER_CANCELED = 52,
1555 	WLAN_REASON_MESH_MAX_PEERS = 53,
1556 	WLAN_REASON_MESH_CONFIG = 54,
1557 	WLAN_REASON_MESH_CLOSE = 55,
1558 	WLAN_REASON_MESH_MAX_RETRIES = 56,
1559 	WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
1560 	WLAN_REASON_MESH_INVALID_GTK = 58,
1561 	WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
1562 	WLAN_REASON_MESH_INVALID_SECURITY = 60,
1563 	WLAN_REASON_MESH_PATH_ERROR = 61,
1564 	WLAN_REASON_MESH_PATH_NOFORWARD = 62,
1565 	WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
1566 	WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
1567 	WLAN_REASON_MESH_CHAN_REGULATORY = 65,
1568 	WLAN_REASON_MESH_CHAN = 66,
1569 };
1570 
1571 
1572 /* Information Element IDs */
1573 enum ieee80211_eid {
1574 	WLAN_EID_SSID = 0,
1575 	WLAN_EID_SUPP_RATES = 1,
1576 	WLAN_EID_FH_PARAMS = 2, /* reserved now */
1577 	WLAN_EID_DS_PARAMS = 3,
1578 	WLAN_EID_CF_PARAMS = 4,
1579 	WLAN_EID_TIM = 5,
1580 	WLAN_EID_IBSS_PARAMS = 6,
1581 	WLAN_EID_COUNTRY = 7,
1582 	/* 8, 9 reserved */
1583 	WLAN_EID_REQUEST = 10,
1584 	WLAN_EID_QBSS_LOAD = 11,
1585 	WLAN_EID_EDCA_PARAM_SET = 12,
1586 	WLAN_EID_TSPEC = 13,
1587 	WLAN_EID_TCLAS = 14,
1588 	WLAN_EID_SCHEDULE = 15,
1589 	WLAN_EID_CHALLENGE = 16,
1590 	/* 17-31 reserved for challenge text extension */
1591 	WLAN_EID_PWR_CONSTRAINT = 32,
1592 	WLAN_EID_PWR_CAPABILITY = 33,
1593 	WLAN_EID_TPC_REQUEST = 34,
1594 	WLAN_EID_TPC_REPORT = 35,
1595 	WLAN_EID_SUPPORTED_CHANNELS = 36,
1596 	WLAN_EID_CHANNEL_SWITCH = 37,
1597 	WLAN_EID_MEASURE_REQUEST = 38,
1598 	WLAN_EID_MEASURE_REPORT = 39,
1599 	WLAN_EID_QUIET = 40,
1600 	WLAN_EID_IBSS_DFS = 41,
1601 	WLAN_EID_ERP_INFO = 42,
1602 	WLAN_EID_TS_DELAY = 43,
1603 	WLAN_EID_TCLAS_PROCESSING = 44,
1604 	WLAN_EID_HT_CAPABILITY = 45,
1605 	WLAN_EID_QOS_CAPA = 46,
1606 	/* 47 reserved for Broadcom */
1607 	WLAN_EID_RSN = 48,
1608 	WLAN_EID_802_15_COEX = 49,
1609 	WLAN_EID_EXT_SUPP_RATES = 50,
1610 	WLAN_EID_AP_CHAN_REPORT = 51,
1611 	WLAN_EID_NEIGHBOR_REPORT = 52,
1612 	WLAN_EID_RCPI = 53,
1613 	WLAN_EID_MOBILITY_DOMAIN = 54,
1614 	WLAN_EID_FAST_BSS_TRANSITION = 55,
1615 	WLAN_EID_TIMEOUT_INTERVAL = 56,
1616 	WLAN_EID_RIC_DATA = 57,
1617 	WLAN_EID_DSE_REGISTERED_LOCATION = 58,
1618 	WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
1619 	WLAN_EID_EXT_CHANSWITCH_ANN = 60,
1620 	WLAN_EID_HT_OPERATION = 61,
1621 	WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
1622 	WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
1623 	WLAN_EID_ANTENNA_INFO = 64,
1624 	WLAN_EID_RSNI = 65,
1625 	WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
1626 	WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
1627 	WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
1628 	WLAN_EID_TIME_ADVERTISEMENT = 69,
1629 	WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
1630 	WLAN_EID_MULTIPLE_BSSID = 71,
1631 	WLAN_EID_BSS_COEX_2040 = 72,
1632 	WLAN_EID_BSS_INTOLERANT_CHL_REPORT = 73,
1633 	WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
1634 	WLAN_EID_RIC_DESCRIPTOR = 75,
1635 	WLAN_EID_MMIE = 76,
1636 	WLAN_EID_ASSOC_COMEBACK_TIME = 77,
1637 	WLAN_EID_EVENT_REQUEST = 78,
1638 	WLAN_EID_EVENT_REPORT = 79,
1639 	WLAN_EID_DIAGNOSTIC_REQUEST = 80,
1640 	WLAN_EID_DIAGNOSTIC_REPORT = 81,
1641 	WLAN_EID_LOCATION_PARAMS = 82,
1642 	WLAN_EID_NON_TX_BSSID_CAP =  83,
1643 	WLAN_EID_SSID_LIST = 84,
1644 	WLAN_EID_MULTI_BSSID_IDX = 85,
1645 	WLAN_EID_FMS_DESCRIPTOR = 86,
1646 	WLAN_EID_FMS_REQUEST = 87,
1647 	WLAN_EID_FMS_RESPONSE = 88,
1648 	WLAN_EID_QOS_TRAFFIC_CAPA = 89,
1649 	WLAN_EID_BSS_MAX_IDLE_PERIOD = 90,
1650 	WLAN_EID_TSF_REQUEST = 91,
1651 	WLAN_EID_TSF_RESPOSNE = 92,
1652 	WLAN_EID_WNM_SLEEP_MODE = 93,
1653 	WLAN_EID_TIM_BCAST_REQ = 94,
1654 	WLAN_EID_TIM_BCAST_RESP = 95,
1655 	WLAN_EID_COLL_IF_REPORT = 96,
1656 	WLAN_EID_CHANNEL_USAGE = 97,
1657 	WLAN_EID_TIME_ZONE = 98,
1658 	WLAN_EID_DMS_REQUEST = 99,
1659 	WLAN_EID_DMS_RESPONSE = 100,
1660 	WLAN_EID_LINK_ID = 101,
1661 	WLAN_EID_WAKEUP_SCHEDUL = 102,
1662 	/* 103 reserved */
1663 	WLAN_EID_CHAN_SWITCH_TIMING = 104,
1664 	WLAN_EID_PTI_CONTROL = 105,
1665 	WLAN_EID_PU_BUFFER_STATUS = 106,
1666 	WLAN_EID_INTERWORKING = 107,
1667 	WLAN_EID_ADVERTISEMENT_PROTOCOL = 108,
1668 	WLAN_EID_EXPEDITED_BW_REQ = 109,
1669 	WLAN_EID_QOS_MAP_SET = 110,
1670 	WLAN_EID_ROAMING_CONSORTIUM = 111,
1671 	WLAN_EID_EMERGENCY_ALERT = 112,
1672 	WLAN_EID_MESH_CONFIG = 113,
1673 	WLAN_EID_MESH_ID = 114,
1674 	WLAN_EID_LINK_METRIC_REPORT = 115,
1675 	WLAN_EID_CONGESTION_NOTIFICATION = 116,
1676 	WLAN_EID_PEER_MGMT = 117,
1677 	WLAN_EID_CHAN_SWITCH_PARAM = 118,
1678 	WLAN_EID_MESH_AWAKE_WINDOW = 119,
1679 	WLAN_EID_BEACON_TIMING = 120,
1680 	WLAN_EID_MCCAOP_SETUP_REQ = 121,
1681 	WLAN_EID_MCCAOP_SETUP_RESP = 122,
1682 	WLAN_EID_MCCAOP_ADVERT = 123,
1683 	WLAN_EID_MCCAOP_TEARDOWN = 124,
1684 	WLAN_EID_GANN = 125,
1685 	WLAN_EID_RANN = 126,
1686 	WLAN_EID_EXT_CAPABILITY = 127,
1687 	/* 128, 129 reserved for Agere */
1688 	WLAN_EID_PREQ = 130,
1689 	WLAN_EID_PREP = 131,
1690 	WLAN_EID_PERR = 132,
1691 	/* 133-136 reserved for Cisco */
1692 	WLAN_EID_PXU = 137,
1693 	WLAN_EID_PXUC = 138,
1694 	WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
1695 	WLAN_EID_MIC = 140,
1696 	WLAN_EID_DESTINATION_URI = 141,
1697 	WLAN_EID_UAPSD_COEX = 142,
1698 	WLAN_EID_WAKEUP_SCHEDULE = 143,
1699 	WLAN_EID_EXT_SCHEDULE = 144,
1700 	WLAN_EID_STA_AVAILABILITY = 145,
1701 	WLAN_EID_DMG_TSPEC = 146,
1702 	WLAN_EID_DMG_AT = 147,
1703 	WLAN_EID_DMG_CAP = 148,
1704 	/* 149 reserved for Cisco */
1705 	WLAN_EID_CISCO_VENDOR_SPECIFIC = 150,
1706 	WLAN_EID_DMG_OPERATION = 151,
1707 	WLAN_EID_DMG_BSS_PARAM_CHANGE = 152,
1708 	WLAN_EID_DMG_BEAM_REFINEMENT = 153,
1709 	WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154,
1710 	/* 155-156 reserved for Cisco */
1711 	WLAN_EID_AWAKE_WINDOW = 157,
1712 	WLAN_EID_MULTI_BAND = 158,
1713 	WLAN_EID_ADDBA_EXT = 159,
1714 	WLAN_EID_NEXT_PCP_LIST = 160,
1715 	WLAN_EID_PCP_HANDOVER = 161,
1716 	WLAN_EID_DMG_LINK_MARGIN = 162,
1717 	WLAN_EID_SWITCHING_STREAM = 163,
1718 	WLAN_EID_SESSION_TRANSITION = 164,
1719 	WLAN_EID_DYN_TONE_PAIRING_REPORT = 165,
1720 	WLAN_EID_CLUSTER_REPORT = 166,
1721 	WLAN_EID_RELAY_CAP = 167,
1722 	WLAN_EID_RELAY_XFER_PARAM_SET = 168,
1723 	WLAN_EID_BEAM_LINK_MAINT = 169,
1724 	WLAN_EID_MULTIPLE_MAC_ADDR = 170,
1725 	WLAN_EID_U_PID = 171,
1726 	WLAN_EID_DMG_LINK_ADAPT_ACK = 172,
1727 	/* 173 reserved for Symbol */
1728 	WLAN_EID_MCCAOP_ADV_OVERVIEW = 174,
1729 	WLAN_EID_QUIET_PERIOD_REQ = 175,
1730 	/* 176 reserved for Symbol */
1731 	WLAN_EID_QUIET_PERIOD_RESP = 177,
1732 	/* 178-179 reserved for Symbol */
1733 	/* 180 reserved for ISO/IEC 20011 */
1734 	WLAN_EID_EPAC_POLICY = 182,
1735 	WLAN_EID_CLISTER_TIME_OFF = 183,
1736 	WLAN_EID_INTER_AC_PRIO = 184,
1737 	WLAN_EID_SCS_DESCRIPTOR = 185,
1738 	WLAN_EID_QLOAD_REPORT = 186,
1739 	WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187,
1740 	WLAN_EID_HL_STREAM_ID = 188,
1741 	WLAN_EID_GCR_GROUP_ADDR = 189,
1742 	WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190,
1743 	WLAN_EID_VHT_CAPABILITY = 191,
1744 	WLAN_EID_VHT_OPERATION = 192,
1745 	WLAN_EID_EXTENDED_BSS_LOAD = 193,
1746 	WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
1747 	WLAN_EID_TX_POWER_ENVELOPE = 195,
1748 	WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
1749 	WLAN_EID_AID = 197,
1750 	WLAN_EID_QUIET_CHANNEL = 198,
1751 	WLAN_EID_OPMODE_NOTIF = 199,
1752 
1753 	WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201,
1754 
1755 	WLAN_EID_AID_REQUEST = 210,
1756 	WLAN_EID_AID_RESPONSE = 211,
1757 	WLAN_EID_S1G_BCN_COMPAT = 213,
1758 	WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214,
1759 	WLAN_EID_S1G_TWT = 216,
1760 	WLAN_EID_S1G_CAPABILITIES = 217,
1761 	WLAN_EID_VENDOR_SPECIFIC = 221,
1762 	WLAN_EID_QOS_PARAMETER = 222,
1763 	WLAN_EID_S1G_OPERATION = 232,
1764 	WLAN_EID_CAG_NUMBER = 237,
1765 	WLAN_EID_AP_CSN = 239,
1766 	WLAN_EID_FILS_INDICATION = 240,
1767 	WLAN_EID_DILS = 241,
1768 	WLAN_EID_FRAGMENT = 242,
1769 	WLAN_EID_RSNX = 244,
1770 	WLAN_EID_EXTENSION = 255
1771 };
1772 
1773 /* Element ID Extensions for Element ID 255 */
1774 enum ieee80211_eid_ext {
1775 	WLAN_EID_EXT_ASSOC_DELAY_INFO = 1,
1776 	WLAN_EID_EXT_FILS_REQ_PARAMS = 2,
1777 	WLAN_EID_EXT_FILS_KEY_CONFIRM = 3,
1778 	WLAN_EID_EXT_FILS_SESSION = 4,
1779 	WLAN_EID_EXT_FILS_HLP_CONTAINER = 5,
1780 	WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN = 6,
1781 	WLAN_EID_EXT_KEY_DELIVERY = 7,
1782 	WLAN_EID_EXT_FILS_WRAPPED_DATA = 8,
1783 	WLAN_EID_EXT_FILS_PUBLIC_KEY = 12,
1784 	WLAN_EID_EXT_FILS_NONCE = 13,
1785 	WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE = 14,
1786 	WLAN_EID_EXT_DH_PARAMETER = 32,
1787 	WLAN_EID_EXT_HE_CAPABILITY = 35,
1788 	WLAN_EID_EXT_HE_OPERATION = 36,
1789 	WLAN_EID_EXT_UORA = 37,
1790 	WLAN_EID_EXT_HE_MU_EDCA = 38,
1791 	WLAN_EID_EXT_HE_SPR = 39,
1792 	WLAN_EID_EXT_NDP_FEEDBACK_REPORT_PARAMSET = 41,
1793 	WLAN_EID_EXT_BSS_COLOR_CHG_ANN = 42,
1794 	WLAN_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43,
1795 	WLAN_EID_EXT_ESS_REPORT = 45,
1796 	WLAN_EID_EXT_OPS = 46,
1797 	WLAN_EID_EXT_HE_BSS_LOAD = 47,
1798 	WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52,
1799 	WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55,
1800 	WLAN_EID_EXT_NON_INHERITANCE = 56,
1801 	WLAN_EID_EXT_KNOWN_BSSID = 57,
1802 	WLAN_EID_EXT_SHORT_SSID_LIST = 58,
1803 	WLAN_EID_EXT_HE_6GHZ_CAPA = 59,
1804 	WLAN_EID_EXT_UL_MU_POWER_CAPA = 60,
1805 	WLAN_EID_EXT_EHT_OPERATION = 106,
1806 	WLAN_EID_EXT_EHT_MULTI_LINK = 107,
1807 	WLAN_EID_EXT_EHT_CAPABILITY = 108,
1808 	WLAN_EID_EXT_TID_TO_LINK_MAPPING = 109,
1809 	WLAN_EID_EXT_BANDWIDTH_INDICATION = 135,
1810 	WLAN_EID_EXT_KNOWN_STA_IDENTIFCATION = 136,
1811 	WLAN_EID_EXT_NON_AP_STA_REG_CON = 137,
1812 	WLAN_EID_EXT_UHR_OPER = 151,
1813 	WLAN_EID_EXT_UHR_CAPA = 152,
1814 	WLAN_EID_EXT_MACP = 153,
1815 	WLAN_EID_EXT_SMD = 154,
1816 	WLAN_EID_EXT_BSS_SMD_TRANS_PARAMS = 155,
1817 	WLAN_EID_EXT_CHAN_USAGE = 156,
1818 	WLAN_EID_EXT_UHR_MODE_CHG = 157,
1819 	WLAN_EID_EXT_UHR_PARAM_UPD = 158,
1820 	WLAN_EID_EXT_TXPI = 159,
1821 };
1822 
1823 /* Action category code */
1824 enum ieee80211_category {
1825 	WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1826 	WLAN_CATEGORY_QOS = 1,
1827 	WLAN_CATEGORY_DLS = 2,
1828 	WLAN_CATEGORY_BACK = 3,
1829 	WLAN_CATEGORY_PUBLIC = 4,
1830 	WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
1831 	WLAN_CATEGORY_FAST_BBS_TRANSITION = 6,
1832 	WLAN_CATEGORY_HT = 7,
1833 	WLAN_CATEGORY_SA_QUERY = 8,
1834 	WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
1835 	WLAN_CATEGORY_WNM = 10,
1836 	WLAN_CATEGORY_WNM_UNPROTECTED = 11,
1837 	WLAN_CATEGORY_TDLS = 12,
1838 	WLAN_CATEGORY_MESH_ACTION = 13,
1839 	WLAN_CATEGORY_MULTIHOP_ACTION = 14,
1840 	WLAN_CATEGORY_SELF_PROTECTED = 15,
1841 	WLAN_CATEGORY_DMG = 16,
1842 	WLAN_CATEGORY_WMM = 17,
1843 	WLAN_CATEGORY_FST = 18,
1844 	WLAN_CATEGORY_UNPROT_DMG = 20,
1845 	WLAN_CATEGORY_VHT = 21,
1846 	WLAN_CATEGORY_S1G = 22,
1847 	WLAN_CATEGORY_PROTECTED_EHT = 37,
1848 	WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
1849 	WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
1850 };
1851 
1852 /* SPECTRUM_MGMT action code */
1853 enum ieee80211_spectrum_mgmt_actioncode {
1854 	WLAN_ACTION_SPCT_MSR_REQ = 0,
1855 	WLAN_ACTION_SPCT_MSR_RPRT = 1,
1856 	WLAN_ACTION_SPCT_TPC_REQ = 2,
1857 	WLAN_ACTION_SPCT_TPC_RPRT = 3,
1858 	WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1859 };
1860 
1861 /* Self Protected Action codes */
1862 enum ieee80211_self_protected_actioncode {
1863 	WLAN_SP_RESERVED = 0,
1864 	WLAN_SP_MESH_PEERING_OPEN = 1,
1865 	WLAN_SP_MESH_PEERING_CONFIRM = 2,
1866 	WLAN_SP_MESH_PEERING_CLOSE = 3,
1867 	WLAN_SP_MGK_INFORM = 4,
1868 	WLAN_SP_MGK_ACK = 5,
1869 };
1870 
1871 /* Unprotected WNM action codes */
1872 enum ieee80211_unprotected_wnm_actioncode {
1873 	WLAN_UNPROTECTED_WNM_ACTION_TIM = 0,
1874 	WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE = 1,
1875 };
1876 
1877 /* Security key length */
1878 enum ieee80211_key_len {
1879 	WLAN_KEY_LEN_WEP40 = 5,
1880 	WLAN_KEY_LEN_WEP104 = 13,
1881 	WLAN_KEY_LEN_CCMP = 16,
1882 	WLAN_KEY_LEN_CCMP_256 = 32,
1883 	WLAN_KEY_LEN_TKIP = 32,
1884 	WLAN_KEY_LEN_AES_CMAC = 16,
1885 	WLAN_KEY_LEN_SMS4 = 32,
1886 	WLAN_KEY_LEN_GCMP = 16,
1887 	WLAN_KEY_LEN_GCMP_256 = 32,
1888 	WLAN_KEY_LEN_BIP_CMAC_256 = 32,
1889 	WLAN_KEY_LEN_BIP_GMAC_128 = 16,
1890 	WLAN_KEY_LEN_BIP_GMAC_256 = 32,
1891 };
1892 
1893 /* Radio measurement action codes as defined in IEEE 802.11-2024 - Table 9-470 */
1894 enum ieee80211_radio_measurement_actioncode {
1895 	WLAN_RM_ACTION_RADIO_MEASUREMENT_REQUEST = 0,
1896 	WLAN_RM_ACTION_RADIO_MEASUREMENT_REPORT  = 1,
1897 	WLAN_RM_ACTION_LINK_MEASUREMENT_REQUEST  = 2,
1898 	WLAN_RM_ACTION_LINK_MEASUREMENT_REPORT   = 3,
1899 	WLAN_RM_ACTION_NEIGHBOR_REPORT_REQUEST   = 4,
1900 	WLAN_RM_ACTION_NEIGHBOR_REPORT_RESPONSE  = 5,
1901 };
1902 
1903 #define IEEE80211_WEP_IV_LEN		4
1904 #define IEEE80211_WEP_ICV_LEN		4
1905 #define IEEE80211_CCMP_HDR_LEN		8
1906 #define IEEE80211_CCMP_MIC_LEN		8
1907 #define IEEE80211_CCMP_PN_LEN		6
1908 #define IEEE80211_CCMP_256_HDR_LEN	8
1909 #define IEEE80211_CCMP_256_MIC_LEN	16
1910 #define IEEE80211_CCMP_256_PN_LEN	6
1911 #define IEEE80211_TKIP_IV_LEN		8
1912 #define IEEE80211_TKIP_ICV_LEN		4
1913 #define IEEE80211_CMAC_PN_LEN		6
1914 #define IEEE80211_GMAC_PN_LEN		6
1915 #define IEEE80211_GCMP_HDR_LEN		8
1916 #define IEEE80211_GCMP_MIC_LEN		16
1917 #define IEEE80211_GCMP_PN_LEN		6
1918 #define IEEE80211_CMAC_128_MIC_LEN	8
1919 #define IEEE80211_CMAC_256_MIC_LEN	16
1920 #define IEEE80211_GMAC_MIC_LEN		16
1921 
1922 #define FILS_NONCE_LEN			16
1923 #define FILS_MAX_KEK_LEN		64
1924 
1925 #define FILS_ERP_MAX_USERNAME_LEN	16
1926 #define FILS_ERP_MAX_REALM_LEN		253
1927 #define FILS_ERP_MAX_RRK_LEN		64
1928 
1929 #define PMK_MAX_LEN			64
1930 #define SAE_PASSWORD_MAX_LEN		128
1931 
1932 /* Public action codes (IEEE Std 802.11-2016, 9.6.8.1, Table 9-307) */
1933 enum ieee80211_pub_actioncode {
1934 	WLAN_PUB_ACTION_20_40_BSS_COEX = 0,
1935 	WLAN_PUB_ACTION_DSE_ENABLEMENT = 1,
1936 	WLAN_PUB_ACTION_DSE_DEENABLEMENT = 2,
1937 	WLAN_PUB_ACTION_DSE_REG_LOC_ANN = 3,
1938 	WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
1939 	WLAN_PUB_ACTION_DSE_MSMT_REQ = 5,
1940 	WLAN_PUB_ACTION_DSE_MSMT_RESP = 6,
1941 	WLAN_PUB_ACTION_MSMT_PILOT = 7,
1942 	WLAN_PUB_ACTION_DSE_PC = 8,
1943 	WLAN_PUB_ACTION_VENDOR_SPECIFIC = 9,
1944 	WLAN_PUB_ACTION_GAS_INITIAL_REQ = 10,
1945 	WLAN_PUB_ACTION_GAS_INITIAL_RESP = 11,
1946 	WLAN_PUB_ACTION_GAS_COMEBACK_REQ = 12,
1947 	WLAN_PUB_ACTION_GAS_COMEBACK_RESP = 13,
1948 	WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
1949 	WLAN_PUB_ACTION_LOC_TRACK_NOTI = 15,
1950 	WLAN_PUB_ACTION_QAB_REQUEST_FRAME = 16,
1951 	WLAN_PUB_ACTION_QAB_RESPONSE_FRAME = 17,
1952 	WLAN_PUB_ACTION_QMF_POLICY = 18,
1953 	WLAN_PUB_ACTION_QMF_POLICY_CHANGE = 19,
1954 	WLAN_PUB_ACTION_QLOAD_REQUEST = 20,
1955 	WLAN_PUB_ACTION_QLOAD_REPORT = 21,
1956 	WLAN_PUB_ACTION_HCCA_TXOP_ADVERT = 22,
1957 	WLAN_PUB_ACTION_HCCA_TXOP_RESPONSE = 23,
1958 	WLAN_PUB_ACTION_PUBLIC_KEY = 24,
1959 	WLAN_PUB_ACTION_CHANNEL_AVAIL_QUERY = 25,
1960 	WLAN_PUB_ACTION_CHANNEL_SCHEDULE_MGMT = 26,
1961 	WLAN_PUB_ACTION_CONTACT_VERI_SIGNAL = 27,
1962 	WLAN_PUB_ACTION_GDD_ENABLEMENT_REQ = 28,
1963 	WLAN_PUB_ACTION_GDD_ENABLEMENT_RESP = 29,
1964 	WLAN_PUB_ACTION_NETWORK_CHANNEL_CONTROL = 30,
1965 	WLAN_PUB_ACTION_WHITE_SPACE_MAP_ANN = 31,
1966 	WLAN_PUB_ACTION_FTM_REQUEST = 32,
1967 	WLAN_PUB_ACTION_FTM_RESPONSE = 33,
1968 	WLAN_PUB_ACTION_FILS_DISCOVERY = 34,
1969 };
1970 
1971 /* TDLS action codes */
1972 enum ieee80211_tdls_actioncode {
1973 	WLAN_TDLS_SETUP_REQUEST = 0,
1974 	WLAN_TDLS_SETUP_RESPONSE = 1,
1975 	WLAN_TDLS_SETUP_CONFIRM = 2,
1976 	WLAN_TDLS_TEARDOWN = 3,
1977 	WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4,
1978 	WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5,
1979 	WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6,
1980 	WLAN_TDLS_PEER_PSM_REQUEST = 7,
1981 	WLAN_TDLS_PEER_PSM_RESPONSE = 8,
1982 	WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9,
1983 	WLAN_TDLS_DISCOVERY_REQUEST = 10,
1984 };
1985 
1986 /* Extended Channel Switching capability to be set in the 1st byte of
1987  * the @WLAN_EID_EXT_CAPABILITY information element
1988  */
1989 #define WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING	BIT(2)
1990 
1991 /* Multiple BSSID capability is set in the 6th bit of 3rd byte of the
1992  * @WLAN_EID_EXT_CAPABILITY information element
1993  */
1994 #define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT	BIT(6)
1995 
1996 /* Timing Measurement protocol for time sync is set in the 7th bit of 3rd byte
1997  * of the @WLAN_EID_EXT_CAPABILITY information element
1998  */
1999 #define WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT	BIT(7)
2000 
2001 /* TDLS capabilities in the 4th byte of @WLAN_EID_EXT_CAPABILITY */
2002 #define WLAN_EXT_CAPA4_TDLS_BUFFER_STA		BIT(4)
2003 #define WLAN_EXT_CAPA4_TDLS_PEER_PSM		BIT(5)
2004 #define WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH		BIT(6)
2005 
2006 /* Interworking capabilities are set in 7th bit of 4th byte of the
2007  * @WLAN_EID_EXT_CAPABILITY information element
2008  */
2009 #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED	BIT(7)
2010 
2011 /*
2012  * TDLS capabililites to be enabled in the 5th byte of the
2013  * @WLAN_EID_EXT_CAPABILITY information element
2014  */
2015 #define WLAN_EXT_CAPA5_TDLS_ENABLED	BIT(5)
2016 #define WLAN_EXT_CAPA5_TDLS_PROHIBITED	BIT(6)
2017 #define WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED	BIT(7)
2018 
2019 #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED	BIT(5)
2020 #define WLAN_EXT_CAPA8_OPMODE_NOTIF	BIT(6)
2021 
2022 /* Defines the maximal number of MSDUs in an A-MSDU. */
2023 #define WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB	BIT(7)
2024 #define WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB	BIT(0)
2025 
2026 /*
2027  * Fine Timing Measurement Initiator - bit 71 of @WLAN_EID_EXT_CAPABILITY
2028  * information element
2029  */
2030 #define WLAN_EXT_CAPA9_FTM_INITIATOR	BIT(7)
2031 
2032 /* Defines support for TWT Requester and TWT Responder */
2033 #define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT	BIT(5)
2034 #define WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT	BIT(6)
2035 
2036 /*
2037  * When set, indicates that the AP is able to tolerate 26-tone RU UL
2038  * OFDMA transmissions using HE TB PPDU from OBSS (not falsely classify the
2039  * 26-tone RU UL OFDMA transmissions as radar pulses).
2040  */
2041 #define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7)
2042 
2043 /* Defines support for enhanced multi-bssid advertisement*/
2044 #define WLAN_EXT_CAPA11_EMA_SUPPORT	BIT(3)
2045 
2046 /* Enable Beacon Protection */
2047 #define WLAN_EXT_CAPA11_BCN_PROTECT	BIT(4)
2048 
2049 /* TDLS specific payload type in the LLC/SNAP header */
2050 #define WLAN_TDLS_SNAP_RFTYPE	0x2
2051 
2052 /* BSS Coex IE information field bits */
2053 #define WLAN_BSS_COEX_INFORMATION_REQUEST	BIT(0)
2054 
2055 /*
2056  * IEEE 802.11-2007 7.3.2.9 Country information element
2057  *
2058  * Minimum length is 8 octets, ie len must be evenly
2059  * divisible by 2
2060  */
2061 
2062 /* Although the spec says 8 I'm seeing 6 in practice */
2063 #define IEEE80211_COUNTRY_IE_MIN_LEN	6
2064 
2065 /* The Country String field of the element shall be 3 octets in length */
2066 #define IEEE80211_COUNTRY_STRING_LEN	3
2067 
2068 /*
2069  * For regulatory extension stuff see IEEE 802.11-2007
2070  * Annex I (page 1141) and Annex J (page 1147). Also
2071  * review 7.3.2.9.
2072  *
2073  * When dot11RegulatoryClassesRequired is true and the
2074  * first_channel/reg_extension_id is >= 201 then the IE
2075  * compromises of the 'ext' struct represented below:
2076  *
2077  *  - Regulatory extension ID - when generating IE this just needs
2078  *    to be monotonically increasing for each triplet passed in
2079  *    the IE
2080  *  - Regulatory class - index into set of rules
2081  *  - Coverage class - index into air propagation time (Table 7-27),
2082  *    in microseconds, you can compute the air propagation time from
2083  *    the index by multiplying by 3, so index 10 yields a propagation
2084  *    of 10 us. Valid values are 0-31, values 32-255 are not defined
2085  *    yet. A value of 0 inicates air propagation of <= 1 us.
2086  *
2087  *  See also Table I.2 for Emission limit sets and table
2088  *  I.3 for Behavior limit sets. Table J.1 indicates how to map
2089  *  a reg_class to an emission limit set and behavior limit set.
2090  */
2091 #define IEEE80211_COUNTRY_EXTENSION_ID 201
2092 
2093 /*
2094  *  Channels numbers in the IE must be monotonically increasing
2095  *  if dot11RegulatoryClassesRequired is not true.
2096  *
2097  *  If dot11RegulatoryClassesRequired is true consecutive
2098  *  subband triplets following a regulatory triplet shall
2099  *  have monotonically increasing first_channel number fields.
2100  *
2101  *  Channel numbers shall not overlap.
2102  *
2103  *  Note that max_power is signed.
2104  */
2105 struct ieee80211_country_ie_triplet {
2106 	union {
2107 		struct {
2108 			u8 first_channel;
2109 			u8 num_channels;
2110 			s8 max_power;
2111 		} __packed chans;
2112 		struct {
2113 			u8 reg_extension_id;
2114 			u8 reg_class;
2115 			u8 coverage_class;
2116 		} __packed ext;
2117 	};
2118 } __packed;
2119 
2120 enum ieee80211_timeout_interval_type {
2121 	WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
2122 	WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
2123 	WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
2124 };
2125 
2126 /**
2127  * struct ieee80211_timeout_interval_ie - Timeout Interval element
2128  * @type: type, see &enum ieee80211_timeout_interval_type
2129  * @value: timeout interval value
2130  */
2131 struct ieee80211_timeout_interval_ie {
2132 	u8 type;
2133 	__le32 value;
2134 } __packed;
2135 
2136 /**
2137  * enum ieee80211_idle_options - BSS idle options
2138  * @WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE: the station should send an RSN
2139  *	protected frame to the AP to reset the idle timer at the AP for
2140  *	the station.
2141  */
2142 enum ieee80211_idle_options {
2143 	WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE = BIT(0),
2144 };
2145 
2146 /**
2147  * struct ieee80211_bss_max_idle_period_ie - BSS max idle period element struct
2148  *
2149  * This structure refers to "BSS Max idle period element"
2150  *
2151  * @max_idle_period: indicates the time period during which a station can
2152  *	refrain from transmitting frames to its associated AP without being
2153  *	disassociated. In units of 1000 TUs.
2154  * @idle_options: indicates the options associated with the BSS idle capability
2155  *	as specified in &enum ieee80211_idle_options.
2156  */
2157 struct ieee80211_bss_max_idle_period_ie {
2158 	__le16 max_idle_period;
2159 	u8 idle_options;
2160 } __packed;
2161 
2162 /* SA Query action */
2163 enum ieee80211_sa_query_action {
2164 	WLAN_ACTION_SA_QUERY_REQUEST = 0,
2165 	WLAN_ACTION_SA_QUERY_RESPONSE = 1,
2166 };
2167 
2168 /**
2169  * struct ieee80211_bssid_index - multiple BSSID index element structure
2170  *
2171  * This structure refers to "Multiple BSSID-index element"
2172  *
2173  * @bssid_index: BSSID index
2174  * @dtim_period: optional, overrides transmitted BSS dtim period
2175  * @dtim_count: optional, overrides transmitted BSS dtim count
2176  */
2177 struct ieee80211_bssid_index {
2178 	u8 bssid_index;
2179 	u8 dtim_period;
2180 	u8 dtim_count;
2181 };
2182 
2183 /**
2184  * struct ieee80211_multiple_bssid_configuration - multiple BSSID configuration
2185  *	element structure
2186  *
2187  * This structure refers to "Multiple BSSID Configuration element"
2188  *
2189  * @bssid_count: total number of active BSSIDs in the set
2190  * @profile_periodicity: the least number of beacon frames need to be received
2191  *	in order to discover all the nontransmitted BSSIDs in the set.
2192  */
2193 struct ieee80211_multiple_bssid_configuration {
2194 	u8 bssid_count;
2195 	u8 profile_periodicity;
2196 };
2197 
2198 #define SUITE(oui, id)	(((oui) << 8) | (id))
2199 
2200 /* cipher suite selectors */
2201 #define WLAN_CIPHER_SUITE_USE_GROUP	SUITE(0x000FAC, 0)
2202 #define WLAN_CIPHER_SUITE_WEP40		SUITE(0x000FAC, 1)
2203 #define WLAN_CIPHER_SUITE_TKIP		SUITE(0x000FAC, 2)
2204 /* reserved: 				SUITE(0x000FAC, 3) */
2205 #define WLAN_CIPHER_SUITE_CCMP		SUITE(0x000FAC, 4)
2206 #define WLAN_CIPHER_SUITE_WEP104	SUITE(0x000FAC, 5)
2207 #define WLAN_CIPHER_SUITE_AES_CMAC	SUITE(0x000FAC, 6)
2208 #define WLAN_CIPHER_SUITE_GCMP		SUITE(0x000FAC, 8)
2209 #define WLAN_CIPHER_SUITE_GCMP_256	SUITE(0x000FAC, 9)
2210 #define WLAN_CIPHER_SUITE_CCMP_256	SUITE(0x000FAC, 10)
2211 #define WLAN_CIPHER_SUITE_BIP_GMAC_128	SUITE(0x000FAC, 11)
2212 #define WLAN_CIPHER_SUITE_BIP_GMAC_256	SUITE(0x000FAC, 12)
2213 #define WLAN_CIPHER_SUITE_BIP_CMAC_256	SUITE(0x000FAC, 13)
2214 
2215 #define WLAN_CIPHER_SUITE_SMS4		SUITE(0x001472, 1)
2216 
2217 /* AKM suite selectors */
2218 #define WLAN_AKM_SUITE_8021X			SUITE(0x000FAC, 1)
2219 #define WLAN_AKM_SUITE_PSK			SUITE(0x000FAC, 2)
2220 #define WLAN_AKM_SUITE_FT_8021X			SUITE(0x000FAC, 3)
2221 #define WLAN_AKM_SUITE_FT_PSK			SUITE(0x000FAC, 4)
2222 #define WLAN_AKM_SUITE_8021X_SHA256		SUITE(0x000FAC, 5)
2223 #define WLAN_AKM_SUITE_PSK_SHA256		SUITE(0x000FAC, 6)
2224 #define WLAN_AKM_SUITE_TDLS			SUITE(0x000FAC, 7)
2225 #define WLAN_AKM_SUITE_SAE			SUITE(0x000FAC, 8)
2226 #define WLAN_AKM_SUITE_FT_OVER_SAE		SUITE(0x000FAC, 9)
2227 #define WLAN_AKM_SUITE_AP_PEER_KEY		SUITE(0x000FAC, 10)
2228 #define WLAN_AKM_SUITE_8021X_SUITE_B		SUITE(0x000FAC, 11)
2229 #define WLAN_AKM_SUITE_8021X_SUITE_B_192	SUITE(0x000FAC, 12)
2230 #define WLAN_AKM_SUITE_FT_8021X_SHA384		SUITE(0x000FAC, 13)
2231 #define WLAN_AKM_SUITE_FILS_SHA256		SUITE(0x000FAC, 14)
2232 #define WLAN_AKM_SUITE_FILS_SHA384		SUITE(0x000FAC, 15)
2233 #define WLAN_AKM_SUITE_FT_FILS_SHA256		SUITE(0x000FAC, 16)
2234 #define WLAN_AKM_SUITE_FT_FILS_SHA384		SUITE(0x000FAC, 17)
2235 #define WLAN_AKM_SUITE_OWE			SUITE(0x000FAC, 18)
2236 #define WLAN_AKM_SUITE_FT_PSK_SHA384		SUITE(0x000FAC, 19)
2237 #define WLAN_AKM_SUITE_PSK_SHA384		SUITE(0x000FAC, 20)
2238 
2239 #define WLAN_AKM_SUITE_WFA_DPP			SUITE(WLAN_OUI_WFA, 2)
2240 
2241 #define WLAN_MAX_KEY_LEN		32
2242 
2243 #define WLAN_PMK_NAME_LEN		16
2244 #define WLAN_PMKID_LEN			16
2245 #define WLAN_PMK_LEN_EAP_LEAP		16
2246 #define WLAN_PMK_LEN			32
2247 #define WLAN_PMK_LEN_SUITE_B_192	48
2248 
2249 #define WLAN_OUI_WFA			0x506f9a
2250 #define WLAN_OUI_TYPE_WFA_P2P		9
2251 #define WLAN_OUI_TYPE_WFA_DPP		0x1A
2252 #define WLAN_OUI_MICROSOFT		0x0050f2
2253 #define WLAN_OUI_TYPE_MICROSOFT_WPA	1
2254 #define WLAN_OUI_TYPE_MICROSOFT_WMM	2
2255 #define WLAN_OUI_TYPE_MICROSOFT_WPS	4
2256 #define WLAN_OUI_TYPE_MICROSOFT_TPC	8
2257 
2258 /*
2259  * WMM/802.11e Tspec Element
2260  */
2261 #define IEEE80211_WMM_IE_TSPEC_TID_MASK		0x0F
2262 #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT	1
2263 
2264 enum ieee80211_tspec_status_code {
2265 	IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
2266 	IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
2267 };
2268 
2269 struct ieee80211_tspec_ie {
2270 	u8 element_id;
2271 	u8 len;
2272 	u8 oui[3];
2273 	u8 oui_type;
2274 	u8 oui_subtype;
2275 	u8 version;
2276 	__le16 tsinfo;
2277 	u8 tsinfo_resvd;
2278 	__le16 nominal_msdu;
2279 	__le16 max_msdu;
2280 	__le32 min_service_int;
2281 	__le32 max_service_int;
2282 	__le32 inactivity_int;
2283 	__le32 suspension_int;
2284 	__le32 service_start_time;
2285 	__le32 min_data_rate;
2286 	__le32 mean_data_rate;
2287 	__le32 peak_data_rate;
2288 	__le32 max_burst_size;
2289 	__le32 delay_bound;
2290 	__le32 min_phy_rate;
2291 	__le16 sba;
2292 	__le16 medium_time;
2293 } __packed;
2294 
2295 /**
2296  * ieee80211_get_qos_ctl - get pointer to qos control bytes
2297  * @hdr: the frame
2298  * Return: a pointer to the QoS control field in the frame header
2299  *
2300  * The qos ctrl bytes come after the frame_control, duration, seq_num
2301  * and 3 or 4 addresses of length ETH_ALEN. Checks frame_control to choose
2302  * between struct ieee80211_qos_hdr_4addr and struct ieee80211_qos_hdr.
2303  */
ieee80211_get_qos_ctl(struct ieee80211_hdr * hdr)2304 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
2305 {
2306 	union {
2307 		struct ieee80211_qos_hdr	addr3;
2308 		struct ieee80211_qos_hdr_4addr	addr4;
2309 	} *qos;
2310 
2311 	qos = (void *)hdr;
2312 	if (ieee80211_has_a4(qos->addr3.frame_control))
2313 		return (u8 *)&qos->addr4.qos_ctrl;
2314 	else
2315 		return (u8 *)&qos->addr3.qos_ctrl;
2316 }
2317 
2318 /**
2319  * ieee80211_get_tid - get qos TID
2320  * @hdr: the frame
2321  * Return: the TID from the QoS control field
2322  */
ieee80211_get_tid(struct ieee80211_hdr * hdr)2323 static inline u8 ieee80211_get_tid(struct ieee80211_hdr *hdr)
2324 {
2325 	u8 *qc = ieee80211_get_qos_ctl(hdr);
2326 
2327 	return qc[0] & IEEE80211_QOS_CTL_TID_MASK;
2328 }
2329 
2330 /**
2331  * ieee80211_get_SA - get pointer to SA
2332  * @hdr: the frame
2333  * Return: a pointer to the source address (SA)
2334  *
2335  * Given an 802.11 frame, this function returns the offset
2336  * to the source address (SA). It does not verify that the
2337  * header is long enough to contain the address, and the
2338  * header must be long enough to contain the frame control
2339  * field.
2340  */
ieee80211_get_SA(struct ieee80211_hdr * hdr)2341 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
2342 {
2343 	if (ieee80211_has_a4(hdr->frame_control))
2344 		return hdr->addr4;
2345 	if (ieee80211_has_fromds(hdr->frame_control))
2346 		return hdr->addr3;
2347 	return hdr->addr2;
2348 }
2349 
2350 /**
2351  * ieee80211_get_DA - get pointer to DA
2352  * @hdr: the frame
2353  * Return: a pointer to the destination address (DA)
2354  *
2355  * Given an 802.11 frame, this function returns the offset
2356  * to the destination address (DA). It does not verify that
2357  * the header is long enough to contain the address, and the
2358  * header must be long enough to contain the frame control
2359  * field.
2360  */
ieee80211_get_DA(struct ieee80211_hdr * hdr)2361 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
2362 {
2363 	if (ieee80211_has_tods(hdr->frame_control))
2364 		return hdr->addr3;
2365 	else
2366 		return hdr->addr1;
2367 }
2368 
2369 /**
2370  * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
2371  * @skb: the skb to check, starting with the 802.11 header
2372  * Return: whether or not the MMPDU is bufferable
2373  */
ieee80211_is_bufferable_mmpdu(struct sk_buff * skb)2374 static inline bool ieee80211_is_bufferable_mmpdu(struct sk_buff *skb)
2375 {
2376 	struct ieee80211_mgmt *mgmt = (void *)skb->data;
2377 	__le16 fc = mgmt->frame_control;
2378 
2379 	/*
2380 	 * IEEE 802.11 REVme D2.0 definition of bufferable MMPDU;
2381 	 * note that this ignores the IBSS special case.
2382 	 */
2383 	if (!ieee80211_is_mgmt(fc))
2384 		return false;
2385 
2386 	if (ieee80211_is_disassoc(fc) || ieee80211_is_deauth(fc))
2387 		return true;
2388 
2389 	if (!ieee80211_is_action(fc))
2390 		return false;
2391 
2392 	if (skb->len < offsetofend(typeof(*mgmt), u.action.u.ftm.action_code))
2393 		return true;
2394 
2395 	/* action frame - additionally check for non-bufferable FTM */
2396 
2397 	if (mgmt->u.action.category != WLAN_CATEGORY_PUBLIC &&
2398 	    mgmt->u.action.category != WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION)
2399 		return true;
2400 
2401 	if (mgmt->u.action.u.ftm.action_code == WLAN_PUB_ACTION_FTM_REQUEST ||
2402 	    mgmt->u.action.u.ftm.action_code == WLAN_PUB_ACTION_FTM_RESPONSE)
2403 		return false;
2404 
2405 	return true;
2406 }
2407 
2408 /**
2409  * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
2410  * @hdr: the frame (buffer must include at least the first octet of payload)
2411  * Return: whether or not the frame is a robust management frame
2412  */
_ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr * hdr)2413 static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
2414 {
2415 	if (ieee80211_is_disassoc(hdr->frame_control) ||
2416 	    ieee80211_is_deauth(hdr->frame_control))
2417 		return true;
2418 
2419 	if (ieee80211_is_action(hdr->frame_control)) {
2420 		u8 *category;
2421 
2422 		/*
2423 		 * Action frames, excluding Public Action frames, are Robust
2424 		 * Management Frames. However, if we are looking at a Protected
2425 		 * frame, skip the check since the data may be encrypted and
2426 		 * the frame has already been found to be a Robust Management
2427 		 * Frame (by the other end).
2428 		 */
2429 		if (ieee80211_has_protected(hdr->frame_control))
2430 			return true;
2431 		category = ((u8 *) hdr) + 24;
2432 		return *category != WLAN_CATEGORY_PUBLIC &&
2433 			*category != WLAN_CATEGORY_HT &&
2434 			*category != WLAN_CATEGORY_WNM_UNPROTECTED &&
2435 			*category != WLAN_CATEGORY_SELF_PROTECTED &&
2436 			*category != WLAN_CATEGORY_UNPROT_DMG &&
2437 			*category != WLAN_CATEGORY_VHT &&
2438 			*category != WLAN_CATEGORY_S1G &&
2439 			*category != WLAN_CATEGORY_VENDOR_SPECIFIC;
2440 	}
2441 
2442 	return false;
2443 }
2444 
2445 /**
2446  * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
2447  * @skb: the skb containing the frame, length will be checked
2448  * Return: whether or not the frame is a robust management frame
2449  */
ieee80211_is_robust_mgmt_frame(struct sk_buff * skb)2450 static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
2451 {
2452 	if (skb->len < IEEE80211_MIN_ACTION_SIZE)
2453 		return false;
2454 	return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
2455 }
2456 
2457 /**
2458  * ieee80211_is_public_action - check if frame is a public action frame
2459  * @hdr: the frame
2460  * @len: length of the frame
2461  * Return: whether or not the frame is a public action frame
2462  */
ieee80211_is_public_action(struct ieee80211_hdr * hdr,size_t len)2463 static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
2464 					      size_t len)
2465 {
2466 	struct ieee80211_mgmt *mgmt = (void *)hdr;
2467 
2468 	if (len < IEEE80211_MIN_ACTION_SIZE)
2469 		return false;
2470 	if (!ieee80211_is_action(hdr->frame_control))
2471 		return false;
2472 	return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
2473 }
2474 
2475 /**
2476  * ieee80211_is_protected_dual_of_public_action - check if skb contains a
2477  * protected dual of public action management frame
2478  * @skb: the skb containing the frame, length will be checked
2479  *
2480  * Return: true if the skb contains a protected dual of public action
2481  * management frame, false otherwise.
2482  */
2483 static inline bool
ieee80211_is_protected_dual_of_public_action(struct sk_buff * skb)2484 ieee80211_is_protected_dual_of_public_action(struct sk_buff *skb)
2485 {
2486 	u8 action;
2487 
2488 	if (!ieee80211_is_public_action((void *)skb->data, skb->len) ||
2489 	    skb->len < IEEE80211_MIN_ACTION_SIZE + 1)
2490 		return false;
2491 
2492 	action = *(u8 *)(skb->data + IEEE80211_MIN_ACTION_SIZE);
2493 
2494 	return action != WLAN_PUB_ACTION_20_40_BSS_COEX &&
2495 		action != WLAN_PUB_ACTION_DSE_REG_LOC_ANN &&
2496 		action != WLAN_PUB_ACTION_MSMT_PILOT &&
2497 		action != WLAN_PUB_ACTION_TDLS_DISCOVER_RES &&
2498 		action != WLAN_PUB_ACTION_LOC_TRACK_NOTI &&
2499 		action != WLAN_PUB_ACTION_FTM_REQUEST &&
2500 		action != WLAN_PUB_ACTION_FTM_RESPONSE &&
2501 		action != WLAN_PUB_ACTION_FILS_DISCOVERY &&
2502 		action != WLAN_PUB_ACTION_VENDOR_SPECIFIC;
2503 }
2504 
2505 /**
2506  * _ieee80211_is_group_privacy_action - check if frame is a group addressed
2507  *	privacy action frame
2508  * @hdr: the frame
2509  * Return: whether or not the frame is a group addressed privacy action frame
2510  */
_ieee80211_is_group_privacy_action(struct ieee80211_hdr * hdr)2511 static inline bool _ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr)
2512 {
2513 	struct ieee80211_mgmt *mgmt = (void *)hdr;
2514 
2515 	if (!ieee80211_is_action(hdr->frame_control) ||
2516 	    !is_multicast_ether_addr(hdr->addr1))
2517 		return false;
2518 
2519 	return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
2520 	       mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
2521 }
2522 
2523 /**
2524  * ieee80211_is_group_privacy_action - check if frame is a group addressed
2525  *	privacy action frame
2526  * @skb: the skb containing the frame, length will be checked
2527  * Return: whether or not the frame is a group addressed privacy action frame
2528  */
ieee80211_is_group_privacy_action(struct sk_buff * skb)2529 static inline bool ieee80211_is_group_privacy_action(struct sk_buff *skb)
2530 {
2531 	if (skb->len < IEEE80211_MIN_ACTION_SIZE)
2532 		return false;
2533 	return _ieee80211_is_group_privacy_action((void *)skb->data);
2534 }
2535 
2536 /**
2537  * ieee80211_tu_to_usec - convert time units (TU) to microseconds
2538  * @tu: the TUs
2539  * Return: the time value converted to microseconds
2540  */
ieee80211_tu_to_usec(unsigned long tu)2541 static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
2542 {
2543 	return 1024 * tu;
2544 }
2545 
__ieee80211_check_tim(const struct ieee80211_tim_ie * tim,u8 tim_len,u16 aid)2546 static inline bool __ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
2547 					 u8 tim_len, u16 aid)
2548 {
2549 	u8 mask;
2550 	u8 index, indexn1, indexn2;
2551 
2552 	if (unlikely(!tim || tim_len < sizeof(*tim)))
2553 		return false;
2554 
2555 	aid &= 0x3fff;
2556 	index = aid / 8;
2557 	mask  = 1 << (aid & 7);
2558 
2559 	indexn1 = tim->bitmap_ctrl & 0xfe;
2560 	indexn2 = tim_len + indexn1 - 4;
2561 
2562 	if (index < indexn1 || index > indexn2)
2563 		return false;
2564 
2565 	index -= indexn1;
2566 
2567 	return !!(tim->virtual_map[index] & mask);
2568 }
2569 
2570 /**
2571  * ieee80211_get_tdls_action - get TDLS action code
2572  * @skb: the skb containing the frame, length will not be checked
2573  * Return: the TDLS action code, or -1 if it's not an encapsulated TDLS action
2574  *	frame
2575  *
2576  * This function assumes the frame is a data frame, and that the network header
2577  * is in the correct place.
2578  */
ieee80211_get_tdls_action(struct sk_buff * skb)2579 static inline int ieee80211_get_tdls_action(struct sk_buff *skb)
2580 {
2581 	if (!skb_is_nonlinear(skb) &&
2582 	    skb->len > (skb_network_offset(skb) + 2)) {
2583 		/* Point to where the indication of TDLS should start */
2584 		const u8 *tdls_data = skb_network_header(skb) - 2;
2585 
2586 		if (get_unaligned_be16(tdls_data) == ETH_P_TDLS &&
2587 		    tdls_data[2] == WLAN_TDLS_SNAP_RFTYPE &&
2588 		    tdls_data[3] == WLAN_CATEGORY_TDLS)
2589 			return tdls_data[4];
2590 	}
2591 
2592 	return -1;
2593 }
2594 
2595 /* convert time units */
2596 #define TU_TO_JIFFIES(x)	(usecs_to_jiffies((x) * 1024))
2597 #define TU_TO_EXP_TIME(x)	(jiffies + TU_TO_JIFFIES(x))
2598 
2599 /* convert frequencies */
2600 #define MHZ_TO_KHZ(freq) ((freq) * 1000)
2601 #define KHZ_TO_MHZ(freq) ((freq) / 1000)
2602 #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000
2603 #define KHZ_F "%d.%03d"
2604 
2605 /* convert powers */
2606 #define DBI_TO_MBI(gain) ((gain) * 100)
2607 #define MBI_TO_DBI(gain) ((gain) / 100)
2608 #define DBM_TO_MBM(gain) ((gain) * 100)
2609 #define MBM_TO_DBM(gain) ((gain) / 100)
2610 
2611 /**
2612  * ieee80211_action_contains_tpc - checks if the frame contains TPC element
2613  * @skb: the skb containing the frame, length will be checked
2614  * Return: %true if the frame contains a TPC element, %false otherwise
2615  *
2616  * This function checks if it's either TPC report action frame or Link
2617  * Measurement report action frame as defined in IEEE Std. 802.11-2012 8.5.2.5
2618  * and 8.5.7.5 accordingly.
2619  */
ieee80211_action_contains_tpc(struct sk_buff * skb)2620 static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb)
2621 {
2622 	struct ieee80211_mgmt *mgmt = (void *)skb->data;
2623 
2624 	if (!ieee80211_is_action(mgmt->frame_control))
2625 		return false;
2626 
2627 	if (skb->len < IEEE80211_MIN_ACTION_SIZE +
2628 		       sizeof(mgmt->u.action.u.tpc_report))
2629 		return false;
2630 
2631 	/*
2632 	 * TPC report - check that:
2633 	 * category = 0 (Spectrum Management) or 5 (Radio Measurement)
2634 	 * spectrum management action = 3 (TPC/Link Measurement report)
2635 	 * TPC report EID = 35
2636 	 * TPC report element length = 2
2637 	 *
2638 	 * The spectrum management's tpc_report struct is used here both for
2639 	 * parsing tpc_report and radio measurement's link measurement report
2640 	 * frame, since the relevant part is identical in both frames.
2641 	 */
2642 	if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT &&
2643 	    mgmt->u.action.category != WLAN_CATEGORY_RADIO_MEASUREMENT)
2644 		return false;
2645 
2646 	/* both spectrum mgmt and link measurement have same action code */
2647 	if (mgmt->u.action.u.tpc_report.action_code !=
2648 	    WLAN_ACTION_SPCT_TPC_RPRT)
2649 		return false;
2650 
2651 	if (mgmt->u.action.u.tpc_report.tpc_elem_id != WLAN_EID_TPC_REPORT ||
2652 	    mgmt->u.action.u.tpc_report.tpc_elem_length !=
2653 	    sizeof(struct ieee80211_tpc_report_ie))
2654 		return false;
2655 
2656 	return true;
2657 }
2658 
2659 /**
2660  * ieee80211_is_timing_measurement - check if frame is timing measurement response
2661  * @skb: the SKB to check
2662  * Return: whether or not the frame is a valid timing measurement response
2663  */
ieee80211_is_timing_measurement(struct sk_buff * skb)2664 static inline bool ieee80211_is_timing_measurement(struct sk_buff *skb)
2665 {
2666 	struct ieee80211_mgmt *mgmt = (void *)skb->data;
2667 
2668 	if (skb->len < IEEE80211_MIN_ACTION_SIZE)
2669 		return false;
2670 
2671 	if (!ieee80211_is_action(mgmt->frame_control))
2672 		return false;
2673 
2674 	if (mgmt->u.action.category == WLAN_CATEGORY_WNM_UNPROTECTED &&
2675 	    mgmt->u.action.u.wnm_timing_msr.action_code ==
2676 		WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE &&
2677 	    skb->len >= offsetofend(typeof(*mgmt), u.action.u.wnm_timing_msr))
2678 		return true;
2679 
2680 	return false;
2681 }
2682 
2683 /**
2684  * ieee80211_is_ftm - check if frame is FTM response
2685  * @skb: the SKB to check
2686  * Return: whether or not the frame is a valid FTM response action frame
2687  */
ieee80211_is_ftm(struct sk_buff * skb)2688 static inline bool ieee80211_is_ftm(struct sk_buff *skb)
2689 {
2690 	struct ieee80211_mgmt *mgmt = (void *)skb->data;
2691 
2692 	if (!ieee80211_is_public_action((void *)mgmt, skb->len))
2693 		return false;
2694 
2695 	if (mgmt->u.action.u.ftm.action_code ==
2696 		WLAN_PUB_ACTION_FTM_RESPONSE &&
2697 	    skb->len >= offsetofend(typeof(*mgmt), u.action.u.ftm))
2698 		return true;
2699 
2700 	return false;
2701 }
2702 
2703 struct element {
2704 	u8 id;
2705 	u8 datalen;
2706 	u8 data[];
2707 } __packed;
2708 
2709 /* element iteration helpers */
2710 #define for_each_element(_elem, _data, _datalen)			\
2711 	for (_elem = (const struct element *)(_data);			\
2712 	     (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=	\
2713 		(int)sizeof(*_elem) &&					\
2714 	     (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=	\
2715 		(int)sizeof(*_elem) + _elem->datalen;			\
2716 	     _elem = (const struct element *)(_elem->data + _elem->datalen))
2717 
2718 #define for_each_element_id(element, _id, data, datalen)		\
2719 	for_each_element(element, data, datalen)			\
2720 		if (element->id == (_id))
2721 
2722 #define for_each_element_extid(element, extid, _data, _datalen)		\
2723 	for_each_element(element, _data, _datalen)			\
2724 		if (element->id == WLAN_EID_EXTENSION &&		\
2725 		    element->datalen > 0 &&				\
2726 		    element->data[0] == (extid))
2727 
2728 #define for_each_subelement(sub, element)				\
2729 	for_each_element(sub, (element)->data, (element)->datalen)
2730 
2731 #define for_each_subelement_id(sub, id, element)			\
2732 	for_each_element_id(sub, id, (element)->data, (element)->datalen)
2733 
2734 #define for_each_subelement_extid(sub, extid, element)			\
2735 	for_each_element_extid(sub, extid, (element)->data, (element)->datalen)
2736 
2737 /**
2738  * for_each_element_completed - determine if element parsing consumed all data
2739  * @element: element pointer after for_each_element() or friends
2740  * @data: same data pointer as passed to for_each_element() or friends
2741  * @datalen: same data length as passed to for_each_element() or friends
2742  * Return: %true if all elements were iterated, %false otherwise; see notes
2743  *
2744  * This function returns %true if all the data was parsed or considered
2745  * while walking the elements. Only use this if your for_each_element()
2746  * loop cannot be broken out of, otherwise it always returns %false.
2747  *
2748  * If some data was malformed, this returns %false since the last parsed
2749  * element will not fill the whole remaining data.
2750  */
for_each_element_completed(const struct element * element,const void * data,size_t datalen)2751 static inline bool for_each_element_completed(const struct element *element,
2752 					      const void *data, size_t datalen)
2753 {
2754 	return (const u8 *)element == (const u8 *)data + datalen;
2755 }
2756 
2757 /*
2758  * RSNX Capabilities:
2759  * bits 0-3: Field length (n-1)
2760  */
2761 #define WLAN_RSNX_CAPA_PROTECTED_TWT BIT(4)
2762 #define WLAN_RSNX_CAPA_SAE_H2E BIT(5)
2763 
2764 /* EBPCC = Enhanced BSS Parameter Change Count */
2765 #define IEEE80211_ENH_CRIT_UPD_EBPCC		0x0F
2766 #define IEEE80211_ENH_CRIT_UPD_TYPE		0x70
2767 #define IEEE80211_ENH_CRIT_UPD_TYPE_NO_UHR	0
2768 #define IEEE80211_ENH_CRIT_UPD_TYPE_UHR		1
2769 #define IEEE80211_ENH_CRIT_UPD_ALL		0x80
2770 
2771 /**
2772  * struct ieee80211_enh_crit_upd - enhanced critical update (UHR)
2773  * @v: value of the enhanced critical update data,
2774  *	see %IEEE80211_ENH_CRIT_UPD_* to parse the bits
2775  */
2776 struct ieee80211_enh_crit_upd {
2777 	u8 v;
2778 } __packed;
2779 
2780 /*
2781  * reduced neighbor report, based on Draft P802.11ax_D6.1,
2782  * section 9.4.2.170 and accepted contributions.
2783  */
2784 #define IEEE80211_AP_INFO_TBTT_HDR_TYPE				0x03
2785 #define IEEE80211_AP_INFO_TBTT_HDR_FILTERED			0x04
2786 #define IEEE80211_AP_INFO_TBTT_HDR_COLOC			0x08
2787 #define IEEE80211_AP_INFO_TBTT_HDR_COUNT			0xF0
2788 #define IEEE80211_TBTT_INFO_TYPE_TBTT				0
2789 #define IEEE80211_TBTT_INFO_TYPE_MLD				1
2790 
2791 #define IEEE80211_RNR_TBTT_PARAMS_OCT_RECOMMENDED		0x01
2792 #define IEEE80211_RNR_TBTT_PARAMS_SAME_SSID			0x02
2793 #define IEEE80211_RNR_TBTT_PARAMS_MULTI_BSSID			0x04
2794 #define IEEE80211_RNR_TBTT_PARAMS_TRANSMITTED_BSSID		0x08
2795 #define IEEE80211_RNR_TBTT_PARAMS_COLOC_ESS			0x10
2796 #define IEEE80211_RNR_TBTT_PARAMS_PROBE_ACTIVE			0x20
2797 #define IEEE80211_RNR_TBTT_PARAMS_COLOC_AP			0x40
2798 #define IEEE80211_RNR_TBTT_PARAMS_SAME_SMD			0x80
2799 
2800 #define IEEE80211_RNR_TBTT_PARAMS_PSD_NO_LIMIT			127
2801 #define IEEE80211_RNR_TBTT_PARAMS_PSD_RESERVED			-128
2802 
2803 struct ieee80211_neighbor_ap_info {
2804 	u8 tbtt_info_hdr;
2805 	u8 tbtt_info_len;
2806 	u8 op_class;
2807 	u8 channel;
2808 } __packed;
2809 
2810 enum ieee80211_range_params_max_total_ltf {
2811 	IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_4 = 0,
2812 	IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_8,
2813 	IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_16,
2814 	IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_UNSPECIFIED,
2815 };
2816 
2817 /*
2818  * reduced neighbor report, based on Draft P802.11be_D3.0,
2819  * section 9.4.2.170.2.
2820  */
2821 struct ieee80211_rnr_mld_params {
2822 	u8 mld_id;
2823 	__le16 params;
2824 } __packed;
2825 
2826 #define IEEE80211_RNR_MLD_PARAMS_LINK_ID			0x000F
2827 #define IEEE80211_RNR_MLD_PARAMS_BSS_CHANGE_COUNT		0x0FF0
2828 #define IEEE80211_RNR_MLD_PARAMS_UPDATES_INCLUDED		0x1000
2829 #define IEEE80211_RNR_MLD_PARAMS_DISABLED_LINK			0x2000
2830 
2831 /* Format of the TBTT information element if it has 7, 8 or 9 bytes */
2832 struct ieee80211_tbtt_info_7_8_9 {
2833 	u8 tbtt_offset;
2834 	u8 bssid[ETH_ALEN];
2835 
2836 	/* The following element is optional, structure may not grow */
2837 	u8 bss_params;
2838 	s8 psd_20;
2839 } __packed;
2840 
2841 /* Format of the TBTT information element if it has >= 11 bytes */
2842 struct ieee80211_tbtt_info_ge_11 {
2843 	u8 tbtt_offset;
2844 	u8 bssid[ETH_ALEN];
2845 	__le32 short_ssid;
2846 
2847 	/* The following elements are optional, structure may grow */
2848 	u8 bss_params;
2849 	s8 psd_20;
2850 	struct ieee80211_rnr_mld_params mld_params;
2851 	struct ieee80211_enh_crit_upd enh_crit_upd;
2852 } __packed;
2853 
2854 #include "ieee80211-ht.h"
2855 #include "ieee80211-vht.h"
2856 #include "ieee80211-he.h"
2857 #include "ieee80211-eht.h"
2858 #include "ieee80211-uhr.h"
2859 #include "ieee80211-mesh.h"
2860 #include "ieee80211-s1g.h"
2861 #include "ieee80211-p2p.h"
2862 #include "ieee80211-nan.h"
2863 
2864 /**
2865  * ieee80211_check_tim - check if AID bit is set in TIM
2866  * @tim: the TIM IE
2867  * @tim_len: length of the TIM IE
2868  * @aid: the AID to look for
2869  * @s1g: whether the TIM is from an S1G PPDU
2870  * Return: whether or not traffic is indicated in the TIM for the given AID
2871  */
ieee80211_check_tim(const struct ieee80211_tim_ie * tim,u8 tim_len,u16 aid,bool s1g)2872 static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
2873 				       u8 tim_len, u16 aid, bool s1g)
2874 {
2875 	return s1g ? ieee80211_s1g_check_tim(tim, tim_len, aid) :
2876 		     __ieee80211_check_tim(tim, tim_len, aid);
2877 }
2878 
2879 #endif /* LINUX_IEEE80211_H */
2880