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