]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl3945-base.c
iwl3945: do not delay hardware scan if it is a direct scan
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index 8c2036850c89ee93e18bd0548134d7762c0620a4..4baa185ba500abe6d0418b34edfc7ffd0fa25a43 100644 (file)
@@ -70,7 +70,7 @@ static int iwl3945_param_disable;  /* def: 0 = enable radio */
 static int iwl3945_param_antenna;  /* def: 0 = both antennas (use diversity) */
 int iwl3945_param_hwcrypto;        /* def: 0 = use software encryption */
 static int iwl3945_param_qos_enable = 1; /* def: 1 = use quality of service */
-int iwl3945_param_queues_num = IWL_MAX_NUM_QUEUES; /* def: 8 Tx queues */
+int iwl3945_param_queues_num = IWL39_MAX_NUM_QUEUES; /* def: 8 Tx queues */
 
 /*
  * module name, copyright, version, etc.
@@ -733,17 +733,17 @@ static int iwl3945_send_cmd_sync(struct iwl3945_priv *priv, struct iwl3945_host_
 {
        int cmd_idx;
        int ret;
-       static atomic_t entry = ATOMIC_INIT(0); /* reentrance protection */
 
        BUG_ON(cmd->meta.flags & CMD_ASYNC);
 
         /* A synchronous command can not have a callback set. */
        BUG_ON(cmd->meta.u.callback != NULL);
 
-       if (atomic_xchg(&entry, 1)) {
+       if (test_and_set_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status)) {
                IWL_ERROR("Error sending %s: Already sending a host command\n",
                          get_cmd_string(cmd->id));
-               return -EBUSY;
+               ret = -EBUSY;
+               goto out;
        }
 
        set_bit(STATUS_HCMD_ACTIVE, &priv->status);
@@ -813,7 +813,7 @@ fail:
                cmd->meta.u.skb = NULL;
        }
 out:
-       atomic_set(&entry, 0);
+       clear_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status);
        return ret;
 }
 
@@ -2391,7 +2391,8 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
                                      struct sk_buff *skb_frag,
                                      int last_frag)
 {
-       struct iwl3945_hw_key *keyinfo = &priv->stations[ctl->key_idx].keyinfo;
+       struct iwl3945_hw_key *keyinfo =
+           &priv->stations[ctl->hw_key->hw_key_idx].keyinfo;
 
        switch (keyinfo->alg) {
        case ALG_CCMP:
@@ -2414,7 +2415,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
 
        case ALG_WEP:
                cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP |
-                   (ctl->key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;
+                   (ctl->hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;
 
                if (keyinfo->keylen == 13)
                        cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128;
@@ -2422,7 +2423,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
                memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen);
 
                IWL_DEBUG_TX("Configuring packet for WEP encryption "
-                            "with key %d\n", ctl->key_idx);
+                            "with key %d\n", ctl->hw_key->hw_key_idx);
                break;
 
        default:
@@ -4840,7 +4841,7 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
                        ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
                        ch_info->min_power = 0;
 
-                       IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
+                       IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x"
                                       " %ddBm): Ad-Hoc %ssupported\n",
                                       ch_info->channel,
                                       is_channel_a_band(ch_info) ?
@@ -4850,7 +4851,6 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
                                       CHECK_AND_PRINT(ACTIVE),
                                       CHECK_AND_PRINT(RADAR),
                                       CHECK_AND_PRINT(WIDE),
-                                      CHECK_AND_PRINT(NARROW),
                                       CHECK_AND_PRINT(DFS),
                                       eeprom_ch_info[ch].flags,
                                       eeprom_ch_info[ch].max_power_avg,
@@ -4965,15 +4965,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
        passive_dwell = iwl3945_get_passive_dwell_time(priv, band);
 
        for (i = 0, added = 0; i < sband->n_channels; i++) {
-               if (channels[i].hw_value ==
-                   le16_to_cpu(priv->active_rxon.channel)) {
-                       if (iwl3945_is_associated(priv)) {
-                               IWL_DEBUG_SCAN
-                                   ("Skipping current channel %d\n",
-                                    le16_to_cpu(priv->active_rxon.channel));
-                               continue;
-                       }
-               } else if (priv->only_active_channel)
+               if (channels[i].flags & IEEE80211_CHAN_DISABLED)
                        continue;
 
                scan_ch->channel = channels[i].hw_value;
@@ -4994,9 +4986,6 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
                if (scan_ch->type & 1)
                        scan_ch->type |= (direct_mask << 1);
 
-               if (is_channel_narrow(ch_info))
-                       scan_ch->type |= (1 << 7);
-
                scan_ch->active_dwell = cpu_to_le16(active_dwell);
                scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
 
@@ -5874,15 +5863,16 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
 
        iwl3945_reg_txpower_periodic(priv);
 
+       iwl3945_led_register(priv);
+
        IWL_DEBUG_INFO("ALIVE processing complete.\n");
        set_bit(STATUS_READY, &priv->status);
        wake_up_interruptible(&priv->wait_command_queue);
 
-       iwl3945_led_register(priv);
-
        if (priv->error_recovering)
                iwl3945_error_recovery(priv);
 
+       ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
        return;
 
  restart:
@@ -6154,6 +6144,24 @@ static void iwl3945_bg_rf_kill(struct work_struct *work)
        mutex_unlock(&priv->mutex);
 }
 
+static void iwl3945_bg_set_monitor(struct work_struct *work)
+{
+       struct iwl3945_priv *priv = container_of(work,
+                               struct iwl3945_priv, set_monitor);
+
+       IWL_DEBUG(IWL_DL_STATE, "setting monitor mode\n");
+
+       mutex_lock(&priv->mutex);
+
+       if (!iwl3945_is_ready(priv))
+               IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n");
+       else
+               if (iwl3945_set_mode(priv, IEEE80211_IF_TYPE_MNTR) != 0)
+                       IWL_ERROR("iwl3945_set_mode() failed\n");
+
+       mutex_unlock(&priv->mutex);
+}
+
 #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
 
 static void iwl3945_bg_scan_check(struct work_struct *data)
@@ -6299,12 +6307,17 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
                       priv->direct_ssid, priv->direct_ssid_len);
                direct_mask = 1;
        } else if (!iwl3945_is_associated(priv) && priv->essid_len) {
+               IWL_DEBUG_SCAN
+                 ("Kicking off one direct scan for '%s' when not associated\n",
+                  iwl3945_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;
-       } else
+       } else {
+               IWL_DEBUG_SCAN("Kicking off one indirect scan.\n");
                direct_mask = 0;
+       }
 
        /* We don't build a direct scan probe request; the uCode will do
         * that based on the direct_mask added to each channel entry */
