refresh madwifi-testing patches
[openwrt.git] / package / madwifi / patches / 351-scanlist.patch
1 --- a/net80211/ieee80211_scan_sta.c
2 +++ b/net80211/ieee80211_scan_sta.c
3 @@ -317,147 +317,6 @@
4 #undef ISPROBE
5 }
6
7 -static struct ieee80211_channel *
8 -find11gchannel(struct ieee80211com *ic, int i, int freq)
9 -{
10 - struct ieee80211_channel *c;
11 - int j;
12 -
13 - /*
14 - * The normal ordering in the channel list is b channel
15 - * immediately followed by g so optimize the search for
16 - * this. We'll still do a full search just in case.
17 - */
18 - for (j = i+1; j < ic->ic_nchans; j++) {
19 - c = &ic->ic_channels[j];
20 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
21 - return c;
22 - }
23 - for (j = 0; j < i; j++) {
24 - c = &ic->ic_channels[j];
25 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
26 - return c;
27 - }
28 - return NULL;
29 -}
30 -static const u_int chanflags[] = {
31 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
32 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
33 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
34 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
35 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
36 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
37 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
38 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
39 -};
40 -
41 -static void
42 -add_channels(struct ieee80211com *ic,
43 - struct ieee80211_scan_state *ss,
44 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
45 -{
46 - struct ieee80211_channel *c, *cg;
47 - u_int modeflags;
48 - int i;
49 -
50 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
51 - modeflags = chanflags[mode];
52 - for (i = 0; i < nfreq; i++) {
53 - c = ieee80211_find_channel(ic, freq[i], modeflags);
54 - if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
55 - continue;
56 - if (mode == IEEE80211_MODE_AUTO) {
57 - /*
58 - * XXX special-case 11b/g channels so we select
59 - * the g channel if both are present.
60 - */
61 - if (IEEE80211_IS_CHAN_B(c) &&
62 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
63 - c = cg;
64 - }
65 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
66 - break;
67 - ss->ss_chans[ss->ss_last++] = c;
68 - }
69 -}
70 -
71 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64, 36, 40, 44, 48 */
72 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
73 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
74 -{ 5170, 5190, 5210, 5230 };
75 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
76 -{ 2412, 2437, 2462, 2442, 2472 };
77 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
78 -{ 5745, 5765, 5785, 5805, 5825 };
79 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100,104,108,112,116,120,124,128,132,136,140 */
80 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
81 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
82 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
83 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
84 -{ 2484 };
85 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
86 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
87 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
88 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
89 -#ifdef ATH_TURBO_SCAN
90 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
91 -{ 5210, 5250, 5290 };
92 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
93 -{ 5760, 5800 };
94 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
95 -{ 5540, 5580, 5620, 5660 };
96 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
97 -{ 2437 };
98 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
99 -{ 5200, 5240, 5280, 5765, 5805 };
100 -#endif /* ATH_TURBO_SCAN */
101 -
102 -struct scanlist {
103 - u_int16_t mode;
104 - u_int16_t count;
105 - const u_int16_t *list;
106 -};
107 -
108 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
109 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
110 -
111 -static const struct scanlist staScanTable[] = {
112 - { IEEE80211_MODE_11B, X(rcl3) },
113 - { IEEE80211_MODE_11A, X(rcl1) },
114 - { IEEE80211_MODE_11A, X(rcl2) },
115 - { IEEE80211_MODE_11B, X(rcl8) },
116 - { IEEE80211_MODE_11B, X(rcl9) },
117 - { IEEE80211_MODE_11A, X(rcl4) },
118 -#ifdef ATH_TURBO_SCAN
119 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
120 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
121 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
122 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
123 -#endif /* ATH_TURBO_SCAN */
124 - { IEEE80211_MODE_11A, X(rcl7) },
125 - { IEEE80211_MODE_11B, X(rcl10) },
126 - { IEEE80211_MODE_11A, X(rcl11) },
127 -#ifdef ATH_TURBO_SCAN
128 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
129 -#endif /* ATH_TURBO_SCAN */
130 - { .list = NULL }
131 -};
132 -
133 -#undef X
134 -
135 -static int
136 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
137 -{
138 - int i;
139 -
140 - for (; scan->list != NULL; scan++) {
141 - for (i = 0; i < scan->count; i++)
142 - if (scan->list[i] == c->ic_freq)
143 - return 1;
144 - }
145 - return 0;
146 -}
147 -
148 /*
149 * Start a station-mode scan by populating the channel list.
150 */
151 @@ -466,81 +325,14 @@
152 {
153 struct ieee80211com *ic = vap->iv_ic;
154 struct sta_table *st = ss->ss_priv;
155 - const struct scanlist *scan;
156 enum ieee80211_phymode mode;
157 struct ieee80211_channel *c;
158 int i;
159
160 ss->ss_last = 0;
161 - /*
162 - * Use the table of ordered channels to construct the list
163 - * of channels for scanning. Any channels in the ordered
164 - * list not in the master list will be discarded.
165 - */
166 - for (scan = staScanTable; scan->list != NULL; scan++) {
167 - mode = scan->mode;
168 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
169 - /*
170 - * If a desired mode was specified, scan only
171 - * channels that satisfy that constraint.
172 - */
173 - if (vap->iv_des_mode != mode) {
174 - /*
175 - * The scan table marks 2.4Ghz channels as b
176 - * so if the desired mode is 11g, then use
177 - * the 11b channel list but upgrade the mode.
178 - */
179 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
180 - mode != IEEE80211_MODE_11B)
181 - continue;
182 - mode = IEEE80211_MODE_11G; /* upgrade */
183 - }
184 - } else {
185 - /*
186 - * This lets ieee80211_scan_add_channels
187 - * upgrade an 11b channel to 11g if available.
188 - */
189 - if (mode == IEEE80211_MODE_11B)
190 - mode = IEEE80211_MODE_AUTO;
191 - }
192 - /* XR does not operate on turbo channels */
193 - if ((vap->iv_flags & IEEE80211_F_XR) &&
194 - (mode == IEEE80211_MODE_TURBO_A ||
195 - mode == IEEE80211_MODE_TURBO_G))
196 - continue;
197 - /*
198 - * Add the list of the channels; any that are not
199 - * in the master channel list will be discarded.
200 - */
201 - add_channels(ic, ss, mode, scan->list, scan->count);
202 - }
203 -
204 - /*
205 - * Add the channels from the ic (from HAL) that are not present
206 - * in the staScanTable.
207 - */
208 - for (i = 0; i < ic->ic_nchans; i++) {
209 - c = &ic->ic_channels[i];
210 - /*
211 - * scan dynamic turbo channels in normal mode.
212 - */
213 - if (IEEE80211_IS_CHAN_DTURBO(c))
214 - continue;
215 - mode = ieee80211_chan2mode(c);
216 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
217 - /*
218 - * If a desired mode was specified, scan only
219 - * channels that satisfy that constraint.
220 - */
221 - if (vap->iv_des_mode != mode)
222 - continue;
223 -
224 - }
225 - if (!checktable(staScanTable, c))
226 - ss->ss_chans[ss->ss_last++] = c;
227 - }
228 -
229 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
230 ss->ss_next = 0;
231 +
232 /* XXX tunables */
233 /*
234 * The scanner will stay on station for ss_maxdwell ms (using a
235 @@ -749,17 +541,7 @@
236 fail = 0;
237 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
238 fail |= 0x01;
239 - /*
240 - * NB: normally the desired mode is used to construct
241 - * the channel list, but it's possible for the scan
242 - * cache to include entries for stations outside this
243 - * list so we check the desired mode here to weed them
244 - * out.
245 - */
246 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
247 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
248 - chanflags[vap->iv_des_mode])
249 - fail |= 0x01;
250 +
251 if (vap->iv_opmode == IEEE80211_M_IBSS) {
252 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
253 fail |= 0x02;
254 @@ -1168,78 +950,6 @@
255 .scan_default = ieee80211_sta_join,
256 };
257
258 -/*
259 - * Start an adhoc-mode scan by populating the channel list.
260 - */
261 -static int
262 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
263 -{
264 - struct ieee80211com *ic = vap->iv_ic;
265 - struct sta_table *st = ss->ss_priv;
266 - const struct scanlist *scan;
267 - enum ieee80211_phymode mode;
268 -
269 - ss->ss_last = 0;
270 - /*
271 - * Use the table of ordered channels to construct the list
272 - * of channels for scanning. Any channels in the ordered
273 - * list not in the master list will be discarded.
274 - */
275 - for (scan = staScanTable; scan->list != NULL; scan++) {
276 - mode = scan->mode;
277 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
278 - /*
279 - * If a desired mode was specified, scan only
280 - * channels that satisfy that constraint.
281 - */
282 - if (vap->iv_des_mode != mode) {
283 - /*
284 - * The scan table marks 2.4Ghz channels as b
285 - * so if the desired mode is 11g, then use
286 - * the 11b channel list but upgrade the mode.
287 - */
288 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
289 - mode != IEEE80211_MODE_11B)
290 - continue;
291 - mode = IEEE80211_MODE_11G; /* upgrade */
292 - }
293 - } else {
294 - /*
295 - * This lets ieee80211_scan_add_channels
296 - * upgrade an 11b channel to 11g if available.
297 - */
298 - if (mode == IEEE80211_MODE_11B)
299 - mode = IEEE80211_MODE_AUTO;
300 - }
301 - /* XR does not operate on turbo channels */
302 - if ((vap->iv_flags & IEEE80211_F_XR) &&
303 - (mode == IEEE80211_MODE_TURBO_A ||
304 - mode == IEEE80211_MODE_TURBO_G))
305 - continue;
306 - /*
307 - * Add the list of the channels; any that are not
308 - * in the master channel list will be discarded.
309 - */
310 - add_channels(ic, ss, mode, scan->list, scan->count);
311 - }
312 - ss->ss_next = 0;
313 - /* XXX tunables */
314 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
315 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
316 -
317 -#ifdef IEEE80211_DEBUG
318 - if (ieee80211_msg_scan(vap)) {
319 - printk("%s: scan set ", vap->iv_dev->name);
320 - ieee80211_scan_dump_channels(ss);
321 - printk(" dwell min %ld max %ld\n",
322 - ss->ss_mindwell, ss->ss_maxdwell);
323 - }
324 -#endif /* IEEE80211_DEBUG */
325 -
326 - st->st_newscan = 1;
327 -
328 - return 0;
329 -}
330
331 /*
332 * Select a channel to start an adhoc network on.
333 @@ -1405,7 +1115,7 @@
334 .scan_name = "default",
335 .scan_attach = sta_attach,
336 .scan_detach = sta_detach,
337 - .scan_start = adhoc_start,
338 + .scan_start = sta_start,
339 .scan_restart = sta_restart,
340 .scan_cancel = sta_cancel,
341 .scan_end = adhoc_pick_bss,
342 --- a/net80211/ieee80211.c
343 +++ b/net80211/ieee80211.c
344 @@ -278,6 +278,11 @@
345 ("channel with bogus ieee number %u", c->ic_ieee));
346 setbit(ic->ic_chan_avail, c->ic_ieee);
347
348 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
349 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
350 + else
351 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
352 +
353 /* Identify mode capabilities. */
354 if (IEEE80211_IS_CHAN_A(c))
355 ic->ic_modecaps |= 1 << IEEE80211_MODE_11A;
356 --- a/net80211/_ieee80211.h
357 +++ b/net80211/_ieee80211.h
358 @@ -132,6 +132,11 @@
359 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
360 };
361
362 +enum ieee80211_scanflags {
363 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
364 + IEEE80211_NOSCAN_SET = (1 << 1),
365 +};
366 +
367 /*
368 * Channels are specified by frequency and attributes.
369 */
370 @@ -142,6 +147,7 @@
371 int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
372 int8_t ic_maxpower; /* maximum tx power in dBm */
373 int8_t ic_minpower; /* minimum tx power in dBm */
374 + u_int8_t ic_scanflags;
375 };
376
377 #define IEEE80211_CHAN_MAX 255
378 --- a/net80211/ieee80211_ioctl.h
379 +++ b/net80211/ieee80211_ioctl.h
380 @@ -555,6 +555,7 @@
381 #define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
382 #define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
383 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
384 +#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
385
386 enum {
387 IEEE80211_WMMPARAMS_CWMIN = 1,
388 --- a/net80211/ieee80211_scan_ap.c
389 +++ b/net80211/ieee80211_scan_ap.c
390 @@ -129,131 +129,7 @@
391
392 static int ap_flush(struct ieee80211_scan_state *);
393 static void action_tasklet(IEEE80211_TQUEUE_ARG);
394 -static struct ieee80211_channel *find11gchannel(struct ieee80211com *ic,
395 - int i, int freq);
396
397 -static const u_int chanflags[] = {
398 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
399 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
400 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
401 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
402 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
403 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode
404 - * look for AP in
405 - * normal channel
406 - */
407 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
408 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
409 -};
410 -
411 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64,
412 - * 36, 40, 44, 48 */
413 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
414 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
415 -{ 5170, 5190, 5210, 5230 };
416 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
417 -{ 2412, 2437, 2462, 2442, 2472 };
418 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
419 -{ 5745, 5765, 5785, 5805, 5825 };
420 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100, 104, 108, 112,
421 - * 116, 120, 124, 128,
422 - * 132, 136, 140 */
423 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
424 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
425 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
426 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
427 -{ 2484 };
428 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
429 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
430 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
431 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
432 -#ifdef ATH_TURBO_SCAN
433 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
434 -{ 5210, 5250, 5290 };
435 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
436 -{ 5760, 5800 };
437 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
438 -{ 5540, 5580, 5620, 5660 };
439 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
440 -{ 2437 };
441 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
442 -{ 5200, 5240, 5280, 5765, 5805 };
443 -#endif /* ATH_TURBO_SCAN */
444 -
445 -struct scanlist {
446 - u_int16_t mode;
447 - u_int16_t count;
448 - const u_int16_t *list;
449 -};
450 -
451 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
452 -#define X(a) .count = ARRAY_SIZE(a), .list = a
453 -
454 -static const struct scanlist staScanTable[] = {
455 - { IEEE80211_MODE_11B, X(rcl3) },
456 - { IEEE80211_MODE_11A, X(rcl1) },
457 - { IEEE80211_MODE_11A, X(rcl2) },
458 - { IEEE80211_MODE_11B, X(rcl8) },
459 - { IEEE80211_MODE_11B, X(rcl9) },
460 - { IEEE80211_MODE_11A, X(rcl4) },
461 -#ifdef ATH_TURBO_SCAN
462 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
463 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
464 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
465 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
466 -#endif /* ATH_TURBO_SCAN */
467 - { IEEE80211_MODE_11A, X(rcl7) },
468 - { IEEE80211_MODE_11B, X(rcl10) },
469 - { IEEE80211_MODE_11A, X(rcl11) },
470 -#ifdef ATH_TURBO_SCAN
471 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
472 -#endif /* ATH_TURBO_SCAN */
473 - { .list = NULL }
474 -};
475 -
476 -#undef X
477 -/* This function must be invoked with locks acquired */
478 -static void
479 -add_channels(struct ieee80211com *ic,
480 - struct ieee80211_scan_state *ss,
481 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
482 -{
483 - struct ieee80211_channel *c, *cg;
484 - u_int modeflags;
485 - int i;
486 -
487 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
488 - modeflags = chanflags[mode];
489 - for (i = 0; i < nfreq; i++) {
490 - c = ieee80211_find_channel(ic, freq[i], modeflags);
491 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
492 - continue;
493 - if (mode == IEEE80211_MODE_AUTO) {
494 - /* XXX special-case 11b/g channels so we select
495 - * the g channel if both are present. */
496 - if (IEEE80211_IS_CHAN_B(c) &&
497 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
498 - c = cg;
499 - }
500 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
501 - break;
502 - ss->ss_chans[ss->ss_last++] = c;
503 - }
504 -}
505 -
506 -/* This function must be invoked with locks acquired */
507 -static int
508 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
509 -{
510 - int i;
511 -
512 - for (; scan->list != NULL; scan++) {
513 - for (i = 0; i < scan->count; i++)
514 - if (scan->list[i] == c->ic_freq)
515 - return 1;
516 - }
517 - return 0;
518 -}
519
520 /*
521 * Attach prior to any scanning work.
522 @@ -327,29 +203,6 @@
523 ieee80211_saveie(iep, ie);
524 }
525
526 -/* This function must be invoked with locks acquired */
527 -static struct ieee80211_channel *
528 -find11gchannel(struct ieee80211com *ic, int i, int freq)
529 -{
530 - struct ieee80211_channel *c;
531 - int j;
532 -
533 - /* The normal ordering in the channel list is b channel
534 - * immediately followed by g so optimize the search for
535 - * this. We'll still do a full search just in case. */
536 - for (j = i + 1; j < ic->ic_nchans; j++) {
537 - c = &ic->ic_channels[j];
538 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
539 - return c;
540 - }
541 - for (j = 0; j < i; j++) {
542 - c = &ic->ic_channels[j];
543 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
544 - return c;
545 - }
546 - return NULL;
547 -}
548 -
549 /*
550 * Start an ap scan by populating the channel list.
551 */
552 @@ -358,8 +211,6 @@
553 {
554 struct ap_state *as = ss->ss_priv;
555 struct ieee80211com *ic = NULL;
556 - const struct scanlist *sl = NULL;
557 - struct ieee80211_channel *c = NULL;
558 int i;
559 unsigned int mode = 0;
560
561 @@ -368,80 +219,8 @@
562 /* Determine mode flags to match, or leave zero for auto mode */
563 as->as_vap_desired_mode = vap->iv_des_mode;
564 as->as_required_mode = 0;
565 - if (as->as_vap_desired_mode != IEEE80211_MODE_AUTO) {
566 - as->as_required_mode = chanflags[as->as_vap_desired_mode];
567 - if ((vap->iv_ath_cap & IEEE80211_ATHC_TURBOP) &&
568 - (as->as_required_mode != IEEE80211_CHAN_ST)) {
569 - /* Fixup for dynamic turbo flags */
570 - if (as->as_vap_desired_mode == IEEE80211_MODE_11G)
571 - as->as_required_mode = IEEE80211_CHAN_108G;
572 - else
573 - as->as_required_mode = IEEE80211_CHAN_108A;
574 - }
575 - }
576 -
577 - ss->ss_last = 0;
578 - /* Use the table of ordered channels to construct the list
579 - * of channels for scanning. Any channels in the ordered
580 - * list not in the master list will be discarded. */
581 - for (sl = staScanTable; sl->list != NULL; sl++) {
582 - mode = sl->mode;
583 -
584 - /* The scan table marks 2.4Ghz channels as b
585 - * so if the desired mode is 11g, then use
586 - * the 11b channel list but upgrade the mode. */
587 - if (as->as_vap_desired_mode &&
588 - (as->as_vap_desired_mode != mode) &&
589 - (as->as_vap_desired_mode == IEEE80211_MODE_11G) &&
590 - (mode == IEEE80211_MODE_11B))
591 - mode = IEEE80211_MODE_11G;
592 -
593 - /* If we are in "AUTO" mode, upgrade the mode to auto.
594 - * This lets add_channels upgrade an 11b channel to
595 - * 11g if available. */
596 - if (!as->as_vap_desired_mode && (mode == IEEE80211_MODE_11B))
597 - mode = IEEE80211_MODE_AUTO;
598 -
599 - /* Add the list of the channels; any that are not
600 - * in the master channel list will be discarded. */
601 - add_channels(ic, ss, mode, sl->list, sl->count);
602 - }
603 -
604 - /* Add the channels from the ic (from HAL) that are not present
605 - * in the staScanTable, assuming they pass the sanity checks... */
606 - for (i = 0; i < ic->ic_nchans; i++) {
607 - c = &ic->ic_channels[i];
608 -
609 - /* XR is not supported on turbo channels */
610 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
611 - continue;
612 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
613
614 - /* Dynamic channels are scanned in base mode */
615 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
616 - continue;
617 -
618 - /* Use any 11g channel instead of 11b one. */
619 - if (vap->iv_des_mode == IEEE80211_MODE_AUTO &&
620 - IEEE80211_IS_CHAN_B(c) &&
621 - find11gchannel(ic, i, c->ic_freq))
622 - continue;
623 -
624 - /* Do not add channels already put into the scan list by the
625 - * scan table - these have already been filtered by mode
626 - * and for whether they are in the active channel list. */
627 - if (checktable(staScanTable, c))
628 - continue;
629 -
630 - /* Make sure the channel is active */
631 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
632 - continue;
633 -
634 - /* Don't overrun */
635 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
636 - break;
637 -
638 - ss->ss_chans[ss->ss_last++] = c;
639 - }
640 ss->ss_next = 0;
641 /* XXX tunables */
642 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
643 @@ -761,13 +540,6 @@
644 if (IEEE80211_IS_CHAN_RADAR(c->chan))
645 continue;
646
647 - /* Do not select 802.11a ST if mode is specified and is not
648 - * 802.11a ST */
649 - if (as->as_required_mode &&
650 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
651 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
652 - continue;
653 -
654 /* Verify mode matches any fixed mode specified */
655 if((c->chan->ic_flags & as->as_required_mode) !=
656 as->as_required_mode)
657 --- a/net80211/ieee80211_scan.c
658 +++ b/net80211/ieee80211_scan.c
659 @@ -958,6 +958,80 @@
660 }
661 }
662
663 +static const u_int chanflags[] = {
664 + 0, /* IEEE80211_MODE_AUTO */
665 + IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
666 + IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
667 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
668 + IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
669 + IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
670 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
671 + IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
672 +};
673 +
674 +static struct ieee80211_channel *
675 +find11gchannel(struct ieee80211com *ic, int i, int freq)
676 +{
677 + struct ieee80211_channel *c;
678 + int j;
679 +
680 + /*
681 + * The normal ordering in the channel list is b channel
682 + * immediately followed by g so optimize the search for
683 + * this. We'll still do a full search just in case.
684 + */
685 + for (j = i+1; j < ic->ic_nchans; j++) {
686 + c = &ic->ic_channels[j];
687 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
688 + return c;
689 + }
690 + for (j = 0; j < i; j++) {
691 + c = &ic->ic_channels[j];
692 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
693 + return c;
694 + }
695 + return NULL;
696 +}
697 +
698 +
699 +void
700 +ieee80211_scan_add_channels(struct ieee80211com *ic,
701 + struct ieee80211_scan_state *ss,
702 + enum ieee80211_phymode mode)
703 +{
704 + struct ieee80211_channel *c, *cg;
705 + u_int modeflags;
706 + int i;
707 +
708 + KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
709 + modeflags = chanflags[mode];
710 + for (i = 0; i < ic->ic_nchans; i++) {
711 + c = &ic->ic_channels[i];
712 + if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
713 + continue;
714 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
715 + continue;
716 + if (modeflags &&
717 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
718 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
719 + continue;
720 + if (mode == IEEE80211_MODE_AUTO) {
721 + /*
722 + * XXX special-case 11b/g channels so we select
723 + * the g channel if both are present.
724 + */
725 + if (IEEE80211_IS_CHAN_B(c) &&
726 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
727 + continue;
728 + }
729 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
730 + break;
731 + ss->ss_chans[ss->ss_last++] = c;
732 + }
733 +}
734 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
735 +
736 +
737 /*
738 * Execute radar channel change. This is called when a radar/dfs
739 * signal is detected. AP mode only. Return 1 on success, 0 on
740 --- a/net80211/ieee80211_scan.h
741 +++ b/net80211/ieee80211_scan.h
742 @@ -219,4 +219,7 @@
743 void ieee80211_scanner_unregister(enum ieee80211_opmode,
744 const struct ieee80211_scanner *);
745 void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
746 +void ieee80211_scan_add_channels(struct ieee80211com *ic,
747 + struct ieee80211_scan_state *ss,
748 + enum ieee80211_phymode mode);
749 #endif /* _NET80211_IEEE80211_SCAN_H_ */
750 --- a/net80211/ieee80211_wireless.c
751 +++ b/net80211/ieee80211_wireless.c
752 @@ -3873,6 +3873,106 @@
753 return ieee80211_ioctl_setmlme(dev, info, w, (char *)&mlme);
754 }
755
756 +static inline void setflag(struct ieee80211_channel *c, int flag)
757 +{
758 + if (flag)
759 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
760 + else
761 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
762 +}
763 +
764 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
765 +{
766 + int i;
767 +
768 + for (i = 0; i < ic->ic_nchans; i++) {
769 + struct ieee80211_channel *c = &ic->ic_channels[i];
770 +
771 + if (min == -1) {
772 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
773 + setflag(c, set);
774 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
775 + setflag(c, set);
776 + }
777 + }
778 +}
779 +
780 +static int
781 +ieee80211_ioctl_setscanlist(struct net_device *dev,
782 + struct iw_request_info *info,
783 + struct iw_point *data, char *extra)
784 +{
785 + struct ieee80211vap *vap = dev->priv;
786 + struct ieee80211com *ic = vap->iv_ic;
787 + char *s, *next;
788 + int val = 1;
789 +
790 + if (data->length <= 0)
791 + return -EINVAL;
792 +
793 + s = kmalloc(data->length + 1, GFP_KERNEL);
794 + if (!s)
795 + return -ENOMEM;
796 +
797 + memset(s, 0, data->length + 1);
798 + if (copy_from_user(s, data->pointer, data->length))
799 + return -EFAULT;
800 +
801 + s[data->length - 1] = '\0'; /* ensure null termination */
802 +
803 + switch(*s) {
804 + case '-':
805 + val = 1;
806 + break;
807 + case '+':
808 + val = 0;
809 + break;
810 + default:
811 + goto error;
812 + }
813 + s++;
814 + next = s;
815 + do {
816 + next = strchr(s, ',');
817 + if (next) {
818 + *next = 0;
819 + next++;
820 + }
821 + if (!strcmp(s, "ALL")) {
822 + setscanflag(ic, 0, 10000, val);
823 + } else if (!strcmp(s, "REG")) {
824 + setscanflag(ic, -1, -1, val);
825 + } else {
826 + int min, max;
827 + char *n, *end = NULL;
828 +
829 + n = strchr(s, '-');
830 + if (n) {
831 + *n = 0;
832 + n++;
833 + }
834 + min = simple_strtoul(s, &end, 10);
835 + if (end && *end)
836 + goto error;
837 + if (n) {
838 + max = simple_strtoul(n, &end, 10);
839 + if (end && *end)
840 + goto error;
841 + } else {
842 + max = min;
843 + }
844 + setscanflag(ic, min, max, val);
845 + }
846 + s = next;
847 + } while (next);
848 + return 0;
849 +
850 +error:
851 + if (s)
852 + kfree(s);
853 + return -EINVAL;
854 +}
855 +
856 static int
857 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info,
858 void *w, char *extra)
859 @@ -5656,6 +5756,8 @@
860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "minrate"},
861 {IEEE80211_PARAM_MINRATE,
862 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
863 + { IEEE80211_IOCTL_SETSCANLIST,
864 + IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
865
866 #ifdef ATH_REVERSE_ENGINEERING
867 /*
868 @@ -5753,6 +5855,7 @@
869 set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
870 set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
871 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
872 + set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
873 #ifdef ATH_REVERSE_ENGINEERING
874 set_priv(IEEE80211_IOCTL_READREG, ieee80211_ioctl_readreg),
875 set_priv(IEEE80211_IOCTL_WRITEREG, ieee80211_ioctl_writereg),
This page took 0.112785 seconds and 5 git commands to generate.