git: d42205c0ba27 - stable/13 - LinuxKPI: 802.11: set sta supported legacy rates

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 18 Jan 2023 16:24:56 UTC
The branch stable/13 has been updated by bz:

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

commit d42205c0ba27c2d223d5dbd6bec3d30e1d4e8c45
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-12-31 00:33:34 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-01-18 13:25:57 +0000

    LinuxKPI: 802.11: set sta supported legacy rates
    
    When initializing the sta set the per-band supported legacy rates
    as some drivers take the information from there.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b6b352e4c7125e7d85ba382f05b1bad8454b6233)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 947878449db4..170f6162cd6b 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -192,7 +192,7 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN],
 	struct lkpi_vif *lvif;
 	struct ieee80211_vif *vif;
 	struct ieee80211_sta *sta;
-	int tid;
+	int band, i, tid;
 
 	lsta = malloc(sizeof(*lsta) + hw->sta_data_size, M_LKPI80211,
 	    M_NOWAIT | M_ZERO);
@@ -216,6 +216,8 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN],
 	sta = LSTA_TO_STA(lsta);
 
 	IEEE80211_ADDR_COPY(sta->addr, mac);
+
+	/* TXQ */
 	for (tid = 0; tid < nitems(sta->txq); tid++) {
 		struct lkpi_txq *ltxq;
 
@@ -243,6 +245,24 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN],
 		sta->txq[tid] = &ltxq->txq;
 	}
 
+	/* Deflink information. */
+	for (band = 0; band < NUM_NL80211_BANDS; band++) {
+		struct ieee80211_supported_band *supband;
+
+		supband = hw->wiphy->bands[band];
+		if (supband == NULL)
+			continue;
+
+		for (i = 0; i < supband->n_bitrates; i++) {
+
+			IMPROVE("Further supband->bitrates[i]* checks?");
+			/* or should we get them from the ni? */
+			sta->deflink.supp_rates[band] |= BIT(i);
+		}
+	}
+	IMPROVE("ht, vht, he, ... bandwidth, smps_mode, ..");
+	/* bandwidth = IEEE80211_STA_RX_... */
+
 	/* Deferred TX path. */
 	mtx_init(&lsta->txq_mtx, "lsta_txq", NULL, MTX_DEF);
 	TASK_INIT(&lsta->txq_task, 0, lkpi_80211_txq_task, lsta);