Update GPIO-based MMC driver
[openwrt.git] / package / madwifi / patches-r3776 / 315-scanlist.patch
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
5 @@ -318,147 +318,6 @@
6 #undef ISPROBE
7 }
8
9 -static struct ieee80211_channel *
10 -find11gchannel(struct ieee80211com *ic, int i, int freq)
11 -{
12 - struct ieee80211_channel *c;
13 - int j;
14 -
15 - /*
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.
19 - */
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))
23 - return c;
24 - }
25 - for (j = 0; j < i; j++) {
26 - c = &ic->ic_channels[j];
27 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
28 - return c;
29 - }
30 - return NULL;
31 -}
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 */
41 -};
42 -
43 -static void
44 -add_channels(struct ieee80211com *ic,
45 - struct ieee80211_scan_state *ss,
46 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
47 -{
48 - struct ieee80211_channel *c, *cg;
49 - u_int modeflags;
50 - int i;
51 -
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))
57 - continue;
58 - if (mode == IEEE80211_MODE_AUTO) {
59 - /*
60 - * XXX special-case 11b/g channels so we select
61 - * the g channel if both are present.
62 - */
63 - if (IEEE80211_IS_CHAN_B(c) &&
64 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
65 - c = cg;
66 - }
67 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
68 - break;
69 - ss->ss_chans[ss->ss_last++] = c;
70 - }
71 -}
72 -
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 */
86 -{ 2484 };
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 */
95 -{ 5760, 5800 };
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 */
99 -{ 2437 };
100 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
101 -{ 5200, 5240, 5280, 5765, 5805 };
102 -#endif /* ATH_TURBO_SCAN */
103 -
104 -struct scanlist {
105 - u_int16_t mode;
106 - u_int16_t count;
107 - const u_int16_t *list;
108 -};
109 -
110 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
111 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
112 -
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 */
132 - { .list = NULL }
133 -};
134 -
135 -#undef X
136 -
137 -static int
138 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
139 -{
140 - int i;
141 -
142 - for (; scan->list != NULL; scan++) {
143 - for (i = 0; i < scan->count; i++)
144 - if (scan->list[i] == c->ic_freq)
145 - return 1;
146 - }
147 - return 0;
148 -}
149 -
150 /*
151 * Start a station-mode scan by populating the channel list.
152 */
153 @@ -467,81 +326,11 @@
154 {
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;
160 - int i;
161
162 ss->ss_last = 0;
163 - /*
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.
167 - */
168 - for (scan = staScanTable; scan->list != NULL; scan++) {
169 - mode = scan->mode;
170 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
171 - /*
172 - * If a desired mode was specified, scan only
173 - * channels that satisfy that constraint.
174 - */
175 - if (vap->iv_des_mode != mode) {
176 - /*
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.
180 - */
181 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
182 - mode != IEEE80211_MODE_11B)
183 - continue;
184 - mode = IEEE80211_MODE_11G; /* upgrade */
185 - }
186 - } else {
187 - /*
188 - * This lets ieee80211_scan_add_channels
189 - * upgrade an 11b channel to 11g if available.
190 - */
191 - if (mode == IEEE80211_MODE_11B)
192 - mode = IEEE80211_MODE_AUTO;
193 - }
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))
198 - continue;
199 - /*
200 - * Add the list of the channels; any that are not
201 - * in the master channel list will be discarded.
202 - */
203 - add_channels(ic, ss, mode, scan->list, scan->count);
204 - }
205 -
206 - /*
207 - * Add the channels from the ic (from HAL) that are not present
208 - * in the staScanTable.
209 - */
210 - for (i = 0; i < ic->ic_nchans; i++) {
211 - c = &ic->ic_channels[i];
212 - /*
213 - * scan dynamic turbo channels in normal mode.
214 - */
215 - if (IEEE80211_IS_CHAN_DTURBO(c))
216 - continue;
217 - mode = ieee80211_chan2mode(c);
218 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
219 - /*
220 - * If a desired mode was specified, scan only
221 - * channels that satisfy that constraint.
222 - */
223 - if (vap->iv_des_mode != mode)
224 - continue;
225 -
226 - }
227 - if (!checktable(staScanTable, c))
228 - ss->ss_chans[ss->ss_last++] = c;
229 - }
230 -
231 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
232 ss->ss_next = 0;
233 +
234 /* XXX tunables */
235 /*
236 * The scanner will stay on station for ss_maxdwell ms (using a
237 @@ -750,17 +539,7 @@
238 fail = 0;
239 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
240 fail |= 0x01;
241 - /*
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
246 - * out.
247 - */
248 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
249 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
250 - chanflags[vap->iv_des_mode])
251 - fail |= 0x01;
252 +
253 if (vap->iv_opmode == IEEE80211_M_IBSS) {
254 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
255 fail |= 0x02;
256 @@ -1175,78 +954,6 @@
257 .scan_default = ieee80211_sta_join,
258 };
259
260 -/*
261 - * Start an adhoc-mode scan by populating the channel list.
262 - */
263 -static int
264 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
265 -{
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;
270 -
271 - ss->ss_last = 0;
272 - /*
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.
276 - */
277 - for (scan = staScanTable; scan->list != NULL; scan++) {
278 - mode = scan->mode;
279 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
280 - /*
281 - * If a desired mode was specified, scan only
282 - * channels that satisfy that constraint.
283 - */
284 - if (vap->iv_des_mode != mode) {
285 - /*
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.
289 - */
290 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
291 - mode != IEEE80211_MODE_11B)
292 - continue;
293 - mode = IEEE80211_MODE_11G; /* upgrade */
294 - }
295 - } else {
296 - /*
297 - * This lets ieee80211_scan_add_channels
298 - * upgrade an 11b channel to 11g if available.
299 - */
300 - if (mode == IEEE80211_MODE_11B)
301 - mode = IEEE80211_MODE_AUTO;
302 - }
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))
307 - continue;
308 - /*
309 - * Add the list of the channels; any that are not
310 - * in the master channel list will be discarded.
311 - */
312 - add_channels(ic, ss, mode, scan->list, scan->count);
313 - }
314 - ss->ss_next = 0;
315 - /* XXX tunables */
316 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
317 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
318 -
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);
325 - }
326 -#endif /* IEEE80211_DEBUG */
327 -
328 - st->st_newscan = 1;
329 -
330 - return 0;
331 -}
332
333 /*
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
348 @@ -292,6 +292,11 @@
349 ("channel with bogus ieee number %u", c->ic_ieee));
350 setbit(ic->ic_chan_avail, c->ic_ieee);
351
352 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
353 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
354 + else
355 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
356 +
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
364 @@ -132,6 +132,11 @@
365 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
366 };
367
368 +enum ieee80211_scanflags {
369 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
370 + IEEE80211_NOSCAN_SET = (1 << 1),
371 +};
372 +
373 /*
374 * Channels are specified by frequency and attributes.
375 */
376 @@ -142,6 +147,7 @@
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;
381 };
382
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
388 @@ -556,6 +556,7 @@
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)
393
394 enum {
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 @@
401
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,
405 - int i, int freq);
406
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
414 - * look for AP in
415 - * normal channel
416 - */
417 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
418 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
419 -};
420 -
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,
432 - * 132, 136, 140 */
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 */
437 -{ 2484 };
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 */
446 -{ 5760, 5800 };
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 */
450 -{ 2437 };
451 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
452 -{ 5200, 5240, 5280, 5765, 5805 };
453 -#endif /* ATH_TURBO_SCAN */
454 -
455 -struct scanlist {
456 - u_int16_t mode;
457 - u_int16_t count;
458 - const u_int16_t *list;
459 -};
460 -
461 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
462 -#define X(a) .count = ARRAY_SIZE(a), .list = a
463 -
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 */
483 - { .list = NULL }
484 -};
485 -
486 -#undef X
487 -/* This function must be invoked with locks acquired */
488 -static void
489 -add_channels(struct ieee80211com *ic,
490 - struct ieee80211_scan_state *ss,
491 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
492 -{
493 - struct ieee80211_channel *c, *cg;
494 - u_int modeflags;
495 - int i;
496 -
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))
502 - continue;
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)
508 - c = cg;
509 - }
510 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
511 - break;
512 - ss->ss_chans[ss->ss_last++] = c;
513 - }
514 -}
515 -
516 -/* This function must be invoked with locks acquired */
517 -static int
518 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
519 -{
520 - int i;
521 -
522 - for (; scan->list != NULL; scan++) {
523 - for (i = 0; i < scan->count; i++)
524 - if (scan->list[i] == c->ic_freq)
525 - return 1;
526 - }
527 - return 0;
528 -}
529
530 /*
531 * Attach prior to any scanning work.
532 @@ -398,29 +274,6 @@
533 ieee80211_saveie(iep, ie);
534 }
535
536 -/* This function must be invoked with locks acquired */
537 -static struct ieee80211_channel *
538 -find11gchannel(struct ieee80211com *ic, int i, int freq)
539 -{
540 - struct ieee80211_channel *c;
541 - int j;
542 -
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))
549 - return c;
550 - }
551 - for (j = 0; j < i; j++) {
552 - c = &ic->ic_channels[j];
553 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
554 - return c;
555 - }
556 - return NULL;
557 -}
558 -
559 /*
560 * Start an ap scan by populating the channel list.
561 */
562 @@ -429,90 +282,14 @@
563 {
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;
568 - int i;
569 - unsigned int mode = 0;
570
571 SCAN_AP_LOCK_IRQ(as);
572 ic = vap->iv_ic;
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;
583 - else
584 - as->as_required_mode = IEEE80211_CHAN_108A;
585 - }
586 - }
587 -
588 - ss->ss_last = 0;
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++) {
593 - mode = sl->mode;
594 -
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;
603 -
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;
609 -
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);
613 - }
614 -
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];
619 -
620 - /* XR is not supported on turbo channels */
621 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
622 - continue;
623 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
624
625 - /* Dynamic channels are scanned in base mode */
626 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
627 - continue;
628 -
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))
633 - continue;
634 -
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))
639 - continue;
640 -
641 - /* Make sure the channel is active */
642 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
643 - continue;
644 -
645 - /* Don't overrun */
646 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
647 - break;
648 -
649 - ss->ss_chans[ss->ss_last++] = c;
650 - }
651 ss->ss_next = 0;
652 /* XXX tunables */
653 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
654 @@ -834,13 +611,6 @@
655 if (IEEE80211_IS_CHAN_RADAR(c->chan))
656 continue;
657
658 - /* Do not select 802.11a ST if mode is specified and is not
659 - * 802.11a ST */
660 - if (as->as_required_mode &&
661 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
662 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
663 - continue;
664 -
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
672 @@ -969,6 +969,80 @@
673 }
674 }
675
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 */
685 +};
686 +
687 +static struct ieee80211_channel *
688 +find11gchannel(struct ieee80211com *ic, int i, int freq)
689 +{
690 + struct ieee80211_channel *c;
691 + int j;
692 +
693 + /*
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.
697 + */
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))
701 + return c;
702 + }
703 + for (j = 0; j < i; j++) {
704 + c = &ic->ic_channels[j];
705 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
706 + return c;
707 + }
708 + return NULL;
709 +}
710 +
711 +
712 +void
713 +ieee80211_scan_add_channels(struct ieee80211com *ic,
714 + struct ieee80211_scan_state *ss,
715 + enum ieee80211_phymode mode)
716 +{
717 + struct ieee80211_channel *c, *cg;
718 + u_int modeflags;
719 + int i;
720 +
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))
726 + continue;
727 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
728 + continue;
729 + if (modeflags &&
730 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
731 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
732 + continue;
733 + if (mode == IEEE80211_MODE_AUTO) {
734 + /*
735 + * XXX special-case 11b/g channels so we select
736 + * the g channel if both are present.
737 + */
738 + if (IEEE80211_IS_CHAN_B(c) &&
739 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
740 + continue;
741 + }
742 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
743 + break;
744 + ss->ss_chans[ss->ss_last++] = c;
745 + }
746 +}
747 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
748 +
749 +
750 /*
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
757 @@ -219,4 +219,7 @@
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);
771 }
772
773 +static inline void setflag(struct ieee80211_channel *c, int flag)
774 +{
775 + if (flag)
776 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
777 + else
778 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
779 +}
780 +
781 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
782 +{
783 + int i;
784 +
785 + for (i = 0; i < ic->ic_nchans; i++) {
786 + struct ieee80211_channel *c = &ic->ic_channels[i];
787 +
788 + if (min == -1) {
789 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
790 + setflag(c, set);
791 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
792 + setflag(c, set);
793 + }
794 + }
795 +}
796 +
797 +static int
798 +ieee80211_ioctl_setscanlist(struct net_device *dev,
799 + struct iw_request_info *info,
800 + struct iw_point *data, char *extra)
801 +{
802 + struct ieee80211vap *vap = dev->priv;
803 + struct ieee80211com *ic = vap->iv_ic;
804 + char *s, *next;
805 + int val = 1;
806 +
807 + if (data->length <= 0)
808 + return -EINVAL;
809 +
810 + s = kmalloc(data->length + 1, GFP_KERNEL);
811 + if (!s)
812 + return -ENOMEM;
813 +
814 + memset(s, 0, data->length + 1);
815 + if (copy_from_user(s, data->pointer, data->length))
816 + return -EFAULT;
817 +
818 + s[data->length - 1] = '\0'; /* ensure null termination */
819 +
820 + switch(*s) {
821 + case '-':
822 + val = 1;
823 + break;
824 + case '+':
825 + val = 0;
826 + break;
827 + default:
828 + goto error;
829 + }
830 + s++;
831 + next = s;
832 + do {
833 + next = strchr(s, ',');
834 + if (next) {
835 + *next = 0;
836 + next++;
837 + }
838 + if (!strcmp(s, "ALL")) {
839 + setscanflag(ic, 0, 10000, val);
840 + } else if (!strcmp(s, "REG")) {
841 + setscanflag(ic, -1, -1, val);
842 + } else {
843 + int min, max;
844 + char *n, *end = NULL;
845 +
846 + n = strchr(s, '-');
847 + if (n) {
848 + *n = 0;
849 + n++;
850 + }
851 + min = simple_strtoul(s, &end, 10);
852 + if (end && *end)
853 + goto error;
854 + if (n) {
855 + max = simple_strtoul(n, &end, 10);
856 + if (end && *end)
857 + goto error;
858 + } else {
859 + max = min;
860 + }
861 + setscanflag(ic, min, max, val);
862 + }
863 + s = next;
864 + } while (next);
865 + return 0;
866 +
867 +error:
868 + if (s)
869 + kfree(s);
870 + return -EINVAL;
871 +}
872 +
873 static int
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"},
882
883 #ifdef ATH_REVERSE_ENGINEERING
884 /*
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),
This page took 0.081425 seconds and 5 git commands to generate.