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 @@ -646,27 +646,40 @@ 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 + ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len);
31 + if (stat.encoding == RX_ENC_LEGACY || !ampdu)
32 + return ieee80211_calc_rx_airtime(hw, &stat, len);
34 + duration = ieee80211_get_rate_duration(hw, &stat, &overhead);
36 * Assume that HT/VHT transmission on any AC except VO will
37 * use aggregation. Since we don't have reliable reporting
38 - * of aggregation length, assume an average of 16.
39 + * of aggregation length, assume an average size based on the
41 * This will not be very accurate, but much better than simply
42 - * assuming un-aggregated tx.
43 + * assuming un-aggregated tx in all cases.
45 - airtime = ieee80211_calc_tx_airtime_rate(hw, rate, ri, band,
46 - ampdu ? len * 16 : len);
49 + if (duration > 400) /* <= VHT20 MCS2 1S */
51 + else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */
53 + else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */
60 + duration /= AVG_PKT_SIZE;
63 + return duration + (overhead >> agg_shift);