git: 2b93e1f9bafd - stable/14 - LinuxKPI: 802.11: add further checks for deflink.supp_rates[]

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

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

commit 2b93e1f9bafde3be0a493e5289cc1c6b8286ab1a
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-12-30 06:35:03 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-02-26 02:39:23 +0000

    LinuxKPI: 802.11: add further checks for deflink.supp_rates[]
    
    When setting the per-band supp_rates bitfield check for mandatory
    rates only.  We cannot easily say at that point for 2Ghz whether
    11g is supported so assume these days it is not pure-b.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 73cd1c5d44ead3b84cebcc0c24278429afa9e6ec)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 455b86284a7a..1255691ccf70 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -550,10 +550,30 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN],
 			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);
+			switch (band) {
+			case NL80211_BAND_2GHZ:
+				switch (supband->bitrates[i].bitrate) {
+				case 240:	/* 11g only */
+				case 120:	/* 11g only */
+				case 110:
+				case 60:	/* 11g only */
+				case 55:
+				case 20:
+				case 10:
+					sta->deflink.supp_rates[band] |= BIT(i);
+					break;
+				}
+				break;
+			case NL80211_BAND_5GHZ:
+				switch (supband->bitrates[i].bitrate) {
+				case 240:
+				case 120:
+				case 60:
+					sta->deflink.supp_rates[band] |= BIT(i);
+					break;
+				}
+				break;
+			}
 		}
 	}