iwlagn: remove priv dereferences from the transport layer
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-core.c
index cf376f62b2f6b3d5dea8c7d13d61a4a313fd3957..d9897da7281f52829e2df4722c4e8271ea76ea0a 100644 (file)
 #include "iwl-io.h"
 #include "iwl-power.h"
 #include "iwl-sta.h"
+#include "iwl-agn.h"
 #include "iwl-helpers.h"
+#include "iwl-shared.h"
 #include "iwl-agn.h"
 #include "iwl-trans.h"
 
-u32 iwl_debug_level;
-
 const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 
 #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
 #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
-static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
+static void iwl_init_ht_hw_capab(const struct iwl_priv *priv,
                              struct ieee80211_sta_ht_cap *ht_info,
                              enum ieee80211_band band)
 {
        u16 max_bit_rate = 0;
-       u8 rx_chains_num = priv->hw_params.rx_chains_num;
-       u8 tx_chains_num = priv->hw_params.tx_chains_num;
+       u8 rx_chains_num = hw_params(priv).rx_chains_num;
+       u8 tx_chains_num = hw_params(priv).tx_chains_num;
 
        ht_info->cap = 0;
        memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
@@ -68,7 +68,7 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
                ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD;
        ht_info->cap |= IEEE80211_HT_CAP_SGI_20;
        max_bit_rate = MAX_BIT_RATE_20_MHZ;
-       if (priv->hw_params.ht40_channel & BIT(band)) {
+       if (hw_params(priv).ht40_channel & BIT(band)) {
                ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
                ht_info->cap |= IEEE80211_HT_CAP_SGI_40;
                ht_info->mcs.rx_mask[4] = 0x01;
@@ -106,9 +106,9 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
 }
 
 /**
- * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom
+ * iwl_init_geos - Initialize mac80211's geo/channel info based from eeprom
  */
-int iwlcore_init_geos(struct iwl_priv *priv)
+int iwl_init_geos(struct iwl_priv *priv)
 {
        struct iwl_channel_info *ch;
        struct ieee80211_supported_band *sband;
@@ -121,7 +121,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
        if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
            priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
                IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n");
-               set_bit(STATUS_GEO_CONFIGURED, &priv->status);
+               set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
                return 0;
        }
 
@@ -145,7 +145,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
        sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE;
 
        if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)
-               iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
+               iwl_init_ht_hw_capab(priv, &sband->ht_cap,
                                         IEEE80211_BAND_5GHZ);
 
        sband = &priv->bands[IEEE80211_BAND_2GHZ];
@@ -155,7 +155,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
        sband->n_bitrates = IWL_RATE_COUNT_LEGACY;
 
        if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)
-               iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
+               iwl_init_ht_hw_capab(priv, &sband->ht_cap,
                                         IEEE80211_BAND_2GHZ);
 
        priv->ieee_channels = channels;
@@ -221,19 +221,19 @@ int iwlcore_init_geos(struct iwl_priv *priv)
                   priv->bands[IEEE80211_BAND_2GHZ].n_channels,
                   priv->bands[IEEE80211_BAND_5GHZ].n_channels);
 
-       set_bit(STATUS_GEO_CONFIGURED, &priv->status);
+       set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
 
        return 0;
 }
 
 /*
- * iwlcore_free_geos - undo allocations in iwlcore_init_geos
+ * iwl_free_geos - undo allocations in iwl_init_geos
  */
-void iwlcore_free_geos(struct iwl_priv *priv)
+void iwl_free_geos(struct iwl_priv *priv)
 {
        kfree(priv->ieee_channels);
        kfree(priv->ieee_rates);
-       clear_bit(STATUS_GEO_CONFIGURED, &priv->status);
+       clear_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
 }
 
 static bool iwl_is_channel_extension(struct iwl_priv *priv,
@@ -325,7 +325,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 
        conf = ieee80211_get_hw_conf(priv->hw);
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd));
 
@@ -359,7 +359,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
        } else {
                beacon_int = iwl_adjust_beacon_interval(beacon_int,
-                               priv->hw_params.max_beacon_itrvl * TIME_UNIT);
+                       IWL_MAX_UCODE_BEACON_INTERVAL * TIME_UNIT);
                ctx->timing.beacon_interval = cpu_to_le16(beacon_int);
        }
 
@@ -378,7 +378,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                        le32_to_cpu(ctx->timing.beacon_init_val),
                        le16_to_cpu(ctx->timing.atim_window));
 
-       return trans_send_cmd_pdu(&priv->trans, ctx->rxon_timing_cmd,
+       return iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_timing_cmd,
                                CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
 }
 
