firewall: fix zone defaults
[openwrt.git] / package / madwifi / patches / 421-channel_handling.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
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 *);
19
20 @@ -265,7 +264,6 @@ static int ath_change_mtu(struct net_dev
21 static int ath_ioctl(struct net_device *, struct ifreq *, int);
22
23 static int ath_rate_setup(struct net_device *, u_int);
24 -static void ath_setup_subrates(struct net_device *);
25 #ifdef ATH_SUPERG_XR
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
29
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;
40 static int tpc = 1;
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
48
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");
56 #ifdef ATH_CAP_TPC
57 @@ -451,9 +443,7 @@ MODULE_PARM(ratectl, "s");
58 #else
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);
66 #ifdef ATH_CAP_TPC
67 @@ -463,9 +453,7 @@ module_param(bstuck_thresh, int, 0600);
68 module_param(autocreate, charp, 0600);
69 module_param(ratectl, charp, 0600);
70 #endif
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");
76 #ifdef ATH_CAP_TPC
77 @@ -531,6 +519,50 @@ MODULE_PARM_DESC(ieee80211_debug, "Load-
78 (bssid)[0] |= (((id) << 2) | 0x02); \
79 } while (0)
80
81 +static inline int ath_chan2mode(struct ieee80211_channel *c)
82 +{
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;
87 + else
88 + return ieee80211_chan2mode(c);
89 +}
90 +
91 +static inline int rate_hal2ieee(int dot11Rate, int f)
92 +{
93 + int flag = dot11Rate & ~(IEEE80211_RATE_VAL);
94 + dot11Rate &= IEEE80211_RATE_VAL;
95 +
96 + if (f == 4) { /* Quarter */
97 + if (dot11Rate == 4)
98 + return 18 | flag;
99 + }
100 + return (dot11Rate * f) | flag;
101 +}
102 +
103 +static inline int rate_factor(int mode)
104 +{
105 + int f;
106 +
107 + /*
108 + * NB: Fix up rates. HAL returns half or quarter dot11Rates,
109 + * while the stack deals with full rates only
110 + */
111 + switch(mode) {
112 + case ATH_MODE_HALF:
113 + f = 2;
114 + break;
115 + case ATH_MODE_QUARTER:
116 + f = 4;
117 + break;
118 + default:
119 + f = 1;
120 + break;
121 + }
122 + return f;
123 +}
124 +
125 /* Initialize ath_softc structure */
126
127 int
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);
131
132 - /*
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.
137 - */
138 - if (countrycode != -1)
139 - ath_countrycode = countrycode;
140 if (maxvaps != -1) {
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;
146 }
147 - if (outdoor != -1)
148 - ath_outdoor = outdoor;
149 if (xchanmode != -1)
150 ath_xchanmode = xchanmode;
151 - error = ath_getchannels(dev, ath_countrycode,
152 - ath_outdoor, ath_xchanmode);
153 + error = ath_getchannels(dev);
154 if (error != 0)
155 goto bad;
156
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;
161
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);
168 -
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);
173
174 /* NB: setup here so ath_rate_update is happy */
175 ath_setcurmode(sc, IEEE80211_MODE_11A);
176 @@ -908,10 +928,6 @@ ath_attach(u_int16_t devid, struct net_d
177 IEEE80211_ATHC_COMP : 0);
178 #endif
179
180 -#ifdef ATH_SUPERG_DYNTURBO
181 - ic->ic_ath_cap |= (ath_hal_turboagsupported(ah, ath_countrycode) ?
182 - (IEEE80211_ATHC_TURBOP | IEEE80211_ATHC_AR) : 0);
183 -#endif
184 #ifdef ATH_SUPERG_XR
185 ic->ic_ath_cap |= (ath_hal_xrsupported(ah) ? IEEE80211_ATHC_XR : 0);
186 #endif
187 @@ -4470,17 +4486,17 @@ ath_mode_init(struct net_device *dev)
188 * Set the slot time based on the current setting.
189 */
190 static void
191 -ath_setslottime(struct ath_softc *sc)
192 +ath_settiming(struct ath_softc *sc)
193 {
194 - struct ieee80211com *ic = &sc->sc_ic;
195 struct ath_hal *ah = sc->sc_ah;
196 + u_int offset = getTimingOffset(sc);
197
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);
202 - else
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;
211 }
212
213 @@ -4502,7 +4518,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);
218 + ath_settiming(sc);
219 }
220
221 #ifdef ATH_SUPERG_DYNTURBO
222 @@ -5346,7 +5362,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 */
228
229 if (bfaddr != 0) {
230 /*
231 @@ -7802,12 +7818,14 @@ ath_get_ivlen(struct ieee80211_key *k)
232 * Get transmit rate index using rate in Kbps
233 */
234 static __inline int
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)
237 {
238 unsigned int i, ndx = 0;
239 + int f;
240
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) {
245 ndx = i;
246 break;
247 }
248 @@ -8100,7 +8118,7 @@ ath_tx_start(struct net_device *dev, str
249 atype = HAL_PKT_TYPE_NORMAL; /* default */
250
251 if (ismcast) {
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;
255 if (shortPreamble)
256 txrate |= rt->info[rix].shortPreamble;
257 @@ -9067,7 +9085,7 @@ ath_chan_change(struct ath_softc *sc, st
258 struct net_device *dev = sc->sc_dev;
259 enum ieee80211_phymode mode;
260
261 - mode = ieee80211_chan2mode(chan);
262 + mode = ath_chan2mode(chan);
263
264 ath_rate_setup(dev, mode);
265 ath_setcurmode(sc, mode);
266 @@ -10124,8 +10142,7 @@ ath_newassoc(struct ieee80211_node *ni,
267 }
268
269 static int
270 -ath_getchannels(struct net_device *dev, u_int cc,
271 - HAL_BOOL outdoor, HAL_BOOL xchanmode)
272 +ath_getchannels(struct net_device *dev)
273 {
274 struct ath_softc *sc = dev->priv;
275 struct ieee80211com *ic = &sc->sc_ic;
276 @@ -10139,17 +10156,31 @@ ath_getchannels(struct net_device *dev,
277 EPRINTF(sc, "Insufficient memory for channel table!\n");
278 return -ENOMEM;
279 }
280 +
281 +restart:
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)) {
286 u_int32_t rd;
287
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;
297 + goto restart;
298 + }
299 kfree(chans);
300 return -EINVAL;
301 }
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);
306 +#endif
307 /*
308 * Convert HAL channels to ieee80211 ones.
309 */
310 @@ -10395,7 +10426,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;
318 if (rt == NULL)
319 @@ -10408,57 +10439,16 @@ ath_xr_rate_setup(struct net_device *dev
320 } else
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)
328 + continue;
329 + rs->rs_rates[j++] = rt->info[i].dot11Rate;
330 + }
331 + rs->rs_nrates = j;
332 return 1;
333 }
334 #endif
335
336 -/* Setup half/quarter rate table support */
337 -static void
338 -ath_setup_subrates(struct net_device *dev)
339 -{
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;
346 -
347 - sc->sc_half_rates = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
348 - rt = sc->sc_half_rates;
349 - if (rt != NULL) {
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;
355 - } else
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;
361 - }
362 -
363 - sc->sc_quarter_rates = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
364 - rt = sc->sc_quarter_rates;
365 - if (rt != NULL) {
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;
371 - } else
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;
377 - }
378 -}
379 -
380 static int
381 ath_rate_setup(struct net_device *dev, u_int mode)
382 {
383 @@ -10467,7 +10457,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;
389
390 switch (mode) {
391 case IEEE80211_MODE_11A:
392 @@ -10485,6 +10475,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);
395 break;
396 + case ATH_MODE_HALF:
397 + sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
398 + break;
399 + case ATH_MODE_QUARTER:
400 + sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
401 + break;
402 default:
403 DPRINTF(sc, ATH_DEBUG_ANY, "Invalid mode %u\n", mode);
404 return 0;
405 @@ -10499,10 +10495,16 @@ ath_rate_setup(struct net_device *dev, u
406 maxrates = IEEE80211_RATE_MAXSIZE;
407 } else
408 maxrates = rt->rateCount;
409 +
410 + /* NB: quarter/half rate channels hijack the 11A rateset */
411 + if (mode >= IEEE80211_MODE_MAX)
412 + return 1;
413 +
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;
418 +
419 return 1;
420 }
421
422 @@ -10531,13 +10533,18 @@ ath_setcurmode(struct ath_softc *sc, enu
423 { 0, 500, 130 },
424 };
425 const HAL_RATE_TABLE *rt;
426 - unsigned int i, j;
427 + unsigned int i, j, f;
428
429 + /*
430 + * NB: Fix up rixmap. HAL returns half or quarter dot11Rates,
431 + * while the stack deals with full rates only
432 + */
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 @@ -10547,7 +10554,7 @@ ath_setcurmode(struct ath_softc *sc, enu
444 continue;
445 }
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 @@ -10948,9 +10955,106 @@ enum {
453 ATH_MAXVAPS = 26,
454 ATH_INTMIT = 27,
455 ATH_NOISE_IMMUNITY = 28,
456 - ATH_OFDM_WEAK_DET = 29
457 + ATH_OFDM_WEAK_DET = 29,
458 + ATH_CHANBW = 30,
459 + ATH_OUTDOOR = 31,
460 };
461
462 +/*
463 + * perform the channel related sysctl, reload the channel list
464 + * and try to stay on the current frequency
465 + */
466 +static int ath_sysctl_setchanparam(struct ath_softc *sc, unsigned long ctl, u_int val)
467 +{
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;
473 + struct ifreq ifr;
474 +
475 + if (ic->ic_curchan != IEEE80211_CHAN_ANYC)
476 + freq = ic->ic_curchan->ic_freq;
477 +
478 + switch(ctl) {
479 + case ATH_COUNTRYCODE:
480 + ic->ic_country_code = val;
481 + break;
482 + case ATH_OUTDOOR:
483 + ic->ic_country_outdoor = val;
484 + break;
485 + case ATH_CHANBW:
486 + switch(val) {
487 + case 0:
488 + case 5:
489 + case 10:
490 + case 20:
491 + case 40:
492 + if (ath_hal_setcapability(ah, HAL_CAP_CHANBW, 1, val, NULL) == AH_TRUE) {
493 + sc->sc_chanbw = val;
494 + break;
495 + }
496 + default:
497 + return -EINVAL;
498 + }
499 + break;
500 + }
501 +
502 + if (ic->ic_curchan != IEEE80211_CHAN_ANYC)
503 + freq = ic->ic_curchan->ic_freq;
504 +
505 + /* clear out any old state */
506 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
507 + vap->iv_des_mode = IEEE80211_MODE_AUTO;
508 + vap->iv_des_chan = IEEE80211_CHAN_ANYC;
509 + }
510 + ieee80211_scan_flush(ic);
511 +
512 + IEEE80211_LOCK_IRQ(ic);
513 + ath_getchannels(sc->sc_dev);
514 + ieee80211_update_channels(ic, 0);
515 + if (freq)
516 + c = ieee80211_find_channel(ic, freq, IEEE80211_MODE_AUTO);
517 + if (!c)
518 + c = &ic->ic_channels[0];
519 + ic->ic_curchan = c;
520 + ic->ic_bsschan = c;
521 + ic->ic_curmode = IEEE80211_MODE_AUTO;
522 + IEEE80211_UNLOCK_IRQ(ic);
523 +
524 + if (!(sc->sc_dev->flags & IFF_RUNNING)) {
525 + ic->ic_bsschan = IEEE80211_CHAN_ANYC;
526 + return 0;
527 + }
528 +
529 +#ifndef ifr_media
530 +#define ifr_media ifr_ifru.ifru_ivalue
531 +#endif
532 + memset(&ifr, 0, sizeof(ifr));
533 + ifr.ifr_media = ic->ic_media.ifm_cur->ifm_media & ~IFM_MMASK;
534 + ifr.ifr_media |= IFM_MAKEMODE(IEEE80211_MODE_AUTO);
535 + ifmedia_ioctl(ic->ic_dev, &ifr, &ic->ic_media, SIOCSIFMEDIA);
536 +
537 + /* apply the channel to the hw */
538 + ath_set_channel(ic);
539 +
540 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
541 + struct net_device *dev = vap->iv_dev;
542 +
543 + /* reactivate all active vaps */
544 + vap->iv_state = IEEE80211_S_SCAN;
545 + if ((vap->iv_opmode == IEEE80211_M_HOSTAP) ||
546 + (vap->iv_opmode == IEEE80211_M_MONITOR) ||
547 + (vap->iv_opmode == IEEE80211_M_WDS))
548 + ieee80211_new_state(vap, IEEE80211_S_RUN, 0);
549 + else
550 + ieee80211_new_state(vap, IEEE80211_S_INIT, -1);
551 + }
552 +
553 + return 0;
554 +}
555 +
556 +
557 static int
558 ath_sysctl_set_intmit(struct ath_softc *sc, long ctl, u_int val)
559 {
560 @@ -11029,6 +11133,7 @@ static int
561 ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
562 {
563 struct ath_softc *sc = ctl->extra1;
564 + struct ieee80211com *ic = &sc->sc_ic;
565 struct ath_hal *ah = sc->sc_ah;
566 u_int val;
567 u_int tab_3_val[3];
568 @@ -11052,25 +11157,34 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
569 lenp, ppos);
570 if (ret == 0) {
571 switch ((long)ctl->extra2) {
572 + case ATH_REGDOMAIN:
573 + ath_hal_setregdomain(ah, val);
574 + break;
575 + case ATH_OUTDOOR:
576 + case ATH_COUNTRYCODE:
577 + case ATH_CHANBW:
578 + ret = ath_sysctl_setchanparam(sc, (long) ctl->extra2, val);
579 + break;
580 case ATH_SLOTTIME:
581 - if (val > 0) {
582 - if (!ath_hal_setslottime(ah, val))
583 - ret = -EINVAL;
584 - else
585 - sc->sc_slottimeconf = val;
586 - } else {
587 - /* disable manual override */
588 + if (val > 0)
589 + sc->sc_slottimeconf = val;
590 + else
591 sc->sc_slottimeconf = 0;
592 - ath_setslottime(sc);
593 - }
594 + ath_settiming(sc);
595 break;
596 case ATH_ACKTIMEOUT:
597 - if (!ath_hal_setacktimeout(ah, val))
598 - ret = -EINVAL;
599 + if (val > 0)
600 + sc->sc_acktimeconf = val;
601 + else
602 + sc->sc_acktimeconf = 0;
603 + ath_settiming(sc);
604 break;
605 case ATH_CTSTIMEOUT:
606 - if (!ath_hal_setctstimeout(ah, val))
607 - ret = -EINVAL;
608 + if (val > 0)
609 + sc->sc_ctstimeconf = val;
610 + else
611 + sc->sc_ctstimeconf = 0;
612 + ath_settiming(sc);
613 break;
614 case ATH_SOFTLED:
615 if (val != sc->sc_softled) {
616 @@ -11223,6 +11337,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
617 }
618 } else {
619 switch ((long)ctl->extra2) {
620 + case ATH_CHANBW:
621 + val = sc->sc_chanbw ?: 20;
622 + break;
623 case ATH_SLOTTIME:
624 val = ath_hal_getslottime(ah);
625 break;
626 @@ -11241,6 +11358,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
627 case ATH_COUNTRYCODE:
628 ath_hal_getcountrycode(ah, &val);
629 break;
630 + case ATH_OUTDOOR:
631 + val = ic->ic_country_outdoor;
632 + break;
633 case ATH_MAXVAPS:
634 val = ath_maxvaps;
635 break;
636 @@ -11354,11 +11474,17 @@ static const ctl_table ath_sysctl_templa
637 },
638 { .ctl_name = CTL_AUTO,
639 .procname = "countrycode",
640 - .mode = 0444,
641 + .mode = 0644,
642 .proc_handler = ath_sysctl_halparam,
643 .extra2 = (void *)ATH_COUNTRYCODE,
644 },
645 { .ctl_name = CTL_AUTO,
646 + .procname = "outdoor",
647 + .mode = 0644,
648 + .proc_handler = ath_sysctl_halparam,
649 + .extra2 = (void *)ATH_OUTDOOR,
650 + },
651 + { .ctl_name = CTL_AUTO,
652 .procname = "maxvaps",
653 .mode = 0444,
654 .proc_handler = ath_sysctl_halparam,
655 @@ -11366,7 +11492,7 @@ static const ctl_table ath_sysctl_templa
656 },
657 { .ctl_name = CTL_AUTO,
658 .procname = "regdomain",
659 - .mode = 0444,
660 + .mode = 0644,
661 .proc_handler = ath_sysctl_halparam,
662 .extra2 = (void *)ATH_REGDOMAIN,
663 },
664 @@ -11429,6 +11555,12 @@ static const ctl_table ath_sysctl_templa
665 .extra2 = (void *)ATH_ACKRATE,
666 },
667 { .ctl_name = CTL_AUTO,
668 + .procname = "channelbw",
669 + .mode = 0644,
670 + .proc_handler = ath_sysctl_halparam,
671 + .extra2 = (void *)ATH_CHANBW,
672 + },
673 + { .ctl_name = CTL_AUTO,
674 .procname = "rp",
675 .mode = 0200,
676 .proc_handler = ath_sysctl_halparam,
677 @@ -11669,13 +11801,6 @@ static ctl_table ath_static_sysctls[] =
678 },
679 #endif
680 { .ctl_name = CTL_AUTO,
681 - .procname = "countrycode",
682 - .mode = 0444,
683 - .data = &ath_countrycode,
684 - .maxlen = sizeof(ath_countrycode),
685 - .proc_handler = proc_dointvec
686 - },
687 - { .ctl_name = CTL_AUTO,
688 .procname = "maxvaps",
689 .mode = 0444,
690 .data = &ath_maxvaps,
691 @@ -11683,13 +11808,6 @@ static ctl_table ath_static_sysctls[] =
692 .proc_handler = proc_dointvec
693 },
694 { .ctl_name = CTL_AUTO,
695 - .procname = "outdoor",
696 - .mode = 0444,
697 - .data = &ath_outdoor,
698 - .maxlen = sizeof(ath_outdoor),
699 - .proc_handler = proc_dointvec
700 - },
701 - { .ctl_name = CTL_AUTO,
702 .procname = "xchanmode",
703 .mode = 0444,
704 .data = &ath_xchanmode,
705 --- a/ath/if_athvar.h
706 +++ b/ath/if_athvar.h
707 @@ -688,17 +688,18 @@ struct ath_softc {
708 int8_t sc_ofdm_weak_det; /* OFDM weak frames detection, -1 == auto */
709
710 /* rate tables */
711 - const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
712 +#define ATH_MODE_HALF (IEEE80211_MODE_MAX)
713 +#define ATH_MODE_QUARTER (IEEE80211_MODE_MAX + 1)
714 + const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX + 2];
715 const HAL_RATE_TABLE *sc_currates; /* current rate table */
716 const HAL_RATE_TABLE *sc_xr_rates; /* XR rate table */
717 - const HAL_RATE_TABLE *sc_half_rates; /* half rate table */
718 - const HAL_RATE_TABLE *sc_quarter_rates; /* quarter rate table */
719 HAL_OPMODE sc_opmode; /* current hal operating mode */
720 enum ieee80211_phymode sc_curmode; /* current phy mode */
721 u_int sc_poweroffset; /* hardware power offset */
722 u_int16_t sc_curtxpow; /* current tx power limit */
723 u_int16_t sc_curaid; /* current association id */
724 HAL_CHANNEL sc_curchan; /* current h/w channel */
725 + u_int8_t sc_chanbw; /* channel bandwidth */
726 u_int8_t sc_curbssid[IEEE80211_ADDR_LEN];
727 u_int8_t sc_rixmap[256]; /* IEEE to h/w rate table ix */
728 struct {
729 @@ -809,6 +810,8 @@ struct ath_softc {
730 u_int32_t sc_dturbo_bw_turbo; /* bandwidth threshold */
731 #endif
732 u_int sc_slottimeconf; /* manual override for slottime */
733 + u_int sc_acktimeconf; /* manual override for acktime */
734 + u_int sc_ctstimeconf; /* manual override for ctstime */
735
736 struct timer_list sc_dfs_excl_timer; /* mark expiration timer task */
737 struct timer_list sc_dfs_cac_timer; /* dfs wait timer */
738 @@ -827,6 +830,7 @@ struct ath_softc {
739 int sc_rp_num;
740 int sc_rp_min;
741 HAL_BOOL (*sc_rp_analyse)(struct ath_softc *sc);
742 + struct ATH_TQ_STRUCT sc_refresh_tq;
743 struct ATH_TQ_STRUCT sc_rp_tq;
744
745 int sc_rp_ignored; /* if set, we ignored all
746 @@ -942,6 +946,48 @@ int ar_device(int devid);
747 DEV_NAME(_v->iv_ic->ic_dev))
748
749 void ath_radar_detected(struct ath_softc *sc, const char* message);
750 +static inline u_int getTimingOffset(struct ath_softc *sc)
751 +{
752 + struct ieee80211com *ic = &sc->sc_ic;
753 + u_int usec = 9;
754 + if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
755 + usec = 20;
756 + if (ic->ic_flags & IEEE80211_F_SHSLOT)
757 + usec = 9;
758 + } else if (IEEE80211_IS_CHAN_A(ic->ic_curchan))
759 + usec = 9;
760 +
761 + if (IEEE80211_IS_CHAN_TURBO(ic->ic_curchan))
762 + usec = 6;
763 +
764 + if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
765 + usec = 13;
766 + else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
767 + usec = 21;
768 + return usec;
769 +}
770 +
771 +static inline void ath_get_timings(struct ath_softc *sc, u_int *t_slot, u_int *t_sifs, u_int *t_difs)
772 +{
773 + struct ieee80211_channel *c = sc->sc_ic.ic_curchan;
774 +
775 + *t_slot = getTimingOffset(sc) + sc->sc_slottimeconf;
776 +
777 + if (IEEE80211_IS_CHAN_HALF(c)) {
778 + *t_sifs = 32;
779 + *t_difs = 56;
780 + } else if (IEEE80211_IS_CHAN_QUARTER(c)) {
781 + *t_sifs = 64;
782 + *t_difs = 112;
783 + } else if (IEEE80211_IS_CHAN_TURBO(c)) {
784 + *t_sifs = 8;
785 + *t_difs = 28;
786 + } else {
787 + *t_sifs = 16;
788 + *t_difs = 28;
789 + }
790 +}
791 +
792
793 struct ath_hw_detect {
794 const char *vendor_name;
795 --- a/tools/athctrl.c
796 +++ b/tools/athctrl.c
797 @@ -118,7 +118,7 @@ CMD(athctrl)(int argc, char *argv[])
798 }
799
800 if (distance >= 0) {
801 - int slottime = 9 + (distance / 300) + ((distance % 300) ? 1 : 0);
802 + int slottime = (distance / 300) + ((distance % 300) ? 1 : 0);
803 int acktimeout = slottime * 2 + 3;
804 int ctstimeout = slottime * 2 + 3;
805
806 --- a/net80211/ieee80211.c
807 +++ b/net80211/ieee80211.c
808 @@ -243,34 +243,17 @@ static const struct country_code_to_str
809 {CTRY_ZIMBABWE, "ZW"}
810 };
811
812 -int
813 -ieee80211_ifattach(struct ieee80211com *ic)
814 +void ieee80211_update_channels(struct ieee80211com *ic, int init)
815 {
816 - struct net_device *dev = ic->ic_dev;
817 struct ieee80211_channel *c;
818 + struct ieee80211vap *vap;
819 struct ifmediareq imr;
820 + int ext = 0;
821 int i;
822
823 - _MOD_INC_USE(THIS_MODULE, return -ENODEV);
824 -
825 - /*
826 - * Pick an initial operating mode until we have a vap
827 - * created to lock it down correctly. This is only
828 - * drivers have something defined for configuring the
829 - * hardware at startup.
830 - */
831 - ic->ic_opmode = IEEE80211_M_STA; /* everyone supports this */
832 -
833 - /*
834 - * Fill in 802.11 available channel set, mark
835 - * all available channels as active, and pick
836 - * a default channel if not already specified.
837 - */
838 - KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX,
839 - ("invalid number of channels specified: %u", ic->ic_nchans));
840 memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));
841 - ic->ic_modecaps |= 1 << IEEE80211_MODE_AUTO;
842 ic->ic_max_txpower = IEEE80211_TXPOWER_MIN;
843 + ic->ic_modecaps = 1 << IEEE80211_MODE_AUTO;
844
845 for (i = 0; i < ic->ic_nchans; i++) {
846 c = &ic->ic_channels[i];
847 @@ -298,6 +281,8 @@ ieee80211_ifattach(struct ieee80211com *
848 ic->ic_modecaps |= 1 << IEEE80211_MODE_TURBO_A;
849 if (IEEE80211_IS_CHAN_108G(c))
850 ic->ic_modecaps |= 1 << IEEE80211_MODE_TURBO_G;
851 + if (IEEE80211_IS_CHAN_HALF(c) || IEEE80211_IS_CHAN_QUARTER(c))
852 + ext = 1;
853 }
854 /* Initialize candidate channels to all available */
855 memcpy(ic->ic_chan_active, ic->ic_chan_avail,
856 @@ -311,11 +296,58 @@ ieee80211_ifattach(struct ieee80211com *
857 * When 11g is supported, force the rate set to
858 * include basic rates suitable for a mixed b/g bss.
859 */
860 - if (ic->ic_modecaps & (1 << IEEE80211_MODE_11G))
861 + if ((ic->ic_modecaps & (1 << IEEE80211_MODE_11G)) && !ext)
862 ieee80211_set11gbasicrates(
863 &ic->ic_sup_rates[IEEE80211_MODE_11G],
864 IEEE80211_MODE_11G);
865
866 + if (init)
867 + return;
868 +
869 + ieee80211_media_setup(ic, &ic->ic_media, ic->ic_caps, NULL, NULL);
870 + ieee80211com_media_status(ic->ic_dev, &imr);
871 + ifmedia_set(&ic->ic_media, imr.ifm_active);
872 +
873 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
874 + struct ieee80211vap *avp;
875 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
876 + (void) ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps, NULL, NULL);
877 + ieee80211_media_status(vap->iv_dev, &imr);
878 + ifmedia_set(&vap->iv_media, imr.ifm_active);
879 + }
880 + (void) ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps, NULL, NULL);
881 + ieee80211_media_status(vap->iv_dev, &imr);
882 + ifmedia_set(&vap->iv_media, imr.ifm_active);
883 + }
884 +}
885 +EXPORT_SYMBOL(ieee80211_update_channels);
886 +
887 +int
888 +ieee80211_ifattach(struct ieee80211com *ic)
889 +{
890 + struct net_device *dev = ic->ic_dev;
891 + struct ieee80211_channel *c;
892 + struct ifmediareq imr;
893 +
894 + _MOD_INC_USE(THIS_MODULE, return -ENODEV);
895 +
896 + /*
897 + * Pick an initial operating mode until we have a vap
898 + * created to lock it down correctly. This is only
899 + * drivers have something defined for configuring the
900 + * hardware at startup.
901 + */
902 + ic->ic_opmode = IEEE80211_M_STA; /* everyone supports this */
903 +
904 + /*
905 + * Fill in 802.11 available channel set, mark
906 + * all available channels as active, and pick
907 + * a default channel if not already specified.
908 + */
909 + KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX,
910 + ("invalid number of channels specified: %u", ic->ic_nchans));
911 + ieee80211_update_channels(ic, 1);
912 +
913 /* Setup initial channel settings */
914 ic->ic_bsschan = IEEE80211_CHAN_ANYC;
915 /* Arbitrarily pick the first channel */
916 @@ -327,6 +359,7 @@ ieee80211_ifattach(struct ieee80211com *
917 /* Enable WME by default, if we're capable. */
918 if (ic->ic_caps & IEEE80211_C_WME)
919 ic->ic_flags |= IEEE80211_F_WME;
920 +
921 (void) ieee80211_setmode(ic, ic->ic_curmode);
922
923 /* Store default beacon interval, as nec. */
924 @@ -763,7 +796,8 @@ ieee80211_media_setup(struct ieee80211co
925 struct ieee80211_rateset allrates;
926
927 /* Fill in media characteristics. */
928 - ifmedia_init(media, 0, media_change, media_stat);
929 + if (media_change || media_stat)
930 + ifmedia_init(media, 0, media_change, media_stat);
931 maxrate = 0;
932 memset(&allrates, 0, sizeof(allrates));
933
934 @@ -793,7 +827,7 @@ ieee80211_media_setup(struct ieee80211co
935 ADD(media, IFM_AUTO, mopt | IFM_IEEE80211_WDS);
936 if (mode == IEEE80211_MODE_AUTO)
937 continue;
938 - rs = &ic->ic_sup_rates[mode];
939 + rs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)];
940
941 for (i = 0; i < rs->rs_nrates; i++) {
942 rate = rs->rs_rates[i];
943 @@ -1207,7 +1241,7 @@ ieee80211_announce(struct ieee80211com *
944 if ((ic->ic_modecaps & (1 << mode)) == 0)
945 continue;
946 if_printf(dev, "%s rates: ", ieee80211_phymode_name[mode]);
947 - rs = &ic->ic_sup_rates[mode];
948 + rs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)];
949 for (i = 0; i < rs->rs_nrates; i++) {
950 rate = rs->rs_rates[i];
951 mword = ieee80211_rate2media(ic, rate, mode);
952 @@ -1417,7 +1451,7 @@ ieee80211com_media_change(struct net_dev
953 * now so drivers have a consistent state.
954 */
955 KASSERT(vap->iv_bss != NULL, ("no bss node"));
956 - vap->iv_bss->ni_rates = ic->ic_sup_rates[newphymode];
957 + vap->iv_bss->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, newphymode)];
958 }
959 error = -ENETRESET;
960 }
961 @@ -1435,7 +1469,7 @@ findrate(struct ieee80211com *ic, enum i
962 {
963 #define IEEERATE(_ic,_m,_i) \
964 ((_ic)->ic_sup_rates[_m].rs_rates[_i] & IEEE80211_RATE_VAL)
965 - int i, nrates = ic->ic_sup_rates[mode].rs_nrates;
966 + int i, nrates = ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)].rs_nrates;
967 for (i = 0; i < nrates; i++)
968 if (IEEERATE(ic, mode, i) == rate)
969 return i;
970 @@ -1877,11 +1911,6 @@ ieee80211_build_countryie(struct ieee802
971 if (ieee80211_chan2mode(c) != curmode_noturbo)
972 continue;
973
974 - /* Skip half/quarter rate channels */
975 - if (IEEE80211_IS_CHAN_HALF(c) ||
976 - IEEE80211_IS_CHAN_QUARTER(c))
977 - continue;
978 -
979 if (*cur_runlen == 0) {
980 (*cur_runlen)++;
981 *cur_pow = c->ic_maxregpower;
982 @@ -1915,7 +1944,7 @@ void
983 ieee80211_build_sc_ie(struct ieee80211com *ic)
984 {
985 struct ieee80211_ie_sc *ie = &ic->ic_sc_ie;
986 - int i, j;
987 + int i, j, k;
988 struct ieee80211_channel *c;
989 u_int8_t prevchan;
990
991 --- a/net80211/ieee80211_var.h
992 +++ b/net80211/ieee80211_var.h
993 @@ -336,8 +336,6 @@ struct ieee80211com {
994 u_int8_t ic_nopened; /* VAPs been opened */
995 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
996 struct ieee80211_rateset ic_sup_xr_rates;
997 - struct ieee80211_rateset ic_sup_half_rates;
998 - struct ieee80211_rateset ic_sup_quarter_rates;
999 u_int16_t ic_modecaps; /* set of mode capabilities */
1000 u_int16_t ic_curmode; /* current mode */
1001 u_int16_t ic_lintval; /* beacon interval */
1002 @@ -714,6 +712,7 @@ MALLOC_DECLARE(M_80211_VAP);
1003
1004 int ieee80211_ifattach(struct ieee80211com *);
1005 void ieee80211_ifdetach(struct ieee80211com *);
1006 +void ieee80211_update_channels(struct ieee80211com *ic, int);
1007 int ieee80211_vap_setup(struct ieee80211com *, struct net_device *,
1008 const char *, int, int, struct ieee80211vap *);
1009 int ieee80211_vap_attach(struct ieee80211vap *, ifm_change_cb_t, ifm_stat_cb_t);
1010 @@ -793,6 +792,23 @@ ieee80211_anyhdrspace(struct ieee80211co
1011 return size;
1012 }
1013
1014 +static __inline int
1015 +ieee80211_chan2ratemode(struct ieee80211_channel *c, int mode)
1016 +{
1017 + if (mode == -1)
1018 + mode = ieee80211_chan2mode(c);
1019 +
1020 + /*
1021 + * Use 11a rateset for half/quarter to restrict things
1022 + * to pure OFDM
1023 + */
1024 + if (IEEE80211_IS_CHAN_HALF(c) ||
1025 + IEEE80211_IS_CHAN_QUARTER(c))
1026 + return IEEE80211_MODE_11A;
1027 +
1028 + return mode;
1029 +}
1030 +
1031 /* Macros to print MAC address used in 802.11 headers */
1032
1033 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
1034 --- a/net80211/ieee80211_node.c
1035 +++ b/net80211/ieee80211_node.c
1036 @@ -287,7 +287,7 @@ ieee80211_node_set_chan(struct ieee80211
1037 ni->ni_rates = ic->ic_sup_xr_rates;
1038 else
1039 #endif
1040 - ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2mode(chan)];
1041 + ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(chan, -1)];
1042 }
1043
1044 static __inline void
1045 @@ -387,6 +387,8 @@ ieee80211_create_ibss(struct ieee80211va
1046 ic->ic_bsschan = chan;
1047 ieee80211_node_set_chan(ic, ni);
1048 ic->ic_curmode = ieee80211_chan2mode(chan);
1049 + ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2ratemode(chan, -1)];
1050 +
1051 spin_lock_irqsave(&channel_lock, flags);
1052 ieee80211_scan_set_bss_channel(ic, ic->ic_bsschan);
1053 spin_unlock_irqrestore(&channel_lock, flags);
1054 @@ -394,14 +396,8 @@ ieee80211_create_ibss(struct ieee80211va
1055 /* Update country ie information */
1056 ieee80211_build_countryie(ic);
1057
1058 - if (IEEE80211_IS_CHAN_HALF(chan)) {
1059 - ni->ni_rates = ic->ic_sup_half_rates;
1060 - } else if (IEEE80211_IS_CHAN_QUARTER(chan)) {
1061 - ni->ni_rates = ic->ic_sup_quarter_rates;
1062 - }
1063 -
1064 - if ((vap->iv_flags & IEEE80211_F_PUREG) &&
1065 - IEEE80211_IS_CHAN_ANYG(chan)) {
1066 + if ((ieee80211_chan2ratemode(chan, -1) != IEEE80211_MODE_11A) &&
1067 + IEEE80211_IS_CHAN_ANYG(chan) && (vap->iv_flags & IEEE80211_F_PUREG)) {
1068 ieee80211_setpuregbasicrates(&ni->ni_rates);
1069 }
1070
1071 --- a/net80211/ieee80211_scan_sta.c
1072 +++ b/net80211/ieee80211_scan_sta.c
1073 @@ -490,12 +490,7 @@ check_rate(struct ieee80211vap *vap, con
1074
1075 okrate = badrate = fixedrate = 0;
1076
1077 - if (IEEE80211_IS_CHAN_HALF(se->se_chan))
1078 - srs = &ic->ic_sup_half_rates;
1079 - else if (IEEE80211_IS_CHAN_QUARTER(se->se_chan))
1080 - srs = &ic->ic_sup_quarter_rates;
1081 - else
1082 - srs = &ic->ic_sup_rates[ieee80211_chan2mode(se->se_chan)];
1083 + srs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, -1)];
1084 nrs = se->se_rates[1];
1085 rs = se->se_rates + 2;
1086 fixedrate = IEEE80211_FIXED_RATE_NONE;
1087 --- a/net80211/ieee80211_output.c
1088 +++ b/net80211/ieee80211_output.c
1089 @@ -1676,8 +1676,8 @@ ieee80211_send_probereq(struct ieee80211
1090
1091 frm = ieee80211_add_ssid(frm, ssid, ssidlen);
1092 mode = ieee80211_chan2mode(ic->ic_curchan);
1093 - frm = ieee80211_add_rates(frm, &ic->ic_sup_rates[mode]);
1094 - frm = ieee80211_add_xrates(frm, &ic->ic_sup_rates[mode]);
1095 + frm = ieee80211_add_rates(frm, &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)]);
1096 + frm = ieee80211_add_xrates(frm, &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, mode)]);
1097
1098 if (optie != NULL) {
1099 memcpy(frm, optie, optielen);
1100 --- a/net80211/ieee80211_proto.c
1101 +++ b/net80211/ieee80211_proto.c
1102 @@ -404,7 +404,7 @@ ieee80211_fix_rate(struct ieee80211_node
1103
1104 error = 0;
1105 okrate = badrate = fixedrate = 0;
1106 - srs = &ic->ic_sup_rates[ieee80211_chan2mode(ni->ni_chan)];
1107 + srs = &ic->ic_sup_rates[ieee80211_chan2ratemode(ic->ic_curchan, -1)];
1108 nrs = &ni->ni_rates;
1109 fixedrate = IEEE80211_FIXED_RATE_NONE;
1110 for (i = 0; i < nrs->rs_nrates;) {
1111 @@ -1407,6 +1407,7 @@ ieee80211_new_state(struct ieee80211vap
1112 IEEE80211_VAPS_UNLOCK_IRQ(ic);
1113 return rc;
1114 }
1115 +EXPORT_SYMBOL(ieee80211_new_state);
1116
1117 static int
1118 __ieee80211_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
1119 --- a/ath_rate/minstrel/minstrel.c
1120 +++ b/ath_rate/minstrel/minstrel.c
1121 @@ -195,31 +195,7 @@ calc_usecs_unicast_packet(struct ath_sof
1122 return 0;
1123 }
1124
1125 - /* XXX: Getting MAC/PHY level timings should be fixed for turbo
1126 - * rates, and there is probably a way to get this from the
1127 - * HAL... */
1128 - switch (rt->info[rix].phy) {
1129 - case IEEE80211_T_OFDM:
1130 -#if 0
1131 - t_slot = 9;
1132 - t_sifs = 16;
1133 - t_difs = 28;
1134 - /* fall through */
1135 -#endif
1136 - case IEEE80211_T_TURBO:
1137 - t_slot = 9;
1138 - t_sifs = 8;
1139 - t_difs = 28;
1140 - break;
1141 - case IEEE80211_T_DS:
1142 - /* Fall through to default */
1143 - default:
1144 - /* pg. 205 ieee.802.11.pdf */
1145 - t_slot = 20;
1146 - t_difs = 50;
1147 - t_sifs = 10;
1148 - }
1149 -
1150 + ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
1151 if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
1152 (rt->info[rix].phy == IEEE80211_T_OFDM)) {
1153 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
1154 --- a/ath_rate/sample/sample.c
1155 +++ b/ath_rate/sample/sample.c
1156 @@ -172,26 +172,7 @@ calc_usecs_unicast_packet(struct ath_sof
1157 * rates, and there is probably a way to get this from the
1158 * hal...
1159 */
1160 - switch (rt->info[rix].phy) {
1161 - case IEEE80211_T_OFDM:
1162 - t_slot = 9;
1163 - t_sifs = 16;
1164 - t_difs = 28;
1165 - /* fall through */
1166 - case IEEE80211_T_TURBO:
1167 - t_slot = 9;
1168 - t_sifs = 8;
1169 - t_difs = 28;
1170 - break;
1171 - case IEEE80211_T_DS:
1172 - /* fall through to default */
1173 - default:
1174 - /* pg 205 ieee.802.11.pdf */
1175 - t_slot = 20;
1176 - t_difs = 50;
1177 - t_sifs = 10;
1178 - }
1179 -
1180 + ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
1181 rts = cts = 0;
1182
1183 if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
1184 --- a/net80211/ieee80211_wireless.c
1185 +++ b/net80211/ieee80211_wireless.c
1186 @@ -2142,7 +2142,7 @@ ieee80211_ioctl_setmode(struct net_devic
1187
1188 vap->iv_des_mode = mode;
1189 if (IS_UP_AUTO(vap))
1190 - ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1191 + ieee80211_init(vap->iv_dev, 0);
1192
1193 retv = 0;
1194 }
1195 @@ -4090,46 +4090,60 @@ ieee80211_ioctl_getchanlist(struct net_d
1196 return 0;
1197 }
1198
1199 +static int alreadyListed(struct ieee80211req_chaninfo *chans, u_int16_t mhz)
1200 +{
1201 + int i;
1202 + for (i = 0; i < chans->ic_nchans; i++) {
1203 + if (chans->ic_chans[i].ic_freq == mhz)
1204 + return 1;
1205 + }
1206 + return 0;
1207 +}
1208 +
1209 static int
1210 ieee80211_ioctl_getchaninfo(struct net_device *dev,
1211 - struct iw_request_info *info, void *w, char *extra)
1212 + struct iw_request_info *info, void *w, char *extra)
1213 {
1214 struct ieee80211vap *vap = dev->priv;
1215 struct ieee80211com *ic = vap->iv_ic;
1216 - struct ieee80211req_chaninfo chans;
1217 + struct ieee80211req_chaninfo *chans =
1218 + (struct ieee80211req_chaninfo *)extra;
1219 +
1220 u_int8_t reported[IEEE80211_CHAN_BYTES]; /* XXX stack usage? */
1221 int i;
1222
1223 - memset(&chans, 0, sizeof(chans));
1224 - memset(&reported, 0, sizeof(reported));
1225 + memset(chans, 0, sizeof(*chans));
1226 + memset(reported, 0, sizeof(reported));
1227 for (i = 0; i < ic->ic_nchans; i++) {
1228 const struct ieee80211_channel *c = &ic->ic_channels[i];
1229 const struct ieee80211_channel *c1 = c;
1230
1231 - if (isclr(reported, c->ic_ieee)) {
1232 + if (!alreadyListed(chans, c->ic_freq)) {
1233 setbit(reported, c->ic_ieee);
1234
1235 - /* pick turbo channel over non-turbo channel, and
1236 - * 11g channel over 11b channel */
1237 if (IEEE80211_IS_CHAN_A(c))
1238 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_A);
1239 + c1 = findchannel(ic, c->ic_freq,
1240 + IEEE80211_MODE_TURBO_A);
1241 if (IEEE80211_IS_CHAN_ANYG(c))
1242 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_G);
1243 + c1 = findchannel(ic, c->ic_freq,
1244 + IEEE80211_MODE_TURBO_G);
1245 else if (IEEE80211_IS_CHAN_B(c)) {
1246 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_TURBO_G);
1247 + c1 = findchannel(ic, c->ic_freq,
1248 + IEEE80211_MODE_TURBO_G);
1249 if (!c1)
1250 - c1 = findchannel(ic, c->ic_ieee, IEEE80211_MODE_11G);
1251 + c1 = findchannel(ic, c->ic_freq,
1252 + IEEE80211_MODE_11G);
1253 }
1254
1255 if (c1)
1256 c = c1;
1257 - /* Copy the entire structure, whereas it used to just copy a few fields */
1258 - memcpy(&chans.ic_chans[chans.ic_nchans], c, sizeof(struct ieee80211_channel));
1259 - if (++chans.ic_nchans >= IEEE80211_CHAN_MAX)
1260 + chans->ic_chans[chans->ic_nchans].ic_ieee = c->ic_ieee;
1261 + chans->ic_chans[chans->ic_nchans].ic_freq = c->ic_freq;
1262 + chans->ic_chans[chans->ic_nchans].ic_flags = c->ic_flags;
1263 + if (++chans->ic_nchans >= IEEE80211_CHAN_MAX)
1264 break;
1265 }
1266 }
1267 - memcpy(extra, &chans, sizeof(struct ieee80211req_chaninfo));
1268 return 0;
1269 }
1270
1271 --- a/net80211/ieee80211_scan_ap.c
1272 +++ b/net80211/ieee80211_scan_ap.c
1273 @@ -512,12 +512,13 @@ pick_channel(struct ieee80211_scan_state
1274 int ss_last = ss->ss_last;
1275 struct ieee80211_channel *best;
1276 struct ap_state *as = ss->ss_priv;
1277 - struct channel chans[ss_last]; /* actually ss_last-1 is required */
1278 + struct channel *chans; /* actually ss_last-1 is required */
1279 struct channel *c = NULL;
1280 struct pc_params params = { vap, ss, flags };
1281 int benefit = 0;
1282 int sta_assoc = 0;
1283
1284 + chans = (struct channel *)kmalloc(ss_last*sizeof(struct channel),GFP_ATOMIC);
1285 for (i = 0; i < ss_last; i++) {
1286 chans[i].chan = ss->ss_chans[i];
1287 chans[i].orig = i;
1288 @@ -571,6 +572,7 @@ pick_channel(struct ieee80211_scan_state
1289 "%s: best: channel %u rssi %d\n",
1290 __func__, i, as->as_maxrssi[i]);
1291 }
1292 + kfree(chans);
1293 return best;
1294 }
1295
1296 @@ -609,6 +611,7 @@ ap_end(struct ieee80211_scan_state *ss,
1297 res = 1; /* Do NOT restart scan */
1298 } else {
1299 struct ieee80211_scan_entry se;
1300 + int i;
1301 /* XXX: notify all VAPs? */
1302 /* if this is a dynamic turbo frequency , start with normal
1303 * mode first */
1304 @@ -623,6 +626,11 @@ ap_end(struct ieee80211_scan_state *ss,
1305 return 0;
1306 }
1307 }
1308 + for (i = (bestchan - &ic->ic_channels[0])/sizeof(*bestchan) + 1; i < ic->ic_nchans; i++) {
1309 + if ((ic->ic_channels[i].ic_freq == bestchan->ic_freq) &&
1310 + IEEE80211_IS_CHAN_ANYG(&ic->ic_channels[i]))
1311 + bestchan = &ic->ic_channels[i];
1312 + }
1313 memset(&se, 0, sizeof(se));
1314 se.se_chan = bestchan;
1315
1316 --- a/tools/wlanconfig.c
1317 +++ b/tools/wlanconfig.c
1318 @@ -737,7 +737,7 @@ list_channels(const char *ifname, int al
1319 if (get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans)) < 0)
1320 errx(1, "unable to get channel information");
1321 if (!allchans) {
1322 - uint8_t active[32];
1323 + uint8_t active[IEEE80211_CHAN_BYTES];
1324
1325 if (get80211priv(ifname, IEEE80211_IOCTL_GETCHANLIST, &active, sizeof(active)) < 0)
1326 errx(1, "unable to get active channel list");
1327 --- a/net80211/ieee80211_scan.c
1328 +++ b/net80211/ieee80211_scan.c
1329 @@ -1044,6 +1044,7 @@ ieee80211_scan_assoc_fail(struct ieee802
1330 ss->ss_ops->scan_assoc_fail(ss, mac, reason);
1331 }
1332 }
1333 +EXPORT_SYMBOL(ieee80211_scan_flush);
1334
1335 /*
1336 * Iterate over the contents of the scan cache.
1337 --- a/ath/if_ath_hal_wrappers.h
1338 +++ b/ath/if_ath_hal_wrappers.h
1339 @@ -111,6 +111,11 @@ static inline HAL_BOOL ath_hal_getregdom
1340 return (ath_hal_getcapability(ah, HAL_CAP_REG_DMN, 0, destination) == HAL_OK);
1341 }
1342
1343 +static inline HAL_BOOL ath_hal_setregdomain(struct ath_hal *ah, u_int32_t v)
1344 +{
1345 + return (ath_hal_setcapability(ah, HAL_CAP_REG_DMN, 0, v, NULL));
1346 +}
1347 +
1348 static inline HAL_BOOL ath_hal_gettkipmic(struct ath_hal *ah)
1349 {
1350 return (ath_hal_getcapability(ah, HAL_CAP_TKIP_MIC, 1, NULL) == HAL_OK);
This page took 0.093353 seconds and 5 git commands to generate.