345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. From: Felix Fietkau <[email protected]>
  2. Date: Fri, 15 Jan 2021 12:15:06 +0100
  3. Subject: [PATCH] mac80211: minstrel_ht: fix rounding error in throughput
  4. calculation
  5. On lower data rates, the throughput calculation has a significant rounding
  6. error, causing rates like 48M and 54M OFDM to share the same throughput
  7. value with >= 90% success probablity.
  8. This is because the result of the division (prob_avg * 1000) / nsecs
  9. is really small (8 in this example).
  10. Improve accuracy by moving over some zeroes, making better use of the full
  11. range of u32 before the division.
  12. Signed-off-by: Felix Fietkau <[email protected]>
  13. ---
  14. --- a/net/mac80211/rc80211_minstrel_ht.c
  15. +++ b/net/mac80211/rc80211_minstrel_ht.c
  16. @@ -445,10 +445,9 @@ minstrel_ht_get_tp_avg(struct minstrel_h
  17. * (prob is scaled - see MINSTREL_FRAC above)
  18. */
  19. if (prob_avg > MINSTREL_FRAC(90, 100))
  20. - return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000)
  21. - / nsecs));
  22. - else
  23. - return MINSTREL_TRUNC(100000 * ((prob_avg * 1000) / nsecs));
  24. + prob_avg = MINSTREL_FRAC(90, 100);
  25. +
  26. + return MINSTREL_TRUNC(100 * ((prob_avg * 1000000) / nsecs));
  27. }
  28. /*