public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net
Subject: [PATCH v3 9/9] mac80211: minstrel_ht: fix rounding error in throughput calculation
Date: Fri, 15 Jan 2021 13:02:42 +0100	[thread overview]
Message-ID: <20210115120242.89616-10-nbd@nbd.name> (raw)
In-Reply-To: <20210115120242.89616-1-nbd@nbd.name>

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>
---
 net/mac80211/rc80211_minstrel_ht.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 6496aa39f60b..9e010c8dd063 100644
--- 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_ht_sta *mi, int group, int rate,
 	 * (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));
 }
 
 /*
-- 
2.28.0


      parent reply	other threads:[~2021-01-15 12:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 12:02 [PATCH v3 0/9] replace minstrel with minstrel_ht Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 1/9] mac80211: minstrel_ht: clean up CCK code Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 2/9] mac80211: minstrel_ht: add support for OFDM rates on non-HT clients Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 3/9] mac80211: remove legacy minstrel rate control Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 4/9] mac80211: minstrel_ht: remove old ewma based rate average code Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 5/9] mac80211: minstrel_ht: improve ampdu length estimation Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 6/9] mac80211: minstrel_ht: improve sample rate selection Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 7/9] mac80211: minstrel_ht: fix max probability " Felix Fietkau
2021-01-15 12:02 ` [PATCH v3 8/9] mac80211: minstrel_ht: increase stats update interval Felix Fietkau
2021-01-15 12:02 ` Felix Fietkau [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210115120242.89616-10-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox