Move throughput estimation into a helper function

This is a step towards allowing this functionality to update the scan
result -based values with the values from a signal poll for the current
BSS.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
This commit is contained in:
Emmanuel Grumbach 2019-12-06 14:27:47 -08:00 committed by Jouni Malinen
parent ef1a45f28a
commit ad06ac0b04
2 changed files with 35 additions and 18 deletions

View File

@ -2248,20 +2248,13 @@ static unsigned int max_vht80_rate(int snr)
}
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)
{
enum local_hw_capab capab = wpa_s->hw_capab;
int rate; /* max legacy rate in 500 kb/s units */
const u8 *ie;
unsigned int est, tmp;
int snr = res->snr;
if (res->est_throughput)
return;
/* Get maximum legacy rate */
rate = wpa_scan_get_max_rate(res);
const u8 *ie;
/* Limit based on estimated SNR */
if (rate > 1 * 2 && snr < 1)
@ -2287,7 +2280,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
est = rate * 500;
if (capab == CAPAB_HT || capab == CAPAB_HT40 || capab == CAPAB_VHT) {
ie = wpa_scan_get_ie(res, WLAN_EID_HT_CAP);
ie = get_ie(ies, ies_len, WLAN_EID_HT_CAP);
if (ie) {
tmp = max_ht20_rate(snr);
if (tmp > est)
@ -2296,7 +2289,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
}
if (capab == CAPAB_HT40 || capab == CAPAB_VHT) {
ie = wpa_scan_get_ie(res, WLAN_EID_HT_OPERATION);
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)) {
tmp = max_ht40_rate(snr);
@ -2307,13 +2300,13 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
if (capab == CAPAB_VHT) {
/* Use +1 to assume VHT is always faster than HT */
ie = wpa_scan_get_ie(res, WLAN_EID_VHT_CAP);
ie = get_ie(ies, ies_len, WLAN_EID_VHT_CAP);
if (ie) {
tmp = max_ht20_rate(snr) + 1;
if (tmp > est)
est = tmp;
ie = wpa_scan_get_ie(res, WLAN_EID_HT_OPERATION);
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)) {
@ -2322,7 +2315,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
est = tmp;
}
ie = wpa_scan_get_ie(res, WLAN_EID_VHT_OPERATION);
ie = get_ie(ies, ies_len, WLAN_EID_VHT_OPERATION);
if (ie && ie[1] >= 1 &&
(ie[2] & VHT_OPMODE_CHANNEL_WIDTH_MASK)) {
tmp = max_vht80_rate(snr) + 1;
@ -2332,9 +2325,30 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
}
}
/* TODO: channel utilization and AP load (e.g., from AP Beacon) */
return est;
}
res->est_throughput = est;
void scan_est_throughput(struct wpa_supplicant *wpa_s,
struct wpa_scan_res *res)
{
int rate; /* max legacy rate in 500 kb/s units */
int snr = res->snr;
const u8 *ies = (const void *) (res + 1);
size_t ie_len = res->ie_len;
if (res->est_throughput)
return;
/* Get maximum legacy rate */
rate = wpa_scan_get_max_rate(res);
if (!ie_len)
ie_len = res->beacon_ie_len;
res->est_throughput =
wpas_get_est_tpt(wpa_s, ies, res->ie_len, rate, snr);
/* TODO: channel utilization and AP load (e.g., from AP Beacon) */
}

View File

@ -82,6 +82,9 @@ void filter_scan_res(struct wpa_supplicant *wpa_s,
void scan_snr(struct wpa_scan_res *res);
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);
void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
#endif /* SCAN_H */