a5df07e58d60955bf7cc37aecf4d8259ec2b5da4
[openwrt/staging/neocturne.git] /
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
4 rates
5
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.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/net/mac80211/airtime.c
14 +++ b/net/mac80211/airtime.c
15 @@ -647,27 +647,41 @@ u32 ieee80211_calc_expected_tx_airtime(s
16 if (pubsta) {
17 struct sta_info *sta = container_of(pubsta, struct sta_info,
18 sta);
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;
22 - u32 airtime;
23 + u32 duration, overhead;
24 + u8 agg_shift;
25
26 - if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS |
27 - IEEE80211_TX_RC_MCS)))
28 - ampdu = false;
29 + if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len))
30 + return 0;
31
32 + if (stat.encoding == RX_ENC_LEGACY || !ampdu)
33 + return ieee80211_calc_rx_airtime(hw, &stat, len);
34 +
35 + duration = ieee80211_get_rate_duration(hw, &stat, &overhead);
36 /*
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
41 + * tx rate.
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.
45 */
46 - airtime = ieee80211_calc_tx_airtime_rate(hw, rate, ri, band,
47 - ampdu ? len * 16 : len);
48 - if (ampdu)
49 - airtime /= 16;
50 + if (duration > 400) /* <= VHT20 MCS2 1S */
51 + agg_shift = 1;
52 + else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */
53 + agg_shift = 2;
54 + else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */
55 + agg_shift = 3;
56 + else
57 + agg_shift = 4;
58 +
59 + duration *= len;
60 + duration /= AVG_PKT_SIZE;
61 + duration /= 1024;
62
63 - return airtime;
64 + return duration + (overhead >> agg_shift);
65 }
66
67 if (!conf)