1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 22 Jan 2021 19:24:59 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: reduce the need to sample slower
6 In order to more gracefully be able to fall back to lower rates without too
7 much throughput fluctuations, initialize all untested rates below tested ones
8 to the maximum probabilty of higher rates.
9 Usually this leads to untested lower rates getting initialized with a
10 probability value of 100%, making them better candidates for fallback without
11 having to rely on random probing
13 Signed-off-by: Felix Fietkau <nbd@nbd.name>
16 --- a/net/mac80211/rc80211_minstrel_ht.c
17 +++ b/net/mac80211/rc80211_minstrel_ht.c
18 @@ -791,14 +791,11 @@ minstrel_ht_calc_rate_stats(struct minst
19 unsigned int cur_prob;
21 if (unlikely(mrs->attempts > 0)) {
22 - mrs->sample_skipped = 0;
23 cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
24 minstrel_filter_avg_add(&mrs->prob_avg,
25 &mrs->prob_avg_1, cur_prob);
26 mrs->att_hist += mrs->attempts;
27 mrs->succ_hist += mrs->success;
29 - mrs->sample_skipped++;
32 mrs->last_success = mrs->success;
33 @@ -851,7 +848,6 @@ minstrel_ht_update_stats(struct minstrel
34 mi->ampdu_packets = 0;
37 - mi->sample_slow = 0;
40 memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate));
41 @@ -883,6 +879,7 @@ minstrel_ht_update_stats(struct minstrel
42 /* Find best rate sets within all MCS groups*/
43 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
44 u16 *tp_rate = tmp_mcs_tp_rate;
47 mg = &mi->groups[group];
48 if (!mi->supported[group])
49 @@ -897,7 +894,7 @@ minstrel_ht_update_stats(struct minstrel
50 if (group == MINSTREL_CCK_GROUP && ht_supported)
51 tp_rate = tmp_legacy_tp_rate;
53 - for (i = 0; i < MCS_GROUP_RATES; i++) {
54 + for (i = MCS_GROUP_RATES - 1; i >= 0; i--) {
55 if (!(mi->supported[group] & BIT(i)))
58 @@ -906,6 +903,11 @@ minstrel_ht_update_stats(struct minstrel
60 mrs->retry_updated = false;
61 minstrel_ht_calc_rate_stats(mp, mrs);
64 + last_prob = max(last_prob, mrs->prob_avg);
66 + mrs->prob_avg = max(last_prob, mrs->prob_avg);
67 cur_prob = mrs->prob_avg;
69 if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0)
70 @@ -1470,13 +1472,9 @@ minstrel_get_sample_rate(struct minstrel
71 if (sample_dur >= minstrel_get_duration(tp_rate2) &&
72 (cur_max_tp_streams - 1 <
73 minstrel_mcs_groups[sample_group].streams ||
74 - sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
75 - if (mrs->sample_skipped < 20)
76 + sample_dur >= minstrel_get_duration(mi->max_prob_rate)))
79 - if (mi->sample_slow++ > 2)
85 --- a/net/mac80211/rc80211_minstrel_ht.h
86 +++ b/net/mac80211/rc80211_minstrel_ht.h
87 @@ -123,7 +123,6 @@ struct minstrel_rate_stats {
89 u8 retry_count_rtscts;
95 @@ -179,7 +178,6 @@ struct minstrel_ht_sta {
101 enum minstrel_sample_mode sample_mode;