Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-scan.c
index c2ed7c1..9bb6adb 100644 (file)
 /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
  * sending probe req.  This should be set long enough to hear probe responses
  * from more than one AP.  */
-#define IWL_ACTIVE_DWELL_TIME_24    (20)       /* all times in msec */
-#define IWL_ACTIVE_DWELL_TIME_52    (10)
+#define IWL_ACTIVE_DWELL_TIME_24    (30)       /* all times in msec */
+#define IWL_ACTIVE_DWELL_TIME_52    (20)
+
+#define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3)
+#define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2)
 
 /* For faster active scanning, scan will move to the next channel if fewer than
  * PLCP_QUIET_THRESH packets are heard on this channel within
@@ -48,7 +51,7 @@
  * no other traffic).
  * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
 #define IWL_PLCP_QUIET_THRESH       __constant_cpu_to_le16(1)  /* packets */
-#define IWL_ACTIVE_QUIET_TIME       __constant_cpu_to_le16(5)  /* msec */
+#define IWL_ACTIVE_QUIET_TIME       __constant_cpu_to_le16(10)  /* msec */
 
 /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel.
  * Must be set longer than active dwell time.
 #define IWL_PASSIVE_DWELL_BASE      (100)
 #define IWL_CHANNEL_TUNE_TIME       5
 
+#define IWL_SCAN_PROBE_MASK(n)         cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
+
+
+static int scan_tx_ant[3] = {
+       RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK
+};
+
 
 
 static int iwl_is_empty_essid(const char *essid, int essid_len)
@@ -192,6 +202,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
                clear_bit(STATUS_SCAN_HW, &priv->status);
        }
 
+       priv->alloc_rxb_skb--;
        dev_kfree_skb_any(cmd.meta.u.skb);
 
        return ret;
@@ -224,8 +235,9 @@ static void iwl_rx_scan_start_notif(struct iwl_priv *priv,
                       "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
                       notif->channel,
                       notif->band ? "bg" : "a",
-                      notif->tsf_high,
-                      notif->tsf_low, notif->status, notif->beacon_timer);
+                      le32_to_cpu(notif->tsf_high),
+                      le32_to_cpu(notif->tsf_low),
+                      notif->status, notif->beacon_timer);
 }
 
 /* Service SCAN_RESULTS_NOTIFICATION (0x83) */
@@ -259,6 +271,7 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
 static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
                                       struct iwl_rx_mem_buffer *rxb)
 {
+#ifdef CONFIG_IWLWIFI_DEBUG
        struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
        struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
 
@@ -266,6 +279,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
                       scan_notif->scanned_channels,
                       scan_notif->tsf_low,
                       scan_notif->tsf_high, scan_notif->status);
+#endif
 
        /* The HW is no longer scanning */
        clear_bit(STATUS_SCAN_HW, &priv->status);
@@ -274,13 +288,18 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
        cancel_delayed_work(&priv->scan_check);
 
        IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n",
-                      (priv->scan_bands == 2) ? "2.4" : "5.2",
+                      (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
+                                               "2.4" : "5.2",
                       jiffies_to_msecs(elapsed_jiffies
                                        (priv->scan_pass_start, jiffies)));
 
-       /* Remove this scanned band from the list
-        * of pending bands to scan */
-       priv->scan_bands--;
+       /* Remove this scanned band from the list of pending
+        * bands to scan, band G precedes A in order of scanning
+        * as seen in iwl_bg_request_scan */
+       if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ))
+               priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ);
+       else if (priv->scan_bands &  BIT(IEEE80211_BAND_5GHZ))
+               priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ);
 
        /* If a request to abort was given, or the scan did not succeed
         * then we reset the scan state machine and terminate,
@@ -290,7 +309,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
                clear_bit(STATUS_SCAN_ABORTING, &priv->status);
        } else {
                /* If there are more bands on this scan pass reschedule */
-               if (priv->scan_bands > 0)
+               if (priv->scan_bands)
                        goto reschedule;
        }
 
