iwlwifi: introduce post_scan hook
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index 68e624a..db148d0 100644 (file)
@@ -1581,16 +1581,16 @@ int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
        num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
        next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
 
-       if (capacity > priv->cfg->max_event_log_size) {
+       if (capacity > priv->cfg->base_params->max_event_log_size) {
                IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
-                       capacity, priv->cfg->max_event_log_size);
-               capacity = priv->cfg->max_event_log_size;
+                       capacity, priv->cfg->base_params->max_event_log_size);
+               capacity = priv->cfg->base_params->max_event_log_size;
        }
 
-       if (next_entry > priv->cfg->max_event_log_size) {
+       if (next_entry > priv->cfg->base_params->max_event_log_size) {
                IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
-                       next_entry, priv->cfg->max_event_log_size);
-               next_entry = priv->cfg->max_event_log_size;
+                       next_entry, priv->cfg->base_params->max_event_log_size);
+               next_entry = priv->cfg->base_params->max_event_log_size;
        }
 
        size = num_wraps ? capacity : next_entry;
@@ -1730,7 +1730,6 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
                IWL_ERR(priv, "Microcode SW error detected. "
                        "Restarting 0x%X.\n", inta);
                priv->isr_stats.sw++;
-               priv->isr_stats.sw_err = inta;
                iwl_irq_handle_error(priv);
                handled |= CSR_INT_BIT_SW_ERR;
        }
@@ -2520,7 +2519,8 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
                /* Enable timer to monitor the driver queues */
                mod_timer(&priv->monitor_recover,
                        jiffies +
-                       msecs_to_jiffies(priv->cfg->monitor_recover_period));
+                       msecs_to_jiffies(
+                         priv->cfg->base_params->monitor_recover_period));
        }
 
        if (iwl_is_rfkill(priv))
@@ -2568,15 +2568,13 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv);
 static void __iwl3945_down(struct iwl_priv *priv)
 {
        unsigned long flags;
-       int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status);
-       struct ieee80211_conf *conf = NULL;
+       int exit_pending;
 
        IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
 
-       conf = ieee80211_get_hw_conf(priv->hw);
+       iwl_scan_cancel_timeout(priv, 200);
 
-       if (!exit_pending)
-               set_bit(STATUS_EXIT_PENDING, &priv->status);
+       exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
 
        /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
         * to prevent rearm timer */
@@ -2820,7 +2818,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
 
 }
 
-void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
+int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
 {
        struct iwl_host_cmd cmd = {
                .id = REPLY_SCAN_CMD,
@@ -2828,61 +2826,19 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                .flags = CMD_SIZE_HUGE,
        };
        struct iwl3945_scan_cmd *scan;
-       struct ieee80211_conf *conf = NULL;
        u8 n_probes = 0;
        enum ieee80211_band band;
        bool is_active = false;
+       int ret;
 
-       conf = ieee80211_get_hw_conf(priv->hw);
-
-       cancel_delayed_work(&priv->scan_check);
-
-       if (!iwl_is_ready(priv)) {
-               IWL_WARN(priv, "request scan called when driver not ready.\n");
-               goto done;
-       }
-
-       /* Make sure the scan wasn't canceled before this queued work
-        * was given the chance to run... */
-       if (!test_bit(STATUS_SCANNING, &priv->status))
-               goto done;
-
-       /* This should never be called or scheduled if there is currently
-        * a scan active in the hardware. */
-       if (test_bit(STATUS_SCAN_HW, &priv->status)) {
-               IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests  "
-                               "Ignoring second request.\n");
-               goto done;
-       }
-
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
-               IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
-               goto done;
-       }
-
-       if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
-               IWL_DEBUG_HC(priv,
-                       "Scan request while abort pending. Queuing.\n");
-               goto done;
-       }
-
-       if (iwl_is_rfkill(priv)) {
-               IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
-               goto done;
-       }
-
-       if (!test_bit(STATUS_READY, &priv->status)) {
-               IWL_DEBUG_HC(priv,
-                       "Scan request while uninitialized. Queuing.\n");
-               goto done;
-       }
+       lockdep_assert_held(&priv->mutex);
 
        if (!priv->scan_cmd) {
                priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) +
                                         IWL_MAX_SCAN_SIZE, GFP_KERNEL);
                if (!priv->scan_cmd) {
                        IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
-                       goto done;
+                       return -ENOMEM;
                }
        }
        scan = priv->scan_cmd;
