aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-scan.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c279
1 files changed, 215 insertions, 64 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 4f3a108fa990..741e65ec8301 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
@@ -25,9 +25,9 @@
25 * Intel Linux Wireless <ilw@linux.intel.com> 25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/ 27 *****************************************************************************/
28#include <linux/slab.h>
28#include <linux/types.h> 29#include <linux/types.h>
29#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
30#include <net/lib80211.h>
31#include <net/mac80211.h> 31#include <net/mac80211.h>
32 32
33#include "iwl-eeprom.h" 33#include "iwl-eeprom.h"
@@ -112,7 +112,7 @@ EXPORT_SYMBOL(iwl_scan_cancel_timeout);
112static int iwl_send_scan_abort(struct iwl_priv *priv) 112static int iwl_send_scan_abort(struct iwl_priv *priv)
113{ 113{
114 int ret = 0; 114 int ret = 0;
115 struct iwl_rx_packet *res; 115 struct iwl_rx_packet *pkt;
116 struct iwl_host_cmd cmd = { 116 struct iwl_host_cmd cmd = {
117 .id = REPLY_SCAN_ABORT_CMD, 117 .id = REPLY_SCAN_ABORT_CMD,
118 .flags = CMD_WANT_SKB, 118 .flags = CMD_WANT_SKB,
@@ -132,21 +132,20 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
132 return ret; 132 return ret;
133 } 133 }
134 134
135 res = (struct iwl_rx_packet *)cmd.reply_skb->data; 135 pkt = (struct iwl_rx_packet *)cmd.reply_page;
136 if (res->u.status != CAN_ABORT_STATUS) { 136 if (pkt->u.status != CAN_ABORT_STATUS) {
137 /* The scan abort will return 1 for success or 137 /* The scan abort will return 1 for success or
138 * 2 for "failure". A failure condition can be 138 * 2 for "failure". A failure condition can be
139 * due to simply not being in an active scan which 139 * due to simply not being in an active scan which
140 * can occur if we send the scan abort before we 140 * can occur if we send the scan abort before we
141 * the microcode has notified us that a scan is 141 * the microcode has notified us that a scan is
142 * completed. */ 142 * completed. */
143 IWL_DEBUG_INFO(priv, "SCAN_ABORT returned %d.\n", res->u.status); 143 IWL_DEBUG_INFO(priv, "SCAN_ABORT returned %d.\n", pkt->u.status);
144 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 144 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
145 clear_bit(STATUS_SCAN_HW, &priv->status); 145 clear_bit(STATUS_SCAN_HW, &priv->status);
146 } 146 }
147 147
148 priv->alloc_rxb_skb--; 148 iwl_free_pages(priv, cmd.reply_page);
149 dev_kfree_skb_any(cmd.reply_skb);
150 149
151 return ret; 150 return ret;
152} 151}
@@ -156,7 +155,7 @@ static void iwl_rx_reply_scan(struct iwl_priv *priv,
156 struct iwl_rx_mem_buffer *rxb) 155 struct iwl_rx_mem_buffer *rxb)
157{ 156{
158#ifdef CONFIG_IWLWIFI_DEBUG 157#ifdef CONFIG_IWLWIFI_DEBUG
159 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 158 struct iwl_rx_packet *pkt = rxb_addr(rxb);
160 struct iwl_scanreq_notification *notif = 159 struct iwl_scanreq_notification *notif =
161 (struct iwl_scanreq_notification *)pkt->u.raw; 160 (struct iwl_scanreq_notification *)pkt->u.raw;
162 161
@@ -168,7 +167,7 @@ static void iwl_rx_reply_scan(struct iwl_priv *priv,
168static void iwl_rx_scan_start_notif(struct iwl_priv *priv, 167static void iwl_rx_scan_start_notif(struct iwl_priv *priv,
169 struct iwl_rx_mem_buffer *rxb) 168 struct iwl_rx_mem_buffer *rxb)
170{ 169{
171 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 170 struct iwl_rx_packet *pkt = rxb_addr(rxb);
172 struct iwl_scanstart_notification *notif = 171 struct iwl_scanstart_notification *notif =
173 (struct iwl_scanstart_notification *)pkt->u.raw; 172 (struct iwl_scanstart_notification *)pkt->u.raw;
174 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 173 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
@@ -187,26 +186,24 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
187 struct iwl_rx_mem_buffer *rxb) 186 struct iwl_rx_mem_buffer *rxb)
188{ 187{
189#ifdef CONFIG_IWLWIFI_DEBUG 188#ifdef CONFIG_IWLWIFI_DEBUG
190 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 189 struct iwl_rx_packet *pkt = rxb_addr(rxb);
191 struct iwl_scanresults_notification *notif = 190 struct iwl_scanresults_notification *notif =
192 (struct iwl_scanresults_notification *)pkt->u.raw; 191 (struct iwl_scanresults_notification *)pkt->u.raw;
193 192
194 IWL_DEBUG_SCAN(priv, "Scan ch.res: " 193 IWL_DEBUG_SCAN(priv, "Scan ch.res: "
195 "%d [802.11%s] " 194 "%d [802.11%s] "
196 "(TSF: 0x%08X:%08X) - %d " 195 "(TSF: 0x%08X:%08X) - %d "
197 "elapsed=%lu usec (%dms since last)\n", 196 "elapsed=%lu usec\n",
198 notif->channel, 197 notif->channel,
199 notif->band ? "bg" : "a", 198 notif->band ? "bg" : "a",
200 le32_to_cpu(notif->tsf_high), 199 le32_to_cpu(notif->tsf_high),
201 le32_to_cpu(notif->tsf_low), 200 le32_to_cpu(notif->tsf_low),
202 le32_to_cpu(notif->statistics[0]), 201 le32_to_cpu(notif->statistics[0]),
203 le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, 202 le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf);
204 jiffies_to_msecs(elapsed_jiffies
205 (priv->last_scan_jiffies, jiffies)));
206#endif 203#endif
207 204
208 priv->last_scan_jiffies = jiffies; 205 if (!priv->is_internal_short_scan)
209 priv->next_scan_jiffies = 0; 206 priv->next_scan_jiffies = 0;
210} 207}
211 208
212/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 209/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
@@ -214,7 +211,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
214 struct iwl_rx_mem_buffer *rxb) 211 struct iwl_rx_mem_buffer *rxb)
215{ 212{
216#ifdef CONFIG_IWLWIFI_DEBUG 213#ifdef CONFIG_IWLWIFI_DEBUG
217 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 214 struct iwl_rx_packet *pkt = rxb_addr(rxb);
218 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 215 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
219 216
220 IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 217 IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
@@ -252,8 +249,9 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
252 goto reschedule; 249 goto reschedule;
253 } 250 }
254 251
255 priv->last_scan_jiffies = jiffies; 252 if (!priv->is_internal_short_scan)
256 priv->next_scan_jiffies = 0; 253 priv->next_scan_jiffies = 0;
254
257 IWL_DEBUG_INFO(priv, "Setting scan to off\n"); 255 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
258 256
259 clear_bit(STATUS_SCANNING, &priv->status); 257 clear_bit(STATUS_SCANNING, &priv->status);
@@ -316,6 +314,72 @@ u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
316} 314}
317EXPORT_SYMBOL(iwl_get_passive_dwell_time); 315EXPORT_SYMBOL(iwl_get_passive_dwell_time);
318 316
317static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
318 enum ieee80211_band band,
319 struct iwl_scan_channel *scan_ch)
320{
321 const struct ieee80211_supported_band *sband;
322 const struct iwl_channel_info *ch_info;
323 u16 passive_dwell = 0;
324 u16 active_dwell = 0;
325 int i, added = 0;
326 u16 channel = 0;
327
328 sband = iwl_get_hw_mode(priv, band);
329 if (!sband) {
330 IWL_ERR(priv, "invalid band\n");
331 return added;
332 }
333
334 active_dwell = iwl_get_active_dwell_time(priv, band, 0);
335 passive_dwell = iwl_get_passive_dwell_time(priv, band);
336
337 if (passive_dwell <= active_dwell)
338 passive_dwell = active_dwell + 1;
339
340 /* only scan single channel, good enough to reset the RF */
341 /* pick the first valid not in-use channel */
342 if (band == IEEE80211_BAND_5GHZ) {
343 for (i = 14; i < priv->channel_count; i++) {
344 if (priv->channel_info[i].channel !=
345 le16_to_cpu(priv->staging_rxon.channel)) {
346 channel = priv->channel_info[i].channel;
347 ch_info = iwl_get_channel_info(priv,
348 band, channel);
349 if (is_channel_valid(ch_info))
350 break;
351 }
352 }
353 } else {
354 for (i = 0; i < 14; i++) {
355 if (priv->channel_info[i].channel !=
356 le16_to_cpu(priv->staging_rxon.channel)) {
357 channel =
358 priv->channel_info[i].channel;
359 ch_info = iwl_get_channel_info(priv,
360 band, channel);
361 if (is_channel_valid(ch_info))
362 break;
363 }
364 }
365 }
366 if (channel) {
367 scan_ch->channel = cpu_to_le16(channel);
368 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
369 scan_ch->active_dwell = cpu_to_le16(active_dwell);
370 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
371 /* Set txpower levels to defaults */
372 scan_ch->dsp_atten = 110;
373 if (band == IEEE80211_BAND_5GHZ)
374 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
375 else
376 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
377 added++;
378 } else
379 IWL_ERR(priv, "no valid channel found\n");
380 return added;
381}
382
319static int iwl_get_channels_for_scan(struct iwl_priv *priv, 383static int iwl_get_channels_for_scan(struct iwl_priv *priv,
320 enum ieee80211_band band, 384 enum ieee80211_band band,
321 u8 is_active, u8 n_probes, 385 u8 is_active, u8 n_probes,
@@ -402,26 +466,15 @@ void iwl_init_scan_params(struct iwl_priv *priv)
402 if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) 466 if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ])
403 priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; 467 priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx;
404} 468}
469EXPORT_SYMBOL(iwl_init_scan_params);
405 470
406static int iwl_scan_initiate(struct iwl_priv *priv) 471static int iwl_scan_initiate(struct iwl_priv *priv)
407{ 472{
408 if (!iwl_is_ready_rf(priv)) { 473 WARN_ON(!mutex_is_locked(&priv->mutex));
409 IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n");
410 return -EIO;
411 }
412
413 if (test_bit(STATUS_SCANNING, &priv->status)) {
414 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
415 return -EAGAIN;
416 }
417
418 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
419 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
420 return -EAGAIN;
421 }
422 474
423 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 475 IWL_DEBUG_INFO(priv, "Starting scan...\n");
424 set_bit(STATUS_SCANNING, &priv->status); 476 set_bit(STATUS_SCANNING, &priv->status);
477 priv->is_internal_short_scan = false;
425 priv->scan_start = jiffies; 478 priv->scan_start = jiffies;
426 priv->scan_pass_start = priv->scan_start; 479 priv->scan_pass_start = priv->scan_start;
427 480
@@ -450,6 +503,18 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
450 goto out_unlock; 503 goto out_unlock;
451 } 504 }
452 505
506 if (test_bit(STATUS_SCANNING, &priv->status)) {
507 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
508 ret = -EAGAIN;
509 goto out_unlock;
510 }
511
512 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
513 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
514 ret = -EAGAIN;
515 goto out_unlock;
516 }
517
453 /* We don't schedule scan within next_scan_jiffies period. 518 /* We don't schedule scan within next_scan_jiffies period.
454 * Avoid scanning during possible EAPOL exchange, return 519 * Avoid scanning during possible EAPOL exchange, return
455 * success immediately. 520 * success immediately.
@@ -462,15 +527,6 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
462 goto out_unlock; 527 goto out_unlock;
463 } 528 }
464 529
465 /* if we just finished scan ask for delay */
466 if (iwl_is_associated(priv) && priv->last_scan_jiffies &&
467 time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) {
468 IWL_DEBUG_SCAN(priv, "scan rejected: within previous scan period\n");
469 queue_work(priv->workqueue, &priv->scan_completed);
470 ret = 0;
471 goto out_unlock;
472 }
473
474 priv->scan_bands = 0; 530 priv->scan_bands = 0;
475 for (i = 0; i < req->n_channels; i++) 531 for (i = 0; i < req->n_channels; i++)
476 priv->scan_bands |= BIT(req->channels[i]->band); 532 priv->scan_bands |= BIT(req->channels[i]->band);
@@ -489,6 +545,52 @@ out_unlock:
489} 545}
490EXPORT_SYMBOL(iwl_mac_hw_scan); 546EXPORT_SYMBOL(iwl_mac_hw_scan);
491 547
548/*
549 * internal short scan, this function should only been called while associated.
550 * It will reset and tune the radio to prevent possible RF related problem
551 */
552void iwl_internal_short_hw_scan(struct iwl_priv *priv)
553{
554 queue_work(priv->workqueue, &priv->start_internal_scan);
555}
556
557static void iwl_bg_start_internal_scan(struct work_struct *work)
558{
559 struct iwl_priv *priv =
560 container_of(work, struct iwl_priv, start_internal_scan);
561
562 mutex_lock(&priv->mutex);
563
564 if (!iwl_is_ready_rf(priv)) {
565 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
566 goto unlock;
567 }
568
569 if (test_bit(STATUS_SCANNING, &priv->status)) {
570 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
571 goto unlock;
572 }
573
574 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
575 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
576 goto unlock;
577 }
578
579 priv->scan_bands = 0;
580 if (priv->band == IEEE80211_BAND_5GHZ)
581 priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
582 else
583 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
584
585 IWL_DEBUG_SCAN(priv, "Start internal short scan...\n");
586 set_bit(STATUS_SCANNING, &priv->status);
587 priv->is_internal_short_scan = true;
588 queue_work(priv->workqueue, &priv->request_scan);
589 unlock:
590 mutex_unlock(&priv->mutex);
591}
592EXPORT_SYMBOL(iwl_internal_short_hw_scan);
593
492#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 594#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
493 595
494void iwl_bg_scan_check(struct work_struct *data) 596void iwl_bg_scan_check(struct work_struct *data)
@@ -552,7 +654,8 @@ u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
552 if (WARN_ON(left < ie_len)) 654 if (WARN_ON(left < ie_len))
553 return len; 655 return len;
554 656
555 memcpy(pos, ies, ie_len); 657 if (ies)
658 memcpy(pos, ies, ie_len);
556 len += ie_len; 659 len += ie_len;
557 left -= ie_len; 660 left -= ie_len;
558 661
@@ -581,6 +684,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
581 u8 rate; 684 u8 rate;
582 bool is_active = false; 685 bool is_active = false;
583 int chan_mod; 686 int chan_mod;
687 u8 active_chains;
584 688
585 conf = ieee80211_get_hw_conf(priv->hw); 689 conf = ieee80211_get_hw_conf(priv->hw);
586 690
@@ -654,7 +758,6 @@ static void iwl_bg_request_scan(struct work_struct *data)
654 unsigned long flags; 758 unsigned long flags;
655 759
656 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 760 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
657
658 spin_lock_irqsave(&priv->lock, flags); 761 spin_lock_irqsave(&priv->lock, flags);
659 interval = priv->beacon_int; 762 interval = priv->beacon_int;
660 spin_unlock_irqrestore(&priv->lock, flags); 763 spin_unlock_irqrestore(&priv->lock, flags);
@@ -672,7 +775,9 @@ static void iwl_bg_request_scan(struct work_struct *data)
672 scan_suspend_time, interval); 775 scan_suspend_time, interval);
673 } 776 }
674 777
675 if (priv->scan_request->n_ssids) { 778 if (priv->is_internal_short_scan) {
779 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
780 } else if (priv->scan_request->n_ssids) {
676 int i, p = 0; 781 int i, p = 0;
677 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 782 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
678 for (i = 0; i < priv->scan_request->n_ssids; i++) { 783 for (i = 0; i < priv->scan_request->n_ssids; i++) {
@@ -708,16 +813,29 @@ static void iwl_bg_request_scan(struct work_struct *data)
708 rate = IWL_RATE_1M_PLCP; 813 rate = IWL_RATE_1M_PLCP;
709 rate_flags = RATE_MCS_CCK_MSK; 814 rate_flags = RATE_MCS_CCK_MSK;
710 } 815 }
711 scan->good_CRC_th = 0; 816 scan->good_CRC_th = IWL_GOOD_CRC_TH_DISABLED;
712 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { 817 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
713 band = IEEE80211_BAND_5GHZ; 818 band = IEEE80211_BAND_5GHZ;
714 rate = IWL_RATE_6M_PLCP; 819 rate = IWL_RATE_6M_PLCP;
715 /* 820 /*
716 * If active scaning is requested but a certain channel 821 * If active scanning is requested but a certain channel is
717 * is marked passive, we can do active scanning if we 822 * marked passive, we can do active scanning if we detect
718 * detect transmissions. 823 * transmissions.
824 *
825 * There is an issue with some firmware versions that triggers
826 * a sysassert on a "good CRC threshold" of zero (== disabled),
827 * on a radar channel even though this means that we should NOT
828 * send probes.
829 *
830 * The "good CRC threshold" is the number of frames that we
831 * need to receive during our dwell time on a channel before
832 * sending out probes -- setting this to a huge value will
833 * mean we never reach it, but at the same time work around
834 * the aforementioned issue. Thus use IWL_GOOD_CRC_TH_NEVER
835 * here instead of IWL_GOOD_CRC_TH_DISABLED.
719 */ 836 */
720 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH : 0; 837 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
838 IWL_GOOD_CRC_TH_NEVER;
721 839
722 /* Force use of chains B and C (0x6) for scan Rx for 4965 840 /* Force use of chains B and C (0x6) for scan Rx for 4965
723 * Avoid A (0x1) because of its off-channel reception on A-band. 841 * Avoid A (0x1) because of its off-channel reception on A-band.
@@ -734,30 +852,57 @@ static void iwl_bg_request_scan(struct work_struct *data)
734 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]); 852 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
735 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags); 853 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
736 854
855 /* In power save mode use one chain, otherwise use all chains */
856 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
857 /* rx_ant has been set to all valid chains previously */
858 active_chains = rx_ant &
859 ((u8)(priv->chain_noise_data.active_chains));
860 if (!active_chains)
861 active_chains = rx_ant;
862
863 IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n",
864 priv->chain_noise_data.active_chains);
865
866 rx_ant = first_antenna(active_chains);
867 }
737 /* MIMO is not used here, but value is required */ 868 /* MIMO is not used here, but value is required */
738 rx_chain |= ANT_ABC << RXON_RX_CHAIN_VALID_POS; 869 rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
739 rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; 870 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
740 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; 871 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
741 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; 872 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
742 scan->rx_chain = cpu_to_le16(rx_chain); 873 scan->rx_chain = cpu_to_le16(rx_chain);
743 cmd_len = iwl_fill_probe_req(priv, 874 if (!priv->is_internal_short_scan) {
744 (struct ieee80211_mgmt *)scan->data, 875 cmd_len = iwl_fill_probe_req(priv,
745 priv->scan_request->ie, 876 (struct ieee80211_mgmt *)scan->data,
746 priv->scan_request->ie_len, 877 priv->scan_request->ie,
747 IWL_MAX_SCAN_SIZE - sizeof(*scan)); 878 priv->scan_request->ie_len,
879 IWL_MAX_SCAN_SIZE - sizeof(*scan));
880 } else {
881 cmd_len = iwl_fill_probe_req(priv,
882 (struct ieee80211_mgmt *)scan->data,
883 NULL, 0,
884 IWL_MAX_SCAN_SIZE - sizeof(*scan));
748 885
886 }
749 scan->tx_cmd.len = cpu_to_le16(cmd_len); 887 scan->tx_cmd.len = cpu_to_le16(cmd_len);
750
751 if (iwl_is_monitor_mode(priv)) 888 if (iwl_is_monitor_mode(priv))
752 scan->filter_flags = RXON_FILTER_PROMISC_MSK; 889 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
753 890
754 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 891 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
755 RXON_FILTER_BCON_AWARE_MSK); 892 RXON_FILTER_BCON_AWARE_MSK);
756 893
757 scan->channel_count = 894 if (priv->is_internal_short_scan) {
758 iwl_get_channels_for_scan(priv, band, is_active, n_probes, 895 scan->channel_count =
759 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 896 iwl_get_single_channel_for_scan(priv, band,
760 897 (void *)&scan->data[le16_to_cpu(
898 scan->tx_cmd.len)]);
899 } else {
900 scan->channel_count =
901 iwl_get_channels_for_scan(priv, band,
902 is_active, n_probes,
903 (void *)&scan->data[le16_to_cpu(
904 scan->tx_cmd.len)]);
905 }
761 if (scan->channel_count == 0) { 906 if (scan->channel_count == 0) {
762 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 907 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
763 goto done; 908 goto done;
@@ -818,7 +963,12 @@ void iwl_bg_scan_completed(struct work_struct *work)
818 963
819 cancel_delayed_work(&priv->scan_check); 964 cancel_delayed_work(&priv->scan_check);
820 965
821 ieee80211_scan_completed(priv->hw, false); 966 if (!priv->is_internal_short_scan)
967 ieee80211_scan_completed(priv->hw, false);
968 else {
969 priv->is_internal_short_scan = false;
970 IWL_DEBUG_SCAN(priv, "internal short scan completed\n");
971 }
822 972
823 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 973 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
824 return; 974 return;
@@ -836,6 +986,7 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
836 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 986 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
837 INIT_WORK(&priv->request_scan, iwl_bg_request_scan); 987 INIT_WORK(&priv->request_scan, iwl_bg_request_scan);
838 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 988 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
989 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
839 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 990 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
840} 991}
841EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 992EXPORT_SYMBOL(iwl_setup_scan_deferred_work);