aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-09-30 01:31:51 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-30 01:31:51 -0400
commit4e9f4b39426de5053308ceadbfa3d066b7ef1288 (patch)
tree6552e3650136dfb0d554b1784ca45bba831b7d8f /drivers/net
parentdf90a497047e41a67c0563e81496a2dc0d2f562d (diff)
parent15b95a15950238eff4d7f24be1716086eea67835 (diff)
Merge tag 'wireless-drivers-next-for-davem-2016-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: wireless-drivers-next patches for 4.9 Major changes: iwlwifi * work for new hardware support continues * dynamic queue allocation stabilization * improvements in the MSIx code * multiqueue support work continues * new firmware version support (API 26) * add 8275 series support * add 9560 series support * add support for MU-MIMO sniffer * add support for RRM by scan * add support for "reverse" rx packet injection faking hw descriptors * migrate to devm memory allocation handling * Remove support for older firmwares (API older than -17 and -22) wl12xx * support booting the same rootfs with both wl12xx and wl18xx hostap * mark the driver as obsolete ath9k * disable RNG by default ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath10k/ahb.c107
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.c9
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c17
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h8
-rw-r--r--drivers/net/wireless/ath/ath10k/htt.h8
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c5
-rw-r--r--drivers/net/wireless/ath/ath10k/hw.c2
-rw-r--r--drivers/net/wireless/ath/ath10k/hw.h5
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c2
-rw-r--r--drivers/net/wireless/ath/ath10k/targaddrs.h2
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.c6
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.h32
-rw-r--r--drivers/net/wireless/ath/ath6kl/wmi.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c46
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c55
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h6
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c17
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/ucode.c11
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-7000.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-8000.c17
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-9000.c15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-a000.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-csr.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-fh.h57
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h29
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-fw.h9
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-io.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c104
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h20
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-trans.c12
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-trans.h20
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c29
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c184
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h21
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h20
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h85
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h74
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw.c152
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c47
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c42
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h18
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/nvm.c93
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/ops.c80
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/power.c15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c38
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/scan.c88
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c51
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.h11
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tt.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tx.c214
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/utils.c24
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/internal.h128
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/rx.c25
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/trans.c325
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx.c397
-rw-r--r--drivers/net/wireless/marvell/mwifiex/cfg80211.c24
-rw-r--r--drivers/net/wireless/marvell/mwifiex/fw.h1
-rw-r--r--drivers/net/wireless/marvell/mwifiex/ioctl.h1
-rw-r--r--drivers/net/wireless/marvell/mwifiex/main.c8
-rw-r--r--drivers/net/wireless/marvell/mwifiex/sta_cmd.c5
-rw-r--r--drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c13
-rw-r--r--drivers/net/wireless/marvell/mwifiex/usb.c37
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h7
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c144
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c49
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h1
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/ps.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c10
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c8
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c9
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c7
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192cu/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c7
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c15
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c10
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c5
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c10
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c9
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/led.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c20
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/wifi.h208
-rw-r--r--drivers/net/wireless/ti/wl18xx/main.c19
-rw-r--r--drivers/net/wireless/ti/wlcore/boot.c15
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c36
-rw-r--r--drivers/net/wireless/ti/wlcore/sdio.c76
-rw-r--r--drivers/net/wireless/ti/wlcore/spi.c48
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore_i.h12
121 files changed, 2381 insertions, 1434 deletions
diff --git a/drivers/net/wireless/ath/ath10k/ahb.c b/drivers/net/wireless/ath/ath10k/ahb.c
index b99ad5df383d..766c63bf05c4 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -91,59 +91,37 @@ static int ath10k_ahb_clock_init(struct ath10k *ar)
91{ 91{
92 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar); 92 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
93 struct device *dev; 93 struct device *dev;
94 int ret;
95 94
96 dev = &ar_ahb->pdev->dev; 95 dev = &ar_ahb->pdev->dev;
97 96
98 ar_ahb->cmd_clk = clk_get(dev, "wifi_wcss_cmd"); 97 ar_ahb->cmd_clk = devm_clk_get(dev, "wifi_wcss_cmd");
99 if (IS_ERR_OR_NULL(ar_ahb->cmd_clk)) { 98 if (IS_ERR_OR_NULL(ar_ahb->cmd_clk)) {
100 ath10k_err(ar, "failed to get cmd clk: %ld\n", 99 ath10k_err(ar, "failed to get cmd clk: %ld\n",
101 PTR_ERR(ar_ahb->cmd_clk)); 100 PTR_ERR(ar_ahb->cmd_clk));
102 ret = ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV; 101 return ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV;
103 goto out;
104 } 102 }
105 103
106 ar_ahb->ref_clk = clk_get(dev, "wifi_wcss_ref"); 104 ar_ahb->ref_clk = devm_clk_get(dev, "wifi_wcss_ref");
107 if (IS_ERR_OR_NULL(ar_ahb->ref_clk)) { 105 if (IS_ERR_OR_NULL(ar_ahb->ref_clk)) {
108 ath10k_err(ar, "failed to get ref clk: %ld\n", 106 ath10k_err(ar, "failed to get ref clk: %ld\n",
109 PTR_ERR(ar_ahb->ref_clk)); 107 PTR_ERR(ar_ahb->ref_clk));
110 ret = ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV; 108 return ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV;
111 goto err_cmd_clk_put;
112 } 109 }
113 110
114 ar_ahb->rtc_clk = clk_get(dev, "wifi_wcss_rtc"); 111 ar_ahb->rtc_clk = devm_clk_get(dev, "wifi_wcss_rtc");
115 if (IS_ERR_OR_NULL(ar_ahb->rtc_clk)) { 112 if (IS_ERR_OR_NULL(ar_ahb->rtc_clk)) {
116 ath10k_err(ar, "failed to get rtc clk: %ld\n", 113 ath10k_err(ar, "failed to get rtc clk: %ld\n",
117 PTR_ERR(ar_ahb->rtc_clk)); 114 PTR_ERR(ar_ahb->rtc_clk));
118 ret = ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV; 115 return ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV;
119 goto err_ref_clk_put;
120 } 116 }
121 117
122 return 0; 118 return 0;
123
124err_ref_clk_put:
125 clk_put(ar_ahb->ref_clk);
126
127err_cmd_clk_put:
128 clk_put(ar_ahb->cmd_clk);
129
130out:
131 return ret;
132} 119}
133 120
134static void ath10k_ahb_clock_deinit(struct ath10k *ar) 121static void ath10k_ahb_clock_deinit(struct ath10k *ar)
135{ 122{
136 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar); 123 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
137 124
138 if (!IS_ERR_OR_NULL(ar_ahb->cmd_clk))
139 clk_put(ar_ahb->cmd_clk);
140
141 if (!IS_ERR_OR_NULL(ar_ahb->ref_clk))
142 clk_put(ar_ahb->ref_clk);
143
144 if (!IS_ERR_OR_NULL(ar_ahb->rtc_clk))
145 clk_put(ar_ahb->rtc_clk);
146
147 ar_ahb->cmd_clk = NULL; 125 ar_ahb->cmd_clk = NULL;
148 ar_ahb->ref_clk = NULL; 126 ar_ahb->ref_clk = NULL;
149 ar_ahb->rtc_clk = NULL; 127 ar_ahb->rtc_clk = NULL;
@@ -213,92 +191,51 @@ static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
213{ 191{
214 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar); 192 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
215 struct device *dev; 193 struct device *dev;
216 int ret;
217 194
218 dev = &ar_ahb->pdev->dev; 195 dev = &ar_ahb->pdev->dev;
219 196
220 ar_ahb->core_cold_rst = reset_control_get(dev, "wifi_core_cold"); 197 ar_ahb->core_cold_rst = devm_reset_control_get(dev, "wifi_core_cold");
221 if (IS_ERR_OR_NULL(ar_ahb->core_cold_rst)) { 198 if (IS_ERR(ar_ahb->core_cold_rst)) {
222 ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n", 199 ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n",
223 PTR_ERR(ar_ahb->core_cold_rst)); 200 PTR_ERR(ar_ahb->core_cold_rst));
224 ret = ar_ahb->core_cold_rst ? 201 return PTR_ERR(ar_ahb->core_cold_rst);
225 PTR_ERR(ar_ahb->core_cold_rst) : -ENODEV;
226 goto out;
227 } 202 }
228 203
229 ar_ahb->radio_cold_rst = reset_control_get(dev, "wifi_radio_cold"); 204 ar_ahb->radio_cold_rst = devm_reset_control_get(dev, "wifi_radio_cold");
230 if (IS_ERR_OR_NULL(ar_ahb->radio_cold_rst)) { 205 if (IS_ERR(ar_ahb->radio_cold_rst)) {
231 ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n", 206 ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n",
232 PTR_ERR(ar_ahb->radio_cold_rst)); 207 PTR_ERR(ar_ahb->radio_cold_rst));
233 ret = ar_ahb->radio_cold_rst ? 208 return PTR_ERR(ar_ahb->radio_cold_rst);
234 PTR_ERR(ar_ahb->radio_cold_rst) : -ENODEV;
235 goto err_core_cold_rst_put;
236 } 209 }
237 210
238 ar_ahb->radio_warm_rst = reset_control_get(dev, "wifi_radio_warm"); 211 ar_ahb->radio_warm_rst = devm_reset_control_get(dev, "wifi_radio_warm");
239 if (IS_ERR_OR_NULL(ar_ahb->radio_warm_rst)) { 212 if (IS_ERR(ar_ahb->radio_warm_rst)) {
240 ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n", 213 ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n",
241 PTR_ERR(ar_ahb->radio_warm_rst)); 214 PTR_ERR(ar_ahb->radio_warm_rst));
242 ret = ar_ahb->radio_warm_rst ? 215 return PTR_ERR(ar_ahb->radio_warm_rst);
243 PTR_ERR(ar_ahb->radio_warm_rst) : -ENODEV;
244 goto err_radio_cold_rst_put;
245 } 216 }
246 217
247 ar_ahb->radio_srif_rst = reset_control_get(dev, "wifi_radio_srif"); 218 ar_ahb->radio_srif_rst = devm_reset_control_get(dev, "wifi_radio_srif");
248 if (IS_ERR_OR_NULL(ar_ahb->radio_srif_rst)) { 219 if (IS_ERR(ar_ahb->radio_srif_rst)) {
249 ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n", 220 ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n",
250 PTR_ERR(ar_ahb->radio_srif_rst)); 221 PTR_ERR(ar_ahb->radio_srif_rst));
251 ret = ar_ahb->radio_srif_rst ? 222 return PTR_ERR(ar_ahb->radio_srif_rst);
252 PTR_ERR(ar_ahb->radio_srif_rst) : -ENODEV;
253 goto err_radio_warm_rst_put;
254 } 223 }
255 224
256 ar_ahb->cpu_init_rst = reset_control_get(dev, "wifi_cpu_init"); 225 ar_ahb->cpu_init_rst = devm_reset_control_get(dev, "wifi_cpu_init");
257 if (IS_ERR_OR_NULL(ar_ahb->cpu_init_rst)) { 226 if (IS_ERR(ar_ahb->cpu_init_rst)) {
258 ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n", 227 ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n",
259 PTR_ERR(ar_ahb->cpu_init_rst)); 228 PTR_ERR(ar_ahb->cpu_init_rst));
260 ret = ar_ahb->cpu_init_rst ? 229 return PTR_ERR(ar_ahb->cpu_init_rst);
261 PTR_ERR(ar_ahb->cpu_init_rst) : -ENODEV;
262 goto err_radio_srif_rst_put;
263 } 230 }
264 231
265 return 0; 232 return 0;
266
267err_radio_srif_rst_put:
268 reset_control_put(ar_ahb->radio_srif_rst);
269
270err_radio_warm_rst_put:
271 reset_control_put(ar_ahb->radio_warm_rst);
272
273err_radio_cold_rst_put:
274 reset_control_put(ar_ahb->radio_cold_rst);
275
276err_core_cold_rst_put:
277 reset_control_put(ar_ahb->core_cold_rst);
278
279out:
280 return ret;
281} 233}
282 234
283static void ath10k_ahb_rst_ctrl_deinit(struct ath10k *ar) 235static void ath10k_ahb_rst_ctrl_deinit(struct ath10k *ar)
284{ 236{
285 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar); 237 struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
286 238
287 if (!IS_ERR_OR_NULL(ar_ahb->core_cold_rst))
288 reset_control_put(ar_ahb->core_cold_rst);
289
290 if (!IS_ERR_OR_NULL(ar_ahb->radio_cold_rst))
291 reset_control_put(ar_ahb->radio_cold_rst);
292
293 if (!IS_ERR_OR_NULL(ar_ahb->radio_warm_rst))
294 reset_control_put(ar_ahb->radio_warm_rst);
295
296 if (!IS_ERR_OR_NULL(ar_ahb->radio_srif_rst))
297 reset_control_put(ar_ahb->radio_srif_rst);
298
299 if (!IS_ERR_OR_NULL(ar_ahb->cpu_init_rst))
300 reset_control_put(ar_ahb->cpu_init_rst);
301
302 ar_ahb->core_cold_rst = NULL; 239 ar_ahb->core_cold_rst = NULL;
303 ar_ahb->radio_cold_rst = NULL; 240 ar_ahb->radio_cold_rst = NULL;
304 ar_ahb->radio_warm_rst = NULL; 241 ar_ahb->radio_warm_rst = NULL;
@@ -572,6 +509,7 @@ static int ath10k_ahb_resource_init(struct ath10k *ar)
572 ar_ahb->irq = platform_get_irq_byname(pdev, "legacy"); 509 ar_ahb->irq = platform_get_irq_byname(pdev, "legacy");
573 if (ar_ahb->irq < 0) { 510 if (ar_ahb->irq < 0) {
574 ath10k_err(ar, "failed to get irq number: %d\n", ar_ahb->irq); 511 ath10k_err(ar, "failed to get irq number: %d\n", ar_ahb->irq);
512 ret = ar_ahb->irq;
575 goto err_clock_deinit; 513 goto err_clock_deinit;
576 } 514 }
577 515
@@ -850,6 +788,7 @@ static int ath10k_ahb_probe(struct platform_device *pdev)
850 chip_id = ath10k_ahb_soc_read32(ar, SOC_CHIP_ID_ADDRESS); 788 chip_id = ath10k_ahb_soc_read32(ar, SOC_CHIP_ID_ADDRESS);
851 if (chip_id == 0xffffffff) { 789 if (chip_id == 0xffffffff) {
852 ath10k_err(ar, "failed to get chip id\n"); 790 ath10k_err(ar, "failed to get chip id\n");
791 ret = -ENODEV;
853 goto err_halt_device; 792 goto err_halt_device;
854 } 793 }
855 794
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index 65d8d714e917..0b4d79659884 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -39,7 +39,7 @@
39 * chooses what to send (buffer address, length). The destination 39 * chooses what to send (buffer address, length). The destination
40 * side keeps a supply of "anonymous receive buffers" available and 40 * side keeps a supply of "anonymous receive buffers" available and
41 * it handles incoming data as it arrives (when the destination 41 * it handles incoming data as it arrives (when the destination
42 * recieves an interrupt). 42 * receives an interrupt).
43 * 43 *
44 * The sender may send a simple buffer (address/length) or it may 44 * The sender may send a simple buffer (address/length) or it may
45 * send a small list of buffers. When a small list is sent, hardware 45 * send a small list of buffers. When a small list is sent, hardware
@@ -433,6 +433,13 @@ void ath10k_ce_rx_update_write_idx(struct ath10k_ce_pipe *pipe, u32 nentries)
433 unsigned int nentries_mask = dest_ring->nentries_mask; 433 unsigned int nentries_mask = dest_ring->nentries_mask;
434 unsigned int write_index = dest_ring->write_index; 434 unsigned int write_index = dest_ring->write_index;
435 u32 ctrl_addr = pipe->ctrl_addr; 435 u32 ctrl_addr = pipe->ctrl_addr;
436 u32 cur_write_idx = ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr);
437
438 /* Prevent CE ring stuck issue that will occur when ring is full.
439 * Make sure that write index is 1 less than read index.
440 */
441 if ((cur_write_idx + nentries) == dest_ring->sw_index)
442 nentries -= 1;
436 443
437 write_index = CE_RING_IDX_ADD(nentries_mask, write_index, nentries); 444 write_index = CE_RING_IDX_ADD(nentries_mask, write_index, nentries);
438 ath10k_ce_dest_ring_write_index_set(ar, ctrl_addr, write_index); 445 ath10k_ce_dest_ring_write_index_set(ar, ctrl_addr, write_index);
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 3a8984ba9f74..21ae8d663e67 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -68,6 +68,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
68 .board_ext_size = QCA988X_BOARD_EXT_DATA_SZ, 68 .board_ext_size = QCA988X_BOARD_EXT_DATA_SZ,
69 }, 69 },
70 .hw_ops = &qca988x_ops, 70 .hw_ops = &qca988x_ops,
71 .decap_align_bytes = 4,
71 }, 72 },
72 { 73 {
73 .id = QCA9887_HW_1_0_VERSION, 74 .id = QCA9887_HW_1_0_VERSION,
@@ -87,6 +88,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
87 .board_ext_size = QCA9887_BOARD_EXT_DATA_SZ, 88 .board_ext_size = QCA9887_BOARD_EXT_DATA_SZ,
88 }, 89 },
89 .hw_ops = &qca988x_ops, 90 .hw_ops = &qca988x_ops,
91 .decap_align_bytes = 4,
90 }, 92 },
91 { 93 {
92 .id = QCA6174_HW_2_1_VERSION, 94 .id = QCA6174_HW_2_1_VERSION,
@@ -105,6 +107,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
105 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, 107 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
106 }, 108 },
107 .hw_ops = &qca988x_ops, 109 .hw_ops = &qca988x_ops,
110 .decap_align_bytes = 4,
108 }, 111 },
109 { 112 {
110 .id = QCA6174_HW_2_1_VERSION, 113 .id = QCA6174_HW_2_1_VERSION,
@@ -123,6 +126,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
123 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, 126 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
124 }, 127 },
125 .hw_ops = &qca988x_ops, 128 .hw_ops = &qca988x_ops,
129 .decap_align_bytes = 4,
126 }, 130 },
127 { 131 {
128 .id = QCA6174_HW_3_0_VERSION, 132 .id = QCA6174_HW_3_0_VERSION,
@@ -141,6 +145,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
141 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, 145 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
142 }, 146 },
143 .hw_ops = &qca988x_ops, 147 .hw_ops = &qca988x_ops,
148 .decap_align_bytes = 4,
144 }, 149 },
145 { 150 {
146 .id = QCA6174_HW_3_2_VERSION, 151 .id = QCA6174_HW_3_2_VERSION,
@@ -160,6 +165,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
160 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, 165 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
161 }, 166 },
162 .hw_ops = &qca988x_ops, 167 .hw_ops = &qca988x_ops,
168 .decap_align_bytes = 4,
163 }, 169 },
164 { 170 {
165 .id = QCA99X0_HW_2_0_DEV_VERSION, 171 .id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -184,6 +190,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
184 }, 190 },
185 .sw_decrypt_mcast_mgmt = true, 191 .sw_decrypt_mcast_mgmt = true,
186 .hw_ops = &qca99x0_ops, 192 .hw_ops = &qca99x0_ops,
193 .decap_align_bytes = 1,
187 }, 194 },
188 { 195 {
189 .id = QCA9984_HW_1_0_DEV_VERSION, 196 .id = QCA9984_HW_1_0_DEV_VERSION,
@@ -208,6 +215,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
208 }, 215 },
209 .sw_decrypt_mcast_mgmt = true, 216 .sw_decrypt_mcast_mgmt = true,
210 .hw_ops = &qca99x0_ops, 217 .hw_ops = &qca99x0_ops,
218 .decap_align_bytes = 1,
211 }, 219 },
212 { 220 {
213 .id = QCA9888_HW_2_0_DEV_VERSION, 221 .id = QCA9888_HW_2_0_DEV_VERSION,
@@ -231,6 +239,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
231 }, 239 },
232 .sw_decrypt_mcast_mgmt = true, 240 .sw_decrypt_mcast_mgmt = true,
233 .hw_ops = &qca99x0_ops, 241 .hw_ops = &qca99x0_ops,
242 .decap_align_bytes = 1,
234 }, 243 },
235 { 244 {
236 .id = QCA9377_HW_1_0_DEV_VERSION, 245 .id = QCA9377_HW_1_0_DEV_VERSION,
@@ -249,6 +258,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
249 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ, 258 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
250 }, 259 },
251 .hw_ops = &qca988x_ops, 260 .hw_ops = &qca988x_ops,
261 .decap_align_bytes = 4,
252 }, 262 },
253 { 263 {
254 .id = QCA9377_HW_1_1_DEV_VERSION, 264 .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -267,6 +277,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
267 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ, 277 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
268 }, 278 },
269 .hw_ops = &qca988x_ops, 279 .hw_ops = &qca988x_ops,
280 .decap_align_bytes = 4,
270 }, 281 },
271 { 282 {
272 .id = QCA4019_HW_1_0_DEV_VERSION, 283 .id = QCA4019_HW_1_0_DEV_VERSION,
@@ -292,6 +303,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
292 }, 303 },
293 .sw_decrypt_mcast_mgmt = true, 304 .sw_decrypt_mcast_mgmt = true,
294 .hw_ops = &qca99x0_ops, 305 .hw_ops = &qca99x0_ops,
306 .decap_align_bytes = 1,
295 }, 307 },
296}; 308};
297 309
@@ -1960,7 +1972,10 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
1960 goto err_hif_stop; 1972 goto err_hif_stop;
1961 } 1973 }
1962 1974
1963 ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1; 1975 if (ar->max_num_vdevs >= 64)
1976 ar->free_vdev_map = 0xFFFFFFFFFFFFFFFFLL;
1977 else
1978 ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
1964 1979
1965 INIT_LIST_HEAD(&ar->arvifs); 1980 INIT_LIST_HEAD(&ar->arvifs);
1966 1981
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 6ec9495bcc04..dda49af1eb74 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -201,10 +201,10 @@ struct ath10k_fw_stats_pdev {
201 201
202 /* PDEV stats */ 202 /* PDEV stats */
203 s32 ch_noise_floor; 203 s32 ch_noise_floor;
204 u32 tx_frame_count; 204 u32 tx_frame_count; /* Cycles spent transmitting frames */
205 u32 rx_frame_count; 205 u32 rx_frame_count; /* Cycles spent receiving frames */
206 u32 rx_clear_count; 206 u32 rx_clear_count; /* Total channel busy time, evidently */
207 u32 cycle_count; 207 u32 cycle_count; /* Total on-channel time */
208 u32 phy_err_count; 208 u32 phy_err_count;
209 u32 chan_tx_power; 209 u32 chan_tx_power;
210 u32 ack_rx_bad; 210 u32 ack_rx_bad;
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
index 98c14247021b..0d2ed09f202b 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -595,7 +595,7 @@ enum htt_rx_mpdu_status {
595 /* only accept EAPOL frames */ 595 /* only accept EAPOL frames */
596 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER, 596 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
597 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC, 597 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
598 /* Non-data in promiscous mode */ 598 /* Non-data in promiscuous mode */
599 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL, 599 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
600 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR, 600 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
601 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR, 601 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
@@ -900,7 +900,7 @@ struct htt_rx_in_ord_ind {
900 * Purpose: indicate how many 32-bit integers follow the message header 900 * Purpose: indicate how many 32-bit integers follow the message header
901 * - NUM_CHARS 901 * - NUM_CHARS
902 * Bits 31:16 902 * Bits 31:16
903 * Purpose: indicate how many 8-bit charaters follow the series of integers 903 * Purpose: indicate how many 8-bit characters follow the series of integers
904 */ 904 */
905struct htt_rx_test { 905struct htt_rx_test {
906 u8 num_ints; 906 u8 num_ints;
@@ -1042,10 +1042,10 @@ struct htt_dbg_stats_wal_tx_stats {
1042 /* illegal rate phy errors */ 1042 /* illegal rate phy errors */
1043 __le32 illgl_rate_phy_err; 1043 __le32 illgl_rate_phy_err;
1044 1044
1045 /* wal pdev continous xretry */ 1045 /* wal pdev continuous xretry */
1046 __le32 pdev_cont_xretry; 1046 __le32 pdev_cont_xretry;
1047 1047
1048 /* wal pdev continous xretry */ 1048 /* wal pdev continuous xretry */
1049 __le32 pdev_tx_timeout; 1049 __le32 pdev_tx_timeout;
1050 1050
1051 /* wal pdev resets */ 1051 /* wal pdev resets */
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index a3785a9aa843..0b4c1562420f 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1103,6 +1103,7 @@ static void *ath10k_htt_rx_h_find_rfc1042(struct ath10k *ar,
1103 size_t hdr_len, crypto_len; 1103 size_t hdr_len, crypto_len;
1104 void *rfc1042; 1104 void *rfc1042;
1105 bool is_first, is_last, is_amsdu; 1105 bool is_first, is_last, is_amsdu;
1106 int bytes_aligned = ar->hw_params.decap_align_bytes;
1106 1107
1107 rxd = (void *)msdu->data - sizeof(*rxd); 1108 rxd = (void *)msdu->data - sizeof(*rxd);
1108 hdr = (void *)rxd->rx_hdr_status; 1109 hdr = (void *)rxd->rx_hdr_status;
@@ -1119,8 +1120,8 @@ static void *ath10k_htt_rx_h_find_rfc1042(struct ath10k *ar,
1119 hdr_len = ieee80211_hdrlen(hdr->frame_control); 1120 hdr_len = ieee80211_hdrlen(hdr->frame_control);
1120 crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype); 1121 crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
1121 1122
1122 rfc1042 += round_up(hdr_len, 4) + 1123 rfc1042 += round_up(hdr_len, bytes_aligned) +
1123 round_up(crypto_len, 4); 1124 round_up(crypto_len, bytes_aligned);
1124 } 1125 }
1125 1126
1126 if (is_amsdu) 1127 if (is_amsdu)
diff --git a/drivers/net/wireless/ath/ath10k/hw.c b/drivers/net/wireless/ath/ath10k/hw.c
index c2ecb9bd824a..675e75d66db2 100644
--- a/drivers/net/wireless/ath/ath10k/hw.c
+++ b/drivers/net/wireless/ath/ath10k/hw.c
@@ -85,7 +85,7 @@ const struct ath10k_hw_regs qca99x0_regs = {
85 .ce7_base_address = 0x0004bc00, 85 .ce7_base_address = 0x0004bc00,
86 /* Note: qca99x0 supports upto 12 Copy Engines. Other than address of 86 /* Note: qca99x0 supports upto 12 Copy Engines. Other than address of
87 * CE0 and CE1 no other copy engine is directly referred in the code. 87 * CE0 and CE1 no other copy engine is directly referred in the code.
88 * It is not really neccessary to assign address for newly supported 88 * It is not really necessary to assign address for newly supported
89 * CEs in this address table. 89 * CEs in this address table.
90 * Copy Engine Address 90 * Copy Engine Address
91 * CE8 0x0004c000 91 * CE8 0x0004c000
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 308e423d4b99..6038b7486f1d 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -284,7 +284,7 @@ void ath10k_hw_fill_survey_time(struct ath10k *ar, struct survey_info *survey,
284#define QCA_REV_9377(ar) ((ar)->hw_rev == ATH10K_HW_QCA9377) 284#define QCA_REV_9377(ar) ((ar)->hw_rev == ATH10K_HW_QCA9377)
285#define QCA_REV_40XX(ar) ((ar)->hw_rev == ATH10K_HW_QCA4019) 285#define QCA_REV_40XX(ar) ((ar)->hw_rev == ATH10K_HW_QCA4019)
286 286
287/* Known pecularities: 287/* Known peculiarities:
288 * - raw appears in nwifi decap, raw and nwifi appear in ethernet decap 288 * - raw appears in nwifi decap, raw and nwifi appear in ethernet decap
289 * - raw have FCS, nwifi doesn't 289 * - raw have FCS, nwifi doesn't
290 * - ethernet frames have 802.11 header decapped and parts (base hdr, cipher 290 * - ethernet frames have 802.11 header decapped and parts (base hdr, cipher
@@ -408,6 +408,9 @@ struct ath10k_hw_params {
408 bool sw_decrypt_mcast_mgmt; 408 bool sw_decrypt_mcast_mgmt;
409 409
410 const struct ath10k_hw_ops *hw_ops; 410 const struct ath10k_hw_ops *hw_ops;
411
412 /* Number of bytes used for alignment in rx_hdr_status of rx desc. */
413 int decap_align_bytes;
411}; 414};
412 415
413struct htt_rx_desc; 416struct htt_rx_desc;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 0a44dab5a287..76297d69f1ed 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -2793,7 +2793,7 @@ static void ath10k_bss_disassoc(struct ieee80211_hw *hw,
2793 2793
2794 ret = ath10k_wmi_vdev_down(ar, arvif->vdev_id); 2794 ret = ath10k_wmi_vdev_down(ar, arvif->vdev_id);
2795 if (ret) 2795 if (ret)
2796 ath10k_warn(ar, "faield to down vdev %i: %d\n", 2796 ath10k_warn(ar, "failed to down vdev %i: %d\n",
2797 arvif->vdev_id, ret); 2797 arvif->vdev_id, ret);
2798 2798
2799 arvif->def_wep_key_idx = -1; 2799 arvif->def_wep_key_idx = -1;
diff --git a/drivers/net/wireless/ath/ath10k/targaddrs.h b/drivers/net/wireless/ath/ath10k/targaddrs.h
index aaf53a81e78b..a47cab44d9c8 100644
--- a/drivers/net/wireless/ath/ath10k/targaddrs.h
+++ b/drivers/net/wireless/ath/ath10k/targaddrs.h
@@ -405,7 +405,7 @@ Fw Mode/SubMode Mask
405 * 1. target firmware would check magic number and if it's a match, firmware 405 * 1. target firmware would check magic number and if it's a match, firmware
406 * would consider the bits[0:15] are valid and base on that to calculate 406 * would consider the bits[0:15] are valid and base on that to calculate
407 * the end of DRAM. Early allocation would be located at that area and 407 * the end of DRAM. Early allocation would be located at that area and
408 * may be reclaimed when necesary 408 * may be reclaimed when necessary
409 * 2. if no magic number is found, early allocation would happen at "_end" 409 * 2. if no magic number is found, early allocation would happen at "_end"
410 * symbol of ROM which is located before the app-data and might NOT be 410 * symbol of ROM which is located before the app-data and might NOT be
411 * re-claimable. If this is adopted, link script should keep this in 411 * re-claimable. If this is adopted, link script should keep this in
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 38993d72f5e6..54df425bb0fc 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -3514,6 +3514,12 @@ void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
3514 continue; 3514 continue;
3515 } 3515 }
3516 3516
3517 /* mac80211 would have already asked us to stop beaconing and
3518 * bring the vdev down, so continue in that case
3519 */
3520 if (!arvif->is_up)
3521 continue;
3522
3517 /* There are no completions for beacons so wait for next SWBA 3523 /* There are no completions for beacons so wait for next SWBA
3518 * before telling mac80211 to decrement CSA counter 3524 * before telling mac80211 to decrement CSA counter
3519 * 3525 *
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 48e04b92e231..1b243c899bef 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -55,7 +55,7 @@
55 * type. 55 * type.
56 * 56 *
57 * 6. Comment each parameter part of the WMI command/event structure by 57 * 6. Comment each parameter part of the WMI command/event structure by
58 * using the 2 stars at the begining of C comment instead of one star to 58 * using the 2 stars at the beginning of C comment instead of one star to
59 * enable HTML document generation using Doxygen. 59 * enable HTML document generation using Doxygen.
60 * 60 *
61 */ 61 */
@@ -2087,7 +2087,7 @@ struct wmi_resource_config {
2087 * In offload mode target supports features like WOW, chatter and 2087 * In offload mode target supports features like WOW, chatter and
2088 * other protocol offloads. In order to support them some 2088 * other protocol offloads. In order to support them some
2089 * functionalities like reorder buffering, PN checking need to be 2089 * functionalities like reorder buffering, PN checking need to be
2090 * done in target. This determines maximum number of peers suported 2090 * done in target. This determines maximum number of peers supported
2091 * by target in offload mode 2091 * by target in offload mode
2092 */ 2092 */
2093 __le32 num_offload_peers; 2093 __le32 num_offload_peers;
@@ -2268,7 +2268,7 @@ struct wmi_resource_config {
2268 * Max. number of Tx fragments per MSDU 2268 * Max. number of Tx fragments per MSDU
2269 * This parameter controls the max number of Tx fragments per MSDU. 2269 * This parameter controls the max number of Tx fragments per MSDU.
2270 * This is sent by the target as part of the WMI_SERVICE_READY event 2270 * This is sent by the target as part of the WMI_SERVICE_READY event
2271 * and is overriden by the OS shim as required. 2271 * and is overridden by the OS shim as required.
2272 */ 2272 */
2273 __le32 max_frag_entries; 2273 __le32 max_frag_entries;
2274} __packed; 2274} __packed;
@@ -2450,7 +2450,7 @@ struct wmi_resource_config_10x {
2450 * Max. number of Tx fragments per MSDU 2450 * Max. number of Tx fragments per MSDU
2451 * This parameter controls the max number of Tx fragments per MSDU. 2451 * This parameter controls the max number of Tx fragments per MSDU.
2452 * This is sent by the target as part of the WMI_SERVICE_READY event 2452 * This is sent by the target as part of the WMI_SERVICE_READY event
2453 * and is overriden by the OS shim as required. 2453 * and is overridden by the OS shim as required.
2454 */ 2454 */
2455 __le32 max_frag_entries; 2455 __le32 max_frag_entries;
2456} __packed; 2456} __packed;
@@ -2744,7 +2744,7 @@ struct wmi_init_cmd {
2744 struct wmi_host_mem_chunks mem_chunks; 2744 struct wmi_host_mem_chunks mem_chunks;
2745} __packed; 2745} __packed;
2746 2746
2747/* _10x stucture is from 10.X FW API */ 2747/* _10x structure is from 10.X FW API */
2748struct wmi_init_cmd_10x { 2748struct wmi_init_cmd_10x {
2749 struct wmi_resource_config_10x resource_config; 2749 struct wmi_resource_config_10x resource_config;
2750 struct wmi_host_mem_chunks mem_chunks; 2750 struct wmi_host_mem_chunks mem_chunks;
@@ -3967,7 +3967,7 @@ struct wmi_pdev_stats_tx {
3967 /* illegal rate phy errors */ 3967 /* illegal rate phy errors */
3968 __le32 illgl_rate_phy_err; 3968 __le32 illgl_rate_phy_err;
3969 3969
3970 /* wal pdev continous xretry */ 3970 /* wal pdev continuous xretry */
3971 __le32 pdev_cont_xretry; 3971 __le32 pdev_cont_xretry;
3972 3972
3973 /* wal pdev continous xretry */ 3973 /* wal pdev continous xretry */
@@ -4222,10 +4222,10 @@ struct wmi_10_2_stats_event {
4222 */ 4222 */
4223struct wmi_pdev_stats_base { 4223struct wmi_pdev_stats_base {
4224 __le32 chan_nf; 4224 __le32 chan_nf;
4225 __le32 tx_frame_count; 4225 __le32 tx_frame_count; /* Cycles spent transmitting frames */
4226 __le32 rx_frame_count; 4226 __le32 rx_frame_count; /* Cycles spent receiving frames */
4227 __le32 rx_clear_count; 4227 __le32 rx_clear_count; /* Total channel busy time, evidently */
4228 __le32 cycle_count; 4228 __le32 cycle_count; /* Total on-channel time */
4229 __le32 phy_err_count; 4229 __le32 phy_err_count;
4230 __le32 chan_tx_pwr; 4230 __le32 chan_tx_pwr;
4231} __packed; 4231} __packed;
@@ -4461,9 +4461,9 @@ struct wmi_vdev_start_request_cmd {
4461 __le32 flags; 4461 __le32 flags;
4462 /* ssid field. Only valid for AP/GO/IBSS/BTAmp VDEV type. */ 4462 /* ssid field. Only valid for AP/GO/IBSS/BTAmp VDEV type. */
4463 struct wmi_ssid ssid; 4463 struct wmi_ssid ssid;
4464 /* beacon/probe reponse xmit rate. Applicable for SoftAP. */ 4464 /* beacon/probe response xmit rate. Applicable for SoftAP. */
4465 __le32 bcn_tx_rate; 4465 __le32 bcn_tx_rate;
4466 /* beacon/probe reponse xmit power. Applicable for SoftAP. */ 4466 /* beacon/probe response xmit power. Applicable for SoftAP. */
4467 __le32 bcn_tx_power; 4467 __le32 bcn_tx_power;
4468 /* number of p2p NOA descriptor(s) from scan entry */ 4468 /* number of p2p NOA descriptor(s) from scan entry */
4469 __le32 num_noa_descriptors; 4469 __le32 num_noa_descriptors;
@@ -4691,7 +4691,7 @@ enum wmi_vdev_param {
4691 WMI_VDEV_PARAM_BEACON_INTERVAL, 4691 WMI_VDEV_PARAM_BEACON_INTERVAL,
4692 /* Listen interval in TUs */ 4692 /* Listen interval in TUs */
4693 WMI_VDEV_PARAM_LISTEN_INTERVAL, 4693 WMI_VDEV_PARAM_LISTEN_INTERVAL,
4694 /* muticast rate in Mbps */ 4694 /* multicast rate in Mbps */
4695 WMI_VDEV_PARAM_MULTICAST_RATE, 4695 WMI_VDEV_PARAM_MULTICAST_RATE,
4696 /* management frame rate in Mbps */ 4696 /* management frame rate in Mbps */
4697 WMI_VDEV_PARAM_MGMT_TX_RATE, 4697 WMI_VDEV_PARAM_MGMT_TX_RATE,
@@ -4822,7 +4822,7 @@ enum wmi_10x_vdev_param {
4822 WMI_10X_VDEV_PARAM_BEACON_INTERVAL, 4822 WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
4823 /* Listen interval in TUs */ 4823 /* Listen interval in TUs */
4824 WMI_10X_VDEV_PARAM_LISTEN_INTERVAL, 4824 WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
4825 /* muticast rate in Mbps */ 4825 /* multicast rate in Mbps */
4826 WMI_10X_VDEV_PARAM_MULTICAST_RATE, 4826 WMI_10X_VDEV_PARAM_MULTICAST_RATE,
4827 /* management frame rate in Mbps */ 4827 /* management frame rate in Mbps */
4828 WMI_10X_VDEV_PARAM_MGMT_TX_RATE, 4828 WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
@@ -5067,7 +5067,7 @@ struct wmi_vdev_simple_event {
5067} __packed; 5067} __packed;
5068 5068
5069/* VDEV start response status codes */ 5069/* VDEV start response status codes */
5070/* VDEV succesfully started */ 5070/* VDEV successfully started */
5071#define WMI_INIFIED_VDEV_START_RESPONSE_STATUS_SUCCESS 0x0 5071#define WMI_INIFIED_VDEV_START_RESPONSE_STATUS_SUCCESS 0x0
5072 5072
5073/* requested VDEV not found */ 5073/* requested VDEV not found */
@@ -5383,7 +5383,7 @@ enum wmi_sta_ps_param_pspoll_count {
5383#define WMI_UAPSD_AC_TYPE_TRIG 1 5383#define WMI_UAPSD_AC_TYPE_TRIG 1
5384 5384
5385#define WMI_UAPSD_AC_BIT_MASK(ac, type) \ 5385#define WMI_UAPSD_AC_BIT_MASK(ac, type) \
5386 ((type == WMI_UAPSD_AC_TYPE_DELI) ? (1 << (ac << 1)) : (1 << ((ac << 1) + 1))) 5386 (type == WMI_UAPSD_AC_TYPE_DELI ? 1 << (ac << 1) : 1 << ((ac << 1) + 1))
5387 5387
5388enum wmi_sta_ps_param_uapsd { 5388enum wmi_sta_ps_param_uapsd {
5389 WMI_STA_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0), 5389 WMI_STA_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index b8cf04d11975..3fd1cc98fd2f 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -3520,7 +3520,7 @@ int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
3520 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, 3520 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
3521 NO_SYNC_WMIFLAG); 3521 NO_SYNC_WMIFLAG);
3522 3522
3523 return 0; 3523 return ret;
3524} 3524}
3525 3525
3526int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, 3526int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index f68cb00450e0..8f231c67dd51 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -180,7 +180,7 @@ config ATH9K_HTC_DEBUGFS
180config ATH9K_HWRNG 180config ATH9K_HWRNG
181 bool "Random number generator support" 181 bool "Random number generator support"
182 depends on ATH9K && (HW_RANDOM = y || HW_RANDOM = ATH9K) 182 depends on ATH9K && (HW_RANDOM = y || HW_RANDOM = ATH9K)
183 default y 183 default n
184 ---help--- 184 ---help---
185 This option incorporates the ADC register output as a source of 185 This option incorporates the ADC register output as a source of
186 randomness into Linux entropy pool (/dev/urandom and /dev/random) 186 randomness into Linux entropy pool (/dev/urandom and /dev/random)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
index d1bc51f92686..038a960c5104 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
@@ -194,7 +194,7 @@ retry:
194 } 194 }
195 195
196 /* Check info buffer */ 196 /* Check info buffer */
197 info = (void *)&msg[1]; 197 info = (void *)&bcdc->buf[0];
198 198
199 /* Copy info buffer */ 199 /* Copy info buffer */
200 if (buf) { 200 if (buf) {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 03404cbe9237..72139b579b18 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -420,7 +420,7 @@ u8 brcmf_sdiod_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret)
420 420
421u32 brcmf_sdiod_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret) 421u32 brcmf_sdiod_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret)
422{ 422{
423 u32 data; 423 u32 data = 0;
424 int retval; 424 int retval;
425 425
426 brcmf_dbg(SDIO, "addr:0x%08x\n", addr); 426 brcmf_dbg(SDIO, "addr:0x%08x\n", addr);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 748eaa68cf07..b777e1b2f87a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -1595,15 +1595,9 @@ static s32 brcmf_set_auth_type(struct net_device *ndev,
1595 val = 1; 1595 val = 1;
1596 brcmf_dbg(CONN, "shared key\n"); 1596 brcmf_dbg(CONN, "shared key\n");
1597 break; 1597 break;
1598 case NL80211_AUTHTYPE_AUTOMATIC:
1599 val = 2;
1600 brcmf_dbg(CONN, "automatic\n");
1601 break;
1602 case NL80211_AUTHTYPE_NETWORK_EAP:
1603 brcmf_dbg(CONN, "network eap\n");
1604 default: 1598 default:
1605 val = 2; 1599 val = 2;
1606 brcmf_err("invalid auth type (%d)\n", sme->auth_type); 1600 brcmf_dbg(CONN, "automatic, auth type (%d)\n", sme->auth_type);
1607 break; 1601 break;
1608 } 1602 }
1609 1603
@@ -2533,7 +2527,7 @@ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si)
2533 WL_BSS_INFO_MAX); 2527 WL_BSS_INFO_MAX);
2534 if (err) { 2528 if (err) {
2535 brcmf_err("Failed to get bss info (%d)\n", err); 2529 brcmf_err("Failed to get bss info (%d)\n", err);
2536 return; 2530 goto out_kfree;
2537 } 2531 }
2538 si->filled |= BIT(NL80211_STA_INFO_BSS_PARAM); 2532 si->filled |= BIT(NL80211_STA_INFO_BSS_PARAM);
2539 si->bss_param.beacon_interval = le16_to_cpu(buf->bss_le.beacon_period); 2533 si->bss_param.beacon_interval = le16_to_cpu(buf->bss_le.beacon_period);
@@ -2545,6 +2539,9 @@ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si)
2545 si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; 2539 si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
2546 if (capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 2540 if (capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
2547 si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; 2541 si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
2542
2543out_kfree:
2544 kfree(buf);
2548} 2545}
2549 2546
2550static s32 2547static s32
@@ -3703,6 +3700,7 @@ static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg,
3703 struct cfg80211_wowlan *wowl) 3700 struct cfg80211_wowlan *wowl)
3704{ 3701{
3705 u32 wowl_config; 3702 u32 wowl_config;
3703 struct brcmf_wowl_wakeind_le wowl_wakeind;
3706 u32 i; 3704 u32 i;
3707 3705
3708 brcmf_dbg(TRACE, "Suspend, wowl config.\n"); 3706 brcmf_dbg(TRACE, "Suspend, wowl config.\n");
@@ -3744,8 +3742,9 @@ static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg,
3744 if (!test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state)) 3742 if (!test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state))
3745 wowl_config |= BRCMF_WOWL_UNASSOC; 3743 wowl_config |= BRCMF_WOWL_UNASSOC;
3746 3744
3747 brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", "clear", 3745 memcpy(&wowl_wakeind, "clear", 6);
3748 sizeof(struct brcmf_wowl_wakeind_le)); 3746 brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind,
3747 sizeof(wowl_wakeind));
3749 brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config); 3748 brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config);
3750 brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1); 3749 brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1);
3751 brcmf_bus_wowl_config(cfg->pub->bus_if, true); 3750 brcmf_bus_wowl_config(cfg->pub->bus_if, true);
@@ -4502,6 +4501,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
4502 u16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef); 4501 u16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef);
4503 bool mbss; 4502 bool mbss;
4504 int is_11d; 4503 int is_11d;
4504 bool supports_11d;
4505 4505
4506 brcmf_dbg(TRACE, "ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, dtim_period=%d,\n", 4506 brcmf_dbg(TRACE, "ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, dtim_period=%d,\n",
4507 settings->chandef.chan->hw_value, 4507 settings->chandef.chan->hw_value,
@@ -4514,11 +4514,16 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
4514 mbss = ifp->vif->mbss; 4514 mbss = ifp->vif->mbss;
4515 4515
4516 /* store current 11d setting */ 4516 /* store current 11d setting */
4517 brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY, &ifp->vif->is_11d); 4517 if (brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY,
4518 country_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail, 4518 &ifp->vif->is_11d)) {
4519 settings->beacon.tail_len, 4519 supports_11d = false;
4520 WLAN_EID_COUNTRY); 4520 } else {
4521 is_11d = country_ie ? 1 : 0; 4521 country_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,
4522 settings->beacon.tail_len,
4523 WLAN_EID_COUNTRY);
4524 is_11d = country_ie ? 1 : 0;
4525 supports_11d = true;
4526 }
4522 4527
4523 memset(&ssid_le, 0, sizeof(ssid_le)); 4528 memset(&ssid_le, 0, sizeof(ssid_le));
4524 if (settings->ssid == NULL || settings->ssid_len == 0) { 4529 if (settings->ssid == NULL || settings->ssid_len == 0) {
@@ -4577,7 +4582,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
4577 4582
4578 /* Parameters shared by all radio interfaces */ 4583 /* Parameters shared by all radio interfaces */
4579 if (!mbss) { 4584 if (!mbss) {
4580 if (is_11d != ifp->vif->is_11d) { 4585 if ((supports_11d) && (is_11d != ifp->vif->is_11d)) {
4581 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY, 4586 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
4582 is_11d); 4587 is_11d);
4583 if (err < 0) { 4588 if (err < 0) {
@@ -4619,7 +4624,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
4619 brcmf_err("SET INFRA error %d\n", err); 4624 brcmf_err("SET INFRA error %d\n", err);
4620 goto exit; 4625 goto exit;
4621 } 4626 }
4622 } else if (WARN_ON(is_11d != ifp->vif->is_11d)) { 4627 } else if (WARN_ON(supports_11d && (is_11d != ifp->vif->is_11d))) {
4623 /* Multiple-BSS should use same 11d configuration */ 4628 /* Multiple-BSS should use same 11d configuration */
4624 err = -EINVAL; 4629 err = -EINVAL;
4625 goto exit; 4630 goto exit;
@@ -4753,11 +4758,8 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
4753 brcmf_err("setting INFRA mode failed %d\n", err); 4758 brcmf_err("setting INFRA mode failed %d\n", err);
4754 if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) 4759 if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS))
4755 brcmf_fil_iovar_int_set(ifp, "mbss", 0); 4760 brcmf_fil_iovar_int_set(ifp, "mbss", 0);
4756 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY, 4761 brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
4757 ifp->vif->is_11d); 4762 ifp->vif->is_11d);
4758 if (err < 0)
4759 brcmf_err("restoring REGULATORY setting failed %d\n",
4760 err);
4761 /* Bring device back up so it can be used again */ 4763 /* Bring device back up so it can be used again */
4762 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1); 4764 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
4763 if (err < 0) 4765 if (err < 0)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 65e8c8766441..5eaac13e2317 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -136,27 +136,6 @@ static void _brcmf_set_multicast_list(struct work_struct *work)
136 err); 136 err);
137} 137}
138 138
139static void
140_brcmf_set_mac_address(struct work_struct *work)
141{
142 struct brcmf_if *ifp;
143 s32 err;
144
145 ifp = container_of(work, struct brcmf_if, setmacaddr_work);
146
147 brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
148
149 err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", ifp->mac_addr,
150 ETH_ALEN);
151 if (err < 0) {
152 brcmf_err("Setting cur_etheraddr failed, %d\n", err);
153 } else {
154 brcmf_dbg(TRACE, "MAC address updated to %pM\n",
155 ifp->mac_addr);
156 memcpy(ifp->ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
157 }
158}
159
160#if IS_ENABLED(CONFIG_IPV6) 139#if IS_ENABLED(CONFIG_IPV6)
161static void _brcmf_update_ndtable(struct work_struct *work) 140static void _brcmf_update_ndtable(struct work_struct *work)
162{ 141{
@@ -190,10 +169,20 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr)
190{ 169{
191 struct brcmf_if *ifp = netdev_priv(ndev); 170 struct brcmf_if *ifp = netdev_priv(ndev);
192 struct sockaddr *sa = (struct sockaddr *)addr; 171 struct sockaddr *sa = (struct sockaddr *)addr;
172 int err;
193 173
194 memcpy(&ifp->mac_addr, sa->sa_data, ETH_ALEN); 174 brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
195 schedule_work(&ifp->setmacaddr_work); 175
196 return 0; 176 err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", sa->sa_data,
177 ETH_ALEN);
178 if (err < 0) {
179 brcmf_err("Setting cur_etheraddr failed, %d\n", err);
180 } else {
181 brcmf_dbg(TRACE, "updated to %pM\n", sa->sa_data);
182 memcpy(ifp->mac_addr, sa->sa_data, ETH_ALEN);
183 memcpy(ifp->ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
184 }
185 return err;
197} 186}
198 187
199static void brcmf_netdev_set_multicast_list(struct net_device *ndev) 188static void brcmf_netdev_set_multicast_list(struct net_device *ndev)
@@ -519,13 +508,9 @@ int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked)
519 ndev->needed_headroom += drvr->hdrlen; 508 ndev->needed_headroom += drvr->hdrlen;
520 ndev->ethtool_ops = &brcmf_ethtool_ops; 509 ndev->ethtool_ops = &brcmf_ethtool_ops;
521 510
522 drvr->rxsz = ndev->mtu + ndev->hard_header_len +
523 drvr->hdrlen;
524
525 /* set the mac address */ 511 /* set the mac address */
526 memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN); 512 memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
527 513
528 INIT_WORK(&ifp->setmacaddr_work, _brcmf_set_mac_address);
529 INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list); 514 INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list);
530 INIT_WORK(&ifp->ndoffload_work, _brcmf_update_ndtable); 515 INIT_WORK(&ifp->ndoffload_work, _brcmf_update_ndtable);
531 516
@@ -730,7 +715,6 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
730 } 715 }
731 716
732 if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { 717 if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
733 cancel_work_sync(&ifp->setmacaddr_work);
734 cancel_work_sync(&ifp->multicast_work); 718 cancel_work_sync(&ifp->multicast_work);
735 cancel_work_sync(&ifp->ndoffload_work); 719 cancel_work_sync(&ifp->ndoffload_work);
736 } 720 }
@@ -886,9 +870,12 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb,
886 } 870 }
887 break; 871 break;
888 case NETDEV_DOWN: 872 case NETDEV_DOWN:
889 if (i < NDOL_MAX_ENTRIES) 873 if (i < NDOL_MAX_ENTRIES) {
890 for (; i < ifp->ipv6addr_idx; i++) 874 for (; i < ifp->ipv6addr_idx - 1; i++)
891 table[i] = table[i + 1]; 875 table[i] = table[i + 1];
876 memset(&table[i], 0, sizeof(table[i]));
877 ifp->ipv6addr_idx--;
878 }
892 break; 879 break;
893 default: 880 default:
894 break; 881 break;
@@ -1061,8 +1048,7 @@ fail:
1061 brcmf_fws_del_interface(ifp); 1048 brcmf_fws_del_interface(ifp);
1062 brcmf_fws_deinit(drvr); 1049 brcmf_fws_deinit(drvr);
1063 } 1050 }
1064 if (ifp) 1051 brcmf_net_detach(ifp->ndev, false);
1065 brcmf_net_detach(ifp->ndev, false);
1066 if (p2p_ifp) 1052 if (p2p_ifp)
1067 brcmf_net_detach(p2p_ifp->ndev, false); 1053 brcmf_net_detach(p2p_ifp->ndev, false);
1068 drvr->iflist[0] = NULL; 1054 drvr->iflist[0] = NULL;
@@ -1169,7 +1155,8 @@ int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp)
1169 !brcmf_get_pend_8021x_cnt(ifp), 1155 !brcmf_get_pend_8021x_cnt(ifp),
1170 MAX_WAIT_FOR_8021X_TX); 1156 MAX_WAIT_FOR_8021X_TX);
1171 1157
1172 WARN_ON(!err); 1158 if (!err)
1159 brcmf_err("Timed out waiting for no pending 802.1x packets\n");
1173 1160
1174 return !err; 1161 return !err;
1175} 1162}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index 8fa34cad5a96..c94dcab260d0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -112,15 +112,11 @@ struct brcmf_pub {
112 112
113 /* Internal brcmf items */ 113 /* Internal brcmf items */
114 uint hdrlen; /* Total BRCMF header length (proto + bus) */ 114 uint hdrlen; /* Total BRCMF header length (proto + bus) */
115 uint rxsz; /* Rx buffer size bus module should use */
116 115
117 /* Dongle media info */ 116 /* Dongle media info */
118 char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN]; 117 char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
119 u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */ 118 u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
120 119
121 /* Multicast data packets sent to dongle */
122 unsigned long tx_multicast;
123
124 struct mac_address addresses[BRCMF_MAX_IFS]; 120 struct mac_address addresses[BRCMF_MAX_IFS];
125 121
126 struct brcmf_if *iflist[BRCMF_MAX_IFS]; 122 struct brcmf_if *iflist[BRCMF_MAX_IFS];
@@ -176,7 +172,6 @@ enum brcmf_netif_stop_reason {
176 * @vif: points to cfg80211 specific interface information. 172 * @vif: points to cfg80211 specific interface information.
177 * @ndev: associated network device. 173 * @ndev: associated network device.
178 * @stats: interface specific network statistics. 174 * @stats: interface specific network statistics.
179 * @setmacaddr_work: worker object for setting mac address.
180 * @multicast_work: worker object for multicast provisioning. 175 * @multicast_work: worker object for multicast provisioning.
181 * @ndoffload_work: worker object for neighbor discovery offload configuration. 176 * @ndoffload_work: worker object for neighbor discovery offload configuration.
182 * @fws_desc: interface specific firmware-signalling descriptor. 177 * @fws_desc: interface specific firmware-signalling descriptor.
@@ -193,7 +188,6 @@ struct brcmf_if {
193 struct brcmf_cfg80211_vif *vif; 188 struct brcmf_cfg80211_vif *vif;
194 struct net_device *ndev; 189 struct net_device *ndev;
195 struct net_device_stats stats; 190 struct net_device_stats stats;
196 struct work_struct setmacaddr_work;
197 struct work_struct multicast_work; 191 struct work_struct multicast_work;
198 struct work_struct ndoffload_work; 192 struct work_struct ndoffload_work;
199 struct brcmf_fws_mac_descriptor *fws_desc; 193 struct brcmf_fws_mac_descriptor *fws_desc;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
index 7e269f9aa607..d0b738da2458 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
@@ -234,13 +234,20 @@ static void brcmf_flowring_block(struct brcmf_flowring *flow, u16 flowid,
234 234
235void brcmf_flowring_delete(struct brcmf_flowring *flow, u16 flowid) 235void brcmf_flowring_delete(struct brcmf_flowring *flow, u16 flowid)
236{ 236{
237 struct brcmf_bus *bus_if = dev_get_drvdata(flow->dev);
237 struct brcmf_flowring_ring *ring; 238 struct brcmf_flowring_ring *ring;
239 struct brcmf_if *ifp;
238 u16 hash_idx; 240 u16 hash_idx;
241 u8 ifidx;
239 struct sk_buff *skb; 242 struct sk_buff *skb;
240 243
241 ring = flow->rings[flowid]; 244 ring = flow->rings[flowid];
242 if (!ring) 245 if (!ring)
243 return; 246 return;
247
248 ifidx = brcmf_flowring_ifidx_get(flow, flowid);
249 ifp = brcmf_get_ifp(bus_if->drvr, ifidx);
250
244 brcmf_flowring_block(flow, flowid, false); 251 brcmf_flowring_block(flow, flowid, false);
245 hash_idx = ring->hash_id; 252 hash_idx = ring->hash_id;
246 flow->hash[hash_idx].ifidx = BRCMF_FLOWRING_INVALID_IFIDX; 253 flow->hash[hash_idx].ifidx = BRCMF_FLOWRING_INVALID_IFIDX;
@@ -249,7 +256,7 @@ void brcmf_flowring_delete(struct brcmf_flowring *flow, u16 flowid)
249 256
250 skb = skb_dequeue(&ring->skblist); 257 skb = skb_dequeue(&ring->skblist);
251 while (skb) { 258 while (skb) {
252 brcmu_pkt_buf_free_skb(skb); 259 brcmf_txfinalize(ifp, skb, false);
253 skb = skb_dequeue(&ring->skblist); 260 skb = skb_dequeue(&ring->skblist);
254 } 261 }
255 262
@@ -495,14 +502,18 @@ void brcmf_flowring_add_tdls_peer(struct brcmf_flowring *flow, int ifidx,
495 } else { 502 } else {
496 search = flow->tdls_entry; 503 search = flow->tdls_entry;
497 if (memcmp(search->mac, peer, ETH_ALEN) == 0) 504 if (memcmp(search->mac, peer, ETH_ALEN) == 0)
498 return; 505 goto free_entry;
499 while (search->next) { 506 while (search->next) {
500 search = search->next; 507 search = search->next;
501 if (memcmp(search->mac, peer, ETH_ALEN) == 0) 508 if (memcmp(search->mac, peer, ETH_ALEN) == 0)
502 return; 509 goto free_entry;
503 } 510 }
504 search->next = tdls_entry; 511 search->next = tdls_entry;
505 } 512 }
506 513
507 flow->tdls_active = true; 514 flow->tdls_active = true;
515 return;
516
517free_entry:
518 kfree(tdls_entry);
508} 519}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
index 9f9024a7bd64..a190f535efc9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
@@ -2104,8 +2104,6 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
2104 if ((skb->priority == 0) || (skb->priority > 7)) 2104 if ((skb->priority == 0) || (skb->priority > 7))
2105 skb->priority = cfg80211_classify8021d(skb, NULL); 2105 skb->priority = cfg80211_classify8021d(skb, NULL);
2106 2106
2107 drvr->tx_multicast += !!multicast;
2108
2109 if (fws->avoid_queueing) { 2107 if (fws->avoid_queueing) {
2110 rc = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb); 2108 rc = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb);
2111 if (rc < 0) 2109 if (rc < 0)
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/ucode.c b/drivers/net/wireless/intel/iwlwifi/dvm/ucode.c
index b662cf35b033..c7509c51e9d9 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/ucode.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/ucode.c
@@ -46,15 +46,6 @@
46 * 46 *
47 ******************************************************************************/ 47 ******************************************************************************/
48 48
49static inline const struct fw_img *
50iwl_get_ucode_image(struct iwl_priv *priv, enum iwl_ucode_type ucode_type)
51{
52 if (ucode_type >= IWL_UCODE_TYPE_MAX)
53 return NULL;
54
55 return &priv->fw->img[ucode_type];
56}
57
58/* 49/*
59 * Calibration 50 * Calibration
60 */ 51 */
@@ -330,7 +321,7 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
330 enum iwl_ucode_type old_type; 321 enum iwl_ucode_type old_type;
331 static const u16 alive_cmd[] = { REPLY_ALIVE }; 322 static const u16 alive_cmd[] = { REPLY_ALIVE };
332 323
333 fw = iwl_get_ucode_image(priv, ucode_type); 324 fw = iwl_get_ucode_image(priv->fw, ucode_type);
334 if (WARN_ON(!fw)) 325 if (WARN_ON(!fw))
335 return -EINVAL; 326 return -EINVAL;
336 327
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-7000.c b/drivers/net/wireless/intel/iwlwifi/iwl-7000.c
index 64690c14ff4d..d4b73dedf89b 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-7000.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-7000.c
@@ -73,13 +73,13 @@
73/* Highest firmware API version supported */ 73/* Highest firmware API version supported */
74#define IWL7260_UCODE_API_MAX 17 74#define IWL7260_UCODE_API_MAX 17
75#define IWL7265_UCODE_API_MAX 17 75#define IWL7265_UCODE_API_MAX 17
76#define IWL7265D_UCODE_API_MAX 24 76#define IWL7265D_UCODE_API_MAX 26
77#define IWL3168_UCODE_API_MAX 24 77#define IWL3168_UCODE_API_MAX 26
78 78
79/* Lowest firmware API version supported */ 79/* Lowest firmware API version supported */
80#define IWL7260_UCODE_API_MIN 16 80#define IWL7260_UCODE_API_MIN 17
81#define IWL7265_UCODE_API_MIN 16 81#define IWL7265_UCODE_API_MIN 17
82#define IWL7265D_UCODE_API_MIN 16 82#define IWL7265D_UCODE_API_MIN 17
83#define IWL3168_UCODE_API_MIN 20 83#define IWL3168_UCODE_API_MIN 20
84 84
85/* NVM versions */ 85/* NVM versions */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-8000.c b/drivers/net/wireless/intel/iwlwifi/iwl-8000.c
index 6c6725e808d4..d02ca1491d16 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-8000.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-8000.c
@@ -70,11 +70,11 @@
70#include "iwl-agn-hw.h" 70#include "iwl-agn-hw.h"
71 71
72/* Highest firmware API version supported */ 72/* Highest firmware API version supported */
73#define IWL8000_UCODE_API_MAX 24 73#define IWL8000_UCODE_API_MAX 26
74#define IWL8265_UCODE_API_MAX 24 74#define IWL8265_UCODE_API_MAX 26
75 75
76/* Lowest firmware API version supported */ 76/* Lowest firmware API version supported */
77#define IWL8000_UCODE_API_MIN 16 77#define IWL8000_UCODE_API_MIN 17
78#define IWL8265_UCODE_API_MIN 20 78#define IWL8265_UCODE_API_MIN 20
79 79
80/* NVM versions */ 80/* NVM versions */
@@ -212,6 +212,17 @@ const struct iwl_cfg iwl8265_2ac_cfg = {
212 .vht_mu_mimo_supported = true, 212 .vht_mu_mimo_supported = true,
213}; 213};
214 214
215const struct iwl_cfg iwl8275_2ac_cfg = {
216 .name = "Intel(R) Dual Band Wireless AC 8275",
217 .fw_name_pre = IWL8265_FW_PRE,
218 IWL_DEVICE_8265,
219 .ht_params = &iwl8000_ht_params,
220 .nvm_ver = IWL8000_NVM_VERSION,
221 .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
222 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
223 .vht_mu_mimo_supported = true,
224};
225
215const struct iwl_cfg iwl4165_2ac_cfg = { 226const struct iwl_cfg iwl4165_2ac_cfg = {
216 .name = "Intel(R) Dual Band Wireless AC 4165", 227 .name = "Intel(R) Dual Band Wireless AC 4165",
217 .fw_name_pre = IWL8000_FW_PRE, 228 .fw_name_pre = IWL8000_FW_PRE,
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-9000.c b/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
index 1fec6afbe041..ff850410d897 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
@@ -55,10 +55,10 @@
55#include "iwl-agn-hw.h" 55#include "iwl-agn-hw.h"
56 56
57/* Highest firmware API version supported */ 57/* Highest firmware API version supported */
58#define IWL9000_UCODE_API_MAX 24 58#define IWL9000_UCODE_API_MAX 26
59 59
60/* Lowest firmware API version supported */ 60/* Lowest firmware API version supported */
61#define IWL9000_UCODE_API_MIN 16 61#define IWL9000_UCODE_API_MIN 17
62 62
63/* NVM versions */ 63/* NVM versions */
64#define IWL9000_NVM_VERSION 0x0a1d 64#define IWL9000_NVM_VERSION 0x0a1d
@@ -187,6 +187,17 @@ const struct iwl_cfg iwl9460_2ac_cfg = {
187 .integrated = true, 187 .integrated = true,
188}; 188};
189 189
190const struct iwl_cfg iwl9560_2ac_cfg = {
191 .name = "Intel(R) Dual Band Wireless AC 9560",
192 .fw_name_pre = IWL9000_FW_PRE,
193 IWL_DEVICE_9000,
194 .ht_params = &iwl9000_ht_params,
195 .nvm_ver = IWL9000_NVM_VERSION,
196 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
197 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
198 .integrated = true,
199};
200
190/* 201/*
191 * TODO the struct below is for internal testing only this should be 202 * TODO the struct below is for internal testing only this should be
192 * removed by EO 2016~ 203 * removed by EO 2016~
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-a000.c b/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
index 4d78232c8afe..ea1618525878 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
@@ -55,7 +55,7 @@
55#include "iwl-agn-hw.h" 55#include "iwl-agn-hw.h"
56 56
57/* Highest firmware API version supported */ 57/* Highest firmware API version supported */
58#define IWL_A000_UCODE_API_MAX 24 58#define IWL_A000_UCODE_API_MAX 26
59 59
60/* Lowest firmware API version supported */ 60/* Lowest firmware API version supported */
61#define IWL_A000_UCODE_API_MIN 24 61#define IWL_A000_UCODE_API_MIN 24
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index 7008319532ef..2660cc4b9f8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -359,7 +359,6 @@ struct iwl_cfg {
359 high_temp:1, 359 high_temp:1,
360 mac_addr_from_csr:1, 360 mac_addr_from_csr:1,
361 lp_xtal_workaround:1, 361 lp_xtal_workaround:1,
362 no_power_up_nic_in_init:1,
363 disable_dummy_notification:1, 362 disable_dummy_notification:1,
364 apmg_not_supported:1, 363 apmg_not_supported:1,
365 mq_rx_supported:1, 364 mq_rx_supported:1,
@@ -445,6 +444,7 @@ extern const struct iwl_cfg iwl7265d_n_cfg;
445extern const struct iwl_cfg iwl8260_2n_cfg; 444extern const struct iwl_cfg iwl8260_2n_cfg;
446extern const struct iwl_cfg iwl8260_2ac_cfg; 445extern const struct iwl_cfg iwl8260_2ac_cfg;
447extern const struct iwl_cfg iwl8265_2ac_cfg; 446extern const struct iwl_cfg iwl8265_2ac_cfg;
447extern const struct iwl_cfg iwl8275_2ac_cfg;
448extern const struct iwl_cfg iwl4165_2ac_cfg; 448extern const struct iwl_cfg iwl4165_2ac_cfg;
449extern const struct iwl_cfg iwl8260_2ac_sdio_cfg; 449extern const struct iwl_cfg iwl8260_2ac_sdio_cfg;
450extern const struct iwl_cfg iwl8265_2ac_sdio_cfg; 450extern const struct iwl_cfg iwl8265_2ac_sdio_cfg;
@@ -454,6 +454,7 @@ extern const struct iwl_cfg iwl9160_2ac_cfg;
454extern const struct iwl_cfg iwl9260_2ac_cfg; 454extern const struct iwl_cfg iwl9260_2ac_cfg;
455extern const struct iwl_cfg iwl9270_2ac_cfg; 455extern const struct iwl_cfg iwl9270_2ac_cfg;
456extern const struct iwl_cfg iwl9460_2ac_cfg; 456extern const struct iwl_cfg iwl9460_2ac_cfg;
457extern const struct iwl_cfg iwl9560_2ac_cfg;
457extern const struct iwl_cfg iwla000_2ac_cfg; 458extern const struct iwl_cfg iwla000_2ac_cfg;
458#endif /* CONFIG_IWLMVM */ 459#endif /* CONFIG_IWLMVM */
459 460
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index 871ad02fdb17..d73e9d436027 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -589,6 +589,8 @@ enum dtd_diode_reg {
589 * Causes for the FH register interrupts 589 * Causes for the FH register interrupts
590 */ 590 */
591enum msix_fh_int_causes { 591enum msix_fh_int_causes {
592 MSIX_FH_INT_CAUSES_Q0 = BIT(0),
593 MSIX_FH_INT_CAUSES_Q1 = BIT(1),
592 MSIX_FH_INT_CAUSES_D2S_CH0_NUM = BIT(16), 594 MSIX_FH_INT_CAUSES_D2S_CH0_NUM = BIT(16),
593 MSIX_FH_INT_CAUSES_D2S_CH1_NUM = BIT(17), 595 MSIX_FH_INT_CAUSES_D2S_CH1_NUM = BIT(17),
594 MSIX_FH_INT_CAUSES_S2D = BIT(19), 596 MSIX_FH_INT_CAUSES_S2D = BIT(19),
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
index 1d9dd153ef1c..50510fb6ab8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
@@ -33,9 +33,6 @@
33#define CREATE_TRACE_POINTS 33#define CREATE_TRACE_POINTS
34#include "iwl-devtrace.h" 34#include "iwl-devtrace.h"
35 35
36EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_iowrite8);
37EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ioread32);
38EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_iowrite32);
39EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_event); 36EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_event);
40EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_error); 37EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_error);
41EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_cont_event); 38EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_cont_event);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fh.h b/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
index dd75ea7c936e..33ef5372d195 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
@@ -643,6 +643,7 @@ struct iwl_rb_status {
643#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) 643#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
644#define IWL_TX_DMA_MASK DMA_BIT_MASK(36) 644#define IWL_TX_DMA_MASK DMA_BIT_MASK(36)
645#define IWL_NUM_OF_TBS 20 645#define IWL_NUM_OF_TBS 20
646#define IWL_TFH_NUM_TBS 25
646 647
647static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr) 648static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
648{ 649{
@@ -664,25 +665,29 @@ struct iwl_tfd_tb {
664} __packed; 665} __packed;
665 666
666/** 667/**
667 * struct iwl_tfd 668 * struct iwl_tfh_tb transmit buffer descriptor within transmit frame descriptor
668 * 669 *
669 * Transmit Frame Descriptor (TFD) 670 * This structure contains dma address and length of transmission address
670 *
671 * @ __reserved1[3] reserved
672 * @ num_tbs 0-4 number of active tbs
673 * 5 reserved
674 * 6-7 padding (not used)
675 * @ tbs[20] transmit frame buffer descriptors
676 * @ __pad padding
677 * 671 *
672 * @tb_len length of the tx buffer
673 * @addr 64 bits dma address
674 */
675struct iwl_tfh_tb {
676 __le16 tb_len;
677 __le64 addr;
678} __packed;
679
680/**
678 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. 681 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
679 * Both driver and device share these circular buffers, each of which must be 682 * Both driver and device share these circular buffers, each of which must be
680 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes 683 * contiguous 256 TFDs.
684 * For pre a000 HW it is 256 x 128 bytes-per-TFD = 32 KBytes
685 * For a000 HW and on it is 256 x 256 bytes-per-TFD = 65 KBytes
681 * 686 *
682 * Driver must indicate the physical address of the base of each 687 * Driver must indicate the physical address of the base of each
683 * circular buffer via the FH_MEM_CBBC_QUEUE registers. 688 * circular buffer via the FH_MEM_CBBC_QUEUE registers.
684 * 689 *
685 * Each TFD contains pointer/size information for up to 20 data buffers 690 * Each TFD contains pointer/size information for up to 20 / 25 data buffers
686 * in host DRAM. These buffers collectively contain the (one) frame described 691 * in host DRAM. These buffers collectively contain the (one) frame described
687 * by the TFD. Each buffer must be a single contiguous block of memory within 692 * by the TFD. Each buffer must be a single contiguous block of memory within
688 * itself, but buffers may be scattered in host DRAM. Each buffer has max size 693 * itself, but buffers may be scattered in host DRAM. Each buffer has max size
@@ -691,6 +696,16 @@ struct iwl_tfd_tb {
691 * 696 *
692 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. 697 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
693 */ 698 */
699
700/**
701 * struct iwl_tfd - Transmit Frame Descriptor (TFD)
702 * @ __reserved1[3] reserved
703 * @ num_tbs 0-4 number of active tbs
704 * 5 reserved
705 * 6-7 padding (not used)
706 * @ tbs[20] transmit frame buffer descriptors
707 * @ __pad padding
708 */
694struct iwl_tfd { 709struct iwl_tfd {
695 u8 __reserved1[3]; 710 u8 __reserved1[3];
696 u8 num_tbs; 711 u8 num_tbs;
@@ -698,6 +713,19 @@ struct iwl_tfd {
698 __le32 __pad; 713 __le32 __pad;
699} __packed; 714} __packed;
700 715
716/**
717 * struct iwl_tfh_tfd - Transmit Frame Descriptor (TFD)
718 * @ num_tbs 0-4 number of active tbs
719 * 5 -15 reserved
720 * @ tbs[25] transmit frame buffer descriptors
721 * @ __pad padding
722 */
723struct iwl_tfh_tfd {
724 __le16 num_tbs;
725 struct iwl_tfh_tb tbs[IWL_TFH_NUM_TBS];
726 __le32 __pad;
727} __packed;
728
701/* Keep Warm Size */ 729/* Keep Warm Size */
702#define IWL_KW_SIZE 0x1000 /* 4k */ 730#define IWL_KW_SIZE 0x1000 /* 4k */
703 731
@@ -706,8 +734,13 @@ struct iwl_tfd {
706/** 734/**
707 * struct iwlagn_schedq_bc_tbl scheduler byte count table 735 * struct iwlagn_schedq_bc_tbl scheduler byte count table
708 * base physical address provided by SCD_DRAM_BASE_ADDR 736 * base physical address provided by SCD_DRAM_BASE_ADDR
737 * For devices up to a000:
738 * @tfd_offset 0-12 - tx command byte count
739 * 12-16 - station index
740 * For a000 and on:
709 * @tfd_offset 0-12 - tx command byte count 741 * @tfd_offset 0-12 - tx command byte count
710 * 12-16 - station index 742 * 12-13 - number of 64 byte chunks
743 * 14-16 - reserved
711 */ 744 */
712struct iwlagn_scd_bc_tbl { 745struct iwlagn_scd_bc_tbl {
713 __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; 746 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
index 1b1e045f8907..ceec5ca2b1ab 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
@@ -199,8 +199,6 @@ struct iwl_ucode_capa {
199 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behavior on hidden SSID, 199 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behavior on hidden SSID,
200 * treats good CRC threshold as a boolean 200 * treats good CRC threshold as a boolean
201 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). 201 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
202 * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
203 * @IWL_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS
204 * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: This uCode image supports uAPSD 202 * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: This uCode image supports uAPSD
205 * @IWL_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan 203 * @IWL_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan
206 * offload profile config command. 204 * offload profile config command.
@@ -210,36 +208,24 @@ struct iwl_ucode_capa {
210 * from the probe request template. 208 * from the probe request template.
211 * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version) 209 * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version)
212 * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version) 210 * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version)
213 * @IWL_UCODE_TLV_FLAGS_P2P_PM: P2P client supports PM as a stand alone MAC
214 * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_DCM: support power save on BSS station and
215 * P2P client interfaces simultaneously if they are in different bindings.
216 * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_SCM: support power save on BSS station and
217 * P2P client interfaces simultaneously if they are in same bindings.
218 * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD 211 * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD
219 * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save 212 * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
220 * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering. 213 * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
221 * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients
222 * @IWL_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS. 214 * @IWL_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS.
223 */ 215 */
224enum iwl_ucode_tlv_flag { 216enum iwl_ucode_tlv_flag {
225 IWL_UCODE_TLV_FLAGS_PAN = BIT(0), 217 IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
226 IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), 218 IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
227 IWL_UCODE_TLV_FLAGS_MFP = BIT(2), 219 IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
228 IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
229 IWL_UCODE_TLV_FLAGS_DW_BC_TABLE = BIT(4),
230 IWL_UCODE_TLV_FLAGS_SHORT_BL = BIT(7), 220 IWL_UCODE_TLV_FLAGS_SHORT_BL = BIT(7),
231 IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS = BIT(10), 221 IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS = BIT(10),
232 IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID = BIT(12), 222 IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID = BIT(12),
233 IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL = BIT(15), 223 IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL = BIT(15),
234 IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE = BIT(16), 224 IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE = BIT(16),
235 IWL_UCODE_TLV_FLAGS_P2P_PM = BIT(21),
236 IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM = BIT(22),
237 IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM = BIT(23),
238 IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT = BIT(24), 225 IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT = BIT(24),
239 IWL_UCODE_TLV_FLAGS_EBS_SUPPORT = BIT(25), 226 IWL_UCODE_TLV_FLAGS_EBS_SUPPORT = BIT(25),
240 IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD = BIT(26), 227 IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD = BIT(26),
241 IWL_UCODE_TLV_FLAGS_BCAST_FILTERING = BIT(29), 228 IWL_UCODE_TLV_FLAGS_BCAST_FILTERING = BIT(29),
242 IWL_UCODE_TLV_FLAGS_GO_UAPSD = BIT(30),
243}; 229};
244 230
245typedef unsigned int __bitwise__ iwl_ucode_tlv_api_t; 231typedef unsigned int __bitwise__ iwl_ucode_tlv_api_t;
@@ -249,24 +235,21 @@ typedef unsigned int __bitwise__ iwl_ucode_tlv_api_t;
249 * @IWL_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time 235 * @IWL_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time
250 * longer than the passive one, which is essential for fragmented scan. 236 * longer than the passive one, which is essential for fragmented scan.
251 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source. 237 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
252 * @IWL_UCODE_TLV_API_WIDE_CMD_HDR: ucode supports wide command header
253 * @IWL_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params 238 * @IWL_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params
254 * @IWL_UCODE_TLV_API_NEW_VERSION: new versioning format 239 * @IWL_UCODE_TLV_API_NEW_VERSION: new versioning format
255 * @IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY: scan APIs use 8-level priority 240 * @IWL_UCODE_TLV_API_SCAN_TSF_REPORT: Scan start time reported in scan
256 * instead of 3. 241 * iteration complete notification, and the timestamp reported for RX
257 * @IWL_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size 242 * received during scan, are reported in TSF of the mac specified in the
258 * (command version 3) that supports per-chain limits 243 * scan request.
259 * 244 *
260 * @NUM_IWL_UCODE_TLV_API: number of bits used 245 * @NUM_IWL_UCODE_TLV_API: number of bits used
261 */ 246 */
262enum iwl_ucode_tlv_api { 247enum iwl_ucode_tlv_api {
263 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = (__force iwl_ucode_tlv_api_t)8, 248 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = (__force iwl_ucode_tlv_api_t)8,
264 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = (__force iwl_ucode_tlv_api_t)9, 249 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = (__force iwl_ucode_tlv_api_t)9,
265 IWL_UCODE_TLV_API_WIDE_CMD_HDR = (__force iwl_ucode_tlv_api_t)14,
266 IWL_UCODE_TLV_API_LQ_SS_PARAMS = (__force iwl_ucode_tlv_api_t)18, 250 IWL_UCODE_TLV_API_LQ_SS_PARAMS = (__force iwl_ucode_tlv_api_t)18,
267 IWL_UCODE_TLV_API_NEW_VERSION = (__force iwl_ucode_tlv_api_t)20, 251 IWL_UCODE_TLV_API_NEW_VERSION = (__force iwl_ucode_tlv_api_t)20,
268 IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY = (__force iwl_ucode_tlv_api_t)24, 252 IWL_UCODE_TLV_API_SCAN_TSF_REPORT = (__force iwl_ucode_tlv_api_t)28,
269 IWL_UCODE_TLV_API_TX_POWER_CHAIN = (__force iwl_ucode_tlv_api_t)27,
270 253
271 NUM_IWL_UCODE_TLV_API 254 NUM_IWL_UCODE_TLV_API
272#ifdef __CHECKER__ 255#ifdef __CHECKER__
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw.h b/drivers/net/wireless/intel/iwlwifi/iwl-fw.h
index 74ea68d1063c..5f229556339a 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw.h
@@ -329,4 +329,13 @@ iwl_fw_dbg_conf_usniffer(const struct iwl_fw *fw, u8 id)
329 return conf_tlv->usniffer; 329 return conf_tlv->usniffer;
330} 330}
331 331
332static inline const struct fw_img *
333iwl_get_ucode_image(const struct iwl_fw *fw, enum iwl_ucode_type ucode_type)
334{
335 if (ucode_type >= IWL_UCODE_TYPE_MAX)
336 return NULL;
337
338 return &fw->img[ucode_type];
339}
340
332#endif /* __iwl_fw_h__ */ 341#endif /* __iwl_fw_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.c b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
index 92c8b5f9a9cb..a9f69fdd170b 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
@@ -267,7 +267,7 @@ static const char *get_rfh_string(int cmd)
267 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_WIDX, i); 267 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_WIDX, i);
268 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_RIDX, i); 268 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_RIDX, i);
269 IWL_CMD_MQ(cmd, RFH_Q_URBD_STTS_WPTR_LSB, i); 269 IWL_CMD_MQ(cmd, RFH_Q_URBD_STTS_WPTR_LSB, i);
270 }; 270 }
271 271
272 switch (cmd) { 272 switch (cmd) {
273 IWL_CMD(RFH_RXF_DMA_CFG); 273 IWL_CMD(RFH_RXF_DMA_CFG);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
index 8aa1f2b7fdfc..88f260db3744 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
@@ -99,8 +99,12 @@ void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_wait,
99 continue; 99 continue;
100 100
101 for (i = 0; i < w->n_cmds; i++) { 101 for (i = 0; i < w->n_cmds; i++) {
102 if (w->cmds[i] == 102 u16 rec_id = WIDE_ID(pkt->hdr.group_id,
103 WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)) { 103 pkt->hdr.cmd);
104
105 if (w->cmds[i] == rec_id ||
106 (!iwl_cmd_groupid(w->cmds[i]) &&
107 DEF_ID(w->cmds[i]) == rec_id)) {
104 found = true; 108 found = true;
105 break; 109 break;
106 } 110 }
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 43f8f7d45ddb..3bd6fc1b76d4 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -67,6 +67,7 @@
67#include <linux/export.h> 67#include <linux/export.h>
68#include <linux/etherdevice.h> 68#include <linux/etherdevice.h>
69#include <linux/pci.h> 69#include <linux/pci.h>
70#include <linux/acpi.h>
70#include "iwl-drv.h" 71#include "iwl-drv.h"
71#include "iwl-modparams.h" 72#include "iwl-modparams.h"
72#include "iwl-nvm-parse.h" 73#include "iwl-nvm-parse.h"
@@ -564,11 +565,16 @@ static void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
564 __le32 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_STRAP)); 565 __le32 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_STRAP));
565 __le32 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_STRAP)); 566 __le32 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_STRAP));
566 567
567 /* If OEM did not fuse address - get it from OTP */ 568 iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
568 if (!mac_addr0 && !mac_addr1) { 569 /*
569 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP)); 570 * If the OEM fused a valid address, use it instead of the one in the
570 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP)); 571 * OTP
571 } 572 */
573 if (is_valid_ether_addr(data->hw_addr))
574 return;
575
576 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP));
577 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP));
572 578
573 iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr); 579 iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
574} 580}
@@ -899,3 +905,91 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
899 return regd; 905 return regd;
900} 906}
901IWL_EXPORT_SYMBOL(iwl_parse_nvm_mcc_info); 907IWL_EXPORT_SYMBOL(iwl_parse_nvm_mcc_info);
908
909#ifdef CONFIG_ACPI
910#define WRDD_METHOD "WRDD"
911#define WRDD_WIFI (0x07)
912#define WRDD_WIGIG (0x10)
913
914static u32 iwl_wrdd_get_mcc(struct device *dev, union acpi_object *wrdd)
915{
916 union acpi_object *mcc_pkg, *domain_type, *mcc_value;
917 u32 i;
918
919 if (wrdd->type != ACPI_TYPE_PACKAGE ||
920 wrdd->package.count < 2 ||
921 wrdd->package.elements[0].type != ACPI_TYPE_INTEGER ||
922 wrdd->package.elements[0].integer.value != 0) {
923 IWL_DEBUG_EEPROM(dev, "Unsupported wrdd structure\n");
924 return 0;
925 }
926
927 for (i = 1 ; i < wrdd->package.count ; ++i) {
928 mcc_pkg = &wrdd->package.elements[i];
929
930 if (mcc_pkg->type != ACPI_TYPE_PACKAGE ||
931 mcc_pkg->package.count < 2 ||
932 mcc_pkg->package.elements[0].type != ACPI_TYPE_INTEGER ||
933 mcc_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
934 mcc_pkg = NULL;
935 continue;
936 }
937
938 domain_type = &mcc_pkg->package.elements[0];
939 if (domain_type->integer.value == WRDD_WIFI)
940 break;
941
942 mcc_pkg = NULL;
943 }
944
945 if (mcc_pkg) {
946 mcc_value = &mcc_pkg->package.elements[1];
947 return mcc_value->integer.value;
948 }
949
950 return 0;
951}
952
953int iwl_get_bios_mcc(struct device *dev, char *mcc)
954{
955 acpi_handle root_handle;
956 acpi_handle handle;
957 struct acpi_buffer wrdd = {ACPI_ALLOCATE_BUFFER, NULL};
958 acpi_status status;
959 u32 mcc_val;
960
961 root_handle = ACPI_HANDLE(dev);
962 if (!root_handle) {
963 IWL_DEBUG_EEPROM(dev,
964 "Could not retrieve root port ACPI handle\n");
965 return -ENOENT;
966 }
967
968 /* Get the method's handle */
969 status = acpi_get_handle(root_handle, (acpi_string)WRDD_METHOD,
970 &handle);
971 if (ACPI_FAILURE(status)) {
972 IWL_DEBUG_EEPROM(dev, "WRD method not found\n");
973 return -ENOENT;
974 }
975
976 /* Call WRDD with no arguments */
977 status = acpi_evaluate_object(handle, NULL, NULL, &wrdd);
978 if (ACPI_FAILURE(status)) {
979 IWL_DEBUG_EEPROM(dev, "WRDC invocation failed (0x%x)\n",
980 status);
981 return -ENOENT;
982 }
983
984 mcc_val = iwl_wrdd_get_mcc(dev, wrdd.pointer);
985 kfree(wrdd.pointer);
986 if (!mcc_val)
987 return -ENOENT;
988
989 mcc[0] = (mcc_val >> 8) & 0xff;
990 mcc[1] = mcc_val & 0xff;
991 mcc[2] = '\0';
992 return 0;
993}
994IWL_EXPORT_SYMBOL(iwl_get_bios_mcc);
995#endif
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
index d704d52aa7ec..7249e5b403f4 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
@@ -5,7 +5,8 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2015 Intel Corporation. All rights reserved.
9 * Copyright(c) 2016 Intel Deutschland GmbH
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify 11 * 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 * it under the terms of version 2 of the GNU General Public License as
@@ -93,4 +94,21 @@ struct ieee80211_regdomain *
93iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, 94iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
94 int num_of_ch, __le32 *channels, u16 fw_mcc); 95 int num_of_ch, __le32 *channels, u16 fw_mcc);
95 96
97#ifdef CONFIG_ACPI
98/**
99 * iwl_get_bios_mcc - read MCC from BIOS, if available
100 *
101 * @dev: the struct device
102 * @mcc: output buffer (3 bytes) that will get the MCC
103 *
104 * This function tries to read the current MCC from ACPI if available.
105 */
106int iwl_get_bios_mcc(struct device *dev, char *mcc);
107#else
108static inline int iwl_get_bios_mcc(struct device *dev, char *mcc)
109{
110 return -ENOENT;
111}
112#endif
113
96#endif /* __iwl_nvm_parse_h__ */ 114#endif /* __iwl_nvm_parse_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
index 7beba9ae5617..2893826d7d2b 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
@@ -110,7 +110,7 @@ enum iwl_phy_db_section_type {
110 IWL_PHY_DB_MAX 110 IWL_PHY_DB_MAX
111}; 111};
112 112
113#define PHY_DB_CMD 0x6c /* TEMP API - The actual is 0x8c */ 113#define PHY_DB_CMD 0x6c
114 114
115/* 115/*
116 * phy db - configure operational ucode 116 * phy db - configure operational ucode
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index 6069a9ff53fa..d42cab291025 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -65,6 +65,7 @@
65 65
66#include "iwl-trans.h" 66#include "iwl-trans.h"
67#include "iwl-drv.h" 67#include "iwl-drv.h"
68#include "iwl-fh.h"
68 69
69struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, 70struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
70 struct device *dev, 71 struct device *dev,
@@ -77,7 +78,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
77 static struct lock_class_key __key; 78 static struct lock_class_key __key;
78#endif 79#endif
79 80
80 trans = kzalloc(sizeof(*trans) + priv_size, GFP_KERNEL); 81 trans = devm_kzalloc(dev, sizeof(*trans) + priv_size, GFP_KERNEL);
81 if (!trans) 82 if (!trans)
82 return NULL; 83 return NULL;
83 84
@@ -102,18 +103,14 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
102 SLAB_HWCACHE_ALIGN, 103 SLAB_HWCACHE_ALIGN,
103 NULL); 104 NULL);
104 if (!trans->dev_cmd_pool) 105 if (!trans->dev_cmd_pool)
105 goto free; 106 return NULL;
106 107
107 return trans; 108 return trans;
108 free:
109 kfree(trans);
110 return NULL;
111} 109}
112 110
113void iwl_trans_free(struct iwl_trans *trans) 111void iwl_trans_free(struct iwl_trans *trans)
114{ 112{
115 kmem_cache_destroy(trans->dev_cmd_pool); 113 kmem_cache_destroy(trans->dev_cmd_pool);
116 kfree(trans);
117} 114}
118 115
119int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) 116int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
@@ -139,6 +136,9 @@ int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
139 if (!(cmd->flags & CMD_ASYNC)) 136 if (!(cmd->flags & CMD_ASYNC))
140 lock_map_acquire_read(&trans->sync_cmd_lockdep_map); 137 lock_map_acquire_read(&trans->sync_cmd_lockdep_map);
141 138
139 if (trans->wide_cmd_header && !iwl_cmd_groupid(cmd->id))
140 cmd->id = DEF_ID(cmd->id);
141
142 ret = trans->ops->send_cmd(trans, cmd); 142 ret = trans->ops->send_cmd(trans, cmd);
143 143
144 if (!(cmd->flags & CMD_ASYNC)) 144 if (!(cmd->flags & CMD_ASYNC))
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 5535e2238da3..0296124a7f9c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -153,6 +153,7 @@ static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 version)
153 153
154/* make u16 wide id out of u8 group and opcode */ 154/* make u16 wide id out of u8 group and opcode */
155#define WIDE_ID(grp, opcode) ((grp << 8) | opcode) 155#define WIDE_ID(grp, opcode) ((grp << 8) | opcode)
156#define DEF_ID(opcode) ((1 << 8) | (opcode))
156 157
157/* due to the conversion, this group is special; new groups 158/* due to the conversion, this group is special; new groups
158 * should be defined in the appropriate fw-api header files 159 * should be defined in the appropriate fw-api header files
@@ -262,8 +263,6 @@ static inline u32 iwl_rx_packet_payload_len(const struct iwl_rx_packet *pkt)
262 * (i.e. mark it as non-idle). 263 * (i.e. mark it as non-idle).
263 * @CMD_WANT_ASYNC_CALLBACK: the op_mode's async callback function must be 264 * @CMD_WANT_ASYNC_CALLBACK: the op_mode's async callback function must be
264 * called after this command completes. Valid only with CMD_ASYNC. 265 * called after this command completes. Valid only with CMD_ASYNC.
265 * @CMD_TB_BITMAP_POS: Position of the first bit for the TB bitmap. We need to
266 * check that we leave enough room for the TBs bitmap which needs 20 bits.
267 */ 266 */
268enum CMD_MODE { 267enum CMD_MODE {
269 CMD_ASYNC = BIT(0), 268 CMD_ASYNC = BIT(0),
@@ -274,8 +273,6 @@ enum CMD_MODE {
274 CMD_MAKE_TRANS_IDLE = BIT(5), 273 CMD_MAKE_TRANS_IDLE = BIT(5),
275 CMD_WAKE_UP_TRANS = BIT(6), 274 CMD_WAKE_UP_TRANS = BIT(6),
276 CMD_WANT_ASYNC_CALLBACK = BIT(7), 275 CMD_WANT_ASYNC_CALLBACK = BIT(7),
277
278 CMD_TB_BITMAP_POS = 11,
279}; 276};
280 277
281#define DEF_CMD_PAYLOAD_SIZE 320 278#define DEF_CMD_PAYLOAD_SIZE 320
@@ -488,7 +485,6 @@ struct iwl_hcmd_arr {
488 * @bc_table_dword: set to true if the BC table expects the byte count to be 485 * @bc_table_dword: set to true if the BC table expects the byte count to be
489 * in DWORD (as opposed to bytes) 486 * in DWORD (as opposed to bytes)
490 * @scd_set_active: should the transport configure the SCD for HCMD queue 487 * @scd_set_active: should the transport configure the SCD for HCMD queue
491 * @wide_cmd_header: firmware supports wide host command header
492 * @sw_csum_tx: transport should compute the TCP checksum 488 * @sw_csum_tx: transport should compute the TCP checksum
493 * @command_groups: array of command groups, each member is an array of the 489 * @command_groups: array of command groups, each member is an array of the
494 * commands in the group; for debugging only 490 * commands in the group; for debugging only
@@ -510,7 +506,6 @@ struct iwl_trans_config {
510 enum iwl_amsdu_size rx_buf_size; 506 enum iwl_amsdu_size rx_buf_size;
511 bool bc_table_dword; 507 bool bc_table_dword;
512 bool scd_set_active; 508 bool scd_set_active;
513 bool wide_cmd_header;
514 bool sw_csum_tx; 509 bool sw_csum_tx;
515 const struct iwl_hcmd_arr *command_groups; 510 const struct iwl_hcmd_arr *command_groups;
516 int command_groups_size; 511 int command_groups_size;
@@ -649,6 +644,8 @@ struct iwl_trans_ops {
649 void (*txq_set_shared_mode)(struct iwl_trans *trans, u32 txq_id, 644 void (*txq_set_shared_mode)(struct iwl_trans *trans, u32 txq_id,
650 bool shared); 645 bool shared);
651 646
647 dma_addr_t (*get_txq_byte_table)(struct iwl_trans *trans, int txq_id);
648
652 int (*wait_tx_queue_empty)(struct iwl_trans *trans, u32 txq_bm); 649 int (*wait_tx_queue_empty)(struct iwl_trans *trans, u32 txq_bm);
653 void (*freeze_txq_timer)(struct iwl_trans *trans, unsigned long txqs, 650 void (*freeze_txq_timer)(struct iwl_trans *trans, unsigned long txqs,
654 bool freeze); 651 bool freeze);
@@ -772,6 +769,7 @@ enum iwl_plat_pm_mode {
772 * @hw_id_str: a string with info about HW ID. Set during transport allocation. 769 * @hw_id_str: a string with info about HW ID. Set during transport allocation.
773 * @pm_support: set to true in start_hw if link pm is supported 770 * @pm_support: set to true in start_hw if link pm is supported
774 * @ltr_enabled: set to true if the LTR is enabled 771 * @ltr_enabled: set to true if the LTR is enabled
772 * @wide_cmd_header: true when ucode supports wide command header format
775 * @num_rx_queues: number of RX queues allocated by the transport; 773 * @num_rx_queues: number of RX queues allocated by the transport;
776 * the transport must set this before calling iwl_drv_start() 774 * the transport must set this before calling iwl_drv_start()
777 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only. 775 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only.
@@ -823,6 +821,7 @@ struct iwl_trans {
823 821
824 const struct iwl_hcmd_arr *command_groups; 822 const struct iwl_hcmd_arr *command_groups;
825 int command_groups_size; 823 int command_groups_size;
824 bool wide_cmd_header;
826 825
827 u8 num_rx_queues; 826 u8 num_rx_queues;
828 827
@@ -1073,6 +1072,15 @@ static inline void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans,
1073 trans->ops->txq_set_shared_mode(trans, queue, shared_mode); 1072 trans->ops->txq_set_shared_mode(trans, queue, shared_mode);
1074} 1073}
1075 1074
1075static inline dma_addr_t iwl_trans_get_txq_byte_table(struct iwl_trans *trans,
1076 int queue)
1077{
1078 /* we should never be called if the trans doesn't support it */
1079 BUG_ON(!trans->ops->get_txq_byte_table);
1080
1081 return trans->ops->get_txq_byte_table(trans, queue);
1082}
1083
1076static inline void iwl_trans_txq_enable(struct iwl_trans *trans, int queue, 1084static inline void iwl_trans_txq_enable(struct iwl_trans *trans, int queue,
1077 int fifo, int sta_id, int tid, 1085 int fifo, int sta_id, int tid,
1078 int frame_limit, u16 ssn, 1086 int frame_limit, u16 ssn,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index b23271755daf..2d6f44fbaf62 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -504,6 +504,28 @@ static inline char *iwl_dbgfs_is_match(char *name, char *buf)
504 return !strncmp(name, buf, len) ? buf + len : NULL; 504 return !strncmp(name, buf, len) ? buf + len : NULL;
505} 505}
506 506
507static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
508 char __user *user_buf,
509 size_t count, loff_t *ppos)
510{
511 struct ieee80211_vif *vif = file->private_data;
512 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
513 struct iwl_mvm *mvm = mvmvif->mvm;
514 u32 curr_gp2;
515 u64 curr_os;
516 s64 diff;
517 char buf[64];
518 const size_t bufsz = sizeof(buf);
519 int pos = 0;
520
521 iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
522 do_div(curr_os, NSEC_PER_USEC);
523 diff = curr_os - curr_gp2;
524 pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
525
526 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
527}
528
507static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif, 529static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
508 char *buf, 530 char *buf,
509 size_t count, loff_t *ppos) 531 size_t count, loff_t *ppos)
@@ -1530,6 +1552,8 @@ MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
1530MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32); 1552MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
1531MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32); 1553MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
1532MVM_DEBUGFS_WRITE_FILE_OPS(lqm_send_cmd, 64); 1554MVM_DEBUGFS_WRITE_FILE_OPS(lqm_send_cmd, 64);
1555MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
1556
1533 1557
1534void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1558void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1535{ 1559{
@@ -1554,8 +1578,7 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1554 1578
1555 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM && 1579 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM &&
1556 ((vif->type == NL80211_IFTYPE_STATION && !vif->p2p) || 1580 ((vif->type == NL80211_IFTYPE_STATION && !vif->p2p) ||
1557 (vif->type == NL80211_IFTYPE_STATION && vif->p2p && 1581 (vif->type == NL80211_IFTYPE_STATION && vif->p2p)))
1558 mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM)))
1559 MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, S_IWUSR | 1582 MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, S_IWUSR |
1560 S_IRUSR); 1583 S_IRUSR);
1561 1584
@@ -1570,6 +1593,8 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1570 MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir, 1593 MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir,
1571 S_IRUSR | S_IWUSR); 1594 S_IRUSR | S_IWUSR);
1572 MVM_DEBUGFS_ADD_FILE_VIF(lqm_send_cmd, mvmvif->dbgfs_dir, S_IWUSR); 1595 MVM_DEBUGFS_ADD_FILE_VIF(lqm_send_cmd, mvmvif->dbgfs_dir, S_IWUSR);
1596 MVM_DEBUGFS_ADD_FILE_VIF(os_device_timediff,
1597 mvmvif->dbgfs_dir, S_IRUSR);
1573 1598
1574 if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p && 1599 if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
1575 mvmvif == mvm->bf_allowed_vif) 1600 mvmvif == mvm->bf_allowed_vif)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index b34489817c70..539d718df797 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -917,6 +917,59 @@ static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
917 return ret ?: count; 917 return ret ?: count;
918} 918}
919 919
920static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
921 char *buf, size_t count,
922 loff_t *ppos)
923{
924 struct iwl_rx_cmd_buffer rxb = {
925 ._rx_page_order = 0,
926 .truesize = 0, /* not used */
927 ._offset = 0,
928 };
929 struct iwl_rx_packet *pkt;
930 struct iwl_rx_mpdu_desc *desc;
931 int bin_len = count / 2;
932 int ret = -EINVAL;
933
934 /* supporting only 9000 descriptor */
935 if (!mvm->trans->cfg->mq_rx_supported)
936 return -ENOTSUPP;
937
938 rxb._page = alloc_pages(GFP_ATOMIC, 0);
939 if (!rxb._page)
940 return -ENOMEM;
941 pkt = rxb_addr(&rxb);
942
943 ret = hex2bin(page_address(rxb._page), buf, bin_len);
944 if (ret)
945 goto out;
946
947 /* avoid invalid memory access */
948 if (bin_len < sizeof(*pkt) + sizeof(*desc))
949 goto out;
950
951 /* check this is RX packet */
952 if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) !=
953 WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))
954 goto out;
955
956 /* check the length in metadata matches actual received length */
957 desc = (void *)pkt->data;
958 if (le16_to_cpu(desc->mpdu_len) !=
959 (bin_len - sizeof(*desc) - sizeof(*pkt)))
960 goto out;
961
962 local_bh_disable();
963 iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0);
964 local_bh_enable();
965 ret = 0;
966
967out:
968 iwl_free_rxb(&rxb);
969
970 return ret ?: count;
971}
972
920static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file, 973static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
921 char __user *user_buf, 974 char __user *user_buf,
922 size_t count, loff_t *ppos) 975 size_t count, loff_t *ppos)
@@ -1454,6 +1507,7 @@ MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
1454MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8); 1507MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
1455MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl, 1508MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1456 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2)); 1509 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
1510MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
1457 1511
1458#ifdef CONFIG_IWLWIFI_BCAST_FILTERING 1512#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1459MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); 1513MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
@@ -1464,6 +1518,132 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1464MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8); 1518MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
1465#endif 1519#endif
1466 1520
1521static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
1522 size_t count, loff_t *ppos)
1523{
1524 struct iwl_mvm *mvm = file->private_data;
1525 struct iwl_dbg_mem_access_cmd cmd = {};
1526 struct iwl_dbg_mem_access_rsp *rsp;
1527 struct iwl_host_cmd hcmd = {
1528 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1529 .data = { &cmd, },
1530 .len = { sizeof(cmd) },
1531 };
1532 size_t delta, len;
1533 ssize_t ret;
1534
1535 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1536 DEBUG_GROUP, 0);
1537 cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
1538
1539 /* Take care of alignment of both the position and the length */
1540 delta = *ppos & 0x3;
1541 cmd.addr = cpu_to_le32(*ppos - delta);
1542 cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
1543 (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
1544
1545 mutex_lock(&mvm->mutex);
1546 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1547 mutex_unlock(&mvm->mutex);
1548
1549 if (ret < 0)
1550 return ret;
1551
1552 rsp = (void *)hcmd.resp_pkt->data;
1553 if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
1554 ret = -ENXIO;
1555 goto out;
1556 }
1557
1558 len = min((size_t)le32_to_cpu(rsp->len) << 2,
1559 iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
1560 len = min(len - delta, count);
1561 if (len < 0) {
1562 ret = -EFAULT;
1563 goto out;
1564 }
1565
1566 ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
1567 *ppos += ret;
1568
1569out:
1570 iwl_free_resp(&hcmd);
1571 return ret;
1572}
1573
1574static ssize_t iwl_dbgfs_mem_write(struct file *file,
1575 const char __user *user_buf, size_t count,
1576 loff_t *ppos)
1577{
1578 struct iwl_mvm *mvm = file->private_data;
1579 struct iwl_dbg_mem_access_cmd *cmd;
1580 struct iwl_dbg_mem_access_rsp *rsp;
1581 struct iwl_host_cmd hcmd = {};
1582 size_t cmd_size;
1583 size_t data_size;
1584 u32 op, len;
1585 ssize_t ret;
1586
1587 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1588 DEBUG_GROUP, 0);
1589
1590 if (*ppos & 0x3 || count < 4) {
1591 op = DEBUG_MEM_OP_WRITE_BYTES;
1592 len = min(count, (size_t)(4 - (*ppos & 0x3)));
1593 data_size = len;
1594 } else {
1595 op = DEBUG_MEM_OP_WRITE;
1596 len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
1597 data_size = len << 2;
1598 }
1599
1600 cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
1601 cmd = kzalloc(cmd_size, GFP_KERNEL);
1602 if (!cmd)
1603 return -ENOMEM;
1604
1605 cmd->op = cpu_to_le32(op);
1606 cmd->len = cpu_to_le32(len);
1607 cmd->addr = cpu_to_le32(*ppos);
1608 if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
1609 kfree(cmd);
1610 return -EFAULT;
1611 }
1612
1613 hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1614 hcmd.data[0] = (void *)cmd;
1615 hcmd.len[0] = cmd_size;
1616
1617 mutex_lock(&mvm->mutex);
1618 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1619 mutex_unlock(&mvm->mutex);
1620
1621 kfree(cmd);
1622
1623 if (ret < 0)
1624 return ret;
1625
1626 rsp = (void *)hcmd.resp_pkt->data;
1627 if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
1628 ret = -ENXIO;
1629 goto out;
1630 }
1631
1632 ret = data_size;
1633 *ppos += ret;
1634
1635out:
1636 iwl_free_resp(&hcmd);
1637 return ret;
1638}
1639
1640static const struct file_operations iwl_dbgfs_mem_ops = {
1641 .read = iwl_dbgfs_mem_read,
1642 .write = iwl_dbgfs_mem_write,
1643 .open = simple_open,
1644 .llseek = default_llseek,
1645};
1646
1467int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) 1647int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1468{ 1648{
1469 struct dentry *bcast_dir __maybe_unused; 1649 struct dentry *bcast_dir __maybe_unused;
@@ -1502,6 +1682,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1502 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR); 1682 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
1503 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR); 1683 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR);
1504 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR); 1684 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR);
1685 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, S_IWUSR);
1505 if (!debugfs_create_bool("enable_scan_iteration_notif", 1686 if (!debugfs_create_bool("enable_scan_iteration_notif",
1506 S_IRUSR | S_IWUSR, 1687 S_IRUSR | S_IWUSR,
1507 mvm->debugfs_dir, 1688 mvm->debugfs_dir,
@@ -1560,6 +1741,9 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1560 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob)) 1741 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
1561 goto err; 1742 goto err;
1562 1743
1744 debugfs_create_file("mem", S_IRUSR | S_IWUSR, dbgfs_dir, mvm,
1745 &iwl_dbgfs_mem_ops);
1746
1563 /* 1747 /*
1564 * Create a symlink with mac80211. It will be removed when mac80211 1748 * Create a symlink with mac80211. It will be removed when mac80211
1565 * exists (before the opmode exists which removes the target.) 1749 * exists (before the opmode exists which removes the target.)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
index 404b0de9e2dc..3fa43d1348a2 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
@@ -313,35 +313,26 @@ enum iwl_dev_tx_power_cmd_mode {
313 IWL_TX_POWER_MODE_SET_ACK = 3, 313 IWL_TX_POWER_MODE_SET_ACK = 3,
314}; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_4 */; 314}; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_4 */;
315 315
316#define IWL_NUM_CHAIN_LIMITS 2
317#define IWL_NUM_SUB_BANDS 5
318
316/** 319/**
317 * struct iwl_dev_tx_power_cmd_v2 - TX power reduction command 320 * struct iwl_dev_tx_power_cmd - TX power reduction command
318 * @set_mode: see &enum iwl_dev_tx_power_cmd_mode 321 * @set_mode: see &enum iwl_dev_tx_power_cmd_mode
319 * @mac_context_id: id of the mac ctx for which we are reducing TX power. 322 * @mac_context_id: id of the mac ctx for which we are reducing TX power.
320 * @pwr_restriction: TX power restriction in 1/8 dBms. 323 * @pwr_restriction: TX power restriction in 1/8 dBms.
321 * @dev_24: device TX power restriction in 1/8 dBms 324 * @dev_24: device TX power restriction in 1/8 dBms
322 * @dev_52_low: device TX power restriction upper band - low 325 * @dev_52_low: device TX power restriction upper band - low
323 * @dev_52_high: device TX power restriction upper band - high 326 * @dev_52_high: device TX power restriction upper band - high
327 * @per_chain_restriction: per chain restrictions
324 */ 328 */
325struct iwl_dev_tx_power_cmd_v2 { 329struct iwl_dev_tx_power_cmd_v3 {
326 __le32 set_mode; 330 __le32 set_mode;
327 __le32 mac_context_id; 331 __le32 mac_context_id;
328 __le16 pwr_restriction; 332 __le16 pwr_restriction;
329 __le16 dev_24; 333 __le16 dev_24;
330 __le16 dev_52_low; 334 __le16 dev_52_low;
331 __le16 dev_52_high; 335 __le16 dev_52_high;
332} __packed; /* TX_REDUCED_POWER_API_S_VER_2 */
333
334#define IWL_NUM_CHAIN_LIMITS 2
335#define IWL_NUM_SUB_BANDS 5
336
337/**
338 * struct iwl_dev_tx_power_cmd - TX power reduction command
339 * @v2: version 2 of the command, embedded here for easier software handling
340 * @per_chain_restriction: per chain restrictions
341 */
342struct iwl_dev_tx_power_cmd_v3 {
343 /* v3 is just an extension of v2 - keep this here */
344 struct iwl_dev_tx_power_cmd_v2 v2;
345 __le16 per_chain_restriction[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS]; 336 __le16 per_chain_restriction[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS];
346} __packed; /* TX_REDUCED_POWER_API_S_VER_3 */ 337} __packed; /* TX_REDUCED_POWER_API_S_VER_3 */
347 338
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
index f01dab0d0dac..0c294c9f98e9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 Intel Deutschland GmbH
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as 13 * it under the terms of version 2 of the GNU General Public License as
@@ -603,6 +604,8 @@ struct iwl_scan_req_umac_tail {
603 * @uid: scan id, &enum iwl_umac_scan_uid_offsets 604 * @uid: scan id, &enum iwl_umac_scan_uid_offsets
604 * @ooc_priority: out of channel priority - &enum iwl_scan_priority 605 * @ooc_priority: out of channel priority - &enum iwl_scan_priority
605 * @general_flags: &enum iwl_umac_scan_general_flags 606 * @general_flags: &enum iwl_umac_scan_general_flags
607 * @reserved2: for future use and alignment
608 * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
606 * @extended_dwell: dwell time for channels 1, 6 and 11 609 * @extended_dwell: dwell time for channels 1, 6 and 11
607 * @active_dwell: dwell time for active scan 610 * @active_dwell: dwell time for active scan
608 * @passive_dwell: dwell time for passive scan 611 * @passive_dwell: dwell time for passive scan
@@ -620,8 +623,10 @@ struct iwl_scan_req_umac {
620 __le32 flags; 623 __le32 flags;
621 __le32 uid; 624 __le32 uid;
622 __le32 ooc_priority; 625 __le32 ooc_priority;
623 /* SCAN_GENERAL_PARAMS_API_S_VER_1 */ 626 /* SCAN_GENERAL_PARAMS_API_S_VER_4 */
624 __le32 general_flags; 627 __le16 general_flags;
628 u8 reserved2;
629 u8 scan_start_mac_id;
625 u8 extended_dwell; 630 u8 extended_dwell;
626 u8 active_dwell; 631 u8 active_dwell;
627 u8 passive_dwell; 632 u8 passive_dwell;
@@ -629,7 +634,7 @@ struct iwl_scan_req_umac {
629 __le32 max_out_time; 634 __le32 max_out_time;
630 __le32 suspend_time; 635 __le32 suspend_time;
631 __le32 scan_priority; 636 __le32 scan_priority;
632 /* SCAN_CHANNEL_PARAMS_API_S_VER_1 */ 637 /* SCAN_CHANNEL_PARAMS_API_S_VER_4 */
633 u8 channel_flags; 638 u8 channel_flags;
634 u8 n_channels; 639 u8 n_channels;
635 __le16 reserved; 640 __le16 reserved;
@@ -718,8 +723,8 @@ struct iwl_scan_offload_profiles_query {
718 * @status: one of SCAN_COMP_STATUS_* 723 * @status: one of SCAN_COMP_STATUS_*
719 * @bt_status: BT on/off status 724 * @bt_status: BT on/off status
720 * @last_channel: last channel that was scanned 725 * @last_channel: last channel that was scanned
721 * @tsf_low: TSF timer (lower half) in usecs 726 * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
722 * @tsf_high: TSF timer (higher half) in usecs 727 * in &struct iwl_scan_req_umac.
723 * @results: array of scan results, only "scanned_channels" of them are valid 728 * @results: array of scan results, only "scanned_channels" of them are valid
724 */ 729 */
725struct iwl_umac_scan_iter_complete_notif { 730struct iwl_umac_scan_iter_complete_notif {
@@ -728,9 +733,8 @@ struct iwl_umac_scan_iter_complete_notif {
728 u8 status; 733 u8 status;
729 u8 bt_status; 734 u8 bt_status;
730 u8 last_channel; 735 u8 last_channel;
731 __le32 tsf_low; 736 __le64 start_tsf;
732 __le32 tsf_high;
733 struct iwl_scan_results_notif results[]; 737 struct iwl_scan_results_notif results[];
734} __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_1 */ 738} __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
735 739
736#endif 740#endif
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
index 6b4c63a5e625..59ca97a11b2b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -89,7 +89,6 @@
89 * @TX_CMD_FLG_MH_PAD: driver inserted 2 byte padding after MAC header. 89 * @TX_CMD_FLG_MH_PAD: driver inserted 2 byte padding after MAC header.
90 * Should be set for 26/30 length MAC headers 90 * Should be set for 26/30 length MAC headers
91 * @TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW 91 * @TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW
92 * @TX_CMD_FLG_CCMP_AGG: this frame uses CCMP for aggregation acceleration
93 * @TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation 92 * @TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation
94 * @TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id 93 * @TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id
95 * @TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped 94 * @TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped
@@ -116,7 +115,6 @@ enum iwl_tx_flags {
116 TX_CMD_FLG_KEEP_SEQ_CTL = BIT(18), 115 TX_CMD_FLG_KEEP_SEQ_CTL = BIT(18),
117 TX_CMD_FLG_MH_PAD = BIT(20), 116 TX_CMD_FLG_MH_PAD = BIT(20),
118 TX_CMD_FLG_RESP_TO_DRV = BIT(21), 117 TX_CMD_FLG_RESP_TO_DRV = BIT(21),
119 TX_CMD_FLG_CCMP_AGG = BIT(22),
120 TX_CMD_FLG_TKIP_MIC_DONE = BIT(23), 118 TX_CMD_FLG_TKIP_MIC_DONE = BIT(23),
121 TX_CMD_FLG_DUR = BIT(25), 119 TX_CMD_FLG_DUR = BIT(25),
122 TX_CMD_FLG_FW_DROP = BIT(26), 120 TX_CMD_FLG_FW_DROP = BIT(26),
@@ -149,7 +147,7 @@ enum iwl_tx_pm_timeouts {
149 * @TX_CMD_SEC_EXT: extended cipher algorithm. 147 * @TX_CMD_SEC_EXT: extended cipher algorithm.
150 * @TX_CMD_SEC_GCMP: GCMP encryption algorithm. 148 * @TX_CMD_SEC_GCMP: GCMP encryption algorithm.
151 * @TX_CMD_SEC_KEY128: set for 104 bits WEP key. 149 * @TX_CMD_SEC_KEY128: set for 104 bits WEP key.
152 * @TC_CMD_SEC_KEY_FROM_TABLE: for a non-WEP key, set if the key should be taken 150 * @TX_CMD_SEC_KEY_FROM_TABLE: for a non-WEP key, set if the key should be taken
153 * from the table instead of from the TX command. 151 * from the table instead of from the TX command.
154 * If the key is taken from the key table its index should be given by the 152 * If the key is taken from the key table its index should be given by the
155 * first byte of the TX command key field. 153 * first byte of the TX command key field.
@@ -161,7 +159,7 @@ enum iwl_tx_cmd_sec_ctrl {
161 TX_CMD_SEC_EXT = 0x04, 159 TX_CMD_SEC_EXT = 0x04,
162 TX_CMD_SEC_GCMP = 0x05, 160 TX_CMD_SEC_GCMP = 0x05,
163 TX_CMD_SEC_KEY128 = 0x08, 161 TX_CMD_SEC_KEY128 = 0x08,
164 TC_CMD_SEC_KEY_FROM_TABLE = 0x08, 162 TX_CMD_SEC_KEY_FROM_TABLE = 0x08,
165}; 163};
166 164
167/* TODO: how does these values are OK with only 16 bit variable??? */ 165/* TODO: how does these values are OK with only 16 bit variable??? */
@@ -578,6 +576,85 @@ struct iwl_mvm_ba_notif {
578} __packed; 576} __packed;
579 577
580/** 578/**
579 * struct iwl_mvm_compressed_ba_tfd - progress of a TFD queue
580 * @q_num: TFD queue number
581 * @tfd_index: Index of first un-acked frame in the TFD queue
582 */
583struct iwl_mvm_compressed_ba_tfd {
584 u8 q_num;
585 u8 reserved;
586 __le16 tfd_index;
587} __packed; /* COMPRESSED_BA_TFD_API_S_VER_1 */
588
589/**
590 * struct iwl_mvm_compressed_ba_ratid - progress of a RA TID queue
591 * @q_num: RA TID queue number
592 * @tid: TID of the queue
593 * @ssn: BA window current SSN
594 */
595struct iwl_mvm_compressed_ba_ratid {
596 u8 q_num;
597 u8 tid;
598 __le16 ssn;
599} __packed; /* COMPRESSED_BA_RATID_API_S_VER_1 */
600
601/*
602 * enum iwl_mvm_ba_resp_flags - TX aggregation status
603 * @IWL_MVM_BA_RESP_TX_AGG: generated due to BA
604 * @IWL_MVM_BA_RESP_TX_BAR: generated due to BA after BAR
605 * @IWL_MVM_BA_RESP_TX_AGG_FAIL: aggregation didn't receive BA
606 * @IWL_MVM_BA_RESP_TX_UNDERRUN: aggregation got underrun
607 * @IWL_MVM_BA_RESP_TX_BT_KILL: aggregation got BT-kill
608 * @IWL_MVM_BA_RESP_TX_DSP_TIMEOUT: aggregation didn't finish within the
609 * expected time
610 */
611enum iwl_mvm_ba_resp_flags {
612 IWL_MVM_BA_RESP_TX_AGG,
613 IWL_MVM_BA_RESP_TX_BAR,
614 IWL_MVM_BA_RESP_TX_AGG_FAIL,
615 IWL_MVM_BA_RESP_TX_UNDERRUN,
616 IWL_MVM_BA_RESP_TX_BT_KILL,
617 IWL_MVM_BA_RESP_TX_DSP_TIMEOUT
618};
619
620/**
621 * struct iwl_mvm_compressed_ba_notif - notifies about reception of BA
622 * ( BA_NOTIF = 0xc5 )
623 * @flags: status flag, see the &iwl_mvm_ba_resp_flags
624 * @sta_id: Index of recipient (BA-sending) station in fw's station table
625 * @reduced_txp: power reduced according to TPC. This is the actual value and
626 * not a copy from the LQ command. Thus, if not the first rate was used
627 * for Tx-ing then this value will be set to 0 by FW.
628 * @initial_rate: TLC rate info, initial rate index, TLC table color
629 * @retry_cnt: retry count
630 * @query_byte_cnt: SCD query byte count
631 * @query_frame_cnt: SCD query frame count
632 * @txed: number of frames sent in the aggregation (all-TIDs)
633 * @done: number of frames that were Acked by the BA (all-TIDs)
634 * @wireless_time: Wireless-media time
635 * @tx_rate: the rate the aggregation was sent at
636 * @tfd_cnt: number of TFD-Q elements
637 * @ra_tid_cnt: number of RATID-Q elements
638 */
639struct iwl_mvm_compressed_ba_notif {
640 __le32 flags;
641 u8 sta_id;
642 u8 reduced_txp;
643 u8 initial_rate;
644 u8 retry_cnt;
645 __le32 query_byte_cnt;
646 __le16 query_frame_cnt;
647 __le16 txed;
648 __le16 done;
649 __le32 wireless_time;
650 __le32 tx_rate;
651 __le16 tfd_cnt;
652 __le16 ra_tid_cnt;
653 struct iwl_mvm_compressed_ba_tfd tfd[1];
654 struct iwl_mvm_compressed_ba_ratid ra_tid[0];
655} __packed; /* COMPRESSED_BA_RES_API_S_VER_4 */
656
657/**
581 * struct iwl_mac_beacon_cmd_v6 - beacon template command 658 * struct iwl_mac_beacon_cmd_v6 - beacon template command
582 * @tx: the tx commands associated with the beacon frame 659 * @tx: the tx commands associated with the beacon frame
583 * @template_id: currently equal to the mac context id of the coresponding 660 * @template_id: currently equal to the mac context id of the coresponding
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 57b574b2a092..97633690f3d5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -205,7 +205,7 @@ enum {
205 /* Phy */ 205 /* Phy */
206 PHY_CONFIGURATION_CMD = 0x6a, 206 PHY_CONFIGURATION_CMD = 0x6a,
207 CALIB_RES_NOTIF_PHY_DB = 0x6b, 207 CALIB_RES_NOTIF_PHY_DB = 0x6b,
208 /* PHY_DB_CMD = 0x6c, */ 208 PHY_DB_CMD = 0x6c,
209 209
210 /* ToF - 802.11mc FTM */ 210 /* ToF - 802.11mc FTM */
211 TOF_CMD = 0x10, 211 TOF_CMD = 0x10,
@@ -340,6 +340,11 @@ enum iwl_prot_offload_subcmd_ids {
340 STORED_BEACON_NTF = 0xFF, 340 STORED_BEACON_NTF = 0xFF,
341}; 341};
342 342
343enum iwl_fmac_debug_cmds {
344 LMAC_RD_WR = 0x0,
345 UMAC_RD_WR = 0x1,
346};
347
343/* command groups */ 348/* command groups */
344enum { 349enum {
345 LEGACY_GROUP = 0x0, 350 LEGACY_GROUP = 0x0,
@@ -349,6 +354,7 @@ enum {
349 PHY_OPS_GROUP = 0x4, 354 PHY_OPS_GROUP = 0x4,
350 DATA_PATH_GROUP = 0x5, 355 DATA_PATH_GROUP = 0x5,
351 PROT_OFFLOAD_GROUP = 0xb, 356 PROT_OFFLOAD_GROUP = 0xb,
357 DEBUG_GROUP = 0xf,
352}; 358};
353 359
354/** 360/**
@@ -1977,8 +1983,9 @@ struct iwl_tdls_config_res {
1977 struct iwl_tdls_config_sta_info_res sta_info[IWL_MVM_TDLS_STA_COUNT]; 1983 struct iwl_tdls_config_sta_info_res sta_info[IWL_MVM_TDLS_STA_COUNT];
1978} __packed; /* TDLS_CONFIG_RSP_API_S_VER_1 */ 1984} __packed; /* TDLS_CONFIG_RSP_API_S_VER_1 */
1979 1985
1980#define TX_FIFO_MAX_NUM 8 1986#define TX_FIFO_MAX_NUM_9000 8
1981#define RX_FIFO_MAX_NUM 2 1987#define TX_FIFO_MAX_NUM 15
1988#define RX_FIFO_MAX_NUM 2
1982#define TX_FIFO_INTERNAL_MAX_NUM 6 1989#define TX_FIFO_INTERNAL_MAX_NUM 6
1983 1990
1984/** 1991/**
@@ -2004,6 +2011,21 @@ struct iwl_tdls_config_res {
2004 * NOTE: on firmware that don't have IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG 2011 * NOTE: on firmware that don't have IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG
2005 * set, the last 3 members don't exist. 2012 * set, the last 3 members don't exist.
2006 */ 2013 */
2014struct iwl_shared_mem_cfg_v1 {
2015 __le32 shared_mem_addr;
2016 __le32 shared_mem_size;
2017 __le32 sample_buff_addr;
2018 __le32 sample_buff_size;
2019 __le32 txfifo_addr;
2020 __le32 txfifo_size[TX_FIFO_MAX_NUM_9000];
2021 __le32 rxfifo_size[RX_FIFO_MAX_NUM];
2022 __le32 page_buff_addr;
2023 __le32 page_buff_size;
2024 __le32 rxfifo_addr;
2025 __le32 internal_txfifo_addr;
2026 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
2027} __packed; /* SHARED_MEM_ALLOC_API_S_VER_2 */
2028
2007struct iwl_shared_mem_cfg { 2029struct iwl_shared_mem_cfg {
2008 __le32 shared_mem_addr; 2030 __le32 shared_mem_addr;
2009 __le32 shared_mem_size; 2031 __le32 shared_mem_size;
@@ -2017,7 +2039,7 @@ struct iwl_shared_mem_cfg {
2017 __le32 rxfifo_addr; 2039 __le32 rxfifo_addr;
2018 __le32 internal_txfifo_addr; 2040 __le32 internal_txfifo_addr;
2019 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM]; 2041 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
2020} __packed; /* SHARED_MEM_ALLOC_API_S_VER_2 */ 2042} __packed; /* SHARED_MEM_ALLOC_API_S_VER_3 */
2021 2043
2022/** 2044/**
2023 * VHT MU-MIMO group configuration 2045 * VHT MU-MIMO group configuration
@@ -2133,4 +2155,48 @@ struct iwl_channel_switch_noa_notif {
2133 __le32 id_and_color; 2155 __le32 id_and_color;
2134} __packed; /* CHANNEL_SWITCH_START_NTFY_API_S_VER_1 */ 2156} __packed; /* CHANNEL_SWITCH_START_NTFY_API_S_VER_1 */
2135 2157
2158/* Operation types for the debug mem access */
2159enum {
2160 DEBUG_MEM_OP_READ = 0,
2161 DEBUG_MEM_OP_WRITE = 1,
2162 DEBUG_MEM_OP_WRITE_BYTES = 2,
2163};
2164
2165#define DEBUG_MEM_MAX_SIZE_DWORDS 32
2166
2167/**
2168 * struct iwl_dbg_mem_access_cmd - Request the device to read/write memory
2169 * @op: DEBUG_MEM_OP_*
2170 * @addr: address to read/write from/to
2171 * @len: in dwords, to read/write
2172 * @data: for write opeations, contains the source buffer
2173 */
2174struct iwl_dbg_mem_access_cmd {
2175 __le32 op;
2176 __le32 addr;
2177 __le32 len;
2178 __le32 data[];
2179} __packed; /* DEBUG_(U|L)MAC_RD_WR_CMD_API_S_VER_1 */
2180
2181/* Status responses for the debug mem access */
2182enum {
2183 DEBUG_MEM_STATUS_SUCCESS = 0x0,
2184 DEBUG_MEM_STATUS_FAILED = 0x1,
2185 DEBUG_MEM_STATUS_LOCKED = 0x2,
2186 DEBUG_MEM_STATUS_HIDDEN = 0x3,
2187 DEBUG_MEM_STATUS_LENGTH = 0x4,
2188};
2189
2190/**
2191 * struct iwl_dbg_mem_access_rsp - Response to debug mem commands
2192 * @status: DEBUG_MEM_STATUS_*
2193 * @len: read dwords (0 for write operations)
2194 * @data: contains the read DWs
2195 */
2196struct iwl_dbg_mem_access_rsp {
2197 __le32 status;
2198 __le32 len;
2199 __le32 data[];
2200} __packed; /* DEBUG_(U|L)MAC_RD_WR_RSP_API_S_VER_1 */
2201
2136#endif /* __fw_api_h__ */ 2202#endif /* __fw_api_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
index 46b52bf705fb..d89d0a1fd34e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
@@ -440,14 +440,12 @@ static const struct iwl_prph_range iwl_prph_dump_addr_comm[] = {
440 { .start = 0x00a04560, .end = 0x00a0457c }, 440 { .start = 0x00a04560, .end = 0x00a0457c },
441 { .start = 0x00a04590, .end = 0x00a04598 }, 441 { .start = 0x00a04590, .end = 0x00a04598 },
442 { .start = 0x00a045c0, .end = 0x00a045f4 }, 442 { .start = 0x00a045c0, .end = 0x00a045f4 },
443 { .start = 0x00a44000, .end = 0x00a7bf80 },
444}; 443};
445 444
446static const struct iwl_prph_range iwl_prph_dump_addr_9000[] = { 445static const struct iwl_prph_range iwl_prph_dump_addr_9000[] = {
447 { .start = 0x00a05c00, .end = 0x00a05c18 }, 446 { .start = 0x00a05c00, .end = 0x00a05c18 },
448 { .start = 0x00a05400, .end = 0x00a056e8 }, 447 { .start = 0x00a05400, .end = 0x00a056e8 },
449 { .start = 0x00a08000, .end = 0x00a098bc }, 448 { .start = 0x00a08000, .end = 0x00a098bc },
450 { .start = 0x00adfc00, .end = 0x00adfd1c },
451 { .start = 0x00a02400, .end = 0x00a02758 }, 449 { .start = 0x00a02400, .end = 0x00a02758 },
452}; 450};
453 451
@@ -559,7 +557,7 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
559 sizeof(struct iwl_fw_error_dump_fifo); 557 sizeof(struct iwl_fw_error_dump_fifo);
560 } 558 }
561 559
562 for (i = 0; i < ARRAY_SIZE(mem_cfg->txfifo_size); i++) { 560 for (i = 0; i < mem_cfg->num_txfifo_entries; i++) {
563 if (!mem_cfg->txfifo_size[i]) 561 if (!mem_cfg->txfifo_size[i])
564 continue; 562 continue;
565 563
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 47e8e70dcfac..872066317fa5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -90,15 +90,6 @@ struct iwl_mvm_alive_data {
90 u32 scd_base_addr; 90 u32 scd_base_addr;
91}; 91};
92 92
93static inline const struct fw_img *
94iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type)
95{
96 if (ucode_type >= IWL_UCODE_TYPE_MAX)
97 return NULL;
98
99 return &mvm->fw->img[ucode_type];
100}
101
102static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) 93static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
103{ 94{
104 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { 95 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
@@ -592,9 +583,9 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
592 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) && 583 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) &&
593 !(fw_has_capa(&mvm->fw->ucode_capa, 584 !(fw_has_capa(&mvm->fw->ucode_capa,
594 IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED))) 585 IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED)))
595 fw = iwl_get_ucode_image(mvm, IWL_UCODE_REGULAR_USNIFFER); 586 fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER);
596 else 587 else
597 fw = iwl_get_ucode_image(mvm, ucode_type); 588 fw = iwl_get_ucode_image(mvm->fw, ucode_type);
598 if (WARN_ON(!fw)) 589 if (WARN_ON(!fw))
599 return -EINVAL; 590 return -EINVAL;
600 mvm->cur_ucode = ucode_type; 591 mvm->cur_ucode = ucode_type;
@@ -838,59 +829,48 @@ out:
838 return ret; 829 return ret;
839} 830}
840 831
841static void iwl_mvm_get_shared_mem_conf(struct iwl_mvm *mvm) 832static void iwl_mvm_parse_shared_mem_a000(struct iwl_mvm *mvm,
833 struct iwl_rx_packet *pkt)
842{ 834{
843 struct iwl_host_cmd cmd = { 835 struct iwl_shared_mem_cfg *mem_cfg = (void *)pkt->data;
844 .flags = CMD_WANT_SKB, 836 int i;
845 .data = { NULL, },
846 .len = { 0, },
847 };
848 struct iwl_shared_mem_cfg *mem_cfg;
849 struct iwl_rx_packet *pkt;
850 u32 i;
851 837
852 lockdep_assert_held(&mvm->mutex); 838 mvm->shared_mem_cfg.num_txfifo_entries =
839 ARRAY_SIZE(mvm->shared_mem_cfg.txfifo_size);
840 for (i = 0; i < ARRAY_SIZE(mem_cfg->txfifo_size); i++)
841 mvm->shared_mem_cfg.txfifo_size[i] =
842 le32_to_cpu(mem_cfg->txfifo_size[i]);
843 for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.rxfifo_size); i++)
844 mvm->shared_mem_cfg.rxfifo_size[i] =
845 le32_to_cpu(mem_cfg->rxfifo_size[i]);
853 846
854 if (fw_has_capa(&mvm->fw->ucode_capa, 847 BUILD_BUG_ON(sizeof(mvm->shared_mem_cfg.internal_txfifo_size) !=
855 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) 848 sizeof(mem_cfg->internal_txfifo_size));
856 cmd.id = iwl_cmd_id(SHARED_MEM_CFG_CMD, SYSTEM_GROUP, 0);
857 else
858 cmd.id = SHARED_MEM_CFG;
859 849
860 if (WARN_ON(iwl_mvm_send_cmd(mvm, &cmd))) 850 for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.internal_txfifo_size);
861 return; 851 i++)
852 mvm->shared_mem_cfg.internal_txfifo_size[i] =
853 le32_to_cpu(mem_cfg->internal_txfifo_size[i]);
854}
862 855
863 pkt = cmd.resp_pkt; 856static void iwl_mvm_parse_shared_mem(struct iwl_mvm *mvm,
864 mem_cfg = (void *)pkt->data; 857 struct iwl_rx_packet *pkt)
865 858{
866 mvm->shared_mem_cfg.shared_mem_addr = 859 struct iwl_shared_mem_cfg_v1 *mem_cfg = (void *)pkt->data;
867 le32_to_cpu(mem_cfg->shared_mem_addr); 860 int i;
868 mvm->shared_mem_cfg.shared_mem_size = 861
869 le32_to_cpu(mem_cfg->shared_mem_size); 862 mvm->shared_mem_cfg.num_txfifo_entries =
870 mvm->shared_mem_cfg.sample_buff_addr = 863 ARRAY_SIZE(mvm->shared_mem_cfg.txfifo_size);
871 le32_to_cpu(mem_cfg->sample_buff_addr); 864 for (i = 0; i < ARRAY_SIZE(mem_cfg->txfifo_size); i++)
872 mvm->shared_mem_cfg.sample_buff_size =
873 le32_to_cpu(mem_cfg->sample_buff_size);
874 mvm->shared_mem_cfg.txfifo_addr = le32_to_cpu(mem_cfg->txfifo_addr);
875 for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.txfifo_size); i++)
876 mvm->shared_mem_cfg.txfifo_size[i] = 865 mvm->shared_mem_cfg.txfifo_size[i] =
877 le32_to_cpu(mem_cfg->txfifo_size[i]); 866 le32_to_cpu(mem_cfg->txfifo_size[i]);
878 for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.rxfifo_size); i++) 867 for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.rxfifo_size); i++)
879 mvm->shared_mem_cfg.rxfifo_size[i] = 868 mvm->shared_mem_cfg.rxfifo_size[i] =
880 le32_to_cpu(mem_cfg->rxfifo_size[i]); 869 le32_to_cpu(mem_cfg->rxfifo_size[i]);
881 mvm->shared_mem_cfg.page_buff_addr =
882 le32_to_cpu(mem_cfg->page_buff_addr);
883 mvm->shared_mem_cfg.page_buff_size =
884 le32_to_cpu(mem_cfg->page_buff_size);
885 870
886 /* new API has more data */ 871 /* new API has more data, from rxfifo_addr field and on */
887 if (fw_has_capa(&mvm->fw->ucode_capa, 872 if (fw_has_capa(&mvm->fw->ucode_capa,
888 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) { 873 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) {
889 mvm->shared_mem_cfg.rxfifo_addr =
890 le32_to_cpu(mem_cfg->rxfifo_addr);
891 mvm->shared_mem_cfg.internal_txfifo_addr =
892 le32_to_cpu(mem_cfg->internal_txfifo_addr);
893
894 BUILD_BUG_ON(sizeof(mvm->shared_mem_cfg.internal_txfifo_size) != 874 BUILD_BUG_ON(sizeof(mvm->shared_mem_cfg.internal_txfifo_size) !=
895 sizeof(mem_cfg->internal_txfifo_size)); 875 sizeof(mem_cfg->internal_txfifo_size));
896 876
@@ -900,6 +880,33 @@ static void iwl_mvm_get_shared_mem_conf(struct iwl_mvm *mvm)
900 mvm->shared_mem_cfg.internal_txfifo_size[i] = 880 mvm->shared_mem_cfg.internal_txfifo_size[i] =
901 le32_to_cpu(mem_cfg->internal_txfifo_size[i]); 881 le32_to_cpu(mem_cfg->internal_txfifo_size[i]);
902 } 882 }
883}
884
885static void iwl_mvm_get_shared_mem_conf(struct iwl_mvm *mvm)
886{
887 struct iwl_host_cmd cmd = {
888 .flags = CMD_WANT_SKB,
889 .data = { NULL, },
890 .len = { 0, },
891 };
892 struct iwl_rx_packet *pkt;
893
894 lockdep_assert_held(&mvm->mutex);
895
896 if (fw_has_capa(&mvm->fw->ucode_capa,
897 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG))
898 cmd.id = iwl_cmd_id(SHARED_MEM_CFG_CMD, SYSTEM_GROUP, 0);
899 else
900 cmd.id = SHARED_MEM_CFG;
901
902 if (WARN_ON(iwl_mvm_send_cmd(mvm, &cmd)))
903 return;
904
905 pkt = cmd.resp_pkt;
906 if (iwl_mvm_has_new_tx_api(mvm))
907 iwl_mvm_parse_shared_mem_a000(mvm, pkt);
908 else
909 iwl_mvm_parse_shared_mem(mvm, pkt);
903 910
904 IWL_DEBUG_INFO(mvm, "SHARED MEM CFG: got memory offsets/sizes\n"); 911 IWL_DEBUG_INFO(mvm, "SHARED MEM CFG: got memory offsets/sizes\n");
905 912
@@ -1039,19 +1046,11 @@ static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
1039{ 1046{
1040 struct iwl_mvm_sar_table sar_table; 1047 struct iwl_mvm_sar_table sar_table;
1041 struct iwl_dev_tx_power_cmd cmd = { 1048 struct iwl_dev_tx_power_cmd cmd = {
1042 .v3.v2.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS), 1049 .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
1043 }; 1050 };
1044 int ret, i, j, idx; 1051 int ret, i, j, idx;
1045 int len = sizeof(cmd); 1052 int len = sizeof(cmd);
1046 1053
1047 /* we can't do anything with the table if the FW doesn't support it */
1048 if (!fw_has_api(&mvm->fw->ucode_capa,
1049 IWL_UCODE_TLV_API_TX_POWER_CHAIN)) {
1050 IWL_DEBUG_RADIO(mvm,
1051 "FW doesn't support per-chain TX power settings.\n");
1052 return 0;
1053 }
1054
1055 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) 1054 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
1056 len = sizeof(cmd.v3); 1055 len = sizeof(cmd.v3);
1057 1056
@@ -1108,27 +1107,27 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1108 * (for example, if we were in RFKILL) 1107 * (for example, if we were in RFKILL)
1109 */ 1108 */
1110 ret = iwl_run_init_mvm_ucode(mvm, false); 1109 ret = iwl_run_init_mvm_ucode(mvm, false);
1111 if (ret && !iwlmvm_mod_params.init_dbg) { 1110
1111 if (iwlmvm_mod_params.init_dbg)
1112 return 0;
1113
1114 if (ret) {
1112 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 1115 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
1113 /* this can't happen */ 1116 /* this can't happen */
1114 if (WARN_ON(ret > 0)) 1117 if (WARN_ON(ret > 0))
1115 ret = -ERFKILL; 1118 ret = -ERFKILL;
1116 goto error; 1119 goto error;
1117 } 1120 }
1118 if (!iwlmvm_mod_params.init_dbg) {
1119 /*
1120 * Stop and start the transport without entering low power
1121 * mode. This will save the state of other components on the
1122 * device that are triggered by the INIT firwmare (MFUART).
1123 */
1124 _iwl_trans_stop_device(mvm->trans, false);
1125 ret = _iwl_trans_start_hw(mvm->trans, false);
1126 if (ret)
1127 goto error;
1128 }
1129 1121
1130 if (iwlmvm_mod_params.init_dbg) 1122 /*
1131 return 0; 1123 * Stop and start the transport without entering low power
1124 * mode. This will save the state of other components on the
1125 * device that are triggered by the INIT firwmare (MFUART).
1126 */
1127 _iwl_trans_stop_device(mvm->trans, false);
1128 ret = _iwl_trans_start_hw(mvm->trans, false);
1129 if (ret)
1130 goto error;
1132 1131
1133 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); 1132 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
1134 if (ret) { 1133 if (ret) {
@@ -1226,9 +1225,12 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1226 } 1225 }
1227 1226
1228 /* TODO: read the budget from BIOS / Platform NVM */ 1227 /* TODO: read the budget from BIOS / Platform NVM */
1229 if (iwl_mvm_is_ctdp_supported(mvm) && mvm->cooling_dev.cur_state > 0) 1228 if (iwl_mvm_is_ctdp_supported(mvm) && mvm->cooling_dev.cur_state > 0) {
1230 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, 1229 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
1231 mvm->cooling_dev.cur_state); 1230 mvm->cooling_dev.cur_state);
1231 if (ret)
1232 goto error;
1233 }
1232#else 1234#else
1233 /* Initialize tx backoffs to the minimal possible */ 1235 /* Initialize tx backoffs to the minimal possible */
1234 iwl_mvm_tt_tx_backoff(mvm, 0); 1236 iwl_mvm_tt_tx_backoff(mvm, 0);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 69c42ce45b8a..6b962d6b067a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -539,6 +539,11 @@ void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
539 iwl_mvm_disable_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE, 539 iwl_mvm_disable_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE,
540 IWL_MVM_OFFCHANNEL_QUEUE, 540 IWL_MVM_OFFCHANNEL_QUEUE,
541 IWL_MAX_TID_COUNT, 0); 541 IWL_MAX_TID_COUNT, 0);
542 else
543 iwl_mvm_disable_txq(mvm,
544 IWL_MVM_DQA_P2P_DEVICE_QUEUE,
545 vif->hw_queue[0], IWL_MAX_TID_COUNT,
546 0);
542 547
543 break; 548 break;
544 case NL80211_IFTYPE_AP: 549 case NL80211_IFTYPE_AP:
@@ -769,26 +774,6 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
769 cmd->ac[txf].fifos_mask = BIT(txf); 774 cmd->ac[txf].fifos_mask = BIT(txf);
770 } 775 }
771 776
772 if (vif->type == NL80211_IFTYPE_AP) {
773 /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
774 cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |=
775 BIT(IWL_MVM_TX_FIFO_MCAST);
776
777 /*
778 * in AP mode, pass probe requests and beacons from other APs
779 * (needed for ht protection); when there're no any associated
780 * station don't ask FW to pass beacons to prevent unnecessary
781 * wake-ups.
782 */
783 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
784 if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) {
785 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
786 IWL_DEBUG_HC(mvm, "Asking FW to pass beacons\n");
787 } else {
788 IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
789 }
790 }
791
792 if (vif->bss_conf.qos) 777 if (vif->bss_conf.qos)
793 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA); 778 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
794 779
@@ -1186,6 +1171,7 @@ static void iwl_mvm_mac_ap_iterator(void *_data, u8 *mac,
1186 */ 1171 */
1187static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm, 1172static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
1188 struct ieee80211_vif *vif, 1173 struct ieee80211_vif *vif,
1174 struct iwl_mac_ctx_cmd *cmd,
1189 struct iwl_mac_data_ap *ctxt_ap, 1175 struct iwl_mac_data_ap *ctxt_ap,
1190 bool add) 1176 bool add)
1191{ 1177{
@@ -1196,6 +1182,23 @@ static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
1196 .beacon_device_ts = 0 1182 .beacon_device_ts = 0
1197 }; 1183 };
1198 1184
1185 /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
1186 cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |= BIT(IWL_MVM_TX_FIFO_MCAST);
1187
1188 /*
1189 * in AP mode, pass probe requests and beacons from other APs
1190 * (needed for ht protection); when there're no any associated
1191 * station don't ask FW to pass beacons to prevent unnecessary
1192 * wake-ups.
1193 */
1194 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
1195 if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) {
1196 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
1197 IWL_DEBUG_HC(mvm, "Asking FW to pass beacons\n");
1198 } else {
1199 IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
1200 }
1201
1199 ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int); 1202 ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
1200 ctxt_ap->bi_reciprocal = 1203 ctxt_ap->bi_reciprocal =
1201 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int)); 1204 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
@@ -1253,7 +1256,7 @@ static int iwl_mvm_mac_ctxt_cmd_ap(struct iwl_mvm *mvm,
1253 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action); 1256 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
1254 1257
1255 /* Fill the data specific for ap mode */ 1258 /* Fill the data specific for ap mode */
1256 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.ap, 1259 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.ap,
1257 action == FW_CTXT_ACTION_ADD); 1260 action == FW_CTXT_ACTION_ADD);
1258 1261
1259 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd); 1262 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
@@ -1272,7 +1275,7 @@ static int iwl_mvm_mac_ctxt_cmd_go(struct iwl_mvm *mvm,
1272 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action); 1275 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
1273 1276
1274 /* Fill the data specific for GO mode */ 1277 /* Fill the data specific for GO mode */
1275 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.go.ap, 1278 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.go.ap,
1276 action == FW_CTXT_ACTION_ADD); 1279 action == FW_CTXT_ACTION_ADD);
1277 1280
1278 cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow & 1281 cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow &
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 9506e658abd3..318efd814037 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -479,13 +479,11 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
479 hw->wiphy->n_cipher_suites++; 479 hw->wiphy->n_cipher_suites++;
480 } 480 }
481 481
482 /* 482 /* Enable 11w if software crypto is not enabled (as the
483 * Enable 11w if advertised by firmware and software crypto 483 * firmware will interpret some mgmt packets, so enabling it
484 * is not enabled (as the firmware will interpret some mgmt 484 * with software crypto isn't safe).
485 * packets, so enabling it with software crypto isn't safe)
486 */ 485 */
487 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && 486 if (!iwlwifi_mod_params.sw_crypto) {
488 !iwlwifi_mod_params.sw_crypto) {
489 ieee80211_hw_set(hw, MFP_CAPABLE); 487 ieee80211_hw_set(hw, MFP_CAPABLE);
490 mvm->ciphers[hw->wiphy->n_cipher_suites] = 488 mvm->ciphers[hw->wiphy->n_cipher_suites] =
491 WLAN_CIPHER_SUITE_AES_CMAC; 489 WLAN_CIPHER_SUITE_AES_CMAC;
@@ -547,9 +545,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
547 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | 545 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG |
548 REGULATORY_DISABLE_BEACON_HINTS; 546 REGULATORY_DISABLE_BEACON_HINTS;
549 547
550 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD) 548 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
551 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
552
553 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; 549 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
554 550
555 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; 551 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
@@ -653,6 +649,16 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
653 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT)) 649 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT))
654 hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES; 650 hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES;
655 651
652 if (fw_has_api(&mvm->fw->ucode_capa,
653 IWL_UCODE_TLV_API_SCAN_TSF_REPORT)) {
654 wiphy_ext_feature_set(hw->wiphy,
655 NL80211_EXT_FEATURE_SCAN_START_TIME);
656 wiphy_ext_feature_set(hw->wiphy,
657 NL80211_EXT_FEATURE_BSS_PARENT_TSF);
658 wiphy_ext_feature_set(hw->wiphy,
659 NL80211_EXT_FEATURE_SET_SCAN_DWELL);
660 }
661
656 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; 662 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
657 663
658#ifdef CONFIG_PM_SLEEP 664#ifdef CONFIG_PM_SLEEP
@@ -720,6 +726,10 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
720 if (ret) 726 if (ret)
721 iwl_mvm_leds_exit(mvm); 727 iwl_mvm_leds_exit(mvm);
722 728
729 if (mvm->cfg->vht_mu_mimo_supported)
730 wiphy_ext_feature_set(hw->wiphy,
731 NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER);
732
723 return ret; 733 return ret;
724} 734}
725 735
@@ -1259,20 +1269,18 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1259 s16 tx_power) 1269 s16 tx_power)
1260{ 1270{
1261 struct iwl_dev_tx_power_cmd cmd = { 1271 struct iwl_dev_tx_power_cmd cmd = {
1262 .v3.v2.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC), 1272 .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC),
1263 .v3.v2.mac_context_id = 1273 .v3.mac_context_id =
1264 cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id), 1274 cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id),
1265 .v3.v2.pwr_restriction = cpu_to_le16(8 * tx_power), 1275 .v3.pwr_restriction = cpu_to_le16(8 * tx_power),
1266 }; 1276 };
1267 int len = sizeof(cmd); 1277 int len = sizeof(cmd);
1268 1278
1269 if (tx_power == IWL_DEFAULT_MAX_TX_POWER) 1279 if (tx_power == IWL_DEFAULT_MAX_TX_POWER)
1270 cmd.v3.v2.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER); 1280 cmd.v3.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER);
1271 1281
1272 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) 1282 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
1273 len = sizeof(cmd.v3); 1283 len = sizeof(cmd.v3);
1274 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_TX_POWER_CHAIN))
1275 len = sizeof(cmd.v3.v2);
1276 1284
1277 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); 1285 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
1278} 1286}
@@ -2229,6 +2237,10 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
2229 case NL80211_IFTYPE_ADHOC: 2237 case NL80211_IFTYPE_ADHOC:
2230 iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); 2238 iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes);
2231 break; 2239 break;
2240 case NL80211_IFTYPE_MONITOR:
2241 if (changes & BSS_CHANGED_MU_GROUPS)
2242 iwl_mvm_update_mu_groups(mvm, vif);
2243 break;
2232 default: 2244 default:
2233 /* shouldn't happen */ 2245 /* shouldn't happen */
2234 WARN_ON_ONCE(1); 2246 WARN_ON_ONCE(1);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 2e30990c717e..d17cbf603f7c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -604,16 +604,9 @@ enum iwl_mvm_tdls_cs_state {
604}; 604};
605 605
606struct iwl_mvm_shared_mem_cfg { 606struct iwl_mvm_shared_mem_cfg {
607 u32 shared_mem_addr; 607 int num_txfifo_entries;
608 u32 shared_mem_size;
609 u32 sample_buff_addr;
610 u32 sample_buff_size;
611 u32 txfifo_addr;
612 u32 txfifo_size[TX_FIFO_MAX_NUM]; 608 u32 txfifo_size[TX_FIFO_MAX_NUM];
613 u32 rxfifo_size[RX_FIFO_MAX_NUM]; 609 u32 rxfifo_size[RX_FIFO_MAX_NUM];
614 u32 page_buff_addr;
615 u32 page_buff_size;
616 u32 rxfifo_addr;
617 u32 internal_txfifo_addr; 610 u32 internal_txfifo_addr;
618 u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM]; 611 u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
619}; 612};
@@ -828,6 +821,12 @@ struct iwl_mvm {
828 /* UMAC scan tracking */ 821 /* UMAC scan tracking */
829 u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS]; 822 u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS];
830 823
824 /* start time of last scan in TSF of the mac that requested the scan */
825 u64 scan_start;
826
827 /* the vif that requested the current scan */
828 struct iwl_mvm_vif *scan_vif;
829
831 /* rx chain antennas set through debugfs for the scan command */ 830 /* rx chain antennas set through debugfs for the scan command */
832 u8 scan_rx_ant; 831 u8 scan_rx_ant;
833 832
@@ -1269,6 +1268,7 @@ u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
1269void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm); 1268void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
1270u8 first_antenna(u8 mask); 1269u8 first_antenna(u8 mask);
1271u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx); 1270u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
1271void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime);
1272 1272
1273/* Tx / Host Commands */ 1273/* Tx / Host Commands */
1274int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm, 1274int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
@@ -1305,8 +1305,6 @@ static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
1305 1305
1306 tx_cmd->sec_ctl = TX_CMD_SEC_CCM; 1306 tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
1307 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); 1307 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
1308 if (info->flags & IEEE80211_TX_CTL_AMPDU)
1309 tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_CCMP_AGG);
1310} 1308}
1311 1309
1312static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm) 1310static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 7a686f67f007..eade099b6dbf 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -66,7 +66,6 @@
66 *****************************************************************************/ 66 *****************************************************************************/
67#include <linux/firmware.h> 67#include <linux/firmware.h>
68#include <linux/rtnetlink.h> 68#include <linux/rtnetlink.h>
69#include <linux/acpi.h>
70#include "iwl-trans.h" 69#include "iwl-trans.h"
71#include "iwl-csr.h" 70#include "iwl-csr.h"
72#include "mvm.h" 71#include "mvm.h"
@@ -751,96 +750,6 @@ exit:
751 return resp_cp; 750 return resp_cp;
752} 751}
753 752
754#ifdef CONFIG_ACPI
755#define WRD_METHOD "WRDD"
756#define WRDD_WIFI (0x07)
757#define WRDD_WIGIG (0x10)
758
759static u32 iwl_mvm_wrdd_get_mcc(struct iwl_mvm *mvm, union acpi_object *wrdd)
760{
761 union acpi_object *mcc_pkg, *domain_type, *mcc_value;
762 u32 i;
763
764 if (wrdd->type != ACPI_TYPE_PACKAGE ||
765 wrdd->package.count < 2 ||
766 wrdd->package.elements[0].type != ACPI_TYPE_INTEGER ||
767 wrdd->package.elements[0].integer.value != 0) {
768 IWL_DEBUG_LAR(mvm, "Unsupported wrdd structure\n");
769 return 0;
770 }
771
772 for (i = 1 ; i < wrdd->package.count ; ++i) {
773 mcc_pkg = &wrdd->package.elements[i];
774
775 if (mcc_pkg->type != ACPI_TYPE_PACKAGE ||
776 mcc_pkg->package.count < 2 ||
777 mcc_pkg->package.elements[0].type != ACPI_TYPE_INTEGER ||
778 mcc_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
779 mcc_pkg = NULL;
780 continue;
781 }
782
783 domain_type = &mcc_pkg->package.elements[0];
784 if (domain_type->integer.value == WRDD_WIFI)
785 break;
786
787 mcc_pkg = NULL;
788 }
789
790 if (mcc_pkg) {
791 mcc_value = &mcc_pkg->package.elements[1];
792 return mcc_value->integer.value;
793 }
794
795 return 0;
796}
797
798static int iwl_mvm_get_bios_mcc(struct iwl_mvm *mvm, char *mcc)
799{
800 acpi_handle root_handle;
801 acpi_handle handle;
802 struct acpi_buffer wrdd = {ACPI_ALLOCATE_BUFFER, NULL};
803 acpi_status status;
804 u32 mcc_val;
805
806 root_handle = ACPI_HANDLE(mvm->dev);
807 if (!root_handle) {
808 IWL_DEBUG_LAR(mvm,
809 "Could not retrieve root port ACPI handle\n");
810 return -ENOENT;
811 }
812
813 /* Get the method's handle */
814 status = acpi_get_handle(root_handle, (acpi_string)WRD_METHOD, &handle);
815 if (ACPI_FAILURE(status)) {
816 IWL_DEBUG_LAR(mvm, "WRD method not found\n");
817 return -ENOENT;
818 }
819
820 /* Call WRDD with no arguments */
821 status = acpi_evaluate_object(handle, NULL, NULL, &wrdd);
822 if (ACPI_FAILURE(status)) {
823 IWL_DEBUG_LAR(mvm, "WRDC invocation failed (0x%x)\n", status);
824 return -ENOENT;
825 }
826
827 mcc_val = iwl_mvm_wrdd_get_mcc(mvm, wrdd.pointer);
828 kfree(wrdd.pointer);
829 if (!mcc_val)
830 return -ENOENT;
831
832 mcc[0] = (mcc_val >> 8) & 0xff;
833 mcc[1] = mcc_val & 0xff;
834 mcc[2] = '\0';
835 return 0;
836}
837#else /* CONFIG_ACPI */
838static int iwl_mvm_get_bios_mcc(struct iwl_mvm *mvm, char *mcc)
839{
840 return -ENOENT;
841}
842#endif
843
844int iwl_mvm_init_mcc(struct iwl_mvm *mvm) 753int iwl_mvm_init_mcc(struct iwl_mvm *mvm)
845{ 754{
846 bool tlv_lar; 755 bool tlv_lar;
@@ -884,7 +793,7 @@ int iwl_mvm_init_mcc(struct iwl_mvm *mvm)
884 return -EIO; 793 return -EIO;
885 794
886 if (iwl_mvm_is_wifi_mcc_supported(mvm) && 795 if (iwl_mvm_is_wifi_mcc_supported(mvm) &&
887 !iwl_mvm_get_bios_mcc(mvm, mcc)) { 796 !iwl_get_bios_mcc(mvm->dev, mcc)) {
888 kfree(regd); 797 kfree(regd);
889 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, mcc, 798 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, mcc,
890 MCC_SOURCE_BIOS, NULL); 799 MCC_SOURCE_BIOS, NULL);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 55d9096da68c..05fe6dd1a2c8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -359,6 +359,7 @@ static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = {
359 HCMD_NAME(BT_COEX_CI), 359 HCMD_NAME(BT_COEX_CI),
360 HCMD_NAME(PHY_CONFIGURATION_CMD), 360 HCMD_NAME(PHY_CONFIGURATION_CMD),
361 HCMD_NAME(CALIB_RES_NOTIF_PHY_DB), 361 HCMD_NAME(CALIB_RES_NOTIF_PHY_DB),
362 HCMD_NAME(PHY_DB_CMD),
362 HCMD_NAME(SCAN_OFFLOAD_COMPLETE), 363 HCMD_NAME(SCAN_OFFLOAD_COMPLETE),
363 HCMD_NAME(SCAN_OFFLOAD_UPDATE_PROFILES_CMD), 364 HCMD_NAME(SCAN_OFFLOAD_UPDATE_PROFILES_CMD),
364 HCMD_NAME(SCAN_OFFLOAD_CONFIG_CMD), 365 HCMD_NAME(SCAN_OFFLOAD_CONFIG_CMD),
@@ -652,11 +653,9 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
652 /* the hardware splits the A-MSDU */ 653 /* the hardware splits the A-MSDU */
653 if (mvm->cfg->mq_rx_supported) 654 if (mvm->cfg->mq_rx_supported)
654 trans_cfg.rx_buf_size = IWL_AMSDU_4K; 655 trans_cfg.rx_buf_size = IWL_AMSDU_4K;
655 trans_cfg.wide_cmd_header = fw_has_api(&mvm->fw->ucode_capa,
656 IWL_UCODE_TLV_API_WIDE_CMD_HDR);
657 656
658 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DW_BC_TABLE) 657 trans->wide_cmd_header = true;
659 trans_cfg.bc_table_dword = true; 658 trans_cfg.bc_table_dword = true;
660 659
661 trans_cfg.command_groups = iwl_mvm_groups; 660 trans_cfg.command_groups = iwl_mvm_groups;
662 trans_cfg.command_groups_size = ARRAY_SIZE(iwl_mvm_groups); 661 trans_cfg.command_groups_size = ARRAY_SIZE(iwl_mvm_groups);
@@ -711,37 +710,21 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
711 IWL_DEBUG_EEPROM(mvm->trans->dev, 710 IWL_DEBUG_EEPROM(mvm->trans->dev,
712 "working without external nvm file\n"); 711 "working without external nvm file\n");
713 712
714 if (WARN(cfg->no_power_up_nic_in_init && !mvm->nvm_file_name, 713 err = iwl_trans_start_hw(mvm->trans);
715 "not allowing power-up and not having nvm_file\n")) 714 if (err)
716 goto out_free; 715 goto out_free;
717 716
718 /* 717 mutex_lock(&mvm->mutex);
719 * Even if nvm exists in the nvm_file driver should read again the nvm 718 iwl_mvm_ref(mvm, IWL_MVM_REF_INIT_UCODE);
720 * from the nic because there might be entries that exist in the OTP 719 err = iwl_run_init_mvm_ucode(mvm, true);
721 * and not in the file. 720 if (!err || !iwlmvm_mod_params.init_dbg)
722 * for nics with no_power_up_nic_in_init: rely completley on nvm_file 721 iwl_mvm_stop_device(mvm);
723 */ 722 iwl_mvm_unref(mvm, IWL_MVM_REF_INIT_UCODE);
724 if (cfg->no_power_up_nic_in_init && mvm->nvm_file_name) { 723 mutex_unlock(&mvm->mutex);
725 err = iwl_nvm_init(mvm, false); 724 /* returns 0 if successful, 1 if success but in rfkill */
726 if (err) 725 if (err < 0 && !iwlmvm_mod_params.init_dbg) {
727 goto out_free; 726 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", err);
728 } else { 727 goto out_free;
729 err = iwl_trans_start_hw(mvm->trans);
730 if (err)
731 goto out_free;
732
733 mutex_lock(&mvm->mutex);
734 iwl_mvm_ref(mvm, IWL_MVM_REF_INIT_UCODE);
735 err = iwl_run_init_mvm_ucode(mvm, true);
736 if (!err || !iwlmvm_mod_params.init_dbg)
737 iwl_mvm_stop_device(mvm);
738 iwl_mvm_unref(mvm, IWL_MVM_REF_INIT_UCODE);
739 mutex_unlock(&mvm->mutex);
740 /* returns 0 if successful, 1 if success but in rfkill */
741 if (err < 0 && !iwlmvm_mod_params.init_dbg) {
742 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", err);
743 goto out_free;
744 }
745 } 728 }
746 729
747 scan_size = iwl_mvm_scan_size(mvm); 730 scan_size = iwl_mvm_scan_size(mvm);
@@ -783,8 +766,8 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
783 flush_delayed_work(&mvm->fw_dump_wk); 766 flush_delayed_work(&mvm->fw_dump_wk);
784 iwl_phy_db_free(mvm->phy_db); 767 iwl_phy_db_free(mvm->phy_db);
785 kfree(mvm->scan_cmd); 768 kfree(mvm->scan_cmd);
786 if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name) 769 iwl_trans_op_mode_leave(trans);
787 iwl_trans_op_mode_leave(trans); 770
788 ieee80211_free_hw(mvm->hw); 771 ieee80211_free_hw(mvm->hw);
789 return NULL; 772 return NULL;
790} 773}
@@ -857,9 +840,7 @@ static void iwl_mvm_async_handlers_wk(struct work_struct *wk)
857 struct iwl_mvm *mvm = 840 struct iwl_mvm *mvm =
858 container_of(wk, struct iwl_mvm, async_handlers_wk); 841 container_of(wk, struct iwl_mvm, async_handlers_wk);
859 struct iwl_async_handler_entry *entry, *tmp; 842 struct iwl_async_handler_entry *entry, *tmp;
860 struct list_head local_list; 843 LIST_HEAD(local_list);
861
862 INIT_LIST_HEAD(&local_list);
863 844
864 /* Ensure that we are not in stop flow (check iwl_mvm_mac_stop) */ 845 /* Ensure that we are not in stop flow (check iwl_mvm_mac_stop) */
865 846
@@ -966,10 +947,11 @@ static void iwl_mvm_rx(struct iwl_op_mode *op_mode,
966{ 947{
967 struct iwl_rx_packet *pkt = rxb_addr(rxb); 948 struct iwl_rx_packet *pkt = rxb_addr(rxb);
968 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 949 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
950 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
969 951
970 if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD)) 952 if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
971 iwl_mvm_rx_rx_mpdu(mvm, napi, rxb); 953 iwl_mvm_rx_rx_mpdu(mvm, napi, rxb);
972 else if (pkt->hdr.cmd == REPLY_RX_PHY_CMD) 954 else if (cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_PHY_CMD))
973 iwl_mvm_rx_rx_phy_cmd(mvm, rxb); 955 iwl_mvm_rx_rx_phy_cmd(mvm, rxb);
974 else 956 else
975 iwl_mvm_rx_common(mvm, rxb, pkt); 957 iwl_mvm_rx_common(mvm, rxb, pkt);
@@ -981,13 +963,14 @@ static void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
981{ 963{
982 struct iwl_rx_packet *pkt = rxb_addr(rxb); 964 struct iwl_rx_packet *pkt = rxb_addr(rxb);
983 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 965 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
966 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
984 967
985 if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD)) 968 if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
986 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0); 969 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0);
987 else if (unlikely(pkt->hdr.group_id == DATA_PATH_GROUP && 970 else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP,
988 pkt->hdr.cmd == RX_QUEUES_NOTIFICATION)) 971 RX_QUEUES_NOTIFICATION)))
989 iwl_mvm_rx_queue_notif(mvm, rxb, 0); 972 iwl_mvm_rx_queue_notif(mvm, rxb, 0);
990 else if (pkt->hdr.cmd == FRAME_RELEASE) 973 else if (cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))
991 iwl_mvm_rx_frame_release(mvm, napi, rxb, 0); 974 iwl_mvm_rx_frame_release(mvm, napi, rxb, 0);
992 else 975 else
993 iwl_mvm_rx_common(mvm, rxb, pkt); 976 iwl_mvm_rx_common(mvm, rxb, pkt);
@@ -1666,13 +1649,14 @@ static void iwl_mvm_rx_mq_rss(struct iwl_op_mode *op_mode,
1666{ 1649{
1667 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1650 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
1668 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1651 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1652 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
1669 1653
1670 if (unlikely(pkt->hdr.cmd == FRAME_RELEASE)) 1654 if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE)))
1671 iwl_mvm_rx_frame_release(mvm, napi, rxb, queue); 1655 iwl_mvm_rx_frame_release(mvm, napi, rxb, queue);
1672 else if (unlikely(pkt->hdr.cmd == RX_QUEUES_NOTIFICATION && 1656 else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP,
1673 pkt->hdr.group_id == DATA_PATH_GROUP)) 1657 RX_QUEUES_NOTIFICATION)))
1674 iwl_mvm_rx_queue_notif(mvm, rxb, queue); 1658 iwl_mvm_rx_queue_notif(mvm, rxb, queue);
1675 else 1659 else if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
1676 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue); 1660 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue);
1677} 1661}
1678 1662
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/power.c b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
index ff85865b1dda..af6d10c23e5a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/power.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
@@ -694,8 +694,7 @@ static void iwl_mvm_power_set_pm(struct iwl_mvm *mvm,
694 694
695 /* enable PM on p2p if p2p stand alone */ 695 /* enable PM on p2p if p2p stand alone */
696 if (vifs->p2p_active && !vifs->bss_active && !vifs->ap_active) { 696 if (vifs->p2p_active && !vifs->bss_active && !vifs->ap_active) {
697 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM) 697 p2p_mvmvif->pm_enabled = true;
698 p2p_mvmvif->pm_enabled = true;
699 return; 698 return;
700 } 699 }
701 700
@@ -707,12 +706,10 @@ static void iwl_mvm_power_set_pm(struct iwl_mvm *mvm,
707 ap_mvmvif->phy_ctxt->id); 706 ap_mvmvif->phy_ctxt->id);
708 707
709 /* clients are not stand alone: enable PM if DCM */ 708 /* clients are not stand alone: enable PM if DCM */
710 if (!(client_same_channel || ap_same_channel) && 709 if (!(client_same_channel || ap_same_channel)) {
711 (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM)) {
712 if (vifs->bss_active) 710 if (vifs->bss_active)
713 bss_mvmvif->pm_enabled = true; 711 bss_mvmvif->pm_enabled = true;
714 if (vifs->p2p_active && 712 if (vifs->p2p_active)
715 (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM))
716 p2p_mvmvif->pm_enabled = true; 713 p2p_mvmvif->pm_enabled = true;
717 return; 714 return;
718 } 715 }
@@ -721,12 +718,10 @@ static void iwl_mvm_power_set_pm(struct iwl_mvm *mvm,
721 * There is only one channel in the system and there are only 718 * There is only one channel in the system and there are only
722 * bss and p2p clients that share it 719 * bss and p2p clients that share it
723 */ 720 */
724 if (client_same_channel && !vifs->ap_active && 721 if (client_same_channel && !vifs->ap_active) {
725 (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM)) {
726 /* share same channel*/ 722 /* share same channel*/
727 bss_mvmvif->pm_enabled = true; 723 bss_mvmvif->pm_enabled = true;
728 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM) 724 p2p_mvmvif->pm_enabled = true;
729 p2p_mvmvif->pm_enabled = true;
730 } 725 }
731} 726}
732 727
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 08d8a8abb918..a57c6ef5bc14 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -418,10 +418,11 @@ static void iwl_mvm_release_frames(struct iwl_mvm *mvm,
418 418
419 ssn = ieee80211_sn_inc(ssn); 419 ssn = ieee80211_sn_inc(ssn);
420 420
421 /* holes are valid since nssn indicates frames were received. */ 421 /*
422 if (skb_queue_empty(skb_list) || !skb_peek_tail(skb_list)) 422 * Empty the list. Will have more than one frame for A-MSDU.
423 continue; 423 * Empty list is valid as well since nssn indicates frames were
424 /* Empty the list. Will have more than one frame for A-MSDU */ 424 * received.
425 */
425 while ((skb = __skb_dequeue(skb_list))) { 426 while ((skb = __skb_dequeue(skb_list))) {
426 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, 427 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb,
427 reorder_buf->queue, 428 reorder_buf->queue,
@@ -434,7 +435,7 @@ static void iwl_mvm_release_frames(struct iwl_mvm *mvm,
434 if (reorder_buf->num_stored && !reorder_buf->removed) { 435 if (reorder_buf->num_stored && !reorder_buf->removed) {
435 u16 index = reorder_buf->head_sn % reorder_buf->buf_size; 436 u16 index = reorder_buf->head_sn % reorder_buf->buf_size;
436 437
437 while (!skb_peek_tail(&reorder_buf->entries[index])) 438 while (skb_queue_empty(&reorder_buf->entries[index]))
438 index = (index + 1) % reorder_buf->buf_size; 439 index = (index + 1) % reorder_buf->buf_size;
439 /* modify timer to match next frame's expiration time */ 440 /* modify timer to match next frame's expiration time */
440 mod_timer(&reorder_buf->reorder_timer, 441 mod_timer(&reorder_buf->reorder_timer,
@@ -452,17 +453,17 @@ void iwl_mvm_reorder_timer_expired(unsigned long data)
452 u16 sn = 0, index = 0; 453 u16 sn = 0, index = 0;
453 bool expired = false; 454 bool expired = false;
454 455
455 spin_lock_bh(&buf->lock); 456 spin_lock(&buf->lock);
456 457
457 if (!buf->num_stored || buf->removed) { 458 if (!buf->num_stored || buf->removed) {
458 spin_unlock_bh(&buf->lock); 459 spin_unlock(&buf->lock);
459 return; 460 return;
460 } 461 }
461 462
462 for (i = 0; i < buf->buf_size ; i++) { 463 for (i = 0; i < buf->buf_size ; i++) {
463 index = (buf->head_sn + i) % buf->buf_size; 464 index = (buf->head_sn + i) % buf->buf_size;
464 465
465 if (!skb_peek_tail(&buf->entries[index])) 466 if (skb_queue_empty(&buf->entries[index]))
466 continue; 467 continue;
467 if (!time_after(jiffies, buf->reorder_time[index] + 468 if (!time_after(jiffies, buf->reorder_time[index] +
468 RX_REORDER_BUF_TIMEOUT_MQ)) 469 RX_REORDER_BUF_TIMEOUT_MQ))
@@ -492,7 +493,7 @@ void iwl_mvm_reorder_timer_expired(unsigned long data)
492 buf->reorder_time[index] + 493 buf->reorder_time[index] +
493 1 + RX_REORDER_BUF_TIMEOUT_MQ); 494 1 + RX_REORDER_BUF_TIMEOUT_MQ);
494 } 495 }
495 spin_unlock_bh(&buf->lock); 496 spin_unlock(&buf->lock);
496} 497}
497 498
498static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue, 499static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue,
@@ -503,7 +504,7 @@ static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue,
503 struct iwl_mvm_reorder_buffer *reorder_buf; 504 struct iwl_mvm_reorder_buffer *reorder_buf;
504 u8 baid = data->baid; 505 u8 baid = data->baid;
505 506
506 if (WARN_ON_ONCE(baid >= IWL_RX_REORDER_DATA_INVALID_BAID)) 507 if (WARN_ONCE(baid >= IWL_MAX_BAID, "invalid BAID: %x\n", baid))
507 return; 508 return;
508 509
509 rcu_read_lock(); 510 rcu_read_lock();
@@ -590,6 +591,11 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
590 baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >> 591 baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >>
591 IWL_RX_MPDU_REORDER_BAID_SHIFT; 592 IWL_RX_MPDU_REORDER_BAID_SHIFT;
592 593
594 /*
595 * This also covers the case of receiving a Block Ack Request
596 * outside a BA session; we'll pass it to mac80211 and that
597 * then sends a delBA action frame.
598 */
593 if (baid == IWL_RX_REORDER_DATA_INVALID_BAID) 599 if (baid == IWL_RX_REORDER_DATA_INVALID_BAID)
594 return false; 600 return false;
595 601
@@ -599,9 +605,10 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
599 605
600 mvm_sta = iwl_mvm_sta_from_mac80211(sta); 606 mvm_sta = iwl_mvm_sta_from_mac80211(sta);
601 607
602 /* not a data packet */ 608 /* not a data packet or a bar */
603 if (!ieee80211_is_data_qos(hdr->frame_control) || 609 if (!ieee80211_is_back_req(hdr->frame_control) &&
604 is_multicast_ether_addr(hdr->addr1)) 610 (!ieee80211_is_data_qos(hdr->frame_control) ||
611 is_multicast_ether_addr(hdr->addr1)))
605 return false; 612 return false;
606 613
607 if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) 614 if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
@@ -625,6 +632,11 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
625 632
626 spin_lock_bh(&buffer->lock); 633 spin_lock_bh(&buffer->lock);
627 634
635 if (ieee80211_is_back_req(hdr->frame_control)) {
636 iwl_mvm_release_frames(mvm, sta, napi, buffer, nssn);
637 goto drop;
638 }
639
628 /* 640 /*
629 * If there was a significant jump in the nssn - adjust. 641 * If there was a significant jump in the nssn - adjust.
630 * If the SN is smaller than the NSSN it might need to first go into 642 * If the SN is smaller than the NSSN it might need to first go into
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
index dac120f8861b..f279fdd6eb44 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
@@ -141,6 +141,7 @@ struct iwl_mvm_scan_params {
141 struct cfg80211_match_set *match_sets; 141 struct cfg80211_match_set *match_sets;
142 int n_scan_plans; 142 int n_scan_plans;
143 struct cfg80211_sched_scan_plan *scan_plans; 143 struct cfg80211_sched_scan_plan *scan_plans;
144 u32 measurement_dwell;
144}; 145};
145 146
146static u8 iwl_mvm_scan_rx_ant(struct iwl_mvm *mvm) 147static u8 iwl_mvm_scan_rx_ant(struct iwl_mvm *mvm)
@@ -232,6 +233,27 @@ iwl_mvm_scan_type iwl_mvm_get_scan_type(struct iwl_mvm *mvm, bool p2p_device)
232 return IWL_SCAN_TYPE_WILD; 233 return IWL_SCAN_TYPE_WILD;
233} 234}
234 235
236static int
237iwl_mvm_get_measurement_dwell(struct iwl_mvm *mvm,
238 struct cfg80211_scan_request *req,
239 struct iwl_mvm_scan_params *params)
240{
241 if (!req->duration)
242 return 0;
243
244 if (req->duration_mandatory &&
245 req->duration > scan_timing[params->type].max_out_time) {
246 IWL_DEBUG_SCAN(mvm,
247 "Measurement scan - too long dwell %hu (max out time %u)\n",
248 req->duration,
249 scan_timing[params->type].max_out_time);
250 return -EOPNOTSUPP;
251 }
252
253 return min_t(u32, (u32)req->duration,
254 scan_timing[params->type].max_out_time);
255}
256
235static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm) 257static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm)
236{ 258{
237 /* require rrm scan whenever the fw supports it */ 259 /* require rrm scan whenever the fw supports it */
@@ -717,22 +739,6 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
717 params->preq.common_data.len = cpu_to_le16(ies->common_ie_len); 739 params->preq.common_data.len = cpu_to_le16(ies->common_ie_len);
718} 740}
719 741
720static __le32 iwl_mvm_scan_priority(struct iwl_mvm *mvm,
721 enum iwl_scan_priority_ext prio)
722{
723 if (fw_has_api(&mvm->fw->ucode_capa,
724 IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY))
725 return cpu_to_le32(prio);
726
727 if (prio <= IWL_SCAN_PRIORITY_EXT_2)
728 return cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
729
730 if (prio <= IWL_SCAN_PRIORITY_EXT_4)
731 return cpu_to_le32(IWL_SCAN_PRIORITY_MEDIUM);
732
733 return cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
734}
735
736static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm, 742static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm,
737 struct iwl_scan_req_lmac *cmd, 743 struct iwl_scan_req_lmac *cmd,
738 struct iwl_mvm_scan_params *params) 744 struct iwl_mvm_scan_params *params)
@@ -743,7 +749,7 @@ static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm,
743 cmd->extended_dwell = scan_timing[params->type].dwell_extended; 749 cmd->extended_dwell = scan_timing[params->type].dwell_extended;
744 cmd->max_out_time = cpu_to_le32(scan_timing[params->type].max_out_time); 750 cmd->max_out_time = cpu_to_le32(scan_timing[params->type].max_out_time);
745 cmd->suspend_time = cpu_to_le32(scan_timing[params->type].suspend_time); 751 cmd->suspend_time = cpu_to_le32(scan_timing[params->type].suspend_time);
746 cmd->scan_prio = iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6); 752 cmd->scan_prio = cpu_to_le32(IWL_SCAN_PRIORITY_EXT_6);
747} 753}
748 754
749static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids, 755static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
@@ -1033,21 +1039,24 @@ static void iwl_mvm_scan_umac_dwell(struct iwl_mvm *mvm,
1033 struct iwl_scan_req_umac *cmd, 1039 struct iwl_scan_req_umac *cmd,
1034 struct iwl_mvm_scan_params *params) 1040 struct iwl_mvm_scan_params *params)
1035{ 1041{
1036 cmd->extended_dwell = scan_timing[params->type].dwell_extended; 1042 if (params->measurement_dwell) {
1037 cmd->active_dwell = scan_timing[params->type].dwell_active; 1043 cmd->active_dwell = params->measurement_dwell;
1038 cmd->passive_dwell = scan_timing[params->type].dwell_passive; 1044 cmd->passive_dwell = params->measurement_dwell;
1045 cmd->extended_dwell = params->measurement_dwell;
1046 } else {
1047 cmd->active_dwell = scan_timing[params->type].dwell_active;
1048 cmd->passive_dwell = scan_timing[params->type].dwell_passive;
1049 cmd->extended_dwell = scan_timing[params->type].dwell_extended;
1050 }
1039 cmd->fragmented_dwell = scan_timing[params->type].dwell_fragmented; 1051 cmd->fragmented_dwell = scan_timing[params->type].dwell_fragmented;
1040 cmd->max_out_time = cpu_to_le32(scan_timing[params->type].max_out_time); 1052 cmd->max_out_time = cpu_to_le32(scan_timing[params->type].max_out_time);
1041 cmd->suspend_time = cpu_to_le32(scan_timing[params->type].suspend_time); 1053 cmd->suspend_time = cpu_to_le32(scan_timing[params->type].suspend_time);
1042 cmd->scan_priority = 1054 cmd->scan_priority = cpu_to_le32(IWL_SCAN_PRIORITY_EXT_6);
1043 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6);
1044 1055
1045 if (iwl_mvm_is_regular_scan(params)) 1056 if (iwl_mvm_is_regular_scan(params))
1046 cmd->ooc_priority = 1057 cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_EXT_6);
1047 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6);
1048 else 1058 else
1049 cmd->ooc_priority = 1059 cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_EXT_2);
1050 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_2);
1051} 1060}
1052 1061
1053static void 1062static void
@@ -1067,11 +1076,11 @@ iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm,
1067 } 1076 }
1068} 1077}
1069 1078
1070static u32 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm, 1079static u16 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm,
1071 struct iwl_mvm_scan_params *params, 1080 struct iwl_mvm_scan_params *params,
1072 struct ieee80211_vif *vif) 1081 struct ieee80211_vif *vif)
1073{ 1082{
1074 int flags = 0; 1083 u16 flags = 0;
1075 1084
1076 if (params->n_ssids == 0) 1085 if (params->n_ssids == 0)
1077 flags = IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE; 1086 flags = IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE;
@@ -1093,6 +1102,9 @@ static u32 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm,
1093 if (!iwl_mvm_is_regular_scan(params)) 1102 if (!iwl_mvm_is_regular_scan(params))
1094 flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC; 1103 flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
1095 1104
1105 if (params->measurement_dwell)
1106 flags |= IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE;
1107
1096#ifdef CONFIG_IWLWIFI_DEBUGFS 1108#ifdef CONFIG_IWLWIFI_DEBUGFS
1097 if (mvm->scan_iter_notif_enabled) 1109 if (mvm->scan_iter_notif_enabled)
1098 flags |= IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE; 1110 flags |= IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE;
@@ -1119,6 +1131,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1119 mvm->fw->ucode_capa.n_scan_channels; 1131 mvm->fw->ucode_capa.n_scan_channels;
1120 int uid, i; 1132 int uid, i;
1121 u32 ssid_bitmap = 0; 1133 u32 ssid_bitmap = 0;
1134 struct iwl_mvm_vif *scan_vif = iwl_mvm_vif_from_mac80211(vif);
1122 1135
1123 lockdep_assert_held(&mvm->mutex); 1136 lockdep_assert_held(&mvm->mutex);
1124 1137
@@ -1136,8 +1149,9 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1136 mvm->scan_uid_status[uid] = type; 1149 mvm->scan_uid_status[uid] = type;
1137 1150
1138 cmd->uid = cpu_to_le32(uid); 1151 cmd->uid = cpu_to_le32(uid);
1139 cmd->general_flags = cpu_to_le32(iwl_mvm_scan_umac_flags(mvm, params, 1152 cmd->general_flags = cpu_to_le16(iwl_mvm_scan_umac_flags(mvm, params,
1140 vif)); 1153 vif));
1154 cmd->scan_start_mac_id = scan_vif->id;
1141 1155
1142 if (type == IWL_MVM_SCAN_SCHED || type == IWL_MVM_SCAN_NETDETECT) 1156 if (type == IWL_MVM_SCAN_SCHED || type == IWL_MVM_SCAN_NETDETECT)
1143 cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE); 1157 cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE);
@@ -1289,6 +1303,12 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1289 iwl_mvm_get_scan_type(mvm, 1303 iwl_mvm_get_scan_type(mvm,
1290 vif->type == NL80211_IFTYPE_P2P_DEVICE); 1304 vif->type == NL80211_IFTYPE_P2P_DEVICE);
1291 1305
1306 ret = iwl_mvm_get_measurement_dwell(mvm, req, &params);
1307 if (ret < 0)
1308 return ret;
1309
1310 params.measurement_dwell = ret;
1311
1292 iwl_mvm_build_scan_probe(mvm, vif, ies, &params); 1312 iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
1293 1313
1294 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { 1314 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
@@ -1315,6 +1335,7 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1315 1335
1316 IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n"); 1336 IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n");
1317 mvm->scan_status |= IWL_MVM_SCAN_REGULAR; 1337 mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
1338 mvm->scan_vif = iwl_mvm_vif_from_mac80211(vif);
1318 iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN); 1339 iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
1319 1340
1320 queue_delayed_work(system_wq, &mvm->scan_timeout_dwork, 1341 queue_delayed_work(system_wq, &mvm->scan_timeout_dwork,
@@ -1437,9 +1458,12 @@ void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
1437 if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_REGULAR) { 1458 if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_REGULAR) {
1438 struct cfg80211_scan_info info = { 1459 struct cfg80211_scan_info info = {
1439 .aborted = aborted, 1460 .aborted = aborted,
1461 .scan_start_tsf = mvm->scan_start,
1440 }; 1462 };
1441 1463
1464 memcpy(info.tsf_bssid, mvm->scan_vif->bssid, ETH_ALEN);
1442 ieee80211_scan_completed(mvm->hw, &info); 1465 ieee80211_scan_completed(mvm->hw, &info);
1466 mvm->scan_vif = NULL;
1443 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); 1467 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
1444 cancel_delayed_work(&mvm->scan_timeout_dwork); 1468 cancel_delayed_work(&mvm->scan_timeout_dwork);
1445 } else if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_SCHED) { 1469 } else if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_SCHED) {
@@ -1473,6 +1497,8 @@ void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
1473 struct iwl_umac_scan_iter_complete_notif *notif = (void *)pkt->data; 1497 struct iwl_umac_scan_iter_complete_notif *notif = (void *)pkt->data;
1474 u8 buf[256]; 1498 u8 buf[256];
1475 1499
1500 mvm->scan_start = le64_to_cpu(notif->start_tsf);
1501
1476 IWL_DEBUG_SCAN(mvm, 1502 IWL_DEBUG_SCAN(mvm,
1477 "UMAC Scan iteration complete: status=0x%x scanned_channels=%d channels list: %s\n", 1503 "UMAC Scan iteration complete: status=0x%x scanned_channels=%d channels list: %s\n",
1478 notif->status, notif->scanned_channels, 1504 notif->status, notif->scanned_channels,
@@ -1485,6 +1511,10 @@ void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
1485 ieee80211_sched_scan_results(mvm->hw); 1511 ieee80211_sched_scan_results(mvm->hw);
1486 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_ENABLED; 1512 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_ENABLED;
1487 } 1513 }
1514
1515 IWL_DEBUG_SCAN(mvm,
1516 "UMAC Scan iteration complete: scan started at %llu (TSF)\n",
1517 mvm->scan_start);
1488} 1518}
1489 1519
1490static int iwl_mvm_umac_scan_abort(struct iwl_mvm *mvm, int type) 1520static int iwl_mvm_umac_scan_abort(struct iwl_mvm *mvm, int type)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 30fc3afe5241..fc771885e383 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -588,9 +588,7 @@ int iwl_mvm_scd_queue_redirect(struct iwl_mvm *mvm, int queue, int tid,
588 ret); 588 ret);
589 589
590 /* Make sure the SCD wrptr is correctly set before reconfiguring */ 590 /* Make sure the SCD wrptr is correctly set before reconfiguring */
591 iwl_trans_txq_enable(mvm->trans, queue, iwl_mvm_ac_to_tx_fifo[ac], 591 iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, NULL, wdg_timeout);
592 cmd.sta_id, tid, LINK_QUAL_AGG_FRAME_LIMIT_DEF,
593 ssn, wdg_timeout);
594 592
595 /* Update the TID "owner" of the queue */ 593 /* Update the TID "owner" of the queue */
596 spin_lock_bh(&mvm->queue_info_lock); 594 spin_lock_bh(&mvm->queue_info_lock);
@@ -747,14 +745,14 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
747 .scd_queue = queue, 745 .scd_queue = queue,
748 .action = SCD_CFG_DISABLE_QUEUE, 746 .action = SCD_CFG_DISABLE_QUEUE,
749 }; 747 };
750 u8 ac; 748 u8 txq_curr_ac;
751 749
752 disable_agg_tids = iwl_mvm_remove_sta_queue_marking(mvm, queue); 750 disable_agg_tids = iwl_mvm_remove_sta_queue_marking(mvm, queue);
753 751
754 spin_lock_bh(&mvm->queue_info_lock); 752 spin_lock_bh(&mvm->queue_info_lock);
755 ac = mvm->queue_info[queue].mac80211_ac; 753 txq_curr_ac = mvm->queue_info[queue].mac80211_ac;
756 cmd.sta_id = mvm->queue_info[queue].ra_sta_id; 754 cmd.sta_id = mvm->queue_info[queue].ra_sta_id;
757 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[ac]; 755 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[txq_curr_ac];
758 cmd.tid = mvm->queue_info[queue].txq_tid; 756 cmd.tid = mvm->queue_info[queue].txq_tid;
759 spin_unlock_bh(&mvm->queue_info_lock); 757 spin_unlock_bh(&mvm->queue_info_lock);
760 758
@@ -935,7 +933,7 @@ static void iwl_mvm_unshare_queue(struct iwl_mvm *mvm, int queue)
935 933
936 /* If aggs should be turned back on - do it */ 934 /* If aggs should be turned back on - do it */
937 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) { 935 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) {
938 struct iwl_mvm_add_sta_cmd cmd; 936 struct iwl_mvm_add_sta_cmd cmd = {0};
939 937
940 mvmsta->tid_disable_agg &= ~BIT(tid); 938 mvmsta->tid_disable_agg &= ~BIT(tid);
941 939
@@ -1299,13 +1297,6 @@ err:
1299 return ret; 1297 return ret;
1300} 1298}
1301 1299
1302int iwl_mvm_update_sta(struct iwl_mvm *mvm,
1303 struct ieee80211_vif *vif,
1304 struct ieee80211_sta *sta)
1305{
1306 return iwl_mvm_sta_send_to_fw(mvm, sta, true, 0);
1307}
1308
1309int iwl_mvm_drain_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, 1300int iwl_mvm_drain_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta,
1310 bool drain) 1301 bool drain)
1311{ 1302{
@@ -1498,9 +1489,31 @@ int iwl_mvm_rm_sta(struct iwl_mvm *mvm,
1498 ret = iwl_mvm_drain_sta(mvm, mvm_sta, false); 1489 ret = iwl_mvm_drain_sta(mvm, mvm_sta, false);
1499 1490
1500 /* If DQA is supported - the queues can be disabled now */ 1491 /* If DQA is supported - the queues can be disabled now */
1501 if (iwl_mvm_is_dqa_supported(mvm)) 1492 if (iwl_mvm_is_dqa_supported(mvm)) {
1493 u8 reserved_txq = mvm_sta->reserved_queue;
1494 enum iwl_mvm_queue_status *status;
1495
1502 iwl_mvm_disable_sta_queues(mvm, vif, mvm_sta); 1496 iwl_mvm_disable_sta_queues(mvm, vif, mvm_sta);
1503 1497
1498 /*
1499 * If no traffic has gone through the reserved TXQ - it
1500 * is still marked as IWL_MVM_QUEUE_RESERVED, and
1501 * should be manually marked as free again
1502 */
1503 spin_lock_bh(&mvm->queue_info_lock);
1504 status = &mvm->queue_info[reserved_txq].status;
1505 if (WARN((*status != IWL_MVM_QUEUE_RESERVED) &&
1506 (*status != IWL_MVM_QUEUE_FREE),
1507 "sta_id %d reserved txq %d status %d",
1508 mvm_sta->sta_id, reserved_txq, *status)) {
1509 spin_unlock_bh(&mvm->queue_info_lock);
1510 return -EINVAL;
1511 }
1512
1513 *status = IWL_MVM_QUEUE_FREE;
1514 spin_unlock_bh(&mvm->queue_info_lock);
1515 }
1516
1504 if (vif->type == NL80211_IFTYPE_STATION && 1517 if (vif->type == NL80211_IFTYPE_STATION &&
1505 mvmvif->ap_sta_id == mvm_sta->sta_id) { 1518 mvmvif->ap_sta_id == mvm_sta->sta_id) {
1506 /* if associated - we can't remove the AP STA now */ 1519 /* if associated - we can't remove the AP STA now */
@@ -2030,11 +2043,9 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2030 baid_data->baid = baid; 2043 baid_data->baid = baid;
2031 baid_data->timeout = timeout; 2044 baid_data->timeout = timeout;
2032 baid_data->last_rx = jiffies; 2045 baid_data->last_rx = jiffies;
2033 init_timer(&baid_data->session_timer); 2046 setup_timer(&baid_data->session_timer,
2034 baid_data->session_timer.function = 2047 iwl_mvm_rx_agg_session_expired,
2035 iwl_mvm_rx_agg_session_expired; 2048 (unsigned long)&mvm->baid_map[baid]);
2036 baid_data->session_timer.data =
2037 (unsigned long)&mvm->baid_map[baid];
2038 baid_data->mvm = mvm; 2049 baid_data->mvm = mvm;
2039 baid_data->tid = tid; 2050 baid_data->tid = tid;
2040 baid_data->sta_id = mvm_sta->sta_id; 2051 baid_data->sta_id = mvm_sta->sta_id;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
index 709542bbfce5..e068d5355865 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
@@ -473,9 +473,14 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
473int iwl_mvm_add_sta(struct iwl_mvm *mvm, 473int iwl_mvm_add_sta(struct iwl_mvm *mvm,
474 struct ieee80211_vif *vif, 474 struct ieee80211_vif *vif,
475 struct ieee80211_sta *sta); 475 struct ieee80211_sta *sta);
476int iwl_mvm_update_sta(struct iwl_mvm *mvm, 476
477 struct ieee80211_vif *vif, 477static inline int iwl_mvm_update_sta(struct iwl_mvm *mvm,
478 struct ieee80211_sta *sta); 478 struct ieee80211_vif *vif,
479 struct ieee80211_sta *sta)
480{
481 return iwl_mvm_sta_send_to_fw(mvm, sta, true, 0);
482}
483
479int iwl_mvm_rm_sta(struct iwl_mvm *mvm, 484int iwl_mvm_rm_sta(struct iwl_mvm *mvm,
480 struct ieee80211_vif *vif, 485 struct ieee80211_vif *vif,
481 struct ieee80211_sta *sta); 486 struct ieee80211_sta *sta);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 58fc7b3c711c..63a051be832e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -241,11 +241,8 @@ static int iwl_mvm_get_temp_cmd(struct iwl_mvm *mvm)
241 }; 241 };
242 u32 cmdid; 242 u32 cmdid;
243 243
244 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR)) 244 cmdid = iwl_cmd_id(CMD_DTS_MEASUREMENT_TRIGGER_WIDE,
245 cmdid = iwl_cmd_id(CMD_DTS_MEASUREMENT_TRIGGER_WIDE, 245 PHY_OPS_GROUP, 0);
246 PHY_OPS_GROUP, 0);
247 else
248 cmdid = CMD_DTS_MEASUREMENT_TRIGGER;
249 246
250 if (!fw_has_capa(&mvm->fw->ucode_capa, 247 if (!fw_has_capa(&mvm->fw->ucode_capa,
251 IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE)) 248 IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE))
@@ -261,9 +258,6 @@ int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp)
261 DTS_MEASUREMENT_NOTIF_WIDE) }; 258 DTS_MEASUREMENT_NOTIF_WIDE) };
262 int ret; 259 int ret;
263 260
264 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR))
265 temp_notif[0] = DTS_MEASUREMENT_NOTIFICATION;
266
267 lockdep_assert_held(&mvm->mutex); 261 lockdep_assert_held(&mvm->mutex);
268 262
269 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif, 263 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index f9150249af76..66957ac12ca4 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -346,7 +346,7 @@ void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
346 346
347 rate_idx = info->control.rates[0].idx; 347 rate_idx = info->control.rates[0].idx;
348 /* if the rate isn't a well known legacy rate, take the lowest one */ 348 /* if the rate isn't a well known legacy rate, take the lowest one */
349 if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT_LEGACY) 349 if (rate_idx < 0 || rate_idx >= IWL_RATE_COUNT_LEGACY)
350 rate_idx = rate_lowest_index( 350 rate_idx = rate_lowest_index(
351 &mvm->nvm_data->bands[info->band], sta); 351 &mvm->nvm_data->bands[info->band], sta);
352 352
@@ -441,7 +441,7 @@ static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
441 * one. 441 * one.
442 * Need to handle this. 442 * Need to handle this.
443 */ 443 */
444 tx_cmd->sec_ctl |= TX_CMD_SEC_GCMP | TC_CMD_SEC_KEY_FROM_TABLE; 444 tx_cmd->sec_ctl |= TX_CMD_SEC_GCMP | TX_CMD_SEC_KEY_FROM_TABLE;
445 tx_cmd->key[0] = keyconf->hw_key_idx; 445 tx_cmd->key[0] = keyconf->hw_key_idx;
446 iwl_mvm_set_tx_cmd_pn(info, crypto_hdr); 446 iwl_mvm_set_tx_cmd_pn(info, crypto_hdr);
447 break; 447 break;
@@ -490,16 +490,34 @@ iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
490static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm, 490static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm,
491 struct ieee80211_tx_info *info, __le16 fc) 491 struct ieee80211_tx_info *info, __le16 fc)
492{ 492{
493 if (iwl_mvm_is_dqa_supported(mvm)) { 493 if (!iwl_mvm_is_dqa_supported(mvm))
494 if (info->control.vif->type == NL80211_IFTYPE_AP && 494 return info->hw_queue;
495 ieee80211_is_probe_resp(fc)) 495
496 switch (info->control.vif->type) {
497 case NL80211_IFTYPE_AP:
498 /*
499 * handle legacy hostapd as well, where station may be added
500 * only after assoc.
501 */
502 if (ieee80211_is_probe_resp(fc) || ieee80211_is_auth(fc))
496 return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; 503 return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
497 else if (ieee80211_is_mgmt(fc) && 504 if (info->hw_queue == info->control.vif->cab_queue)
498 info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE) 505 return info->hw_queue;
506
507 WARN_ON_ONCE(1);
508 return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
509 case NL80211_IFTYPE_P2P_DEVICE:
510 if (ieee80211_is_mgmt(fc))
499 return IWL_MVM_DQA_P2P_DEVICE_QUEUE; 511 return IWL_MVM_DQA_P2P_DEVICE_QUEUE;
500 } 512 if (info->hw_queue == info->control.vif->cab_queue)
513 return info->hw_queue;
501 514
502 return info->hw_queue; 515 WARN_ON_ONCE(1);
516 return IWL_MVM_DQA_P2P_DEVICE_QUEUE;
517 default:
518 WARN_ONCE(1, "Not a ctrl vif, no available queue\n");
519 return -1;
520 }
503} 521}
504 522
505int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb) 523int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
@@ -559,6 +577,9 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
559 sta_id = mvmvif->bcast_sta.sta_id; 577 sta_id = mvmvif->bcast_sta.sta_id;
560 queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, 578 queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info,
561 hdr->frame_control); 579 hdr->frame_control);
580 if (queue < 0)
581 return -1;
582
562 } else if (info.control.vif->type == NL80211_IFTYPE_STATION && 583 } else if (info.control.vif->type == NL80211_IFTYPE_STATION &&
563 is_multicast_ether_addr(hdr->addr1)) { 584 is_multicast_ether_addr(hdr->addr1)) {
564 u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id); 585 u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id);
@@ -919,9 +940,13 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
919 tid = IWL_MAX_TID_COUNT; 940 tid = IWL_MAX_TID_COUNT;
920 } 941 }
921 942
922 if (iwl_mvm_is_dqa_supported(mvm)) 943 if (iwl_mvm_is_dqa_supported(mvm)) {
923 txq_id = mvmsta->tid_data[tid].txq_id; 944 txq_id = mvmsta->tid_data[tid].txq_id;
924 945
946 if (ieee80211_is_mgmt(fc))
947 tx_cmd->tid_tspec = IWL_TID_NON_QOS;
948 }
949
925 /* Copy MAC header from skb into command buffer */ 950 /* Copy MAC header from skb into command buffer */
926 memcpy(tx_cmd->hdr, hdr, hdrlen); 951 memcpy(tx_cmd->hdr, hdr, hdrlen);
927 952
@@ -1099,9 +1124,13 @@ static void iwl_mvm_check_ratid_empty(struct iwl_mvm *mvm,
1099 IWL_DEBUG_TX_QUEUES(mvm, 1124 IWL_DEBUG_TX_QUEUES(mvm,
1100 "Can continue DELBA flow ssn = next_recl = %d\n", 1125 "Can continue DELBA flow ssn = next_recl = %d\n",
1101 tid_data->next_reclaimed); 1126 tid_data->next_reclaimed);
1102 iwl_mvm_disable_txq(mvm, tid_data->txq_id, 1127 if (!iwl_mvm_is_dqa_supported(mvm)) {
1103 vif->hw_queue[tid_to_mac80211_ac[tid]], tid, 1128 u8 mac80211_ac = tid_to_mac80211_ac[tid];
1104 CMD_ASYNC); 1129
1130 iwl_mvm_disable_txq(mvm, tid_data->txq_id,
1131 vif->hw_queue[mac80211_ac], tid,
1132 CMD_ASYNC);
1133 }
1105 tid_data->state = IWL_AGG_OFF; 1134 tid_data->state = IWL_AGG_OFF;
1106 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 1135 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1107 break; 1136 break;
@@ -1579,41 +1608,16 @@ void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1579 iwl_mvm_rx_tx_cmd_agg(mvm, pkt); 1608 iwl_mvm_rx_tx_cmd_agg(mvm, pkt);
1580} 1609}
1581 1610
1582static void iwl_mvm_tx_info_from_ba_notif(struct ieee80211_tx_info *info, 1611static void iwl_mvm_tx_reclaim(struct iwl_mvm *mvm, int sta_id, int tid,
1583 struct iwl_mvm_ba_notif *ba_notif, 1612 int txq, int index,
1584 struct iwl_mvm_tid_data *tid_data) 1613 struct ieee80211_tx_info *ba_info, u32 rate)
1585{
1586 info->flags |= IEEE80211_TX_STAT_AMPDU;
1587 info->status.ampdu_ack_len = ba_notif->txed_2_done;
1588 info->status.ampdu_len = ba_notif->txed;
1589 iwl_mvm_hwrate_to_tx_status(tid_data->rate_n_flags,
1590 info);
1591 /* TODO: not accounted if the whole A-MPDU failed */
1592 info->status.tx_time = tid_data->tx_time;
1593 info->status.status_driver_data[0] =
1594 (void *)(uintptr_t)ba_notif->reduced_txp;
1595 info->status.status_driver_data[1] =
1596 (void *)(uintptr_t)tid_data->rate_n_flags;
1597}
1598
1599void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1600{ 1614{
1601 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1602 struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data;
1603 struct sk_buff_head reclaimed_skbs; 1615 struct sk_buff_head reclaimed_skbs;
1604 struct iwl_mvm_tid_data *tid_data; 1616 struct iwl_mvm_tid_data *tid_data;
1605 struct ieee80211_sta *sta; 1617 struct ieee80211_sta *sta;
1606 struct iwl_mvm_sta *mvmsta; 1618 struct iwl_mvm_sta *mvmsta;
1607 struct sk_buff *skb; 1619 struct sk_buff *skb;
1608 int sta_id, tid, freed; 1620 int freed;
1609 /* "flow" corresponds to Tx queue */
1610 u16 scd_flow = le16_to_cpu(ba_notif->scd_flow);
1611 /* "ssn" is start of block-ack Tx window, corresponds to index
1612 * (in Tx queue's circular buffer) of first TFD/frame in window */
1613 u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn);
1614
1615 sta_id = ba_notif->sta_id;
1616 tid = ba_notif->tid;
1617 1621
1618 if (WARN_ONCE(sta_id >= IWL_MVM_STATION_COUNT || 1622 if (WARN_ONCE(sta_id >= IWL_MVM_STATION_COUNT ||
1619 tid >= IWL_MAX_TID_COUNT, 1623 tid >= IWL_MAX_TID_COUNT,
@@ -1633,10 +1637,10 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1633 mvmsta = iwl_mvm_sta_from_mac80211(sta); 1637 mvmsta = iwl_mvm_sta_from_mac80211(sta);
1634 tid_data = &mvmsta->tid_data[tid]; 1638 tid_data = &mvmsta->tid_data[tid];
1635 1639
1636 if (tid_data->txq_id != scd_flow) { 1640 if (tid_data->txq_id != txq) {
1637 IWL_ERR(mvm, 1641 IWL_ERR(mvm,
1638 "invalid BA notification: Q %d, tid %d, flow %d\n", 1642 "invalid BA notification: Q %d, tid %d\n",
1639 tid_data->txq_id, tid, scd_flow); 1643 tid_data->txq_id, tid);
1640 rcu_read_unlock(); 1644 rcu_read_unlock();
1641 return; 1645 return;
1642 } 1646 }
@@ -1650,27 +1654,14 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1650 * block-ack window (we assume that they've been successfully 1654 * block-ack window (we assume that they've been successfully
1651 * transmitted ... if not, it's too late anyway). 1655 * transmitted ... if not, it's too late anyway).
1652 */ 1656 */
1653 iwl_trans_reclaim(mvm->trans, scd_flow, ba_resp_scd_ssn, 1657 iwl_trans_reclaim(mvm->trans, txq, index, &reclaimed_skbs);
1654 &reclaimed_skbs);
1655 1658
1656 IWL_DEBUG_TX_REPLY(mvm, 1659 tid_data->next_reclaimed = index;
1657 "BA_NOTIFICATION Received from %pM, sta_id = %d\n",
1658 (u8 *)&ba_notif->sta_addr_lo32,
1659 ba_notif->sta_id);
1660 IWL_DEBUG_TX_REPLY(mvm,
1661 "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = %d, scd_ssn = %d sent:%d, acked:%d\n",
1662 ba_notif->tid, le16_to_cpu(ba_notif->seq_ctl),
1663 (unsigned long long)le64_to_cpu(ba_notif->bitmap),
1664 scd_flow, ba_resp_scd_ssn, ba_notif->txed,
1665 ba_notif->txed_2_done);
1666
1667 IWL_DEBUG_TX_REPLY(mvm, "reduced txp from ba notif %d\n",
1668 ba_notif->reduced_txp);
1669 tid_data->next_reclaimed = ba_resp_scd_ssn;
1670 1660
1671 iwl_mvm_check_ratid_empty(mvm, sta, tid); 1661 iwl_mvm_check_ratid_empty(mvm, sta, tid);
1672 1662
1673 freed = 0; 1663 freed = 0;
1664 ba_info->status.status_driver_data[1] = (void *)(uintptr_t)rate;
1674 1665
1675 skb_queue_walk(&reclaimed_skbs, skb) { 1666 skb_queue_walk(&reclaimed_skbs, skb) {
1676 struct ieee80211_hdr *hdr = (void *)skb->data; 1667 struct ieee80211_hdr *hdr = (void *)skb->data;
@@ -1692,8 +1683,12 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1692 1683
1693 /* this is the first skb we deliver in this batch */ 1684 /* this is the first skb we deliver in this batch */
1694 /* put the rate scaling data there */ 1685 /* put the rate scaling data there */
1695 if (freed == 1) 1686 if (freed == 1) {
1696 iwl_mvm_tx_info_from_ba_notif(info, ba_notif, tid_data); 1687 info->flags |= IEEE80211_TX_STAT_AMPDU;
1688 memcpy(&info->status, &ba_info->status,
1689 sizeof(ba_info->status));
1690 iwl_mvm_hwrate_to_tx_status(rate, info);
1691 }
1697 } 1692 }
1698 1693
1699 spin_unlock_bh(&mvmsta->lock); 1694 spin_unlock_bh(&mvmsta->lock);
@@ -1703,7 +1698,6 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1703 * Still it's important to update RS about sent vs. acked. 1698 * Still it's important to update RS about sent vs. acked.
1704 */ 1699 */
1705 if (skb_queue_empty(&reclaimed_skbs)) { 1700 if (skb_queue_empty(&reclaimed_skbs)) {
1706 struct ieee80211_tx_info ba_info = {};
1707 struct ieee80211_chanctx_conf *chanctx_conf = NULL; 1701 struct ieee80211_chanctx_conf *chanctx_conf = NULL;
1708 1702
1709 if (mvmsta->vif) 1703 if (mvmsta->vif)
@@ -1713,11 +1707,11 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1713 if (WARN_ON_ONCE(!chanctx_conf)) 1707 if (WARN_ON_ONCE(!chanctx_conf))
1714 goto out; 1708 goto out;
1715 1709
1716 ba_info.band = chanctx_conf->def.chan->band; 1710 ba_info->band = chanctx_conf->def.chan->band;
1717 iwl_mvm_tx_info_from_ba_notif(&ba_info, ba_notif, tid_data); 1711 iwl_mvm_hwrate_to_tx_status(rate, ba_info);
1718 1712
1719 IWL_DEBUG_TX_REPLY(mvm, "No reclaim. Update rs directly\n"); 1713 IWL_DEBUG_TX_REPLY(mvm, "No reclaim. Update rs directly\n");
1720 iwl_mvm_rs_tx_status(mvm, sta, tid, &ba_info, false); 1714 iwl_mvm_rs_tx_status(mvm, sta, tid, ba_info, false);
1721 } 1715 }
1722 1716
1723out: 1717out:
@@ -1729,6 +1723,92 @@ out:
1729 } 1723 }
1730} 1724}
1731 1725
1726void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1727{
1728 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1729 int sta_id, tid, txq, index;
1730 struct ieee80211_tx_info ba_info = {};
1731 struct iwl_mvm_ba_notif *ba_notif;
1732 struct iwl_mvm_tid_data *tid_data;
1733 struct iwl_mvm_sta *mvmsta;
1734
1735 if (iwl_mvm_has_new_tx_api(mvm)) {
1736 struct iwl_mvm_compressed_ba_notif *ba_res =
1737 (void *)pkt->data;
1738
1739 sta_id = ba_res->sta_id;
1740 ba_info.status.ampdu_ack_len = (u8)le16_to_cpu(ba_res->done);
1741 ba_info.status.ampdu_len = (u8)le16_to_cpu(ba_res->txed);
1742 ba_info.status.tx_time =
1743 (u16)le32_to_cpu(ba_res->wireless_time);
1744 ba_info.status.status_driver_data[0] =
1745 (void *)(uintptr_t)ba_res->reduced_txp;
1746
1747 /*
1748 * TODO:
1749 * When supporting multi TID aggregations - we need to move
1750 * next_reclaimed to be per TXQ and not per TID or handle it
1751 * in a different way.
1752 * This will go together with SN and AddBA offload and cannot
1753 * be handled properly for now.
1754 */
1755 WARN_ON(le16_to_cpu(ba_res->tfd_cnt) != 1);
1756 iwl_mvm_tx_reclaim(mvm, sta_id, ba_res->ra_tid[0].tid,
1757 (int)ba_res->tfd[0].q_num,
1758 le16_to_cpu(ba_res->tfd[0].tfd_index),
1759 &ba_info, le32_to_cpu(ba_res->tx_rate));
1760
1761 IWL_DEBUG_TX_REPLY(mvm,
1762 "BA_NOTIFICATION Received from sta_id = %d, flags %x, sent:%d, acked:%d\n",
1763 sta_id, le32_to_cpu(ba_res->flags),
1764 le16_to_cpu(ba_res->txed),
1765 le16_to_cpu(ba_res->done));
1766 return;
1767 }
1768
1769 ba_notif = (void *)pkt->data;
1770 sta_id = ba_notif->sta_id;
1771 tid = ba_notif->tid;
1772 /* "flow" corresponds to Tx queue */
1773 txq = le16_to_cpu(ba_notif->scd_flow);
1774 /* "ssn" is start of block-ack Tx window, corresponds to index
1775 * (in Tx queue's circular buffer) of first TFD/frame in window */
1776 index = le16_to_cpu(ba_notif->scd_ssn);
1777
1778 rcu_read_lock();
1779 mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, sta_id);
1780 if (WARN_ON_ONCE(!mvmsta)) {
1781 rcu_read_unlock();
1782 return;
1783 }
1784
1785 tid_data = &mvmsta->tid_data[tid];
1786
1787 ba_info.status.ampdu_ack_len = ba_notif->txed_2_done;
1788 ba_info.status.ampdu_len = ba_notif->txed;
1789 ba_info.status.tx_time = tid_data->tx_time;
1790 ba_info.status.status_driver_data[0] =
1791 (void *)(uintptr_t)ba_notif->reduced_txp;
1792
1793 rcu_read_unlock();
1794
1795 iwl_mvm_tx_reclaim(mvm, sta_id, tid, txq, index, &ba_info,
1796 tid_data->rate_n_flags);
1797
1798 IWL_DEBUG_TX_REPLY(mvm,
1799 "BA_NOTIFICATION Received from %pM, sta_id = %d\n",
1800 (u8 *)&ba_notif->sta_addr_lo32, ba_notif->sta_id);
1801
1802 IWL_DEBUG_TX_REPLY(mvm,
1803 "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = %d, scd_ssn = %d sent:%d, acked:%d\n",
1804 ba_notif->tid, le16_to_cpu(ba_notif->seq_ctl),
1805 le64_to_cpu(ba_notif->bitmap), txq, index,
1806 ba_notif->txed, ba_notif->txed_2_done);
1807
1808 IWL_DEBUG_TX_REPLY(mvm, "reduced txp from ba notif %d\n",
1809 ba_notif->reduced_txp);
1810}
1811
1732/* 1812/*
1733 * Note that there are transports that buffer frames before they reach 1813 * Note that there are transports that buffer frames before they reach
1734 * the firmware. This means that after flush_tx_path is called, the 1814 * the firmware. This means that after flush_tx_path is called, the
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index 7c138fedcb19..d04babd99b53 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -512,7 +512,7 @@ void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
512 base = mvm->fw->inst_errlog_ptr; 512 base = mvm->fw->inst_errlog_ptr;
513 } 513 }
514 514
515 if (base < 0x800000) { 515 if (base < 0x400000) {
516 IWL_ERR(mvm, 516 IWL_ERR(mvm,
517 "Not valid error log pointer 0x%08X for %s uCode\n", 517 "Not valid error log pointer 0x%08X for %s uCode\n",
518 base, 518 base,
@@ -1225,6 +1225,28 @@ void iwl_mvm_inactivity_check(struct iwl_mvm *mvm)
1225 rcu_read_unlock(); 1225 rcu_read_unlock();
1226} 1226}
1227 1227
1228void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime)
1229{
1230 bool ps_disabled;
1231
1232 lockdep_assert_held(&mvm->mutex);
1233
1234 /* Disable power save when reading GP2 */
1235 ps_disabled = mvm->ps_disabled;
1236 if (!ps_disabled) {
1237 mvm->ps_disabled = true;
1238 iwl_mvm_power_update_device(mvm);
1239 }
1240
1241 *gp2 = iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG);
1242 *boottime = ktime_get_boot_ns();
1243
1244 if (!ps_disabled) {
1245 mvm->ps_disabled = ps_disabled;
1246 iwl_mvm_power_update_device(mvm);
1247 }
1248}
1249
1228int iwl_mvm_send_lqm_cmd(struct ieee80211_vif *vif, 1250int iwl_mvm_send_lqm_cmd(struct ieee80211_vif *vif,
1229 enum iwl_lqm_cmd_operatrions operation, 1251 enum iwl_lqm_cmd_operatrions operation,
1230 u32 duration, u32 timeout) 1252 u32 duration, u32 timeout)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index c6e24fb286be..001be406a3d3 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -487,6 +487,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
487 {IWL_PCI_DEVICE(0x24FD, 0x1130, iwl8265_2ac_cfg)}, 487 {IWL_PCI_DEVICE(0x24FD, 0x1130, iwl8265_2ac_cfg)},
488 {IWL_PCI_DEVICE(0x24FD, 0x0130, iwl8265_2ac_cfg)}, 488 {IWL_PCI_DEVICE(0x24FD, 0x0130, iwl8265_2ac_cfg)},
489 {IWL_PCI_DEVICE(0x24FD, 0x1010, iwl8265_2ac_cfg)}, 489 {IWL_PCI_DEVICE(0x24FD, 0x1010, iwl8265_2ac_cfg)},
490 {IWL_PCI_DEVICE(0x24FD, 0x10D0, iwl8265_2ac_cfg)},
490 {IWL_PCI_DEVICE(0x24FD, 0x0050, iwl8265_2ac_cfg)}, 491 {IWL_PCI_DEVICE(0x24FD, 0x0050, iwl8265_2ac_cfg)},
491 {IWL_PCI_DEVICE(0x24FD, 0x0150, iwl8265_2ac_cfg)}, 492 {IWL_PCI_DEVICE(0x24FD, 0x0150, iwl8265_2ac_cfg)},
492 {IWL_PCI_DEVICE(0x24FD, 0x9010, iwl8265_2ac_cfg)}, 493 {IWL_PCI_DEVICE(0x24FD, 0x9010, iwl8265_2ac_cfg)},
@@ -500,6 +501,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
500 {IWL_PCI_DEVICE(0x24FD, 0x0930, iwl8265_2ac_cfg)}, 501 {IWL_PCI_DEVICE(0x24FD, 0x0930, iwl8265_2ac_cfg)},
501 {IWL_PCI_DEVICE(0x24FD, 0x0950, iwl8265_2ac_cfg)}, 502 {IWL_PCI_DEVICE(0x24FD, 0x0950, iwl8265_2ac_cfg)},
502 {IWL_PCI_DEVICE(0x24FD, 0x0850, iwl8265_2ac_cfg)}, 503 {IWL_PCI_DEVICE(0x24FD, 0x0850, iwl8265_2ac_cfg)},
504 {IWL_PCI_DEVICE(0x24FD, 0x0012, iwl8275_2ac_cfg)},
503 505
504/* 9000 Series */ 506/* 9000 Series */
505 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, 507 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
@@ -523,6 +525,12 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
523 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)}, 525 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)},
524 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)}, 526 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)},
525 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)}, 527 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)},
528 {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)},
529 {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)},
530 {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)},
531 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)},
532 {IWL_PCI_DEVICE(0x2526, 0x1030, iwl9560_2ac_cfg)},
533 {IWL_PCI_DEVICE(0xA370, 0x1030, iwl9560_2ac_cfg)},
526 534
527/* a000 Series */ 535/* a000 Series */
528 {IWL_PCI_DEVICE(0x2720, 0x0A10, iwla000_2ac_cfg)}, 536 {IWL_PCI_DEVICE(0x2720, 0x0A10, iwla000_2ac_cfg)},
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 11e347dd44c7..cac6d99012b3 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -37,6 +37,7 @@
37#include <linux/wait.h> 37#include <linux/wait.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/timer.h> 39#include <linux/timer.h>
40#include <linux/cpu.h>
40 41
41#include "iwl-fh.h" 42#include "iwl-fh.h"
42#include "iwl-csr.h" 43#include "iwl-csr.h"
@@ -49,7 +50,7 @@
49 * be needed for potential data in the SKB's head. The remaining ones can 50 * be needed for potential data in the SKB's head. The remaining ones can
50 * be used for frags. 51 * be used for frags.
51 */ 52 */
52#define IWL_PCIE_MAX_FRAGS (IWL_NUM_OF_TBS - 3) 53#define IWL_PCIE_MAX_FRAGS(x) (x->max_tbs - 3)
53 54
54/* 55/*
55 * RX related structures and functions 56 * RX related structures and functions
@@ -192,41 +193,9 @@ struct iwl_cmd_meta {
192 /* only for SYNC commands, iff the reply skb is wanted */ 193 /* only for SYNC commands, iff the reply skb is wanted */
193 struct iwl_host_cmd *source; 194 struct iwl_host_cmd *source;
194 u32 flags; 195 u32 flags;
196 u32 tbs;
195}; 197};
196 198
197/*
198 * Generic queue structure
199 *
200 * Contains common data for Rx and Tx queues.
201 *
202 * Note the difference between TFD_QUEUE_SIZE_MAX and n_window: the hardware
203 * always assumes 256 descriptors, so TFD_QUEUE_SIZE_MAX is always 256 (unless
204 * there might be HW changes in the future). For the normal TX
205 * queues, n_window, which is the size of the software queue data
206 * is also 256; however, for the command queue, n_window is only
207 * 32 since we don't need so many commands pending. Since the HW
208 * still uses 256 BDs for DMA though, TFD_QUEUE_SIZE_MAX stays 256. As a result,
209 * the software buffers (in the variables @meta, @txb in struct
210 * iwl_txq) only have 32 entries, while the HW buffers (@tfds in
211 * the same struct) have 256.
212 * This means that we end up with the following:
213 * HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
214 * SW entries: | 0 | ... | 31 |
215 * where N is a number between 0 and 7. This means that the SW
216 * data is a window overlayed over the HW queue.
217 */
218struct iwl_queue {
219 int write_ptr; /* 1-st empty entry (index) host_w*/
220 int read_ptr; /* last used entry (index) host_r*/
221 /* use for monitoring and recovering the stuck queue */
222 dma_addr_t dma_addr; /* physical addr for BD's */
223 int n_window; /* safe queue window */
224 u32 id;
225 int low_mark; /* low watermark, resume queue if free
226 * space more than this */
227 int high_mark; /* high watermark, stop queue if free
228 * space less than this */
229};
230 199
231#define TFD_TX_CMD_SLOTS 256 200#define TFD_TX_CMD_SLOTS 256
232#define TFD_CMD_SLOTS 32 201#define TFD_CMD_SLOTS 32
@@ -273,13 +242,32 @@ struct iwl_pcie_first_tb_buf {
273 * @wd_timeout: queue watchdog timeout (jiffies) - per queue 242 * @wd_timeout: queue watchdog timeout (jiffies) - per queue
274 * @frozen: tx stuck queue timer is frozen 243 * @frozen: tx stuck queue timer is frozen
275 * @frozen_expiry_remainder: remember how long until the timer fires 244 * @frozen_expiry_remainder: remember how long until the timer fires
245 * @write_ptr: 1-st empty entry (index) host_w
246 * @read_ptr: last used entry (index) host_r
247 * @dma_addr: physical addr for BD's
248 * @n_window: safe queue window
249 * @id: queue id
250 * @low_mark: low watermark, resume queue if free space more than this
251 * @high_mark: high watermark, stop queue if free space less than this
276 * 252 *
277 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame 253 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
278 * descriptors) and required locking structures. 254 * descriptors) and required locking structures.
255 *
256 * Note the difference between TFD_QUEUE_SIZE_MAX and n_window: the hardware
257 * always assumes 256 descriptors, so TFD_QUEUE_SIZE_MAX is always 256 (unless
258 * there might be HW changes in the future). For the normal TX
259 * queues, n_window, which is the size of the software queue data
260 * is also 256; however, for the command queue, n_window is only
261 * 32 since we don't need so many commands pending. Since the HW
262 * still uses 256 BDs for DMA though, TFD_QUEUE_SIZE_MAX stays 256.
263 * This means that we end up with the following:
264 * HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
265 * SW entries: | 0 | ... | 31 |
266 * where N is a number between 0 and 7. This means that the SW
267 * data is a window overlayed over the HW queue.
279 */ 268 */
280struct iwl_txq { 269struct iwl_txq {
281 struct iwl_queue q; 270 void *tfds;
282 struct iwl_tfd *tfds;
283 struct iwl_pcie_first_tb_buf *first_tb_bufs; 271 struct iwl_pcie_first_tb_buf *first_tb_bufs;
284 dma_addr_t first_tb_dma; 272 dma_addr_t first_tb_dma;
285 struct iwl_pcie_txq_entry *entries; 273 struct iwl_pcie_txq_entry *entries;
@@ -294,6 +282,14 @@ struct iwl_txq {
294 bool block; 282 bool block;
295 unsigned long wd_timeout; 283 unsigned long wd_timeout;
296 struct sk_buff_head overflow_q; 284 struct sk_buff_head overflow_q;
285
286 int write_ptr;
287 int read_ptr;
288 dma_addr_t dma_addr;
289 int n_window;
290 u32 id;
291 int low_mark;
292 int high_mark;
297}; 293};
298 294
299static inline dma_addr_t 295static inline dma_addr_t
@@ -309,6 +305,16 @@ struct iwl_tso_hdr_page {
309}; 305};
310 306
311/** 307/**
308 * enum iwl_shared_irq_flags - level of sharing for irq
309 * @IWL_SHARED_IRQ_NON_RX: interrupt vector serves non rx causes.
310 * @IWL_SHARED_IRQ_FIRST_RSS: interrupt vector serves first RSS queue.
311 */
312enum iwl_shared_irq_flags {
313 IWL_SHARED_IRQ_NON_RX = BIT(0),
314 IWL_SHARED_IRQ_FIRST_RSS = BIT(1),
315};
316
317/**
312 * struct iwl_trans_pcie - PCIe transport specific data 318 * struct iwl_trans_pcie - PCIe transport specific data
313 * @rxq: all the RX queue data 319 * @rxq: all the RX queue data
314 * @rx_pool: initial pool of iwl_rx_mem_buffer for all the queues 320 * @rx_pool: initial pool of iwl_rx_mem_buffer for all the queues
@@ -326,7 +332,6 @@ struct iwl_tso_hdr_page {
326 * @rx_buf_size: Rx buffer size 332 * @rx_buf_size: Rx buffer size
327 * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes) 333 * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes)
328 * @scd_set_active: should the transport configure the SCD for HCMD queue 334 * @scd_set_active: should the transport configure the SCD for HCMD queue
329 * @wide_cmd_header: true when ucode supports wide command header format
330 * @sw_csum_tx: if true, then the transport will compute the csum of the TXed 335 * @sw_csum_tx: if true, then the transport will compute the csum of the TXed
331 * frame. 336 * frame.
332 * @rx_page_order: page order for receive buffer size 337 * @rx_page_order: page order for receive buffer size
@@ -338,8 +343,10 @@ struct iwl_tso_hdr_page {
338 * @fw_mon_size: size of the buffer for the firmware monitor 343 * @fw_mon_size: size of the buffer for the firmware monitor
339 * @msix_entries: array of MSI-X entries 344 * @msix_entries: array of MSI-X entries
340 * @msix_enabled: true if managed to enable MSI-X 345 * @msix_enabled: true if managed to enable MSI-X
341 * @allocated_vector: the number of interrupt vector allocated by the OS 346 * @shared_vec_mask: the type of causes the shared vector handles
342 * @default_irq_num: default irq for non rx interrupt 347 * (see iwl_shared_irq_flags).
348 * @alloc_vecs: the number of interrupt vectors allocated by the OS
349 * @def_irq: default irq for non rx causes
343 * @fh_init_mask: initial unmasked fh causes 350 * @fh_init_mask: initial unmasked fh causes
344 * @hw_init_mask: initial unmasked hw causes 351 * @hw_init_mask: initial unmasked hw causes
345 * @fh_mask: current unmasked fh causes 352 * @fh_mask: current unmasked fh causes
@@ -391,11 +398,12 @@ struct iwl_trans_pcie {
391 unsigned int cmd_q_wdg_timeout; 398 unsigned int cmd_q_wdg_timeout;
392 u8 n_no_reclaim_cmds; 399 u8 n_no_reclaim_cmds;
393 u8 no_reclaim_cmds[MAX_NO_RECLAIM_CMDS]; 400 u8 no_reclaim_cmds[MAX_NO_RECLAIM_CMDS];
401 u8 max_tbs;
402 u16 tfd_size;
394 403
395 enum iwl_amsdu_size rx_buf_size; 404 enum iwl_amsdu_size rx_buf_size;
396 bool bc_table_dword; 405 bool bc_table_dword;
397 bool scd_set_active; 406 bool scd_set_active;
398 bool wide_cmd_header;
399 bool sw_csum_tx; 407 bool sw_csum_tx;
400 u32 rx_page_order; 408 u32 rx_page_order;
401 409
@@ -410,12 +418,14 @@ struct iwl_trans_pcie {
410 418
411 struct msix_entry msix_entries[IWL_MAX_RX_HW_QUEUES]; 419 struct msix_entry msix_entries[IWL_MAX_RX_HW_QUEUES];
412 bool msix_enabled; 420 bool msix_enabled;
413 u32 allocated_vector; 421 u8 shared_vec_mask;
414 u32 default_irq_num; 422 u32 alloc_vecs;
423 u32 def_irq;
415 u32 fh_init_mask; 424 u32 fh_init_mask;
416 u32 hw_init_mask; 425 u32 hw_init_mask;
417 u32 fh_mask; 426 u32 fh_mask;
418 u32 hw_mask; 427 u32 hw_mask;
428 cpumask_t affinity_mask[IWL_MAX_RX_HW_QUEUES];
419}; 429};
420 430
421static inline struct iwl_trans_pcie * 431static inline struct iwl_trans_pcie *
@@ -474,6 +484,7 @@ void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int queue,
474 bool configure_scd); 484 bool configure_scd);
475void iwl_trans_pcie_txq_set_shared_mode(struct iwl_trans *trans, u32 txq_id, 485void iwl_trans_pcie_txq_set_shared_mode(struct iwl_trans *trans, u32 txq_id,
476 bool shared_mode); 486 bool shared_mode);
487dma_addr_t iwl_trans_pcie_get_txq_byte_table(struct iwl_trans *trans, int txq);
477void iwl_trans_pcie_log_scd_error(struct iwl_trans *trans, 488void iwl_trans_pcie_log_scd_error(struct iwl_trans *trans,
478 struct iwl_txq *txq); 489 struct iwl_txq *txq);
479int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, 490int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
@@ -486,11 +497,20 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
486 struct sk_buff_head *skbs); 497 struct sk_buff_head *skbs);
487void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); 498void iwl_trans_pcie_tx_reset(struct iwl_trans *trans);
488 499
489static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) 500static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_trans *trans, void *_tfd,
501 u8 idx)
490{ 502{
491 struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 503 if (trans->cfg->use_tfh) {
504 struct iwl_tfh_tfd *tfd = _tfd;
505 struct iwl_tfh_tb *tb = &tfd->tbs[idx];
506
507 return le16_to_cpu(tb->tb_len);
508 } else {
509 struct iwl_tfd *tfd = _tfd;
510 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
492 511
493 return le16_to_cpu(tb->hi_n_len) >> 4; 512 return le16_to_cpu(tb->hi_n_len) >> 4;
513 }
494} 514}
495 515
496/***************************************************** 516/*****************************************************
@@ -617,9 +637,9 @@ static inline void iwl_wake_queue(struct iwl_trans *trans,
617{ 637{
618 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 638 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
619 639
620 if (test_and_clear_bit(txq->q.id, trans_pcie->queue_stopped)) { 640 if (test_and_clear_bit(txq->id, trans_pcie->queue_stopped)) {
621 IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d\n", txq->q.id); 641 IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d\n", txq->id);
622 iwl_op_mode_queue_not_full(trans->op_mode, txq->q.id); 642 iwl_op_mode_queue_not_full(trans->op_mode, txq->id);
623 } 643 }
624} 644}
625 645
@@ -628,22 +648,22 @@ static inline void iwl_stop_queue(struct iwl_trans *trans,
628{ 648{
629 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 649 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
630 650
631 if (!test_and_set_bit(txq->q.id, trans_pcie->queue_stopped)) { 651 if (!test_and_set_bit(txq->id, trans_pcie->queue_stopped)) {
632 iwl_op_mode_queue_full(trans->op_mode, txq->q.id); 652 iwl_op_mode_queue_full(trans->op_mode, txq->id);
633 IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d\n", txq->q.id); 653 IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d\n", txq->id);
634 } else 654 } else
635 IWL_DEBUG_TX_QUEUES(trans, "hwq %d already stopped\n", 655 IWL_DEBUG_TX_QUEUES(trans, "hwq %d already stopped\n",
636 txq->q.id); 656 txq->id);
637} 657}
638 658
639static inline bool iwl_queue_used(const struct iwl_queue *q, int i) 659static inline bool iwl_queue_used(const struct iwl_txq *q, int i)
640{ 660{
641 return q->write_ptr >= q->read_ptr ? 661 return q->write_ptr >= q->read_ptr ?
642 (i >= q->read_ptr && i < q->write_ptr) : 662 (i >= q->read_ptr && i < q->write_ptr) :
643 !(i < q->read_ptr && i >= q->write_ptr); 663 !(i < q->read_ptr && i >= q->write_ptr);
644} 664}
645 665
646static inline u8 get_cmd_index(struct iwl_queue *q, u32 index) 666static inline u8 get_cmd_index(struct iwl_txq *q, u32 index)
647{ 667{
648 return index & (q->n_window - 1); 668 return index & (q->n_window - 1);
649} 669}
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 5c36e6d00622..6fe5546dc773 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -487,15 +487,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
487 487
488 while (pending) { 488 while (pending) {
489 int i; 489 int i;
490 struct list_head local_allocated; 490 LIST_HEAD(local_allocated);
491 gfp_t gfp_mask = GFP_KERNEL; 491 gfp_t gfp_mask = GFP_KERNEL;
492 492
493 /* Do not post a warning if there are only a few requests */ 493 /* Do not post a warning if there are only a few requests */
494 if (pending < RX_PENDING_WATERMARK) 494 if (pending < RX_PENDING_WATERMARK)
495 gfp_mask |= __GFP_NOWARN; 495 gfp_mask |= __GFP_NOWARN;
496 496
497 INIT_LIST_HEAD(&local_allocated);
498
499 for (i = 0; i < RX_CLAIM_REQ_ALLOC;) { 497 for (i = 0; i < RX_CLAIM_REQ_ALLOC;) {
500 struct iwl_rx_mem_buffer *rxb; 498 struct iwl_rx_mem_buffer *rxb;
501 struct page *page; 499 struct page *page;
@@ -1108,13 +1106,14 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
1108 FH_RSCSR_RXQ_POS != rxq->id); 1106 FH_RSCSR_RXQ_POS != rxq->id);
1109 1107
1110 IWL_DEBUG_RX(trans, 1108 IWL_DEBUG_RX(trans,
1111 "cmd at offset %d: %s (0x%.2x, seq 0x%x)\n", 1109 "cmd at offset %d: %s (%.2x.%2x, seq 0x%x)\n",
1112 rxcb._offset, 1110 rxcb._offset,
1113 iwl_get_cmd_string(trans, 1111 iwl_get_cmd_string(trans,
1114 iwl_cmd_id(pkt->hdr.cmd, 1112 iwl_cmd_id(pkt->hdr.cmd,
1115 pkt->hdr.group_id, 1113 pkt->hdr.group_id,
1116 0)), 1114 0)),
1117 pkt->hdr.cmd, le16_to_cpu(pkt->hdr.sequence)); 1115 pkt->hdr.group_id, pkt->hdr.cmd,
1116 le16_to_cpu(pkt->hdr.sequence));
1118 1117
1119 len = iwl_rx_packet_len(pkt); 1118 len = iwl_rx_packet_len(pkt);
1120 len += sizeof(u32); /* account for status word */ 1119 len += sizeof(u32); /* account for status word */
@@ -1142,7 +1141,7 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
1142 1141
1143 sequence = le16_to_cpu(pkt->hdr.sequence); 1142 sequence = le16_to_cpu(pkt->hdr.sequence);
1144 index = SEQ_TO_INDEX(sequence); 1143 index = SEQ_TO_INDEX(sequence);
1145 cmd_index = get_cmd_index(&txq->q, index); 1144 cmd_index = get_cmd_index(txq, index);
1146 1145
1147 if (rxq->id == 0) 1146 if (rxq->id == 0)
1148 iwl_op_mode_rx(trans->op_mode, &rxq->napi, 1147 iwl_op_mode_rx(trans->op_mode, &rxq->napi,
@@ -1885,6 +1884,20 @@ irqreturn_t iwl_pcie_irq_msix_handler(int irq, void *dev_id)
1885 inta_fh, 1884 inta_fh,
1886 iwl_read32(trans, CSR_MSIX_FH_INT_MASK_AD)); 1885 iwl_read32(trans, CSR_MSIX_FH_INT_MASK_AD));
1887 1886
1887 if ((trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_NON_RX) &&
1888 inta_fh & MSIX_FH_INT_CAUSES_Q0) {
1889 local_bh_disable();
1890 iwl_pcie_rx_handle(trans, 0);
1891 local_bh_enable();
1892 }
1893
1894 if ((trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS) &&
1895 inta_fh & MSIX_FH_INT_CAUSES_Q1) {
1896 local_bh_disable();
1897 iwl_pcie_rx_handle(trans, 1);
1898 local_bh_enable();
1899 }
1900
1888 /* This "Tx" DMA channel is used only for loading uCode */ 1901 /* This "Tx" DMA channel is used only for loading uCode */
1889 if (inta_fh & MSIX_FH_INT_CAUSES_D2S_CH0_NUM) { 1902 if (inta_fh & MSIX_FH_INT_CAUSES_D2S_CH0_NUM) {
1890 IWL_DEBUG_ISR(trans, "uCode load interrupt\n"); 1903 IWL_DEBUG_ISR(trans, "uCode load interrupt\n");
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 2f46eedd7c4d..ae95533e587d 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1170,7 +1170,7 @@ static void iwl_pcie_synchronize_irqs(struct iwl_trans *trans)
1170 if (trans_pcie->msix_enabled) { 1170 if (trans_pcie->msix_enabled) {
1171 int i; 1171 int i;
1172 1172
1173 for (i = 0; i < trans_pcie->allocated_vector; i++) 1173 for (i = 0; i < trans_pcie->alloc_vecs; i++)
1174 synchronize_irq(trans_pcie->msix_entries[i].vector); 1174 synchronize_irq(trans_pcie->msix_entries[i].vector);
1175 } else { 1175 } else {
1176 synchronize_irq(trans_pcie->pci_dev->irq); 1176 synchronize_irq(trans_pcie->pci_dev->irq);
@@ -1429,13 +1429,58 @@ static struct iwl_causes_list causes_list[] = {
1429 {MSIX_HW_INT_CAUSES_REG_HAP, CSR_MSIX_HW_INT_MASK_AD, 0x2E}, 1429 {MSIX_HW_INT_CAUSES_REG_HAP, CSR_MSIX_HW_INT_MASK_AD, 0x2E},
1430}; 1430};
1431 1431
1432static void iwl_pcie_map_non_rx_causes(struct iwl_trans *trans)
1433{
1434 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1435 int val = trans_pcie->def_irq | MSIX_NON_AUTO_CLEAR_CAUSE;
1436 int i;
1437
1438 /*
1439 * Access all non RX causes and map them to the default irq.
1440 * In case we are missing at least one interrupt vector,
1441 * the first interrupt vector will serve non-RX and FBQ causes.
1442 */
1443 for (i = 0; i < ARRAY_SIZE(causes_list); i++) {
1444 iwl_write8(trans, CSR_MSIX_IVAR(causes_list[i].addr), val);
1445 iwl_clear_bit(trans, causes_list[i].mask_reg,
1446 causes_list[i].cause_num);
1447 }
1448}
1449
1450static void iwl_pcie_map_rx_causes(struct iwl_trans *trans)
1451{
1452 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1453 u32 offset =
1454 trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS ? 1 : 0;
1455 u32 val, idx;
1456
1457 /*
1458 * The first RX queue - fallback queue, which is designated for
1459 * management frame, command responses etc, is always mapped to the
1460 * first interrupt vector. The other RX queues are mapped to
1461 * the other (N - 2) interrupt vectors.
1462 */
1463 val = BIT(MSIX_FH_INT_CAUSES_Q(0));
1464 for (idx = 1; idx < trans->num_rx_queues; idx++) {
1465 iwl_write8(trans, CSR_MSIX_RX_IVAR(idx),
1466 MSIX_FH_INT_CAUSES_Q(idx - offset));
1467 val |= BIT(MSIX_FH_INT_CAUSES_Q(idx));
1468 }
1469 iwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD, ~val);
1470
1471 val = MSIX_FH_INT_CAUSES_Q(0);
1472 if (trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_NON_RX)
1473 val |= MSIX_NON_AUTO_CLEAR_CAUSE;
1474 iwl_write8(trans, CSR_MSIX_RX_IVAR(0), val);
1475
1476 if (trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS)
1477 iwl_write8(trans, CSR_MSIX_RX_IVAR(1), val);
1478}
1479
1432static void iwl_pcie_init_msix(struct iwl_trans_pcie *trans_pcie) 1480static void iwl_pcie_init_msix(struct iwl_trans_pcie *trans_pcie)
1433{ 1481{
1434 u32 val, max_rx_vector, i;
1435 struct iwl_trans *trans = trans_pcie->trans; 1482 struct iwl_trans *trans = trans_pcie->trans;
1436 1483
1437 max_rx_vector = trans_pcie->allocated_vector - 1;
1438
1439 if (!trans_pcie->msix_enabled) { 1484 if (!trans_pcie->msix_enabled) {
1440 if (trans->cfg->mq_rx_supported) 1485 if (trans->cfg->mq_rx_supported)
1441 iwl_write_prph(trans, UREG_CHICK, 1486 iwl_write_prph(trans, UREG_CHICK,
@@ -1446,25 +1491,16 @@ static void iwl_pcie_init_msix(struct iwl_trans_pcie *trans_pcie)
1446 iwl_write_prph(trans, UREG_CHICK, UREG_CHICK_MSIX_ENABLE); 1491 iwl_write_prph(trans, UREG_CHICK, UREG_CHICK_MSIX_ENABLE);
1447 1492
1448 /* 1493 /*
1449 * Each cause from the list above and the RX causes is represented as 1494 * Each cause from the causes list above and the RX causes is
1450 * a byte in the IVAR table. We access the first (N - 1) bytes and map 1495 * represented as a byte in the IVAR table. The first nibble
1451 * them to the (N - 1) vectors so these vectors will be used as rx 1496 * represents the bound interrupt vector of the cause, the second
1452 * vectors. Then access all non rx causes and map them to the 1497 * represents no auto clear for this cause. This will be set if its
1453 * default queue (N'th queue). 1498 * interrupt vector is bound to serve other causes.
1454 */ 1499 */
1455 for (i = 0; i < max_rx_vector; i++) { 1500 iwl_pcie_map_rx_causes(trans);
1456 iwl_write8(trans, CSR_MSIX_RX_IVAR(i), MSIX_FH_INT_CAUSES_Q(i)); 1501
1457 iwl_clear_bit(trans, CSR_MSIX_FH_INT_MASK_AD, 1502 iwl_pcie_map_non_rx_causes(trans);
1458 BIT(MSIX_FH_INT_CAUSES_Q(i)));
1459 }
1460 1503
1461 for (i = 0; i < ARRAY_SIZE(causes_list); i++) {
1462 val = trans_pcie->default_irq_num |
1463 MSIX_NON_AUTO_CLEAR_CAUSE;
1464 iwl_write8(trans, CSR_MSIX_IVAR(causes_list[i].addr), val);
1465 iwl_clear_bit(trans, causes_list[i].mask_reg,
1466 causes_list[i].cause_num);
1467 }
1468 trans_pcie->fh_init_mask = 1504 trans_pcie->fh_init_mask =
1469 ~iwl_read32(trans, CSR_MSIX_FH_INT_MASK_AD); 1505 ~iwl_read32(trans, CSR_MSIX_FH_INT_MASK_AD);
1470 trans_pcie->fh_mask = trans_pcie->fh_init_mask; 1506 trans_pcie->fh_mask = trans_pcie->fh_init_mask;
@@ -1477,40 +1513,55 @@ static void iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
1477 struct iwl_trans *trans) 1513 struct iwl_trans *trans)
1478{ 1514{
1479 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1515 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1516 int max_irqs, num_irqs, i, ret, nr_online_cpus;
1480 u16 pci_cmd; 1517 u16 pci_cmd;
1481 int max_vector; 1518
1482 int ret, i; 1519 if (!trans->cfg->mq_rx_supported)
1483 1520 goto enable_msi;
1484 if (trans->cfg->mq_rx_supported) { 1521
1485 max_vector = min_t(u32, (num_possible_cpus() + 2), 1522 nr_online_cpus = num_online_cpus();
1486 IWL_MAX_RX_HW_QUEUES); 1523 max_irqs = min_t(u32, nr_online_cpus + 2, IWL_MAX_RX_HW_QUEUES);
1487 for (i = 0; i < max_vector; i++) 1524 for (i = 0; i < max_irqs; i++)
1488 trans_pcie->msix_entries[i].entry = i; 1525 trans_pcie->msix_entries[i].entry = i;
1489 1526
1490 ret = pci_enable_msix_range(pdev, trans_pcie->msix_entries, 1527 num_irqs = pci_enable_msix_range(pdev, trans_pcie->msix_entries,
1491 MSIX_MIN_INTERRUPT_VECTORS, 1528 MSIX_MIN_INTERRUPT_VECTORS,
1492 max_vector); 1529 max_irqs);
1493 if (ret > 1) { 1530 if (num_irqs < 0) {
1494 IWL_DEBUG_INFO(trans,
1495 "Enable MSI-X allocate %d interrupt vector\n",
1496 ret);
1497 trans_pcie->allocated_vector = ret;
1498 trans_pcie->default_irq_num =
1499 trans_pcie->allocated_vector - 1;
1500 trans_pcie->trans->num_rx_queues =
1501 trans_pcie->allocated_vector - 1;
1502 trans_pcie->msix_enabled = true;
1503
1504 return;
1505 }
1506 IWL_DEBUG_INFO(trans, 1531 IWL_DEBUG_INFO(trans,
1507 "ret = %d %s move to msi mode\n", ret, 1532 "Failed to enable msi-x mode (ret %d). Moving to msi mode.\n",
1508 (ret == 1) ? 1533 num_irqs);
1509 "can't allocate more than 1 interrupt vector" : 1534 goto enable_msi;
1510 "failed to enable msi-x mode"); 1535 }
1511 pci_disable_msix(pdev); 1536 trans_pcie->def_irq = (num_irqs == max_irqs) ? num_irqs - 1 : 0;
1537
1538 IWL_DEBUG_INFO(trans,
1539 "MSI-X enabled. %d interrupt vectors were allocated\n",
1540 num_irqs);
1541
1542 /*
1543 * In case the OS provides fewer interrupts than requested, different
1544 * causes will share the same interrupt vector as follows:
1545 * One interrupt less: non rx causes shared with FBQ.
1546 * Two interrupts less: non rx causes shared with FBQ and RSS.
1547 * More than two interrupts: we will use fewer RSS queues.
1548 */
1549 if (num_irqs <= nr_online_cpus) {
1550 trans_pcie->trans->num_rx_queues = num_irqs + 1;
1551 trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX |
1552 IWL_SHARED_IRQ_FIRST_RSS;
1553 } else if (num_irqs == nr_online_cpus + 1) {
1554 trans_pcie->trans->num_rx_queues = num_irqs;
1555 trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX;
1556 } else {
1557 trans_pcie->trans->num_rx_queues = num_irqs - 1;
1512 } 1558 }
1513 1559
1560 trans_pcie->alloc_vecs = num_irqs;
1561 trans_pcie->msix_enabled = true;
1562 return;
1563
1564enable_msi:
1514 ret = pci_enable_msi(pdev); 1565 ret = pci_enable_msi(pdev);
1515 if (ret) { 1566 if (ret) {
1516 dev_err(&pdev->dev, "pci_enable_msi failed - %d\n", ret); 1567 dev_err(&pdev->dev, "pci_enable_msi failed - %d\n", ret);
@@ -1523,36 +1574,57 @@ static void iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
1523 } 1574 }
1524} 1575}
1525 1576
1577static void iwl_pcie_irq_set_affinity(struct iwl_trans *trans)
1578{
1579 int iter_rx_q, i, ret, cpu, offset;
1580 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1581
1582 i = trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS ? 0 : 1;
1583 iter_rx_q = trans_pcie->trans->num_rx_queues - 1 + i;
1584 offset = 1 + i;
1585 for (; i < iter_rx_q ; i++) {
1586 /*
1587 * Get the cpu prior to the place to search
1588 * (i.e. return will be > i - 1).
1589 */
1590 cpu = cpumask_next(i - offset, cpu_online_mask);
1591 cpumask_set_cpu(cpu, &trans_pcie->affinity_mask[i]);
1592 ret = irq_set_affinity_hint(trans_pcie->msix_entries[i].vector,
1593 &trans_pcie->affinity_mask[i]);
1594 if (ret)
1595 IWL_ERR(trans_pcie->trans,
1596 "Failed to set affinity mask for IRQ %d\n",
1597 i);
1598 }
1599}
1600
1526static int iwl_pcie_init_msix_handler(struct pci_dev *pdev, 1601static int iwl_pcie_init_msix_handler(struct pci_dev *pdev,
1527 struct iwl_trans_pcie *trans_pcie) 1602 struct iwl_trans_pcie *trans_pcie)
1528{ 1603{
1529 int i, last_vector; 1604 int i;
1530
1531 last_vector = trans_pcie->trans->num_rx_queues;
1532 1605
1533 for (i = 0; i < trans_pcie->allocated_vector; i++) { 1606 for (i = 0; i < trans_pcie->alloc_vecs; i++) {
1534 int ret; 1607 int ret;
1535 1608 struct msix_entry *msix_entry;
1536 ret = request_threaded_irq(trans_pcie->msix_entries[i].vector, 1609
1537 iwl_pcie_msix_isr, 1610 msix_entry = &trans_pcie->msix_entries[i];
1538 (i == last_vector) ? 1611 ret = devm_request_threaded_irq(&pdev->dev,
1539 iwl_pcie_irq_msix_handler : 1612 msix_entry->vector,
1540 iwl_pcie_irq_rx_msix_handler, 1613 iwl_pcie_msix_isr,
1541 IRQF_SHARED, 1614 (i == trans_pcie->def_irq) ?
1542 DRV_NAME, 1615 iwl_pcie_irq_msix_handler :
1543 &trans_pcie->msix_entries[i]); 1616 iwl_pcie_irq_rx_msix_handler,
1617 IRQF_SHARED,
1618 DRV_NAME,
1619 msix_entry);
1544 if (ret) { 1620 if (ret) {
1545 int j;
1546
1547 IWL_ERR(trans_pcie->trans, 1621 IWL_ERR(trans_pcie->trans,
1548 "Error allocating IRQ %d\n", i); 1622 "Error allocating IRQ %d\n", i);
1549 for (j = 0; j < i; j++) 1623
1550 free_irq(trans_pcie->msix_entries[j].vector,
1551 &trans_pcie->msix_entries[j]);
1552 pci_disable_msix(pdev);
1553 return ret; 1624 return ret;
1554 } 1625 }
1555 } 1626 }
1627 iwl_pcie_irq_set_affinity(trans_pcie->trans);
1556 1628
1557 return 0; 1629 return 0;
1558} 1630}
@@ -1681,7 +1753,6 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,
1681 trans_pcie->rx_page_order = 1753 trans_pcie->rx_page_order =
1682 iwl_trans_get_rb_size_order(trans_pcie->rx_buf_size); 1754 iwl_trans_get_rb_size_order(trans_pcie->rx_buf_size);
1683 1755
1684 trans_pcie->wide_cmd_header = trans_cfg->wide_cmd_header;
1685 trans_pcie->bc_table_dword = trans_cfg->bc_table_dword; 1756 trans_pcie->bc_table_dword = trans_cfg->bc_table_dword;
1686 trans_pcie->scd_set_active = trans_cfg->scd_set_active; 1757 trans_pcie->scd_set_active = trans_cfg->scd_set_active;
1687 trans_pcie->sw_csum_tx = trans_cfg->sw_csum_tx; 1758 trans_pcie->sw_csum_tx = trans_cfg->sw_csum_tx;
@@ -1712,22 +1783,16 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
1712 iwl_pcie_rx_free(trans); 1783 iwl_pcie_rx_free(trans);
1713 1784
1714 if (trans_pcie->msix_enabled) { 1785 if (trans_pcie->msix_enabled) {
1715 for (i = 0; i < trans_pcie->allocated_vector; i++) 1786 for (i = 0; i < trans_pcie->alloc_vecs; i++) {
1716 free_irq(trans_pcie->msix_entries[i].vector, 1787 irq_set_affinity_hint(
1717 &trans_pcie->msix_entries[i]); 1788 trans_pcie->msix_entries[i].vector,
1789 NULL);
1790 }
1718 1791
1719 pci_disable_msix(trans_pcie->pci_dev);
1720 trans_pcie->msix_enabled = false; 1792 trans_pcie->msix_enabled = false;
1721 } else { 1793 } else {
1722 free_irq(trans_pcie->pci_dev->irq, trans);
1723
1724 iwl_pcie_free_ict(trans); 1794 iwl_pcie_free_ict(trans);
1725
1726 pci_disable_msi(trans_pcie->pci_dev);
1727 } 1795 }
1728 iounmap(trans_pcie->hw_base);
1729 pci_release_regions(trans_pcie->pci_dev);
1730 pci_disable_device(trans_pcie->pci_dev);
1731 1796
1732 iwl_pcie_free_fw_monitor(trans); 1797 iwl_pcie_free_fw_monitor(trans);
1733 1798
@@ -1899,7 +1964,7 @@ static void iwl_trans_pcie_freeze_txq_timer(struct iwl_trans *trans,
1899 1964
1900 txq->frozen = freeze; 1965 txq->frozen = freeze;
1901 1966
1902 if (txq->q.read_ptr == txq->q.write_ptr) 1967 if (txq->read_ptr == txq->write_ptr)
1903 goto next_queue; 1968 goto next_queue;
1904 1969
1905 if (freeze) { 1970 if (freeze) {
@@ -1947,7 +2012,7 @@ static void iwl_trans_pcie_block_txq_ptrs(struct iwl_trans *trans, bool block)
1947 txq->block--; 2012 txq->block--;
1948 if (!txq->block) { 2013 if (!txq->block) {
1949 iwl_write32(trans, HBUS_TARG_WRPTR, 2014 iwl_write32(trans, HBUS_TARG_WRPTR,
1950 txq->q.write_ptr | (i << 8)); 2015 txq->write_ptr | (i << 8));
1951 } 2016 }
1952 } else if (block) { 2017 } else if (block) {
1953 txq->block++; 2018 txq->block++;
@@ -1967,14 +2032,14 @@ void iwl_trans_pcie_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq)
1967 int cnt; 2032 int cnt;
1968 2033
1969 IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n", 2034 IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n",
1970 txq->q.read_ptr, txq->q.write_ptr); 2035 txq->read_ptr, txq->write_ptr);
1971 2036
1972 if (trans->cfg->use_tfh) 2037 if (trans->cfg->use_tfh)
1973 /* TODO: access new SCD registers and dump them */ 2038 /* TODO: access new SCD registers and dump them */
1974 return; 2039 return;
1975 2040
1976 scd_sram_addr = trans_pcie->scd_base_addr + 2041 scd_sram_addr = trans_pcie->scd_base_addr +
1977 SCD_TX_STTS_QUEUE_OFFSET(txq->q.id); 2042 SCD_TX_STTS_QUEUE_OFFSET(txq->id);
1978 iwl_trans_read_mem_bytes(trans, scd_sram_addr, buf, sizeof(buf)); 2043 iwl_trans_read_mem_bytes(trans, scd_sram_addr, buf, sizeof(buf));
1979 2044
1980 iwl_print_hex_error(trans, buf, sizeof(buf)); 2045 iwl_print_hex_error(trans, buf, sizeof(buf));
@@ -2009,7 +2074,6 @@ static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, u32 txq_bm)
2009{ 2074{
2010 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2075 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2011 struct iwl_txq *txq; 2076 struct iwl_txq *txq;
2012 struct iwl_queue *q;
2013 int cnt; 2077 int cnt;
2014 unsigned long now = jiffies; 2078 unsigned long now = jiffies;
2015 int ret = 0; 2079 int ret = 0;
@@ -2027,13 +2091,12 @@ static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, u32 txq_bm)
2027 2091
2028 IWL_DEBUG_TX_QUEUES(trans, "Emptying queue %d...\n", cnt); 2092 IWL_DEBUG_TX_QUEUES(trans, "Emptying queue %d...\n", cnt);
2029 txq = &trans_pcie->txq[cnt]; 2093 txq = &trans_pcie->txq[cnt];
2030 q = &txq->q; 2094 wr_ptr = ACCESS_ONCE(txq->write_ptr);
2031 wr_ptr = ACCESS_ONCE(q->write_ptr);
2032 2095
2033 while (q->read_ptr != ACCESS_ONCE(q->write_ptr) && 2096 while (txq->read_ptr != ACCESS_ONCE(txq->write_ptr) &&
2034 !time_after(jiffies, 2097 !time_after(jiffies,
2035 now + msecs_to_jiffies(IWL_FLUSH_WAIT_MS))) { 2098 now + msecs_to_jiffies(IWL_FLUSH_WAIT_MS))) {
2036 u8 write_ptr = ACCESS_ONCE(q->write_ptr); 2099 u8 write_ptr = ACCESS_ONCE(txq->write_ptr);
2037 2100
2038 if (WARN_ONCE(wr_ptr != write_ptr, 2101 if (WARN_ONCE(wr_ptr != write_ptr,
2039 "WR pointer moved while flushing %d -> %d\n", 2102 "WR pointer moved while flushing %d -> %d\n",
@@ -2042,7 +2105,7 @@ static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, u32 txq_bm)
2042 usleep_range(1000, 2000); 2105 usleep_range(1000, 2000);
2043 } 2106 }
2044 2107
2045 if (q->read_ptr != q->write_ptr) { 2108 if (txq->read_ptr != txq->write_ptr) {
2046 IWL_ERR(trans, 2109 IWL_ERR(trans,
2047 "fail to flush all tx fifo queues Q %d\n", cnt); 2110 "fail to flush all tx fifo queues Q %d\n", cnt);
2048 ret = -ETIMEDOUT; 2111 ret = -ETIMEDOUT;
@@ -2210,7 +2273,6 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
2210 struct iwl_trans *trans = file->private_data; 2273 struct iwl_trans *trans = file->private_data;
2211 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2274 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2212 struct iwl_txq *txq; 2275 struct iwl_txq *txq;
2213 struct iwl_queue *q;
2214 char *buf; 2276 char *buf;
2215 int pos = 0; 2277 int pos = 0;
2216 int cnt; 2278 int cnt;
@@ -2228,10 +2290,9 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
2228 2290
2229 for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) { 2291 for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) {
2230 txq = &trans_pcie->txq[cnt]; 2292 txq = &trans_pcie->txq[cnt];
2231 q = &txq->q;
2232 pos += scnprintf(buf + pos, bufsz - pos, 2293 pos += scnprintf(buf + pos, bufsz - pos,
2233 "hwq %.2d: read=%u write=%u use=%d stop=%d need_update=%d frozen=%d%s\n", 2294 "hwq %.2d: read=%u write=%u use=%d stop=%d need_update=%d frozen=%d%s\n",
2234 cnt, q->read_ptr, q->write_ptr, 2295 cnt, txq->read_ptr, txq->write_ptr,
2235 !!test_bit(cnt, trans_pcie->queue_used), 2296 !!test_bit(cnt, trans_pcie->queue_used),
2236 !!test_bit(cnt, trans_pcie->queue_stopped), 2297 !!test_bit(cnt, trans_pcie->queue_stopped),
2237 txq->need_update, txq->frozen, 2298 txq->need_update, txq->frozen,
@@ -2437,13 +2498,14 @@ err:
2437} 2498}
2438#endif /*CONFIG_IWLWIFI_DEBUGFS */ 2499#endif /*CONFIG_IWLWIFI_DEBUGFS */
2439 2500
2440static u32 iwl_trans_pcie_get_cmdlen(struct iwl_tfd *tfd) 2501static u32 iwl_trans_pcie_get_cmdlen(struct iwl_trans *trans, void *tfd)
2441{ 2502{
2503 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2442 u32 cmdlen = 0; 2504 u32 cmdlen = 0;
2443 int i; 2505 int i;
2444 2506
2445 for (i = 0; i < IWL_NUM_OF_TBS; i++) 2507 for (i = 0; i < trans_pcie->max_tbs; i++)
2446 cmdlen += iwl_pcie_tfd_tb_get_len(tfd, i); 2508 cmdlen += iwl_pcie_tfd_tb_get_len(trans, tfd, i);
2447 2509
2448 return cmdlen; 2510 return cmdlen;
2449} 2511}
@@ -2658,7 +2720,7 @@ static struct iwl_trans_dump_data
2658 2720
2659 /* host commands */ 2721 /* host commands */
2660 len += sizeof(*data) + 2722 len += sizeof(*data) +
2661 cmdq->q.n_window * (sizeof(*txcmd) + TFD_MAX_PAYLOAD_SIZE); 2723 cmdq->n_window * (sizeof(*txcmd) + TFD_MAX_PAYLOAD_SIZE);
2662 2724
2663 /* FW monitor */ 2725 /* FW monitor */
2664 if (trans_pcie->fw_mon_page) { 2726 if (trans_pcie->fw_mon_page) {
@@ -2726,12 +2788,13 @@ static struct iwl_trans_dump_data
2726 data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXCMD); 2788 data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXCMD);
2727 txcmd = (void *)data->data; 2789 txcmd = (void *)data->data;
2728 spin_lock_bh(&cmdq->lock); 2790 spin_lock_bh(&cmdq->lock);
2729 ptr = cmdq->q.write_ptr; 2791 ptr = cmdq->write_ptr;
2730 for (i = 0; i < cmdq->q.n_window; i++) { 2792 for (i = 0; i < cmdq->n_window; i++) {
2731 u8 idx = get_cmd_index(&cmdq->q, ptr); 2793 u8 idx = get_cmd_index(cmdq, ptr);
2732 u32 caplen, cmdlen; 2794 u32 caplen, cmdlen;
2733 2795
2734 cmdlen = iwl_trans_pcie_get_cmdlen(&cmdq->tfds[ptr]); 2796 cmdlen = iwl_trans_pcie_get_cmdlen(trans, cmdq->tfds +
2797 trans_pcie->tfd_size * ptr);
2735 caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen); 2798 caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen);
2736 2799
2737 if (cmdlen) { 2800 if (cmdlen) {
@@ -2801,6 +2864,8 @@ static const struct iwl_trans_ops trans_ops_pcie = {
2801 .txq_disable = iwl_trans_pcie_txq_disable, 2864 .txq_disable = iwl_trans_pcie_txq_disable,
2802 .txq_enable = iwl_trans_pcie_txq_enable, 2865 .txq_enable = iwl_trans_pcie_txq_enable,
2803 2866
2867 .get_txq_byte_table = iwl_trans_pcie_get_txq_byte_table,
2868
2804 .txq_set_shared_mode = iwl_trans_pcie_txq_set_shared_mode, 2869 .txq_set_shared_mode = iwl_trans_pcie_txq_set_shared_mode,
2805 2870
2806 .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty, 2871 .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty,
@@ -2834,13 +2899,15 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2834 struct iwl_trans *trans; 2899 struct iwl_trans *trans;
2835 int ret, addr_size; 2900 int ret, addr_size;
2836 2901
2902 ret = pcim_enable_device(pdev);
2903 if (ret)
2904 return ERR_PTR(ret);
2905
2837 trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), 2906 trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
2838 &pdev->dev, cfg, &trans_ops_pcie, 0); 2907 &pdev->dev, cfg, &trans_ops_pcie, 0);
2839 if (!trans) 2908 if (!trans)
2840 return ERR_PTR(-ENOMEM); 2909 return ERR_PTR(-ENOMEM);
2841 2910
2842 trans->max_skb_frags = IWL_PCIE_MAX_FRAGS;
2843
2844 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2911 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2845 2912
2846 trans_pcie->trans = trans; 2913 trans_pcie->trans = trans;
@@ -2854,9 +2921,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2854 goto out_no_pci; 2921 goto out_no_pci;
2855 } 2922 }
2856 2923
2857 ret = pci_enable_device(pdev);
2858 if (ret)
2859 goto out_no_pci;
2860 2924
2861 if (!cfg->base_params->pcie_l1_allowed) { 2925 if (!cfg->base_params->pcie_l1_allowed) {
2862 /* 2926 /*
@@ -2874,6 +2938,16 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2874 else 2938 else
2875 addr_size = 36; 2939 addr_size = 36;
2876 2940
2941 if (cfg->use_tfh) {
2942 trans_pcie->max_tbs = IWL_TFH_NUM_TBS;
2943 trans_pcie->tfd_size = sizeof(struct iwl_tfh_tfd);
2944
2945 } else {
2946 trans_pcie->max_tbs = IWL_NUM_OF_TBS;
2947 trans_pcie->tfd_size = sizeof(struct iwl_tfd);
2948 }
2949 trans->max_skb_frags = IWL_PCIE_MAX_FRAGS(trans_pcie);
2950
2877 pci_set_master(pdev); 2951 pci_set_master(pdev);
2878 2952
2879 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(addr_size)); 2953 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(addr_size));
@@ -2888,21 +2962,21 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2888 /* both attempts failed: */ 2962 /* both attempts failed: */
2889 if (ret) { 2963 if (ret) {
2890 dev_err(&pdev->dev, "No suitable DMA available\n"); 2964 dev_err(&pdev->dev, "No suitable DMA available\n");
2891 goto out_pci_disable_device; 2965 goto out_no_pci;
2892 } 2966 }
2893 } 2967 }
2894 2968
2895 ret = pci_request_regions(pdev, DRV_NAME); 2969 ret = pcim_iomap_regions_request_all(pdev, BIT(0), DRV_NAME);
2896 if (ret) { 2970 if (ret) {
2897 dev_err(&pdev->dev, "pci_request_regions failed\n"); 2971 dev_err(&pdev->dev, "pcim_iomap_regions_request_all failed\n");
2898 goto out_pci_disable_device; 2972 goto out_no_pci;
2899 } 2973 }
2900 2974
2901 trans_pcie->hw_base = pci_ioremap_bar(pdev, 0); 2975 trans_pcie->hw_base = pcim_iomap_table(pdev)[0];
2902 if (!trans_pcie->hw_base) { 2976 if (!trans_pcie->hw_base) {
2903 dev_err(&pdev->dev, "pci_ioremap_bar failed\n"); 2977 dev_err(&pdev->dev, "pcim_iomap_table failed\n");
2904 ret = -ENODEV; 2978 ret = -ENODEV;
2905 goto out_pci_release_regions; 2979 goto out_no_pci;
2906 } 2980 }
2907 2981
2908 /* We disable the RETRY_TIMEOUT register (0x41) to keep 2982 /* We disable the RETRY_TIMEOUT register (0x41) to keep
@@ -2929,7 +3003,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2929 ret = iwl_pcie_prepare_card_hw(trans); 3003 ret = iwl_pcie_prepare_card_hw(trans);
2930 if (ret) { 3004 if (ret) {
2931 IWL_WARN(trans, "Exit HW not ready\n"); 3005 IWL_WARN(trans, "Exit HW not ready\n");
2932 goto out_pci_disable_msi; 3006 goto out_no_pci;
2933 } 3007 }
2934 3008
2935 /* 3009 /*
@@ -2946,7 +3020,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2946 25000); 3020 25000);
2947 if (ret < 0) { 3021 if (ret < 0) {
2948 IWL_DEBUG_INFO(trans, "Failed to wake up the nic\n"); 3022 IWL_DEBUG_INFO(trans, "Failed to wake up the nic\n");
2949 goto out_pci_disable_msi; 3023 goto out_no_pci;
2950 } 3024 }
2951 3025
2952 if (iwl_trans_grab_nic_access(trans, &flags)) { 3026 if (iwl_trans_grab_nic_access(trans, &flags)) {
@@ -2978,15 +3052,16 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
2978 3052
2979 if (trans_pcie->msix_enabled) { 3053 if (trans_pcie->msix_enabled) {
2980 if (iwl_pcie_init_msix_handler(pdev, trans_pcie)) 3054 if (iwl_pcie_init_msix_handler(pdev, trans_pcie))
2981 goto out_pci_release_regions; 3055 goto out_no_pci;
2982 } else { 3056 } else {
2983 ret = iwl_pcie_alloc_ict(trans); 3057 ret = iwl_pcie_alloc_ict(trans);
2984 if (ret) 3058 if (ret)
2985 goto out_pci_disable_msi; 3059 goto out_no_pci;
2986 3060
2987 ret = request_threaded_irq(pdev->irq, iwl_pcie_isr, 3061 ret = devm_request_threaded_irq(&pdev->dev, pdev->irq,
2988 iwl_pcie_irq_handler, 3062 iwl_pcie_isr,
2989 IRQF_SHARED, DRV_NAME, trans); 3063 iwl_pcie_irq_handler,
3064 IRQF_SHARED, DRV_NAME, trans);
2990 if (ret) { 3065 if (ret) {
2991 IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq); 3066 IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq);
2992 goto out_free_ict; 3067 goto out_free_ict;
@@ -3004,12 +3079,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3004 3079
3005out_free_ict: 3080out_free_ict:
3006 iwl_pcie_free_ict(trans); 3081 iwl_pcie_free_ict(trans);
3007out_pci_disable_msi:
3008 pci_disable_msi(pdev);
3009out_pci_release_regions:
3010 pci_release_regions(pdev);
3011out_pci_disable_device:
3012 pci_disable_device(pdev);
3013out_no_pci: 3082out_no_pci:
3014 free_percpu(trans_pcie->tso_hdr_page); 3083 free_percpu(trans_pcie->tso_hdr_page);
3015 iwl_trans_free(trans); 3084 iwl_trans_free(trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 9636dc89f6bd..e9a278b60dfd 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -71,7 +71,7 @@
71 * 71 *
72 ***************************************************/ 72 ***************************************************/
73 73
74static int iwl_queue_space(const struct iwl_queue *q) 74static int iwl_queue_space(const struct iwl_txq *q)
75{ 75{
76 unsigned int max; 76 unsigned int max;
77 unsigned int used; 77 unsigned int used;
@@ -102,7 +102,7 @@ static int iwl_queue_space(const struct iwl_queue *q)
102/* 102/*
103 * iwl_queue_init - Initialize queue's high/low-water and read/write indexes 103 * iwl_queue_init - Initialize queue's high/low-water and read/write indexes
104 */ 104 */
105static int iwl_queue_init(struct iwl_queue *q, int slots_num, u32 id) 105static int iwl_queue_init(struct iwl_txq *q, int slots_num, u32 id)
106{ 106{
107 q->n_window = slots_num; 107 q->n_window = slots_num;
108 q->id = id; 108 q->id = id;
@@ -158,13 +158,13 @@ static void iwl_pcie_txq_stuck_timer(unsigned long data)
158 158
159 spin_lock(&txq->lock); 159 spin_lock(&txq->lock);
160 /* check if triggered erroneously */ 160 /* check if triggered erroneously */
161 if (txq->q.read_ptr == txq->q.write_ptr) { 161 if (txq->read_ptr == txq->write_ptr) {
162 spin_unlock(&txq->lock); 162 spin_unlock(&txq->lock);
163 return; 163 return;
164 } 164 }
165 spin_unlock(&txq->lock); 165 spin_unlock(&txq->lock);
166 166
167 IWL_ERR(trans, "Queue %d stuck for %u ms.\n", txq->q.id, 167 IWL_ERR(trans, "Queue %d stuck for %u ms.\n", txq->id,
168 jiffies_to_msecs(txq->wd_timeout)); 168 jiffies_to_msecs(txq->wd_timeout));
169 169
170 iwl_trans_pcie_log_scd_error(trans, txq); 170 iwl_trans_pcie_log_scd_error(trans, txq);
@@ -176,22 +176,21 @@ static void iwl_pcie_txq_stuck_timer(unsigned long data)
176 * iwl_pcie_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array 176 * iwl_pcie_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
177 */ 177 */
178static void iwl_pcie_txq_update_byte_cnt_tbl(struct iwl_trans *trans, 178static void iwl_pcie_txq_update_byte_cnt_tbl(struct iwl_trans *trans,
179 struct iwl_txq *txq, u16 byte_cnt) 179 struct iwl_txq *txq, u16 byte_cnt,
180 int num_tbs)
180{ 181{
181 struct iwlagn_scd_bc_tbl *scd_bc_tbl; 182 struct iwlagn_scd_bc_tbl *scd_bc_tbl;
182 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 183 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
183 int write_ptr = txq->q.write_ptr; 184 int write_ptr = txq->write_ptr;
184 int txq_id = txq->q.id; 185 int txq_id = txq->id;
185 u8 sec_ctl = 0; 186 u8 sec_ctl = 0;
186 u8 sta_id = 0;
187 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 187 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
188 __le16 bc_ent; 188 __le16 bc_ent;
189 struct iwl_tx_cmd *tx_cmd = 189 struct iwl_tx_cmd *tx_cmd =
190 (void *) txq->entries[txq->q.write_ptr].cmd->payload; 190 (void *)txq->entries[txq->write_ptr].cmd->payload;
191 191
192 scd_bc_tbl = trans_pcie->scd_bc_tbls.addr; 192 scd_bc_tbl = trans_pcie->scd_bc_tbls.addr;
193 193
194 sta_id = tx_cmd->sta_id;
195 sec_ctl = tx_cmd->sec_ctl; 194 sec_ctl = tx_cmd->sec_ctl;
196 195
197 switch (sec_ctl & TX_CMD_SEC_MSK) { 196 switch (sec_ctl & TX_CMD_SEC_MSK) {
@@ -205,14 +204,32 @@ static void iwl_pcie_txq_update_byte_cnt_tbl(struct iwl_trans *trans,
205 len += IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN; 204 len += IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN;
206 break; 205 break;
207 } 206 }
208
209 if (trans_pcie->bc_table_dword) 207 if (trans_pcie->bc_table_dword)
210 len = DIV_ROUND_UP(len, 4); 208 len = DIV_ROUND_UP(len, 4);
211 209
212 if (WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX)) 210 if (WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX))
213 return; 211 return;
214 212
215 bc_ent = cpu_to_le16(len | (sta_id << 12)); 213 if (trans->cfg->use_tfh) {
214 u8 filled_tfd_size = offsetof(struct iwl_tfh_tfd, tbs) +
215 num_tbs * sizeof(struct iwl_tfh_tb);
216 /*
217 * filled_tfd_size contains the number of filled bytes in the
218 * TFD.
219 * Dividing it by 64 will give the number of chunks to fetch
220 * to SRAM- 0 for one chunk, 1 for 2 and so on.
221 * If, for example, TFD contains only 3 TBs then 32 bytes
222 * of the TFD are used, and only one chunk of 64 bytes should
223 * be fetched
224 */
225 u8 num_fetch_chunks = DIV_ROUND_UP(filled_tfd_size, 64) - 1;
226
227 bc_ent = cpu_to_le16(len | (num_fetch_chunks << 12));
228 } else {
229 u8 sta_id = tx_cmd->sta_id;
230
231 bc_ent = cpu_to_le16(len | (sta_id << 12));
232 }
216 233
217 scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; 234 scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
218 235
@@ -227,12 +244,12 @@ static void iwl_pcie_txq_inval_byte_cnt_tbl(struct iwl_trans *trans,
227 struct iwl_trans_pcie *trans_pcie = 244 struct iwl_trans_pcie *trans_pcie =
228 IWL_TRANS_GET_PCIE_TRANS(trans); 245 IWL_TRANS_GET_PCIE_TRANS(trans);
229 struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans_pcie->scd_bc_tbls.addr; 246 struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans_pcie->scd_bc_tbls.addr;
230 int txq_id = txq->q.id; 247 int txq_id = txq->id;
231 int read_ptr = txq->q.read_ptr; 248 int read_ptr = txq->read_ptr;
232 u8 sta_id = 0; 249 u8 sta_id = 0;
233 __le16 bc_ent; 250 __le16 bc_ent;
234 struct iwl_tx_cmd *tx_cmd = 251 struct iwl_tx_cmd *tx_cmd =
235 (void *)txq->entries[txq->q.read_ptr].cmd->payload; 252 (void *)txq->entries[read_ptr].cmd->payload;
236 253
237 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); 254 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
238 255
@@ -240,6 +257,7 @@ static void iwl_pcie_txq_inval_byte_cnt_tbl(struct iwl_trans *trans,
240 sta_id = tx_cmd->sta_id; 257 sta_id = tx_cmd->sta_id;
241 258
242 bc_ent = cpu_to_le16(1 | (sta_id << 12)); 259 bc_ent = cpu_to_le16(1 | (sta_id << 12));
260
243 scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent; 261 scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
244 262
245 if (read_ptr < TFD_QUEUE_SIZE_BC_DUP) 263 if (read_ptr < TFD_QUEUE_SIZE_BC_DUP)
@@ -255,7 +273,7 @@ static void iwl_pcie_txq_inc_wr_ptr(struct iwl_trans *trans,
255{ 273{
256 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 274 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
257 u32 reg = 0; 275 u32 reg = 0;
258 int txq_id = txq->q.id; 276 int txq_id = txq->id;
259 277
260 lockdep_assert_held(&txq->lock); 278 lockdep_assert_held(&txq->lock);
261 279
@@ -289,10 +307,10 @@ static void iwl_pcie_txq_inc_wr_ptr(struct iwl_trans *trans,
289 * if not in power-save mode, uCode will never sleep when we're 307 * if not in power-save mode, uCode will never sleep when we're
290 * trying to tx (during RFKILL, we're not trying to tx). 308 * trying to tx (during RFKILL, we're not trying to tx).
291 */ 309 */
292 IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq_id, txq->q.write_ptr); 310 IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq_id, txq->write_ptr);
293 if (!txq->block) 311 if (!txq->block)
294 iwl_write32(trans, HBUS_TARG_WRPTR, 312 iwl_write32(trans, HBUS_TARG_WRPTR,
295 txq->q.write_ptr | (txq_id << 8)); 313 txq->write_ptr | (txq_id << 8));
296} 314}
297 315
298void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans) 316void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans)
@@ -312,49 +330,93 @@ void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans)
312 } 330 }
313} 331}
314 332
315static inline dma_addr_t iwl_pcie_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) 333static inline void *iwl_pcie_get_tfd(struct iwl_trans_pcie *trans_pcie,
334 struct iwl_txq *txq, int idx)
316{ 335{
317 struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 336 return txq->tfds + trans_pcie->tfd_size * idx;
337}
318 338
319 dma_addr_t addr = get_unaligned_le32(&tb->lo); 339static inline dma_addr_t iwl_pcie_tfd_tb_get_addr(struct iwl_trans *trans,
320 if (sizeof(dma_addr_t) > sizeof(u32)) 340 void *_tfd, u8 idx)
321 addr |= 341{
322 ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16;
323 342
324 return addr; 343 if (trans->cfg->use_tfh) {
344 struct iwl_tfh_tfd *tfd = _tfd;
345 struct iwl_tfh_tb *tb = &tfd->tbs[idx];
346
347 return (dma_addr_t)(le64_to_cpu(tb->addr));
348 } else {
349 struct iwl_tfd *tfd = _tfd;
350 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
351 dma_addr_t addr = get_unaligned_le32(&tb->lo);
352 dma_addr_t hi_len;
353
354 if (sizeof(dma_addr_t) <= sizeof(u32))
355 return addr;
356
357 hi_len = le16_to_cpu(tb->hi_n_len) & 0xF;
358
359 /*
360 * shift by 16 twice to avoid warnings on 32-bit
361 * (where this code never runs anyway due to the
362 * if statement above)
363 */
364 return addr | ((hi_len << 16) << 16);
365 }
325} 366}
326 367
327static inline void iwl_pcie_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, 368static inline void iwl_pcie_tfd_set_tb(struct iwl_trans *trans, void *tfd,
328 dma_addr_t addr, u16 len) 369 u8 idx, dma_addr_t addr, u16 len)
329{ 370{
330 struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 371 if (trans->cfg->use_tfh) {
331 u16 hi_n_len = len << 4; 372 struct iwl_tfh_tfd *tfd_fh = (void *)tfd;
373 struct iwl_tfh_tb *tb = &tfd_fh->tbs[idx];
374
375 put_unaligned_le64(addr, &tb->addr);
376 tb->tb_len = cpu_to_le16(len);
377
378 tfd_fh->num_tbs = cpu_to_le16(idx + 1);
379 } else {
380 struct iwl_tfd *tfd_fh = (void *)tfd;
381 struct iwl_tfd_tb *tb = &tfd_fh->tbs[idx];
332 382
333 put_unaligned_le32(addr, &tb->lo); 383 u16 hi_n_len = len << 4;
334 if (sizeof(dma_addr_t) > sizeof(u32))
335 hi_n_len |= ((addr >> 16) >> 16) & 0xF;
336 384
337 tb->hi_n_len = cpu_to_le16(hi_n_len); 385 put_unaligned_le32(addr, &tb->lo);
386 if (sizeof(dma_addr_t) > sizeof(u32))
387 hi_n_len |= ((addr >> 16) >> 16) & 0xF;
338 388
339 tfd->num_tbs = idx + 1; 389 tb->hi_n_len = cpu_to_le16(hi_n_len);
390
391 tfd_fh->num_tbs = idx + 1;
392 }
340} 393}
341 394
342static inline u8 iwl_pcie_tfd_get_num_tbs(struct iwl_tfd *tfd) 395static inline u8 iwl_pcie_tfd_get_num_tbs(struct iwl_trans *trans, void *_tfd)
343{ 396{
344 return tfd->num_tbs & 0x1f; 397 if (trans->cfg->use_tfh) {
398 struct iwl_tfh_tfd *tfd = _tfd;
399
400 return le16_to_cpu(tfd->num_tbs) & 0x1f;
401 } else {
402 struct iwl_tfd *tfd = _tfd;
403
404 return tfd->num_tbs & 0x1f;
405 }
345} 406}
346 407
347static void iwl_pcie_tfd_unmap(struct iwl_trans *trans, 408static void iwl_pcie_tfd_unmap(struct iwl_trans *trans,
348 struct iwl_cmd_meta *meta, 409 struct iwl_cmd_meta *meta,
349 struct iwl_tfd *tfd) 410 struct iwl_txq *txq, int index)
350{ 411{
351 int i; 412 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
352 int num_tbs; 413 int i, num_tbs;
414 void *tfd = iwl_pcie_get_tfd(trans_pcie, txq, index);
353 415
354 /* Sanity check on number of chunks */ 416 /* Sanity check on number of chunks */
355 num_tbs = iwl_pcie_tfd_get_num_tbs(tfd); 417 num_tbs = iwl_pcie_tfd_get_num_tbs(trans, tfd);
356 418
357 if (num_tbs >= IWL_NUM_OF_TBS) { 419 if (num_tbs >= trans_pcie->max_tbs) {
358 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); 420 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs);
359 /* @todo issue fatal error, it is quite serious situation */ 421 /* @todo issue fatal error, it is quite serious situation */
360 return; 422 return;
@@ -363,18 +425,30 @@ static void iwl_pcie_tfd_unmap(struct iwl_trans *trans,
363 /* first TB is never freed - it's the bidirectional DMA data */ 425 /* first TB is never freed - it's the bidirectional DMA data */
364 426
365 for (i = 1; i < num_tbs; i++) { 427 for (i = 1; i < num_tbs; i++) {
366 if (meta->flags & BIT(i + CMD_TB_BITMAP_POS)) 428 if (meta->tbs & BIT(i))
367 dma_unmap_page(trans->dev, 429 dma_unmap_page(trans->dev,
368 iwl_pcie_tfd_tb_get_addr(tfd, i), 430 iwl_pcie_tfd_tb_get_addr(trans, tfd, i),
369 iwl_pcie_tfd_tb_get_len(tfd, i), 431 iwl_pcie_tfd_tb_get_len(trans, tfd, i),
370 DMA_TO_DEVICE); 432 DMA_TO_DEVICE);
371 else 433 else
372 dma_unmap_single(trans->dev, 434 dma_unmap_single(trans->dev,
373 iwl_pcie_tfd_tb_get_addr(tfd, i), 435 iwl_pcie_tfd_tb_get_addr(trans, tfd,
374 iwl_pcie_tfd_tb_get_len(tfd, i), 436 i),
437 iwl_pcie_tfd_tb_get_len(trans, tfd,
438 i),
375 DMA_TO_DEVICE); 439 DMA_TO_DEVICE);
376 } 440 }
377 tfd->num_tbs = 0; 441
442 if (trans->cfg->use_tfh) {
443 struct iwl_tfh_tfd *tfd_fh = (void *)tfd;
444
445 tfd_fh->num_tbs = 0;
446 } else {
447 struct iwl_tfd *tfd_fh = (void *)tfd;
448
449 tfd_fh->num_tbs = 0;
450 }
451
378} 452}
379 453
380/* 454/*
@@ -388,20 +462,18 @@ static void iwl_pcie_tfd_unmap(struct iwl_trans *trans,
388 */ 462 */
389static void iwl_pcie_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 463static void iwl_pcie_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq)
390{ 464{
391 struct iwl_tfd *tfd_tmp = txq->tfds;
392
393 /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 465 /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and
394 * idx is bounded by n_window 466 * idx is bounded by n_window
395 */ 467 */
396 int rd_ptr = txq->q.read_ptr; 468 int rd_ptr = txq->read_ptr;
397 int idx = get_cmd_index(&txq->q, rd_ptr); 469 int idx = get_cmd_index(txq, rd_ptr);
398 470
399 lockdep_assert_held(&txq->lock); 471 lockdep_assert_held(&txq->lock);
400 472
401 /* We have only q->n_window txq->entries, but we use 473 /* We have only q->n_window txq->entries, but we use
402 * TFD_QUEUE_SIZE_MAX tfds 474 * TFD_QUEUE_SIZE_MAX tfds
403 */ 475 */
404 iwl_pcie_tfd_unmap(trans, &txq->entries[idx].meta, &tfd_tmp[rd_ptr]); 476 iwl_pcie_tfd_unmap(trans, &txq->entries[idx].meta, txq, rd_ptr);
405 477
406 /* free SKB */ 478 /* free SKB */
407 if (txq->entries) { 479 if (txq->entries) {
@@ -423,23 +495,21 @@ static void iwl_pcie_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq)
423static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq, 495static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq,
424 dma_addr_t addr, u16 len, bool reset) 496 dma_addr_t addr, u16 len, bool reset)
425{ 497{
426 struct iwl_queue *q; 498 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
427 struct iwl_tfd *tfd, *tfd_tmp; 499 void *tfd;
428 u32 num_tbs; 500 u32 num_tbs;
429 501
430 q = &txq->q; 502 tfd = txq->tfds + trans_pcie->tfd_size * txq->write_ptr;
431 tfd_tmp = txq->tfds;
432 tfd = &tfd_tmp[q->write_ptr];
433 503
434 if (reset) 504 if (reset)
435 memset(tfd, 0, sizeof(*tfd)); 505 memset(tfd, 0, trans_pcie->tfd_size);
436 506
437 num_tbs = iwl_pcie_tfd_get_num_tbs(tfd); 507 num_tbs = iwl_pcie_tfd_get_num_tbs(trans, tfd);
438 508
439 /* Each TFD can point to a maximum 20 Tx buffers */ 509 /* Each TFD can point to a maximum max_tbs Tx buffers */
440 if (num_tbs >= IWL_NUM_OF_TBS) { 510 if (num_tbs >= trans_pcie->max_tbs) {
441 IWL_ERR(trans, "Error can not send more than %d chunks\n", 511 IWL_ERR(trans, "Error can not send more than %d chunks\n",
442 IWL_NUM_OF_TBS); 512 trans_pcie->max_tbs);
443 return -EINVAL; 513 return -EINVAL;
444 } 514 }
445 515
@@ -447,7 +517,7 @@ static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq,
447 "Unaligned address = %llx\n", (unsigned long long)addr)) 517 "Unaligned address = %llx\n", (unsigned long long)addr))
448 return -EINVAL; 518 return -EINVAL;
449 519
450 iwl_pcie_tfd_set_tb(tfd, num_tbs, addr, len); 520 iwl_pcie_tfd_set_tb(trans, tfd, num_tbs, addr, len);
451 521
452 return num_tbs; 522 return num_tbs;
453} 523}
@@ -457,7 +527,7 @@ static int iwl_pcie_txq_alloc(struct iwl_trans *trans,
457 u32 txq_id) 527 u32 txq_id)
458{ 528{
459 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 529 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
460 size_t tfd_sz = sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX; 530 size_t tfd_sz = trans_pcie->tfd_size * TFD_QUEUE_SIZE_MAX;
461 size_t tb0_buf_sz; 531 size_t tb0_buf_sz;
462 int i; 532 int i;
463 533
@@ -468,7 +538,7 @@ static int iwl_pcie_txq_alloc(struct iwl_trans *trans,
468 (unsigned long)txq); 538 (unsigned long)txq);
469 txq->trans_pcie = trans_pcie; 539 txq->trans_pcie = trans_pcie;
470 540
471 txq->q.n_window = slots_num; 541 txq->n_window = slots_num;
472 542
473 txq->entries = kcalloc(slots_num, 543 txq->entries = kcalloc(slots_num,
474 sizeof(struct iwl_pcie_txq_entry), 544 sizeof(struct iwl_pcie_txq_entry),
@@ -489,7 +559,7 @@ static int iwl_pcie_txq_alloc(struct iwl_trans *trans,
489 /* Circular buffer of transmit frame descriptors (TFDs), 559 /* Circular buffer of transmit frame descriptors (TFDs),
490 * shared with device */ 560 * shared with device */
491 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, 561 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz,
492 &txq->q.dma_addr, GFP_KERNEL); 562 &txq->dma_addr, GFP_KERNEL);
493 if (!txq->tfds) 563 if (!txq->tfds)
494 goto error; 564 goto error;
495 565
@@ -503,11 +573,11 @@ static int iwl_pcie_txq_alloc(struct iwl_trans *trans,
503 if (!txq->first_tb_bufs) 573 if (!txq->first_tb_bufs)
504 goto err_free_tfds; 574 goto err_free_tfds;
505 575
506 txq->q.id = txq_id; 576 txq->id = txq_id;
507 577
508 return 0; 578 return 0;
509err_free_tfds: 579err_free_tfds:
510 dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->q.dma_addr); 580 dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr);
511error: 581error:
512 if (txq->entries && txq_id == trans_pcie->cmd_queue) 582 if (txq->entries && txq_id == trans_pcie->cmd_queue)
513 for (i = 0; i < slots_num; i++) 583 for (i = 0; i < slots_num; i++)
@@ -531,7 +601,7 @@ static int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq,
531 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 601 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
532 602
533 /* Initialize queue's high/low-water marks, and head/tail indexes */ 603 /* Initialize queue's high/low-water marks, and head/tail indexes */
534 ret = iwl_queue_init(&txq->q, slots_num, txq_id); 604 ret = iwl_queue_init(txq, slots_num, txq_id);
535 if (ret) 605 if (ret)
536 return ret; 606 return ret;
537 607
@@ -545,10 +615,10 @@ static int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq,
545 if (trans->cfg->use_tfh) 615 if (trans->cfg->use_tfh)
546 iwl_write_direct64(trans, 616 iwl_write_direct64(trans,
547 FH_MEM_CBBC_QUEUE(trans, txq_id), 617 FH_MEM_CBBC_QUEUE(trans, txq_id),
548 txq->q.dma_addr); 618 txq->dma_addr);
549 else 619 else
550 iwl_write_direct32(trans, FH_MEM_CBBC_QUEUE(trans, txq_id), 620 iwl_write_direct32(trans, FH_MEM_CBBC_QUEUE(trans, txq_id),
551 txq->q.dma_addr >> 8); 621 txq->dma_addr >> 8);
552 622
553 return 0; 623 return 0;
554} 624}
@@ -595,15 +665,14 @@ static void iwl_pcie_txq_unmap(struct iwl_trans *trans, int txq_id)
595{ 665{
596 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 666 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
597 struct iwl_txq *txq = &trans_pcie->txq[txq_id]; 667 struct iwl_txq *txq = &trans_pcie->txq[txq_id];
598 struct iwl_queue *q = &txq->q;
599 668
600 spin_lock_bh(&txq->lock); 669 spin_lock_bh(&txq->lock);
601 while (q->write_ptr != q->read_ptr) { 670 while (txq->write_ptr != txq->read_ptr) {
602 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", 671 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n",
603 txq_id, q->read_ptr); 672 txq_id, txq->read_ptr);
604 673
605 if (txq_id != trans_pcie->cmd_queue) { 674 if (txq_id != trans_pcie->cmd_queue) {
606 struct sk_buff *skb = txq->entries[q->read_ptr].skb; 675 struct sk_buff *skb = txq->entries[txq->read_ptr].skb;
607 676
608 if (WARN_ON_ONCE(!skb)) 677 if (WARN_ON_ONCE(!skb))
609 continue; 678 continue;
@@ -611,15 +680,15 @@ static void iwl_pcie_txq_unmap(struct iwl_trans *trans, int txq_id)
611 iwl_pcie_free_tso_page(trans_pcie, skb); 680 iwl_pcie_free_tso_page(trans_pcie, skb);
612 } 681 }
613 iwl_pcie_txq_free_tfd(trans, txq); 682 iwl_pcie_txq_free_tfd(trans, txq);
614 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr); 683 txq->read_ptr = iwl_queue_inc_wrap(txq->read_ptr);
615 684
616 if (q->read_ptr == q->write_ptr) { 685 if (txq->read_ptr == txq->write_ptr) {
617 unsigned long flags; 686 unsigned long flags;
618 687
619 spin_lock_irqsave(&trans_pcie->reg_lock, flags); 688 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
620 if (txq_id != trans_pcie->cmd_queue) { 689 if (txq_id != trans_pcie->cmd_queue) {
621 IWL_DEBUG_RPM(trans, "Q %d - last tx freed\n", 690 IWL_DEBUG_RPM(trans, "Q %d - last tx freed\n",
622 q->id); 691 txq->id);
623 iwl_trans_unref(trans); 692 iwl_trans_unref(trans);
624 } else { 693 } else {
625 iwl_pcie_clear_cmd_in_flight(trans); 694 iwl_pcie_clear_cmd_in_flight(trans);
@@ -663,7 +732,7 @@ static void iwl_pcie_txq_free(struct iwl_trans *trans, int txq_id)
663 732
664 /* De-alloc array of command/tx buffers */ 733 /* De-alloc array of command/tx buffers */
665 if (txq_id == trans_pcie->cmd_queue) 734 if (txq_id == trans_pcie->cmd_queue)
666 for (i = 0; i < txq->q.n_window; i++) { 735 for (i = 0; i < txq->n_window; i++) {
667 kzfree(txq->entries[i].cmd); 736 kzfree(txq->entries[i].cmd);
668 kzfree(txq->entries[i].free_buf); 737 kzfree(txq->entries[i].free_buf);
669 } 738 }
@@ -671,13 +740,13 @@ static void iwl_pcie_txq_free(struct iwl_trans *trans, int txq_id)
671 /* De-alloc circular buffer of TFDs */ 740 /* De-alloc circular buffer of TFDs */
672 if (txq->tfds) { 741 if (txq->tfds) {
673 dma_free_coherent(dev, 742 dma_free_coherent(dev,
674 sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX, 743 trans_pcie->tfd_size * TFD_QUEUE_SIZE_MAX,
675 txq->tfds, txq->q.dma_addr); 744 txq->tfds, txq->dma_addr);
676 txq->q.dma_addr = 0; 745 txq->dma_addr = 0;
677 txq->tfds = NULL; 746 txq->tfds = NULL;
678 747
679 dma_free_coherent(dev, 748 dma_free_coherent(dev,
680 sizeof(*txq->first_tb_bufs) * txq->q.n_window, 749 sizeof(*txq->first_tb_bufs) * txq->n_window,
681 txq->first_tb_bufs, txq->first_tb_dma); 750 txq->first_tb_bufs, txq->first_tb_dma);
682 } 751 }
683 752
@@ -761,14 +830,14 @@ void iwl_trans_pcie_tx_reset(struct iwl_trans *trans)
761 if (trans->cfg->use_tfh) 830 if (trans->cfg->use_tfh)
762 iwl_write_direct64(trans, 831 iwl_write_direct64(trans,
763 FH_MEM_CBBC_QUEUE(trans, txq_id), 832 FH_MEM_CBBC_QUEUE(trans, txq_id),
764 txq->q.dma_addr); 833 txq->dma_addr);
765 else 834 else
766 iwl_write_direct32(trans, 835 iwl_write_direct32(trans,
767 FH_MEM_CBBC_QUEUE(trans, txq_id), 836 FH_MEM_CBBC_QUEUE(trans, txq_id),
768 txq->q.dma_addr >> 8); 837 txq->dma_addr >> 8);
769 iwl_pcie_txq_unmap(trans, txq_id); 838 iwl_pcie_txq_unmap(trans, txq_id);
770 txq->q.read_ptr = 0; 839 txq->read_ptr = 0;
771 txq->q.write_ptr = 0; 840 txq->write_ptr = 0;
772 } 841 }
773 842
774 /* Tell NIC where to find the "keep warm" buffer */ 843 /* Tell NIC where to find the "keep warm" buffer */
@@ -1012,7 +1081,7 @@ static inline void iwl_pcie_txq_progress(struct iwl_txq *txq)
1012 * if empty delete timer, otherwise move timer forward 1081 * if empty delete timer, otherwise move timer forward
1013 * since we're making progress on this queue 1082 * since we're making progress on this queue
1014 */ 1083 */
1015 if (txq->q.read_ptr == txq->q.write_ptr) 1084 if (txq->read_ptr == txq->write_ptr)
1016 del_timer(&txq->stuck_timer); 1085 del_timer(&txq->stuck_timer);
1017 else 1086 else
1018 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 1087 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
@@ -1025,7 +1094,6 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1025 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1094 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1026 struct iwl_txq *txq = &trans_pcie->txq[txq_id]; 1095 struct iwl_txq *txq = &trans_pcie->txq[txq_id];
1027 int tfd_num = ssn & (TFD_QUEUE_SIZE_MAX - 1); 1096 int tfd_num = ssn & (TFD_QUEUE_SIZE_MAX - 1);
1028 struct iwl_queue *q = &txq->q;
1029 int last_to_free; 1097 int last_to_free;
1030 1098
1031 /* This function is not meant to release cmd queue*/ 1099 /* This function is not meant to release cmd queue*/
@@ -1040,21 +1108,21 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1040 goto out; 1108 goto out;
1041 } 1109 }
1042 1110
1043 if (txq->q.read_ptr == tfd_num) 1111 if (txq->read_ptr == tfd_num)
1044 goto out; 1112 goto out;
1045 1113
1046 IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n", 1114 IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n",
1047 txq_id, txq->q.read_ptr, tfd_num, ssn); 1115 txq_id, txq->read_ptr, tfd_num, ssn);
1048 1116
1049 /*Since we free until index _not_ inclusive, the one before index is 1117 /*Since we free until index _not_ inclusive, the one before index is
1050 * the last we will free. This one must be used */ 1118 * the last we will free. This one must be used */
1051 last_to_free = iwl_queue_dec_wrap(tfd_num); 1119 last_to_free = iwl_queue_dec_wrap(tfd_num);
1052 1120
1053 if (!iwl_queue_used(q, last_to_free)) { 1121 if (!iwl_queue_used(txq, last_to_free)) {
1054 IWL_ERR(trans, 1122 IWL_ERR(trans,
1055 "%s: Read index for DMA queue txq id (%d), last_to_free %d is out of range [0-%d] %d %d.\n", 1123 "%s: Read index for DMA queue txq id (%d), last_to_free %d is out of range [0-%d] %d %d.\n",
1056 __func__, txq_id, last_to_free, TFD_QUEUE_SIZE_MAX, 1124 __func__, txq_id, last_to_free, TFD_QUEUE_SIZE_MAX,
1057 q->write_ptr, q->read_ptr); 1125 txq->write_ptr, txq->read_ptr);
1058 goto out; 1126 goto out;
1059 } 1127 }
1060 1128
@@ -1062,9 +1130,9 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1062 goto out; 1130 goto out;
1063 1131
1064 for (; 1132 for (;
1065 q->read_ptr != tfd_num; 1133 txq->read_ptr != tfd_num;
1066 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr)) { 1134 txq->read_ptr = iwl_queue_inc_wrap(txq->read_ptr)) {
1067 struct sk_buff *skb = txq->entries[txq->q.read_ptr].skb; 1135 struct sk_buff *skb = txq->entries[txq->read_ptr].skb;
1068 1136
1069 if (WARN_ON_ONCE(!skb)) 1137 if (WARN_ON_ONCE(!skb))
1070 continue; 1138 continue;
@@ -1073,16 +1141,17 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1073 1141
1074 __skb_queue_tail(skbs, skb); 1142 __skb_queue_tail(skbs, skb);
1075 1143
1076 txq->entries[txq->q.read_ptr].skb = NULL; 1144 txq->entries[txq->read_ptr].skb = NULL;
1077 1145
1078 iwl_pcie_txq_inval_byte_cnt_tbl(trans, txq); 1146 if (!trans->cfg->use_tfh)
1147 iwl_pcie_txq_inval_byte_cnt_tbl(trans, txq);
1079 1148
1080 iwl_pcie_txq_free_tfd(trans, txq); 1149 iwl_pcie_txq_free_tfd(trans, txq);
1081 } 1150 }
1082 1151
1083 iwl_pcie_txq_progress(txq); 1152 iwl_pcie_txq_progress(txq);
1084 1153
1085 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1154 if (iwl_queue_space(txq) > txq->low_mark &&
1086 test_bit(txq_id, trans_pcie->queue_stopped)) { 1155 test_bit(txq_id, trans_pcie->queue_stopped)) {
1087 struct sk_buff_head overflow_skbs; 1156 struct sk_buff_head overflow_skbs;
1088 1157
@@ -1114,12 +1183,12 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1114 } 1183 }
1115 spin_lock_bh(&txq->lock); 1184 spin_lock_bh(&txq->lock);
1116 1185
1117 if (iwl_queue_space(&txq->q) > txq->q.low_mark) 1186 if (iwl_queue_space(txq) > txq->low_mark)
1118 iwl_wake_queue(trans, txq); 1187 iwl_wake_queue(trans, txq);
1119 } 1188 }
1120 1189
1121 if (q->read_ptr == q->write_ptr) { 1190 if (txq->read_ptr == txq->write_ptr) {
1122 IWL_DEBUG_RPM(trans, "Q %d - last tx reclaimed\n", q->id); 1191 IWL_DEBUG_RPM(trans, "Q %d - last tx reclaimed\n", txq->id);
1123 iwl_trans_unref(trans); 1192 iwl_trans_unref(trans);
1124 } 1193 }
1125 1194
@@ -1181,31 +1250,30 @@ static void iwl_pcie_cmdq_reclaim(struct iwl_trans *trans, int txq_id, int idx)
1181{ 1250{
1182 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1251 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1183 struct iwl_txq *txq = &trans_pcie->txq[txq_id]; 1252 struct iwl_txq *txq = &trans_pcie->txq[txq_id];
1184 struct iwl_queue *q = &txq->q;
1185 unsigned long flags; 1253 unsigned long flags;
1186 int nfreed = 0; 1254 int nfreed = 0;
1187 1255
1188 lockdep_assert_held(&txq->lock); 1256 lockdep_assert_held(&txq->lock);
1189 1257
1190 if ((idx >= TFD_QUEUE_SIZE_MAX) || (!iwl_queue_used(q, idx))) { 1258 if ((idx >= TFD_QUEUE_SIZE_MAX) || (!iwl_queue_used(txq, idx))) {
1191 IWL_ERR(trans, 1259 IWL_ERR(trans,
1192 "%s: Read index for DMA queue txq id (%d), index %d is out of range [0-%d] %d %d.\n", 1260 "%s: Read index for DMA queue txq id (%d), index %d is out of range [0-%d] %d %d.\n",
1193 __func__, txq_id, idx, TFD_QUEUE_SIZE_MAX, 1261 __func__, txq_id, idx, TFD_QUEUE_SIZE_MAX,
1194 q->write_ptr, q->read_ptr); 1262 txq->write_ptr, txq->read_ptr);
1195 return; 1263 return;
1196 } 1264 }
1197 1265
1198 for (idx = iwl_queue_inc_wrap(idx); q->read_ptr != idx; 1266 for (idx = iwl_queue_inc_wrap(idx); txq->read_ptr != idx;
1199 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr)) { 1267 txq->read_ptr = iwl_queue_inc_wrap(txq->read_ptr)) {
1200 1268
1201 if (nfreed++ > 0) { 1269 if (nfreed++ > 0) {
1202 IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", 1270 IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n",
1203 idx, q->write_ptr, q->read_ptr); 1271 idx, txq->write_ptr, txq->read_ptr);
1204 iwl_force_nmi(trans); 1272 iwl_force_nmi(trans);
1205 } 1273 }
1206 } 1274 }
1207 1275
1208 if (q->read_ptr == q->write_ptr) { 1276 if (txq->read_ptr == txq->write_ptr) {
1209 spin_lock_irqsave(&trans_pcie->reg_lock, flags); 1277 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
1210 iwl_pcie_clear_cmd_in_flight(trans); 1278 iwl_pcie_clear_cmd_in_flight(trans);
1211 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); 1279 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
@@ -1291,14 +1359,14 @@ void iwl_trans_pcie_txq_enable(struct iwl_trans *trans, int txq_id, u16 ssn,
1291 */ 1359 */
1292 iwl_scd_txq_disable_agg(trans, txq_id); 1360 iwl_scd_txq_disable_agg(trans, txq_id);
1293 1361
1294 ssn = txq->q.read_ptr; 1362 ssn = txq->read_ptr;
1295 } 1363 }
1296 } 1364 }
1297 1365
1298 /* Place first TFD at index corresponding to start sequence number. 1366 /* Place first TFD at index corresponding to start sequence number.
1299 * Assumes that ssn_idx is valid (!= 0xFFF) */ 1367 * Assumes that ssn_idx is valid (!= 0xFFF) */
1300 txq->q.read_ptr = (ssn & 0xff); 1368 txq->read_ptr = (ssn & 0xff);
1301 txq->q.write_ptr = (ssn & 0xff); 1369 txq->write_ptr = (ssn & 0xff);
1302 iwl_write_direct32(trans, HBUS_TARG_WRPTR, 1370 iwl_write_direct32(trans, HBUS_TARG_WRPTR,
1303 (ssn & 0xff) | (txq_id << 8)); 1371 (ssn & 0xff) | (txq_id << 8));
1304 1372
@@ -1351,6 +1419,14 @@ void iwl_trans_pcie_txq_set_shared_mode(struct iwl_trans *trans, u32 txq_id,
1351 txq->ampdu = !shared_mode; 1419 txq->ampdu = !shared_mode;
1352} 1420}
1353 1421
1422dma_addr_t iwl_trans_pcie_get_txq_byte_table(struct iwl_trans *trans, int txq)
1423{
1424 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1425
1426 return trans_pcie->scd_bc_tbls.dma +
1427 txq * sizeof(struct iwlagn_scd_bc_tbl);
1428}
1429
1354void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id, 1430void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id,
1355 bool configure_scd) 1431 bool configure_scd)
1356{ 1432{
@@ -1406,7 +1482,6 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1406{ 1482{
1407 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1483 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1408 struct iwl_txq *txq = &trans_pcie->txq[trans_pcie->cmd_queue]; 1484 struct iwl_txq *txq = &trans_pcie->txq[trans_pcie->cmd_queue];
1409 struct iwl_queue *q = &txq->q;
1410 struct iwl_device_cmd *out_cmd; 1485 struct iwl_device_cmd *out_cmd;
1411 struct iwl_cmd_meta *out_meta; 1486 struct iwl_cmd_meta *out_meta;
1412 unsigned long flags; 1487 unsigned long flags;
@@ -1421,7 +1496,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1421 const u8 *cmddata[IWL_MAX_CMD_TBS_PER_TFD]; 1496 const u8 *cmddata[IWL_MAX_CMD_TBS_PER_TFD];
1422 u16 cmdlen[IWL_MAX_CMD_TBS_PER_TFD]; 1497 u16 cmdlen[IWL_MAX_CMD_TBS_PER_TFD];
1423 1498
1424 if (WARN(!trans_pcie->wide_cmd_header && 1499 if (WARN(!trans->wide_cmd_header &&
1425 group_id > IWL_ALWAYS_LONG_GROUP, 1500 group_id > IWL_ALWAYS_LONG_GROUP,
1426 "unsupported wide command %#x\n", cmd->id)) 1501 "unsupported wide command %#x\n", cmd->id))
1427 return -EINVAL; 1502 return -EINVAL;
@@ -1505,7 +1580,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1505 1580
1506 spin_lock_bh(&txq->lock); 1581 spin_lock_bh(&txq->lock);
1507 1582
1508 if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { 1583 if (iwl_queue_space(txq) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
1509 spin_unlock_bh(&txq->lock); 1584 spin_unlock_bh(&txq->lock);
1510 1585
1511 IWL_ERR(trans, "No space in command queue\n"); 1586 IWL_ERR(trans, "No space in command queue\n");
@@ -1514,7 +1589,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1514 goto free_dup_buf; 1589 goto free_dup_buf;
1515 } 1590 }
1516 1591
1517 idx = get_cmd_index(q, q->write_ptr); 1592 idx = get_cmd_index(txq, txq->write_ptr);
1518 out_cmd = txq->entries[idx].cmd; 1593 out_cmd = txq->entries[idx].cmd;
1519 out_meta = &txq->entries[idx].meta; 1594 out_meta = &txq->entries[idx].meta;
1520 1595
@@ -1533,7 +1608,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1533 out_cmd->hdr_wide.reserved = 0; 1608 out_cmd->hdr_wide.reserved = 0;
1534 out_cmd->hdr_wide.sequence = 1609 out_cmd->hdr_wide.sequence =
1535 cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->cmd_queue) | 1610 cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->cmd_queue) |
1536 INDEX_TO_SEQ(q->write_ptr)); 1611 INDEX_TO_SEQ(txq->write_ptr));
1537 1612
1538 cmd_pos = sizeof(struct iwl_cmd_header_wide); 1613 cmd_pos = sizeof(struct iwl_cmd_header_wide);
1539 copy_size = sizeof(struct iwl_cmd_header_wide); 1614 copy_size = sizeof(struct iwl_cmd_header_wide);
@@ -1541,7 +1616,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1541 out_cmd->hdr.cmd = iwl_cmd_opcode(cmd->id); 1616 out_cmd->hdr.cmd = iwl_cmd_opcode(cmd->id);
1542 out_cmd->hdr.sequence = 1617 out_cmd->hdr.sequence =
1543 cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->cmd_queue) | 1618 cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->cmd_queue) |
1544 INDEX_TO_SEQ(q->write_ptr)); 1619 INDEX_TO_SEQ(txq->write_ptr));
1545 out_cmd->hdr.group_id = 0; 1620 out_cmd->hdr.group_id = 0;
1546 1621
1547 cmd_pos = sizeof(struct iwl_cmd_header); 1622 cmd_pos = sizeof(struct iwl_cmd_header);
@@ -1591,7 +1666,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1591 iwl_get_cmd_string(trans, cmd->id), 1666 iwl_get_cmd_string(trans, cmd->id),
1592 group_id, out_cmd->hdr.cmd, 1667 group_id, out_cmd->hdr.cmd,
1593 le16_to_cpu(out_cmd->hdr.sequence), 1668 le16_to_cpu(out_cmd->hdr.sequence),
1594 cmd_size, q->write_ptr, idx, trans_pcie->cmd_queue); 1669 cmd_size, txq->write_ptr, idx, trans_pcie->cmd_queue);
1595 1670
1596 /* start the TFD with the minimum copy bytes */ 1671 /* start the TFD with the minimum copy bytes */
1597 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE); 1672 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE);
@@ -1607,8 +1682,8 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1607 copy_size - tb0_size, 1682 copy_size - tb0_size,
1608 DMA_TO_DEVICE); 1683 DMA_TO_DEVICE);
1609 if (dma_mapping_error(trans->dev, phys_addr)) { 1684 if (dma_mapping_error(trans->dev, phys_addr)) {
1610 iwl_pcie_tfd_unmap(trans, out_meta, 1685 iwl_pcie_tfd_unmap(trans, out_meta, txq,
1611 &txq->tfds[q->write_ptr]); 1686 txq->write_ptr);
1612 idx = -ENOMEM; 1687 idx = -ENOMEM;
1613 goto out; 1688 goto out;
1614 } 1689 }
@@ -1631,8 +1706,8 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1631 phys_addr = dma_map_single(trans->dev, (void *)data, 1706 phys_addr = dma_map_single(trans->dev, (void *)data,
1632 cmdlen[i], DMA_TO_DEVICE); 1707 cmdlen[i], DMA_TO_DEVICE);
1633 if (dma_mapping_error(trans->dev, phys_addr)) { 1708 if (dma_mapping_error(trans->dev, phys_addr)) {
1634 iwl_pcie_tfd_unmap(trans, out_meta, 1709 iwl_pcie_tfd_unmap(trans, out_meta, txq,
1635 &txq->tfds[q->write_ptr]); 1710 txq->write_ptr);
1636 idx = -ENOMEM; 1711 idx = -ENOMEM;
1637 goto out; 1712 goto out;
1638 } 1713 }
@@ -1640,8 +1715,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1640 iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmdlen[i], false); 1715 iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmdlen[i], false);
1641 } 1716 }
1642 1717
1643 BUILD_BUG_ON(IWL_NUM_OF_TBS + CMD_TB_BITMAP_POS > 1718 BUILD_BUG_ON(IWL_TFH_NUM_TBS > sizeof(out_meta->tbs) * BITS_PER_BYTE);
1644 sizeof(out_meta->flags) * BITS_PER_BYTE);
1645 out_meta->flags = cmd->flags; 1719 out_meta->flags = cmd->flags;
1646 if (WARN_ON_ONCE(txq->entries[idx].free_buf)) 1720 if (WARN_ON_ONCE(txq->entries[idx].free_buf))
1647 kzfree(txq->entries[idx].free_buf); 1721 kzfree(txq->entries[idx].free_buf);
@@ -1650,7 +1724,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1650 trace_iwlwifi_dev_hcmd(trans->dev, cmd, cmd_size, &out_cmd->hdr_wide); 1724 trace_iwlwifi_dev_hcmd(trans->dev, cmd, cmd_size, &out_cmd->hdr_wide);
1651 1725
1652 /* start timer if queue currently empty */ 1726 /* start timer if queue currently empty */
1653 if (q->read_ptr == q->write_ptr && txq->wd_timeout) 1727 if (txq->read_ptr == txq->write_ptr && txq->wd_timeout)
1654 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 1728 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
1655 1729
1656 spin_lock_irqsave(&trans_pcie->reg_lock, flags); 1730 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
@@ -1662,7 +1736,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
1662 } 1736 }
1663 1737
1664 /* Increment and update queue's write index */ 1738 /* Increment and update queue's write index */
1665 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr); 1739 txq->write_ptr = iwl_queue_inc_wrap(txq->write_ptr);
1666 iwl_pcie_txq_inc_wr_ptr(trans, txq); 1740 iwl_pcie_txq_inc_wr_ptr(trans, txq);
1667 1741
1668 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); 1742 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
@@ -1700,20 +1774,20 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
1700 if (WARN(txq_id != trans_pcie->cmd_queue, 1774 if (WARN(txq_id != trans_pcie->cmd_queue,
1701 "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", 1775 "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n",
1702 txq_id, trans_pcie->cmd_queue, sequence, 1776 txq_id, trans_pcie->cmd_queue, sequence,
1703 trans_pcie->txq[trans_pcie->cmd_queue].q.read_ptr, 1777 trans_pcie->txq[trans_pcie->cmd_queue].read_ptr,
1704 trans_pcie->txq[trans_pcie->cmd_queue].q.write_ptr)) { 1778 trans_pcie->txq[trans_pcie->cmd_queue].write_ptr)) {
1705 iwl_print_hex_error(trans, pkt, 32); 1779 iwl_print_hex_error(trans, pkt, 32);
1706 return; 1780 return;
1707 } 1781 }
1708 1782
1709 spin_lock_bh(&txq->lock); 1783 spin_lock_bh(&txq->lock);
1710 1784
1711 cmd_index = get_cmd_index(&txq->q, index); 1785 cmd_index = get_cmd_index(txq, index);
1712 cmd = txq->entries[cmd_index].cmd; 1786 cmd = txq->entries[cmd_index].cmd;
1713 meta = &txq->entries[cmd_index].meta; 1787 meta = &txq->entries[cmd_index].meta;
1714 cmd_id = iwl_cmd_id(cmd->hdr.cmd, group_id, 0); 1788 cmd_id = iwl_cmd_id(cmd->hdr.cmd, group_id, 0);
1715 1789
1716 iwl_pcie_tfd_unmap(trans, meta, &txq->tfds[index]); 1790 iwl_pcie_tfd_unmap(trans, meta, txq, index);
1717 1791
1718 /* Input error checking is done when commands are added to queue. */ 1792 /* Input error checking is done when commands are added to queue. */
1719 if (meta->flags & CMD_WANT_SKB) { 1793 if (meta->flags & CMD_WANT_SKB) {
@@ -1826,14 +1900,13 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1826 HOST_COMPLETE_TIMEOUT); 1900 HOST_COMPLETE_TIMEOUT);
1827 if (!ret) { 1901 if (!ret) {
1828 struct iwl_txq *txq = &trans_pcie->txq[trans_pcie->cmd_queue]; 1902 struct iwl_txq *txq = &trans_pcie->txq[trans_pcie->cmd_queue];
1829 struct iwl_queue *q = &txq->q;
1830 1903
1831 IWL_ERR(trans, "Error sending %s: time out after %dms.\n", 1904 IWL_ERR(trans, "Error sending %s: time out after %dms.\n",
1832 iwl_get_cmd_string(trans, cmd->id), 1905 iwl_get_cmd_string(trans, cmd->id),
1833 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); 1906 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
1834 1907
1835 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", 1908 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n",
1836 q->read_ptr, q->write_ptr); 1909 txq->read_ptr, txq->write_ptr);
1837 1910
1838 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1911 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
1839 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", 1912 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n",
@@ -1911,7 +1984,7 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, struct sk_buff *skb,
1911 struct iwl_cmd_meta *out_meta, 1984 struct iwl_cmd_meta *out_meta,
1912 struct iwl_device_cmd *dev_cmd, u16 tb1_len) 1985 struct iwl_device_cmd *dev_cmd, u16 tb1_len)
1913{ 1986{
1914 struct iwl_queue *q = &txq->q; 1987 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1915 u16 tb2_len; 1988 u16 tb2_len;
1916 int i; 1989 int i;
1917 1990
@@ -1926,8 +1999,8 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, struct sk_buff *skb,
1926 skb->data + hdr_len, 1999 skb->data + hdr_len,
1927 tb2_len, DMA_TO_DEVICE); 2000 tb2_len, DMA_TO_DEVICE);
1928 if (unlikely(dma_mapping_error(trans->dev, tb2_phys))) { 2001 if (unlikely(dma_mapping_error(trans->dev, tb2_phys))) {
1929 iwl_pcie_tfd_unmap(trans, out_meta, 2002 iwl_pcie_tfd_unmap(trans, out_meta, txq,
1930 &txq->tfds[q->write_ptr]); 2003 txq->write_ptr);
1931 return -EINVAL; 2004 return -EINVAL;
1932 } 2005 }
1933 iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, false); 2006 iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, false);
@@ -1946,19 +2019,19 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, struct sk_buff *skb,
1946 skb_frag_size(frag), DMA_TO_DEVICE); 2019 skb_frag_size(frag), DMA_TO_DEVICE);
1947 2020
1948 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) { 2021 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) {
1949 iwl_pcie_tfd_unmap(trans, out_meta, 2022 iwl_pcie_tfd_unmap(trans, out_meta, txq,
1950 &txq->tfds[q->write_ptr]); 2023 txq->write_ptr);
1951 return -EINVAL; 2024 return -EINVAL;
1952 } 2025 }
1953 tb_idx = iwl_pcie_txq_build_tfd(trans, txq, tb_phys, 2026 tb_idx = iwl_pcie_txq_build_tfd(trans, txq, tb_phys,
1954 skb_frag_size(frag), false); 2027 skb_frag_size(frag), false);
1955 2028
1956 out_meta->flags |= BIT(tb_idx + CMD_TB_BITMAP_POS); 2029 out_meta->tbs |= BIT(tb_idx);
1957 } 2030 }
1958 2031
1959 trace_iwlwifi_dev_tx(trans->dev, skb, 2032 trace_iwlwifi_dev_tx(trans->dev, skb,
1960 &txq->tfds[txq->q.write_ptr], 2033 iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr),
1961 sizeof(struct iwl_tfd), 2034 trans_pcie->tfd_size,
1962 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 2035 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len,
1963 skb->data + hdr_len, tb2_len); 2036 skb->data + hdr_len, tb2_len);
1964 trace_iwlwifi_dev_tx_data(trans->dev, skb, 2037 trace_iwlwifi_dev_tx_data(trans->dev, skb,
@@ -2019,7 +2092,6 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
2019 struct ieee80211_hdr *hdr = (void *)skb->data; 2092 struct ieee80211_hdr *hdr = (void *)skb->data;
2020 unsigned int snap_ip_tcp_hdrlen, ip_hdrlen, total_len, hdr_room; 2093 unsigned int snap_ip_tcp_hdrlen, ip_hdrlen, total_len, hdr_room;
2021 unsigned int mss = skb_shinfo(skb)->gso_size; 2094 unsigned int mss = skb_shinfo(skb)->gso_size;
2022 struct iwl_queue *q = &txq->q;
2023 u16 length, iv_len, amsdu_pad; 2095 u16 length, iv_len, amsdu_pad;
2024 u8 *start_hdr; 2096 u8 *start_hdr;
2025 struct iwl_tso_hdr_page *hdr_page; 2097 struct iwl_tso_hdr_page *hdr_page;
@@ -2033,8 +2105,8 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
2033 IEEE80211_CCMP_HDR_LEN : 0; 2105 IEEE80211_CCMP_HDR_LEN : 0;
2034 2106
2035 trace_iwlwifi_dev_tx(trans->dev, skb, 2107 trace_iwlwifi_dev_tx(trans->dev, skb,
2036 &txq->tfds[txq->q.write_ptr], 2108 iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr),
2037 sizeof(struct iwl_tfd), 2109 trans_pcie->tfd_size,
2038 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 2110 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len,
2039 NULL, 0); 2111 NULL, 0);
2040 2112
@@ -2190,7 +2262,7 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
2190 return 0; 2262 return 0;
2191 2263
2192out_unmap: 2264out_unmap:
2193 iwl_pcie_tfd_unmap(trans, out_meta, &txq->tfds[q->write_ptr]); 2265 iwl_pcie_tfd_unmap(trans, out_meta, txq, txq->write_ptr);
2194 return ret; 2266 return ret;
2195} 2267}
2196#else /* CONFIG_INET */ 2268#else /* CONFIG_INET */
@@ -2214,9 +2286,9 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2214 struct iwl_tx_cmd *tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload; 2286 struct iwl_tx_cmd *tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
2215 struct iwl_cmd_meta *out_meta; 2287 struct iwl_cmd_meta *out_meta;
2216 struct iwl_txq *txq; 2288 struct iwl_txq *txq;
2217 struct iwl_queue *q;
2218 dma_addr_t tb0_phys, tb1_phys, scratch_phys; 2289 dma_addr_t tb0_phys, tb1_phys, scratch_phys;
2219 void *tb1_addr; 2290 void *tb1_addr;
2291 void *tfd;
2220 u16 len, tb1_len; 2292 u16 len, tb1_len;
2221 bool wait_write_ptr; 2293 bool wait_write_ptr;
2222 __le16 fc; 2294 __le16 fc;
@@ -2225,7 +2297,6 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2225 bool amsdu; 2297 bool amsdu;
2226 2298
2227 txq = &trans_pcie->txq[txq_id]; 2299 txq = &trans_pcie->txq[txq_id];
2228 q = &txq->q;
2229 2300
2230 if (WARN_ONCE(!test_bit(txq_id, trans_pcie->queue_used), 2301 if (WARN_ONCE(!test_bit(txq_id, trans_pcie->queue_used),
2231 "TX on unused queue %d\n", txq_id)) 2302 "TX on unused queue %d\n", txq_id))
@@ -2247,7 +2318,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2247 } 2318 }
2248 2319
2249 if (skb_is_nonlinear(skb) && 2320 if (skb_is_nonlinear(skb) &&
2250 skb_shinfo(skb)->nr_frags > IWL_PCIE_MAX_FRAGS && 2321 skb_shinfo(skb)->nr_frags > IWL_PCIE_MAX_FRAGS(trans_pcie) &&
2251 __skb_linearize(skb)) 2322 __skb_linearize(skb))
2252 return -ENOMEM; 2323 return -ENOMEM;
2253 2324
@@ -2260,11 +2331,11 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2260 2331
2261 spin_lock(&txq->lock); 2332 spin_lock(&txq->lock);
2262 2333
2263 if (iwl_queue_space(q) < q->high_mark) { 2334 if (iwl_queue_space(txq) < txq->high_mark) {
2264 iwl_stop_queue(trans, txq); 2335 iwl_stop_queue(trans, txq);
2265 2336
2266 /* don't put the packet on the ring, if there is no room */ 2337 /* don't put the packet on the ring, if there is no room */
2267 if (unlikely(iwl_queue_space(q) < 3)) { 2338 if (unlikely(iwl_queue_space(txq) < 3)) {
2268 struct iwl_device_cmd **dev_cmd_ptr; 2339 struct iwl_device_cmd **dev_cmd_ptr;
2269 2340
2270 dev_cmd_ptr = (void *)((u8 *)skb->cb + 2341 dev_cmd_ptr = (void *)((u8 *)skb->cb +
@@ -2285,19 +2356,19 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2285 */ 2356 */
2286 wifi_seq = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); 2357 wifi_seq = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
2287 WARN_ONCE(txq->ampdu && 2358 WARN_ONCE(txq->ampdu &&
2288 (wifi_seq & 0xff) != q->write_ptr, 2359 (wifi_seq & 0xff) != txq->write_ptr,
2289 "Q: %d WiFi Seq %d tfdNum %d", 2360 "Q: %d WiFi Seq %d tfdNum %d",
2290 txq_id, wifi_seq, q->write_ptr); 2361 txq_id, wifi_seq, txq->write_ptr);
2291 2362
2292 /* Set up driver data for this TFD */ 2363 /* Set up driver data for this TFD */
2293 txq->entries[q->write_ptr].skb = skb; 2364 txq->entries[txq->write_ptr].skb = skb;
2294 txq->entries[q->write_ptr].cmd = dev_cmd; 2365 txq->entries[txq->write_ptr].cmd = dev_cmd;
2295 2366
2296 dev_cmd->hdr.sequence = 2367 dev_cmd->hdr.sequence =
2297 cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | 2368 cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
2298 INDEX_TO_SEQ(q->write_ptr))); 2369 INDEX_TO_SEQ(txq->write_ptr)));
2299 2370
2300 tb0_phys = iwl_pcie_get_first_tb_dma(txq, q->write_ptr); 2371 tb0_phys = iwl_pcie_get_first_tb_dma(txq, txq->write_ptr);
2301 scratch_phys = tb0_phys + sizeof(struct iwl_cmd_header) + 2372 scratch_phys = tb0_phys + sizeof(struct iwl_cmd_header) +
2302 offsetof(struct iwl_tx_cmd, scratch); 2373 offsetof(struct iwl_tx_cmd, scratch);
2303 2374
@@ -2305,7 +2376,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2305 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys); 2376 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
2306 2377
2307 /* Set up first empty entry in queue's array of Tx/cmd buffers */ 2378 /* Set up first empty entry in queue's array of Tx/cmd buffers */
2308 out_meta = &txq->entries[q->write_ptr].meta; 2379 out_meta = &txq->entries[txq->write_ptr].meta;
2309 out_meta->flags = 0; 2380 out_meta->flags = 0;
2310 2381
2311 /* 2382 /*
@@ -2330,7 +2401,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2330 } 2401 }
2331 2402
2332 /* The first TB points to bi-directional DMA data */ 2403 /* The first TB points to bi-directional DMA data */
2333 memcpy(&txq->first_tb_bufs[q->write_ptr], &dev_cmd->hdr, 2404 memcpy(&txq->first_tb_bufs[txq->write_ptr], &dev_cmd->hdr,
2334 IWL_FIRST_TB_SIZE); 2405 IWL_FIRST_TB_SIZE);
2335 iwl_pcie_txq_build_tfd(trans, txq, tb0_phys, 2406 iwl_pcie_txq_build_tfd(trans, txq, tb0_phys,
2336 IWL_FIRST_TB_SIZE, true); 2407 IWL_FIRST_TB_SIZE, true);
@@ -2355,13 +2426,15 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2355 goto out_err; 2426 goto out_err;
2356 } 2427 }
2357 2428
2429 tfd = iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr);
2358 /* Set up entry for this TFD in Tx byte-count array */ 2430 /* Set up entry for this TFD in Tx byte-count array */
2359 iwl_pcie_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len)); 2431 iwl_pcie_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len),
2432 iwl_pcie_tfd_get_num_tbs(trans, tfd));
2360 2433
2361 wait_write_ptr = ieee80211_has_morefrags(fc); 2434 wait_write_ptr = ieee80211_has_morefrags(fc);
2362 2435
2363 /* start timer if queue currently empty */ 2436 /* start timer if queue currently empty */
2364 if (q->read_ptr == q->write_ptr) { 2437 if (txq->read_ptr == txq->write_ptr) {
2365 if (txq->wd_timeout) { 2438 if (txq->wd_timeout) {
2366 /* 2439 /*
2367 * If the TXQ is active, then set the timer, if not, 2440 * If the TXQ is active, then set the timer, if not,
@@ -2375,12 +2448,12 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2375 else 2448 else
2376 txq->frozen_expiry_remainder = txq->wd_timeout; 2449 txq->frozen_expiry_remainder = txq->wd_timeout;
2377 } 2450 }
2378 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", q->id); 2451 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", txq->id);
2379 iwl_trans_ref(trans); 2452 iwl_trans_ref(trans);
2380 } 2453 }
2381 2454
2382 /* Tell device the write index *just past* this latest filled TFD */ 2455 /* Tell device the write index *just past* this latest filled TFD */
2383 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr); 2456 txq->write_ptr = iwl_queue_inc_wrap(txq->write_ptr);
2384 if (!wait_write_ptr) 2457 if (!wait_write_ptr)
2385 iwl_pcie_txq_inc_wr_ptr(trans, txq); 2458 iwl_pcie_txq_inc_wr_ptr(trans, txq);
2386 2459
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index c7f2faa81921..39ce76ad00bc 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -484,6 +484,29 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
484} 484}
485 485
486/* 486/*
487 * CFG802.11 operation handler to set default mgmt key.
488 */
489static int
490mwifiex_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
491 struct net_device *netdev,
492 u8 key_index)
493{
494 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
495 struct mwifiex_ds_encrypt_key encrypt_key;
496
497 wiphy_dbg(wiphy, "set default mgmt key, key index=%d\n", key_index);
498
499 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
500 encrypt_key.key_len = WLAN_KEY_LEN_CCMP;
501 encrypt_key.key_index = key_index;
502 encrypt_key.is_igtk_def_key = true;
503 eth_broadcast_addr(encrypt_key.mac_addr);
504
505 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
506 HostCmd_ACT_GEN_SET, true, &encrypt_key, true);
507}
508
509/*
487 * This function sends domain information to the firmware. 510 * This function sends domain information to the firmware.
488 * 511 *
489 * The following information are passed to the firmware - 512 * The following information are passed to the firmware -
@@ -4082,6 +4105,7 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = {
4082 .leave_ibss = mwifiex_cfg80211_leave_ibss, 4105 .leave_ibss = mwifiex_cfg80211_leave_ibss,
4083 .add_key = mwifiex_cfg80211_add_key, 4106 .add_key = mwifiex_cfg80211_add_key,
4084 .del_key = mwifiex_cfg80211_del_key, 4107 .del_key = mwifiex_cfg80211_del_key,
4108 .set_default_mgmt_key = mwifiex_cfg80211_set_default_mgmt_key,
4085 .mgmt_tx = mwifiex_cfg80211_mgmt_tx, 4109 .mgmt_tx = mwifiex_cfg80211_mgmt_tx,
4086 .mgmt_frame_register = mwifiex_cfg80211_mgmt_frame_register, 4110 .mgmt_frame_register = mwifiex_cfg80211_mgmt_frame_register,
4087 .remain_on_channel = mwifiex_cfg80211_remain_on_channel, 4111 .remain_on_channel = mwifiex_cfg80211_remain_on_channel,
diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index 18aa5256e88b..4b1894b4757f 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -78,6 +78,7 @@ enum KEY_TYPE_ID {
78 KEY_TYPE_ID_AES, 78 KEY_TYPE_ID_AES,
79 KEY_TYPE_ID_WAPI, 79 KEY_TYPE_ID_WAPI,
80 KEY_TYPE_ID_AES_CMAC, 80 KEY_TYPE_ID_AES_CMAC,
81 KEY_TYPE_ID_AES_CMAC_DEF,
81}; 82};
82 83
83#define WPA_PN_SIZE 8 84#define WPA_PN_SIZE 8
diff --git a/drivers/net/wireless/marvell/mwifiex/ioctl.h b/drivers/net/wireless/marvell/mwifiex/ioctl.h
index 70429815ff53..536ab834b126 100644
--- a/drivers/net/wireless/marvell/mwifiex/ioctl.h
+++ b/drivers/net/wireless/marvell/mwifiex/ioctl.h
@@ -260,6 +260,7 @@ struct mwifiex_ds_encrypt_key {
260 u8 is_igtk_key; 260 u8 is_igtk_key;
261 u8 is_current_wep_key; 261 u8 is_current_wep_key;
262 u8 is_rx_seq_valid; 262 u8 is_rx_seq_valid;
263 u8 is_igtk_def_key;
263}; 264};
264 265
265struct mwifiex_power_cfg { 266struct mwifiex_power_cfg {
diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index 9b2e98cfe090..2478ccd6f2d9 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -1369,12 +1369,12 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter, struct semaphore *sem)
1369 struct mwifiex_private *priv; 1369 struct mwifiex_private *priv;
1370 int i; 1370 int i;
1371 1371
1372 if (!adapter)
1373 goto exit_return;
1374
1372 if (down_interruptible(sem)) 1375 if (down_interruptible(sem))
1373 goto exit_sem_err; 1376 goto exit_sem_err;
1374 1377
1375 if (!adapter)
1376 goto exit_remove;
1377
1378 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); 1378 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
1379 mwifiex_deauthenticate(priv, NULL); 1379 mwifiex_deauthenticate(priv, NULL);
1380 1380
@@ -1430,10 +1430,10 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter, struct semaphore *sem)
1430 rtnl_unlock(); 1430 rtnl_unlock();
1431 } 1431 }
1432 1432
1433exit_remove:
1434 up(sem); 1433 up(sem);
1435exit_sem_err: 1434exit_sem_err:
1436 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); 1435 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
1436exit_return:
1437 return 0; 1437 return 0;
1438} 1438}
1439 1439
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
index 49048b41fd36..2a162c33d271 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
@@ -598,6 +598,11 @@ static int mwifiex_set_aes_key_v2(struct mwifiex_private *priv,
598 memcpy(km->key_param_set.key_params.cmac_aes.key, 598 memcpy(km->key_param_set.key_params.cmac_aes.key,
599 enc_key->key_material, enc_key->key_len); 599 enc_key->key_material, enc_key->key_len);
600 len += sizeof(struct mwifiex_cmac_aes_param); 600 len += sizeof(struct mwifiex_cmac_aes_param);
601 } else if (enc_key->is_igtk_def_key) {
602 mwifiex_dbg(adapter, INFO,
603 "%s: Set CMAC default Key index\n", __func__);
604 km->key_param_set.key_type = KEY_TYPE_ID_AES_CMAC_DEF;
605 km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK;
601 } else { 606 } else {
602 mwifiex_dbg(adapter, INFO, 607 mwifiex_dbg(adapter, INFO,
603 "%s: Set AES Key\n", __func__); 608 "%s: Set AES Key\n", __func__);
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 3344a26bed03..8548027abf71 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -1049,8 +1049,10 @@ mwifiex_create_custom_regdomain(struct mwifiex_private *priv,
1049 enum nl80211_band band; 1049 enum nl80211_band band;
1050 1050
1051 chan = *buf++; 1051 chan = *buf++;
1052 if (!chan) 1052 if (!chan) {
1053 kfree(regd);
1053 return NULL; 1054 return NULL;
1055 }
1054 chflags = *buf++; 1056 chflags = *buf++;
1055 band = (chan <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ; 1057 band = (chan <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
1056 freq = ieee80211_channel_to_frequency(chan, band); 1058 freq = ieee80211_channel_to_frequency(chan, band);
@@ -1116,6 +1118,7 @@ static int mwifiex_ret_chan_region_cfg(struct mwifiex_private *priv,
1116 u16 action = le16_to_cpu(reg->action); 1118 u16 action = le16_to_cpu(reg->action);
1117 u16 tlv, tlv_buf_len, tlv_buf_left; 1119 u16 tlv, tlv_buf_len, tlv_buf_left;
1118 struct mwifiex_ie_types_header *head; 1120 struct mwifiex_ie_types_header *head;
1121 struct ieee80211_regdomain *regd;
1119 u8 *tlv_buf; 1122 u8 *tlv_buf;
1120 1123
1121 if (action != HostCmd_ACT_GEN_GET) 1124 if (action != HostCmd_ACT_GEN_GET)
@@ -1137,10 +1140,10 @@ static int mwifiex_ret_chan_region_cfg(struct mwifiex_private *priv,
1137 mwifiex_dbg_dump(priv->adapter, CMD_D, "CHAN:", 1140 mwifiex_dbg_dump(priv->adapter, CMD_D, "CHAN:",
1138 (u8 *)head + sizeof(*head), 1141 (u8 *)head + sizeof(*head),
1139 tlv_buf_len); 1142 tlv_buf_len);
1140 priv->adapter->regd = 1143 regd = mwifiex_create_custom_regdomain(priv,
1141 mwifiex_create_custom_regdomain(priv, 1144 (u8 *)head + sizeof(*head), tlv_buf_len);
1142 (u8 *)head + 1145 if (!IS_ERR(regd))
1143 sizeof(*head), tlv_buf_len); 1146 priv->adapter->regd = regd;
1144 break; 1147 break;
1145 } 1148 }
1146 1149
diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 8a20620fa119..73eb0846db21 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -273,6 +273,8 @@ static void mwifiex_usb_tx_complete(struct urb *urb)
273 } else { 273 } else {
274 mwifiex_dbg(adapter, DATA, 274 mwifiex_dbg(adapter, DATA,
275 "%s: DATA\n", __func__); 275 "%s: DATA\n", __func__);
276 mwifiex_write_data_complete(adapter, context->skb, 0,
277 urb->status ? -1 : 0);
276 for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) { 278 for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
277 port = &card->port[i]; 279 port = &card->port[i];
278 if (context->ep == port->tx_data_ep) { 280 if (context->ep == port->tx_data_ep) {
@@ -282,8 +284,6 @@ static void mwifiex_usb_tx_complete(struct urb *urb)
282 } 284 }
283 } 285 }
284 adapter->data_sent = false; 286 adapter->data_sent = false;
285 mwifiex_write_data_complete(adapter, context->skb, 0,
286 urb->status ? -1 : 0);
287 } 287 }
288 288
289 if (card->mc_resync_flag) 289 if (card->mc_resync_flag)
@@ -841,7 +841,7 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
841 struct usb_tx_data_port *port = NULL; 841 struct usb_tx_data_port *port = NULL;
842 u8 *data = (u8 *)skb->data; 842 u8 *data = (u8 *)skb->data;
843 struct urb *tx_urb; 843 struct urb *tx_urb;
844 int idx, ret; 844 int idx, ret = -EINPROGRESS;
845 845
846 if (adapter->is_suspended) { 846 if (adapter->is_suspended) {
847 mwifiex_dbg(adapter, ERROR, 847 mwifiex_dbg(adapter, ERROR,
@@ -865,8 +865,9 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
865 if (atomic_read(&port->tx_data_urb_pending) 865 if (atomic_read(&port->tx_data_urb_pending)
866 >= MWIFIEX_TX_DATA_URB) { 866 >= MWIFIEX_TX_DATA_URB) {
867 port->block_status = true; 867 port->block_status = true;
868 ret = -EBUSY; 868 adapter->data_sent =
869 goto done; 869 mwifiex_usb_data_sent(adapter);
870 return -EBUSY;
870 } 871 }
871 if (port->tx_data_ix >= MWIFIEX_TX_DATA_URB) 872 if (port->tx_data_ix >= MWIFIEX_TX_DATA_URB)
872 port->tx_data_ix = 0; 873 port->tx_data_ix = 0;
@@ -897,6 +898,14 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
897 else 898 else
898 atomic_inc(&port->tx_data_urb_pending); 899 atomic_inc(&port->tx_data_urb_pending);
899 900
901 if (ep != card->tx_cmd_ep &&
902 atomic_read(&port->tx_data_urb_pending) ==
903 MWIFIEX_TX_DATA_URB) {
904 port->block_status = true;
905 adapter->data_sent = mwifiex_usb_data_sent(adapter);
906 ret = -ENOSR;
907 }
908
900 if (usb_submit_urb(tx_urb, GFP_ATOMIC)) { 909 if (usb_submit_urb(tx_urb, GFP_ATOMIC)) {
901 mwifiex_dbg(adapter, ERROR, 910 mwifiex_dbg(adapter, ERROR,
902 "%s: usb_submit_urb failed\n", __func__); 911 "%s: usb_submit_urb failed\n", __func__);
@@ -905,29 +914,15 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
905 } else { 914 } else {
906 atomic_dec(&port->tx_data_urb_pending); 915 atomic_dec(&port->tx_data_urb_pending);
907 port->block_status = false; 916 port->block_status = false;
917 adapter->data_sent = false;
908 if (port->tx_data_ix) 918 if (port->tx_data_ix)
909 port->tx_data_ix--; 919 port->tx_data_ix--;
910 else 920 else
911 port->tx_data_ix = MWIFIEX_TX_DATA_URB; 921 port->tx_data_ix = MWIFIEX_TX_DATA_URB;
912 } 922 }
913 923 ret = -1;
914 return -1;
915 } else {
916 if (ep != card->tx_cmd_ep &&
917 atomic_read(&port->tx_data_urb_pending) ==
918 MWIFIEX_TX_DATA_URB) {
919 port->block_status = true;
920 ret = -ENOSR;
921 goto done;
922 }
923 } 924 }
924 925
925 return -EINPROGRESS;
926
927done:
928 if (ep != card->tx_cmd_ep)
929 adapter->data_sent = mwifiex_usb_data_sent(adapter);
930
931 return ret; 926 return ret;
932} 927}
933 928
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 1f54b8928d3c..1016628926d2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -29,6 +29,7 @@
29#define RTL8XXXU_DEBUG_H2C 0x800 29#define RTL8XXXU_DEBUG_H2C 0x800
30#define RTL8XXXU_DEBUG_ACTION 0x1000 30#define RTL8XXXU_DEBUG_ACTION 0x1000
31#define RTL8XXXU_DEBUG_EFUSE 0x2000 31#define RTL8XXXU_DEBUG_EFUSE 0x2000
32#define RTL8XXXU_DEBUG_INTERRUPT 0x4000
32 33
33#define RTW_USB_CONTROL_MSG_TIMEOUT 500 34#define RTW_USB_CONTROL_MSG_TIMEOUT 500
34#define RTL8XXXU_MAX_REG_POLL 500 35#define RTL8XXXU_MAX_REG_POLL 500
@@ -1318,7 +1319,7 @@ struct rtl8xxxu_fileops {
1318 int (*power_on) (struct rtl8xxxu_priv *priv); 1319 int (*power_on) (struct rtl8xxxu_priv *priv);
1319 void (*power_off) (struct rtl8xxxu_priv *priv); 1320 void (*power_off) (struct rtl8xxxu_priv *priv);
1320 void (*reset_8051) (struct rtl8xxxu_priv *priv); 1321 void (*reset_8051) (struct rtl8xxxu_priv *priv);
1321 int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page); 1322 int (*llt_init) (struct rtl8xxxu_priv *priv);
1322 void (*init_phy_bb) (struct rtl8xxxu_priv *priv); 1323 void (*init_phy_bb) (struct rtl8xxxu_priv *priv);
1323 int (*init_phy_rf) (struct rtl8xxxu_priv *priv); 1324 int (*init_phy_rf) (struct rtl8xxxu_priv *priv);
1324 void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv); 1325 void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv);
@@ -1400,14 +1401,14 @@ int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name);
1400void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv); 1401void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv);
1401void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv); 1402void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv);
1402void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv); 1403void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv);
1403int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); 1404int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv);
1404void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start); 1405void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start);
1405int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv); 1406int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv);
1406int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv, 1407int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv,
1407 struct h2c_cmd *h2c, int len); 1408 struct h2c_cmd *h2c, int len);
1408int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv); 1409int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv);
1409void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv); 1410void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv);
1410int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); 1411int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv);
1411void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv); 1412void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv);
1412void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv); 1413void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv);
1413void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, 1414void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index 841522ee6379..df54d27e7851 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -1396,6 +1396,114 @@ exit:
1396 return ret; 1396 return ret;
1397} 1397}
1398 1398
1399static int rtl8192eu_active_to_lps(struct rtl8xxxu_priv *priv)
1400{
1401 struct device *dev = &priv->udev->dev;
1402 u8 val8;
1403 u16 val16;
1404 u32 val32;
1405 int retry, retval;
1406
1407 rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff);
1408
1409 retry = 100;
1410 retval = -EBUSY;
1411 /*
1412 * Poll 32 bit wide 0x05f8 for 0x00000000 to ensure no TX is pending.
1413 */
1414 do {
1415 val32 = rtl8xxxu_read32(priv, REG_SCH_TX_CMD);
1416 if (!val32) {
1417 retval = 0;
1418 break;
1419 }
1420 } while (retry--);
1421
1422 if (!retry) {
1423 dev_warn(dev, "Failed to flush TX queue\n");
1424 retval = -EBUSY;
1425 goto out;
1426 }
1427
1428 /* Disable CCK and OFDM, clock gated */
1429 val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC);
1430 val8 &= ~SYS_FUNC_BBRSTB;
1431 rtl8xxxu_write8(priv, REG_SYS_FUNC, val8);
1432
1433 udelay(2);
1434
1435 /* Reset whole BB */
1436 val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC);
1437 val8 &= ~SYS_FUNC_BB_GLB_RSTN;
1438 rtl8xxxu_write8(priv, REG_SYS_FUNC, val8);
1439
1440 /* Reset MAC TRX */
1441 val16 = rtl8xxxu_read16(priv, REG_CR);
1442 val16 &= 0xff00;
1443 val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE);
1444 rtl8xxxu_write16(priv, REG_CR, val16);
1445
1446 val16 = rtl8xxxu_read16(priv, REG_CR);
1447 val16 &= ~CR_SECURITY_ENABLE;
1448 rtl8xxxu_write16(priv, REG_CR, val16);
1449
1450 val8 = rtl8xxxu_read8(priv, REG_DUAL_TSF_RST);
1451 val8 |= DUAL_TSF_TX_OK;
1452 rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, val8);
1453
1454out:
1455 return retval;
1456}
1457
1458static int rtl8192eu_active_to_emu(struct rtl8xxxu_priv *priv)
1459{
1460 u8 val8;
1461 int count, ret = 0;
1462
1463 /* Turn off RF */
1464 rtl8xxxu_write8(priv, REG_RF_CTRL, 0);
1465
1466 /* Switch DPDT_SEL_P output from register 0x65[2] */
1467 val8 = rtl8xxxu_read8(priv, REG_LEDCFG2);
1468 val8 &= ~LEDCFG2_DPDT_SELECT;
1469 rtl8xxxu_write8(priv, REG_LEDCFG2, val8);
1470
1471 /* 0x0005[1] = 1 turn off MAC by HW state machine*/
1472 val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
1473 val8 |= BIT(1);
1474 rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8);
1475
1476 for (count = RTL8XXXU_MAX_REG_POLL; count; count--) {
1477 val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
1478 if ((val8 & BIT(1)) == 0)
1479 break;
1480 udelay(10);
1481 }
1482
1483 if (!count) {
1484 dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n",
1485 __func__);
1486 ret = -EBUSY;
1487 goto exit;
1488 }
1489
1490exit:
1491 return ret;
1492}
1493
1494static int rtl8192eu_emu_to_disabled(struct rtl8xxxu_priv *priv)
1495{
1496 u8 val8;
1497
1498 /* 0x04[12:11] = 01 enable WL suspend */
1499 val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
1500 val8 &= ~(BIT(3) | BIT(4));
1501 val8 |= BIT(3);
1502 rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8);
1503
1504 return 0;
1505}
1506
1399static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) 1507static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv)
1400{ 1508{
1401 u16 val16; 1509 u16 val16;
@@ -1446,6 +1554,40 @@ exit:
1446 return ret; 1554 return ret;
1447} 1555}
1448 1556
1557void rtl8192eu_power_off(struct rtl8xxxu_priv *priv)
1558{
1559 u8 val8;
1560 u16 val16;
1561
1562 rtl8xxxu_flush_fifo(priv);
1563
1564 val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL);
1565 val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE;
1566 rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8);
1567
1568 /* Turn off RF */
1569 rtl8xxxu_write8(priv, REG_RF_CTRL, 0x00);
1570
1571 rtl8192eu_active_to_lps(priv);
1572
1573 /* Reset Firmware if running in RAM */
1574 if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL)
1575 rtl8xxxu_firmware_self_reset(priv);
1576
1577 /* Reset MCU */
1578 val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
1579 val16 &= ~SYS_FUNC_CPU_ENABLE;
1580 rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
1581
1582 /* Reset MCU ready status */
1583 rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00);
1584
1585 rtl8xxxu_reset_8051(priv);
1586
1587 rtl8192eu_active_to_emu(priv);
1588 rtl8192eu_emu_to_disabled(priv);
1589}
1590
1449static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) 1591static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv)
1450{ 1592{
1451 u32 val32; 1593 u32 val32;
@@ -1487,7 +1629,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = {
1487 .parse_efuse = rtl8192eu_parse_efuse, 1629 .parse_efuse = rtl8192eu_parse_efuse,
1488 .load_firmware = rtl8192eu_load_firmware, 1630 .load_firmware = rtl8192eu_load_firmware,
1489 .power_on = rtl8192eu_power_on, 1631 .power_on = rtl8192eu_power_on,
1490 .power_off = rtl8xxxu_power_off, 1632 .power_off = rtl8192eu_power_off,
1491 .reset_8051 = rtl8xxxu_reset_8051, 1633 .reset_8051 = rtl8xxxu_reset_8051,
1492 .llt_init = rtl8xxxu_auto_llt_table, 1634 .llt_init = rtl8xxxu_auto_llt_table,
1493 .init_phy_bb = rtl8192eu_init_phy_bb, 1635 .init_phy_bb = rtl8192eu_init_phy_bb,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index ca92022f9d50..b2d7f6e69667 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -2472,10 +2472,13 @@ static int rtl8xxxu_llt_write(struct rtl8xxxu_priv *priv, u8 address, u8 data)
2472 return ret; 2472 return ret;
2473} 2473}
2474 2474
2475int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 2475int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv)
2476{ 2476{
2477 int ret; 2477 int ret;
2478 int i; 2478 int i;
2479 u8 last_tx_page;
2480
2481 last_tx_page = priv->fops->total_page_num;
2479 2482
2480 for (i = 0; i < last_tx_page; i++) { 2483 for (i = 0; i < last_tx_page; i++) {
2481 ret = rtl8xxxu_llt_write(priv, i, i + 1); 2484 ret = rtl8xxxu_llt_write(priv, i, i + 1);
@@ -2503,7 +2506,7 @@ exit:
2503 return ret; 2506 return ret;
2504} 2507}
2505 2508
2506int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 2509int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv)
2507{ 2510{
2508 u32 val32; 2511 u32 val32;
2509 int ret = 0; 2512 int ret = 0;
@@ -3869,7 +3872,7 @@ static void rtl8xxxu_init_queue_reserved_page(struct rtl8xxxu_priv *priv)
3869 val32 = (nq << RQPN_NPQ_SHIFT) | (eq << RQPN_EPQ_SHIFT); 3872 val32 = (nq << RQPN_NPQ_SHIFT) | (eq << RQPN_EPQ_SHIFT);
3870 rtl8xxxu_write32(priv, REG_RQPN_NPQ, val32); 3873 rtl8xxxu_write32(priv, REG_RQPN_NPQ, val32);
3871 3874
3872 pubq = fops->total_page_num - hq - lq - nq; 3875 pubq = fops->total_page_num - hq - lq - nq - 1;
3873 3876
3874 val32 = RQPN_LOAD; 3877 val32 = RQPN_LOAD;
3875 val32 |= (hq << RQPN_HI_PQ_SHIFT); 3878 val32 |= (hq << RQPN_HI_PQ_SHIFT);
@@ -3883,6 +3886,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3883{ 3886{
3884 struct rtl8xxxu_priv *priv = hw->priv; 3887 struct rtl8xxxu_priv *priv = hw->priv;
3885 struct device *dev = &priv->udev->dev; 3888 struct device *dev = &priv->udev->dev;
3889 struct rtl8xxxu_fileops *fops = priv->fops;
3886 bool macpower; 3890 bool macpower;
3887 int ret; 3891 int ret;
3888 u8 val8; 3892 u8 val8;
@@ -3901,7 +3905,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3901 else 3905 else
3902 macpower = true; 3906 macpower = true;
3903 3907
3904 ret = priv->fops->power_on(priv); 3908 ret = fops->power_on(priv);
3905 if (ret < 0) { 3909 if (ret < 0) {
3906 dev_warn(dev, "%s: Failed power on\n", __func__); 3910 dev_warn(dev, "%s: Failed power on\n", __func__);
3907 goto exit; 3911 goto exit;
@@ -3918,7 +3922,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3918 /* 3922 /*
3919 * Set RX page boundary 3923 * Set RX page boundary
3920 */ 3924 */
3921 rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, priv->fops->trxff_boundary); 3925 rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, fops->trxff_boundary);
3922 3926
3923 ret = rtl8xxxu_download_firmware(priv); 3927 ret = rtl8xxxu_download_firmware(priv);
3924 dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret); 3928 dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret);
@@ -3929,8 +3933,8 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3929 if (ret) 3933 if (ret)
3930 goto exit; 3934 goto exit;
3931 3935
3932 if (priv->fops->phy_init_antenna_selection) 3936 if (fops->phy_init_antenna_selection)
3933 priv->fops->phy_init_antenna_selection(priv); 3937 fops->phy_init_antenna_selection(priv);
3934 3938
3935 ret = rtl8xxxu_init_mac(priv); 3939 ret = rtl8xxxu_init_mac(priv);
3936 3940
@@ -3943,7 +3947,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3943 if (ret) 3947 if (ret)
3944 goto exit; 3948 goto exit;
3945 3949
3946 ret = priv->fops->init_phy_rf(priv); 3950 ret = fops->init_phy_rf(priv);
3947 if (ret) 3951 if (ret)
3948 goto exit; 3952 goto exit;
3949 3953
@@ -3968,7 +3972,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3968 /* 3972 /*
3969 * Set TX buffer boundary 3973 * Set TX buffer boundary
3970 */ 3974 */
3971 val8 = priv->fops->total_page_num + 1; 3975 val8 = fops->total_page_num + 1;
3972 3976
3973 rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8); 3977 rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8);
3974 rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8); 3978 rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8);
@@ -3981,14 +3985,14 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3981 * The vendor drivers set PBP for all devices, except 8192e. 3985 * The vendor drivers set PBP for all devices, except 8192e.
3982 * There is no explanation for this in any of the sources. 3986 * There is no explanation for this in any of the sources.
3983 */ 3987 */
3984 val8 = (priv->fops->pbp_rx << PBP_PAGE_SIZE_RX_SHIFT) | 3988 val8 = (fops->pbp_rx << PBP_PAGE_SIZE_RX_SHIFT) |
3985 (priv->fops->pbp_tx << PBP_PAGE_SIZE_TX_SHIFT); 3989 (fops->pbp_tx << PBP_PAGE_SIZE_TX_SHIFT);
3986 if (priv->rtl_chip != RTL8192E) 3990 if (priv->rtl_chip != RTL8192E)
3987 rtl8xxxu_write8(priv, REG_PBP, val8); 3991 rtl8xxxu_write8(priv, REG_PBP, val8);
3988 3992
3989 dev_dbg(dev, "%s: macpower %i\n", __func__, macpower); 3993 dev_dbg(dev, "%s: macpower %i\n", __func__, macpower);
3990 if (!macpower) { 3994 if (!macpower) {
3991 ret = priv->fops->llt_init(priv, TX_TOTAL_PAGE_NUM); 3995 ret = fops->llt_init(priv);
3992 if (ret) { 3996 if (ret) {
3993 dev_warn(dev, "%s: LLT table init failed\n", __func__); 3997 dev_warn(dev, "%s: LLT table init failed\n", __func__);
3994 goto exit; 3998 goto exit;
@@ -3997,12 +4001,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
3997 /* 4001 /*
3998 * Chip specific quirks 4002 * Chip specific quirks
3999 */ 4003 */
4000 priv->fops->usb_quirks(priv); 4004 fops->usb_quirks(priv);
4001 4005
4002 /* 4006 /*
4003 * Enable TX report and TX report timer for 8723bu/8188eu/... 4007 * Enable TX report and TX report timer for 8723bu/8188eu/...
4004 */ 4008 */
4005 if (priv->fops->has_tx_report) { 4009 if (fops->has_tx_report) {
4006 val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); 4010 val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL);
4007 val8 |= TX_REPORT_CTRL_TIMER_ENABLE; 4011 val8 |= TX_REPORT_CTRL_TIMER_ENABLE;
4008 rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); 4012 rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8);
@@ -4137,8 +4141,8 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
4137 rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); 4141 rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
4138 } 4142 }
4139 4143
4140 if (priv->fops->init_aggregation) 4144 if (fops->init_aggregation)
4141 priv->fops->init_aggregation(priv); 4145 fops->init_aggregation(priv);
4142 4146
4143 /* 4147 /*
4144 * Enable CCK and OFDM block 4148 * Enable CCK and OFDM block
@@ -4155,7 +4159,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
4155 /* 4159 /*
4156 * Start out with default power levels for channel 6, 20MHz 4160 * Start out with default power levels for channel 6, 20MHz
4157 */ 4161 */
4158 priv->fops->set_tx_power(priv, 1, false); 4162 fops->set_tx_power(priv, 1, false);
4159 4163
4160 /* Let the 8051 take control of antenna setting */ 4164 /* Let the 8051 take control of antenna setting */
4161 if (priv->rtl_chip != RTL8192E) { 4165 if (priv->rtl_chip != RTL8192E) {
@@ -4171,8 +4175,8 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
4171 4175
4172 rtl8xxxu_write16(priv, REG_FAST_EDCA_CTRL, 0); 4176 rtl8xxxu_write16(priv, REG_FAST_EDCA_CTRL, 0);
4173 4177
4174 if (priv->fops->init_statistics) 4178 if (fops->init_statistics)
4175 priv->fops->init_statistics(priv); 4179 fops->init_statistics(priv);
4176 4180
4177 if (priv->rtl_chip == RTL8192E) { 4181 if (priv->rtl_chip == RTL8192E) {
4178 /* 4182 /*
@@ -4190,12 +4194,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
4190 4194
4191 rtl8723a_phy_lc_calibrate(priv); 4195 rtl8723a_phy_lc_calibrate(priv);
4192 4196
4193 priv->fops->phy_iq_calibrate(priv); 4197 fops->phy_iq_calibrate(priv);
4194 4198
4195 /* 4199 /*
4196 * This should enable thermal meter 4200 * This should enable thermal meter
4197 */ 4201 */
4198 if (priv->fops->gen2_thermal_meter) 4202 if (fops->gen2_thermal_meter)
4199 rtl8xxxu_write_rfreg(priv, 4203 rtl8xxxu_write_rfreg(priv,
4200 RF_A, RF6052_REG_T_METER_8723B, 0x37cf8); 4204 RF_A, RF6052_REG_T_METER_8723B, 0x37cf8);
4201 else 4205 else
@@ -5371,7 +5375,8 @@ static void rtl8xxxu_int_complete(struct urb *urb)
5371 struct device *dev = &priv->udev->dev; 5375 struct device *dev = &priv->udev->dev;
5372 int ret; 5376 int ret;
5373 5377
5374 dev_dbg(dev, "%s: status %i\n", __func__, urb->status); 5378 if (rtl8xxxu_debug & RTL8XXXU_DEBUG_INTERRUPT)
5379 dev_dbg(dev, "%s: status %i\n", __func__, urb->status);
5375 if (urb->status == 0) { 5380 if (urb->status == 0) {
5376 usb_anchor_urb(urb, &priv->int_anchor); 5381 usb_anchor_urb(urb, &priv->int_anchor);
5377 ret = usb_submit_urb(urb, GFP_ATOMIC); 5382 ret = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index 3555a2f24285..315ccfb2dff5 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -676,6 +676,7 @@
676#define REG_SCH_TXCMD 0x05d0 676#define REG_SCH_TXCMD 0x05d0
677 677
678/* define REG_FW_TSF_SYNC_CNT 0x04a0 */ 678/* define REG_FW_TSF_SYNC_CNT 0x04a0 */
679#define REG_SCH_TX_CMD 0x05f8
679#define REG_FW_RESET_TSF_CNT_1 0x05fc 680#define REG_FW_RESET_TSF_CNT_1 0x05fc
680#define REG_FW_RESET_TSF_CNT_0 0x05fd 681#define REG_FW_RESET_TSF_CNT_0 0x05fd
681#define REG_FW_BCN_DIS_CNT 0x05fe 682#define REG_FW_BCN_DIS_CNT 0x05fe
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index 7aee5ebb147d..f95760c13c56 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -765,7 +765,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
765 mac->bw_40 = false; 765 mac->bw_40 = false;
766 mac->bw_80 = false; 766 mac->bw_80 = false;
767 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 767 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
768 "switch case not processed\n"); 768 "switch case %#x not processed\n",
769 channel_type);
769 break; 770 break;
770 } 771 }
771 } 772 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index d12586d4f845..0dfa9eac3926 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -179,7 +179,8 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
179 break; 179 break;
180 default: 180 default:
181 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 181 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
182 "switch case not processed\n"); 182 "switch case %#x not processed\n",
183 rtlpci->const_support_pciaspm);
183 break; 184 break;
184 } 185 }
185 186
diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
index 9a64f9b703e5..18d979affc18 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -151,7 +151,7 @@ static bool rtl_ps_set_rf_state(struct ieee80211_hw *hw,
151 151
152 default: 152 default:
153 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 153 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
154 "switch case not processed\n"); 154 "switch case %#x not processed\n", state_toset);
155 break; 155 break;
156 } 156 }
157 157
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
index 629125658b87..5360d5332359 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
@@ -334,7 +334,7 @@ static void _rtl88e_fill_h2c_command(struct ieee80211_hw *hw,
334 break; 334 break;
335 default: 335 default:
336 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 336 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
337 "switch case not process\n"); 337 "switch case %#x not processed\n", boxnum);
338 break; 338 break;
339 } 339 }
340 isfw_read = _rtl88e_check_fw_read_last_h2c(hw, boxnum); 340 isfw_read = _rtl88e_check_fw_read_last_h2c(hw, boxnum);
@@ -405,7 +405,7 @@ static void _rtl88e_fill_h2c_command(struct ieee80211_hw *hw,
405 break; 405 break;
406 default: 406 default:
407 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 407 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
408 "switch case not process\n"); 408 "switch case %#x not processed\n", cmd_len);
409 break; 409 break;
410 } 410 }
411 411
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
index 4ab6201daf1a..37d6efc3d240 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
@@ -355,9 +355,11 @@ void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
355 355
356 *((u64 *)(val)) = tsf; 356 *((u64 *)(val)) = tsf;
357 break; } 357 break; }
358 case HAL_DEF_WOWLAN:
359 break;
358 default: 360 default:
359 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 361 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
360 "switch case not process %x\n", variable); 362 "switch case %#x not processed\n", variable);
361 break; 363 break;
362 } 364 }
363} 365}
@@ -571,7 +573,8 @@ void rtl88ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
571 break; 573 break;
572 default: 574 default:
573 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 575 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
574 "switch case not process\n"); 576 "switch case %#x not processed\n",
577 e_aci);
575 break; 578 break;
576 } 579 }
577 } 580 }
@@ -735,7 +738,7 @@ void rtl88ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
735 break; } 738 break; }
736 default: 739 default:
737 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 740 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
738 "switch case not process %x\n", variable); 741 "switch case %#x not processed\n", variable);
739 break; 742 break;
740 } 743 }
741} 744}
@@ -2352,7 +2355,7 @@ void rtl88ee_set_key(struct ieee80211_hw *hw, u32 key_index,
2352 break; 2355 break;
2353 default: 2356 default:
2354 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2357 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2355 "switch case not process\n"); 2358 "switch case %#x not processed\n", enc_algo);
2356 enc_algo = CAM_TKIP; 2359 enc_algo = CAM_TKIP;
2357 break; 2360 break;
2358 } 2361 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c
index b504bd092fc4..f05c2c674165 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c
@@ -62,7 +62,7 @@ void rtl88ee_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
62 break; 62 break;
63 default: 63 default:
64 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 64 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
65 "switch case not process\n"); 65 "switch case %#x not processed\n", pled->ledpin);
66 break; 66 break;
67 } 67 }
68 pled->ledon = true; 68 pled->ledon = true;
@@ -100,7 +100,7 @@ void rtl88ee_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
100 break; 100 break;
101 default: 101 default:
102 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 102 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
103 "switch case not process\n"); 103 "switch case %#x not processed\n", pled->ledpin);
104 break; 104 break;
105 } 105 }
106 pled->ledon = false; 106 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
index 7498a1218cba..fffaa92eda81 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
@@ -1346,7 +1346,8 @@ static bool _rtl88e_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
1346 break; 1346 break;
1347 default: 1347 default:
1348 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1348 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1349 "switch case not process\n"); 1349 "switch case %#x not processed\n",
1350 currentcmd->cmdid);
1350 break; 1351 break;
1351 } 1352 }
1352 1353
@@ -2128,7 +2129,7 @@ bool rtl88e_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
2128 break; 2129 break;
2129 default: 2130 default:
2130 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2131 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2131 "switch case not process\n"); 2132 "switch case %#x not processed\n", iotype);
2132 break; 2133 break;
2133 } 2134 }
2134 } while (false); 2135 } while (false);
@@ -2166,7 +2167,8 @@ static void rtl88e_phy_set_io(struct ieee80211_hw *hw)
2166 break; 2167 break;
2167 default: 2168 default:
2168 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2169 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2169 "switch case not process\n"); 2170 "switch case %#x not processed\n",
2171 rtlphy->current_io_type);
2170 break; 2172 break;
2171 } 2173 }
2172 rtlphy->set_io_inprogress = false; 2174 rtlphy->set_io_inprogress = false;
@@ -2319,7 +2321,7 @@ static bool _rtl88ee_phy_set_rf_power_state(struct ieee80211_hw *hw,
2319 } 2321 }
2320 default: 2322 default:
2321 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2323 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2322 "switch case not process\n"); 2324 "switch case %#x not processed\n", rfpwr_state);
2323 bresult = false; 2325 bresult = false;
2324 break; 2326 break;
2325 } 2327 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
index 43fcb25c885f..7d152466152b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
@@ -352,7 +352,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
352 break; 352 break;
353 default: 353 default:
354 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 354 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
355 "switch case not process\n"); 355 "switch case %#x not processed\n", boxnum);
356 break; 356 break;
357 } 357 }
358 358
@@ -456,7 +456,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
456 break; 456 break;
457 default: 457 default:
458 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 458 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
459 "switch case not process\n"); 459 "switch case %#x not processed\n", cmd_len);
460 break; 460 break;
461 } 461 }
462 462
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
index 60ab2ec4f4ef..27e3d5f9ca34 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
@@ -910,7 +910,8 @@ bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
910 break; 910 break;
911 default: 911 default:
912 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 912 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
913 "switch case not process\n"); 913 "switch case %#x not processed\n",
914 currentcmd->cmdid);
914 break; 915 break;
915 } 916 }
916 917
@@ -1567,7 +1568,7 @@ bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
1567 break; 1568 break;
1568 default: 1569 default:
1569 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1570 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1570 "switch case not process\n"); 1571 "switch case %#x not processed\n", iotype);
1571 break; 1572 break;
1572 } 1573 }
1573 } while (false); 1574 } while (false);
@@ -1605,7 +1606,8 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw)
1605 break; 1606 break;
1606 default: 1607 default:
1607 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1608 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1608 "switch case not process\n"); 1609 "switch case %#x not processed\n",
1610 rtlphy->current_io_type);
1609 break; 1611 break;
1610 } 1612 }
1611 rtlphy->set_io_inprogress = false; 1613 rtlphy->set_io_inprogress = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index 244607951e28..a47be73a0980 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -141,9 +141,11 @@ void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
141 141
142 break; 142 break;
143 } 143 }
144 case HAL_DEF_WOWLAN:
145 break;
144 default: 146 default:
145 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 147 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
146 "switch case not processed\n"); 148 "switch case %#x not processed\n", variable);
147 break; 149 break;
148 } 150 }
149} 151}
@@ -367,7 +369,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
367 break; 369 break;
368 default: 370 default:
369 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 371 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
370 "switch case not processed\n"); 372 "switch case %#x not processed\n",
373 e_aci);
371 break; 374 break;
372 } 375 }
373 } 376 }
@@ -2154,7 +2157,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2154 break; 2157 break;
2155 default: 2158 default:
2156 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2159 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2157 "switch case not processed\n"); 2160 "switch case %#x not processed\n", enc_algo);
2158 enc_algo = CAM_TKIP; 2161 enc_algo = CAM_TKIP;
2159 break; 2162 break;
2160 } 2163 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/led.c
index 8283e9b27639..24e483ba3fa4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/led.c
@@ -62,7 +62,7 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
62 break; 62 break;
63 default: 63 default:
64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
65 "switch case not processed\n"); 65 "switch case %#x not processed\n", pled->ledpin);
66 break; 66 break;
67 } 67 }
68 pled->ledon = true; 68 pled->ledon = true;
@@ -97,7 +97,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
97 break; 97 break;
98 default: 98 default:
99 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 99 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
100 "switch case not processed\n"); 100 "switch case %#x not processed\n", pled->ledpin);
101 break; 101 break;
102 } 102 }
103 pled->ledon = false; 103 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
index 1ee5a6ae9960..46d0d945f283 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
@@ -300,12 +300,9 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
300 } 300 }
301 break; 301 break;
302 case RF90_PATH_C: 302 case RF90_PATH_C:
303 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
304 "switch case not processed\n");
305 break;
306 case RF90_PATH_D: 303 case RF90_PATH_D:
307 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 304 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
308 "switch case not processed\n"); 305 "switch case %#x not processed\n", rfpath);
309 break; 306 break;
310 default: 307 default:
311 break; 308 break;
@@ -554,7 +551,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
554 } 551 }
555 default: 552 default:
556 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 553 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
557 "switch case not processed\n"); 554 "switch case %#x not processed\n", rfpwr_state);
558 bresult = false; 555 bresult = false;
559 break; 556 break;
560 } 557 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index 8789752f8143..ae8f055483fa 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -1560,7 +1560,7 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1560 break; 1560 break;
1561 default: 1561 default:
1562 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1562 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1563 "switch case not processed\n"); 1563 "switch case %#x not processed\n", variable);
1564 break; 1564 break;
1565 } 1565 }
1566} 1566}
@@ -1931,7 +1931,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1931 } 1931 }
1932 default: 1932 default:
1933 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1933 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1934 "switch case not processed\n"); 1934 "switch case %#x not processed\n", variable);
1935 break; 1935 break;
1936 } 1936 }
1937} 1937}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/led.c
index 75a2deb23af1..8514ab652520 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/led.c
@@ -62,7 +62,7 @@ void rtl92cu_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
62 break; 62 break;
63 default: 63 default:
64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
65 "switch case not processed\n"); 65 "switch case %#x not processed\n", pled->ledpin);
66 break; 66 break;
67 } 67 }
68 pled->ledon = true; 68 pled->ledon = true;
@@ -95,7 +95,7 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
95 break; 95 break;
96 default: 96 default:
97 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 97 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
98 "switch case not processed\n"); 98 "switch case %#x not processed\n", pled->ledpin);
99 break; 99 break;
100 } 100 }
101 pled->ledon = false; 101 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
index c972fa50926d..4b2976465905 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
@@ -277,12 +277,9 @@ bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
277 } 277 }
278 break; 278 break;
279 case RF90_PATH_C: 279 case RF90_PATH_C:
280 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
281 "switch case not processed\n");
282 break;
283 case RF90_PATH_D: 280 case RF90_PATH_D:
284 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 281 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
285 "switch case not processed\n"); 282 "switch case %#x not processed\n", rfpath);
286 break; 283 break;
287 default: 284 default:
288 break; 285 break;
@@ -517,7 +514,7 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
517 break; 514 break;
518 default: 515 default:
519 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 516 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
520 "switch case not processed\n"); 517 "switch case %#x not processed\n", rfpwr_state);
521 bresult = false; 518 bresult = false;
522 break; 519 break;
523 } 520 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
index 62ef8209718f..8de29cc3ced0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
@@ -435,7 +435,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
435 break; 435 break;
436 default: 436 default:
437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
438 "switch case not processed\n"); 438 "switch case %#x not processed\n", boxnum);
439 break; 439 break;
440 } 440 }
441 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); 441 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum);
@@ -512,7 +512,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
512 break; 512 break;
513 default: 513 default:
514 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 514 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
515 "switch case not processed\n"); 515 "switch case %#x not processed\n", cmd_len);
516 break; 516 break;
517 } 517 }
518 bwrite_success = true; 518 bwrite_success = true;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
index 57205514801c..d91f8bbfe7a0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
@@ -164,9 +164,11 @@ void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
164 case HW_VAR_INT_AC: 164 case HW_VAR_INT_AC:
165 *((bool *)(val)) = rtlpriv->dm.disable_tx_int; 165 *((bool *)(val)) = rtlpriv->dm.disable_tx_int;
166 break; 166 break;
167 case HAL_DEF_WOWLAN:
168 break;
167 default: 169 default:
168 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 170 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
169 "switch case not processed\n"); 171 "switch case %#x not processed\n", variable);
170 break; 172 break;
171 } 173 }
172} 174}
@@ -361,7 +363,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
361 break; 363 break;
362 default: 364 default:
363 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 365 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
364 "switch case not processed\n"); 366 "switch case %#x not processed\n",
367 e_aci);
365 break; 368 break;
366 } 369 }
367 } 370 }
@@ -502,7 +505,7 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
502 } 505 }
503 default: 506 default:
504 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 507 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
505 "switch case not processed\n"); 508 "switch case %#x not processed\n", variable);
506 break; 509 break;
507 } 510 }
508} 511}
@@ -2171,7 +2174,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2171 break; 2174 break;
2172 default: 2175 default:
2173 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2176 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2174 "switch case not processed\n"); 2177 "switch case %#x not processed\n", enc_algo);
2175 enc_algo = CAM_TKIP; 2178 enc_algo = CAM_TKIP;
2176 break; 2179 break;
2177 } 2180 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c
index 76a57ae4af3e..811ba57eb9bb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c
@@ -71,7 +71,7 @@ void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
71 break; 71 break;
72 default: 72 default:
73 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 73 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
74 "switch case not processed\n"); 74 "switch case %#x not processed\n", pled->ledpin);
75 break; 75 break;
76 } 76 }
77 pled->ledon = true; 77 pled->ledon = true;
@@ -106,7 +106,7 @@ void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
106 break; 106 break;
107 default: 107 default:
108 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 108 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
109 "switch case not processed\n"); 109 "switch case %#x not processed\n", pled->ledpin);
110 break; 110 break;
111 } 111 }
112 pled->ledon = false; 112 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
index 2a4810d32182..2a1edfd21b96 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
@@ -836,12 +836,9 @@ bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
836 } 836 }
837 break; 837 break;
838 case RF90_PATH_C: 838 case RF90_PATH_C:
839 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
840 "switch case not processed\n");
841 break;
842 case RF90_PATH_D: 839 case RF90_PATH_D:
843 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 840 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
844 "switch case not processed\n"); 841 "switch case %#x not processed\n", rfpath);
845 break; 842 break;
846 } 843 }
847 return true; 844 return true;
@@ -2850,7 +2847,8 @@ static bool _rtl92d_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
2850 break; 2847 break;
2851 default: 2848 default:
2852 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2849 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2853 "switch case not processed\n"); 2850 "switch case %#x not processed\n",
2851 currentcmd->cmdid);
2854 break; 2852 break;
2855 } 2853 }
2856 break; 2854 break;
@@ -2963,7 +2961,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
2963 break; 2961 break;
2964 default: 2962 default:
2965 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2963 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2966 "switch case not processed\n"); 2964 "switch case %#x not processed\n",
2965 rtlphy->current_io_type);
2967 break; 2966 break;
2968 } 2967 }
2969 rtlphy->set_io_inprogress = false; 2968 rtlphy->set_io_inprogress = false;
@@ -2994,7 +2993,7 @@ bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
2994 break; 2993 break;
2995 default: 2994 default:
2996 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2995 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2997 "switch case not processed\n"); 2996 "switch case %#x not processed\n", iotype);
2998 break; 2997 break;
2999 } 2998 }
3000 } while (false); 2999 } while (false);
@@ -3182,7 +3181,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw,
3182 break; 3181 break;
3183 default: 3182 default:
3184 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 3183 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3185 "switch case not processed\n"); 3184 "switch case %#x not processed\n", rfpwr_state);
3186 bresult = false; 3185 bresult = false;
3187 break; 3186 break;
3188 } 3187 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index 0708eedd9671..b3f6a9ed15d4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -344,7 +344,7 @@ static void _rtl92ee_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
344 break; 344 break;
345 default: 345 default:
346 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 346 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
347 "switch case not process\n"); 347 "switch case %#x not processed\n", boxnum);
348 break; 348 break;
349 } 349 }
350 350
@@ -433,7 +433,7 @@ static void _rtl92ee_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
433 break; 433 break;
434 default: 434 default:
435 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 435 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
436 "switch case not process\n"); 436 "switch case %#x not processed\n", cmd_len);
437 break; 437 break;
438 } 438 }
439 439
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
index b07af8d15273..ebf663e1a81a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
@@ -338,9 +338,11 @@ void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
338 *((u64 *)(val)) = tsf; 338 *((u64 *)(val)) = tsf;
339 } 339 }
340 break; 340 break;
341 case HAL_DEF_WOWLAN:
342 break;
341 default: 343 default:
342 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 344 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
343 "switch case not process %x\n", variable); 345 "switch case %#x not processed\n", variable);
344 break; 346 break;
345 } 347 }
346} 348}
@@ -566,7 +568,8 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
566 break; 568 break;
567 default: 569 default:
568 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 570 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
569 "switch case not process\n"); 571 "switch case %#x not processed\n",
572 e_aci);
570 break; 573 break;
571 } 574 }
572 } 575 }
@@ -685,7 +688,7 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
685 break; 688 break;
686 default: 689 default:
687 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 690 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
688 "switch case not process %x\n", variable); 691 "switch case %#x not processed\n", variable);
689 break; 692 break;
690 } 693 }
691} 694}
@@ -2463,7 +2466,7 @@ void rtl92ee_set_key(struct ieee80211_hw *hw, u32 key_index,
2463 break; 2466 break;
2464 default: 2467 default:
2465 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 2468 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
2466 "switch case not process\n"); 2469 "switch case %#x not processed\n", enc_algo);
2467 enc_algo = CAM_TKIP; 2470 enc_algo = CAM_TKIP;
2468 break; 2471 break;
2469 } 2472 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/led.c
index 8388e371c8e2..47da05dd3076 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/led.c
@@ -61,7 +61,7 @@ void rtl92ee_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
61 break; 61 break;
62 default: 62 default:
63 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 63 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
64 "switch case not process\n"); 64 "switch case %#x not processed\n", pled->ledpin);
65 break; 65 break;
66 } 66 }
67 pled->ledon = true; 67 pled->ledon = true;
@@ -91,7 +91,7 @@ void rtl92ee_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
91 break; 91 break;
92 default: 92 default:
93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
94 "switch case not process\n"); 94 "switch case %#x not processed\n", pled->ledpin);
95 break; 95 break;
96 } 96 }
97 pled->ledon = false; 97 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
index beafc9a10ad8..5ad7e753c357 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
@@ -1927,7 +1927,8 @@ static bool _rtl92ee_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
1927 break; 1927 break;
1928 default: 1928 default:
1929 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1929 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1930 "switch case not process\n"); 1930 "switch case %#x not processed\n",
1931 currentcmd->cmdid);
1931 break; 1932 break;
1932 } 1933 }
1933 1934
@@ -3001,7 +3002,7 @@ bool rtl92ee_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
3001 break; 3002 break;
3002 default: 3003 default:
3003 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 3004 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
3004 "switch case not process\n"); 3005 "switch case %#x not processed\n", iotype);
3005 break; 3006 break;
3006 } 3007 }
3007 } while (false); 3008 } while (false);
@@ -3041,7 +3042,8 @@ static void rtl92ee_phy_set_io(struct ieee80211_hw *hw)
3041 break; 3042 break;
3042 default: 3043 default:
3043 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 3044 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
3044 "switch case not process\n"); 3045 "switch case %#x not processed\n",
3046 rtlphy->current_io_type);
3045 break; 3047 break;
3046 } 3048 }
3047 rtlphy->set_io_inprogress = false; 3049 rtlphy->set_io_inprogress = false;
@@ -3187,7 +3189,7 @@ static bool _rtl92ee_phy_set_rf_power_state(struct ieee80211_hw *hw,
3187 break; 3189 break;
3188 default: 3190 default:
3189 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 3191 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
3190 "switch case not process\n"); 3192 "switch case %#x not processed\n", rfpwr_state);
3191 bresult = false; 3193 bresult = false;
3192 break; 3194 break;
3193 } 3195 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
index ddfa0aee5bf8..52e4430edb54 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
@@ -77,9 +77,11 @@ void rtl92se_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
77 *((bool *)(val)) = rtlpriv->dm.current_mrc_switch; 77 *((bool *)(val)) = rtlpriv->dm.current_mrc_switch;
78 break; 78 break;
79 } 79 }
80 case HAL_DEF_WOWLAN:
81 break;
80 default: { 82 default: {
81 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 83 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
82 "switch case not processed\n"); 84 "switch case %#x not processed\n", variable);
83 break; 85 break;
84 } 86 }
85 } 87 }
@@ -297,7 +299,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
297 break; 299 break;
298 default: 300 default:
299 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 301 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
300 "switch case not processed\n"); 302 "switch case %#x not processed\n",
303 e_aci);
301 break; 304 break;
302 } 305 }
303 } 306 }
@@ -433,7 +436,7 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
433 break; } 436 break; }
434 default: 437 default:
435 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 438 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
436 "switch case not processed\n"); 439 "switch case %#x not processed\n", variable);
437 break; 440 break;
438 } 441 }
439 442
@@ -2465,7 +2468,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2465 break; 2468 break;
2466 default: 2469 default:
2467 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2470 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2468 "switch case not processed\n"); 2471 "switch case %#x not processed\n", enc_algo);
2469 enc_algo = CAM_TKIP; 2472 enc_algo = CAM_TKIP;
2470 break; 2473 break;
2471 } 2474 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/led.c
index 44949b5cbb87..9849cb988186 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/led.c
@@ -68,7 +68,7 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
68 break; 68 break;
69 default: 69 default:
70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
71 "switch case not processed\n"); 71 "switch case %#x not processed\n", pled->ledpin);
72 break; 72 break;
73 } 73 }
74 pled->ledon = true; 74 pled->ledon = true;
@@ -104,7 +104,7 @@ void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
104 break; 104 break;
105 default: 105 default:
106 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 106 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
107 "switch case not processed\n"); 107 "switch case %#x not processed\n", pled->ledpin);
108 break; 108 break;
109 } 109 }
110 pled->ledon = false; 110 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
index 881821f4e243..4bb75581ab38 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
@@ -442,7 +442,8 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
442 break; 442 break;
443 default: 443 default:
444 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 444 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
445 "switch case not processed\n"); 445 "switch case %#x not processed\n",
446 currentcmd->cmdid);
446 break; 447 break;
447 } 448 }
448 449
@@ -648,7 +649,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
648 break; 649 break;
649 default: 650 default:
650 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 651 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
651 "switch case not processed\n"); 652 "switch case %#x not processed\n", rfpwr_state);
652 bresult = false; 653 bresult = false;
653 break; 654 break;
654 } 655 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
index b7c0d38ee5b5..1186755e55b8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
@@ -124,7 +124,7 @@ static void _rtl8723e_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
124 break; 124 break;
125 default: 125 default:
126 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 126 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
127 "switch case not process\n"); 127 "switch case %#x not processed\n", boxnum);
128 break; 128 break;
129 } 129 }
130 130
@@ -230,7 +230,7 @@ static void _rtl8723e_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
230 break; 230 break;
231 default: 231 default:
232 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 232 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
233 "switch case not process\n"); 233 "switch case %#x not processed\n", cmd_len);
234 break; 234 break;
235 } 235 }
236 236
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index ba30efc2d195..f8be0bd7e326 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -141,9 +141,11 @@ void rtl8723e_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
141 141
142 break; 142 break;
143 } 143 }
144 case HAL_DEF_WOWLAN:
145 break;
144 default: 146 default:
145 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 147 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
146 "switch case not process\n"); 148 "switch case %#x not processed\n", variable);
147 break; 149 break;
148 } 150 }
149} 151}
@@ -366,7 +368,8 @@ void rtl8723e_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
366 break; 368 break;
367 default: 369 default:
368 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 370 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
369 "switch case not process\n"); 371 "switch case %#x not processed\n",
372 e_aci);
370 break; 373 break;
371 } 374 }
372 } 375 }
@@ -546,7 +549,7 @@ void rtl8723e_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
546 } 549 }
547 default: 550 default:
548 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 551 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
549 "switch case not process\n"); 552 "switch case %#x not processed\n", variable);
550 break; 553 break;
551 } 554 }
552} 555}
@@ -2225,7 +2228,7 @@ void rtl8723e_set_key(struct ieee80211_hw *hw, u32 key_index,
2225 break; 2228 break;
2226 default: 2229 default:
2227 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2230 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2228 "switch case not process\n"); 2231 "switch case %#x not processed\n", enc_algo);
2229 enc_algo = CAM_TKIP; 2232 enc_algo = CAM_TKIP;
2230 break; 2233 break;
2231 } 2234 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/led.c
index 13173351cbfd..c7be9342136c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/led.c
@@ -63,7 +63,7 @@ void rtl8723e_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
63 break; 63 break;
64 default: 64 default:
65 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 65 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
66 "switch case not process\n"); 66 "switch case %#x not processed\n", pled->ledpin);
67 break; 67 break;
68 } 68 }
69 pled->ledon = true; 69 pled->ledon = true;
@@ -105,7 +105,7 @@ void rtl8723e_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
105 break; 105 break;
106 default: 106 default:
107 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 107 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
108 "switch case not process\n"); 108 "switch case %#x not processed\n", pled->ledpin);
109 break; 109 break;
110 } 110 }
111 pled->ledon = false; 111 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
index 601b78efedfb..17b58cb32d55 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
@@ -1023,7 +1023,8 @@ static bool _rtl8723e_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
1023 break; 1023 break;
1024 default: 1024 default:
1025 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1025 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1026 "switch case not process\n"); 1026 "switch case %#x not processed\n",
1027 currentcmd->cmdid);
1027 break; 1028 break;
1028 } 1029 }
1029 1030
@@ -1499,7 +1500,7 @@ bool rtl8723e_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
1499 break; 1500 break;
1500 default: 1501 default:
1501 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1502 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1502 "switch case not process\n"); 1503 "switch case %#x not processed\n", iotype);
1503 break; 1504 break;
1504 } 1505 }
1505 } while (false); 1506 } while (false);
@@ -1536,7 +1537,8 @@ static void rtl8723e_phy_set_io(struct ieee80211_hw *hw)
1536 break; 1537 break;
1537 default: 1538 default:
1538 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1539 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1539 "switch case not process\n"); 1540 "switch case %#x not processed\n",
1541 rtlphy->current_io_type);
1540 break; 1542 break;
1541 } 1543 }
1542 rtlphy->set_io_inprogress = false; 1544 rtlphy->set_io_inprogress = false;
@@ -1682,7 +1684,7 @@ static bool _rtl8723e_phy_set_rf_power_state(struct ieee80211_hw *hw,
1682 break; 1684 break;
1683 default: 1685 default:
1684 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1686 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1685 "switch case not process\n"); 1687 "switch case %#x not processed\n", rfpwr_state);
1686 bresult = false; 1688 bresult = false;
1687 break; 1689 break;
1688 } 1690 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
index d5da0f3c1217..8c5c27ce8e05 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
@@ -122,7 +122,7 @@ static void _rtl8723be_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
122 break; 122 break;
123 default: 123 default:
124 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 124 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
125 "switch case not process\n"); 125 "switch case %#x not processed\n", boxnum);
126 break; 126 break;
127 } 127 }
128 128
@@ -195,7 +195,7 @@ static void _rtl8723be_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id,
195 break; 195 break;
196 default: 196 default:
197 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 197 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
198 "switch case not process\n"); 198 "switch case %#x not processed\n", cmd_len);
199 break; 199 break;
200 } 200 }
201 201
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 82e4476cab23..aba60c3145c5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -348,9 +348,11 @@ void rtl8723be_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
348 *((u64 *)(val)) = tsf; 348 *((u64 *)(val)) = tsf;
349 } 349 }
350 break; 350 break;
351 case HAL_DEF_WOWLAN:
352 break;
351 default: 353 default:
352 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 354 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
353 "switch case not process %x\n", variable); 355 "switch case %#x not processed\n", variable);
354 break; 356 break;
355 } 357 }
356} 358}
@@ -607,7 +609,8 @@ void rtl8723be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
607 break; 609 break;
608 default: 610 default:
609 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 611 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
610 "switch case not process\n"); 612 "switch case %#x not processed\n",
613 e_aci);
611 break; 614 break;
612 } 615 }
613 } 616 }
@@ -723,8 +726,7 @@ void rtl8723be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
723 break; 726 break;
724 default: 727 default:
725 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 728 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
726 "switch case not process %x\n", 729 "switch case %#x not processed\n", variable);
727 variable);
728 break; 730 break;
729 } 731 }
730} 732}
@@ -2565,7 +2567,7 @@ void rtl8723be_set_key(struct ieee80211_hw *hw, u32 key_index,
2565 break; 2567 break;
2566 default: 2568 default:
2567 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2569 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2568 "switch case not process\n"); 2570 "switch case %#x not processed\n", enc_algo);
2569 enc_algo = CAM_TKIP; 2571 enc_algo = CAM_TKIP;
2570 break; 2572 break;
2571 } 2573 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/led.c
index 4196efb723a2..497913eb3b37 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/led.c
@@ -58,7 +58,7 @@ void rtl8723be_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
58 break; 58 break;
59 default: 59 default:
60 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 60 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
61 "switch case not process\n"); 61 "switch case %#x not processed\n", pled->ledpin);
62 break; 62 break;
63 } 63 }
64 pled->ledon = true; 64 pled->ledon = true;
@@ -100,7 +100,7 @@ void rtl8723be_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
100 break; 100 break;
101 default: 101 default:
102 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 102 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
103 "switch case not process\n"); 103 "switch case %#x not processed\n", pled->ledpin);
104 break; 104 break;
105 } 105 }
106 pled->ledon = false; 106 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
index 285818df149b..3cc2232f25ca 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
@@ -837,7 +837,7 @@ bool rtl8723be_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
837 break; 837 break;
838 case RF90_PATH_D: 838 case RF90_PATH_D:
839 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 839 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
840 "switch case not process\n"); 840 "switch case %#x not processed\n", rfpath);
841 break; 841 break;
842 } 842 }
843 return true; 843 return true;
@@ -1507,7 +1507,8 @@ static bool _rtl8723be_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
1507 break; 1507 break;
1508 default: 1508 default:
1509 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1509 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1510 "switch case not process\n"); 1510 "switch case %#x not processed\n",
1511 currentcmd->cmdid);
1511 break; 1512 break;
1512 } 1513 }
1513 1514
@@ -2515,7 +2516,7 @@ bool rtl8723be_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
2515 break; 2516 break;
2516 default: 2517 default:
2517 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2518 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2518 "switch case not process\n"); 2519 "switch case %#x not processed\n", iotype);
2519 break; 2520 break;
2520 } 2521 }
2521 } while (false); 2522 } while (false);
@@ -2553,7 +2554,8 @@ static void rtl8723be_phy_set_io(struct ieee80211_hw *hw)
2553 break; 2554 break;
2554 default: 2555 default:
2555 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2556 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2556 "switch case not process\n"); 2557 "switch case %#x not processed\n",
2558 rtlphy->current_io_type);
2557 break; 2559 break;
2558 } 2560 }
2559 rtlphy->set_io_inprogress = false; 2561 rtlphy->set_io_inprogress = false;
@@ -2705,7 +2707,7 @@ static bool _rtl8723be_phy_set_rf_power_state(struct ieee80211_hw *hw,
2705 2707
2706 default: 2708 default:
2707 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 2709 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
2708 "switch case not process\n"); 2710 "switch case %#x not processed\n", rfpwr_state);
2709 bresult = false; 2711 bresult = false;
2710 break; 2712 break;
2711 } 2713 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
index a4fc70e8c9c0..b665446351a4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
@@ -392,7 +392,7 @@ static void _rtl8821ae_fill_h2c_command(struct ieee80211_hw *hw,
392 break; 392 break;
393 default: 393 default:
394 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 394 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
395 "switch case not process\n"); 395 "switch case %#x not processed\n", boxnum);
396 break; 396 break;
397 } 397 }
398 398
@@ -481,7 +481,7 @@ static void _rtl8821ae_fill_h2c_command(struct ieee80211_hw *hw,
481 break; 481 break;
482 default: 482 default:
483 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 483 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
484 "switch case not process\n"); 484 "switch case %#x not processed\n", cmd_len);
485 break; 485 break;
486 } 486 }
487 487
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 0cddf1ad0fff..1281ebe0c30a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -480,7 +480,7 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
480 break; 480 break;
481 default: 481 default:
482 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 482 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
483 "switch case not process %x\n", variable); 483 "switch case %#x not processed\n", variable);
484 break; 484 break;
485 } 485 }
486} 486}
@@ -671,7 +671,8 @@ void rtl8821ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
671 break; 671 break;
672 default: 672 default:
673 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 673 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
674 "switch case not process\n"); 674 "switch case %#x not processed\n",
675 e_aci);
675 break; 676 break;
676 } 677 }
677 } 678 }
@@ -800,7 +801,7 @@ void rtl8821ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
800 break; } 801 break; }
801 default: 802 default:
802 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 803 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
803 "switch case not process %x\n", variable); 804 "switch case %#x not processed\n", variable);
804 break; 805 break;
805 } 806 }
806} 807}
@@ -3934,7 +3935,7 @@ void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index,
3934 break; 3935 break;
3935 default: 3936 default:
3936 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 3937 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
3937 "switch case not process\n"); 3938 "switch case %#x not processed\n", enc_algo);
3938 enc_algo = CAM_TKIP; 3939 enc_algo = CAM_TKIP;
3939 break; 3940 break;
3940 } 3941 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/led.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/led.c
index ba1946a0280e..fcb3b28c6b8f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/led.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/led.c
@@ -60,7 +60,7 @@ void rtl8821ae_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
60 break; 60 break;
61 default: 61 default:
62 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 62 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
63 "switch case not process\n"); 63 "switch case %#x not processed\n", pled->ledpin);
64 break; 64 break;
65 } 65 }
66 pled->ledon = true; 66 pled->ledon = true;
@@ -133,7 +133,7 @@ void rtl8821ae_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
133 break; 133 break;
134 default: 134 default:
135 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 135 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
136 "switch case not process\n"); 136 "switch case %#x not processed\n", pled->ledpin);
137 break; 137 break;
138 } 138 }
139 pled->ledon = false; 139 pled->ledon = false;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
index a71bfe38e7e1..5dad402171c2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
@@ -2063,12 +2063,9 @@ bool rtl8812ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
2063 } 2063 }
2064 break; 2064 break;
2065 case RF90_PATH_C: 2065 case RF90_PATH_C:
2066 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2067 "switch case not process\n");
2068 break;
2069 case RF90_PATH_D: 2066 case RF90_PATH_D:
2070 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2067 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2071 "switch case not process\n"); 2068 "switch case %#x not processed\n", rfpath);
2072 break; 2069 break;
2073 } 2070 }
2074 return true; 2071 return true;
@@ -2133,16 +2130,10 @@ bool rtl8821ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
2133 break; 2130 break;
2134 2131
2135 case RF90_PATH_B: 2132 case RF90_PATH_B:
2136 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2137 "switch case not process\n");
2138 break;
2139 case RF90_PATH_C: 2133 case RF90_PATH_C:
2140 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2141 "switch case not process\n");
2142 break;
2143 case RF90_PATH_D: 2134 case RF90_PATH_D:
2144 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2135 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2145 "switch case not process\n"); 2136 "switch case %#x not processed\n", rfpath);
2146 break; 2137 break;
2147 } 2138 }
2148 return true; 2139 return true;
@@ -4670,7 +4661,7 @@ bool rtl8821ae_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
4670 break; 4661 break;
4671 default: 4662 default:
4672 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 4663 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
4673 "switch case not process\n"); 4664 "switch case %#x not processed\n", iotype);
4674 break; 4665 break;
4675 } 4666 }
4676 } while (false); 4667 } while (false);
@@ -4714,7 +4705,8 @@ static void rtl8821ae_phy_set_io(struct ieee80211_hw *hw)
4714 break; 4705 break;
4715 default: 4706 default:
4716 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 4707 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
4717 "switch case not process\n"); 4708 "switch case %#x not processed\n",
4709 rtlphy->current_io_type);
4718 break; 4710 break;
4719 } 4711 }
4720 rtlphy->set_io_inprogress = false; 4712 rtlphy->set_io_inprogress = false;
@@ -4820,7 +4812,7 @@ static bool _rtl8821ae_phy_set_rf_power_state(struct ieee80211_hw *hw,
4820 break; 4812 break;
4821 default: 4813 default:
4822 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 4814 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
4823 "switch case not process\n"); 4815 "switch case %#x not processed\n", rfpwr_state);
4824 bresult = false; 4816 bresult = false;
4825 break; 4817 break;
4826 } 4818 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index c5086c2229aa..595f7d5d091a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -394,110 +394,110 @@ enum io_type {
394}; 394};
395 395
396enum hw_variables { 396enum hw_variables {
397 HW_VAR_ETHER_ADDR, 397 HW_VAR_ETHER_ADDR = 0x0,
398 HW_VAR_MULTICAST_REG, 398 HW_VAR_MULTICAST_REG = 0x1,
399 HW_VAR_BASIC_RATE, 399 HW_VAR_BASIC_RATE = 0x2,
400 HW_VAR_BSSID, 400 HW_VAR_BSSID = 0x3,
401 HW_VAR_MEDIA_STATUS, 401 HW_VAR_MEDIA_STATUS= 0x4,
402 HW_VAR_SECURITY_CONF, 402 HW_VAR_SECURITY_CONF= 0x5,
403 HW_VAR_BEACON_INTERVAL, 403 HW_VAR_BEACON_INTERVAL = 0x6,
404 HW_VAR_ATIM_WINDOW, 404 HW_VAR_ATIM_WINDOW = 0x7,
405 HW_VAR_LISTEN_INTERVAL, 405 HW_VAR_LISTEN_INTERVAL = 0x8,
406 HW_VAR_CS_COUNTER, 406 HW_VAR_CS_COUNTER = 0x9,
407 HW_VAR_DEFAULTKEY0, 407 HW_VAR_DEFAULTKEY0 = 0xa,
408 HW_VAR_DEFAULTKEY1, 408 HW_VAR_DEFAULTKEY1 = 0xb,
409 HW_VAR_DEFAULTKEY2, 409 HW_VAR_DEFAULTKEY2 = 0xc,
410 HW_VAR_DEFAULTKEY3, 410 HW_VAR_DEFAULTKEY3 = 0xd,
411 HW_VAR_SIFS, 411 HW_VAR_SIFS = 0xe,
412 HW_VAR_R2T_SIFS, 412 HW_VAR_R2T_SIFS = 0xf,
413 HW_VAR_DIFS, 413 HW_VAR_DIFS = 0x10,
414 HW_VAR_EIFS, 414 HW_VAR_EIFS = 0x11,
415 HW_VAR_SLOT_TIME, 415 HW_VAR_SLOT_TIME = 0x12,
416 HW_VAR_ACK_PREAMBLE, 416 HW_VAR_ACK_PREAMBLE = 0x13,
417 HW_VAR_CW_CONFIG, 417 HW_VAR_CW_CONFIG = 0x14,
418 HW_VAR_CW_VALUES, 418 HW_VAR_CW_VALUES = 0x15,
419 HW_VAR_RATE_FALLBACK_CONTROL, 419 HW_VAR_RATE_FALLBACK_CONTROL= 0x16,
420 HW_VAR_CONTENTION_WINDOW, 420 HW_VAR_CONTENTION_WINDOW = 0x17,
421 HW_VAR_RETRY_COUNT, 421 HW_VAR_RETRY_COUNT = 0x18,
422 HW_VAR_TR_SWITCH, 422 HW_VAR_TR_SWITCH = 0x19,
423 HW_VAR_COMMAND, 423 HW_VAR_COMMAND = 0x1a,
424 HW_VAR_WPA_CONFIG, 424 HW_VAR_WPA_CONFIG = 0x1b,
425 HW_VAR_AMPDU_MIN_SPACE, 425 HW_VAR_AMPDU_MIN_SPACE = 0x1c,
426 HW_VAR_SHORTGI_DENSITY, 426 HW_VAR_SHORTGI_DENSITY = 0x1d,
427 HW_VAR_AMPDU_FACTOR, 427 HW_VAR_AMPDU_FACTOR = 0x1e,
428 HW_VAR_MCS_RATE_AVAILABLE, 428 HW_VAR_MCS_RATE_AVAILABLE = 0x1f,
429 HW_VAR_AC_PARAM, 429 HW_VAR_AC_PARAM = 0x20,
430 HW_VAR_ACM_CTRL, 430 HW_VAR_ACM_CTRL = 0x21,
431 HW_VAR_DIS_Req_Qsize, 431 HW_VAR_DIS_Req_Qsize = 0x22,
432 HW_VAR_CCX_CHNL_LOAD, 432 HW_VAR_CCX_CHNL_LOAD = 0x23,
433 HW_VAR_CCX_NOISE_HISTOGRAM, 433 HW_VAR_CCX_NOISE_HISTOGRAM = 0x24,
434 HW_VAR_CCX_CLM_NHM, 434 HW_VAR_CCX_CLM_NHM = 0x25,
435 HW_VAR_TxOPLimit, 435 HW_VAR_TxOPLimit = 0x26,
436 HW_VAR_TURBO_MODE, 436 HW_VAR_TURBO_MODE = 0x27,
437 HW_VAR_RF_STATE, 437 HW_VAR_RF_STATE = 0x28,
438 HW_VAR_RF_OFF_BY_HW, 438 HW_VAR_RF_OFF_BY_HW = 0x29,
439 HW_VAR_BUS_SPEED, 439 HW_VAR_BUS_SPEED = 0x2a,
440 HW_VAR_SET_DEV_POWER, 440 HW_VAR_SET_DEV_POWER = 0x2b,
441 441
442 HW_VAR_RCR, 442 HW_VAR_RCR = 0x2c,
443 HW_VAR_RATR_0, 443 HW_VAR_RATR_0 = 0x2d,
444 HW_VAR_RRSR, 444 HW_VAR_RRSR = 0x2e,
445 HW_VAR_CPU_RST, 445 HW_VAR_CPU_RST = 0x2f,
446 HW_VAR_CHECK_BSSID, 446 HW_VAR_CHECK_BSSID = 0x30,
447 HW_VAR_LBK_MODE, 447 HW_VAR_LBK_MODE = 0x31,
448 HW_VAR_AES_11N_FIX, 448 HW_VAR_AES_11N_FIX = 0x32,
449 HW_VAR_USB_RX_AGGR, 449 HW_VAR_USB_RX_AGGR = 0x33,
450 HW_VAR_USER_CONTROL_TURBO_MODE, 450 HW_VAR_USER_CONTROL_TURBO_MODE = 0x34,
451 HW_VAR_RETRY_LIMIT, 451 HW_VAR_RETRY_LIMIT = 0x35,
452 HW_VAR_INIT_TX_RATE, 452 HW_VAR_INIT_TX_RATE = 0x36,
453 HW_VAR_TX_RATE_REG, 453 HW_VAR_TX_RATE_REG = 0x37,
454 HW_VAR_EFUSE_USAGE, 454 HW_VAR_EFUSE_USAGE = 0x38,
455 HW_VAR_EFUSE_BYTES, 455 HW_VAR_EFUSE_BYTES = 0x39,
456 HW_VAR_AUTOLOAD_STATUS, 456 HW_VAR_AUTOLOAD_STATUS = 0x3a,
457 HW_VAR_RF_2R_DISABLE, 457 HW_VAR_RF_2R_DISABLE = 0x3b,
458 HW_VAR_SET_RPWM, 458 HW_VAR_SET_RPWM = 0x3c,
459 HW_VAR_H2C_FW_PWRMODE, 459 HW_VAR_H2C_FW_PWRMODE = 0x3d,
460 HW_VAR_H2C_FW_JOINBSSRPT, 460 HW_VAR_H2C_FW_JOINBSSRPT = 0x3e,
461 HW_VAR_H2C_FW_MEDIASTATUSRPT, 461 HW_VAR_H2C_FW_MEDIASTATUSRPT = 0x3f,
462 HW_VAR_H2C_FW_P2P_PS_OFFLOAD, 462 HW_VAR_H2C_FW_P2P_PS_OFFLOAD = 0x40,
463 HW_VAR_FW_PSMODE_STATUS, 463 HW_VAR_FW_PSMODE_STATUS = 0x41,
464 HW_VAR_INIT_RTS_RATE, 464 HW_VAR_INIT_RTS_RATE = 0x42,
465 HW_VAR_RESUME_CLK_ON, 465 HW_VAR_RESUME_CLK_ON = 0x43,
466 HW_VAR_FW_LPS_ACTION, 466 HW_VAR_FW_LPS_ACTION = 0x44,
467 HW_VAR_1X1_RECV_COMBINE, 467 HW_VAR_1X1_RECV_COMBINE = 0x45,
468 HW_VAR_STOP_SEND_BEACON, 468 HW_VAR_STOP_SEND_BEACON = 0x46,
469 HW_VAR_TSF_TIMER, 469 HW_VAR_TSF_TIMER = 0x47,
470 HW_VAR_IO_CMD, 470 HW_VAR_IO_CMD = 0x48,
471 471
472 HW_VAR_RF_RECOVERY, 472 HW_VAR_RF_RECOVERY = 0x49,
473 HW_VAR_H2C_FW_UPDATE_GTK, 473 HW_VAR_H2C_FW_UPDATE_GTK = 0x4a,
474 HW_VAR_WF_MASK, 474 HW_VAR_WF_MASK = 0x4b,
475 HW_VAR_WF_CRC, 475 HW_VAR_WF_CRC = 0x4c,
476 HW_VAR_WF_IS_MAC_ADDR, 476 HW_VAR_WF_IS_MAC_ADDR = 0x4d,
477 HW_VAR_H2C_FW_OFFLOAD, 477 HW_VAR_H2C_FW_OFFLOAD = 0x4e,
478 HW_VAR_RESET_WFCRC, 478 HW_VAR_RESET_WFCRC = 0x4f,
479 479
480 HW_VAR_HANDLE_FW_C2H, 480 HW_VAR_HANDLE_FW_C2H = 0x50,
481 HW_VAR_DL_FW_RSVD_PAGE, 481 HW_VAR_DL_FW_RSVD_PAGE = 0x51,
482 HW_VAR_AID, 482 HW_VAR_AID = 0x52,
483 HW_VAR_HW_SEQ_ENABLE, 483 HW_VAR_HW_SEQ_ENABLE = 0x53,
484 HW_VAR_CORRECT_TSF, 484 HW_VAR_CORRECT_TSF = 0x54,
485 HW_VAR_BCN_VALID, 485 HW_VAR_BCN_VALID = 0x55,
486 HW_VAR_FWLPS_RF_ON, 486 HW_VAR_FWLPS_RF_ON = 0x56,
487 HW_VAR_DUAL_TSF_RST, 487 HW_VAR_DUAL_TSF_RST = 0x57,
488 HW_VAR_SWITCH_EPHY_WoWLAN, 488 HW_VAR_SWITCH_EPHY_WoWLAN = 0x58,
489 HW_VAR_INT_MIGRATION, 489 HW_VAR_INT_MIGRATION = 0x59,
490 HW_VAR_INT_AC, 490 HW_VAR_INT_AC = 0x5a,
491 HW_VAR_RF_TIMING, 491 HW_VAR_RF_TIMING = 0x5b,
492 492
493 HAL_DEF_WOWLAN, 493 HAL_DEF_WOWLAN = 0x5c,
494 HW_VAR_MRC, 494 HW_VAR_MRC = 0x5d,
495 HW_VAR_KEEP_ALIVE, 495 HW_VAR_KEEP_ALIVE = 0x5e,
496 HW_VAR_NAV_UPPER, 496 HW_VAR_NAV_UPPER = 0x5f,
497 497
498 HW_VAR_MGT_FILTER, 498 HW_VAR_MGT_FILTER = 0x60,
499 HW_VAR_CTRL_FILTER, 499 HW_VAR_CTRL_FILTER = 0x61,
500 HW_VAR_DATA_FILTER, 500 HW_VAR_DATA_FILTER = 0x62,
501}; 501};
502 502
503enum rt_media_status { 503enum rt_media_status {
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index 00a04dfc03d1..06d6943b257c 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -1397,25 +1397,24 @@ out:
1397 return ret; 1397 return ret;
1398} 1398}
1399 1399
1400#define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
1401
1402static int wl18xx_load_conf_file(struct device *dev, struct wlcore_conf *conf, 1400static int wl18xx_load_conf_file(struct device *dev, struct wlcore_conf *conf,
1403 struct wl18xx_priv_conf *priv_conf) 1401 struct wl18xx_priv_conf *priv_conf,
1402 const char *file)
1404{ 1403{
1405 struct wlcore_conf_file *conf_file; 1404 struct wlcore_conf_file *conf_file;
1406 const struct firmware *fw; 1405 const struct firmware *fw;
1407 int ret; 1406 int ret;
1408 1407
1409 ret = request_firmware(&fw, WL18XX_CONF_FILE_NAME, dev); 1408 ret = request_firmware(&fw, file, dev);
1410 if (ret < 0) { 1409 if (ret < 0) {
1411 wl1271_error("could not get configuration binary %s: %d", 1410 wl1271_error("could not get configuration binary %s: %d",
1412 WL18XX_CONF_FILE_NAME, ret); 1411 file, ret);
1413 return ret; 1412 return ret;
1414 } 1413 }
1415 1414
1416 if (fw->size != WL18XX_CONF_SIZE) { 1415 if (fw->size != WL18XX_CONF_SIZE) {
1417 wl1271_error("configuration binary file size is wrong, expected %zu got %zu", 1416 wl1271_error("%s configuration binary size is wrong, expected %zu got %zu",
1418 WL18XX_CONF_SIZE, fw->size); 1417 file, WL18XX_CONF_SIZE, fw->size);
1419 ret = -EINVAL; 1418 ret = -EINVAL;
1420 goto out_release; 1419 goto out_release;
1421 } 1420 }
@@ -1448,9 +1447,12 @@ out_release:
1448 1447
1449static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev) 1448static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
1450{ 1449{
1450 struct platform_device *pdev = wl->pdev;
1451 struct wlcore_platdev_data *pdata = dev_get_platdata(&pdev->dev);
1451 struct wl18xx_priv *priv = wl->priv; 1452 struct wl18xx_priv *priv = wl->priv;
1452 1453
1453 if (wl18xx_load_conf_file(dev, &wl->conf, &priv->conf) < 0) { 1454 if (wl18xx_load_conf_file(dev, &wl->conf, &priv->conf,
1455 pdata->family->cfg_name) < 0) {
1454 wl1271_warning("falling back to default config"); 1456 wl1271_warning("falling back to default config");
1455 1457
1456 /* apply driver default configuration */ 1458 /* apply driver default configuration */
@@ -2141,4 +2143,3 @@ MODULE_PARM_DESC(num_rx_desc_param,
2141MODULE_LICENSE("GPL v2"); 2143MODULE_LICENSE("GPL v2");
2142MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>"); 2144MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
2143MODULE_FIRMWARE(WL18XX_FW_NAME); 2145MODULE_FIRMWARE(WL18XX_FW_NAME);
2144MODULE_FIRMWARE(WL18XX_CONF_FILE_NAME);
diff --git a/drivers/net/wireless/ti/wlcore/boot.c b/drivers/net/wireless/ti/wlcore/boot.c
index f75d30444117..f00509ea8aca 100644
--- a/drivers/net/wireless/ti/wlcore/boot.c
+++ b/drivers/net/wireless/ti/wlcore/boot.c
@@ -282,6 +282,9 @@ EXPORT_SYMBOL_GPL(wlcore_boot_upload_firmware);
282 282
283int wlcore_boot_upload_nvs(struct wl1271 *wl) 283int wlcore_boot_upload_nvs(struct wl1271 *wl)
284{ 284{
285 struct platform_device *pdev = wl->pdev;
286 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&pdev->dev);
287 const char *nvs_name = "unknown";
285 size_t nvs_len, burst_len; 288 size_t nvs_len, burst_len;
286 int i; 289 int i;
287 u32 dest_addr, val; 290 u32 dest_addr, val;
@@ -293,6 +296,9 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)
293 return -ENODEV; 296 return -ENODEV;
294 } 297 }
295 298
299 if (pdev_data && pdev_data->family)
300 nvs_name = pdev_data->family->nvs_name;
301
296 if (wl->quirks & WLCORE_QUIRK_LEGACY_NVS) { 302 if (wl->quirks & WLCORE_QUIRK_LEGACY_NVS) {
297 struct wl1271_nvs_file *nvs = 303 struct wl1271_nvs_file *nvs =
298 (struct wl1271_nvs_file *)wl->nvs; 304 (struct wl1271_nvs_file *)wl->nvs;
@@ -310,8 +316,9 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)
310 if (wl->nvs_len != sizeof(struct wl1271_nvs_file) && 316 if (wl->nvs_len != sizeof(struct wl1271_nvs_file) &&
311 (wl->nvs_len != WL1271_INI_LEGACY_NVS_FILE_SIZE || 317 (wl->nvs_len != WL1271_INI_LEGACY_NVS_FILE_SIZE ||
312 wl->enable_11a)) { 318 wl->enable_11a)) {
313 wl1271_error("nvs size is not as expected: %zu != %zu", 319 wl1271_error("%s size is not as expected: %zu != %zu",
314 wl->nvs_len, sizeof(struct wl1271_nvs_file)); 320 nvs_name, wl->nvs_len,
321 sizeof(struct wl1271_nvs_file));
315 kfree(wl->nvs); 322 kfree(wl->nvs);
316 wl->nvs = NULL; 323 wl->nvs = NULL;
317 wl->nvs_len = 0; 324 wl->nvs_len = 0;
@@ -328,8 +335,8 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)
328 if (nvs->general_params.dual_mode_select) 335 if (nvs->general_params.dual_mode_select)
329 wl->enable_11a = true; 336 wl->enable_11a = true;
330 } else { 337 } else {
331 wl1271_error("nvs size is not as expected: %zu != %zu", 338 wl1271_error("%s size is not as expected: %zu != %zu",
332 wl->nvs_len, 339 nvs_name, wl->nvs_len,
333 sizeof(struct wl128x_nvs_file)); 340 sizeof(struct wl128x_nvs_file));
334 kfree(wl->nvs); 341 kfree(wl->nvs);
335 wl->nvs = NULL; 342 wl->nvs = NULL;
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index ef6c15b952cc..471521a0db7b 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -6413,9 +6413,12 @@ static void wlcore_nvs_cb(const struct firmware *fw, void *context)
6413 goto out; 6413 goto out;
6414 } 6414 }
6415 wl->nvs_len = fw->size; 6415 wl->nvs_len = fw->size;
6416 } else { 6416 } else if (pdev_data->family->nvs_name) {
6417 wl1271_debug(DEBUG_BOOT, "Could not get nvs file %s", 6417 wl1271_debug(DEBUG_BOOT, "Could not get nvs file %s",
6418 WL12XX_NVS_NAME); 6418 pdev_data->family->nvs_name);
6419 wl->nvs = NULL;
6420 wl->nvs_len = 0;
6421 } else {
6419 wl->nvs = NULL; 6422 wl->nvs = NULL;
6420 wl->nvs_len = 0; 6423 wl->nvs_len = 0;
6421 } 6424 }
@@ -6510,21 +6513,29 @@ out:
6510 6513
6511int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev) 6514int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
6512{ 6515{
6513 int ret; 6516 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&pdev->dev);
6517 const char *nvs_name;
6518 int ret = 0;
6514 6519
6515 if (!wl->ops || !wl->ptable) 6520 if (!wl->ops || !wl->ptable || !pdev_data)
6516 return -EINVAL; 6521 return -EINVAL;
6517 6522
6518 wl->dev = &pdev->dev; 6523 wl->dev = &pdev->dev;
6519 wl->pdev = pdev; 6524 wl->pdev = pdev;
6520 platform_set_drvdata(pdev, wl); 6525 platform_set_drvdata(pdev, wl);
6521 6526
6522 ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, 6527 if (pdev_data->family && pdev_data->family->nvs_name) {
6523 WL12XX_NVS_NAME, &pdev->dev, GFP_KERNEL, 6528 nvs_name = pdev_data->family->nvs_name;
6524 wl, wlcore_nvs_cb); 6529 ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
6525 if (ret < 0) { 6530 nvs_name, &pdev->dev, GFP_KERNEL,
6526 wl1271_error("request_firmware_nowait failed: %d", ret); 6531 wl, wlcore_nvs_cb);
6527 complete_all(&wl->nvs_loading_complete); 6532 if (ret < 0) {
6533 wl1271_error("request_firmware_nowait failed for %s: %d",
6534 nvs_name, ret);
6535 complete_all(&wl->nvs_loading_complete);
6536 }
6537 } else {
6538 wlcore_nvs_cb(NULL, wl);
6528 } 6539 }
6529 6540
6530 return ret; 6541 return ret;
@@ -6533,9 +6544,11 @@ EXPORT_SYMBOL_GPL(wlcore_probe);
6533 6544
6534int wlcore_remove(struct platform_device *pdev) 6545int wlcore_remove(struct platform_device *pdev)
6535{ 6546{
6547 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&pdev->dev);
6536 struct wl1271 *wl = platform_get_drvdata(pdev); 6548 struct wl1271 *wl = platform_get_drvdata(pdev);
6537 6549
6538 wait_for_completion(&wl->nvs_loading_complete); 6550 if (pdev_data->family && pdev_data->family->nvs_name)
6551 wait_for_completion(&wl->nvs_loading_complete);
6539 if (!wl->initialized) 6552 if (!wl->initialized)
6540 return 0; 6553 return 0;
6541 6554
@@ -6572,4 +6585,3 @@ MODULE_PARM_DESC(no_recovery, "Prevent HW recovery. FW will remain stuck.");
6572MODULE_LICENSE("GPL"); 6585MODULE_LICENSE("GPL");
6573MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>"); 6586MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
6574MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>"); 6587MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
6575MODULE_FIRMWARE(WL12XX_NVS_NAME);
diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
index 5839acbbc782..a6e94b1a12cb 100644
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -216,17 +216,33 @@ static struct wl1271_if_operations sdio_ops = {
216}; 216};
217 217
218#ifdef CONFIG_OF 218#ifdef CONFIG_OF
219
220static const struct wilink_family_data wl127x_data = {
221 .name = "wl127x",
222 .nvs_name = "ti-connectivity/wl127x-nvs.bin",
223};
224
225static const struct wilink_family_data wl128x_data = {
226 .name = "wl128x",
227 .nvs_name = "ti-connectivity/wl128x-nvs.bin",
228};
229
230static const struct wilink_family_data wl18xx_data = {
231 .name = "wl18xx",
232 .cfg_name = "ti-connectivity/wl18xx-conf.bin",
233};
234
219static const struct of_device_id wlcore_sdio_of_match_table[] = { 235static const struct of_device_id wlcore_sdio_of_match_table[] = {
220 { .compatible = "ti,wl1271" }, 236 { .compatible = "ti,wl1271", .data = &wl127x_data },
221 { .compatible = "ti,wl1273" }, 237 { .compatible = "ti,wl1273", .data = &wl127x_data },
222 { .compatible = "ti,wl1281" }, 238 { .compatible = "ti,wl1281", .data = &wl128x_data },
223 { .compatible = "ti,wl1283" }, 239 { .compatible = "ti,wl1283", .data = &wl128x_data },
224 { .compatible = "ti,wl1801" }, 240 { .compatible = "ti,wl1801", .data = &wl18xx_data },
225 { .compatible = "ti,wl1805" }, 241 { .compatible = "ti,wl1805", .data = &wl18xx_data },
226 { .compatible = "ti,wl1807" }, 242 { .compatible = "ti,wl1807", .data = &wl18xx_data },
227 { .compatible = "ti,wl1831" }, 243 { .compatible = "ti,wl1831", .data = &wl18xx_data },
228 { .compatible = "ti,wl1835" }, 244 { .compatible = "ti,wl1835", .data = &wl18xx_data },
229 { .compatible = "ti,wl1837" }, 245 { .compatible = "ti,wl1837", .data = &wl18xx_data },
230 { } 246 { }
231}; 247};
232 248
@@ -234,9 +250,13 @@ static int wlcore_probe_of(struct device *dev, int *irq,
234 struct wlcore_platdev_data *pdev_data) 250 struct wlcore_platdev_data *pdev_data)
235{ 251{
236 struct device_node *np = dev->of_node; 252 struct device_node *np = dev->of_node;
253 const struct of_device_id *of_id;
254
255 of_id = of_match_node(wlcore_sdio_of_match_table, np);
256 if (!of_id)
257 return -ENODEV;
237 258
238 if (!np || !of_match_node(wlcore_sdio_of_match_table, np)) 259 pdev_data->family = of_id->data;
239 return -ENODATA;
240 260
241 *irq = irq_of_parse_and_map(np, 0); 261 *irq = irq_of_parse_and_map(np, 0);
242 if (!*irq) { 262 if (!*irq) {
@@ -263,7 +283,7 @@ static int wlcore_probe_of(struct device *dev, int *irq,
263static int wl1271_probe(struct sdio_func *func, 283static int wl1271_probe(struct sdio_func *func,
264 const struct sdio_device_id *id) 284 const struct sdio_device_id *id)
265{ 285{
266 struct wlcore_platdev_data pdev_data; 286 struct wlcore_platdev_data *pdev_data;
267 struct wl12xx_sdio_glue *glue; 287 struct wl12xx_sdio_glue *glue;
268 struct resource res[1]; 288 struct resource res[1];
269 mmc_pm_flag_t mmcflags; 289 mmc_pm_flag_t mmcflags;
@@ -275,14 +295,15 @@ static int wl1271_probe(struct sdio_func *func,
275 if (func->num != 0x02) 295 if (func->num != 0x02)
276 return -ENODEV; 296 return -ENODEV;
277 297
278 memset(&pdev_data, 0x00, sizeof(pdev_data)); 298 pdev_data = devm_kzalloc(&func->dev, sizeof(*pdev_data), GFP_KERNEL);
279 pdev_data.if_ops = &sdio_ops; 299 if (!pdev_data)
300 return -ENOMEM;
280 301
281 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 302 pdev_data->if_ops = &sdio_ops;
282 if (!glue) { 303
283 dev_err(&func->dev, "can't allocate glue\n"); 304 glue = devm_kzalloc(&func->dev, sizeof(*glue), GFP_KERNEL);
284 goto out; 305 if (!glue)
285 } 306 return -ENOMEM;
286 307
287 glue->dev = &func->dev; 308 glue->dev = &func->dev;
288 309
@@ -292,16 +313,16 @@ static int wl1271_probe(struct sdio_func *func,
292 /* Use block mode for transferring over one block size of data */ 313 /* Use block mode for transferring over one block size of data */
293 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; 314 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
294 315
295 ret = wlcore_probe_of(&func->dev, &irq, &pdev_data); 316 ret = wlcore_probe_of(&func->dev, &irq, pdev_data);
296 if (ret) 317 if (ret)
297 goto out_free_glue; 318 goto out;
298 319
299 /* if sdio can keep power while host is suspended, enable wow */ 320 /* if sdio can keep power while host is suspended, enable wow */
300 mmcflags = sdio_get_host_pm_caps(func); 321 mmcflags = sdio_get_host_pm_caps(func);
301 dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); 322 dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags);
302 323
303 if (mmcflags & MMC_PM_KEEP_POWER) 324 if (mmcflags & MMC_PM_KEEP_POWER)
304 pdev_data.pwr_in_suspend = true; 325 pdev_data->pwr_in_suspend = true;
305 326
306 sdio_set_drvdata(func, glue); 327 sdio_set_drvdata(func, glue);
307 328
@@ -323,7 +344,7 @@ static int wl1271_probe(struct sdio_func *func,
323 if (!glue->core) { 344 if (!glue->core) {
324 dev_err(glue->dev, "can't allocate platform_device"); 345 dev_err(glue->dev, "can't allocate platform_device");
325 ret = -ENOMEM; 346 ret = -ENOMEM;
326 goto out_free_glue; 347 goto out;
327 } 348 }
328 349
329 glue->core->dev.parent = &func->dev; 350 glue->core->dev.parent = &func->dev;
@@ -341,8 +362,8 @@ static int wl1271_probe(struct sdio_func *func,
341 goto out_dev_put; 362 goto out_dev_put;
342 } 363 }
343 364
344 ret = platform_device_add_data(glue->core, &pdev_data, 365 ret = platform_device_add_data(glue->core, pdev_data,
345 sizeof(pdev_data)); 366 sizeof(*pdev_data));
346 if (ret) { 367 if (ret) {
347 dev_err(glue->dev, "can't add platform data\n"); 368 dev_err(glue->dev, "can't add platform data\n");
348 goto out_dev_put; 369 goto out_dev_put;
@@ -358,9 +379,6 @@ static int wl1271_probe(struct sdio_func *func,
358out_dev_put: 379out_dev_put:
359 platform_device_put(glue->core); 380 platform_device_put(glue->core);
360 381
361out_free_glue:
362 kfree(glue);
363
364out: 382out:
365 return ret; 383 return ret;
366} 384}
diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c
index 0ed526e4c0df..f949ad2bd898 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -79,19 +79,19 @@
79#define WSPI_MAX_NUM_OF_CHUNKS \ 79#define WSPI_MAX_NUM_OF_CHUNKS \
80 ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1) 80 ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1)
81 81
82 82static const struct wilink_family_data wl127x_data = {
83struct wilink_familiy_data { 83 .name = "wl127x",
84 char name[8]; 84 .nvs_name = "ti-connectivity/wl127x-nvs.bin",
85}; 85};
86 86
87static const struct wilink_familiy_data *wilink_data; 87static const struct wilink_family_data wl128x_data = {
88 88 .name = "wl128x",
89static const struct wilink_familiy_data wl18xx_data = { 89 .nvs_name = "ti-connectivity/wl128x-nvs.bin",
90 .name = "wl18xx",
91}; 90};
92 91
93static const struct wilink_familiy_data wl12xx_data = { 92static const struct wilink_family_data wl18xx_data = {
94 .name = "wl12xx", 93 .name = "wl18xx",
94 .cfg_name = "ti-connectivity/wl18xx-conf.bin",
95}; 95};
96 96
97struct wl12xx_spi_glue { 97struct wl12xx_spi_glue {
@@ -429,10 +429,10 @@ static struct wl1271_if_operations spi_ops = {
429}; 429};
430 430
431static const struct of_device_id wlcore_spi_of_match_table[] = { 431static const struct of_device_id wlcore_spi_of_match_table[] = {
432 { .compatible = "ti,wl1271", .data = &wl12xx_data}, 432 { .compatible = "ti,wl1271", .data = &wl127x_data},
433 { .compatible = "ti,wl1273", .data = &wl12xx_data}, 433 { .compatible = "ti,wl1273", .data = &wl127x_data},
434 { .compatible = "ti,wl1281", .data = &wl12xx_data}, 434 { .compatible = "ti,wl1281", .data = &wl128x_data},
435 { .compatible = "ti,wl1283", .data = &wl12xx_data}, 435 { .compatible = "ti,wl1283", .data = &wl128x_data},
436 { .compatible = "ti,wl1801", .data = &wl18xx_data}, 436 { .compatible = "ti,wl1801", .data = &wl18xx_data},
437 { .compatible = "ti,wl1805", .data = &wl18xx_data}, 437 { .compatible = "ti,wl1805", .data = &wl18xx_data},
438 { .compatible = "ti,wl1807", .data = &wl18xx_data}, 438 { .compatible = "ti,wl1807", .data = &wl18xx_data},
@@ -460,9 +460,9 @@ static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue,
460 if (!of_id) 460 if (!of_id)
461 return -ENODEV; 461 return -ENODEV;
462 462
463 wilink_data = of_id->data; 463 pdev_data->family = of_id->data;
464 dev_info(&spi->dev, "selected chip familiy is %s\n", 464 dev_info(&spi->dev, "selected chip family is %s\n",
465 wilink_data->name); 465 pdev_data->family->name);
466 466
467 if (of_find_property(dt_node, "clock-xtal", NULL)) 467 if (of_find_property(dt_node, "clock-xtal", NULL))
468 pdev_data->ref_clock_xtal = true; 468 pdev_data->ref_clock_xtal = true;
@@ -479,13 +479,15 @@ static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue,
479static int wl1271_probe(struct spi_device *spi) 479static int wl1271_probe(struct spi_device *spi)
480{ 480{
481 struct wl12xx_spi_glue *glue; 481 struct wl12xx_spi_glue *glue;
482 struct wlcore_platdev_data pdev_data; 482 struct wlcore_platdev_data *pdev_data;
483 struct resource res[1]; 483 struct resource res[1];
484 int ret; 484 int ret;
485 485
486 memset(&pdev_data, 0x00, sizeof(pdev_data)); 486 pdev_data = devm_kzalloc(&spi->dev, sizeof(*pdev_data), GFP_KERNEL);
487 if (!pdev_data)
488 return -ENOMEM;
487 489
488 pdev_data.if_ops = &spi_ops; 490 pdev_data->if_ops = &spi_ops;
489 491
490 glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL); 492 glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL);
491 if (!glue) { 493 if (!glue) {
@@ -509,7 +511,7 @@ static int wl1271_probe(struct spi_device *spi)
509 return PTR_ERR(glue->reg); 511 return PTR_ERR(glue->reg);
510 } 512 }
511 513
512 ret = wlcore_probe_of(spi, glue, &pdev_data); 514 ret = wlcore_probe_of(spi, glue, pdev_data);
513 if (ret) { 515 if (ret) {
514 dev_err(glue->dev, 516 dev_err(glue->dev,
515 "can't get device tree parameters (%d)\n", ret); 517 "can't get device tree parameters (%d)\n", ret);
@@ -522,7 +524,7 @@ static int wl1271_probe(struct spi_device *spi)
522 return ret; 524 return ret;
523 } 525 }
524 526
525 glue->core = platform_device_alloc(wilink_data->name, 527 glue->core = platform_device_alloc(pdev_data->family->name,
526 PLATFORM_DEVID_AUTO); 528 PLATFORM_DEVID_AUTO);
527 if (!glue->core) { 529 if (!glue->core) {
528 dev_err(glue->dev, "can't allocate platform_device\n"); 530 dev_err(glue->dev, "can't allocate platform_device\n");
@@ -543,8 +545,8 @@ static int wl1271_probe(struct spi_device *spi)
543 goto out_dev_put; 545 goto out_dev_put;
544 } 546 }
545 547
546 ret = platform_device_add_data(glue->core, &pdev_data, 548 ret = platform_device_add_data(glue->core, pdev_data,
547 sizeof(pdev_data)); 549 sizeof(*pdev_data));
548 if (ret) { 550 if (ret) {
549 dev_err(glue->dev, "can't add platform data\n"); 551 dev_err(glue->dev, "can't add platform data\n");
550 goto out_dev_put; 552 goto out_dev_put;
diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h
index 0277ae508b8a..e840985385fc 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore_i.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h
@@ -35,12 +35,11 @@
35#include "conf.h" 35#include "conf.h"
36#include "ini.h" 36#include "ini.h"
37 37
38/* 38struct wilink_family_data {
39 * wl127x and wl128x are using the same NVS file name. However, the 39 const char *name;
40 * ini parameters between them are different. The driver validates 40 const char *nvs_name; /* wl12xx nvs file */
41 * the correct NVS size in wl1271_boot_upload_nvs(). 41 const char *cfg_name; /* wl18xx cfg file */
42 */ 42};
43#define WL12XX_NVS_NAME "ti-connectivity/wl1271-nvs.bin"
44 43
45#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff)) 44#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
46#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff)) 45#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
@@ -208,6 +207,7 @@ struct wl1271_if_operations {
208 207
209struct wlcore_platdev_data { 208struct wlcore_platdev_data {
210 struct wl1271_if_operations *if_ops; 209 struct wl1271_if_operations *if_ops;
210 const struct wilink_family_data *family;
211 211
212 bool ref_clock_xtal; /* specify whether the clock is XTAL or not */ 212 bool ref_clock_xtal; /* specify whether the clock is XTAL or not */
213 u32 ref_clock_freq; /* in Hertz */ 213 u32 ref_clock_freq; /* in Hertz */