git: 67121a1ed050 - stable/13 - net80211: Radiotap: update for newer standards (add EHT, U-SIG)

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 26 Jun 2023 12:08:35 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=67121a1ed05043d93b9ab05bb31814697db860c8

commit 67121a1ed05043d93b9ab05bb31814697db860c8
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-05-16 16:03:17 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-06-26 09:12:47 +0000

    net80211: Radiotap: update for newer standards (add EHT, U-SIG)
    
    iwlwifi already uses suggested EHT and U-SIG bits as well as some
    more TLV bits.  Update radiotap to know of those even if they might
    get updated again in the future in order to get newer versions of
    the driver to compile.
    
    ath1xk drivers require further HE defines.  Some of those we had
    already predicted as comments in the past.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 7232e6dcc89b978825b30a537bca2e7d3a9b71bb)
    (cherry picked from commit 63231f4d5bae5fbdb2ebbca4860416557c397059)
---
 sys/net80211/ieee80211_radiotap.h | 145 +++++++++++++++++++++++++++++++++++---
 1 file changed, 136 insertions(+), 9 deletions(-)

diff --git a/sys/net80211/ieee80211_radiotap.h b/sys/net80211/ieee80211_radiotap.h
index 35800325f121..1515ce7afd34 100644
--- a/sys/net80211/ieee80211_radiotap.h
+++ b/sys/net80211/ieee80211_radiotap.h
@@ -234,9 +234,13 @@ enum ieee80211_radiotap_type {
 	IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
 	IEEE80211_RADIOTAP_VHT = 21,
 
+	IEEE80211_RADIOTAP_TLV = 28,
         IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
-	IEEE80211_RADIOTAP_VENDOREXT = 30,
+	IEEE80211_RADIOTAP_VENDOREXT = 30,		/* obsolete? */
+	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
 	IEEE80211_RADIOTAP_EXT = 31,
+	IEEE80211_RADIOTAP_EHT_USIG = 33,
+	IEEE80211_RADIOTAP_EHT = 34,
 };
 
 #ifndef _KERNEL
@@ -381,10 +385,25 @@ enum ieee80211_radiotap_type {
 #define	IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED		0x01
 #define	IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR			0xFF
 
+/* http://www.radiotap.org/fields/TLV.html */
+struct ieee80211_radiotap_tlv {
+	uint16_t	type;
+	uint16_t	len;
+	uint8_t		data[];
+} __packed;
+
+struct ieee80211_radiotap_vendor_content {
+	uint8_t		oui[3];
+	uint8_t		oui_subtype;
+	uint16_t	vendor_type;
+	uint16_t	__padding;
+	uint8_t		data[];
+} __packed;
+
 /* https://www.radiotap.org/fields/HE.html */
 struct ieee80211_radiotap_he {
 	uint16_t	data1, data2, data3, data4, data5, data6;
-};
+} __packed;
 
 #define	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU			0x0000
 #define	IEEE80211_RADIOTAP_HE_DATA1_FORMAT_EXT_SU		0x0001
