aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c17
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-devices.c25
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hw.h11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c42
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h36
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rx.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c128
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-sta.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tt.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c61
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c308
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-config.h28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c297
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h133
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h34
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c309
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h99
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c151
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.h25
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h53
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c21
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-mac80211.c88
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-modparams.h (renamed from drivers/net/wireless/iwlwifi/iwl-shared.h)78
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-op-mode.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-phy-db.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-phy-db.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h43
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c35
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c184
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h49
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-ucode.c25
49 files changed, 953 insertions, 1660 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index f2cd67874cf4..406f297a9a56 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -5,7 +5,7 @@ iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o iwl-debug.o
5iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o 5iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o
6iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o 6iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o
7 7
8iwlwifi-objs += iwl-core.o iwl-eeprom.o iwl-power.o 8iwlwifi-objs += iwl-eeprom.o iwl-power.o
9iwlwifi-objs += iwl-scan.o iwl-led.o 9iwlwifi-objs += iwl-scan.o iwl-led.o
10iwlwifi-objs += iwl-agn-rxon.o iwl-agn-devices.o 10iwlwifi-objs += iwl-agn-rxon.o iwl-agn-devices.o
11iwlwifi-objs += iwl-5000.o 11iwlwifi-objs += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index e9006078f4e2..8c7a0cd13854 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -28,7 +28,8 @@
28#include <linux/stringify.h> 28#include <linux/stringify.h>
29#include "iwl-config.h" 29#include "iwl-config.h"
30#include "iwl-cfg.h" 30#include "iwl-cfg.h"
31#include "iwl-dev.h" /* still needed */ 31#include "iwl-csr.h"
32#include "iwl-agn-hw.h"
32 33
33/* Highest firmware API version supported */ 34/* Highest firmware API version supported */
34#define IWL1000_UCODE_API_MAX 6 35#define IWL1000_UCODE_API_MAX 6
@@ -42,6 +43,10 @@
42#define IWL1000_UCODE_API_MIN 1 43#define IWL1000_UCODE_API_MIN 1
43#define IWL100_UCODE_API_MIN 5 44#define IWL100_UCODE_API_MIN 5
44 45
46/* EEPROM version */
47#define EEPROM_1000_TX_POWER_VERSION (4)
48#define EEPROM_1000_EEPROM_VERSION (0x15C)
49
45#define IWL1000_FW_PRE "iwlwifi-1000-" 50#define IWL1000_FW_PRE "iwlwifi-1000-"
46#define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE __stringify(api) ".ucode" 51#define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE __stringify(api) ".ucode"
47 52
@@ -66,7 +71,6 @@ static const struct iwl_base_params iwl1000_base_params = {
66static const struct iwl_ht_params iwl1000_ht_params = { 71static const struct iwl_ht_params iwl1000_ht_params = {
67 .ht_greenfield_support = true, 72 .ht_greenfield_support = true,
68 .use_rts_for_aggregation = true, /* use rts/cts protection */ 73 .use_rts_for_aggregation = true, /* use rts/cts protection */
69 .smps_mode = IEEE80211_SMPS_DYNAMIC,
70}; 74};
71 75
72#define IWL_DEVICE_1000 \ 76#define IWL_DEVICE_1000 \
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index 3d4a36cf0408..9484e3be2678 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -28,7 +28,8 @@
28#include <linux/stringify.h> 28#include <linux/stringify.h>
29#include "iwl-config.h" 29#include "iwl-config.h"
30#include "iwl-cfg.h" 30#include "iwl-cfg.h"
31#include "iwl-dev.h" /* still needed */ 31#include "iwl-agn-hw.h"
32#include "iwl-commands.h" /* needed for BT for now */
32 33
33/* Highest firmware API version supported */ 34/* Highest firmware API version supported */
34#define IWL2030_UCODE_API_MAX 6 35#define IWL2030_UCODE_API_MAX 6
@@ -48,6 +49,11 @@
48#define IWL105_UCODE_API_MIN 5 49#define IWL105_UCODE_API_MIN 5
49#define IWL135_UCODE_API_MIN 5 50#define IWL135_UCODE_API_MIN 5
50 51
52/* EEPROM version */
53#define EEPROM_2000_TX_POWER_VERSION (6)
54#define EEPROM_2000_EEPROM_VERSION (0x805)
55
56
51#define IWL2030_FW_PRE "iwlwifi-2030-" 57#define IWL2030_FW_PRE "iwlwifi-2030-"
52#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode" 58#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
53 59
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index ffa9ac5fe086..67d4ef26043b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -28,7 +28,8 @@
28#include <linux/stringify.h> 28#include <linux/stringify.h>
29#include "iwl-config.h" 29#include "iwl-config.h"
30#include "iwl-cfg.h" 30#include "iwl-cfg.h"
31#include "iwl-dev.h" /* still needed */ 31#include "iwl-agn-hw.h"
32#include "iwl-csr.h"
32 33
33/* Highest firmware API version supported */ 34/* Highest firmware API version supported */
34#define IWL5000_UCODE_API_MAX 5 35#define IWL5000_UCODE_API_MAX 5
@@ -38,6 +39,12 @@
38#define IWL5000_UCODE_API_MIN 1 39#define IWL5000_UCODE_API_MIN 1
39#define IWL5150_UCODE_API_MIN 1 40#define IWL5150_UCODE_API_MIN 1
40 41
42/* EEPROM versions */
43#define EEPROM_5000_TX_POWER_VERSION (4)
44#define EEPROM_5000_EEPROM_VERSION (0x11A)
45#define EEPROM_5050_TX_POWER_VERSION (4)
46#define EEPROM_5050_EEPROM_VERSION (0x21E)
47
41#define IWL5000_FW_PRE "iwlwifi-5000-" 48#define IWL5000_FW_PRE "iwlwifi-5000-"
42#define IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE __stringify(api) ".ucode" 49#define IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE __stringify(api) ".ucode"
43 50
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 00da2520a4b7..08afedf4b3ec 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -28,7 +28,8 @@
28#include <linux/stringify.h> 28#include <linux/stringify.h>
29#include "iwl-config.h" 29#include "iwl-config.h"
30#include "iwl-cfg.h" 30#include "iwl-cfg.h"
31#include "iwl-dev.h" /* still needed */ 31#include "iwl-agn-hw.h"
32#include "iwl-commands.h" /* needed for BT for now */
32 33
33/* Highest firmware API version supported */ 34/* Highest firmware API version supported */
34#define IWL6000_UCODE_API_MAX 6 35#define IWL6000_UCODE_API_MAX 6
@@ -44,6 +45,20 @@
44#define IWL6050_UCODE_API_MIN 4 45#define IWL6050_UCODE_API_MIN 4
45#define IWL6000G2_UCODE_API_MIN 4 46#define IWL6000G2_UCODE_API_MIN 4
46 47
48/* EEPROM versions */
49#define EEPROM_6000_TX_POWER_VERSION (4)
50#define EEPROM_6000_EEPROM_VERSION (0x423)
51#define EEPROM_6050_TX_POWER_VERSION (4)
52#define EEPROM_6050_EEPROM_VERSION (0x532)
53#define EEPROM_6150_TX_POWER_VERSION (6)
54#define EEPROM_6150_EEPROM_VERSION (0x553)
55#define EEPROM_6005_TX_POWER_VERSION (6)
56#define EEPROM_6005_EEPROM_VERSION (0x709)
57#define EEPROM_6030_TX_POWER_VERSION (6)
58#define EEPROM_6030_EEPROM_VERSION (0x709)
59#define EEPROM_6035_TX_POWER_VERSION (6)
60#define EEPROM_6035_EEPROM_VERSION (0x753)
61
47#define IWL6000_FW_PRE "iwlwifi-6000-" 62#define IWL6000_FW_PRE "iwlwifi-6000-"
48#define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode" 63#define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode"
49 64
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 61c243f7395f..95f27f1a423b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -64,7 +64,6 @@
64#include <net/mac80211.h> 64#include <net/mac80211.h>
65 65
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67#include "iwl-core.h"
68#include "iwl-agn-calib.h" 67#include "iwl-agn-calib.h"
69#include "iwl-trans.h" 68#include "iwl-trans.h"
70#include "iwl-agn.h" 69#include "iwl-agn.h"
@@ -521,7 +520,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
521 520
522 iwl_prepare_legacy_sensitivity_tbl(priv, data, &cmd.enhance_table[0]); 521 iwl_prepare_legacy_sensitivity_tbl(priv, data, &cmd.enhance_table[0]);
523 522
524 if (cfg(priv)->base_params->hd_v2) { 523 if (priv->cfg->base_params->hd_v2) {
525 cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX] = 524 cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX] =
526 HD_INA_NON_SQUARE_DET_OFDM_DATA_V2; 525 HD_INA_NON_SQUARE_DET_OFDM_DATA_V2;
527 cmd.enhance_table[HD_INA_NON_SQUARE_DET_CCK_INDEX] = 526 cmd.enhance_table[HD_INA_NON_SQUARE_DET_CCK_INDEX] =
@@ -895,7 +894,7 @@ static void iwlagn_gain_computation(struct iwl_priv *priv,
895 continue; 894 continue;
896 } 895 }
897 896
898 delta_g = (cfg(priv)->base_params->chain_noise_scale * 897 delta_g = (priv->cfg->base_params->chain_noise_scale *
899 ((s32)average_noise[default_chain] - 898 ((s32)average_noise[default_chain] -
900 (s32)average_noise[i])) / 1500; 899 (s32)average_noise[i])) / 1500;
901 900
@@ -1051,8 +1050,8 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
1051 return; 1050 return;
1052 1051
1053 /* Analyze signal for disconnected antenna */ 1052 /* Analyze signal for disconnected antenna */
1054 if (cfg(priv)->bt_params && 1053 if (priv->cfg->bt_params &&
1055 cfg(priv)->bt_params->advanced_bt_coexist) { 1054 priv->cfg->bt_params->advanced_bt_coexist) {
1056 /* Disable disconnected antenna algorithm for advanced 1055 /* Disable disconnected antenna algorithm for advanced
1057 bt coex, assuming valid antennas are connected */ 1056 bt coex, assuming valid antennas are connected */
1058 data->active_chains = priv->hw_params.valid_rx_ant; 1057 data->active_chains = priv->hw_params.valid_rx_ant;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
index 9ed6683314a7..dbe13787f272 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
@@ -63,7 +63,6 @@
63#define __iwl_calib_h__ 63#define __iwl_calib_h__
64 64
65#include "iwl-dev.h" 65#include "iwl-dev.h"
66#include "iwl-core.h"
67#include "iwl-commands.h" 66#include "iwl-commands.h"
68 67
69void iwl_chain_noise_calibration(struct iwl_priv *priv); 68void iwl_chain_noise_calibration(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-devices.c b/drivers/net/wireless/iwlwifi/iwl-agn-devices.c
index 08718caf4aa9..48533b3a0f9a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-devices.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-devices.c
@@ -27,7 +27,6 @@
27/* 27/*
28 * DVM device-specific data & functions 28 * DVM device-specific data & functions
29 */ 29 */
30#include "iwl-core.h"
31#include "iwl-agn.h" 30#include "iwl-agn.h"
32#include "iwl-dev.h" 31#include "iwl-dev.h"
33#include "iwl-commands.h" 32#include "iwl-commands.h"
@@ -60,13 +59,13 @@ static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
60static void iwl1000_nic_config(struct iwl_priv *priv) 59static void iwl1000_nic_config(struct iwl_priv *priv)
61{ 60{
62 /* set CSR_HW_CONFIG_REG for uCode use */ 61 /* set CSR_HW_CONFIG_REG for uCode use */
63 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, 62 iwl_set_bit(priv->trans, CSR_HW_IF_CONFIG_REG,
64 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | 63 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
65 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); 64 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
66 65
67 /* Setting digital SVR for 1000 card to 1.32V */ 66 /* Setting digital SVR for 1000 card to 1.32V */
68 /* locking is acquired in iwl_set_bits_mask_prph() function */ 67 /* locking is acquired in iwl_set_bits_mask_prph() function */
69 iwl_set_bits_mask_prph(trans(priv), APMG_DIGITAL_SVR_REG, 68 iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
70 APMG_SVR_DIGITAL_VOLTAGE_1_32, 69 APMG_SVR_DIGITAL_VOLTAGE_1_32,
71 ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK); 70 ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
72} 71}
@@ -175,7 +174,7 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
175 174
176 priv->hw_params.tx_chains_num = 175 priv->hw_params.tx_chains_num =
177 num_of_ant(priv->hw_params.valid_tx_ant); 176 num_of_ant(priv->hw_params.valid_tx_ant);
178 if (cfg(priv)->rx_with_siso_diversity) 177 if (priv->cfg->rx_with_siso_diversity)
179 priv->hw_params.rx_chains_num = 1; 178 priv->hw_params.rx_chains_num = 1;
180 else 179 else
181 priv->hw_params.rx_chains_num = 180 priv->hw_params.rx_chains_num =
@@ -222,7 +221,7 @@ static void iwl2000_nic_config(struct iwl_priv *priv)
222{ 221{
223 iwl_rf_config(priv); 222 iwl_rf_config(priv);
224 223
225 iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, 224 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
226 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER); 225 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
227} 226}
228 227
@@ -256,7 +255,7 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
256 255
257 priv->hw_params.tx_chains_num = 256 priv->hw_params.tx_chains_num =
258 num_of_ant(priv->hw_params.valid_tx_ant); 257 num_of_ant(priv->hw_params.valid_tx_ant);
259 if (cfg(priv)->rx_with_siso_diversity) 258 if (priv->cfg->rx_with_siso_diversity)
260 priv->hw_params.rx_chains_num = 1; 259 priv->hw_params.rx_chains_num = 1;
261 else 260 else
262 priv->hw_params.rx_chains_num = 261 priv->hw_params.rx_chains_num =
@@ -318,7 +317,7 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
318 * (PCIe power is lost before PERST# is asserted), 317 * (PCIe power is lost before PERST# is asserted),
319 * causing ME FW to lose ownership and not being able to obtain it back. 318 * causing ME FW to lose ownership and not being able to obtain it back.
320 */ 319 */
321 iwl_set_bits_mask_prph(trans(priv), APMG_PS_CTRL_REG, 320 iwl_set_bits_mask_prph(priv->trans, APMG_PS_CTRL_REG,
322 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, 321 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
323 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); 322 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
324} 323}
@@ -573,28 +572,28 @@ static void iwl6000_nic_config(struct iwl_priv *priv)
573{ 572{
574 iwl_rf_config(priv); 573 iwl_rf_config(priv);
575 574
576 switch (cfg(priv)->device_family) { 575 switch (priv->cfg->device_family) {
577 case IWL_DEVICE_FAMILY_6005: 576 case IWL_DEVICE_FAMILY_6005:
578 case IWL_DEVICE_FAMILY_6030: 577 case IWL_DEVICE_FAMILY_6030:
579 case IWL_DEVICE_FAMILY_6000: 578 case IWL_DEVICE_FAMILY_6000:
580 break; 579 break;
581 case IWL_DEVICE_FAMILY_6000i: 580 case IWL_DEVICE_FAMILY_6000i:
582 /* 2x2 IPA phy type */ 581 /* 2x2 IPA phy type */
583 iwl_write32(trans(priv), CSR_GP_DRIVER_REG, 582 iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
584 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA); 583 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
585 break; 584 break;
586 case IWL_DEVICE_FAMILY_6050: 585 case IWL_DEVICE_FAMILY_6050:
587 /* Indicate calibration version to uCode. */ 586 /* Indicate calibration version to uCode. */
588 if (iwl_eeprom_calib_version(priv) >= 6) 587 if (iwl_eeprom_calib_version(priv) >= 6)
589 iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, 588 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
590 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); 589 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
591 break; 590 break;
592 case IWL_DEVICE_FAMILY_6150: 591 case IWL_DEVICE_FAMILY_6150:
593 /* Indicate calibration version to uCode. */ 592 /* Indicate calibration version to uCode. */
594 if (iwl_eeprom_calib_version(priv) >= 6) 593 if (iwl_eeprom_calib_version(priv) >= 6)
595 iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, 594 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
596 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); 595 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
597 iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, 596 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
598 CSR_GP_DRIVER_REG_BIT_6050_1x2); 597 CSR_GP_DRIVER_REG_BIT_6050_1x2);
599 break; 598 break;
600 default: 599 default:
@@ -633,7 +632,7 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
633 632
634 priv->hw_params.tx_chains_num = 633 priv->hw_params.tx_chains_num =
635 num_of_ant(priv->hw_params.valid_tx_ant); 634 num_of_ant(priv->hw_params.valid_tx_ant);
636 if (cfg(priv)->rx_with_siso_diversity) 635 if (priv->cfg->rx_with_siso_diversity)
637 priv->hw_params.rx_chains_num = 1; 636 priv->hw_params.rx_chains_num = 1;
638 else 637 else
639 priv->hw_params.rx_chains_num = 638 priv->hw_params.rx_chains_num =
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
index c797ab19d933..7960a52f6ad4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
@@ -102,6 +102,17 @@
102 102
103/* EEPROM */ 103/* EEPROM */
104#define IWLAGN_EEPROM_IMG_SIZE 2048 104#define IWLAGN_EEPROM_IMG_SIZE 2048
105/* OTP */
106/* lower blocks contain EEPROM image and calibration data */
107#define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */
108/* high blocks contain PAPD data */
109#define OTP_HIGH_IMAGE_SIZE_6x00 (6 * 512 * sizeof(u16)) /* 6 KB */
110#define OTP_HIGH_IMAGE_SIZE_1000 (0x200 * sizeof(u16)) /* 1024 bytes */
111#define OTP_MAX_LL_ITEMS_1000 (3) /* OTP blocks for 1000 */
112#define OTP_MAX_LL_ITEMS_6x00 (4) /* OTP blocks for 6x00 */
113#define OTP_MAX_LL_ITEMS_6x50 (7) /* OTP blocks for 6x50 */
114#define OTP_MAX_LL_ITEMS_2x00 (4) /* OTP blocks for 2x00 */
115
105 116
106#define IWLAGN_NUM_QUEUES 20 117#define IWLAGN_NUM_QUEUES 20
107 118
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 4e0c248a0050..e1c2bb802050 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -33,12 +33,11 @@
33#include <linux/sched.h> 33#include <linux/sched.h>
34 34
35#include "iwl-dev.h" 35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-io.h" 36#include "iwl-io.h"
38#include "iwl-agn-hw.h" 37#include "iwl-agn-hw.h"
39#include "iwl-agn.h" 38#include "iwl-agn.h"
40#include "iwl-trans.h" 39#include "iwl-trans.h"
41#include "iwl-shared.h" 40#include "iwl-modparams.h"
42 41
43int iwlagn_hw_valid_rtc_data_addr(u32 addr) 42int iwlagn_hw_valid_rtc_data_addr(u32 addr)
44{ 43{
@@ -94,17 +93,6 @@ void iwlagn_temperature(struct iwl_priv *priv)
94 iwl_tt_handler(priv); 93 iwl_tt_handler(priv);
95} 94}
96 95
97struct iwl_mod_params iwlagn_mod_params = {
98 .amsdu_size_8K = 1,
99 .restart_fw = 1,
100 .plcp_check = true,
101 .bt_coex_active = true,
102 .power_level = IWL_POWER_INDEX_1,
103 .bt_ch_announce = true,
104 .auto_agg = true,
105 /* the rest are 0 by default */
106};
107
108int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) 96int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band)
109{ 97{
110 int idx = 0; 98 int idx = 0;
@@ -189,7 +177,7 @@ void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
189 goto done; 177 goto done;
190 } 178 }
191 IWL_DEBUG_INFO(priv, "wait transmit/flush all frames\n"); 179 IWL_DEBUG_INFO(priv, "wait transmit/flush all frames\n");
192 iwl_trans_wait_tx_queue_empty(trans(priv)); 180 iwl_trans_wait_tx_queue_empty(priv->trans);
193done: 181done:
194 ieee80211_wake_queues(priv->hw); 182 ieee80211_wake_queues(priv->hw);
195 mutex_unlock(&priv->mutex); 183 mutex_unlock(&priv->mutex);
@@ -312,21 +300,21 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
312 BUILD_BUG_ON(sizeof(iwlagn_def_3w_lookup) != 300 BUILD_BUG_ON(sizeof(iwlagn_def_3w_lookup) !=
313 sizeof(basic.bt3_lookup_table)); 301 sizeof(basic.bt3_lookup_table));
314 302
315 if (cfg(priv)->bt_params) { 303 if (priv->cfg->bt_params) {
316 /* 304 /*
317 * newer generation of devices (2000 series and newer) 305 * newer generation of devices (2000 series and newer)
318 * use the version 2 of the bt command 306 * use the version 2 of the bt command
319 * we need to make sure sending the host command 307 * we need to make sure sending the host command
320 * with correct data structure to avoid uCode assert 308 * with correct data structure to avoid uCode assert
321 */ 309 */
322 if (cfg(priv)->bt_params->bt_session_2) { 310 if (priv->cfg->bt_params->bt_session_2) {
323 bt_cmd_v2.prio_boost = cpu_to_le32( 311 bt_cmd_v2.prio_boost = cpu_to_le32(
324 cfg(priv)->bt_params->bt_prio_boost); 312 priv->cfg->bt_params->bt_prio_boost);
325 bt_cmd_v2.tx_prio_boost = 0; 313 bt_cmd_v2.tx_prio_boost = 0;
326 bt_cmd_v2.rx_prio_boost = 0; 314 bt_cmd_v2.rx_prio_boost = 0;
327 } else { 315 } else {
328 bt_cmd_v1.prio_boost = 316 bt_cmd_v1.prio_boost =
329 cfg(priv)->bt_params->bt_prio_boost; 317 priv->cfg->bt_params->bt_prio_boost;
330 bt_cmd_v1.tx_prio_boost = 0; 318 bt_cmd_v1.tx_prio_boost = 0;
331 bt_cmd_v1.rx_prio_boost = 0; 319 bt_cmd_v1.rx_prio_boost = 0;
332 } 320 }
@@ -345,7 +333,7 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
345 * (might be in monitor mode), or the interface is in 333 * (might be in monitor mode), or the interface is in
346 * IBSS mode (no proper uCode support for coex then). 334 * IBSS mode (no proper uCode support for coex then).
347 */ 335 */
348 if (!iwlagn_mod_params.bt_coex_active || 336 if (!iwlwifi_mod_params.bt_coex_active ||
349 priv->iw_mode == NL80211_IFTYPE_ADHOC) { 337 priv->iw_mode == NL80211_IFTYPE_ADHOC) {
350 basic.flags = IWLAGN_BT_FLAG_COEX_MODE_DISABLED; 338 basic.flags = IWLAGN_BT_FLAG_COEX_MODE_DISABLED;
351 } else { 339 } else {
@@ -374,7 +362,7 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
374 priv->bt_full_concurrent ? 362 priv->bt_full_concurrent ?
375 "full concurrency" : "3-wire"); 363 "full concurrency" : "3-wire");
376 364
377 if (cfg(priv)->bt_params->bt_session_2) { 365 if (priv->cfg->bt_params->bt_session_2) {
378 memcpy(&bt_cmd_v2.basic, &basic, 366 memcpy(&bt_cmd_v2.basic, &basic,
379 sizeof(basic)); 367 sizeof(basic));
380 ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG, 368 ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG,
@@ -740,8 +728,8 @@ static bool is_single_rx_stream(struct iwl_priv *priv)
740 */ 728 */
741static int iwl_get_active_rx_chain_count(struct iwl_priv *priv) 729static int iwl_get_active_rx_chain_count(struct iwl_priv *priv)
742{ 730{
743 if (cfg(priv)->bt_params && 731 if (priv->cfg->bt_params &&
744 cfg(priv)->bt_params->advanced_bt_coexist && 732 priv->cfg->bt_params->advanced_bt_coexist &&
745 (priv->bt_full_concurrent || 733 (priv->bt_full_concurrent ||
746 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) { 734 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) {
747 /* 735 /*
@@ -812,8 +800,8 @@ void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
812 else 800 else
813 active_chains = priv->hw_params.valid_rx_ant; 801 active_chains = priv->hw_params.valid_rx_ant;
814 802
815 if (cfg(priv)->bt_params && 803 if (priv->cfg->bt_params &&
816 cfg(priv)->bt_params->advanced_bt_coexist && 804 priv->cfg->bt_params->advanced_bt_coexist &&
817 (priv->bt_full_concurrent || 805 (priv->bt_full_concurrent ||
818 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) { 806 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) {
819 /* 807 /*
@@ -1132,7 +1120,7 @@ int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan)
1132 memcpy(&rxon, &ctx->active, sizeof(rxon)); 1120 memcpy(&rxon, &ctx->active, sizeof(rxon));
1133 1121
1134 priv->ucode_loaded = false; 1122 priv->ucode_loaded = false;
1135 iwl_trans_stop_device(trans(priv)); 1123 iwl_trans_stop_device(priv->trans);
1136 1124
1137 priv->wowlan = true; 1125 priv->wowlan = true;
1138 1126
@@ -1154,7 +1142,7 @@ int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan)
1154 if (ret) 1142 if (ret)
1155 goto out; 1143 goto out;
1156 1144
1157 if (!iwlagn_mod_params.sw_crypto) { 1145 if (!iwlwifi_mod_params.sw_crypto) {
1158 /* mark all keys clear */ 1146 /* mark all keys clear */
1159 priv->ucode_key_table = 0; 1147 priv->ucode_key_table = 0;
1160 ctx->key_mapping_keys = 0; 1148 ctx->key_mapping_keys = 0;
@@ -1260,7 +1248,7 @@ int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1260 return -EIO; 1248 return -EIO;
1261 } 1249 }
1262 1250
1263 return iwl_trans_send_cmd(trans(priv), cmd); 1251 return iwl_trans_send_cmd(priv->trans, cmd);
1264} 1252}
1265 1253
1266int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id, 1254int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 8b13b6cf940a..51e1a69ffdda 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -36,9 +36,9 @@
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37 37
38#include "iwl-dev.h" 38#include "iwl-dev.h"
39#include "iwl-core.h"
40#include "iwl-agn.h" 39#include "iwl-agn.h"
41#include "iwl-op-mode.h" 40#include "iwl-op-mode.h"
41#include "iwl-modparams.h"
42 42
43#define RS_NAME "iwl-agn-rs" 43#define RS_NAME "iwl-agn-rs"
44 44
@@ -420,7 +420,7 @@ static int rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
420 420
421 load = rs_tl_get_load(lq_data, tid); 421 load = rs_tl_get_load(lq_data, tid);
422 422
423 if ((iwlagn_mod_params.auto_agg) || (load > IWL_AGG_LOAD_THRESHOLD)) { 423 if ((iwlwifi_mod_params.auto_agg) || (load > IWL_AGG_LOAD_THRESHOLD)) {
424 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", 424 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
425 sta->addr, tid); 425 sta->addr, tid);
426 ret = ieee80211_start_tx_ba_session(sta, tid, 5000); 426 ret = ieee80211_start_tx_ba_session(sta, tid, 5000);
@@ -1085,7 +1085,7 @@ done:
1085 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate)) 1085 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate))
1086 rs_program_fix_rate(priv, lq_sta); 1086 rs_program_fix_rate(priv, lq_sta);
1087#endif 1087#endif
1088 if (cfg(priv)->bt_params && cfg(priv)->bt_params->advanced_bt_coexist) 1088 if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist)
1089 rs_bt_update_lq(priv, ctx, lq_sta); 1089 rs_bt_update_lq(priv, ctx, lq_sta);
1090} 1090}
1091 1091
@@ -3063,11 +3063,11 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,
3063 * overwrite if needed, pass aggregation time limit 3063 * overwrite if needed, pass aggregation time limit
3064 * to uCode in uSec 3064 * to uCode in uSec
3065 */ 3065 */
3066 if (priv && cfg(priv)->bt_params && 3066 if (priv && priv->cfg->bt_params &&
3067 cfg(priv)->bt_params->agg_time_limit && 3067 priv->cfg->bt_params->agg_time_limit &&
3068 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) 3068 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)
3069 lq_cmd->agg_params.agg_time_limit = 3069 lq_cmd->agg_params.agg_time_limit =
3070 cpu_to_le16(cfg(priv)->bt_params->agg_time_limit); 3070 cpu_to_le16(priv->cfg->bt_params->agg_time_limit);
3071} 3071}
3072 3072
3073static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 3073static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 203b1c13c491..82d02e1ae89f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -30,6 +30,7 @@
30#include <net/mac80211.h> 30#include <net/mac80211.h>
31 31
32#include "iwl-commands.h" 32#include "iwl-commands.h"
33#include "iwl-config.h"
33 34
34struct iwl_rate_info { 35struct iwl_rate_info {
35 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ 36 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
@@ -174,32 +175,6 @@ enum {
174 IWL_RATE_11M_IEEE = 22, 175 IWL_RATE_11M_IEEE = 22,
175}; 176};
176 177
177#define IWL_CCK_BASIC_RATES_MASK \
178 (IWL_RATE_1M_MASK | \
179 IWL_RATE_2M_MASK)
180
181#define IWL_CCK_RATES_MASK \
182 (IWL_CCK_BASIC_RATES_MASK | \
183 IWL_RATE_5M_MASK | \
184 IWL_RATE_11M_MASK)
185
186#define IWL_OFDM_BASIC_RATES_MASK \
187 (IWL_RATE_6M_MASK | \
188 IWL_RATE_12M_MASK | \
189 IWL_RATE_24M_MASK)
190
191#define IWL_OFDM_RATES_MASK \
192 (IWL_OFDM_BASIC_RATES_MASK | \
193 IWL_RATE_9M_MASK | \
194 IWL_RATE_18M_MASK | \
195 IWL_RATE_36M_MASK | \
196 IWL_RATE_48M_MASK | \
197 IWL_RATE_54M_MASK)
198
199#define IWL_BASIC_RATES_MASK \
200 (IWL_OFDM_BASIC_RATES_MASK | \
201 IWL_CCK_BASIC_RATES_MASK)
202
203#define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) 178#define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1)
204 179
205#define IWL_INVALID_VALUE -1 180#define IWL_INVALID_VALUE -1
@@ -306,15 +281,6 @@ enum iwl_table_type {
306#define is_a_band(tbl) ((tbl) == LQ_A) 281#define is_a_band(tbl) ((tbl) == LQ_A)
307#define is_g_and(tbl) ((tbl) == LQ_G) 282#define is_g_and(tbl) ((tbl) == LQ_G)
308 283
309#define ANT_NONE 0x0
310#define ANT_A BIT(0)
311#define ANT_B BIT(1)
312#define ANT_AB (ANT_A | ANT_B)
313#define ANT_C BIT(2)
314#define ANT_AC (ANT_A | ANT_C)
315#define ANT_BC (ANT_B | ANT_C)
316#define ANT_ABC (ANT_AB | ANT_C)
317
318#define IWL_MAX_MCS_DISPLAY_SIZE 12 284#define IWL_MAX_MCS_DISPLAY_SIZE 12
319 285
320struct iwl_rate_mcs_info { 286struct iwl_rate_mcs_info {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
index db6c90f6affe..f94122387e25 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
@@ -34,11 +34,10 @@
34#include <asm/unaligned.h> 34#include <asm/unaligned.h>
35#include "iwl-eeprom.h" 35#include "iwl-eeprom.h"
36#include "iwl-dev.h" 36#include "iwl-dev.h"
37#include "iwl-core.h"
38#include "iwl-io.h" 37#include "iwl-io.h"
39#include "iwl-agn-calib.h" 38#include "iwl-agn-calib.h"
40#include "iwl-agn.h" 39#include "iwl-agn.h"
41#include "iwl-shared.h" 40#include "iwl-modparams.h"
42 41
43#define IWL_CMD_ENTRY(x) [x] = #x 42#define IWL_CMD_ENTRY(x) [x] = #x
44 43
@@ -339,7 +338,7 @@ static void iwlagn_recover_from_statistics(struct iwl_priv *priv,
339 if (msecs < 99) 338 if (msecs < 99)
340 return; 339 return;
341 340
342 if (iwlagn_mod_params.plcp_check && 341 if (iwlwifi_mod_params.plcp_check &&
343 !iwlagn_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs)) 342 !iwlagn_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs))
344 iwl_force_rf_reset(priv, false); 343 iwl_force_rf_reset(priv, false);
345} 344}
@@ -604,16 +603,16 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
604 if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | 603 if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
605 CT_CARD_DISABLED)) { 604 CT_CARD_DISABLED)) {
606 605
607 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, 606 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_SET,
608 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); 607 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
609 608
610 iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C, 609 iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C,
611 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); 610 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
612 611
613 if (!(flags & RXON_CARD_DISABLED)) { 612 if (!(flags & RXON_CARD_DISABLED)) {
614 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, 613 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
615 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); 614 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
616 iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C, 615 iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C,
617 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); 616 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
618 } 617 }
619 if (flags & CT_CARD_DISABLED) 618 if (flags & CT_CARD_DISABLED)
@@ -636,7 +635,7 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
636 wiphy_rfkill_set_hw_state(priv->hw->wiphy, 635 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
637 test_bit(STATUS_RF_KILL_HW, &priv->status)); 636 test_bit(STATUS_RF_KILL_HW, &priv->status));
638 else 637 else
639 wake_up(&trans(priv)->wait_command_queue); 638 wake_up(&priv->trans->wait_command_queue);
640 return 0; 639 return 0;
641} 640}
642 641
@@ -749,7 +748,7 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
749 } 748 }
750 749
751 /* In case of HW accelerated crypto and bad decryption, drop */ 750 /* In case of HW accelerated crypto and bad decryption, drop */
752 if (!iwlagn_mod_params.sw_crypto && 751 if (!iwlwifi_mod_params.sw_crypto &&
753 iwlagn_set_decrypted_flag(priv, hdr, ampdu_status, stats)) 752 iwlagn_set_decrypted_flag(priv, hdr, ampdu_status, stats))
754 return; 753 return;
755 754
@@ -763,8 +762,6 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
763 p = rxb_steal_page(rxb); 762 p = rxb_steal_page(rxb);
764 skb_add_rx_frag(skb, 0, p, offset, len, len); 763 skb_add_rx_frag(skb, 0, p, offset, len, len);
765 764
766 iwl_update_stats(priv, false, fc, len);
767
768 /* 765 /*
769 * Wake any queues that were stopped due to a passive channel tx 766 * Wake any queues that were stopped due to a passive channel tx
770 * failure. This can happen because the regulatory enforcement in 767 * failure. This can happen because the regulatory enforcement in
@@ -970,7 +967,6 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
970 /* Find max signal strength (dBm) among 3 antenna/receiver chains */ 967 /* Find max signal strength (dBm) among 3 antenna/receiver chains */
971 rx_status.signal = iwlagn_calc_rssi(priv, phy_res); 968 rx_status.signal = iwlagn_calc_rssi(priv, phy_res);
972 969
973 iwl_dbg_log_rx_data_frame(priv, len, header);
974 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", 970 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
975 rx_status.signal, (unsigned long long)rx_status.mactime); 971 rx_status.signal, (unsigned long long)rx_status.mactime);
976 972
@@ -1105,7 +1101,7 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv)
1105 iwl_notification_wait_init(&priv->notif_wait); 1101 iwl_notification_wait_init(&priv->notif_wait);
1106 1102
1107 /* Set up BT Rx handlers */ 1103 /* Set up BT Rx handlers */
1108 if (cfg(priv)->bt_params) 1104 if (priv->cfg->bt_params)
1109 iwlagn_bt_rx_handler_setup(priv); 1105 iwlagn_bt_rx_handler_setup(priv);
1110} 1106}
1111 1107
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index 5c7bddd5cfef..0f7c444f2440 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -27,10 +27,9 @@
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include "iwl-dev.h" 28#include "iwl-dev.h"
29#include "iwl-agn.h" 29#include "iwl-agn.h"
30#include "iwl-core.h"
31#include "iwl-agn-calib.h" 30#include "iwl-agn-calib.h"
32#include "iwl-trans.h" 31#include "iwl-trans.h"
33#include "iwl-shared.h" 32#include "iwl-modparams.h"
34 33
35/* 34/*
36 * initialize rxon structure with default values from eeprom 35 * initialize rxon structure with default values from eeprom
@@ -88,11 +87,6 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv,
88 87
89 iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif); 88 iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif);
90 89
91 ctx->staging.ofdm_basic_rates =
92 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
93 ctx->staging.cck_basic_rates =
94 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
95
96 /* clear both MIX and PURE40 mode flag */ 90 /* clear both MIX and PURE40 mode flag */
97 ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | 91 ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED |
98 RXON_FLG_CHANNEL_MODE_PURE_40); 92 RXON_FLG_CHANNEL_MODE_PURE_40);
@@ -531,9 +525,9 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
531 } 525 }
532 526
533 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION && 527 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION &&
534 cfg(priv)->ht_params && cfg(priv)->ht_params->smps_mode) 528 priv->cfg->ht_params && priv->cfg->ht_params->smps_mode)
535 ieee80211_request_smps(ctx->vif, 529 ieee80211_request_smps(ctx->vif,
536 cfg(priv)->ht_params->smps_mode); 530 priv->cfg->ht_params->smps_mode);
537 531
538 return 0; 532 return 0;
539} 533}
@@ -772,19 +766,6 @@ void iwl_set_flags_for_band(struct iwl_priv *priv,
772 } 766 }
773} 767}
774 768
775void iwl_set_rate(struct iwl_priv *priv)
776{
777 struct iwl_rxon_context *ctx;
778
779 for_each_context(priv, ctx) {
780 ctx->staging.cck_basic_rates =
781 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
782
783 ctx->staging.ofdm_basic_rates =
784 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
785 }
786}
787
788static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, 769static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv,
789 struct iwl_rxon_context *ctx, int hw_decrypt) 770 struct iwl_rxon_context *ctx, int hw_decrypt)
790{ 771{
@@ -960,6 +941,97 @@ void iwl_print_rx_config_cmd(struct iwl_priv *priv,
960} 941}
961#endif 942#endif
962 943
944static void iwl_calc_basic_rates(struct iwl_priv *priv,
945 struct iwl_rxon_context *ctx)
946{
947 int lowest_present_ofdm = 100;
948 int lowest_present_cck = 100;
949 u8 cck = 0;
950 u8 ofdm = 0;
951
952 if (ctx->vif) {
953 struct ieee80211_supported_band *sband;
954 unsigned long basic = ctx->vif->bss_conf.basic_rates;
955 int i;
956
957 sband = priv->hw->wiphy->bands[priv->hw->conf.channel->band];
958
959 for_each_set_bit(i, &basic, BITS_PER_LONG) {
960 int hw = sband->bitrates[i].hw_value;
961 if (hw >= IWL_FIRST_OFDM_RATE) {
962 ofdm |= BIT(hw - IWL_FIRST_OFDM_RATE);
963 if (lowest_present_ofdm > hw)
964 lowest_present_ofdm = hw;
965 } else {
966 BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
967
968 cck |= BIT(hw);
969 if (lowest_present_cck > hw)
970 lowest_present_cck = hw;
971 }
972 }
973 }
974
975 /*
976 * Now we've got the basic rates as bitmaps in the ofdm and cck
977 * variables. This isn't sufficient though, as there might not
978 * be all the right rates in the bitmap. E.g. if the only basic
979 * rates are 5.5 Mbps and 11 Mbps, we still need to add 1 Mbps
980 * and 6 Mbps because the 802.11-2007 standard says in 9.6:
981 *
982 * [...] a STA responding to a received frame shall transmit
983 * its Control Response frame [...] at the highest rate in the
984 * BSSBasicRateSet parameter that is less than or equal to the
985 * rate of the immediately previous frame in the frame exchange
986 * sequence ([...]) and that is of the same modulation class
987 * ([...]) as the received frame. If no rate contained in the
988 * BSSBasicRateSet parameter meets these conditions, then the
989 * control frame sent in response to a received frame shall be
990 * transmitted at the highest mandatory rate of the PHY that is
991 * less than or equal to the rate of the received frame, and
992 * that is of the same modulation class as the received frame.
993 *
994 * As a consequence, we need to add all mandatory rates that are
995 * lower than all of the basic rates to these bitmaps.
996 */
997
998 if (IWL_RATE_24M_INDEX < lowest_present_ofdm)
999 ofdm |= IWL_RATE_24M_MASK >> IWL_FIRST_OFDM_RATE;
1000 if (IWL_RATE_12M_INDEX < lowest_present_ofdm)
1001 ofdm |= IWL_RATE_12M_MASK >> IWL_FIRST_OFDM_RATE;
1002 /* 6M already there or needed so always add */
1003 ofdm |= IWL_RATE_6M_MASK >> IWL_FIRST_OFDM_RATE;
1004
1005 /*
1006 * CCK is a bit more complex with DSSS vs. HR/DSSS vs. ERP.
1007 * Note, however:
1008 * - if no CCK rates are basic, it must be ERP since there must
1009 * be some basic rates at all, so they're OFDM => ERP PHY
1010 * (or we're in 5 GHz, and the cck bitmap will never be used)
1011 * - if 11M is a basic rate, it must be ERP as well, so add 5.5M
1012 * - if 5.5M is basic, 1M and 2M are mandatory
1013 * - if 2M is basic, 1M is mandatory
1014 * - if 1M is basic, that's the only valid ACK rate.
1015 * As a consequence, it's not as complicated as it sounds, just add
1016 * any lower rates to the ACK rate bitmap.
1017 */
1018 if (IWL_RATE_11M_INDEX < lowest_present_ofdm)
1019 ofdm |= IWL_RATE_11M_MASK >> IWL_FIRST_CCK_RATE;
1020 if (IWL_RATE_5M_INDEX < lowest_present_ofdm)
1021 ofdm |= IWL_RATE_5M_MASK >> IWL_FIRST_CCK_RATE;
1022 if (IWL_RATE_2M_INDEX < lowest_present_ofdm)
1023 ofdm |= IWL_RATE_2M_MASK >> IWL_FIRST_CCK_RATE;
1024 /* 1M already there or needed so always add */
1025 cck |= IWL_RATE_1M_MASK >> IWL_FIRST_CCK_RATE;
1026
1027 IWL_DEBUG_RATE(priv, "Set basic rates cck:0x%.2x ofdm:0x%.2x\n",
1028 cck, ofdm);
1029
1030 /* "basic_rates" is a misnomer here -- should be called ACK rates */
1031 ctx->staging.cck_basic_rates = cck;
1032 ctx->staging.ofdm_basic_rates = ofdm;
1033}
1034
963/** 1035/**
964 * iwlagn_commit_rxon - commit staging_rxon to hardware 1036 * iwlagn_commit_rxon - commit staging_rxon to hardware
965 * 1037 *
@@ -999,6 +1071,9 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
999 /* always get timestamp with Rx frame */ 1071 /* always get timestamp with Rx frame */
1000 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; 1072 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
1001 1073
1074 /* recalculate basic rates */
1075 iwl_calc_basic_rates(priv, ctx);
1076
1002 /* 1077 /*
1003 * force CTS-to-self frames protection if RTS-CTS is not preferred 1078 * force CTS-to-self frames protection if RTS-CTS is not preferred
1004 * one aggregation protection method 1079 * one aggregation protection method
@@ -1055,7 +1130,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1055 return 0; 1130 return 0;
1056 } 1131 }
1057 1132
1058 iwl_set_rxon_hwcrypto(priv, ctx, !iwlagn_mod_params.sw_crypto); 1133 iwl_set_rxon_hwcrypto(priv, ctx, !iwlwifi_mod_params.sw_crypto);
1059 1134
1060 IWL_DEBUG_INFO(priv, 1135 IWL_DEBUG_INFO(priv,
1061 "Going to commit RXON\n" 1136 "Going to commit RXON\n"
@@ -1187,13 +1262,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
1187 } 1262 }
1188 1263
1189 iwl_update_bcast_stations(priv); 1264 iwl_update_bcast_stations(priv);
1190
1191 /*
1192 * The list of supported rates and rate mask can be different
1193 * for each band; since the band may have changed, reset
1194 * the rate mask to what mac80211 lists.
1195 */
1196 iwl_set_rate(priv);
1197 } 1265 }
1198 1266
1199 if (changed & (IEEE80211_CONF_CHANGE_PS | 1267 if (changed & (IEEE80211_CONF_CHANGE_PS |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
index 0119e7a7b78d..67e6f1d2a08b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
@@ -30,7 +30,6 @@
30#include <net/mac80211.h> 30#include <net/mac80211.h>
31 31
32#include "iwl-dev.h" 32#include "iwl-dev.h"
33#include "iwl-core.h"
34#include "iwl-agn.h" 33#include "iwl-agn.h"
35#include "iwl-trans.h" 34#include "iwl-trans.h"
36 35
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
index baaf5ba2fc38..a5cfe0aceedb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
@@ -37,11 +37,11 @@
37#include "iwl-agn.h" 37#include "iwl-agn.h"
38#include "iwl-eeprom.h" 38#include "iwl-eeprom.h"
39#include "iwl-dev.h" 39#include "iwl-dev.h"
40#include "iwl-core.h"
41#include "iwl-io.h" 40#include "iwl-io.h"
42#include "iwl-commands.h" 41#include "iwl-commands.h"
43#include "iwl-debug.h" 42#include "iwl-debug.h"
44#include "iwl-agn-tt.h" 43#include "iwl-agn-tt.h"
44#include "iwl-modparams.h"
45 45
46/* default Thermal Throttling transaction table 46/* default Thermal Throttling transaction table
47 * Current state | Throttling Down | Throttling Up 47 * Current state | Throttling Down | Throttling Up
@@ -179,19 +179,19 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data)
179 179
180 if (tt->state == IWL_TI_CT_KILL) { 180 if (tt->state == IWL_TI_CT_KILL) {
181 if (priv->thermal_throttle.ct_kill_toggle) { 181 if (priv->thermal_throttle.ct_kill_toggle) {
182 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, 182 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
183 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); 183 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
184 priv->thermal_throttle.ct_kill_toggle = false; 184 priv->thermal_throttle.ct_kill_toggle = false;
185 } else { 185 } else {
186 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, 186 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_SET,
187 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); 187 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
188 priv->thermal_throttle.ct_kill_toggle = true; 188 priv->thermal_throttle.ct_kill_toggle = true;
189 } 189 }
190 iwl_read32(trans(priv), CSR_UCODE_DRV_GP1); 190 iwl_read32(priv->trans, CSR_UCODE_DRV_GP1);
191 spin_lock_irqsave(&trans(priv)->reg_lock, flags); 191 spin_lock_irqsave(&priv->trans->reg_lock, flags);
192 if (likely(iwl_grab_nic_access(trans(priv)))) 192 if (likely(iwl_grab_nic_access(priv->trans)))
193 iwl_release_nic_access(trans(priv)); 193 iwl_release_nic_access(priv->trans);
194 spin_unlock_irqrestore(&trans(priv)->reg_lock, flags); 194 spin_unlock_irqrestore(&priv->trans->reg_lock, flags);
195 195
196 /* Reschedule the ct_kill timer to occur in 196 /* Reschedule the ct_kill timer to occur in
197 * CT_KILL_EXIT_DURATION seconds to ensure we get a 197 * CT_KILL_EXIT_DURATION seconds to ensure we get a
@@ -632,7 +632,7 @@ void iwl_tt_initialize(struct iwl_priv *priv)
632 INIT_WORK(&priv->ct_enter, iwl_bg_ct_enter); 632 INIT_WORK(&priv->ct_enter, iwl_bg_ct_enter);
633 INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit); 633 INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit);
634 634
635 if (cfg(priv)->base_params->adv_thermal_throttle) { 635 if (priv->cfg->base_params->adv_thermal_throttle) {
636 IWL_DEBUG_TEMP(priv, "Advanced Thermal Throttling\n"); 636 IWL_DEBUG_TEMP(priv, "Advanced Thermal Throttling\n");
637 tt->restriction = kcalloc(IWL_TI_STATE_MAX, 637 tt->restriction = kcalloc(IWL_TI_STATE_MAX,
638 sizeof(struct iwl_tt_restriction), 638 sizeof(struct iwl_tt_restriction),
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index ad21b5ddf59d..f2e9f298a947 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -34,7 +34,6 @@
34#include <linux/ieee80211.h> 34#include <linux/ieee80211.h>
35 35
36#include "iwl-dev.h" 36#include "iwl-dev.h"
37#include "iwl-core.h"
38#include "iwl-io.h" 37#include "iwl-io.h"
39#include "iwl-agn-hw.h" 38#include "iwl-agn-hw.h"
40#include "iwl-agn.h" 39#include "iwl-agn.h"
@@ -85,8 +84,8 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
85 else if (ieee80211_is_back_req(fc)) 84 else if (ieee80211_is_back_req(fc))
86 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; 85 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
87 else if (info->band == IEEE80211_BAND_2GHZ && 86 else if (info->band == IEEE80211_BAND_2GHZ &&
88 cfg(priv)->bt_params && 87 priv->cfg->bt_params &&
89 cfg(priv)->bt_params->advanced_bt_coexist && 88 priv->cfg->bt_params->advanced_bt_coexist &&
90 (ieee80211_is_auth(fc) || ieee80211_is_assoc_req(fc) || 89 (ieee80211_is_auth(fc) || ieee80211_is_assoc_req(fc) ||
91 ieee80211_is_reassoc_req(fc) || 90 ieee80211_is_reassoc_req(fc) ||
92 skb->protocol == cpu_to_be16(ETH_P_PAE))) 91 skb->protocol == cpu_to_be16(ETH_P_PAE)))
@@ -203,8 +202,8 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
203 rate_flags |= RATE_MCS_CCK_MSK; 202 rate_flags |= RATE_MCS_CCK_MSK;
204 203
205 /* Set up antennas */ 204 /* Set up antennas */
206 if (cfg(priv)->bt_params && 205 if (priv->cfg->bt_params &&
207 cfg(priv)->bt_params->advanced_bt_coexist && 206 priv->cfg->bt_params->advanced_bt_coexist &&
208 priv->bt_full_concurrent) { 207 priv->bt_full_concurrent) {
209 /* operated as 1x1 in full concurrency mode */ 208 /* operated as 1x1 in full concurrency mode */
210 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant, 209 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
@@ -396,12 +395,9 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
396 395
397 /* TODO need this for burst mode later on */ 396 /* TODO need this for burst mode later on */
398 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); 397 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id);
399 iwl_dbg_log_tx_data_frame(priv, len, hdr);
400 398
401 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc); 399 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc);
402 400
403 iwl_update_stats(priv, true, fc, len);
404
405 memset(&info->status, 0, sizeof(info->status)); 401 memset(&info->status, 0, sizeof(info->status));
406 402
407 info->driver_data[0] = ctx; 403 info->driver_data[0] = ctx;
@@ -467,7 +463,11 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
467 else 463 else
468 txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; 464 txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)];
469 465
470 if (iwl_trans_tx(trans(priv), skb, dev_cmd, txq_id)) 466 WARN_ON_ONCE(!is_agg && txq_id != info->hw_queue);
467 WARN_ON_ONCE(is_agg &&
468 priv->queue_to_mac80211[txq_id] != info->hw_queue);
469
470 if (iwl_trans_tx(priv->trans, skb, dev_cmd, txq_id))
471 goto drop_unlock_sta; 471 goto drop_unlock_sta;
472 472
473 if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc) && 473 if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc) &&
@@ -496,14 +496,14 @@ drop_unlock_priv:
496 return -1; 496 return -1;
497} 497}
498 498
499static int iwlagn_alloc_agg_txq(struct iwl_priv *priv, int ac) 499static int iwlagn_alloc_agg_txq(struct iwl_priv *priv, int mq)
500{ 500{
501 int q; 501 int q;
502 502
503 for (q = IWLAGN_FIRST_AMPDU_QUEUE; 503 for (q = IWLAGN_FIRST_AMPDU_QUEUE;
504 q < cfg(priv)->base_params->num_of_queues; q++) { 504 q < priv->cfg->base_params->num_of_queues; q++) {
505 if (!test_and_set_bit(q, priv->agg_q_alloc)) { 505 if (!test_and_set_bit(q, priv->agg_q_alloc)) {
506 priv->queue_to_ac[q] = ac; 506 priv->queue_to_mac80211[q] = mq;
507 return q; 507 return q;
508 } 508 }
509 } 509 }
@@ -514,7 +514,7 @@ static int iwlagn_alloc_agg_txq(struct iwl_priv *priv, int ac)
514static void iwlagn_dealloc_agg_txq(struct iwl_priv *priv, int q) 514static void iwlagn_dealloc_agg_txq(struct iwl_priv *priv, int q)
515{ 515{
516 clear_bit(q, priv->agg_q_alloc); 516 clear_bit(q, priv->agg_q_alloc);
517 priv->queue_to_ac[q] = IWL_INVALID_AC; 517 priv->queue_to_mac80211[q] = IWL_INVALID_MAC80211_QUEUE;
518} 518}
519 519
520int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, 520int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
@@ -522,6 +522,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
522{ 522{
523 struct iwl_tid_data *tid_data; 523 struct iwl_tid_data *tid_data;
524 int sta_id, txq_id; 524 int sta_id, txq_id;
525 enum iwl_agg_state agg_state;
525 526
526 sta_id = iwl_sta_id(sta); 527 sta_id = iwl_sta_id(sta);
527 528
@@ -545,6 +546,13 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
545 */ 546 */
546 IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); 547 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
547 goto turn_off; 548 goto turn_off;
549 case IWL_AGG_STARTING:
550 /*
551 * This can happen when the session is stopped before
552 * we receive ADDBA response
553 */
554 IWL_DEBUG_HT(priv, "AGG stop before AGG became operational\n");
555 goto turn_off;
548 case IWL_AGG_ON: 556 case IWL_AGG_ON:
549 break; 557 break;
550 default: 558 default:
@@ -576,12 +584,17 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
576 IWL_DEBUG_TX_QUEUES(priv, "Can proceed: ssn = next_recl = %d\n", 584 IWL_DEBUG_TX_QUEUES(priv, "Can proceed: ssn = next_recl = %d\n",
577 tid_data->agg.ssn); 585 tid_data->agg.ssn);
578turn_off: 586turn_off:
587 agg_state = priv->tid_data[sta_id][tid].agg.state;
579 priv->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; 588 priv->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF;
580 589
581 spin_unlock_bh(&priv->sta_lock); 590 spin_unlock_bh(&priv->sta_lock);
582 591
583 if (test_bit(txq_id, priv->agg_q_alloc)) { 592 if (test_bit(txq_id, priv->agg_q_alloc)) {
584 iwl_trans_tx_agg_disable(trans(priv), txq_id); 593 /* If the transport didn't know that we wanted to start
594 * agreggation, don't tell it that we want to stop them
595 */
596 if (agg_state != IWL_AGG_STARTING)
597 iwl_trans_tx_agg_disable(priv->trans, txq_id);
585 iwlagn_dealloc_agg_txq(priv, txq_id); 598 iwlagn_dealloc_agg_txq(priv, txq_id);
586 } 599 }
587 600
@@ -593,6 +606,7 @@ turn_off:
593int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, 606int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
594 struct ieee80211_sta *sta, u16 tid, u16 *ssn) 607 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
595{ 608{
609 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
596 struct iwl_tid_data *tid_data; 610 struct iwl_tid_data *tid_data;
597 int sta_id, txq_id, ret; 611 int sta_id, txq_id, ret;
598 612
@@ -612,7 +626,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
612 return -ENXIO; 626 return -ENXIO;
613 } 627 }
614 628
615 txq_id = iwlagn_alloc_agg_txq(priv, tid_to_ac[tid]); 629 txq_id = iwlagn_alloc_agg_txq(priv, ctx->ac_to_queue[tid_to_ac[tid]]);
616 if (txq_id < 0) { 630 if (txq_id < 0) {
617 IWL_DEBUG_TX_QUEUES(priv, 631 IWL_DEBUG_TX_QUEUES(priv,
618 "No free aggregation queue for %pM/%d\n", 632 "No free aggregation queue for %pM/%d\n",
@@ -634,7 +648,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
634 if (*ssn == tid_data->next_reclaimed) { 648 if (*ssn == tid_data->next_reclaimed) {
635 IWL_DEBUG_TX_QUEUES(priv, "Can proceed: ssn = next_recl = %d\n", 649 IWL_DEBUG_TX_QUEUES(priv, "Can proceed: ssn = next_recl = %d\n",
636 tid_data->agg.ssn); 650 tid_data->agg.ssn);
637 tid_data->agg.state = IWL_AGG_ON; 651 tid_data->agg.state = IWL_AGG_STARTING;
638 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); 652 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
639 } else { 653 } else {
640 IWL_DEBUG_TX_QUEUES(priv, "Can't proceed: ssn %d, " 654 IWL_DEBUG_TX_QUEUES(priv, "Can't proceed: ssn %d, "
@@ -661,11 +675,12 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
661 spin_lock_bh(&priv->sta_lock); 675 spin_lock_bh(&priv->sta_lock);
662 ssn = priv->tid_data[sta_priv->sta_id][tid].agg.ssn; 676 ssn = priv->tid_data[sta_priv->sta_id][tid].agg.ssn;
663 q = priv->tid_data[sta_priv->sta_id][tid].agg.txq_id; 677 q = priv->tid_data[sta_priv->sta_id][tid].agg.txq_id;
678 priv->tid_data[sta_priv->sta_id][tid].agg.state = IWL_AGG_ON;
664 spin_unlock_bh(&priv->sta_lock); 679 spin_unlock_bh(&priv->sta_lock);
665 680
666 fifo = ctx->ac_to_fifo[tid_to_ac[tid]]; 681 fifo = ctx->ac_to_fifo[tid_to_ac[tid]];
667 682
668 iwl_trans_tx_agg_setup(trans(priv), q, fifo, 683 iwl_trans_tx_agg_setup(priv->trans, q, fifo,
669 sta_priv->sta_id, tid, 684 sta_priv->sta_id, tid,
670 buf_size, ssn); 685 buf_size, ssn);
671 686
@@ -732,7 +747,7 @@ static void iwlagn_check_ratid_empty(struct iwl_priv *priv, int sta_id, u8 tid)
732 IWL_DEBUG_TX_QUEUES(priv, 747 IWL_DEBUG_TX_QUEUES(priv,
733 "Can continue DELBA flow ssn = next_recl =" 748 "Can continue DELBA flow ssn = next_recl ="
734 " %d", tid_data->next_reclaimed); 749 " %d", tid_data->next_reclaimed);
735 iwl_trans_tx_agg_disable(trans(priv), 750 iwl_trans_tx_agg_disable(priv->trans,
736 tid_data->agg.txq_id); 751 tid_data->agg.txq_id);
737 iwlagn_dealloc_agg_txq(priv, tid_data->agg.txq_id); 752 iwlagn_dealloc_agg_txq(priv, tid_data->agg.txq_id);
738 tid_data->agg.state = IWL_AGG_OFF; 753 tid_data->agg.state = IWL_AGG_OFF;
@@ -745,7 +760,7 @@ static void iwlagn_check_ratid_empty(struct iwl_priv *priv, int sta_id, u8 tid)
745 IWL_DEBUG_TX_QUEUES(priv, 760 IWL_DEBUG_TX_QUEUES(priv,
746 "Can continue ADDBA flow ssn = next_recl =" 761 "Can continue ADDBA flow ssn = next_recl ="
747 " %d", tid_data->next_reclaimed); 762 " %d", tid_data->next_reclaimed);
748 tid_data->agg.state = IWL_AGG_ON; 763 tid_data->agg.state = IWL_AGG_STARTING;
749 ieee80211_start_tx_ba_cb_irqsafe(vif, addr, tid); 764 ieee80211_start_tx_ba_cb_irqsafe(vif, addr, tid);
750 } 765 }
751 break; 766 break;
@@ -909,8 +924,8 @@ static void iwl_rx_reply_tx_agg(struct iwl_priv *priv,
909 * notification again. 924 * notification again.
910 */ 925 */
911 if (tx_resp->bt_kill_count && tx_resp->frame_count == 1 && 926 if (tx_resp->bt_kill_count && tx_resp->frame_count == 1 &&
912 cfg(priv)->bt_params && 927 priv->cfg->bt_params &&
913 cfg(priv)->bt_params->advanced_bt_coexist) { 928 priv->cfg->bt_params->advanced_bt_coexist) {
914 IWL_DEBUG_COEX(priv, "receive reply tx w/ bt_kill\n"); 929 IWL_DEBUG_COEX(priv, "receive reply tx w/ bt_kill\n");
915 } 930 }
916 931
@@ -1092,7 +1107,7 @@ static int iwl_reclaim(struct iwl_priv *priv, int sta_id, int tid,
1092 return 1; 1107 return 1;
1093 } 1108 }
1094 1109
1095 iwl_trans_reclaim(trans(priv), txq_id, ssn, skbs); 1110 iwl_trans_reclaim(priv->trans, txq_id, ssn, skbs);
1096 return 0; 1111 return 0;
1097} 1112}
1098 1113
@@ -1249,7 +1264,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1249 * (in Tx queue's circular buffer) of first TFD/frame in window */ 1264 * (in Tx queue's circular buffer) of first TFD/frame in window */
1250 u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); 1265 u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn);
1251 1266
1252 if (scd_flow >= cfg(priv)->base_params->num_of_queues) { 1267 if (scd_flow >= priv->cfg->base_params->num_of_queues) {
1253 IWL_ERR(priv, 1268 IWL_ERR(priv,
1254 "BUG_ON scd_flow is bigger than number of queues\n"); 1269 "BUG_ON scd_flow is bigger than number of queues\n");
1255 return 0; 1270 return 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 7db39866bdc4..b53852dcdbfd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -46,13 +46,13 @@
46 46
47#include "iwl-eeprom.h" 47#include "iwl-eeprom.h"
48#include "iwl-dev.h" 48#include "iwl-dev.h"
49#include "iwl-core.h"
50#include "iwl-io.h" 49#include "iwl-io.h"
51#include "iwl-agn-calib.h" 50#include "iwl-agn-calib.h"
52#include "iwl-agn.h" 51#include "iwl-agn.h"
53#include "iwl-shared.h"
54#include "iwl-trans.h" 52#include "iwl-trans.h"
55#include "iwl-op-mode.h" 53#include "iwl-op-mode.h"
54#include "iwl-drv.h"
55#include "iwl-modparams.h"
56 56
57/****************************************************************************** 57/******************************************************************************
58 * 58 *
@@ -348,14 +348,14 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
348 ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32)); 348 ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32));
349 349
350 /* Make sure device is powered up for SRAM reads */ 350 /* Make sure device is powered up for SRAM reads */
351 spin_lock_irqsave(&trans(priv)->reg_lock, reg_flags); 351 spin_lock_irqsave(&priv->trans->reg_lock, reg_flags);
352 if (unlikely(!iwl_grab_nic_access(trans(priv)))) { 352 if (unlikely(!iwl_grab_nic_access(priv->trans))) {
353 spin_unlock_irqrestore(&trans(priv)->reg_lock, reg_flags); 353 spin_unlock_irqrestore(&priv->trans->reg_lock, reg_flags);
354 return; 354 return;
355 } 355 }
356 356
357 /* Set starting address; reads will auto-increment */ 357 /* Set starting address; reads will auto-increment */
358 iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, ptr); 358 iwl_write32(priv->trans, HBUS_TARG_MEM_RADDR, ptr);
359 359
360 /* 360 /*
361 * Refuse to read more than would have fit into the log from 361 * Refuse to read more than would have fit into the log from
@@ -371,20 +371,20 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
371 * place event id # at far right for easier visual parsing. 371 * place event id # at far right for easier visual parsing.
372 */ 372 */
373 for (i = 0; i < num_events; i++) { 373 for (i = 0; i < num_events; i++) {
374 ev = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 374 ev = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
375 time = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 375 time = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
376 if (mode == 0) { 376 if (mode == 0) {
377 trace_iwlwifi_dev_ucode_cont_event( 377 trace_iwlwifi_dev_ucode_cont_event(
378 trans(priv)->dev, 0, time, ev); 378 priv->trans->dev, 0, time, ev);
379 } else { 379 } else {
380 data = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 380 data = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
381 trace_iwlwifi_dev_ucode_cont_event( 381 trace_iwlwifi_dev_ucode_cont_event(
382 trans(priv)->dev, time, data, ev); 382 priv->trans->dev, time, data, ev);
383 } 383 }
384 } 384 }
385 /* Allow device to power down */ 385 /* Allow device to power down */
386 iwl_release_nic_access(trans(priv)); 386 iwl_release_nic_access(priv->trans);
387 spin_unlock_irqrestore(&trans(priv)->reg_lock, reg_flags); 387 spin_unlock_irqrestore(&priv->trans->reg_lock, reg_flags);
388} 388}
389 389
390static void iwl_continuous_event_trace(struct iwl_priv *priv) 390static void iwl_continuous_event_trace(struct iwl_priv *priv)
@@ -403,8 +403,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)
403 403
404 base = priv->device_pointers.log_event_table; 404 base = priv->device_pointers.log_event_table;
405 if (iwlagn_hw_valid_rtc_data_addr(base)) { 405 if (iwlagn_hw_valid_rtc_data_addr(base)) {
406 iwl_read_targ_mem_words(trans(priv), base, &read, sizeof(read)); 406 iwl_read_targ_mem_words(priv->trans, base, &read, sizeof(read));
407
408 capacity = read.capacity; 407 capacity = read.capacity;
409 mode = read.mode; 408 mode = read.mode;
410 num_wraps = read.wrap_counter; 409 num_wraps = read.wrap_counter;
@@ -444,7 +443,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)
444 else 443 else
445 priv->event_log.wraps_once_count++; 444 priv->event_log.wraps_once_count++;
446 445
447 trace_iwlwifi_dev_ucode_wrap_event(trans(priv)->dev, 446 trace_iwlwifi_dev_ucode_wrap_event(priv->trans->dev,
448 num_wraps - priv->event_log.num_wraps, 447 num_wraps - priv->event_log.num_wraps,
449 next_entry, priv->event_log.next_entry); 448 next_entry, priv->event_log.next_entry);
450 449
@@ -579,24 +578,6 @@ static const u8 iwlagn_pan_ac_to_queue[] = {
579 7, 6, 5, 4, 578 7, 6, 5, 4,
580}; 579};
581 580
582static const u8 iwlagn_bss_queue_to_ac[] = {
583 IEEE80211_AC_VO,
584 IEEE80211_AC_VI,
585 IEEE80211_AC_BE,
586 IEEE80211_AC_BK,
587};
588
589static const u8 iwlagn_pan_queue_to_ac[] = {
590 IEEE80211_AC_VO,
591 IEEE80211_AC_VI,
592 IEEE80211_AC_BE,
593 IEEE80211_AC_BK,
594 IEEE80211_AC_BK,
595 IEEE80211_AC_BE,
596 IEEE80211_AC_VI,
597 IEEE80211_AC_VO,
598};
599
600void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) 581void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags)
601{ 582{
602 int i; 583 int i;
@@ -670,12 +651,12 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv)
670 struct iwl_ct_kill_throttling_config adv_cmd; 651 struct iwl_ct_kill_throttling_config adv_cmd;
671 int ret = 0; 652 int ret = 0;
672 653
673 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, 654 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
674 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); 655 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
675 656
676 priv->thermal_throttle.ct_kill_toggle = false; 657 priv->thermal_throttle.ct_kill_toggle = false;
677 658
678 if (cfg(priv)->base_params->support_ct_kill_exit) { 659 if (priv->cfg->base_params->support_ct_kill_exit) {
679 adv_cmd.critical_temperature_enter = 660 adv_cmd.critical_temperature_enter =
680 cpu_to_le32(priv->hw_params.ct_kill_threshold); 661 cpu_to_le32(priv->hw_params.ct_kill_threshold);
681 adv_cmd.critical_temperature_exit = 662 adv_cmd.critical_temperature_exit =
@@ -754,7 +735,7 @@ void iwl_send_bt_config(struct iwl_priv *priv)
754 .kill_cts_mask = 0, 735 .kill_cts_mask = 0,
755 }; 736 };
756 737
757 if (!iwlagn_mod_params.bt_coex_active) 738 if (!iwlwifi_mod_params.bt_coex_active)
758 bt_cmd.flags = BT_COEX_DISABLE; 739 bt_cmd.flags = BT_COEX_DISABLE;
759 else 740 else
760 bt_cmd.flags = BT_COEX_ENABLE; 741 bt_cmd.flags = BT_COEX_ENABLE;
@@ -792,10 +773,10 @@ int iwl_alive_start(struct iwl_priv *priv)
792 } 773 }
793 774
794 /* download priority table before any calibration request */ 775 /* download priority table before any calibration request */
795 if (cfg(priv)->bt_params && 776 if (priv->cfg->bt_params &&
796 cfg(priv)->bt_params->advanced_bt_coexist) { 777 priv->cfg->bt_params->advanced_bt_coexist) {
797 /* Configure Bluetooth device coexistence support */ 778 /* Configure Bluetooth device coexistence support */
798 if (cfg(priv)->bt_params->bt_sco_disable) 779 if (priv->cfg->bt_params->bt_sco_disable)
799 priv->bt_enable_pspoll = false; 780 priv->bt_enable_pspoll = false;
800 else 781 else
801 priv->bt_enable_pspoll = true; 782 priv->bt_enable_pspoll = true;
@@ -932,9 +913,9 @@ void iwl_down(struct iwl_priv *priv)
932 priv->bt_status = 0; 913 priv->bt_status = 0;
933 priv->cur_rssi_ctx = NULL; 914 priv->cur_rssi_ctx = NULL;
934 priv->bt_is_sco = 0; 915 priv->bt_is_sco = 0;
935 if (cfg(priv)->bt_params) 916 if (priv->cfg->bt_params)
936 priv->bt_traffic_load = 917 priv->bt_traffic_load =
937 cfg(priv)->bt_params->bt_init_traffic_load; 918 priv->cfg->bt_params->bt_init_traffic_load;
938 else 919 else
939 priv->bt_traffic_load = 0; 920 priv->bt_traffic_load = 0;
940 priv->bt_full_concurrent = false; 921 priv->bt_full_concurrent = false;
@@ -949,7 +930,7 @@ void iwl_down(struct iwl_priv *priv)
949 ieee80211_stop_queues(priv->hw); 930 ieee80211_stop_queues(priv->hw);
950 931
951 priv->ucode_loaded = false; 932 priv->ucode_loaded = false;
952 iwl_trans_stop_device(trans(priv)); 933 iwl_trans_stop_device(priv->trans);
953 934
954 /* Clear out all status bits but a few that are stable across reset */ 935 /* Clear out all status bits but a few that are stable across reset */
955 priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << 936 priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) <<
@@ -1031,12 +1012,12 @@ void iwlagn_prepare_restart(struct iwl_priv *priv)
1031 priv->bt_status = bt_status; 1012 priv->bt_status = bt_status;
1032 priv->bt_is_sco = bt_is_sco; 1013 priv->bt_is_sco = bt_is_sco;
1033 1014
1034 /* reset all queues */ 1015 /* reset aggregation queues */
1035 for (i = 0; i < IEEE80211_NUM_ACS; i++)
1036 atomic_set(&priv->ac_stop_count[i], 0);
1037
1038 for (i = IWLAGN_FIRST_AMPDU_QUEUE; i < IWL_MAX_HW_QUEUES; i++) 1016 for (i = IWLAGN_FIRST_AMPDU_QUEUE; i < IWL_MAX_HW_QUEUES; i++)
1039 priv->queue_to_ac[i] = IWL_INVALID_AC; 1017 priv->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE;
1018 /* and stop counts */
1019 for (i = 0; i < IWL_MAX_HW_QUEUES; i++)
1020 atomic_set(&priv->queue_stop_count[i], 0);
1040 1021
1041 memset(priv->agg_q_alloc, 0, sizeof(priv->agg_q_alloc)); 1022 memset(priv->agg_q_alloc, 0, sizeof(priv->agg_q_alloc));
1042} 1023}
@@ -1115,7 +1096,7 @@ void iwl_setup_deferred_work(struct iwl_priv *priv)
1115 1096
1116 iwl_setup_scan_deferred_work(priv); 1097 iwl_setup_scan_deferred_work(priv);
1117 1098
1118 if (cfg(priv)->bt_params) 1099 if (priv->cfg->bt_params)
1119 iwlagn_bt_setup_deferred_work(priv); 1100 iwlagn_bt_setup_deferred_work(priv);
1120 1101
1121 init_timer(&priv->statistics_periodic); 1102 init_timer(&priv->statistics_periodic);
@@ -1129,7 +1110,7 @@ void iwl_setup_deferred_work(struct iwl_priv *priv)
1129 1110
1130void iwl_cancel_deferred_work(struct iwl_priv *priv) 1111void iwl_cancel_deferred_work(struct iwl_priv *priv)
1131{ 1112{
1132 if (cfg(priv)->bt_params) 1113 if (priv->cfg->bt_params)
1133 iwlagn_bt_cancel_deferred_work(priv); 1114 iwlagn_bt_cancel_deferred_work(priv);
1134 1115
1135 cancel_work_sync(&priv->run_time_calib_work); 1116 cancel_work_sync(&priv->run_time_calib_work);
@@ -1180,8 +1161,8 @@ static void iwl_init_ht_hw_capab(const struct iwl_priv *priv,
1180 1161
1181 ht_info->ht_supported = true; 1162 ht_info->ht_supported = true;
1182 1163
1183 if (cfg(priv)->ht_params && 1164 if (priv->cfg->ht_params &&
1184 cfg(priv)->ht_params->ht_greenfield_support) 1165 priv->cfg->ht_params->ht_greenfield_support)
1185 ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD; 1166 ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD;
1186 ht_info->cap |= IEEE80211_HT_CAP_SGI_20; 1167 ht_info->cap |= IEEE80211_HT_CAP_SGI_20;
1187 max_bit_rate = MAX_BIT_RATE_20_MHZ; 1168 max_bit_rate = MAX_BIT_RATE_20_MHZ;
@@ -1192,7 +1173,7 @@ static void iwl_init_ht_hw_capab(const struct iwl_priv *priv,
1192 max_bit_rate = MAX_BIT_RATE_40_MHZ; 1173 max_bit_rate = MAX_BIT_RATE_40_MHZ;
1193 } 1174 }
1194 1175
1195 if (iwlagn_mod_params.amsdu_size_8K) 1176 if (iwlwifi_mod_params.amsdu_size_8K)
1196 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; 1177 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU;
1197 1178
1198 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; 1179 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF;
@@ -1325,7 +1306,7 @@ static int iwl_init_geos(struct iwl_priv *priv)
1325 priv->hw_params.sku & EEPROM_SKU_CAP_BAND_52GHZ) { 1306 priv->hw_params.sku & EEPROM_SKU_CAP_BAND_52GHZ) {
1326 IWL_INFO(priv, "Incorrectly detected BG card as ABG. " 1307 IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
1327 "Please send your %s to maintainer.\n", 1308 "Please send your %s to maintainer.\n",
1328 trans(priv)->hw_id_str); 1309 priv->trans->hw_id_str);
1329 priv->hw_params.sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; 1310 priv->hw_params.sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
1330 } 1311 }
1331 1312
@@ -1363,7 +1344,7 @@ int iwl_init_drv(struct iwl_priv *priv)
1363 priv->band = IEEE80211_BAND_2GHZ; 1344 priv->band = IEEE80211_BAND_2GHZ;
1364 1345
1365 priv->plcp_delta_threshold = 1346 priv->plcp_delta_threshold =
1366 cfg(priv)->base_params->plcp_delta_threshold; 1347 priv->cfg->base_params->plcp_delta_threshold;
1367 1348
1368 priv->iw_mode = NL80211_IFTYPE_STATION; 1349 priv->iw_mode = NL80211_IFTYPE_STATION;
1369 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 1350 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
@@ -1380,8 +1361,8 @@ int iwl_init_drv(struct iwl_priv *priv)
1380 iwl_init_scan_params(priv); 1361 iwl_init_scan_params(priv);
1381 1362
1382 /* init bt coex */ 1363 /* init bt coex */
1383 if (cfg(priv)->bt_params && 1364 if (priv->cfg->bt_params &&
1384 cfg(priv)->bt_params->advanced_bt_coexist) { 1365 priv->cfg->bt_params->advanced_bt_coexist) {
1385 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; 1366 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
1386 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; 1367 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
1387 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; 1368 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
@@ -1426,11 +1407,11 @@ void iwl_uninit_drv(struct iwl_priv *priv)
1426 1407
1427void iwl_set_hw_params(struct iwl_priv *priv) 1408void iwl_set_hw_params(struct iwl_priv *priv)
1428{ 1409{
1429 if (cfg(priv)->ht_params) 1410 if (priv->cfg->ht_params)
1430 priv->hw_params.use_rts_for_aggregation = 1411 priv->hw_params.use_rts_for_aggregation =
1431 cfg(priv)->ht_params->use_rts_for_aggregation; 1412 priv->cfg->ht_params->use_rts_for_aggregation;
1432 1413
1433 if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_ALL) 1414 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_ALL)
1434 priv->hw_params.sku &= ~EEPROM_SKU_CAP_11N_ENABLE; 1415 priv->hw_params.sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
1435 1416
1436 /* Device-specific setup */ 1417 /* Device-specific setup */
@@ -1441,32 +1422,32 @@ void iwl_set_hw_params(struct iwl_priv *priv)
1441 1422
1442void iwl_debug_config(struct iwl_priv *priv) 1423void iwl_debug_config(struct iwl_priv *priv)
1443{ 1424{
1444 dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_DEBUG " 1425 dev_printk(KERN_INFO, priv->trans->dev, "CONFIG_IWLWIFI_DEBUG "
1445#ifdef CONFIG_IWLWIFI_DEBUG 1426#ifdef CONFIG_IWLWIFI_DEBUG
1446 "enabled\n"); 1427 "enabled\n");
1447#else 1428#else
1448 "disabled\n"); 1429 "disabled\n");
1449#endif 1430#endif
1450 dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_DEBUGFS " 1431 dev_printk(KERN_INFO, priv->trans->dev, "CONFIG_IWLWIFI_DEBUGFS "
1451#ifdef CONFIG_IWLWIFI_DEBUGFS 1432#ifdef CONFIG_IWLWIFI_DEBUGFS
1452 "enabled\n"); 1433 "enabled\n");
1453#else 1434#else
1454 "disabled\n"); 1435 "disabled\n");
1455#endif 1436#endif
1456 dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_DEVICE_TRACING " 1437 dev_printk(KERN_INFO, priv->trans->dev, "CONFIG_IWLWIFI_DEVICE_TRACING "
1457#ifdef CONFIG_IWLWIFI_DEVICE_TRACING 1438#ifdef CONFIG_IWLWIFI_DEVICE_TRACING
1458 "enabled\n"); 1439 "enabled\n");
1459#else 1440#else
1460 "disabled\n"); 1441 "disabled\n");
1461#endif 1442#endif
1462 1443
1463 dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_DEVICE_TESTMODE " 1444 dev_printk(KERN_INFO, priv->trans->dev, "CONFIG_IWLWIFI_DEVICE_TESTMODE "
1464#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 1445#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
1465 "enabled\n"); 1446 "enabled\n");
1466#else 1447#else
1467 "disabled\n"); 1448 "disabled\n");
1468#endif 1449#endif
1469 dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_P2P " 1450 dev_printk(KERN_INFO, priv->trans->dev, "CONFIG_IWLWIFI_P2P "
1470#ifdef CONFIG_IWLWIFI_P2P 1451#ifdef CONFIG_IWLWIFI_P2P
1471 "enabled\n"); 1452 "enabled\n");
1472#else 1453#else
@@ -1475,6 +1456,7 @@ void iwl_debug_config(struct iwl_priv *priv)
1475} 1456}
1476 1457
1477static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, 1458static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1459 const struct iwl_cfg *cfg,
1478 const struct iwl_fw *fw) 1460 const struct iwl_fw *fw)
1479{ 1461{
1480 struct iwl_priv *priv; 1462 struct iwl_priv *priv;
@@ -1491,8 +1473,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1491 STATISTICS_NOTIFICATION, 1473 STATISTICS_NOTIFICATION,
1492 REPLY_TX, 1474 REPLY_TX,
1493 }; 1475 };
1494 const u8 *q_to_ac;
1495 int n_q_to_ac;
1496 int i; 1476 int i;
1497 1477
1498 /************************ 1478 /************************
@@ -1500,18 +1480,19 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1500 ************************/ 1480 ************************/
1501 hw = iwl_alloc_all(); 1481 hw = iwl_alloc_all();
1502 if (!hw) { 1482 if (!hw) {
1503 pr_err("%s: Cannot allocate network device\n", 1483 pr_err("%s: Cannot allocate network device\n", cfg->name);
1504 cfg(trans)->name);
1505 goto out; 1484 goto out;
1506 } 1485 }
1507 1486
1508 op_mode = hw->priv; 1487 op_mode = hw->priv;
1509 op_mode->ops = &iwl_dvm_ops; 1488 op_mode->ops = &iwl_dvm_ops;
1510 priv = IWL_OP_MODE_GET_DVM(op_mode); 1489 priv = IWL_OP_MODE_GET_DVM(op_mode);
1511 priv->shrd = trans->shrd; 1490 priv->trans = trans;
1491 priv->dev = trans->dev;
1492 priv->cfg = cfg;
1512 priv->fw = fw; 1493 priv->fw = fw;
1513 1494
1514 switch (cfg(priv)->device_family) { 1495 switch (priv->cfg->device_family) {
1515 case IWL_DEVICE_FAMILY_1000: 1496 case IWL_DEVICE_FAMILY_1000:
1516 case IWL_DEVICE_FAMILY_100: 1497 case IWL_DEVICE_FAMILY_100:
1517 priv->lib = &iwl1000_lib; 1498 priv->lib = &iwl1000_lib;
@@ -1545,7 +1526,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1545 } 1526 }
1546 1527
1547 if (WARN_ON(!priv->lib)) 1528 if (WARN_ON(!priv->lib))
1548 goto out_free_traffic_mem; 1529 goto out_free_hw;
1549 1530
1550 /* 1531 /*
1551 * Populate the state variables that the transport layer needs 1532 * Populate the state variables that the transport layer needs
@@ -1554,10 +1535,10 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1554 trans_cfg.op_mode = op_mode; 1535 trans_cfg.op_mode = op_mode;
1555 trans_cfg.no_reclaim_cmds = no_reclaim_cmds; 1536 trans_cfg.no_reclaim_cmds = no_reclaim_cmds;
1556 trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds); 1537 trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds);
1557 trans_cfg.rx_buf_size_8k = iwlagn_mod_params.amsdu_size_8K; 1538 trans_cfg.rx_buf_size_8k = iwlwifi_mod_params.amsdu_size_8K;
1558 if (!iwlagn_mod_params.wd_disable) 1539 if (!iwlwifi_mod_params.wd_disable)
1559 trans_cfg.queue_watchdog_timeout = 1540 trans_cfg.queue_watchdog_timeout =
1560 cfg(priv)->base_params->wd_timeout; 1541 priv->cfg->base_params->wd_timeout;
1561 else 1542 else
1562 trans_cfg.queue_watchdog_timeout = IWL_WATCHHDOG_DISABLED; 1543 trans_cfg.queue_watchdog_timeout = IWL_WATCHHDOG_DISABLED;
1563 trans_cfg.command_names = iwl_dvm_cmd_strings; 1544 trans_cfg.command_names = iwl_dvm_cmd_strings;
@@ -1574,24 +1555,20 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1574 trans_cfg.queue_to_fifo = iwlagn_ipan_queue_to_tx_fifo; 1555 trans_cfg.queue_to_fifo = iwlagn_ipan_queue_to_tx_fifo;
1575 trans_cfg.n_queue_to_fifo = 1556 trans_cfg.n_queue_to_fifo =
1576 ARRAY_SIZE(iwlagn_ipan_queue_to_tx_fifo); 1557 ARRAY_SIZE(iwlagn_ipan_queue_to_tx_fifo);
1577 q_to_ac = iwlagn_pan_queue_to_ac;
1578 n_q_to_ac = ARRAY_SIZE(iwlagn_pan_queue_to_ac);
1579 } else { 1558 } else {
1580 priv->sta_key_max_num = STA_KEY_MAX_NUM; 1559 priv->sta_key_max_num = STA_KEY_MAX_NUM;
1581 trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; 1560 trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
1582 trans_cfg.queue_to_fifo = iwlagn_default_queue_to_tx_fifo; 1561 trans_cfg.queue_to_fifo = iwlagn_default_queue_to_tx_fifo;
1583 trans_cfg.n_queue_to_fifo = 1562 trans_cfg.n_queue_to_fifo =
1584 ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo); 1563 ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo);
1585 q_to_ac = iwlagn_bss_queue_to_ac;
1586 n_q_to_ac = ARRAY_SIZE(iwlagn_bss_queue_to_ac);
1587 } 1564 }
1588 1565
1589 /* Configure transport layer */ 1566 /* Configure transport layer */
1590 iwl_trans_configure(trans(priv), &trans_cfg); 1567 iwl_trans_configure(priv->trans, &trans_cfg);
1591 1568
1592 /* At this point both hw and priv are allocated. */ 1569 /* At this point both hw and priv are allocated. */
1593 1570
1594 SET_IEEE80211_DEV(priv->hw, trans(priv)->dev); 1571 SET_IEEE80211_DEV(priv->hw, priv->trans->dev);
1595 1572
1596 /* show what debugging capabilities we have */ 1573 /* show what debugging capabilities we have */
1597 iwl_debug_config(priv); 1574 iwl_debug_config(priv);
@@ -1600,40 +1577,37 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1600 1577
1601 /* is antenna coupling more than 35dB ? */ 1578 /* is antenna coupling more than 35dB ? */
1602 priv->bt_ant_couple_ok = 1579 priv->bt_ant_couple_ok =
1603 (iwlagn_mod_params.ant_coupling > 1580 (iwlwifi_mod_params.ant_coupling >
1604 IWL_BT_ANTENNA_COUPLING_THRESHOLD) ? 1581 IWL_BT_ANTENNA_COUPLING_THRESHOLD) ?
1605 true : false; 1582 true : false;
1606 1583
1607 /* enable/disable bt channel inhibition */ 1584 /* enable/disable bt channel inhibition */
1608 priv->bt_ch_announce = iwlagn_mod_params.bt_ch_announce; 1585 priv->bt_ch_announce = iwlwifi_mod_params.bt_ch_announce;
1609 IWL_DEBUG_INFO(priv, "BT channel inhibition is %s\n", 1586 IWL_DEBUG_INFO(priv, "BT channel inhibition is %s\n",
1610 (priv->bt_ch_announce) ? "On" : "Off"); 1587 (priv->bt_ch_announce) ? "On" : "Off");
1611 1588
1612 if (iwl_alloc_traffic_mem(priv))
1613 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
1614
1615 /* these spin locks will be used in apm_ops.init and EEPROM access 1589 /* these spin locks will be used in apm_ops.init and EEPROM access
1616 * we should init now 1590 * we should init now
1617 */ 1591 */
1618 spin_lock_init(&trans(priv)->reg_lock); 1592 spin_lock_init(&priv->trans->reg_lock);
1619 spin_lock_init(&priv->statistics.lock); 1593 spin_lock_init(&priv->statistics.lock);
1620 1594
1621 /*********************** 1595 /***********************
1622 * 2. Read REV register 1596 * 2. Read REV register
1623 ***********************/ 1597 ***********************/
1624 IWL_INFO(priv, "Detected %s, REV=0x%X\n", 1598 IWL_INFO(priv, "Detected %s, REV=0x%X\n",
1625 cfg(priv)->name, trans(priv)->hw_rev); 1599 priv->cfg->name, priv->trans->hw_rev);
1626 1600
1627 if (iwl_trans_start_hw(trans(priv))) 1601 if (iwl_trans_start_hw(priv->trans))
1628 goto out_free_traffic_mem; 1602 goto out_free_hw;
1629 1603
1630 /* Read the EEPROM */ 1604 /* Read the EEPROM */
1631 if (iwl_eeprom_init(priv, trans(priv)->hw_rev)) { 1605 if (iwl_eeprom_init(priv, priv->trans->hw_rev)) {
1632 IWL_ERR(priv, "Unable to init EEPROM\n"); 1606 IWL_ERR(priv, "Unable to init EEPROM\n");
1633 goto out_free_traffic_mem; 1607 goto out_free_hw;
1634 } 1608 }
1635 /* Reset chip to save power until we load uCode during "up". */ 1609 /* Reset chip to save power until we load uCode during "up". */
1636 iwl_trans_stop_hw(trans(priv)); 1610 iwl_trans_stop_hw(priv->trans, false);
1637 1611
1638 if (iwl_eeprom_check_version(priv)) 1612 if (iwl_eeprom_check_version(priv))
1639 goto out_free_eeprom; 1613 goto out_free_eeprom;
@@ -1672,24 +1646,21 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1672 trans_cfg.queue_to_fifo = iwlagn_default_queue_to_tx_fifo; 1646 trans_cfg.queue_to_fifo = iwlagn_default_queue_to_tx_fifo;
1673 trans_cfg.n_queue_to_fifo = 1647 trans_cfg.n_queue_to_fifo =
1674 ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo); 1648 ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo);
1675 q_to_ac = iwlagn_bss_queue_to_ac;
1676 n_q_to_ac = ARRAY_SIZE(iwlagn_bss_queue_to_ac);
1677 1649
1678 /* Configure transport layer again*/ 1650 /* Configure transport layer again*/
1679 iwl_trans_configure(trans(priv), &trans_cfg); 1651 iwl_trans_configure(priv->trans, &trans_cfg);
1680 } 1652 }
1681 1653
1682 /******************* 1654 /*******************
1683 * 5. Setup priv 1655 * 5. Setup priv
1684 *******************/ 1656 *******************/
1685 for (i = 0; i < IEEE80211_NUM_ACS; i++)
1686 atomic_set(&priv->ac_stop_count[i], 0);
1687
1688 for (i = 0; i < IWL_MAX_HW_QUEUES; i++) { 1657 for (i = 0; i < IWL_MAX_HW_QUEUES; i++) {
1689 if (i < n_q_to_ac) 1658 priv->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE;
1690 priv->queue_to_ac[i] = q_to_ac[i]; 1659 if (i < IWLAGN_FIRST_AMPDU_QUEUE &&
1691 else 1660 i != IWL_DEFAULT_CMD_QUEUE_NUM &&
1692 priv->queue_to_ac[i] = IWL_INVALID_AC; 1661 i != IWL_IPAN_CMD_QUEUE_NUM)
1662 priv->queue_to_mac80211[i] = i;
1663 atomic_set(&priv->queue_stop_count[i], 0);
1693 } 1664 }
1694 1665
1695 WARN_ON(trans_cfg.queue_to_fifo[trans_cfg.cmd_queue] != 1666 WARN_ON(trans_cfg.queue_to_fifo[trans_cfg.cmd_queue] !=
@@ -1745,8 +1716,7 @@ out_destroy_workqueue:
1745 iwl_uninit_drv(priv); 1716 iwl_uninit_drv(priv);
1746out_free_eeprom: 1717out_free_eeprom:
1747 iwl_eeprom_free(priv); 1718 iwl_eeprom_free(priv);
1748out_free_traffic_mem: 1719out_free_hw:
1749 iwl_free_traffic_mem(priv);
1750 ieee80211_free_hw(priv->hw); 1720 ieee80211_free_hw(priv->hw);
1751out: 1721out:
1752 op_mode = NULL; 1722 op_mode = NULL;
@@ -1768,7 +1738,7 @@ void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
1768 1738
1769 /*This will stop the queues, move the device to low power state */ 1739 /*This will stop the queues, move the device to low power state */
1770 priv->ucode_loaded = false; 1740 priv->ucode_loaded = false;
1771 iwl_trans_stop_device(trans(priv)); 1741 iwl_trans_stop_device(priv->trans);
1772 1742
1773 iwl_eeprom_free(priv); 1743 iwl_eeprom_free(priv);
1774 1744
@@ -1780,12 +1750,12 @@ void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
1780 * until now... */ 1750 * until now... */
1781 destroy_workqueue(priv->workqueue); 1751 destroy_workqueue(priv->workqueue);
1782 priv->workqueue = NULL; 1752 priv->workqueue = NULL;
1783 iwl_free_traffic_mem(priv);
1784 1753
1785 iwl_uninit_drv(priv); 1754 iwl_uninit_drv(priv);
1786 1755
1787 dev_kfree_skb(priv->beacon_skb); 1756 dev_kfree_skb(priv->beacon_skb);
1788 1757
1758 iwl_trans_stop_hw(priv->trans, true);
1789 ieee80211_free_hw(priv->hw); 1759 ieee80211_free_hw(priv->hw);
1790} 1760}
1791 1761
@@ -1860,7 +1830,7 @@ static const char *desc_lookup(u32 num)
1860 1830
1861static void iwl_dump_nic_error_log(struct iwl_priv *priv) 1831static void iwl_dump_nic_error_log(struct iwl_priv *priv)
1862{ 1832{
1863 struct iwl_trans *trans = trans(priv); 1833 struct iwl_trans *trans = priv->trans;
1864 u32 base; 1834 u32 base;
1865 struct iwl_error_event_table table; 1835 struct iwl_error_event_table table;
1866 1836
@@ -1950,7 +1920,7 @@ static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
1950 u32 ev, time, data; /* event log data */ 1920 u32 ev, time, data; /* event log data */
1951 unsigned long reg_flags; 1921 unsigned long reg_flags;
1952 1922
1953 struct iwl_trans *trans = trans(priv); 1923 struct iwl_trans *trans = priv->trans;
1954 1924
1955 if (num_events == 0) 1925 if (num_events == 0)
1956 return pos; 1926 return pos;
@@ -2068,7 +2038,7 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
2068 u32 logsize; 2038 u32 logsize;
2069 int pos = 0; 2039 int pos = 0;
2070 size_t bufsz = 0; 2040 size_t bufsz = 0;
2071 struct iwl_trans *trans = trans(priv); 2041 struct iwl_trans *trans = priv->trans;
2072 2042
2073 base = priv->device_pointers.log_event_table; 2043 base = priv->device_pointers.log_event_table;
2074 if (priv->cur_ucode == IWL_UCODE_INIT) { 2044 if (priv->cur_ucode == IWL_UCODE_INIT) {
@@ -2184,7 +2154,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
2184 * commands by clearing the ready bit */ 2154 * commands by clearing the ready bit */
2185 clear_bit(STATUS_READY, &priv->status); 2155 clear_bit(STATUS_READY, &priv->status);
2186 2156
2187 wake_up(&trans(priv)->wait_command_queue); 2157 wake_up(&priv->trans->wait_command_queue);
2188 2158
2189 if (!ondemand) { 2159 if (!ondemand) {
2190 /* 2160 /*
@@ -2208,7 +2178,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
2208 } 2178 }
2209 2179
2210 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { 2180 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2211 if (iwlagn_mod_params.restart_fw) { 2181 if (iwlwifi_mod_params.restart_fw) {
2212 IWL_DEBUG_FW_ERRORS(priv, 2182 IWL_DEBUG_FW_ERRORS(priv,
2213 "Restarting adapter due to uCode error.\n"); 2183 "Restarting adapter due to uCode error.\n");
2214 queue_work(priv->workqueue, &priv->restart); 2184 queue_work(priv->workqueue, &priv->restart);
@@ -2259,56 +2229,56 @@ static void iwl_wimax_active(struct iwl_op_mode *op_mode)
2259void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, int queue) 2229void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, int queue)
2260{ 2230{
2261 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); 2231 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
2262 int ac = priv->queue_to_ac[queue]; 2232 int mq = priv->queue_to_mac80211[queue];
2263 2233
2264 if (WARN_ON_ONCE(ac == IWL_INVALID_AC)) 2234 if (WARN_ON_ONCE(mq == IWL_INVALID_MAC80211_QUEUE))
2265 return; 2235 return;
2266 2236
2267 if (atomic_inc_return(&priv->ac_stop_count[ac]) > 1) { 2237 if (atomic_inc_return(&priv->queue_stop_count[mq]) > 1) {
2268 IWL_DEBUG_TX_QUEUES(priv, 2238 IWL_DEBUG_TX_QUEUES(priv,
2269 "queue %d (AC %d) already stopped\n", 2239 "queue %d (mac80211 %d) already stopped\n",
2270 queue, ac); 2240 queue, mq);
2271 return; 2241 return;
2272 } 2242 }
2273 2243
2274 set_bit(ac, &priv->transport_queue_stop); 2244 set_bit(mq, &priv->transport_queue_stop);
2275 ieee80211_stop_queue(priv->hw, ac); 2245 ieee80211_stop_queue(priv->hw, mq);
2276} 2246}
2277 2247
2278void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, int queue) 2248void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, int queue)
2279{ 2249{
2280 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); 2250 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
2281 int ac = priv->queue_to_ac[queue]; 2251 int mq = priv->queue_to_mac80211[queue];
2282 2252
2283 if (WARN_ON_ONCE(ac == IWL_INVALID_AC)) 2253 if (WARN_ON_ONCE(mq == IWL_INVALID_MAC80211_QUEUE))
2284 return; 2254 return;
2285 2255
2286 if (atomic_dec_return(&priv->ac_stop_count[ac]) > 0) { 2256 if (atomic_dec_return(&priv->queue_stop_count[mq]) > 0) {
2287 IWL_DEBUG_TX_QUEUES(priv, 2257 IWL_DEBUG_TX_QUEUES(priv,
2288 "queue %d (AC %d) already awake\n", 2258 "queue %d (mac80211 %d) already awake\n",
2289 queue, ac); 2259 queue, mq);
2290 return; 2260 return;
2291 } 2261 }
2292 2262
2293 clear_bit(ac, &priv->transport_queue_stop); 2263 clear_bit(mq, &priv->transport_queue_stop);
2294 2264
2295 if (!priv->passive_no_rx) 2265 if (!priv->passive_no_rx)
2296 ieee80211_wake_queue(priv->hw, ac); 2266 ieee80211_wake_queue(priv->hw, mq);
2297} 2267}
2298 2268
2299void iwlagn_lift_passive_no_rx(struct iwl_priv *priv) 2269void iwlagn_lift_passive_no_rx(struct iwl_priv *priv)
2300{ 2270{
2301 int ac; 2271 int mq;
2302 2272
2303 if (!priv->passive_no_rx) 2273 if (!priv->passive_no_rx)
2304 return; 2274 return;
2305 2275
2306 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) { 2276 for (mq = 0; mq < IWLAGN_FIRST_AMPDU_QUEUE; mq++) {
2307 if (!test_bit(ac, &priv->transport_queue_stop)) { 2277 if (!test_bit(mq, &priv->transport_queue_stop)) {
2308 IWL_DEBUG_TX_QUEUES(priv, "Wake queue %d"); 2278 IWL_DEBUG_TX_QUEUES(priv, "Wake queue %d", mq);
2309 ieee80211_wake_queue(priv->hw, ac); 2279 ieee80211_wake_queue(priv->hw, mq);
2310 } else { 2280 } else {
2311 IWL_DEBUG_TX_QUEUES(priv, "Don't wake queue %d"); 2281 IWL_DEBUG_TX_QUEUES(priv, "Don't wake queue %d", mq);
2312 } 2282 }
2313 } 2283 }
2314 2284
@@ -2398,77 +2368,3 @@ static void __exit iwl_exit(void)
2398 2368
2399module_exit(iwl_exit); 2369module_exit(iwl_exit);
2400module_init(iwl_init); 2370module_init(iwl_init);
2401
2402#ifdef CONFIG_IWLWIFI_DEBUG
2403module_param_named(debug, iwlagn_mod_params.debug_level, uint,
2404 S_IRUGO | S_IWUSR);
2405MODULE_PARM_DESC(debug, "debug output mask");
2406#endif
2407
2408module_param_named(swcrypto, iwlagn_mod_params.sw_crypto, int, S_IRUGO);
2409MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
2410module_param_named(11n_disable, iwlagn_mod_params.disable_11n, uint, S_IRUGO);
2411MODULE_PARM_DESC(11n_disable,
2412 "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
2413module_param_named(amsdu_size_8K, iwlagn_mod_params.amsdu_size_8K,
2414 int, S_IRUGO);
2415MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
2416module_param_named(fw_restart, iwlagn_mod_params.restart_fw, int, S_IRUGO);
2417MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
2418
2419module_param_named(antenna_coupling, iwlagn_mod_params.ant_coupling,
2420 int, S_IRUGO);
2421MODULE_PARM_DESC(antenna_coupling,
2422 "specify antenna coupling in dB (defualt: 0 dB)");
2423
2424module_param_named(bt_ch_inhibition, iwlagn_mod_params.bt_ch_announce,
2425 bool, S_IRUGO);
2426MODULE_PARM_DESC(bt_ch_inhibition,
2427 "Enable BT channel inhibition (default: enable)");
2428
2429module_param_named(plcp_check, iwlagn_mod_params.plcp_check, bool, S_IRUGO);
2430MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
2431
2432module_param_named(wd_disable, iwlagn_mod_params.wd_disable, int, S_IRUGO);
2433MODULE_PARM_DESC(wd_disable,
2434 "Disable stuck queue watchdog timer 0=system default, "
2435 "1=disable, 2=enable (default: 0)");
2436
2437/*
2438 * set bt_coex_active to true, uCode will do kill/defer
2439 * every time the priority line is asserted (BT is sending signals on the
2440 * priority line in the PCIx).
2441 * set bt_coex_active to false, uCode will ignore the BT activity and
2442 * perform the normal operation
2443 *
2444 * User might experience transmit issue on some platform due to WiFi/BT
2445 * co-exist problem. The possible behaviors are:
2446 * Able to scan and finding all the available AP
2447 * Not able to associate with any AP
2448 * On those platforms, WiFi communication can be restored by set
2449 * "bt_coex_active" module parameter to "false"
2450 *
2451 * default: bt_coex_active = true (BT_COEX_ENABLE)
2452 */
2453module_param_named(bt_coex_active, iwlagn_mod_params.bt_coex_active,
2454 bool, S_IRUGO);
2455MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
2456
2457module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO);
2458MODULE_PARM_DESC(led_mode, "0=system default, "
2459 "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
2460
2461module_param_named(power_save, iwlagn_mod_params.power_save,
2462 bool, S_IRUGO);
2463MODULE_PARM_DESC(power_save,
2464 "enable WiFi power management (default: disable)");
2465
2466module_param_named(power_level, iwlagn_mod_params.power_level,
2467 int, S_IRUGO);
2468MODULE_PARM_DESC(power_level,
2469 "default power save level (range from 1 - 5, default: 1)");
2470
2471module_param_named(auto_agg, iwlagn_mod_params.auto_agg,
2472 bool, S_IRUGO);
2473MODULE_PARM_DESC(auto_agg,
2474 "enable agg w/o check traffic load (default: enable)");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 942b3649fff1..34900e6523dd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -64,6 +64,7 @@
64#define __iwl_agn_h__ 64#define __iwl_agn_h__
65 65
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67#include "iwl-config.h"
67 68
68/* The first 11 queues (0-10) are used otherwise */ 69/* The first 11 queues (0-10) are used otherwise */
69#define IWLAGN_FIRST_AMPDU_QUEUE 11 70#define IWLAGN_FIRST_AMPDU_QUEUE 11
@@ -81,6 +82,7 @@ extern struct iwl_lib_ops iwl6000_lib;
81extern struct iwl_lib_ops iwl6030_lib; 82extern struct iwl_lib_ops iwl6030_lib;
82 83
83 84
85#define TIME_UNIT 1024
84 86
85/***************************************************** 87/*****************************************************
86* DRIVER STATUS FUNCTIONS 88* DRIVER STATUS FUNCTIONS
@@ -154,7 +156,6 @@ void iwl_set_flags_for_band(struct iwl_priv *priv,
154 struct iwl_rxon_context *ctx, 156 struct iwl_rxon_context *ctx,
155 enum ieee80211_band band, 157 enum ieee80211_band band,
156 struct ieee80211_vif *vif); 158 struct ieee80211_vif *vif);
157void iwl_set_rate(struct iwl_priv *priv);
158 159
159/* uCode */ 160/* uCode */
160int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); 161int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
@@ -279,8 +280,8 @@ void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena);
279 280
280static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv) 281static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
281{ 282{
282 return cfg(priv)->bt_params && 283 return priv->cfg->bt_params &&
283 cfg(priv)->bt_params->advanced_bt_coexist; 284 priv->cfg->bt_params->advanced_bt_coexist;
284} 285}
285 286
286#ifdef CONFIG_IWLWIFI_DEBUG 287#ifdef CONFIG_IWLWIFI_DEBUG
@@ -472,16 +473,29 @@ static inline void iwl_dvm_set_pmi(struct iwl_priv *priv, bool state)
472 set_bit(STATUS_POWER_PMI, &priv->status); 473 set_bit(STATUS_POWER_PMI, &priv->status);
473 else 474 else
474 clear_bit(STATUS_POWER_PMI, &priv->status); 475 clear_bit(STATUS_POWER_PMI, &priv->status);
475 iwl_trans_set_pmi(trans(priv), state); 476 iwl_trans_set_pmi(priv->trans, state);
476} 477}
477 478
479#ifdef CONFIG_IWLWIFI_DEBUGFS
480int iwl_dbgfs_register(struct iwl_priv *priv, const char *name);
481void iwl_dbgfs_unregister(struct iwl_priv *priv);
482#else
483static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
484{
485 return 0;
486}
487static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
488{
489}
490#endif /* CONFIG_IWLWIFI_DEBUGFS */
491
478#ifdef CONFIG_IWLWIFI_DEBUG 492#ifdef CONFIG_IWLWIFI_DEBUG
479#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ 493#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \
480do { \ 494do { \
481 if (!iwl_is_rfkill((m))) \ 495 if (!iwl_is_rfkill((m))) \
482 IWL_ERR(m, fmt, ##args); \ 496 IWL_ERR(m, fmt, ##args); \
483 else \ 497 else \
484 __iwl_err(trans(m)->dev, true, \ 498 __iwl_err((m)->dev, true, \
485 !iwl_have_debug_level(IWL_DL_RADIO), \ 499 !iwl_have_debug_level(IWL_DL_RADIO), \
486 fmt, ##args); \ 500 fmt, ##args); \
487} while (0) 501} while (0)
@@ -491,7 +505,7 @@ do { \
491 if (!iwl_is_rfkill((m))) \ 505 if (!iwl_is_rfkill((m))) \
492 IWL_ERR(m, fmt, ##args); \ 506 IWL_ERR(m, fmt, ##args); \
493 else \ 507 else \
494 __iwl_err(trans(m)->dev, true, true, fmt, ##args); \ 508 __iwl_err((m)->dev, true, true, fmt, ##args); \
495} while (0) 509} while (0)
496#endif /* CONFIG_IWLWIFI_DEBUG */ 510#endif /* CONFIG_IWLWIFI_DEBUG */
497 511
diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h
index 47bfd5e59575..67b28aa7f9be 100644
--- a/drivers/net/wireless/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/iwlwifi/iwl-config.h
@@ -102,6 +102,34 @@ enum iwl_led_mode {
102}; 102};
103 103
104/* 104/*
105 * This is the threshold value of plcp error rate per 100mSecs. It is
106 * used to set and check for the validity of plcp_delta.
107 */
108#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN 1
109#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF 50
110#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF 100
111#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF 200
112#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX 255
113#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE 0
114
115/* TX queue watchdog timeouts in mSecs */
116#define IWL_WATCHHDOG_DISABLED 0
117#define IWL_DEF_WD_TIMEOUT 2000
118#define IWL_LONG_WD_TIMEOUT 10000
119#define IWL_MAX_WD_TIMEOUT 120000
120
121/* Antenna presence definitions */
122#define ANT_NONE 0x0
123#define ANT_A BIT(0)
124#define ANT_B BIT(1)
125#define ANT_C BIT(2)
126#define ANT_AB (ANT_A | ANT_B)
127#define ANT_AC (ANT_A | ANT_C)
128#define ANT_BC (ANT_B | ANT_C)
129#define ANT_ABC (ANT_A | ANT_B | ANT_C)
130
131
132/*
105 * @max_ll_items: max number of OTP blocks 133 * @max_ll_items: max number of OTP blocks
106 * @shadow_ram_support: shadow support for OTP memory 134 * @shadow_ram_support: shadow support for OTP memory
107 * @led_compensation: compensate on the led on/off time per HW according 135 * @led_compensation: compensate on the led on/off time per HW according
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
deleted file mode 100644
index d7a8cde249ff..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ /dev/null
@@ -1,297 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/sched.h>
32#include <linux/slab.h>
33#include <net/mac80211.h>
34
35#include "iwl-eeprom.h"
36#include "iwl-debug.h"
37#include "iwl-core.h"
38#include "iwl-io.h"
39#include "iwl-power.h"
40#include "iwl-shared.h"
41#include "iwl-agn.h"
42#include "iwl-trans.h"
43
44
45
46#ifdef CONFIG_IWLWIFI_DEBUGFS
47
48#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES)
49
50void iwl_reset_traffic_log(struct iwl_priv *priv)
51{
52 priv->tx_traffic_idx = 0;
53 priv->rx_traffic_idx = 0;
54 if (priv->tx_traffic)
55 memset(priv->tx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE);
56 if (priv->rx_traffic)
57 memset(priv->rx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE);
58}
59
60int iwl_alloc_traffic_mem(struct iwl_priv *priv)
61{
62 u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE;
63
64 if (iwl_have_debug_level(IWL_DL_TX)) {
65 if (!priv->tx_traffic) {
66 priv->tx_traffic =
67 kzalloc(traffic_size, GFP_KERNEL);
68 if (!priv->tx_traffic)
69 return -ENOMEM;
70 }
71 }
72 if (iwl_have_debug_level(IWL_DL_RX)) {
73 if (!priv->rx_traffic) {
74 priv->rx_traffic =
75 kzalloc(traffic_size, GFP_KERNEL);
76 if (!priv->rx_traffic)
77 return -ENOMEM;
78 }
79 }
80 iwl_reset_traffic_log(priv);
81 return 0;
82}
83
84void iwl_free_traffic_mem(struct iwl_priv *priv)
85{
86 kfree(priv->tx_traffic);
87 priv->tx_traffic = NULL;
88
89 kfree(priv->rx_traffic);
90 priv->rx_traffic = NULL;
91}
92
93void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
94 u16 length, struct ieee80211_hdr *header)
95{
96 __le16 fc;
97 u16 len;
98
99 if (likely(!iwl_have_debug_level(IWL_DL_TX)))
100 return;
101
102 if (!priv->tx_traffic)
103 return;
104
105 fc = header->frame_control;
106 if (ieee80211_is_data(fc)) {
107 len = (length > IWL_TRAFFIC_ENTRY_SIZE)
108 ? IWL_TRAFFIC_ENTRY_SIZE : length;
109 memcpy((priv->tx_traffic +
110 (priv->tx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)),
111 header, len);
112 priv->tx_traffic_idx =
113 (priv->tx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES;
114 }
115}
116
117void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
118 u16 length, struct ieee80211_hdr *header)
119{
120 __le16 fc;
121 u16 len;
122
123 if (likely(!iwl_have_debug_level(IWL_DL_RX)))
124 return;
125
126 if (!priv->rx_traffic)
127 return;
128
129 fc = header->frame_control;
130 if (ieee80211_is_data(fc)) {
131 len = (length > IWL_TRAFFIC_ENTRY_SIZE)
132 ? IWL_TRAFFIC_ENTRY_SIZE : length;
133 memcpy((priv->rx_traffic +
134 (priv->rx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)),
135 header, len);
136 priv->rx_traffic_idx =
137 (priv->rx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES;
138 }
139}
140
141const char *get_mgmt_string(int cmd)
142{
143#define IWL_CMD(x) case x: return #x
144 switch (cmd) {
145 IWL_CMD(MANAGEMENT_ASSOC_REQ);
146 IWL_CMD(MANAGEMENT_ASSOC_RESP);
147 IWL_CMD(MANAGEMENT_REASSOC_REQ);
148 IWL_CMD(MANAGEMENT_REASSOC_RESP);
149 IWL_CMD(MANAGEMENT_PROBE_REQ);
150 IWL_CMD(MANAGEMENT_PROBE_RESP);
151 IWL_CMD(MANAGEMENT_BEACON);
152 IWL_CMD(MANAGEMENT_ATIM);
153 IWL_CMD(MANAGEMENT_DISASSOC);
154 IWL_CMD(MANAGEMENT_AUTH);
155 IWL_CMD(MANAGEMENT_DEAUTH);
156 IWL_CMD(MANAGEMENT_ACTION);
157 default:
158 return "UNKNOWN";
159
160 }
161#undef IWL_CMD
162}
163
164const char *get_ctrl_string(int cmd)
165{
166#define IWL_CMD(x) case x: return #x
167 switch (cmd) {
168 IWL_CMD(CONTROL_BACK_REQ);
169 IWL_CMD(CONTROL_BACK);
170 IWL_CMD(CONTROL_PSPOLL);
171 IWL_CMD(CONTROL_RTS);
172 IWL_CMD(CONTROL_CTS);
173 IWL_CMD(CONTROL_ACK);
174 IWL_CMD(CONTROL_CFEND);
175 IWL_CMD(CONTROL_CFENDACK);
176 default:
177 return "UNKNOWN";
178
179 }
180#undef IWL_CMD
181}
182
183void iwl_clear_traffic_stats(struct iwl_priv *priv)
184{
185 memset(&priv->tx_stats, 0, sizeof(struct traffic_stats));
186 memset(&priv->rx_stats, 0, sizeof(struct traffic_stats));
187}
188
189/*
190 * if CONFIG_IWLWIFI_DEBUGFS defined, iwl_update_stats function will
191 * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass.
192 * Use debugFs to display the rx/rx_statistics
193 * if CONFIG_IWLWIFI_DEBUGFS not being defined, then no MGMT and CTRL
194 * information will be recorded, but DATA pkt still will be recorded
195 * for the reason of iwl_led.c need to control the led blinking based on
196 * number of tx and rx data.
197 *
198 */
199void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
200{
201 struct traffic_stats *stats;
202
203 if (is_tx)
204 stats = &priv->tx_stats;
205 else
206 stats = &priv->rx_stats;
207
208 if (ieee80211_is_mgmt(fc)) {
209 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
210 case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
211 stats->mgmt[MANAGEMENT_ASSOC_REQ]++;
212 break;
213 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
214 stats->mgmt[MANAGEMENT_ASSOC_RESP]++;
215 break;
216 case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
217 stats->mgmt[MANAGEMENT_REASSOC_REQ]++;
218 break;
219 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
220 stats->mgmt[MANAGEMENT_REASSOC_RESP]++;
221 break;
222 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ):
223 stats->mgmt[MANAGEMENT_PROBE_REQ]++;
224 break;
225 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
226 stats->mgmt[MANAGEMENT_PROBE_RESP]++;
227 break;
228 case cpu_to_le16(IEEE80211_STYPE_BEACON):
229 stats->mgmt[MANAGEMENT_BEACON]++;
230 break;
231 case cpu_to_le16(IEEE80211_STYPE_ATIM):
232 stats->mgmt[MANAGEMENT_ATIM]++;
233 break;
234 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
235 stats->mgmt[MANAGEMENT_DISASSOC]++;
236 break;
237 case cpu_to_le16(IEEE80211_STYPE_AUTH):
238 stats->mgmt[MANAGEMENT_AUTH]++;
239 break;
240 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
241 stats->mgmt[MANAGEMENT_DEAUTH]++;
242 break;
243 case cpu_to_le16(IEEE80211_STYPE_ACTION):
244 stats->mgmt[MANAGEMENT_ACTION]++;
245 break;
246 }
247 } else if (ieee80211_is_ctl(fc)) {
248 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
249 case cpu_to_le16(IEEE80211_STYPE_BACK_REQ):
250 stats->ctrl[CONTROL_BACK_REQ]++;
251 break;
252 case cpu_to_le16(IEEE80211_STYPE_BACK):
253 stats->ctrl[CONTROL_BACK]++;
254 break;
255 case cpu_to_le16(IEEE80211_STYPE_PSPOLL):
256 stats->ctrl[CONTROL_PSPOLL]++;
257 break;
258 case cpu_to_le16(IEEE80211_STYPE_RTS):
259 stats->ctrl[CONTROL_RTS]++;
260 break;
261 case cpu_to_le16(IEEE80211_STYPE_CTS):
262 stats->ctrl[CONTROL_CTS]++;
263 break;
264 case cpu_to_le16(IEEE80211_STYPE_ACK):
265 stats->ctrl[CONTROL_ACK]++;
266 break;
267 case cpu_to_le16(IEEE80211_STYPE_CFEND):
268 stats->ctrl[CONTROL_CFEND]++;
269 break;
270 case cpu_to_le16(IEEE80211_STYPE_CFENDACK):
271 stats->ctrl[CONTROL_CFENDACK]++;
272 break;
273 }
274 } else {
275 /* data */
276 stats->data_cnt++;
277 stats->data_bytes += len;
278 }
279}
280#endif
281
282int iwl_cmd_echo_test(struct iwl_priv *priv)
283{
284 int ret;
285 struct iwl_host_cmd cmd = {
286 .id = REPLY_ECHO,
287 .len = { 0 },
288 .flags = CMD_SYNC,
289 };
290
291 ret = iwl_dvm_send_cmd(priv, &cmd);
292 if (ret)
293 IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
294 else
295 IWL_DEBUG_INFO(priv, "echo testing pass\n");
296 return ret;
297}
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
deleted file mode 100644
index 199a0c03774c..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ /dev/null
@@ -1,133 +0,0 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/
62
63#ifndef __iwl_core_h__
64#define __iwl_core_h__
65
66#include "iwl-dev.h"
67#include "iwl-io.h"
68
69/************************
70 * forward declarations *
71 ************************/
72struct iwl_host_cmd;
73struct iwl_cmd;
74
75#define TIME_UNIT 1024
76
77/***************************
78 * L i b *
79 ***************************/
80
81int iwl_cmd_echo_test(struct iwl_priv *priv);
82#ifdef CONFIG_IWLWIFI_DEBUGFS
83int iwl_alloc_traffic_mem(struct iwl_priv *priv);
84void iwl_free_traffic_mem(struct iwl_priv *priv);
85void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
86 u16 length, struct ieee80211_hdr *header);
87void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
88 u16 length, struct ieee80211_hdr *header);
89const char *get_mgmt_string(int cmd);
90const char *get_ctrl_string(int cmd);
91void iwl_clear_traffic_stats(struct iwl_priv *priv);
92void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc,
93 u16 len);
94void iwl_reset_traffic_log(struct iwl_priv *priv);
95
96#else
97static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv)
98{
99 return 0;
100}
101static inline void iwl_free_traffic_mem(struct iwl_priv *priv)
102{
103}
104static inline void iwl_reset_traffic_log(struct iwl_priv *priv)
105{
106}
107static inline void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
108 u16 length, struct ieee80211_hdr *header)
109{
110}
111static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
112 u16 length, struct ieee80211_hdr *header)
113{
114}
115static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
116 __le16 fc, u16 len)
117{
118}
119#endif
120
121/*******************************************************************************
122 * Scanning
123 ******************************************************************************/
124/* traffic log definitions */
125#define IWL_TRAFFIC_ENTRIES (256)
126#define IWL_TRAFFIC_ENTRY_SIZE (64)
127
128/*****************************************************
129 * S e n d i n g H o s t C o m m a n d s *
130 *****************************************************/
131extern bool bt_siso_mode;
132
133#endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.c b/drivers/net/wireless/iwlwifi/iwl-debug.c
index 059efabda184..2d1b42847b9b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.c
@@ -63,6 +63,7 @@
63 63
64#include <linux/interrupt.h> 64#include <linux/interrupt.h>
65#include "iwl-debug.h" 65#include "iwl-debug.h"
66#include "iwl-devtrace.h"
66 67
67#define __iwl_fn(fn) \ 68#define __iwl_fn(fn) \
68void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \ 69void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index a6b32a11e103..8376b842bdba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -29,10 +29,13 @@
29#ifndef __iwl_debug_h__ 29#ifndef __iwl_debug_h__
30#define __iwl_debug_h__ 30#define __iwl_debug_h__
31 31
32#include "iwl-shared.h" 32#include "iwl-modparams.h"
33#include "iwl-devtrace.h"
34 33
35struct iwl_priv; 34
35static inline bool iwl_have_debug_level(u32 level)
36{
37 return iwlwifi_mod_params.debug_level & level;
38}
36 39
37void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace, 40void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
38 const char *fmt, ...); 41 const char *fmt, ...);
@@ -41,10 +44,10 @@ void __iwl_info(struct device *dev, const char *fmt, ...);
41void __iwl_crit(struct device *dev, const char *fmt, ...); 44void __iwl_crit(struct device *dev, const char *fmt, ...);
42 45
43/* No matter what is m (priv, bus, trans), this will work */ 46/* No matter what is m (priv, bus, trans), this will work */
44#define IWL_ERR(m, f, a...) __iwl_err(trans(m)->dev, false, false, f, ## a) 47#define IWL_ERR(m, f, a...) __iwl_err((m)->dev, false, false, f, ## a)
45#define IWL_WARN(m, f, a...) __iwl_warn(trans(m)->dev, f, ## a) 48#define IWL_WARN(m, f, a...) __iwl_warn((m)->dev, f, ## a)
46#define IWL_INFO(m, f, a...) __iwl_info(trans(m)->dev, f, ## a) 49#define IWL_INFO(m, f, a...) __iwl_info((m)->dev, f, ## a)
47#define IWL_CRIT(m, f, a...) __iwl_crit(trans(m)->dev, f, ## a) 50#define IWL_CRIT(m, f, a...) __iwl_crit((m)->dev, f, ## a)
48 51
49#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING) 52#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
50void __iwl_dbg(struct device *dev, 53void __iwl_dbg(struct device *dev,
@@ -65,9 +68,9 @@ do { \
65} while (0) 68} while (0)
66 69
67#define IWL_DEBUG(m, level, fmt, args...) \ 70#define IWL_DEBUG(m, level, fmt, args...) \
68 __iwl_dbg(trans(m)->dev, level, false, __func__, fmt, ##args) 71 __iwl_dbg((m)->dev, level, false, __func__, fmt, ##args)
69#define IWL_DEBUG_LIMIT(m, level, fmt, args...) \ 72#define IWL_DEBUG_LIMIT(m, level, fmt, args...) \
70 __iwl_dbg(trans(m)->dev, level, true, __func__, fmt, ##args) 73 __iwl_dbg((m)->dev, level, true, __func__, fmt, ##args)
71 74
72#ifdef CONFIG_IWLWIFI_DEBUG 75#ifdef CONFIG_IWLWIFI_DEBUG
73#define iwl_print_hex_dump(m, level, p, len) \ 76#define iwl_print_hex_dump(m, level, p, len) \
@@ -80,19 +83,6 @@ do { \
80#define iwl_print_hex_dump(m, level, p, len) 83#define iwl_print_hex_dump(m, level, p, len)
81#endif /* CONFIG_IWLWIFI_DEBUG */ 84#endif /* CONFIG_IWLWIFI_DEBUG */
82 85
83#ifdef CONFIG_IWLWIFI_DEBUGFS
84int iwl_dbgfs_register(struct iwl_priv *priv, const char *name);
85void iwl_dbgfs_unregister(struct iwl_priv *priv);
86#else
87static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
88{
89 return 0;
90}
91static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
92{
93}
94#endif /* CONFIG_IWLWIFI_DEBUGFS */
95
96/* 86/*
97 * To use the debug system: 87 * To use the debug system:
98 * 88 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 32834a797d11..e7c157e5ebeb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -37,9 +37,9 @@
37 37
38#include "iwl-dev.h" 38#include "iwl-dev.h"
39#include "iwl-debug.h" 39#include "iwl-debug.h"
40#include "iwl-core.h"
41#include "iwl-io.h" 40#include "iwl-io.h"
42#include "iwl-agn.h" 41#include "iwl-agn.h"
42#include "iwl-modparams.h"
43 43
44/* create and remove of files */ 44/* create and remove of files */
45#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ 45#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
@@ -111,105 +111,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
111 .llseek = generic_file_llseek, \ 111 .llseek = generic_file_llseek, \
112}; 112};
113 113
114static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
115 char __user *user_buf,
116 size_t count, loff_t *ppos) {
117
118 struct iwl_priv *priv = file->private_data;
119 char *buf;
120 int pos = 0;
121
122 int cnt;
123 ssize_t ret;
124 const size_t bufsz = 100 +
125 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
126 buf = kzalloc(bufsz, GFP_KERNEL);
127 if (!buf)
128 return -ENOMEM;
129 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
130 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
131 pos += scnprintf(buf + pos, bufsz - pos,
132 "\t%25s\t\t: %u\n",
133 get_mgmt_string(cnt),
134 priv->tx_stats.mgmt[cnt]);
135 }
136 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
137 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
138 pos += scnprintf(buf + pos, bufsz - pos,
139 "\t%25s\t\t: %u\n",
140 get_ctrl_string(cnt),
141 priv->tx_stats.ctrl[cnt]);
142 }
143 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
144 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
145 priv->tx_stats.data_cnt);
146 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
147 priv->tx_stats.data_bytes);
148 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
149 kfree(buf);
150 return ret;
151}
152
153static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
154 const char __user *user_buf,
155 size_t count, loff_t *ppos)
156{
157 struct iwl_priv *priv = file->private_data;
158 u32 clear_flag;
159 char buf[8];
160 int buf_size;
161
162 memset(buf, 0, sizeof(buf));
163 buf_size = min(count, sizeof(buf) - 1);
164 if (copy_from_user(buf, user_buf, buf_size))
165 return -EFAULT;
166 if (sscanf(buf, "%x", &clear_flag) != 1)
167 return -EFAULT;
168 iwl_clear_traffic_stats(priv);
169
170 return count;
171}
172
173static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
174 char __user *user_buf,
175 size_t count, loff_t *ppos) {
176
177 struct iwl_priv *priv = file->private_data;
178 char *buf;
179 int pos = 0;
180 int cnt;
181 ssize_t ret;
182 const size_t bufsz = 100 +
183 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
184 buf = kzalloc(bufsz, GFP_KERNEL);
185 if (!buf)
186 return -ENOMEM;
187
188 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
189 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
190 pos += scnprintf(buf + pos, bufsz - pos,
191 "\t%25s\t\t: %u\n",
192 get_mgmt_string(cnt),
193 priv->rx_stats.mgmt[cnt]);
194 }
195 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
196 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
197 pos += scnprintf(buf + pos, bufsz - pos,
198 "\t%25s\t\t: %u\n",
199 get_ctrl_string(cnt),
200 priv->rx_stats.ctrl[cnt]);
201 }
202 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
203 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
204 priv->rx_stats.data_cnt);
205 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
206 priv->rx_stats.data_bytes);
207
208 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
209 kfree(buf);
210 return ret;
211}
212
213static ssize_t iwl_dbgfs_sram_read(struct file *file, 114static ssize_t iwl_dbgfs_sram_read(struct file *file,
214 char __user *user_buf, 115 char __user *user_buf,
215 size_t count, loff_t *ppos) 116 size_t count, loff_t *ppos)
@@ -230,10 +131,8 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
230 /* default is to dump the entire data segment */ 131 /* default is to dump the entire data segment */
231 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { 132 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
232 priv->dbgfs_sram_offset = 0x800000; 133 priv->dbgfs_sram_offset = 0x800000;
233 if (!priv->ucode_loaded) { 134 if (!priv->ucode_loaded)
234 IWL_ERR(priv, "No uCode has been loadded.\n");
235 return -EINVAL; 135 return -EINVAL;
236 }
237 img = &priv->fw->img[priv->cur_ucode]; 136 img = &priv->fw->img[priv->cur_ucode];
238 priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; 137 priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
239 } 138 }
@@ -259,7 +158,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
259 sram = priv->dbgfs_sram_offset & ~0x3; 158 sram = priv->dbgfs_sram_offset & ~0x3;
260 159
261 /* read the first u32 from sram */ 160 /* read the first u32 from sram */
262 val = iwl_read_targ_mem(trans(priv), sram); 161 val = iwl_read_targ_mem(priv->trans, sram);
263 162
264 for (; len; len--) { 163 for (; len; len--) {
265 /* put the address at the start of every line */ 164 /* put the address at the start of every line */
@@ -278,7 +177,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
278 if (++offset == 4) { 177 if (++offset == 4) {
279 sram += 4; 178 sram += 4;
280 offset = 0; 179 offset = 0;
281 val = iwl_read_targ_mem(trans(priv), sram); 180 val = iwl_read_targ_mem(priv->trans, sram);
282 } 181 }
283 182
284 /* put in extra spaces and split lines for human readability */ 183 /* put in extra spaces and split lines for human readability */
@@ -408,26 +307,21 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
408 const u8 *ptr; 307 const u8 *ptr;
409 char *buf; 308 char *buf;
410 u16 eeprom_ver; 309 u16 eeprom_ver;
411 size_t eeprom_len = cfg(priv)->base_params->eeprom_size; 310 size_t eeprom_len = priv->cfg->base_params->eeprom_size;
412 buf_size = 4 * eeprom_len + 256; 311 buf_size = 4 * eeprom_len + 256;
413 312
414 if (eeprom_len % 16) { 313 if (eeprom_len % 16)
415 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
416 return -ENODATA; 314 return -ENODATA;
417 }
418 315
419 ptr = priv->eeprom; 316 ptr = priv->eeprom;
420 if (!ptr) { 317 if (!ptr)
421 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
422 return -ENOMEM; 318 return -ENOMEM;
423 }
424 319
425 /* 4 characters for byte 0xYY */ 320 /* 4 characters for byte 0xYY */
426 buf = kzalloc(buf_size, GFP_KERNEL); 321 buf = kzalloc(buf_size, GFP_KERNEL);
427 if (!buf) { 322 if (!buf)
428 IWL_ERR(priv, "Can not allocate Buffer\n");
429 return -ENOMEM; 323 return -ENOMEM;
430 } 324
431 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); 325 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
432 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " 326 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
433 "version: 0x%x\n", 327 "version: 0x%x\n",
@@ -461,10 +355,8 @@ static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
461 return -EAGAIN; 355 return -EAGAIN;
462 356
463 buf = kzalloc(bufsz, GFP_KERNEL); 357 buf = kzalloc(bufsz, GFP_KERNEL);
464 if (!buf) { 358 if (!buf)
465 IWL_ERR(priv, "Can not allocate Buffer\n");
466 return -ENOMEM; 359 return -ENOMEM;
467 }
468 360
469 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); 361 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
470 if (supp_band) { 362 if (supp_band) {
@@ -566,10 +458,8 @@ static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
566 ssize_t ret; 458 ssize_t ret;
567 459
568 buf = kzalloc(bufsz, GFP_KERNEL); 460 buf = kzalloc(bufsz, GFP_KERNEL);
569 if (!buf) { 461 if (!buf)
570 IWL_ERR(priv, "Can not allocate Buffer\n");
571 return -ENOMEM; 462 return -ENOMEM;
572 }
573 463
574 for (cnt = 0; cnt < REPLY_MAX; cnt++) { 464 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
575 if (priv->rx_handlers_stats[cnt] > 0) 465 if (priv->rx_handlers_stats[cnt] > 0)
@@ -683,11 +573,8 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
683 return -EFAULT; 573 return -EFAULT;
684 if (!iwl_is_any_associated(priv)) 574 if (!iwl_is_any_associated(priv))
685 priv->disable_ht40 = ht40 ? true : false; 575 priv->disable_ht40 = ht40 ? true : false;
686 else { 576 else
687 IWL_ERR(priv, "Sta associated with AP - "
688 "Change to 40MHz channel support is not allowed\n");
689 return -EINVAL; 577 return -EINVAL;
690 }
691 578
692 return count; 579 return count;
693} 580}
@@ -819,87 +706,6 @@ DEBUGFS_READ_FILE_OPS(temperature);
819DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); 706DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
820DEBUGFS_READ_FILE_OPS(current_sleep_command); 707DEBUGFS_READ_FILE_OPS(current_sleep_command);
821 708
822static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
823 char __user *user_buf,
824 size_t count, loff_t *ppos)
825{
826 struct iwl_priv *priv = file->private_data;
827 int pos = 0, ofs = 0;
828 int cnt = 0, entry;
829
830 char *buf;
831 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
832 (cfg(priv)->base_params->num_of_queues * 32 * 8) + 400;
833 const u8 *ptr;
834 ssize_t ret;
835
836 buf = kzalloc(bufsz, GFP_KERNEL);
837 if (!buf) {
838 IWL_ERR(priv, "Can not allocate buffer\n");
839 return -ENOMEM;
840 }
841 if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) {
842 ptr = priv->tx_traffic;
843 pos += scnprintf(buf + pos, bufsz - pos,
844 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
845 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
846 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
847 entry++, ofs += 16) {
848 pos += scnprintf(buf + pos, bufsz - pos,
849 "0x%.4x ", ofs);
850 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
851 buf + pos, bufsz - pos, 0);
852 pos += strlen(buf + pos);
853 if (bufsz - pos > 0)
854 buf[pos++] = '\n';
855 }
856 }
857 }
858
859 if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) {
860 ptr = priv->rx_traffic;
861 pos += scnprintf(buf + pos, bufsz - pos,
862 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
863 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
864 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
865 entry++, ofs += 16) {
866 pos += scnprintf(buf + pos, bufsz - pos,
867 "0x%.4x ", ofs);
868 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
869 buf + pos, bufsz - pos, 0);
870 pos += strlen(buf + pos);
871 if (bufsz - pos > 0)
872 buf[pos++] = '\n';
873 }
874 }
875 }
876
877 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
878 kfree(buf);
879 return ret;
880}
881
882static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
883 const char __user *user_buf,
884 size_t count, loff_t *ppos)
885{
886 struct iwl_priv *priv = file->private_data;
887 char buf[8];
888 int buf_size;
889 int traffic_log;
890
891 memset(buf, 0, sizeof(buf));
892 buf_size = min(count, sizeof(buf) - 1);
893 if (copy_from_user(buf, user_buf, buf_size))
894 return -EFAULT;
895 if (sscanf(buf, "%d", &traffic_log) != 1)
896 return -EFAULT;
897 if (traffic_log == 0)
898 iwl_reset_traffic_log(priv);
899
900 return count;
901}
902
903static const char *fmt_value = " %-30s %10u\n"; 709static const char *fmt_value = " %-30s %10u\n";
904static const char *fmt_hex = " %-30s 0x%02X\n"; 710static const char *fmt_hex = " %-30s 0x%02X\n";
905static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; 711static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
@@ -950,10 +756,8 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
950 return -EAGAIN; 756 return -EAGAIN;
951 757
952 buf = kzalloc(bufsz, GFP_KERNEL); 758 buf = kzalloc(bufsz, GFP_KERNEL);
953 if (!buf) { 759 if (!buf)
954 IWL_ERR(priv, "Can not allocate Buffer\n");
955 return -ENOMEM; 760 return -ENOMEM;
956 }
957 761
958 /* 762 /*
959 * the statistic information display here is based on 763 * the statistic information display here is based on
@@ -1379,10 +1183,8 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1379 return -EAGAIN; 1183 return -EAGAIN;
1380 1184
1381 buf = kzalloc(bufsz, GFP_KERNEL); 1185 buf = kzalloc(bufsz, GFP_KERNEL);
1382 if (!buf) { 1186 if (!buf)
1383 IWL_ERR(priv, "Can not allocate Buffer\n");
1384 return -ENOMEM; 1187 return -ENOMEM;
1385 }
1386 1188
1387 /* the statistic information display here is based on 1189 /* the statistic information display here is based on
1388 * the last statistics notification from uCode 1190 * the last statistics notification from uCode
@@ -1581,10 +1383,8 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1581 return -EAGAIN; 1383 return -EAGAIN;
1582 1384
1583 buf = kzalloc(bufsz, GFP_KERNEL); 1385 buf = kzalloc(bufsz, GFP_KERNEL);
1584 if (!buf) { 1386 if (!buf)
1585 IWL_ERR(priv, "Can not allocate Buffer\n");
1586 return -ENOMEM; 1387 return -ENOMEM;
1587 }
1588 1388
1589 /* the statistic information display here is based on 1389 /* the statistic information display here is based on
1590 * the last statistics notification from uCode 1390 * the last statistics notification from uCode
@@ -1707,16 +1507,11 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1707 ret = iwl_send_statistics_request(priv, CMD_SYNC, false); 1507 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
1708 mutex_unlock(&priv->mutex); 1508 mutex_unlock(&priv->mutex);
1709 1509
1710 if (ret) { 1510 if (ret)
1711 IWL_ERR(priv,
1712 "Error sending statistics request: %zd\n", ret);
1713 return -EAGAIN; 1511 return -EAGAIN;
1714 }
1715 buf = kzalloc(bufsz, GFP_KERNEL); 1512 buf = kzalloc(bufsz, GFP_KERNEL);
1716 if (!buf) { 1513 if (!buf)
1717 IWL_ERR(priv, "Can not allocate Buffer\n");
1718 return -ENOMEM; 1514 return -ENOMEM;
1719 }
1720 1515
1721 /* 1516 /*
1722 * the statistic information display here is based on 1517 * the statistic information display here is based on
@@ -1793,10 +1588,8 @@ static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1793 return -EAGAIN; 1588 return -EAGAIN;
1794 1589
1795 buf = kzalloc(bufsz, GFP_KERNEL); 1590 buf = kzalloc(bufsz, GFP_KERNEL);
1796 if (!buf) { 1591 if (!buf)
1797 IWL_ERR(priv, "Can not allocate Buffer\n");
1798 return -ENOMEM; 1592 return -ENOMEM;
1799 }
1800 1593
1801 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); 1594 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1802 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", 1595 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
@@ -1936,10 +1729,8 @@ static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1936 1729
1937 data = &priv->sensitivity_data; 1730 data = &priv->sensitivity_data;
1938 buf = kzalloc(bufsz, GFP_KERNEL); 1731 buf = kzalloc(bufsz, GFP_KERNEL);
1939 if (!buf) { 1732 if (!buf)
1940 IWL_ERR(priv, "Can not allocate Buffer\n");
1941 return -ENOMEM; 1733 return -ENOMEM;
1942 }
1943 1734
1944 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", 1735 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1945 data->auto_corr_ofdm); 1736 data->auto_corr_ofdm);
@@ -2017,10 +1808,8 @@ static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
2017 1808
2018 data = &priv->chain_noise_data; 1809 data = &priv->chain_noise_data;
2019 buf = kzalloc(bufsz, GFP_KERNEL); 1810 buf = kzalloc(bufsz, GFP_KERNEL);
2020 if (!buf) { 1811 if (!buf)
2021 IWL_ERR(priv, "Can not allocate Buffer\n");
2022 return -ENOMEM; 1812 return -ENOMEM;
2023 }
2024 1813
2025 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", 1814 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
2026 data->active_chains); 1815 data->active_chains);
@@ -2071,7 +1860,7 @@ static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
2071 const size_t bufsz = sizeof(buf); 1860 const size_t bufsz = sizeof(buf);
2072 u32 pwrsave_status; 1861 u32 pwrsave_status;
2073 1862
2074 pwrsave_status = iwl_read32(trans(priv), CSR_GP_CNTRL) & 1863 pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) &
2075 CSR_GP_REG_POWER_SAVE_STATUS_MSK; 1864 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
2076 1865
2077 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); 1866 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
@@ -2380,7 +2169,7 @@ static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2380 char buf[40]; 2169 char buf[40];
2381 const size_t bufsz = sizeof(buf); 2170 const size_t bufsz = sizeof(buf);
2382 2171
2383 if (cfg(priv)->ht_params) 2172 if (priv->cfg->ht_params)
2384 pos += scnprintf(buf + pos, bufsz - pos, 2173 pos += scnprintf(buf + pos, bufsz - pos,
2385 "use %s for aggregation\n", 2174 "use %s for aggregation\n",
2386 (priv->hw_params.use_rts_for_aggregation) ? 2175 (priv->hw_params.use_rts_for_aggregation) ?
@@ -2400,7 +2189,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2400 int buf_size; 2189 int buf_size;
2401 int rts; 2190 int rts;
2402 2191
2403 if (!cfg(priv)->ht_params) 2192 if (!priv->cfg->ht_params)
2404 return -EINVAL; 2193 return -EINVAL;
2405 2194
2406 memset(buf, 0, sizeof(buf)); 2195 memset(buf, 0, sizeof(buf));
@@ -2416,6 +2205,23 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2416 return count; 2205 return count;
2417} 2206}
2418 2207
2208static int iwl_cmd_echo_test(struct iwl_priv *priv)
2209{
2210 int ret;
2211 struct iwl_host_cmd cmd = {
2212 .id = REPLY_ECHO,
2213 .len = { 0 },
2214 .flags = CMD_SYNC,
2215 };
2216
2217 ret = iwl_dvm_send_cmd(priv, &cmd);
2218 if (ret)
2219 IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
2220 else
2221 IWL_DEBUG_INFO(priv, "echo testing pass\n");
2222 return ret;
2223}
2224
2419static ssize_t iwl_dbgfs_echo_test_write(struct file *file, 2225static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
2420 const char __user *user_buf, 2226 const char __user *user_buf,
2421 size_t count, loff_t *ppos) 2227 size_t count, loff_t *ppos)
@@ -2499,9 +2305,27 @@ static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
2499 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2305 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2500} 2306}
2501 2307
2502DEBUGFS_READ_FILE_OPS(rx_statistics); 2308static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
2503DEBUGFS_READ_FILE_OPS(tx_statistics); 2309 const char __user *user_buf,
2504DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 2310 size_t count, loff_t *ppos)
2311{
2312 struct iwl_priv *priv = file->private_data;
2313 char buf[8];
2314 u32 calib_disabled;
2315 int buf_size;
2316
2317 memset(buf, 0, sizeof(buf));
2318 buf_size = min(count, sizeof(buf) - 1);
2319 if (copy_from_user(buf, user_buf, buf_size))
2320 return -EFAULT;
2321 if (sscanf(buf, "%x", &calib_disabled) != 1)
2322 return -EFAULT;
2323
2324 priv->calib_disabled = calib_disabled;
2325
2326 return count;
2327}
2328
2505DEBUGFS_READ_FILE_OPS(ucode_rx_stats); 2329DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2506DEBUGFS_READ_FILE_OPS(ucode_tx_stats); 2330DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2507DEBUGFS_READ_FILE_OPS(ucode_general_stats); 2331DEBUGFS_READ_FILE_OPS(ucode_general_stats);
@@ -2509,7 +2333,6 @@ DEBUGFS_READ_FILE_OPS(sensitivity);
2509DEBUGFS_READ_FILE_OPS(chain_noise); 2333DEBUGFS_READ_FILE_OPS(chain_noise);
2510DEBUGFS_READ_FILE_OPS(power_save_status); 2334DEBUGFS_READ_FILE_OPS(power_save_status);
2511DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); 2335DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2512DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
2513DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); 2336DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
2514DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); 2337DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
2515DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); 2338DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
@@ -2523,7 +2346,7 @@ DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
2523DEBUGFS_READ_FILE_OPS(reply_tx_error); 2346DEBUGFS_READ_FILE_OPS(reply_tx_error);
2524DEBUGFS_WRITE_FILE_OPS(echo_test); 2347DEBUGFS_WRITE_FILE_OPS(echo_test);
2525DEBUGFS_READ_WRITE_FILE_OPS(log_event); 2348DEBUGFS_READ_WRITE_FILE_OPS(log_event);
2526DEBUGFS_READ_FILE_OPS(calib_disabled); 2349DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled);
2527 2350
2528/* 2351/*
2529 * Create the debugfs files and directories 2352 * Create the debugfs files and directories
@@ -2564,12 +2387,8 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2564 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); 2387 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
2565 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR); 2388 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
2566 2389
2567 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
2568 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
2569 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
2570 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); 2390 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2571 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); 2391 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
2572 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
2573 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 2392 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2574 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); 2393 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2575 DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR); 2394 DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR);
@@ -2592,9 +2411,9 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2592 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); 2411 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
2593 2412
2594 /* Calibrations disabled/enabled status*/ 2413 /* Calibrations disabled/enabled status*/
2595 DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IRUSR); 2414 DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR);
2596 2415
2597 if (iwl_trans_dbgfs_register(trans(priv), dir_debug)) 2416 if (iwl_trans_dbgfs_register(priv->trans, dir_debug))
2598 goto err; 2417 goto err;
2599 return 0; 2418 return 0;
2600 2419
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c235a1ea71b4..f70219c3b122 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -38,6 +38,7 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mutex.h> 39#include <linux/mutex.h>
40 40
41#include "iwl-fw.h"
41#include "iwl-eeprom.h" 42#include "iwl-eeprom.h"
42#include "iwl-csr.h" 43#include "iwl-csr.h"
43#include "iwl-debug.h" 44#include "iwl-debug.h"
@@ -47,7 +48,6 @@
47#include "iwl-agn-rs.h" 48#include "iwl-agn-rs.h"
48#include "iwl-agn-tt.h" 49#include "iwl-agn-tt.h"
49#include "iwl-trans.h" 50#include "iwl-trans.h"
50#include "iwl-shared.h"
51#include "iwl-op-mode.h" 51#include "iwl-op-mode.h"
52#include "iwl-notif-wait.h" 52#include "iwl-notif-wait.h"
53 53
@@ -194,6 +194,7 @@ struct iwl_qos_info {
194 * These states relate to a specific RA / TID. 194 * These states relate to a specific RA / TID.
195 * 195 *
196 * @IWL_AGG_OFF: aggregation is not used 196 * @IWL_AGG_OFF: aggregation is not used
197 * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
197 * @IWL_AGG_ON: aggregation session is up 198 * @IWL_AGG_ON: aggregation session is up
198 * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the 199 * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
199 * HW queue to be empty from packets for this RA /TID. 200 * HW queue to be empty from packets for this RA /TID.
@@ -202,6 +203,7 @@ struct iwl_qos_info {
202 */ 203 */
203enum iwl_agg_state { 204enum iwl_agg_state {
204 IWL_AGG_OFF = 0, 205 IWL_AGG_OFF = 0,
206 IWL_AGG_STARTING,
205 IWL_AGG_ON, 207 IWL_AGG_ON,
206 IWL_EMPTYING_HW_QUEUE_ADDBA, 208 IWL_EMPTYING_HW_QUEUE_ADDBA,
207 IWL_EMPTYING_HW_QUEUE_DELBA, 209 IWL_EMPTYING_HW_QUEUE_DELBA,
@@ -504,44 +506,6 @@ struct reply_agg_tx_error_statistics {
504 u32 unknown; 506 u32 unknown;
505}; 507};
506 508
507/* management statistics */
508enum iwl_mgmt_stats {
509 MANAGEMENT_ASSOC_REQ = 0,
510 MANAGEMENT_ASSOC_RESP,
511 MANAGEMENT_REASSOC_REQ,
512 MANAGEMENT_REASSOC_RESP,
513 MANAGEMENT_PROBE_REQ,
514 MANAGEMENT_PROBE_RESP,
515 MANAGEMENT_BEACON,
516 MANAGEMENT_ATIM,
517 MANAGEMENT_DISASSOC,
518 MANAGEMENT_AUTH,
519 MANAGEMENT_DEAUTH,
520 MANAGEMENT_ACTION,
521 MANAGEMENT_MAX,
522};
523/* control statistics */
524enum iwl_ctrl_stats {
525 CONTROL_BACK_REQ = 0,
526 CONTROL_BACK,
527 CONTROL_PSPOLL,
528 CONTROL_RTS,
529 CONTROL_CTS,
530 CONTROL_ACK,
531 CONTROL_CFEND,
532 CONTROL_CFENDACK,
533 CONTROL_MAX,
534};
535
536struct traffic_stats {
537#ifdef CONFIG_IWLWIFI_DEBUGFS
538 u32 mgmt[MANAGEMENT_MAX];
539 u32 ctrl[CONTROL_MAX];
540 u32 data_cnt;
541 u64 data_bytes;
542#endif
543};
544
545/* 509/*
546 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds 510 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
547 * to perform continuous uCode event logging operation if enabled 511 * to perform continuous uCode event logging operation if enabled
@@ -568,25 +532,8 @@ struct iwl_event_log {
568 int wraps_more_count; 532 int wraps_more_count;
569}; 533};
570 534
571/*
572 * This is the threshold value of plcp error rate per 100mSecs. It is
573 * used to set and check for the validity of plcp_delta.
574 */
575#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
576#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
577#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
578#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
579#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
580#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
581
582#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3) 535#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
583 536
584/* TX queue watchdog timeouts in mSecs */
585#define IWL_WATCHHDOG_DISABLED (0)
586#define IWL_DEF_WD_TIMEOUT (2000)
587#define IWL_LONG_WD_TIMEOUT (10000)
588#define IWL_MAX_WD_TIMEOUT (120000)
589
590/* BT Antenna Coupling Threshold (dB) */ 537/* BT Antenna Coupling Threshold (dB) */
591#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35) 538#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
592 539
@@ -602,6 +549,13 @@ struct iwl_rf_reset {
602 unsigned long last_reset_jiffies; 549 unsigned long last_reset_jiffies;
603}; 550};
604 551
552enum iwl_rxon_context_id {
553 IWL_RXON_CTX_BSS,
554 IWL_RXON_CTX_PAN,
555
556 NUM_IWL_RXON_CTX
557};
558
605/* extend beacon time format bit shifting */ 559/* extend beacon time format bit shifting */
606/* 560/*
607 * for _agn devices 561 * for _agn devices
@@ -742,12 +696,15 @@ struct iwl_wipan_noa_data {
742}; 696};
743 697
744/* Calibration disabling bit mask */ 698/* Calibration disabling bit mask */
745#define IWL_SENSITIVITY_CALIB_DISABLED BIT(1) 699enum {
746#define IWL_CHAIN_NOISE_CALIB_DISABLED BIT(2) 700 IWL_CALIB_ENABLE_ALL = 0,
747#define IWL_TX_POWER_CALIB_DISABLED BIT(3) 701
702 IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
703 IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
704 IWL_TX_POWER_CALIB_DISABLED = BIT(2),
748 705
749#define IWL_CALIB_ENABLE_ALL 0 706 IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
750#define IWL_CALIB_DISABLE_ALL 0xFFFFFFFF 707};
751 708
752#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \ 709#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
753 ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific)) 710 ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
@@ -758,8 +715,9 @@ struct iwl_wipan_noa_data {
758 715
759struct iwl_priv { 716struct iwl_priv {
760 717
761 /*data shared among all the driver's layers */ 718 struct iwl_trans *trans;
762 struct iwl_shared *shrd; 719 struct device *dev; /* for debug prints only */
720 const struct iwl_cfg *cfg;
763 const struct iwl_fw *fw; 721 const struct iwl_fw *fw;
764 const struct iwl_lib_ops *lib; 722 const struct iwl_lib_ops *lib;
765 unsigned long status; 723 unsigned long status;
@@ -769,9 +727,9 @@ struct iwl_priv {
769 727
770 unsigned long transport_queue_stop; 728 unsigned long transport_queue_stop;
771 bool passive_no_rx; 729 bool passive_no_rx;
772#define IWL_INVALID_AC 0xff 730#define IWL_INVALID_MAC80211_QUEUE 0xff
773 u8 queue_to_ac[IWL_MAX_HW_QUEUES]; 731 u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
774 atomic_t ac_stop_count[IEEE80211_NUM_ACS]; 732 atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
775 733
776 unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)]; 734 unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
777 735
@@ -880,10 +838,6 @@ struct iwl_priv {
880 838
881 int activity_timer_active; 839 int activity_timer_active;
882 840
883 /* counts mgmt, ctl, and data packets */
884 struct traffic_stats tx_stats;
885 struct traffic_stats rx_stats;
886
887 struct iwl_power_mgr power_data; 841 struct iwl_power_mgr power_data;
888 struct iwl_tt_mgmt thermal_throttle; 842 struct iwl_tt_mgmt thermal_throttle;
889 843
@@ -1003,10 +957,6 @@ struct iwl_priv {
1003 957
1004#ifdef CONFIG_IWLWIFI_DEBUGFS 958#ifdef CONFIG_IWLWIFI_DEBUGFS
1005 /* debugfs */ 959 /* debugfs */
1006 u16 tx_traffic_idx;
1007 u16 rx_traffic_idx;
1008 u8 *tx_traffic;
1009 u8 *rx_traffic;
1010 struct dentry *debugfs_dir; 960 struct dentry *debugfs_dir;
1011 u32 dbgfs_sram_offset, dbgfs_sram_len; 961 u32 dbgfs_sram_offset, dbgfs_sram_len;
1012 bool disable_ht40; 962 bool disable_ht40;
@@ -1051,7 +1001,6 @@ struct iwl_priv {
1051}; /*iwl_priv */ 1001}; /*iwl_priv */
1052 1002
1053extern struct kmem_cache *iwl_tx_cmd_pool; 1003extern struct kmem_cache *iwl_tx_cmd_pool;
1054extern struct iwl_mod_params iwlagn_mod_params;
1055 1004
1056static inline struct iwl_rxon_context * 1005static inline struct iwl_rxon_context *
1057iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif) 1006iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 17485e715424..05302d6f989f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -67,9 +67,11 @@
67 67
68#include "iwl-drv.h" 68#include "iwl-drv.h"
69#include "iwl-trans.h" 69#include "iwl-trans.h"
70#include "iwl-shared.h"
71#include "iwl-op-mode.h" 70#include "iwl-op-mode.h"
72#include "iwl-agn-hw.h" 71#include "iwl-agn-hw.h"
72#include "iwl-fw.h"
73#include "iwl-config.h"
74#include "iwl-modparams.h"
73 75
74/* private includes */ 76/* private includes */
75#include "iwl-fw-file.h" 77#include "iwl-fw-file.h"
@@ -77,8 +79,10 @@
77/** 79/**
78 * struct iwl_drv - drv common data 80 * struct iwl_drv - drv common data
79 * @fw: the iwl_fw structure 81 * @fw: the iwl_fw structure
80 * @shrd: pointer to common shared structure
81 * @op_mode: the running op_mode 82 * @op_mode: the running op_mode
83 * @trans: transport layer
84 * @dev: for debug prints only
85 * @cfg: configuration struct
82 * @fw_index: firmware revision to try loading 86 * @fw_index: firmware revision to try loading
83 * @firmware_name: composite filename of ucode file to load 87 * @firmware_name: composite filename of ucode file to load
84 * @request_firmware_complete: the firmware has been obtained from user space 88 * @request_firmware_complete: the firmware has been obtained from user space
@@ -86,8 +90,10 @@
86struct iwl_drv { 90struct iwl_drv {
87 struct iwl_fw fw; 91 struct iwl_fw fw;
88 92
89 struct iwl_shared *shrd;
90 struct iwl_op_mode *op_mode; 93 struct iwl_op_mode *op_mode;
94 struct iwl_trans *trans;
95 struct device *dev;
96 const struct iwl_cfg *cfg;
91 97
92 int fw_index; /* firmware we're trying to load */ 98 int fw_index; /* firmware we're trying to load */
93 char firmware_name[25]; /* name of firmware file to load */ 99 char firmware_name[25]; /* name of firmware file to load */
@@ -110,7 +116,7 @@ struct fw_sec {
110static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) 116static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
111{ 117{
112 if (desc->v_addr) 118 if (desc->v_addr)
113 dma_free_coherent(trans(drv)->dev, desc->len, 119 dma_free_coherent(drv->trans->dev, desc->len,
114 desc->v_addr, desc->p_addr); 120 desc->v_addr, desc->p_addr);
115 desc->v_addr = NULL; 121 desc->v_addr = NULL;
116 desc->len = 0; 122 desc->len = 0;
@@ -138,7 +144,7 @@ static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
138 return -EINVAL; 144 return -EINVAL;
139 } 145 }
140 146
141 desc->v_addr = dma_alloc_coherent(trans(drv)->dev, sec->size, 147 desc->v_addr = dma_alloc_coherent(drv->trans->dev, sec->size,
142 &desc->p_addr, GFP_KERNEL); 148 &desc->p_addr, GFP_KERNEL);
143 if (!desc->v_addr) 149 if (!desc->v_addr)
144 return -ENOMEM; 150 return -ENOMEM;
@@ -156,8 +162,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
156 162
157static int iwl_request_firmware(struct iwl_drv *drv, bool first) 163static int iwl_request_firmware(struct iwl_drv *drv, bool first)
158{ 164{
159 const struct iwl_cfg *cfg = cfg(drv); 165 const char *name_pre = drv->cfg->fw_name_pre;
160 const char *name_pre = cfg->fw_name_pre;
161 char tag[8]; 166 char tag[8];
162 167
163 if (first) { 168 if (first) {
@@ -166,14 +171,14 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
166 strcpy(tag, UCODE_EXPERIMENTAL_TAG); 171 strcpy(tag, UCODE_EXPERIMENTAL_TAG);
167 } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { 172 } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
168#endif 173#endif
169 drv->fw_index = cfg->ucode_api_max; 174 drv->fw_index = drv->cfg->ucode_api_max;
170 sprintf(tag, "%d", drv->fw_index); 175 sprintf(tag, "%d", drv->fw_index);
171 } else { 176 } else {
172 drv->fw_index--; 177 drv->fw_index--;
173 sprintf(tag, "%d", drv->fw_index); 178 sprintf(tag, "%d", drv->fw_index);
174 } 179 }
175 180
176 if (drv->fw_index < cfg->ucode_api_min) { 181 if (drv->fw_index < drv->cfg->ucode_api_min) {
177 IWL_ERR(drv, "no suitable firmware found!\n"); 182 IWL_ERR(drv, "no suitable firmware found!\n");
178 return -ENOENT; 183 return -ENOENT;
179 } 184 }
@@ -186,7 +191,7 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
186 drv->firmware_name); 191 drv->firmware_name);
187 192
188 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, 193 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
189 trans(drv)->dev, 194 drv->trans->dev,
190 GFP_KERNEL, drv, iwl_ucode_callback); 195 GFP_KERNEL, drv, iwl_ucode_callback);
191} 196}
192 197
@@ -725,14 +730,13 @@ static int validate_sec_sizes(struct iwl_drv *drv,
725static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) 730static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
726{ 731{
727 struct iwl_drv *drv = context; 732 struct iwl_drv *drv = context;
728 const struct iwl_cfg *cfg = cfg(drv);
729 struct iwl_fw *fw = &drv->fw; 733 struct iwl_fw *fw = &drv->fw;
730 struct iwl_ucode_header *ucode; 734 struct iwl_ucode_header *ucode;
731 int err; 735 int err;
732 struct iwl_firmware_pieces pieces; 736 struct iwl_firmware_pieces pieces;
733 const unsigned int api_max = cfg->ucode_api_max; 737 const unsigned int api_max = drv->cfg->ucode_api_max;
734 unsigned int api_ok = cfg->ucode_api_ok; 738 unsigned int api_ok = drv->cfg->ucode_api_ok;
735 const unsigned int api_min = cfg->ucode_api_min; 739 const unsigned int api_min = drv->cfg->ucode_api_min;
736 u32 api_ver; 740 u32 api_ver;
737 int i; 741 int i;
738 742
@@ -811,7 +815,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
811 * In mvm uCode there is no difference between data and instructions 815 * In mvm uCode there is no difference between data and instructions
812 * sections. 816 * sections.
813 */ 817 */
814 if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, cfg)) 818 if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg))
815 goto try_again; 819 goto try_again;
816 820
817 /* Allocate ucode buffers for card's bus-master loading ... */ 821 /* Allocate ucode buffers for card's bus-master loading ... */
@@ -835,14 +839,14 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
835 fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; 839 fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
836 else 840 else
837 fw->init_evtlog_size = 841 fw->init_evtlog_size =
838 cfg->base_params->max_event_log_size; 842 drv->cfg->base_params->max_event_log_size;
839 fw->init_errlog_ptr = pieces.init_errlog_ptr; 843 fw->init_errlog_ptr = pieces.init_errlog_ptr;
840 fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; 844 fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
841 if (pieces.inst_evtlog_size) 845 if (pieces.inst_evtlog_size)
842 fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; 846 fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
843 else 847 else
844 fw->inst_evtlog_size = 848 fw->inst_evtlog_size =
845 cfg->base_params->max_event_log_size; 849 drv->cfg->base_params->max_event_log_size;
846 fw->inst_errlog_ptr = pieces.inst_errlog_ptr; 850 fw->inst_errlog_ptr = pieces.inst_errlog_ptr;
847 851
848 /* 852 /*
@@ -858,7 +862,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
858 release_firmware(ucode_raw); 862 release_firmware(ucode_raw);
859 complete(&drv->request_firmware_complete); 863 complete(&drv->request_firmware_complete);
860 864
861 drv->op_mode = iwl_dvm_ops.start(drv->shrd->trans, &drv->fw); 865 drv->op_mode = iwl_dvm_ops.start(drv->trans, drv->cfg, &drv->fw);
862 866
863 if (!drv->op_mode) 867 if (!drv->op_mode)
864 goto out_unbind; 868 goto out_unbind;
@@ -878,24 +882,23 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
878 release_firmware(ucode_raw); 882 release_firmware(ucode_raw);
879 out_unbind: 883 out_unbind:
880 complete(&drv->request_firmware_complete); 884 complete(&drv->request_firmware_complete);
881 device_release_driver(trans(drv)->dev); 885 device_release_driver(drv->trans->dev);
882} 886}
883 887
884int iwl_drv_start(struct iwl_shared *shrd, 888struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
885 struct iwl_trans *trans, const struct iwl_cfg *cfg) 889 const struct iwl_cfg *cfg)
886{ 890{
887 struct iwl_drv *drv; 891 struct iwl_drv *drv;
888 int ret; 892 int ret;
889 893
890 shrd->cfg = cfg;
891
892 drv = kzalloc(sizeof(*drv), GFP_KERNEL); 894 drv = kzalloc(sizeof(*drv), GFP_KERNEL);
893 if (!drv) { 895 if (!drv) {
894 dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv"); 896 dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv");
895 return -ENOMEM; 897 return NULL;
896 } 898 }
897 drv->shrd = shrd; 899 drv->trans = trans;
898 shrd->drv = drv; 900 drv->dev = trans->dev;
901 drv->cfg = cfg;
899 902
900 init_completion(&drv->request_firmware_complete); 903 init_completion(&drv->request_firmware_complete);
901 904
@@ -904,16 +907,14 @@ int iwl_drv_start(struct iwl_shared *shrd,
904 if (ret) { 907 if (ret) {
905 dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); 908 dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw");
906 kfree(drv); 909 kfree(drv);
907 shrd->drv = NULL; 910 drv = NULL;
908 } 911 }
909 912
910 return ret; 913 return drv;
911} 914}
912 915
913void iwl_drv_stop(struct iwl_shared *shrd) 916void iwl_drv_stop(struct iwl_drv *drv)
914{ 917{
915 struct iwl_drv *drv = shrd->drv;
916
917 wait_for_completion(&drv->request_firmware_complete); 918 wait_for_completion(&drv->request_firmware_complete);
918 919
919 /* op_mode can be NULL if its start failed */ 920 /* op_mode can be NULL if its start failed */
@@ -923,5 +924,91 @@ void iwl_drv_stop(struct iwl_shared *shrd)
923 iwl_dealloc_ucode(drv); 924 iwl_dealloc_ucode(drv);
924 925
925 kfree(drv); 926 kfree(drv);
926 shrd->drv = NULL;
927} 927}
928
929
930/* shared module parameters */
931struct iwl_mod_params iwlwifi_mod_params = {
932 .amsdu_size_8K = 1,
933 .restart_fw = 1,
934 .plcp_check = true,
935 .bt_coex_active = true,
936 .power_level = IWL_POWER_INDEX_1,
937 .bt_ch_announce = true,
938 .auto_agg = true,
939 /* the rest are 0 by default */
940};
941
942#ifdef CONFIG_IWLWIFI_DEBUG
943module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
944 S_IRUGO | S_IWUSR);
945MODULE_PARM_DESC(debug, "debug output mask");
946#endif
947
948module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
949MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
950module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
951MODULE_PARM_DESC(11n_disable,
952 "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
953module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
954 int, S_IRUGO);
955MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
956module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO);
957MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
958
959module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
960 int, S_IRUGO);
961MODULE_PARM_DESC(antenna_coupling,
962 "specify antenna coupling in dB (defualt: 0 dB)");
963
964module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce,
965 bool, S_IRUGO);
966MODULE_PARM_DESC(bt_ch_inhibition,
967 "Enable BT channel inhibition (default: enable)");
968
969module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO);
970MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
971
972module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO);
973MODULE_PARM_DESC(wd_disable,
974 "Disable stuck queue watchdog timer 0=system default, "
975 "1=disable, 2=enable (default: 0)");
976
977/*
978 * set bt_coex_active to true, uCode will do kill/defer
979 * every time the priority line is asserted (BT is sending signals on the
980 * priority line in the PCIx).
981 * set bt_coex_active to false, uCode will ignore the BT activity and
982 * perform the normal operation
983 *
984 * User might experience transmit issue on some platform due to WiFi/BT
985 * co-exist problem. The possible behaviors are:
986 * Able to scan and finding all the available AP
987 * Not able to associate with any AP
988 * On those platforms, WiFi communication can be restored by set
989 * "bt_coex_active" module parameter to "false"
990 *
991 * default: bt_coex_active = true (BT_COEX_ENABLE)
992 */
993module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
994 bool, S_IRUGO);
995MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
996
997module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
998MODULE_PARM_DESC(led_mode, "0=system default, "
999 "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
1000
1001module_param_named(power_save, iwlwifi_mod_params.power_save,
1002 bool, S_IRUGO);
1003MODULE_PARM_DESC(power_save,
1004 "enable WiFi power management (default: disable)");
1005
1006module_param_named(power_level, iwlwifi_mod_params.power_level,
1007 int, S_IRUGO);
1008MODULE_PARM_DESC(power_level,
1009 "default power save level (range from 1 - 5, default: 1)");
1010
1011module_param_named(auto_agg, iwlwifi_mod_params.auto_agg,
1012 bool, S_IRUGO);
1013MODULE_PARM_DESC(auto_agg,
1014 "enable agg w/o check traffic load (default: enable)");
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.h b/drivers/net/wireless/iwlwifi/iwl-drv.h
index 3b771c1d9096..2cbf137b25bf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.h
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.h
@@ -63,7 +63,12 @@
63#ifndef __iwl_drv_h__ 63#ifndef __iwl_drv_h__
64#define __iwl_drv_h__ 64#define __iwl_drv_h__
65 65
66#include "iwl-shared.h" 66/* for all modules */
67#define DRV_NAME "iwlwifi"
68#define IWLWIFI_VERSION "in-tree:"
69#define DRV_COPYRIGHT "Copyright(c) 2003-2012 Intel Corporation"
70#define DRV_AUTHOR "<ilw@linux.intel.com>"
71
67 72
68/** 73/**
69 * DOC: Driver system flows - drv component 74 * DOC: Driver system flows - drv component
@@ -90,34 +95,32 @@
90 * 8) iwl_ucode_callback starts the wifi implementation to matches the fw 95 * 8) iwl_ucode_callback starts the wifi implementation to matches the fw
91 */ 96 */
92 97
98struct iwl_drv;
99struct iwl_trans;
100struct iwl_cfg;
93/** 101/**
94 * iwl_drv_start - start the drv 102 * iwl_drv_start - start the drv
95 * 103 *
96 * @shrd: the shrd area
97 * @trans_ops: the ops of the transport 104 * @trans_ops: the ops of the transport
98 * @cfg: device specific constants / virtual functions 105 * @cfg: device specific constants / virtual functions
99 * 106 *
100 * TODO: review the parameters given to this function
101 *
102 * starts the driver: fetches the firmware. This should be called by bus 107 * starts the driver: fetches the firmware. This should be called by bus
103 * specific system flows implementations. For example, the bus specific probe 108 * specific system flows implementations. For example, the bus specific probe
104 * function should do bus related operations only, and then call to this 109 * function should do bus related operations only, and then call to this
105 * function. 110 * function. It returns the driver object or %NULL if an error occured.
106 */ 111 */
107int iwl_drv_start(struct iwl_shared *shrd, 112struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
108 struct iwl_trans *trans, const struct iwl_cfg *cfg); 113 const struct iwl_cfg *cfg);
109 114
110/** 115/**
111 * iwl_drv_stop - stop the drv 116 * iwl_drv_stop - stop the drv
112 * 117 *
113 * @shrd: the shrd area 118 * @drv:
114 *
115 * TODO: review the parameters given to this function
116 * 119 *
117 * Stop the driver. This should be called by bus specific system flows 120 * Stop the driver. This should be called by bus specific system flows
118 * implementations. For example, the bus specific remove function should first 121 * implementations. For example, the bus specific remove function should first
119 * call this function and then do the bus related operations only. 122 * call this function and then do the bus related operations only.
120 */ 123 */
121void iwl_drv_stop(struct iwl_shared *shrd); 124void iwl_drv_stop(struct iwl_drv *drv);
122 125
123#endif /* __iwl_drv_h__ */ 126#endif /* __iwl_drv_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index a004431d1a60..50c58911e718 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -68,9 +68,7 @@
68 68
69#include <net/mac80211.h> 69#include <net/mac80211.h>
70 70
71#include "iwl-commands.h"
72#include "iwl-dev.h" 71#include "iwl-dev.h"
73#include "iwl-core.h"
74#include "iwl-debug.h" 72#include "iwl-debug.h"
75#include "iwl-agn.h" 73#include "iwl-agn.h"
76#include "iwl-eeprom.h" 74#include "iwl-eeprom.h"
@@ -189,7 +187,7 @@ static void iwl_eeprom_release_semaphore(struct iwl_trans *trans)
189 187
190static int iwl_eeprom_verify_signature(struct iwl_priv *priv) 188static int iwl_eeprom_verify_signature(struct iwl_priv *priv)
191{ 189{
192 u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP) & 190 u32 gp = iwl_read32(priv->trans, CSR_EEPROM_GP) &
193 CSR_EEPROM_GP_VALID_MSK; 191 CSR_EEPROM_GP_VALID_MSK;
194 int ret = 0; 192 int ret = 0;
195 193
@@ -236,8 +234,8 @@ int iwl_eeprom_check_version(struct iwl_priv *priv)
236 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); 234 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
237 calib_ver = iwl_eeprom_calib_version(priv); 235 calib_ver = iwl_eeprom_calib_version(priv);
238 236
239 if (eeprom_ver < cfg(priv)->eeprom_ver || 237 if (eeprom_ver < priv->cfg->eeprom_ver ||
240 calib_ver < cfg(priv)->eeprom_calib_ver) 238 calib_ver < priv->cfg->eeprom_calib_ver)
241 goto err; 239 goto err;
242 240
243 IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", 241 IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n",
@@ -247,8 +245,8 @@ int iwl_eeprom_check_version(struct iwl_priv *priv)
247err: 245err:
248 IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " 246 IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x "
249 "CALIB=0x%x < 0x%x\n", 247 "CALIB=0x%x < 0x%x\n",
250 eeprom_ver, cfg(priv)->eeprom_ver, 248 eeprom_ver, priv->cfg->eeprom_ver,
251 calib_ver, cfg(priv)->eeprom_calib_ver); 249 calib_ver, priv->cfg->eeprom_calib_ver);
252 return -EINVAL; 250 return -EINVAL;
253 251
254} 252}
@@ -259,7 +257,7 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
259 257
260 priv->hw_params.sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); 258 priv->hw_params.sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP);
261 if (priv->hw_params.sku & EEPROM_SKU_CAP_11N_ENABLE && 259 if (priv->hw_params.sku & EEPROM_SKU_CAP_11N_ENABLE &&
262 !cfg(priv)->ht_params) { 260 !priv->cfg->ht_params) {
263 IWL_ERR(priv, "Invalid 11n configuration\n"); 261 IWL_ERR(priv, "Invalid 11n configuration\n");
264 return -EINVAL; 262 return -EINVAL;
265 } 263 }
@@ -277,10 +275,10 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
277 priv->hw_params.valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); 275 priv->hw_params.valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
278 276
279 /* check overrides (some devices have wrong EEPROM) */ 277 /* check overrides (some devices have wrong EEPROM) */
280 if (cfg(priv)->valid_tx_ant) 278 if (priv->cfg->valid_tx_ant)
281 priv->hw_params.valid_tx_ant = cfg(priv)->valid_tx_ant; 279 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
282 if (cfg(priv)->valid_rx_ant) 280 if (priv->cfg->valid_rx_ant)
283 priv->hw_params.valid_rx_ant = cfg(priv)->valid_rx_ant; 281 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
284 282
285 if (!priv->hw_params.valid_tx_ant || !priv->hw_params.valid_rx_ant) { 283 if (!priv->hw_params.valid_tx_ant || !priv->hw_params.valid_rx_ant) {
286 IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n", 284 IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
@@ -349,7 +347,7 @@ static u32 eeprom_indirect_address(struct iwl_priv *priv, u32 address)
349const u8 *iwl_eeprom_query_addr(struct iwl_priv *priv, size_t offset) 347const u8 *iwl_eeprom_query_addr(struct iwl_priv *priv, size_t offset)
350{ 348{
351 u32 address = eeprom_indirect_address(priv, offset); 349 u32 address = eeprom_indirect_address(priv, offset);
352 BUG_ON(address >= cfg(priv)->base_params->eeprom_size); 350 BUG_ON(address >= priv->cfg->base_params->eeprom_size);
353 return &priv->eeprom[address]; 351 return &priv->eeprom[address];
354} 352}
355 353
@@ -433,7 +431,7 @@ static int iwl_init_otp_access(struct iwl_trans *trans)
433 * CSR auto clock gate disable bit - 431 * CSR auto clock gate disable bit -
434 * this is only applicable for HW with OTP shadow RAM 432 * this is only applicable for HW with OTP shadow RAM
435 */ 433 */
436 if (cfg(trans)->base_params->shadow_ram_support) 434 if (trans->cfg->base_params->shadow_ram_support)
437 iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 435 iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
438 CSR_RESET_LINK_PWR_MGMT_DISABLED); 436 CSR_RESET_LINK_PWR_MGMT_DISABLED);
439 } 437 }
@@ -554,7 +552,7 @@ static int iwl_find_otp_image(struct iwl_trans *trans,
554 } 552 }
555 /* more in the link list, continue */ 553 /* more in the link list, continue */
556 usedblocks++; 554 usedblocks++;
557 } while (usedblocks <= cfg(trans)->base_params->max_ll_items); 555 } while (usedblocks <= trans->cfg->base_params->max_ll_items);
558 556
559 /* OTP has no valid blocks */ 557 /* OTP has no valid blocks */
560 IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n"); 558 IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n");
@@ -693,7 +691,7 @@ static void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv)
693 ((txp->delta_20_in_40 & 0xf0) >> 4), 691 ((txp->delta_20_in_40 & 0xf0) >> 4),
694 (txp->delta_20_in_40 & 0x0f)); 692 (txp->delta_20_in_40 & 0x0f));
695 693
696 max_txp_avg = iwl_get_max_txpower_avg(cfg(priv), txp_array, idx, 694 max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx,
697 &max_txp_avg_halfdbm); 695 &max_txp_avg_halfdbm);
698 696
699 /* 697 /*
@@ -719,18 +717,18 @@ static void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv)
719int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) 717int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
720{ 718{
721 __le16 *e; 719 __le16 *e;
722 u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP); 720 u32 gp = iwl_read32(priv->trans, CSR_EEPROM_GP);
723 int sz; 721 int sz;
724 int ret; 722 int ret;
725 u16 addr; 723 u16 addr;
726 u16 validblockaddr = 0; 724 u16 validblockaddr = 0;
727 u16 cache_addr = 0; 725 u16 cache_addr = 0;
728 726
729 priv->nvm_device_type = iwl_get_nvm_type(trans(priv), hw_rev); 727 priv->nvm_device_type = iwl_get_nvm_type(priv->trans, hw_rev);
730 if (priv->nvm_device_type == -ENOENT) 728 if (priv->nvm_device_type == -ENOENT)
731 return -ENOENT; 729 return -ENOENT;
732 /* allocate eeprom */ 730 /* allocate eeprom */
733 sz = cfg(priv)->base_params->eeprom_size; 731 sz = priv->cfg->base_params->eeprom_size;
734 IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); 732 IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz);
735 priv->eeprom = kzalloc(sz, GFP_KERNEL); 733 priv->eeprom = kzalloc(sz, GFP_KERNEL);
736 if (!priv->eeprom) { 734 if (!priv->eeprom) {
@@ -747,7 +745,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
747 } 745 }
748 746
749 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 747 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
750 ret = iwl_eeprom_acquire_semaphore(trans(priv)); 748 ret = iwl_eeprom_acquire_semaphore(priv->trans);
751 if (ret < 0) { 749 if (ret < 0) {
752 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); 750 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n");
753 ret = -ENOENT; 751 ret = -ENOENT;
@@ -756,22 +754,22 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
756 754
757 if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { 755 if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
758 756
759 ret = iwl_init_otp_access(trans(priv)); 757 ret = iwl_init_otp_access(priv->trans);
760 if (ret) { 758 if (ret) {
761 IWL_ERR(priv, "Failed to initialize OTP access.\n"); 759 IWL_ERR(priv, "Failed to initialize OTP access.\n");
762 ret = -ENOENT; 760 ret = -ENOENT;
763 goto done; 761 goto done;
764 } 762 }
765 iwl_write32(trans(priv), CSR_EEPROM_GP, 763 iwl_write32(priv->trans, CSR_EEPROM_GP,
766 iwl_read32(trans(priv), CSR_EEPROM_GP) & 764 iwl_read32(priv->trans, CSR_EEPROM_GP) &
767 ~CSR_EEPROM_GP_IF_OWNER_MSK); 765 ~CSR_EEPROM_GP_IF_OWNER_MSK);
768 766
769 iwl_set_bit(trans(priv), CSR_OTP_GP_REG, 767 iwl_set_bit(priv->trans, CSR_OTP_GP_REG,
770 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK | 768 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
771 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); 769 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
772 /* traversing the linked list if no shadow ram supported */ 770 /* traversing the linked list if no shadow ram supported */
773 if (!cfg(priv)->base_params->shadow_ram_support) { 771 if (!priv->cfg->base_params->shadow_ram_support) {
774 if (iwl_find_otp_image(trans(priv), &validblockaddr)) { 772 if (iwl_find_otp_image(priv->trans, &validblockaddr)) {
775 ret = -ENOENT; 773 ret = -ENOENT;
776 goto done; 774 goto done;
777 } 775 }
@@ -780,7 +778,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
780 addr += sizeof(u16)) { 778 addr += sizeof(u16)) {
781 __le16 eeprom_data; 779 __le16 eeprom_data;
782 780
783 ret = iwl_read_otp_word(trans(priv), addr, 781 ret = iwl_read_otp_word(priv->trans, addr,
784 &eeprom_data); 782 &eeprom_data);
785 if (ret) 783 if (ret)
786 goto done; 784 goto done;
@@ -792,10 +790,10 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
792 for (addr = 0; addr < sz; addr += sizeof(u16)) { 790 for (addr = 0; addr < sz; addr += sizeof(u16)) {
793 u32 r; 791 u32 r;
794 792
795 iwl_write32(trans(priv), CSR_EEPROM_REG, 793 iwl_write32(priv->trans, CSR_EEPROM_REG,
796 CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); 794 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
797 795
798 ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG, 796 ret = iwl_poll_bit(priv->trans, CSR_EEPROM_REG,
799 CSR_EEPROM_REG_READ_VALID_MSK, 797 CSR_EEPROM_REG_READ_VALID_MSK,
800 CSR_EEPROM_REG_READ_VALID_MSK, 798 CSR_EEPROM_REG_READ_VALID_MSK,
801 IWL_EEPROM_ACCESS_TIMEOUT); 799 IWL_EEPROM_ACCESS_TIMEOUT);
@@ -804,7 +802,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
804 "Time out reading EEPROM[%d]\n", addr); 802 "Time out reading EEPROM[%d]\n", addr);
805 goto done; 803 goto done;
806 } 804 }
807 r = iwl_read32(trans(priv), CSR_EEPROM_REG); 805 r = iwl_read32(priv->trans, CSR_EEPROM_REG);
808 e[addr / 2] = cpu_to_le16(r >> 16); 806 e[addr / 2] = cpu_to_le16(r >> 16);
809 } 807 }
810 } 808 }
@@ -816,7 +814,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
816 814
817 ret = 0; 815 ret = 0;
818done: 816done:
819 iwl_eeprom_release_semaphore(trans(priv)); 817 iwl_eeprom_release_semaphore(priv->trans);
820 818
821err: 819err:
822 if (ret) 820 if (ret)
@@ -1132,7 +1130,7 @@ void iwl_rf_config(struct iwl_priv *priv)
1132 1130
1133 /* write radio config values to register */ 1131 /* write radio config values to register */
1134 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) { 1132 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) {
1135 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, 1133 iwl_set_bit(priv->trans, CSR_HW_IF_CONFIG_REG,
1136 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | 1134 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
1137 EEPROM_RF_CFG_STEP_MSK(radio_cfg) | 1135 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
1138 EEPROM_RF_CFG_DASH_MSK(radio_cfg)); 1136 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
@@ -1144,7 +1142,7 @@ void iwl_rf_config(struct iwl_priv *priv)
1144 WARN_ON(1); 1142 WARN_ON(1);
1145 1143
1146 /* set CSR_HW_CONFIG_REG for uCode use */ 1144 /* set CSR_HW_CONFIG_REG for uCode use */
1147 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, 1145 iwl_set_bit(priv->trans, CSR_HW_IF_CONFIG_REG,
1148 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | 1146 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
1149 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); 1147 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
1150} 1148}
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index b3a3b1f0fdc4..64bfd947caeb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -206,59 +206,6 @@ struct iwl_eeprom_calib_hdr {
206/* 6000 regulatory - indirect access */ 206/* 6000 regulatory - indirect access */
207#define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\ 207#define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\
208 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */ 208 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */
209
210/* 5000 Specific */
211#define EEPROM_5000_TX_POWER_VERSION (4)
212#define EEPROM_5000_EEPROM_VERSION (0x11A)
213
214/* 5050 Specific */
215#define EEPROM_5050_TX_POWER_VERSION (4)
216#define EEPROM_5050_EEPROM_VERSION (0x21E)
217
218/* 1000 Specific */
219#define EEPROM_1000_TX_POWER_VERSION (4)
220#define EEPROM_1000_EEPROM_VERSION (0x15C)
221
222/* 6x00 Specific */
223#define EEPROM_6000_TX_POWER_VERSION (4)
224#define EEPROM_6000_EEPROM_VERSION (0x423)
225
226/* 6x50 Specific */
227#define EEPROM_6050_TX_POWER_VERSION (4)
228#define EEPROM_6050_EEPROM_VERSION (0x532)
229
230/* 6150 Specific */
231#define EEPROM_6150_TX_POWER_VERSION (6)
232#define EEPROM_6150_EEPROM_VERSION (0x553)
233
234/* 6x05 Specific */
235#define EEPROM_6005_TX_POWER_VERSION (6)
236#define EEPROM_6005_EEPROM_VERSION (0x709)
237
238/* 6x30 Specific */
239#define EEPROM_6030_TX_POWER_VERSION (6)
240#define EEPROM_6030_EEPROM_VERSION (0x709)
241
242/* 2x00 Specific */
243#define EEPROM_2000_TX_POWER_VERSION (6)
244#define EEPROM_2000_EEPROM_VERSION (0x805)
245
246/* 6x35 Specific */
247#define EEPROM_6035_TX_POWER_VERSION (6)
248#define EEPROM_6035_EEPROM_VERSION (0x753)
249
250
251/* OTP */
252/* lower blocks contain EEPROM image and calibration data */
253#define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */
254/* high blocks contain PAPD data */
255#define OTP_HIGH_IMAGE_SIZE_6x00 (6 * 512 * sizeof(u16)) /* 6 KB */
256#define OTP_HIGH_IMAGE_SIZE_1000 (0x200 * sizeof(u16)) /* 1024 bytes */
257#define OTP_MAX_LL_ITEMS_1000 (3) /* OTP blocks for 1000 */
258#define OTP_MAX_LL_ITEMS_6x00 (4) /* OTP blocks for 6x00 */
259#define OTP_MAX_LL_ITEMS_6x50 (7) /* OTP blocks for 6x50 */
260#define OTP_MAX_LL_ITEMS_2x00 (4) /* OTP blocks for 2x00 */
261
262/* 2.4 GHz */ 209/* 2.4 GHz */
263extern const u8 iwl_eeprom_band_1[14]; 210extern const u8 iwl_eeprom_band_1[14];
264 211
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h
index 8e36bdc1e522..2153e4cc5572 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw.h
@@ -63,6 +63,7 @@
63#ifndef __iwl_fw_h__ 63#ifndef __iwl_fw_h__
64#define __iwl_fw_h__ 64#define __iwl_fw_h__
65#include <linux/types.h> 65#include <linux/types.h>
66#include <net/mac80211.h>
66 67
67/** 68/**
68 * enum iwl_ucode_tlv_flag - ucode API flags 69 * enum iwl_ucode_tlv_flag - ucode API flags
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index 09b856768f62..abb3250164ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -30,7 +30,6 @@
30#define __iwl_io_h__ 30#define __iwl_io_h__
31 31
32#include "iwl-devtrace.h" 32#include "iwl-devtrace.h"
33#include "iwl-shared.h"
34#include "iwl-trans.h" 33#include "iwl-trans.h"
35 34
36static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val) 35static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val)
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 1993a2b7ae63..47000419f916 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -36,11 +36,10 @@
36#include <asm/unaligned.h> 36#include <asm/unaligned.h>
37 37
38#include "iwl-dev.h" 38#include "iwl-dev.h"
39#include "iwl-core.h"
40#include "iwl-agn.h" 39#include "iwl-agn.h"
41#include "iwl-io.h" 40#include "iwl-io.h"
42#include "iwl-trans.h" 41#include "iwl-trans.h"
43#include "iwl-shared.h" 42#include "iwl-modparams.h"
44 43
45/* Throughput OFF time(ms) ON time (ms) 44/* Throughput OFF time(ms) ON time (ms)
46 * >300 25 25 45 * >300 25 25
@@ -71,7 +70,7 @@ static const struct ieee80211_tpt_blink iwl_blink[] = {
71/* Set led register off */ 70/* Set led register off */
72void iwlagn_led_enable(struct iwl_priv *priv) 71void iwlagn_led_enable(struct iwl_priv *priv)
73{ 72{
74 iwl_write32(trans(priv), CSR_LED_REG, CSR_LED_REG_TRUN_ON); 73 iwl_write32(priv->trans, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
75} 74}
76 75
77/* 76/*
@@ -107,9 +106,9 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
107 }; 106 };
108 u32 reg; 107 u32 reg;
109 108
110 reg = iwl_read32(trans(priv), CSR_LED_REG); 109 reg = iwl_read32(priv->trans, CSR_LED_REG);
111 if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) 110 if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
112 iwl_write32(trans(priv), CSR_LED_REG, 111 iwl_write32(priv->trans, CSR_LED_REG,
113 reg & CSR_LED_BSM_CTRL_MSK); 112 reg & CSR_LED_BSM_CTRL_MSK);
114 113
115 return iwl_dvm_send_cmd(priv, &cmd); 114 return iwl_dvm_send_cmd(priv, &cmd);
@@ -138,11 +137,11 @@ static int iwl_led_cmd(struct iwl_priv *priv,
138 } 137 }
139 138
140 IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", 139 IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n",
141 cfg(priv)->base_params->led_compensation); 140 priv->cfg->base_params->led_compensation);
142 led_cmd.on = iwl_blink_compensation(priv, on, 141 led_cmd.on = iwl_blink_compensation(priv, on,
143 cfg(priv)->base_params->led_compensation); 142 priv->cfg->base_params->led_compensation);
144 led_cmd.off = iwl_blink_compensation(priv, off, 143 led_cmd.off = iwl_blink_compensation(priv, off,
145 cfg(priv)->base_params->led_compensation); 144 priv->cfg->base_params->led_compensation);
146 145
147 ret = iwl_send_led_cmd(priv, &led_cmd); 146 ret = iwl_send_led_cmd(priv, &led_cmd);
148 if (!ret) { 147 if (!ret) {
@@ -175,7 +174,7 @@ static int iwl_led_blink_set(struct led_classdev *led_cdev,
175 174
176void iwl_leds_init(struct iwl_priv *priv) 175void iwl_leds_init(struct iwl_priv *priv)
177{ 176{
178 int mode = iwlagn_mod_params.led_mode; 177 int mode = iwlwifi_mod_params.led_mode;
179 int ret; 178 int ret;
180 179
181 if (mode == IWL_LED_DISABLE) { 180 if (mode == IWL_LED_DISABLE) {
@@ -183,7 +182,7 @@ void iwl_leds_init(struct iwl_priv *priv)
183 return; 182 return;
184 } 183 }
185 if (mode == IWL_LED_DEFAULT) 184 if (mode == IWL_LED_DEFAULT)
186 mode = cfg(priv)->led_mode; 185 mode = priv->cfg->led_mode;
187 186
188 priv->led.name = kasprintf(GFP_KERNEL, "%s-led", 187 priv->led.name = kasprintf(GFP_KERNEL, "%s-led",
189 wiphy_name(priv->hw->wiphy)); 188 wiphy_name(priv->hw->wiphy));
@@ -207,7 +206,7 @@ void iwl_leds_init(struct iwl_priv *priv)
207 break; 206 break;
208 } 207 }
209 208
210 ret = led_classdev_register(trans(priv)->dev, &priv->led); 209 ret = led_classdev_register(priv->trans->dev, &priv->led);
211 if (ret) { 210 if (ret) {
212 kfree(priv->led.name); 211 kfree(priv->led.name);
213 return; 212 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
index 3f82ff4f3afe..b30bb0c637ca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c
+++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
@@ -44,13 +44,12 @@
44 44
45#include "iwl-eeprom.h" 45#include "iwl-eeprom.h"
46#include "iwl-dev.h" 46#include "iwl-dev.h"
47#include "iwl-core.h"
48#include "iwl-io.h" 47#include "iwl-io.h"
49#include "iwl-agn-calib.h" 48#include "iwl-agn-calib.h"
50#include "iwl-agn.h" 49#include "iwl-agn.h"
51#include "iwl-shared.h"
52#include "iwl-trans.h" 50#include "iwl-trans.h"
53#include "iwl-op-mode.h" 51#include "iwl-op-mode.h"
52#include "iwl-modparams.h"
54 53
55/***************************************************************************** 54/*****************************************************************************
56 * 55 *
@@ -147,7 +146,13 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
147 IEEE80211_HW_AMPDU_AGGREGATION | 146 IEEE80211_HW_AMPDU_AGGREGATION |
148 IEEE80211_HW_NEED_DTIM_PERIOD | 147 IEEE80211_HW_NEED_DTIM_PERIOD |
149 IEEE80211_HW_SPECTRUM_MGMT | 148 IEEE80211_HW_SPECTRUM_MGMT |
150 IEEE80211_HW_REPORTS_TX_ACK_STATUS; 149 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
150 IEEE80211_HW_QUEUE_CONTROL |
151 IEEE80211_HW_SUPPORTS_PS |
152 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
153 IEEE80211_HW_SCAN_WHILE_IDLE;
154
155 hw->offchannel_tx_hw_queue = IWL_AUX_QUEUE;
151 156
152 /* 157 /*
153 * Including the following line will crash some AP's. This 158 * Including the following line will crash some AP's. This
@@ -156,10 +161,6 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
156 hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; 161 hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
157 */ 162 */
158 163
159 hw->flags |= IEEE80211_HW_SUPPORTS_PS |
160 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
161 IEEE80211_HW_SCAN_WHILE_IDLE;
162
163 if (priv->hw_params.sku & EEPROM_SKU_CAP_11N_ENABLE) 164 if (priv->hw_params.sku & EEPROM_SKU_CAP_11N_ENABLE)
164 hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 165 hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
165 IEEE80211_HW_SUPPORTS_STATIC_SMPS; 166 IEEE80211_HW_SUPPORTS_STATIC_SMPS;
@@ -198,13 +199,13 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
198 WIPHY_FLAG_IBSS_RSN; 199 WIPHY_FLAG_IBSS_RSN;
199 200
200 if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len && 201 if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len &&
201 trans(priv)->ops->wowlan_suspend && 202 priv->trans->ops->wowlan_suspend &&
202 device_can_wakeup(trans(priv)->dev)) { 203 device_can_wakeup(priv->trans->dev)) {
203 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | 204 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
204 WIPHY_WOWLAN_DISCONNECT | 205 WIPHY_WOWLAN_DISCONNECT |
205 WIPHY_WOWLAN_EAP_IDENTITY_REQ | 206 WIPHY_WOWLAN_EAP_IDENTITY_REQ |
206 WIPHY_WOWLAN_RFKILL_RELEASE; 207 WIPHY_WOWLAN_RFKILL_RELEASE;
207 if (!iwlagn_mod_params.sw_crypto) 208 if (!iwlwifi_mod_params.sw_crypto)
208 hw->wiphy->wowlan.flags |= 209 hw->wiphy->wowlan.flags |=
209 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | 210 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
210 WIPHY_WOWLAN_GTK_REKEY_FAILURE; 211 WIPHY_WOWLAN_GTK_REKEY_FAILURE;
@@ -216,7 +217,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
216 IWLAGN_WOWLAN_MAX_PATTERN_LEN; 217 IWLAGN_WOWLAN_MAX_PATTERN_LEN;
217 } 218 }
218 219
219 if (iwlagn_mod_params.power_save) 220 if (iwlwifi_mod_params.power_save)
220 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; 221 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
221 else 222 else
222 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 223 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
@@ -225,8 +226,11 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
225 /* we create the 802.11 header and a zero-length SSID element */ 226 /* we create the 802.11 header and a zero-length SSID element */
226 hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; 227 hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2;
227 228
228 /* Default value; 4 EDCA QOS priorities */ 229 /*
229 hw->queues = 4; 230 * We don't use all queues: 4 and 9 are unused and any
231 * aggregation queue gets mapped down to the AC queue.
232 */
233 hw->queues = IWLAGN_FIRST_AMPDU_QUEUE;
230 234
231 hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; 235 hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
232 236
@@ -237,7 +241,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
237 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 241 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
238 &priv->bands[IEEE80211_BAND_5GHZ]; 242 &priv->bands[IEEE80211_BAND_5GHZ];
239 243
240 hw->wiphy->hw_version = trans(priv)->hw_id; 244 hw->wiphy->hw_version = priv->trans->hw_id;
241 245
242 iwl_leds_init(priv); 246 iwl_leds_init(priv);
243 247
@@ -356,7 +360,7 @@ void iwlagn_mac_stop(struct ieee80211_hw *hw)
356 * even if interface is down, trans->down will leave the RF 360 * even if interface is down, trans->down will leave the RF
357 * kill interrupt enabled 361 * kill interrupt enabled
358 */ 362 */
359 iwl_trans_stop_hw(trans(priv)); 363 iwl_trans_stop_hw(priv->trans, false);
360 364
361 IWL_DEBUG_MAC80211(priv, "leave\n"); 365 IWL_DEBUG_MAC80211(priv, "leave\n");
362} 366}
@@ -367,7 +371,7 @@ void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
367{ 371{
368 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 372 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
369 373
370 if (iwlagn_mod_params.sw_crypto) 374 if (iwlwifi_mod_params.sw_crypto)
371 return; 375 return;
372 376
373 IWL_DEBUG_MAC80211(priv, "enter\n"); 377 IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -412,9 +416,9 @@ int iwlagn_mac_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
412 if (ret) 416 if (ret)
413 goto error; 417 goto error;
414 418
415 device_set_wakeup_enable(trans(priv)->dev, true); 419 device_set_wakeup_enable(priv->trans->dev, true);
416 420
417 iwl_trans_wowlan_suspend(trans(priv)); 421 iwl_trans_wowlan_suspend(priv->trans);
418 422
419 goto out; 423 goto out;
420 424
@@ -441,19 +445,19 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
441 IWL_DEBUG_MAC80211(priv, "enter\n"); 445 IWL_DEBUG_MAC80211(priv, "enter\n");
442 mutex_lock(&priv->mutex); 446 mutex_lock(&priv->mutex);
443 447
444 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, 448 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
445 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 449 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
446 450
447 base = priv->device_pointers.error_event_table; 451 base = priv->device_pointers.error_event_table;
448 if (iwlagn_hw_valid_rtc_data_addr(base)) { 452 if (iwlagn_hw_valid_rtc_data_addr(base)) {
449 spin_lock_irqsave(&trans(priv)->reg_lock, flags); 453 spin_lock_irqsave(&priv->trans->reg_lock, flags);
450 ret = iwl_grab_nic_access_silent(trans(priv)); 454 ret = iwl_grab_nic_access_silent(priv->trans);
451 if (likely(ret == 0)) { 455 if (likely(ret == 0)) {
452 iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, base); 456 iwl_write32(priv->trans, HBUS_TARG_MEM_RADDR, base);
453 status = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 457 status = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
454 iwl_release_nic_access(trans(priv)); 458 iwl_release_nic_access(priv->trans);
455 } 459 }
456 spin_unlock_irqrestore(&trans(priv)->reg_lock, flags); 460 spin_unlock_irqrestore(&priv->trans->reg_lock, flags);
457 461
458#ifdef CONFIG_IWLWIFI_DEBUGFS 462#ifdef CONFIG_IWLWIFI_DEBUGFS
459 if (ret == 0) { 463 if (ret == 0) {
@@ -468,7 +472,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
468 472
469 if (priv->wowlan_sram) 473 if (priv->wowlan_sram)
470 _iwl_read_targ_mem_words( 474 _iwl_read_targ_mem_words(
471 trans(priv), 0x800000, 475 priv->trans, 0x800000,
472 priv->wowlan_sram, 476 priv->wowlan_sram,
473 img->sec[IWL_UCODE_SECTION_DATA].len / 4); 477 img->sec[IWL_UCODE_SECTION_DATA].len / 4);
474 } 478 }
@@ -480,7 +484,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
480 484
481 priv->wowlan = false; 485 priv->wowlan = false;
482 486
483 device_set_wakeup_enable(trans(priv)->dev, false); 487 device_set_wakeup_enable(priv->trans->dev, false);
484 488
485 iwlagn_prepare_restart(priv); 489 iwlagn_prepare_restart(priv);
486 490
@@ -533,7 +537,7 @@ int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
533 537
534 IWL_DEBUG_MAC80211(priv, "enter\n"); 538 IWL_DEBUG_MAC80211(priv, "enter\n");
535 539
536 if (iwlagn_mod_params.sw_crypto) { 540 if (iwlwifi_mod_params.sw_crypto) {
537 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 541 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
538 return -EOPNOTSUPP; 542 return -EOPNOTSUPP;
539 } 543 }
@@ -644,7 +648,7 @@ int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
644 648
645 switch (action) { 649 switch (action) {
646 case IEEE80211_AMPDU_RX_START: 650 case IEEE80211_AMPDU_RX_START:
647 if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) 651 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
648 break; 652 break;
649 IWL_DEBUG_HT(priv, "start Rx\n"); 653 IWL_DEBUG_HT(priv, "start Rx\n");
650 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); 654 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
@@ -654,9 +658,9 @@ int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
654 ret = iwl_sta_rx_agg_stop(priv, sta, tid); 658 ret = iwl_sta_rx_agg_stop(priv, sta, tid);
655 break; 659 break;
656 case IEEE80211_AMPDU_TX_START: 660 case IEEE80211_AMPDU_TX_START:
657 if (!trans(priv)->ops->tx_agg_setup) 661 if (!priv->trans->ops->tx_agg_setup)
658 break; 662 break;
659 if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) 663 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
660 break; 664 break;
661 IWL_DEBUG_HT(priv, "start Tx\n"); 665 IWL_DEBUG_HT(priv, "start Tx\n");
662 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 666 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
@@ -895,7 +899,6 @@ void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
895 iwl_set_rxon_ht(priv, ht_conf); 899 iwl_set_rxon_ht(priv, ht_conf);
896 iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); 900 iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
897 901
898 iwl_set_rate(priv);
899 /* 902 /*
900 * at this point, staging_rxon has the 903 * at this point, staging_rxon has the
901 * configuration for channel switch 904 * configuration for channel switch
@@ -1006,7 +1009,7 @@ void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
1006 } 1009 }
1007 } 1010 }
1008 IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); 1011 IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n");
1009 iwl_trans_wait_tx_queue_empty(trans(priv)); 1012 iwl_trans_wait_tx_queue_empty(priv->trans);
1010done: 1013done:
1011 mutex_unlock(&priv->mutex); 1014 mutex_unlock(&priv->mutex);
1012 IWL_DEBUG_MAC80211(priv, "leave\n"); 1015 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -1130,8 +1133,8 @@ void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw,
1130 IWL_DEBUG_MAC80211(priv, "enter\n"); 1133 IWL_DEBUG_MAC80211(priv, "enter\n");
1131 mutex_lock(&priv->mutex); 1134 mutex_lock(&priv->mutex);
1132 1135
1133 if (cfg(priv)->bt_params && 1136 if (priv->cfg->bt_params &&
1134 cfg(priv)->bt_params->advanced_bt_coexist) { 1137 priv->cfg->bt_params->advanced_bt_coexist) {
1135 if (rssi_event == RSSI_EVENT_LOW) 1138 if (rssi_event == RSSI_EVENT_LOW)
1136 priv->bt_enable_pspoll = true; 1139 priv->bt_enable_pspoll = true;
1137 else if (rssi_event == RSSI_EVENT_HIGH) 1140 else if (rssi_event == RSSI_EVENT_HIGH)
@@ -1220,7 +1223,7 @@ static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1220int iwl_setup_interface(struct iwl_priv *priv, struct iwl_rxon_context *ctx) 1223int iwl_setup_interface(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1221{ 1224{
1222 struct ieee80211_vif *vif = ctx->vif; 1225 struct ieee80211_vif *vif = ctx->vif;
1223 int err; 1226 int err, ac;
1224 1227
1225 lockdep_assert_held(&priv->mutex); 1228 lockdep_assert_held(&priv->mutex);
1226 1229
@@ -1240,7 +1243,7 @@ int iwl_setup_interface(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1240 return err; 1243 return err;
1241 } 1244 }
1242 1245
1243 if (cfg(priv)->bt_params && cfg(priv)->bt_params->advanced_bt_coexist && 1246 if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist &&
1244 vif->type == NL80211_IFTYPE_ADHOC) { 1247 vif->type == NL80211_IFTYPE_ADHOC) {
1245 /* 1248 /*
1246 * pretend to have high BT traffic as long as we 1249 * pretend to have high BT traffic as long as we
@@ -1250,11 +1253,20 @@ int iwl_setup_interface(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1250 priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; 1253 priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
1251 } 1254 }
1252 1255
1256 /* set up queue mappings */
1257 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
1258 vif->hw_queue[ac] = ctx->ac_to_queue[ac];
1259
1260 if (vif->type == NL80211_IFTYPE_AP)
1261 vif->cab_queue = ctx->mcast_queue;
1262 else
1263 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
1264
1253 return 0; 1265 return 0;
1254} 1266}
1255 1267
1256static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, 1268static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1257 struct ieee80211_vif *vif) 1269 struct ieee80211_vif *vif)
1258{ 1270{
1259 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 1271 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
1260 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1272 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-modparams.h
index 35bd83ce3dae..558b2e63c5cf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-shared.h
+++ b/drivers/net/wireless/iwlwifi/iwl-modparams.h
@@ -68,42 +68,16 @@
68#include <linux/gfp.h> 68#include <linux/gfp.h>
69#include <net/mac80211.h> 69#include <net/mac80211.h>
70 70
71#include "iwl-commands.h" 71extern struct iwl_mod_params iwlwifi_mod_params;
72#include "iwl-fw.h"
73#include "iwl-config.h"
74 72
75/** 73enum iwl_power_level {
76 * DOC: shared area - role and goal 74 IWL_POWER_INDEX_1,
77 * 75 IWL_POWER_INDEX_2,
78 * The shared area contains all the data exported by the upper layer to the 76 IWL_POWER_INDEX_3,
79 * other layers. Since the bus and transport layer shouldn't dereference 77 IWL_POWER_INDEX_4,
80 * iwl_priv, all the data needed by the upper layer and the transport / bus 78 IWL_POWER_INDEX_5,
81 * layer must be here. 79 IWL_POWER_NUM
82 * The shared area also holds pointer to all the other layers. This allows a 80};
83 * layer to call a function from another layer.
84 *
85 * NOTE: All the layers hold a pointer to the shared area which must be shrd.
86 * A few macros assume that (_m)->shrd points to the shared area no matter
87 * what _m is.
88 *
89 * gets notifications about enumeration, suspend, resume.
90 * For the moment, the bus layer is not a linux kernel module as itself, and
91 * the module_init function of the driver must call the bus specific
92 * registration functions. These functions are listed at the end of this file.
93 * For the moment, there is only one implementation of this interface: PCI-e.
94 * This implementation is iwl-pci.c
95 */
96
97struct iwl_priv;
98struct iwl_trans;
99struct iwl_trans_ops;
100
101#define DRV_NAME "iwlwifi"
102#define IWLWIFI_VERSION "in-tree:"
103#define DRV_COPYRIGHT "Copyright(c) 2003-2012 Intel Corporation"
104#define DRV_AUTHOR "<ilw@linux.intel.com>"
105
106extern struct iwl_mod_params iwlagn_mod_params;
107 81
108#define IWL_DISABLE_HT_ALL BIT(0) 82#define IWL_DISABLE_HT_ALL BIT(0)
109#define IWL_DISABLE_HT_TXAGG BIT(1) 83#define IWL_DISABLE_HT_TXAGG BIT(1)
@@ -147,38 +121,4 @@ struct iwl_mod_params {
147 bool auto_agg; 121 bool auto_agg;
148}; 122};
149 123
150/**
151 * struct iwl_shared - shared fields for all the layers of the driver
152 *
153 * @wowlan: are we running wowlan uCode
154 * @bus: pointer to the bus layer data
155 * @cfg: see struct iwl_cfg
156 * @priv: pointer to the upper layer data
157 * @trans: pointer to the transport layer data
158 * @nic: pointer to the nic data
159 * @lock: protect general shared data
160 * @eeprom: pointer to the eeprom/OTP image
161 */
162struct iwl_shared {
163 const struct iwl_cfg *cfg;
164 struct iwl_trans *trans;
165 void *drv;
166};
167
168/*Whatever _m is (iwl_trans, iwl_priv, these macros will work */
169#define cfg(_m) ((_m)->shrd->cfg)
170#define trans(_m) ((_m)->shrd->trans)
171
172static inline bool iwl_have_debug_level(u32 level)
173{
174 return iwlagn_mod_params.debug_level & level;
175}
176
177enum iwl_rxon_context_id {
178 IWL_RXON_CTX_BSS,
179 IWL_RXON_CTX_PAN,
180
181 NUM_IWL_RXON_CTX
182};
183
184#endif /* #__iwl_shared_h__ */ 124#endif /* #__iwl_shared_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h
index ca947aebb727..4ef742b28e08 100644
--- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h
+++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h
@@ -69,6 +69,7 @@ struct sk_buff;
69struct iwl_device_cmd; 69struct iwl_device_cmd;
70struct iwl_rx_cmd_buffer; 70struct iwl_rx_cmd_buffer;
71struct iwl_fw; 71struct iwl_fw;
72struct iwl_cfg;
72 73
73/** 74/**
74 * DOC: Operational mode - what is it ? 75 * DOC: Operational mode - what is it ?
@@ -129,6 +130,7 @@ struct iwl_fw;
129 */ 130 */
130struct iwl_op_mode_ops { 131struct iwl_op_mode_ops {
131 struct iwl_op_mode *(*start)(struct iwl_trans *trans, 132 struct iwl_op_mode *(*start)(struct iwl_trans *trans,
133 const struct iwl_cfg *cfg,
132 const struct iwl_fw *fw); 134 const struct iwl_fw *fw);
133 void (*stop)(struct iwl_op_mode *op_mode); 135 void (*stop)(struct iwl_op_mode *op_mode);
134 int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, 136 int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index 754001581340..0c8a1c2d8847 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -67,11 +67,11 @@
67#include <linux/pci.h> 67#include <linux/pci.h>
68#include <linux/pci-aspm.h> 68#include <linux/pci-aspm.h>
69 69
70#include "iwl-shared.h"
71#include "iwl-trans.h" 70#include "iwl-trans.h"
72#include "iwl-cfg.h" 71#include "iwl-cfg.h"
73#include "iwl-drv.h" 72#include "iwl-drv.h"
74#include "iwl-trans.h" 73#include "iwl-trans.h"
74#include "iwl-trans-pcie-int.h"
75 75
76#define IWL_PCI_DEVICE(dev, subdev, cfg) \ 76#define IWL_PCI_DEVICE(dev, subdev, cfg) \
77 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ 77 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
@@ -262,61 +262,46 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
262/* PCI registers */ 262/* PCI registers */
263#define PCI_CFG_RETRY_TIMEOUT 0x041 263#define PCI_CFG_RETRY_TIMEOUT 0x041
264 264
265#ifndef CONFIG_IWLWIFI_IDI
266
265static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 267static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
266{ 268{
267 const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 269 const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
268 struct iwl_shared *shrd;
269 struct iwl_trans *iwl_trans; 270 struct iwl_trans *iwl_trans;
270 int err; 271 struct iwl_trans_pcie *trans_pcie;
271
272 shrd = kzalloc(sizeof(*iwl_trans->shrd), GFP_KERNEL);
273 if (!shrd) {
274 dev_printk(KERN_ERR, &pdev->dev,
275 "Couldn't allocate iwl_shared");
276 err = -ENOMEM;
277 goto out_free_bus;
278 }
279 272
280#ifdef CONFIG_IWLWIFI_IDI 273 iwl_trans = iwl_trans_pcie_alloc(pdev, ent, cfg);
281 iwl_trans = iwl_trans_idi_alloc(shrd, pdev, ent); 274 if (iwl_trans == NULL)
282#else 275 return -ENOMEM;
283 iwl_trans = iwl_trans_pcie_alloc(shrd, pdev, ent);
284#endif
285 if (iwl_trans == NULL) {
286 err = -ENOMEM;
287 goto out_free_bus;
288 }
289 276
290 shrd->trans = iwl_trans;
291 pci_set_drvdata(pdev, iwl_trans); 277 pci_set_drvdata(pdev, iwl_trans);
292 278
293 err = iwl_drv_start(shrd, iwl_trans, cfg); 279 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans);
294 if (err) 280 trans_pcie->drv = iwl_drv_start(iwl_trans, cfg);
281 if (!trans_pcie->drv)
295 goto out_free_trans; 282 goto out_free_trans;
296 283
297 return 0; 284 return 0;
298 285
299out_free_trans: 286out_free_trans:
300 iwl_trans_free(iwl_trans); 287 iwl_trans_pcie_free(iwl_trans);
301 pci_set_drvdata(pdev, NULL); 288 pci_set_drvdata(pdev, NULL);
302out_free_bus: 289 return -EFAULT;
303 kfree(shrd);
304 return err;
305} 290}
306 291
307static void __devexit iwl_pci_remove(struct pci_dev *pdev) 292static void __devexit iwl_pci_remove(struct pci_dev *pdev)
308{ 293{
309 struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); 294 struct iwl_trans *trans = pci_get_drvdata(pdev);
310 struct iwl_shared *shrd = iwl_trans->shrd; 295 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
311 296
312 iwl_drv_stop(shrd); 297 iwl_drv_stop(trans_pcie->drv);
313 iwl_trans_free(shrd->trans); 298 iwl_trans_pcie_free(trans);
314 299
315 pci_set_drvdata(pdev, NULL); 300 pci_set_drvdata(pdev, NULL);
316
317 kfree(shrd);
318} 301}
319 302
303#endif /* CONFIG_IWLWIFI_IDI */
304
320#ifdef CONFIG_PM_SLEEP 305#ifdef CONFIG_PM_SLEEP
321 306
322static int iwl_pci_suspend(struct device *device) 307static int iwl_pci_suspend(struct device *device)
@@ -361,6 +346,15 @@ static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
361 346
362#endif 347#endif
363 348
349#ifdef CONFIG_IWLWIFI_IDI
350/*
351 * Defined externally in iwl-idi.c
352 */
353int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
354void __devexit iwl_pci_remove(struct pci_dev *pdev);
355
356#endif /* CONFIG_IWLWIFI_IDI */
357
364static struct pci_driver iwl_pci_driver = { 358static struct pci_driver iwl_pci_driver = {
365 .name = DRV_NAME, 359 .name = DRV_NAME,
366 .id_table = iwl_hw_card_ids, 360 .id_table = iwl_hw_card_ids,
diff --git a/drivers/net/wireless/iwlwifi/iwl-phy-db.c b/drivers/net/wireless/iwlwifi/iwl-phy-db.c
index 1a791af82d15..f166955340fe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-phy-db.c
+++ b/drivers/net/wireless/iwlwifi/iwl-phy-db.c
@@ -65,14 +65,13 @@
65#include <linux/string.h> 65#include <linux/string.h>
66 66
67#include "iwl-debug.h" 67#include "iwl-debug.h"
68#include "iwl-shared.h"
69#include "iwl-dev.h" 68#include "iwl-dev.h"
70 69
71#include "iwl-phy-db.h" 70#include "iwl-phy-db.h"
72 71
73#define CHANNEL_NUM_SIZE 4 /* num of channels in calib_ch size */ 72#define CHANNEL_NUM_SIZE 4 /* num of channels in calib_ch size */
74 73
75struct iwl_phy_db *iwl_phy_db_init(struct iwl_shared *shrd) 74struct iwl_phy_db *iwl_phy_db_init(struct device *dev)
76{ 75{
77 struct iwl_phy_db *phy_db = kzalloc(sizeof(struct iwl_phy_db), 76 struct iwl_phy_db *phy_db = kzalloc(sizeof(struct iwl_phy_db),
78 GFP_KERNEL); 77 GFP_KERNEL);
@@ -80,7 +79,7 @@ struct iwl_phy_db *iwl_phy_db_init(struct iwl_shared *shrd)
80 if (!phy_db) 79 if (!phy_db)
81 return phy_db; 80 return phy_db;
82 81
83 phy_db->shrd = shrd; 82 phy_db->dev = dev;
84 83
85 /* TODO: add default values of the phy db. */ 84 /* TODO: add default values of the phy db. */
86 return phy_db; 85 return phy_db;
diff --git a/drivers/net/wireless/iwlwifi/iwl-phy-db.h b/drivers/net/wireless/iwlwifi/iwl-phy-db.h
index 5e86305de66a..c34c6a9303ab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-phy-db.h
+++ b/drivers/net/wireless/iwlwifi/iwl-phy-db.h
@@ -96,7 +96,7 @@ struct iwl_phy_db {
96 u32 channel_size; 96 u32 channel_size;
97 97
98 /* for an access to the logger */ 98 /* for an access to the logger */
99 const struct iwl_shared *shrd; 99 struct device *dev;
100}; 100};
101 101
102enum iwl_phy_db_section_type { 102enum iwl_phy_db_section_type {
@@ -114,7 +114,7 @@ struct iwl_phy_db_chg_txp {
114 __le16 max_channel_idx; 114 __le16 max_channel_idx;
115} __packed; 115} __packed;
116 116
117struct iwl_phy_db *iwl_phy_db_init(struct iwl_shared *shrd); 117struct iwl_phy_db *iwl_phy_db_init(struct device *dev);
118 118
119void iwl_phy_db_free(struct iwl_phy_db *phy_db); 119void iwl_phy_db_free(struct iwl_phy_db *phy_db);
120 120
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 174a0f737214..8352265dbc4b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -37,13 +37,12 @@
37#include "iwl-eeprom.h" 37#include "iwl-eeprom.h"
38#include "iwl-dev.h" 38#include "iwl-dev.h"
39#include "iwl-agn.h" 39#include "iwl-agn.h"
40#include "iwl-core.h"
41#include "iwl-io.h" 40#include "iwl-io.h"
42#include "iwl-commands.h" 41#include "iwl-commands.h"
43#include "iwl-debug.h" 42#include "iwl-debug.h"
44#include "iwl-power.h" 43#include "iwl-power.h"
45#include "iwl-trans.h" 44#include "iwl-trans.h"
46#include "iwl-shared.h" 45#include "iwl-modparams.h"
47 46
48/* 47/*
49 * Setting power level allows the card to go to sleep when not busy. 48 * Setting power level allows the card to go to sleep when not busy.
@@ -167,7 +166,7 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
167 u8 skip; 166 u8 skip;
168 u32 slp_itrvl; 167 u32 slp_itrvl;
169 168
170 if (cfg(priv)->adv_pm) { 169 if (priv->cfg->adv_pm) {
171 table = apm_range_2; 170 table = apm_range_2;
172 if (period <= IWL_DTIM_RANGE_1_MAX) 171 if (period <= IWL_DTIM_RANGE_1_MAX)
173 table = apm_range_1; 172 table = apm_range_1;
@@ -215,13 +214,13 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
215 else 214 else
216 cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; 215 cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
217 216
218 if (cfg(priv)->base_params->shadow_reg_enable) 217 if (priv->cfg->base_params->shadow_reg_enable)
219 cmd->flags |= IWL_POWER_SHADOW_REG_ENA; 218 cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
220 else 219 else
221 cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA; 220 cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
222 221
223 if (iwl_advanced_bt_coexist(priv)) { 222 if (iwl_advanced_bt_coexist(priv)) {
224 if (!cfg(priv)->bt_params->bt_sco_disable) 223 if (!priv->cfg->bt_params->bt_sco_disable)
225 cmd->flags |= IWL_POWER_BT_SCO_ENA; 224 cmd->flags |= IWL_POWER_BT_SCO_ENA;
226 else 225 else
227 cmd->flags &= ~IWL_POWER_BT_SCO_ENA; 226 cmd->flags &= ~IWL_POWER_BT_SCO_ENA;
@@ -295,7 +294,7 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
295 294
296 if (priv->wowlan) 295 if (priv->wowlan)
297 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper); 296 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
298 else if (!cfg(priv)->base_params->no_idle_support && 297 else if (!priv->cfg->base_params->no_idle_support &&
299 priv->hw->conf.flags & IEEE80211_CONF_IDLE) 298 priv->hw->conf.flags & IEEE80211_CONF_IDLE)
300 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20); 299 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
301 else if (iwl_tt_is_low_power_state(priv)) { 300 else if (iwl_tt_is_low_power_state(priv)) {
@@ -309,10 +308,10 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
309 priv->power_data.debug_sleep_level_override, 308 priv->power_data.debug_sleep_level_override,
310 dtimper); 309 dtimper);
311 else { 310 else {
312 if (iwlagn_mod_params.power_level > IWL_POWER_INDEX_1 && 311 if (iwlwifi_mod_params.power_level > IWL_POWER_INDEX_1 &&
313 iwlagn_mod_params.power_level <= IWL_POWER_INDEX_5) 312 iwlwifi_mod_params.power_level <= IWL_POWER_INDEX_5)
314 iwl_static_sleep_cmd(priv, cmd, 313 iwl_static_sleep_cmd(priv, cmd,
315 iwlagn_mod_params.power_level, dtimper); 314 iwlwifi_mod_params.power_level, dtimper);
316 else 315 else
317 iwl_static_sleep_cmd(priv, cmd, 316 iwl_static_sleep_cmd(priv, cmd,
318 IWL_POWER_INDEX_1, dtimper); 317 IWL_POWER_INDEX_1, dtimper);
@@ -378,7 +377,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
378/* initialize to default */ 377/* initialize to default */
379void iwl_power_initialize(struct iwl_priv *priv) 378void iwl_power_initialize(struct iwl_priv *priv)
380{ 379{
381 priv->power_data.bus_pm = trans(priv)->pm_support; 380 priv->power_data.bus_pm = priv->trans->pm_support;
382 381
383 priv->power_data.debug_sleep_level_override = -1; 382 priv->power_data.debug_sleep_level_override = -1;
384 383
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 07a19fce5fdc..21afc92efacb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -30,15 +30,6 @@
30 30
31#include "iwl-commands.h" 31#include "iwl-commands.h"
32 32
33enum iwl_power_level {
34 IWL_POWER_INDEX_1,
35 IWL_POWER_INDEX_2,
36 IWL_POWER_INDEX_3,
37 IWL_POWER_INDEX_4,
38 IWL_POWER_INDEX_5,
39 IWL_POWER_NUM
40};
41
42struct iwl_power_mgr { 33struct iwl_power_mgr {
43 struct iwl_powertable_cmd sleep_cmd; 34 struct iwl_powertable_cmd sleep_cmd;
44 struct iwl_powertable_cmd sleep_cmd_next; 35 struct iwl_powertable_cmd sleep_cmd_next;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 490a60d8ad7d..a8437a6bc18e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -32,7 +32,6 @@
32 32
33#include "iwl-eeprom.h" 33#include "iwl-eeprom.h"
34#include "iwl-dev.h" 34#include "iwl-dev.h"
35#include "iwl-core.h"
36#include "iwl-io.h" 35#include "iwl-io.h"
37#include "iwl-agn.h" 36#include "iwl-agn.h"
38#include "iwl-trans.h" 37#include "iwl-trans.h"
@@ -791,8 +790,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
791 * Internal scans are passive, so we can indiscriminately set 790 * Internal scans are passive, so we can indiscriminately set
792 * the BT ignore flag on 2.4 GHz since it applies to TX only. 791 * the BT ignore flag on 2.4 GHz since it applies to TX only.
793 */ 792 */
794 if (cfg(priv)->bt_params && 793 if (priv->cfg->bt_params &&
795 cfg(priv)->bt_params->advanced_bt_coexist) 794 priv->cfg->bt_params->advanced_bt_coexist)
796 scan->tx_cmd.tx_flags |= TX_CMD_FLG_IGNORE_BT; 795 scan->tx_cmd.tx_flags |= TX_CMD_FLG_IGNORE_BT;
797 break; 796 break;
798 case IEEE80211_BAND_5GHZ: 797 case IEEE80211_BAND_5GHZ:
@@ -834,8 +833,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
834 band = priv->scan_band; 833 band = priv->scan_band;
835 834
836 if (band == IEEE80211_BAND_2GHZ && 835 if (band == IEEE80211_BAND_2GHZ &&
837 cfg(priv)->bt_params && 836 priv->cfg->bt_params &&
838 cfg(priv)->bt_params->advanced_bt_coexist) { 837 priv->cfg->bt_params->advanced_bt_coexist) {
839 /* transmit 2.4 GHz probes only on first antenna */ 838 /* transmit 2.4 GHz probes only on first antenna */
840 scan_tx_antennas = first_antenna(scan_tx_antennas); 839 scan_tx_antennas = first_antenna(scan_tx_antennas);
841 } 840 }
@@ -863,8 +862,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
863 862
864 rx_ant = first_antenna(active_chains); 863 rx_ant = first_antenna(active_chains);
865 } 864 }
866 if (cfg(priv)->bt_params && 865 if (priv->cfg->bt_params &&
867 cfg(priv)->bt_params->advanced_bt_coexist && 866 priv->cfg->bt_params->advanced_bt_coexist &&
868 priv->bt_full_concurrent) { 867 priv->bt_full_concurrent) {
869 /* operated as 1x1 in full concurrency mode */ 868 /* operated as 1x1 in full concurrency mode */
870 rx_ant = first_antenna(rx_ant); 869 rx_ant = first_antenna(rx_ant);
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c
index bb275098bb10..060aac3e22f1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-testmode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c
@@ -71,7 +71,6 @@
71#include <net/netlink.h> 71#include <net/netlink.h>
72 72
73#include "iwl-dev.h" 73#include "iwl-dev.h"
74#include "iwl-core.h"
75#include "iwl-debug.h" 74#include "iwl-debug.h"
76#include "iwl-io.h" 75#include "iwl-io.h"
77#include "iwl-agn.h" 76#include "iwl-agn.h"
@@ -219,7 +218,7 @@ static void iwl_trace_cleanup(struct iwl_priv *priv)
219 if (priv->testmode_trace.trace_enabled) { 218 if (priv->testmode_trace.trace_enabled) {
220 if (priv->testmode_trace.cpu_addr && 219 if (priv->testmode_trace.cpu_addr &&
221 priv->testmode_trace.dma_addr) 220 priv->testmode_trace.dma_addr)
222 dma_free_coherent(trans(priv)->dev, 221 dma_free_coherent(priv->trans->dev,
223 priv->testmode_trace.total_size, 222 priv->testmode_trace.total_size,
224 priv->testmode_trace.cpu_addr, 223 priv->testmode_trace.cpu_addr,
225 priv->testmode_trace.dma_addr); 224 priv->testmode_trace.dma_addr);
@@ -373,7 +372,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
373 372
374 switch (cmd) { 373 switch (cmd) {
375 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: 374 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
376 val32 = iwl_read_direct32(trans(priv), ofs); 375 val32 = iwl_read_direct32(priv->trans, ofs);
377 IWL_INFO(priv, "32bit value to read 0x%x\n", val32); 376 IWL_INFO(priv, "32bit value to read 0x%x\n", val32);
378 377
379 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 378 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
@@ -394,7 +393,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
394 } else { 393 } else {
395 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); 394 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
396 IWL_INFO(priv, "32bit value to write 0x%x\n", val32); 395 IWL_INFO(priv, "32bit value to write 0x%x\n", val32);
397 iwl_write_direct32(trans(priv), ofs, val32); 396 iwl_write_direct32(priv->trans, ofs, val32);
398 } 397 }
399 break; 398 break;
400 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: 399 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
@@ -404,7 +403,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
404 } else { 403 } else {
405 val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); 404 val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]);
406 IWL_INFO(priv, "8bit value to write 0x%x\n", val8); 405 IWL_INFO(priv, "8bit value to write 0x%x\n", val8);
407 iwl_write8(trans(priv), ofs, val8); 406 iwl_write8(priv->trans, ofs, val8);
408 } 407 }
409 break; 408 break;
410 default: 409 default:
@@ -467,7 +466,7 @@ cfg_init_calib_error:
467static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) 466static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
468{ 467{
469 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 468 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
470 struct iwl_trans *trans = trans(priv); 469 struct iwl_trans *trans = priv->trans;
471 struct sk_buff *skb; 470 struct sk_buff *skb;
472 unsigned char *rsp_data_ptr = NULL; 471 unsigned char *rsp_data_ptr = NULL;
473 int status = 0, rsp_data_len = 0; 472 int status = 0, rsp_data_len = 0;
@@ -476,8 +475,8 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
476 475
477 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 476 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
478 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: 477 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
479 rsp_data_ptr = (unsigned char *)cfg(priv)->name; 478 rsp_data_ptr = (unsigned char *)priv->cfg->name;
480 rsp_data_len = strlen(cfg(priv)->name); 479 rsp_data_len = strlen(priv->cfg->name);
481 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 480 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
482 rsp_data_len + 20); 481 rsp_data_len + 20);
483 if (!skb) { 482 if (!skb) {
@@ -538,7 +537,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
538 case IWL_TM_CMD_APP2DEV_GET_EEPROM: 537 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
539 if (priv->eeprom) { 538 if (priv->eeprom) {
540 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 539 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
541 cfg(priv)->base_params->eeprom_size + 20); 540 priv->cfg->base_params->eeprom_size + 20);
542 if (!skb) { 541 if (!skb) {
543 IWL_ERR(priv, "Memory allocation fail\n"); 542 IWL_ERR(priv, "Memory allocation fail\n");
544 return -ENOMEM; 543 return -ENOMEM;
@@ -546,7 +545,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
546 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND, 545 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
547 IWL_TM_CMD_DEV2APP_EEPROM_RSP) || 546 IWL_TM_CMD_DEV2APP_EEPROM_RSP) ||
548 nla_put(skb, IWL_TM_ATTR_EEPROM, 547 nla_put(skb, IWL_TM_ATTR_EEPROM,
549 cfg(priv)->base_params->eeprom_size, 548 priv->cfg->base_params->eeprom_size,
550 priv->eeprom)) 549 priv->eeprom))
551 goto nla_put_failure; 550 goto nla_put_failure;
552 status = cfg80211_testmode_reply(skb); 551 status = cfg80211_testmode_reply(skb);
@@ -583,7 +582,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
583 break; 582 break;
584 583
585 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: 584 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
586 devid = trans(priv)->hw_id; 585 devid = priv->trans->hw_id;
587 IWL_INFO(priv, "hw version: 0x%x\n", devid); 586 IWL_INFO(priv, "hw version: 0x%x\n", devid);
588 587
589 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 588 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
@@ -650,7 +649,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
650 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 649 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
651 struct sk_buff *skb; 650 struct sk_buff *skb;
652 int status = 0; 651 int status = 0;
653 struct device *dev = trans(priv)->dev; 652 struct device *dev = priv->trans->dev;
654 653
655 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 654 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
656 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: 655 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
@@ -792,7 +791,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
792 791
793static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size) 792static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size)
794{ 793{
795 struct iwl_trans *trans = trans(priv); 794 struct iwl_trans *trans = priv->trans;
796 unsigned long flags; 795 unsigned long flags;
797 int i; 796 int i;
798 797
@@ -832,7 +831,7 @@ static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size)
832static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, 831static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr,
833 u32 size, unsigned char *buf) 832 u32 size, unsigned char *buf)
834{ 833{
835 struct iwl_trans *trans = trans(priv); 834 struct iwl_trans *trans = priv->trans;
836 u32 val, i; 835 u32 val, i;
837 unsigned long flags; 836 unsigned long flags;
838 837
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
index 70bdd0e2df38..6213c05a4b52 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
@@ -38,7 +38,6 @@
38 38
39#include "iwl-fh.h" 39#include "iwl-fh.h"
40#include "iwl-csr.h" 40#include "iwl-csr.h"
41#include "iwl-shared.h"
42#include "iwl-trans.h" 41#include "iwl-trans.h"
43#include "iwl-debug.h" 42#include "iwl-debug.h"
44#include "iwl-io.h" 43#include "iwl-io.h"
@@ -180,30 +179,33 @@ struct iwl_queue {
180 * space less than this */ 179 * space less than this */
181}; 180};
182 181
182#define TFD_TX_CMD_SLOTS 256
183#define TFD_CMD_SLOTS 32
184
185struct iwl_pcie_tx_queue_entry {
186 struct iwl_device_cmd *cmd;
187 struct sk_buff *skb;
188 struct iwl_cmd_meta meta;
189};
190
183/** 191/**
184 * struct iwl_tx_queue - Tx Queue for DMA 192 * struct iwl_tx_queue - Tx Queue for DMA
185 * @q: generic Rx/Tx queue descriptor 193 * @q: generic Rx/Tx queue descriptor
186 * @bd: base of circular buffer of TFDs 194 * @tfds: transmit frame descriptors (DMA memory)
187 * @cmd: array of command/TX buffer pointers 195 * @entries: transmit entries (driver state)
188 * @meta: array of meta data for each command/tx buffer 196 * @lock: queue lock
189 * @dma_addr_cmd: physical address of cmd/tx buffer array 197 * @stuck_timer: timer that fires if queue gets stuck
190 * @txb: array of per-TFD driver data 198 * @trans_pcie: pointer back to transport (for timer)
191 * lock: queue lock
192 * @time_stamp: time (in jiffies) of last read_ptr change
193 * @need_update: indicates need to update read/write index 199 * @need_update: indicates need to update read/write index
200 * @active: stores if queue is active
194 * 201 *
195 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame 202 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
196 * descriptors) and required locking structures. 203 * descriptors) and required locking structures.
197 */ 204 */
198#define TFD_TX_CMD_SLOTS 256
199#define TFD_CMD_SLOTS 32
200
201struct iwl_tx_queue { 205struct iwl_tx_queue {
202 struct iwl_queue q; 206 struct iwl_queue q;
203 struct iwl_tfd *tfds; 207 struct iwl_tfd *tfds;
204 struct iwl_device_cmd **cmd; 208 struct iwl_pcie_tx_queue_entry *entries;
205 struct iwl_cmd_meta *meta;
206 struct sk_buff **skbs;
207 spinlock_t lock; 209 spinlock_t lock;
208 struct timer_list stuck_timer; 210 struct timer_list stuck_timer;
209 struct iwl_trans_pcie *trans_pcie; 211 struct iwl_trans_pcie *trans_pcie;
@@ -215,6 +217,7 @@ struct iwl_tx_queue {
215 * struct iwl_trans_pcie - PCIe transport specific data 217 * struct iwl_trans_pcie - PCIe transport specific data
216 * @rxq: all the RX queue data 218 * @rxq: all the RX queue data
217 * @rx_replenish: work that will be called when buffers need to be allocated 219 * @rx_replenish: work that will be called when buffers need to be allocated
220 * @drv - pointer to iwl_drv
218 * @trans: pointer to the generic transport area 221 * @trans: pointer to the generic transport area
219 * @irq - the irq number for the device 222 * @irq - the irq number for the device
220 * @irq_requested: true when the irq has been requested 223 * @irq_requested: true when the irq has been requested
@@ -235,6 +238,7 @@ struct iwl_trans_pcie {
235 struct iwl_rx_queue rxq; 238 struct iwl_rx_queue rxq;
236 struct work_struct rx_replenish; 239 struct work_struct rx_replenish;
237 struct iwl_trans *trans; 240 struct iwl_trans *trans;
241 struct iwl_drv *drv;
238 242
239 /* INT ICT Table */ 243 /* INT ICT Table */
240 __le32 *ict_tbl; 244 __le32 *ict_tbl;
@@ -297,6 +301,11 @@ iwl_trans_pcie_get_trans(struct iwl_trans_pcie *trans_pcie)
297 trans_specific); 301 trans_specific);
298} 302}
299 303
304struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
305 const struct pci_device_id *ent,
306 const struct iwl_cfg *cfg);
307void iwl_trans_pcie_free(struct iwl_trans *trans);
308
300/***************************************************** 309/*****************************************************
301* RX 310* RX
302******************************************************/ 311******************************************************/
@@ -426,4 +435,10 @@ trans_pcie_get_cmd_string(struct iwl_trans_pcie *trans_pcie, u8 cmd)
426 return trans_pcie->command_names[cmd]; 435 return trans_pcie->command_names[cmd];
427} 436}
428 437
438static inline bool iwl_is_rfkill_set(struct iwl_trans *trans)
439{
440 return !(iwl_read32(trans, CSR_GP_CNTRL) &
441 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
442}
443
429#endif /* __iwl_trans_int_pcie_h__ */ 444#endif /* __iwl_trans_int_pcie_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
index de78fb8dca9f..d2239aad7f11 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
@@ -140,7 +140,7 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
140 if (q->need_update == 0) 140 if (q->need_update == 0)
141 goto exit_unlock; 141 goto exit_unlock;
142 142
143 if (cfg(trans)->base_params->shadow_reg_enable) { 143 if (trans->cfg->base_params->shadow_reg_enable) {
144 /* shadow register enabled */ 144 /* shadow register enabled */
145 /* Device expects a multiple of 8 */ 145 /* Device expects a multiple of 8 */
146 q->write_actual = (q->write & ~0x7); 146 q->write_actual = (q->write & ~0x7);
@@ -425,7 +425,7 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans,
425 cmd_index = get_cmd_index(&txq->q, index); 425 cmd_index = get_cmd_index(&txq->q, index);
426 426
427 if (reclaim) 427 if (reclaim)
428 cmd = txq->cmd[cmd_index]; 428 cmd = txq->entries[cmd_index].cmd;
429 else 429 else
430 cmd = NULL; 430 cmd = NULL;
431 431
@@ -543,7 +543,7 @@ static void iwl_rx_handle(struct iwl_trans *trans)
543static void iwl_irq_handle_error(struct iwl_trans *trans) 543static void iwl_irq_handle_error(struct iwl_trans *trans)
544{ 544{
545 /* W/A for WiFi/WiMAX coex and WiMAX own the RF */ 545 /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
546 if (cfg(trans)->internal_wimax_coex && 546 if (trans->cfg->internal_wimax_coex &&
547 (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) & 547 (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) &
548 APMS_CLK_VAL_MRB_FUNC_MODE) || 548 APMS_CLK_VAL_MRB_FUNC_MODE) ||
549 (iwl_read_prph(trans, APMG_PS_CTRL_REG) & 549 (iwl_read_prph(trans, APMG_PS_CTRL_REG) &
@@ -648,8 +648,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
648 if (inta & CSR_INT_BIT_RF_KILL) { 648 if (inta & CSR_INT_BIT_RF_KILL) {
649 bool hw_rfkill; 649 bool hw_rfkill;
650 650
651 hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & 651 hw_rfkill = iwl_is_rfkill_set(trans);
652 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
653 IWL_WARN(trans, "RF_KILL bit toggled to %s.\n", 652 IWL_WARN(trans, "RF_KILL bit toggled to %s.\n",
654 hw_rfkill ? "disable radio" : "enable radio"); 653 hw_rfkill ? "disable radio" : "enable radio");
655 654
@@ -680,7 +679,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
680 if (inta & CSR_INT_BIT_WAKEUP) { 679 if (inta & CSR_INT_BIT_WAKEUP) {
681 IWL_DEBUG_ISR(trans, "Wakeup interrupt\n"); 680 IWL_DEBUG_ISR(trans, "Wakeup interrupt\n");
682 iwl_rx_queue_update_write_ptr(trans, &trans_pcie->rxq); 681 iwl_rx_queue_update_write_ptr(trans, &trans_pcie->rxq);
683 for (i = 0; i < cfg(trans)->base_params->num_of_queues; i++) 682 for (i = 0; i < trans->cfg->base_params->num_of_queues; i++)
684 iwl_txq_update_write_ptr(trans, 683 iwl_txq_update_write_ptr(trans,
685 &trans_pcie->txq[i]); 684 &trans_pcie->txq[i]);
686 685
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
index 918874067bd3..21a8a672fbb2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
@@ -37,6 +37,8 @@
37#include "iwl-agn-hw.h" 37#include "iwl-agn-hw.h"
38#include "iwl-op-mode.h" 38#include "iwl-op-mode.h"
39#include "iwl-trans-pcie-int.h" 39#include "iwl-trans-pcie-int.h"
40/* FIXME: need to abstract out TX command (once we know what it looks like) */
41#include "iwl-commands.h"
40 42
41#define IWL_TX_CRC_SIZE 4 43#define IWL_TX_CRC_SIZE 4
42#define IWL_TX_DELIMITER_SIZE 4 44#define IWL_TX_DELIMITER_SIZE 4
@@ -58,7 +60,7 @@ void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_trans *trans,
58 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 60 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
59 __le16 bc_ent; 61 __le16 bc_ent;
60 struct iwl_tx_cmd *tx_cmd = 62 struct iwl_tx_cmd *tx_cmd =
61 (struct iwl_tx_cmd *) txq->cmd[txq->q.write_ptr]->payload; 63 (void *) txq->entries[txq->q.write_ptr].cmd->payload;
62 64
63 scd_bc_tbl = trans_pcie->scd_bc_tbls.addr; 65 scd_bc_tbl = trans_pcie->scd_bc_tbls.addr;
64 66
@@ -99,7 +101,7 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq)
99 if (txq->need_update == 0) 101 if (txq->need_update == 0)
100 return; 102 return;
101 103
102 if (cfg(trans)->base_params->shadow_reg_enable) { 104 if (trans->cfg->base_params->shadow_reg_enable) {
103 /* shadow register enabled */ 105 /* shadow register enabled */
104 iwl_write32(trans, HBUS_TARG_WRPTR, 106 iwl_write32(trans, HBUS_TARG_WRPTR,
105 txq->q.write_ptr | (txq_id << 8)); 107 txq->q.write_ptr | (txq_id << 8));
@@ -221,13 +223,14 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq,
221 223
222 lockdep_assert_held(&txq->lock); 224 lockdep_assert_held(&txq->lock);
223 225
224 iwlagn_unmap_tfd(trans, &txq->meta[index], &tfd_tmp[index], dma_dir); 226 iwlagn_unmap_tfd(trans, &txq->entries[index].meta,
227 &tfd_tmp[index], dma_dir);
225 228
226 /* free SKB */ 229 /* free SKB */
227 if (txq->skbs) { 230 if (txq->entries) {
228 struct sk_buff *skb; 231 struct sk_buff *skb;
229 232
230 skb = txq->skbs[index]; 233 skb = txq->entries[index].skb;
231 234
232 /* Can be called from irqs-disabled context 235 /* Can be called from irqs-disabled context
233 * If skb is not NULL, it means that the whole queue is being 236 * If skb is not NULL, it means that the whole queue is being
@@ -235,7 +238,7 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq,
235 */ 238 */
236 if (skb) { 239 if (skb) {
237 iwl_op_mode_free_skb(trans->op_mode, skb); 240 iwl_op_mode_free_skb(trans->op_mode, skb);
238 txq->skbs[index] = NULL; 241 txq->entries[index].skb = NULL;
239 } 242 }
240 } 243 }
241} 244}
@@ -358,7 +361,7 @@ static void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_trans *trans,
358 u8 sta_id = 0; 361 u8 sta_id = 0;
359 __le16 bc_ent; 362 __le16 bc_ent;
360 struct iwl_tx_cmd *tx_cmd = 363 struct iwl_tx_cmd *tx_cmd =
361 (struct iwl_tx_cmd *) txq->cmd[txq->q.read_ptr]->payload; 364 (void *)txq->entries[txq->q.read_ptr].cmd->payload;
362 365
363 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); 366 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
364 367
@@ -578,8 +581,8 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
578 } 581 }
579 582
580 idx = get_cmd_index(q, q->write_ptr); 583 idx = get_cmd_index(q, q->write_ptr);
581 out_cmd = txq->cmd[idx]; 584 out_cmd = txq->entries[idx].cmd;
582 out_meta = &txq->meta[idx]; 585 out_meta = &txq->entries[idx].meta;
583 586
584 memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ 587 memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */
585 if (cmd->flags & CMD_WANT_SKB) 588 if (cmd->flags & CMD_WANT_SKB)
@@ -772,8 +775,8 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb,
772 spin_lock(&txq->lock); 775 spin_lock(&txq->lock);
773 776
774 cmd_index = get_cmd_index(&txq->q, index); 777 cmd_index = get_cmd_index(&txq->q, index);
775 cmd = txq->cmd[cmd_index]; 778 cmd = txq->entries[cmd_index].cmd;
776 meta = &txq->meta[cmd_index]; 779 meta = &txq->entries[cmd_index].meta;
777 780
778 iwlagn_unmap_tfd(trans, meta, &txq->tfds[index], 781 iwlagn_unmap_tfd(trans, meta, &txq->tfds[index],
779 DMA_BIDIRECTIONAL); 782 DMA_BIDIRECTIONAL);
@@ -905,8 +908,8 @@ cancel:
905 * in later, it will possibly set an invalid 908 * in later, it will possibly set an invalid
906 * address (cmd->meta.source). 909 * address (cmd->meta.source).
907 */ 910 */
908 trans_pcie->txq[trans_pcie->cmd_queue].meta[cmd_idx].flags &= 911 trans_pcie->txq[trans_pcie->cmd_queue].
909 ~CMD_WANT_SKB; 912 entries[cmd_idx].meta.flags &= ~CMD_WANT_SKB;
910 } 913 }
911 914
912 if (cmd->resp_pkt) { 915 if (cmd->resp_pkt) {
@@ -961,12 +964,12 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index,
961 q->read_ptr != index; 964 q->read_ptr != index;
962 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 965 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
963 966
964 if (WARN_ON_ONCE(txq->skbs[txq->q.read_ptr] == NULL)) 967 if (WARN_ON_ONCE(txq->entries[txq->q.read_ptr].skb == NULL))
965 continue; 968 continue;
966 969
967 __skb_queue_tail(skbs, txq->skbs[txq->q.read_ptr]); 970 __skb_queue_tail(skbs, txq->entries[txq->q.read_ptr].skb);
968 971
969 txq->skbs[txq->q.read_ptr] = NULL; 972 txq->entries[txq->q.read_ptr].skb = NULL;
970 973
971 iwlagn_txq_inval_byte_cnt_tbl(trans, txq); 974 iwlagn_txq_inval_byte_cnt_tbl(trans, txq);
972 975
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 14a32c420fd4..63557bb85cda 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -68,18 +68,20 @@
68#include <linux/bitops.h> 68#include <linux/bitops.h>
69#include <linux/gfp.h> 69#include <linux/gfp.h>
70 70
71#include "iwl-drv.h"
71#include "iwl-trans.h" 72#include "iwl-trans.h"
72#include "iwl-trans-pcie-int.h" 73#include "iwl-trans-pcie-int.h"
73#include "iwl-csr.h" 74#include "iwl-csr.h"
74#include "iwl-prph.h" 75#include "iwl-prph.h"
75#include "iwl-shared.h"
76#include "iwl-eeprom.h" 76#include "iwl-eeprom.h"
77#include "iwl-agn-hw.h" 77#include "iwl-agn-hw.h"
78/* FIXME: need to abstract out TX command (once we know what it looks like) */
79#include "iwl-commands.h"
78 80
79#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) 81#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
80 82
81#define SCD_QUEUECHAIN_SEL_ALL(trans, trans_pcie) \ 83#define SCD_QUEUECHAIN_SEL_ALL(trans, trans_pcie) \
82 (((1<<cfg(trans)->base_params->num_of_queues) - 1) &\ 84 (((1<<trans->cfg->base_params->num_of_queues) - 1) &\
83 (~(1<<(trans_pcie)->cmd_queue))) 85 (~(1<<(trans_pcie)->cmd_queue)))
84 86
85static int iwl_trans_rx_alloc(struct iwl_trans *trans) 87static int iwl_trans_rx_alloc(struct iwl_trans *trans)
@@ -334,7 +336,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans,
334 int i; 336 int i;
335 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 337 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
336 338
337 if (WARN_ON(txq->meta || txq->cmd || txq->skbs || txq->tfds)) 339 if (WARN_ON(txq->entries || txq->tfds))
338 return -EINVAL; 340 return -EINVAL;
339 341
340 setup_timer(&txq->stuck_timer, iwl_trans_pcie_queue_stuck_timer, 342 setup_timer(&txq->stuck_timer, iwl_trans_pcie_queue_stuck_timer,
@@ -343,35 +345,22 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans,
343 345
344 txq->q.n_window = slots_num; 346 txq->q.n_window = slots_num;
345 347
346 txq->meta = kcalloc(slots_num, sizeof(txq->meta[0]), GFP_KERNEL); 348 txq->entries = kcalloc(slots_num,
347 txq->cmd = kcalloc(slots_num, sizeof(txq->cmd[0]), GFP_KERNEL); 349 sizeof(struct iwl_pcie_tx_queue_entry),
350 GFP_KERNEL);
348 351
349 if (!txq->meta || !txq->cmd) 352 if (!txq->entries)
350 goto error; 353 goto error;
351 354
352 if (txq_id == trans_pcie->cmd_queue) 355 if (txq_id == trans_pcie->cmd_queue)
353 for (i = 0; i < slots_num; i++) { 356 for (i = 0; i < slots_num; i++) {
354 txq->cmd[i] = kmalloc(sizeof(struct iwl_device_cmd), 357 txq->entries[i].cmd =
355 GFP_KERNEL); 358 kmalloc(sizeof(struct iwl_device_cmd),
356 if (!txq->cmd[i]) 359 GFP_KERNEL);
360 if (!txq->entries[i].cmd)
357 goto error; 361 goto error;
358 } 362 }
359 363
360 /* Alloc driver data array and TFD circular buffer */
361 /* Driver private data, only for Tx (not command) queues,
362 * not shared with device. */
363 if (txq_id != trans_pcie->cmd_queue) {
364 txq->skbs = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(txq->skbs[0]),
365 GFP_KERNEL);
366 if (!txq->skbs) {
367 IWL_ERR(trans, "kmalloc for auxiliary BD "
368 "structures failed\n");
369 goto error;
370 }
371 } else {
372 txq->skbs = NULL;
373 }
374
375 /* Circular buffer of transmit frame descriptors (TFDs), 364 /* Circular buffer of transmit frame descriptors (TFDs),
376 * shared with device */ 365 * shared with device */
377 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, 366 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz,
@@ -384,17 +373,11 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans,
384 373
385 return 0; 374 return 0;
386error: 375error:
387 kfree(txq->skbs); 376 if (txq->entries && txq_id == trans_pcie->cmd_queue)
388 txq->skbs = NULL;
389 /* since txq->cmd has been zeroed,
390 * all non allocated cmd[i] will be NULL */
391 if (txq->cmd && txq_id == trans_pcie->cmd_queue)
392 for (i = 0; i < slots_num; i++) 377 for (i = 0; i < slots_num; i++)
393 kfree(txq->cmd[i]); 378 kfree(txq->entries[i].cmd);
394 kfree(txq->meta); 379 kfree(txq->entries);
395 kfree(txq->cmd); 380 txq->entries = NULL;
396 txq->meta = NULL;
397 txq->cmd = NULL;
398 381
399 return -ENOMEM; 382 return -ENOMEM;
400 383
@@ -406,7 +389,6 @@ static int iwl_trans_txq_init(struct iwl_trans *trans, struct iwl_tx_queue *txq,
406 int ret; 389 int ret;
407 390
408 txq->need_update = 0; 391 txq->need_update = 0;
409 memset(txq->meta, 0, sizeof(txq->meta[0]) * slots_num);
410 392
411 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise 393 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
412 * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ 394 * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
@@ -484,7 +466,7 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id)
484 466
485 if (txq_id == trans_pcie->cmd_queue) 467 if (txq_id == trans_pcie->cmd_queue)
486 for (i = 0; i < txq->q.n_window; i++) 468 for (i = 0; i < txq->q.n_window; i++)
487 kfree(txq->cmd[i]); 469 kfree(txq->entries[i].cmd);
488 470
489 /* De-alloc circular buffer of TFDs */ 471 /* De-alloc circular buffer of TFDs */
490 if (txq->q.n_bd) { 472 if (txq->q.n_bd) {
@@ -493,15 +475,8 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id)
493 memset(&txq->q.dma_addr, 0, sizeof(txq->q.dma_addr)); 475 memset(&txq->q.dma_addr, 0, sizeof(txq->q.dma_addr));
494 } 476 }
495 477
496 /* De-alloc array of per-TFD driver data */ 478 kfree(txq->entries);
497 kfree(txq->skbs); 479 txq->entries = NULL;
498 txq->skbs = NULL;
499
500 /* deallocate arrays */
501 kfree(txq->cmd);
502 kfree(txq->meta);
503 txq->cmd = NULL;
504 txq->meta = NULL;
505 480
506 del_timer_sync(&txq->stuck_timer); 481 del_timer_sync(&txq->stuck_timer);
507 482
@@ -522,7 +497,7 @@ static void iwl_trans_pcie_tx_free(struct iwl_trans *trans)
522 /* Tx queues */ 497 /* Tx queues */
523 if (trans_pcie->txq) { 498 if (trans_pcie->txq) {
524 for (txq_id = 0; 499 for (txq_id = 0;
525 txq_id < cfg(trans)->base_params->num_of_queues; txq_id++) 500 txq_id < trans->cfg->base_params->num_of_queues; txq_id++)
526 iwl_tx_queue_free(trans, txq_id); 501 iwl_tx_queue_free(trans, txq_id);
527 } 502 }
528 503
@@ -547,7 +522,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans)
547 int txq_id, slots_num; 522 int txq_id, slots_num;
548 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 523 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
549 524
550 u16 scd_bc_tbls_size = cfg(trans)->base_params->num_of_queues * 525 u16 scd_bc_tbls_size = trans->cfg->base_params->num_of_queues *
551 sizeof(struct iwlagn_scd_bc_tbl); 526 sizeof(struct iwlagn_scd_bc_tbl);
552 527
553 /*It is not allowed to alloc twice, so warn when this happens. 528 /*It is not allowed to alloc twice, so warn when this happens.
@@ -571,7 +546,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans)
571 goto error; 546 goto error;
572 } 547 }
573 548
574 trans_pcie->txq = kcalloc(cfg(trans)->base_params->num_of_queues, 549 trans_pcie->txq = kcalloc(trans->cfg->base_params->num_of_queues,
575 sizeof(struct iwl_tx_queue), GFP_KERNEL); 550 sizeof(struct iwl_tx_queue), GFP_KERNEL);
576 if (!trans_pcie->txq) { 551 if (!trans_pcie->txq) {
577 IWL_ERR(trans, "Not enough memory for txq\n"); 552 IWL_ERR(trans, "Not enough memory for txq\n");
@@ -580,7 +555,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans)
580 } 555 }
581 556
582 /* Alloc and init all Tx queues, including the command queue (#4/#9) */ 557 /* Alloc and init all Tx queues, including the command queue (#4/#9) */
583 for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; 558 for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
584 txq_id++) { 559 txq_id++) {
585 slots_num = (txq_id == trans_pcie->cmd_queue) ? 560 slots_num = (txq_id == trans_pcie->cmd_queue) ?
586 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; 561 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
@@ -626,7 +601,7 @@ static int iwl_tx_init(struct iwl_trans *trans)
626 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); 601 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
627 602
628 /* Alloc and init all Tx queues, including the command queue (#4/#9) */ 603 /* Alloc and init all Tx queues, including the command queue (#4/#9) */
629 for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; 604 for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
630 txq_id++) { 605 txq_id++) {
631 slots_num = (txq_id == trans_pcie->cmd_queue) ? 606 slots_num = (txq_id == trans_pcie->cmd_queue) ?
632 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; 607 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
@@ -749,9 +724,9 @@ static int iwl_apm_init(struct iwl_trans *trans)
749 iwl_apm_config(trans); 724 iwl_apm_config(trans);
750 725
751 /* Configure analog phase-lock-loop before activating to D0A */ 726 /* Configure analog phase-lock-loop before activating to D0A */
752 if (cfg(trans)->base_params->pll_cfg_val) 727 if (trans->cfg->base_params->pll_cfg_val)
753 iwl_set_bit(trans, CSR_ANA_PLL_CFG, 728 iwl_set_bit(trans, CSR_ANA_PLL_CFG,
754 cfg(trans)->base_params->pll_cfg_val); 729 trans->cfg->base_params->pll_cfg_val);
755 730
756 /* 731 /*
757 * Set "initialization complete" bit to move adapter from 732 * Set "initialization complete" bit to move adapter from
@@ -861,7 +836,7 @@ static int iwl_nic_init(struct iwl_trans *trans)
861 if (iwl_tx_init(trans)) 836 if (iwl_tx_init(trans))
862 return -ENOMEM; 837 return -ENOMEM;
863 838
864 if (cfg(trans)->base_params->shadow_reg_enable) { 839 if (trans->cfg->base_params->shadow_reg_enable) {
865 /* enable shadow regs in HW */ 840 /* enable shadow regs in HW */
866 iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL, 841 iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL,
867 0x800FFFFF); 842 0x800FFFFF);
@@ -1008,15 +983,13 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
1008 return -EIO; 983 return -EIO;
1009 } 984 }
1010 985
986 iwl_enable_rfkill_int(trans);
987
1011 /* If platform's RF_KILL switch is NOT set to KILL */ 988 /* If platform's RF_KILL switch is NOT set to KILL */
1012 hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & 989 hw_rfkill = iwl_is_rfkill_set(trans);
1013 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
1014 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 990 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
1015 991 if (hw_rfkill)
1016 if (hw_rfkill) {
1017 iwl_enable_rfkill_int(trans);
1018 return -ERFKILL; 992 return -ERFKILL;
1019 }
1020 993
1021 iwl_write32(trans, CSR_INT, 0xFFFFFFFF); 994 iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
1022 995
@@ -1080,7 +1053,7 @@ static void iwl_tx_start(struct iwl_trans *trans)
1080 iwl_write_targ_mem(trans, a, 0); 1053 iwl_write_targ_mem(trans, a, 0);
1081 for (; a < trans_pcie->scd_base_addr + 1054 for (; a < trans_pcie->scd_base_addr +
1082 SCD_TRANS_TBL_OFFSET_QUEUE( 1055 SCD_TRANS_TBL_OFFSET_QUEUE(
1083 cfg(trans)->base_params->num_of_queues); 1056 trans->cfg->base_params->num_of_queues);
1084 a += 4) 1057 a += 4)
1085 iwl_write_targ_mem(trans, a, 0); 1058 iwl_write_targ_mem(trans, a, 0);
1086 1059
@@ -1103,7 +1076,7 @@ static void iwl_tx_start(struct iwl_trans *trans)
1103 iwl_write_prph(trans, SCD_AGGR_SEL, 0); 1076 iwl_write_prph(trans, SCD_AGGR_SEL, 0);
1104 1077
1105 /* initiate the queues */ 1078 /* initiate the queues */
1106 for (i = 0; i < cfg(trans)->base_params->num_of_queues; i++) { 1079 for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) {
1107 iwl_write_prph(trans, SCD_QUEUE_RDPTR(i), 0); 1080 iwl_write_prph(trans, SCD_QUEUE_RDPTR(i), 0);
1108 iwl_write_direct32(trans, HBUS_TARG_WRPTR, 0 | (i << 8)); 1081 iwl_write_direct32(trans, HBUS_TARG_WRPTR, 0 | (i << 8));
1109 iwl_write_targ_mem(trans, trans_pcie->scd_base_addr + 1082 iwl_write_targ_mem(trans, trans_pcie->scd_base_addr +
@@ -1120,7 +1093,7 @@ static void iwl_tx_start(struct iwl_trans *trans)
1120 } 1093 }
1121 1094
1122 iwl_write_prph(trans, SCD_INTERRUPT_MASK, 1095 iwl_write_prph(trans, SCD_INTERRUPT_MASK,
1123 IWL_MASK(0, cfg(trans)->base_params->num_of_queues)); 1096 IWL_MASK(0, trans->cfg->base_params->num_of_queues));
1124 1097
1125 /* Activate all Tx DMA/FIFO channels */ 1098 /* Activate all Tx DMA/FIFO channels */
1126 iwl_trans_txq_set_sched(trans, IWL_MASK(0, 7)); 1099 iwl_trans_txq_set_sched(trans, IWL_MASK(0, 7));
@@ -1188,7 +1161,7 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans)
1188 } 1161 }
1189 1162
1190 /* Unmap DMA from host system and free skb's */ 1163 /* Unmap DMA from host system and free skb's */
1191 for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; 1164 for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
1192 txq_id++) 1165 txq_id++)
1193 iwl_tx_queue_unmap(trans, txq_id); 1166 iwl_tx_queue_unmap(trans, txq_id);
1194 1167
@@ -1240,6 +1213,8 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1240 iwl_disable_interrupts(trans); 1213 iwl_disable_interrupts(trans);
1241 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); 1214 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
1242 1215
1216 iwl_enable_rfkill_int(trans);
1217
1243 /* wait to make sure we flush pending tasklet*/ 1218 /* wait to make sure we flush pending tasklet*/
1244 synchronize_irq(trans_pcie->irq); 1219 synchronize_irq(trans_pcie->irq);
1245 tasklet_kill(&trans_pcie->irq_tasklet); 1220 tasklet_kill(&trans_pcie->irq_tasklet);
@@ -1296,15 +1271,15 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
1296 spin_lock(&txq->lock); 1271 spin_lock(&txq->lock);
1297 1272
1298 /* Set up driver data for this TFD */ 1273 /* Set up driver data for this TFD */
1299 txq->skbs[q->write_ptr] = skb; 1274 txq->entries[q->write_ptr].skb = skb;
1300 txq->cmd[q->write_ptr] = dev_cmd; 1275 txq->entries[q->write_ptr].cmd = dev_cmd;
1301 1276
1302 dev_cmd->hdr.cmd = REPLY_TX; 1277 dev_cmd->hdr.cmd = REPLY_TX;
1303 dev_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | 1278 dev_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
1304 INDEX_TO_SEQ(q->write_ptr))); 1279 INDEX_TO_SEQ(q->write_ptr)));
1305 1280
1306 /* Set up first empty entry in queue's array of Tx/cmd buffers */ 1281 /* Set up first empty entry in queue's array of Tx/cmd buffers */
1307 out_meta = &txq->meta[q->write_ptr]; 1282 out_meta = &txq->entries[q->write_ptr].meta;
1308 1283
1309 /* 1284 /*
1310 * Use the first empty entry in this queue's command buffer array 1285 * Use the first empty entry in this queue's command buffer array
@@ -1450,8 +1425,10 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1450 1425
1451 iwl_apm_init(trans); 1426 iwl_apm_init(trans);
1452 1427
1453 hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & 1428 /* From now on, the op_mode will be kept updated about RF kill state */
1454 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); 1429 iwl_enable_rfkill_int(trans);
1430
1431 hw_rfkill = iwl_is_rfkill_set(trans);
1455 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 1432 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
1456 1433
1457 return err; 1434 return err;
@@ -1464,14 +1441,37 @@ error:
1464 return err; 1441 return err;
1465} 1442}
1466 1443
1467static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans) 1444static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans,
1445 bool op_mode_leaving)
1468{ 1446{
1447 bool hw_rfkill;
1448 unsigned long flags;
1449 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1450
1469 iwl_apm_stop(trans); 1451 iwl_apm_stop(trans);
1470 1452
1453 spin_lock_irqsave(&trans_pcie->irq_lock, flags);
1454 iwl_disable_interrupts(trans);
1455 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
1456
1471 iwl_write32(trans, CSR_INT, 0xFFFFFFFF); 1457 iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
1472 1458
1473 /* Even if we stop the HW, we still want the RF kill interrupt */ 1459 if (!op_mode_leaving) {
1474 iwl_enable_rfkill_int(trans); 1460 /*
1461 * Even if we stop the HW, we still want the RF kill
1462 * interrupt
1463 */
1464 iwl_enable_rfkill_int(trans);
1465
1466 /*
1467 * Check again since the RF kill state may have changed while
1468 * all the interrupts were disabled, in this case we couldn't
1469 * receive the RF kill interrupt and update the state in the
1470 * op_mode.
1471 */
1472 hw_rfkill = iwl_is_rfkill_set(trans);
1473 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
1474 }
1475} 1475}
1476 1476
1477static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 1477static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
@@ -1548,7 +1548,7 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,
1548 trans_pcie->command_names = trans_cfg->command_names; 1548 trans_pcie->command_names = trans_cfg->command_names;
1549} 1549}
1550 1550
1551static void iwl_trans_pcie_free(struct iwl_trans *trans) 1551void iwl_trans_pcie_free(struct iwl_trans *trans)
1552{ 1552{
1553 struct iwl_trans_pcie *trans_pcie = 1553 struct iwl_trans_pcie *trans_pcie =
1554 IWL_TRANS_GET_PCIE_TRANS(trans); 1554 IWL_TRANS_GET_PCIE_TRANS(trans);
@@ -1567,7 +1567,6 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans)
1567 pci_release_regions(trans_pcie->pci_dev); 1567 pci_release_regions(trans_pcie->pci_dev);
1568 pci_disable_device(trans_pcie->pci_dev); 1568 pci_disable_device(trans_pcie->pci_dev);
1569 1569
1570 trans->shrd->trans = NULL;
1571 kfree(trans); 1570 kfree(trans);
1572} 1571}
1573 1572
@@ -1591,16 +1590,14 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans)
1591{ 1590{
1592 bool hw_rfkill; 1591 bool hw_rfkill;
1593 1592
1594 hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & 1593 iwl_enable_rfkill_int(trans);
1595 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
1596
1597 if (hw_rfkill)
1598 iwl_enable_rfkill_int(trans);
1599 else
1600 iwl_enable_interrupts(trans);
1601 1594
1595 hw_rfkill = iwl_is_rfkill_set(trans);
1602 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 1596 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
1603 1597
1598 if (!hw_rfkill)
1599 iwl_enable_interrupts(trans);
1600
1604 return 0; 1601 return 0;
1605} 1602}
1606#endif /* CONFIG_PM_SLEEP */ 1603#endif /* CONFIG_PM_SLEEP */
@@ -1617,7 +1614,7 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans)
1617 int ret = 0; 1614 int ret = 0;
1618 1615
1619 /* waiting for all the tx frames complete might take a while */ 1616 /* waiting for all the tx frames complete might take a while */
1620 for (cnt = 0; cnt < cfg(trans)->base_params->num_of_queues; cnt++) { 1617 for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) {
1621 if (cnt == trans_pcie->cmd_queue) 1618 if (cnt == trans_pcie->cmd_queue)
1622 continue; 1619 continue;
1623 txq = &trans_pcie->txq[cnt]; 1620 txq = &trans_pcie->txq[cnt];
@@ -1829,17 +1826,16 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
1829 int ret; 1826 int ret;
1830 size_t bufsz; 1827 size_t bufsz;
1831 1828
1832 bufsz = sizeof(char) * 64 * cfg(trans)->base_params->num_of_queues; 1829 bufsz = sizeof(char) * 64 * trans->cfg->base_params->num_of_queues;
1833 1830
1834 if (!trans_pcie->txq) { 1831 if (!trans_pcie->txq)
1835 IWL_ERR(trans, "txq not ready\n");
1836 return -EAGAIN; 1832 return -EAGAIN;
1837 } 1833
1838 buf = kzalloc(bufsz, GFP_KERNEL); 1834 buf = kzalloc(bufsz, GFP_KERNEL);
1839 if (!buf) 1835 if (!buf)
1840 return -ENOMEM; 1836 return -ENOMEM;
1841 1837
1842 for (cnt = 0; cnt < cfg(trans)->base_params->num_of_queues; cnt++) { 1838 for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) {
1843 txq = &trans_pcie->txq[cnt]; 1839 txq = &trans_pcie->txq[cnt];
1844 q = &txq->q; 1840 q = &txq->q;
1845 pos += scnprintf(buf + pos, bufsz - pos, 1841 pos += scnprintf(buf + pos, bufsz - pos,
@@ -1895,10 +1891,8 @@ static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
1895 ssize_t ret; 1891 ssize_t ret;
1896 1892
1897 buf = kzalloc(bufsz, GFP_KERNEL); 1893 buf = kzalloc(bufsz, GFP_KERNEL);
1898 if (!buf) { 1894 if (!buf)
1899 IWL_ERR(trans, "Can not allocate Buffer\n");
1900 return -ENOMEM; 1895 return -ENOMEM;
1901 }
1902 1896
1903 pos += scnprintf(buf + pos, bufsz - pos, 1897 pos += scnprintf(buf + pos, bufsz - pos,
1904 "Interrupt Statistics Report:\n"); 1898 "Interrupt Statistics Report:\n");
@@ -2049,7 +2043,7 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans,
2049 2043
2050#endif /*CONFIG_IWLWIFI_DEBUGFS */ 2044#endif /*CONFIG_IWLWIFI_DEBUGFS */
2051 2045
2052const struct iwl_trans_ops trans_ops_pcie = { 2046static const struct iwl_trans_ops trans_ops_pcie = {
2053 .start_hw = iwl_trans_pcie_start_hw, 2047 .start_hw = iwl_trans_pcie_start_hw,
2054 .stop_hw = iwl_trans_pcie_stop_hw, 2048 .stop_hw = iwl_trans_pcie_stop_hw,
2055 .fw_alive = iwl_trans_pcie_fw_alive, 2049 .fw_alive = iwl_trans_pcie_fw_alive,
@@ -2066,8 +2060,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
2066 .tx_agg_disable = iwl_trans_pcie_tx_agg_disable, 2060 .tx_agg_disable = iwl_trans_pcie_tx_agg_disable,
2067 .tx_agg_setup = iwl_trans_pcie_tx_agg_setup, 2061 .tx_agg_setup = iwl_trans_pcie_tx_agg_setup,
2068 2062
2069 .free = iwl_trans_pcie_free,
2070
2071 .dbgfs_register = iwl_trans_pcie_dbgfs_register, 2063 .dbgfs_register = iwl_trans_pcie_dbgfs_register,
2072 2064
2073 .wait_tx_queue_empty = iwl_trans_pcie_wait_tx_queue_empty, 2065 .wait_tx_queue_empty = iwl_trans_pcie_wait_tx_queue_empty,
@@ -2083,9 +2075,9 @@ const struct iwl_trans_ops trans_ops_pcie = {
2083 .set_pmi = iwl_trans_pcie_set_pmi, 2075 .set_pmi = iwl_trans_pcie_set_pmi,
2084}; 2076};
2085 2077
2086struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, 2078struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2087 struct pci_dev *pdev, 2079 const struct pci_device_id *ent,
2088 const struct pci_device_id *ent) 2080 const struct iwl_cfg *cfg)
2089{ 2081{
2090 struct iwl_trans_pcie *trans_pcie; 2082 struct iwl_trans_pcie *trans_pcie;
2091 struct iwl_trans *trans; 2083 struct iwl_trans *trans;
@@ -2101,7 +2093,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
2101 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2093 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2102 2094
2103 trans->ops = &trans_ops_pcie; 2095 trans->ops = &trans_ops_pcie;
2104 trans->shrd = shrd; 2096 trans->cfg = cfg;
2105 trans_pcie->trans = trans; 2097 trans_pcie->trans = trans;
2106 spin_lock_init(&trans_pcie->irq_lock); 2098 spin_lock_init(&trans_pcie->irq_lock);
2107 init_waitqueue_head(&trans_pcie->ucode_write_waitq); 2099 init_waitqueue_head(&trans_pcie->ucode_write_waitq);
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index f3496a0490f0..7018d313a4e0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -66,8 +66,9 @@
66#include <linux/ieee80211.h> 66#include <linux/ieee80211.h>
67#include <linux/mm.h> /* for page_address */ 67#include <linux/mm.h> /* for page_address */
68 68
69#include "iwl-shared.h"
70#include "iwl-debug.h" 69#include "iwl-debug.h"
70#include "iwl-config.h"
71#include "iwl-fw.h"
71 72
72/** 73/**
73 * DOC: Transport layer - what is it ? 74 * DOC: Transport layer - what is it ?
@@ -104,13 +105,6 @@
104 * 6) Eventually, the free function will be called. 105 * 6) Eventually, the free function will be called.
105 */ 106 */
106 107
107struct iwl_priv;
108struct iwl_shared;
109struct iwl_op_mode;
110struct fw_img;
111struct sk_buff;
112struct dentry;
113
114/** 108/**
115 * DOC: Host command section 109 * DOC: Host command section
116 * 110 *
@@ -326,6 +320,8 @@ struct iwl_trans_config {
326 const char **command_names; 320 const char **command_names;
327}; 321};
328 322
323struct iwl_trans;
324
329/** 325/**
330 * struct iwl_trans_ops - transport specific operations 326 * struct iwl_trans_ops - transport specific operations
331 * 327 *
@@ -334,7 +330,8 @@ struct iwl_trans_config {
334 * @start_hw: starts the HW- from that point on, the HW can send interrupts 330 * @start_hw: starts the HW- from that point on, the HW can send interrupts
335 * May sleep 331 * May sleep
336 * @stop_hw: stops the HW- from that point on, the HW will be in low power but 332 * @stop_hw: stops the HW- from that point on, the HW will be in low power but
337 * will still issue interrupt if the HW RF kill is triggered. 333 * will still issue interrupt if the HW RF kill is triggered unless
334 * op_mode_leaving is true.
338 * May sleep 335 * May sleep
339 * @start_fw: allocates and inits all the resources for the transport 336 * @start_fw: allocates and inits all the resources for the transport
340 * layer. Also kick a fw image. 337 * layer. Also kick a fw image.
@@ -357,10 +354,6 @@ struct iwl_trans_config {
357 * May sleep 354 * May sleep
358 * @tx_agg_disable: de-configure a Tx queue to send AMPDUs 355 * @tx_agg_disable: de-configure a Tx queue to send AMPDUs
359 * Must be atomic 356 * Must be atomic
360 * @free: release all the ressource for the transport layer itself such as
361 * irq, tasklet etc... From this point on, the device may not issue
362 * any interrupt (incl. RFKILL).
363 * May sleep
364 * @wait_tx_queue_empty: wait until all tx queues are empty 357 * @wait_tx_queue_empty: wait until all tx queues are empty
365 * May sleep 358 * May sleep
366 * @dbgfs_register: add the dbgfs files under this directory. Files will be 359 * @dbgfs_register: add the dbgfs files under this directory. Files will be
@@ -378,7 +371,7 @@ struct iwl_trans_config {
378struct iwl_trans_ops { 371struct iwl_trans_ops {
379 372
380 int (*start_hw)(struct iwl_trans *iwl_trans); 373 int (*start_hw)(struct iwl_trans *iwl_trans);
381 void (*stop_hw)(struct iwl_trans *iwl_trans); 374 void (*stop_hw)(struct iwl_trans *iwl_trans, bool op_mode_leaving);
382 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw); 375 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw);
383 void (*fw_alive)(struct iwl_trans *trans); 376 void (*fw_alive)(struct iwl_trans *trans);
384 void (*stop_device)(struct iwl_trans *trans); 377 void (*stop_device)(struct iwl_trans *trans);
@@ -396,8 +389,6 @@ struct iwl_trans_ops {
396 int sta_id, int tid, int frame_limit, u16 ssn); 389 int sta_id, int tid, int frame_limit, u16 ssn);
397 void (*tx_agg_disable)(struct iwl_trans *trans, int queue); 390 void (*tx_agg_disable)(struct iwl_trans *trans, int queue);
398 391
399 void (*free)(struct iwl_trans *trans);
400
401 int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); 392 int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir);
402 int (*wait_tx_queue_empty)(struct iwl_trans *trans); 393 int (*wait_tx_queue_empty)(struct iwl_trans *trans);
403#ifdef CONFIG_PM_SLEEP 394#ifdef CONFIG_PM_SLEEP
@@ -428,7 +419,7 @@ enum iwl_trans_state {
428 * 419 *
429 * @ops - pointer to iwl_trans_ops 420 * @ops - pointer to iwl_trans_ops
430 * @op_mode - pointer to the op_mode 421 * @op_mode - pointer to the op_mode
431 * @shrd - pointer to iwl_shared which holds shared data from the upper layer 422 * @cfg - pointer to the configuration
432 * @reg_lock - protect hw register access 423 * @reg_lock - protect hw register access
433 * @dev - pointer to struct device * that represents the device 424 * @dev - pointer to struct device * that represents the device
434 * @hw_id: a u32 with the ID of the device / subdevice. 425 * @hw_id: a u32 with the ID of the device / subdevice.
@@ -440,7 +431,7 @@ enum iwl_trans_state {
440struct iwl_trans { 431struct iwl_trans {
441 const struct iwl_trans_ops *ops; 432 const struct iwl_trans_ops *ops;
442 struct iwl_op_mode *op_mode; 433 struct iwl_op_mode *op_mode;
443 struct iwl_shared *shrd; 434 const struct iwl_cfg *cfg;
444 enum iwl_trans_state state; 435 enum iwl_trans_state state;
445 spinlock_t reg_lock; 436 spinlock_t reg_lock;
446 437
@@ -477,11 +468,12 @@ static inline int iwl_trans_start_hw(struct iwl_trans *trans)
477 return trans->ops->start_hw(trans); 468 return trans->ops->start_hw(trans);
478} 469}
479 470
480static inline void iwl_trans_stop_hw(struct iwl_trans *trans) 471static inline void iwl_trans_stop_hw(struct iwl_trans *trans,
472 bool op_mode_leaving)
481{ 473{
482 might_sleep(); 474 might_sleep();
483 475
484 trans->ops->stop_hw(trans); 476 trans->ops->stop_hw(trans, op_mode_leaving);
485 477
486 trans->state = IWL_TRANS_NO_FW; 478 trans->state = IWL_TRANS_NO_FW;
487} 479}
@@ -566,11 +558,6 @@ static inline void iwl_trans_tx_agg_setup(struct iwl_trans *trans, int queue,
566 frame_limit, ssn); 558 frame_limit, ssn);
567} 559}
568 560
569static inline void iwl_trans_free(struct iwl_trans *trans)
570{
571 trans->ops->free(trans);
572}
573
574static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) 561static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans)
575{ 562{
576 WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 563 WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,
@@ -618,19 +605,9 @@ static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state)
618} 605}
619 606
620/***************************************************** 607/*****************************************************
621* Transport layers implementations + their allocation function 608* driver (transport) register/unregister functions
622******************************************************/ 609******************************************************/
623struct pci_dev;
624struct pci_device_id;
625extern const struct iwl_trans_ops trans_ops_pcie;
626struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
627 struct pci_dev *pdev,
628 const struct pci_device_id *ent);
629int __must_check iwl_pci_register_driver(void); 610int __must_check iwl_pci_register_driver(void);
630void iwl_pci_unregister_driver(void); 611void iwl_pci_unregister_driver(void);
631 612
632extern const struct iwl_trans_ops trans_ops_idi;
633struct iwl_trans *iwl_trans_idi_alloc(struct iwl_shared *shrd,
634 void *pdev_void,
635 const void *ent_void);
636#endif /* __iwl_trans_h__ */ 613#endif /* __iwl_trans_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c
index 539171945610..bc40dc68b0f4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c
@@ -31,7 +31,6 @@
31#include <linux/init.h> 31#include <linux/init.h>
32 32
33#include "iwl-dev.h" 33#include "iwl-dev.h"
34#include "iwl-core.h"
35#include "iwl-io.h" 34#include "iwl-io.h"
36#include "iwl-agn-hw.h" 35#include "iwl-agn-hw.h"
37#include "iwl-agn.h" 36#include "iwl-agn.h"
@@ -145,8 +144,8 @@ int iwl_init_alive_start(struct iwl_priv *priv)
145{ 144{
146 int ret; 145 int ret;
147 146
148 if (cfg(priv)->bt_params && 147 if (priv->cfg->bt_params &&
149 cfg(priv)->bt_params->advanced_bt_coexist) { 148 priv->cfg->bt_params->advanced_bt_coexist) {
150 /* 149 /*
151 * Tell uCode we are ready to perform calibration 150 * Tell uCode we are ready to perform calibration
152 * need to perform this before any calibration 151 * need to perform this before any calibration
@@ -168,8 +167,8 @@ int iwl_init_alive_start(struct iwl_priv *priv)
168 * temperature offset calibration is only needed for runtime ucode, 167 * temperature offset calibration is only needed for runtime ucode,
169 * so prepare the value now. 168 * so prepare the value now.
170 */ 169 */
171 if (cfg(priv)->need_temp_offset_calib) { 170 if (priv->cfg->need_temp_offset_calib) {
172 if (cfg(priv)->temp_offset_v2) 171 if (priv->cfg->temp_offset_v2)
173 return iwl_set_temperature_offset_calib_v2(priv); 172 return iwl_set_temperature_offset_calib_v2(priv);
174 else 173 else
175 return iwl_set_temperature_offset_calib(priv); 174 return iwl_set_temperature_offset_calib(priv);
@@ -244,7 +243,7 @@ static int iwl_alive_notify(struct iwl_priv *priv)
244{ 243{
245 int ret; 244 int ret;
246 245
247 iwl_trans_fw_alive(trans(priv)); 246 iwl_trans_fw_alive(priv->trans);
248 247
249 priv->passive_no_rx = false; 248 priv->passive_no_rx = false;
250 priv->transport_queue_stop = 0; 249 priv->transport_queue_stop = 0;
@@ -253,7 +252,7 @@ static int iwl_alive_notify(struct iwl_priv *priv)
253 if (ret) 252 if (ret)
254 return ret; 253 return ret;
255 254
256 if (!cfg(priv)->no_xtal_calib) { 255 if (!priv->cfg->no_xtal_calib) {
257 ret = iwl_set_Xtal_calib(priv); 256 ret = iwl_set_Xtal_calib(priv);
258 if (ret) 257 if (ret)
259 return ret; 258 return ret;
@@ -282,9 +281,9 @@ static int iwl_verify_sec_sparse(struct iwl_priv *priv,
282 /* read data comes through single port, auto-incr addr */ 281 /* read data comes through single port, auto-incr addr */
283 /* NOTE: Use the debugless read so we don't flood kernel log 282 /* NOTE: Use the debugless read so we don't flood kernel log
284 * if IWL_DL_IO is set */ 283 * if IWL_DL_IO is set */
285 iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR, 284 iwl_write_direct32(priv->trans, HBUS_TARG_MEM_RADDR,
286 i + fw_desc->offset); 285 i + fw_desc->offset);
287 val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 286 val = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
288 if (val != le32_to_cpu(*image)) 287 if (val != le32_to_cpu(*image))
289 return -EIO; 288 return -EIO;
290 } 289 }
@@ -303,14 +302,14 @@ static void iwl_print_mismatch_sec(struct iwl_priv *priv,
303 302
304 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); 303 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len);
305 304
306 iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR, 305 iwl_write_direct32(priv->trans, HBUS_TARG_MEM_RADDR,
307 fw_desc->offset); 306 fw_desc->offset);
308 307
309 for (offs = 0; 308 for (offs = 0;
310 offs < len && errors < 20; 309 offs < len && errors < 20;
311 offs += sizeof(u32), image++) { 310 offs += sizeof(u32), image++) {
312 /* read data comes through single port, auto-incr addr */ 311 /* read data comes through single port, auto-incr addr */
313 val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); 312 val = iwl_read32(priv->trans, HBUS_TARG_MEM_RDAT);
314 if (val != le32_to_cpu(*image)) { 313 if (val != le32_to_cpu(*image)) {
315 IWL_ERR(priv, "uCode INST section at " 314 IWL_ERR(priv, "uCode INST section at "
316 "offset 0x%x, is 0x%x, s/b 0x%x\n", 315 "offset 0x%x, is 0x%x, s/b 0x%x\n",
@@ -402,7 +401,7 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
402 alive_cmd, ARRAY_SIZE(alive_cmd), 401 alive_cmd, ARRAY_SIZE(alive_cmd),
403 iwl_alive_fn, &alive_data); 402 iwl_alive_fn, &alive_data);
404 403
405 ret = iwl_trans_start_fw(trans(priv), fw); 404 ret = iwl_trans_start_fw(priv->trans, fw);
406 if (ret) { 405 if (ret) {
407 priv->cur_ucode = old_type; 406 priv->cur_ucode = old_type;
408 iwl_remove_notification(&priv->notif_wait, &alive_wait); 407 iwl_remove_notification(&priv->notif_wait, &alive_wait);
@@ -526,7 +525,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv)
526 iwl_remove_notification(&priv->notif_wait, &calib_wait); 525 iwl_remove_notification(&priv->notif_wait, &calib_wait);
527 out: 526 out:
528 /* Whatever happened, stop the device */ 527 /* Whatever happened, stop the device */
529 iwl_trans_stop_device(trans(priv)); 528 iwl_trans_stop_device(priv->trans);
530 priv->ucode_loaded = false; 529 priv->ucode_loaded = false;
531 530
532 return ret; 531 return ret;