git: 1568caaf5721 - main - net80211: add valid VHT MCS combinations and helper functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Feb 2025 19:31:42 UTC
The branch main has been updated by adrian:
URL: https://cgit.FreeBSD.org/src/commit/?id=1568caaf572125b883aa6d0ed7f87b87ab0c9d45
commit 1568caaf572125b883aa6d0ed7f87b87ab0c9d45
Author: Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2025-01-13 05:47:37 +0000
Commit: Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-02-26 19:30:51 +0000
net80211: add valid VHT MCS combinations and helper functions
Not all NSS / MCS / channel bandwidth combinations are valid.
This will be important for rate control and transmit rate
setup (eg static management, unicast, multicast rates.)
This is based on 802.11-2020 Section 21.5 (Parameters for VHT-MCSs.)
Differential Revision: https://reviews.freebsd.org/D48608
Reviewed by: bz
---
sys/net80211/ieee80211_phy.c | 86 ++++++++++++++++++++++++++++++++++++++++++++
sys/net80211/ieee80211_phy.h | 7 ++++
2 files changed, 93 insertions(+)
diff --git a/sys/net80211/ieee80211_phy.c b/sys/net80211/ieee80211_phy.c
index eaad7dde0653..9c2b1197564a 100644
--- a/sys/net80211/ieee80211_phy.c
+++ b/sys/net80211/ieee80211_phy.c
@@ -621,3 +621,89 @@ ieee80211_compute_duration_ht(uint32_t frameLen, uint16_t rate,
#undef HT_L_LTF
#undef HT_L_STF
#undef OFDM_PLCP_BITS
+
+
+/*
+ * A bitmask of allowable rates for each spatial stream
+ * and bandwidth.
+ *
+ * This is based on 802.11-2020 21.5 (Parameters for VHT-MCSs.)
+ *
+ * Not all MCS rate / channel widths are valid, as there needs
+ * to be an integer number of symbols and the number of tones
+ * available for each channel bandwidth doesn't result in
+ * an integer value.
+ */
+static uint16_t ieee80211_vht_mcs_allowed_list_20[] = {
+ 0x01ff, 0x01ff, 0x03ff, 0x01ff, 0x01ff, 0x03ff, 0x01ff, 0x01ff,
+};
+
+static uint16_t ieee80211_vht_mcs_allowed_list_40[] = {
+ 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff,
+};
+
+static uint16_t ieee80211_vht_mcs_allowed_list_80[] = {
+ 0x03ff, 0x03ff, 0x03bf, 0x03ff, 0x03ff, 0x01ff, 0x03bf, 0x03ff,
+};
+
+static uint16_t ieee80211_vht_mcs_allowed_list_160[] = {
+ 0x03ff, 0x03ff, 0x01ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff,
+};
+
+/**
+ * @brief Fetch the allowable MCS mask for the given channel bandwidth and NSS
+ *
+ * Return a bitmask of valid MCS rates from 0..9 given a channel bandwith
+ * and number of spatial streams.
+ *
+ * See 802.11-2020 21.5 (Parameters for VHT-MCSs) for more details.
+ *
+ * @param bw channel bandwidth, via enum ieee80211_sta_rx_bw
+ * @param nss number of spatial streams, 1..8
+ * @returns bitmask of valid MCS rates from 0..9
+ */
+uint16_t
+ieee80211_phy_vht_get_mcs_mask(enum ieee80211_sta_rx_bw bw, uint8_t nss)
+{
+ if (nss == 0 || nss > 8)
+ return (0);
+
+ switch (bw) {
+ case IEEE80211_STA_RX_BW_20:
+ return (ieee80211_vht_mcs_allowed_list_20[nss - 1]);
+ case IEEE80211_STA_RX_BW_40:
+ return (ieee80211_vht_mcs_allowed_list_40[nss - 1]);
+ case IEEE80211_STA_RX_BW_80:
+ return (ieee80211_vht_mcs_allowed_list_80[nss - 1]);
+ case IEEE80211_STA_RX_BW_160:
+ return (ieee80211_vht_mcs_allowed_list_160[nss - 1]);
+ case IEEE80211_STA_RX_BW_320:
+ /* invalid for VHT */
+ return (0);
+ }
+}
+
+/**
+ * @brief Check if the given NSS/MCS combination is valid for the given channel
+ * bandwidth
+ *
+ * See 802.11-2020 21.5 (Parameters for VHT-MCSs) for more details.
+ *
+ * @param bw channel bandwidth, via enum ieee80211_sta_rx_bw
+ * @param nss number of spatial streams, 1..8
+ * @param mcs MCS rate, 0..9
+ * @retval true if the NSS / MCS / bandwidth combination is valid
+ * @retval false if the NSS / MCS / bandwidth combination is not valid
+ */
+bool
+ieee80211_phy_vht_validate_mcs(enum ieee80211_sta_rx_bw bw, uint8_t nss,
+ uint8_t mcs)
+{
+ uint16_t mask;
+
+ mask = ieee80211_phy_vht_get_mcs_mask(bw, nss);
+ if (mask == 0)
+ return (false);
+
+ return ((mask & (1 << mcs)) != 0);
+}
diff --git a/sys/net80211/ieee80211_phy.h b/sys/net80211/ieee80211_phy.h
index f73abaff85d0..466f59584f2c 100644
--- a/sys/net80211/ieee80211_phy.h
+++ b/sys/net80211/ieee80211_phy.h
@@ -221,5 +221,12 @@ uint32_t ieee80211_compute_duration_ht(uint32_t frameLen,
uint16_t rate, int streams, int isht40,
int isShortGI);
+enum ieee80211_sta_rx_bw;
+
+uint16_t ieee80211_phy_vht_get_mcs_mask(enum ieee80211_sta_rx_bw,
+ uint8_t);
+bool ieee80211_phy_vht_validate_mcs(enum ieee80211_sta_rx_bw,
+ uint8_t, uint8_t);
+
#endif /* _KERNEL */
#endif /* !_NET80211_IEEE80211_PHY_H_ */