@@ -325,19 +344,21 @@ void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
 EXPORT_SYMBOL(iwl_setup_rx_scan_handlers);
 
 static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
-                                               enum ieee80211_band band)
+                                           enum ieee80211_band band,
+                                           u8 n_probes)
 {
        if (band == IEEE80211_BAND_5GHZ)
-               return IWL_ACTIVE_DWELL_TIME_52;
+               return IWL_ACTIVE_DWELL_TIME_52 +
+                       IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1);
        else
-               return IWL_ACTIVE_DWELL_TIME_24;
+               return IWL_ACTIVE_DWELL_TIME_24 +
+                       IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1);
 }
 
 static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
-                                         enum ieee80211_band band)
+                                     enum ieee80211_band band)
 {
-       u16 active = iwl_get_active_dwell_time(priv, band);
-       u16 passive = (band != IEEE80211_BAND_5GHZ) ?
+       u16 passive = (band == IEEE80211_BAND_2GHZ) ?
            IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
            IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
 
@@ -351,15 +372,12 @@ static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
                passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
        }
 
-       if (passive <= active)
-               passive = active + 1;
-
        return passive;
 }
 
 static int iwl_get_channels_for_scan(struct iwl_priv *priv,
                                     enum ieee80211_band band,
-                                    u8 is_active, u8 direct_mask,
+                                    u8 is_active, u8 n_probes,
                                     struct iwl_scan_channel *scan_ch)
 {
        const struct ieee80211_channel *channels = NULL;
@@ -368,6 +386,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
        u16 passive_dwell = 0;
        u16 active_dwell = 0;
        int added, i;
+       u16 channel;
 
        sband = iwl_get_hw_mode(priv, band);
        if (!sband)
@@ -375,55 +394,56 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
 
        channels = sband->channels;
 
-       active_dwell = iwl_get_active_dwell_time(priv, band);
+       active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
        passive_dwell = iwl_get_passive_dwell_time(priv, band);
 
+       if (passive_dwell <= active_dwell)
+               passive_dwell = active_dwell + 1;
+
        for (i = 0, added = 0; i < sband->n_channels; i++) {
                if (channels[i].flags & IEEE80211_CHAN_DISABLED)
                        continue;
 
-               scan_ch->channel =
+               channel =
                        ieee80211_frequency_to_channel(channels[i].center_freq);
+               scan_ch->channel = cpu_to_le16(channel);
 
-               ch_info = iwl_get_channel_info(priv, band,
-                                        scan_ch->channel);
+               ch_info = iwl_get_channel_info(priv, band, channel);
                if (!is_channel_valid(ch_info)) {
-                       IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n",
-                                      scan_ch->channel);
+                       IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n",
+                                       channel);
                        continue;
                }
 
                if (!is_active || is_channel_passive(ch_info) ||
                    (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
-                       scan_ch->type = 0;      /* passive */
+                       scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
                else
-                       scan_ch->type = 1;      /* active */
+                       scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
 
-               if (scan_ch->type & 1)
-                       scan_ch->type |= (direct_mask << 1);
+               if ((scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) && n_probes)
+                       scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
 
                scan_ch->active_dwell = cpu_to_le16(active_dwell);
                scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
 
                /* Set txpower levels to defaults */
-               scan_ch->tpc.dsp_atten = 110;
-               /* scan_pwr_info->tpc.dsp_atten; */
+               scan_ch->dsp_atten = 110;
 
-               /*scan_pwr_info->tpc.tx_gain; */
+               /* NOTE: if we were doing 6Mb OFDM for scans we'd use
+                * power level:
+                * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
+                */
                if (band == IEEE80211_BAND_5GHZ)
-                       scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3;
-               else {
-                       scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
-                       /* NOTE: if we were doing 6Mb OFDM for scans we'd use
-                        * power level:
-                        * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3;
-                        */
-               }
+                       scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
+               else
+                       scan_ch->tx_gain = ((1 << 5) | (5 << 3));
 
-               IWL_DEBUG_SCAN("Scanning %d [%s %d]\n",
-                              scan_ch->channel,
-                              (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE",
-                              (scan_ch->type & 1) ?
+               IWL_DEBUG_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n",
+                              channel, le32_to_cpu(scan_ch->type),
+                              (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
+                               "ACTIVE" : "PASSIVE",
+                              (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
                               active_dwell : passive_dwell);
 
                scan_ch++;
@@ -434,6 +454,14 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
        return added;
 }
 
+void iwl_init_scan_params(struct iwl_priv *priv)
+{
+       if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ])
+               priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = RATE_MCS_ANT_INIT_IND;
+       if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ])
+               priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = RATE_MCS_ANT_INIT_IND;
+}
+
 int iwl_scan_initiate(struct iwl_priv *priv)
 {
        if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
@@ -458,7 +486,10 @@ int iwl_scan_initiate(struct iwl_priv *priv)
        }
 
        IWL_DEBUG_INFO("Starting scan...\n");
