From 46f897619621d8e036644b197bee7c3f7a1f6999 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Date: Tue, 4 May 2021 19:16:44 +0530 Subject: [PATCH] Prefer 6 GHz APs for connection in BSS selection Prefer 6 GHz APs when estimated throughputs are equal with APs from the 2.4/5 GHz bands while selecting APs for connection. Also add a 6 GHz specific noise floor default value for the 6 GHz band (with the same value as was used for 5 GHz previously) to make this step clearer. Signed-off-by: Jouni Malinen --- wpa_supplicant/scan.c | 9 ++++++--- wpa_supplicant/scan.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 76d3d6566..c624c3c84 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -2047,6 +2047,8 @@ static int wpa_scan_result_compar(const void *a, const void *b) } if ((snr_a && snr_b && abs(snr_b - snr_a) < 5) || (wa->qual && wb->qual && abs(wb->qual - wa->qual) < 10)) { + if (is_6ghz_freq(wa->freq) ^ is_6ghz_freq(wb->freq)) + return is_6ghz_freq(wa->freq) ? -1 : 1; if (IS_5GHZ(wa->freq) ^ IS_5GHZ(wb->freq)) return IS_5GHZ(wa->freq) ? -1 : 1; } @@ -2207,9 +2209,10 @@ void filter_scan_res(struct wpa_supplicant *wpa_s, void scan_snr(struct wpa_scan_res *res) { if (res->flags & WPA_SCAN_NOISE_INVALID) { - res->noise = IS_5GHZ(res->freq) ? - DEFAULT_NOISE_FLOOR_5GHZ : - DEFAULT_NOISE_FLOOR_2GHZ; + res->noise = is_6ghz_freq(res->freq) ? + DEFAULT_NOISE_FLOOR_6GHZ : + (IS_5GHZ(res->freq) ? + DEFAULT_NOISE_FLOOR_5GHZ : DEFAULT_NOISE_FLOOR_2GHZ); } if (res->flags & WPA_SCAN_LEVEL_DBM) { diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index bcf3838b0..d1780eb09 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -16,6 +16,7 @@ */ #define DEFAULT_NOISE_FLOOR_2GHZ (-89) #define DEFAULT_NOISE_FLOOR_5GHZ (-92) +#define DEFAULT_NOISE_FLOOR_6GHZ (-92) /* * Channels with a great SNR can operate at full rate. What is a great SNR? @@ -30,7 +31,7 @@ #define GREAT_SNR 25 #define IS_2P4GHZ(n) (n >= 2412 && n <= 2484) -#define IS_5GHZ(n) (n > 4000) +#define IS_5GHZ(n) (n > 4000 && n < 5895) int wpa_supplicant_enabled_networks(struct wpa_supplicant *wpa_s); void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);