@@ -2977,7 +2933,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                break;
        default:
                IWL_WARN(priv, "Invalid scan band\n");
-               goto done;
+               return -EIO;
        }
 
        if (!priv->is_internal_short_scan) {
@@ -3012,7 +2968,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
 
        if (scan->channel_count == 0) {
                IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
-               goto done;
+               return -EIO;
        }
 
        cmd.len += le16_to_cpu(scan->tx_cmd.len) +
@@ -3021,25 +2977,22 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        scan->len = cpu_to_le16(cmd.len);
 
        set_bit(STATUS_SCAN_HW, &priv->status);
-       if (iwl_send_cmd_sync(priv, &cmd))
-               goto done;
-
-       queue_delayed_work(priv->workqueue, &priv->scan_check,
-                          IWL_SCAN_CHECK_WATCHDOG);
+       ret = iwl_send_cmd_sync(priv, &cmd);
+       if (ret)
+               clear_bit(STATUS_SCAN_HW, &priv->status);
+       return ret;
+}
 
-       return;
+void iwl3945_post_scan(struct iwl_priv *priv)
+{
+       struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
- done:
-       /* can not perform scan make sure we clear scanning
-        * bits from status so next scan request can be performed.
-        * if we dont clear scanning status bit here all next scan
-        * will fail
-       */
-       clear_bit(STATUS_SCAN_HW, &priv->status);
-       clear_bit(STATUS_SCANNING, &priv->status);
-
-       /* inform mac80211 scan aborted */
-       queue_work(priv->workqueue, &priv->scan_completed);
+       /*
+        * Since setting the RXON may have been deferred while
+        * performing the scan, fire one off if needed
+        */
+       if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
+               iwlcore_commit_rxon(priv, ctx);
 }
 
 static void iwl3945_bg_restart(struct work_struct *data)
@@ -3233,15 +3186,6 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
 
        priv->is_open = 0;
 
-       if (iwl_is_ready_rf(priv)) {
-               /* stop mac, cancel any scan request and clear
-                * RXON_FILTER_ASSOC_MSK BIT
-                */
-               mutex_lock(&priv->mutex);
-               iwl_scan_cancel_timeout(priv, 100);
-               mutex_unlock(&priv->mutex);
-       }
-
        iwl3945_down(priv);
 
        flush_workqueue(priv->workqueue);
@@ -3831,10 +3775,10 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
        iwl3945_hw_cancel_deferred_work(priv);
 
        cancel_delayed_work_sync(&priv->init_alive_start);
-       cancel_delayed_work(&priv->scan_check);
        cancel_delayed_work(&priv->alive_start);
-       cancel_work_sync(&priv->start_internal_scan);
        cancel_work_sync(&priv->beacon_update);
+
+       iwl_cancel_scan_deferred_work(priv);
 }
 
 static struct attribute *iwl3945_sysfs_entries[] = {
@@ -3950,7 +3894,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
        hw->flags = IEEE80211_HW_SIGNAL_DBM |
                    IEEE80211_HW_SPECTRUM_MGMT;
 
-       if (!priv->cfg->broken_powersave)
+       if (!priv->cfg->base_params->broken_powersave)
                hw->flags |= IEEE80211_HW_SUPPORTS_PS |
                             IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
 
@@ -4035,7 +3979,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
         * "the hard way", rather than using device's scan.
         */
        if (iwl3945_mod_params.disable_hw_scan) {
-               IWL_DEBUG_INFO(priv, "Disabling hw_scan\n");
+               IWL_ERR(priv, "sw scan support is deprecated\n");
                iwl3945_hw_ops.hw_scan = NULL;
        }
 
@@ -4360,7 +4304,8 @@ MODULE_PARM_DESC(debug, "debug output mask");
 #endif
 module_param_named(disable_hw_scan, iwl3945_mod_params.disable_hw_scan,
                   int, S_IRUGO);
-MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
+MODULE_PARM_DESC(disable_hw_scan,
+                "disable hardware scanning (default 0) (deprecated)");
 module_param_named(fw_restart3945, iwl3945_mod_params.restart_fw, int, S_IRUGO);
 MODULE_PARM_DESC(fw_restart3945, "restart firmware in case of error");