341-mac80211-minstrel_ht-improve-ampdu-length-estimation.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From: Felix Fietkau <[email protected]>
  2. Date: Sat, 26 Dec 2020 19:08:19 +0100
  3. Subject: [PATCH] mac80211: minstrel_ht: improve ampdu length estimation
  4. If the driver does not report A-MPDU length, estimate it based on the rate.
  5. Signed-off-by: Felix Fietkau <[email protected]>
  6. ---
  7. --- a/net/mac80211/rc80211_minstrel_ht.c
  8. +++ b/net/mac80211/rc80211_minstrel_ht.c
  9. @@ -382,13 +382,37 @@ minstrel_get_ratestats(struct minstrel_h
  10. return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
  11. }
  12. +static inline int
  13. +minstrel_get_duration(int index)
  14. +{
  15. + const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
  16. + unsigned int duration = group->duration[index % MCS_GROUP_RATES];
  17. + return duration << group->shift;
  18. +}
  19. +
  20. static unsigned int
  21. minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
  22. {
  23. - if (!mi->avg_ampdu_len)
  24. - return AVG_AMPDU_SIZE;
  25. + int duration;
  26. +
  27. + if (mi->avg_ampdu_len)
  28. + return MINSTREL_TRUNC(mi->avg_ampdu_len);
  29. +
  30. + if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES))
  31. + return 1;
  32. +
  33. + duration = minstrel_get_duration(mi->max_tp_rate[0]);
  34. - return MINSTREL_TRUNC(mi->avg_ampdu_len);
  35. + if (duration > 400 * 1000)
  36. + return 2;
  37. +
  38. + if (duration > 250 * 1000)
  39. + return 4;
  40. +
  41. + if (duration > 150 * 1000)
  42. + return 8;
  43. +
  44. + return 16;
  45. }
  46. /*
  47. @@ -588,14 +612,6 @@ minstrel_ht_prob_rate_reduce_streams(str
  48. }
  49. }
  50. -static inline int
  51. -minstrel_get_duration(int index)
  52. -{
  53. - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
  54. - unsigned int duration = group->duration[index % MCS_GROUP_RATES];
  55. - return duration << group->shift;
  56. -}
  57. -
  58. static bool
  59. minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group,
  60. int tp_idx, const struct mcs_group *group)