313-mac80211-improve-AQL-aggregation-estimation-for-low-.patch 2.1 KB

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