ieee80211_fill_rate_info() rejects every rate when the wiphy has no sband for the band it is given, although only a legacy rate is looked up in the bitrate table of the band. HT, VHT, HE and EHT durations come from the MCS tables alone. ieee80211_calc_expected_tx_airtime() takes the band from the channel context of vif->bss_conf, which an MLD vif does not have, and uses band 0 (2.4 GHz) then. On a wiphy without 2.4 GHz the last_rate_info of the station is rejected whatever its encoding, and AQL charges each frame 4 us unless last_rate holds a valid rate. On a wiphy with 2.4 GHz a legacy last_rate index is looked up in the 2.4 GHz table, where it names a different rate than in the 5 or 6 GHz table it came from. Check the band only for a legacy rate. Pass NUM_NL80211_BANDS when the vif has no channel context, and look a legacy bitrate up in each band then: its duration depends only on the bitrate and on whether it is CCK, and cfg80211 marks a bitrate as CCK in every band that has it. A legacy last_rate index cannot be resolved without its band, so that fallback gives no estimate then. Fixes: 8ed37e791960 ("mac80211: use rate provided via status->rate on ieee80211_tx_status_ext for AQL") Signed-off-by: Julius Bairaktaris --- v3: - New. Found by the hosted Sashiko review of v2, on v2 4/7: on an MLD vif ieee80211_8023_gso_fits() and the AQL charge used band 0. net/mac80211/airtime.c | 52 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/net/mac80211/airtime.c b/net/mac80211/airtime.c index d3b911fb711af..579e77f49e9d8 100644 --- a/net/mac80211/airtime.c +++ b/net/mac80211/airtime.c @@ -622,15 +622,34 @@ u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw, } EXPORT_SYMBOL_GPL(ieee80211_calc_rx_airtime); -static bool ieee80211_fill_rate_info(struct ieee80211_hw *hw, - struct ieee80211_rx_status *stat, u8 band, - struct rate_info *ri) +static bool ieee80211_fill_legacy_rate(struct ieee80211_hw *hw, + struct ieee80211_rx_status *stat, + u8 band, u16 bitrate) { struct ieee80211_supported_band *sband = hw->wiphy->bands[band]; int i; - if (!ri || !sband) - return false; + if (!sband) + return false; + + for (i = 0; i < sband->n_bitrates; i++) { + if (bitrate != sband->bitrates[i].bitrate) + continue; + + stat->band = band; + stat->rate_idx = i; + return true; + } + + return false; +} + +static bool ieee80211_fill_rate_info(struct ieee80211_hw *hw, + struct ieee80211_rx_status *stat, u8 band, + struct rate_info *ri) +{ + if (!ri) + return false; /* * ieee80211_get_rate_duration() only handles these widths. Drivers @@ -678,13 +697,20 @@ static bool ieee80211_fill_rate_info(struct ieee80211_hw *hw, if (stat->encoding != RX_ENC_LEGACY) return true; - stat->rate_idx = 0; - for (i = 0; i < sband->n_bitrates; i++) { - if (ri->legacy != sband->bitrates[i].bitrate) + if (band < NUM_NL80211_BANDS) + return ieee80211_fill_legacy_rate(hw, stat, band, ri->legacy); + + /* + * The band is not known (an MLD vif). The duration of a legacy rate + * depends only on its bitrate and on whether it is CCK, and cfg80211 + * marks a bitrate as CCK (mandatory B) in every band that has it. + */ + for (band = 0; band < NUM_NL80211_BANDS; band++) { + if (band == NL80211_BAND_60GHZ || band == NL80211_BAND_S1GHZ) continue; - stat->rate_idx = i; - return true; + if (ieee80211_fill_legacy_rate(hw, stat, band, ri->legacy)) + return true; } return false; @@ -727,6 +753,9 @@ static int ieee80211_fill_rx_status(struct ieee80211_rx_status *stat, } else if (rate->flags & IEEE80211_TX_RC_MCS) { stat->encoding = RX_ENC_HT; } else { + /* a legacy rate index means nothing without its band */ + if (band >= NUM_NL80211_BANDS) + return -1; stat->encoding = RX_ENC_LEGACY; } @@ -827,11 +856,12 @@ u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw, int rateidx; bool cck, short_pream; u32 basic_rates; - u8 band = 0; + u8 band = NUM_NL80211_BANDS; u16 rate; len += 38; /* Ethernet header length */ + /* an MLD vif has no channel context here, the band is not known */ conf = rcu_dereference(vif->bss_conf.chanctx_conf); if (conf) band = conf->def.chan->band; -- 2.53.0