@@ -808,10 +808,11 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
         */
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
-       if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
+       if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING,
+                               &priv->shrd->status))
                ieee80211_chswitch_done(ctx->vif, is_success);
 }
 
@@ -856,18 +857,18 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
        unsigned long reload_jiffies;
 
        /* Set the FW error flag -- cleared on iwl_down */
-       set_bit(STATUS_FW_ERROR, &priv->status);
+       set_bit(STATUS_FW_ERROR, &priv->shrd->status);
 
        /* Cancel currently queued command. */
-       clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
+       clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status);
 
        iwlagn_abort_notification_waits(priv);
 
        /* Keep the restart process from trying to send host
         * commands by clearing the ready bit */
-       clear_bit(STATUS_READY, &priv->status);
+       clear_bit(STATUS_READY, &priv->shrd->status);
 
-       wake_up_interruptible(&priv->wait_command_queue);
+       wake_up_interruptible(&priv->shrd->wait_command_queue);
 
        if (!ondemand) {
                /*
@@ -890,63 +891,26 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
                        priv->reload_count = 0;
        }
 
-       if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+       if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
                if (iwlagn_mod_params.restart_fw) {
-                       IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
+                       IWL_DEBUG_FW_ERRORS(priv,
                                  "Restarting adapter due to uCode error.\n");
-                       queue_work(priv->workqueue, &priv->restart);
+                       queue_work(priv->shrd->workqueue, &priv->restart);
                } else
-                       IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
+                       IWL_DEBUG_FW_ERRORS(priv,
                                  "Detected FW error, but not restarting\n");
        }
 }
 
-/**
- * iwl_irq_handle_error - called for HW or SW error interrupt from card
- */
-void iwl_irq_handle_error(struct iwl_priv *priv)
-{
-       /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
-       if (priv->cfg->internal_wimax_coex &&
-           (!(iwl_read_prph(priv, APMG_CLK_CTRL_REG) &
-                       APMS_CLK_VAL_MRB_FUNC_MODE) ||
-            (iwl_read_prph(priv, APMG_PS_CTRL_REG) &
-                       APMG_PS_CTRL_VAL_RESET_REQ))) {
-               /*
-                * Keep the restart process from trying to send host
-                * commands by clearing the ready bit.
-                */
-               clear_bit(STATUS_READY, &priv->status);
-               clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
-               wake_up_interruptible(&priv->wait_command_queue);
-               IWL_ERR(priv, "RF is used by WiMAX\n");
-               return;
-       }
-
-       IWL_ERR(priv, "Loaded firmware version: %s\n",
-               priv->hw->wiphy->fw_version);
-
-       iwl_dump_nic_error_log(priv);
-       iwl_dump_csr(priv);
-       iwl_dump_fh(priv, NULL, false);
-       iwl_dump_nic_event_log(priv, false, NULL, false);
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS)
-               iwl_print_rx_config_cmd(priv,
-                                       &priv->contexts[IWL_RXON_CTX_BSS]);
-#endif
-
-       iwlagn_fw_error(priv, false);
-}
-
 static int iwl_apm_stop_master(struct iwl_priv *priv)
 {
        int ret = 0;
 
        /* stop device's busmaster DMA activity */
-       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
+       iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
 
-       ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED,
+       ret = iwl_poll_bit(bus(priv), CSR_RESET,
+                       CSR_RESET_REG_FLAG_MASTER_DISABLED,
                        CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
        if (ret)
                IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n");
@@ -960,13 +924,13 @@ void iwl_apm_stop(struct iwl_priv *priv)
 {
        IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n");
 
-       clear_bit(STATUS_DEVICE_ENABLED, &priv->status);
+       clear_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
 
        /* Stop device's DMA activity */
        iwl_apm_stop_master(priv);
 
        /* Reset the entire device */
-       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
+       iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
 
        udelay(10);
 
@@ -974,7 +938,7 @@ void iwl_apm_stop(struct iwl_priv *priv)
         * Clear "initialization complete" bit to move adapter from
         * D0A* (powered-up Active) --> D0U* (Uninitialized) state.
         */
-       iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
+       iwl_clear_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 }
 
 
@@ -994,45 +958,45 @@ int iwl_apm_init(struct iwl_priv *priv)
         */
 
        /* Disable L0S exit timer (platform NMI Work/Around) */
-       iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
+       iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS,
                          CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
 
        /*
         * Disable L0s without affecting L1;
         *  don't wait for ICH L0s (ICH bug W/A)
         */
-       iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
+       iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS,
                          CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
 
        /* Set FH wait threshold to maximum (HW error during stress W/A) */
-       iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
+       iwl_set_bit(bus(priv), CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
 
        /*
         * Enable HAP INTA (interrupt from management bus) to
         * wake device's PCI Express link L1a -> L0s
         */
-       iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
+       iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
                                    CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
 
        bus_apm_config(priv->bus);
 
        /* Configure analog phase-lock-loop before activating to D0A */
        if (priv->cfg->base_params->pll_cfg_val)
-               iwl_set_bit(priv, CSR_ANA_PLL_CFG,
+               iwl_set_bit(bus(priv), CSR_ANA_PLL_CFG,
                            priv->cfg->base_params->pll_cfg_val);
 
        /*
         * Set "initialization complete" bit to move adapter from
         * D0U* --> D0A* (powered-up active) state.
         */
-       iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
+       iwl_set_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
        /*
         * Wait for clock stabilization; once stabilized, access to
         * device-internal resources is supported, e.g. iwl_write_prph()
         * and accesses to uCode SRAM.
         */
-       ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+       ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL,
                        CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
                        CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
        if (ret < 0) {
@@ -1047,14 +1011,14 @@ int iwl_apm_init(struct iwl_priv *priv)
         * do not disable clocks.  This preserves any hardware bits already
         * set by default in "CLK_CTRL_REG" after reset.
         */
-       iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
+       iwl_write_prph(bus(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
        udelay(20);
 
        /* Disable L1-Active */
-       iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
+       iwl_set_bits_prph(bus(priv), APMG_PCIDEV_STT_REG,
                          APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
 
-       set_bit(STATUS_DEVICE_ENABLED, &priv->status);
+       set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
 
 out:
        return ret;
@@ -1068,7 +1032,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
        bool defer;
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (priv->tx_power_user_lmt == tx_power && !force)
                return 0;
@@ -1088,7 +1052,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
                return -EINVAL;
        }
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return -EIO;
 
        /* scan complete and commit_rxon use tx_power_next value,
@@ -1096,7 +1060,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
        priv->tx_power_next = tx_power;
 
        /* do not set tx power when scanning or channel changing */
-       defer = test_bit(STATUS_SCANNING, &priv->status) ||
+       defer = test_bit(STATUS_SCANNING, &priv->shrd->status) ||
                memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging));
        if (defer && !force) {
                IWL_DEBUG_INFO(priv, "Deferring tx power set\n");
@@ -1134,7 +1098,7 @@ void iwl_send_bt_config(struct iwl_priv *priv)
        IWL_DEBUG_INFO(priv, "BT coex %s\n",
                (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
 
-       if (trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
+       if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
                             CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd))
                IWL_ERR(priv, "failed to send BT Coex Config\n");
 }
@@ -1147,22 +1111,17 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
        };
 
        if (flags & CMD_ASYNC)
-               return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
+               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
                                              CMD_ASYNC,
                                               sizeof(struct iwl_statistics_cmd),
                                               &statistics_cmd);
        else
-               return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
+               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
                                        CMD_SYNC,
                                        sizeof(struct iwl_statistics_cmd),
                                        &statistics_cmd);
 }
 
-void iwl_clear_isr_stats(struct iwl_priv *priv)
-{
-       memset(&priv->isr_stats, 0, sizeof(priv->isr_stats));
-}
-
 int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
                           const struct ieee80211_tx_queue_params *params)
 {
@@ -1173,7 +1132,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       if (!iwl_is_ready_rf(priv)) {
+       if (!iwl_is_ready_rf(priv->shrd)) {
                IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
                return -EIO;
        }
@@ -1185,7 +1144,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
 
        q = AC_NUM - 1 - queue;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->shrd->lock, flags);
 
        /*
         * MULTI-FIXME
@@ -1203,7 +1162,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
                ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0;
        }
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->lock, flags);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return 0;
@@ -1231,7 +1190,7 @@ static int iwl_setup_interface(struct iwl_priv *priv,
        struct ieee80211_vif *vif = ctx->vif;
        int err;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        /*
         * This variable will be correct only when there's just
@@ -1273,9 +1232,13 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n",
                           viftype, vif->addr);
 
-       mutex_lock(&priv->mutex);
+       cancel_delayed_work_sync(&priv->hw_roc_disable_work);
+
+       mutex_lock(&priv->shrd->mutex);
 
-       if (!iwl_is_ready_rf(priv)) {
+       iwlagn_disable_roc(priv);
+
+       if (!iwl_is_ready_rf(priv->shrd)) {
                IWL_WARN(priv, "Try to add interface when device not ready\n");
                err = -EINVAL;
                goto out;
@@ -1318,7 +1281,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        ctx->vif = NULL;
        priv->iw_mode = NL80211_IFTYPE_STATION;
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return err;
@@ -1330,7 +1293,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv,
 {
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (priv->scan_vif == vif) {
                iwl_scan_cancel_timeout(priv, 200);
@@ -1362,14 +1325,14 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        WARN_ON(ctx->vif != vif);
        ctx->vif = NULL;
 
        iwl_teardown_interface(priv, vif, false);
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
@@ -1393,7 +1356,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv)
 {
        u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE;
 
-       if (iwl_debug_level & IWL_DL_TX) {
+       if (iwl_get_debug_level(priv->shrd) & IWL_DL_TX) {
                if (!priv->tx_traffic) {
                        priv->tx_traffic =
                                kzalloc(traffic_size, GFP_KERNEL);
@@ -1401,7 +1364,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv)
                                return -ENOMEM;
                }
        }
-       if (iwl_debug_level & IWL_DL_RX) {
+       if (iwl_get_debug_level(priv->shrd) & IWL_DL_RX) {
                if (!priv->rx_traffic) {
                        priv->rx_traffic =
                                kzalloc(traffic_size, GFP_KERNEL);
@@ -1428,7 +1391,7 @@ void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
        __le16 fc;
        u16 len;
 
-       if (likely(!(iwl_debug_level & IWL_DL_TX)))
+       if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_TX)))
                return;
 
        if (!priv->tx_traffic)
@@ -1452,7 +1415,7 @@ void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
        __le16 fc;
        u16 len;
 
-       if (likely(!(iwl_debug_level & IWL_DL_RX)))
+       if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_RX)))
                return;
 
        if (!priv->rx_traffic)
@@ -1609,7 +1572,7 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
 
 static void iwl_force_rf_reset(struct iwl_priv *priv)
 {
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        if (!iwl_is_any_associated(priv)) {
@@ -1634,7 +1597,7 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external)
 {
        struct iwl_force_reset *force_reset;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return -EINVAL;
 
        if (mode >= IWL_MAX_FORCE_RESET) {
@@ -1693,9 +1656,9 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
        newtype = ieee80211_iftype_p2p(newtype, newp2p);
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
-       if (!ctx->vif || !iwl_is_ready_rf(priv)) {
+       if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) {
                /*
                 * Huh? But wait ... this can maybe happen when
                 * we're in the middle of a firmware restart!
@@ -1757,36 +1720,16 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        err = 0;
 
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        return err;
 }
 
-/*
- * On every watchdog tick we check (latest) time stamp. If it does not
- * change during timeout period and queue is not empty we reset firmware.
- */
-static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt)
+static inline int iwl_check_stuck_queue(struct iwl_priv *priv, int txq)
 {
-       struct iwl_tx_queue *txq = &priv->txq[cnt];
-       struct iwl_queue *q = &txq->q;
-       unsigned long timeout;
-       int ret;
-
-       if (q->read_ptr == q->write_ptr) {
-               txq->time_stamp = jiffies;
-               return 0;
-       }
-
-       timeout = txq->time_stamp +
-                 msecs_to_jiffies(priv->cfg->base_params->wd_timeout);
-
-       if (time_after(jiffies, timeout)) {
-               IWL_ERR(priv, "Queue %d stuck for %u ms.\n",
-                               q->id, priv->cfg->base_params->wd_timeout);
-               ret = iwl_force_reset(priv, IWL_FW_RESET, false);
+       if (iwl_trans_check_stuck_queue(trans(priv), txq)) {
+               int ret = iwl_force_reset(priv, IWL_FW_RESET, false);
                return (ret == -EAGAIN) ? 0 : 1;
        }
-
        return 0;
 }
 
@@ -1806,7 +1749,7 @@ void iwl_bg_watchdog(unsigned long data)
        int cnt;
        unsigned long timeout;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        timeout = priv->cfg->base_params->wd_timeout;
@@ -1814,14 +1757,14 @@ void iwl_bg_watchdog(unsigned long data)
                return;
 
        /* monitor and check for stuck cmd queue */
-       if (iwl_check_stuck_queue(priv, priv->cmd_queue))
+       if (iwl_check_stuck_queue(priv, priv->shrd->cmd_queue))
                return;
 
        /* monitor and check for other stuck queues */
        if (iwl_is_any_associated(priv)) {
-               for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
+               for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) {
                        /* skip as we already checked the command queue */
-                       if (cnt == priv->cmd_queue)
+                       if (cnt == priv->shrd->cmd_queue)
                                continue;
                        if (iwl_check_stuck_queue(priv, cnt))
                                return;
@@ -1860,12 +1803,12 @@ u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval)
 
        quot = (usec / interval) &
                (iwl_beacon_time_mask_high(priv,
-               priv->hw_params.beacon_time_tsf_bits) >>
-               priv->hw_params.beacon_time_tsf_bits);
+               hw_params(priv).beacon_time_tsf_bits) >>
+               hw_params(priv).beacon_time_tsf_bits);
        rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
