]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Check local supported features for estimating BSS throughputs accurately
authorVamsi Krishna <vamsin@codeaurora.org>
Tue, 4 May 2021 19:15:30 +0000 (00:45 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 7 May 2021 09:27:21 +0000 (12:27 +0300)
Add checks for features supported by the specific hardware mode of the
local device that has the channel for which the throughput is being
estimated instead of assuming the local device supports all optional
features. This is more accurate for cases where the local capabilities
might differ based on the band. In addition, this is in preparation for
extending rate estimates to cover optional VHT and HE features.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpa_supplicant/events.c
wpa_supplicant/scan.c
wpa_supplicant/scan.h
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index b3c07f926b69080e7129fc5452f22bdda8ca2aa7..b511d1cc14575edce08dadf1c4f600adfef6b8bd 100644 (file)
@@ -1853,7 +1853,7 @@ wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s,
        const u8 *ies = wpa_bss_ie_ptr(bss);
        size_t ie_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
 
-       return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr);
+       return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr, bss->freq);
 }
 
 
index c53474dae26b9c1588ec33c4e43fb46215288f1c..63e59fe87671f5c4653611ce7c9c44267c35211e 100644 (file)
@@ -2322,9 +2322,9 @@ static unsigned int max_vht80_rate(int snr)
 
 unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
                              const u8 *ies, size_t ies_len, int rate,
-                             int snr)
+                             int snr, int freq)
 {
-       enum local_hw_capab capab = wpa_s->hw_capab;
+       struct hostapd_hw_modes *hw_mode;
        unsigned int est, tmp;
        const u8 *ie;
 
@@ -2369,7 +2369,10 @@ unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
                rate = 54 * 2;
        est = rate * 500;
 
-       if (capab == CAPAB_HT || capab == CAPAB_HT40 || capab == CAPAB_VHT) {
+       hw_mode = get_mode_with_freq(wpa_s->hw.modes, wpa_s->hw.num_modes,
+                                    freq);
+
+       if (hw_mode && hw_mode->ht_capab) {
                ie = get_ie(ies, ies_len, WLAN_EID_HT_CAP);
                if (ie) {
                        tmp = max_ht20_rate(snr, false);
@@ -2378,7 +2381,8 @@ unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
                }
        }
 
-       if (capab == CAPAB_HT40 || capab == CAPAB_VHT) {
+       if (hw_mode &&
+           (hw_mode->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
                ie = get_ie(ies, ies_len, WLAN_EID_HT_OPERATION);
                if (ie && ie[1] >= 2 &&
                    (ie[3] & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK)) {
@@ -2388,7 +2392,7 @@ unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
                }
        }
 
-       if (capab == CAPAB_VHT) {
+       if (hw_mode && hw_mode->vht_capab) {
                /* Use +1 to assume VHT is always faster than HT */
                ie = get_ie(ies, ies_len, WLAN_EID_VHT_CAP);
                if (ie) {
@@ -2436,7 +2440,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
        if (!ie_len)
                ie_len = res->beacon_ie_len;
        res->est_throughput =
-               wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr);
+               wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr, res->freq);
 
        /* TODO: channel utilization and AP load (e.g., from AP Beacon) */
 }
index 8eb5c73e275e71e0dabbbb5b859fa9adae7f0902..36ca6371a8868f2f4a870282eb7a7cf4f96f2644 100644 (file)
@@ -84,7 +84,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
                         struct wpa_scan_res *res);
 unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
                              const u8 *ies, size_t ies_len, int rate,
-                             int snr);
+                             int snr, int freq);
 void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
 int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
                            enum hostapd_hw_mode band,
index 835b33575760599bd06dd65ff2ccf938c75797b4..aed576c0bf67d99cf10c39a9b23a9ee5227c597b 100644 (file)
@@ -8111,6 +8111,22 @@ struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
 }
 
 
+struct hostapd_hw_modes * get_mode_with_freq(struct hostapd_hw_modes *modes,
+                                            u16 num_modes, int freq)
+{
+       int i, j;
+
+       for (i = 0; i < num_modes; i++) {
+               for (j = 0; j < modes[i].num_channels; j++) {
+                       if (freq == modes[i].channels[j].freq)
+                               return &modes[i];
+               }
+       }
+
+       return NULL;
+}
+
+
 static struct
 wpa_bss_tmp_disallowed * wpas_get_disallowed_bss(struct wpa_supplicant *wpa_s,
                                                 const u8 *bssid)
index 49007cfc2e8fe5a02c7ad27baf83066669ae24b7..6877f5a9960d777a405b6b6aedec1eeccef694d5 100644 (file)
@@ -1701,6 +1701,8 @@ int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd);
 struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
                                   u16 num_modes, enum hostapd_hw_mode mode,
                                   bool is_6ghz);
+struct hostapd_hw_modes * get_mode_with_freq(struct hostapd_hw_modes *modes,
+                                            u16 num_modes, int freq);
 
 void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
                          unsigned int sec, int rssi_threshold);