diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-core.c')
| -rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.c | 395 |
1 files changed, 203 insertions, 192 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index cf376f62b2f6..001fdf140abb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
| @@ -34,29 +34,26 @@ | |||
| 34 | #include <net/mac80211.h> | 34 | #include <net/mac80211.h> |
| 35 | 35 | ||
| 36 | #include "iwl-eeprom.h" | 36 | #include "iwl-eeprom.h" |
| 37 | #include "iwl-dev.h" /* FIXME: remove */ | ||
| 38 | #include "iwl-debug.h" | 37 | #include "iwl-debug.h" |
| 39 | #include "iwl-core.h" | 38 | #include "iwl-core.h" |
| 40 | #include "iwl-io.h" | 39 | #include "iwl-io.h" |
| 41 | #include "iwl-power.h" | 40 | #include "iwl-power.h" |
| 42 | #include "iwl-sta.h" | 41 | #include "iwl-agn.h" |
| 43 | #include "iwl-helpers.h" | 42 | #include "iwl-shared.h" |
| 44 | #include "iwl-agn.h" | 43 | #include "iwl-agn.h" |
| 45 | #include "iwl-trans.h" | 44 | #include "iwl-trans.h" |
| 46 | 45 | ||
| 47 | u32 iwl_debug_level; | ||
| 48 | |||
| 49 | const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 46 | const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
| 50 | 47 | ||
| 51 | #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ | 48 | #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ |
| 52 | #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ | 49 | #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ |
| 53 | static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | 50 | static void iwl_init_ht_hw_capab(const struct iwl_priv *priv, |
| 54 | struct ieee80211_sta_ht_cap *ht_info, | 51 | struct ieee80211_sta_ht_cap *ht_info, |
| 55 | enum ieee80211_band band) | 52 | enum ieee80211_band band) |
| 56 | { | 53 | { |
| 57 | u16 max_bit_rate = 0; | 54 | u16 max_bit_rate = 0; |
| 58 | u8 rx_chains_num = priv->hw_params.rx_chains_num; | 55 | u8 rx_chains_num = hw_params(priv).rx_chains_num; |
| 59 | u8 tx_chains_num = priv->hw_params.tx_chains_num; | 56 | u8 tx_chains_num = hw_params(priv).tx_chains_num; |
| 60 | 57 | ||
| 61 | ht_info->cap = 0; | 58 | ht_info->cap = 0; |
| 62 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); | 59 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
| @@ -68,7 +65,7 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | |||
| 68 | ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD; | 65 | ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD; |
| 69 | ht_info->cap |= IEEE80211_HT_CAP_SGI_20; | 66 | ht_info->cap |= IEEE80211_HT_CAP_SGI_20; |
| 70 | max_bit_rate = MAX_BIT_RATE_20_MHZ; | 67 | max_bit_rate = MAX_BIT_RATE_20_MHZ; |
| 71 | if (priv->hw_params.ht40_channel & BIT(band)) { | 68 | if (hw_params(priv).ht40_channel & BIT(band)) { |
| 72 | ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; | 69 | ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 73 | ht_info->cap |= IEEE80211_HT_CAP_SGI_40; | 70 | ht_info->cap |= IEEE80211_HT_CAP_SGI_40; |
| 74 | ht_info->mcs.rx_mask[4] = 0x01; | 71 | ht_info->mcs.rx_mask[4] = 0x01; |
| @@ -106,9 +103,9 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | |||
| 106 | } | 103 | } |
| 107 | 104 | ||
| 108 | /** | 105 | /** |
| 109 | * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom | 106 | * iwl_init_geos - Initialize mac80211's geo/channel info based from eeprom |
| 110 | */ | 107 | */ |
| 111 | int iwlcore_init_geos(struct iwl_priv *priv) | 108 | int iwl_init_geos(struct iwl_priv *priv) |
| 112 | { | 109 | { |
| 113 | struct iwl_channel_info *ch; | 110 | struct iwl_channel_info *ch; |
| 114 | struct ieee80211_supported_band *sband; | 111 | struct ieee80211_supported_band *sband; |
| @@ -121,16 +118,16 @@ int iwlcore_init_geos(struct iwl_priv *priv) | |||
| 121 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || | 118 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || |
| 122 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { | 119 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { |
| 123 | IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); | 120 | IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); |
| 124 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 121 | set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); |
| 125 | return 0; | 122 | return 0; |
| 126 | } | 123 | } |
| 127 | 124 | ||
| 128 | channels = kzalloc(sizeof(struct ieee80211_channel) * | 125 | channels = kcalloc(priv->channel_count, |
| 129 | priv->channel_count, GFP_KERNEL); | 126 | sizeof(struct ieee80211_channel), GFP_KERNEL); |
| 130 | if (!channels) | 127 | if (!channels) |
| 131 | return -ENOMEM; | 128 | return -ENOMEM; |
| 132 | 129 | ||
| 133 | rates = kzalloc((sizeof(struct ieee80211_rate) * IWL_RATE_COUNT_LEGACY), | 130 | rates = kcalloc(IWL_RATE_COUNT_LEGACY, sizeof(struct ieee80211_rate), |
| 134 | GFP_KERNEL); | 131 | GFP_KERNEL); |
| 135 | if (!rates) { | 132 | if (!rates) { |
| 136 | kfree(channels); | 133 | kfree(channels); |
| @@ -145,7 +142,7 @@ int iwlcore_init_geos(struct iwl_priv *priv) | |||
| 145 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; | 142 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; |
| 146 | 143 | ||
| 147 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) | 144 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) |
| 148 | iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, | 145 | iwl_init_ht_hw_capab(priv, &sband->ht_cap, |
| 149 | IEEE80211_BAND_5GHZ); | 146 | IEEE80211_BAND_5GHZ); |
| 150 | 147 | ||
| 151 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; | 148 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; |
| @@ -155,7 +152,7 @@ int iwlcore_init_geos(struct iwl_priv *priv) | |||
| 155 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY; | 152 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY; |
| 156 | 153 | ||
| 157 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) | 154 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) |
| 158 | iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, | 155 | iwl_init_ht_hw_capab(priv, &sband->ht_cap, |
| 159 | IEEE80211_BAND_2GHZ); | 156 | IEEE80211_BAND_2GHZ); |
| 160 | 157 | ||
| 161 | priv->ieee_channels = channels; | 158 | priv->ieee_channels = channels; |
| @@ -211,7 +208,7 @@ int iwlcore_init_geos(struct iwl_priv *priv) | |||
| 211 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && | 208 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && |
| 212 | priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) { | 209 | priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) { |
| 213 | char buf[32]; | 210 | char buf[32]; |
| 214 | bus_get_hw_id(priv->bus, buf, sizeof(buf)); | 211 | bus_get_hw_id(bus(priv), buf, sizeof(buf)); |
| 215 | IWL_INFO(priv, "Incorrectly detected BG card as ABG. " | 212 | IWL_INFO(priv, "Incorrectly detected BG card as ABG. " |
| 216 | "Please send your %s to maintainer.\n", buf); | 213 | "Please send your %s to maintainer.\n", buf); |
| 217 | priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; | 214 | priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; |
| @@ -221,19 +218,19 @@ int iwlcore_init_geos(struct iwl_priv *priv) | |||
| 221 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, | 218 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, |
| 222 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | 219 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); |
| 223 | 220 | ||
| 224 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 221 | set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); |
| 225 | 222 | ||
| 226 | return 0; | 223 | return 0; |
| 227 | } | 224 | } |
| 228 | 225 | ||
| 229 | /* | 226 | /* |
| 230 | * iwlcore_free_geos - undo allocations in iwlcore_init_geos | 227 | * iwl_free_geos - undo allocations in iwl_init_geos |
| 231 | */ | 228 | */ |
| 232 | void iwlcore_free_geos(struct iwl_priv *priv) | 229 | void iwl_free_geos(struct iwl_priv *priv) |
| 233 | { | 230 | { |
| 234 | kfree(priv->ieee_channels); | 231 | kfree(priv->ieee_channels); |
| 235 | kfree(priv->ieee_rates); | 232 | kfree(priv->ieee_rates); |
| 236 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | 233 | clear_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); |
| 237 | } | 234 | } |
| 238 | 235 | ||
| 239 | static bool iwl_is_channel_extension(struct iwl_priv *priv, | 236 | static bool iwl_is_channel_extension(struct iwl_priv *priv, |
| @@ -323,9 +320,9 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
| 323 | u16 beacon_int; | 320 | u16 beacon_int; |
| 324 | struct ieee80211_vif *vif = ctx->vif; | 321 | struct ieee80211_vif *vif = ctx->vif; |
| 325 | 322 | ||
| 326 | conf = ieee80211_get_hw_conf(priv->hw); | 323 | conf = &priv->hw->conf; |
| 327 | 324 | ||
| 328 | lockdep_assert_held(&priv->mutex); | 325 | lockdep_assert_held(&priv->shrd->mutex); |
| 329 | 326 | ||
| 330 | memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); | 327 | memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); |
| 331 | 328 | ||
| @@ -359,7 +356,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
| 359 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); | 356 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); |
| 360 | } else { | 357 | } else { |
| 361 | beacon_int = iwl_adjust_beacon_interval(beacon_int, | 358 | beacon_int = iwl_adjust_beacon_interval(beacon_int, |
| 362 | priv->hw_params.max_beacon_itrvl * TIME_UNIT); | 359 | IWL_MAX_UCODE_BEACON_INTERVAL * TIME_UNIT); |
| 363 | ctx->timing.beacon_interval = cpu_to_le16(beacon_int); | 360 | ctx->timing.beacon_interval = cpu_to_le16(beacon_int); |
| 364 | } | 361 | } |
| 365 | 362 | ||
| @@ -378,7 +375,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
| 378 | le32_to_cpu(ctx->timing.beacon_init_val), | 375 | le32_to_cpu(ctx->timing.beacon_init_val), |
| 379 | le16_to_cpu(ctx->timing.atim_window)); | 376 | le16_to_cpu(ctx->timing.atim_window)); |
| 380 | 377 | ||
| 381 | return trans_send_cmd_pdu(&priv->trans, ctx->rxon_timing_cmd, | 378 | return iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_timing_cmd, |
| 382 | CMD_SYNC, sizeof(ctx->timing), &ctx->timing); | 379 | CMD_SYNC, sizeof(ctx->timing), &ctx->timing); |
| 383 | } | 380 | } |
| 384 | 381 | ||
| @@ -804,21 +801,23 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success) | |||
| 804 | { | 801 | { |
| 805 | /* | 802 | /* |
| 806 | * MULTI-FIXME | 803 | * MULTI-FIXME |
| 807 | * See iwl_mac_channel_switch. | 804 | * See iwlagn_mac_channel_switch. |
| 808 | */ | 805 | */ |
| 809 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | 806 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; |
| 810 | 807 | ||
| 811 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 808 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) |
| 812 | return; | 809 | return; |
| 813 | 810 | ||
| 814 | if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) | 811 | if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, |
| 812 | &priv->shrd->status)) | ||
| 815 | ieee80211_chswitch_done(ctx->vif, is_success); | 813 | ieee80211_chswitch_done(ctx->vif, is_success); |
| 816 | } | 814 | } |
| 817 | 815 | ||
| 818 | #ifdef CONFIG_IWLWIFI_DEBUG | 816 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 819 | void iwl_print_rx_config_cmd(struct iwl_priv *priv, | 817 | void iwl_print_rx_config_cmd(struct iwl_priv *priv, |
| 820 | struct iwl_rxon_context *ctx) | 818 | enum iwl_rxon_context_id ctxid) |
| 821 | { | 819 | { |
| 820 | struct iwl_rxon_context *ctx = &priv->contexts[ctxid]; | ||
| 822 | struct iwl_rxon_cmd *rxon = &ctx->staging; | 821 | struct iwl_rxon_cmd *rxon = &ctx->staging; |
| 823 | 822 | ||
| 824 | IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); | 823 | IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); |
| @@ -856,18 +855,18 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) | |||
| 856 | unsigned long reload_jiffies; | 855 | unsigned long reload_jiffies; |
| 857 | 856 | ||
| 858 | /* Set the FW error flag -- cleared on iwl_down */ | 857 | /* Set the FW error flag -- cleared on iwl_down */ |
| 859 | set_bit(STATUS_FW_ERROR, &priv->status); | 858 | set_bit(STATUS_FW_ERROR, &priv->shrd->status); |
| 860 | 859 | ||
| 861 | /* Cancel currently queued command. */ | 860 | /* Cancel currently queued command. */ |
| 862 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | 861 | clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status); |
| 863 | 862 | ||
| 864 | iwlagn_abort_notification_waits(priv); | 863 | iwlagn_abort_notification_waits(priv); |
| 865 | 864 | ||
| 866 | /* Keep the restart process from trying to send host | 865 | /* Keep the restart process from trying to send host |
| 867 | * commands by clearing the ready bit */ | 866 | * commands by clearing the ready bit */ |
| 868 | clear_bit(STATUS_READY, &priv->status); | 867 | clear_bit(STATUS_READY, &priv->shrd->status); |
| 869 | 868 | ||
| 870 | wake_up_interruptible(&priv->wait_command_queue); | 869 | wake_up(&priv->shrd->wait_command_queue); |
| 871 | 870 | ||
| 872 | if (!ondemand) { | 871 | if (!ondemand) { |
| 873 | /* | 872 | /* |
| @@ -890,63 +889,26 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) | |||
| 890 | priv->reload_count = 0; | 889 | priv->reload_count = 0; |
| 891 | } | 890 | } |
| 892 | 891 | ||
| 893 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { | 892 | if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { |
| 894 | if (iwlagn_mod_params.restart_fw) { | 893 | if (iwlagn_mod_params.restart_fw) { |
| 895 | IWL_DEBUG(priv, IWL_DL_FW_ERRORS, | 894 | IWL_DEBUG_FW_ERRORS(priv, |
| 896 | "Restarting adapter due to uCode error.\n"); | 895 | "Restarting adapter due to uCode error.\n"); |
| 897 | queue_work(priv->workqueue, &priv->restart); | 896 | queue_work(priv->shrd->workqueue, &priv->restart); |
| 898 | } else | 897 | } else |
| 899 | IWL_DEBUG(priv, IWL_DL_FW_ERRORS, | 898 | IWL_DEBUG_FW_ERRORS(priv, |
| 900 | "Detected FW error, but not restarting\n"); | 899 | "Detected FW error, but not restarting\n"); |
| 901 | } | 900 | } |
| 902 | } | 901 | } |
| 903 | 902 | ||
| 904 | /** | ||
| 905 | * iwl_irq_handle_error - called for HW or SW error interrupt from card | ||
| 906 | */ | ||
| 907 | void iwl_irq_handle_error(struct iwl_priv *priv) | ||
| 908 | { | ||
| 909 | /* W/A for WiFi/WiMAX coex and WiMAX own the RF */ | ||
| 910 | if (priv->cfg->internal_wimax_coex && | ||
| 911 | (!(iwl_read_prph(priv, APMG_CLK_CTRL_REG) & | ||
| 912 | APMS_CLK_VAL_MRB_FUNC_MODE) || | ||
| 913 | (iwl_read_prph(priv, APMG_PS_CTRL_REG) & | ||
| 914 | APMG_PS_CTRL_VAL_RESET_REQ))) { | ||
| 915 | /* | ||
| 916 | * Keep the restart process from trying to send host | ||
| 917 | * commands by clearing the ready bit. | ||
| 918 | */ | ||
| 919 | clear_bit(STATUS_READY, &priv->status); | ||
| 920 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | ||
| 921 | wake_up_interruptible(&priv->wait_command_queue); | ||
| 922 | IWL_ERR(priv, "RF is used by WiMAX\n"); | ||
| 923 | return; | ||
| 924 | } | ||
| 925 | |||
| 926 | IWL_ERR(priv, "Loaded firmware version: %s\n", | ||
| 927 | priv->hw->wiphy->fw_version); | ||
| 928 | |||
| 929 | iwl_dump_nic_error_log(priv); | ||
| 930 | iwl_dump_csr(priv); | ||
| 931 | iwl_dump_fh(priv, NULL, false); | ||
| 932 | iwl_dump_nic_event_log(priv, false, NULL, false); | ||
| 933 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
| 934 | if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) | ||
| 935 | iwl_print_rx_config_cmd(priv, | ||
| 936 | &priv->contexts[IWL_RXON_CTX_BSS]); | ||
| 937 | #endif | ||
| 938 | |||
| 939 | iwlagn_fw_error(priv, false); | ||
| 940 | } | ||
| 941 | |||
| 942 | static int iwl_apm_stop_master(struct iwl_priv *priv) | 903 | static int iwl_apm_stop_master(struct iwl_priv *priv) |
| 943 | { | 904 | { |
| 944 | int ret = 0; | 905 | int ret = 0; |
| 945 | 906 | ||
| 946 | /* stop device's busmaster DMA activity */ | 907 | /* stop device's busmaster DMA activity */ |
| 947 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | 908 | iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); |
| 948 | 909 | ||
| 949 | ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, | 910 | ret = iwl_poll_bit(bus(priv), CSR_RESET, |
| 911 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | ||
| 950 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | 912 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); |
| 951 | if (ret) | 913 | if (ret) |
| 952 | IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); | 914 | IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); |
| @@ -960,13 +922,13 @@ void iwl_apm_stop(struct iwl_priv *priv) | |||
| 960 | { | 922 | { |
| 961 | IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); | 923 | IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); |
| 962 | 924 | ||
| 963 | clear_bit(STATUS_DEVICE_ENABLED, &priv->status); | 925 | clear_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status); |
| 964 | 926 | ||
| 965 | /* Stop device's DMA activity */ | 927 | /* Stop device's DMA activity */ |
| 966 | iwl_apm_stop_master(priv); | 928 | iwl_apm_stop_master(priv); |
| 967 | 929 | ||
| 968 | /* Reset the entire device */ | 930 | /* Reset the entire device */ |
| 969 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | 931 | iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
| 970 | 932 | ||
| 971 | udelay(10); | 933 | udelay(10); |
| 972 | 934 | ||
| @@ -974,7 +936,7 @@ void iwl_apm_stop(struct iwl_priv *priv) | |||
| 974 | * Clear "initialization complete" bit to move adapter from | 936 | * Clear "initialization complete" bit to move adapter from |
| 975 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. | 937 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. |
| 976 | */ | 938 | */ |
| 977 | iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 939 | iwl_clear_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
| 978 | } | 940 | } |
| 979 | 941 | ||
| 980 | 942 | ||
| @@ -994,45 +956,45 @@ int iwl_apm_init(struct iwl_priv *priv) | |||
| 994 | */ | 956 | */ |
| 995 | 957 | ||
| 996 | /* Disable L0S exit timer (platform NMI Work/Around) */ | 958 | /* Disable L0S exit timer (platform NMI Work/Around) */ |
| 997 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | 959 | iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS, |
| 998 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); | 960 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
| 999 | 961 | ||
| 1000 | /* | 962 | /* |
| 1001 | * Disable L0s without affecting L1; | 963 | * Disable L0s without affecting L1; |
| 1002 | * don't wait for ICH L0s (ICH bug W/A) | 964 | * don't wait for ICH L0s (ICH bug W/A) |
| 1003 | */ | 965 | */ |
| 1004 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | 966 | iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS, |
| 1005 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); | 967 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); |
| 1006 | 968 | ||
| 1007 | /* Set FH wait threshold to maximum (HW error during stress W/A) */ | 969 | /* Set FH wait threshold to maximum (HW error during stress W/A) */ |
| 1008 | iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); | 970 | iwl_set_bit(bus(priv), CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); |
| 1009 | 971 | ||
| 1010 | /* | 972 | /* |
| 1011 | * Enable HAP INTA (interrupt from management bus) to | 973 | * Enable HAP INTA (interrupt from management bus) to |
| 1012 | * wake device's PCI Express link L1a -> L0s | 974 | * wake device's PCI Express link L1a -> L0s |
| 1013 | */ | 975 | */ |
| 1014 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | 976 | iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, |
| 1015 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); | 977 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); |
| 1016 | 978 | ||
| 1017 | bus_apm_config(priv->bus); | 979 | bus_apm_config(bus(priv)); |
| 1018 | 980 | ||
| 1019 | /* Configure analog phase-lock-loop before activating to D0A */ | 981 | /* Configure analog phase-lock-loop before activating to D0A */ |
| 1020 | if (priv->cfg->base_params->pll_cfg_val) | 982 | if (priv->cfg->base_params->pll_cfg_val) |
| 1021 | iwl_set_bit(priv, CSR_ANA_PLL_CFG, | 983 | iwl_set_bit(bus(priv), CSR_ANA_PLL_CFG, |
| 1022 | priv->cfg->base_params->pll_cfg_val); | 984 | priv->cfg->base_params->pll_cfg_val); |
| 1023 | 985 | ||
| 1024 | /* | 986 | /* |
| 1025 | * Set "initialization complete" bit to move adapter from | 987 | * Set "initialization complete" bit to move adapter from |
| 1026 | * D0U* --> D0A* (powered-up active) state. | 988 | * D0U* --> D0A* (powered-up active) state. |
| 1027 | */ | 989 | */ |
| 1028 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 990 | iwl_set_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
| 1029 | 991 | ||
| 1030 | /* | 992 | /* |
| 1031 | * Wait for clock stabilization; once stabilized, access to | 993 | * Wait for clock stabilization; once stabilized, access to |
| 1032 | * device-internal resources is supported, e.g. iwl_write_prph() | 994 | * device-internal resources is supported, e.g. iwl_write_prph() |
| 1033 | * and accesses to uCode SRAM. | 995 | * and accesses to uCode SRAM. |
| 1034 | */ | 996 | */ |
| 1035 | ret = iwl_poll_bit(priv, CSR_GP_CNTRL, | 997 | ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL, |
| 1036 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | 998 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
| 1037 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); | 999 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); |
| 1038 | if (ret < 0) { | 1000 | if (ret < 0) { |
| @@ -1047,14 +1009,14 @@ int iwl_apm_init(struct iwl_priv *priv) | |||
| 1047 | * do not disable clocks. This preserves any hardware bits already | 1009 | * do not disable clocks. This preserves any hardware bits already |
| 1048 | * set by default in "CLK_CTRL_REG" after reset. | 1010 | * set by default in "CLK_CTRL_REG" after reset. |
| 1049 | */ | 1011 | */ |
| 1050 | iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); | 1012 | iwl_write_prph(bus(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); |
| 1051 | udelay(20); | 1013 | udelay(20); |
| 1052 | 1014 | ||
| 1053 | /* Disable L1-Active */ | 1015 | /* Disable L1-Active */ |
| 1054 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | 1016 | iwl_set_bits_prph(bus(priv), APMG_PCIDEV_STT_REG, |
| 1055 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | 1017 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); |
| 1056 | 1018 | ||
| 1057 | set_bit(STATUS_DEVICE_ENABLED, &priv->status); | 1019 | set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status); |
| 1058 | 1020 | ||
| 1059 | out: | 1021 | out: |
| 1060 | return ret; | 1022 | return ret; |
| @@ -1068,7 +1030,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) | |||
| 1068 | bool defer; | 1030 | bool defer; |
| 1069 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | 1031 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; |
| 1070 | 1032 | ||
| 1071 | lockdep_assert_held(&priv->mutex); | 1033 | lockdep_assert_held(&priv->shrd->mutex); |
| 1072 | 1034 | ||
| 1073 | if (priv->tx_power_user_lmt == tx_power && !force) | 1035 | if (priv->tx_power_user_lmt == tx_power && !force) |
| 1074 | return 0; | 1036 | return 0; |
| @@ -1088,7 +1050,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) | |||
| 1088 | return -EINVAL; | 1050 | return -EINVAL; |
| 1089 | } | 1051 | } |
| 1090 | 1052 | ||
| 1091 | if (!iwl_is_ready_rf(priv)) | 1053 | if (!iwl_is_ready_rf(priv->shrd)) |
| 1092 | return -EIO; | 1054 | return -EIO; |
| 1093 | 1055 | ||
| 1094 | /* scan complete and commit_rxon use tx_power_next value, | 1056 | /* scan complete and commit_rxon use tx_power_next value, |
| @@ -1096,7 +1058,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) | |||
| 1096 | priv->tx_power_next = tx_power; | 1058 | priv->tx_power_next = tx_power; |
| 1097 | 1059 | ||
| 1098 | /* do not set tx power when scanning or channel changing */ | 1060 | /* do not set tx power when scanning or channel changing */ |
| 1099 | defer = test_bit(STATUS_SCANNING, &priv->status) || | 1061 | defer = test_bit(STATUS_SCANNING, &priv->shrd->status) || |
| 1100 | memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); | 1062 | memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); |
| 1101 | if (defer && !force) { | 1063 | if (defer && !force) { |
| 1102 | IWL_DEBUG_INFO(priv, "Deferring tx power set\n"); | 1064 | IWL_DEBUG_INFO(priv, "Deferring tx power set\n"); |
| @@ -1134,7 +1096,7 @@ void iwl_send_bt_config(struct iwl_priv *priv) | |||
| 1134 | IWL_DEBUG_INFO(priv, "BT coex %s\n", | 1096 | IWL_DEBUG_INFO(priv, "BT coex %s\n", |
| 1135 | (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); | 1097 | (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); |
| 1136 | 1098 | ||
| 1137 | if (trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG, | 1099 | if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG, |
| 1138 | CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd)) | 1100 | CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd)) |
| 1139 | IWL_ERR(priv, "failed to send BT Coex Config\n"); | 1101 | IWL_ERR(priv, "failed to send BT Coex Config\n"); |
| 1140 | } | 1102 | } |
| @@ -1147,24 +1109,20 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) | |||
| 1147 | }; | 1109 | }; |
| 1148 | 1110 | ||
| 1149 | if (flags & CMD_ASYNC) | 1111 | if (flags & CMD_ASYNC) |
| 1150 | return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD, | 1112 | return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD, |
| 1151 | CMD_ASYNC, | 1113 | CMD_ASYNC, |
| 1152 | sizeof(struct iwl_statistics_cmd), | 1114 | sizeof(struct iwl_statistics_cmd), |
| 1153 | &statistics_cmd); | 1115 | &statistics_cmd); |
| 1154 | else | 1116 | else |
| 1155 | return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD, | 1117 | return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD, |
| 1156 | CMD_SYNC, | 1118 | CMD_SYNC, |
| 1157 | sizeof(struct iwl_statistics_cmd), | 1119 | sizeof(struct iwl_statistics_cmd), |
| 1158 | &statistics_cmd); | 1120 | &statistics_cmd); |
| 1159 | } | 1121 | } |
| 1160 | 1122 | ||
| 1161 | void iwl_clear_isr_stats(struct iwl_priv *priv) | 1123 | int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, |
| 1162 | { | 1124 | struct ieee80211_vif *vif, u16 queue, |
| 1163 | memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); | 1125 | const struct ieee80211_tx_queue_params *params) |
| 1164 | } | ||
| 1165 | |||
| 1166 | int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | ||
| 1167 | const struct ieee80211_tx_queue_params *params) | ||
| 1168 | { | 1126 | { |
| 1169 | struct iwl_priv *priv = hw->priv; | 1127 | struct iwl_priv *priv = hw->priv; |
| 1170 | struct iwl_rxon_context *ctx; | 1128 | struct iwl_rxon_context *ctx; |
| @@ -1173,7 +1131,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | |||
| 1173 | 1131 | ||
| 1174 | IWL_DEBUG_MAC80211(priv, "enter\n"); | 1132 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
| 1175 | 1133 | ||
| 1176 | if (!iwl_is_ready_rf(priv)) { | 1134 | if (!iwl_is_ready_rf(priv->shrd)) { |
| 1177 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); | 1135 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); |
| 1178 | return -EIO; | 1136 | return -EIO; |
| 1179 | } | 1137 | } |
| @@ -1185,7 +1143,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | |||
| 1185 | 1143 | ||
| 1186 | q = AC_NUM - 1 - queue; | 1144 | q = AC_NUM - 1 - queue; |
| 1187 | 1145 | ||
| 1188 | spin_lock_irqsave(&priv->lock, flags); | 1146 | spin_lock_irqsave(&priv->shrd->lock, flags); |
| 1189 | 1147 | ||
| 1190 | /* | 1148 | /* |
| 1191 | * MULTI-FIXME | 1149 | * MULTI-FIXME |
| @@ -1203,13 +1161,13 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | |||
| 1203 | ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; | 1161 | ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; |
| 1204 | } | 1162 | } |
| 1205 | 1163 | ||
| 1206 | spin_unlock_irqrestore(&priv->lock, flags); | 1164 | spin_unlock_irqrestore(&priv->shrd->lock, flags); |
| 1207 | 1165 | ||
| 1208 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 1166 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 1209 | return 0; | 1167 | return 0; |
| 1210 | } | 1168 | } |
| 1211 | 1169 | ||
| 1212 | int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw) | 1170 | int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) |
| 1213 | { | 1171 | { |
| 1214 | struct iwl_priv *priv = hw->priv; | 1172 | struct iwl_priv *priv = hw->priv; |
| 1215 | 1173 | ||
| @@ -1231,7 +1189,7 @@ static int iwl_setup_interface(struct iwl_priv *priv, | |||
| 1231 | struct ieee80211_vif *vif = ctx->vif; | 1189 | struct ieee80211_vif *vif = ctx->vif; |
| 1232 | int err; | 1190 | int err; |
| 1233 | 1191 | ||
| 1234 | lockdep_assert_held(&priv->mutex); | 1192 | lockdep_assert_held(&priv->shrd->mutex); |
| 1235 | 1193 | ||
| 1236 | /* | 1194 | /* |
| 1237 | * This variable will be correct only when there's just | 1195 | * This variable will be correct only when there's just |
| @@ -1262,7 +1220,8 @@ static int iwl_setup_interface(struct iwl_priv *priv, | |||
| 1262 | return 0; | 1220 | return 0; |
| 1263 | } | 1221 | } |
| 1264 | 1222 | ||
| 1265 | int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | 1223 | int iwlagn_mac_add_interface(struct ieee80211_hw *hw, |
| 1224 | struct ieee80211_vif *vif) | ||
| 1266 | { | 1225 | { |
| 1267 | struct iwl_priv *priv = hw->priv; | 1226 | struct iwl_priv *priv = hw->priv; |
| 1268 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | 1227 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; |
| @@ -1273,9 +1232,13 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 1273 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", | 1232 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", |
| 1274 | viftype, vif->addr); | 1233 | viftype, vif->addr); |
| 1275 | 1234 | ||
| 1276 | mutex_lock(&priv->mutex); | 1235 | cancel_delayed_work_sync(&priv->hw_roc_disable_work); |
| 1236 | |||
| 1237 | mutex_lock(&priv->shrd->mutex); | ||
| 1277 | 1238 | ||
| 1278 | if (!iwl_is_ready_rf(priv)) { | 1239 | iwlagn_disable_roc(priv); |
| 1240 | |||
| 1241 | if (!iwl_is_ready_rf(priv->shrd)) { | ||
| 1279 | IWL_WARN(priv, "Try to add interface when device not ready\n"); | 1242 | IWL_WARN(priv, "Try to add interface when device not ready\n"); |
| 1280 | err = -EINVAL; | 1243 | err = -EINVAL; |
| 1281 | goto out; | 1244 | goto out; |
| @@ -1318,7 +1281,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 1318 | ctx->vif = NULL; | 1281 | ctx->vif = NULL; |
| 1319 | priv->iw_mode = NL80211_IFTYPE_STATION; | 1282 | priv->iw_mode = NL80211_IFTYPE_STATION; |
| 1320 | out: | 1283 | out: |
| 1321 | mutex_unlock(&priv->mutex); | 1284 | mutex_unlock(&priv->shrd->mutex); |
| 1322 | 1285 | ||
| 1323 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 1286 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 1324 | return err; | 1287 | return err; |
| @@ -1330,7 +1293,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv, | |||
| 1330 | { | 1293 | { |
| 1331 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | 1294 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
| 1332 | 1295 | ||
| 1333 | lockdep_assert_held(&priv->mutex); | 1296 | lockdep_assert_held(&priv->shrd->mutex); |
| 1334 | 1297 | ||
| 1335 | if (priv->scan_vif == vif) { | 1298 | if (priv->scan_vif == vif) { |
| 1336 | iwl_scan_cancel_timeout(priv, 200); | 1299 | iwl_scan_cancel_timeout(priv, 200); |
| @@ -1354,7 +1317,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv, | |||
| 1354 | priv->bt_traffic_load = priv->last_bt_traffic_load; | 1317 | priv->bt_traffic_load = priv->last_bt_traffic_load; |
| 1355 | } | 1318 | } |
| 1356 | 1319 | ||
| 1357 | void iwl_mac_remove_interface(struct ieee80211_hw *hw, | 1320 | void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, |
| 1358 | struct ieee80211_vif *vif) | 1321 | struct ieee80211_vif *vif) |
| 1359 | { | 1322 | { |
| 1360 | struct iwl_priv *priv = hw->priv; | 1323 | struct iwl_priv *priv = hw->priv; |
| @@ -1362,14 +1325,20 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw, | |||
| 1362 | 1325 | ||
| 1363 | IWL_DEBUG_MAC80211(priv, "enter\n"); | 1326 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
| 1364 | 1327 | ||
| 1365 | mutex_lock(&priv->mutex); | 1328 | mutex_lock(&priv->shrd->mutex); |
| 1366 | 1329 | ||
| 1367 | WARN_ON(ctx->vif != vif); | 1330 | if (WARN_ON(ctx->vif != vif)) { |
| 1331 | struct iwl_rxon_context *tmp; | ||
| 1332 | IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); | ||
| 1333 | for_each_context(priv, tmp) | ||
| 1334 | IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", | ||
| 1335 | tmp->ctxid, tmp, tmp->vif); | ||
| 1336 | } | ||
| 1368 | ctx->vif = NULL; | 1337 | ctx->vif = NULL; |
| 1369 | 1338 | ||
| 1370 | iwl_teardown_interface(priv, vif, false); | 1339 | iwl_teardown_interface(priv, vif, false); |
| 1371 | 1340 | ||
| 1372 | mutex_unlock(&priv->mutex); | 1341 | mutex_unlock(&priv->shrd->mutex); |
| 1373 | 1342 | ||
| 1374 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 1343 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 1375 | 1344 | ||
| @@ -1393,7 +1362,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv) | |||
| 1393 | { | 1362 | { |
| 1394 | u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; | 1363 | u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; |
| 1395 | 1364 | ||
| 1396 | if (iwl_debug_level & IWL_DL_TX) { | 1365 | if (iwl_get_debug_level(priv->shrd) & IWL_DL_TX) { |
| 1397 | if (!priv->tx_traffic) { | 1366 | if (!priv->tx_traffic) { |
| 1398 | priv->tx_traffic = | 1367 | priv->tx_traffic = |
| 1399 | kzalloc(traffic_size, GFP_KERNEL); | 1368 | kzalloc(traffic_size, GFP_KERNEL); |
| @@ -1401,7 +1370,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv) | |||
| 1401 | return -ENOMEM; | 1370 | return -ENOMEM; |
| 1402 | } | 1371 | } |
| 1403 | } | 1372 | } |
| 1404 | if (iwl_debug_level & IWL_DL_RX) { | 1373 | if (iwl_get_debug_level(priv->shrd) & IWL_DL_RX) { |
| 1405 | if (!priv->rx_traffic) { | 1374 | if (!priv->rx_traffic) { |
| 1406 | priv->rx_traffic = | 1375 | priv->rx_traffic = |
| 1407 | kzalloc(traffic_size, GFP_KERNEL); | 1376 | kzalloc(traffic_size, GFP_KERNEL); |
| @@ -1428,7 +1397,7 @@ void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv, | |||
| 1428 | __le16 fc; | 1397 | __le16 fc; |
| 1429 | u16 len; | 1398 | u16 len; |
| 1430 | 1399 | ||
| 1431 | if (likely(!(iwl_debug_level & IWL_DL_TX))) | 1400 | if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_TX))) |
| 1432 | return; | 1401 | return; |
| 1433 | 1402 | ||
| 1434 | if (!priv->tx_traffic) | 1403 | if (!priv->tx_traffic) |
| @@ -1452,7 +1421,7 @@ void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv, | |||
| 1452 | __le16 fc; | 1421 | __le16 fc; |
| 1453 | u16 len; | 1422 | u16 len; |
| 1454 | 1423 | ||
| 1455 | if (likely(!(iwl_debug_level & IWL_DL_RX))) | 1424 | if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_RX))) |
| 1456 | return; | 1425 | return; |
| 1457 | 1426 | ||
| 1458 | if (!priv->rx_traffic) | 1427 | if (!priv->rx_traffic) |
| @@ -1609,7 +1578,7 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) | |||
| 1609 | 1578 | ||
| 1610 | static void iwl_force_rf_reset(struct iwl_priv *priv) | 1579 | static void iwl_force_rf_reset(struct iwl_priv *priv) |
| 1611 | { | 1580 | { |
| 1612 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 1581 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) |
| 1613 | return; | 1582 | return; |
| 1614 | 1583 | ||
| 1615 | if (!iwl_is_any_associated(priv)) { | 1584 | if (!iwl_is_any_associated(priv)) { |
| @@ -1634,7 +1603,7 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) | |||
| 1634 | { | 1603 | { |
| 1635 | struct iwl_force_reset *force_reset; | 1604 | struct iwl_force_reset *force_reset; |
| 1636 | 1605 | ||
| 1637 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 1606 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) |
| 1638 | return -EINVAL; | 1607 | return -EINVAL; |
| 1639 | 1608 | ||
| 1640 | if (mode >= IWL_MAX_FORCE_RESET) { | 1609 | if (mode >= IWL_MAX_FORCE_RESET) { |
| @@ -1680,8 +1649,9 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) | |||
| 1680 | return 0; | 1649 | return 0; |
| 1681 | } | 1650 | } |
| 1682 | 1651 | ||
| 1683 | int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1652 | int iwlagn_mac_change_interface(struct ieee80211_hw *hw, |
| 1684 | enum nl80211_iftype newtype, bool newp2p) | 1653 | struct ieee80211_vif *vif, |
| 1654 | enum nl80211_iftype newtype, bool newp2p) | ||
| 1685 | { | 1655 | { |
| 1686 | struct iwl_priv *priv = hw->priv; | 1656 | struct iwl_priv *priv = hw->priv; |
| 1687 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | 1657 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
| @@ -1691,11 +1661,13 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
| 1691 | u32 interface_modes; | 1661 | u32 interface_modes; |
| 1692 | int err; | 1662 | int err; |
| 1693 | 1663 | ||
| 1664 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
| 1665 | |||
| 1694 | newtype = ieee80211_iftype_p2p(newtype, newp2p); | 1666 | newtype = ieee80211_iftype_p2p(newtype, newp2p); |
| 1695 | 1667 | ||
| 1696 | mutex_lock(&priv->mutex); | 1668 | mutex_lock(&priv->shrd->mutex); |
| 1697 | 1669 | ||
| 1698 | if (!ctx->vif || !iwl_is_ready_rf(priv)) { | 1670 | if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { |
| 1699 | /* | 1671 | /* |
| 1700 | * Huh? But wait ... this can maybe happen when | 1672 | * Huh? But wait ... this can maybe happen when |
| 1701 | * we're in the middle of a firmware restart! | 1673 | * we're in the middle of a firmware restart! |
| @@ -1757,36 +1729,35 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
| 1757 | err = 0; | 1729 | err = 0; |
| 1758 | 1730 | ||
| 1759 | out: | 1731 | out: |
| 1760 | mutex_unlock(&priv->mutex); | 1732 | mutex_unlock(&priv->shrd->mutex); |
| 1733 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
| 1734 | |||
| 1761 | return err; | 1735 | return err; |
| 1762 | } | 1736 | } |
| 1763 | 1737 | ||
| 1764 | /* | 1738 | int iwl_cmd_echo_test(struct iwl_priv *priv) |
| 1765 | * On every watchdog tick we check (latest) time stamp. If it does not | ||
| 1766 | * change during timeout period and queue is not empty we reset firmware. | ||
| 1767 | */ | ||
| 1768 | static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt) | ||
| 1769 | { | 1739 | { |
| 1770 | struct iwl_tx_queue *txq = &priv->txq[cnt]; | ||
| 1771 | struct iwl_queue *q = &txq->q; | ||
| 1772 | unsigned long timeout; | ||
| 1773 | int ret; | 1740 | int ret; |
| 1741 | struct iwl_host_cmd cmd = { | ||
| 1742 | .id = REPLY_ECHO, | ||
| 1743 | .flags = CMD_SYNC, | ||
| 1744 | }; | ||
| 1774 | 1745 | ||
| 1775 | if (q->read_ptr == q->write_ptr) { | 1746 | ret = iwl_trans_send_cmd(trans(priv), &cmd); |
| 1776 | txq->time_stamp = jiffies; | 1747 | if (ret) |
| 1777 | return 0; | 1748 | IWL_ERR(priv, "echo testing fail: 0X%x\n", ret); |
| 1778 | } | 1749 | else |
| 1779 | 1750 | IWL_DEBUG_INFO(priv, "echo testing pass\n"); | |
| 1780 | timeout = txq->time_stamp + | 1751 | return ret; |
| 1781 | msecs_to_jiffies(priv->cfg->base_params->wd_timeout); | 1752 | } |
| 1782 | 1753 | ||
| 1783 | if (time_after(jiffies, timeout)) { | 1754 | static inline int iwl_check_stuck_queue(struct iwl_priv *priv, int txq) |
| 1784 | IWL_ERR(priv, "Queue %d stuck for %u ms.\n", | 1755 | { |
| 1785 | q->id, priv->cfg->base_params->wd_timeout); | 1756 | if (iwl_trans_check_stuck_queue(trans(priv), txq)) { |
| 1757 | int ret; | ||
| 1786 | ret = iwl_force_reset(priv, IWL_FW_RESET, false); | 1758 | ret = iwl_force_reset(priv, IWL_FW_RESET, false); |
| 1787 | return (ret == -EAGAIN) ? 0 : 1; | 1759 | return (ret == -EAGAIN) ? 0 : 1; |
| 1788 | } | 1760 | } |
| 1789 | |||
| 1790 | return 0; | 1761 | return 0; |
| 1791 | } | 1762 | } |
| 1792 | 1763 | ||
| @@ -1806,7 +1777,10 @@ void iwl_bg_watchdog(unsigned long data) | |||
| 1806 | int cnt; | 1777 | int cnt; |
| 1807 | unsigned long timeout; | 1778 | unsigned long timeout; |
| 1808 | 1779 | ||
| 1809 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 1780 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) |
| 1781 | return; | ||
| 1782 | |||
| 1783 | if (iwl_is_rfkill(priv->shrd)) | ||
| 1810 | return; | 1784 | return; |
| 1811 | 1785 | ||
| 1812 | timeout = priv->cfg->base_params->wd_timeout; | 1786 | timeout = priv->cfg->base_params->wd_timeout; |
| @@ -1814,14 +1788,14 @@ void iwl_bg_watchdog(unsigned long data) | |||
| 1814 | return; | 1788 | return; |
| 1815 | 1789 | ||
| 1816 | /* monitor and check for stuck cmd queue */ | 1790 | /* monitor and check for stuck cmd queue */ |
| 1817 | if (iwl_check_stuck_queue(priv, priv->cmd_queue)) | 1791 | if (iwl_check_stuck_queue(priv, priv->shrd->cmd_queue)) |
| 1818 | return; | 1792 | return; |
| 1819 | 1793 | ||
| 1820 | /* monitor and check for other stuck queues */ | 1794 | /* monitor and check for other stuck queues */ |
| 1821 | if (iwl_is_any_associated(priv)) { | 1795 | if (iwl_is_any_associated(priv)) { |
| 1822 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { | 1796 | for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) { |
| 1823 | /* skip as we already checked the command queue */ | 1797 | /* skip as we already checked the command queue */ |
| 1824 | if (cnt == priv->cmd_queue) | 1798 | if (cnt == priv->shrd->cmd_queue) |
| 1825 | continue; | 1799 | continue; |
| 1826 | if (iwl_check_stuck_queue(priv, cnt)) | 1800 | if (iwl_check_stuck_queue(priv, cnt)) |
| 1827 | return; | 1801 | return; |
| @@ -1843,6 +1817,28 @@ void iwl_setup_watchdog(struct iwl_priv *priv) | |||
| 1843 | del_timer(&priv->watchdog); | 1817 | del_timer(&priv->watchdog); |
| 1844 | } | 1818 | } |
| 1845 | 1819 | ||
| 1820 | /** | ||
| 1821 | * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time | ||
| 1822 | * @priv -- pointer to iwl_priv data structure | ||
| 1823 | * @tsf_bits -- number of bits need to shift for masking) | ||
| 1824 | */ | ||
| 1825 | static inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv, | ||
| 1826 | u16 tsf_bits) | ||
| 1827 | { | ||
| 1828 | return (1 << tsf_bits) - 1; | ||
| 1829 | } | ||
| 1830 | |||
| 1831 | /** | ||
| 1832 | * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time | ||
| 1833 | * @priv -- pointer to iwl_priv data structure | ||
| 1834 | * @tsf_bits -- number of bits need to shift for masking) | ||
| 1835 | */ | ||
| 1836 | static inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv, | ||
| 1837 | u16 tsf_bits) | ||
| 1838 | { | ||
| 1839 | return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; | ||
| 1840 | } | ||
| 1841 | |||
| 1846 | /* | 1842 | /* |
| 1847 | * extended beacon time format | 1843 | * extended beacon time format |
| 1848 | * time in usec will be changed into a 32-bit value in extended:internal format | 1844 | * time in usec will be changed into a 32-bit value in extended:internal format |
| @@ -1859,13 +1855,12 @@ u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval) | |||
| 1859 | return 0; | 1855 | return 0; |
| 1860 | 1856 | ||
| 1861 | quot = (usec / interval) & | 1857 | quot = (usec / interval) & |
| 1862 | (iwl_beacon_time_mask_high(priv, | 1858 | (iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >> |
| 1863 | priv->hw_params.beacon_time_tsf_bits) >> | 1859 | IWLAGN_EXT_BEACON_TIME_POS); |
| 1864 | priv->hw_params.beacon_time_tsf_bits); | ||
| 1865 | rem = (usec % interval) & iwl_beacon_time_mask_low(priv, | 1860 | rem = (usec % interval) & iwl_beacon_time_mask_low(priv, |
| 1866 | priv->hw_params.beacon_time_tsf_bits); | 1861 | IWLAGN_EXT_BEACON_TIME_POS); |
| 1867 | 1862 | ||
| 1868 | return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; | 1863 | return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem; |
| 1869 | } | 1864 | } |
| 1870 | 1865 | ||
| 1871 | /* base is usually what we get from ucode with each received frame, | 1866 | /* base is usually what we get from ucode with each received frame, |
| @@ -1875,64 +1870,80 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, | |||
| 1875 | u32 addon, u32 beacon_interval) | 1870 | u32 addon, u32 beacon_interval) |
| 1876 | { | 1871 | { |
| 1877 | u32 base_low = base & iwl_beacon_time_mask_low(priv, | 1872 | u32 base_low = base & iwl_beacon_time_mask_low(priv, |
| 1878 | priv->hw_params.beacon_time_tsf_bits); | 1873 | IWLAGN_EXT_BEACON_TIME_POS); |
| 1879 | u32 addon_low = addon & iwl_beacon_time_mask_low(priv, | 1874 | u32 addon_low = addon & iwl_beacon_time_mask_low(priv, |
| 1880 | priv->hw_params.beacon_time_tsf_bits); | 1875 | IWLAGN_EXT_BEACON_TIME_POS); |
| 1881 | u32 interval = beacon_interval * TIME_UNIT; | 1876 | u32 interval = beacon_interval * TIME_UNIT; |
| 1882 | u32 res = (base & iwl_beacon_time_mask_high(priv, | 1877 | u32 res = (base & iwl_beacon_time_mask_high(priv, |
| 1883 | priv->hw_params.beacon_time_tsf_bits)) + | 1878 | IWLAGN_EXT_BEACON_TIME_POS)) + |
| 1884 | (addon & iwl_beacon_time_mask_high(priv, | 1879 | (addon & iwl_beacon_time_mask_high(priv, |
| 1885 | priv->hw_params.beacon_time_tsf_bits)); | 1880 | IWLAGN_EXT_BEACON_TIME_POS)); |
| 1886 | 1881 | ||
| 1887 | if (base_low > addon_low) | 1882 | if (base_low > addon_low) |
| 1888 | res += base_low - addon_low; | 1883 | res += base_low - addon_low; |
| 1889 | else if (base_low < addon_low) { | 1884 | else if (base_low < addon_low) { |
| 1890 | res += interval + base_low - addon_low; | 1885 | res += interval + base_low - addon_low; |
| 1891 | res += (1 << priv->hw_params.beacon_time_tsf_bits); | 1886 | res += (1 << IWLAGN_EXT_BEACON_TIME_POS); |
| 1892 | } else | 1887 | } else |
| 1893 | res += (1 << priv->hw_params.beacon_time_tsf_bits); | 1888 | res += (1 << IWLAGN_EXT_BEACON_TIME_POS); |
| 1894 | 1889 | ||
| 1895 | return cpu_to_le32(res); | 1890 | return cpu_to_le32(res); |
| 1896 | } | 1891 | } |
| 1897 | 1892 | ||
| 1898 | #ifdef CONFIG_PM | 1893 | void iwl_start_tx_ba_trans_ready(struct iwl_priv *priv, |
| 1894 | enum iwl_rxon_context_id ctx, | ||
| 1895 | u8 sta_id, u8 tid) | ||
| 1896 | { | ||
| 1897 | struct ieee80211_vif *vif; | ||
| 1898 | u8 *addr = priv->stations[sta_id].sta.sta.addr; | ||
| 1899 | |||
| 1900 | if (ctx == NUM_IWL_RXON_CTX) | ||
| 1901 | ctx = priv->stations[sta_id].ctxid; | ||
| 1902 | vif = priv->contexts[ctx].vif; | ||
| 1899 | 1903 | ||
| 1900 | int iwl_suspend(struct iwl_priv *priv) | 1904 | ieee80211_start_tx_ba_cb_irqsafe(vif, addr, tid); |
| 1905 | } | ||
| 1906 | |||
| 1907 | void iwl_stop_tx_ba_trans_ready(struct iwl_priv *priv, | ||
| 1908 | enum iwl_rxon_context_id ctx, | ||
| 1909 | u8 sta_id, u8 tid) | ||
| 1901 | { | 1910 | { |
| 1902 | /* | 1911 | struct ieee80211_vif *vif; |
| 1903 | * This function is called when system goes into suspend state | 1912 | u8 *addr = priv->stations[sta_id].sta.sta.addr; |
| 1904 | * mac80211 will call iwl_mac_stop() from the mac80211 suspend function | ||
| 1905 | * first but since iwl_mac_stop() has no knowledge of who the caller is, | ||
| 1906 | * it will not call apm_ops.stop() to stop the DMA operation. | ||
| 1907 | * Calling apm_ops.stop here to make sure we stop the DMA. | ||
| 1908 | * | ||
| 1909 | * But of course ... if we have configured WoWLAN then we did other | ||
| 1910 | * things already :-) | ||
| 1911 | */ | ||
| 1912 | if (!priv->wowlan) | ||
| 1913 | iwl_apm_stop(priv); | ||
| 1914 | 1913 | ||
| 1915 | return 0; | 1914 | if (ctx == NUM_IWL_RXON_CTX) |
| 1915 | ctx = priv->stations[sta_id].ctxid; | ||
| 1916 | vif = priv->contexts[ctx].vif; | ||
| 1917 | |||
| 1918 | ieee80211_stop_tx_ba_cb_irqsafe(vif, addr, tid); | ||
| 1916 | } | 1919 | } |
| 1917 | 1920 | ||
| 1918 | int iwl_resume(struct iwl_priv *priv) | 1921 | void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state) |
| 1919 | { | 1922 | { |
| 1920 | bool hw_rfkill = false; | 1923 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, state); |
| 1924 | } | ||
| 1921 | 1925 | ||
| 1922 | iwl_enable_interrupts(priv); | 1926 | void iwl_nic_config(struct iwl_priv *priv) |
| 1927 | { | ||
| 1928 | priv->cfg->lib->nic_config(priv); | ||
| 1923 | 1929 | ||
| 1924 | if (!(iwl_read32(priv, CSR_GP_CNTRL) & | 1930 | } |
| 1925 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) | ||
| 1926 | hw_rfkill = true; | ||
| 1927 | 1931 | ||
| 1928 | if (hw_rfkill) | 1932 | void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb) |
| 1929 | set_bit(STATUS_RF_KILL_HW, &priv->status); | 1933 | { |
| 1930 | else | 1934 | struct ieee80211_tx_info *info; |
| 1931 | clear_bit(STATUS_RF_KILL_HW, &priv->status); | ||
| 1932 | 1935 | ||
| 1933 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill); | 1936 | info = IEEE80211_SKB_CB(skb); |
| 1937 | kmem_cache_free(priv->tx_cmd_pool, (info->driver_data[1])); | ||
| 1938 | dev_kfree_skb_any(skb); | ||
| 1939 | } | ||
| 1934 | 1940 | ||
| 1935 | return 0; | 1941 | void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac) |
| 1942 | { | ||
| 1943 | ieee80211_stop_queue(priv->hw, ac); | ||
| 1936 | } | 1944 | } |
| 1937 | 1945 | ||
| 1938 | #endif /* CONFIG_PM */ | 1946 | void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac) |
| 1947 | { | ||
| 1948 | ieee80211_wake_queue(priv->hw, ac); | ||
| 1949 | } | ||