-                                  priv->hw_params.beacon_time_tsf_bits);
+                                  hw_params(priv).beacon_time_tsf_bits);
 
-       return (quot << priv->hw_params.beacon_time_tsf_bits) + rem;
+       return (quot << hw_params(priv).beacon_time_tsf_bits) + rem;
 }
 
 /* base is usually what we get from ucode with each received frame,
@@ -1875,64 +1818,55 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
                           u32 addon, u32 beacon_interval)
 {
        u32 base_low = base & iwl_beacon_time_mask_low(priv,
-                                       priv->hw_params.beacon_time_tsf_bits);
+                               hw_params(priv).beacon_time_tsf_bits);
        u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
-                                       priv->hw_params.beacon_time_tsf_bits);
+                               hw_params(priv).beacon_time_tsf_bits);
        u32 interval = beacon_interval * TIME_UNIT;
        u32 res = (base & iwl_beacon_time_mask_high(priv,
-                               priv->hw_params.beacon_time_tsf_bits)) +
+                               hw_params(priv).beacon_time_tsf_bits)) +
                                (addon & iwl_beacon_time_mask_high(priv,
-                               priv->hw_params.beacon_time_tsf_bits));
+                               hw_params(priv).beacon_time_tsf_bits));
 
        if (base_low > addon_low)
                res += base_low - addon_low;
        else if (base_low < addon_low) {
                res += interval + base_low - addon_low;
-               res += (1 << priv->hw_params.beacon_time_tsf_bits);
+               res += (1 << hw_params(priv).beacon_time_tsf_bits);
        } else
-               res += (1 << priv->hw_params.beacon_time_tsf_bits);
+               res += (1 << hw_params(priv).beacon_time_tsf_bits);
 
        return cpu_to_le32(res);
 }
 
-#ifdef CONFIG_PM
-
-int iwl_suspend(struct iwl_priv *priv)
+void iwl_start_tx_ba_trans_ready(struct iwl_priv *priv,
+                                enum iwl_rxon_context_id ctx,
+                                u8 sta_id, u8 tid)
 {
-       /*
-        * This function is called when system goes into suspend state
-        * mac80211 will call iwl_mac_stop() from the mac80211 suspend function
-        * first but since iwl_mac_stop() has no knowledge of who the caller is,
-        * it will not call apm_ops.stop() to stop the DMA operation.
-        * Calling apm_ops.stop here to make sure we stop the DMA.
-        *
-        * But of course ... if we have configured WoWLAN then we did other
-        * things already :-)
-        */
-       if (!priv->wowlan)
-               iwl_apm_stop(priv);
+       struct ieee80211_vif *vif;
+       u8 *addr = priv->stations[sta_id].sta.sta.addr;
 