@@ -412,7 +431,7 @@ struct ieee80211_radiotap_he {
 #define	IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN			0x0010
 #define	IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN		0x0020
 #define	IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN			0x0040
-/* #define	IEEE80211_RADIOTAP_HE_DATA2_ midamble periodicity _KNOWN 0x0080 */
+#define	IEEE80211_RADIOTAP_HE_DATA2_MIDAMBLE_KNOWN		0x0080
 #define	IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET			0x3F00
 #define	IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN		0x4000
 #define	IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC		0x8000
@@ -420,11 +439,11 @@ struct ieee80211_radiotap_he {
 #define	IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR			0x003F
 #define	IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE			0x0040
 #define	IEEE80211_RADIOTAP_HE_DATA3_UL_DL			0x0080
-/* #deifne	IEEE80211_RADIOTAP_HE_DATA3_data_MCS		0x0F00 */
-/* #define	IEEE80211_RADIOTAP_HE_DATA3_data_DCM		0x1000 */
-/* #define	IEEE80211_RADIOTAP_HE_DATA3_Coding		0x2000 */
+#define	IEEE80211_RADIOTAP_HE_DATA3_DATA_MCS			0x0F00
+#define	IEEE80211_RADIOTAP_HE_DATA3_DATA_DCM			0x1000
+#define	IEEE80211_RADIOTAP_HE_DATA3_CODING			0x2000
 #define	IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG		0x4000
-/* #define	IEEE80211_RADIOTAP_HE_DATA3_STBC		0x8000 */
+#define	IEEE80211_RADIOTAP_HE_DATA3_STBC			0x8000
 
 #define	IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE		0x000F
 #define	IEEE80211_RADIOTAP_HE_DATA4_MU_STA_ID			0x7FF0
@@ -433,6 +452,8 @@ struct ieee80211_radiotap_he {
 #define	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3		0x0F00
 #define	IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4		0xF000
 
+#define	IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC		0x000F
+#define	IEEE80211_RADIOTAP_HE_DATA5_GI				0x0030
 #define	IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE			0x00C0
 #define	IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN		0x0
 #define	IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X			0x1
@@ -443,6 +464,7 @@ struct ieee80211_radiotap_he {
 #define	IEEE80211_RADIOTAP_HE_DATA5_TXBF			0x4000
 #define	IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG			0x8000
 
+#define	IEEE80211_RADIOTAP_HE_DATA6_NSTS			0x000F
 #define	IEEE80211_RADIOTAP_HE_DATA6_DOPPLER			0x0010
 /* 0x00e0 	(reserved) ; use these for the following undocumented. */
 #define	IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN		0x0020
@@ -459,7 +481,7 @@ struct ieee80211_radiotap_he_mu {
 	uint16_t	flags2;
 	uint8_t		ru_ch1[4];
 	uint8_t		ru_ch2[4];
-};
+} __packed;
 
 #define	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS		0x000F
 #define	IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS_KNOWN		0x0010
@@ -490,7 +512,7 @@ struct ieee80211_radiotap_he_mu {
 struct ieee80211_radiotap_lsig {
 	uint16_t	data1;
 	uint16_t	data2;
-};
+} __packed;
 #define	IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN		0x0002
 
 #define	IEEE80211_RADIOTAP_LSIG_DATA2_LENGTH			0xFFF0
@@ -503,4 +525,109 @@ struct ieee80211_radiotap_lsig {
 #define	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US			0x01
 #define	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ		0x10
 
+/* http://www.radiotap.org/fields/U-SIG.html */
+struct ieee80211_radiotap_eht_usig {
+	uint32_t	common;
+	uint32_t	value;
+	uint32_t	mask;
+} __packed;
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN	0x00000001
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_KNOWN		0x00000002
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL_KNOWN		0x00000004
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR_KNOWN	0x00000008
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN		0x00000010
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC		0x00000020
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER		0x00007000
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW			0x00038000
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL		0x00040000
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR		0x01f80000
+#define	IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP			0xfe000000
+
+#define	IEEE80211_RADIOTAP_EHT_USIG1_MU_B20_B24_DISREGARD	0x0000001f
+#define	IEEE80211_RADIOTAP_EHT_USIG1_MU_B25_VALIDATE		0x00000020
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE		0x000000c0
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B2_VALIDATE		0x00000100
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO	0x00003e00
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B8_VALIDATE		0x00004000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS		0x00018000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS	0x003e0000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B16_B19_CRC		0x03c00000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_MU_B20_B25_TAIL		0xfc000000
+
+#define	IEEE80211_RADIOTAP_EHT_USIG1_TB_B20_B25_DISREGARD	0x0000003f
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE		0x000000c0
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B2_VALIDATE		0x00000100
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1	0x00001e00
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2	0x0001e000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B11_B15_DISREGARD	0x003e0000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B16_B19_CRC		0x03c00000
+#define	IEEE80211_RADIOTAP_EHT_USIG2_TB_B20_B25_TAIL		0xfc000000
+
+/* http://www.radiotap.org/fields/EHT.html */
+struct ieee80211_radiotap_eht {
+	uint32_t	known;
+	uint32_t	data[9];
+	uint32_t	user_info[];
+} __packed;
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE		0x00000002
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_GI				0x00000004
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF			0x00000010
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM		0x00000020
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM		0x00000040
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM		0x00000080
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S			0x00020000
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_BEAMFORMED_S		0x00040000
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M	0x00080000
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT		0x01000000
+#define	IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80			0x02000000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA0_SPATIAL_REUSE		0x00000078
+#define	IEEE80211_RADIOTAP_EHT_DATA0_GI				0x00000180
+#define	IEEE80211_RADIOTAP_EHT_DATA0_LTF			0x00000600
+#define	IEEE80211_RADIOTAP_EHT_DATA0_EHT_LTF			0x00003800
+#define	IEEE80211_RADIOTAP_EHT_DATA0_LDPC_EXTRA_SYM_OM		0x00004000
+#define	IEEE80211_RADIOTAP_EHT_DATA0_PRE_PADD_FACOR_OM		0x00018000
+#define	IEEE80211_RADIOTAP_EHT_DATA0_PE_DISAMBIGUITY_OM		0x00020000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1		0x003fe000
+#define	IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1_KNOWN	0x00400000
+#define	IEEE80211_RADIOTAP_EHT_DATA1_PRIMARY_80			0xc0000000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1		0x000001ff
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1_KNOWN	0x00000200
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2		0x0007fc00
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2_KNOWN	0x00080000
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2		0x1ff00000
+#define	IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2_KNOWN	0x20000000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1		0x000001ff
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1_KNOWN	0x00000200
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1		0x0007fc00
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1_KNOWN	0x00080000
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2		0x1ff00000
+#define	IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2_KNOWN	0x20000000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2		0x000001ff
+#define	IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2_KNOWN	0x00000200
+
+#define	IEEE80211_RADIOTAP_EHT_DATA7_NSS_S			0x0000f000
+#define	IEEE80211_RADIOTAP_EHT_DATA7_BEAMFORMED_S		0x00010000
+#define	IEEE80211_RADIOTAP_EHT_DATA7_NUM_OF_NON_OFDMA_USERS	0x000e0000
+
+#define	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_PS_160	0x00000001
+#define	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B0		0x00000002
+#define	IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1	0x000001fc
+
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID_KNOWN		0x00000001
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_MCS_KNOWN		0x00000002
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_CODING_KNOWN		0x00000004
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_KNOWN_O		0x00000010
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_KNOWN_O	0x00000020
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_DATA_FOR_USER		0x00000080
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID			0x0007ff00
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_CODING			0x00080000
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_MCS			0x00f00000
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_O			0x0f000000
+#define	IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_O		0x20000000
+
 #endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */