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 v2 2/4] knownnetworks: sort known frequencies by BSS rank
Date: Wed, 24 Jan 2024 05:39:59 -0800	[thread overview]
Message-ID: <20240124134001.20453-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20240124134001.20453-1-prestwoj@gmail.com>

Currently a quick scan uses the entire known frequency list so
ordering really doesn't matter but improvements will be made here
to make quick scans "quicker" for large network deployments (with
many known frequencies).

To prepare for this the known frequency list has been changed to
be sorted by BSS rank rather than most recently seen. This makes
a lot more sense because IWD should prefer to scan frequencies
that had higher ranked BSS's, not just frequencies that were scanned
last on the most recent scan.

As far as the disk sync goes the ranking is not included, but
ordering is. This really isn't a limitation because when IWD starts
up there isn't any guarantee its in the same physical location so
old scan ranks are likely not valid anymore. The first set of scans
will begin replacing the frequencies loaded from disk.
---
 src/knownnetworks.c | 16 ++++++++++++++--
 src/knownnetworks.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index f6284fdc..6e549e02 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -562,9 +562,19 @@ static bool known_frequency_match(const void *a, const void *b)
 	return known_freq->frequency == *frequency;
 }
 
+static int known_frequency_compare(const void *a, const void *b,
+					void *user_data)
+{
+	const struct known_frequency *kf_a = a;
+	const struct known_frequency *kf_b = b;
+
+	return (kf_b->rank > kf_a->rank) ? 1 : -1;
+}
+
 /*
  * Adds a frequency to the 'known' set of frequencies that this network
- * operates on.  The list is sorted according to most-recently seen
+ * operates on.  The list is sorted according to the rank of the BSS on that
+ * frequency.
  */
 int known_network_add_frequency(struct network_info *info, struct scan_bss *bss)
 {
@@ -578,9 +588,11 @@ int known_network_add_frequency(struct network_info *info, struct scan_bss *bss)
 	if (!known_freq) {
 		known_freq = l_new(struct known_frequency, 1);
 		known_freq->frequency = bss->frequency;
+		known_freq->rank = bss->rank;
 	}
 
-	l_queue_push_head(info->known_frequencies, known_freq);
+	l_queue_insert(info->known_frequencies, known_freq,
+			known_frequency_compare, NULL);
 
 	return 0;
 }
diff --git a/src/knownnetworks.h b/src/knownnetworks.h
index 9f81e308..36106501 100644
--- a/src/knownnetworks.h
+++ b/src/knownnetworks.h
@@ -96,6 +96,7 @@ typedef void (*known_networks_destroy_func_t)(void *user_data);
 
 struct known_frequency {
 	uint32_t frequency;
+	uint16_t rank;
 };
 
 void __network_config_parse(const struct l_settings *settings,
-- 
2.34.1


  reply	other threads:[~2024-01-24 13:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 13:39 [PATCH v2 1/4] knownnetworks: pass scan_bss to known_network_add_frequency James Prestwood
2024-01-24 13:39 ` James Prestwood [this message]
2024-01-24 18:10   ` [PATCH v2 2/4] knownnetworks: sort known frequencies by BSS rank Denis Kenzior
2024-01-24 18:33     ` James Prestwood
2024-01-24 18:44       ` Denis Kenzior
2024-01-24 18:55         ` James Prestwood
2024-01-24 19:06           ` Denis Kenzior
2024-01-25 13:21             ` James Prestwood
2024-01-25 15:39               ` Denis Kenzior
2024-01-24 13:40 ` [PATCH v2 3/4] station: knownnetworks: limit quick scans to 5 freqs per network James Prestwood
2024-01-24 18:21   ` Denis Kenzior
2024-01-24 13:40 ` [PATCH v2 4/4] auto-t: add test for known frequency sorting/maximum James Prestwood
2024-01-24 18:16 ` [PATCH v2 1/4] knownnetworks: pass scan_bss to known_network_add_frequency Denis Kenzior

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=20240124134001.20453-2-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