]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Prefer 6 GHz APs for connection in BSS selection
authorVamsi Krishna <vamsin@codeaurora.org>
Tue, 4 May 2021 13:46:44 +0000 (19:16 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 7 May 2021 10:05:58 +0000 (13:05 +0300)
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 <jouni@codeaurora.org>
wpa_supplicant/scan.c
wpa_supplicant/scan.h

index 76d3d65663c4f9702862fc367a5c3d784905862e..c624c3c84a8c020bb2374dcc85ccbc03e635b0cf 100644 (file)
@@ -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) {
index bcf3838b0b9d8527e8aa5dea36794d249b663f08..d1780eb09979d0d57a863a3bbe1285675ce1460b 100644 (file)
@@ -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);