1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 12 Aug 2020 17:07:10 +0200
3 Subject: [PATCH] mac80211: improve AQL aggregation estimation for low data
6 Links with low data rates use much smaller aggregates and are much more
7 sensitive to latency added by bufferbloat.
8 Tune the assumed aggregation length based on the tx rate duration.
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 --- a/net/mac80211/airtime.c
14 +++ b/net/mac80211/airtime.c
15 @@ -647,27 +647,41 @@ u32 ieee80211_calc_expected_tx_airtime(s
17 struct sta_info *sta = container_of(pubsta, struct sta_info,
19 + struct ieee80211_rx_status stat;
20 struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate;
21 struct rate_info *ri = &sta->tx_stats.last_rate_info;
23 + u32 duration, overhead;
26 - if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS |
27 - IEEE80211_TX_RC_MCS)))
29 + if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len))
32 + if (stat.encoding == RX_ENC_LEGACY || !ampdu)
33 + return ieee80211_calc_rx_airtime(hw, &stat, len);
35 + duration = ieee80211_get_rate_duration(hw, &stat, &overhead);
37 * Assume that HT/VHT transmission on any AC except VO will
38 * use aggregation. Since we don't have reliable reporting
39 - * of aggregation length, assume an average of 16.
40 + * of aggregation length, assume an average size based on the
42 * This will not be very accurate, but much better than simply
43 - * assuming un-aggregated tx.
44 + * assuming un-aggregated tx in all cases.
46 - airtime = ieee80211_calc_tx_airtime_rate(hw, rate, ri, band,
47 - ampdu ? len * 16 : len);
50 + if (duration > 400) /* <= VHT20 MCS2 1S */
52 + else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */
54 + else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */
61 + duration /= AVG_PKT_SIZE;
64 + return duration + (overhead >> agg_shift);