Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jun 2025 18:37:39 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9df0d1f3d1f3 - main - LinuxKPI: 802.11: ensure bandwidth <= channel bandwidth
Message-ID:  <202506031837.553Ibdu5000408@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

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

commit 9df0d1f3d1f3dd8823800210dd49e40170d5abd8
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-04-23 23:15:12 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-06-03 18:35:09 +0000

    LinuxKPI: 802.11: ensure bandwidth <= channel bandwidth
    
    While we could select our own channel width and station bandwidth
    indepedent of net80211 that is not a good idea and will lead to
    trouble.  Make sure the station bandwidth we select does not
    exceed the bandwidth of the channel we are tuned into.
    
    Now that VHT160 work we may locally disable it (-vht160) and the
    AP may still support it but we would be on a 80Mhz channel.
    Or we do support VHT160 but the AP does not.  Again we would be
    on a 80Mhz channel and not support 160Mhz.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 42d23629bc0f..197604e04490 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -522,6 +522,7 @@ static void
 lkpi_sta_sync_vht_from_ni(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
     struct ieee80211_node *ni)
 {
+	enum ieee80211_sta_rx_bw bw;
 	uint32_t width;
 	int rx_nss;
 	uint16_t rx_mcs_map;
@@ -545,19 +546,38 @@ lkpi_sta_sync_vht_from_ni(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
 	if (ni->ni_vht_chanwidth == IEEE80211_VHT_CHANWIDTH_USE_HT)
 		goto skip_bw;
 
+	bw = sta->deflink.bandwidth;
 	width = (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK);
 	switch (width) {
+	/* Deprecated. */
 	case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ:
 	case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ:
-		sta->deflink.bandwidth = IEEE80211_STA_RX_BW_160;
+		bw = IEEE80211_STA_RX_BW_160;
 		break;
 	default:
 		/* Check if we do support 160Mhz somehow after all. */
 		if ((sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) != 0)
-			sta->deflink.bandwidth = IEEE80211_STA_RX_BW_160;
+			bw = IEEE80211_STA_RX_BW_160;
 		else
-			sta->deflink.bandwidth = IEEE80211_STA_RX_BW_80;
+			bw = IEEE80211_STA_RX_BW_80;
 	}
+	/*
+	 * While we can set what is possibly supported we also need to be
+	 * on a channel which supports that bandwidth; e.g., we can support
+	 * VHT160 but the AP only does VHT80.
+	 * Further ni_chan will also have filtered out what we disabled
+	 * by configuration.
+	 * Once net80211 channel selection is fixed for 802.11-2020 and
+	 * VHT160 we can possibly spare ourselves the above.
+	 */
+	if (bw == IEEE80211_STA_RX_BW_160 &&
+	    !IEEE80211_IS_CHAN_VHT160(ni->ni_chan) &&
+	    !IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan))
+		bw = IEEE80211_STA_RX_BW_80;
+	if (bw == IEEE80211_STA_RX_BW_80 &&
+	    !IEEE80211_IS_CHAN_VHT80(ni->ni_chan))
+		bw = sta->deflink.bandwidth;
+	sta->deflink.bandwidth = bw;
 skip_bw:
 
 	rx_nss = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506031837.553Ibdu5000408>