The branch main has been updated by adrian:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6fef9e7378d0af0e710ce7c3601886410db82cd6

commit 6fef9e7378d0af0e710ce7c3601886410db82cd6
Author:     Adrian Chadd <adr...@freebsd.org>
AuthorDate: 2025-01-15 05:10:59 +0000
Commit:     Adrian Chadd <adr...@freebsd.org>
CommitDate: 2025-02-26 19:31:26 +0000

    net80211: update ieee80211_node_get_txrate_mbit() to support VHT
    
    Update ieee80211_node_get_txrate_mbit() to use
    ieee80211_phy_vht_get_mcs_kbit() to calculate VHT rates.
    
    For now just assume long-GI; I'd have to go and do some extra
    work to figure out which short/long GI flag to use.
    
    Differential Revision:  https://reviews.freebsd.org/D48613
---
 sys/net80211/ieee80211_node.c | 58 ++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 31 deletions(-)

diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index bc0358feb7a8..f4185dfb04d4 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -3292,46 +3292,42 @@ ieee80211_node_set_txrate_vht_rate(struct 
ieee80211_node *ni,
 uint32_t
 ieee80211_node_get_txrate_kbit(struct ieee80211_node *ni)
 {
-       uint32_t mbps;
+       uint32_t kbps;
 
-       /*
-        * TODO: only handle legacy/HT rates, VHT will need
-        * to use other logic.
-        */
        switch (ni->ni_txrate.type) {
        case IEEE80211_NODE_TXRATE_LEGACY:
+               kbps = ni->ni_txrate.dot11rate * 500;
+               break;
        case IEEE80211_NODE_TXRATE_HT:
+               /* Note: Valid for MCS 0..76 */
+               {
+                       const struct ieee80211_mcs_rates *mcs =
+                           &ieee80211_htrates[ni->ni_txrate.dot11rate &
+                           ~IEEE80211_RATE_MCS];
+
+                       if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) {
+                               if (ni->ni_flags & IEEE80211_NODE_SGI40)
+                                       kbps = mcs->ht40_rate_800ns * 500;
+                               else
+                                       kbps = mcs->ht40_rate_400ns * 500;
+                       } else {
+                               if (ni->ni_flags & IEEE80211_NODE_SGI20)
+                                       kbps = mcs->ht20_rate_800ns * 500;
+                               else
+                                       kbps = mcs->ht20_rate_400ns * 500;
+                       }
+               }
                break;
        case IEEE80211_NODE_TXRATE_VHT:
+               /* Note: valid for VHT rates, assumes long-GI for now */
+               kbps = ieee80211_phy_vht_get_mcs_kbit(ni->ni_chw,
+                   ni->ni_txrate.nss, ni->ni_txrate.mcs, false);
+               break;
        default:
-               printf("%s: called for VHT / unknown rate (type %d)!\n",
+               printf("%s: called for unknown rate (type %d)!\n",
                    __func__, ni->ni_txrate.type);
                return (0);
        }
 
-       /* Legacy / MCS rates */
-       if (ni->ni_txrate.dot11rate & IEEE80211_RATE_MCS) {
-               const struct ieee80211_mcs_rates *mcs =
-                   &ieee80211_htrates[ni->ni_txrate.dot11rate &
-                   ~IEEE80211_RATE_MCS];
-               if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) {
-                       /* Note: these are in 1/2Mbit/s units */
-                       if (ni->ni_flags & IEEE80211_NODE_SGI40)
-                               mbps = mcs->ht40_rate_800ns;
-                       else
-                               mbps = mcs->ht40_rate_400ns;
-               } else {
-                       if (ni->ni_flags & IEEE80211_NODE_SGI20)
-                               mbps = mcs->ht20_rate_800ns;
-                       else
-                               mbps = mcs->ht20_rate_400ns;
-               }
-       } else
-               /* Note: CCK/OFDM dot11rate entries are in 1/2Mbit/s units */
-               mbps = ni->ni_txrate.dot11rate;
-
-       /*
-        * Note; 'mbps' in 1/2 Mbit/s units so *500 to make it in kbit/s units.
-        */
-       return (mbps * 500);
+       return (kbps);
 }

Reply via email to