3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2025-01-02 09:22:32 +01:00

scan: Include BSS Load channel utilization in rank

This commit is contained in:
Denis Kenzior 2015-06-10 12:37:50 -05:00
parent 3f2c728242
commit f648a3f0eb
2 changed files with 17 additions and 1 deletions

View File

@ -241,6 +241,14 @@ static bool scan_parse_bss_information_elements(struct scan_bss *bss,
bss->rsne = l_memdup(iter.data - 2, bss->rsne = l_memdup(iter.data - 2,
iter.len + 2); iter.len + 2);
break; break;
case IE_TYPE_BSS_LOAD:
if (ie_parse_bss_load(&iter, NULL, &bss->utilization,
NULL) < 0)
l_warn("Unable to parse BSS Load IE");
else
l_debug("Load: %u/255", bss->utilization);
break;
case IE_TYPE_VENDOR_SPECIFIC: case IE_TYPE_VENDOR_SPECIFIC:
/* Interested only in WPA IE from Vendor data */ /* Interested only in WPA IE from Vendor data */
if (!bss->wpa && is_ie_wpa_ie(iter.data, iter.len)) if (!bss->wpa && is_ie_wpa_ie(iter.data, iter.len))
@ -260,6 +268,7 @@ static struct scan_bss *scan_parse_attr_bss(struct l_genl_attr *attr)
struct scan_bss *bss; struct scan_bss *bss;
bss = l_new(struct scan_bss, 1); bss = l_new(struct scan_bss, 1);
bss->utilization = 127;
while (l_genl_attr_next(attr, &type, &len, &data)) { while (l_genl_attr_next(attr, &type, &len, &data)) {
switch (type) { switch (type) {
@ -361,6 +370,8 @@ void scan_bss_compute_rank(struct scan_bss *bss)
static const double RANK_OPEN_FACTOR = 0.5; static const double RANK_OPEN_FACTOR = 0.5;
static const double RANK_NO_PRIVACY_FACTOR = 0.5; static const double RANK_NO_PRIVACY_FACTOR = 0.5;
static const double RANK_5G_FACTOR = 1.1; static const double RANK_5G_FACTOR = 1.1;
static const double RANK_HIGH_UTILIZATION_FACTOR = 0.8;
static const double RANK_LOW_UTILIZATION_FACTOR = 1.2;
double rank; double rank;
uint32_t irank; uint32_t irank;
@ -391,7 +402,11 @@ void scan_bss_compute_rank(struct scan_bss *bss)
if (bss->frequency > 4000) if (bss->frequency > 4000)
rank *= RANK_5G_FACTOR; rank *= RANK_5G_FACTOR;
/* TODO: Take BSS Load into consideration */ /* Rank loaded APs lower and lighly loaded APs higher */
if (bss->utilization >= 192)
rank *= RANK_HIGH_UTILIZATION_FACTOR;
else if (bss->utilization <= 63)
rank *= RANK_LOW_UTILIZATION_FACTOR;
/* TODO: Take maximum supported rate into consideration */ /* TODO: Take maximum supported rate into consideration */

View File

@ -40,6 +40,7 @@ struct scan_bss {
uint8_t *wpa; uint8_t *wpa;
uint8_t ssid[32]; uint8_t ssid[32];
uint8_t ssid_len; uint8_t ssid_len;
uint8_t utilization;
uint16_t rank; uint16_t rank;
}; };