eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit a7ed0e6ba54a899a1b10a97fe381424f7c016b4e
parent 9baaaebd38b79067e976db379738ba019f1dfc43
Author: James Prestwood <prestwoj@gmail.com>
Date:   Tue, 19 Jul 2022 11:55:41 -0700

band: add find_best_mcs_nss

This 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).

Diffstat:
Msrc/band.c | 75+++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 51 insertions(+), 24 deletions(-)

diff --git a/src/band.c b/src/band.c @@ -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; /*