1 --- a/ath_rate/minstrel/minstrel.c
2 +++ b/ath_rate/minstrel/minstrel.c
4 #include <net80211/ieee80211_var.h>
5 #include <net80211/ieee80211_rate.h>
7 +#include "if_ath_debug.h"
9 #include "if_ath_hal.h"
15 -#define MINSTREL_DEBUG
17 -#ifdef MINSTREL_DEBUG
19 - ATH_DEBUG_RATE = 0x00000010 /* rate control */
21 -#define DPRINTF(sc, _fmt, ...) do { \
22 - if (sc->sc_debug & ATH_DEBUG_RATE) \
23 - printk(_fmt, __VA_ARGS__); \
26 -#define DPRINTF(sc, _fmt, ...)
29 #define ONE_SECOND (1000 * 1000) /* 1 second, or 1000 milliseconds; eternity, in other words */
33 final_rate = sc->sc_hwmap[ts->ts_rate & ~HAL_TXSTAT_ALTRATE].ieeerate;
34 final_ndx = rate_to_ndx(sn, final_rate);
35 if (final_ndx >= sn->num_rates) {
36 - DPRINTF(sc, "%s: final ndx too high\n", __func__);
37 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: final ndx too high\n", __func__);
41 - DPRINTF(sc, "%s: final ndx too low\n", __func__);
42 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: final ndx too low\n", __func__);
47 tries = ts->ts_longretry + 1;
49 if (sn->num_rates <= 0) {
50 - DPRINTF(sc, "%s: " MAC_FMT " %s no rates yet\n", dev_info,
51 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " %s no rates yet\n", dev_info,
52 MAC_ADDR(an->an_node.ni_macaddr), __func__);
57 ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
59 - DPRINTF(sc, "%s: " MAC_FMT " %s\n", dev_info,
60 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " %s\n", dev_info,
61 MAC_ADDR(an->an_node.ni_macaddr), __func__);
63 ath_rate_ctl_reset(sc, &an->an_node);
65 p = rates + sprintf(rates, "rates :: %d ", column_index);
66 for (i = 0; i < num_sample_rates; i++)
67 p += sprintf(p, "%2u ", sn->rs_sampleTable[i][column_index]);
68 - DPRINTF(sc, "%s\n", rates);
69 + DPRINTF(sc, ATH_DEBUG_RATE, "%s\n", rates);
77 - DPRINTF(sc, "no rates yet! mode %u\n", sc->sc_curmode);
78 + DPRINTF(sc, ATH_DEBUG_RATE, "no rates yet! mode %u\n", sc->sc_curmode);
81 sn->static_rate_ndx = -1;
83 sn->rates[x].rix = sc->sc_rixmap[sn->rates[x].rate];
85 if (sn->rates[x].rix == 0xff) {
86 - DPRINTF(sc, "%s: %s ignore bogus rix at %d\n",
87 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s ignore bogus rix at %d\n",
88 dev_info, __func__, x);
94 if (sn->num_rates <= 0) {
95 - DPRINTF(sc, "%s: %s " MAC_FMT " no rates (fixed %d) \n",
96 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " no rates (fixed %d) \n",
97 dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
99 /* There are no rates yet; we're done */
100 @@ -689,23 +675,23 @@
101 * the node. We know the rate is there because the
102 * rate set is checked when the station associates. */
103 /* NB: the rate set is assumed sorted */
104 - for (; (srate >= 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
106 - KASSERT(srate >= 0,
107 - ("fixed rate %d not in rate set", vap->iv_fixed_rate));
108 + for (; (srate > 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
110 sn->static_rate_ndx = srate;
111 ni->ni_txrate = srate;
112 - DPRINTF(sc, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
113 - dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
114 - sn->rates[srate].rate / 2,
115 - (sn->rates[srate].rate % 2) ? ".5 " : " ");
116 + if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
117 + EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
119 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
120 + dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
121 + sn->rates[srate].rate / 2,
122 + (sn->rates[srate].rate % 2) ? ".5 " : " ");
126 for (x = 0; x < ni->ni_rates.rs_nrates; x++) {
127 if (sn->rates[x].rix == 0xff) {
128 - DPRINTF(sc, "%s: %s ignore bogus rix at %d\n",
129 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s ignore bogus rix at %d\n",
130 dev_info, __func__, x);
137 - DPRINTF(sc, "%s: Retry table for this node\n", __func__);
138 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: Retry table for this node\n", __func__);
139 for (x = 0; x < ni->ni_rates.rs_nrates; x++)
140 - DPRINTF(sc, "%2d %2d %6d \n", x, sn->retry_count[x], sn->perfect_tx_time[x]);
141 + DPRINTF(sc, ATH_DEBUG_RATE, "%2d %2d %6d \n", x, sn->retry_count[x], sn->perfect_tx_time[x]);
144 /* Set the initial rate */
145 @@ -781,10 +767,10 @@
146 unsigned int interval = ath_timer_interval;
149 - DPRINTF(sc, "%s: 'dev' is null in this timer \n", __func__);
150 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'dev' is null in this timer \n", __func__);
153 - DPRINTF(sc, "%s: 'sc' is null in this timer\n", __func__);
154 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'sc' is null in this timer\n", __func__);
160 timer = &(ssc->timer);
162 - DPRINTF(sc, "%s: timer is null - leave it\n", __func__);
163 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: timer is null - leave it\n", __func__);
165 timer->expires = jiffies + ((HZ * interval) / 1000);
168 ath_rate_attach(struct ath_softc *sc)
170 struct minstrel_softc *osc;
171 - DPRINTF(sc, "%s: %s\n", dev_info, __func__);
172 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s\n", dev_info, __func__);
174 _MOD_INC_USE(THIS_MODULE, return NULL);
175 osc = kmalloc(sizeof(struct minstrel_softc), GFP_ATOMIC);
177 p += sprintf(p, "out of room for node " MAC_FMT "\n\n", MAC_ADDR(ni->ni_macaddr));
180 - DPRINTF(sc, "%s: out of memeory to write tall of the nodes\n", __func__);
181 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: out of memeory to write tall of the nodes\n", __func__);
185 --- a/ath_rate/amrr/amrr.c
186 +++ b/ath_rate/amrr/amrr.c
188 #include <net80211/ieee80211_var.h>
189 #include <net80211/ieee80211_rate.h>
191 +#include "if_ath_debug.h"
192 #include "if_athvar.h"
193 #include "if_ath_hal.h"
202 -#define DPRINTF(sc, _fmt, ...) do { \
203 - if (sc->sc_debug & 0x10) \
204 - printk(_fmt, __VA_ARGS__); \
207 -#define DPRINTF(sc, _fmt, ...)
210 static int ath_rateinterval = 1000; /* rate ctl interval (ms) */
211 static int ath_rate_max_success_threshold = 10;
212 static int ath_rate_min_success_threshold = 1;
215 KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
217 - DPRINTF(sc, "%s: set xmit rate for " MAC_FMT " to %dM\n",
218 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: set xmit rate for " MAC_FMT " to %dM\n",
219 __func__, MAC_ADDR(ni->ni_macaddr),
220 ni->ni_rates.rs_nrates > 0 ?
221 (ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
223 * rate set is checked when the station associates.
225 srate = ni->ni_rates.rs_nrates - 1;
226 - for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
227 - KASSERT(srate >= 0,
228 - ("fixed rate %d not in rate set", vap->iv_fixed_rate));
229 + for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
230 + if (RATE(srate) != vap->iv_fixed_rate)
231 + EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
233 ath_rate_update(sc, ni, srate);
237 old_rate = ni->ni_txrate;
239 - DPRINTF (sc, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
240 + DPRINTF(sc, ATH_DEBUG_RATE, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
241 amn->amn_tx_try0_cnt,
242 amn->amn_tx_try1_cnt,
243 amn->amn_tx_try2_cnt,
245 amn->amn_recovery = 1;
246 amn->amn_success = 0;
248 - DPRINTF(sc, "increase rate to %d\n", ni->ni_txrate);
249 + DPRINTF(sc, ATH_DEBUG_RATE, "increase rate to %d\n", ni->ni_txrate);
251 amn->amn_recovery = 0;
252 } else if (is_failure(amn)) {
253 @@ -401,12 +390,12 @@
254 amn->amn_success_threshold *= 2;
255 amn->amn_success_threshold = min(amn->amn_success_threshold,
256 (u_int)ath_rate_max_success_threshold);
257 - DPRINTF(sc, "decrease rate recovery thr: %d\n",
258 + DPRINTF(sc, ATH_DEBUG_RATE, "decrease rate recovery thr: %d\n",
259 amn->amn_success_threshold);
261 /* simple failure. */
262 amn->amn_success_threshold = ath_rate_min_success_threshold;
263 - DPRINTF(sc, "decrease rate normal thr: %d\n",
264 + DPRINTF(sc, ATH_DEBUG_RATE, "decrease rate normal thr: %d\n",
265 amn->amn_success_threshold);
267 amn->amn_recovery = 0;
268 --- a/ath_rate/onoe/onoe.c
269 +++ b/ath_rate/onoe/onoe.c
271 #include <net80211/ieee80211_var.h>
272 #include <net80211/ieee80211_rate.h>
274 +#include "if_ath_debug.h"
275 #include "if_athvar.h"
276 #include "if_ath_hal.h"
286 - ATH_DEBUG_RATE = 0x00000010, /* rate control */
288 -#define DPRINTF(sc, _fmt, ...) do { \
289 - if (sc->sc_debug & ATH_DEBUG_RATE) \
290 - printk(_fmt, __VA_ARGS__); \
293 -#define DPRINTF(sc, _fmt, ...)
297 * Default parameters for the rate control algorithm. These are
298 * all tunable with sysctls. The rate controller runs periodically
301 KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
303 - DPRINTF(sc, "%s: set xmit rate for " MAC_FMT " to %dM\n",
304 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: set xmit rate for " MAC_FMT " to %dM\n",
305 __func__, MAC_ADDR(ni->ni_macaddr),
306 ni->ni_rates.rs_nrates > 0 ?
307 (ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
310 /* NB: the rate set is assumed sorted */
311 srate = ni->ni_rates.rs_nrates - 1;
312 - for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
313 - KASSERT(srate >= 0,
314 - ("fixed rate %d not in rate set", vap->iv_fixed_rate));
315 + for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
316 + if (RATE(srate) != vap->iv_fixed_rate)
317 + EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
319 ath_rate_update(sc, ni, srate);
322 on->on_tx_retr < (on->on_tx_ok * ath_rate_raise) / 100)
325 - DPRINTF(sc, MAC_FMT ": ok %d err %d retr %d upper %d dir %d\n",
326 + DPRINTF(sc, ATH_DEBUG_RATE, MAC_FMT ": ok %d err %d retr %d upper %d dir %d\n",
327 MAC_ADDR(ni->ni_macaddr),
328 on->on_tx_ok, on->on_tx_err, on->on_tx_retr,
329 on->on_tx_upper, dir);
333 if (nrate != ni->ni_txrate) {
334 - DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
335 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
337 (rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 2,
338 (rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
339 --- a/ath_rate/sample/sample.c
340 +++ b/ath_rate/sample/sample.c
342 #include <net80211/ieee80211_var.h>
343 #include <net80211/ieee80211_rate.h>
345 +#include "if_ath_debug.h"
346 #include "if_athvar.h"
347 #include "if_ath_hal.h"
353 -#define SAMPLE_DEBUG
357 - ATH_DEBUG_RATE = 0x00000010, /* rate control */
358 - ATH_DEBUG_ANY = 0xffffffff
360 -#define DPRINTF(sc, m, fmt, ...) do { \
361 - if (sc->sc_debug & (m)) \
362 - printk(fmt, __VA_ARGS__); \
365 -#define DPRINTF(sc, m, fmt, ...) do { \
371 * This file is an implementation of the SampleRate algorithm
372 * in "Bit-rate Selection in Wireless Networks"
374 ndx[3] = rate_to_ndx(sn, rate[3]);
377 - DPRINTF(sc, "%s: " MAC_FMT " size %u finaltsidx %u tries %u status %u rate/try %u/%u %u/%u %u/%u %u/%u\n",
378 + 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",
379 dev_info, MAC_ADDR(an->an_node.ni_macaddr),
380 bin_to_size(size_to_bin(frame_size)),
382 @@ -886,15 +869,16 @@
383 if ((ni->ni_rates.rs_rates[x] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate)
386 - KASSERT(((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate),
387 - ("fixed rate %u not in rate set", vap->iv_fixed_rate));
389 sn->static_rate_ndx = srate;
390 ni->ni_txrate = srate;
391 - DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
392 - dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
393 - sn->rates[srate].rate / 2,
394 - (sn->rates[srate].rate % 0x1) ? ".5" : " ");
396 + if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
397 + EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
399 + DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
400 + dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
401 + sn->rates[srate].rate / 2,
402 + (sn->rates[srate].rate % 0x1) ? ".5" : " ");