Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2025 20:27:08 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 09d83ae036c7 - stable/14 - LinuxKPI: 802.11: adjust the hw_scan channel list
Message-ID:  <202502242027.51OKR8G6027198@gitrepo.freebsd.org>

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

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

commit 09d83ae036c7cd28256fede833fbd33f78afd769
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-02-12 23:26:24 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-02-24 20:26:48 +0000

    LinuxKPI: 802.11: adjust the hw_scan channel list
    
    Until net80211 will grow proper scan offload with the various options
    needed and will allow switching the scan engine try to improve the
    situation if we are doing a hw_scan and the device supports
    SINGLE_SCAN_ON_ALL_BANDS.  In that case create the channel list from
    our device information of supported channels rather than from the
    net80211 scan list.  Filter out currently unsupported bands.
    
    While the general "scan EBUSY" problem remains at least in my local
    testing I am seeing a lot more 2 and 5 GHz band results rather than
    being stuck on a single band (as was also often the case with iwm for
    me in the past).
    
    Tested by:      rene (previous version)
    
    (cherry picked from commit c272abc5c6a72881f1252f069d79990201559d1a)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 61 +++++++++++++++++++++++-----
 1 file changed, 50 insertions(+), 11 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index d0dde529c7a8..02cacc62a4c2 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2020-2024 The FreeBSD Foundation
- * Copyright (c) 2020-2024 Bjoern A. Zeeb
+ * Copyright (c) 2020-2025 Bjoern A. Zeeb
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -3268,7 +3268,6 @@ sw_scan:
 		/* XXX want to adjust ss end time/ maxdwell? */
 
 	} else {
-		struct ieee80211_channel *c;
 		struct ieee80211_scan_request *hw_req;
 		struct linuxkpi_ieee80211_channel *lc, **cpp;
 		struct cfg80211_ssid *ssids;
@@ -3285,14 +3284,31 @@ sw_scan:
 
 		band_mask = 0;
 		nchan = 0;
-		for (i = ss->ss_next; i < ss->ss_last; i++) {
-			nchan++;
-			band = lkpi_net80211_chan_to_nl80211_band(
-			    ss->ss_chans[ss->ss_next + i]);
-			band_mask |= (1 << band);
-		}
-
-		if (!ieee80211_hw_check(hw, SINGLE_SCAN_ON_ALL_BANDS)) {
+		if (ieee80211_hw_check(hw, SINGLE_SCAN_ON_ALL_BANDS)) {
+#if 0	/* Avoid net80211 scan lists until it has proper scan offload support. */
+			for (i = ss->ss_next; i < ss->ss_last; i++) {
+				nchan++;
+				band = lkpi_net80211_chan_to_nl80211_band(
+				    ss->ss_chans[ss->ss_next + i]);
+				band_mask |= (1 << band);
+			}
+#else
+			/* Instead we scan for all channels all the time. */
+			for (band = 0; band < NUM_NL80211_BANDS; band++) {
+				switch (band) {
+				case NL80211_BAND_2GHZ:
+				case NL80211_BAND_5GHZ:
+					break;
+				default:
+					continue;
+				}
+				if (hw->wiphy->bands[band] != NULL) {
+					nchan += hw->wiphy->bands[band]->n_channels;
+					band_mask |= (1 << band);
+				}
+			}
+#endif
+		} else {
 			IMPROVE("individual band scans not yet supported, only scanning first band");
 			/* In theory net80211 should drive this. */
 			/* Probably we need to add local logic for now;
@@ -3346,9 +3362,11 @@ sw_scan:
 			*(cpp + i) =
 			    (struct linuxkpi_ieee80211_channel *)(lc + i);
 		}
+#if 0	/* Avoid net80211 scan lists until it has proper scan offload support. */
 		for (i = 0; i < nchan; i++) {
-			c = ss->ss_chans[ss->ss_next + i];
+			struct ieee80211_channel *c;
 
+			c = ss->ss_chans[ss->ss_next + i];
 			lc->hw_value = c->ic_ieee;
 			lc->center_freq = c->ic_freq;	/* XXX */
 			/* lc->flags */
@@ -3357,6 +3375,27 @@ sw_scan:
 			/* lc-> ... */
 			lc++;
 		}
+#else
+		for (band = 0; band < NUM_NL80211_BANDS; band++) {
+			struct ieee80211_supported_band *supband;
+			struct linuxkpi_ieee80211_channel *channels;
+
+			/* Band disabled for scanning? */
+			if ((band_mask & (1 << band)) == 0)
+				continue;
+
+			/* Nothing to scan in band? */
+			supband = hw->wiphy->bands[band];
+			if (supband == NULL || supband->n_channels == 0)
+				continue;
+
+			channels = supband->channels;
+			for (i = 0; i < supband->n_channels; i++) {
+				*lc = channels[i];
+				lc++;
+			}
+		}
+#endif
 
 		hw_req->req.n_ssids = ssid_count;
 		if (hw_req->req.n_ssids > 0) {



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