b7f55d500580c329b2bab96b5b368a2b5cb1f82d
[openwrt/svn-archive/archive.git] / package / madwifi / patches-testing / 310-minstrel_sampling.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -8110,6 +8110,7 @@
4 ath_hal_setupxtxdesc(sc->sc_ah, ds, mrr.rate1, mrr.retries1,
5 mrr.rate2, mrr.retries2,
6 mrr.rate3, mrr.retries3);
7 + bf->rcflags = mrr.privflags;
8 }
9
10 #ifndef ATH_SUPERG_FF
11 --- a/ath/if_athvar.h
12 +++ b/ath/if_athvar.h
13 @@ -454,6 +454,7 @@
14 u_int16_t bf_flags; /* tx descriptor flags */
15 u_int64_t bf_tsf;
16 int16_t bf_channoise;
17 + unsigned int rcflags;
18 #ifdef ATH_SUPERG_FF
19 /* XXX: combine this with bf_skbaddr if it ever changes to accommodate
20 * multiple segments.
21 --- a/ath_rate/minstrel/minstrel.c
22 +++ b/ath_rate/minstrel/minstrel.c
23 @@ -341,18 +341,21 @@
24 if (sn->static_rate_ndx >= 0) {
25 ndx = sn->static_rate_ndx;
26 } else {
27 + int delta;
28 +
29 sn->packet_count++;
30 sn->random_n = (sn->a * sn->random_n) + sn->b;
31 offset = sn->random_n & 0xf;
32
33 - if ((((100 * sn->sample_count) / sn->packet_count) <
34 - ath_lookaround_rate) &&
35 - (offset < 2)) {
36 + delta = (sn->packet_count * ath_lookaround_rate / 100) - sn->sample_count;
37 + if ((delta > 0) && (offset < 2)) {
38 sn->sample_count++;
39 sn->is_sampling = 1;
40 if (sn->packet_count >= 10000) {
41 sn->sample_count = 0;
42 sn->packet_count = 0;
43 + } else if (delta > sn->num_rates * 2) {
44 + sn->sample_count += ((delta - sn->num_rates * 2) * ath_lookaround_rate) / 100;
45 }
46
47 /* Don't look for slowest rate (i.e. slowest
48 @@ -420,11 +423,14 @@
49 if (sn->num_rates <= 0)
50 return;
51
52 + mrr->privflags = sn->is_sampling;
53 if (sn->is_sampling) {
54 sn->is_sampling = 0;
55 - if (sn->rs_sample_rate_slower)
56 + if (sn->rs_sample_rate_slower) {
57 rc1 = sn->rs_sample_rate;
58 - else
59 + if (sn->sample_count > 0)
60 + sn->sample_count--;
61 + } else
62 rc1 = sn->max_tp_rate;
63 } else {
64 rc1 = sn->max_tp_rate2;
65 @@ -552,6 +558,9 @@
66 if (tries <= tries1)
67 return;
68
69 + if (bf->rcflags)
70 + sn->sample_count++;
71 +
72 if (tries2 < 0)
73 return;
74 tries = tries - tries1;
75 --- a/net80211/ieee80211_rate.h
76 +++ b/net80211/ieee80211_rate.h
77 @@ -87,6 +87,7 @@
78 int retries2;
79 int rate3;
80 int retries3;
81 + int privflags;
82 };
83
84 struct ieee80211_rate_ops {