376-mac80211-minstrel-fix-sampling-reporting-of-CCK-rate.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Thu, 1 Mar 2018 13:28:48 +0100
  3. Subject: [PATCH] mac80211: minstrel: fix sampling/reporting of CCK rates
  4. in HT mode
  5. Long/short preamble selection cannot be sampled separately, since it
  6. depends on the BSS state. Because of that, sampling attempts to
  7. currently not used preamble modes are not counted in the statistics,
  8. which leads to CCK rates being sampled too often.
  9. Fix statistics accounting for long/short preamble by increasing the
  10. index where necessary.
  11. Fix excessive CCK rate sampling by dropping unsupported sample attempts.
  12. This improves throughput on 2.4 GHz channels
  13. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  14. ---
  15. --- a/net/mac80211/rc80211_minstrel_ht.c
  16. +++ b/net/mac80211/rc80211_minstrel_ht.c
  17. @@ -281,7 +281,8 @@ minstrel_ht_get_stats(struct minstrel_pr
  18. break;
  19. /* short preamble */
  20. - if (!(mi->supported[group] & BIT(idx)))
  21. + if ((mi->supported[group] & BIT(idx + 4)) &&
  22. + (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
  23. idx += 4;
  24. }
  25. return &mi->groups[group].rates[idx];
  26. @@ -1080,18 +1081,23 @@ minstrel_ht_get_rate(void *priv, struct
  27. return;
  28. sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
  29. + sample_idx %= MCS_GROUP_RATES;
  30. +
  31. + if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] &&
  32. + (sample_idx >= 4) != txrc->short_preamble)
  33. + return;
  34. +
  35. info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
  36. rate->count = 1;
  37. - if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
  38. + if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) {
  39. int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
  40. rate->idx = mp->cck_rates[idx];
  41. } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
  42. ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
  43. sample_group->streams);
  44. } else {
  45. - rate->idx = sample_idx % MCS_GROUP_RATES +
  46. - (sample_group->streams - 1) * 8;
  47. + rate->idx = sample_idx + (sample_group->streams - 1) * 8;
  48. }
  49. rate->flags = sample_group->flags;