1 /*
2  * Copyright (c) 2017		Intel Deutschland GmbH
3  * Copyright (c) 2018-2019, 2021-2022 Intel Corporation
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 #ifndef __RADIOTAP_H
18 #define __RADIOTAP_H
19 
20 #include <linux/kernel.h>
21 #include <asm/unaligned.h>
22 
23 /**
24  * struct ieee80211_radiotap_header - base radiotap header
25  */
26 struct ieee80211_radiotap_header {
27 	/**
28 	 * @it_version: radiotap version, always 0
29 	 */
30 	uint8_t it_version;
31 
32 	/**
33 	 * @it_pad: padding (or alignment)
34 	 */
35 	uint8_t it_pad;
36 
37 	/**
38 	 * @it_len: overall radiotap header length
39 	 */
40 	__le16 it_len;
41 
42 	/**
43 	 * @it_present: (first) present word
44 	 */
45 	__le32 it_present;
46 
47 	/**
48 	 * @it_optional: all remaining presence bitmaps
49 	 */
50 	__le32 it_optional[];
51 } __packed;
52 
53 /* version is always 0 */
54 #define PKTHDR_RADIOTAP_VERSION	0
55 
56 /* see the radiotap website for the descriptions */
57 enum ieee80211_radiotap_presence {
58 	IEEE80211_RADIOTAP_TSFT = 0,
59 	IEEE80211_RADIOTAP_FLAGS = 1,
60 	IEEE80211_RADIOTAP_RATE = 2,
61 	IEEE80211_RADIOTAP_CHANNEL = 3,
62 	IEEE80211_RADIOTAP_FHSS = 4,
63 	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
64 	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
65 	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
66 	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
67 	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
68 	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
69 	IEEE80211_RADIOTAP_ANTENNA = 11,
70 	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
71 	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
72 	IEEE80211_RADIOTAP_RX_FLAGS = 14,
73 	IEEE80211_RADIOTAP_TX_FLAGS = 15,
74 	IEEE80211_RADIOTAP_RTS_RETRIES = 16,
75 	IEEE80211_RADIOTAP_DATA_RETRIES = 17,
76 	/* 18 is XChannel, but it's not defined yet */
77 	IEEE80211_RADIOTAP_MCS = 19,
78 	IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
79 	IEEE80211_RADIOTAP_VHT = 21,
80 	IEEE80211_RADIOTAP_TIMESTAMP = 22,
81 	IEEE80211_RADIOTAP_HE = 23,
82 	IEEE80211_RADIOTAP_HE_MU = 24,
83 	IEEE80211_RADIOTAP_ZERO_LEN_PSDU = 26,
84 	IEEE80211_RADIOTAP_LSIG = 27,
85 	IEEE80211_RADIOTAP_TLV = 28,
86 
87 	/* valid in every it_present bitmap, even vendor namespaces */
88 	IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
89 	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
90 	IEEE80211_RADIOTAP_EXT = 31,
91 	IEEE80211_RADIOTAP_EHT_USIG = 33,
92 	IEEE80211_RADIOTAP_EHT = 34,
93 };
94 
95 /* for IEEE80211_RADIOTAP_FLAGS */
96 enum ieee80211_radiotap_flags {
97 	IEEE80211_RADIOTAP_F_CFP = 0x01,
98 	IEEE80211_RADIOTAP_F_SHORTPRE = 0x02,
99 	IEEE80211_RADIOTAP_F_WEP = 0x04,
100 	IEEE80211_RADIOTAP_F_FRAG = 0x08,
101 	IEEE80211_RADIOTAP_F_FCS = 0x10,
102 	IEEE80211_RADIOTAP_F_DATAPAD = 0x20,
103 	IEEE80211_RADIOTAP_F_BADFCS = 0x40,
104 };
105 
106 /* for IEEE80211_RADIOTAP_CHANNEL */
107 enum ieee80211_radiotap_channel_flags {
108 	IEEE80211_CHAN_CCK = 0x0020,
109 	IEEE80211_CHAN_OFDM = 0x0040,
110 	IEEE80211_CHAN_2GHZ = 0x0080,
111 	IEEE80211_CHAN_5GHZ = 0x0100,
112 	IEEE80211_CHAN_DYN = 0x0400,
113 	IEEE80211_CHAN_HALF = 0x4000,
114 	IEEE80211_CHAN_QUARTER = 0x8000,
115 };
116 
117 /* for IEEE80211_RADIOTAP_RX_FLAGS */
118 enum ieee80211_radiotap_rx_flags {
119 	IEEE80211_RADIOTAP_F_RX_BADPLCP = 0x0002,
120 };
121 
122 /* for IEEE80211_RADIOTAP_TX_FLAGS */
123 enum ieee80211_radiotap_tx_flags {
124 	IEEE80211_RADIOTAP_F_TX_FAIL = 0x0001,
125 	IEEE80211_RADIOTAP_F_TX_CTS = 0x0002,
126 	IEEE80211_RADIOTAP_F_TX_RTS = 0x0004,
127 	IEEE80211_RADIOTAP_F_TX_NOACK = 0x0008,
128 	IEEE80211_RADIOTAP_F_TX_NOSEQNO = 0x0010,
129 	IEEE80211_RADIOTAP_F_TX_ORDER = 0x0020,
130 };
131 
132 /* for IEEE80211_RADIOTAP_MCS "have" flags */
133 enum ieee80211_radiotap_mcs_have {
134 	IEEE80211_RADIOTAP_MCS_HAVE_BW = 0x01,
135 	IEEE80211_RADIOTAP_MCS_HAVE_MCS = 0x02,
136 	IEEE80211_RADIOTAP_MCS_HAVE_GI = 0x04,
137 	IEEE80211_RADIOTAP_MCS_HAVE_FMT = 0x08,
138 	IEEE80211_RADIOTAP_MCS_HAVE_FEC = 0x10,
139 	IEEE80211_RADIOTAP_MCS_HAVE_STBC = 0x20,
140 };
141 
142 enum ieee80211_radiotap_mcs_flags {
143 	IEEE80211_RADIOTAP_MCS_BW_MASK = 0x03,
144 	IEEE80211_RADIOTAP_MCS_BW_20 = 0,
145 	IEEE80211_RADIOTAP_MCS_BW_40 = 1,
146 	IEEE80211_RADIOTAP_MCS_BW_20L = 2,
147 	IEEE80211_RADIOTAP_MCS_BW_20U = 3,
148 
149 	IEEE80211_RADIOTAP_MCS_SGI = 0x04,
150 	IEEE80211_RADIOTAP_MCS_FMT_GF = 0x08,
151 	IEEE80211_RADIOTAP_MCS_FEC_LDPC = 0x10,
152 	IEEE80211_RADIOTAP_MCS_STBC_MASK = 0x60,
153 	IEEE80211_RADIOTAP_MCS_STBC_1 = 1,
154 	IEEE80211_RADIOTAP_MCS_STBC_2 = 2,
155 	IEEE80211_RADIOTAP_MCS_STBC_3 = 3,
156 	IEEE80211_RADIOTAP_MCS_STBC_SHIFT = 5,
157 };
158 
159 /* for IEEE80211_RADIOTAP_AMPDU_STATUS */
160 enum ieee80211_radiotap_ampdu_flags {
161 	IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN = 0x0001,
162 	IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN = 0x0002,
163 	IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN = 0x0004,
164 	IEEE80211_RADIOTAP_AMPDU_IS_LAST = 0x0008,
165 	IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR = 0x0010,
166 	IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN = 0x0020,
167 	IEEE80211_RADIOTAP_AMPDU_EOF = 0x0040,
168 	IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN = 0x0080,
169 };
170 
171 /* for IEEE80211_RADIOTAP_VHT */
172 enum ieee80211_radiotap_vht_known {
173 	IEEE80211_RADIOTAP_VHT_KNOWN_STBC = 0x0001,
174 	IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA = 0x0002,
175 	IEEE80211_RADIOTAP_VHT_KNOWN_GI = 0x0004,
176 	IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS = 0x0008,
177 	IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM = 0x0010,
178 	IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED = 0x0020,
179 	IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH = 0x0040,
180 	IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID = 0x0080,
181 	IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID = 0x0100,
182 };
183 
184 enum ieee80211_radiotap_vht_flags {
185 	IEEE80211_RADIOTAP_VHT_FLAG_STBC = 0x01,
186 	IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA = 0x02,
187 	IEEE80211_RADIOTAP_VHT_FLAG_SGI = 0x04,
188 	IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 = 0x08,
189 	IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM = 0x10,
190 	IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED = 0x20,
191 };
192 
193 enum ieee80211_radiotap_vht_coding {
194 	IEEE80211_RADIOTAP_CODING_LDPC_USER0 = 0x01,
195 	IEEE80211_RADIOTAP_CODING_LDPC_USER1 = 0x02,
196 	IEEE80211_RADIOTAP_CODING_LDPC_USER2 = 0x04,
197 	IEEE80211_RADIOTAP_CODING_LDPC_USER3 = 0x08,
198 };
199 
200 /* for IEEE80211_RADIOTAP_TIMESTAMP */
201 enum ieee80211_radiotap_timestamp_unit_spos {
202 	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MASK = 0x000F,
203 	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MS = 0x0000,
204 	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US = 0x0001,
205 	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_NS = 0x0003,
206 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_MASK = 0x00F0,
207 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_BEGIN_MDPU = 0x0000,
208 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ = 0x0010,
209 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_PPDU = 0x0020,
210 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_MPDU = 0x0030,
211 	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_UNKNOWN = 0x00F0,
212 };
213 
214 enum ieee80211_radiotap_timestamp_flags {
215 	IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT = 0x00,
216 	IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT = 0x01,
217 	IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 0x02,
218 };
219 
220 struct ieee80211_radiotap_he {
221 	__le16 data1, data2, data3, data4, data5, data6;
222 };
223 
224 enum ieee80211_radiotap_he_bits {
225 	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MASK		= 3,
226 	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU		= 0,
227 	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_EXT_SU	= 1,
228 	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MU		= 2,
229 	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_TRIG		= 3,
230 
231 	IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN	= 0x0004,
232 	IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN	= 0x0008,
233 	IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN		= 0x0010,
234 	IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN	= 0x0020,
235 	IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN	= 0x0040,
236 	IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN	= 0x0080,
237 	IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN	= 0x0100,
238 	IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN		= 0x0200,
239 	IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN	= 0x0400,
240 	IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN	= 0x0800,
241 	IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN	= 0x1000,
242 	IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN	= 0x2000,
243 	IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN	= 0x4000,
244 	IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN	= 0x8000,
245 
246 	IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN	= 0x0001,
247 	IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN		= 0x0002,
248 	IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN	= 0x0004,
249 	IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN	= 0x0008,
250 	IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN		= 0x0010,
251 	IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN	= 0x0020,
252 	IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN		= 0x0040,
253 	IEEE80211_RADIOTAP_HE_DATA2_MIDAMBLE_KNOWN	= 0x0080,
254 	IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET		= 0x3f00,
255 	IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN	= 0x4000,
256 	IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC	= 0x8000,
257 
258 	IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR		= 0x003f,
259 	IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE		= 0x0040,
260 	IEEE80211_RADIOTAP_HE_DATA3_UL_DL		= 0x0080,
261 	IEEE80211_RADIOTAP_HE_DATA3_DATA_MCS		= 0x0f00,
262 	IEEE80211_RADIOTAP_HE_DATA3_DATA_DCM		= 0x1000,
263 	IEEE80211_RADIOTAP_HE_DATA3_CODING		= 0x2000,
264 	IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG	= 0x4000,
265 	IEEE80211_RADIOTAP_HE_DATA3_STBC		= 0x8000,
266 
267 	IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE	= 0x000f,
268 	IEEE80211_RADIOTAP_HE_DATA4_MU_STA_ID		= 0x7ff0,
269 	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE1	= 0x000f,
270 	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE2	= 0x00f0,
271 	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3	= 0x0f00,
272 	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4	= 0xf000,
273 
274 	IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC	= 0x000f,
275 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ	= 0,
276 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ	= 1,
277 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ	= 2,
278 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ	= 3,
279 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_26T	= 4,
280 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_52T	= 5,
281 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_106T	= 6,
282 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_242T	= 7,
283 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_484T	= 8,
284 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_996T	= 9,
285 		IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_2x996T	= 10,
286 
287 	IEEE80211_RADIOTAP_HE_DATA5_GI			= 0x0030,
288 		IEEE80211_RADIOTAP_HE_DATA5_GI_0_8			= 0,
289 		IEEE80211_RADIOTAP_HE_DATA5_GI_1_6			= 1,
290 		IEEE80211_RADIOTAP_HE_DATA5_GI_3_2			= 2,
291 
292 	IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE		= 0x00c0,
293 		IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN		= 0,
294 		IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X			= 1,
295 		IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X			= 2,
296 		IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X			= 3,
297 	IEEE80211_RADIOTAP_HE_DATA5_NUM_LTF_SYMS	= 0x0700,
298 	IEEE80211_RADIOTAP_HE_DATA5_PRE_FEC_PAD		= 0x3000,
299 	IEEE80211_RADIOTAP_HE_DATA5_TXBF		= 0x4000,
300 	IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG		= 0x8000,
301 
302 	IEEE80211_RADIOTAP_HE_DATA6_NSTS		= 0x000f,
303 	IEEE80211_RADIOTAP_HE_DATA6_DOPPLER		= 0x0010,
304 	IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN	= 0x0020,
305 	IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW		= 0x00c0,
306 		IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_20MHZ	= 0,
307 		IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_40MHZ	= 1,
308 		IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_80MHZ	= 2,
309 		IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_160MHZ	= 3,
310 	IEEE80211_RADIOTAP_HE_DATA6_TXOP		= 0x7f00,
311 	IEEE80211_RADIOTAP_HE_DATA6_MIDAMBLE_PDCTY	= 0x8000,
312 };
313 
314 struct ieee80211_radiotap_he_mu {
315 	__le16 flags1, flags2;
316 	u8 ru_ch1[4];
317 	u8 ru_ch2[4];
318 };
319 
320 enum ieee80211_radiotap_he_mu_bits {
321 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS		= 0x000f,
322 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS_KNOWN		= 0x0010,
323 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM		= 0x0020,
324 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM_KNOWN		= 0x0040,
325 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_CTR_26T_RU_KNOWN	= 0x0080,
326 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_RU_KNOWN		= 0x0100,
327 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_RU_KNOWN		= 0x0200,
328 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU_KNOWN	= 0x1000,
329 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU		= 0x2000,
330 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_COMP_KNOWN	= 0x4000,
331 	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN	= 0x8000,
332 
333 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW	= 0x0003,
334 		IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_20MHZ	= 0x0000,
335 		IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_40MHZ	= 0x0001,
336 		IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_80MHZ	= 0x0002,
337 		IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_160MHZ	= 0x0003,
338 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN	= 0x0004,
339 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_COMP		= 0x0008,
340 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_SYMS_USERS	= 0x00f0,
341 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW	= 0x0300,
342 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN= 0x0400,
343 	IEEE80211_RADIOTAP_HE_MU_FLAGS2_CH2_CTR_26T_RU		= 0x0800,
344 };
345 
346 enum ieee80211_radiotap_lsig_data1 {
347 	IEEE80211_RADIOTAP_LSIG_DATA1_RATE_KNOWN		= 0x0001,
348 	IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN		= 0x0002,
349 };
350 
351 enum ieee80211_radiotap_lsig_data2 {
352 	IEEE80211_RADIOTAP_LSIG_DATA2_RATE			= 0x000f,
353 	IEEE80211_RADIOTAP_LSIG_DATA2_LENGTH			= 0xfff0,
354 };
355 
356 struct ieee80211_radiotap_lsig {
357 	__le16 data1, data2;
358 };
359 
360 enum ieee80211_radiotap_zero_len_psdu_type {
361 	IEEE80211_RADIOTAP_ZERO_LEN_PSDU_SOUNDING		= 0,
362 	IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED		= 1,
363 	IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR			= 0xff,
364 };
365 
366 struct ieee80211_radiotap_tlv {
367 	__le16 type;
368 	__le16 len;
369 	u8 data[];
370 } __packed;
371 
372 /**
373  * struct ieee80211_radiotap_vendor_content - radiotap vendor data content
374  * @oui: radiotap vendor namespace OUI
375  * @oui_subtype: radiotap vendor sub namespace
376  * @vendor_type: radiotap vendor type
377  * @reserved: should always be set to zero (to avoid leaking memory)
378  * @data: the actual vendor namespace data
379  */
380 struct ieee80211_radiotap_vendor_content {
381 	u8 oui[3];
382 	u8 oui_subtype;
383 	__le16 vendor_type;
384 	__le16 reserved;
385 	u8 data[];
386 } __packed;
387 
388 /**
389  * struct ieee80211_radiotap_vendor_tlv - vendor radiotap data information
390  * @type: should always be set to IEEE80211_RADIOTAP_VENDOR_NAMESPACE
391  * @len: length of data
392  * @content: vendor content see @ieee80211_radiotap_vendor_content
393  */
394 struct ieee80211_radiotap_vendor_tlv {
395 	__le16 type; /* IEEE80211_RADIOTAP_VENDOR_NAMESPACE */
396 	__le16 len;
397 	struct ieee80211_radiotap_vendor_content content;
398 };
399 
400 /* ieee80211_radiotap_eht_usig - content of U-SIG tlv (type 33)
401  * see www.radiotap.org/fields/U-SIG.html for details
402  */
403 struct ieee80211_radiotap_eht_usig {
404 	__le32 common;
405 	__le32 value;
406 	__le32 mask;
407 } __packed;
408 
409 /* ieee80211_radiotap_eht - content of EHT tlv (type 34)
410  * see www.radiotap.org/fields/EHT.html for details
411  */
412 struct ieee80211_radiotap_eht {
413 	__le32 known;
414 	__le32 data[9];
415 	__le32 user_info[];
416 } __packed;
417 
418 /* Known field for EHT TLV
419  * The ending defines for what the field applies as following
420  * O - OFDMA (including TB), M - MU-MIMO, S - EHT sounding.
421  */
422 enum ieee80211_radiotap_eht_known {
423 	IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE		= 0x00000002,
424 	IEEE80211_RADIOTAP_EHT_KNOWN_GI				= 0x00000004,
425 	IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF			= 0x00000010,
426 	IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM		= 0x00000020,
427 	IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM		= 0x00000040,
428 	IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM		= 0x00000080,
429 	IEEE80211_RADIOTAP_EHT_KNOWN_DISREGARD_O		= 0x00000100,
430 	IEEE80211_RADIOTAP_EHT_KNOWN_DISREGARD_S		= 0x00000200,
431 	IEEE80211_RADIOTAP_EHT_KNOWN_CRC1			= 0x00002000,
432 	IEEE80211_RADIOTAP_EHT_KNOWN_TAIL1			= 0x00004000,
433 	IEEE80211_RADIOTAP_EHT_KNOWN_CRC2_O			= 0x00008000,
434 	IEEE80211_RADIOTAP_EHT_KNOWN_TAIL2_O			= 0x00010000,
435 	IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S			= 0x00020000,
436 	IEEE80211_RADIOTAP_EHT_KNOWN_BEAMFORMED_S		= 0x00040000,
437 	IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M	= 0x00080000,
438 	IEEE80211_RADIOTAP_EHT_KNOWN_ENCODING_BLOCK_CRC_M	= 0x00100000,
439 	IEEE80211_RADIOTAP_EHT_KNOWN_ENCODING_BLOCK_TAIL_M	= 0x00200000,
440 	IEEE80211_RADIOTAP_EHT_KNOWN_RU_MRU_SIZE_OM		= 0x00400000,
441 	IEEE80211_RADIOTAP_EHT_KNOWN_RU_MRU_INDEX_OM		= 0x00800000,
442 	IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT		= 0x01000000,
443 	IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80			= 0x02000000,
444 };
445 
446 enum ieee80211_radiotap_eht_data {
447 	/* Data 0 */
448 	IEEE80211_RADIOTAP_EHT_DATA0_SPATIAL_REUSE		= 0x00000078,
449 	IEEE80211_RADIOTAP_EHT_DATA0_GI				= 0x00000180,
450 	IEEE80211_RADIOTAP_EHT_DATA0_LTF			= 0x00000600,
451 	IEEE80211_RADIOTAP_EHT_DATA0_EHT_LTF			= 0x00003800,
452 	IEEE80211_RADIOTAP_EHT_DATA0_LDPC_EXTRA_SYM_OM		= 0x00004000,
453 	IEEE80211_RADIOTAP_EHT_DATA0_PRE_PADD_FACOR_OM		= 0x00018000,
454 	IEEE80211_RADIOTAP_EHT_DATA0_PE_DISAMBIGUITY_OM		= 0x00020000,
455 	IEEE80211_RADIOTAP_EHT_DATA0_DISREGARD_S		= 0x000c0000,
456 	IEEE80211_RADIOTAP_EHT_DATA0_DISREGARD_O		= 0x003c0000,
457 	IEEE80211_RADIOTAP_EHT_DATA0_CRC1_O			= 0x03c00000,
458 	IEEE80211_RADIOTAP_EHT_DATA0_TAIL1_O			= 0xfc000000,
459 	/* Data 1 */
460 	IEEE80211_RADIOTAP_EHT_DATA1_RU_SIZE			= 0x0000001f,
461 	IEEE80211_RADIOTAP_EHT_DATA1_RU_INDEX			= 0x00001fe0,
462 	IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1		= 0x003fe000,
463 	IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1_KNOWN	= 0x00400000,
464 	IEEE80211_RADIOTAP_EHT_DATA1_PRIMARY_80			= 0xc0000000,
465 	/* Data 2 */
466 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1		= 0x000001ff,
467 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1_KNOWN	= 0x00000200,
468 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2		= 0x0007fc00,
469 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2_KNOWN	= 0x00080000,
470 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2		= 0x1ff00000,
471 	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2_KNOWN	= 0x20000000,
472 	/* Data 3 */
473 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1		= 0x000001ff,
474 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1_KNOWN	= 0x00000200,
475 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1		= 0x0007fc00,
476 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1_KNOWN	= 0x00080000,
477 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2		= 0x1ff00000,
478 	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2_KNOWN	= 0x20000000,
479 	/* Data 4 */
480 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2		= 0x000001ff,
481 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2_KNOWN	= 0x00000200,
482 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_1_2_3		= 0x0007fc00,
483 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_1_2_3_KNOWN	= 0x00080000,
484 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_3		= 0x1ff00000,
485 	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_3_KNOWN	= 0x20000000,
486 	/* Data 5 */
487 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_4		= 0x000001ff,
488 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_4_KNOWN	= 0x00000200,
489 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_2_2_4		= 0x0007fc00,
490 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_2_2_4_KNOWN	= 0x00080000,
491 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_5		= 0x1ff00000,
492 	IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_5_KNOWN	= 0x20000000,
493 	/* Data 6 */
494 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_5		= 0x000001ff,
495 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_5_KNOWN	= 0x00000200,
496 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_1_2_6		= 0x0007fc00,
497 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_1_2_6_KNOWN	= 0x00080000,
498 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_6		= 0x1ff00000,
499 	IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_6_KNOWN	= 0x20000000,
500 	/* Data 7 */
501 	IEEE80211_RADIOTAP_EHT_DATA7_CRC2_O			= 0x0000000f,
502 	IEEE80211_RADIOTAP_EHT_DATA7_TAIL_2_O			= 0x000003f0,
503 	IEEE80211_RADIOTAP_EHT_DATA7_NSS_S			= 0x0000f000,
504 	IEEE80211_RADIOTAP_EHT_DATA7_BEAMFORMED_S		= 0x00010000,
505 	IEEE80211_RADIOTAP_EHT_DATA7_NUM_OF_NON_OFDMA_USERS	= 0x000e0000,
506 	IEEE80211_RADIOTAP_EHT_DATA7_USER_ENCODING_BLOCK_CRC	= 0x00f00000,
507 	IEEE80211_RADIOTAP_EHT_DATA7_USER_ENCODING_BLOCK_TAIL	= 0x3f000000,
508 	/* Data 8 */
509 	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_PS_160	= 0x00000001,
510 	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B0		= 0x00000002,
511 	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1	= 0x000001fc,
512 };
513 
514 enum ieee80211_radiotap_eht_user_info {
515 	IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID_KNOWN		= 0x00000001,
516 	IEEE80211_RADIOTAP_EHT_USER_INFO_MCS_KNOWN		= 0x00000002,
517 	IEEE80211_RADIOTAP_EHT_USER_INFO_CODING_KNOWN		= 0x00000004,
518 	IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_KNOWN_O		= 0x00000010,
519 	IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_KNOWN_O	= 0x00000020,
520 	IEEE80211_RADIOTAP_EHT_USER_INFO_SPATIAL_CONFIG_KNOWN_M	= 0x00000040,
521 	IEEE80211_RADIOTAP_EHT_USER_INFO_DATA_FOR_USER		= 0x00000080,
522 	IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID			= 0x0007ff00,
523 	IEEE80211_RADIOTAP_EHT_USER_INFO_CODING			= 0x00080000,
524 	IEEE80211_RADIOTAP_EHT_USER_INFO_MCS			= 0x00f00000,
525 	IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_O			= 0x0f000000,
526 	IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_O		= 0x20000000,
527 	IEEE80211_RADIOTAP_EHT_USER_INFO_SPATIAL_CONFIG_M	= 0x3f000000,
528 	IEEE80211_RADIOTAP_EHT_USER_INFO_RESEVED_c0000000	= 0xc0000000,
529 };
530 
531 enum ieee80211_radiotap_eht_usig_common {
532 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN	= 0x00000001,
533 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_KNOWN		= 0x00000002,
534 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL_KNOWN		= 0x00000004,
535 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR_KNOWN	= 0x00000008,
536 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN		= 0x00000010,
537 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC		= 0x00000020,
538 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_CHECKED = 0x00000040,
539 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_OK	= 0x00000080,
540 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER		= 0x00007000,
541 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW			= 0x00038000,
542 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL		= 0x00040000,
543 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR		= 0x01f80000,
544 	IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP			= 0xfe000000,
545 };
546 
547 enum ieee80211_radiotap_eht_usig_mu {
548 	/* MU-USIG-1 */
549 	IEEE80211_RADIOTAP_EHT_USIG1_MU_B20_B24_DISREGARD	= 0x0000001f,
550 	IEEE80211_RADIOTAP_EHT_USIG1_MU_B25_VALIDATE		= 0x00000020,
551 	/* MU-USIG-2 */
552 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE		= 0x000000c0,
553 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B2_VALIDATE		= 0x00000100,
554 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO	= 0x00003e00,
555 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B8_VALIDATE		= 0x00004000,
556 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS		= 0x00018000,
557 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS = 0x003e0000,
558 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B16_B19_CRC		= 0x03c00000,
559 	IEEE80211_RADIOTAP_EHT_USIG2_MU_B20_B25_TAIL		= 0xfc000000,
560 };
561 
562 enum ieee80211_radiotap_eht_usig_tb {
563 	/* TB-USIG-1 */
564 	IEEE80211_RADIOTAP_EHT_USIG1_TB_B20_B25_DISREGARD	= 0x0000001f,
565 
566 	/* TB-USIG-2 */
567 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE		= 0x000000c0,
568 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B2_VALIDATE		= 0x00000100,
569 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1	= 0x00001e00,
570 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2	= 0x0001e000,
571 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B11_B15_DISREGARD	= 0x003e0000,
572 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B16_B19_CRC		= 0x03c00000,
573 	IEEE80211_RADIOTAP_EHT_USIG2_TB_B20_B25_TAIL		= 0xfc000000,
574 };
575 
576 /**
577  * ieee80211_get_radiotap_len - get radiotap header length
578  * @data: pointer to the header
579  */
ieee80211_get_radiotap_len(const char * data)580 static inline u16 ieee80211_get_radiotap_len(const char *data)
581 {
582 	const struct ieee80211_radiotap_header *hdr = (const void *)data;
583 
584 	return get_unaligned_le16(&hdr->it_len);
585 }
586 
587 #endif /* __RADIOTAP_H */
588