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