1 Index: madwifi-trunk-r3776/net80211/ieee80211_scan_sta.c
2 ===================================================================
3 --- madwifi-trunk-r3776.orig/net80211/ieee80211_scan_sta.c 2008-07-17 00:21:29.000000000 +0200
4 +++ madwifi-trunk-r3776/net80211/ieee80211_scan_sta.c 2008-07-17 03:10:02.000000000 +0200
9 -static struct ieee80211_channel *
10 -find11gchannel(struct ieee80211com *ic, int i, int freq)
12 - struct ieee80211_channel *c;
16 - * The normal ordering in the channel list is b channel
17 - * immediately followed by g so optimize the search for
18 - * this. We'll still do a full search just in case.
20 - for (j = i+1; j < ic->ic_nchans; j++) {
21 - c = &ic->ic_channels[j];
22 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
25 - for (j = 0; j < i; j++) {
26 - c = &ic->ic_channels[j];
27 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
32 -static const u_int chanflags[] = {
33 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
34 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
35 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
36 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
37 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
38 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
39 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
40 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
44 -add_channels(struct ieee80211com *ic,
45 - struct ieee80211_scan_state *ss,
46 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
48 - struct ieee80211_channel *c, *cg;
52 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
53 - modeflags = chanflags[mode];
54 - for (i = 0; i < nfreq; i++) {
55 - c = ieee80211_find_channel(ic, freq[i], modeflags);
56 - if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
58 - if (mode == IEEE80211_MODE_AUTO) {
60 - * XXX special-case 11b/g channels so we select
61 - * the g channel if both are present.
63 - if (IEEE80211_IS_CHAN_B(c) &&
64 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
67 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
69 - ss->ss_chans[ss->ss_last++] = c;
73 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64, 36, 40, 44, 48 */
74 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
75 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
76 -{ 5170, 5190, 5210, 5230 };
77 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
78 -{ 2412, 2437, 2462, 2442, 2472 };
79 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
80 -{ 5745, 5765, 5785, 5805, 5825 };
81 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100,104,108,112,116,120,124,128,132,136,140 */
82 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
83 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
84 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
85 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
87 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
88 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
89 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
90 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
91 -#ifdef ATH_TURBO_SCAN
92 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
93 -{ 5210, 5250, 5290 };
94 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
96 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
97 -{ 5540, 5580, 5620, 5660 };
98 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
100 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
101 -{ 5200, 5240, 5280, 5765, 5805 };
102 -#endif /* ATH_TURBO_SCAN */
107 - const u_int16_t *list;
110 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
111 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
113 -static const struct scanlist staScanTable[] = {
114 - { IEEE80211_MODE_11B, X(rcl3) },
115 - { IEEE80211_MODE_11A, X(rcl1) },
116 - { IEEE80211_MODE_11A, X(rcl2) },
117 - { IEEE80211_MODE_11B, X(rcl8) },
118 - { IEEE80211_MODE_11B, X(rcl9) },
119 - { IEEE80211_MODE_11A, X(rcl4) },
120 -#ifdef ATH_TURBO_SCAN
121 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
122 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
123 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
124 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
125 -#endif /* ATH_TURBO_SCAN */
126 - { IEEE80211_MODE_11A, X(rcl7) },
127 - { IEEE80211_MODE_11B, X(rcl10) },
128 - { IEEE80211_MODE_11A, X(rcl11) },
129 -#ifdef ATH_TURBO_SCAN
130 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
131 -#endif /* ATH_TURBO_SCAN */
138 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
142 - for (; scan->list != NULL; scan++) {
143 - for (i = 0; i < scan->count; i++)
144 - if (scan->list[i] == c->ic_freq)
151 * Start a station-mode scan by populating the channel list.
153 @@ -467,81 +326,11 @@
155 struct ieee80211com *ic = vap->iv_ic;
156 struct sta_table *st = ss->ss_priv;
157 - const struct scanlist *scan;
158 - enum ieee80211_phymode mode;
159 - struct ieee80211_channel *c;
164 - * Use the table of ordered channels to construct the list
165 - * of channels for scanning. Any channels in the ordered
166 - * list not in the master list will be discarded.
168 - for (scan = staScanTable; scan->list != NULL; scan++) {
170 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
172 - * If a desired mode was specified, scan only
173 - * channels that satisfy that constraint.
175 - if (vap->iv_des_mode != mode) {
177 - * The scan table marks 2.4Ghz channels as b
178 - * so if the desired mode is 11g, then use
179 - * the 11b channel list but upgrade the mode.
181 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
182 - mode != IEEE80211_MODE_11B)
184 - mode = IEEE80211_MODE_11G; /* upgrade */
188 - * This lets ieee80211_scan_add_channels
189 - * upgrade an 11b channel to 11g if available.
191 - if (mode == IEEE80211_MODE_11B)
192 - mode = IEEE80211_MODE_AUTO;
194 - /* XR does not operate on turbo channels */
195 - if ((vap->iv_flags & IEEE80211_F_XR) &&
196 - (mode == IEEE80211_MODE_TURBO_A ||
197 - mode == IEEE80211_MODE_TURBO_G))
200 - * Add the list of the channels; any that are not
201 - * in the master channel list will be discarded.
203 - add_channels(ic, ss, mode, scan->list, scan->count);
207 - * Add the channels from the ic (from HAL) that are not present
208 - * in the staScanTable.
210 - for (i = 0; i < ic->ic_nchans; i++) {
211 - c = &ic->ic_channels[i];
213 - * scan dynamic turbo channels in normal mode.
215 - if (IEEE80211_IS_CHAN_DTURBO(c))
217 - mode = ieee80211_chan2mode(c);
218 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
220 - * If a desired mode was specified, scan only
221 - * channels that satisfy that constraint.
223 - if (vap->iv_des_mode != mode)
227 - if (!checktable(staScanTable, c))
228 - ss->ss_chans[ss->ss_last++] = c;
231 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
236 * The scanner will stay on station for ss_maxdwell ms (using a
239 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
242 - * NB: normally the desired mode is used to construct
243 - * the channel list, but it's possible for the scan
244 - * cache to include entries for stations outside this
245 - * list so we check the desired mode here to weed them
248 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
249 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
250 - chanflags[vap->iv_des_mode])
253 if (vap->iv_opmode == IEEE80211_M_IBSS) {
254 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
256 @@ -1175,78 +954,6 @@
257 .scan_default = ieee80211_sta_join,
261 - * Start an adhoc-mode scan by populating the channel list.
264 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
266 - struct ieee80211com *ic = vap->iv_ic;
267 - struct sta_table *st = ss->ss_priv;
268 - const struct scanlist *scan;
269 - enum ieee80211_phymode mode;
273 - * Use the table of ordered channels to construct the list
274 - * of channels for scanning. Any channels in the ordered
275 - * list not in the master list will be discarded.
277 - for (scan = staScanTable; scan->list != NULL; scan++) {
279 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
281 - * If a desired mode was specified, scan only
282 - * channels that satisfy that constraint.
284 - if (vap->iv_des_mode != mode) {
286 - * The scan table marks 2.4Ghz channels as b
287 - * so if the desired mode is 11g, then use
288 - * the 11b channel list but upgrade the mode.
290 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
291 - mode != IEEE80211_MODE_11B)
293 - mode = IEEE80211_MODE_11G; /* upgrade */
297 - * This lets ieee80211_scan_add_channels
298 - * upgrade an 11b channel to 11g if available.
300 - if (mode == IEEE80211_MODE_11B)
301 - mode = IEEE80211_MODE_AUTO;
303 - /* XR does not operate on turbo channels */
304 - if ((vap->iv_flags & IEEE80211_F_XR) &&
305 - (mode == IEEE80211_MODE_TURBO_A ||
306 - mode == IEEE80211_MODE_TURBO_G))
309 - * Add the list of the channels; any that are not
310 - * in the master channel list will be discarded.
312 - add_channels(ic, ss, mode, scan->list, scan->count);
316 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
317 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
319 -#ifdef IEEE80211_DEBUG
320 - if (ieee80211_msg_scan(vap)) {
321 - printk("%s: scan set ", vap->iv_dev->name);
322 - ieee80211_scan_dump_channels(ss);
323 - printk(" dwell min %ld max %ld\n",
324 - ss->ss_mindwell, ss->ss_maxdwell);
326 -#endif /* IEEE80211_DEBUG */
328 - st->st_newscan = 1;
334 * Select a channel to start an adhoc network on.
335 @@ -1412,7 +1119,7 @@
336 .scan_name = "default",
337 .scan_attach = sta_attach,
338 .scan_detach = sta_detach,
339 - .scan_start = adhoc_start,
340 + .scan_start = sta_start,
341 .scan_restart = sta_restart,
342 .scan_cancel = sta_cancel,
343 .scan_end = adhoc_pick_bss,
344 Index: madwifi-trunk-r3776/net80211/ieee80211.c
345 ===================================================================
346 --- madwifi-trunk-r3776.orig/net80211/ieee80211.c 2008-07-17 02:56:18.000000000 +0200
347 +++ madwifi-trunk-r3776/net80211/ieee80211.c 2008-07-17 03:07:53.000000000 +0200
349 ("channel with bogus ieee number %u", c->ic_ieee));
350 setbit(ic->ic_chan_avail, c->ic_ieee);
352 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
353 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
355 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
357 /* Identify mode capabilities. */
358 if (IEEE80211_IS_CHAN_A(c))
359 ic->ic_modecaps |= 1 << IEEE80211_MODE_11A;
360 Index: madwifi-trunk-r3776/net80211/_ieee80211.h
361 ===================================================================
362 --- madwifi-trunk-r3776.orig/net80211/_ieee80211.h 2008-07-17 00:21:29.000000000 +0200
363 +++ madwifi-trunk-r3776/net80211/_ieee80211.h 2008-07-17 03:07:53.000000000 +0200
365 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
368 +enum ieee80211_scanflags {
369 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
370 + IEEE80211_NOSCAN_SET = (1 << 1),
374 * Channels are specified by frequency and attributes.
377 int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
378 int8_t ic_maxpower; /* maximum tx power in dBm */
379 int8_t ic_minpower; /* minimum tx power in dBm */
380 + u_int8_t ic_scanflags;
383 #define IEEE80211_CHAN_MAX 255
384 Index: madwifi-trunk-r3776/net80211/ieee80211_ioctl.h
385 ===================================================================
386 --- madwifi-trunk-r3776.orig/net80211/ieee80211_ioctl.h 2008-07-17 02:56:52.000000000 +0200
387 +++ madwifi-trunk-r3776/net80211/ieee80211_ioctl.h 2008-07-17 03:07:53.000000000 +0200
389 #define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
390 #define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
391 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
392 +#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
395 IEEE80211_WMMPARAMS_CWMIN = 1,
396 Index: madwifi-trunk-r3776/net80211/ieee80211_scan_ap.c
397 ===================================================================
398 --- madwifi-trunk-r3776.orig/net80211/ieee80211_scan_ap.c 2008-07-17 02:20:50.000000000 +0200
399 +++ madwifi-trunk-r3776/net80211/ieee80211_scan_ap.c 2008-07-17 03:09:25.000000000 +0200
400 @@ -200,131 +200,7 @@
402 static int ap_flush(struct ieee80211_scan_state *);
403 static void action_tasklet(IEEE80211_TQUEUE_ARG);
404 -static struct ieee80211_channel *find11gchannel(struct ieee80211com *ic,
407 -static const u_int chanflags[] = {
408 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
409 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
410 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
411 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
412 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
413 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode
417 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
418 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
421 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64,
422 - * 36, 40, 44, 48 */
423 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
424 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
425 -{ 5170, 5190, 5210, 5230 };
426 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
427 -{ 2412, 2437, 2462, 2442, 2472 };
428 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
429 -{ 5745, 5765, 5785, 5805, 5825 };
430 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100, 104, 108, 112,
431 - * 116, 120, 124, 128,
433 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
434 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
435 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
436 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
438 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
439 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
440 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
441 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
442 -#ifdef ATH_TURBO_SCAN
443 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
444 -{ 5210, 5250, 5290 };
445 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
447 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
448 -{ 5540, 5580, 5620, 5660 };
449 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
451 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
452 -{ 5200, 5240, 5280, 5765, 5805 };
453 -#endif /* ATH_TURBO_SCAN */
458 - const u_int16_t *list;
461 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
462 -#define X(a) .count = ARRAY_SIZE(a), .list = a
464 -static const struct scanlist staScanTable[] = {
465 - { IEEE80211_MODE_11B, X(rcl3) },
466 - { IEEE80211_MODE_11A, X(rcl1) },
467 - { IEEE80211_MODE_11A, X(rcl2) },
468 - { IEEE80211_MODE_11B, X(rcl8) },
469 - { IEEE80211_MODE_11B, X(rcl9) },
470 - { IEEE80211_MODE_11A, X(rcl4) },
471 -#ifdef ATH_TURBO_SCAN
472 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
473 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
474 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
475 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
476 -#endif /* ATH_TURBO_SCAN */
477 - { IEEE80211_MODE_11A, X(rcl7) },
478 - { IEEE80211_MODE_11B, X(rcl10) },
479 - { IEEE80211_MODE_11A, X(rcl11) },
480 -#ifdef ATH_TURBO_SCAN
481 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
482 -#endif /* ATH_TURBO_SCAN */
487 -/* This function must be invoked with locks acquired */
489 -add_channels(struct ieee80211com *ic,
490 - struct ieee80211_scan_state *ss,
491 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
493 - struct ieee80211_channel *c, *cg;
497 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
498 - modeflags = chanflags[mode];
499 - for (i = 0; i < nfreq; i++) {
500 - c = ieee80211_find_channel(ic, freq[i], modeflags);
501 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
503 - if (mode == IEEE80211_MODE_AUTO) {
504 - /* XXX special-case 11b/g channels so we select
505 - * the g channel if both are present. */
506 - if (IEEE80211_IS_CHAN_B(c) &&
507 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
510 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
512 - ss->ss_chans[ss->ss_last++] = c;
516 -/* This function must be invoked with locks acquired */
518 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
522 - for (; scan->list != NULL; scan++) {
523 - for (i = 0; i < scan->count; i++)
524 - if (scan->list[i] == c->ic_freq)
531 * Attach prior to any scanning work.
533 ieee80211_saveie(iep, ie);
536 -/* This function must be invoked with locks acquired */
537 -static struct ieee80211_channel *
538 -find11gchannel(struct ieee80211com *ic, int i, int freq)
540 - struct ieee80211_channel *c;
543 - /* The normal ordering in the channel list is b channel
544 - * immediately followed by g so optimize the search for
545 - * this. We'll still do a full search just in case. */
546 - for (j = i + 1; j < ic->ic_nchans; j++) {
547 - c = &ic->ic_channels[j];
548 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
551 - for (j = 0; j < i; j++) {
552 - c = &ic->ic_channels[j];
553 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
560 * Start an ap scan by populating the channel list.
562 @@ -429,90 +282,14 @@
564 struct ap_state *as = ss->ss_priv;
565 struct ieee80211com *ic = NULL;
566 - const struct scanlist *sl = NULL;
567 - struct ieee80211_channel *c = NULL;
569 - unsigned int mode = 0;
571 SCAN_AP_LOCK_IRQ(as);
573 /* Determine mode flags to match, or leave zero for auto mode */
574 as->as_vap_desired_mode = vap->iv_des_mode;
575 as->as_required_mode = 0;
576 - if (as->as_vap_desired_mode != IEEE80211_MODE_AUTO) {
577 - as->as_required_mode = chanflags[as->as_vap_desired_mode];
578 - if ((vap->iv_ath_cap & IEEE80211_ATHC_TURBOP) &&
579 - (as->as_required_mode != IEEE80211_CHAN_ST)) {
580 - /* Fixup for dynamic turbo flags */
581 - if (as->as_vap_desired_mode == IEEE80211_MODE_11G)
582 - as->as_required_mode = IEEE80211_CHAN_108G;
584 - as->as_required_mode = IEEE80211_CHAN_108A;
589 - /* Use the table of ordered channels to construct the list
590 - * of channels for scanning. Any channels in the ordered
591 - * list not in the master list will be discarded. */
592 - for (sl = staScanTable; sl->list != NULL; sl++) {
595 - /* The scan table marks 2.4Ghz channels as b
596 - * so if the desired mode is 11g, then use
597 - * the 11b channel list but upgrade the mode. */
598 - if (as->as_vap_desired_mode &&
599 - (as->as_vap_desired_mode != mode) &&
600 - (as->as_vap_desired_mode == IEEE80211_MODE_11G) &&
601 - (mode == IEEE80211_MODE_11B))
602 - mode = IEEE80211_MODE_11G;
604 - /* If we are in "AUTO" mode, upgrade the mode to auto.
605 - * This lets add_channels upgrade an 11b channel to
606 - * 11g if available. */
607 - if (!as->as_vap_desired_mode && (mode == IEEE80211_MODE_11B))
608 - mode = IEEE80211_MODE_AUTO;
610 - /* Add the list of the channels; any that are not
611 - * in the master channel list will be discarded. */
612 - add_channels(ic, ss, mode, sl->list, sl->count);
615 - /* Add the channels from the ic (from HAL) that are not present
616 - * in the staScanTable, assuming they pass the sanity checks... */
617 - for (i = 0; i < ic->ic_nchans; i++) {
618 - c = &ic->ic_channels[i];
620 - /* XR is not supported on turbo channels */
621 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
623 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
625 - /* Dynamic channels are scanned in base mode */
626 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
629 - /* Use any 11g channel instead of 11b one. */
630 - if (vap->iv_des_mode == IEEE80211_MODE_AUTO &&
631 - IEEE80211_IS_CHAN_B(c) &&
632 - find11gchannel(ic, i, c->ic_freq))
635 - /* Do not add channels already put into the scan list by the
636 - * scan table - these have already been filtered by mode
637 - * and for whether they are in the active channel list. */
638 - if (checktable(staScanTable, c))
641 - /* Make sure the channel is active */
642 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
645 - /* Don't overrun */
646 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
649 - ss->ss_chans[ss->ss_last++] = c;
653 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
655 if (IEEE80211_IS_CHAN_RADAR(c->chan))
658 - /* Do not select 802.11a ST if mode is specified and is not
660 - if (as->as_required_mode &&
661 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
662 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
665 /* Verify mode matches any fixed mode specified */
666 if ((c->chan->ic_flags & as->as_required_mode) !=
667 as->as_required_mode)
668 Index: madwifi-trunk-r3776/net80211/ieee80211_scan.c
669 ===================================================================
670 --- madwifi-trunk-r3776.orig/net80211/ieee80211_scan.c 2008-07-17 00:49:51.000000000 +0200
671 +++ madwifi-trunk-r3776/net80211/ieee80211_scan.c 2008-07-17 03:07:53.000000000 +0200
676 +static const u_int chanflags[] = {
677 + 0, /* IEEE80211_MODE_AUTO */
678 + IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
679 + IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
680 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
681 + IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
682 + IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
683 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
684 + IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
687 +static struct ieee80211_channel *
688 +find11gchannel(struct ieee80211com *ic, int i, int freq)
690 + struct ieee80211_channel *c;
694 + * The normal ordering in the channel list is b channel
695 + * immediately followed by g so optimize the search for
696 + * this. We'll still do a full search just in case.
698 + for (j = i+1; j < ic->ic_nchans; j++) {
699 + c = &ic->ic_channels[j];
700 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
703 + for (j = 0; j < i; j++) {
704 + c = &ic->ic_channels[j];
705 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
713 +ieee80211_scan_add_channels(struct ieee80211com *ic,
714 + struct ieee80211_scan_state *ss,
715 + enum ieee80211_phymode mode)
717 + struct ieee80211_channel *c, *cg;
721 + KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
722 + modeflags = chanflags[mode];
723 + for (i = 0; i < ic->ic_nchans; i++) {
724 + c = &ic->ic_channels[i];
725 + if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
727 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
730 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
731 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
733 + if (mode == IEEE80211_MODE_AUTO) {
735 + * XXX special-case 11b/g channels so we select
736 + * the g channel if both are present.
738 + if (IEEE80211_IS_CHAN_B(c) &&
739 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
742 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
744 + ss->ss_chans[ss->ss_last++] = c;
747 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
751 * Execute radar channel change. This is called when a radar/dfs
752 * signal is detected. AP mode only. Return 1 on success, 0 on
753 Index: madwifi-trunk-r3776/net80211/ieee80211_scan.h
754 ===================================================================
755 --- madwifi-trunk-r3776.orig/net80211/ieee80211_scan.h 2008-07-17 00:21:29.000000000 +0200
756 +++ madwifi-trunk-r3776/net80211/ieee80211_scan.h 2008-07-17 03:07:53.000000000 +0200
758 void ieee80211_scanner_unregister(enum ieee80211_opmode,
759 const struct ieee80211_scanner *);
760 void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
761 +void ieee80211_scan_add_channels(struct ieee80211com *ic,
762 + struct ieee80211_scan_state *ss,
763 + enum ieee80211_phymode mode);
764 #endif /* _NET80211_IEEE80211_SCAN_H_ */
765 Index: madwifi-trunk-r3776/net80211/ieee80211_wireless.c
766 ===================================================================
767 --- madwifi-trunk-r3776.orig/net80211/ieee80211_wireless.c 2008-07-17 02:56:18.000000000 +0200
768 +++ madwifi-trunk-r3776/net80211/ieee80211_wireless.c 2008-07-17 03:08:16.000000000 +0200
769 @@ -3911,6 +3911,106 @@
770 return ieee80211_ioctl_setmlme(dev, info, w, (char *)&mlme);
773 +static inline void setflag(struct ieee80211_channel *c, int flag)
776 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
778 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
781 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
785 + for (i = 0; i < ic->ic_nchans; i++) {
786 + struct ieee80211_channel *c = &ic->ic_channels[i];
789 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
791 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
798 +ieee80211_ioctl_setscanlist(struct net_device *dev,
799 + struct iw_request_info *info,
800 + struct iw_point *data, char *extra)
802 + struct ieee80211vap *vap = dev->priv;
803 + struct ieee80211com *ic = vap->iv_ic;
807 + if (data->length <= 0)
810 + s = kmalloc(data->length + 1, GFP_KERNEL);
814 + memset(s, 0, data->length + 1);
815 + if (copy_from_user(s, data->pointer, data->length))
818 + s[data->length - 1] = '\0'; /* ensure null termination */
833 + next = strchr(s, ',');
838 + if (!strcmp(s, "ALL")) {
839 + setscanflag(ic, 0, 10000, val);
840 + } else if (!strcmp(s, "REG")) {
841 + setscanflag(ic, -1, -1, val);
844 + char *n, *end = NULL;
846 + n = strchr(s, '-');
851 + min = simple_strtoul(s, &end, 10);
855 + max = simple_strtoul(n, &end, 10);
861 + setscanflag(ic, min, max, val);
874 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info,
875 void *w, char *extra)
876 @@ -5712,6 +5812,8 @@
877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "minrate"},
878 {IEEE80211_PARAM_MINRATE,
879 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
880 + { IEEE80211_IOCTL_SETSCANLIST,
881 + IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
883 #ifdef ATH_REVERSE_ENGINEERING
885 @@ -5809,6 +5911,7 @@
886 set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
887 set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
888 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
889 + set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
890 #ifdef ATH_REVERSE_ENGINEERING
891 set_priv(IEEE80211_IOCTL_READREG, ieee80211_ioctl_readreg),
892 set_priv(IEEE80211_IOCTL_WRITEREG, ieee80211_ioctl_writereg),