The branch main has been updated by adrian:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7b0e3c5b2b74f6e249d2820dbac6e420338bd226

commit 7b0e3c5b2b74f6e249d2820dbac6e420338bd226
Author:     Adrian Chadd <adr...@freebsd.org>
AuthorDate: 2025-01-23 02:18:07 +0000
Commit:     Adrian Chadd <adr...@freebsd.org>
CommitDate: 2025-02-26 19:31:02 +0000

    net80211: add ieee80211_vht_node_check_tx_valid_mcs()
    
    Introduce ieee80211_vht_node_check_tx_valid_mcs(), which takes the
    node, bandwidth, NSS and MCS and validates whether that is possible
    to TX to the given node.
    
    Differential Revision:  https://reviews.freebsd.org/D48610
    Reviewed by:    bz, thj
---
 sys/net80211/ieee80211_vht.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
 sys/net80211/ieee80211_vht.h |  2 ++
 2 files changed, 51 insertions(+)

diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c
index e704e0cbd176..703447945845 100644
--- a/sys/net80211/ieee80211_vht.c
+++ b/sys/net80211/ieee80211_vht.c
@@ -1061,3 +1061,52 @@ ieee80211_vht_check_tx_bw(const struct ieee80211_node 
*ni,
                return (false);
        }
 }
+
+/**
+ * @brief Check if the given VHT bw/nss/mcs combination is valid
+ *        for the give node.
+ *
+ * This checks whether the given VHT bw/nss/mcs is valid based on
+ * the negotiated rate mask in the node.
+ *
+ * @param ni   struct ieee80211_node node to check
+ * @param bw   channel bandwidth to check
+ * @param nss  NSS
+ * @param mcs  MCS
+ * @returns True if this combination is available, false otherwise.
+ */
+bool
+ieee80211_vht_node_check_tx_valid_mcs(const struct ieee80211_node *ni,
+    enum ieee80211_sta_rx_bw bw, uint8_t nss, uint8_t mcs)
+{
+       uint8_t mc;
+
+       /* Validate arguments */
+       if (nss < 1 || nss > 8)
+               return (false);
+       if (mcs > 9)
+               return (false);
+
+       /* Check our choice of rate is actually valid */
+       if (!ieee80211_phy_vht_validate_mcs(bw, nss, mcs))
+               return (false);
+
+       /*
+        * Next, check if the MCS rate is available for the
+        * given NSS.
+        */
+       mc = ni->ni_vht_tx_map >> (2*(nss-1)) & 0x3;
+       switch (mc) {
+       case IEEE80211_VHT_MCS_NOT_SUPPORTED:
+               /* Not supported at this NSS */
+               return (false);
+       case IEEE80211_VHT_MCS_SUPPORT_0_9:
+               return (mcs <= 9);
+       case IEEE80211_VHT_MCS_SUPPORT_0_8:
+               return (mcs <= 8);
+       case IEEE80211_VHT_MCS_SUPPORT_0_7:
+               return (mcs <= 7);
+       default:
+               return (false);
+       }
+}
diff --git a/sys/net80211/ieee80211_vht.h b/sys/net80211/ieee80211_vht.h
index a61804a43059..2964de63c343 100644
--- a/sys/net80211/ieee80211_vht.h
+++ b/sys/net80211/ieee80211_vht.h
@@ -67,5 +67,7 @@ void  ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni,
 bool   ieee80211_vht_check_tx_vht(const struct ieee80211_node *);
 bool   ieee80211_vht_check_tx_bw(const struct ieee80211_node *,
            enum ieee80211_sta_rx_bw);
+bool   ieee80211_vht_node_check_tx_valid_mcs(const struct ieee80211_node *,
+           enum ieee80211_sta_rx_bw bw, uint8_t, uint8_t);
 
 #endif /* _NET80211_IEEE80211_VHT_H_ */

Reply via email to