diff mbox series

[7/7] station: do full passive scan if 6GHz is supported but disabled.

Message ID 20220722163417.1119334-7-prestwoj@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/7] wiphy: fix runtime error from bit shift | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint fail [7/7] station: do full passive scan if 6GHz is supported but disabled. 1: T3 Title has trailing punctuation (.): "[7/7] station: do full passive scan if 6GHz is supported but disabled."

Commit Message

James Prestwood July 22, 2022, 4:34 p.m. UTC
The kernel handles setting the regulatory domain by receiving beacons which
set the country IE. Presumably since most regulatory domains disallow 6GHz
the default (world) domain also disables it. This means until the country
is set, 6GHz is disabled.

This poses a problem for IWD's quick scanning since it only scans a few
frequencies and this likely isn't enough beacons for the firmware to update
the country, leaving 6Ghz inaccessable to the user without manual intervention
(e.g. iw scan passive, or periodic scans by IWD).

To try and work around this limitation the quick scan logic has been updated
to check if a 6GHz AP has been connected to before and if that frequency is
disabled (but supported). If this is the case IWD will opt for a full passive
scan rather than scanning a limited set of frequencies.
---
 src/station.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index 02f21c76..373bd1c3 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1352,12 +1352,35 @@  static void station_quick_scan_destroy(void *userdata)
 
 static int station_quick_scan_trigger(struct station *station)
 {
+	uint32_t max_freq;
 	struct scan_freq_set *known_freq_set;
+	const struct scan_freq_set *supported = wiphy_get_supported_freqs(
+								station->wiphy);
+	const struct scan_freq_set *disabled = wiphy_get_disabled_freqs(
+								station->wiphy);
 
 	known_freq_set = known_networks_get_recent_frequencies(5);
 	if (!known_freq_set)
 		return -ENODATA;
 
+	/*
+	 * This means IWD has previously connected to a 6GHz AP before, but now
+	 * the regulatory domain disallows 6GHz likely caused by a reboot or
+	 * the firmware going down. The only way to re-enable 6GHz is to get
+	 * enough beacons via scanning for the firmware to set the regulatory
+	 * domain and open up the frequencies.
+	 */
+	max_freq = scan_freq_set_max(known_freq_set);
+	if (max_freq > 6000 && scan_freq_set_contains(disabled, max_freq)) {
+		l_debug("6GHz may be available, doing full passive scan");
+		station->quick_scan_id = scan_passive(
+					netdev_get_wdev_id(station->netdev),
+					supported, station_quick_scan_triggered,
+					station_quick_scan_results, station,
+					station_quick_scan_destroy);
+		goto done;
+	}
+
 	if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) {
 		scan_freq_set_free(known_freq_set);
 		return -ENOTSUP;
@@ -1368,6 +1391,7 @@  static int station_quick_scan_trigger(struct station *station)
 						station_quick_scan_triggered,
 						station_quick_scan_results,
 						station_quick_scan_destroy);
+done:
 	scan_freq_set_free(known_freq_set);
 
 	if (!station->quick_scan_id)