public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 3/4] station: knownnetworks: limit quick scans to 5 freqs per network
Date: Fri, 26 Jan 2024 12:22:42 -0800	[thread overview]
Message-ID: <20240126202243.91947-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20240126202243.91947-1-prestwoj@gmail.com>

In very large network deployments there could be a vast amount of APs
which could create a large known frequency list after some time once
all the APs are seen in scan results. This then increases the quick
scan time significantly, in the very worst case (but unlikely) just
as long as a full scan.

To help with this support in knownnetworks was added to limit the
number of frequencies per network. Station will now only get 5
recent frequencies per network making the maximum frequencies 25
in the worst case (~2.5s scan).

The magic values are now defines, and the recent roam frequencies
was also changed to use this define as well.
---
 src/knownnetworks.c | 30 +++++++++++++++++++-----------
 src/knownnetworks.h |  6 ++++--
 src/station.c       | 10 ++++++++--
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index 04ce74ec..fc810057 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -517,8 +517,23 @@ struct network_info *known_networks_find(const char *ssid,
 	return l_queue_find(known_networks, network_info_match, &query);
 }
 
+static void known_network_append_frequencies(const struct network_info *info,
+						struct scan_freq_set *set,
+						uint8_t max)
+{
+	const struct l_queue_entry *entry;
+
+	for (entry = l_queue_get_entries(info->known_frequencies); entry && max;
+					entry = entry->next, max--) {
+		const struct known_frequency *known_freq = entry->data;
+
+		scan_freq_set_add(set, known_freq->frequency);
+	}
+}
+
 struct scan_freq_set *known_networks_get_recent_frequencies(
-						uint8_t num_networks_tosearch)
+						uint8_t num_networks_tosearch,
+						uint8_t freqs_per_network)
 {
 	/*
 	 * This search function assumes that the known networks are always
@@ -527,10 +542,9 @@ struct scan_freq_set *known_networks_get_recent_frequencies(
 	 * list.
 	 */
 	const struct l_queue_entry *network_entry;
-	const struct l_queue_entry *freq_entry;
 	struct scan_freq_set *set;
 
-	if (!num_networks_tosearch)
+	if (!num_networks_tosearch || !freqs_per_network)
 		return NULL;
 
 	set = scan_freq_set_new();
@@ -541,14 +555,8 @@ struct scan_freq_set *known_networks_get_recent_frequencies(
 						num_networks_tosearch--) {
 		const struct network_info *network = network_entry->data;
 
-		for (freq_entry = l_queue_get_entries(
-						network->known_frequencies);
-				freq_entry; freq_entry = freq_entry->next) {
-			const struct known_frequency *known_freq =
-							freq_entry->data;
-
-			scan_freq_set_add(set, known_freq->frequency);
-		}
+		known_network_append_frequencies(network, set,
+							freqs_per_network);
 	}
 
 	return set;
diff --git a/src/knownnetworks.h b/src/knownnetworks.h
index e8ffac0b..741d42ed 100644
--- a/src/knownnetworks.h
+++ b/src/knownnetworks.h
@@ -113,8 +113,10 @@ struct network_info *known_networks_find(const char *ssid,
 						enum security security);
 
 struct scan_freq_set *known_networks_get_recent_frequencies(
-						uint8_t num_networks_tosearch);
-int known_network_add_frequency(struct network_info *info, uint32_t frequency);
+						uint8_t num_networks_tosearch,
+						uint8_t freqs_per_network);
+int known_network_add_frequency(struct network_info *info,
+				uint32_t frequency);
 void known_network_frequency_sync(struct network_info *info);
 
 uint32_t known_networks_watch_add(known_networks_watch_func_t func,
diff --git a/src/station.c b/src/station.c
index b186c505..8a5f4e18 100644
--- a/src/station.c
+++ b/src/station.c
@@ -64,6 +64,9 @@
 #include "src/eap-tls-common.h"
 #include "src/storage.h"
 
+#define STATION_RECENT_NETWORK_LIMIT	5
+#define STATION_RECENT_FREQS_LIMIT	5
+
 static struct l_queue *station_list;
 static uint32_t netdev_watch;
 static uint32_t mfp_setting;
@@ -1438,7 +1441,9 @@ static int station_quick_scan_trigger(struct station *station)
 		return -EAGAIN;
 	}
 
-	known_freq_set = known_networks_get_recent_frequencies(5);
+	known_freq_set = known_networks_get_recent_frequencies(
+						STATION_RECENT_NETWORK_LIMIT,
+						STATION_RECENT_FREQS_LIMIT);
 	if (!known_freq_set)
 		return -ENODATA;
 
@@ -2761,7 +2766,8 @@ static int station_roam_scan_known_freqs(struct station *station)
 	const struct network_info *info = network_get_info(
 						station->connected_network);
 	struct scan_freq_set *freqs = network_info_get_roam_frequencies(info,
-					station->connected_bss->frequency, 5);
+					station->connected_bss->frequency,
+					STATION_RECENT_FREQS_LIMIT);
 	int r = -ENODATA;
 
 	if (!freqs)
-- 
2.34.1


  parent reply	other threads:[~2024-01-26 20:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 20:22 [PATCH v3 1/4] network: add network_update_known_frequencies James Prestwood
2024-01-26 20:22 ` [PATCH v3 2/4] station: use network_update_known_frequencies James Prestwood
2024-01-26 20:22 ` James Prestwood [this message]
2024-01-26 20:22 ` [PATCH v3 4/4] auto-t: add test for known frequency sorting/maximum James Prestwood
2024-01-30  2:54 ` [PATCH v3 1/4] network: add network_update_known_frequencies Denis Kenzior
2024-01-30 12:30   ` James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240126202243.91947-3-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox