diff mbox series

scan: Add support for separate 6Ghz band modifier

Message ID 20221113140735.2325-1-marcel@holtmann.org (mailing list archive)
State New
Headers show
Series scan: Add support for separate 6Ghz band modifier | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Marcel Holtmann Nov. 13, 2022, 2:07 p.m. UTC
---
 src/iwd.config.rst |  7 +++++++
 src/scan.c         | 13 +++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

Comments

Denis Kenzior Nov. 14, 2022, 5:09 p.m. UTC | #1
Hi Marcel,

On 11/13/22 08:07, Marcel Holtmann wrote:
> ---
>   src/iwd.config.rst |  7 +++++++
>   src/scan.c         | 13 +++++++++++--
>   2 files changed, 18 insertions(+), 2 deletions(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/iwd.config.rst b/src/iwd.config.rst
index bafb6b8513db..d77ed0776da8 100644
--- a/src/iwd.config.rst
+++ b/src/iwd.config.rst
@@ -310,6 +310,13 @@  autoconnect purposes.
        networks are highly RSSI sensitive, so it is still possible for IWD to
        prefer 2.4Ghz APs in certain circumstances.
 
+   * - BandModifier6Ghz
+     - Values: floating point value (default: **1.0**)
+
+       Increase or decrease the preference for 6GHz access points by increasing
+       or decreasing the value of this modifier.  Since 6GHz networks are highly
+       RSSI sensitive, this gives an option to prefer 6GHz APs over 5GHz APs.
+
 Scan
 ----
 
diff --git a/src/scan.c b/src/scan.c
index ee2d843c6127..5548914a12de 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -54,6 +54,7 @@ 
 
 /* User configurable options */
 static double RANK_5G_FACTOR;
+static double RANK_6G_FACTOR;
 static uint32_t SCAN_MAX_INTERVAL;
 static uint32_t SCAN_INIT_INTERVAL;
 
@@ -1645,10 +1646,14 @@  static void scan_bss_compute_rank(struct scan_bss *bss)
 
 	rank = (double)bss->data_rate / max_rate * USHRT_MAX;
 
-	/* Prefer 5G/6G networks over 2.4G */
-	if (bss->frequency > 4000)
+	/* Prefer 5G networks over 2.4G and 6G */
+	if (bss->frequency >= 4900 && bss->frequency < 5900)
 		rank *= RANK_5G_FACTOR;
 
+	/* Prefer 6G networks over 2.4G and 5G */
+	if (bss->frequency >= 5900 && bss->frequency < 7200)
+		rank *= RANK_6G_FACTOR;
+
 	/* Rank loaded APs lower and lightly loaded APs higher */
 	if (bss->utilization >= 192)
 		rank *= RANK_HIGH_UTILIZATION_FACTOR;
@@ -2343,6 +2348,10 @@  static int scan_init(void)
 					&RANK_5G_FACTOR))
 		RANK_5G_FACTOR = 1.0;
 
+	if (!l_settings_get_double(config, "Rank", "BandModifier6Ghz",
+					&RANK_6G_FACTOR))
+		RANK_6G_FACTOR = 1.0;
+
 	if (!l_settings_get_uint(config, "Scan", "InitialPeriodicScanInterval",
 					&SCAN_INIT_INTERVAL))
 		SCAN_INIT_INTERVAL = 10;