3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

wiphy: Add wiphy_estimate_data_rate

The data rate estimation belongs in wiphy since it should take hardware
capabilities into account.  Right now the data rate calculation simply
assumes the hardware is as capable as the AP.  scan.c will be ported to
use this utility and the data rate estimation will be expanded to take
wiphy capabilities into account.
This commit is contained in:
Denis Kenzior 2021-05-28 16:06:26 -05:00
parent 8679b82db4
commit 74761fcdd3
2 changed files with 55 additions and 0 deletions

View File

@ -687,6 +687,56 @@ void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out)
out[1] = country[1];
}
int wiphy_estimate_data_rate(struct wiphy *wiphy,
const void *ies, uint16_t ies_len,
const struct scan_bss *bss,
uint64_t *out_data_rate)
{
struct ie_tlv_iter iter;
const void *supported_rates = NULL;
const void *ext_supported_rates = NULL;
const void *vht_capabilities = NULL;
const void *ht_capabilities = NULL;
ie_tlv_iter_init(&iter, ies, ies_len);
while (ie_tlv_iter_next(&iter)) {
uint8_t tag = ie_tlv_iter_get_tag(&iter);
switch (tag) {
case IE_TYPE_SUPPORTED_RATES:
if (iter.len > 8)
return -EBADMSG;
supported_rates = iter.data - 2;
break;
case IE_TYPE_EXTENDED_SUPPORTED_RATES:
ext_supported_rates = iter.data - 2;
break;
case IE_TYPE_HT_CAPABILITIES:
if (iter.len != 26)
return -EBADMSG;
ht_capabilities = iter.data - 2;
break;
case IE_TYPE_VHT_CAPABILITIES:
if (iter.len != 12)
return false;
vht_capabilities = iter.data - 2;
break;
default:
break;
}
}
return ie_parse_data_rates(supported_rates, ext_supported_rates,
ht_capabilities,
vht_capabilities,
bss->signal_strength / 100,
out_data_rate);
}
uint32_t wiphy_state_watch_add(struct wiphy *wiphy,
wiphy_state_watch_func_t func,
void *user_data, wiphy_destroy_func_t destroy)

View File

@ -107,6 +107,11 @@ void wiphy_generate_random_address(struct wiphy *wiphy, uint8_t addr[static 6]);
void wiphy_generate_address_from_ssid(struct wiphy *wiphy, const char *ssid,
uint8_t addr[static 6]);
int wiphy_estimate_data_rate(struct wiphy *wiphy,
const void *ies, uint16_t ies_len,
const struct scan_bss *bss,
uint64_t *out_data_rate);
uint32_t wiphy_state_watch_add(struct wiphy *wiphy,
wiphy_state_watch_func_t func, void *user_data,
wiphy_destroy_func_t destroy);