-       priv->scan_bands = 2;
+       if (priv->cfg->sku & IWL_SKU_G)
+               priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
+       if (priv->cfg->sku & IWL_SKU_A)
+               priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
        set_bit(STATUS_SCANNING, &priv->status);
        priv->scan_start = jiffies;
        priv->scan_pass_start = priv->scan_start;
@@ -522,7 +553,7 @@ static u16 iwl_supported_rate_to_ie(u8 *ie, u16 supported_rate,
 
 
 static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
-                       u8 *pos, int *left)
+                            u8 *pos, int *left)
 {
        struct ieee80211_ht_cap *ht_cap;
 
@@ -547,10 +578,11 @@ static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
 /**
  * iwl_fill_probe_req - fill in all required fields and IE for probe request
  */
+
 static u16 iwl_fill_probe_req(struct iwl_priv *priv,
                                  enum ieee80211_band band,
                                  struct ieee80211_mgmt *frame,
-                                 int left, int is_direct)
+                                 int left)
 {
        int len = 0;
        u8 *pos = NULL;
@@ -558,12 +590,12 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv,
        const struct ieee80211_supported_band *sband =
                                                iwl_get_hw_mode(priv, band);
 
+
        /* Make sure there is enough space for the probe request,
         * two mandatory IEs and the data */
        left -= 24;
        if (left < 0)
                return 0;
-       len += 24;
 
        frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
        memcpy(frame->da, iwl_bcast_addr, ETH_ALEN);
@@ -571,38 +603,25 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv,
        memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN);
        frame->seq_ctrl = 0;
 
-       /* fill in our indirect SSID IE */
+       len += 24;
+
        /* ...next IE... */
+       pos = &frame->u.probe_req.variable[0];
 
+       /* fill in our indirect SSID IE */
        left -= 2;
        if (left < 0)
                return 0;
-       len += 2;
-       pos = &(frame->u.probe_req.variable[0]);
        *pos++ = WLAN_EID_SSID;
        *pos++ = 0;
 
-       /* fill in our direct SSID IE... */
-       if (is_direct) {
-               /* ...next IE... */
-               left -= 2 + priv->essid_len;
-               if (left < 0)
-                       return 0;
-               /* ... fill it in... */
-               *pos++ = WLAN_EID_SSID;
-               *pos++ = priv->essid_len;
-               memcpy(pos, priv->essid, priv->essid_len);
-               pos += priv->essid_len;
-               len += 2 + priv->essid_len;
-       }
+       len += 2;
 
        /* fill in supported rate */
-       /* ...next IE... */
        left -= 2;
        if (left < 0)
                return 0;
 
-       /* ... fill it in... */
        *pos++ = WLAN_EID_SUPP_RATES;
        *pos = 0;
 
@@ -614,15 +633,16 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv,
 
        cck_rates = IWL_CCK_RATES_MASK & active_rates;
        ret_rates = iwl_supported_rate_to_ie(pos, cck_rates,
-                       active_rate_basic, &left);
+                                            active_rate_basic, &left);
        active_rates &= ~ret_rates;
 
        ret_rates = iwl_supported_rate_to_ie(pos, active_rates,
-                                active_rate_basic, &left);
+                                            active_rate_basic, &left);
        active_rates &= ~ret_rates;
 
        len += 2 + *pos;
        pos += (*pos) + 1;
+
        if (active_rates == 0)
                goto fill_end;
 
@@ -634,27 +654,46 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv,
        /* ... fill it in... */
        *pos++ = WLAN_EID_EXT_SUPP_RATES;
        *pos = 0;
-       iwl_supported_rate_to_ie(pos, active_rates,
-                                active_rate_basic, &left);
-       if (*pos > 0)
+       iwl_supported_rate_to_ie(pos, active_rates, active_rate_basic, &left);
+       if (*pos > 0) {
                len += 2 + *pos;
+               pos += (*pos) + 1;
+       } else {
+               pos--;
+       }
 
  fill_end:
-       /* fill in HT IE */
+
        left -= 2;
        if (left < 0)
                return 0;
 
        *pos++ = WLAN_EID_HT_CAPABILITY;
        *pos = 0;
-
        iwl_ht_cap_to_ie(sband, pos, &left);
-
        if (*pos > 0)
                len += 2 + *pos;
+
        return (u16)len;
 }
 
+static u32 iwl_scan_tx_ant(struct iwl_priv *priv, enum ieee80211_band band)
+{
+       int i, ind;
+
+       ind = priv->scan_tx_ant[band];
+       for (i = 0; i < priv->hw_params.tx_chains_num; i++) {
+               ind = (ind+1) >= priv->hw_params.tx_chains_num ? 0 : ind+1;
+               if (priv->hw_params.valid_tx_ant & (1 << ind)) {
+                       priv->scan_tx_ant[band] = ind;
+                       break;
+               }
+       }
+       IWL_DEBUG_SCAN("select TX ANT = %c\n", 'A' + ind);
+       return scan_tx_ant[ind];
+}
+
+
 static void iwl_bg_request_scan(struct work_struct *data)
 {
        struct iwl_priv *priv =
@@ -666,10 +705,12 @@ static void iwl_bg_request_scan(struct work_struct *data)
        };
        struct iwl_scan_cmd *scan;
        struct ieee80211_conf *conf = NULL;
+       int ret = 0;
+       u32 tx_ant;
        u16 cmd_len;
        enum ieee80211_band band;
-       u8 direct_mask;
-       int ret = 0;
+       u8 n_probes = 2;
+       u8 rx_chain = 0x7; /* bitmap: ABC chains */
 
        conf = ieee80211_get_hw_conf(priv->hw);
 
@@ -761,26 +802,23 @@ static void iwl_bg_request_scan(struct work_struct *data)
 
        /* We should add the ability for user to lock to PASSIVE ONLY */
        if (priv->one_direct_scan) {
-               IWL_DEBUG_SCAN
-                   ("Kicking off one direct scan for '%s'\n",
-                    iwl_escape_essid(priv->direct_ssid,
-                                     priv->direct_ssid_len));
+               IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
+                               iwl_escape_essid(priv->direct_ssid,
+                               priv->direct_ssid_len));
                scan->direct_scan[0].id = WLAN_EID_SSID;
                scan->direct_scan[0].len = priv->direct_ssid_len;
                memcpy(scan->direct_scan[0].ssid,
                       priv->direct_ssid, priv->direct_ssid_len);
-               direct_mask = 1;
+               n_probes++;
        } else if (!iwl_is_associated(priv) && priv->essid_len) {
-               IWL_DEBUG_SCAN
-                 ("Kicking off one direct scan for '%s' when not associated\n",
-                  iwl_escape_essid(priv->essid, priv->essid_len));
+               IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
+                               iwl_escape_essid(priv->essid, priv->essid_len));
                scan->direct_scan[0].id = WLAN_EID_SSID;
                scan->direct_scan[0].len = priv->essid_len;
                memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
