mac80211: improve AQL tx airtime estimation
authorFelix Fietkau <nbd@nbd.name>
Fri, 24 Jul 2020 18:28:16 +0000 (20:28 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 31 Jul 2020 07:24:24 +0000 (09:24 +0200)
AQL does not take into account that most HT/VHT/HE traffic is A-MPDU aggregated.
Because of that, the per-packet airtime overhead is vastly overestimated.
Improve it by assuming an average aggregation length of 16 for non-legacy
traffic if not using the VO AC queue.
This should improve performance with high data rates, especially with multiple
stations

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20200724182816.18678-1-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/airtime.c
net/mac80211/ieee80211_i.h
net/mac80211/tx.c

index 9fc2968856c0bf9019972f21f9e67a3c3463f50c..366f76c9003ddd1b125473218cd7daff445bcc80 100644 (file)
@@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(ieee80211_calc_tx_airtime);
 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
                                       struct ieee80211_vif *vif,
                                       struct ieee80211_sta *pubsta,
-                                      int len)
+                                      int len, bool ampdu)
 {
        struct ieee80211_supported_band *sband;
        struct ieee80211_chanctx_conf *conf;
@@ -572,10 +572,26 @@ u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
        if (pubsta) {
                struct sta_info *sta = container_of(pubsta, struct sta_info,
                                                    sta);
-
-               return ieee80211_calc_tx_airtime_rate(hw,
-                                                     &sta->tx_stats.last_rate,
-                                                     band, len);
+               struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate;
+               u32 airtime;
+
+               if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS |
+                                    IEEE80211_TX_RC_MCS)))
+                       ampdu = false;
+
+               /*
+                * Assume that HT/VHT transmission on any AC except VO will
+                * use aggregation. Since we don't have reliable reporting
+                * of aggregation length, assume an average of 16.
+                * This will not be very accurate, but much better than simply
+                * assuming un-aggregated tx.
+                */
+               airtime = ieee80211_calc_tx_airtime_rate(hw, rate, band,
+                                                        ampdu ? len * 16 : len);
+               if (ampdu)
+                       airtime /= 16;
+
+               return airtime;
        }
 
        if (!conf)
index ec1a71ac65f2e6729e3a7fce63ead3064f7c0867..28b154c6e72dc78bbe47683232a87fd9edf8bb5e 100644 (file)
@@ -2290,7 +2290,7 @@ extern const struct ethtool_ops ieee80211_ethtool_ops;
 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
                                       struct ieee80211_vif *vif,
                                       struct ieee80211_sta *pubsta,
-                                      int len);
+                                      int len, bool ampdu);
 #ifdef CONFIG_MAC80211_NOINLINE
 #define debug_noinline noinline
 #else
index 0d0e901b1d4ce50d1a0e052ce5446794b88d2907..7c0abe477b03ba4f1beb377082e8804a3e4139dc 100644 (file)
@@ -3722,10 +3722,11 @@ encap_out:
 
        if (vif &&
            wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
+               bool ampdu = txq->ac != IEEE80211_AC_VO;
                u32 airtime;
 
                airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta,
-                                                            skb->len);
+                                                            skb->len, ampdu);
                if (airtime) {
                        airtime = ieee80211_info_set_tx_time_est(info, airtime);
                        ieee80211_sta_update_pending_airtime(local, tx.sta,