git: d4a529ad0d56 - main - LinuxKPI: 802.11: add 11g check to lkpi_ic_getradiocaps()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 22 Jun 2026 05:31:03 UTC
The branch main has been updated by bz:

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

commit d4a529ad0d5638ad3e8d27815948b0a7c4628e3f
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-06-22 00:10:22 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-06-22 01:21:38 +0000

    LinuxKPI: 802.11: add 11g check to lkpi_ic_getradiocaps()
    
    Replace an early comment with code and add a (simplified) 11g check.
    We make use of the annotated bitrate flags we added (see
    lkpi_wiphy_band_annotate()) and check if on the 2GHz band there are
    any bitrates which are 11g.  Upon the first one found we do set the
    IEEE80211_MODE_11G to announce to net80211 that the 2.4Ghz channels
    may operate on 11g as well.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 6f5e2756f421..95385474840a 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -6732,18 +6732,28 @@ lkpi_ic_getradiocaps(struct ieee80211com *ic, int maxchan,
 	if (hw->wiphy->bands[NL80211_BAND_2GHZ] != NULL)
 		nchans = hw->wiphy->bands[NL80211_BAND_2GHZ]->n_channels;
 	if (nchans > 0) {
+		struct ieee80211_supported_band *supband;
+
 		memset(bands, 0, sizeof(bands));
 		chan_flags = 0;
 		setbit(bands, IEEE80211_MODE_11B);
-		/* XXX-BZ unclear how to check for 11g. */
+
+		/* Check for 11g (simplified). */
+		supband = hw->wiphy->bands[NL80211_BAND_2GHZ];
+		for (i = 0; i < supband->n_bitrates; i++) {
+			if ((supband->bitrates[i].flags &
+			    IEEE80211_RATE_MANDATORY_G) != 0) {
+				setbit(bands, IEEE80211_MODE_11G);
+				break;
+			}
+		}
 
 		IMPROVE("the bitrates may have flags?");
-		setbit(bands, IEEE80211_MODE_11G);
 
 		lkpi_ic_getradiocaps_ht(ic, hw, bands, &chan_flags,
 		    NL80211_BAND_2GHZ);
 
-		channels = hw->wiphy->bands[NL80211_BAND_2GHZ]->channels;
+		channels = supband->channels;
 		for (i = 0; i < nchans && *n < maxchan; i++) {
 			uint32_t nflags = 0;
 			int cflags = chan_flags;