diff options
author | Felix Fietkau <nbd@nbd.name> | 2021-01-15 13:05:25 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-01-15 13:05:40 +0100 |
commit | b0ad07e9a0fcdf59430547773e4ccc2416a2185a (patch) | |
tree | 5ec6d17664272125ff8d65690ff3481bf702b492 /package | |
parent | 4dad3244297d8315b25ef029286681be4e7123a0 (diff) | |
download | upstream-b0ad07e9a0fcdf59430547773e4ccc2416a2185a.tar.gz upstream-b0ad07e9a0fcdf59430547773e4ccc2416a2185a.tar.bz2 upstream-b0ad07e9a0fcdf59430547773e4ccc2416a2185a.zip |
mac80211: fix rounding error in minstrel_ht throughput calculation
Fixes rate selection with lower data rates
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package')
-rw-r--r-- | package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch b/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch new file mode 100644 index 0000000000..1df5dec039 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch @@ -0,0 +1,34 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Fri, 15 Jan 2021 12:15:06 +0100 +Subject: [PATCH] mac80211: minstrel_ht: fix rounding error in throughput + calculation + +On lower data rates, the throughput calculation has a significant rounding +error, causing rates like 48M and 54M OFDM to share the same throughput +value with >= 90% success probablity. + +This is because the result of the division (prob_avg * 1000) / nsecs +is really small (8 in this example). + +Improve accuracy by moving over some zeroes, making better use of the full +range of u32 before the division. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/rc80211_minstrel_ht.c ++++ b/net/mac80211/rc80211_minstrel_ht.c +@@ -445,10 +445,9 @@ minstrel_ht_get_tp_avg(struct minstrel_h + * (prob is scaled - see MINSTREL_FRAC above) + */ + if (prob_avg > MINSTREL_FRAC(90, 100)) +- return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000) +- / nsecs)); +- else +- return MINSTREL_TRUNC(100000 * ((prob_avg * 1000) / nsecs)); ++ prob_avg = MINSTREL_FRAC(90, 100); ++ ++ return MINSTREL_TRUNC(100 * ((prob_avg * 1000000) / nsecs)); + } + + /* |