[PATCH 2/2] Apply a symmetrical bias against moving away from higher bands

Matthew Wang matthewmwang at chromium.org
Thu Dec 28 13:03:43 PST 2023


There is currently a bias towards moving to higher bands but not one
against moving away from them. Fix that.

Signed-off-by: Matthew Wang <matthewmwang at chromium.org>
---
 wpa_supplicant/events.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 47169c181..ae2a814fb 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2129,11 +2129,22 @@ wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s,
 }
 
 
+static int wpas_evaluate_band_score(int frequency) {
+	if (is_6ghz_freq(frequency)) {
+		return 2;
+	} else if (IS_5GHZ(frequency)) {
+		return 1;
+	}
+	return 0;
+}
+
+
 int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
 					   struct wpa_bss *current_bss,
 					   struct wpa_bss *selected)
 {
 	int min_diff, diff;
+	int cur_band_score, sel_band_score;
 	int to_5ghz, to_6ghz;
 	int cur_level, sel_level;
 	unsigned int cur_est, sel_est;
@@ -2280,10 +2291,9 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
 	else if (sel_est > cur_est)
 		min_diff--;
 
-	if (to_5ghz)
-		min_diff -= 2;
-	if (to_6ghz)
-		min_diff -= 2;
+	cur_band_score = wpas_evaluate_band_score(current_bss->freq);
+	sel_band_score = wpas_evaluate_band_score(selected->freq);
+	min_diff += (cur_band_score - sel_band_score) * 2;
 	if (wpa_s->signal_threshold && cur_level <= wpa_s->signal_threshold &&
 	    sel_level > wpa_s->signal_threshold)
 		min_diff -= 2;
-- 
2.43.0.472.g3155946c3a-goog




More information about the Hostap mailing list