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