mac80211: update encap offload patches to the latest version
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / subsys / 305-mac80211-improve-AQL-tx-airtime-estimation.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 24 Jul 2020 20:25:07 +0200
3 Subject: [PATCH] mac80211: improve AQL tx airtime estimation
4
5 AQL does not take into account that most HT/VHT/HE traffic is A-MPDU aggregated.
6 Because of that, the per-packet airtime overhead is vastly overestimated.
7 Improve it by assuming an average aggregation length of 16 for non-legacy
8 traffic if not using the VO AC queue.
9 This should improve performance with high data rates, especially with multiple
10 stations
11
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 ---
14
15 --- a/net/mac80211/airtime.c
16 +++ b/net/mac80211/airtime.c
17 @@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(ieee80211_calc_tx_airt
18 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
19 struct ieee80211_vif *vif,
20 struct ieee80211_sta *pubsta,
21 - int len)
22 + int len, bool ampdu)
23 {
24 struct ieee80211_supported_band *sband;
25 struct ieee80211_chanctx_conf *conf;
26 @@ -572,10 +572,26 @@ u32 ieee80211_calc_expected_tx_airtime(s
27 if (pubsta) {
28 struct sta_info *sta = container_of(pubsta, struct sta_info,
29 sta);
30 + struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate;
31 + u32 airtime;
32
33 - return ieee80211_calc_tx_airtime_rate(hw,
34 - &sta->tx_stats.last_rate,
35 - band, len);
36 + if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS |
37 + IEEE80211_TX_RC_MCS)))
38 + ampdu = false;
39 +
40 + /*
41 + * Assume that HT/VHT transmission on any AC except VO will
42 + * use aggregation. Since we don't have reliable reporting
43 + * of aggregation length, assume an average of 16.
44 + * This will not be very accurate, but much better than simply
45 + * assuming un-aggregated tx.
46 + */
47 + airtime = ieee80211_calc_tx_airtime_rate(hw, rate, band,
48 + ampdu ? len * 16 : len);
49 + if (ampdu)
50 + airtime /= 16;
51 +
52 + return airtime;
53 }
54
55 if (!conf)
56 --- a/net/mac80211/ieee80211_i.h
57 +++ b/net/mac80211/ieee80211_i.h
58 @@ -2294,7 +2294,7 @@ extern const struct ethtool_ops ieee8021
59 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
60 struct ieee80211_vif *vif,
61 struct ieee80211_sta *pubsta,
62 - int len);
63 + int len, bool ampdu);
64 #ifdef CPTCFG_MAC80211_NOINLINE
65 #define debug_noinline noinline
66 #else
67 --- a/net/mac80211/tx.c
68 +++ b/net/mac80211/tx.c
69 @@ -3707,10 +3707,11 @@ encap_out:
70
71 if (vif &&
72 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
73 + bool ampdu = txq->ac != IEEE80211_AC_VO;
74 u32 airtime;
75
76 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta,
77 - skb->len);
78 + skb->len, ampdu);
79 if (airtime) {
80 airtime = ieee80211_info_set_tx_time_est(info, airtime);
81 ieee80211_sta_update_pending_airtime(local, tx.sta,