blob: 3b0bee331a3350634c3179e86888900e562075c5 [file] [log] [blame]
Tomas Winkler2a421b92008-06-12 09:47:10 +08001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Tomas Winkler <tomas.winkler@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28#include <net/mac80211.h>
29#include <linux/etherdevice.h>
30
31#include "iwl-eeprom.h"
32#include "iwl-dev.h"
33#include "iwl-core.h"
34#include "iwl-sta.h"
35#include "iwl-io.h"
36#include "iwl-helpers.h"
37
38/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
39 * sending probe req. This should be set long enough to hear probe responses
40 * from more than one AP. */
Tomas Winklerfe905f12008-07-11 11:53:39 +080041#define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */
42#define IWL_ACTIVE_DWELL_TIME_52 (20)
43
44#define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3)
45#define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2)
Tomas Winkler2a421b92008-06-12 09:47:10 +080046
47/* For faster active scanning, scan will move to the next channel if fewer than
48 * PLCP_QUIET_THRESH packets are heard on this channel within
49 * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
50 * time if it's a quiet channel (nothing responded to our probe, and there's
51 * no other traffic).
52 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
53#define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */
Tomas Winklerfe905f12008-07-11 11:53:39 +080054#define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */
Tomas Winkler2a421b92008-06-12 09:47:10 +080055
56/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel.
57 * Must be set longer than active dwell time.
58 * For the most reliable scan, set > AP beacon interval (typically 100msec). */
59#define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */
60#define IWL_PASSIVE_DWELL_TIME_52 (10)
61#define IWL_PASSIVE_DWELL_BASE (100)
62#define IWL_CHANNEL_TUNE_TIME 5
63
Tomas Winklerfe905f12008-07-11 11:53:39 +080064#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
65
66
Tomas Winklerf53696d2008-06-12 09:47:12 +080067static int scan_tx_ant[3] = {
68 RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK
69};
Tomas Winkler2a421b92008-06-12 09:47:10 +080070
Tomas Winklerfe905f12008-07-11 11:53:39 +080071
72
Tomas Winkler2a421b92008-06-12 09:47:10 +080073static int iwl_is_empty_essid(const char *essid, int essid_len)
74{
75 /* Single white space is for Linksys APs */
76 if (essid_len == 1 && essid[0] == ' ')
77 return 1;
78
79 /* Otherwise, if the entire essid is 0, we assume it is hidden */
80 while (essid_len) {
81 essid_len--;
82 if (essid[essid_len] != '\0')
83 return 0;
84 }
85
86 return 1;
87}
88
89
90
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +080091static const char *iwl_escape_essid(const char *essid, u8 essid_len)
Tomas Winkler2a421b92008-06-12 09:47:10 +080092{
93 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
94 const char *s = essid;
95 char *d = escaped;
96
97 if (iwl_is_empty_essid(essid, essid_len)) {
98 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
99 return escaped;
100 }
101
102 essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
103 while (essid_len--) {
104 if (*s == '\0') {
105 *d++ = '\\';
106 *d++ = '0';
107 s++;
108 } else
109 *d++ = *s++;
110 }
111 *d = '\0';
112 return escaped;
113}
Tomas Winkler2a421b92008-06-12 09:47:10 +0800114
115/**
116 * iwl_scan_cancel - Cancel any currently executing HW scan
117 *
118 * NOTE: priv->mutex is not required before calling this function
119 */
120int iwl_scan_cancel(struct iwl_priv *priv)
121{
122 if (!test_bit(STATUS_SCAN_HW, &priv->status)) {
123 clear_bit(STATUS_SCANNING, &priv->status);
124 return 0;
125 }
126
127 if (test_bit(STATUS_SCANNING, &priv->status)) {
128 if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
129 IWL_DEBUG_SCAN("Queuing scan abort.\n");
130 set_bit(STATUS_SCAN_ABORTING, &priv->status);
131 queue_work(priv->workqueue, &priv->abort_scan);
132
133 } else
134 IWL_DEBUG_SCAN("Scan abort already in progress.\n");
135
136 return test_bit(STATUS_SCANNING, &priv->status);
137 }
138
139 return 0;
140}
141EXPORT_SYMBOL(iwl_scan_cancel);
142/**
143 * iwl_scan_cancel_timeout - Cancel any currently executing HW scan
144 * @ms: amount of time to wait (in milliseconds) for scan to abort
145 *
146 * NOTE: priv->mutex must be held before calling this function
147 */
148int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
149{
150 unsigned long now = jiffies;
151 int ret;
152
153 ret = iwl_scan_cancel(priv);
154 if (ret && ms) {
155 mutex_unlock(&priv->mutex);
156 while (!time_after(jiffies, now + msecs_to_jiffies(ms)) &&
157 test_bit(STATUS_SCANNING, &priv->status))
158 msleep(1);
159 mutex_lock(&priv->mutex);
160
161 return test_bit(STATUS_SCANNING, &priv->status);
162 }
163
164 return ret;
165}
166EXPORT_SYMBOL(iwl_scan_cancel_timeout);
167
168static int iwl_send_scan_abort(struct iwl_priv *priv)
169{
170 int ret = 0;
171 struct iwl_rx_packet *res;
172 struct iwl_host_cmd cmd = {
173 .id = REPLY_SCAN_ABORT_CMD,
174 .meta.flags = CMD_WANT_SKB,
175 };
176
177 /* If there isn't a scan actively going on in the hardware
178 * then we are in between scan bands and not actually
179 * actively scanning, so don't send the abort command */
180 if (!test_bit(STATUS_SCAN_HW, &priv->status)) {
181 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
182 return 0;
183 }
184
185 ret = iwl_send_cmd_sync(priv, &cmd);
186 if (ret) {
187 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
188 return ret;
189 }
190
191 res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
192 if (res->u.status != CAN_ABORT_STATUS) {
193 /* The scan abort will return 1 for success or
194 * 2 for "failure". A failure condition can be
195 * due to simply not being in an active scan which
196 * can occur if we send the scan abort before we
197 * the microcode has notified us that a scan is
198 * completed. */
199 IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status);
200 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
201 clear_bit(STATUS_SCAN_HW, &priv->status);
202 }
203
Emmanuel Grumbach14652562008-08-04 16:00:46 +0800204 priv->alloc_rxb_skb--;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800205 dev_kfree_skb_any(cmd.meta.u.skb);
206
207 return ret;
208}
209
210
211/* Service response to REPLY_SCAN_CMD (0x80) */
212static void iwl_rx_reply_scan(struct iwl_priv *priv,
213 struct iwl_rx_mem_buffer *rxb)
214{
215#ifdef CONFIG_IWLWIFI_DEBUG
216 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
217 struct iwl_scanreq_notification *notif =
218 (struct iwl_scanreq_notification *)pkt->u.raw;
219
220 IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status);
221#endif
222}
223
224/* Service SCAN_START_NOTIFICATION (0x82) */
225static void iwl_rx_scan_start_notif(struct iwl_priv *priv,
226 struct iwl_rx_mem_buffer *rxb)
227{
228 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
229 struct iwl_scanstart_notification *notif =
230 (struct iwl_scanstart_notification *)pkt->u.raw;
231 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
232 IWL_DEBUG_SCAN("Scan start: "
233 "%d [802.11%s] "
234 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
235 notif->channel,
236 notif->band ? "bg" : "a",
Tomas Winklerfe905f12008-07-11 11:53:39 +0800237 le32_to_cpu(notif->tsf_high),
238 le32_to_cpu(notif->tsf_low),
239 notif->status, notif->beacon_timer);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800240}
241
242/* Service SCAN_RESULTS_NOTIFICATION (0x83) */
243static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
244 struct iwl_rx_mem_buffer *rxb)
245{
246#ifdef CONFIG_IWLWIFI_DEBUG
247 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
248 struct iwl_scanresults_notification *notif =
249 (struct iwl_scanresults_notification *)pkt->u.raw;
250
251 IWL_DEBUG_SCAN("Scan ch.res: "
252 "%d [802.11%s] "
253 "(TSF: 0x%08X:%08X) - %d "
254 "elapsed=%lu usec (%dms since last)\n",
255 notif->channel,
256 notif->band ? "bg" : "a",
257 le32_to_cpu(notif->tsf_high),
258 le32_to_cpu(notif->tsf_low),
259 le32_to_cpu(notif->statistics[0]),
260 le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf,
261 jiffies_to_msecs(elapsed_jiffies
262 (priv->last_scan_jiffies, jiffies)));
263#endif
264
265 priv->last_scan_jiffies = jiffies;
266 priv->next_scan_jiffies = 0;
267}
268
269/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
270static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
271 struct iwl_rx_mem_buffer *rxb)
272{
Denis V. Lunevcb9289c2008-07-18 10:56:12 +0400273#ifdef CONFIG_IWLWIFI_DEBUG
Tomas Winkler2a421b92008-06-12 09:47:10 +0800274 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
275 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
276
277 IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
278 scan_notif->scanned_channels,
279 scan_notif->tsf_low,
280 scan_notif->tsf_high, scan_notif->status);
Denis V. Lunevcb9289c2008-07-18 10:56:12 +0400281#endif
Tomas Winkler2a421b92008-06-12 09:47:10 +0800282
283 /* The HW is no longer scanning */
284 clear_bit(STATUS_SCAN_HW, &priv->status);
285
286 /* The scan completion notification came in, so kill that timer... */
287 cancel_delayed_work(&priv->scan_check);
288
289 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n",
David S. Miller1b63ba82008-06-28 01:19:40 -0700290 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
291 "2.4" : "5.2",
Tomas Winkler2a421b92008-06-12 09:47:10 +0800292 jiffies_to_msecs(elapsed_jiffies
293 (priv->scan_pass_start, jiffies)));
294
David S. Miller1b63ba82008-06-28 01:19:40 -0700295 /* Remove this scanned band from the list of pending
296 * bands to scan, band G precedes A in order of scanning
297 * as seen in iwl_bg_request_scan */
298 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ))
299 priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ);
300 else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ))
301 priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800302
303 /* If a request to abort was given, or the scan did not succeed
304 * then we reset the scan state machine and terminate,
305 * re-queuing another scan if one has been requested */
306 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
307 IWL_DEBUG_INFO("Aborted scan completed.\n");
308 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
309 } else {
310 /* If there are more bands on this scan pass reschedule */
David S. Miller1b63ba82008-06-28 01:19:40 -0700311 if (priv->scan_bands)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800312 goto reschedule;
313 }
314
315 priv->last_scan_jiffies = jiffies;
316 priv->next_scan_jiffies = 0;
317 IWL_DEBUG_INFO("Setting scan to off\n");
318
319 clear_bit(STATUS_SCANNING, &priv->status);
320
321 IWL_DEBUG_INFO("Scan took %dms\n",
322 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies)));
323
324 queue_work(priv->workqueue, &priv->scan_completed);
325
326 return;
327
328reschedule:
329 priv->scan_pass_start = jiffies;
330 queue_work(priv->workqueue, &priv->request_scan);
331}
332
333void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
334{
335 /* scan handlers */
336 priv->rx_handlers[REPLY_SCAN_CMD] = iwl_rx_reply_scan;
337 priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl_rx_scan_start_notif;
338 priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] =
339 iwl_rx_scan_results_notif;
340 priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] =
341 iwl_rx_scan_complete_notif;
342}
343EXPORT_SYMBOL(iwl_setup_rx_scan_handlers);
344
345static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
Tomas Winklerfe905f12008-07-11 11:53:39 +0800346 enum ieee80211_band band,
347 u8 n_probes)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800348{
349 if (band == IEEE80211_BAND_5GHZ)
Tomas Winklerfe905f12008-07-11 11:53:39 +0800350 return IWL_ACTIVE_DWELL_TIME_52 +
351 IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800352 else
Tomas Winklerfe905f12008-07-11 11:53:39 +0800353 return IWL_ACTIVE_DWELL_TIME_24 +
354 IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800355}
356
357static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
Tomas Winklerfe905f12008-07-11 11:53:39 +0800358 enum ieee80211_band band)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800359{
Tomas Winklerfe905f12008-07-11 11:53:39 +0800360 u16 passive = (band == IEEE80211_BAND_2GHZ) ?
Tomas Winkler2a421b92008-06-12 09:47:10 +0800361 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
362 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
363
364 if (iwl_is_associated(priv)) {
365 /* If we're associated, we clamp the maximum passive
366 * dwell time to be 98% of the beacon interval (minus
367 * 2 * channel tune time) */
368 passive = priv->beacon_int;
369 if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive)
370 passive = IWL_PASSIVE_DWELL_BASE;
371 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
372 }
373
Tomas Winkler2a421b92008-06-12 09:47:10 +0800374 return passive;
375}
376
377static int iwl_get_channels_for_scan(struct iwl_priv *priv,
378 enum ieee80211_band band,
Tomas Winklerfe905f12008-07-11 11:53:39 +0800379 u8 is_active, u8 n_probes,
Tomas Winkler2a421b92008-06-12 09:47:10 +0800380 struct iwl_scan_channel *scan_ch)
381{
382 const struct ieee80211_channel *channels = NULL;
383 const struct ieee80211_supported_band *sband;
384 const struct iwl_channel_info *ch_info;
385 u16 passive_dwell = 0;
386 u16 active_dwell = 0;
387 int added, i;
Tomas Winklerd16dc482008-07-11 11:53:38 +0800388 u16 channel;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800389
390 sband = iwl_get_hw_mode(priv, band);
391 if (!sband)
392 return 0;
393
394 channels = sband->channels;
395
Tomas Winklerfe905f12008-07-11 11:53:39 +0800396 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800397 passive_dwell = iwl_get_passive_dwell_time(priv, band);
398
Tomas Winklerfe905f12008-07-11 11:53:39 +0800399 if (passive_dwell <= active_dwell)
400 passive_dwell = active_dwell + 1;
401
Tomas Winkler2a421b92008-06-12 09:47:10 +0800402 for (i = 0, added = 0; i < sband->n_channels; i++) {
403 if (channels[i].flags & IEEE80211_CHAN_DISABLED)
404 continue;
405
Tomas Winklerd16dc482008-07-11 11:53:38 +0800406 channel =
Tomas Winkler2a421b92008-06-12 09:47:10 +0800407 ieee80211_frequency_to_channel(channels[i].center_freq);
Tomas Winklerd16dc482008-07-11 11:53:38 +0800408 scan_ch->channel = cpu_to_le16(channel);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800409
Tomas Winklerd16dc482008-07-11 11:53:38 +0800410 ch_info = iwl_get_channel_info(priv, band, channel);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800411 if (!is_channel_valid(ch_info)) {
David S. Miller1b63ba82008-06-28 01:19:40 -0700412 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n",
Tomas Winklerd16dc482008-07-11 11:53:38 +0800413 channel);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800414 continue;
415 }
416
417 if (!is_active || is_channel_passive(ch_info) ||
418 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
Tomas Winklerd16dc482008-07-11 11:53:38 +0800419 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800420 else
Tomas Winklerd16dc482008-07-11 11:53:38 +0800421 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800422
Ron Rindjunsky0ffe0142008-09-03 11:18:43 +0800423 if (n_probes)
Tomas Winklerfe905f12008-07-11 11:53:39 +0800424 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800425
426 scan_ch->active_dwell = cpu_to_le16(active_dwell);
427 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
428
429 /* Set txpower levels to defaults */
Tomas Winklerf53696d2008-06-12 09:47:12 +0800430 scan_ch->dsp_atten = 110;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800431
Tomas Winklerfe905f12008-07-11 11:53:39 +0800432 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
433 * power level:
434 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
435 */
Tomas Winkler2a421b92008-06-12 09:47:10 +0800436 if (band == IEEE80211_BAND_5GHZ)
Tomas Winklerf53696d2008-06-12 09:47:12 +0800437 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
Tomas Winklerfe905f12008-07-11 11:53:39 +0800438 else
Tomas Winklerf53696d2008-06-12 09:47:12 +0800439 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
Tomas Winkler2a421b92008-06-12 09:47:10 +0800440
Tomas Winklerfe905f12008-07-11 11:53:39 +0800441 IWL_DEBUG_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n",
442 channel, le32_to_cpu(scan_ch->type),
Tomas Winklerd16dc482008-07-11 11:53:38 +0800443 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
444 "ACTIVE" : "PASSIVE",
445 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
Tomas Winkler2a421b92008-06-12 09:47:10 +0800446 active_dwell : passive_dwell);
447
448 scan_ch++;
449 added++;
450 }
451
452 IWL_DEBUG_SCAN("total channels to scan %d \n", added);
453 return added;
454}
455
Tomas Winklerf53696d2008-06-12 09:47:12 +0800456void iwl_init_scan_params(struct iwl_priv *priv)
457{
458 if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ])
459 priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = RATE_MCS_ANT_INIT_IND;
460 if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ])
461 priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = RATE_MCS_ANT_INIT_IND;
462}
463
Tomas Winkler2a421b92008-06-12 09:47:10 +0800464int iwl_scan_initiate(struct iwl_priv *priv)
465{
Tomas Winkler2a421b92008-06-12 09:47:10 +0800466 if (!iwl_is_ready_rf(priv)) {
467 IWL_DEBUG_SCAN("Aborting scan due to not ready.\n");
468 return -EIO;
469 }
470
471 if (test_bit(STATUS_SCANNING, &priv->status)) {
472 IWL_DEBUG_SCAN("Scan already in progress.\n");
473 return -EAGAIN;
474 }
475
476 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
Tomas Winkler8d09a5e2008-09-24 13:57:46 +0800477 IWL_DEBUG_SCAN("Scan request while abort pending\n");
Tomas Winkler2a421b92008-06-12 09:47:10 +0800478 return -EAGAIN;
479 }
480
481 IWL_DEBUG_INFO("Starting scan...\n");
David S. Miller1b63ba82008-06-28 01:19:40 -0700482 if (priv->cfg->sku & IWL_SKU_G)
483 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
484 if (priv->cfg->sku & IWL_SKU_A)
485 priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800486 set_bit(STATUS_SCANNING, &priv->status);
487 priv->scan_start = jiffies;
488 priv->scan_pass_start = priv->scan_start;
489
490 queue_work(priv->workqueue, &priv->request_scan);
491
492 return 0;
493}
494EXPORT_SYMBOL(iwl_scan_initiate);
495
496#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
497
498static void iwl_bg_scan_check(struct work_struct *data)
499{
500 struct iwl_priv *priv =
501 container_of(data, struct iwl_priv, scan_check.work);
502
503 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
504 return;
505
506 mutex_lock(&priv->mutex);
507 if (test_bit(STATUS_SCANNING, &priv->status) ||
508 test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
509 IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting "
510 "adapter (%dms)\n",
511 jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
512
513 if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
514 iwl_send_scan_abort(priv);
515 }
516 mutex_unlock(&priv->mutex);
517}
518/**
519 * iwl_supported_rate_to_ie - fill in the supported rate in IE field
520 *
521 * return : set the bit for each supported rate insert in ie
522 */
523static u16 iwl_supported_rate_to_ie(u8 *ie, u16 supported_rate,
524 u16 basic_rate, int *left)
525{
526 u16 ret_rates = 0, bit;
527 int i;
528 u8 *cnt = ie;
529 u8 *rates = ie + 1;
530
531 for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) {
532 if (bit & supported_rate) {
533 ret_rates |= bit;
534 rates[*cnt] = iwl_rates[i].ieee |
535 ((bit & basic_rate) ? 0x80 : 0x00);
536 (*cnt)++;
537 (*left)--;
538 if ((*left <= 0) ||
539 (*cnt >= IWL_SUPPORTED_RATES_IE_LEN))
540 break;
541 }
542 }
543
544 return ret_rates;
545}
546
547
548static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800549 u8 *pos, int *left)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800550{
551 struct ieee80211_ht_cap *ht_cap;
552
553 if (!sband || !sband->ht_info.ht_supported)
554 return;
555
556 if (*left < sizeof(struct ieee80211_ht_cap))
557 return;
558
559 *pos++ = sizeof(struct ieee80211_ht_cap);
560 ht_cap = (struct ieee80211_ht_cap *) pos;
561
562 ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap);
563 memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16);
564 ht_cap->ampdu_params_info =
565 (sband->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) |
566 ((sband->ht_info.ampdu_density << 2) &
567 IEEE80211_HT_CAP_AMPDU_DENSITY);
568 *left -= sizeof(struct ieee80211_ht_cap);
569}
570
571/**
572 * iwl_fill_probe_req - fill in all required fields and IE for probe request
573 */
Tomas Winklerf53696d2008-06-12 09:47:12 +0800574
Tomas Winkler2a421b92008-06-12 09:47:10 +0800575static u16 iwl_fill_probe_req(struct iwl_priv *priv,
576 enum ieee80211_band band,
577 struct ieee80211_mgmt *frame,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800578 int left)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800579{
580 int len = 0;
581 u8 *pos = NULL;
582 u16 active_rates, ret_rates, cck_rates, active_rate_basic;
583 const struct ieee80211_supported_band *sband =
584 iwl_get_hw_mode(priv, band);
585
Tomas Winklerf53696d2008-06-12 09:47:12 +0800586
Tomas Winkler2a421b92008-06-12 09:47:10 +0800587 /* Make sure there is enough space for the probe request,
588 * two mandatory IEs and the data */
589 left -= 24;
590 if (left < 0)
591 return 0;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800592
593 frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
594 memcpy(frame->da, iwl_bcast_addr, ETH_ALEN);
595 memcpy(frame->sa, priv->mac_addr, ETH_ALEN);
596 memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN);
597 frame->seq_ctrl = 0;
598
Tomas Winklerf53696d2008-06-12 09:47:12 +0800599 len += 24;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800600
Tomas Winklerf53696d2008-06-12 09:47:12 +0800601 /* ...next IE... */
602 pos = &frame->u.probe_req.variable[0];
603
604 /* fill in our indirect SSID IE */
Tomas Winkler2a421b92008-06-12 09:47:10 +0800605 left -= 2;
606 if (left < 0)
607 return 0;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800608 *pos++ = WLAN_EID_SSID;
609 *pos++ = 0;
610
Tomas Winklerf53696d2008-06-12 09:47:12 +0800611 len += 2;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800612
613 /* fill in supported rate */
Tomas Winkler2a421b92008-06-12 09:47:10 +0800614 left -= 2;
615 if (left < 0)
616 return 0;
617
Tomas Winkler2a421b92008-06-12 09:47:10 +0800618 *pos++ = WLAN_EID_SUPP_RATES;
619 *pos = 0;
620
621 /* exclude 60M rate */
622 active_rates = priv->rates_mask;
623 active_rates &= ~IWL_RATE_60M_MASK;
624
625 active_rate_basic = active_rates & IWL_BASIC_RATES_MASK;
626
627 cck_rates = IWL_CCK_RATES_MASK & active_rates;
628 ret_rates = iwl_supported_rate_to_ie(pos, cck_rates,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800629 active_rate_basic, &left);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800630 active_rates &= ~ret_rates;
631
632 ret_rates = iwl_supported_rate_to_ie(pos, active_rates,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800633 active_rate_basic, &left);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800634 active_rates &= ~ret_rates;
635
636 len += 2 + *pos;
637 pos += (*pos) + 1;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800638
Tomas Winkler2a421b92008-06-12 09:47:10 +0800639 if (active_rates == 0)
640 goto fill_end;
641
642 /* fill in supported extended rate */
643 /* ...next IE... */
644 left -= 2;
645 if (left < 0)
646 return 0;
647 /* ... fill it in... */
648 *pos++ = WLAN_EID_EXT_SUPP_RATES;
649 *pos = 0;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800650 iwl_supported_rate_to_ie(pos, active_rates, active_rate_basic, &left);
651 if (*pos > 0) {
Tomas Winkler2a421b92008-06-12 09:47:10 +0800652 len += 2 + *pos;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800653 pos += (*pos) + 1;
654 } else {
655 pos--;
656 }
Tomas Winkler2a421b92008-06-12 09:47:10 +0800657
658 fill_end:
Tomas Winklerf53696d2008-06-12 09:47:12 +0800659
Tomas Winkler2a421b92008-06-12 09:47:10 +0800660 left -= 2;
661 if (left < 0)
662 return 0;
663
664 *pos++ = WLAN_EID_HT_CAPABILITY;
665 *pos = 0;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800666 iwl_ht_cap_to_ie(sband, pos, &left);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800667 if (*pos > 0)
668 len += 2 + *pos;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800669
Tomas Winkler2a421b92008-06-12 09:47:10 +0800670 return (u16)len;
671}
672
Tomas Winklerf53696d2008-06-12 09:47:12 +0800673static u32 iwl_scan_tx_ant(struct iwl_priv *priv, enum ieee80211_band band)
674{
675 int i, ind;
676
677 ind = priv->scan_tx_ant[band];
678 for (i = 0; i < priv->hw_params.tx_chains_num; i++) {
679 ind = (ind+1) >= priv->hw_params.tx_chains_num ? 0 : ind+1;
680 if (priv->hw_params.valid_tx_ant & (1 << ind)) {
681 priv->scan_tx_ant[band] = ind;
682 break;
683 }
684 }
Tomas Winklerfe905f12008-07-11 11:53:39 +0800685 IWL_DEBUG_SCAN("select TX ANT = %c\n", 'A' + ind);
Tomas Winklerf53696d2008-06-12 09:47:12 +0800686 return scan_tx_ant[ind];
687}
688
689
Tomas Winkler2a421b92008-06-12 09:47:10 +0800690static void iwl_bg_request_scan(struct work_struct *data)
691{
692 struct iwl_priv *priv =
693 container_of(data, struct iwl_priv, request_scan);
694 struct iwl_host_cmd cmd = {
695 .id = REPLY_SCAN_CMD,
696 .len = sizeof(struct iwl_scan_cmd),
697 .meta.flags = CMD_SIZE_HUGE,
698 };
699 struct iwl_scan_cmd *scan;
700 struct ieee80211_conf *conf = NULL;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800701 int ret = 0;
702 u32 tx_ant;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800703 u16 cmd_len;
704 enum ieee80211_band band;
Tomas Winklerfe905f12008-07-11 11:53:39 +0800705 u8 n_probes = 2;
Tomas Winklerd588be62008-10-06 16:05:29 +0800706 u8 rx_chain = priv->hw_params.valid_rx_ant;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800707
708 conf = ieee80211_get_hw_conf(priv->hw);
709
710 mutex_lock(&priv->mutex);
711
712 if (!iwl_is_ready(priv)) {
713 IWL_WARNING("request scan called when driver not ready.\n");
714 goto done;
715 }
716
717 /* Make sure the scan wasn't cancelled before this queued work
718 * was given the chance to run... */
719 if (!test_bit(STATUS_SCANNING, &priv->status))
720 goto done;
721
722 /* This should never be called or scheduled if there is currently
723 * a scan active in the hardware. */
724 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
725 IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. "
726 "Ignoring second request.\n");
727 ret = -EIO;
728 goto done;
729 }
730
731 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
732 IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n");
733 goto done;
734 }
735
736 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
737 IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n");
738 goto done;
739 }
740
741 if (iwl_is_rfkill(priv)) {
742 IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n");
743 goto done;
744 }
745
746 if (!test_bit(STATUS_READY, &priv->status)) {
747 IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n");
748 goto done;
749 }
750
751 if (!priv->scan_bands) {
752 IWL_DEBUG_HC("Aborting scan due to no requested bands\n");
753 goto done;
754 }
755
756 if (!priv->scan) {
757 priv->scan = kmalloc(sizeof(struct iwl_scan_cmd) +
758 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
759 if (!priv->scan) {
760 ret = -ENOMEM;
761 goto done;
762 }
763 }
764 scan = priv->scan;
765 memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE);
766
767 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
768 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
769
770 if (iwl_is_associated(priv)) {
771 u16 interval = 0;
772 u32 extra;
773 u32 suspend_time = 100;
774 u32 scan_suspend_time = 100;
775 unsigned long flags;
776
777 IWL_DEBUG_INFO("Scanning while associated...\n");
778
779 spin_lock_irqsave(&priv->lock, flags);
780 interval = priv->beacon_int;
781 spin_unlock_irqrestore(&priv->lock, flags);
782
783 scan->suspend_time = 0;
784 scan->max_out_time = cpu_to_le32(200 * 1024);
785 if (!interval)
786 interval = suspend_time;
787
788 extra = (suspend_time / interval) << 22;
789 scan_suspend_time = (extra |
790 ((suspend_time % interval) * 1024));
791 scan->suspend_time = cpu_to_le32(scan_suspend_time);
792 IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n",
793 scan_suspend_time, interval);
794 }
795
796 /* We should add the ability for user to lock to PASSIVE ONLY */
797 if (priv->one_direct_scan) {
Tomas Winklerf53696d2008-06-12 09:47:12 +0800798 IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
799 iwl_escape_essid(priv->direct_ssid,
800 priv->direct_ssid_len));
Tomas Winkler2a421b92008-06-12 09:47:10 +0800801 scan->direct_scan[0].id = WLAN_EID_SSID;
802 scan->direct_scan[0].len = priv->direct_ssid_len;
803 memcpy(scan->direct_scan[0].ssid,
804 priv->direct_ssid, priv->direct_ssid_len);
Tomas Winklerfe905f12008-07-11 11:53:39 +0800805 n_probes++;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800806 } else if (!iwl_is_associated(priv) && priv->essid_len) {
Tomas Winklerf53696d2008-06-12 09:47:12 +0800807 IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
808 iwl_escape_essid(priv->essid, priv->essid_len));
Tomas Winkler2a421b92008-06-12 09:47:10 +0800809 scan->direct_scan[0].id = WLAN_EID_SSID;
810 scan->direct_scan[0].len = priv->essid_len;
811 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
Tomas Winklerfe905f12008-07-11 11:53:39 +0800812 n_probes++;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800813 } else {
Tomas Winklerf53696d2008-06-12 09:47:12 +0800814 IWL_DEBUG_SCAN("Start indirect scan.\n");
Tomas Winkler2a421b92008-06-12 09:47:10 +0800815 }
816
817 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
818 scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id;
819 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
820
821
David S. Miller1b63ba82008-06-28 01:19:40 -0700822 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
Tomas Winkler2a421b92008-06-12 09:47:10 +0800823 band = IEEE80211_BAND_2GHZ;
Tomas Winklerf53696d2008-06-12 09:47:12 +0800824 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
825 tx_ant = iwl_scan_tx_ant(priv, band);
826 if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK)
827 scan->tx_cmd.rate_n_flags =
828 iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
829 tx_ant);
830 else
831 scan->tx_cmd.rate_n_flags =
832 iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP,
833 tx_ant |
834 RATE_MCS_CCK_MSK);
835 scan->good_CRC_th = 0;
David S. Miller1b63ba82008-06-28 01:19:40 -0700836 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
Tomas Winklerf53696d2008-06-12 09:47:12 +0800837 band = IEEE80211_BAND_5GHZ;
838 tx_ant = iwl_scan_tx_ant(priv, band);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800839 scan->tx_cmd.rate_n_flags =
Tomas Winklere7d326a2008-06-12 09:47:11 +0800840 iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800841 tx_ant);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800842 scan->good_CRC_th = IWL_GOOD_CRC_TH;
Tomas Winkler2a421b92008-06-12 09:47:10 +0800843
Tomas Winklerf53696d2008-06-12 09:47:12 +0800844 /* Force use of chains B and C (0x6) for scan Rx for 4965
845 * Avoid A (0x1) because of its off-channel reception on A-band.
Tomas Winkler51183032008-10-06 16:05:30 +0800846 */
Tomas Winklerf53696d2008-06-12 09:47:12 +0800847 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
848 rx_chain = 0x6;
David S. Miller1b63ba82008-06-28 01:19:40 -0700849 } else {
Tomas Winkler2a421b92008-06-12 09:47:10 +0800850 IWL_WARNING("Invalid scan band count\n");
851 goto done;
852 }
853
Tomas Winkler51183032008-10-06 16:05:30 +0800854 /* MIMO is not used here, but value is required */
Tomas Winklerf53696d2008-06-12 09:47:12 +0800855 scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK |
856 cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) |
857 (rx_chain << RXON_RX_CHAIN_FORCE_SEL_POS) |
858 (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS));
859
Tomas Winkler2a421b92008-06-12 09:47:10 +0800860 cmd_len = iwl_fill_probe_req(priv, band,
Tomas Winklerf53696d2008-06-12 09:47:12 +0800861 (struct ieee80211_mgmt *)scan->data,
862 IWL_MAX_SCAN_SIZE - sizeof(*scan));
Tomas Winkler2a421b92008-06-12 09:47:10 +0800863
864 scan->tx_cmd.len = cpu_to_le16(cmd_len);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800865
Johannes Berg05c914f2008-09-11 00:01:58 +0200866 if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
Tomas Winkler2a421b92008-06-12 09:47:10 +0800867 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
868
Tomas Winklerf53696d2008-06-12 09:47:12 +0800869 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
870 RXON_FILTER_BCON_AWARE_MSK);
871
Tomas Winklerfe905f12008-07-11 11:53:39 +0800872 scan->channel_count =
873 iwl_get_channels_for_scan(priv, band, 1, /* active */
874 n_probes,
875 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
876
Tomas Winklerf53696d2008-06-12 09:47:12 +0800877 if (scan->channel_count == 0) {
878 IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count);
879 goto done;
880 }
Tomas Winkler2a421b92008-06-12 09:47:10 +0800881
Tomas Winkler2a421b92008-06-12 09:47:10 +0800882 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
883 scan->channel_count * sizeof(struct iwl_scan_channel);
884 cmd.data = scan;
885 scan->len = cpu_to_le16(cmd.len);
886
887 set_bit(STATUS_SCAN_HW, &priv->status);
888 ret = iwl_send_cmd_sync(priv, &cmd);
889 if (ret)
890 goto done;
891
892 queue_delayed_work(priv->workqueue, &priv->scan_check,
893 IWL_SCAN_CHECK_WATCHDOG);
894
895 mutex_unlock(&priv->mutex);
896 return;
897
898 done:
899 /* inform mac80211 scan aborted */
900 queue_work(priv->workqueue, &priv->scan_completed);
901 mutex_unlock(&priv->mutex);
902}
903
904static void iwl_bg_abort_scan(struct work_struct *work)
905{
906 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
907
908 if (!iwl_is_ready(priv))
909 return;
910
911 mutex_lock(&priv->mutex);
912
913 set_bit(STATUS_SCAN_ABORTING, &priv->status);
914 iwl_send_scan_abort(priv);
915
916 mutex_unlock(&priv->mutex);
917}
918
Tomas Winklereedda362008-10-06 16:05:32 +0800919static void iwl_bg_scan_completed(struct work_struct *work)
920{
921 struct iwl_priv *priv =
922 container_of(work, struct iwl_priv, scan_completed);
923
924 IWL_DEBUG_SCAN("SCAN complete scan\n");
925
926 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
927 return;
928
929 ieee80211_scan_completed(priv->hw);
930
931 /* Since setting the TXPOWER may have been deferred while
932 * performing the scan, fire one off */
933 mutex_lock(&priv->mutex);
934 iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
935 mutex_unlock(&priv->mutex);
936}
937
938
Tomas Winkler2a421b92008-06-12 09:47:10 +0800939void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
940{
Tomas Winklereedda362008-10-06 16:05:32 +0800941 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800942 INIT_WORK(&priv->request_scan, iwl_bg_request_scan);
943 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
944 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
945}
946EXPORT_SYMBOL(iwl_setup_scan_deferred_work);
947