scan: add colocated scan flag
PATCH 1/12 scan: add colocated scan flag
--- src/scan.c | 2 ++ 1 file changed, 2 insertions(+)
src/scan.c +2 -0
@@ -394,6 +394,8 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,if (params->ap_scan) flags |=NL80211_SCAN_FLAG_AP ; + flags |=NL80211_SCAN_FLAG_COLOCATED_6GHZ ; +if (flags)l_genl_msg_append_attr (msg,NL80211_ATTR_SCAN_FLAGS ,4 , &flags);
Signature · 1 line
2.34.1
PATCH 2/12 ie: add IE's from 802.11ax amendment
--- src/ie.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
src/ie.h +19 -0
@@ -274,10 +274,29 @@ enum ie_type {IE_TYPE_OWE_DH_PARAM =256 +32 ,IE_TYPE_PASSWORD_IDENTIFIER =256 +33 ,IE_TYPE_GLK_GCR_PARAMETER_SET =256 +34 , +IE_TYPE_HE_CAPABILITIES =256 +35 , +IE_TYPE_HE_OPERATION =256 +36 , +IE_TYPE_UORA_PARAMETER_SET =256 +37 , +IE_TYPE_MU_EDCA_PARAMETER_SET =256 +38 , +IE_TYPE_SPATIAL_REUSE_PARAMETER_SET =256 +39 , +/* Reserved 40 */ +IE_TYPE_NDP_FEEDBACK_REPORT_PARAMETER =256 +41 , +IE_TYPE_BSS_COLOR_CHANGE_ANNOUNCEMENT =256 +42 , +IE_TYPE_QUIET_TIME_PERIOD =256 +43 ,IE_TYPE_VENDOR_SPECIFIC_REQUEST =256 +44 , +IE_TYPE_ESS_REPORT =256 +45 , +IE_TYPE_OPS =256 +46 , +IE_TYPE_HE_BSS_LOAD =256 +47 ,IE_TYPE_MAX_CHANNEL_SWITCH_TIME =256 +52 ,IE_TYPE_ESTIMATED_SERVICE_PARAMETERS_OUT =256 +53 ,IE_TYPE_OCI =256 +54 , +IE_TYPE_MULTIPLE_BSSID_CONFIGURATION =256 +55 , +/* Reserved 56 */ +IE_TYPE_KNOWN_BSSID =256 +57 , +IE_TYPE_SHORT_SSID_LIST =256 +58 , +IE_TYPE_HE_6GHZ_BAND_CAPABILITIES =256 +59 , +IE_TYPE_UL_MU_POWER_CAPABILITIES =256 +60 , +/* Reserved 61 - 87 */ IE_TYPE_MSCS_DESCRIPTOR =256 +88 ,IE_TYPE_SUPPLEMENTAL_CLASS_2_CAPABILITIES =256 +90 , IE_TYPE_REJECTED_GROUPS = 256 + 92,
Signature · 1 line
2.34.1
PATCH 3/12 band: add band_freq
In reply to James PrestwoodHE has different rules depending on the frequency, so the band structure also needs to track the frequency for any rate information to have context.
--- src/band.h | 1 + 1 file changed, 1 insertion(+)
src/band.h +1 -0
@@ -50,6 +50,7 @@ struct band_chandef { };struct band { +enum band_freq freq;uint8_t vht_mcs_set[8 ];uint8_t vht_capabilities[4 ];bool vht_supported :1 ;
Signature · 1 line
2.34.1
PATCH 4/12 band: add he_capabilities queue
In reply to James PrestwoodThis queue will hold iftype(s) specific data for HE capabilities. Since the capabilities may differ per-iftype the data is stored as such. Iftypes may share a configuration so the band_he_capabilities structure has a mask for each iftype using that configuration.
--- src/band.c | 3 +++ src/band.h | 8 ++++++++ 2 files changed, 11 insertions(+)
src/band.c +3 -0
@@ -32,6 +32,9 @@void band_free (struct band *band) { +if (band->he_capabilities) +l_queue_destroy (band->he_capabilities, l_free); +l_free (band); }
src/band.h +8 -0
@@ -49,8 +49,16 @@ struct band_chandef {uint32_t center2_frequency; }; +struct band_he_capabilities { +uint32_t iftypes; +uint8_t he_phy_capa[11 ]; +uint8_t he_mcs_set[12 ]; +}; +struct band {enum band_freq freq; +/* Each entry is type struct band_he_capabilities */ +struct l_queue *he_capabilities;uint8_t vht_mcs_set[8 ];uint8_t vht_capabilities[4 ];bool vht_supported :1 ;
Signature · 1 line
2.34.1
PATCH 5/12 wiphy: set band->freq when parsing band info
In reply to James PrestwoodThis sets the band into the 'band' structure in order to support HE data rates.
--- src/wiphy.c | 6 ++++++ 1 file changed, 6 insertions(+)
src/wiphy.c +6 -0
@@ -1203,16 +1203,20 @@ static void parse_supported_bands(struct wiphy *wiphy,while (l_genl_attr_next (bands, &type,NULL ,NULL )) {struct band **bandp;struct band *band; +enum band_freq freq;switch (type) {case NL80211_BAND_2GHZ : bandp = &wiphy->band_2g; + freq =BAND_FREQ_2_4_GHZ ;break ;case NL80211_BAND_5GHZ : bandp = &wiphy->band_5g; + freq =BAND_FREQ_5_GHZ ;break ;case NL80211_BAND_6GHZ : bandp = &wiphy->band_6g; + freq =BAND_FREQ_6_GHZ ;break ;default :continue ;
@@ -1226,6 +1230,8 @@ static void parse_supported_bands(struct wiphy *wiphy,if (!band)continue ; + band->freq = freq; +/* Reset iter to beginning */ if (!l_genl_attr_recurse (bands, &attr)) {band_free (band);
Signature · 1 line
2.34.1
PATCH 6/12 wiphy: use a 16 bit tag for extended IEs
In reply to James PrestwoodIf an extended IE is needed a uint8_t tag would overflow.
--- src/wiphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/wiphy.c +1 -1
@@ -811,7 +811,7 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy,ie_tlv_iter_init (&iter, ies, ies_len);while (ie_tlv_iter_next (&iter)) { -uint8_t tag =ie_tlv_iter_get_tag (&iter); +uint16_t tag =ie_tlv_iter_get_tag (&iter);switch (tag) {case IE_TYPE_SUPPORTED_RATES :
Signature · 1 line
2.34.1
PATCH 7/12 wiphy: make MCS info print more generic
In reply to James PrestwoodWith the addition of HE, the print function for MCS sets needs to change slightly. The maps themselves are the same format, but the values indicate different MCS ranges. Now the three MCS max values are passed in.
--- src/wiphy.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
src/wiphy.c +21 -5
@@ -903,19 +903,35 @@ static void wiphy_print_mcs_indexes(const uint8_t *mcs) } } -static void wiphy_print_vht_mcs_info (const uint8_t *mcs_map, -const char *prefix) +static void wiphy_print_mcs_info (const uint8_t *mcs_map, +const char *prefix, +uint8_t value0, +uint8_t value1, +uint8_t value2) {int i;for (i =14 ; i >=0 ; i -=2 ) { +uint8_t value;int mcs =bit_field (mcs_map[i /8 ], i %8 ,2 );if (mcs ==0x3 )continue ; +switch (mcs) { +case 0 : + value = value0; +break ; +case 1 : + value = value1; +break ; +case 2 : + value = value2; +break ; + } +l_info ("\t\t\tMax %s MCS: 0-%d for NSS: %d" , prefix, - mcs +7 , i /2 +1 ); + value, i /2 +1 );return ; } }
@@ -976,8 +992,8 @@ static void wiphy_print_band_info(struct band *band, const char *name)if (test_bit (band->vht_capabilities,6 ))l_info ("\t\t\tShort GI for 160 and 80 + 80 Mhz" ); -wiphy_print_vht_mcs_info (band->vht_mcs_set,"RX" ); -wiphy_print_vht_mcs_info (band->vht_mcs_set +4 ,"TX" ); +wiphy_print_mcs_info (band->vht_mcs_set,"RX" ,7 ,8 ,9 ); +wiphy_print_mcs_info (band->vht_mcs_set +4 ,"TX" ,7 ,8 ,9 ); } }
Signature · 1 line
2.34.1
PATCH 8/12 wiphy: parse HE capabilities from band info
In reply to James PrestwoodThe HE capabilities information is contained in NL80211_BAND_ATTR_IFTYPE_DATA where each entry is a set of attributes which define the rules for one or more interface types. This patch specifically parses the HE PHY and HE MCS data which will be used for data rate estimation.
Since the set of info is per-iftype(s) the data is stored in a queue where each entry contains the PHY/MCS info, and a uint32 bit mask where each bit index signifies an interface type.
--- src/wiphy.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 3 deletions(-)
src/wiphy.c +177 -3
@@ -936,6 +936,74 @@ static void wiphy_print_mcs_info(const uint8_t *mcs_map, } } +static void wiphy_print_he_capabilities (struct band *band, +const struct band_he_capabilities *he_cap) +{ +int i; +char type_buf[128 ]; +char *s = type_buf; +uint8_t width_set =bit_field (he_cap->he_phy_capa[0 ],1 ,7 ); + +for (i =0 ; i <32 ; i++) { +if (!(he_cap->iftypes & (1 << i))) +continue ; + +if (L_WARN_ON (s >= type_buf +sizeof (type_buf))) +return ; + +switch (i) { +case NETDEV_IFTYPE_ADHOC : + s +=sprintf (s,"%s " ,"Ad-Hoc" ); +break ; +case NETDEV_IFTYPE_STATION : + s +=sprintf (s,"%s " ,"Station" ); +break ; +case NETDEV_IFTYPE_AP : + s +=sprintf (s,"%s " ,"AP" ); +break ; +case NETDEV_IFTYPE_P2P_CLIENT : + s +=sprintf (s,"%s " ,"P2P Client" ); +break ; +case NETDEV_IFTYPE_P2P_GO : + s +=sprintf (s,"%s " ,"P2P GO" ); +break ; + } + } + +l_info ("\t\t\tInterface Types: %s" , type_buf); + +switch (band->freq) { +case BAND_FREQ_2_4_GHZ : +wiphy_print_mcs_info (he_cap->he_mcs_set, +"HE RX <= 80MHz" ,7 ,9 ,11 ); +wiphy_print_mcs_info (he_cap->he_mcs_set +2 , +"HE TX <= 80MHz" ,7 ,9 ,11 ); +break ; +case BAND_FREQ_5_GHZ : +case BAND_FREQ_6_GHZ : +wiphy_print_mcs_info (he_cap->he_mcs_set, +"HE RX <= 80MHz" ,7 ,9 ,11 ); +wiphy_print_mcs_info (he_cap->he_mcs_set +2 , +"HE TX <= 80MHz" ,7 ,9 ,11 ); + +if (test_bit (&width_set,2 )) { +wiphy_print_mcs_info (he_cap->he_mcs_set +4 , +"HE RX <= 160MHz" ,7 ,9 ,11 ); +wiphy_print_mcs_info (he_cap->he_mcs_set +6 , +"HE TX <= 160MHz" ,7 ,9 ,11 ); + } + +if (test_bit (&width_set,3 )) { +wiphy_print_mcs_info (he_cap->he_mcs_set +8 , +"HE RX <= 80+80MHz" ,7 ,9 ,11 ); +wiphy_print_mcs_info (he_cap->he_mcs_set +10 , +"HE TX <= 80+80MHz" ,7 ,9 ,11 ); + } + +break ; + } +} +static void wiphy_print_band_info (struct band *band,const char *name) {int i;
@@ -995,6 +1063,20 @@ static void wiphy_print_band_info(struct band *band, const char *name)wiphy_print_mcs_info (band->vht_mcs_set,"RX" ,7 ,8 ,9 );wiphy_print_mcs_info (band->vht_mcs_set +4 ,"TX" ,7 ,8 ,9 ); } + +if (band->he_capabilities) { +const struct l_queue_entry *entry; + +l_info ("\t\tHE Capabilities" ); + +for (entry =l_queue_get_entries (band->he_capabilities); + entry; entry = entry->next) { +const struct band_he_capabilities *he_cap = entry->data; + +wiphy_print_he_capabilities (band, he_cap); + } + + } }static void wiphy_print_basic_info (struct wiphy *wiphy)
@@ -1208,6 +1290,90 @@ static struct band *band_new_from_message(struct l_genl_attr *band)return ret; } +static uint32_t get_iftypes (struct l_genl_attr *iftypes) +{ +uint16_t type; +uint16_t len; +uint32_t types =0 ; + +while (l_genl_attr_next (iftypes, &type, &len,NULL )) { +if (len !=0 ) +continue ; + + types |= (1 << type); + } + +return types; +} + +static void parse_iftype_attrs (struct band *band,struct l_genl_attr *types) +{ +uint16_t type; +uint16_t len; +const void *data; +unsigned int count =0 ; +struct band_he_capabilities *he_cap = + l_new(struct band_he_capabilities, 1); + +while (l_genl_attr_next (types, &type, &len, &data)) { +struct l_genl_attr iftypes; + +switch (type) { +case NL80211_BAND_IFTYPE_ATTR_IFTYPES : +if (!l_genl_attr_recurse (types, &iftypes)) + goto parse_error; + + he_cap->iftypes =get_iftypes (&iftypes); +break ; +case NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY : +if (len >sizeof (he_cap->he_phy_capa)) +continue ; + +memcpy (he_cap->he_phy_capa, data, len); + count++; +break ; +case NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET : +if (len >sizeof (he_cap->he_mcs_set)) +continue ; + +memcpy (he_cap->he_mcs_set, data, len); + count++; +break ; +default : +break ; + } + } + +/* +* Since the capabilities element indicates what values are present in +* the MCS set ensure both values are parsed +*/ +if (count !=2 || !he_cap->iftypes) + goto parse_error; + +if (!band->he_capabilities) + band->he_capabilities =l_queue_new (); + +l_queue_push_head (band->he_capabilities, he_cap); + +return ; + +parse_error: +l_free (he_cap); +} + +static void parse_band_iftype_data (struct band *band,struct l_genl_attr *ifdata) +{ +while (l_genl_attr_next (ifdata,NULL ,NULL ,NULL )) { +struct l_genl_attr types; + +if (!l_genl_attr_recurse (ifdata, &types)) +continue ; + +parse_iftype_attrs (band, &types); + } +} +static void parse_supported_bands (struct wiphy *wiphy,struct l_genl_attr *bands) {
@@ -1256,15 +1422,17 @@ static void parse_supported_bands(struct wiphy *wiphy, }else band = *bandp; + +while (l_genl_attr_next (&attr, &type, &len, &data)) { -struct l_genl_attr freqs; +struct l_genl_attr nested;switch (type) {case NL80211_BAND_ATTR_FREQS : -if (!l_genl_attr_recurse (&attr, &freqs)) +if (!l_genl_attr_recurse (&attr, &nested))continue ; -parse_supported_frequencies (wiphy, &freqs); +parse_supported_frequencies (wiphy, &nested);break ;case NL80211_BAND_ATTR_RATES :
@@ -1304,6 +1472,12 @@ static void parse_supported_bands(struct wiphy *wiphy,memcpy (band->ht_capabilities, data, len); band->ht_supported = true;break ; +case NL80211_BAND_ATTR_IFTYPE_DATA : +if (!l_genl_attr_recurse (&attr, &nested)) +continue ; + +parse_band_iftype_data (band, &nested); +break ; } }
Signature · 1 line
2.34.1
PATCH 9/12 band: add find_best_mcs_nss
In reply to James PrestwoodThis is a general way of finding the best MCS/NSS values which will work for HT, VHT, and HE by passing in the max MCS values for each value which the MCS map could contain (0, 1, or 2).
--- src/band.c | 75 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 24 deletions(-)
src/band.c +51 -24
@@ -334,6 +334,56 @@ static bool find_best_mcs_vht(uint8_t max_index, enum ofdm_channel_width width,return false; } +static bool find_best_mcs_nss (const uint8_t *rx_map,const uint8_t *tx_map, +uint8_t value0,uint8_t value1,uint8_t value2, +uint32_t *mcs_out,uint32_t *nss_out) +{ +uint32_t nss =0 ; +uint32_t max_mcs =0 ; +int bitoffset; + +for (bitoffset =14 ; bitoffset >=0 ; bitoffset -=2 ) { +uint8_t rx_val =bit_field (rx_map[bitoffset /8 ], + bitoffset %8 ,2 ); +uint8_t tx_val =bit_field (tx_map[bitoffset /8 ], + bitoffset %8 ,2 ); + +/* +* 0 indicates support for MCS 0 - value0 +* 1 indicates support for MCS 0 - value1 +* 2 indicates support for MCS 0 - value2 +* 3 indicates no support +*/ + +if (rx_val ==3 || tx_val ==3 ) +continue ; + +/* rx_val/tx_val tells us which value# to use */ + max_mcs =minsize (rx_val, tx_val); +switch (max_mcs) { +case 0 : + max_mcs = value0; +break ; +case 1 : + max_mcs = value1; +break ; +case 2 : + max_mcs = value2; +break ; + } + + nss = bitoffset /2 +1 ; +break ; + } + +if (!nss) +return false; + + *nss_out = nss; + *mcs_out = max_mcs; + +return true; +}/* * IEEE 802.11 - Table 9-250 *
@@ -355,7 +405,6 @@ int band_estimate_vht_rx_rate(const struct band *band,uint32_t max_mcs =7 ;/* MCS 0-7 for NSS:1 is always supported */ const uint8_t *rx_mcs_map;const uint8_t *tx_mcs_map; -int bitoffset;uint8_t chan_width;uint8_t channel_offset;bool sgi;
@@ -378,29 +427,7 @@ int band_estimate_vht_rx_rate(const struct band *band, rx_mcs_map = band->vht_mcs_set; tx_mcs_map = vhtc +2 +8 ; -for (bitoffset =14 ; bitoffset >=0 ; bitoffset -=2 ) { -uint8_t rx_val =bit_field (rx_mcs_map[bitoffset /8 ], - bitoffset %8 ,2 ); -uint8_t tx_val =bit_field (tx_mcs_map[bitoffset /8 ], - bitoffset %8 ,2 ); - -/* -* 0 indicates support for MCS 0-7 -* 1 indicates support for MCS 0-8 -* 2 indicates support for MCS 0-9 -* 3 indicates no support -*/ - -if (rx_val ==3 || tx_val ==3 ) -continue ; - -/* 7 + rx_val/tx_val gives us the maximum mcs index */ - max_mcs =minsize (rx_val, tx_val) +7 ; - nss = bitoffset /2 +1 ; -break ; - } - -if (!nss) +if (!find_best_mcs_nss (rx_mcs_map, tx_mcs_map,7 ,8 ,9 , &max_mcs, &nss))return -EBADMSG ;/*
Signature · 1 line
2.34.1
PATCH 10/12 band: add band_estimate_he_rx_rate
In reply to James PrestwoodSimilar to the HT/VHT APIs, this estimates the data rate based on the HE Capabilities element, in addition to our own capabilities. The logic is much the same as HT/VHT. The major difference being that HE uses several MCS tables depending on the channel width. Each width MCS set is checked (if supported) and the highest estimated rate out of all the MCS sets is used.
--- src/band.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/band.h | 3 +- 2 files changed, 268 insertions(+), 9 deletions(-)
src/band.c +266 -8
@@ -28,7 +28,8 @@#include "ell/useful.h" -#include "band.h" +#include "src/band.h" +#include "src/netdev.h" void band_free (struct band *band) {
@@ -125,14 +126,21 @@ int band_estimate_nonht_rate(const struct band *band, }/* -* Base RSSI values for 20MHz (both HT and VHT) channel. These values can be +* Base RSSI values for 20MHz (HT, VHT and HE) channel. These values can be * used to calculate the minimum RSSI values for all other channel widths. HT -* MCS indexes are grouped into ranges of 8 (per spatial stream) where VHT are -* grouped in chunks of 10. This just means HT will not use the last two -* index's of this array. +* MCS indexes are grouped into ranges of 8 (per spatial stream), VHT in groups +* of 10 and HE in groups of 12. This just means HT will not use the last four +* index's of this array, and VHT won't use the last two. +* +* Note: The values here are not based on anything from 802.11 but data +* found elsewhere online (presumably from testing, we hope). The two +* indexes for HE (MCS 11/12) are not based on any data, but just +* increased by 3dB compared to the previous value. We consider this good +* enough for its purpose to estimate the date rate for network/BSS +* preference. */ -static const int32_t ht_vht_base_rssi[] = { --82 ,-79 ,-77 ,-74 ,-70 ,-66 ,-65 ,-64 ,-59 ,-57 +static const int32_t ht_vht_he_base_rssi[] = { +-82 ,-79 ,-77 ,-74 ,-70 ,-66 ,-65 ,-64 ,-59 ,-57 ,-54 ,-51 };/*
@@ -194,7 +202,7 @@ bool band_ofdm_rate(uint8_t index, enum ofdm_channel_width width,uint64_t rate;int32_t width_adjust = width *3 ; -if (rssi < ht_vht_base_rssi[index] + width_adjust) +if (rssi < ht_vht_he_base_rssi[index] + width_adjust)return false; rate = ht_vht_rates[width][index];
@@ -495,6 +503,256 @@ try_vht80:return -ENETUNREACH ; } +/* +* Data Rate for HE is much the same as HT/VHT but some additional MCS indexes +* were added. This mean rfactors, and nbpscs will contain two additional +* values: +* +* rfactors.extend([3/4, 5/6]) +* nbpscs.extend([10, 10]) +* +* The guard interval also differs: +* +* Tdft = 12.8us +* Tgi = 0.8, 1.6 or 2.3us +* +* The Nsd values for HE are: +* +* Nsd = [234, 468, 980, 1960] +* +* The formula is identical to HT/VHT: +* +* Nsd * Nbpscs * R * Nss / (Tdft + Tgi) +* +* Note: The table below assumes a 0.8us GI. There isn't any way to know what +* GI will be used for an actual connection, so assume the best. +*/ +static uint64_t he_rates[5 ][12 ] = { +/* no-HT not applicable */ + [BAND_CHANDEF_WIDTH_20 ] = { +8600000ULL ,17200000ULL ,25800000ULL ,34400000ULL , +51600000ULL ,68800000ULL ,77400000ULL ,86000000ULL , +103200000ULL ,114700000ULL ,129000000ULL ,143300000ULL , + }, + [BAND_CHANDEF_WIDTH_40 ] = { +17200000ULL ,34400000ULL ,51600000ULL ,68800000ULL , +103200000ULL ,137600000ULL ,154900000ULL ,172000000ULL , +206500000ULL ,229400000ULL ,258000000ULL ,286800000ULL , + }, + [BAND_CHANDEF_WIDTH_80 ] = { +36000000ULL ,72000000ULL ,108000000ULL ,144100000ULL , +216200000ULL ,288200000ULL ,324300000ULL ,360300000ULL , +432400000ULL ,480400000ULL ,540400000ULL ,600500000ULL , + }, + [BAND_CHANDEF_WIDTH_80P80 ] = { +72000000ULL ,144100000ULL ,216200000ULL ,288200000ULL , +432400000ULL ,576500000ULL ,648500000ULL ,720600000ULL , +864700000ULL ,960800000ULL ,1080900000ULL ,1201000000ULL , + }, +/* 80+80MHz rates equal 160MHz according to 27.5.1 */ +}; + +static bool band_he_rate (uint8_t index,enum band_chandef_width width, +int32_t rssi,uint8_t nss,uint64_t *data_rate) +{ +uint64_t rate; +int32_t width_adjust; + +/* +* 802.11ax treats 80+80MHz and 160MHz widths together in terms of the +* data rate tables, hence why the above table has no entry for 160MHz. +* We can't simply combine the two widths fully because they differ in +* what MCS/NSS values may be supported. So if 160MHz was chosen, use +* the 80+80MHz table. +*/ +if (width ==BAND_CHANDEF_WIDTH_160 ) + width =BAND_CHANDEF_WIDTH_80P80 ; + +/* +* The band_chandef_width enum is being reused for HE so we have to +* subtract 1 to account for 20MHz being at index 1 (index 0 is no-HT +* which isn't applicable to HE). +*/ + width_adjust = (width -1 ) *3 ; + +if (rssi < ht_vht_he_base_rssi[index] + width_adjust) +return false; + + rate = he_rates[width][index]; + + rate *= nss; + + *data_rate = rate; +return true; +} + +static enum band_chandef_width find_he_max_width (enum band_freq freq, +struct band_he_capabilities *he_cap, +const uint8_t *he_phy) +{ + +uint8_t own_width_set =bit_field (he_cap->he_phy_capa[0 ],1 ,7 ); +uint8_t peer_width_set =bit_field (he_phy[0 ],1 ,7 ); +enum band_chandef_width max_width =BAND_CHANDEF_WIDTH_20 ; + +/* +* 802.11ax Table 9-322b +*/ +switch (freq) { +case BAND_FREQ_2_4_GHZ : +/* B0 indicates support for 40MHz */ +if (test_bit (&peer_width_set,0 ) &&test_bit (&own_width_set,0 )) + max_width =BAND_CHANDEF_WIDTH_40 ; +break ; +case BAND_FREQ_5_GHZ : +case BAND_FREQ_6_GHZ : +/* B1 indicates support for 40MHz and 80MHz, choose 80 */ +if (test_bit (&peer_width_set,1 ) &&test_bit (&own_width_set,1 )) + max_width =BAND_CHANDEF_WIDTH_80 ; +/* B2 indicates support for 160MHz */ +if (test_bit (&peer_width_set,2 ) &&test_bit (&own_width_set,2 )) + max_width =BAND_CHANDEF_WIDTH_160 ; +/* B3 indicates support for 80+80MHz */ +if (test_bit (&peer_width_set,3 ) &&test_bit (&own_width_set,3 )) + max_width =BAND_CHANDEF_WIDTH_80P80 ; + +break ; + } + +return max_width; +} + +static bool find_best_mcs_he (uint8_t max_index,enum band_chandef_width width, +int32_t rssi,uint8_t nss, +uint64_t *out_data_rate) +{ +int i; + +/* +* Iterate over all available MCS indexes to find the best one +* we can use. +*/ +for (i = max_index; i >=0 ; i--) +if (band_he_rate (i, width, rssi, nss, out_data_rate)) +return true; + +return false; +} + +static bool find_he_capabilities (const void *data,const void *user_data) +{ +const struct band_he_capabilities *he_cap = data; +enum netdev_iftype iftype = *((enum netdev_iftype *)user_data); + +if (he_cap->iftypes & (1 << iftype)) +return true; + +return false; +} + +/* +* HE data rate is calculated based on 802.11ax - Section 27.5 +*/ +int band_estimate_he_rx_rate (const struct band *band,const uint8_t *hec, +int32_t rssi,uint64_t *out_data_rate) +{ +uint32_t nss =0 ; +uint32_t max_mcs =7 ; +enum band_chandef_width width; +enum band_chandef_width i; +struct band_he_capabilities *he_cap; +uint64_t best_rate =0 ; + +/* +* TODO: Station type is assumed here since it is the only consumer of +* these data rate estimation APIs. If this changes the iftype +* would need to be passed in. +*/ +enum netdev_iftype iftype =NETDEV_IFTYPE_STATION ; + +if (!hec || !band->he_capabilities) +return -EBADMSG ; + + he_cap =l_queue_find (band->he_capabilities, find_he_capabilities, + &iftype); +if (!he_cap) +return -ENOTSUP ; + +/* The maximum width sets where to stop checking MCS sets */ + width =find_he_max_width (band->freq, he_cap, hec +8 ); + +/* +* The HE-MCS maps are 19 bytes into the HE Capabilities IE, and +* alternate RX/TX every 2 bytes. Start the TX map 19 + 2 bytes +* into the MCS set. For each supported width beyond 80MHz +* (only 160/80+80) increment to the next map, 4 bytes ahead. +* Estimate a rate for each width, and track the largest. +*/ +for (i =BAND_CHANDEF_WIDTH_80 ; i <=BAND_CHANDEF_WIDTH_160 ; i++) { +enum band_chandef_width check = i; +const uint8_t *rx_map = he_cap->he_mcs_set; +const uint8_t *tx_map = hec +21 ; +uint64_t rate; + +/* +* The band_chandef_width enum does not use the same ordering as +* the MCS sets (160 and 80+80 are swapped) so we can't just +* iterate the widths and increment by 4 bytes. Instead 80+80 +* and 160 must be checked individually and skipped if not +* supported. +*/ +switch (i) { +case BAND_CHANDEF_WIDTH_80P80 : +/* +* 80+80 is the last map so if the width is not set to +* this continue to allow 160MHz to be checked. +*/ +if (width !=BAND_CHANDEF_WIDTH_80P80 ) +continue ; + + rx_map +=8 ; + tx_map +=8 ; +break ; +case BAND_CHANDEF_WIDTH_160 : +/* If neither 160 or 80+80 MCS sets are supported */ +if (width !=BAND_CHANDEF_WIDTH_160 && + width !=BAND_CHANDEF_WIDTH_80P80 ) +continue ; + + rx_map +=4 ; + tx_map +=4 ; +break ; +default : +/* +* The <= 80MHz MCS set. If the supported width is less +* than 80Mhz use that to calculate the rate rather than +* 80Mhz. +*/ +if (width <BAND_CHANDEF_WIDTH_80 ) + check = width; + +break ; + } + +if (!find_best_mcs_nss (rx_map, tx_map,7 ,9 ,11 , + &max_mcs, &nss)) +continue ; + +if (!find_best_mcs_he (max_mcs, check, rssi, nss, &rate)) +continue ; + +if (rate > best_rate) + best_rate = rate; + } + +if (!best_rate) +return -EBADMSG ; + + *out_data_rate = best_rate; + +return 0 ; +} +static int band_channel_info_get_bandwidth (const struct band_chandef *info) {switch (info->channel_width) {
src/band.h +2 -1
@@ -74,7 +74,8 @@ void band_free(struct band *band);bool band_ofdm_rate (uint8_t index,enum ofdm_channel_width width,int32_t rssi,uint8_t nss,bool sgi,uint64_t *data_rate); - +int band_estimate_he_rx_rate (const struct band *band,const uint8_t *hec, +int32_t rssi,uint64_t *out_dat_rate); int band_estimate_vht_rx_rate(const struct band *band, const uint8_t *vhtc, const uint8_t *vhto, const uint8_t *htc, const uint8_t *hto,
Signature · 1 line
2.34.1
PATCH 11/12 wiphy: use HE element for data rate estimation
In reply to James PrestwoodIf an HE element is found, prefer using this for the rate estimation since it will likely yield the fastest rate.
--- src/wiphy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
src/wiphy.c +12 -0
@@ -788,6 +788,7 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy,const void *vht_operation =NULL ;const void *ht_capabilities =NULL ;const void *ht_operation =NULL ; +const void *he_capabilities =NULL ;const struct band *bandp;enum band_freq band;
@@ -847,11 +848,22 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy, vht_operation = iter.data -2 ;break ; +case IE_TYPE_HE_CAPABILITIES : +if (iter.len <21 ) +return -EBADMSG ; + + he_capabilities = iter.data -2 ; +break ;default :break ; } } +if (!band_estimate_he_rx_rate (bandp, he_capabilities, + bss->signal_strength /100 , + out_data_rate)) +return 0 ; + if (!band_estimate_vht_rx_rate(bandp, vht_capabilities, vht_operation, ht_capabilities, ht_operation, bss->signal_strength / 100,
Signature · 1 line
2.34.1
PATCH 12/12 scan: increase max data rate, now for HE
In reply to James PrestwoodThis increases the maximum data rate which now is possible with HE. A few comments were also updated, one to include 6G when adjusting the rank for >4000mhz, and the other fixing a typo.
--- src/scan.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
src/scan.c +4 -4
@@ -1628,17 +1628,17 @@ static void scan_bss_compute_rank(struct scan_bss *bss)double rank;uint32_t irank;/* -* Maximum rate is 2340Mbps (VHT) +* Maximum rate is 9607.8Mbps (HE) */ -double max_rate =2340000000 ; +double max_rate =9607800000 ; rank = (double )bss->data_rate / max_rate *USHRT_MAX ; -/* Prefer 5G networks over 2.4G */ +/* Prefer 5G/6G networks over 2.4G */ if (bss->frequency >4000 ) rank *=RANK_5G_FACTOR ; -/* Rank loaded APs lower and lighly loaded APs higher */ +/* Rank loaded APs lower and lightly loaded APs higher */ if (bss->utilization >=192 ) rank *=RANK_HIGH_UTILIZATION_FACTOR ;else if (bss->utilization <=63 )
Signature · 1 line
2.34.1
Hi James,
Quoted 4 lines · James Prestwood
--- src/scan.c | 2 ++ 1 file changed, 2 insertions(+)
I went ahead and applied patches 1-9 and 12.
Regards,
-Denis