3 @@ -148,7 +148,6 @@ static int ath_key_set(struct ieee80211v
4 static void ath_key_update_begin(struct ieee80211vap *);
5 static void ath_key_update_end(struct ieee80211vap *);
6 static void ath_mode_init(struct net_device *);
7 -static void ath_setslottime(struct ath_softc *);
8 static void ath_updateslot(struct net_device *);
9 static int ath_beaconq_setup(struct ath_softc *);
10 static int ath_beacon_alloc(struct ath_softc *, struct ieee80211_node *);
11 @@ -240,7 +239,7 @@ static void ath_setup_stationkey(struct
12 static void ath_setup_stationwepkey(struct ieee80211_node *);
13 static void ath_setup_keycacheslot(struct ath_softc *, struct ieee80211_node *);
14 static void ath_newassoc(struct ieee80211_node *, int);
15 -static int ath_getchannels(struct net_device *, u_int, HAL_BOOL, HAL_BOOL);
16 +static int ath_getchannels(struct net_device *);
17 static void ath_led_event(struct ath_softc *, int);
18 static void ath_update_txpow(struct ath_softc *);
20 @@ -265,7 +264,6 @@ static int ath_change_mtu(struct net_dev
21 static int ath_ioctl(struct net_device *, struct ifreq *, int);
23 static int ath_rate_setup(struct net_device *, u_int);
24 -static void ath_setup_subrates(struct net_device *);
26 static int ath_xr_rate_setup(struct net_device *);
27 static void ath_grppoll_txq_setup(struct ath_softc *, int, int);
28 @@ -387,8 +385,6 @@ static void ath_fetch_idle_time(struct a
30 /* calibrate every 30 secs in steady state but check every second at first. */
31 static int ath_calinterval = ATH_SHORT_CALINTERVAL;
32 -static int ath_countrycode = CTRY_DEFAULT; /* country code */
33 -static int ath_outdoor = AH_FALSE; /* enable outdoor use */
34 static int ath_xchanmode = AH_TRUE; /* enable extended channels */
35 static int ath_maxvaps = ATH_MAXVAPS_DEFAULT; /* set default maximum vaps */
36 static int bstuck_thresh = BSTUCK_THRESH; /* Stuck beacon count required for reset */
37 @@ -396,9 +392,7 @@ static char *autocreate = NULL;
38 static char *ratectl = DEF_RATE_CTL;
39 static int rfkill = 0;
41 -static int countrycode = -1;
42 static int maxvaps = -1;
43 -static int outdoor = -1;
44 static int xchanmode = -1;
45 #include "ath_wprobe.c"
46 static int beacon_cal = 1;
47 @@ -437,9 +431,7 @@ static struct notifier_block ath_event_b
49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
50 MODULE_PARM(beacon_cal, "i");
51 -MODULE_PARM(countrycode, "i");
52 MODULE_PARM(maxvaps, "i");
53 -MODULE_PARM(outdoor, "i");
54 MODULE_PARM(xchanmode, "i");
55 MODULE_PARM(rfkill, "i");
57 @@ -451,9 +443,7 @@ MODULE_PARM(ratectl, "s");
59 #include <linux/moduleparam.h>
60 module_param(beacon_cal, int, 0600);
61 -module_param(countrycode, int, 0600);
62 module_param(maxvaps, int, 0600);
63 -module_param(outdoor, int, 0600);
64 module_param(xchanmode, int, 0600);
65 module_param(rfkill, int, 0600);
67 @@ -463,9 +453,7 @@ module_param(bstuck_thresh, int, 0600);
68 module_param(autocreate, charp, 0600);
69 module_param(ratectl, charp, 0600);
71 -MODULE_PARM_DESC(countrycode, "Override default country code");
72 MODULE_PARM_DESC(maxvaps, "Maximum VAPs");
73 -MODULE_PARM_DESC(outdoor, "Enable/disable outdoor use");
74 MODULE_PARM_DESC(xchanmode, "Enable/disable extended channel mode");
75 MODULE_PARM_DESC(rfkill, "Enable/disable RFKILL capability");
77 @@ -531,6 +519,50 @@ MODULE_PARM_DESC(ieee80211_debug, "Load-
78 (bssid)[0] |= (((id) << 2) | 0x02); \
81 +static inline int ath_chan2mode(struct ieee80211_channel *c)
83 + if (IEEE80211_IS_CHAN_HALF(c))
84 + return ATH_MODE_HALF;
85 + else if (IEEE80211_IS_CHAN_QUARTER(c))
86 + return ATH_MODE_QUARTER;
88 + return ieee80211_chan2mode(c);
91 +static inline int rate_hal2ieee(int dot11Rate, int f)
93 + int flag = dot11Rate & ~(IEEE80211_RATE_VAL);
94 + dot11Rate &= IEEE80211_RATE_VAL;
96 + if (f == 4) { /* Quarter */
100 + return (dot11Rate * f) | flag;
103 +static inline int rate_factor(int mode)
108 + * NB: Fix up rates. HAL returns half or quarter dot11Rates,
109 + * while the stack deals with full rates only
112 + case ATH_MODE_HALF:
115 + case ATH_MODE_QUARTER:
125 /* Initialize ath_softc structure */
128 @@ -647,14 +679,6 @@ ath_attach(u_int16_t devid, struct net_d
129 for (i = 0; i < sc->sc_keymax; i++)
130 ath_hal_keyreset(ah, i);
133 - * Collect the channel list using the default country
134 - * code and including outdoor channels. The 802.11 layer
135 - * is responsible for filtering this list based on settings
136 - * like the phy mode.
138 - if (countrycode != -1)
139 - ath_countrycode = countrycode;
141 ath_maxvaps = maxvaps;
142 if (ath_maxvaps < ATH_MAXVAPS_MIN)
143 @@ -662,17 +686,14 @@ ath_attach(u_int16_t devid, struct net_d
144 else if (ath_maxvaps > ATH_MAXVAPS_MAX)
145 ath_maxvaps = ATH_MAXVAPS_MAX;
148 - ath_outdoor = outdoor;
150 ath_xchanmode = xchanmode;
151 - error = ath_getchannels(dev, ath_countrycode,
152 - ath_outdoor, ath_xchanmode);
153 + error = ath_getchannels(dev);
157 - ic->ic_country_code = ath_countrycode;
158 - ic->ic_country_outdoor = ath_outdoor;
159 + ic->ic_country_code = CTRY_DEFAULT;
160 + ic->ic_country_outdoor = 0;
162 IPRINTF(sc, "Switching rfkill capability %s\n",
163 rfkill ? "on" : "off");
164 @@ -686,9 +707,8 @@ ath_attach(u_int16_t devid, struct net_d
165 ath_rate_setup(dev, IEEE80211_MODE_11G);
166 ath_rate_setup(dev, IEEE80211_MODE_TURBO_A);
167 ath_rate_setup(dev, IEEE80211_MODE_TURBO_G);
169 - /* Setup for half/quarter rates */
170 - ath_setup_subrates(dev);
171 + ath_rate_setup(dev, ATH_MODE_HALF);
172 + ath_rate_setup(dev, ATH_MODE_QUARTER);
174 /* NB: setup here so ath_rate_update is happy */
175 ath_setcurmode(sc, IEEE80211_MODE_11A);
176 @@ -909,10 +929,6 @@ ath_attach(u_int16_t devid, struct net_d
177 IEEE80211_ATHC_COMP : 0);
180 -#ifdef ATH_SUPERG_DYNTURBO
181 - ic->ic_ath_cap |= (ath_hal_turboagsupported(ah, ath_countrycode) ?
182 - (IEEE80211_ATHC_TURBOP | IEEE80211_ATHC_AR) : 0);
185 ic->ic_ath_cap |= (ath_hal_xrsupported(ah) ? IEEE80211_ATHC_XR : 0);
187 @@ -4466,17 +4482,17 @@ ath_mode_init(struct net_device *dev)
188 * Set the slot time based on the current setting.
191 -ath_setslottime(struct ath_softc *sc)
192 +ath_settiming(struct ath_softc *sc)
194 - struct ieee80211com *ic = &sc->sc_ic;
195 struct ath_hal *ah = sc->sc_ah;
196 + u_int offset = getTimingOffset(sc);
198 - if (sc->sc_slottimeconf > 0) /* manual override */
199 - ath_hal_setslottime(ah, sc->sc_slottimeconf);
200 - else if (ic->ic_flags & IEEE80211_F_SHSLOT)
201 - ath_hal_setslottime(ah, HAL_SLOT_TIME_9);
203 - ath_hal_setslottime(ah, HAL_SLOT_TIME_20);
204 + if (sc->sc_slottimeconf > 0)
205 + ath_hal_setslottime(ah, offset + sc->sc_slottimeconf);
206 + if (sc->sc_acktimeconf > 0)
207 + ath_hal_setacktimeout(ah, 2 * offset + sc->sc_acktimeconf);
208 + if (sc->sc_ctstimeconf > 0)
209 + ath_hal_setctstimeout(ah, 2 * offset + sc->sc_ctstimeconf);
210 sc->sc_updateslot = OK;
213 @@ -4498,7 +4514,7 @@ ath_updateslot(struct net_device *dev)
214 if (ic->ic_opmode == IEEE80211_M_HOSTAP)
215 sc->sc_updateslot = UPDATE;
216 else if (dev->flags & IFF_RUNNING)
217 - ath_setslottime(sc);
221 #ifdef ATH_SUPERG_DYNTURBO
222 @@ -5342,7 +5358,7 @@ ath_beacon_send(struct ath_softc *sc, in
223 sc->sc_updateslot = COMMIT; /* commit next beacon */
224 sc->sc_slotupdate = slot;
225 } else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot))
226 - ath_setslottime(sc); /* commit change to hardware */
227 + ath_settiming(sc); /* commit change to hardware */
231 @@ -7796,12 +7812,14 @@ ath_get_ivlen(struct ieee80211_key *k)
232 * Get transmit rate index using rate in Kbps
235 -ath_tx_findindex(const HAL_RATE_TABLE *rt, int rate)
236 +ath_tx_findindex(struct ath_softc *sc, const HAL_RATE_TABLE *rt, int rate)
238 unsigned int i, ndx = 0;
241 + f = rate_factor(sc->sc_curmode);
242 for (i = 0; i < rt->rateCount; i++) {
243 - if (rt->info[i].rateKbps == rate) {
244 + if ((rt->info[i].rateKbps * f) == rate) {
248 @@ -8094,7 +8112,7 @@ ath_tx_start(struct net_device *dev, str
249 atype = HAL_PKT_TYPE_NORMAL; /* default */
252 - rix = ath_tx_findindex(rt, vap->iv_mcast_rate);
253 + rix = ath_tx_findindex(sc, rt, vap->iv_mcast_rate);
254 txrate = rt->info[rix].rateCode;
256 txrate |= rt->info[rix].shortPreamble;
257 @@ -9061,7 +9079,7 @@ ath_chan_change(struct ath_softc *sc, st
258 struct net_device *dev = sc->sc_dev;
259 enum ieee80211_phymode mode;
261 - mode = ieee80211_chan2mode(chan);
262 + mode = ath_chan2mode(chan);
264 ath_rate_setup(dev, mode);
265 ath_setcurmode(sc, mode);
266 @@ -10110,8 +10128,7 @@ ath_newassoc(struct ieee80211_node *ni,
270 -ath_getchannels(struct net_device *dev, u_int cc,
271 - HAL_BOOL outdoor, HAL_BOOL xchanmode)
272 +ath_getchannels(struct net_device *dev)
274 struct ath_softc *sc = dev->priv;
275 struct ieee80211com *ic = &sc->sc_ic;
276 @@ -10125,17 +10142,31 @@ ath_getchannels(struct net_device *dev,
277 EPRINTF(sc, "Insufficient memory for channel table!\n");
282 if (!ath_hal_init_channels(ah, chans, IEEE80211_CHAN_MAX, &nchan,
283 ic->ic_regclassids, IEEE80211_REGCLASSIDS_MAX, &ic->ic_nregclass,
284 - cc, HAL_MODE_ALL, outdoor, xchanmode)) {
285 + ic->ic_country_code, HAL_MODE_ALL, ic->ic_country_outdoor, ath_xchanmode)) {
288 ath_hal_getregdomain(ah, &rd);
289 EPRINTF(sc, "Unable to collect channel list from HAL; "
290 - "regdomain likely %u country code %u\n", rd, cc);
291 + "regdomain likely %u country code %u\n", rd, ic->ic_country_code);
292 + if ((ic->ic_country_code != CTRY_DEFAULT) ||
293 + (ic->ic_country_outdoor != 0)) {
294 + EPRINTF(sc, "Reverting to defaults\n");
295 + ic->ic_country_code = CTRY_DEFAULT;
296 + ic->ic_country_outdoor = 0;
302 +#ifdef ATH_SUPERG_DYNTURBO
303 + ic->ic_ath_cap &= ~(IEEE80211_ATHC_TURBOP | IEEE80211_ATHC_AR);
304 + ic->ic_ath_cap |= (ath_hal_turboagsupported(ah, ic->ic_country_code) ?
305 + (IEEE80211_ATHC_TURBOP | IEEE80211_ATHC_AR) : 0);
308 * Convert HAL channels to ieee80211 ones.
310 @@ -10379,7 +10410,7 @@ ath_xr_rate_setup(struct net_device *dev
311 struct ieee80211com *ic = &sc->sc_ic;
312 const HAL_RATE_TABLE *rt;
313 struct ieee80211_rateset *rs;
314 - unsigned int i, maxrates;
315 + unsigned int i, j, maxrates;
316 sc->sc_xr_rates = ath_hal_getratetable(ah, HAL_MODE_XR);
317 rt = sc->sc_xr_rates;
319 @@ -10392,57 +10423,16 @@ ath_xr_rate_setup(struct net_device *dev
321 maxrates = rt->rateCount;
322 rs = &ic->ic_sup_xr_rates;
323 - for (i = 0; i < maxrates; i++)
324 - rs->rs_rates[i] = rt->info[i].dot11Rate;
325 - rs->rs_nrates = maxrates;
326 + for (j = 0, i = 0; i < maxrates; i++) {
327 + if (!rt->info[i].valid)
329 + rs->rs_rates[j++] = rt->info[i].dot11Rate;
336 -/* Setup half/quarter rate table support */
338 -ath_setup_subrates(struct net_device *dev)
340 - struct ath_softc *sc = dev->priv;
341 - struct ath_hal *ah = sc->sc_ah;
342 - struct ieee80211com *ic = &sc->sc_ic;
343 - const HAL_RATE_TABLE *rt;
344 - struct ieee80211_rateset *rs;
345 - unsigned int i, maxrates;
347 - sc->sc_half_rates = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
348 - rt = sc->sc_half_rates;
350 - if (rt->rateCount > IEEE80211_RATE_MAXSIZE) {
351 - DPRINTF(sc, ATH_DEBUG_ANY,
352 - "The rate table is too small (%u > %u)\n",
353 - rt->rateCount, IEEE80211_RATE_MAXSIZE);
354 - maxrates = IEEE80211_RATE_MAXSIZE;
356 - maxrates = rt->rateCount;
357 - rs = &ic->ic_sup_half_rates;
358 - for (i = 0; i < maxrates; i++)
359 - rs->rs_rates[i] = rt->info[i].dot11Rate;
360 - rs->rs_nrates = maxrates;
363 - sc->sc_quarter_rates = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
364 - rt = sc->sc_quarter_rates;
366 - if (rt->rateCount > IEEE80211_RATE_MAXSIZE) {
367 - DPRINTF(sc, ATH_DEBUG_ANY,
368 - "The rate table is too small (%u > %u)\n",
369 - rt->rateCount, IEEE80211_RATE_MAXSIZE);
370 - maxrates = IEEE80211_RATE_MAXSIZE;
372 - maxrates = rt->rateCount;
373 - rs = &ic->ic_sup_quarter_rates;
374 - for (i = 0; i < maxrates; i++)
375 - rs->rs_rates[i] = rt->info[i].dot11Rate;
376 - rs->rs_nrates = maxrates;
381 ath_rate_setup(struct net_device *dev, u_int mode)
383 @@ -10451,7 +10441,7 @@ ath_rate_setup(struct net_device *dev, u
384 struct ieee80211com *ic = &sc->sc_ic;
385 const HAL_RATE_TABLE *rt;
386 struct ieee80211_rateset *rs;
387 - unsigned int i, maxrates;
388 + unsigned int i, j, maxrates, f;
391 case IEEE80211_MODE_11A:
392 @@ -10469,6 +10459,12 @@ ath_rate_setup(struct net_device *dev, u
393 case IEEE80211_MODE_TURBO_G:
394 sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_108G);
396 + case ATH_MODE_HALF:
397 + sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
399 + case ATH_MODE_QUARTER:
400 + sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
403 DPRINTF(sc, ATH_DEBUG_ANY, "Invalid mode %u\n", mode);
405 @@ -10483,10 +10479,16 @@ ath_rate_setup(struct net_device *dev, u
406 maxrates = IEEE80211_RATE_MAXSIZE;
408 maxrates = rt->rateCount;
410 + /* NB: quarter/half rate channels hijack the 11A rateset */
411 + if (mode >= IEEE80211_MODE_MAX)
414 rs = &ic->ic_sup_rates[mode];
415 for (i = 0; i < maxrates; i++)
416 rs->rs_rates[i] = rt->info[i].dot11Rate;
417 rs->rs_nrates = maxrates;
422 @@ -10515,13 +10517,18 @@ ath_setcurmode(struct ath_softc *sc, enu
425 const HAL_RATE_TABLE *rt;
427 + unsigned int i, j, f;
430 + * NB: Fix up rixmap. HAL returns half or quarter dot11Rates,
431 + * while the stack deals with full rates only
433 + f = rate_factor(mode);
434 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap));
435 rt = sc->sc_rates[mode];
436 KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode));
437 for (i = 0; i < rt->rateCount; i++)
438 - sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i;
439 + sc->sc_rixmap[rate_hal2ieee(rt->info[i].dot11Rate, f) & IEEE80211_RATE_VAL] = i;
440 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
441 for (i = 0; i < 32; i++) {
442 u_int8_t ix = rt->rateCodeToIndex[i];
443 @@ -10531,7 +10538,7 @@ ath_setcurmode(struct ath_softc *sc, enu
446 sc->sc_hwmap[i].ieeerate =
447 - rt->info[ix].dot11Rate & IEEE80211_RATE_VAL;
448 + rate_hal2ieee(rt->info[ix].dot11Rate, f) & IEEE80211_RATE_VAL;
449 if (rt->info[ix].shortPreamble ||
450 rt->info[ix].phy == IEEE80211_T_OFDM)
451 sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
452 @@ -10932,9 +10939,115 @@ enum {
455 ATH_NOISE_IMMUNITY = 28,
456 - ATH_OFDM_WEAK_DET = 29
457 + ATH_OFDM_WEAK_DET = 29,
463 + * perform the channel related sysctl, reload the channel list
464 + * and try to stay on the current frequency
466 +static int ath_sysctl_setchanparam(struct ath_softc *sc, unsigned long ctl, u_int val)
468 + struct ieee80211com *ic = &sc->sc_ic;
469 + struct ath_hal *ah = sc->sc_ah;
470 + struct ieee80211_channel *c = NULL;
471 + struct ieee80211vap *vap;
472 + u_int16_t freq = 0;
477 + if (ic->ic_curchan != IEEE80211_CHAN_ANYC)
478 + freq = ic->ic_curchan->ic_freq;
481 + case ATH_REGDOMAIN:
483 + ptr += sizeof(struct ath_hal);
488 + case ATH_COUNTRYCODE:
489 + ic->ic_country_code = val;
492 + ic->ic_country_outdoor = val;
501 + if (ath_hal_setcapability(ah, HAL_CAP_CHANBW, 1, val, NULL) == AH_TRUE) {
502 + sc->sc_chanbw = val;
511 + if (ic->ic_curchan != IEEE80211_CHAN_ANYC)
512 + freq = ic->ic_curchan->ic_freq;
514 + /* clear out any old state */
515 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
516 + vap->iv_des_mode = IEEE80211_MODE_AUTO;
517 + vap->iv_des_chan = IEEE80211_CHAN_ANYC;
519 + ieee80211_scan_flush(ic);
521 + IEEE80211_LOCK_IRQ(ic);
522 + ath_getchannels(sc->sc_dev);
523 + ieee80211_update_channels(ic, 0);
525 + c = ieee80211_find_channel(ic, freq, IEEE80211_MODE_AUTO);
527 + c = &ic->ic_channels[0];
528 + ic->ic_curchan = c;
529 + ic->ic_bsschan = c;
530 + ic->ic_curmode = IEEE80211_MODE_AUTO;
531 + IEEE80211_UNLOCK_IRQ(ic);
533 + if (!(sc->sc_dev->flags & IFF_RUNNING)) {
534 + ic->ic_bsschan = IEEE80211_CHAN_ANYC;
539 +#define ifr_media ifr_ifru.ifru_ivalue
541 + memset(&ifr, 0, sizeof(ifr));
542 + ifr.ifr_media = ic->ic_media.ifm_cur->ifm_media & ~IFM_MMASK;
543 + ifr.ifr_media |= IFM_MAKEMODE(IEEE80211_MODE_AUTO);
544 + ifmedia_ioctl(ic->ic_dev, &ifr, &ic->ic_media, SIOCSIFMEDIA);
546 + /* apply the channel to the hw */
547 + ath_set_channel(ic);
549 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
550 + struct net_device *dev = vap->iv_dev;
552 + /* reactivate all active vaps */
553 + vap->iv_state = IEEE80211_S_SCAN;
554 + if ((vap->iv_opmode == IEEE80211_M_HOSTAP) ||
555 + (vap->iv_opmode == IEEE80211_M_MONITOR) ||
556 + (vap->iv_opmode == IEEE80211_M_WDS))
557 + ieee80211_new_state(vap, IEEE80211_S_RUN, 0);
559 + ieee80211_new_state(vap, IEEE80211_S_INIT, -1);
567 ath_sysctl_set_intmit(struct ath_softc *sc, long ctl, u_int val)
569 @@ -11013,6 +11126,7 @@ static int
570 ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
572 struct ath_softc *sc = ctl->extra1;
573 + struct ieee80211com *ic = &sc->sc_ic;
574 struct ath_hal *ah = sc->sc_ah;
577 @@ -11036,25 +11150,31 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
580 switch ((long)ctl->extra2) {
581 + case ATH_REGDOMAIN:
582 + case ATH_COUNTRYCODE:
584 + ret = ath_sysctl_setchanparam(sc, (long) ctl->extra2, val);
588 - if (!ath_hal_setslottime(ah, val))
591 - sc->sc_slottimeconf = val;
593 - /* disable manual override */
595 + sc->sc_slottimeconf = val;
597 sc->sc_slottimeconf = 0;
598 - ath_setslottime(sc);
603 - if (!ath_hal_setacktimeout(ah, val))
606 + sc->sc_acktimeconf = val;
608 + sc->sc_acktimeconf = 0;
612 - if (!ath_hal_setctstimeout(ah, val))
615 + sc->sc_ctstimeconf = val;
617 + sc->sc_ctstimeconf = 0;
621 if (val != sc->sc_softled) {
622 @@ -11206,7 +11326,12 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
628 switch ((long)ctl->extra2) {
630 + val = sc->sc_chanbw ?: 20;
633 val = ath_hal_getslottime(ah);
635 @@ -11225,11 +11350,18 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
636 case ATH_COUNTRYCODE:
637 ath_hal_getcountrycode(ah, &val);
640 + val = ic->ic_country_outdoor;
646 - ath_hal_getregdomain(ah, &val);
648 + ptr += sizeof(struct ath_hal);
654 val = sc->sc_debug | ath_debug_global;
655 @@ -11338,11 +11470,17 @@ static const ctl_table ath_sysctl_templa
657 { .ctl_name = CTL_AUTO,
658 .procname = "countrycode",
661 .proc_handler = ath_sysctl_halparam,
662 .extra2 = (void *)ATH_COUNTRYCODE,
664 { .ctl_name = CTL_AUTO,
665 + .procname = "outdoor",
667 + .proc_handler = ath_sysctl_halparam,
668 + .extra2 = (void *)ATH_OUTDOOR,
670 + { .ctl_name = CTL_AUTO,
671 .procname = "maxvaps",
673 .proc_handler = ath_sysctl_halparam,
674 @@ -11350,7 +11488,7 @@ static const ctl_table ath_sysctl_templa
676 { .ctl_name = CTL_AUTO,
677 .procname = "regdomain",
680 .proc_handler = ath_sysctl_halparam,
681 .extra2 = (void *)ATH_REGDOMAIN,
683 @@ -11413,6 +11551,12 @@ static const ctl_table ath_sysctl_templa
684 .extra2 = (void *)ATH_ACKRATE,
686 { .ctl_name = CTL_AUTO,
687 + .procname = "channelbw",
689 + .proc_handler = ath_sysctl_halparam,
690 + .extra2 = (void *)ATH_CHANBW,
692 + { .ctl_name = CTL_AUTO,
695 .proc_handler = ath_sysctl_halparam,
696 @@ -11653,13 +11797,6 @@ static ctl_table ath_static_sysctls[] =
699 { .ctl_name = CTL_AUTO,
700 - .procname = "countrycode",
702 - .data = &ath_countrycode,
703 - .maxlen = sizeof(ath_countrycode),
704 - .proc_handler = proc_dointvec
706 - { .ctl_name = CTL_AUTO,
707 .procname = "maxvaps",
709 .data = &ath_maxvaps,
710 @@ -11667,13 +11804,6 @@ static ctl_table ath_static_sysctls[] =
711 .proc_handler = proc_dointvec
713 { .ctl_name = CTL_AUTO,
714 - .procname = "outdoor",
716 - .data = &ath_outdoor,
717 - .maxlen = sizeof(ath_outdoor),
718 - .proc_handler = proc_dointvec
720 - { .ctl_name = CTL_AUTO,
721 .procname = "xchanmode",
723 .data = &ath_xchanmode,
724 --- a/ath/if_athvar.h
725 +++ b/ath/if_athvar.h
726 @@ -689,16 +689,17 @@ struct ath_softc {
727 int8_t sc_ofdm_weak_det; /* OFDM weak frames detection, -1 == auto */
730 - const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
731 +#define ATH_MODE_HALF (IEEE80211_MODE_MAX)
732 +#define ATH_MODE_QUARTER (IEEE80211_MODE_MAX + 1)
733 + const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX + 2];
734 const HAL_RATE_TABLE *sc_currates; /* current rate table */
735 const HAL_RATE_TABLE *sc_xr_rates; /* XR rate table */
736 - const HAL_RATE_TABLE *sc_half_rates; /* half rate table */
737 - const HAL_RATE_TABLE *sc_quarter_rates; /* quarter rate table */
738 HAL_OPMODE sc_opmode; /* current hal operating mode */
739 enum ieee80211_phymode sc_curmode; /* current phy mode */
740 u_int16_t sc_curtxpow; /* current tx power limit */
741 u_int16_t sc_curaid; /* current association id */
742 HAL_CHANNEL sc_curchan; /* current h/w channel */
743 + u_int8_t sc_chanbw; /* channel bandwidth */
744 u_int8_t sc_curbssid[IEEE80211_ADDR_LEN];
745 u_int8_t sc_rixmap[256]; /* IEEE to h/w rate table ix */
747 @@ -809,6 +810,8 @@ struct ath_softc {
748 u_int32_t sc_dturbo_bw_turbo; /* bandwidth threshold */
750 u_int sc_slottimeconf; /* manual override for slottime */
751 + u_int sc_acktimeconf; /* manual override for acktime */
752 + u_int sc_ctstimeconf; /* manual override for ctstime */
754 struct timer_list sc_dfs_excl_timer; /* mark expiration timer task */
755 struct timer_list sc_dfs_cac_timer; /* dfs wait timer */
756 @@ -827,6 +830,7 @@ struct ath_softc {
759 HAL_BOOL (*sc_rp_analyse)(struct ath_softc *sc);
760 + struct ATH_TQ_STRUCT sc_refresh_tq;
761 struct ATH_TQ_STRUCT sc_rp_tq;
763 int sc_rp_ignored; /* if set, we ignored all
764 @@ -942,6 +946,48 @@ int ar_device(int devid);
765 DEV_NAME(_v->iv_ic->ic_dev))
767 void ath_radar_detected(struct ath_softc *sc, const char* message);
768 +static inline u_int getTimingOffset(struct ath_softc *sc)
770 + struct ieee80211com *ic = &sc->sc_ic;
772 + if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
774 + if (ic->ic_flags & IEEE80211_F_SHSLOT)
776 + } else if (IEEE80211_IS_CHAN_A(ic->ic_curchan))
779 + if (IEEE80211_IS_CHAN_TURBO(ic->ic_curchan))
782 + if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
784 + else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
789 +static inline void ath_get_timings(struct ath_softc *sc, u_int *t_slot, u_int *t_sifs, u_int *t_difs)
791 + struct ieee80211_channel *c = sc->sc_ic.ic_curchan;
793 + *t_slot = getTimingOffset(sc) + sc->sc_slottimeconf;
795 + if (IEEE80211_IS_CHAN_HALF(c)) {
798 + } else if (IEEE80211_IS_CHAN_QUARTER(c)) {
801 + } else if (IEEE80211_IS_CHAN_TURBO(c)) {
811 struct ath_hw_detect {
812 const char *vendor_name;
813 --- a/tools/athctrl.c
814 +++ b/tools/athctrl.c
815 @@ -118,7 +118,7 @@ CMD(athctrl)(int argc, char *argv[])
819 - int slottime = 9 + (distance / 300) + ((distance % 300) ? 1 : 0);
820 + int slottime = (distance / 300) + ((distance % 300) ? 1 : 0);
821 int acktimeout = slottime * 2 + 3;
822 int ctstimeout = slottime * 2 + 3;
824 --- a/net80211/ieee80211.c
825 +++ b/net80211/ieee80211.c
826 @@ -243,34 +243,17 @@ static const struct country_code_to_str
827 {CTRY_ZIMBABWE, "ZW"}
831 -ieee80211_ifattach(struct ieee80211com *ic)
832 +void ieee80211_update_channels(struct ieee80211com *ic, int init)
834 - struct net_device *dev = ic->ic_dev;
835 struct ieee80211_channel *c;
836 + struct ieee80211vap *vap;
837 struct ifmediareq imr;
841 - _MOD_INC_USE(THIS_MODULE, return -ENODEV);
844 - * Pick an initial operating mode until we have a vap
845 - * created to lock it down correctly. This is only
846 - * drivers have something defined for configuring the
847 - * hardware at startup.
849 - ic->ic_opmode = IEEE80211_M_STA; /* everyone supports this */
852 - * Fill in 802.11 available channel set, mark
853 - * all available channels as active, and pick
854 - * a default channel if not already specified.
856 - KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX,
857 - ("invalid number of channels specified: %u", ic->ic_nchans));
858 memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));
859 - ic->ic_modecaps |= 1 << IEEE80211_MODE_AUTO;
860 ic->ic_max_txpower = IEEE80211_TXPOWER_MIN;
861 + ic->ic_modecaps = 1 << IEEE80211_MODE_AUTO;
863 for (i = 0; i < ic->ic_nchans; i++) {
864 c = &ic->ic_channels[i];
865 @@ -298,6 +281,8 @@ ieee80211_ifattach(struct ieee80211com *
866 ic->ic_modecaps |= 1 << IEEE80211_MODE_TURBO_A;
867 if (IEEE80211_IS_CHAN_108G(c))
868 ic->ic_modecaps |= 1 << IEEE80211_MODE_TURBO_G;
869 + if (IEEE80211_IS_CHAN_HALF(c) || IEEE80211_IS_CHAN_QUARTER(c))
872 /* Initialize candidate channels to all available */
873 memcpy(ic->ic_chan_active, ic->ic_chan_avail,
874 @@ -311,11 +296,58 @@ ieee80211_ifattach(struct ieee80211com *
875 * When 11g is supported, force the rate set to
876 * include basic rates suitable for a mixed b/g bss.
878 - if (ic->ic_modecaps & (1 << IEEE80211_MODE_11G))
879 + if ((ic->ic_modecaps & (1 << IEEE80211_MODE_11G)) && !ext)
880 ieee80211_set11gbasicrates(
881 &ic->ic_sup_rates[IEEE80211_MODE_11G],
887 + ieee80211_media_setup(ic, &ic->ic_media, ic->ic_caps, NULL, NULL);
888 + ieee80211com_media_status(ic->ic_dev, &imr);
889 + ifmedia_set(&ic->ic_media, imr.ifm_active);
891 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
892 + struct ieee80211vap *avp;
893 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
894 + (void) ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps, NULL, NULL);
895 + ieee80211_media_status(vap->iv_dev, &imr);
896 + ifmedia_set(&vap->iv_media, imr.ifm_active);
898 + (void) ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps, NULL, NULL);
899 + ieee80211_media_status(vap->iv_dev, &imr);
900 + ifmedia_set(&vap->iv_media, imr.ifm_active);
903 +EXPORT_SYMBOL(ieee80211_update_channels);
906 +ieee80211_ifattach(struct ieee80211com *ic)
908 + struct net_device *dev = ic->ic_dev;
909 + struct ieee80211_channel *c;
910 + struct ifmediareq imr;
912 + _MOD_INC_USE(THIS_MODULE, return -ENODEV);
915 + * Pick an initial operating mode until we have a vap
916 + * created to lock it down correctly. This is only
917 + * drivers have something defined for configuring the
918 + * hardware at startup.
920 + ic->ic_opmode = IEEE80211_M_STA; /* everyone supports this */
923 + * Fill in 802.11 available channel set, mark
924 + * all available channels as active, and pick
925 + * a default channel if not already specified.
927 + KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX,
928 + ("invalid number of channels specified: %u", ic->ic_nchans));
929 + ieee80211_update_channels(ic, 1);
931 /* Setup initial channel settings */
932 ic->ic_bsschan = IEEE80211_CHAN_ANYC;
933 /* Arbitrarily pick the first channel */
934 @@ -327,6 +359,7 @@ ieee80211_ifattach(struct ieee80211com *
935 /* Enable WME by default, if we're capable. */
936 if (ic->ic_caps & IEEE80211_C_WME)
937 ic->ic_flags |= IEEE80211_F_WME;
939 (void) ieee80211_setmode(ic, ic->ic_curmode);
941 /* Store default beacon interval, as nec. */
942 @@ -763,7 +796,8 @@ ieee80211_media_setup(struct ieee80211co
943 struct ieee80211_rateset allrates;
945 /* Fill in media characteristics. */
946 - ifmedia_init(media, 0, media_change, media_stat);
947 + if (media_change || media_stat)
948 + ifmedia_init(media, 0, media_change, media_stat);
950 memset(&allrates, 0, sizeof(allrates));
952 @@ -793,7 +827,7 @@ ieee80211_media_setup(struct ieee80211co
953 ADD(media, IFM_AUTO, mopt | IFM_IEEE80211_WDS);
954 if (mode == IEEE80211_MODE_AUTO)
956 - rs = &ic->ic_sup_rates[mode];
957 + rs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)];
959 for (i = 0; i < rs->rs_nrates; i++) {
960 rate = rs->rs_rates[i];
961 @@ -1207,7 +1241,7 @@ ieee80211_announce(struct ieee80211com *
962 if ((ic->ic_modecaps & (1 << mode)) == 0)
964 if_printf(dev, "%s rates: ", ieee80211_phymode_name[mode]);
965 - rs = &ic->ic_sup_rates[mode];
966 + rs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)];
967 for (i = 0; i < rs->rs_nrates; i++) {
968 rate = rs->rs_rates[i];
969 mword = ieee80211_rate2media(ic, rate, mode);
970 @@ -1417,7 +1451,7 @@ ieee80211com_media_change(struct net_dev
971 * now so drivers have a consistent state.
973 KASSERT(vap->iv_bss != NULL, ("no bss node"));
974 - vap->iv_bss->ni_rates = ic->ic_sup_rates[newphymode];
975 + vap->iv_bss->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, newphymode)];
979 @@ -1435,7 +1469,7 @@ findrate(struct ieee80211com *ic, enum i
981 #define IEEERATE(_ic,_m,_i) \
982 ((_ic)->ic_sup_rates[_m].rs_rates[_i] & IEEE80211_RATE_VAL)
983 - int i, nrates = ic->ic_sup_rates[mode].rs_nrates;
984 + int i, nrates = ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)].rs_nrates;
985 for (i = 0; i < nrates; i++)
986 if (IEEERATE(ic, mode, i) == rate)
988 @@ -1881,11 +1915,6 @@ ieee80211_build_countryie(struct ieee802
989 if (ieee80211_chan2mode(c) != curmode_noturbo)
992 - /* Skip half/quarter rate channels */
993 - if (IEEE80211_IS_CHAN_HALF(c) ||
994 - IEEE80211_IS_CHAN_QUARTER(c))
997 if (*cur_runlen == 0) {
999 *cur_pow = c->ic_maxregpower;
1000 @@ -1919,7 +1948,7 @@ void
1001 ieee80211_build_sc_ie(struct ieee80211com *ic)
1003 struct ieee80211_ie_sc *ie = &ic->ic_sc_ie;
1006 struct ieee80211_channel *c;
1009 --- a/net80211/ieee80211_var.h
1010 +++ b/net80211/ieee80211_var.h
1011 @@ -336,8 +336,6 @@ struct ieee80211com {
1012 u_int8_t ic_nopened; /* VAPs been opened */
1013 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
1014 struct ieee80211_rateset ic_sup_xr_rates;
1015 - struct ieee80211_rateset ic_sup_half_rates;
1016 - struct ieee80211_rateset ic_sup_quarter_rates;
1017 u_int16_t ic_modecaps; /* set of mode capabilities */
1018 u_int16_t ic_curmode; /* current mode */
1019 u_int16_t ic_lintval; /* beacon interval */
1020 @@ -715,6 +713,7 @@ MALLOC_DECLARE(M_80211_VAP);
1022 int ieee80211_ifattach(struct ieee80211com *);
1023 void ieee80211_ifdetach(struct ieee80211com *);
1024 +void ieee80211_update_channels(struct ieee80211com *ic, int);
1025 int ieee80211_vap_setup(struct ieee80211com *, struct net_device *,
1026 const char *, int, int, struct ieee80211vap *);
1027 int ieee80211_vap_attach(struct ieee80211vap *, ifm_change_cb_t, ifm_stat_cb_t);
1028 @@ -794,6 +793,23 @@ ieee80211_anyhdrspace(struct ieee80211co
1032 +static __inline int
1033 +ieee80211_chan2ratemode(struct ieee80211_channel *c, int mode)
1036 + mode = ieee80211_chan2mode(c);
1039 + * Use 11a rateset for half/quarter to restrict things
1042 + if (IEEE80211_IS_CHAN_HALF(c) ||
1043 + IEEE80211_IS_CHAN_QUARTER(c))
1044 + return IEEE80211_MODE_11A;
1049 /* Macros to print MAC address used in 802.11 headers */
1051 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
1052 --- a/net80211/ieee80211_node.c
1053 +++ b/net80211/ieee80211_node.c
1054 @@ -287,7 +287,7 @@ ieee80211_node_set_chan(struct ieee80211
1055 ni->ni_rates = ic->ic_sup_xr_rates;
1058 - ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2mode(chan)];
1059 + ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(chan, -1)];
1062 static __inline void
1063 @@ -387,6 +387,8 @@ ieee80211_create_ibss(struct ieee80211va
1064 ic->ic_bsschan = chan;
1065 ieee80211_node_set_chan(ic, ni);
1066 ic->ic_curmode = ieee80211_chan2mode(chan);
1067 + ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(chan, -1)];
1069 spin_lock_irqsave(&channel_lock, flags);
1070 ieee80211_scan_set_bss_channel(ic, ic->ic_bsschan);
1071 spin_unlock_irqrestore(&channel_lock, flags);
1072 @@ -394,14 +396,8 @@ ieee80211_create_ibss(struct ieee80211va
1073 /* Update country ie information */
1074 ieee80211_build_countryie(ic);
1076 - if (IEEE80211_IS_CHAN_HALF(chan)) {
1077 - ni->ni_rates = ic->ic_sup_half_rates;
1078 - } else if (IEEE80211_IS_CHAN_QUARTER(chan)) {
1079 - ni->ni_rates = ic->ic_sup_quarter_rates;
1082 - if ((vap->iv_flags & IEEE80211_F_PUREG) &&
1083 - IEEE80211_IS_CHAN_ANYG(chan)) {
1084 + if ((ieee80211_chan2ratemode(chan, -1) != IEEE80211_MODE_11A) &&
1085 + IEEE80211_IS_CHAN_ANYG(chan) && (vap->iv_flags & IEEE80211_F_PUREG)) {
1086 ieee80211_setpuregbasicrates(&ni->ni_rates);
1089 --- a/net80211/ieee80211_scan_sta.c
1090 +++ b/net80211/ieee80211_scan_sta.c
1091 @@ -490,12 +490,7 @@ check_rate(struct ieee80211vap *vap, con
1093 okrate = badrate = fixedrate = 0;
1095 - if (IEEE80211_IS_CHAN_HALF(se->se_chan))
1096 - srs = &ic->ic_sup_half_rates;
1097 - else if (IEEE80211_IS_CHAN_QUARTER(se->se_chan))
1098 - srs = &ic->ic_sup_quarter_rates;
1100 - srs = &ic->ic_sup_rates[ieee80211_chan2mode(se->se_chan)];
1101 + srs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, -1)];
1102 nrs = se->se_rates[1];
1103 rs = se->se_rates + 2;
1104 fixedrate = IEEE80211_FIXED_RATE_NONE;
1105 --- a/net80211/ieee80211_output.c
1106 +++ b/net80211/ieee80211_output.c
1107 @@ -1676,8 +1676,8 @@ ieee80211_send_probereq(struct ieee80211
1109 frm = ieee80211_add_ssid(frm, ssid, ssidlen);
1110 mode = ieee80211_chan2mode(ic->ic_curchan);
1111 - frm = ieee80211_add_rates(frm, &ic->ic_sup_rates[mode]);
1112 - frm = ieee80211_add_xrates(frm, &ic->ic_sup_rates[mode]);
1113 + frm = ieee80211_add_rates(frm, &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)]);
1114 + frm = ieee80211_add_xrates(frm, &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)]);
1116 if (optie != NULL) {
1117 memcpy(frm, optie, optielen);
1118 --- a/net80211/ieee80211_proto.c
1119 +++ b/net80211/ieee80211_proto.c
1120 @@ -404,7 +404,7 @@ ieee80211_fix_rate(struct ieee80211_node
1123 okrate = badrate = fixedrate = 0;
1124 - srs = &ic->ic_sup_rates[ieee80211_chan2mode(ni->ni_chan)];
1125 + srs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, -1)];
1126 nrs = &ni->ni_rates;
1127 fixedrate = IEEE80211_FIXED_RATE_NONE;
1128 for (i = 0; i < nrs->rs_nrates;) {
1129 @@ -1401,6 +1401,7 @@ ieee80211_new_state(struct ieee80211vap
1130 IEEE80211_VAPS_UNLOCK_IRQ(ic);
1133 +EXPORT_SYMBOL(ieee80211_new_state);
1136 __ieee80211_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
1137 --- a/ath_rate/minstrel/minstrel.c
1138 +++ b/ath_rate/minstrel/minstrel.c
1139 @@ -195,31 +195,7 @@ calc_usecs_unicast_packet(struct ath_sof
1143 - /* XXX: Getting MAC/PHY level timings should be fixed for turbo
1144 - * rates, and there is probably a way to get this from the
1146 - switch (rt->info[rix].phy) {
1147 - case IEEE80211_T_OFDM:
1152 - /* fall through */
1154 - case IEEE80211_T_TURBO:
1159 - case IEEE80211_T_DS:
1160 - /* Fall through to default */
1162 - /* pg. 205 ieee.802.11.pdf */
1168 + ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
1169 if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
1170 (rt->info[rix].phy == IEEE80211_T_OFDM)) {
1171 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
1172 --- a/ath_rate/sample/sample.c
1173 +++ b/ath_rate/sample/sample.c
1174 @@ -172,26 +172,7 @@ calc_usecs_unicast_packet(struct ath_sof
1175 * rates, and there is probably a way to get this from the
1178 - switch (rt->info[rix].phy) {
1179 - case IEEE80211_T_OFDM:
1183 - /* fall through */
1184 - case IEEE80211_T_TURBO:
1189 - case IEEE80211_T_DS:
1190 - /* fall through to default */
1192 - /* pg 205 ieee.802.11.pdf */
1198 + ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
1201 if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
1202 --- a/net80211/ieee80211_wireless.c
1203 +++ b/net80211/ieee80211_wireless.c
1204 @@ -2133,7 +2133,7 @@ ieee80211_ioctl_setmode(struct net_devic
1206 vap->iv_des_mode = mode;
1207 if (IS_UP_AUTO(vap))
1208 - ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1209 + ieee80211_init(vap->iv_dev, 0);
1213 @@ -4081,46 +4081,60 @@ ieee80211_ioctl_getchanlist(struct net_d
1217 +static int alreadyListed(struct ieee80211req_chaninfo *chans, u_int16_t mhz)
1220 + for (i = 0; i < chans->ic_nchans; i++) {
1221 + if (chans->ic_chans[i].ic_freq == mhz)
1228 ieee80211_ioctl_getchaninfo(struct net_device *dev,
1229 - struct iw_request_info *info, void *w, char *extra)
1230 + struct iw_request_info *info, void *w, char *extra)
1232 struct ieee80211vap *vap = dev->priv;
1233 struct ieee80211com *ic = vap->iv_ic;
1234 - struct ieee80211req_chaninfo chans;
1235 + struct ieee80211req_chaninfo *chans =
1236 + (struct ieee80211req_chaninfo *)extra;
1238 u_int8_t reported[IEEE80211_CHAN_BYTES]; /* XXX stack usage? */
1241 - memset(&chans, 0, sizeof(chans));
1242 - memset(&reported, 0, sizeof(reported));
1243 + memset(chans, 0, sizeof(*chans));
1244 + memset(reported, 0, sizeof(reported));
1245 for (i = 0; i < ic->ic_nchans; i++) {
1246 const struct ieee80211_channel *c = &ic->ic_channels[i];
1247 const struct ieee80211_channel *c1 = c;
1249 - if (isclr(reported, c->ic_ieee)) {
1250 + if (!alreadyListed(chans, c->ic_freq)) {
1251 setbit(reported, c->ic_ieee);
1253 - /* pick turbo channel over non-turbo channel, and
1254 - * 11g channel over 11b channel */
1255 if (IEEE80211_IS_CHAN_A(c))
1256 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_A);
1257 + c1 = findchannel(ic, c->ic_freq,
1258 + IEEE80211_MODE_TURBO_A);
1259 if (IEEE80211_IS_CHAN_ANYG(c))
1260 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_G);
1261 + c1 = findchannel(ic, c->ic_freq,
1262 + IEEE80211_MODE_TURBO_G);
1263 else if (IEEE80211_IS_CHAN_B(c)) {
1264 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_G);
1265 + c1 = findchannel(ic, c->ic_freq,
1266 + IEEE80211_MODE_TURBO_G);
1268 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_11G);
1269 + c1 = findchannel(ic, c->ic_freq,
1270 + IEEE80211_MODE_11G);
1275 - /* Copy the entire structure, whereas it used to just copy a few fields */
1276 - memcpy(&chans.ic_chans[chans.ic_nchans], c, sizeof(struct ieee80211_channel));
1277 - if (++chans.ic_nchans >= IEEE80211_CHAN_MAX)
1278 + chans->ic_chans[chans->ic_nchans].ic_ieee = c->ic_ieee;
1279 + chans->ic_chans[chans->ic_nchans].ic_freq = c->ic_freq;
1280 + chans->ic_chans[chans->ic_nchans].ic_flags = c->ic_flags;
1281 + if (++chans->ic_nchans >= IEEE80211_CHAN_MAX)
1285 - memcpy(extra, &chans, sizeof(struct ieee80211req_chaninfo));
1289 --- a/net80211/ieee80211_scan_ap.c
1290 +++ b/net80211/ieee80211_scan_ap.c
1291 @@ -518,12 +518,13 @@ pick_channel(struct ieee80211_scan_state
1292 int ss_last = ss->ss_last;
1293 struct ieee80211_channel *best;
1294 struct ap_state *as = ss->ss_priv;
1295 - struct channel chans[ss_last]; /* actually ss_last-1 is required */
1296 + struct channel *chans; /* actually ss_last-1 is required */
1297 struct channel *c = NULL;
1298 struct pc_params params = { vap, ss, flags };
1302 + chans = (struct channel *)kmalloc(ss_last*sizeof(struct channel),GFP_ATOMIC);
1303 for (i = 0; i < ss_last; i++) {
1304 chans[i].chan = ss->ss_chans[i];
1306 @@ -612,6 +613,7 @@ pick_channel(struct ieee80211_scan_state
1307 "%s: best: channel %u rssi %d\n",
1308 __func__, i, as->as_maxrssi[i]);
1314 @@ -647,6 +649,7 @@ ap_end(struct ieee80211_scan_state *ss,
1315 res = 1; /* Do NOT restart scan */
1317 struct ieee80211_scan_entry se;
1319 /* XXX: notify all VAPs? */
1320 /* if this is a dynamic turbo frequency , start with normal
1322 @@ -661,6 +664,11 @@ ap_end(struct ieee80211_scan_state *ss,
1326 + for (i = (bestchan - &ic->ic_channels[0])/sizeof(*bestchan) + 1; i < ic->ic_nchans; i++) {
1327 + if ((ic->ic_channels[i].ic_freq == bestchan->ic_freq) &&
1328 + IEEE80211_IS_CHAN_ANYG(&ic->ic_channels[i]))
1329 + bestchan = &ic->ic_channels[i];
1331 memset(&se, 0, sizeof(se));
1332 se.se_chan = bestchan;
1334 --- a/tools/wlanconfig.c
1335 +++ b/tools/wlanconfig.c
1336 @@ -737,7 +737,7 @@ list_channels(const char *ifname, int al
1337 if (get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans)) < 0)
1338 errx(1, "unable to get channel information");
1340 - uint8_t active[32];
1341 + uint8_t active[IEEE80211_CHAN_BYTES];
1343 if (get80211priv(ifname, IEEE80211_IOCTL_GETCHANLIST, &active, sizeof(active)) < 0)
1344 errx(1, "unable to get active channel list");
1345 --- a/net80211/ieee80211_scan.c
1346 +++ b/net80211/ieee80211_scan.c
1347 @@ -1044,6 +1044,7 @@ ieee80211_scan_assoc_fail(struct ieee802
1348 ss->ss_ops->scan_assoc_fail(ss, mac, reason);
1351 +EXPORT_SYMBOL(ieee80211_scan_flush);
1354 * Iterate over the contents of the scan cache.