-               direct_mask = 1;
+               n_probes++;
        } else {
-               IWL_DEBUG_SCAN("Kicking off one indirect scan.\n");
-               direct_mask = 0;
+               IWL_DEBUG_SCAN("Start indirect scan.\n");
        }
 
        scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
@@ -788,65 +826,65 @@ static void iwl_bg_request_scan(struct work_struct *data)
        scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
 
 
-       switch (priv->scan_bands) {
-       case 2:
+       if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
+               band = IEEE80211_BAND_2GHZ;
                scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
-               scan->tx_cmd.rate_n_flags =
-                               iwl4965_hw_set_rate_n_flags(IWL_RATE_1M_PLCP,
-                               RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK);
-
+               tx_ant = iwl_scan_tx_ant(priv, band);
+               if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK)
+                       scan->tx_cmd.rate_n_flags =
+                               iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
+                                                       tx_ant);
+               else
+                       scan->tx_cmd.rate_n_flags =
+                               iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP,
+                                                       tx_ant |
+                                                       RATE_MCS_CCK_MSK);
                scan->good_CRC_th = 0;
-               band = IEEE80211_BAND_2GHZ;
-               break;
-
-       case 1:
+       } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
+               band = IEEE80211_BAND_5GHZ;
+               tx_ant = iwl_scan_tx_ant(priv, band);
                scan->tx_cmd.rate_n_flags =
-                               iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
-                               RATE_MCS_ANT_B_MSK);
+                               iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
+                                                       tx_ant);
                scan->good_CRC_th = IWL_GOOD_CRC_TH;
-               band = IEEE80211_BAND_5GHZ;
-               break;
 
-       default:
+               /* Force use of chains B and C (0x6) for scan Rx for 4965
+                * Avoid A (0x1) because of its off-channel reception on A-band.
+                * MIMO is not used here, but value is required */
+               if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
+                       rx_chain = 0x6;
+       } else {
                IWL_WARNING("Invalid scan band count\n");
                goto done;
        }
 
-       /* We don't build a direct scan probe request; the uCode will do
-        * that based on the direct_mask added to each channel entry */
+       scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK |
+                               cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) |
+                               (rx_chain << RXON_RX_CHAIN_FORCE_SEL_POS) |
+                               (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS));
+
        cmd_len = iwl_fill_probe_req(priv, band,
-                                       (struct ieee80211_mgmt *)scan->data,
-                                       IWL_MAX_SCAN_SIZE - sizeof(*scan), 0);
+                                    (struct ieee80211_mgmt *)scan->data,
+                                    IWL_MAX_SCAN_SIZE - sizeof(*scan));
 
        scan->tx_cmd.len = cpu_to_le16(cmd_len);
-       /* select Rx chains */
-
-       /* Force use of chains B and C (0x6) for scan Rx.
-        * Avoid A (0x1) because of its off-channel reception on A-band.
-        * MIMO is not used here, but value is required to make uCode happy. */
-       scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK |
-                       cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) |
-                       (0x6 << RXON_RX_CHAIN_FORCE_SEL_POS) |
-                       (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS));
 
        if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
                scan->filter_flags = RXON_FILTER_PROMISC_MSK;
 
-       if (direct_mask)
-               scan->channel_count =
-                       iwl_get_channels_for_scan(
-                               priv, band, 1, /* active */
-                               direct_mask,
-                               (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
-       else
-               scan->channel_count =
-                       iwl_get_channels_for_scan(
-                               priv, band, 0, /* passive */
-                               direct_mask,
-                               (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
-
        scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
                               RXON_FILTER_BCON_AWARE_MSK);
+
+       scan->channel_count =
+               iwl_get_channels_for_scan(priv, band, 1, /* active */
+                       n_probes,
+                       (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+
+       if (scan->channel_count == 0) {
+               IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count);
+               goto done;
+       }
+
        cmd.len += le16_to_cpu(scan->tx_cmd.len) +
            scan->channel_count * sizeof(struct iwl_scan_channel);
        cmd.data = scan;