335-mac80211-minstrel_ht-set-A-MSDU-tx-limits-based-on-s.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From: Felix Fietkau <nbd@openwrt.org>
  2. Date: Thu, 18 Feb 2016 19:30:05 +0100
  3. Subject: [PATCH] mac80211: minstrel_ht: set A-MSDU tx limits based on selected
  4. max_prob_rate
  5. Prevents excessive A-MSDU aggregation at low data rates or bad
  6. conditions.
  7. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  8. ---
  9. --- a/net/mac80211/rc80211_minstrel_ht.c
  10. +++ b/net/mac80211/rc80211_minstrel_ht.c
  11. @@ -883,6 +883,39 @@ minstrel_ht_set_rate(struct minstrel_pri
  12. ratetbl->rate[offset].flags = flags;
  13. }
  14. +static int
  15. +minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi)
  16. +{
  17. + int group = mi->max_prob_rate / MCS_GROUP_RATES;
  18. + const struct mcs_group *g = &minstrel_mcs_groups[group];
  19. + int rate = mi->max_prob_rate % MCS_GROUP_RATES;
  20. +
  21. + /* Disable A-MSDU if max_prob_rate is bad */
  22. + if (mi->groups[group].rates[rate].prob_ewma < MINSTREL_FRAC(50, 100))
  23. + return 1;
  24. +
  25. + /* If the rate is slower than single-stream MCS1, make A-MSDU limit small */
  26. + if (g->duration[rate] > MCS_DURATION(1, 0, 52))
  27. + return 500;
  28. +
  29. + /*
  30. + * If the rate is slower than single-stream MCS4, limit A-MSDU to usual
  31. + * data packet size
  32. + */
  33. + if (g->duration[rate] > MCS_DURATION(1, 0, 104))
  34. + return 1500;
  35. +
  36. + /*
  37. + * If the rate is slower than single-stream MCS7, limit A-MSDU to twice
  38. + * the usual data packet size
  39. + */
  40. + if (g->duration[rate] > MCS_DURATION(1, 0, 260))
  41. + return 3000;
  42. +
  43. + /* unlimited */
  44. + return 0;
  45. +}
  46. +
  47. static void
  48. minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
  49. {
  50. @@ -907,6 +940,7 @@ minstrel_ht_update_rates(struct minstrel
  51. minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
  52. }
  53. + mi->sta->max_rc_amsdu_len = minstrel_ht_get_max_amsdu_len(mi);
  54. rates->rate[i].idx = -1;
  55. rate_control_set_rates(mp->hw, mi->sta, rates);
  56. }