aboutsummaryrefslogtreecommitdiffstats
path: root/package/madwifi/patches/379-invalid_rate_fix.patch
blob: c96c04daffaef2e72bbc768b7efc90e982339f7a (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
--- a/ath_rate/minstrel/minstrel.c
+++ b/ath_rate/minstrel/minstrel.c
@@ -111,27 +111,13 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_rate.h>
 
+#include "if_ath_debug.h"
 #include "if_athvar.h"
 #include "if_ath_hal.h"
 #include "ah_desc.h"
 
 #include "minstrel.h"
 
-#ifdef AR_DEBUG
-#define	MINSTREL_DEBUG
-#endif
-#ifdef MINSTREL_DEBUG
-enum {
-		ATH_DEBUG_RATE		= 0x00000010	/* rate control */
-};
-#define	DPRINTF(sc, _fmt, ...) do {		\
-		if (sc->sc_debug & ATH_DEBUG_RATE)	\
-			printk(_fmt, __VA_ARGS__);		\
-} while (0)
-#else
-#define	DPRINTF(sc, _fmt, ...)
-#endif
-
 #define ONE_SECOND (1000 * 1000)  /* 1 second, or 1000 milliseconds; eternity, in other words */
 
 #include "release.h"
@@ -471,11 +457,11 @@ ath_rate_tx_complete(struct ath_softc *s
 		final_rate = sc->sc_hwmap[ts->ts_rate & ~HAL_TXSTAT_ALTRATE].ieeerate;
 		final_ndx = rate_to_ndx(sn, final_rate);
 		if (final_ndx >= sn->num_rates) {
-			DPRINTF(sc, "%s: final ndx too high\n", __func__);
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: final ndx too high\n", __func__);
 			final_ndx = 0;
 		}
 		if (final_ndx < 0) {
-			DPRINTF(sc, "%s: final ndx too low\n", __func__);
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: final ndx too low\n", __func__);
 			final_ndx = 0;
 		}
 
@@ -485,7 +471,7 @@ ath_rate_tx_complete(struct ath_softc *s
 		tries = ts->ts_longretry + 1;
 
 		if (sn->num_rates <= 0) {
-			DPRINTF(sc, "%s: " MAC_FMT " %s no rates yet\n", dev_info,
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " %s no rates yet\n", dev_info,
 				MAC_ADDR(an->an_node.ni_macaddr), __func__);
 			return;
 		}
@@ -551,7 +537,7 @@ ath_rate_tx_complete(struct ath_softc *s
 static void
 ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
 {
-		DPRINTF(sc, "%s: " MAC_FMT " %s\n", dev_info,
+		DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " %s\n", dev_info,
 			MAC_ADDR(an->an_node.ni_macaddr), __func__);
 		if (isnew)
 			ath_rate_ctl_reset(sc, &an->an_node);
@@ -601,7 +587,7 @@ ath_fill_sample_table(struct minstrel_no
 			    p = rates + sprintf(rates, "rates :: %d ", column_index);
 			    for (i = 0; i < num_sample_rates; i++)
 			            p += sprintf(p, "%2u ", sn->rs_sampleTable[i][column_index]);
-			    DPRINTF(sc, "%s\n", rates);
+			    DPRINTF(sc, ATH_DEBUG_RATE, "%s\n", rates);
 		};
 #endif
 }
@@ -628,7 +614,7 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 		sn->is_sampling = 0;
 
 		if (rt == NULL) {
-			DPRINTF(sc, "no rates yet! mode %u\n", sc->sc_curmode);
+			DPRINTF(sc, ATH_DEBUG_RATE, "no rates yet! mode %u\n", sc->sc_curmode);
 			return;
 		}
 		sn->static_rate_ndx = -1;
@@ -658,7 +644,7 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 			sn->rates[x].rix = sc->sc_rixmap[sn->rates[x].rate];
 			}
 			if (sn->rates[x].rix == 0xff) {
-				DPRINTF(sc, "%s: %s ignore bogus rix at %d\n",
+				DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s ignore bogus rix at %d\n",
 					dev_info, __func__, x);
 				continue;
 			}
@@ -673,7 +659,7 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 		ni->ni_txrate = 0;
 
 		if (sn->num_rates <= 0) {
-			DPRINTF(sc, "%s: %s " MAC_FMT " no rates (fixed %d) \n",
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " no rates (fixed %d) \n",
 				dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
 				vap->iv_fixed_rate);
 			/* There are no rates yet; we're done */
@@ -689,23 +675,23 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 			 * the node.  We know the rate is there because the
 			 * rate set is checked when the station associates. */
 			/* NB: the rate set is assumed sorted */
-			for (; (srate >= 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
-
-			KASSERT(srate >= 0,
-				("fixed rate %d not in rate set", vap->iv_fixed_rate));
+			for (; (srate > 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
 
 			sn->static_rate_ndx = srate;
 			ni->ni_txrate = srate;
-			DPRINTF(sc, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
-				dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
-				sn->rates[srate].rate / 2,
-				(sn->rates[srate].rate % 2) ? ".5 " : " ");
+			if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
+				EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
+			else
+				DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
+					dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
+					sn->rates[srate].rate / 2,
+					(sn->rates[srate].rate % 2) ? ".5 " : " ");
 			return;
 		}
 
 		for (x = 0; x < ni->ni_rates.rs_nrates; x++) {
 			if (sn->rates[x].rix == 0xff) {
-				DPRINTF(sc, "%s: %s ignore bogus rix at %d\n",
+				DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s ignore bogus rix at %d\n",
 					dev_info, __func__, x);
 				continue;
 			}
@@ -735,9 +721,9 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 		}
 
 #if 0
-		DPRINTF(sc, "%s: Retry table for this node\n", __func__);
+		DPRINTF(sc, ATH_DEBUG_RATE, "%s: Retry table for this node\n", __func__);
 		  for (x = 0; x < ni->ni_rates.rs_nrates; x++)
-			     DPRINTF(sc, "%2d  %2d %6d  \n", x, sn->retry_count[x], sn->perfect_tx_time[x]);
+			     DPRINTF(sc, ATH_DEBUG_RATE, "%2d  %2d %6d  \n", x, sn->retry_count[x], sn->perfect_tx_time[x]);
 #endif
 
 		/* Set the initial rate */
@@ -781,10 +767,10 @@ ath_timer_function(unsigned long data)
 		unsigned int interval = ath_timer_interval;
 
 		if (dev == NULL)
-			DPRINTF(sc, "%s: 'dev' is null in this timer \n", __func__);
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'dev' is null in this timer \n", __func__);
 
 		if (sc == NULL)
-			DPRINTF(sc, "%s: 'sc' is null in this timer\n", __func__);
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'sc' is null in this timer\n", __func__);
 
 		ic = &sc->sc_ic;
 
@@ -808,7 +794,7 @@ ath_timer_function(unsigned long data)
 
 		timer  = &(ssc->timer);
 		if (timer == NULL)
-			DPRINTF(sc, "%s: timer is null - leave it\n", __func__);
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: timer is null - leave it\n", __func__);
 
 		timer->expires = jiffies + ((HZ * interval) / 1000);
 		add_timer(timer);
@@ -904,7 +890,7 @@ static struct ath_ratectrl *
 ath_rate_attach(struct ath_softc *sc)
 {
 		struct minstrel_softc *osc;
-		DPRINTF(sc, "%s: %s\n", dev_info, __func__);
+		DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s\n", dev_info, __func__);
 
 		_MOD_INC_USE(THIS_MODULE, return NULL);
 		osc = kmalloc(sizeof(struct minstrel_softc), GFP_ATOMIC);
@@ -963,7 +949,7 @@ ath_proc_read_nodes(struct ieee80211vap
 					p += sprintf(p, "out of room for node " MAC_FMT "\n\n", MAC_ADDR(ni->ni_macaddr));
 					break;
 				}
-				DPRINTF(sc, "%s: out of memeory to write tall of the nodes\n", __func__);
+				DPRINTF(sc, ATH_DEBUG_RATE, "%s: out of memeory to write tall of the nodes\n", __func__);
 			            break;
 			}
 			an = ATH_NODE(ni);
--- a/ath_rate/amrr/amrr.c
+++ b/ath_rate/amrr/amrr.c
@@ -64,24 +64,13 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_rate.h>
 
+#include "if_ath_debug.h"
 #include "if_athvar.h"
 #include "if_ath_hal.h"
 #include "ah_desc.h"
 
 #include "amrr.h"
 
-#ifdef AR_DEBUG
-#define	AMRR_DEBUG
-#endif
-#ifdef AMRR_DEBUG
-#define	DPRINTF(sc, _fmt, ...) do {					\
-	if (sc->sc_debug & 0x10)					\
-		printk(_fmt, __VA_ARGS__);				\
-} while (0)
-#else
-#define	DPRINTF(sc, _fmt, ...)
-#endif
-
 static int ath_rateinterval = 1000;		/* rate ctl interval (ms)  */
 static int ath_rate_max_success_threshold = 10;
 static int ath_rate_min_success_threshold = 1;
@@ -197,7 +186,7 @@ ath_rate_update(struct ath_softc *sc, st
 
 	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
 
-	DPRINTF(sc, "%s: set xmit rate for " MAC_FMT " to %dM\n",
+	DPRINTF(sc, ATH_DEBUG_RATE, "%s: set xmit rate for " MAC_FMT " to %dM\n",
 		__func__, MAC_ADDR(ni->ni_macaddr),
 		ni->ni_rates.rs_nrates > 0 ?
 			(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
@@ -297,9 +286,9 @@ ath_rate_ctl_start(struct ath_softc *sc,
 		 * rate set is checked when the station associates.
 		 */
 		srate = ni->ni_rates.rs_nrates - 1;
-		for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
-		KASSERT(srate >= 0,
-			("fixed rate %d not in rate set", vap->iv_fixed_rate));
+		for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
+		if (RATE(srate) != vap->iv_fixed_rate)
+			EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
 	}
 	ath_rate_update(sc, ni, srate);
 #undef RATE
@@ -377,7 +366,7 @@ ath_rate_ctl(void *arg, struct ieee80211
 
 	old_rate = ni->ni_txrate;
 
-  	DPRINTF (sc, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
+  	DPRINTF(sc, ATH_DEBUG_RATE, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
 		 amn->amn_tx_try0_cnt,
 		 amn->amn_tx_try1_cnt,
 		 amn->amn_tx_try2_cnt,
@@ -390,7 +379,7 @@ ath_rate_ctl(void *arg, struct ieee80211
   			amn->amn_recovery = 1;
   			amn->amn_success = 0;
   			ni->ni_txrate++;
-			DPRINTF(sc, "increase rate to %d\n", ni->ni_txrate);
+			DPRINTF(sc, ATH_DEBUG_RATE, "increase rate to %d\n", ni->ni_txrate);
   		} else
 			amn->amn_recovery = 0;
   	} else if (is_failure(amn)) {
@@ -401,12 +390,12 @@ ath_rate_ctl(void *arg, struct ieee80211
   				amn->amn_success_threshold *= 2;
   				amn->amn_success_threshold = min(amn->amn_success_threshold,
 								  (u_int)ath_rate_max_success_threshold);
- 				DPRINTF(sc, "decrease rate recovery thr: %d\n",
+ 				DPRINTF(sc, ATH_DEBUG_RATE, "decrease rate recovery thr: %d\n",
 					amn->amn_success_threshold);
   			} else {
   				/* simple failure. */
  				amn->amn_success_threshold = ath_rate_min_success_threshold;
- 				DPRINTF(sc, "decrease rate normal thr: %d\n",
+ 				DPRINTF(sc, ATH_DEBUG_RATE, "decrease rate normal thr: %d\n",
 					amn->amn_success_threshold);
   			}
 			amn->amn_recovery = 0;
--- a/ath_rate/onoe/onoe.c
+++ b/ath_rate/onoe/onoe.c
@@ -60,27 +60,13 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_rate.h>
 
+#include "if_ath_debug.h"
 #include "if_athvar.h"
 #include "if_ath_hal.h"
 #include "ah_desc.h"
 
 #include "onoe.h"
 
-#ifdef AR_DEBUG
-#define	ONOE_DEBUG
-#endif
-#ifdef ONOE_DEBUG
-enum {
-	ATH_DEBUG_RATE	= 0x00000010,	/* rate control */
-};
-#define	DPRINTF(sc, _fmt, ...) do {				\
-	if (sc->sc_debug & ATH_DEBUG_RATE)			\
-		printk(_fmt, __VA_ARGS__);			\
-} while (0)
-#else
-#define	DPRINTF(sc, _fmt, ...)
-#endif
-
 /*
  * Default parameters for the rate control algorithm.  These are
  * all tunable with sysctls.  The rate controller runs periodically
@@ -186,7 +172,7 @@ ath_rate_update(struct ath_softc *sc, st
 
 	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
 
-	DPRINTF(sc, "%s: set xmit rate for " MAC_FMT " to %dM\n",
+	DPRINTF(sc, ATH_DEBUG_RATE, "%s: set xmit rate for " MAC_FMT " to %dM\n",
 		__func__, MAC_ADDR(ni->ni_macaddr),
 		ni->ni_rates.rs_nrates > 0 ?
 			(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
@@ -283,9 +269,9 @@ ath_rate_ctl_start(struct ath_softc *sc,
 		 */
 		/* NB: the rate set is assumed sorted */
 		srate = ni->ni_rates.rs_nrates - 1;
-		for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
-		KASSERT(srate >= 0,
-			("fixed rate %d not in rate set", vap->iv_fixed_rate));
+		for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
+		if (RATE(srate) != vap->iv_fixed_rate)
+			EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
 	}
 	ath_rate_update(sc, ni, srate);
 #undef RATE
@@ -364,7 +350,7 @@ ath_rate_ctl(void *arg, struct ieee80211
 	    on->on_tx_retr < (on->on_tx_ok * ath_rate_raise) / 100)
 		dir = 1;
 
-	DPRINTF(sc, MAC_FMT ": ok %d err %d retr %d upper %d dir %d\n",
+	DPRINTF(sc, ATH_DEBUG_RATE, MAC_FMT ": ok %d err %d retr %d upper %d dir %d\n",
 		MAC_ADDR(ni->ni_macaddr),
 		on->on_tx_ok, on->on_tx_err, on->on_tx_retr,
 		on->on_tx_upper, dir);
@@ -395,7 +381,7 @@ ath_rate_ctl(void *arg, struct ieee80211
 	}
 
 	if (nrate != ni->ni_txrate) {
-		DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
+		DPRINTF(sc, ATH_DEBUG_RATE, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
 		    __func__,
 		    (rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 2,
 		    (rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
--- a/ath_rate/sample/sample.c
+++ b/ath_rate/sample/sample.c
@@ -62,30 +62,13 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_rate.h>
 
+#include "if_ath_debug.h"
 #include "if_athvar.h"
 #include "if_ath_hal.h"
 #include "ah_desc.h"
 
 #include "sample.h"
 
-#ifdef AR_DEBUG
-#define SAMPLE_DEBUG
-#endif
-#ifdef SAMPLE_DEBUG
-enum {
-	ATH_DEBUG_RATE		= 0x00000010,	/* rate control */
-	ATH_DEBUG_ANY		= 0xffffffff
-};
-#define	DPRINTF(sc, m, fmt, ...) do {				\
-	if (sc->sc_debug & (m))					\
-		printk(fmt, __VA_ARGS__);			\
-} while (0)
-#else
-#define	DPRINTF(sc, m, fmt, ...) do {				\
-	(void) sc;						\
-} while (0)
-#endif
-
 /*
  * This file is an implementation of the SampleRate algorithm
  * in "Bit-rate Selection in Wireless Networks"
@@ -740,7 +723,7 @@ ath_rate_tx_complete(struct ath_softc *s
 		ndx[3] = rate_to_ndx(sn, rate[3]);
 
 #if 0
-		DPRINTF(sc, "%s: " MAC_FMT " size %u finaltsidx %u tries %u status %u rate/try %u/%u %u/%u %u/%u %u/%u\n",
+		DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " size %u finaltsidx %u tries %u status %u rate/try %u/%u %u/%u %u/%u %u/%u\n",
 			dev_info, MAC_ADDR(an->an_node.ni_macaddr),
 			bin_to_size(size_to_bin(frame_size)),
 			finalTSIdx,
@@ -886,15 +869,16 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 			if ((ni->ni_rates.rs_rates[x] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate)
 				srate = x;
 
-		KASSERT(((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate),
-			("fixed rate %u not in rate set", vap->iv_fixed_rate));
-
 		sn->static_rate_ndx = srate;
 		ni->ni_txrate = srate;
-		DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
-			dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
-			sn->rates[srate].rate / 2,
-			(sn->rates[srate].rate % 0x1) ? ".5" : " ");
+
+		if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
+			EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
+		else
+			DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
+				dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
+				sn->rates[srate].rate / 2,
+				(sn->rates[srate].rate % 0x1) ? ".5" : " ");
 		return;
 	}