blob: 16bcbc2ef914ac2592cdf8c98ed1b238ca82b075 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: Felix Fietkau <nbd@nbd.name>
2Date: Sat, 6 Feb 2021 16:08:01 +0100
3Subject: [PATCH] mac80211: minstrel_ht: reduce fluctuations in rate
4 probability stats
5
6In some scenarios when there is a lot of fluctuation in packet error rates,
7rate switching can be amplified when the statistics get skewed by time slots
8with very few tries.
9Make the input data to the moving average more smooth by adding the
10success/attempts count from the last stats window as well. This has the
11advantage of smoothing the data without introducing any extra lag to sampling
12rates.
13This significantly improves rate stability on a strong test link subjected to
14periodic noise bursts generated with a SDR
15
16Signed-off-by: Felix Fietkau <nbd@nbd.name>
17---
18
19--- a/net/mac80211/rc80211_minstrel_ht.c
20+++ b/net/mac80211/rc80211_minstrel_ht.c
21@@ -700,7 +700,8 @@ minstrel_ht_calc_rate_stats(struct minst
22 unsigned int cur_prob;
23
24 if (unlikely(mrs->attempts > 0)) {
25- cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
26+ cur_prob = MINSTREL_FRAC(mrs->success + mrs->last_success,
27+ mrs->attempts + mrs->last_attempts);
28 minstrel_filter_avg_add(&mrs->prob_avg,
29 &mrs->prob_avg_1, cur_prob);
30 mrs->att_hist += mrs->attempts;