git: 7117d83bae36 - stable/14 - LinuxKPI: 802.11: factor out dynamic_rx_chains computation

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 26 Feb 2025 23:46:16 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=7117d83bae368d9240b2596d9db26423877ff4f0

commit 7117d83bae368d9240b2596d9db26423877ff4f0
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-02-24 02:43:27 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-02-26 23:45:57 +0000

    LinuxKPI: 802.11: factor out dynamic_rx_chains computation
    
    For the moment we set dynamic_rx_chains to the rx_nss value which
    should be correct given we count from 1 there too and we call
    lkpi_get_max_rx_chains() after we synced ht/vht initially already.
    
    Long-term some of these counting bits should be further factored
    out into their own functions and used both here and for the sync
    code.
    
    This will likely want to change as well once more dyamic
    synncronization takes place.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 389265e3ca827ad88b3b8ad787251471161d6634)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 30 +++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 4504a8f4f513..b7d3d7a298fc 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -509,6 +509,33 @@ lkpi_sta_sync_from_ni(struct ieee80211_sta *sta, struct ieee80211_node *ni)
 #endif
 }
 
+static uint8_t
+lkpi_get_max_rx_chains(struct ieee80211_node *ni)
+{
+	uint8_t chains;
+#if defined(LKPI_80211_HT) || defined(LKPI_80211_VHT)
+	struct lkpi_sta *lsta;
+	struct ieee80211_sta *sta;
+
+	lsta = ni->ni_drv_data;
+	sta = LSTA_TO_STA(lsta);
+#endif
+
+	chains = 1;
+#if defined(LKPI_80211_HT)
+	IMPROVE("We should factor counting MCS/NSS out for sync and here");
+	if (sta->deflink.ht_cap.ht_supported)
+		chains = MAX(chains, sta->deflink.rx_nss);
+#endif
+
+#if defined(LKPI_80211_VHT)
+	if (sta->deflink.vht_cap.vht_supported)
+		chains = MAX(chains, sta->deflink.rx_nss);
+#endif
+
+	return (chains);
+}
+
 static void
 lkpi_lsta_dump(struct lkpi_sta *lsta, struct ieee80211_node *ni,
     const char *_f, int _l)
@@ -1726,8 +1753,8 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 		chanctx_conf = &lchanctx->chanctx_conf;
 	}
 
-	chanctx_conf->rx_chains_dynamic = 1;
 	chanctx_conf->rx_chains_static = 1;
+	chanctx_conf->rx_chains_dynamic = 1;
 	chanctx_conf->radar_enabled =
 	    (chan->flags & IEEE80211_CHAN_RADAR) ? true : false;
 	chanctx_conf->def.chan = chan;
@@ -1758,6 +1785,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 			chanctx_conf->def.width = NL80211_CHAN_WIDTH_80;
 	}
 #endif
+	chanctx_conf->rx_chains_dynamic = lkpi_get_max_rx_chains(ni);
 	/* Responder ... */
 #if 0
 	chanctx_conf->min_def.chan = chanctx_conf->def.chan;