1 This patch enhances minstrel's performance for non-MRR setups,
2 by preventing it from sampling slower rates with >95% success
3 probability and by putting at least 1 non-sample frame between
6 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 --- a/net/mac80211/rc80211_minstrel.c
9 +++ b/net/mac80211/rc80211_minstrel.c
10 @@ -126,7 +126,9 @@ minstrel_update_stats(struct minstrel_pr
11 mr->adjusted_retry_count = mr->retry_count >> 1;
12 if (mr->adjusted_retry_count > 2)
13 mr->adjusted_retry_count = 2;
14 + mr->sample_limit = 4;
16 + mr->sample_limit = -1;
17 mr->adjusted_retry_count = mr->retry_count;
19 if (!mr->adjusted_retry_count)
20 @@ -265,7 +267,8 @@ minstrel_get_rate(void *priv, struct iee
21 (mi->sample_count + mi->sample_deferred / 2);
23 /* delta > 0: sampling required */
25 + if ((delta > 0) && (mrr || !mi->prev_sample)) {
26 + struct minstrel_rate *msr;
27 if (mi->packet_count >= 10000) {
28 mi->sample_deferred = 0;
30 @@ -284,13 +287,20 @@ minstrel_get_rate(void *priv, struct iee
33 sample_ndx = minstrel_get_next_sample(mi);
34 + msr = &mi->r[sample_ndx];
36 - sample_slower = mrr && (mi->r[sample_ndx].perfect_tx_time >
37 + sample_slower = mrr && (msr->perfect_tx_time >
38 mi->r[ndx].perfect_tx_time);
43 + if (msr->sample_limit != 0) {
46 + if (msr->sample_limit > 0)
47 + msr->sample_limit--;
52 /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
53 * packets that have the sampling rate deferred to the
54 @@ -302,10 +312,20 @@ minstrel_get_rate(void *priv, struct iee
55 mi->sample_deferred++;
58 + mi->prev_sample = sample;
60 + /* If we're not using MRR and the sampling rate already
61 + * has a probability of >95%, we shouldn't be attempting
62 + * to use it, as this only wastes precious airtime */
63 + if (!mrr && sample && (mi->r[ndx].probability > 17100))
64 + ndx = mi->max_tp_rate;
66 ar[0].idx = mi->r[ndx].rix;
67 ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
71 + ar[0].count = mp->max_retry;
72 ar[1].idx = mi->lowest_rix;
73 ar[1].count = mp->max_retry;
75 @@ -401,6 +421,7 @@ minstrel_rate_init(void *priv, struct ie
77 /* calculate maximum number of retransmissions before
78 * fallback (based on maximum segment size) */
79 + mr->sample_limit = -1;
81 mr->retry_count_cts = 1;
82 mr->retry_count_rtscts = 1;
83 --- a/net/mac80211/rc80211_minstrel.h
84 +++ b/net/mac80211/rc80211_minstrel.h
85 @@ -16,6 +16,7 @@ struct minstrel_rate {
86 unsigned int perfect_tx_time;
87 unsigned int ack_time;
90 unsigned int retry_count;
91 unsigned int retry_count_cts;
92 unsigned int retry_count_rtscts;
93 @@ -57,6 +58,7 @@ struct minstrel_sta_info {
96 struct minstrel_rate *r;