Enable more PCMCIA specific options, thanks sn9
[librecmc/librecmc.git] / package / mac80211 / patches / 426-minstrel_performance.patch
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
4 several sample frames.
5
6 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
7
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;
15                 } else {
16 +                       mr->sample_limit = -1;
17                         mr->adjusted_retry_count = mr->retry_count;
18                 }
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);
22  
23         /* delta > 0: sampling required */
24 -       if (delta > 0) {
25 +       if ((delta > 0) && (mrr || !mi->prev_sample)) {
26 +               struct minstrel_rate *msr;
27                 if (mi->packet_count >= 10000) {
28                         mi->sample_deferred = 0;
29                         mi->sample_count = 0;
30 @@ -284,13 +287,20 @@ minstrel_get_rate(void *priv, struct iee
31                 }
32  
33                 sample_ndx = minstrel_get_next_sample(mi);
34 +               msr = &mi->r[sample_ndx];
35                 sample = true;
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);
39  
40                 if (!sample_slower) {
41 -                       ndx = sample_ndx;
42 -                       mi->sample_count++;
43 +                       if (msr->sample_limit != 0) {
44 +                               ndx = sample_ndx;
45 +                               mi->sample_count++;
46 +                               if (msr->sample_limit > 0)
47 +                                       msr->sample_limit--;
48 +                       } else {
49 +                               sample = false;
50 +                       }
51                 } else {
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++;
56                 }
57         }
58 +       mi->prev_sample = sample;
59 +
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;
65 +
66         ar[0].idx = mi->r[ndx].rix;
67         ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
68  
69         if (!mrr) {
70 +               if (!sample)
71 +                       ar[0].count = mp->max_retry;
72                 ar[1].idx = mi->lowest_rix;
73                 ar[1].count = mp->max_retry;
74                 return;
75 @@ -401,6 +421,7 @@ minstrel_rate_init(void *priv, struct ie
76  
77                 /* calculate maximum number of retransmissions before
78                  * fallback (based on maximum segment size) */
79 +               mr->sample_limit = -1;
80                 mr->retry_count = 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;
88  
89 +       int sample_limit;
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 {
94  
95         int n_rates;
96         struct minstrel_rate *r;
97 +       bool prev_sample;
98  
99         /* sampling table */
100         u8 *sample_table;