-       return 0;
+       if (ctx == NUM_IWL_RXON_CTX)
+               ctx = priv->stations[sta_id].ctxid;
+       vif = priv->contexts[ctx].vif;
+
+       ieee80211_start_tx_ba_cb_irqsafe(vif, addr, tid);
 }
 
-int iwl_resume(struct iwl_priv *priv)
+void iwl_stop_tx_ba_trans_ready(struct iwl_priv *priv,
+                               enum iwl_rxon_context_id ctx,
+                               u8 sta_id, u8 tid)
 {
-       bool hw_rfkill = false;
-
-       iwl_enable_interrupts(priv);
+       struct ieee80211_vif *vif;
+       u8 *addr = priv->stations[sta_id].sta.sta.addr;
 
-       if (!(iwl_read32(priv, CSR_GP_CNTRL) &
-                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
-               hw_rfkill = true;
+       if (ctx == NUM_IWL_RXON_CTX)
+               ctx = priv->stations[sta_id].ctxid;
+       vif = priv->contexts[ctx].vif;
 
-       if (hw_rfkill)
-               set_bit(STATUS_RF_KILL_HW, &priv->status);
-       else
-               clear_bit(STATUS_RF_KILL_HW, &priv->status);
-
-       wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill);
-
-       return 0;
+       ieee80211_stop_tx_ba_cb_irqsafe(vif, addr, tid);
 }
 
-#endif /* CONFIG_PM */
+void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state)
+{
+       wiphy_rfkill_set_hw_state(priv->hw->wiphy, state);
+}
This page took 0.036841 seconds and 5 git commands to generate.