@@ -6342,23 +6355,18 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
        if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
                scan->filter_flags = RXON_FILTER_PROMISC_MSK;
 
-       if (direct_mask) {
-               IWL_DEBUG_SCAN
-                   ("Initiating direct scan for %s.\n",
-                    iwl3945_escape_essid(priv->essid, priv->essid_len));
+       if (direct_mask)
                scan->channel_count =
                        iwl3945_get_channels_for_scan(
                                priv, band, 1, /* active */
                                direct_mask,
                                (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
-       } else {
-               IWL_DEBUG_SCAN("Initiating indirect scan.\n");
+       else
                scan->channel_count =
                        iwl3945_get_channels_for_scan(
                                priv, band, 0, /* passive */
                                direct_mask,
                                (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
-       }
 
        cmd.len += le16_to_cpu(scan->tx_cmd.len) +
            scan->channel_count * sizeof(struct iwl3945_scan_channel);
@@ -6903,7 +6911,6 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
 
        if (priv->vif != vif) {
                IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
-               mutex_unlock(&priv->mutex);
                return 0;
        }
 
@@ -7007,7 +7014,22 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
         * XXX: dummy
         * see also iwl3945_connection_init_rx_config
         */
-       *total_flags = 0;
+       struct iwl3945_priv *priv = hw->priv;
+       int new_flags = 0;
+       if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) {
+               if (*total_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) {
+                       IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n",
+                                          IEEE80211_IF_TYPE_MNTR,
+                                          changed_flags, *total_flags);
+                       /* queue work 'cuz mac80211 is holding a lock which
+                        * prevents us from issuing (synchronous) f/w cmds */
+                       queue_work(priv->workqueue, &priv->set_monitor);
+                       new_flags &= FIF_PROMISC_IN_BSS |
+                                    FIF_OTHER_BSS |
+                                    FIF_ALLMULTI;
+               }
+       }
+       *total_flags = new_flags;
 }
 
 static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw,
@@ -7065,9 +7087,10 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
                rc = -EAGAIN;
                goto out_unlock;
        }
-       /* if we just finished scan ask for delay */
-       if (priv->last_scan_jiffies && time_after(priv->last_scan_jiffies +
-                               IWL_DELAY_NEXT_SCAN, jiffies)) {
+       /* if we just finished scan ask for delay for a broadcast scan */
+       if ((len == 0) && priv->last_scan_jiffies &&
+           time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN,
+                      jiffies)) {
                rc = -EAGAIN;
                goto out_unlock;
        }
@@ -7154,7 +7177,7 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        return rc;
 }
 
-static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, int queue,
+static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
                           const struct ieee80211_tx_queue_params *params)
 {
        struct iwl3945_priv *priv = hw->priv;
@@ -7228,9 +7251,9 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
                q = &txq->q;
                avail = iwl3945_queue_space(q);
 
-               stats->data[i].len = q->n_window - avail;
-               stats->data[i].limit = q->n_window - q->high_mark;
-               stats->data[i].count = q->n_window;
+               stats[i].len = q->n_window - avail;
+               stats[i].limit = q->n_window - q->high_mark;
+               stats[i].count = q->n_window;
 
        }
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -7311,8 +7334,6 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
                return;
        }
 
-       priv->only_active_channel = 0;
-
        iwl3945_set_rate(priv);
 
        mutex_unlock(&priv->mutex);
@@ -7885,6 +7906,7 @@ static void iwl3945_setup_deferred_work(struct iwl3945_priv *priv)
        INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan);
        INIT_WORK(&priv->rf_kill, iwl3945_bg_rf_kill);
        INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update);
+       INIT_WORK(&priv->set_monitor, iwl3945_bg_set_monitor);
        INIT_DELAYED_WORK(&priv->post_associate, iwl3945_bg_post_associate);
        INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start);
        INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
@@ -7970,10 +7992,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
                iwl3945_hw_ops.hw_scan = NULL;
        }
 
-       if ((iwl3945_param_queues_num > IWL_MAX_NUM_QUEUES) ||
+       if ((iwl3945_param_queues_num > IWL39_MAX_NUM_QUEUES) ||
            (iwl3945_param_queues_num < IWL_MIN_NUM_QUEUES)) {
                IWL_ERROR("invalid queues_num, should be between %d and %d\n",
-                         IWL_MIN_NUM_QUEUES, IWL_MAX_NUM_QUEUES);
+                         IWL_MIN_NUM_QUEUES, IWL39_MAX_NUM_QUEUES);
                err = -EINVAL;
                goto out;
        }