summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-02-06 12:36:36 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-06 12:36:36 -0500
commit5661f29ade245afe85c14f642e5043737f53015f (patch)
tree8d4bbc9063c7fcd106d0e5b0c81627790fc0657d
parentbfbae2eafe059cd4f222aee426da7d870e3cd33c (diff)
parent030b43671ae88f827a415ad35700705ffc10d10d (diff)
Merge tag 'wireless-drivers-next-for-davem-2019-02-06' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: ==================== wireless-drivers-next patches for 5.1 First set of patches for 5.1. Lots of new features in various drivers but nothing really special standing out. Major changes: brcmfmac * DMI nvram filename quirk for PoV TAB-P1006W-232 tablet rsi * support for hardware scan offload iwlwifi * support for Target Wakeup Time (TWT) -- a feature that allows the AP to specify when individual stations can access the medium * support for mac80211 AMSDU handling * some new PCI IDs * relicense the pcie submodule to dual GPL/BSD * reworked the TOF/CSI (channel estimation matrix) implementation * Some product name updates in the human-readable strings mt76 * energy detect regulatory compliance fixes * preparation for MT7603 support * channel switch announcement support mwifiex * support for sd8977 chipset qtnfmac * support for 4addr mode * convert to SPDX license identifiers ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/bcma/bcma_private.h9
-rw-r--r--drivers/bcma/driver_gpio.c2
-rw-r--r--drivers/bcma/host_pci.c2
-rw-r--r--drivers/bcma/host_soc.c4
-rw-r--r--drivers/bcma/main.c45
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.h2
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c2
-rw-r--r--drivers/net/wireless/broadcom/b43/debugfs.c36
-rw-r--r--drivers/net/wireless/broadcom/b43legacy/debugfs.c35
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile4
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c15
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c5
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c6
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile6
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c26
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c13
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile4
-rw-r--r--drivers/net/wireless/intel/iwlegacy/3945-mac.c5
-rw-r--r--drivers/net/wireless/intel/iwlegacy/4965-mac.c5
-rw-r--r--drivers/net/wireless/intel/iwlegacy/common.h6
-rw-r--r--drivers/net/wireless/intel/iwlegacy/debug.c34
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/22000.c74
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/9000.c139
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/Makefile2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c23
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/main.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/tt.c5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/commands.h23
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/d3.h10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h55
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/debug.h33
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/location.h711
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h51
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/rx.h11
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/stats.h15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h19
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h34
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/tof.h393
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/dbg.c212
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/dbg.h22
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/error-dump.h11
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/file.h12
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/runtime.h3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h17
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-csr.h1
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-drv.c27
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-io.c41
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-io.h38
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-modparams.h18
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-prph.h4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/Makefile3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/d3.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c813
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c91
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c200
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c249
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h203
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/nvm.c15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/ops.c116
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c24
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c21
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rs.c26
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rx.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c104
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sf.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c377
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.h4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tdls.c33
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/time-event.c5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tof.c305
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tof.h89
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tx.c161
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/utils.c37
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c266
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/internal.h46
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/rx.c78
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/trans.c45
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c14
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx.c47
-rw-r--r--drivers/net/wireless/marvell/libertas/debugfs.c6
-rw-r--r--drivers/net/wireless/marvell/libertas/mesh.c5
-rw-r--r--drivers/net/wireless/marvell/libertas_tf/main.c2
-rw-r--r--drivers/net/wireless/marvell/mwifiex/Kconfig2
-rw-r--r--drivers/net/wireless/marvell/mwifiex/debugfs.c5
-rw-r--r--drivers/net/wireless/marvell/mwifiex/sdio.c5
-rw-r--r--drivers/net/wireless/marvell/mwifiex/sdio.h70
-rw-r--r--drivers/net/wireless/mediatek/mt76/dma.c31
-rw-r--r--drivers/net/wireless/mediatek/mt76/mac80211.c68
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76.h23
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/pci.c11
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/phy.c6
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/usb.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02.h22
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c6
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_mac.c222
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_mac.h12
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c142
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_phy.c47
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_phy.h1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_regs.h38
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c3
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_util.c89
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/init.c1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/mcu.h23
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c58
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c4
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/phy.c4
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/tx.c17
-rw-r--r--drivers/net/wireless/mediatek/mt76/usb.c20
-rw-r--r--drivers/net/wireless/mediatek/mt76/util.c42
-rw-r--r--drivers/net/wireless/mediatek/mt7601u/dma.c6
-rw-r--r--drivers/net/wireless/mediatek/mt7601u/eeprom.h2
-rw-r--r--drivers/net/wireless/quantenna/Makefile1
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/bus.h19
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/cfg80211.c43
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/cfg80211.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.c63
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.h22
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/core.c21
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/core.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/debug.c31
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/debug.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/event.c96
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/event.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c6
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/qlink.h27
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/qlink_util.c16
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/qlink_util.h28
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/qtn_hw_ids.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/shm_ipc.c17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/shm_ipc.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/shm_ipc_defs.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/trans.c17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/trans.h17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/util.c17
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/util.h17
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt2800lib.c2
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt2x00debug.c27
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt61pci.c93
-rw-r--r--drivers/net/wireless/ray_cs.c4
-rw-r--r--drivers/net/wireless/realtek/rtl818x/rtl8180/Makefile2
-rw-r--r--drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c2
-rw-r--r--drivers/net/wireless/realtek/rtl818x/rtl8187/Makefile2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/base.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/debug.c14
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c95
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c8
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c6
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_debugfs.c5
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_hal.c3
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_mac80211.c67
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_main.c1
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_mgmt.c133
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_sdio.c15
-rw-r--r--drivers/net/wireless/rsi/rsi_main.h22
-rw-r--r--drivers/net/wireless/rsi/rsi_mgmt.h35
-rw-r--r--drivers/net/wireless/st/cw1200/debug.c26
-rw-r--r--drivers/net/wireless/st/cw1200/fwio.c4
-rw-r--r--drivers/net/wireless/st/cw1200/queue.c1
-rw-r--r--drivers/net/wireless/st/cw1200/scan.c5
-rw-r--r--drivers/net/wireless/ti/wl1251/debugfs.c59
-rw-r--r--drivers/net/wireless/ti/wl12xx/debugfs.c20
-rw-r--r--drivers/net/wireless/ti/wl18xx/debugfs.c20
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.c2
-rw-r--r--drivers/net/wireless/ti/wlcore/debugfs.c28
-rw-r--r--drivers/net/wireless/ti/wlcore/debugfs.h10
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c7
-rw-r--r--include/linux/bcma/bcma.h11
183 files changed, 4083 insertions, 3927 deletions
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index a4aac370f21f..6eded32d1aac 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -10,13 +10,13 @@
10#include <linux/delay.h> 10#include <linux/delay.h>
11 11
12#define bcma_err(bus, fmt, ...) \ 12#define bcma_err(bus, fmt, ...) \
13 pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__) 13 dev_err((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
14#define bcma_warn(bus, fmt, ...) \ 14#define bcma_warn(bus, fmt, ...) \
15 pr_warn("bus%d: " fmt, (bus)->num, ##__VA_ARGS__) 15 dev_warn((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
16#define bcma_info(bus, fmt, ...) \ 16#define bcma_info(bus, fmt, ...) \
17 pr_info("bus%d: " fmt, (bus)->num, ##__VA_ARGS__) 17 dev_info((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
18#define bcma_debug(bus, fmt, ...) \ 18#define bcma_debug(bus, fmt, ...) \
19 pr_debug("bus%d: " fmt, (bus)->num, ##__VA_ARGS__) 19 dev_dbg((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
20 20
21struct bcma_bus; 21struct bcma_bus;
22 22
@@ -33,7 +33,6 @@ int __init bcma_bus_early_register(struct bcma_bus *bus);
33int bcma_bus_suspend(struct bcma_bus *bus); 33int bcma_bus_suspend(struct bcma_bus *bus);
34int bcma_bus_resume(struct bcma_bus *bus); 34int bcma_bus_resume(struct bcma_bus *bus);
35#endif 35#endif
36struct device *bcma_bus_get_host_dev(struct bcma_bus *bus);
37 36
38/* scan.c */ 37/* scan.c */
39void bcma_detect_chip(struct bcma_bus *bus); 38void bcma_detect_chip(struct bcma_bus *bus);
diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c
index 2c0ffb77d738..a5df3d111334 100644
--- a/drivers/bcma/driver_gpio.c
+++ b/drivers/bcma/driver_gpio.c
@@ -183,7 +183,7 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
183 chip->direction_input = bcma_gpio_direction_input; 183 chip->direction_input = bcma_gpio_direction_input;
184 chip->direction_output = bcma_gpio_direction_output; 184 chip->direction_output = bcma_gpio_direction_output;
185 chip->owner = THIS_MODULE; 185 chip->owner = THIS_MODULE;
186 chip->parent = bcma_bus_get_host_dev(bus); 186 chip->parent = bus->dev;
187#if IS_BUILTIN(CONFIG_OF) 187#if IS_BUILTIN(CONFIG_OF)
188 chip->of_node = cc->core->dev.of_node; 188 chip->of_node = cc->core->dev.of_node;
189#endif 189#endif
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 63410ecfe640..f52239feb4cb 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -196,6 +196,8 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
196 goto err_pci_release_regions; 196 goto err_pci_release_regions;
197 } 197 }
198 198
199 bus->dev = &dev->dev;
200
199 /* Map MMIO */ 201 /* Map MMIO */
200 err = -ENOMEM; 202 err = -ENOMEM;
201 bus->mmio = pci_iomap(dev, 0, ~0UL); 203 bus->mmio = pci_iomap(dev, 0, ~0UL);
diff --git a/drivers/bcma/host_soc.c b/drivers/bcma/host_soc.c
index 2dce34789329..c8073b509a2b 100644
--- a/drivers/bcma/host_soc.c
+++ b/drivers/bcma/host_soc.c
@@ -179,7 +179,6 @@ int __init bcma_host_soc_register(struct bcma_soc *soc)
179 /* Host specific */ 179 /* Host specific */
180 bus->hosttype = BCMA_HOSTTYPE_SOC; 180 bus->hosttype = BCMA_HOSTTYPE_SOC;
181 bus->ops = &bcma_host_soc_ops; 181 bus->ops = &bcma_host_soc_ops;
182 bus->host_pdev = NULL;
183 182
184 /* Initialize struct, detect chip */ 183 /* Initialize struct, detect chip */
185 bcma_init_bus(bus); 184 bcma_init_bus(bus);
@@ -213,6 +212,8 @@ static int bcma_host_soc_probe(struct platform_device *pdev)
213 if (!bus) 212 if (!bus)
214 return -ENOMEM; 213 return -ENOMEM;
215 214
215 bus->dev = dev;
216
216 /* Map MMIO */ 217 /* Map MMIO */
217 bus->mmio = of_iomap(np, 0); 218 bus->mmio = of_iomap(np, 0);
218 if (!bus->mmio) 219 if (!bus->mmio)
@@ -221,7 +222,6 @@ static int bcma_host_soc_probe(struct platform_device *pdev)
221 /* Host specific */ 222 /* Host specific */
222 bus->hosttype = BCMA_HOSTTYPE_SOC; 223 bus->hosttype = BCMA_HOSTTYPE_SOC;
223 bus->ops = &bcma_host_soc_ops; 224 bus->ops = &bcma_host_soc_ops;
224 bus->host_pdev = pdev;
225 225
226 /* Initialize struct, detect chip */ 226 /* Initialize struct, detect chip */
227 bcma_init_bus(bus); 227 bcma_init_bus(bus);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index fc1f4acdd189..6535614a7dc1 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -223,8 +223,8 @@ unsigned int bcma_core_irq(struct bcma_device *core, int num)
223 mips_irq = bcma_core_mips_irq(core); 223 mips_irq = bcma_core_mips_irq(core);
224 return mips_irq <= 4 ? mips_irq + 2 : 0; 224 return mips_irq <= 4 ? mips_irq + 2 : 0;
225 } 225 }
226 if (bus->host_pdev) 226 if (bus->dev)
227 return bcma_of_get_irq(&bus->host_pdev->dev, core, num); 227 return bcma_of_get_irq(bus->dev, core, num);
228 return 0; 228 return 0;
229 case BCMA_HOSTTYPE_SDIO: 229 case BCMA_HOSTTYPE_SDIO:
230 return 0; 230 return 0;
@@ -239,18 +239,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
239 core->dev.release = bcma_release_core_dev; 239 core->dev.release = bcma_release_core_dev;
240 core->dev.bus = &bcma_bus_type; 240 core->dev.bus = &bcma_bus_type;
241 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); 241 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
242 core->dev.parent = bcma_bus_get_host_dev(bus); 242 core->dev.parent = bus->dev;
243 if (core->dev.parent) 243 if (bus->dev)
244 bcma_of_fill_device(core->dev.parent, core); 244 bcma_of_fill_device(bus->dev, core);
245 245
246 switch (bus->hosttype) { 246 switch (bus->hosttype) {
247 case BCMA_HOSTTYPE_PCI: 247 case BCMA_HOSTTYPE_PCI:
248 core->dma_dev = &bus->host_pci->dev; 248 core->dma_dev = bus->dev;
249 core->irq = bus->host_pci->irq; 249 core->irq = bus->host_pci->irq;
250 break; 250 break;
251 case BCMA_HOSTTYPE_SOC: 251 case BCMA_HOSTTYPE_SOC:
252 if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) { 252 if (IS_ENABLED(CONFIG_OF) && bus->dev) {
253 core->dma_dev = &bus->host_pdev->dev; 253 core->dma_dev = bus->dev;
254 } else { 254 } else {
255 core->dev.dma_mask = &core->dev.coherent_dma_mask; 255 core->dev.dma_mask = &core->dev.coherent_dma_mask;
256 core->dma_dev = &core->dev; 256 core->dma_dev = &core->dev;
@@ -261,28 +261,6 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
261 } 261 }
262} 262}
263 263
264struct device *bcma_bus_get_host_dev(struct bcma_bus *bus)
265{
266 switch (bus->hosttype) {
267 case BCMA_HOSTTYPE_PCI:
268 if (bus->host_pci)
269 return &bus->host_pci->dev;
270 else
271 return NULL;
272 case BCMA_HOSTTYPE_SOC:
273 if (bus->host_pdev)
274 return &bus->host_pdev->dev;
275 else
276 return NULL;
277 case BCMA_HOSTTYPE_SDIO:
278 if (bus->host_sdio)
279 return &bus->host_sdio->dev;
280 else
281 return NULL;
282 }
283 return NULL;
284}
285
286void bcma_init_bus(struct bcma_bus *bus) 264void bcma_init_bus(struct bcma_bus *bus)
287{ 265{
288 mutex_lock(&bcma_buses_mutex); 266 mutex_lock(&bcma_buses_mutex);
@@ -402,7 +380,6 @@ int bcma_bus_register(struct bcma_bus *bus)
402{ 380{
403 int err; 381 int err;
404 struct bcma_device *core; 382 struct bcma_device *core;
405 struct device *dev;
406 383
407 /* Scan for devices (cores) */ 384 /* Scan for devices (cores) */
408 err = bcma_bus_scan(bus); 385 err = bcma_bus_scan(bus);
@@ -425,10 +402,8 @@ int bcma_bus_register(struct bcma_bus *bus)
425 bcma_core_pci_early_init(&bus->drv_pci[0]); 402 bcma_core_pci_early_init(&bus->drv_pci[0]);
426 } 403 }
427 404
428 dev = bcma_bus_get_host_dev(bus); 405 if (bus->dev)
429 if (dev) { 406 of_platform_default_populate(bus->dev->of_node, NULL, bus->dev);
430 of_platform_default_populate(dev->of_node, NULL, dev);
431 }
432 407
433 /* Cores providing flash access go before SPROM init */ 408 /* Cores providing flash access go before SPROM init */
434 list_for_each_entry(core, &bus->cores, list) { 409 list_for_each_entry(core, &bus->cores, list) {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 2034ccc7cc72..021eb30d1fb7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -1986,7 +1986,7 @@ static inline const char *ath10k_wmi_phymode_str(enum wmi_phy_mode mode)
1986 /* no default handler to allow compiler to check that the 1986 /* no default handler to allow compiler to check that the
1987 * enum is fully handled 1987 * enum is fully handled
1988 */ 1988 */
1989 }; 1989 }
1990 1990
1991 return "<unknown>"; 1991 return "<unknown>";
1992} 1992}
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 54132af70094..aa1c71a76ef7 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1140,7 +1140,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name)
1140 1140
1141 len -= ie_len; 1141 len -= ie_len;
1142 data += ie_len; 1142 data += ie_len;
1143 }; 1143 }
1144 1144
1145 ret = 0; 1145 ret = 0;
1146out: 1146out:
diff --git a/drivers/net/wireless/broadcom/b43/debugfs.c b/drivers/net/wireless/broadcom/b43/debugfs.c
index 77046384dd80..976c8ec4e992 100644
--- a/drivers/net/wireless/broadcom/b43/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43/debugfs.c
@@ -668,15 +668,13 @@ static void b43_remove_dynamic_debug(struct b43_wldev *dev)
668static void b43_add_dynamic_debug(struct b43_wldev *dev) 668static void b43_add_dynamic_debug(struct b43_wldev *dev)
669{ 669{
670 struct b43_dfsentry *e = dev->dfsentry; 670 struct b43_dfsentry *e = dev->dfsentry;
671 struct dentry *d;
672 671
673#define add_dyn_dbg(name, id, initstate) do { \ 672#define add_dyn_dbg(name, id, initstate) do { \
674 e->dyn_debug[id] = (initstate); \ 673 e->dyn_debug[id] = (initstate); \
675 d = debugfs_create_bool(name, 0600, e->subdir, \ 674 e->dyn_debug_dentries[id] = \
676 &(e->dyn_debug[id])); \ 675 debugfs_create_bool(name, 0600, e->subdir, \
677 if (!IS_ERR(d)) \ 676 &(e->dyn_debug[id])); \
678 e->dyn_debug_dentries[id] = d; \ 677 } while (0)
679 } while (0)
680 678
681 add_dyn_dbg("debug_xmitpower", B43_DBG_XMITPOWER, false); 679 add_dyn_dbg("debug_xmitpower", B43_DBG_XMITPOWER, false);
682 add_dyn_dbg("debug_dmaoverflow", B43_DBG_DMAOVERFLOW, false); 680 add_dyn_dbg("debug_dmaoverflow", B43_DBG_DMAOVERFLOW, false);
@@ -718,19 +716,6 @@ void b43_debugfs_add_device(struct b43_wldev *dev)
718 716
719 snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy)); 717 snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy));
720 e->subdir = debugfs_create_dir(devdir, rootdir); 718 e->subdir = debugfs_create_dir(devdir, rootdir);
721 if (!e->subdir || IS_ERR(e->subdir)) {
722 if (e->subdir == ERR_PTR(-ENODEV)) {
723 b43dbg(dev->wl, "DebugFS (CONFIG_DEBUG_FS) not "
724 "enabled in kernel config\n");
725 } else {
726 b43err(dev->wl, "debugfs: cannot create %s directory\n",
727 devdir);
728 }
729 dev->dfsentry = NULL;
730 kfree(log->log);
731 kfree(e);
732 return;
733 }
734 719
735 e->mmio16read_next = 0xFFFF; /* invalid address */ 720 e->mmio16read_next = 0xFFFF; /* invalid address */
736 e->mmio32read_next = 0xFFFF; /* invalid address */ 721 e->mmio32read_next = 0xFFFF; /* invalid address */
@@ -741,13 +726,10 @@ void b43_debugfs_add_device(struct b43_wldev *dev)
741 726
742#define ADD_FILE(name, mode) \ 727#define ADD_FILE(name, mode) \
743 do { \ 728 do { \
744 struct dentry *d; \ 729 e->file_##name.dentry = \
745 d = debugfs_create_file(__stringify(name), \ 730 debugfs_create_file(__stringify(name), \
746 mode, e->subdir, dev, \ 731 mode, e->subdir, dev, \
747 &fops_##name.fops); \ 732 &fops_##name.fops); \
748 e->file_##name.dentry = NULL; \
749 if (!IS_ERR(d)) \
750 e->file_##name.dentry = d; \
751 } while (0) 733 } while (0)
752 734
753 735
@@ -818,8 +800,6 @@ void b43_debugfs_log_txstat(struct b43_wldev *dev,
818void b43_debugfs_init(void) 800void b43_debugfs_init(void)
819{ 801{
820 rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); 802 rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
821 if (IS_ERR(rootdir))
822 rootdir = NULL;
823} 803}
824 804
825void b43_debugfs_exit(void) 805void b43_debugfs_exit(void)
diff --git a/drivers/net/wireless/broadcom/b43legacy/debugfs.c b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
index 82ef56ed7ca1..8150adee3e34 100644
--- a/drivers/net/wireless/broadcom/b43legacy/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
@@ -361,15 +361,13 @@ static void b43legacy_remove_dynamic_debug(struct b43legacy_wldev *dev)
361static void b43legacy_add_dynamic_debug(struct b43legacy_wldev *dev) 361static void b43legacy_add_dynamic_debug(struct b43legacy_wldev *dev)
362{ 362{
363 struct b43legacy_dfsentry *e = dev->dfsentry; 363 struct b43legacy_dfsentry *e = dev->dfsentry;
364 struct dentry *d;
365 364
366#define add_dyn_dbg(name, id, initstate) do { \ 365#define add_dyn_dbg(name, id, initstate) do { \
367 e->dyn_debug[id] = (initstate); \ 366 e->dyn_debug[id] = (initstate); \
368 d = debugfs_create_bool(name, 0600, e->subdir, \ 367 e->dyn_debug_dentries[id] = \
369 &(e->dyn_debug[id])); \ 368 debugfs_create_bool(name, 0600, e->subdir, \
370 if (!IS_ERR(d)) \ 369 &(e->dyn_debug[id])); \
371 e->dyn_debug_dentries[id] = d; \ 370 } while (0)
372 } while (0)
373 371
374 add_dyn_dbg("debug_xmitpower", B43legacy_DBG_XMITPOWER, false); 372 add_dyn_dbg("debug_xmitpower", B43legacy_DBG_XMITPOWER, false);
375 add_dyn_dbg("debug_dmaoverflow", B43legacy_DBG_DMAOVERFLOW, false); 373 add_dyn_dbg("debug_dmaoverflow", B43legacy_DBG_DMAOVERFLOW, false);
@@ -408,29 +406,14 @@ void b43legacy_debugfs_add_device(struct b43legacy_wldev *dev)
408 406
409 snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy)); 407 snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy));
410 e->subdir = debugfs_create_dir(devdir, rootdir); 408 e->subdir = debugfs_create_dir(devdir, rootdir);
411 if (!e->subdir || IS_ERR(e->subdir)) {
412 if (e->subdir == ERR_PTR(-ENODEV)) {
413 b43legacydbg(dev->wl, "DebugFS (CONFIG_DEBUG_FS) not "
414 "enabled in kernel config\n");
415 } else {
416 b43legacyerr(dev->wl, "debugfs: cannot create %s directory\n",
417 devdir);
418 }
419 dev->dfsentry = NULL;
420 kfree(log->log);
421 kfree(e);
422 return;
423 }
424 409
425#define ADD_FILE(name, mode) \ 410#define ADD_FILE(name, mode) \
426 do { \ 411 do { \
427 struct dentry *d; \ 412 e->file_##name.dentry = \
428 d = debugfs_create_file(__stringify(name), \ 413 debugfs_create_file(__stringify(name), \
429 mode, e->subdir, dev, \ 414 mode, e->subdir, dev, \
430 &fops_##name.fops); \ 415 &fops_##name.fops); \
431 e->file_##name.dentry = NULL; \ 416 e->file_##name.dentry = NULL; \
432 if (!IS_ERR(d)) \
433 e->file_##name.dentry = d; \
434 } while (0) 417 } while (0)
435 418
436 419
@@ -492,8 +475,6 @@ void b43legacy_debugfs_log_txstat(struct b43legacy_wldev *dev,
492void b43legacy_debugfs_init(void) 475void b43legacy_debugfs_init(void)
493{ 476{
494 rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); 477 rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
495 if (IS_ERR(rootdir))
496 rootdir = NULL;
497} 478}
498 479
499void b43legacy_debugfs_exit(void) 480void b43legacy_debugfs_exit(void)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
index 22fd95a736a8..f7cf3e5f4849 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
@@ -16,8 +16,8 @@
16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
18ccflags-y += \ 18ccflags-y += \
19 -Idrivers/net/wireless/broadcom/brcm80211/brcmfmac \ 19 -I $(srctree)/$(src) \
20 -Idrivers/net/wireless/broadcom/brcm80211/include 20 -I $(srctree)/$(src)/../include
21 21
22obj-$(CONFIG_BRCMFMAC) += brcmfmac.o 22obj-$(CONFIG_BRCMFMAC) += brcmfmac.o
23brcmfmac-objs += \ 23brcmfmac-objs += \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index d64bf233b12c..ec129864cc9c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -315,7 +315,7 @@ static int brcmf_sdiod_skbuff_read(struct brcmf_sdio_dev *sdiodev,
315 /* bail out as things are really fishy here */ 315 /* bail out as things are really fishy here */
316 WARN(1, "invalid sdio function number: %d\n", func->num); 316 WARN(1, "invalid sdio function number: %d\n", func->num);
317 err = -ENOMEDIUM; 317 err = -ENOMEDIUM;
318 }; 318 }
319 319
320 if (err == -ENOMEDIUM) 320 if (err == -ENOMEDIUM)
321 brcmf_sdiod_change_state(sdiodev, BRCMF_SDIOD_NOMEDIUM); 321 brcmf_sdiod_change_state(sdiodev, BRCMF_SDIOD_NOMEDIUM);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 1f1e95a15a17..0ce1d8174e6d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -149,7 +149,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
149 return err; 149 return err;
150 } 150 }
151 151
152 err = request_firmware(&clm, clm_name, bus->dev); 152 err = firmware_request_nowarn(&clm, clm_name, bus->dev);
153 if (err) { 153 if (err) {
154 brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n", 154 brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n",
155 err); 155 err);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
index 51d76ac45075..7535cb0d4ac0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
@@ -43,6 +43,10 @@ static const struct brcmf_dmi_data meegopad_t08_data = {
43 BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08" 43 BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08"
44}; 44};
45 45
46static const struct brcmf_dmi_data pov_tab_p1006w_data = {
47 BRCM_CC_43340_CHIP_ID, 2, "pov-tab-p1006w-data"
48};
49
46static const struct dmi_system_id dmi_platform_data[] = { 50static const struct dmi_system_id dmi_platform_data[] = {
47 { 51 {
48 /* Match for the GPDwin which unfortunately uses somewhat 52 /* Match for the GPDwin which unfortunately uses somewhat
@@ -81,6 +85,17 @@ static const struct dmi_system_id dmi_platform_data[] = {
81 }, 85 },
82 .driver_data = (void *)&meegopad_t08_data, 86 .driver_data = (void *)&meegopad_t08_data,
83 }, 87 },
88 {
89 /* Point of View TAB-P1006W-232 */
90 .matches = {
91 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
92 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BayTrail"),
93 /* Note 105b is Foxcon's USB/PCI vendor id */
94 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "105B"),
95 DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"),
96 },
97 .driver_data = (void *)&pov_tab_p1006w_data,
98 },
84 {} 99 {}
85}; 100};
86 101
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
index ffa243e2e2d0..37b403877228 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
@@ -496,6 +496,11 @@ int brcmf_pno_stop_sched_scan(struct brcmf_if *ifp, u64 reqid)
496 brcmf_dbg(TRACE, "reqid=%llu\n", reqid); 496 brcmf_dbg(TRACE, "reqid=%llu\n", reqid);
497 497
498 pi = ifp_to_pno(ifp); 498 pi = ifp_to_pno(ifp);
499
500 /* No PNO request */
501 if (!pi->n_reqs)
502 return 0;
503
499 err = brcmf_pno_remove_request(pi, reqid); 504 err = brcmf_pno_remove_request(pi, reqid);
500 if (err) 505 if (err)
501 return err; 506 return err;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index a4308c6e72d7..76cfaf6999c8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1550,6 +1550,10 @@ void brcmf_usb_exit(void)
1550 1550
1551void brcmf_usb_register(void) 1551void brcmf_usb_register(void)
1552{ 1552{
1553 int ret;
1554
1553 brcmf_dbg(USB, "Enter\n"); 1555 brcmf_dbg(USB, "Enter\n");
1554 usb_register(&brcmf_usbdrvr); 1556 ret = usb_register(&brcmf_usbdrvr);
1557 if (ret)
1558 brcmf_err("usb_register failed %d\n", ret);
1555} 1559}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile
index ed83f33aceb7..482d7737764d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile
@@ -16,9 +16,9 @@
16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
18ccflags-y := \ 18ccflags-y := \
19 -Idrivers/net/wireless/broadcom/brcm80211/brcmsmac \ 19 -I $(srctree)/$(src) \
20 -Idrivers/net/wireless/broadcom/brcm80211/brcmsmac/phy \ 20 -I $(srctree)/$(src)/phy \
21 -Idrivers/net/wireless/broadcom/brcm80211/include 21 -I $(srctree)/$(src)/../include
22 22
23brcmsmac-y := \ 23brcmsmac-y := \
24 mac80211_if.o \ 24 mac80211_if.o \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
index 3bd54f125776..6d776ef6ff54 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
@@ -37,27 +37,18 @@ static struct dentry *root_folder;
37void brcms_debugfs_init(void) 37void brcms_debugfs_init(void)
38{ 38{
39 root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL); 39 root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
40 if (IS_ERR(root_folder))
41 root_folder = NULL;
42} 40}
43 41
44void brcms_debugfs_exit(void) 42void brcms_debugfs_exit(void)
45{ 43{
46 if (!root_folder)
47 return;
48
49 debugfs_remove_recursive(root_folder); 44 debugfs_remove_recursive(root_folder);
50 root_folder = NULL; 45 root_folder = NULL;
51} 46}
52 47
53int brcms_debugfs_attach(struct brcms_pub *drvr) 48void brcms_debugfs_attach(struct brcms_pub *drvr)
54{ 49{
55 if (!root_folder)
56 return -ENODEV;
57
58 drvr->dbgfs_dir = debugfs_create_dir( 50 drvr->dbgfs_dir = debugfs_create_dir(
59 dev_name(&drvr->wlc->hw->d11core->dev), root_folder); 51 dev_name(&drvr->wlc->hw->d11core->dev), root_folder);
60 return PTR_ERR_OR_ZERO(drvr->dbgfs_dir);
61} 52}
62 53
63void brcms_debugfs_detach(struct brcms_pub *drvr) 54void brcms_debugfs_detach(struct brcms_pub *drvr)
@@ -195,7 +186,7 @@ static const struct file_operations brcms_debugfs_def_ops = {
195 .llseek = seq_lseek 186 .llseek = seq_lseek
196}; 187};
197 188
198static int 189static void
199brcms_debugfs_add_entry(struct brcms_pub *drvr, const char *fn, 190brcms_debugfs_add_entry(struct brcms_pub *drvr, const char *fn,
200 int (*read_fn)(struct seq_file *seq, void *data)) 191 int (*read_fn)(struct seq_file *seq, void *data))
201{ 192{
@@ -203,27 +194,18 @@ brcms_debugfs_add_entry(struct brcms_pub *drvr, const char *fn,
203 struct dentry *dentry = drvr->dbgfs_dir; 194 struct dentry *dentry = drvr->dbgfs_dir;
204 struct brcms_debugfs_entry *entry; 195 struct brcms_debugfs_entry *entry;
205 196
206 if (IS_ERR_OR_NULL(dentry))
207 return -ENOENT;
208
209 entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL); 197 entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
210 if (!entry) 198 if (!entry)
211 return -ENOMEM; 199 return;
212 200
213 entry->read = read_fn; 201 entry->read = read_fn;
214 entry->drvr = drvr; 202 entry->drvr = drvr;
215 203
216 dentry = debugfs_create_file(fn, 0444, dentry, entry, 204 debugfs_create_file(fn, 0444, dentry, entry, &brcms_debugfs_def_ops);
217 &brcms_debugfs_def_ops);
218
219 return PTR_ERR_OR_ZERO(dentry);
220} 205}
221 206
222void brcms_debugfs_create_files(struct brcms_pub *drvr) 207void brcms_debugfs_create_files(struct brcms_pub *drvr)
223{ 208{
224 if (IS_ERR_OR_NULL(drvr->dbgfs_dir))
225 return;
226
227 brcms_debugfs_add_entry(drvr, "hardware", brcms_debugfs_hardware_read); 209 brcms_debugfs_add_entry(drvr, "hardware", brcms_debugfs_hardware_read);
228 brcms_debugfs_add_entry(drvr, "macstat", brcms_debugfs_macstat_read); 210 brcms_debugfs_add_entry(drvr, "macstat", brcms_debugfs_macstat_read);
229} 211}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
index 822781cf15d4..56898e6d789d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
@@ -68,7 +68,7 @@ void __brcms_dbg(struct device *dev, u32 level, const char *func,
68struct brcms_pub; 68struct brcms_pub;
69void brcms_debugfs_init(void); 69void brcms_debugfs_init(void);
70void brcms_debugfs_exit(void); 70void brcms_debugfs_exit(void);
71int brcms_debugfs_attach(struct brcms_pub *drvr); 71void brcms_debugfs_attach(struct brcms_pub *drvr);
72void brcms_debugfs_detach(struct brcms_pub *drvr); 72void brcms_debugfs_detach(struct brcms_pub *drvr);
73struct dentry *brcms_debugfs_get_devdir(struct brcms_pub *drvr); 73struct dentry *brcms_debugfs_get_devdir(struct brcms_pub *drvr);
74void brcms_debugfs_create_files(struct brcms_pub *drvr); 74void brcms_debugfs_create_files(struct brcms_pub *drvr);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index e78a93a45741..c6e107f41948 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -1199,8 +1199,6 @@ wlc_lcnphy_rx_iq_est(struct brcms_phy *pi,
1199{ 1199{
1200 int wait_count = 0; 1200 int wait_count = 0;
1201 bool result = true; 1201 bool result = true;
1202 u8 phybw40;
1203 phybw40 = CHSPEC_IS40(pi->radio_chanspec);
1204 1202
1205 mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5); 1203 mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5);
1206 1204
@@ -3082,7 +3080,7 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi)
3082 u8 bbmult; 3080 u8 bbmult;
3083 struct phytbl_info tab; 3081 struct phytbl_info tab;
3084 s32 a1, b0, b1; 3082 s32 a1, b0, b1;
3085 s32 tssi, pwr, maxtargetpwr, mintargetpwr; 3083 s32 tssi, pwr, mintargetpwr;
3086 bool suspend; 3084 bool suspend;
3087 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); 3085 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
3088 3086
@@ -3119,7 +3117,6 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi)
3119 b0 = pi->txpa_2g[0]; 3117 b0 = pi->txpa_2g[0];
3120 b1 = pi->txpa_2g[1]; 3118 b1 = pi->txpa_2g[1];
3121 a1 = pi->txpa_2g[2]; 3119 a1 = pi->txpa_2g[2];
3122 maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1);
3123 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); 3120 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1);
3124 3121
3125 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; 3122 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL;
@@ -4212,7 +4209,7 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi)
4212 s8 index; 4209 s8 index;
4213 struct phytbl_info tab; 4210 struct phytbl_info tab;
4214 s32 a1, b0, b1; 4211 s32 a1, b0, b1;
4215 s32 tssi, pwr, maxtargetpwr, mintargetpwr; 4212 s32 tssi, pwr, mintargetpwr;
4216 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; 4213 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
4217 4214
4218 pi->phy_lastcal = pi->sh->now; 4215 pi->phy_lastcal = pi->sh->now;
@@ -4249,7 +4246,6 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi)
4249 b0 = pi->txpa_2g[0]; 4246 b0 = pi->txpa_2g[0];
4250 b1 = pi->txpa_2g[1]; 4247 b1 = pi->txpa_2g[1];
4251 a1 = pi->txpa_2g[2]; 4248 a1 = pi->txpa_2g[2];
4252 maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1);
4253 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); 4249 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1);
4254 4250
4255 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; 4251 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL;
@@ -4622,13 +4618,10 @@ static void wlc_lcnphy_radio_init(struct brcms_phy *pi)
4622static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) 4618static void wlc_lcnphy_tbl_init(struct brcms_phy *pi)
4623{ 4619{
4624 uint idx; 4620 uint idx;
4625 u8 phybw40;
4626 struct phytbl_info tab; 4621 struct phytbl_info tab;
4627 const struct phytbl_info *tb; 4622 const struct phytbl_info *tb;
4628 u32 val; 4623 u32 val;
4629 4624
4630 phybw40 = CHSPEC_IS40(pi->radio_chanspec);
4631
4632 for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++) 4625 for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++)
4633 wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]); 4626 wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]);
4634 4627
@@ -4831,9 +4824,7 @@ static void wlc_lcnphy_baseband_init(struct brcms_phy *pi)
4831 4824
4832void wlc_phy_init_lcnphy(struct brcms_phy *pi) 4825void wlc_phy_init_lcnphy(struct brcms_phy *pi)
4833{ 4826{
4834 u8 phybw40;
4835 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; 4827 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
4836 phybw40 = CHSPEC_IS40(pi->radio_chanspec);
4837 4828
4838 pi_lcn->lcnphy_cal_counter = 0; 4829 pi_lcn->lcnphy_cal_counter = 0;
4839 pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense; 4830 pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile b/drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile
index 256c91f9ac4b..bb02c6220a88 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile
@@ -15,9 +15,7 @@
15# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 15# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
18ccflags-y := \ 18ccflags-y := -I $(srctree)/$(src)/../include
19 -Idrivers/net/wireless/broadcom/brcm80211/brcmutil \
20 -Idrivers/net/wireless/broadcom/brcm80211/include
21 19
22obj-$(CONFIG_BRCMUTIL) += brcmutil.o 20obj-$(CONFIG_BRCMUTIL) += brcmutil.o
23brcmutil-objs = utils.o d11.o 21brcmutil-objs = utils.o d11.o
diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
index 57e3b6cca234..271977f7fbb0 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
@@ -3756,10 +3756,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3756 if (err) 3756 if (err)
3757 goto out_remove_sysfs; 3757 goto out_remove_sysfs;
3758 3758
3759 err = il_dbgfs_register(il, DRV_NAME); 3759 il_dbgfs_register(il, DRV_NAME);
3760 if (err)
3761 IL_ERR("failed to create debugfs files. Ignoring error: %d\n",
3762 err);
3763 3760
3764 /* Start monitoring the killswitch */ 3761 /* Start monitoring the killswitch */
3765 queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); 3762 queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ);
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
index 6b4488a178a7..94222ae464ae 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -4988,10 +4988,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context)
4988 if (err) 4988 if (err)
4989 goto out_unbind; 4989 goto out_unbind;
4990 4990
4991 err = il_dbgfs_register(il, DRV_NAME); 4991 il_dbgfs_register(il, DRV_NAME);
4992 if (err)
4993 IL_ERR("failed to create debugfs files. Ignoring error: %d\n",
4994 err);
4995 4992
4996 err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); 4993 err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group);
4997 if (err) { 4994 if (err) {
diff --git a/drivers/net/wireless/intel/iwlegacy/common.h b/drivers/net/wireless/intel/iwlegacy/common.h
index dc6a74a05983..b079c64ca014 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.h
+++ b/drivers/net/wireless/intel/iwlegacy/common.h
@@ -2974,13 +2974,11 @@ il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len)
2974#endif /* CONFIG_IWLEGACY_DEBUG */ 2974#endif /* CONFIG_IWLEGACY_DEBUG */
2975 2975
2976#ifdef CONFIG_IWLEGACY_DEBUGFS 2976#ifdef CONFIG_IWLEGACY_DEBUGFS
2977int il_dbgfs_register(struct il_priv *il, const char *name); 2977void il_dbgfs_register(struct il_priv *il, const char *name);
2978void il_dbgfs_unregister(struct il_priv *il); 2978void il_dbgfs_unregister(struct il_priv *il);
2979#else 2979#else
2980static inline int 2980static inline void il_dbgfs_register(struct il_priv *il, const char *name)
2981il_dbgfs_register(struct il_priv *il, const char *name)
2982{ 2981{
2983 return 0;
2984} 2982}
2985 2983
2986static inline void 2984static inline void
diff --git a/drivers/net/wireless/intel/iwlegacy/debug.c b/drivers/net/wireless/intel/iwlegacy/debug.c
index d76073def677..fa211412e0ac 100644
--- a/drivers/net/wireless/intel/iwlegacy/debug.c
+++ b/drivers/net/wireless/intel/iwlegacy/debug.c
@@ -128,23 +128,12 @@ EXPORT_SYMBOL(il_update_stats);
128 128
129/* create and remove of files */ 129/* create and remove of files */
130#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ 130#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
131 if (!debugfs_create_file(#name, mode, parent, il, \ 131 debugfs_create_file(#name, mode, parent, il, \
132 &il_dbgfs_##name##_ops)) \ 132 &il_dbgfs_##name##_ops); \
133 goto err; \
134} while (0) 133} while (0)
135 134
136#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ 135#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
137 struct dentry *__tmp; \ 136 debugfs_create_bool(#name, 0600, parent, ptr); \
138 __tmp = debugfs_create_bool(#name, 0600, parent, ptr); \
139 if (IS_ERR(__tmp) || !__tmp) \
140 goto err; \
141} while (0)
142
143#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
144 struct dentry *__tmp; \
145 __tmp = debugfs_create_x32(#name, 0600, parent, ptr); \
146 if (IS_ERR(__tmp) || !__tmp) \
147 goto err; \
148} while (0) 137} while (0)
149 138
150/* file operation */ 139/* file operation */
@@ -1341,27 +1330,18 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout);
1341 * Create the debugfs files and directories 1330 * Create the debugfs files and directories
1342 * 1331 *
1343 */ 1332 */
1344int 1333void
1345il_dbgfs_register(struct il_priv *il, const char *name) 1334il_dbgfs_register(struct il_priv *il, const char *name)
1346{ 1335{
1347 struct dentry *phyd = il->hw->wiphy->debugfsdir; 1336 struct dentry *phyd = il->hw->wiphy->debugfsdir;
1348 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; 1337 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
1349 1338
1350 dir_drv = debugfs_create_dir(name, phyd); 1339 dir_drv = debugfs_create_dir(name, phyd);
1351 if (!dir_drv)
1352 return -ENOMEM;
1353
1354 il->debugfs_dir = dir_drv; 1340 il->debugfs_dir = dir_drv;
1355 1341
1356 dir_data = debugfs_create_dir("data", dir_drv); 1342 dir_data = debugfs_create_dir("data", dir_drv);
1357 if (!dir_data)
1358 goto err;
1359 dir_rf = debugfs_create_dir("rf", dir_drv); 1343 dir_rf = debugfs_create_dir("rf", dir_drv);
1360 if (!dir_rf)
1361 goto err;
1362 dir_debug = debugfs_create_dir("debug", dir_drv); 1344 dir_debug = debugfs_create_dir("debug", dir_drv);
1363 if (!dir_debug)
1364 goto err;
1365 1345
1366 DEBUGFS_ADD_FILE(nvm, dir_data, 0400); 1346 DEBUGFS_ADD_FILE(nvm, dir_data, 0400);
1367 DEBUGFS_ADD_FILE(sram, dir_data, 0600); 1347 DEBUGFS_ADD_FILE(sram, dir_data, 0600);
@@ -1399,12 +1379,6 @@ il_dbgfs_register(struct il_priv *il, const char *name)
1399 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, 1379 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
1400 &il->disable_chain_noise_cal); 1380 &il->disable_chain_noise_cal);
1401 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, &il->disable_tx_power_cal); 1381 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, &il->disable_tx_power_cal);
1402 return 0;
1403
1404err:
1405 IL_ERR("Can't create the debugfs directory\n");
1406 il_dbgfs_unregister(il);
1407 return -ENOMEM;
1408} 1382}
1409EXPORT_SYMBOL(il_dbgfs_register); 1383EXPORT_SYMBOL(il_dbgfs_register);
1410 1384
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
index 7e65073834b7..eb93711d474b 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
@@ -83,6 +83,7 @@
83#define IWL_22000_HR_A0_FW_PRE "iwlwifi-QuQnj-a0-hr-a0-" 83#define IWL_22000_HR_A0_FW_PRE "iwlwifi-QuQnj-a0-hr-a0-"
84#define IWL_22000_SU_Z0_FW_PRE "iwlwifi-su-z0-" 84#define IWL_22000_SU_Z0_FW_PRE "iwlwifi-su-z0-"
85#define IWL_QU_B_JF_B_FW_PRE "iwlwifi-Qu-b0-jf-b0-" 85#define IWL_QU_B_JF_B_FW_PRE "iwlwifi-Qu-b0-jf-b0-"
86#define IWL_CC_A_FW_PRE "iwlwifi-cc-a0-"
86 87
87#define IWL_22000_HR_MODULE_FIRMWARE(api) \ 88#define IWL_22000_HR_MODULE_FIRMWARE(api) \
88 IWL_22000_HR_FW_PRE __stringify(api) ".ucode" 89 IWL_22000_HR_FW_PRE __stringify(api) ".ucode"
@@ -104,6 +105,8 @@
104 IWL_22000_SU_Z0_FW_PRE __stringify(api) ".ucode" 105 IWL_22000_SU_Z0_FW_PRE __stringify(api) ".ucode"
105#define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \ 106#define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \
106 IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode" 107 IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode"
108#define IWL_CC_A_MODULE_FIRMWARE(api) \
109 IWL_CC_A_FW_PRE __stringify(api) ".ucode"
107 110
108static const struct iwl_base_params iwl_22000_base_params = { 111static const struct iwl_base_params iwl_22000_base_params = {
109 .eeprom_size = OTP_LOW_IMAGE_SIZE_32K, 112 .eeprom_size = OTP_LOW_IMAGE_SIZE_32K,
@@ -195,8 +198,8 @@ const struct iwl_cfg iwl22000_2ac_cfg_jf = {
195 IWL_DEVICE_22500, 198 IWL_DEVICE_22500,
196}; 199};
197 200
198const struct iwl_cfg iwl22000_2ax_cfg_hr = { 201const struct iwl_cfg iwl22560_2ax_cfg_hr = {
199 .name = "Intel(R) Dual Band Wireless AX 22000", 202 .name = "Intel(R) Wireless-AX 22560",
200 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE, 203 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE,
201 IWL_DEVICE_22500, 204 IWL_DEVICE_22500,
202 /* 205 /*
@@ -207,6 +210,42 @@ const struct iwl_cfg iwl22000_2ax_cfg_hr = {
207 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT, 210 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
208}; 211};
209 212
213const struct iwl_cfg iwl22260_2ax_cfg = {
214 .name = "Intel(R) Wireless-AX 22260",
215 .fw_name_pre = IWL_CC_A_FW_PRE,
216 IWL_DEVICE_22500,
217 /*
218 * This device doesn't support receiving BlockAck with a large bitmap
219 * so we need to restrict the size of transmitted aggregation to the
220 * HT size; mac80211 would otherwise pick the HE max (256) by default.
221 */
222 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
223};
224
225const struct iwl_cfg killer1650x_2ax_cfg = {
226 .name = "Killer(R) Wireless-AX 1650x Wireless Network Adapter (22260NGW)",
227 .fw_name_pre = IWL_CC_A_FW_PRE,
228 IWL_DEVICE_22500,
229 /*
230 * This device doesn't support receiving BlockAck with a large bitmap
231 * so we need to restrict the size of transmitted aggregation to the
232 * HT size; mac80211 would otherwise pick the HE max (256) by default.
233 */
234 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
235};
236
237const struct iwl_cfg killer1650w_2ax_cfg = {
238 .name = "Killer(R) Wireless-AX 1650w Wireless Network Adapter (22260D2W)",
239 .fw_name_pre = IWL_CC_A_FW_PRE,
240 IWL_DEVICE_22500,
241 /*
242 * This device doesn't support receiving BlockAck with a large bitmap
243 * so we need to restrict the size of transmitted aggregation to the
244 * HT size; mac80211 would otherwise pick the HE max (256) by default.
245 */
246 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
247};
248
210/* 249/*
211 * All JF radio modules are part of the 9000 series, but the MAC part 250 * All JF radio modules are part of the 9000 series, but the MAC part
212 * looks more like 22000. That's why this device is here, but called 251 * looks more like 22000. That's why this device is here, but called
@@ -230,6 +269,12 @@ const struct iwl_cfg iwl9560_2ac_cfg_qu_b0_jf_b0 = {
230 IWL_DEVICE_22500, 269 IWL_DEVICE_22500,
231}; 270};
232 271
272const struct iwl_cfg iwl9560_2ac_160_cfg_qu_b0_jf_b0 = {
273 .name = "Intel(R) Wireless-AC 9560 160MHz",
274 .fw_name_pre = IWL_QU_B_JF_B_FW_PRE,
275 IWL_DEVICE_22500,
276};
277
233const struct iwl_cfg killer1550i_2ac_cfg_qu_b0_jf_b0 = { 278const struct iwl_cfg killer1550i_2ac_cfg_qu_b0_jf_b0 = {
234 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)", 279 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)",
235 .fw_name_pre = IWL_QU_B_JF_B_FW_PRE, 280 .fw_name_pre = IWL_QU_B_JF_B_FW_PRE,
@@ -242,6 +287,30 @@ const struct iwl_cfg killer1550s_2ac_cfg_qu_b0_jf_b0 = {
242 IWL_DEVICE_22500, 287 IWL_DEVICE_22500,
243}; 288};
244 289
290const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0 = {
291 .name = "Killer(R) Wireless-AX 1650i Wireless Network Adapter (22560NGW)",
292 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE,
293 IWL_DEVICE_22500,
294 /*
295 * This device doesn't support receiving BlockAck with a large bitmap
296 * so we need to restrict the size of transmitted aggregation to the
297 * HT size; mac80211 would otherwise pick the HE max (256) by default.
298 */
299 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
300};
301
302const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0 = {
303 .name = "Killer(R) Wireless-AX 1650s Wireless Network Adapter (22560D2W)",
304 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE,
305 IWL_DEVICE_22500,
306 /*
307 * This device doesn't support receiving BlockAck with a large bitmap
308 * so we need to restrict the size of transmitted aggregation to the
309 * HT size; mac80211 would otherwise pick the HE max (256) by default.
310 */
311 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
312};
313
245const struct iwl_cfg iwl22000_2ax_cfg_jf = { 314const struct iwl_cfg iwl22000_2ax_cfg_jf = {
246 .name = "Intel(R) Dual Band Wireless AX 22000", 315 .name = "Intel(R) Dual Band Wireless AX 22000",
247 .fw_name_pre = IWL_QU_B_JF_B_FW_PRE, 316 .fw_name_pre = IWL_QU_B_JF_B_FW_PRE,
@@ -324,3 +393,4 @@ MODULE_FIRMWARE(IWL_22000_JF_B0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
324MODULE_FIRMWARE(IWL_22000_HR_A0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 393MODULE_FIRMWARE(IWL_22000_HR_A0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
325MODULE_FIRMWARE(IWL_22000_SU_Z0_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 394MODULE_FIRMWARE(IWL_22000_SU_Z0_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
326MODULE_FIRMWARE(IWL_QU_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 395MODULE_FIRMWARE(IWL_QU_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
396MODULE_FIRMWARE(IWL_CC_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
index f2114137c13f..113bcf7735a0 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
@@ -73,21 +73,12 @@
73#define IWL9000_SMEM_OFFSET 0x400000 73#define IWL9000_SMEM_OFFSET 0x400000
74#define IWL9000_SMEM_LEN 0x68000 74#define IWL9000_SMEM_LEN 0x68000
75 75
76#define IWL9000A_FW_PRE "iwlwifi-9000-pu-a0-jf-a0-" 76#define IWL9000_FW_PRE "iwlwifi-9000-pu-b0-jf-b0-"
77#define IWL9000B_FW_PRE "iwlwifi-9000-pu-b0-jf-b0-" 77#define IWL9260_FW_PRE "iwlwifi-9260-th-b0-jf-b0-"
78#define IWL9000RFB_FW_PRE "iwlwifi-9000-pu-a0-jf-b0-" 78#define IWL9000_MODULE_FIRMWARE(api) \
79#define IWL9260A_FW_PRE "iwlwifi-9260-th-a0-jf-a0-" 79 IWL9000_FW_PRE __stringify(api) ".ucode"
80#define IWL9260B_FW_PRE "iwlwifi-9260-th-b0-jf-b0-" 80#define IWL9260_MODULE_FIRMWARE(api) \
81#define IWL9000A_MODULE_FIRMWARE(api) \ 81 IWL9260_FW_PRE __stringify(api) ".ucode"
82 IWL9000A_FW_PRE __stringify(api) ".ucode"
83#define IWL9000B_MODULE_FIRMWARE(api) \
84 IWL9000B_FW_PRE __stringify(api) ".ucode"
85#define IWL9000RFB_MODULE_FIRMWARE(api) \
86 IWL9000RFB_FW_PRE __stringify(api) ".ucode"
87#define IWL9260A_MODULE_FIRMWARE(api) \
88 IWL9260A_FW_PRE __stringify(api) ".ucode"
89#define IWL9260B_MODULE_FIRMWARE(api) \
90 IWL9260B_FW_PRE __stringify(api) ".ucode"
91 82
92static const struct iwl_base_params iwl9000_base_params = { 83static const struct iwl_base_params iwl9000_base_params = {
93 .eeprom_size = OTP_LOW_IMAGE_SIZE_32K, 84 .eeprom_size = OTP_LOW_IMAGE_SIZE_32K,
@@ -162,81 +153,87 @@ static const struct iwl_tt_params iwl9000_tt_params = {
162 153
163const struct iwl_cfg iwl9160_2ac_cfg = { 154const struct iwl_cfg iwl9160_2ac_cfg = {
164 .name = "Intel(R) Dual Band Wireless AC 9160", 155 .name = "Intel(R) Dual Band Wireless AC 9160",
165 .fw_name_pre = IWL9260A_FW_PRE, 156 .fw_name_pre = IWL9260_FW_PRE,
166 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
167 IWL_DEVICE_9000, 157 IWL_DEVICE_9000,
168}; 158};
169 159
170const struct iwl_cfg iwl9260_2ac_cfg = { 160const struct iwl_cfg iwl9260_2ac_cfg = {
171 .name = "Intel(R) Dual Band Wireless AC 9260", 161 .name = "Intel(R) Dual Band Wireless AC 9260",
172 .fw_name_pre = IWL9260A_FW_PRE, 162 .fw_name_pre = IWL9260_FW_PRE,
173 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, 163 IWL_DEVICE_9000,
164};
165
166const struct iwl_cfg iwl9260_2ac_160_cfg = {
167 .name = "Intel(R) Wireless-AC 9260 160MHz",
168 .fw_name_pre = IWL9260_FW_PRE,
174 IWL_DEVICE_9000, 169 IWL_DEVICE_9000,
175}; 170};
176 171
177const struct iwl_cfg iwl9260_killer_2ac_cfg = { 172const struct iwl_cfg iwl9260_killer_2ac_cfg = {
178 .name = "Killer (R) Wireless-AC 1550 Wireless Network Adapter (9260NGW)", 173 .name = "Killer (R) Wireless-AC 1550 Wireless Network Adapter (9260NGW)",
179 .fw_name_pre = IWL9260A_FW_PRE, 174 .fw_name_pre = IWL9260_FW_PRE,
180 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
181 IWL_DEVICE_9000, 175 IWL_DEVICE_9000,
182}; 176};
183 177
184const struct iwl_cfg iwl9270_2ac_cfg = { 178const struct iwl_cfg iwl9270_2ac_cfg = {
185 .name = "Intel(R) Dual Band Wireless AC 9270", 179 .name = "Intel(R) Dual Band Wireless AC 9270",
186 .fw_name_pre = IWL9260A_FW_PRE, 180 .fw_name_pre = IWL9260_FW_PRE,
187 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
188 IWL_DEVICE_9000, 181 IWL_DEVICE_9000,
189}; 182};
190 183
191const struct iwl_cfg iwl9460_2ac_cfg = { 184const struct iwl_cfg iwl9460_2ac_cfg = {
192 .name = "Intel(R) Dual Band Wireless AC 9460", 185 .name = "Intel(R) Dual Band Wireless AC 9460",
193 .fw_name_pre = IWL9260A_FW_PRE, 186 .fw_name_pre = IWL9260_FW_PRE,
194 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
195 IWL_DEVICE_9000, 187 IWL_DEVICE_9000,
196}; 188};
197 189
198const struct iwl_cfg iwl9460_2ac_cfg_soc = { 190const struct iwl_cfg iwl9460_2ac_cfg_soc = {
199 .name = "Intel(R) Dual Band Wireless AC 9460", 191 .name = "Intel(R) Dual Band Wireless AC 9460",
200 .fw_name_pre = IWL9000A_FW_PRE, 192 .fw_name_pre = IWL9000_FW_PRE,
201 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
202 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
203 IWL_DEVICE_9000, 193 IWL_DEVICE_9000,
204 .integrated = true, 194 .integrated = true,
205 .soc_latency = 5000, 195 .soc_latency = 5000,
206}; 196};
207 197
208const struct iwl_cfg iwl9461_2ac_cfg_soc = { 198const struct iwl_cfg iwl9461_2ac_cfg_soc = {
209 .name = "Intel(R) Dual Band Wireless AC 9461", 199 .name = "Intel(R) Dual Band Wireless AC 9461",
210 .fw_name_pre = IWL9000A_FW_PRE, 200 .fw_name_pre = IWL9000_FW_PRE,
211 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE, 201 IWL_DEVICE_9000,
212 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 202 .integrated = true,
213 IWL_DEVICE_9000, 203 .soc_latency = 5000,
214 .integrated = true,
215 .soc_latency = 5000,
216}; 204};
217 205
218const struct iwl_cfg iwl9462_2ac_cfg_soc = { 206const struct iwl_cfg iwl9462_2ac_cfg_soc = {
219 .name = "Intel(R) Dual Band Wireless AC 9462", 207 .name = "Intel(R) Dual Band Wireless AC 9462",
220 .fw_name_pre = IWL9000A_FW_PRE, 208 .fw_name_pre = IWL9000_FW_PRE,
221 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE, 209 IWL_DEVICE_9000,
222 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 210 .integrated = true,
223 IWL_DEVICE_9000, 211 .soc_latency = 5000,
224 .integrated = true,
225 .soc_latency = 5000,
226}; 212};
227 213
228const struct iwl_cfg iwl9560_2ac_cfg = { 214const struct iwl_cfg iwl9560_2ac_cfg = {
229 .name = "Intel(R) Dual Band Wireless AC 9560", 215 .name = "Intel(R) Dual Band Wireless AC 9560",
230 .fw_name_pre = IWL9260A_FW_PRE, 216 .fw_name_pre = IWL9260_FW_PRE,
231 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, 217 IWL_DEVICE_9000,
218};
219
220const struct iwl_cfg iwl9560_2ac_160_cfg = {
221 .name = "Intel(R) Wireless-AC 9560 160MHz",
222 .fw_name_pre = IWL9260_FW_PRE,
232 IWL_DEVICE_9000, 223 IWL_DEVICE_9000,
233}; 224};
234 225
235const struct iwl_cfg iwl9560_2ac_cfg_soc = { 226const struct iwl_cfg iwl9560_2ac_cfg_soc = {
236 .name = "Intel(R) Dual Band Wireless AC 9560", 227 .name = "Intel(R) Dual Band Wireless AC 9560",
237 .fw_name_pre = IWL9000A_FW_PRE, 228 .fw_name_pre = IWL9000_FW_PRE,
238 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE, 229 IWL_DEVICE_9000,
239 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 230 .integrated = true,
231 .soc_latency = 5000,
232};
233
234const struct iwl_cfg iwl9560_2ac_160_cfg_soc = {
235 .name = "Intel(R) Wireless-AC 9560 160MHz",
236 .fw_name_pre = IWL9000_FW_PRE,
240 IWL_DEVICE_9000, 237 IWL_DEVICE_9000,
241 .integrated = true, 238 .integrated = true,
242 .soc_latency = 5000, 239 .soc_latency = 5000,
@@ -244,9 +241,7 @@ const struct iwl_cfg iwl9560_2ac_cfg_soc = {
244 241
245const struct iwl_cfg iwl9560_killer_2ac_cfg_soc = { 242const struct iwl_cfg iwl9560_killer_2ac_cfg_soc = {
246 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)", 243 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)",
247 .fw_name_pre = IWL9000A_FW_PRE, 244 .fw_name_pre = IWL9000_FW_PRE,
248 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
249 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
250 IWL_DEVICE_9000, 245 IWL_DEVICE_9000,
251 .integrated = true, 246 .integrated = true,
252 .soc_latency = 5000, 247 .soc_latency = 5000,
@@ -254,9 +249,7 @@ const struct iwl_cfg iwl9560_killer_2ac_cfg_soc = {
254 249
255const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc = { 250const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc = {
256 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)", 251 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)",
257 .fw_name_pre = IWL9000A_FW_PRE, 252 .fw_name_pre = IWL9000_FW_PRE,
258 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
259 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
260 IWL_DEVICE_9000, 253 IWL_DEVICE_9000,
261 .integrated = true, 254 .integrated = true,
262 .soc_latency = 5000, 255 .soc_latency = 5000,
@@ -264,9 +257,7 @@ const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc = {
264 257
265const struct iwl_cfg iwl9460_2ac_cfg_shared_clk = { 258const struct iwl_cfg iwl9460_2ac_cfg_shared_clk = {
266 .name = "Intel(R) Dual Band Wireless AC 9460", 259 .name = "Intel(R) Dual Band Wireless AC 9460",
267 .fw_name_pre = IWL9000A_FW_PRE, 260 .fw_name_pre = IWL9000_FW_PRE,
268 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
269 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
270 IWL_DEVICE_9000, 261 IWL_DEVICE_9000,
271 .integrated = true, 262 .integrated = true,
272 .soc_latency = 5000, 263 .soc_latency = 5000,
@@ -275,9 +266,7 @@ const struct iwl_cfg iwl9460_2ac_cfg_shared_clk = {
275 266
276const struct iwl_cfg iwl9461_2ac_cfg_shared_clk = { 267const struct iwl_cfg iwl9461_2ac_cfg_shared_clk = {
277 .name = "Intel(R) Dual Band Wireless AC 9461", 268 .name = "Intel(R) Dual Band Wireless AC 9461",
278 .fw_name_pre = IWL9000A_FW_PRE, 269 .fw_name_pre = IWL9000_FW_PRE,
279 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
280 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
281 IWL_DEVICE_9000, 270 IWL_DEVICE_9000,
282 .integrated = true, 271 .integrated = true,
283 .soc_latency = 5000, 272 .soc_latency = 5000,
@@ -286,9 +275,7 @@ const struct iwl_cfg iwl9461_2ac_cfg_shared_clk = {
286 275
287const struct iwl_cfg iwl9462_2ac_cfg_shared_clk = { 276const struct iwl_cfg iwl9462_2ac_cfg_shared_clk = {
288 .name = "Intel(R) Dual Band Wireless AC 9462", 277 .name = "Intel(R) Dual Band Wireless AC 9462",
289 .fw_name_pre = IWL9000A_FW_PRE, 278 .fw_name_pre = IWL9000_FW_PRE,
290 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
291 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
292 IWL_DEVICE_9000, 279 IWL_DEVICE_9000,
293 .integrated = true, 280 .integrated = true,
294 .soc_latency = 5000, 281 .soc_latency = 5000,
@@ -297,9 +284,16 @@ const struct iwl_cfg iwl9462_2ac_cfg_shared_clk = {
297 284
298const struct iwl_cfg iwl9560_2ac_cfg_shared_clk = { 285const struct iwl_cfg iwl9560_2ac_cfg_shared_clk = {
299 .name = "Intel(R) Dual Band Wireless AC 9560", 286 .name = "Intel(R) Dual Band Wireless AC 9560",
300 .fw_name_pre = IWL9000A_FW_PRE, 287 .fw_name_pre = IWL9000_FW_PRE,
301 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE, 288 IWL_DEVICE_9000,
302 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 289 .integrated = true,
290 .soc_latency = 5000,
291 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK
292};
293
294const struct iwl_cfg iwl9560_2ac_160_cfg_shared_clk = {
295 .name = "Intel(R) Wireless-AC 9560 160MHz",
296 .fw_name_pre = IWL9000_FW_PRE,
303 IWL_DEVICE_9000, 297 IWL_DEVICE_9000,
304 .integrated = true, 298 .integrated = true,
305 .soc_latency = 5000, 299 .soc_latency = 5000,
@@ -308,9 +302,7 @@ const struct iwl_cfg iwl9560_2ac_cfg_shared_clk = {
308 302
309const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk = { 303const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk = {
310 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)", 304 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)",
311 .fw_name_pre = IWL9000A_FW_PRE, 305 .fw_name_pre = IWL9000_FW_PRE,
312 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
313 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
314 IWL_DEVICE_9000, 306 IWL_DEVICE_9000,
315 .integrated = true, 307 .integrated = true,
316 .soc_latency = 5000, 308 .soc_latency = 5000,
@@ -319,17 +311,12 @@ const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk = {
319 311
320const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk = { 312const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk = {
321 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)", 313 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)",
322 .fw_name_pre = IWL9000A_FW_PRE, 314 .fw_name_pre = IWL9000_FW_PRE,
323 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
324 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
325 IWL_DEVICE_9000, 315 IWL_DEVICE_9000,
326 .integrated = true, 316 .integrated = true,
327 .soc_latency = 5000, 317 .soc_latency = 5000,
328 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK 318 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK
329}; 319};
330 320
331MODULE_FIRMWARE(IWL9000A_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 321MODULE_FIRMWARE(IWL9000_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
332MODULE_FIRMWARE(IWL9000B_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 322MODULE_FIRMWARE(IWL9260_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
333MODULE_FIRMWARE(IWL9000RFB_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
334MODULE_FIRMWARE(IWL9260A_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
335MODULE_FIRMWARE(IWL9260B_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/Makefile b/drivers/net/wireless/intel/iwlwifi/dvm/Makefile
index 702d42b2d452..0486b17d7c41 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/Makefile
@@ -11,4 +11,4 @@ iwldvm-objs += rxon.o devices.o
11iwldvm-$(CONFIG_IWLWIFI_LEDS) += led.o 11iwldvm-$(CONFIG_IWLWIFI_LEDS) += led.o
12iwldvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o 12iwldvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o
13 13
14ccflags-y += -I$(src)/../ 14ccflags-y += -I $(srctree)/$(src)/../
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
index 49b71dbf8490..54b759cec8b3 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
@@ -1,6 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
4 * Copyright (C) 2018 Intel Corporation
4 * 5 *
5 * Portions of this file are derived from the ipw3945 project, as well 6 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 7 * as portions of the ieee80211 subsystem header files.
@@ -710,24 +711,6 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
710 return ret; 711 return ret;
711} 712}
712 713
713static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg)
714{
715 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
716 return false;
717 return true;
718}
719
720static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg)
721{
722 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
723 return false;
724 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
725 return true;
726
727 /* disabled by default */
728 return false;
729}
730
731static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, 714static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
732 struct ieee80211_vif *vif, 715 struct ieee80211_vif *vif,
733 struct ieee80211_ampdu_params *params) 716 struct ieee80211_ampdu_params *params)
@@ -752,7 +735,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
752 735
753 switch (action) { 736 switch (action) {
754 case IEEE80211_AMPDU_RX_START: 737 case IEEE80211_AMPDU_RX_START:
755 if (!iwl_enable_rx_ampdu(priv->cfg)) 738 if (!iwl_enable_rx_ampdu())
756 break; 739 break;
757 IWL_DEBUG_HT(priv, "start Rx\n"); 740 IWL_DEBUG_HT(priv, "start Rx\n");
758 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); 741 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
@@ -764,7 +747,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
764 case IEEE80211_AMPDU_TX_START: 747 case IEEE80211_AMPDU_TX_START:
765 if (!priv->trans->ops->txq_enable) 748 if (!priv->trans->ops->txq_enable)
766 break; 749 break;
767 if (!iwl_enable_tx_ampdu(priv->cfg)) 750 if (!iwl_enable_tx_ampdu())
768 break; 751 break;
769 IWL_DEBUG_HT(priv, "start Tx\n"); 752 IWL_DEBUG_HT(priv, "start Tx\n");
770 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 753 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/main.c b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
index c219bca5cff4..bd3c3b921d4c 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
@@ -1054,7 +1054,7 @@ static void iwl_bg_restart(struct work_struct *data)
1054 ieee80211_restart_hw(priv->hw); 1054 ieee80211_restart_hw(priv->hw);
1055 else 1055 else
1056 IWL_ERR(priv, 1056 IWL_ERR(priv,
1057 "Cannot request restart before registrating with mac80211\n"); 1057 "Cannot request restart before registering with mac80211\n");
1058 } else { 1058 } else {
1059 WARN_ON(1); 1059 WARN_ON(1);
1060 } 1060 }
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/tt.c b/drivers/net/wireless/intel/iwlwifi/dvm/tt.c
index 4de2727ac63e..a156dcf5b7d9 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/tt.c
@@ -1,6 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
4 * Copyright (C) 2018 Intel Corporation
4 * 5 *
5 * Portions of this file are derived from the ipw3945 project, as well 6 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 7 * as portions of the ieee80211 subsystem header files.
@@ -325,9 +326,9 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
325 iwl_prepare_ct_kill_task(priv); 326 iwl_prepare_ct_kill_task(priv);
326 tt->state = old_state; 327 tt->state = old_state;
327 } 328 }
328 } else if (old_state == IWL_TI_CT_KILL && 329 } else if (old_state == IWL_TI_CT_KILL) {
329 tt->state != IWL_TI_CT_KILL)
330 iwl_perform_ct_kill_task(priv, false); 330 iwl_perform_ct_kill_task(priv, false);
331 }
331 IWL_DEBUG_TEMP(priv, "Temperature state changed %u\n", 332 IWL_DEBUG_TEMP(priv, "Temperature state changed %u\n",
332 tt->state); 333 tt->state);
333 IWL_DEBUG_TEMP(priv, "Power Index change to %u\n", 334 IWL_DEBUG_TEMP(priv, "Power Index change to %u\n",
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
index 8b4922bbe139..0290b333d860 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
@@ -77,7 +77,8 @@
77 * @DATA_PATH_GROUP: data path group, uses command IDs from 77 * @DATA_PATH_GROUP: data path group, uses command IDs from
78 * &enum iwl_data_path_subcmd_ids 78 * &enum iwl_data_path_subcmd_ids
79 * @NAN_GROUP: NAN group, uses command IDs from &enum iwl_nan_subcmd_ids 79 * @NAN_GROUP: NAN group, uses command IDs from &enum iwl_nan_subcmd_ids
80 * @TOF_GROUP: TOF group, uses command IDs from &enum iwl_tof_subcmd_ids 80 * @LOCATION_GROUP: location group, uses command IDs from
81 * &enum iwl_location_subcmd_ids
81 * @PROT_OFFLOAD_GROUP: protocol offload group, uses command IDs from 82 * @PROT_OFFLOAD_GROUP: protocol offload group, uses command IDs from
82 * &enum iwl_prot_offload_subcmd_ids 83 * &enum iwl_prot_offload_subcmd_ids
83 * @REGULATORY_AND_NVM_GROUP: regulatory/NVM group, uses command IDs from 84 * @REGULATORY_AND_NVM_GROUP: regulatory/NVM group, uses command IDs from
@@ -92,7 +93,7 @@ enum iwl_mvm_command_groups {
92 PHY_OPS_GROUP = 0x4, 93 PHY_OPS_GROUP = 0x4,
93 DATA_PATH_GROUP = 0x5, 94 DATA_PATH_GROUP = 0x5,
94 NAN_GROUP = 0x7, 95 NAN_GROUP = 0x7,
95 TOF_GROUP = 0x8, 96 LOCATION_GROUP = 0x8,
96 PROT_OFFLOAD_GROUP = 0xb, 97 PROT_OFFLOAD_GROUP = 0xb,
97 REGULATORY_AND_NVM_GROUP = 0xc, 98 REGULATORY_AND_NVM_GROUP = 0xc,
98 DEBUG_GROUP = 0xf, 99 DEBUG_GROUP = 0xf,
@@ -353,16 +354,6 @@ enum iwl_legacy_cmds {
353 PHY_DB_CMD = 0x6c, 354 PHY_DB_CMD = 0x6c,
354 355
355 /** 356 /**
356 * @TOF_CMD: &struct iwl_tof_config_cmd
357 */
358 TOF_CMD = 0x10,
359
360 /**
361 * @TOF_NOTIFICATION: &struct iwl_tof_gen_resp_cmd
362 */
363 TOF_NOTIFICATION = 0x11,
364
365 /**
366 * @POWER_TABLE_CMD: &struct iwl_device_power_cmd 357 * @POWER_TABLE_CMD: &struct iwl_device_power_cmd
367 */ 358 */
368 POWER_TABLE_CMD = 0x77, 359 POWER_TABLE_CMD = 0x77,
@@ -415,7 +406,11 @@ enum iwl_legacy_cmds {
415 TX_ANT_CONFIGURATION_CMD = 0x98, 406 TX_ANT_CONFIGURATION_CMD = 0x98,
416 407
417 /** 408 /**
418 * @STATISTICS_CMD: &struct iwl_statistics_cmd 409 * @STATISTICS_CMD:
410 * one of &struct iwl_statistics_cmd,
411 * &struct iwl_notif_statistics_v11,
412 * &struct iwl_notif_statistics_v10,
413 * &struct iwl_notif_statistics
419 */ 414 */
420 STATISTICS_CMD = 0x9c, 415 STATISTICS_CMD = 0x9c,
421 416
@@ -423,7 +418,7 @@ enum iwl_legacy_cmds {
423 * @STATISTICS_NOTIFICATION: 418 * @STATISTICS_NOTIFICATION:
424 * one of &struct iwl_notif_statistics_v10, 419 * one of &struct iwl_notif_statistics_v10,
425 * &struct iwl_notif_statistics_v11, 420 * &struct iwl_notif_statistics_v11,
426 * &struct iwl_notif_statistics_cdb 421 * &struct iwl_notif_statistics
427 */ 422 */
428 STATISTICS_NOTIFICATION = 0x9d, 423 STATISTICS_NOTIFICATION = 0x9d,
429 424
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/d3.h b/drivers/net/wireless/intel/iwlwifi/fw/api/d3.h
index 6fae02fa4cad..86ea0784e1a3 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/d3.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/d3.h
@@ -224,8 +224,18 @@ struct iwl_wowlan_pattern {
224 224
225#define IWL_WOWLAN_MAX_PATTERNS 20 225#define IWL_WOWLAN_MAX_PATTERNS 20
226 226
227/**
228 * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns
229 */
227struct iwl_wowlan_patterns_cmd { 230struct iwl_wowlan_patterns_cmd {
231 /**
232 * @n_patterns: number of patterns
233 */
228 __le32 n_patterns; 234 __le32 n_patterns;
235
236 /**
237 * @patterns: the patterns, array length in @n_patterns
238 */
229 struct iwl_wowlan_pattern patterns[]; 239 struct iwl_wowlan_pattern patterns[];
230} __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */ 240} __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */
231 241
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
index fdc54a5dc9de..93c06e6c1ced 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
@@ -105,6 +105,12 @@ enum iwl_data_path_subcmd_ids {
105 HE_AIR_SNIFFER_CONFIG_CMD = 0x13, 105 HE_AIR_SNIFFER_CONFIG_CMD = 0x13,
106 106
107 /** 107 /**
108 * @CHEST_COLLECTOR_FILTER_CONFIG_CMD: Configure the CSI
109 * matrix collection, uses &struct iwl_channel_estimation_cfg
110 */
111 CHEST_COLLECTOR_FILTER_CONFIG_CMD = 0x14,
112
113 /**
108 * @RX_NO_DATA_NOTIF: &struct iwl_rx_no_data 114 * @RX_NO_DATA_NOTIF: &struct iwl_rx_no_data
109 */ 115 */
110 RX_NO_DATA_NOTIF = 0xF5, 116 RX_NO_DATA_NOTIF = 0xF5,
@@ -156,4 +162,53 @@ struct iwl_mu_group_mgmt_notif {
156 __le32 user_position[4]; 162 __le32 user_position[4];
157} __packed; /* MU_GROUP_MNG_NTFY_API_S_VER_1 */ 163} __packed; /* MU_GROUP_MNG_NTFY_API_S_VER_1 */
158 164
165enum iwl_channel_estimation_flags {
166 IWL_CHANNEL_ESTIMATION_ENABLE = BIT(0),
167 IWL_CHANNEL_ESTIMATION_TIMER = BIT(1),
168 IWL_CHANNEL_ESTIMATION_COUNTER = BIT(2),
169};
170
171/**
172 * struct iwl_channel_estimation_cfg - channel estimation reporting config
173 */
174struct iwl_channel_estimation_cfg {
175 /**
176 * @flags: flags, see &enum iwl_channel_estimation_flags
177 */
178 __le32 flags;
179 /**
180 * @timer: if enabled via flags, automatically disable after this many
181 * microseconds
182 */
183 __le32 timer;
184 /**
185 * @count: if enabled via flags, automatically disable after this many
186 * frames with channel estimation matrix were captured
187 */
188 __le32 count;
189 /**
190 * @rate_n_flags_mask: only try to record the channel estimation matrix
191 * if the rate_n_flags value for the received frame (let's call
192 * that rx_rnf) matches the mask/value given here like this:
193 * (rx_rnf & rate_n_flags_mask) == rate_n_flags_val.
194 */
195 __le32 rate_n_flags_mask;
196 /**
197 * @rate_n_flags_val: see @rate_n_flags_mask
198 */
199 __le32 rate_n_flags_val;
200 /**
201 * @reserved: reserved (for alignment)
202 */
203 __le32 reserved;
204 /**
205 * @frame_types: bitmap of frame types to capture, the received frame's
206 * subtype|type takes 6 bits in the frame and the corresponding bit
207 * in this field must be set to 1 to capture channel estimation for
208 * that frame type. Set to all-ones to enable capturing for all
209 * frame types.
210 */
211 __le64 frame_types;
212} __packed; /* CHEST_COLLECTOR_FILTER_CMD_API_S_VER_1 */
213
159#endif /* __iwl_fw_api_datapath_h__ */ 214#endif /* __iwl_fw_api_datapath_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
index dc1fa377087a..988584973aba 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
@@ -335,29 +335,11 @@ struct iwl_dbg_mem_access_rsp {
335 __le32 data[]; 335 __le32 data[];
336} __packed; /* DEBUG_(U|L)MAC_RD_WR_RSP_API_S_VER_1 */ 336} __packed; /* DEBUG_(U|L)MAC_RD_WR_RSP_API_S_VER_1 */
337 337
338#define CONT_REC_COMMAND_SIZE 80 338#define LDBG_CFG_COMMAND_SIZE 80
339#define ENABLE_CONT_RECORDING 0x15
340#define DISABLE_CONT_RECORDING 0x16
341#define BUFFER_ALLOCATION 0x27 339#define BUFFER_ALLOCATION 0x27
342#define START_DEBUG_RECORDING 0x29 340#define START_DEBUG_RECORDING 0x29
343#define STOP_DEBUG_RECORDING 0x2A 341#define STOP_DEBUG_RECORDING 0x2A
344 342
345/*
346 * struct iwl_continuous_record_mode - recording mode
347 */
348struct iwl_continuous_record_mode {
349 __le16 enable_recording;
350} __packed;
351
352/*
353 * struct iwl_continuous_record_cmd - enable/disable continuous recording
354 */
355struct iwl_continuous_record_cmd {
356 struct iwl_continuous_record_mode record_mode;
357 u8 pad[CONT_REC_COMMAND_SIZE -
358 sizeof(struct iwl_continuous_record_mode)];
359} __packed;
360
361/* maximum fragments to be allocated per target of allocationId */ 343/* maximum fragments to be allocated per target of allocationId */
362#define IWL_BUFFER_LOCATION_MAX_FRAGS 2 344#define IWL_BUFFER_LOCATION_MAX_FRAGS 2
363 345
@@ -385,4 +367,17 @@ struct iwl_buffer_allocation_cmd {
385 struct iwl_fragment_data fragments[IWL_BUFFER_LOCATION_MAX_FRAGS]; 367 struct iwl_fragment_data fragments[IWL_BUFFER_LOCATION_MAX_FRAGS];
386} __packed; /* BUFFER_ALLOCATION_CMD_API_S_VER_1 */ 368} __packed; /* BUFFER_ALLOCATION_CMD_API_S_VER_1 */
387 369
370/**
371 * struct iwl_ldbg_config_cmd - LDBG config command
372 * @type: configuration type
373 * @pad: reserved space for type-dependent data
374 */
375struct iwl_ldbg_config_cmd {
376 __le32 type;
377 union {
378 u8 pad[LDBG_CFG_COMMAND_SIZE - sizeof(__le32)];
379 struct iwl_buffer_allocation_cmd buffer_allocation;
380 }; /* LDBG_CFG_BODY_API_U_VER_2 (partially) */
381} __packed; /* LDBG_CFG_CMD_API_S_VER_2 */
382
388#endif /* __iwl_fw_api_debug_h__ */ 383#endif /* __iwl_fw_api_debug_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h
new file mode 100644
index 000000000000..6da91ec0df55
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h
@@ -0,0 +1,711 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
9 * Copyright (C) 2018 Intel Corporation
10 *
11 * 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 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called COPYING.
22 *
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *
27 * BSD LICENSE
28 *
29 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
30 * Copyright (C) 2018 Intel Corporation
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 *
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
41 * the documentation and/or other materials provided with the
42 * distribution.
43 * * Neither the name Intel Corporation nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *
59 *****************************************************************************/
60#ifndef __iwl_fw_api_location_h__
61#define __iwl_fw_api_location_h__
62
63/**
64 * enum iwl_location_subcmd_ids - location group command IDs
65 */
66enum iwl_location_subcmd_ids {
67 /**
68 * @TOF_RANGE_REQ_CMD: TOF ranging request,
69 * uses &struct iwl_tof_range_req_cmd
70 */
71 TOF_RANGE_REQ_CMD = 0x0,
72 /**
73 * @TOF_CONFIG_CMD: TOF configuration, uses &struct iwl_tof_config_cmd
74 */
75 TOF_CONFIG_CMD = 0x1,
76 /**
77 * @TOF_RANGE_ABORT_CMD: abort ongoing ranging, uses
78 * &struct iwl_tof_range_abort_cmd
79 */
80 TOF_RANGE_ABORT_CMD = 0x2,
81 /**
82 * @TOF_RANGE_REQ_EXT_CMD: TOF extended ranging config,
83 * uses &struct iwl_tof_range_request_ext_cmd
84 */
85 TOF_RANGE_REQ_EXT_CMD = 0x3,
86 /**
87 * @TOF_RESPONDER_CONFIG_CMD: FTM responder configuration,
88 * uses &struct iwl_tof_responder_config_cmd
89 */
90 TOF_RESPONDER_CONFIG_CMD = 0x4,
91 /**
92 * @TOF_RESPONDER_DYN_CONFIG_CMD: FTM dynamic configuration,
93 * uses &struct iwl_tof_responder_dyn_config_cmd
94 */
95 TOF_RESPONDER_DYN_CONFIG_CMD = 0x5,
96 /**
97 * @CSI_HEADER_NOTIFICATION: CSI header
98 */
99 CSI_HEADER_NOTIFICATION = 0xFA,
100 /**
101 * @CSI_CHUNKS_NOTIFICATION: CSI chunk,
102 * uses &struct iwl_csi_chunk_notification
103 */
104 CSI_CHUNKS_NOTIFICATION = 0xFB,
105 /**
106 * @TOF_LC_NOTIF: used for LCI/civic location, contains just
107 * the action frame
108 */
109 TOF_LC_NOTIF = 0xFC,
110 /**
111 * @TOF_RESPONDER_STATS: FTM responder statistics notification,
112 * uses &struct iwl_ftm_responder_stats
113 */
114 TOF_RESPONDER_STATS = 0xFD,
115 /**
116 * @TOF_MCSI_DEBUG_NOTIF: MCSI debug notification, uses
117 * &struct iwl_tof_mcsi_notif
118 */
119 TOF_MCSI_DEBUG_NOTIF = 0xFE,
120 /**
121 * @TOF_RANGE_RESPONSE_NOTIF: ranging response, using
122 * &struct iwl_tof_range_rsp_ntfy
123 */
124 TOF_RANGE_RESPONSE_NOTIF = 0xFF,
125};
126
127/**
128 * struct iwl_tof_config_cmd - ToF configuration
129 * @tof_disabled: indicates if ToF is disabled (or not)
130 * @one_sided_disabled: indicates if one-sided is disabled (or not)
131 * @is_debug_mode: indiciates if debug mode is active
132 * @is_buf_required: indicates if channel estimation buffer is required
133 */
134struct iwl_tof_config_cmd {
135 u8 tof_disabled;
136 u8 one_sided_disabled;
137 u8 is_debug_mode;
138 u8 is_buf_required;
139} __packed;
140
141/**
142 * enum iwl_tof_bandwidth - values for iwl_tof_range_req_ap_entry.bandwidth
143 * @IWL_TOF_BW_20_LEGACY: 20 MHz non-HT
144 * @IWL_TOF_BW_20_HT: 20 MHz HT
145 * @IWL_TOF_BW_40: 40 MHz
146 * @IWL_TOF_BW_80: 80 MHz
147 * @IWL_TOF_BW_160: 160 MHz
148 */
149enum iwl_tof_bandwidth {
150 IWL_TOF_BW_20_LEGACY,
151 IWL_TOF_BW_20_HT,
152 IWL_TOF_BW_40,
153 IWL_TOF_BW_80,
154 IWL_TOF_BW_160,
155}; /* LOCAT_BW_TYPE_E */
156
157/*
158 * enum iwl_tof_algo_type - Algorithym type for range measurement request
159 */
160enum iwl_tof_algo_type {
161 IWL_TOF_ALGO_TYPE_MAX_LIKE = 0,
162 IWL_TOF_ALGO_TYPE_LINEAR_REG = 1,
163 IWL_TOF_ALGO_TYPE_FFT = 2,
164
165 /* Keep last */
166 IWL_TOF_ALGO_TYPE_INVALID,
167}; /* ALGO_TYPE_E */
168
169/*
170 * enum iwl_tof_mcsi_ntfy - Enable/Disable MCSI notifications
171 */
172enum iwl_tof_mcsi_enable {
173 IWL_TOF_MCSI_DISABLED = 0,
174 IWL_TOF_MCSI_ENABLED = 1,
175}; /* MCSI_ENABLE_E */
176
177/**
178 * enum iwl_tof_responder_cmd_valid_field - valid fields in the responder cfg
179 * @IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO: channel info is valid
180 * @IWL_TOF_RESPONDER_CMD_VALID_TOA_OFFSET: ToA offset is valid
181 * @IWL_TOF_RESPONDER_CMD_VALID_COMMON_CALIB: common calibration mode is valid
182 * @IWL_TOF_RESPONDER_CMD_VALID_SPECIFIC_CALIB: spefici calibration mode is
183 * valid
184 * @IWL_TOF_RESPONDER_CMD_VALID_BSSID: BSSID is valid
185 * @IWL_TOF_RESPONDER_CMD_VALID_TX_ANT: TX antenna is valid
186 * @IWL_TOF_RESPONDER_CMD_VALID_ALGO_TYPE: algorithm type is valid
187 * @IWL_TOF_RESPONDER_CMD_VALID_NON_ASAP_SUPPORT: non-ASAP support is valid
188 * @IWL_TOF_RESPONDER_CMD_VALID_STATISTICS_REPORT_SUPPORT: statistics report
189 * support is valid
190 * @IWL_TOF_RESPONDER_CMD_VALID_MCSI_NOTIF_SUPPORT: MCSI notification support
191 * is valid
192 * @IWL_TOF_RESPONDER_CMD_VALID_FAST_ALGO_SUPPORT: fast algorithm support
193 * is valid
194 * @IWL_TOF_RESPONDER_CMD_VALID_RETRY_ON_ALGO_FAIL: retry on algorithm failure
195 * is valid
196 * @IWL_TOF_RESPONDER_CMD_VALID_STA_ID: station ID is valid
197 */
198enum iwl_tof_responder_cmd_valid_field {
199 IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO = BIT(0),
200 IWL_TOF_RESPONDER_CMD_VALID_TOA_OFFSET = BIT(1),
201 IWL_TOF_RESPONDER_CMD_VALID_COMMON_CALIB = BIT(2),
202 IWL_TOF_RESPONDER_CMD_VALID_SPECIFIC_CALIB = BIT(3),
203 IWL_TOF_RESPONDER_CMD_VALID_BSSID = BIT(4),
204 IWL_TOF_RESPONDER_CMD_VALID_TX_ANT = BIT(5),
205 IWL_TOF_RESPONDER_CMD_VALID_ALGO_TYPE = BIT(6),
206 IWL_TOF_RESPONDER_CMD_VALID_NON_ASAP_SUPPORT = BIT(7),
207 IWL_TOF_RESPONDER_CMD_VALID_STATISTICS_REPORT_SUPPORT = BIT(8),
208 IWL_TOF_RESPONDER_CMD_VALID_MCSI_NOTIF_SUPPORT = BIT(9),
209 IWL_TOF_RESPONDER_CMD_VALID_FAST_ALGO_SUPPORT = BIT(10),
210 IWL_TOF_RESPONDER_CMD_VALID_RETRY_ON_ALGO_FAIL = BIT(11),
211 IWL_TOF_RESPONDER_CMD_VALID_STA_ID = BIT(12),
212};
213
214/**
215 * enum iwl_tof_responder_cfg_flags - responder configuration flags
216 * @IWL_TOF_RESPONDER_FLAGS_NON_ASAP_SUPPORT: non-ASAP support
217 * @IWL_TOF_RESPONDER_FLAGS_REPORT_STATISTICS: report statistics
218 * @IWL_TOF_RESPONDER_FLAGS_REPORT_MCSI: report MCSI
219 * @IWL_TOF_RESPONDER_FLAGS_ALGO_TYPE: algorithm type
220 * @IWL_TOF_RESPONDER_FLAGS_TOA_OFFSET_MODE: ToA offset mode
221 * @IWL_TOF_RESPONDER_FLAGS_COMMON_CALIB_MODE: common calibration mode
222 * @IWL_TOF_RESPONDER_FLAGS_SPECIFIC_CALIB_MODE: specific calibration mode
223 * @IWL_TOF_RESPONDER_FLAGS_FAST_ALGO_SUPPORT: fast algorithm support
224 * @IWL_TOF_RESPONDER_FLAGS_RETRY_ON_ALGO_FAIL: retry on algorithm fail
225 * @IWL_TOF_RESPONDER_FLAGS_FTM_TX_ANT: TX antenna mask
226 */
227enum iwl_tof_responder_cfg_flags {
228 IWL_TOF_RESPONDER_FLAGS_NON_ASAP_SUPPORT = BIT(0),
229 IWL_TOF_RESPONDER_FLAGS_REPORT_STATISTICS = BIT(1),
230 IWL_TOF_RESPONDER_FLAGS_REPORT_MCSI = BIT(2),
231 IWL_TOF_RESPONDER_FLAGS_ALGO_TYPE = BIT(3) | BIT(4) | BIT(5),
232 IWL_TOF_RESPONDER_FLAGS_TOA_OFFSET_MODE = BIT(6),
233 IWL_TOF_RESPONDER_FLAGS_COMMON_CALIB_MODE = BIT(7),
234 IWL_TOF_RESPONDER_FLAGS_SPECIFIC_CALIB_MODE = BIT(8),
235 IWL_TOF_RESPONDER_FLAGS_FAST_ALGO_SUPPORT = BIT(9),
236 IWL_TOF_RESPONDER_FLAGS_RETRY_ON_ALGO_FAIL = BIT(10),
237 IWL_TOF_RESPONDER_FLAGS_FTM_TX_ANT = RATE_MCS_ANT_ABC_MSK,
238};
239
240/**
241 * struct iwl_tof_responder_config_cmd - ToF AP mode (for debug)
242 * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
243 * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
244 * @bandwidth: current AP Bandwidth: &enum iwl_tof_bandwidth
245 * @rate: current AP rate
246 * @channel_num: current AP Channel
247 * @ctrl_ch_position: coding of the control channel position relative to
248 * the center frequency, see iwl_mvm_get_ctrl_pos()
249 * @sta_id: index of the AP STA when in AP mode
250 * @reserved1: reserved
251 * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
252 * purposes, simulating station movement by adding various values
253 * to this field
254 * @common_calib: XVT: common calibration value
255 * @specific_calib: XVT: specific calibration value
256 * @bssid: Current AP BSSID
257 * @reserved2: reserved
258 */
259struct iwl_tof_responder_config_cmd {
260 __le32 cmd_valid_fields;
261 __le32 responder_cfg_flags;
262 u8 bandwidth;
263 u8 rate;
264 u8 channel_num;
265 u8 ctrl_ch_position;
266 u8 sta_id;
267 u8 reserved1;
268 __le16 toa_offset;
269 __le16 common_calib;
270 __le16 specific_calib;
271 u8 bssid[ETH_ALEN];
272 __le16 reserved2;
273} __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_6 */
274
275#define IWL_LCI_CIVIC_IE_MAX_SIZE 400
276
277/**
278 * struct iwl_tof_responder_dyn_config_cmd - Dynamic responder settings
279 * @lci_len: The length of the 1st (LCI) part in the @lci_civic buffer
280 * @civic_len: The length of the 2nd (CIVIC) part in the @lci_civic buffer
281 * @lci_civic: The LCI/CIVIC buffer. LCI data (if exists) comes first, then, if
282 * needed, 0-padding such that the next part is dword-aligned, then CIVIC
283 * data (if exists) follows, and then 0-padding again to complete a
284 * 4-multiple long buffer.
285 */
286struct iwl_tof_responder_dyn_config_cmd {
287 __le32 lci_len;
288 __le32 civic_len;
289 u8 lci_civic[];
290} __packed; /* TOF_RESPONDER_DYN_CONFIG_CMD_API_S_VER_2 */
291
292/**
293 * struct iwl_tof_range_request_ext_cmd - extended range req for WLS
294 * @tsf_timer_offset_msec: the recommended time offset (mSec) from the AP's TSF
295 * @reserved: reserved
296 * @min_delta_ftm: Minimal time between two consecutive measurements,
297 * in units of 100us. 0 means no preference by station
298 * @ftm_format_and_bw20M: FTM Channel Spacing/Format for 20MHz: recommended
299 * value be sent to the AP
300 * @ftm_format_and_bw40M: FTM Channel Spacing/Format for 40MHz: recommended
301 * value to be sent to the AP
302 * @ftm_format_and_bw80M: FTM Channel Spacing/Format for 80MHz: recommended
303 * value to be sent to the AP
304 */
305struct iwl_tof_range_req_ext_cmd {
306 __le16 tsf_timer_offset_msec;
307 __le16 reserved;
308 u8 min_delta_ftm;
309 u8 ftm_format_and_bw20M;
310 u8 ftm_format_and_bw40M;
311 u8 ftm_format_and_bw80M;
312} __packed;
313
314/**
315 * enum iwl_tof_location_query - values for query bitmap
316 * @IWL_TOF_LOC_LCI: query LCI
317 * @IWL_TOF_LOC_CIVIC: query civic
318 */
319enum iwl_tof_location_query {
320 IWL_TOF_LOC_LCI = 0x01,
321 IWL_TOF_LOC_CIVIC = 0x02,
322};
323
324 /**
325 * struct iwl_tof_range_req_ap_entry - AP configuration parameters
326 * @channel_num: Current AP Channel
327 * @bandwidth: Current AP Bandwidth. One of iwl_tof_bandwidth.
328 * @tsf_delta_direction: TSF relatively to the subject AP
329 * @ctrl_ch_position: Coding of the control channel position relative to the
330 * center frequency, see iwl_mvm_get_ctrl_pos().
331 * @bssid: AP's BSSID
332 * @measure_type: Measurement type: 0 - two sided, 1 - One sided
333 * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of the
334 * number of measurement iterations (min 2^0 = 1, max 2^14)
335 * @burst_period: Recommended value to be sent to the AP. Measurement
336 * periodicity In units of 100ms. ignored if num_of_bursts = 0
337 * @samples_per_burst: 2-sided: the number of FTMs pairs in single Burst (1-31);
338 * 1-sided: how many rts/cts pairs should be used per burst.
339 * @retries_per_sample: Max number of retries that the LMAC should send
340 * in case of no replies by the AP.
341 * @tsf_delta: TSF Delta in units of microseconds.
342 * The difference between the AP TSF and the device local clock.
343 * @location_req: Location Request Bit[0] LCI should be sent in the FTMR;
344 * Bit[1] Civic should be sent in the FTMR
345 * @asap_mode: 0 - non asap mode, 1 - asap mode (not relevant for one sided)
346 * @enable_dyn_ack: Enable Dynamic ACK BW.
347 * 0: Initiator interact with regular AP;
348 * 1: Initiator interact with Responder machine: need to send the
349 * Initiator Acks with HT 40MHz / 80MHz, since the Responder should
350 * use it for its ch est measurement (this flag will be set when we
351 * configure the opposite machine to be Responder).
352 * @rssi: Last received value
353 * legal values: -128-0 (0x7f). above 0x0 indicating an invalid value.
354 * @algo_type: &enum iwl_tof_algo_type
355 * @notify_mcsi: &enum iwl_tof_mcsi_ntfy.
356 * @reserved: For alignment and future use
357 */
358struct iwl_tof_range_req_ap_entry {
359 u8 channel_num;
360 u8 bandwidth;
361 u8 tsf_delta_direction;
362 u8 ctrl_ch_position;
363 u8 bssid[ETH_ALEN];
364 u8 measure_type;
365 u8 num_of_bursts;
366 __le16 burst_period;
367 u8 samples_per_burst;
368 u8 retries_per_sample;
369 __le32 tsf_delta;
370 u8 location_req;
371 u8 asap_mode;
372 u8 enable_dyn_ack;
373 s8 rssi;
374 u8 algo_type;
375 u8 notify_mcsi;
376 __le16 reserved;
377} __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_3 */
378
379/**
380 * enum iwl_tof_response_mode
381 * @IWL_MVM_TOF_RESPONSE_ASAP: report each AP measurement separately as soon as
382 * possible (not supported for this release)
383 * @IWL_MVM_TOF_RESPONSE_TIMEOUT: report all AP measurements as a batch upon
384 * timeout expiration
385 * @IWL_MVM_TOF_RESPONSE_COMPLETE: report all AP measurements as a batch at the
386 * earlier of: measurements completion / timeout
387 * expiration.
388 */
389enum iwl_tof_response_mode {
390 IWL_MVM_TOF_RESPONSE_ASAP,
391 IWL_MVM_TOF_RESPONSE_TIMEOUT,
392 IWL_MVM_TOF_RESPONSE_COMPLETE,
393};
394
395/**
396 * enum iwl_tof_initiator_flags
397 *
398 * @IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED: disable fast algo, meaning run
399 * the algo on ant A+B, instead of only one of them.
400 * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A: open RX antenna A for FTMs RX
401 * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B: open RX antenna B for FTMs RX
402 * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C: open RX antenna C for FTMs RX
403 * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A: use antenna A fo TX ACKs during FTM
404 * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B: use antenna B fo TX ACKs during FTM
405 * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C: use antenna C fo TX ACKs during FTM
406 * @IWL_TOF_INITIATOR_FLAGS_MINDELTA_NO_PREF: no preference for minDeltaFTM
407 */
408enum iwl_tof_initiator_flags {
409 IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED = BIT(0),
410 IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A = BIT(1),
411 IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B = BIT(2),
412 IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C = BIT(3),
413 IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A = BIT(4),
414 IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B = BIT(5),
415 IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C = BIT(6),
416 IWL_TOF_INITIATOR_FLAGS_MINDELTA_NO_PREF = BIT(7),
417}; /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
418
419#define IWL_MVM_TOF_MAX_APS 5
420#define IWL_MVM_TOF_MAX_TWO_SIDED_APS 5
421
422/**
423 * struct iwl_tof_range_req_cmd - start measurement cmd
424 * @initiator_flags: see flags @ iwl_tof_initiator_flags
425 * @request_id: A Token incremented per request. The same Token will be
426 * sent back in the range response
427 * @initiator: 0- NW initiated, 1 - Client Initiated
428 * @one_sided_los_disable: '0'- run ML-Algo for both ToF/OneSided,
429 * '1' - run ML-Algo for ToF only
430 * @req_timeout: Requested timeout of the response in units of 100ms.
431 * This is equivalent to the session time configured to the
432 * LMAC in Initiator Request
433 * @report_policy: Supported partially for this release: For current release -
434 * the range report will be uploaded as a batch when ready or
435 * when the session is done (successfully / partially).
436 * one of iwl_tof_response_mode.
437 * @reserved0: reserved
438 * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
439 * @macaddr_random: '0' Use default source MAC address (i.e. p2_p),
440 * '1' Use MAC Address randomization according to the below
441 * @range_req_bssid: ranging request BSSID
442 * @macaddr_template: MAC address template to use for non-randomized bits
443 * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
444 * Bits set to 1 shall be randomized by the UMAC
445 * @ftm_rx_chains: Rx chain to open to receive Responder's FTMs (XVT)
446 * @ftm_tx_chains: Tx chain to send the ack to the Responder FTM (XVT)
447 * @common_calib: The common calib value to inject to this measurement calc
448 * @specific_calib: The specific calib value to inject to this measurement calc
449 * @ap: per-AP request data
450 */
451struct iwl_tof_range_req_cmd {
452 __le32 initiator_flags;
453 u8 request_id;
454 u8 initiator;
455 u8 one_sided_los_disable;
456 u8 req_timeout;
457 u8 report_policy;
458 u8 reserved0;
459 u8 num_of_ap;
460 u8 macaddr_random;
461 u8 range_req_bssid[ETH_ALEN];
462 u8 macaddr_template[ETH_ALEN];
463 u8 macaddr_mask[ETH_ALEN];
464 u8 ftm_rx_chains;
465 u8 ftm_tx_chains;
466 __le16 common_calib;
467 __le16 specific_calib;
468 struct iwl_tof_range_req_ap_entry ap[IWL_MVM_TOF_MAX_APS];
469} __packed;
470/* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
471
472/*
473 * enum iwl_tof_range_request_status - status of the sent request
474 * @IWL_TOF_RANGE_REQUEST_STATUS_SUCCESSFUL - FW successfully received the
475 * request
476 * @IWL_TOF_RANGE_REQUEST_STATUS_BUSY - FW is busy with a previous request, the
477 * sent request will not be handled
478 */
479enum iwl_tof_range_request_status {
480 IWL_TOF_RANGE_REQUEST_STATUS_SUCCESS,
481 IWL_TOF_RANGE_REQUEST_STATUS_BUSY,
482};
483
484/**
485 * enum iwl_tof_entry_status
486 *
487 * @IWL_TOF_ENTRY_SUCCESS: successful measurement.
488 * @IWL_TOF_ENTRY_GENERAL_FAILURE: General failure.
489 * @IWL_TOF_ENTRY_NO_RESPONSE: Responder didn't reply to the request.
490 * @IWL_TOF_ENTRY_REQUEST_REJECTED: Responder rejected the request.
491 * @IWL_TOF_ENTRY_NOT_SCHEDULED: Time event was scheduled but not called yet.
492 * @IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT: Time event triggered but no
493 * measurement was completed.
494 * @IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE: No range due inability to switch
495 * from the primary channel.
496 * @IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED: Device doesn't support FTM.
497 * @IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON: Request aborted due to unknown
498 * reason.
499 * @IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP: Failure due to invalid
500 * T1/T4.
501 * @IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE: Failure due to invalid FTM frame
502 * structure.
503 * @IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED: Request cannot be scheduled.
504 * @IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE: Responder cannot serve the
505 * initiator for some period, period supplied in @refusal_period.
506 * @IWL_TOF_ENTRY_BAD_REQUEST_ARGS: Bad request arguments.
507 * @IWL_TOF_ENTRY_WIFI_NOT_ENABLED: Wifi not enabled.
508 * @IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS: Responder override the original
509 * parameters within the current session.
510 */
511enum iwl_tof_entry_status {
512 IWL_TOF_ENTRY_SUCCESS = 0,
513 IWL_TOF_ENTRY_GENERAL_FAILURE = 1,
514 IWL_TOF_ENTRY_NO_RESPONSE = 2,
515 IWL_TOF_ENTRY_REQUEST_REJECTED = 3,
516 IWL_TOF_ENTRY_NOT_SCHEDULED = 4,
517 IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT = 5,
518 IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE = 6,
519 IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED = 7,
520 IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON = 8,
521 IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP = 9,
522 IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE = 10,
523 IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED = 11,
524 IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE = 12,
525 IWL_TOF_ENTRY_BAD_REQUEST_ARGS = 13,
526 IWL_TOF_ENTRY_WIFI_NOT_ENABLED = 14,
527 IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS = 15,
528}; /* LOCATION_RANGE_RSP_AP_ENTRY_NTFY_API_S_VER_2 */
529
530/**
531 * struct iwl_tof_range_rsp_ap_entry_ntfy - AP parameters (response)
532 * @bssid: BSSID of the AP
533 * @measure_status: current APs measurement status, one of
534 * &enum iwl_tof_entry_status.
535 * @measure_bw: Current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
536 * @rtt: The Round Trip Time that took for the last measurement for
537 * current AP [pSec]
538 * @rtt_variance: The Variance of the RTT values measured for current AP
539 * @rtt_spread: The Difference between the maximum and the minimum RTT
540 * values measured for current AP in the current session [pSec]
541 * @rssi: RSSI as uploaded in the Channel Estimation notification
542 * @rssi_spread: The Difference between the maximum and the minimum RSSI values
543 * measured for current AP in the current session
544 * @reserved: reserved
545 * @refusal_period: refusal period in case of
546 * @IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
547 * @range: Measured range [cm]
548 * @range_variance: Measured range variance [cm]
549 * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
550 * uploaded by the LMAC
551 * @t2t3_initiator: as calculated from the algo in the initiator
552 * @t1t4_responder: as calculated from the algo in the responder
553 * @common_calib: Calib val that was used in for this AP measurement
554 * @specific_calib: val that was used in for this AP measurement
555 * @papd_calib_output: The result of the tof papd calibration that was injected
556 * into the algorithm.
557 */
558struct iwl_tof_range_rsp_ap_entry_ntfy {
559 u8 bssid[ETH_ALEN];
560 u8 measure_status;
561 u8 measure_bw;
562 __le32 rtt;
563 __le32 rtt_variance;
564 __le32 rtt_spread;
565 s8 rssi;
566 u8 rssi_spread;
567 u8 reserved;
568 u8 refusal_period;
569 __le32 range;
570 __le32 range_variance;
571 __le32 timestamp;
572 __le32 t2t3_initiator;
573 __le32 t1t4_responder;
574 __le16 common_calib;
575 __le16 specific_calib;
576 __le32 papd_calib_output;
577} __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_3 */
578
579/**
580 * enum iwl_tof_response_status - tof response status
581 *
582 * @IWL_TOF_RESPONSE_SUCCESS: successful range.
583 * @IWL_TOF_RESPONSE_TIMEOUT: request aborted due to timeout expiration.
584 * partial result of ranges done so far is included in the response.
585 * @IWL_TOF_RESPONSE_ABORTED: Measurement aborted by command.
586 * @IWL_TOF_RESPONSE_FAILED: Measurement request command failed.
587 */
588enum iwl_tof_response_status {
589 IWL_TOF_RESPONSE_SUCCESS = 0,
590 IWL_TOF_RESPONSE_TIMEOUT = 1,
591 IWL_TOF_RESPONSE_ABORTED = 4,
592 IWL_TOF_RESPONSE_FAILED = 5,
593}; /* LOCATION_RNG_RSP_STATUS */
594
595/**
596 * struct iwl_tof_range_rsp_ntfy - ranging response notification
597 * @request_id: A Token ID of the corresponding Range request
598 * @request_status: status of current measurement session, one of
599 * &enum iwl_tof_response_status.
600 * @last_in_batch: reprot policy (when not all responses are uploaded at once)
601 * @num_of_aps: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
602 * @ap: per-AP data
603 */
604struct iwl_tof_range_rsp_ntfy {
605 u8 request_id;
606 u8 request_status;
607 u8 last_in_batch;
608 u8 num_of_aps;
609 struct iwl_tof_range_rsp_ap_entry_ntfy ap[IWL_MVM_TOF_MAX_APS];
610} __packed;
611
612#define IWL_MVM_TOF_MCSI_BUF_SIZE (245)
613/**
614 * struct iwl_tof_mcsi_notif - used for debug
615 * @token: token ID for the current session
616 * @role: '0' - initiator, '1' - responder
617 * @reserved: reserved
618 * @initiator_bssid: initiator machine
619 * @responder_bssid: responder machine
620 * @mcsi_buffer: debug data
621 */
622struct iwl_tof_mcsi_notif {
623 u8 token;
624 u8 role;
625 __le16 reserved;
626 u8 initiator_bssid[ETH_ALEN];
627 u8 responder_bssid[ETH_ALEN];
628 u8 mcsi_buffer[IWL_MVM_TOF_MCSI_BUF_SIZE * 4];
629} __packed;
630
631/**
632 * struct iwl_tof_range_abort_cmd
633 * @request_id: corresponds to a range request
634 * @reserved: reserved
635 */
636struct iwl_tof_range_abort_cmd {
637 u8 request_id;
638 u8 reserved[3];
639} __packed;
640
641enum ftm_responder_stats_flags {
642 FTM_RESP_STAT_NON_ASAP_STARTED = BIT(0),
643 FTM_RESP_STAT_NON_ASAP_IN_WIN = BIT(1),
644 FTM_RESP_STAT_NON_ASAP_OUT_WIN = BIT(2),
645 FTM_RESP_STAT_TRIGGER_DUP = BIT(3),
646 FTM_RESP_STAT_DUP = BIT(4),
647 FTM_RESP_STAT_DUP_IN_WIN = BIT(5),
648 FTM_RESP_STAT_DUP_OUT_WIN = BIT(6),
649 FTM_RESP_STAT_SCHED_SUCCESS = BIT(7),
650 FTM_RESP_STAT_ASAP_REQ = BIT(8),
651 FTM_RESP_STAT_NON_ASAP_REQ = BIT(9),
652 FTM_RESP_STAT_ASAP_RESP = BIT(10),
653 FTM_RESP_STAT_NON_ASAP_RESP = BIT(11),
654 FTM_RESP_STAT_FAIL_INITIATOR_INACTIVE = BIT(12),
655 FTM_RESP_STAT_FAIL_INITIATOR_OUT_WIN = BIT(13),
656 FTM_RESP_STAT_FAIL_INITIATOR_RETRY_LIM = BIT(14),
657 FTM_RESP_STAT_FAIL_NEXT_SERVED = BIT(15),
658 FTM_RESP_STAT_FAIL_TRIGGER_ERR = BIT(16),
659 FTM_RESP_STAT_FAIL_GC = BIT(17),
660 FTM_RESP_STAT_SUCCESS = BIT(18),
661 FTM_RESP_STAT_INTEL_IE = BIT(19),
662 FTM_RESP_STAT_INITIATOR_ACTIVE = BIT(20),
663 FTM_RESP_STAT_MEASUREMENTS_AVAILABLE = BIT(21),
664 FTM_RESP_STAT_TRIGGER_UNKNOWN = BIT(22),
665 FTM_RESP_STAT_PROCESS_FAIL = BIT(23),
666 FTM_RESP_STAT_ACK = BIT(24),
667 FTM_RESP_STAT_NACK = BIT(25),
668 FTM_RESP_STAT_INVALID_INITIATOR_ID = BIT(26),
669 FTM_RESP_STAT_TIMER_MIN_DELTA = BIT(27),
670 FTM_RESP_STAT_INITIATOR_REMOVED = BIT(28),
671 FTM_RESP_STAT_INITIATOR_ADDED = BIT(29),
672 FTM_RESP_STAT_ERR_LIST_FULL = BIT(30),
673 FTM_RESP_STAT_INITIATOR_SCHED_NOW = BIT(31),
674}; /* RESP_IND_E */
675
676/**
677 * struct iwl_ftm_responder_stats - FTM responder statistics
678 * @addr: initiator address
679 * @success_ftm: number of successful ftm frames
680 * @ftm_per_burst: num of FTM frames that were received
681 * @flags: &enum ftm_responder_stats_flags
682 * @duration: actual duration of FTM
683 * @allocated_duration: time that was allocated for this FTM session
684 * @bw: FTM request bandwidth
685 * @rate: FTM request rate
686 * @reserved: for alingment and future use
687 */
688struct iwl_ftm_responder_stats {
689 u8 addr[ETH_ALEN];
690 u8 success_ftm;
691 u8 ftm_per_burst;
692 __le32 flags;
693 __le32 duration;
694 __le32 allocated_duration;
695 u8 bw;
696 u8 rate;
697 __le16 reserved;
698} __packed; /* TOF_RESPONDER_STATISTICS_NTFY_S_VER_2 */
699
700#define IWL_CSI_CHUNK_CTL_NUM_MASK 0x3
701#define IWL_CSI_CHUNK_CTL_IDX_MASK 0xc
702
703struct iwl_csi_chunk_notification {
704 __le32 token;
705 __le16 seq;
706 __le16 ctl;
707 __le32 size;
708 u8 data[];
709} __packed; /* CSI_CHUNKS_HDR_NTFY_API_S_VER_1 */
710
711#endif /* __iwl_fw_api_location_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h b/drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h
index 45f61c6af14e..b833b80ea3d6 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h
@@ -8,6 +8,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 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 14 * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
33 * All rights reserved. 35 * All rights reserved.
34 * 36 *
35 * Redistribution and use in source and binary forms, with or without 37 * Redistribution and use in source and binary forms, with or without
@@ -95,17 +97,36 @@
95#define PHY_VHT_CTRL_POS_4_ABOVE (0x7) 97#define PHY_VHT_CTRL_POS_4_ABOVE (0x7)
96 98
97/* 99/*
100 * struct iwl_fw_channel_info_v1 - channel information
101 *
98 * @band: PHY_BAND_* 102 * @band: PHY_BAND_*
99 * @channel: channel number 103 * @channel: channel number
100 * @width: PHY_[VHT|LEGACY]_CHANNEL_* 104 * @width: PHY_[VHT|LEGACY]_CHANNEL_*
101 * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_* 105 * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
102 */ 106 */
103struct iwl_fw_channel_info { 107struct iwl_fw_channel_info_v1 {
104 u8 band; 108 u8 band;
105 u8 channel; 109 u8 channel;
106 u8 width; 110 u8 width;
107 u8 ctrl_pos; 111 u8 ctrl_pos;
108} __packed; 112} __packed; /* CHANNEL_CONFIG_API_S_VER_1 */
113
114/*
115 * struct iwl_fw_channel_info - channel information
116 *
117 * @channel: channel number
118 * @band: PHY_BAND_*
119 * @width: PHY_[VHT|LEGACY]_CHANNEL_*
120 * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
121 * @reserved: for future use and alignment
122 */
123struct iwl_fw_channel_info {
124 __le32 channel;
125 u8 band;
126 u8 width;
127 u8 ctrl_pos;
128 u8 reserved;
129} __packed; /*CHANNEL_CONFIG_API_S_VER_2 */
109 130
110#define PHY_RX_CHAIN_DRIVER_FORCE_POS (0) 131#define PHY_RX_CHAIN_DRIVER_FORCE_POS (0)
111#define PHY_RX_CHAIN_DRIVER_FORCE_MSK \ 132#define PHY_RX_CHAIN_DRIVER_FORCE_MSK \
@@ -134,6 +155,22 @@ struct iwl_fw_channel_info {
134 155
135/* TODO: complete missing documentation */ 156/* TODO: complete missing documentation */
136/** 157/**
158 * struct iwl_phy_context_cmd_tail - tail of iwl_phy_ctx_cmd for alignment with
159 * various channel structures.
160 *
161 * @txchain_info: ???
162 * @rxchain_info: ???
163 * @acquisition_data: ???
164 * @dsp_cfg_flags: set to 0
165 */
166struct iwl_phy_context_cmd_tail {
167 __le32 txchain_info;
168 __le32 rxchain_info;
169 __le32 acquisition_data;
170 __le32 dsp_cfg_flags;
171} __packed;
172
173/**
137 * struct iwl_phy_context_cmd - config of the PHY context 174 * struct iwl_phy_context_cmd - config of the PHY context
138 * ( PHY_CONTEXT_CMD = 0x8 ) 175 * ( PHY_CONTEXT_CMD = 0x8 )
139 * @id_and_color: ID and color of the relevant Binding 176 * @id_and_color: ID and color of the relevant Binding
@@ -142,10 +179,7 @@ struct iwl_fw_channel_info {
142 * other value means apply new params after X usecs 179 * other value means apply new params after X usecs
143 * @tx_param_color: ??? 180 * @tx_param_color: ???
144 * @ci: channel info 181 * @ci: channel info
145 * @txchain_info: ??? 182 * @tail: command tail
146 * @rxchain_info: ???
147 * @acquisition_data: ???
148 * @dsp_cfg_flags: set to 0
149 */ 183 */
150struct iwl_phy_context_cmd { 184struct iwl_phy_context_cmd {
151 /* COMMON_INDEX_HDR_API_S_VER_1 */ 185 /* COMMON_INDEX_HDR_API_S_VER_1 */
@@ -155,10 +189,7 @@ struct iwl_phy_context_cmd {
155 __le32 apply_time; 189 __le32 apply_time;
156 __le32 tx_param_color; 190 __le32 tx_param_color;
157 struct iwl_fw_channel_info ci; 191 struct iwl_fw_channel_info ci;
158 __le32 txchain_info; 192 struct iwl_phy_context_cmd_tail tail;
159 __le32 rxchain_info;
160 __le32 acquisition_data;
161 __le32 dsp_cfg_flags;
162} __packed; /* PHY_CONTEXT_CMD_API_VER_1 */ 193} __packed; /* PHY_CONTEXT_CMD_API_VER_1 */
163 194
164#endif /* __iwl_fw_api_phy_ctxt_h__ */ 195#endif /* __iwl_fw_api_phy_ctxt_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index 0791a854fc8f..6e8224ce8906 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -209,8 +209,6 @@ enum iwl_rx_phy_flags {
209 * @RX_MPDU_RES_STATUS_CSUM_OK: checksum found no errors 209 * @RX_MPDU_RES_STATUS_CSUM_OK: checksum found no errors
210 * @RX_MPDU_RES_STATUS_STA_ID_MSK: station ID mask 210 * @RX_MPDU_RES_STATUS_STA_ID_MSK: station ID mask
211 * @RX_MDPU_RES_STATUS_STA_ID_SHIFT: station ID bit shift 211 * @RX_MDPU_RES_STATUS_STA_ID_SHIFT: station ID bit shift
212 * @RX_MPDU_RES_STATUS_FILTERING_MSK: filter status
213 * @RX_MPDU_RES_STATUS2_FILTERING_MSK: filter status 2
214 */ 212 */
215enum iwl_mvm_rx_status { 213enum iwl_mvm_rx_status {
216 RX_MPDU_RES_STATUS_CRC_OK = BIT(0), 214 RX_MPDU_RES_STATUS_CRC_OK = BIT(0),
@@ -238,8 +236,6 @@ enum iwl_mvm_rx_status {
238 RX_MPDU_RES_STATUS_CSUM_OK = BIT(17), 236 RX_MPDU_RES_STATUS_CSUM_OK = BIT(17),
239 RX_MDPU_RES_STATUS_STA_ID_SHIFT = 24, 237 RX_MDPU_RES_STATUS_STA_ID_SHIFT = 24,
240 RX_MPDU_RES_STATUS_STA_ID_MSK = 0x1f << RX_MDPU_RES_STATUS_STA_ID_SHIFT, 238 RX_MPDU_RES_STATUS_STA_ID_MSK = 0x1f << RX_MDPU_RES_STATUS_STA_ID_SHIFT,
241 RX_MPDU_RES_STATUS_FILTERING_MSK = (0xc00000),
242 RX_MPDU_RES_STATUS2_FILTERING_MSK = (0xc0000000),
243}; 239};
244 240
245/* 9000 series API */ 241/* 9000 series API */
@@ -337,6 +333,8 @@ enum iwl_rx_mpdu_phy_info {
337 IWL_RX_MPDU_PHY_AMPDU = BIT(5), 333 IWL_RX_MPDU_PHY_AMPDU = BIT(5),
338 IWL_RX_MPDU_PHY_AMPDU_TOGGLE = BIT(6), 334 IWL_RX_MPDU_PHY_AMPDU_TOGGLE = BIT(6),
339 IWL_RX_MPDU_PHY_SHORT_PREAMBLE = BIT(7), 335 IWL_RX_MPDU_PHY_SHORT_PREAMBLE = BIT(7),
336 /* short preamble is only for CCK, for non-CCK overridden by this */
337 IWL_RX_MPDU_PHY_NCCK_ADDTL_NTFY = BIT(7),
340 IWL_RX_MPDU_PHY_TSF_OVERLOAD = BIT(8), 338 IWL_RX_MPDU_PHY_TSF_OVERLOAD = BIT(8),
341}; 339};
342 340
@@ -723,6 +721,9 @@ struct iwl_rx_mpdu_desc {
723#define RX_NO_DATA_FRAME_TIME_POS 0 721#define RX_NO_DATA_FRAME_TIME_POS 0
724#define RX_NO_DATA_FRAME_TIME_MSK (0xfffff << RX_NO_DATA_FRAME_TIME_POS) 722#define RX_NO_DATA_FRAME_TIME_MSK (0xfffff << RX_NO_DATA_FRAME_TIME_POS)
725 723
724#define RX_NO_DATA_RX_VEC0_HE_NSTS_MSK 0x03800000
725#define RX_NO_DATA_RX_VEC0_VHT_NSTS_MSK 0x38000000
726
726/** 727/**
727 * struct iwl_rx_no_data - RX no data descriptor 728 * struct iwl_rx_no_data - RX no data descriptor
728 * @info: 7:0 frame type, 15:8 RX error type 729 * @info: 7:0 frame type, 15:8 RX error type
@@ -743,7 +744,7 @@ struct iwl_rx_no_data {
743 __le32 fr_time; 744 __le32 fr_time;
744 __le32 rate; 745 __le32 rate;
745 __le32 phy_info[2]; 746 __le32 phy_info[2];
746 __le32 rx_vec[3]; 747 __le32 rx_vec[2];
747} __packed; /* RX_NO_DATA_NTFY_API_S_VER_1 */ 748} __packed; /* RX_NO_DATA_NTFY_API_S_VER_1 */
748 749
749/** 750/**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/stats.h b/drivers/net/wireless/intel/iwlwifi/fw/api/stats.h
index 53cb622aa9ab..318843138490 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/stats.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/stats.h
@@ -8,6 +8,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 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright (C) 2018 Intel Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 14 * it under the terms of version 2 of the GNU General Public License as
@@ -29,6 +30,7 @@
29 * 30 *
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright (C) 2018 Intel Corporation
32 * All rights reserved. 34 * All rights reserved.
33 * 35 *
34 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
@@ -363,14 +365,7 @@ struct mvm_statistics_general_v8 {
363 u8 reserved[4 - (NUM_MAC_INDEX % 4)]; 365 u8 reserved[4 - (NUM_MAC_INDEX % 4)];
364} __packed; /* STATISTICS_GENERAL_API_S_VER_8 */ 366} __packed; /* STATISTICS_GENERAL_API_S_VER_8 */
365 367
366struct mvm_statistics_general_cdb_v9 { 368struct mvm_statistics_general {
367 struct mvm_statistics_general_common_v19 common;
368 __le32 beacon_counter[NUM_MAC_INDEX_CDB];
369 u8 beacon_average_energy[NUM_MAC_INDEX_CDB];
370 u8 reserved[4 - (NUM_MAC_INDEX_CDB % 4)];
371} __packed; /* STATISTICS_GENERAL_API_S_VER_9 */
372
373struct mvm_statistics_general_cdb {
374 struct mvm_statistics_general_common common; 369 struct mvm_statistics_general_common common;
375 __le32 beacon_counter[MAC_INDEX_AUX]; 370 __le32 beacon_counter[MAC_INDEX_AUX];
376 u8 beacon_average_energy[MAC_INDEX_AUX]; 371 u8 beacon_average_energy[MAC_INDEX_AUX];
@@ -435,11 +430,11 @@ struct iwl_notif_statistics_v11 {
435 struct mvm_statistics_load_v1 load_stats; 430 struct mvm_statistics_load_v1 load_stats;
436} __packed; /* STATISTICS_NTFY_API_S_VER_11 */ 431} __packed; /* STATISTICS_NTFY_API_S_VER_11 */
437 432
438struct iwl_notif_statistics_cdb { 433struct iwl_notif_statistics {
439 __le32 flag; 434 __le32 flag;
440 struct mvm_statistics_rx rx; 435 struct mvm_statistics_rx rx;
441 struct mvm_statistics_tx tx; 436 struct mvm_statistics_tx tx;
442 struct mvm_statistics_general_cdb general; 437 struct mvm_statistics_general general;
443 struct mvm_statistics_load load_stats; 438 struct mvm_statistics_load load_stats;
444} __packed; /* STATISTICS_NTFY_API_S_VER_13 */ 439} __packed; /* STATISTICS_NTFY_API_S_VER_13 */
445 440
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
index 7c6c2462d0e8..b089285ac466 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
@@ -8,6 +8,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 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 14 * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
33 * All rights reserved. 35 * All rights reserved.
34 * 36 *
35 * Redistribution and use in source and binary forms, with or without 37 * Redistribution and use in source and binary forms, with or without
@@ -111,6 +113,17 @@ struct iwl_tdls_channel_switch_frame {
111} __packed; /* TDLS_STA_CHANNEL_SWITCH_FRAME_API_S_VER_1 */ 113} __packed; /* TDLS_STA_CHANNEL_SWITCH_FRAME_API_S_VER_1 */
112 114
113/** 115/**
116 * struct iwl_tdls_channel_switch_cmd_tail - tail of iwl_tdls_channel_switch_cmd
117 *
118 * @timing: timing related data for command
119 * @frame: channel-switch request/response template, depending to switch_type
120 */
121struct iwl_tdls_channel_switch_cmd_tail {
122 struct iwl_tdls_channel_switch_timing timing;
123 struct iwl_tdls_channel_switch_frame frame;
124} __packed;
125
126/**
114 * struct iwl_tdls_channel_switch_cmd - TDLS channel switch command 127 * struct iwl_tdls_channel_switch_cmd - TDLS channel switch command
115 * 128 *
116 * The command is sent to initiate a channel switch and also in response to 129 * The command is sent to initiate a channel switch and also in response to
@@ -119,15 +132,13 @@ struct iwl_tdls_channel_switch_frame {
119 * @switch_type: see &enum iwl_tdls_channel_switch_type 132 * @switch_type: see &enum iwl_tdls_channel_switch_type
120 * @peer_sta_id: station id of TDLS peer 133 * @peer_sta_id: station id of TDLS peer
121 * @ci: channel we switch to 134 * @ci: channel we switch to
122 * @timing: timing related data for command 135 * @tail: command tail
123 * @frame: channel-switch request/response template, depending to switch_type
124 */ 136 */
125struct iwl_tdls_channel_switch_cmd { 137struct iwl_tdls_channel_switch_cmd {
126 u8 switch_type; 138 u8 switch_type;
127 __le32 peer_sta_id; 139 __le32 peer_sta_id;
128 struct iwl_fw_channel_info ci; 140 struct iwl_fw_channel_info ci;
129 struct iwl_tdls_channel_switch_timing timing; 141 struct iwl_tdls_channel_switch_cmd_tail tail;
130 struct iwl_tdls_channel_switch_frame frame;
131} __packed; /* TDLS_STA_CHANNEL_SWITCH_CMD_API_S_VER_1 */ 142} __packed; /* TDLS_STA_CHANNEL_SWITCH_CMD_API_S_VER_1 */
132 143
133/** 144/**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h b/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h
index f824bebceb06..4621ef93a2cf 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h
@@ -8,6 +8,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 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 14 * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
33 * All rights reserved. 35 * All rights reserved.
34 * 36 *
35 * Redistribution and use in source and binary forms, with or without 37 * Redistribution and use in source and binary forms, with or without
@@ -318,6 +320,25 @@ struct iwl_time_event_notif {
318} __packed; /* MAC_TIME_EVENT_NTFY_API_S_VER_1 */ 320} __packed; /* MAC_TIME_EVENT_NTFY_API_S_VER_1 */
319 321
320/* 322/*
323 * struct iwl_hs20_roc_req_tail - tail of iwl_hs20_roc_req
324 *
325 * @node_addr: Our MAC Address
326 * @reserved: reserved for alignment
327 * @apply_time: GP2 value to start (should always be the current GP2 value)
328 * @apply_time_max_delay: Maximum apply time delay value in TU. Defines max
329 * time by which start of the event is allowed to be postponed.
330 * @duration: event duration in TU To calculate event duration:
331 * timeEventDuration = min(duration, remainingQuota)
332 */
333struct iwl_hs20_roc_req_tail {
334 u8 node_addr[ETH_ALEN];
335 __le16 reserved;
336 __le32 apply_time;
337 __le32 apply_time_max_delay;
338 __le32 duration;
339} __packed;
340
341/*
321 * Aux ROC command 342 * Aux ROC command
322 * 343 *
323 * Command requests the firmware to create a time event for a certain duration 344 * Command requests the firmware to create a time event for a certain duration
@@ -336,13 +357,6 @@ struct iwl_time_event_notif {
336 * @sta_id_and_color: station id and color, resumed during "Remain On Channel" 357 * @sta_id_and_color: station id and color, resumed during "Remain On Channel"
337 * activity. 358 * activity.
338 * @channel_info: channel info 359 * @channel_info: channel info
339 * @node_addr: Our MAC Address
340 * @reserved: reserved for alignment
341 * @apply_time: GP2 value to start (should always be the current GP2 value)
342 * @apply_time_max_delay: Maximum apply time delay value in TU. Defines max
343 * time by which start of the event is allowed to be postponed.
344 * @duration: event duration in TU To calculate event duration:
345 * timeEventDuration = min(duration, remainingQuota)
346 */ 360 */
347struct iwl_hs20_roc_req { 361struct iwl_hs20_roc_req {
348 /* COMMON_INDEX_HDR_API_S_VER_1 hdr */ 362 /* COMMON_INDEX_HDR_API_S_VER_1 hdr */
@@ -351,11 +365,7 @@ struct iwl_hs20_roc_req {
351 __le32 event_unique_id; 365 __le32 event_unique_id;
352 __le32 sta_id_and_color; 366 __le32 sta_id_and_color;
353 struct iwl_fw_channel_info channel_info; 367 struct iwl_fw_channel_info channel_info;
354 u8 node_addr[ETH_ALEN]; 368 struct iwl_hs20_roc_req_tail tail;
355 __le16 reserved;
356 __le32 apply_time;
357 __le32 apply_time_max_delay;
358 __le32 duration;
359} __packed; /* HOT_SPOT_CMD_API_S_VER_1 */ 369} __packed; /* HOT_SPOT_CMD_API_S_VER_1 */
360 370
361/* 371/*
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tof.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tof.h
deleted file mode 100644
index 7328a1606146..000000000000
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/tof.h
+++ /dev/null
@@ -1,393 +0,0 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * The full GNU General Public License is included in this distribution
20 * in the file called COPYING.
21 *
22 * Contact Information:
23 * Intel Linux Wireless <linuxwifi@intel.com>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 * BSD LICENSE
27 *
28 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
40 * distribution.
41 * * Neither the name Intel Corporation nor the names of its
42 * contributors may be used to endorse or promote products derived
43 * from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
57 *****************************************************************************/
58#ifndef __iwl_fw_api_tof_h__
59#define __iwl_fw_api_tof_h__
60
61/* ToF sub-group command IDs */
62enum iwl_mvm_tof_sub_grp_ids {
63 TOF_RANGE_REQ_CMD = 0x1,
64 TOF_CONFIG_CMD = 0x2,
65 TOF_RANGE_ABORT_CMD = 0x3,
66 TOF_RANGE_REQ_EXT_CMD = 0x4,
67 TOF_RESPONDER_CONFIG_CMD = 0x5,
68 TOF_NW_INITIATED_RES_SEND_CMD = 0x6,
69 TOF_NEIGHBOR_REPORT_REQ_CMD = 0x7,
70 TOF_NEIGHBOR_REPORT_RSP_NOTIF = 0xFC,
71 TOF_NW_INITIATED_REQ_RCVD_NOTIF = 0xFD,
72 TOF_RANGE_RESPONSE_NOTIF = 0xFE,
73 TOF_MCSI_DEBUG_NOTIF = 0xFB,
74};
75
76/**
77 * struct iwl_tof_config_cmd - ToF configuration
78 * @tof_disabled: 0 enabled, 1 - disabled
79 * @one_sided_disabled: 0 enabled, 1 - disabled
80 * @is_debug_mode: 1 debug mode, 0 - otherwise
81 * @is_buf_required: 1 channel estimation buffer required, 0 - otherwise
82 */
83struct iwl_tof_config_cmd {
84 __le32 sub_grp_cmd_id;
85 u8 tof_disabled;
86 u8 one_sided_disabled;
87 u8 is_debug_mode;
88 u8 is_buf_required;
89} __packed;
90
91/**
92 * struct iwl_tof_responder_config_cmd - ToF AP mode (for debug)
93 * @burst_period: future use: (currently hard coded in the LMAC)
94 * The interval between two sequential bursts.
95 * @min_delta_ftm: future use: (currently hard coded in the LMAC)
96 * The minimum delay between two sequential FTM Responses
97 * in the same burst.
98 * @burst_duration: future use: (currently hard coded in the LMAC)
99 * The total time for all FTMs handshake in the same burst.
100 * Affect the time events duration in the LMAC.
101 * @num_of_burst_exp: future use: (currently hard coded in the LMAC)
102 * The number of bursts for the current ToF request. Affect
103 * the number of events allocations in the current iteration.
104 * @get_ch_est: for xVT only, NA for driver
105 * @abort_responder: when set to '1' - Responder will terminate its activity
106 * (all other fields in the command are ignored)
107 * @recv_sta_req_params: 1 - Responder will ignore the other Responder's
108 * params and use the recomended Initiator params.
109 * 0 - otherwise
110 * @channel_num: current AP Channel
111 * @bandwidth: current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
112 * @rate: current AP rate
113 * @ctrl_ch_position: coding of the control channel position relative to
114 * the center frequency:
115 *
116 * 40 MHz
117 * 0 below center, 1 above center
118 *
119 * 80 MHz
120 * bits [0..1]
121 * * 0 the near 20MHz to the center,
122 * * 1 the far 20MHz to the center
123 * bit[2]
124 * as above 40MHz
125 * @ftm_per_burst: FTMs per Burst
126 * @ftm_resp_ts_avail: '0' - we don't measure over the Initial FTM Response,
127 * '1' - we measure over the Initial FTM Response
128 * @asap_mode: ASAP / Non ASAP mode for the current WLS station
129 * @sta_id: index of the AP STA when in AP mode
130 * @tsf_timer_offset_msecs: The dictated time offset (mSec) from the AP's TSF
131 * @toa_offset: Artificial addition [0.1nsec] for the ToA - to be used for debug
132 * purposes, simulating station movement by adding various values
133 * to this field
134 * @bssid: Current AP BSSID
135 */
136struct iwl_tof_responder_config_cmd {
137 __le32 sub_grp_cmd_id;
138 __le16 burst_period;
139 u8 min_delta_ftm;
140 u8 burst_duration;
141 u8 num_of_burst_exp;
142 u8 get_ch_est;
143 u8 abort_responder;
144 u8 recv_sta_req_params;
145 u8 channel_num;
146 u8 bandwidth;
147 u8 rate;
148 u8 ctrl_ch_position;
149 u8 ftm_per_burst;
150 u8 ftm_resp_ts_avail;
151 u8 asap_mode;
152 u8 sta_id;
153 __le16 tsf_timer_offset_msecs;
154 __le16 toa_offset;
155 u8 bssid[ETH_ALEN];
156} __packed;
157
158/**
159 * struct iwl_tof_range_request_ext_cmd - extended range req for WLS
160 * @tsf_timer_offset_msec: the recommended time offset (mSec) from the AP's TSF
161 * @reserved: reserved
162 * @min_delta_ftm: Minimal time between two consecutive measurements,
163 * in units of 100us. 0 means no preference by station
164 * @ftm_format_and_bw20M: FTM Channel Spacing/Format for 20MHz: recommended
165 * value be sent to the AP
166 * @ftm_format_and_bw40M: FTM Channel Spacing/Format for 40MHz: recommended
167 * value to be sent to the AP
168 * @ftm_format_and_bw80M: FTM Channel Spacing/Format for 80MHz: recommended
169 * value to be sent to the AP
170 */
171struct iwl_tof_range_req_ext_cmd {
172 __le32 sub_grp_cmd_id;
173 __le16 tsf_timer_offset_msec;
174 __le16 reserved;
175 u8 min_delta_ftm;
176 u8 ftm_format_and_bw20M;
177 u8 ftm_format_and_bw40M;
178 u8 ftm_format_and_bw80M;
179} __packed;
180
181#define IWL_MVM_TOF_MAX_APS 21
182
183/**
184 * struct iwl_tof_range_req_ap_entry - AP configuration parameters
185 * @channel_num: Current AP Channel
186 * @bandwidth: Current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
187 * @tsf_delta_direction: TSF relatively to the subject AP
188 * @ctrl_ch_position: Coding of the control channel position relative to the
189 * center frequency.
190 * 40MHz 0 below center, 1 above center
191 * 80MHz bits [0..1]: 0 the near 20MHz to the center,
192 * 1 the far 20MHz to the center
193 * bit[2] as above 40MHz
194 * @bssid: AP's bss id
195 * @measure_type: Measurement type: 0 - two sided, 1 - One sided
196 * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of the
197 * number of measurement iterations (min 2^0 = 1, max 2^14)
198 * @burst_period: Recommended value to be sent to the AP. Measurement
199 * periodicity In units of 100ms. ignored if num_of_bursts = 0
200 * @samples_per_burst: 2-sided: the number of FTMs pairs in single Burst (1-31)
201 * 1-sided: how many rts/cts pairs should be used per burst.
202 * @retries_per_sample: Max number of retries that the LMAC should send
203 * in case of no replies by the AP.
204 * @tsf_delta: TSF Delta in units of microseconds.
205 * The difference between the AP TSF and the device local clock.
206 * @location_req: Location Request Bit[0] LCI should be sent in the FTMR
207 * Bit[1] Civic should be sent in the FTMR
208 * @asap_mode: 0 - non asap mode, 1 - asap mode (not relevant for one sided)
209 * @enable_dyn_ack: Enable Dynamic ACK BW.
210 * 0 Initiator interact with regular AP
211 * 1 Initiator interact with Responder machine: need to send the
212 * Initiator Acks with HT 40MHz / 80MHz, since the Responder should
213 * use it for its ch est measurement (this flag will be set when we
214 * configure the opposite machine to be Responder).
215 * @rssi: Last received value
216 * leagal values: -128-0 (0x7f). above 0x0 indicating an invalid value.
217 */
218struct iwl_tof_range_req_ap_entry {
219 u8 channel_num;
220 u8 bandwidth;
221 u8 tsf_delta_direction;
222 u8 ctrl_ch_position;
223 u8 bssid[ETH_ALEN];
224 u8 measure_type;
225 u8 num_of_bursts;
226 __le16 burst_period;
227 u8 samples_per_burst;
228 u8 retries_per_sample;
229 __le32 tsf_delta;
230 u8 location_req;
231 u8 asap_mode;
232 u8 enable_dyn_ack;
233 s8 rssi;
234} __packed;
235
236/**
237 * enum iwl_tof_response_mode
238 * @IWL_MVM_TOF_RESPOSE_ASAP: report each AP measurement separately as soon as
239 * possible (not supported for this release)
240 * @IWL_MVM_TOF_RESPOSE_TIMEOUT: report all AP measurements as a batch upon
241 * timeout expiration
242 * @IWL_MVM_TOF_RESPOSE_COMPLETE: report all AP measurements as a batch at the
243 * earlier of: measurements completion / timeout
244 * expiration.
245 */
246enum iwl_tof_response_mode {
247 IWL_MVM_TOF_RESPOSE_ASAP = 1,
248 IWL_MVM_TOF_RESPOSE_TIMEOUT,
249 IWL_MVM_TOF_RESPOSE_COMPLETE,
250};
251
252/**
253 * struct iwl_tof_range_req_cmd - start measurement cmd
254 * @request_id: A Token incremented per request. The same Token will be
255 * sent back in the range response
256 * @initiator: 0- NW initiated, 1 - Client Initiated
257 * @one_sided_los_disable: '0'- run ML-Algo for both ToF/OneSided,
258 * '1' - run ML-Algo for ToF only
259 * @req_timeout: Requested timeout of the response in units of 100ms.
260 * This is equivalent to the session time configured to the
261 * LMAC in Initiator Request
262 * @report_policy: Supported partially for this release: For current release -
263 * the range report will be uploaded as a batch when ready or
264 * when the session is done (successfully / partially).
265 * one of iwl_tof_response_mode.
266 * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
267 * @macaddr_random: '0' Use default source MAC address (i.e. p2_p),
268 * '1' Use MAC Address randomization according to the below
269 * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
270 * Bits set to 1 shall be randomized by the UMAC
271 * @ap: per-AP request data
272 */
273struct iwl_tof_range_req_cmd {
274 __le32 sub_grp_cmd_id;
275 u8 request_id;
276 u8 initiator;
277 u8 one_sided_los_disable;
278 u8 req_timeout;
279 u8 report_policy;
280 u8 los_det_disable;
281 u8 num_of_ap;
282 u8 macaddr_random;
283 u8 macaddr_template[ETH_ALEN];
284 u8 macaddr_mask[ETH_ALEN];
285 struct iwl_tof_range_req_ap_entry ap[IWL_MVM_TOF_MAX_APS];
286} __packed;
287
288/**
289 * struct iwl_tof_gen_resp_cmd - generic ToF response
290 */
291struct iwl_tof_gen_resp_cmd {
292 __le32 sub_grp_cmd_id;
293 u8 data[];
294} __packed;
295
296/**
297 * struct iwl_tof_range_rsp_ap_entry_ntfy - AP parameters (response)
298 * @bssid: BSSID of the AP
299 * @measure_status: current APs measurement status, one of
300 * &enum iwl_tof_entry_status.
301 * @measure_bw: Current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
302 * @rtt: The Round Trip Time that took for the last measurement for
303 * current AP [nSec]
304 * @rtt_variance: The Variance of the RTT values measured for current AP
305 * @rtt_spread: The Difference between the maximum and the minimum RTT
306 * values measured for current AP in the current session [nsec]
307 * @rssi: RSSI as uploaded in the Channel Estimation notification
308 * @rssi_spread: The Difference between the maximum and the minimum RSSI values
309 * measured for current AP in the current session
310 * @reserved: reserved
311 * @range: Measured range [cm]
312 * @range_variance: Measured range variance [cm]
313 * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
314 * uploaded by the LMAC
315 */
316struct iwl_tof_range_rsp_ap_entry_ntfy {
317 u8 bssid[ETH_ALEN];
318 u8 measure_status;
319 u8 measure_bw;
320 __le32 rtt;
321 __le32 rtt_variance;
322 __le32 rtt_spread;
323 s8 rssi;
324 u8 rssi_spread;
325 __le16 reserved;
326 __le32 range;
327 __le32 range_variance;
328 __le32 timestamp;
329} __packed;
330
331/**
332 * struct iwl_tof_range_rsp_ntfy -
333 * @request_id: A Token ID of the corresponding Range request
334 * @request_status: status of current measurement session
335 * @last_in_batch: reprot policy (when not all responses are uploaded at once)
336 * @num_of_aps: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
337 * @ap: per-AP data
338 */
339struct iwl_tof_range_rsp_ntfy {
340 u8 request_id;
341 u8 request_status;
342 u8 last_in_batch;
343 u8 num_of_aps;
344 struct iwl_tof_range_rsp_ap_entry_ntfy ap[IWL_MVM_TOF_MAX_APS];
345} __packed;
346
347#define IWL_MVM_TOF_MCSI_BUF_SIZE (245)
348/**
349 * struct iwl_tof_mcsi_notif - used for debug
350 * @token: token ID for the current session
351 * @role: '0' - initiator, '1' - responder
352 * @reserved: reserved
353 * @initiator_bssid: initiator machine
354 * @responder_bssid: responder machine
355 * @mcsi_buffer: debug data
356 */
357struct iwl_tof_mcsi_notif {
358 u8 token;
359 u8 role;
360 __le16 reserved;
361 u8 initiator_bssid[ETH_ALEN];
362 u8 responder_bssid[ETH_ALEN];
363 u8 mcsi_buffer[IWL_MVM_TOF_MCSI_BUF_SIZE * 4];
364} __packed;
365
366/**
367 * struct iwl_tof_neighbor_report_notif
368 * @bssid: BSSID of the AP which sent the report
369 * @request_token: same token as the corresponding request
370 * @status:
371 * @report_ie_len: the length of the response frame starting from the Element ID
372 * @data: the IEs
373 */
374struct iwl_tof_neighbor_report {
375 u8 bssid[ETH_ALEN];
376 u8 request_token;
377 u8 status;
378 __le16 report_ie_len;
379 u8 data[];
380} __packed;
381
382/**
383 * struct iwl_tof_range_abort_cmd
384 * @request_id: corresponds to a range request
385 * @reserved: reserved
386 */
387struct iwl_tof_range_abort_cmd {
388 __le32 sub_grp_cmd_id;
389 u8 request_id;
390 u8 reserved[3];
391} __packed;
392
393#endif
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 2a19b178c5e8..22efd94da6d3 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -469,6 +469,93 @@ static const struct iwl_prph_range iwl_prph_dump_addr_9000[] = {
469 { .start = 0x00a02400, .end = 0x00a02758 }, 469 { .start = 0x00a02400, .end = 0x00a02758 },
470}; 470};
471 471
472static const struct iwl_prph_range iwl_prph_dump_addr_22000[] = {
473 { .start = 0x00a00000, .end = 0x00a00000 },
474 { .start = 0x00a0000c, .end = 0x00a00024 },
475 { .start = 0x00a0002c, .end = 0x00a00034 },
476 { .start = 0x00a0003c, .end = 0x00a0003c },
477 { .start = 0x00a00410, .end = 0x00a00418 },
478 { .start = 0x00a00420, .end = 0x00a00420 },
479 { .start = 0x00a00428, .end = 0x00a00428 },
480 { .start = 0x00a00430, .end = 0x00a0043c },
481 { .start = 0x00a00444, .end = 0x00a00444 },
482 { .start = 0x00a00840, .end = 0x00a00840 },
483 { .start = 0x00a00850, .end = 0x00a00858 },
484 { .start = 0x00a01004, .end = 0x00a01008 },
485 { .start = 0x00a01010, .end = 0x00a01010 },
486 { .start = 0x00a01018, .end = 0x00a01018 },
487 { .start = 0x00a01024, .end = 0x00a01024 },
488 { .start = 0x00a0102c, .end = 0x00a01034 },
489 { .start = 0x00a0103c, .end = 0x00a01040 },
490 { .start = 0x00a01048, .end = 0x00a01050 },
491 { .start = 0x00a01058, .end = 0x00a01058 },
492 { .start = 0x00a01060, .end = 0x00a01070 },
493 { .start = 0x00a0108c, .end = 0x00a0108c },
494 { .start = 0x00a01c20, .end = 0x00a01c28 },
495 { .start = 0x00a01d10, .end = 0x00a01d10 },
496 { .start = 0x00a01e28, .end = 0x00a01e2c },
497 { .start = 0x00a01e60, .end = 0x00a01e60 },
498 { .start = 0x00a01e80, .end = 0x00a01e80 },
499 { .start = 0x00a01ea0, .end = 0x00a01ea0 },
500 { .start = 0x00a02000, .end = 0x00a0201c },
501 { .start = 0x00a02024, .end = 0x00a02024 },
502 { .start = 0x00a02040, .end = 0x00a02048 },
503 { .start = 0x00a020c0, .end = 0x00a020e0 },
504 { .start = 0x00a02400, .end = 0x00a02404 },
505 { .start = 0x00a0240c, .end = 0x00a02414 },
506 { .start = 0x00a0241c, .end = 0x00a0243c },
507 { .start = 0x00a02448, .end = 0x00a024bc },
508 { .start = 0x00a024c4, .end = 0x00a024cc },
509 { .start = 0x00a02508, .end = 0x00a02508 },
510 { .start = 0x00a02510, .end = 0x00a02514 },
511 { .start = 0x00a0251c, .end = 0x00a0251c },
512 { .start = 0x00a0252c, .end = 0x00a0255c },
513 { .start = 0x00a02564, .end = 0x00a025a0 },
514 { .start = 0x00a025a8, .end = 0x00a025b4 },
515 { .start = 0x00a025c0, .end = 0x00a025c0 },
516 { .start = 0x00a025e8, .end = 0x00a025f4 },
517 { .start = 0x00a02c08, .end = 0x00a02c18 },
518 { .start = 0x00a02c2c, .end = 0x00a02c38 },
519 { .start = 0x00a02c68, .end = 0x00a02c78 },
520 { .start = 0x00a03000, .end = 0x00a03000 },
521 { .start = 0x00a03010, .end = 0x00a03014 },
522 { .start = 0x00a0301c, .end = 0x00a0302c },
523 { .start = 0x00a03034, .end = 0x00a03038 },
524 { .start = 0x00a03040, .end = 0x00a03044 },
525 { .start = 0x00a03060, .end = 0x00a03068 },
526 { .start = 0x00a03070, .end = 0x00a03070 },
527 { .start = 0x00a0307c, .end = 0x00a03084 },
528 { .start = 0x00a0308c, .end = 0x00a03090 },
529 { .start = 0x00a03098, .end = 0x00a03098 },
530 { .start = 0x00a030a0, .end = 0x00a030a0 },
531 { .start = 0x00a030a8, .end = 0x00a030b4 },
532 { .start = 0x00a030bc, .end = 0x00a030c0 },
533 { .start = 0x00a030c8, .end = 0x00a030f4 },
534 { .start = 0x00a03100, .end = 0x00a0312c },
535 { .start = 0x00a03c00, .end = 0x00a03c5c },
536 { .start = 0x00a04400, .end = 0x00a04454 },
537 { .start = 0x00a04460, .end = 0x00a04474 },
538 { .start = 0x00a044c0, .end = 0x00a044ec },
539 { .start = 0x00a04500, .end = 0x00a04504 },
540 { .start = 0x00a04510, .end = 0x00a04538 },
541 { .start = 0x00a04540, .end = 0x00a04548 },
542 { .start = 0x00a04560, .end = 0x00a04560 },
543 { .start = 0x00a04570, .end = 0x00a0457c },
544 { .start = 0x00a04590, .end = 0x00a04590 },
545 { .start = 0x00a04598, .end = 0x00a04598 },
546 { .start = 0x00a045c0, .end = 0x00a045f4 },
547 { .start = 0x00a0c000, .end = 0x00a0c018 },
548 { .start = 0x00a0c020, .end = 0x00a0c028 },
549 { .start = 0x00a0c038, .end = 0x00a0c094 },
550 { .start = 0x00a0c0c0, .end = 0x00a0c104 },
551 { .start = 0x00a0c10c, .end = 0x00a0c118 },
552 { .start = 0x00a0c150, .end = 0x00a0c174 },
553 { .start = 0x00a0c17c, .end = 0x00a0c188 },
554 { .start = 0x00a0c190, .end = 0x00a0c198 },
555 { .start = 0x00a0c1a0, .end = 0x00a0c1a8 },
556 { .start = 0x00a0c1b0, .end = 0x00a0c1b8 },
557};
558
472static void iwl_read_prph_block(struct iwl_trans *trans, u32 start, 559static void iwl_read_prph_block(struct iwl_trans *trans, u32 start,
473 u32 len_bytes, __le32 *data) 560 u32 len_bytes, __le32 *data)
474{ 561{
@@ -478,15 +565,20 @@ static void iwl_read_prph_block(struct iwl_trans *trans, u32 start,
478 *data++ = cpu_to_le32(iwl_read_prph_no_grab(trans, start + i)); 565 *data++ = cpu_to_le32(iwl_read_prph_no_grab(trans, start + i));
479} 566}
480 567
481static void iwl_dump_prph(struct iwl_trans *trans, 568static void iwl_dump_prph(struct iwl_fw_runtime *fwrt,
482 struct iwl_fw_error_dump_data **data,
483 const struct iwl_prph_range *iwl_prph_dump_addr, 569 const struct iwl_prph_range *iwl_prph_dump_addr,
484 u32 range_len) 570 u32 range_len, void *ptr)
485{ 571{
486 struct iwl_fw_error_dump_prph *prph; 572 struct iwl_fw_error_dump_prph *prph;
573 struct iwl_trans *trans = fwrt->trans;
574 struct iwl_fw_error_dump_data **data =
575 (struct iwl_fw_error_dump_data **)ptr;
487 unsigned long flags; 576 unsigned long flags;
488 u32 i; 577 u32 i;
489 578
579 if (!data)
580 return;
581
490 IWL_DEBUG_INFO(trans, "WRT PRPH dump\n"); 582 IWL_DEBUG_INFO(trans, "WRT PRPH dump\n");
491 583
492 if (!iwl_trans_grab_nic_access(trans, &flags)) 584 if (!iwl_trans_grab_nic_access(trans, &flags))
@@ -552,37 +644,47 @@ static struct scatterlist *alloc_sgtable(int size)
552 return table; 644 return table;
553} 645}
554 646
555static int iwl_fw_get_prph_len(struct iwl_fw_runtime *fwrt) 647static void iwl_fw_get_prph_len(struct iwl_fw_runtime *fwrt,
648 const struct iwl_prph_range *iwl_prph_dump_addr,
649 u32 range_len, void *ptr)
556{ 650{
557 u32 prph_len = 0; 651 u32 *prph_len = (u32 *)ptr;
558 int i; 652 int i, num_bytes_in_chunk;
653
654 if (!prph_len)
655 return;
559 656
560 for (i = 0; i < ARRAY_SIZE(iwl_prph_dump_addr_comm); 657 for (i = 0; i < range_len; i++) {
561 i++) {
562 /* The range includes both boundaries */ 658 /* The range includes both boundaries */
563 int num_bytes_in_chunk = 659 num_bytes_in_chunk =
564 iwl_prph_dump_addr_comm[i].end - 660 iwl_prph_dump_addr[i].end -
565 iwl_prph_dump_addr_comm[i].start + 4; 661 iwl_prph_dump_addr[i].start + 4;
566 662
567 prph_len += sizeof(struct iwl_fw_error_dump_data) + 663 *prph_len += sizeof(struct iwl_fw_error_dump_data) +
568 sizeof(struct iwl_fw_error_dump_prph) + 664 sizeof(struct iwl_fw_error_dump_prph) +
569 num_bytes_in_chunk; 665 num_bytes_in_chunk;
570 } 666 }
667}
571 668
572 if (fwrt->trans->cfg->mq_rx_supported) { 669static void iwl_fw_prph_handler(struct iwl_fw_runtime *fwrt, void *ptr,
573 for (i = 0; i < 670 void (*handler)(struct iwl_fw_runtime *,
574 ARRAY_SIZE(iwl_prph_dump_addr_9000); i++) { 671 const struct iwl_prph_range *,
575 /* The range includes both boundaries */ 672 u32, void *))
576 int num_bytes_in_chunk = 673{
577 iwl_prph_dump_addr_9000[i].end - 674 u32 range_len;
578 iwl_prph_dump_addr_9000[i].start + 4; 675
579 676 if (fwrt->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) {
580 prph_len += sizeof(struct iwl_fw_error_dump_data) + 677 range_len = ARRAY_SIZE(iwl_prph_dump_addr_22000);
581 sizeof(struct iwl_fw_error_dump_prph) + 678 handler(fwrt, iwl_prph_dump_addr_22000, range_len, ptr);
582 num_bytes_in_chunk; 679 } else {
680 range_len = ARRAY_SIZE(iwl_prph_dump_addr_comm);
681 handler(fwrt, iwl_prph_dump_addr_comm, range_len, ptr);
682
683 if (fwrt->trans->cfg->mq_rx_supported) {
684 range_len = ARRAY_SIZE(iwl_prph_dump_addr_9000);
685 handler(fwrt, iwl_prph_dump_addr_9000, range_len, ptr);
583 } 686 }
584 } 687 }
585 return prph_len;
586} 688}
587 689
588static void iwl_fw_dump_mem(struct iwl_fw_runtime *fwrt, 690static void iwl_fw_dump_mem(struct iwl_fw_runtime *fwrt,
@@ -646,6 +748,9 @@ static int iwl_fw_rxf_len(struct iwl_fw_runtime *fwrt,
646 ADD_LEN(fifo_len, mem_cfg->rxfifo2_size, hdr_len); 748 ADD_LEN(fifo_len, mem_cfg->rxfifo2_size, hdr_len);
647 749
648 /* Count RXF1 sizes */ 750 /* Count RXF1 sizes */
751 if (WARN_ON(mem_cfg->num_lmacs > MAX_NUM_LMAC))
752 mem_cfg->num_lmacs = MAX_NUM_LMAC;
753
649 for (i = 0; i < mem_cfg->num_lmacs; i++) 754 for (i = 0; i < mem_cfg->num_lmacs; i++)
650 ADD_LEN(fifo_len, mem_cfg->lmac[i].rxfifo1_size, hdr_len); 755 ADD_LEN(fifo_len, mem_cfg->lmac[i].rxfifo1_size, hdr_len);
651 756
@@ -664,6 +769,9 @@ static int iwl_fw_txf_len(struct iwl_fw_runtime *fwrt,
664 goto dump_internal_txf; 769 goto dump_internal_txf;
665 770
666 /* Count TXF sizes */ 771 /* Count TXF sizes */
772 if (WARN_ON(mem_cfg->num_lmacs > MAX_NUM_LMAC))
773 mem_cfg->num_lmacs = MAX_NUM_LMAC;
774
667 for (i = 0; i < mem_cfg->num_lmacs; i++) { 775 for (i = 0; i < mem_cfg->num_lmacs; i++) {
668 int j; 776 int j;
669 777
@@ -733,6 +841,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
733 if (!fwrt->trans->cfg->dccm_offset || !fwrt->trans->cfg->dccm_len) { 841 if (!fwrt->trans->cfg->dccm_offset || !fwrt->trans->cfg->dccm_len) {
734 const struct fw_img *img; 842 const struct fw_img *img;
735 843
844 if (fwrt->cur_fw_img >= IWL_UCODE_TYPE_MAX)
845 return NULL;
736 img = &fwrt->fw->img[fwrt->cur_fw_img]; 846 img = &fwrt->fw->img[fwrt->cur_fw_img];
737 sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; 847 sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
738 sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; 848 sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
@@ -747,9 +857,9 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
747 fifo_len += iwl_fw_txf_len(fwrt, mem_cfg); 857 fifo_len += iwl_fw_txf_len(fwrt, mem_cfg);
748 858
749 /* Make room for PRPH registers */ 859 /* Make room for PRPH registers */
750 if (!fwrt->trans->cfg->gen2 && 860 if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PRPH))
751 iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PRPH)) 861 iwl_fw_prph_handler(fwrt, &prph_len,
752 prph_len += iwl_fw_get_prph_len(fwrt); 862 iwl_fw_get_prph_len);
753 863
754 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000 && 864 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000 &&
755 iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RADIO_REG)) 865 iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RADIO_REG))
@@ -828,7 +938,13 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
828 sizeof(dump_info->dev_human_readable) - 1); 938 sizeof(dump_info->dev_human_readable) - 1);
829 strncpy(dump_info->bus_human_readable, fwrt->dev->bus->name, 939 strncpy(dump_info->bus_human_readable, fwrt->dev->bus->name,
830 sizeof(dump_info->bus_human_readable) - 1); 940 sizeof(dump_info->bus_human_readable) - 1);
831 dump_info->rt_status = cpu_to_le32(fwrt->dump.rt_status); 941 dump_info->num_of_lmacs = fwrt->smem_cfg.num_lmacs;
942 dump_info->lmac_err_id[0] =
943 cpu_to_le32(fwrt->dump.lmac_err_id[0]);
944 if (fwrt->smem_cfg.num_lmacs > 1)
945 dump_info->lmac_err_id[1] =
946 cpu_to_le32(fwrt->dump.lmac_err_id[1]);
947 dump_info->umac_err_id = cpu_to_le32(fwrt->dump.umac_err_id);
832 948
833 dump_data = iwl_fw_error_next_data(dump_data); 949 dump_data = iwl_fw_error_next_data(dump_data);
834 } 950 }
@@ -935,16 +1051,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
935 if (iwl_fw_dbg_is_paging_enabled(fwrt)) 1051 if (iwl_fw_dbg_is_paging_enabled(fwrt))
936 iwl_dump_paging(fwrt, &dump_data); 1052 iwl_dump_paging(fwrt, &dump_data);
937 1053
938 if (prph_len) { 1054 if (prph_len)
939 iwl_dump_prph(fwrt->trans, &dump_data, 1055 iwl_fw_prph_handler(fwrt, &dump_data, iwl_dump_prph);
940 iwl_prph_dump_addr_comm,
941 ARRAY_SIZE(iwl_prph_dump_addr_comm));
942
943 if (fwrt->trans->cfg->mq_rx_supported)
944 iwl_dump_prph(fwrt->trans, &dump_data,
945 iwl_prph_dump_addr_9000,
946 ARRAY_SIZE(iwl_prph_dump_addr_9000));
947 }
948 1056
949out: 1057out:
950 dump_file->file_len = cpu_to_le32(file_len); 1058 dump_file->file_len = cpu_to_le32(file_len);
@@ -1108,13 +1216,13 @@ static void iwl_fw_ini_dump_trigger(struct iwl_fw_runtime *fwrt,
1108 iwl_dump_prph_ini(fwrt->trans, data, reg); 1216 iwl_dump_prph_ini(fwrt->trans, data, reg);
1109 break; 1217 break;
1110 case IWL_FW_INI_REGION_DRAM_BUFFER: 1218 case IWL_FW_INI_REGION_DRAM_BUFFER:
1111 *dump_mask |= IWL_FW_ERROR_DUMP_FW_MONITOR; 1219 *dump_mask |= BIT(IWL_FW_ERROR_DUMP_FW_MONITOR);
1112 break; 1220 break;
1113 case IWL_FW_INI_REGION_PAGING: 1221 case IWL_FW_INI_REGION_PAGING:
1114 if (iwl_fw_dbg_is_paging_enabled(fwrt)) 1222 if (iwl_fw_dbg_is_paging_enabled(fwrt))
1115 iwl_dump_paging(fwrt, data); 1223 iwl_dump_paging(fwrt, data);
1116 else 1224 else
1117 *dump_mask |= IWL_FW_ERROR_DUMP_PAGING; 1225 *dump_mask |= BIT(IWL_FW_ERROR_DUMP_PAGING);
1118 break; 1226 break;
1119 case IWL_FW_INI_REGION_TXF: 1227 case IWL_FW_INI_REGION_TXF:
1120 iwl_fw_dump_txf(fwrt, data); 1228 iwl_fw_dump_txf(fwrt, data);
@@ -1146,10 +1254,6 @@ _iwl_fw_error_ini_dump(struct iwl_fw_runtime *fwrt,
1146 1254
1147 if (id == FW_DBG_TRIGGER_FW_ASSERT) 1255 if (id == FW_DBG_TRIGGER_FW_ASSERT)
1148 id = IWL_FW_TRIGGER_ID_FW_ASSERT; 1256 id = IWL_FW_TRIGGER_ID_FW_ASSERT;
1149 else if (id == FW_DBG_TRIGGER_USER)
1150 id = IWL_FW_TRIGGER_ID_USER_TRIGGER;
1151 else if (id < FW_DBG_TRIGGER_MAX)
1152 return NULL;
1153 1257
1154 if (WARN_ON(id >= ARRAY_SIZE(fwrt->dump.active_trigs))) 1258 if (WARN_ON(id >= ARRAY_SIZE(fwrt->dump.active_trigs)))
1155 return NULL; 1259 return NULL;
@@ -1385,7 +1489,7 @@ int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,
1385 if (WARN_ON(!fwrt->dump.active_trigs[id].active)) 1489 if (WARN_ON(!fwrt->dump.active_trigs[id].active))
1386 return -EINVAL; 1490 return -EINVAL;
1387 1491
1388 delay = le32_to_cpu(fwrt->dump.active_trigs[id].conf->ignore_consec); 1492 delay = le32_to_cpu(fwrt->dump.active_trigs[id].conf->dump_delay);
1389 occur = le32_to_cpu(fwrt->dump.active_trigs[id].conf->occurrences); 1493 occur = le32_to_cpu(fwrt->dump.active_trigs[id].conf->occurrences);
1390 if (!occur) 1494 if (!occur)
1391 return 0; 1495 return 0;
@@ -1570,27 +1674,29 @@ iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt,
1570 struct iwl_fw_ini_allocation_tlv *alloc) 1674 struct iwl_fw_ini_allocation_tlv *alloc)
1571{ 1675{
1572 struct iwl_trans *trans = fwrt->trans; 1676 struct iwl_trans *trans = fwrt->trans;
1573 struct iwl_continuous_record_cmd cont_rec = {}; 1677 struct iwl_ldbg_config_cmd ldbg_cmd = {
1574 struct iwl_buffer_allocation_cmd *cmd = (void *)&cont_rec.pad[0]; 1678 .type = cpu_to_le32(BUFFER_ALLOCATION),
1679 };
1680 struct iwl_buffer_allocation_cmd *cmd = &ldbg_cmd.buffer_allocation;
1575 struct iwl_host_cmd hcmd = { 1681 struct iwl_host_cmd hcmd = {
1576 .id = LDBG_CONFIG_CMD, 1682 .id = LDBG_CONFIG_CMD,
1577 .flags = CMD_ASYNC, 1683 .flags = CMD_ASYNC,
1578 .data[0] = &cont_rec, 1684 .data[0] = &ldbg_cmd,
1579 .len[0] = sizeof(cont_rec), 1685 .len[0] = sizeof(ldbg_cmd),
1580 }; 1686 };
1581 void *virtual_addr = NULL; 1687 void *virtual_addr = NULL;
1582 u32 size = le32_to_cpu(alloc->size); 1688 u32 size = le32_to_cpu(alloc->size);
1583 dma_addr_t phys_addr; 1689 dma_addr_t phys_addr;
1584 1690
1585 cont_rec.record_mode.enable_recording = cpu_to_le16(BUFFER_ALLOCATION);
1586
1587 if (!trans->num_blocks && 1691 if (!trans->num_blocks &&
1588 le32_to_cpu(alloc->buffer_location) != 1692 le32_to_cpu(alloc->buffer_location) !=
1589 IWL_FW_INI_LOCATION_DRAM_PATH) 1693 IWL_FW_INI_LOCATION_DRAM_PATH)
1590 return; 1694 return;
1591 1695
1592 virtual_addr = dma_alloc_coherent(fwrt->trans->dev, size, 1696 virtual_addr =
1593 &phys_addr, GFP_KERNEL); 1697 dma_alloc_coherent(fwrt->trans->dev, size, &phys_addr,
1698 GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO |
1699 __GFP_COMP);
1594 1700
1595 /* TODO: alloc fragments if needed */ 1701 /* TODO: alloc fragments if needed */
1596 if (!virtual_addr) 1702 if (!virtual_addr)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
index 6aabbdd72326..330229d2a61d 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
@@ -102,7 +102,10 @@ static inline void iwl_fw_free_dump_desc(struct iwl_fw_runtime *fwrt)
102 if (fwrt->dump.desc != &iwl_dump_desc_assert) 102 if (fwrt->dump.desc != &iwl_dump_desc_assert)
103 kfree(fwrt->dump.desc); 103 kfree(fwrt->dump.desc);
104 fwrt->dump.desc = NULL; 104 fwrt->dump.desc = NULL;
105 fwrt->dump.rt_status = 0; 105 fwrt->dump.lmac_err_id[0] = 0;
106 if (fwrt->smem_cfg.num_lmacs > 1)
107 fwrt->dump.lmac_err_id[1] = 0;
108 fwrt->dump.umac_err_id = 0;
106} 109}
107 110
108void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt); 111void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt);
@@ -266,20 +269,20 @@ _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt,
266 iwl_fw_dbg_get_trigger((fwrt)->fw,\ 269 iwl_fw_dbg_get_trigger((fwrt)->fw,\
267 (trig))) 270 (trig)))
268 271
269static int iwl_fw_dbg_start_stop_hcmd(struct iwl_fw_runtime *fwrt, bool start) 272static inline int
273iwl_fw_dbg_start_stop_hcmd(struct iwl_fw_runtime *fwrt, bool start)
270{ 274{
271 struct iwl_continuous_record_cmd cont_rec = {}; 275 struct iwl_ldbg_config_cmd cmd = {
276 .type = start ? cpu_to_le32(START_DEBUG_RECORDING) :
277 cpu_to_le32(STOP_DEBUG_RECORDING),
278 };
272 struct iwl_host_cmd hcmd = { 279 struct iwl_host_cmd hcmd = {
273 .id = LDBG_CONFIG_CMD, 280 .id = LDBG_CONFIG_CMD,
274 .flags = CMD_ASYNC, 281 .flags = CMD_ASYNC,
275 .data[0] = &cont_rec, 282 .data[0] = &cmd,
276 .len[0] = sizeof(cont_rec), 283 .len[0] = sizeof(cmd),
277 }; 284 };
278 285
279 cont_rec.record_mode.enable_recording = start ?
280 cpu_to_le16(START_DEBUG_RECORDING) :
281 cpu_to_le16(STOP_DEBUG_RECORDING);
282
283 return iwl_trans_send_cmd(fwrt->trans, &hcmd); 286 return iwl_trans_send_cmd(fwrt->trans, &hcmd);
284} 287}
285 288
@@ -378,6 +381,7 @@ static inline bool iwl_fw_dbg_is_paging_enabled(struct iwl_fw_runtime *fwrt)
378{ 381{
379 return iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) && 382 return iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) &&
380 !fwrt->trans->cfg->gen2 && 383 !fwrt->trans->cfg->gen2 &&
384 fwrt->cur_fw_img < IWL_UCODE_TYPE_MAX &&
381 fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size && 385 fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size &&
382 fwrt->fw_paging_db[0].fw_paging_block; 386 fwrt->fw_paging_db[0].fw_paging_block;
383} 387}
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h b/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
index 65faecf552cd..c02425a1e64f 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
@@ -180,6 +180,8 @@ enum iwl_fw_error_dump_family {
180 IWL_FW_ERROR_DUMP_FAMILY_8 = 8, 180 IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
181}; 181};
182 182
183#define MAX_NUM_LMAC 2
184
183/** 185/**
184 * struct iwl_fw_error_dump_info - info on the device / firmware 186 * struct iwl_fw_error_dump_info - info on the device / firmware
185 * @device_family: the family of the device (7 / 8) 187 * @device_family: the family of the device (7 / 8)
@@ -187,7 +189,10 @@ enum iwl_fw_error_dump_family {
187 * @fw_human_readable: human readable FW version 189 * @fw_human_readable: human readable FW version
188 * @dev_human_readable: name of the device 190 * @dev_human_readable: name of the device
189 * @bus_human_readable: name of the bus used 191 * @bus_human_readable: name of the bus used
190 * @rt_status: the error_id/rt_status that that triggered the latest dump 192 * @num_of_lmacs: the number of lmacs
193 * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
194 * if the dump collection was not initiated by an assert, the value is 0
195 * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
191 * if the dump collection was not initiated by an assert, the value is 0 196 * if the dump collection was not initiated by an assert, the value is 0
192 */ 197 */
193struct iwl_fw_error_dump_info { 198struct iwl_fw_error_dump_info {
@@ -196,7 +201,9 @@ struct iwl_fw_error_dump_info {
196 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ]; 201 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
197 u8 dev_human_readable[64]; 202 u8 dev_human_readable[64];
198 u8 bus_human_readable[8]; 203 u8 bus_human_readable[8];
199 __le32 rt_status; 204 u8 num_of_lmacs;
205 __le32 umac_err_id;
206 __le32 lmac_err_id[MAX_NUM_LMAC];
200} __packed; 207} __packed;
201 208
202/** 209/**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 81f557c0b58d..e8b00b795cbb 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -303,7 +303,6 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
303 * @IWL_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory 303 * @IWL_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory
304 * @IWL_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan. 304 * @IWL_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan.
305 * @IWL_UCODE_TLV_CAPA_BEAMFORMER: supports Beamformer 305 * @IWL_UCODE_TLV_CAPA_BEAMFORMER: supports Beamformer
306 * @IWL_UCODE_TLV_CAPA_TOF_SUPPORT: supports Time of Flight (802.11mc FTM)
307 * @IWL_UCODE_TLV_CAPA_TDLS_SUPPORT: support basic TDLS functionality 306 * @IWL_UCODE_TLV_CAPA_TDLS_SUPPORT: support basic TDLS functionality
308 * @IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT: supports insertion of current 307 * @IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT: supports insertion of current
309 * tx power value into TPC Report action frame and Link Measurement Report 308 * tx power value into TPC Report action frame and Link Measurement Report
@@ -334,6 +333,8 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
334 * @IWL_UCODE_TLV_CAPA_TLC_OFFLOAD: firmware implements rate scaling algorithm 333 * @IWL_UCODE_TLV_CAPA_TLC_OFFLOAD: firmware implements rate scaling algorithm
335 * @IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA: firmware implements quota related 334 * @IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA: firmware implements quota related
336 * @IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2: firmware implements Coex Schema 2 335 * @IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2: firmware implements Coex Schema 2
336 * @IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS: firmware supports ultra high band
337 * (6 GHz).
337 * @IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE: extended DTS measurement 338 * @IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE: extended DTS measurement
338 * @IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS: supports short PM timeouts 339 * @IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS: supports short PM timeouts
339 * @IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT: supports bt-coex Multi-priority LUT 340 * @IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT: supports bt-coex Multi-priority LUT
@@ -357,10 +358,13 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
357 * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger 358 * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
358 * command size (command version 4) that supports toggling ACK TX 359 * command size (command version 4) that supports toggling ACK TX
359 * power reduction. 360 * power reduction.
360 * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
361 * @IWL_UCODE_TLV_CAPA_D3_DEBUG: supports debug recording during D3 361 * @IWL_UCODE_TLV_CAPA_D3_DEBUG: supports debug recording during D3
362 * @IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT: MCC response support 11ax 362 * @IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT: MCC response support 11ax
363 * capability. 363 * capability.
364 * @IWL_UCODE_TLV_CAPA_CSI_REPORTING: firmware is capable of being configured
365 * to report the CSI information with (certain) RX frames
366 *
367 * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
364 * 368 *
365 * @NUM_IWL_UCODE_TLV_CAPA: number of bits used 369 * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
366 */ 370 */
@@ -369,7 +373,6 @@ enum iwl_ucode_tlv_capa {
369 IWL_UCODE_TLV_CAPA_LAR_SUPPORT = (__force iwl_ucode_tlv_capa_t)1, 373 IWL_UCODE_TLV_CAPA_LAR_SUPPORT = (__force iwl_ucode_tlv_capa_t)1,
370 IWL_UCODE_TLV_CAPA_UMAC_SCAN = (__force iwl_ucode_tlv_capa_t)2, 374 IWL_UCODE_TLV_CAPA_UMAC_SCAN = (__force iwl_ucode_tlv_capa_t)2,
371 IWL_UCODE_TLV_CAPA_BEAMFORMER = (__force iwl_ucode_tlv_capa_t)3, 375 IWL_UCODE_TLV_CAPA_BEAMFORMER = (__force iwl_ucode_tlv_capa_t)3,
372 IWL_UCODE_TLV_CAPA_TOF_SUPPORT = (__force iwl_ucode_tlv_capa_t)5,
373 IWL_UCODE_TLV_CAPA_TDLS_SUPPORT = (__force iwl_ucode_tlv_capa_t)6, 376 IWL_UCODE_TLV_CAPA_TDLS_SUPPORT = (__force iwl_ucode_tlv_capa_t)6,
374 IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT = (__force iwl_ucode_tlv_capa_t)8, 377 IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT = (__force iwl_ucode_tlv_capa_t)8,
375 IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT = (__force iwl_ucode_tlv_capa_t)9, 378 IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT = (__force iwl_ucode_tlv_capa_t)9,
@@ -394,6 +397,7 @@ enum iwl_ucode_tlv_capa {
394 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD = (__force iwl_ucode_tlv_capa_t)43, 397 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD = (__force iwl_ucode_tlv_capa_t)43,
395 IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA = (__force iwl_ucode_tlv_capa_t)44, 398 IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA = (__force iwl_ucode_tlv_capa_t)44,
396 IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2 = (__force iwl_ucode_tlv_capa_t)45, 399 IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2 = (__force iwl_ucode_tlv_capa_t)45,
400 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS = (__force iwl_ucode_tlv_capa_t)48,
397 IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE = (__force iwl_ucode_tlv_capa_t)64, 401 IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE = (__force iwl_ucode_tlv_capa_t)64,
398 IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS = (__force iwl_ucode_tlv_capa_t)65, 402 IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS = (__force iwl_ucode_tlv_capa_t)65,
399 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT = (__force iwl_ucode_tlv_capa_t)67, 403 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT = (__force iwl_ucode_tlv_capa_t)67,
@@ -412,6 +416,8 @@ enum iwl_ucode_tlv_capa {
412 IWL_UCODE_TLV_CAPA_D3_DEBUG = (__force iwl_ucode_tlv_capa_t)87, 416 IWL_UCODE_TLV_CAPA_D3_DEBUG = (__force iwl_ucode_tlv_capa_t)87,
413 IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT = (__force iwl_ucode_tlv_capa_t)88, 417 IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT = (__force iwl_ucode_tlv_capa_t)88,
414 IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT = (__force iwl_ucode_tlv_capa_t)89, 418 IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT = (__force iwl_ucode_tlv_capa_t)89,
419 IWL_UCODE_TLV_CAPA_CSI_REPORTING = (__force iwl_ucode_tlv_capa_t)90,
420
415 IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96, 421 IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96,
416 422
417 NUM_IWL_UCODE_TLV_CAPA 423 NUM_IWL_UCODE_TLV_CAPA
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
index 4f7090f88cb0..a0fcbb28114b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
@@ -142,7 +142,8 @@ struct iwl_fw_runtime {
142 u32 *d3_debug_data; 142 u32 *d3_debug_data;
143 struct iwl_fw_ini_active_regs active_regs[IWL_FW_INI_MAX_REGION_ID]; 143 struct iwl_fw_ini_active_regs active_regs[IWL_FW_INI_MAX_REGION_ID];
144 struct iwl_fw_ini_active_triggers active_trigs[IWL_FW_TRIGGER_ID_NUM]; 144 struct iwl_fw_ini_active_triggers active_trigs[IWL_FW_TRIGGER_ID_NUM];
145 u32 rt_status; 145 u32 lmac_err_id[MAX_NUM_LMAC];
146 u32 umac_err_id;
146 } dump; 147 } dump;
147#ifdef CONFIG_IWLWIFI_DEBUGFS 148#ifdef CONFIG_IWLWIFI_DEBUGFS
148 struct { 149 struct {
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index 91861a9cbe57..ff942532fac3 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -335,10 +335,6 @@ struct iwl_csr_params {
335 * @fw_name_pre: Firmware filename prefix. The api version and extension 335 * @fw_name_pre: Firmware filename prefix. The api version and extension
336 * (.ucode) will be added to filename before loading from disk. The 336 * (.ucode) will be added to filename before loading from disk. The
337 * filename is constructed as fw_name_pre<api>.ucode. 337 * filename is constructed as fw_name_pre<api>.ucode.
338 * @fw_name_pre_b_or_c_step: same as @fw_name_pre, only for b or c steps
339 * (if supported)
340 * @fw_name_pre_rf_next_step: same as @fw_name_pre_b_or_c_step, only for rf
341 * next step. Supported only in integrated solutions.
342 * @ucode_api_max: Highest version of uCode API supported by driver. 338 * @ucode_api_max: Highest version of uCode API supported by driver.
343 * @ucode_api_min: Lowest version of uCode API supported by driver. 339 * @ucode_api_min: Lowest version of uCode API supported by driver.
344 * @max_inst_size: The maximal length of the fw inst section (only DVM) 340 * @max_inst_size: The maximal length of the fw inst section (only DVM)
@@ -392,8 +388,6 @@ struct iwl_cfg {
392 /* params specific to an individual device within a device family */ 388 /* params specific to an individual device within a device family */
393 const char *name; 389 const char *name;
394 const char *fw_name_pre; 390 const char *fw_name_pre;
395 const char *fw_name_pre_b_or_c_step;
396 const char *fw_name_pre_rf_next_step;
397 /* params not likely to change within a device family */ 391 /* params not likely to change within a device family */
398 const struct iwl_base_params *base_params; 392 const struct iwl_base_params *base_params;
399 /* params likely to change within a device family */ 393 /* params likely to change within a device family */
@@ -551,29 +545,40 @@ extern const struct iwl_cfg iwl8275_2ac_cfg;
551extern const struct iwl_cfg iwl4165_2ac_cfg; 545extern const struct iwl_cfg iwl4165_2ac_cfg;
552extern const struct iwl_cfg iwl9160_2ac_cfg; 546extern const struct iwl_cfg iwl9160_2ac_cfg;
553extern const struct iwl_cfg iwl9260_2ac_cfg; 547extern const struct iwl_cfg iwl9260_2ac_cfg;
548extern const struct iwl_cfg iwl9260_2ac_160_cfg;
554extern const struct iwl_cfg iwl9260_killer_2ac_cfg; 549extern const struct iwl_cfg iwl9260_killer_2ac_cfg;
555extern const struct iwl_cfg iwl9270_2ac_cfg; 550extern const struct iwl_cfg iwl9270_2ac_cfg;
556extern const struct iwl_cfg iwl9460_2ac_cfg; 551extern const struct iwl_cfg iwl9460_2ac_cfg;
557extern const struct iwl_cfg iwl9560_2ac_cfg; 552extern const struct iwl_cfg iwl9560_2ac_cfg;
553extern const struct iwl_cfg iwl9560_2ac_160_cfg;
558extern const struct iwl_cfg iwl9460_2ac_cfg_soc; 554extern const struct iwl_cfg iwl9460_2ac_cfg_soc;
559extern const struct iwl_cfg iwl9461_2ac_cfg_soc; 555extern const struct iwl_cfg iwl9461_2ac_cfg_soc;
560extern const struct iwl_cfg iwl9462_2ac_cfg_soc; 556extern const struct iwl_cfg iwl9462_2ac_cfg_soc;
561extern const struct iwl_cfg iwl9560_2ac_cfg_soc; 557extern const struct iwl_cfg iwl9560_2ac_cfg_soc;
558extern const struct iwl_cfg iwl9560_2ac_160_cfg_soc;
562extern const struct iwl_cfg iwl9560_killer_2ac_cfg_soc; 559extern const struct iwl_cfg iwl9560_killer_2ac_cfg_soc;
563extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc; 560extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc;
564extern const struct iwl_cfg iwl9460_2ac_cfg_shared_clk; 561extern const struct iwl_cfg iwl9460_2ac_cfg_shared_clk;
565extern const struct iwl_cfg iwl9461_2ac_cfg_shared_clk; 562extern const struct iwl_cfg iwl9461_2ac_cfg_shared_clk;
566extern const struct iwl_cfg iwl9462_2ac_cfg_shared_clk; 563extern const struct iwl_cfg iwl9462_2ac_cfg_shared_clk;
567extern const struct iwl_cfg iwl9560_2ac_cfg_shared_clk; 564extern const struct iwl_cfg iwl9560_2ac_cfg_shared_clk;
565extern const struct iwl_cfg iwl9560_2ac_160_cfg_shared_clk;
568extern const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk; 566extern const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk;
569extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk; 567extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk;
570extern const struct iwl_cfg iwl22000_2ac_cfg_hr; 568extern const struct iwl_cfg iwl22000_2ac_cfg_hr;
571extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb; 569extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb;
572extern const struct iwl_cfg iwl22000_2ac_cfg_jf; 570extern const struct iwl_cfg iwl22000_2ac_cfg_jf;
571extern const struct iwl_cfg iwl22560_2ax_cfg_hr;
573extern const struct iwl_cfg iwl22000_2ax_cfg_hr; 572extern const struct iwl_cfg iwl22000_2ax_cfg_hr;
573extern const struct iwl_cfg iwl22260_2ax_cfg;
574extern const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0;
575extern const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0;
576extern const struct iwl_cfg killer1650x_2ax_cfg;
577extern const struct iwl_cfg killer1650w_2ax_cfg;
574extern const struct iwl_cfg iwl9461_2ac_cfg_qu_b0_jf_b0; 578extern const struct iwl_cfg iwl9461_2ac_cfg_qu_b0_jf_b0;
575extern const struct iwl_cfg iwl9462_2ac_cfg_qu_b0_jf_b0; 579extern const struct iwl_cfg iwl9462_2ac_cfg_qu_b0_jf_b0;
576extern const struct iwl_cfg iwl9560_2ac_cfg_qu_b0_jf_b0; 580extern const struct iwl_cfg iwl9560_2ac_cfg_qu_b0_jf_b0;
581extern const struct iwl_cfg iwl9560_2ac_160_cfg_qu_b0_jf_b0;
577extern const struct iwl_cfg killer1550i_2ac_cfg_qu_b0_jf_b0; 582extern const struct iwl_cfg killer1550i_2ac_cfg_qu_b0_jf_b0;
578extern const struct iwl_cfg killer1550s_2ac_cfg_qu_b0_jf_b0; 583extern const struct iwl_cfg killer1550s_2ac_cfg_qu_b0_jf_b0;
579extern const struct iwl_cfg iwl22000_2ax_cfg_jf; 584extern const struct iwl_cfg iwl22000_2ax_cfg_jf;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index caa5806acd81..42af421bbc3c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -325,6 +325,7 @@ enum {
325#define CSR_HW_REV_TYPE_7265D (0x0000210) 325#define CSR_HW_REV_TYPE_7265D (0x0000210)
326#define CSR_HW_REV_TYPE_NONE (0x00001F0) 326#define CSR_HW_REV_TYPE_NONE (0x00001F0)
327#define CSR_HW_REV_TYPE_QNJ (0x0000360) 327#define CSR_HW_REV_TYPE_QNJ (0x0000360)
328#define CSR_HW_REV_TYPE_QNJ_B0 (0x0000364)
328#define CSR_HW_REV_TYPE_HR_CDB (0x0000340) 329#define CSR_HW_REV_TYPE_HR_CDB (0x0000340)
329 330
330/* RF_ID value */ 331/* RF_ID value */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index bf1be985f36b..2efa1dfe9b4c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -210,18 +210,15 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
210{ 210{
211 const struct iwl_cfg *cfg = drv->trans->cfg; 211 const struct iwl_cfg *cfg = drv->trans->cfg;
212 char tag[8]; 212 char tag[8];
213 const char *fw_pre_name;
214 213
215 if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 && 214 if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
216 (CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP || 215 (CSR_HW_REV_STEP(drv->trans->hw_rev) != SILICON_B_STEP &&
217 CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_C_STEP)) 216 CSR_HW_REV_STEP(drv->trans->hw_rev) != SILICON_C_STEP)) {
218 fw_pre_name = cfg->fw_name_pre_b_or_c_step; 217 IWL_ERR(drv,
219 else if (drv->trans->cfg->integrated && 218 "Only HW steps B and C are currently supported (0x%0x)\n",
220 CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP && 219 drv->trans->hw_rev);
221 cfg->fw_name_pre_rf_next_step) 220 return -EINVAL;
222 fw_pre_name = cfg->fw_name_pre_rf_next_step; 221 }
223 else
224 fw_pre_name = cfg->fw_name_pre;
225 222
226 if (first) { 223 if (first) {
227 drv->fw_index = cfg->ucode_api_max; 224 drv->fw_index = cfg->ucode_api_max;
@@ -235,15 +232,13 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
235 IWL_ERR(drv, "no suitable firmware found!\n"); 232 IWL_ERR(drv, "no suitable firmware found!\n");
236 233
237 if (cfg->ucode_api_min == cfg->ucode_api_max) { 234 if (cfg->ucode_api_min == cfg->ucode_api_max) {
238 IWL_ERR(drv, "%s%d is required\n", fw_pre_name, 235 IWL_ERR(drv, "%s%d is required\n", cfg->fw_name_pre,
239 cfg->ucode_api_max); 236 cfg->ucode_api_max);
240 } else { 237 } else {
241 IWL_ERR(drv, "minimum version required: %s%d\n", 238 IWL_ERR(drv, "minimum version required: %s%d\n",
242 fw_pre_name, 239 cfg->fw_name_pre, cfg->ucode_api_min);
243 cfg->ucode_api_min);
244 IWL_ERR(drv, "maximum version supported: %s%d\n", 240 IWL_ERR(drv, "maximum version supported: %s%d\n",
245 fw_pre_name, 241 cfg->fw_name_pre, cfg->ucode_api_max);
246 cfg->ucode_api_max);
247 } 242 }
248 243
249 IWL_ERR(drv, 244 IWL_ERR(drv,
@@ -252,7 +247,7 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
252 } 247 }
253 248
254 snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode", 249 snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode",
255 fw_pre_name, tag); 250 cfg->fw_name_pre, tag);
256 251
257 IWL_DEBUG_INFO(drv, "attempting to load firmware '%s'\n", 252 IWL_DEBUG_INFO(drv, "attempting to load firmware '%s'\n",
258 drv->firmware_name); 253 drv->firmware_name);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.c b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
index 4f10914f6048..ffd1e649bfa0 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
@@ -1,10 +1,13 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
4 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH 9 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
5 * 10 *
6 * Portions of this file are derived from the ipw3945 project.
7 *
8 * This program is free software; you can redistribute it and/or modify it 11 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as 12 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
@@ -15,12 +18,44 @@
15 * more details. 18 * more details.
16 * 19 *
17 * The full GNU General Public License is included in this distribution in the 20 * The full GNU General Public License is included in this distribution in the
18 * file called LICENSE. 21 * file called COPYING.
19 * 22 *
20 * Contact Information: 23 * Contact Information:
21 * Intel Linux Wireless <linuxwifi@intel.com> 24 * Intel Linux Wireless <linuxwifi@intel.com>
22 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23 * 26 *
27 * BSD LICENSE
28 *
29 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 *
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
41 * the documentation and/or other materials provided with the
42 * distribution.
43 * * Neither the name Intel Corporation nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *
24 *****************************************************************************/ 59 *****************************************************************************/
25#include <linux/delay.h> 60#include <linux/delay.h>
26#include <linux/device.h> 61#include <linux/device.h>
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.h b/drivers/net/wireless/intel/iwlwifi/iwl-io.h
index 38085850a2d3..61477e58352d 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.h
@@ -1,8 +1,9 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
4 * 5 *
5 * Portions of this file are derived from the ipw3945 project. 6 * GPL LICENSE SUMMARY
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as 9 * under the terms of version 2 of the GNU General Public License as
@@ -14,14 +15,43 @@
14 * more details. 15 * more details.
15 * 16 *
16 * The full GNU General Public License is included in this distribution in the 17 * The full GNU General Public License is included in this distribution in the
17 * file called LICENSE. 18 * file called COPYING.
18 * 19 *
19 * Contact Information: 20 * Contact Information:
20 * Intel Linux Wireless <linuxwifi@intel.com> 21 * Intel Linux Wireless <linuxwifi@intel.com>
21 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 22 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22 * 23 *
24 * BSD LICENSE
25 *
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 *
32 * * Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * * Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in
36 * the documentation and/or other materials provided with the
37 * distribution.
38 * * Neither the name Intel Corporation nor the names of its
39 * contributors may be used to endorse or promote products derived
40 * from this software without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 *
23 *****************************************************************************/ 54 *****************************************************************************/
24
25#ifndef __iwl_io_h__ 55#ifndef __iwl_io_h__
26#define __iwl_io_h__ 56#define __iwl_io_h__
27 57
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
index 73b1c46f1158..0cae2ef9b9df 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
@@ -152,4 +152,22 @@ struct iwl_mod_params {
152 bool enable_ini; 152 bool enable_ini;
153}; 153};
154 154
155static inline bool iwl_enable_rx_ampdu(void)
156{
157 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
158 return false;
159 return true;
160}
161
162static inline bool iwl_enable_tx_ampdu(void)
163{
164 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
165 return false;
166 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
167 return true;
168
169 /* enabled by default */
170 return true;
171}
172
155#endif /* #__iwl_modparams_h__ */ 173#endif /* #__iwl_modparams_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index d9afedc3d1d9..484ef4556953 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -569,8 +569,7 @@ static struct ieee80211_sband_iftype_data iwl_he_capa[] = {
569 .has_he = true, 569 .has_he = true,
570 .he_cap_elem = { 570 .he_cap_elem = {
571 .mac_cap_info[0] = 571 .mac_cap_info[0] =
572 IEEE80211_HE_MAC_CAP0_HTC_HE | 572 IEEE80211_HE_MAC_CAP0_HTC_HE,
573 IEEE80211_HE_MAC_CAP0_TWT_RES,
574 .mac_cap_info[1] = 573 .mac_cap_info[1] =
575 IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US | 574 IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US |
576 IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8, 575 IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8,
@@ -1196,14 +1195,12 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
1196 regd_to_copy = sizeof(struct ieee80211_regdomain) + 1195 regd_to_copy = sizeof(struct ieee80211_regdomain) +
1197 valid_rules * sizeof(struct ieee80211_reg_rule); 1196 valid_rules * sizeof(struct ieee80211_reg_rule);
1198 1197
1199 copy_rd = kzalloc(regd_to_copy, GFP_KERNEL); 1198 copy_rd = kmemdup(regd, regd_to_copy, GFP_KERNEL);
1200 if (!copy_rd) { 1199 if (!copy_rd) {
1201 copy_rd = ERR_PTR(-ENOMEM); 1200 copy_rd = ERR_PTR(-ENOMEM);
1202 goto out; 1201 goto out;
1203 } 1202 }
1204 1203
1205 memcpy(copy_rd, regd, regd_to_copy);
1206
1207out: 1204out:
1208 kfree(regdb_ptrs); 1205 kfree(regdb_ptrs);
1209 kfree(regd); 1206 kfree(regd);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
index 9d89b7d7f9fa..3aaa5f06461c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
@@ -358,12 +358,12 @@
358 358
359/* FW monitor */ 359/* FW monitor */
360#define MON_BUFF_SAMPLE_CTL (0xa03c00) 360#define MON_BUFF_SAMPLE_CTL (0xa03c00)
361#define MON_BUFF_BASE_ADDR (0xa03c3c) 361#define MON_BUFF_BASE_ADDR (0xa03c1c)
362#define MON_BUFF_END_ADDR (0xa03c40) 362#define MON_BUFF_END_ADDR (0xa03c40)
363#define MON_BUFF_WRPTR (0xa03c44) 363#define MON_BUFF_WRPTR (0xa03c44)
364#define MON_BUFF_CYCLE_CNT (0xa03c48) 364#define MON_BUFF_CYCLE_CNT (0xa03c48)
365/* FW monitor family 8000 and on */ 365/* FW monitor family 8000 and on */
366#define MON_BUFF_BASE_ADDR_VER2 (0xa03c3c) 366#define MON_BUFF_BASE_ADDR_VER2 (0xa03c1c)
367#define MON_BUFF_END_ADDR_VER2 (0xa03c20) 367#define MON_BUFF_END_ADDR_VER2 (0xa03c20)
368#define MON_BUFF_WRPTR_VER2 (0xa03c24) 368#define MON_BUFF_WRPTR_VER2 (0xa03c24)
369#define MON_BUFF_CYCLE_CNT_VER2 (0xa03c28) 369#define MON_BUFF_CYCLE_CNT_VER2 (0xa03c28)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/Makefile b/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
index 9ffd21918b5a..30cbd981efbd 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
@@ -7,7 +7,6 @@ iwlmvm-y += power.o coex.o
7iwlmvm-y += tt.o offloading.o tdls.o 7iwlmvm-y += tt.o offloading.o tdls.o
8iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o 8iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o
9iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o 9iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o
10iwlmvm-y += tof.o
11iwlmvm-$(CONFIG_PM) += d3.o 10iwlmvm-$(CONFIG_PM) += d3.o
12 11
13ccflags-y += -I$(src)/../ 12ccflags-y += -I $(srctree)/$(src)/../
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index 01b5338201d6..36ed7d6fc971 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -2125,7 +2125,6 @@ static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
2125 2125
2126 file->private_data = inode->i_private; 2126 file->private_data = inode->i_private;
2127 2127
2128 ieee80211_stop_queues(mvm->hw);
2129 synchronize_net(); 2128 synchronize_net();
2130 2129
2131 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3; 2130 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3;
@@ -2140,10 +2139,9 @@ static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
2140 rtnl_unlock(); 2139 rtnl_unlock();
2141 if (err > 0) 2140 if (err > 0)
2142 err = -EINVAL; 2141 err = -EINVAL;
2143 if (err) { 2142 if (err)
2144 ieee80211_wake_queues(mvm->hw);
2145 return err; 2143 return err;
2146 } 2144
2147 mvm->d3_test_active = true; 2145 mvm->d3_test_active = true;
2148 mvm->keep_vif = NULL; 2146 mvm->keep_vif = NULL;
2149 return 0; 2147 return 0;
@@ -2223,8 +2221,6 @@ static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
2223 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, 2221 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
2224 iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif); 2222 iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif);
2225 2223
2226 ieee80211_wake_queues(mvm->hw);
2227
2228 return 0; 2224 return 0;
2229} 2225}
2230 2226
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 33b0af24a537..2453ceabf00d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -60,7 +60,6 @@
60 * 60 *
61 *****************************************************************************/ 61 *****************************************************************************/
62#include "mvm.h" 62#include "mvm.h"
63#include "fw/api/tof.h"
64#include "debugfs.h" 63#include "debugfs.h"
65 64
66static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm, 65static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm,
@@ -523,753 +522,30 @@ static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
523 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 522 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
524} 523}
525 524
526static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif, 525static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
527 char *buf, 526 size_t count, loff_t *ppos)
528 size_t count, loff_t *ppos)
529{
530 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
531 struct iwl_mvm *mvm = mvmvif->mvm;
532 u32 value;
533 int ret = -EINVAL;
534 char *data;
535
536 mutex_lock(&mvm->mutex);
537
538 data = iwl_dbgfs_is_match("tof_disabled=", buf);
539 if (data) {
540 ret = kstrtou32(data, 10, &value);
541 if (ret == 0)
542 mvm->tof_data.tof_cfg.tof_disabled = value;
543 goto out;
544 }
545
546 data = iwl_dbgfs_is_match("one_sided_disabled=", buf);
547 if (data) {
548 ret = kstrtou32(data, 10, &value);
549 if (ret == 0)
550 mvm->tof_data.tof_cfg.one_sided_disabled = value;
551 goto out;
552 }
553
554 data = iwl_dbgfs_is_match("is_debug_mode=", buf);
555 if (data) {
556 ret = kstrtou32(data, 10, &value);
557 if (ret == 0)
558 mvm->tof_data.tof_cfg.is_debug_mode = value;
559 goto out;
560 }
561
562 data = iwl_dbgfs_is_match("is_buf=", buf);
563 if (data) {
564 ret = kstrtou32(data, 10, &value);
565 if (ret == 0)
566 mvm->tof_data.tof_cfg.is_buf_required = value;
567 goto out;
568 }
569
570 data = iwl_dbgfs_is_match("send_tof_cfg=", buf);
571 if (data) {
572 ret = kstrtou32(data, 10, &value);
573 if (ret == 0 && value) {
574 ret = iwl_mvm_tof_config_cmd(mvm);
575 goto out;
576 }
577 }
578
579out:
580 mutex_unlock(&mvm->mutex);
581
582 return ret ?: count;
583}
584
585static ssize_t iwl_dbgfs_tof_enable_read(struct file *file,
586 char __user *user_buf,
587 size_t count, loff_t *ppos)
588{
589 struct ieee80211_vif *vif = file->private_data;
590 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
591 struct iwl_mvm *mvm = mvmvif->mvm;
592 char buf[256];
593 int pos = 0;
594 const size_t bufsz = sizeof(buf);
595 struct iwl_tof_config_cmd *cmd;
596
597 cmd = &mvm->tof_data.tof_cfg;
598
599 mutex_lock(&mvm->mutex);
600
601 pos += scnprintf(buf + pos, bufsz - pos, "tof_disabled = %d\n",
602 cmd->tof_disabled);
603 pos += scnprintf(buf + pos, bufsz - pos, "one_sided_disabled = %d\n",
604 cmd->one_sided_disabled);
605 pos += scnprintf(buf + pos, bufsz - pos, "is_debug_mode = %d\n",
606 cmd->is_debug_mode);
607 pos += scnprintf(buf + pos, bufsz - pos, "is_buf_required = %d\n",
608 cmd->is_buf_required);
609
610 mutex_unlock(&mvm->mutex);
611
612 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
613}
614
615static ssize_t iwl_dbgfs_tof_responder_params_write(struct ieee80211_vif *vif,
616 char *buf,
617 size_t count, loff_t *ppos)
618{
619 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
620 struct iwl_mvm *mvm = mvmvif->mvm;
621 u32 value;
622 int ret = 0;
623 char *data;
624
625 mutex_lock(&mvm->mutex);
626
627 data = iwl_dbgfs_is_match("burst_period=", buf);
628 if (data) {
629 ret = kstrtou32(data, 10, &value);
630 if (!ret)
631 mvm->tof_data.responder_cfg.burst_period =
632 cpu_to_le16(value);
633 goto out;
634 }
635
636 data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
637 if (data) {
638 ret = kstrtou32(data, 10, &value);
639 if (ret == 0)
640 mvm->tof_data.responder_cfg.min_delta_ftm = value;
641 goto out;
642 }
643
644 data = iwl_dbgfs_is_match("burst_duration=", buf);
645 if (data) {
646 ret = kstrtou32(data, 10, &value);
647 if (ret == 0)
648 mvm->tof_data.responder_cfg.burst_duration = value;
649 goto out;
650 }
651
652 data = iwl_dbgfs_is_match("num_of_burst_exp=", buf);
653 if (data) {
654 ret = kstrtou32(data, 10, &value);
655 if (ret == 0)
656 mvm->tof_data.responder_cfg.num_of_burst_exp = value;
657 goto out;
658 }
659
660 data = iwl_dbgfs_is_match("abort_responder=", buf);
661 if (data) {
662 ret = kstrtou32(data, 10, &value);
663 if (ret == 0)
664 mvm->tof_data.responder_cfg.abort_responder = value;
665 goto out;
666 }
667
668 data = iwl_dbgfs_is_match("get_ch_est=", buf);
669 if (data) {
670 ret = kstrtou32(data, 10, &value);
671 if (ret == 0)
672 mvm->tof_data.responder_cfg.get_ch_est = value;
673 goto out;
674 }
675
676 data = iwl_dbgfs_is_match("recv_sta_req_params=", buf);
677 if (data) {
678 ret = kstrtou32(data, 10, &value);
679 if (ret == 0)
680 mvm->tof_data.responder_cfg.recv_sta_req_params = value;
681 goto out;
682 }
683
684 data = iwl_dbgfs_is_match("channel_num=", buf);
685 if (data) {
686 ret = kstrtou32(data, 10, &value);
687 if (ret == 0)
688 mvm->tof_data.responder_cfg.channel_num = value;
689 goto out;
690 }
691
692 data = iwl_dbgfs_is_match("bandwidth=", buf);
693 if (data) {
694 ret = kstrtou32(data, 10, &value);
695 if (ret == 0)
696 mvm->tof_data.responder_cfg.bandwidth = value;
697 goto out;
698 }
699
700 data = iwl_dbgfs_is_match("rate=", buf);
701 if (data) {
702 ret = kstrtou32(data, 10, &value);
703 if (ret == 0)
704 mvm->tof_data.responder_cfg.rate = value;
705 goto out;
706 }
707
708 data = iwl_dbgfs_is_match("bssid=", buf);
709 if (data) {
710 u8 *mac = mvm->tof_data.responder_cfg.bssid;
711
712 if (!mac_pton(data, mac)) {
713 ret = -EINVAL;
714 goto out;
715 }
716 }
717
718 data = iwl_dbgfs_is_match("tsf_timer_offset_msecs=", buf);
719 if (data) {
720 ret = kstrtou32(data, 10, &value);
721 if (ret == 0)
722 mvm->tof_data.responder_cfg.tsf_timer_offset_msecs =
723 cpu_to_le16(value);
724 goto out;
725 }
726
727 data = iwl_dbgfs_is_match("toa_offset=", buf);
728 if (data) {
729 ret = kstrtou32(data, 10, &value);
730 if (ret == 0)
731 mvm->tof_data.responder_cfg.toa_offset =
732 cpu_to_le16(value);
733 goto out;
734 }
735
736 data = iwl_dbgfs_is_match("center_freq=", buf);
737 if (data) {
738 struct iwl_tof_responder_config_cmd *cmd =
739 &mvm->tof_data.responder_cfg;
740
741 ret = kstrtou32(data, 10, &value);
742 if (ret == 0 && value) {
743 enum nl80211_band band = (cmd->channel_num <= 14) ?
744 NL80211_BAND_2GHZ :
745 NL80211_BAND_5GHZ;
746 struct ieee80211_channel chn = {
747 .band = band,
748 .center_freq = ieee80211_channel_to_frequency(
749 cmd->channel_num, band),
750 };
751 struct cfg80211_chan_def chandef = {
752 .chan = &chn,
753 .center_freq1 =
754 ieee80211_channel_to_frequency(value,
755 band),
756 };
757
758 cmd->ctrl_ch_position = iwl_mvm_get_ctrl_pos(&chandef);
759 }
760 goto out;
761 }
762
763 data = iwl_dbgfs_is_match("ftm_per_burst=", buf);
764 if (data) {
765 ret = kstrtou32(data, 10, &value);
766 if (ret == 0)
767 mvm->tof_data.responder_cfg.ftm_per_burst = value;
768 goto out;
769 }
770
771 data = iwl_dbgfs_is_match("ftm_resp_ts_avail=", buf);
772 if (data) {
773 ret = kstrtou32(data, 10, &value);
774 if (ret == 0)
775 mvm->tof_data.responder_cfg.ftm_resp_ts_avail = value;
776 goto out;
777 }
778
779 data = iwl_dbgfs_is_match("asap_mode=", buf);
780 if (data) {
781 ret = kstrtou32(data, 10, &value);
782 if (ret == 0)
783 mvm->tof_data.responder_cfg.asap_mode = value;
784 goto out;
785 }
786
787 data = iwl_dbgfs_is_match("send_responder_cfg=", buf);
788 if (data) {
789 ret = kstrtou32(data, 10, &value);
790 if (ret == 0 && value) {
791 ret = iwl_mvm_tof_responder_cmd(mvm, vif);
792 goto out;
793 }
794 }
795
796out:
797 mutex_unlock(&mvm->mutex);
798
799 return ret ?: count;
800}
801
802static ssize_t iwl_dbgfs_tof_responder_params_read(struct file *file,
803 char __user *user_buf,
804 size_t count, loff_t *ppos)
805{
806 struct ieee80211_vif *vif = file->private_data;
807 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
808 struct iwl_mvm *mvm = mvmvif->mvm;
809 char buf[256];
810 int pos = 0;
811 const size_t bufsz = sizeof(buf);
812 struct iwl_tof_responder_config_cmd *cmd;
813
814 cmd = &mvm->tof_data.responder_cfg;
815
816 mutex_lock(&mvm->mutex);
817
818 pos += scnprintf(buf + pos, bufsz - pos, "burst_period = %d\n",
819 le16_to_cpu(cmd->burst_period));
820 pos += scnprintf(buf + pos, bufsz - pos, "burst_duration = %d\n",
821 cmd->burst_duration);
822 pos += scnprintf(buf + pos, bufsz - pos, "bandwidth = %d\n",
823 cmd->bandwidth);
824 pos += scnprintf(buf + pos, bufsz - pos, "channel_num = %d\n",
825 cmd->channel_num);
826 pos += scnprintf(buf + pos, bufsz - pos, "ctrl_ch_position = 0x%x\n",
827 cmd->ctrl_ch_position);
828 pos += scnprintf(buf + pos, bufsz - pos, "bssid = %pM\n",
829 cmd->bssid);
830 pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %d\n",
831 cmd->min_delta_ftm);
832 pos += scnprintf(buf + pos, bufsz - pos, "num_of_burst_exp = %d\n",
833 cmd->num_of_burst_exp);
834 pos += scnprintf(buf + pos, bufsz - pos, "rate = %d\n", cmd->rate);
835 pos += scnprintf(buf + pos, bufsz - pos, "abort_responder = %d\n",
836 cmd->abort_responder);
837 pos += scnprintf(buf + pos, bufsz - pos, "get_ch_est = %d\n",
838 cmd->get_ch_est);
839 pos += scnprintf(buf + pos, bufsz - pos, "recv_sta_req_params = %d\n",
840 cmd->recv_sta_req_params);
841 pos += scnprintf(buf + pos, bufsz - pos, "ftm_per_burst = %d\n",
842 cmd->ftm_per_burst);
843 pos += scnprintf(buf + pos, bufsz - pos, "ftm_resp_ts_avail = %d\n",
844 cmd->ftm_resp_ts_avail);
845 pos += scnprintf(buf + pos, bufsz - pos, "asap_mode = %d\n",
846 cmd->asap_mode);
847 pos += scnprintf(buf + pos, bufsz - pos,
848 "tsf_timer_offset_msecs = %d\n",
849 le16_to_cpu(cmd->tsf_timer_offset_msecs));
850 pos += scnprintf(buf + pos, bufsz - pos, "toa_offset = %d\n",
851 le16_to_cpu(cmd->toa_offset));
852
853 mutex_unlock(&mvm->mutex);
854
855 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
856}
857
858static ssize_t iwl_dbgfs_tof_range_request_write(struct ieee80211_vif *vif,
859 char *buf, size_t count,
860 loff_t *ppos)
861{
862 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
863 struct iwl_mvm *mvm = mvmvif->mvm;
864 u32 value;
865 int ret = 0;
866 char *data;
867
868 mutex_lock(&mvm->mutex);
869
870 data = iwl_dbgfs_is_match("request_id=", buf);
871 if (data) {
872 ret = kstrtou32(data, 10, &value);
873 if (ret == 0)
874 mvm->tof_data.range_req.request_id = value;
875 goto out;
876 }
877
878 data = iwl_dbgfs_is_match("initiator=", buf);
879 if (data) {
880 ret = kstrtou32(data, 10, &value);
881 if (ret == 0)
882 mvm->tof_data.range_req.initiator = value;
883 goto out;
884 }
885
886 data = iwl_dbgfs_is_match("one_sided_los_disable=", buf);
887 if (data) {
888 ret = kstrtou32(data, 10, &value);
889 if (ret == 0)
890 mvm->tof_data.range_req.one_sided_los_disable = value;
891 goto out;
892 }
893
894 data = iwl_dbgfs_is_match("req_timeout=", buf);
895 if (data) {
896 ret = kstrtou32(data, 10, &value);
897 if (ret == 0)
898 mvm->tof_data.range_req.req_timeout = value;
899 goto out;
900 }
901
902 data = iwl_dbgfs_is_match("report_policy=", buf);
903 if (data) {
904 ret = kstrtou32(data, 10, &value);
905 if (ret == 0)
906 mvm->tof_data.range_req.report_policy = value;
907 goto out;
908 }
909
910 data = iwl_dbgfs_is_match("macaddr_random=", buf);
911 if (data) {
912 ret = kstrtou32(data, 10, &value);
913 if (ret == 0)
914 mvm->tof_data.range_req.macaddr_random = value;
915 goto out;
916 }
917
918 data = iwl_dbgfs_is_match("num_of_ap=", buf);
919 if (data) {
920 ret = kstrtou32(data, 10, &value);
921 if (ret == 0)
922 mvm->tof_data.range_req.num_of_ap = value;
923 goto out;
924 }
925
926 data = iwl_dbgfs_is_match("macaddr_template=", buf);
927 if (data) {
928 u8 mac[ETH_ALEN];
929
930 if (!mac_pton(data, mac)) {
931 ret = -EINVAL;
932 goto out;
933 }
934 memcpy(mvm->tof_data.range_req.macaddr_template, mac, ETH_ALEN);
935 goto out;
936 }
937
938 data = iwl_dbgfs_is_match("macaddr_mask=", buf);
939 if (data) {
940 u8 mac[ETH_ALEN];
941
942 if (!mac_pton(data, mac)) {
943 ret = -EINVAL;
944 goto out;
945 }
946 memcpy(mvm->tof_data.range_req.macaddr_mask, mac, ETH_ALEN);
947 goto out;
948 }
949
950 data = iwl_dbgfs_is_match("ap=", buf);
951 if (data) {
952 struct iwl_tof_range_req_ap_entry ap = {};
953 int size = sizeof(struct iwl_tof_range_req_ap_entry);
954 u16 burst_period;
955 u8 *mac = ap.bssid;
956 unsigned int i;
957
958 if (sscanf(data, "%u %hhd %hhd %hhd"
959 "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"
960 "%hhd %hhd %hd"
961 "%hhd %hhd %d"
962 "%hhx %hhd %hhd %hhd",
963 &i, &ap.channel_num, &ap.bandwidth,
964 &ap.ctrl_ch_position,
965 mac, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5,
966 &ap.measure_type, &ap.num_of_bursts,
967 &burst_period,
968 &ap.samples_per_burst, &ap.retries_per_sample,
969 &ap.tsf_delta, &ap.location_req, &ap.asap_mode,
970 &ap.enable_dyn_ack, &ap.rssi) != 20) {
971 ret = -EINVAL;
972 goto out;
973 }
974 if (i >= IWL_MVM_TOF_MAX_APS) {
975 IWL_ERR(mvm, "Invalid AP index %d\n", i);
976 ret = -EINVAL;
977 goto out;
978 }
979
980 ap.burst_period = cpu_to_le16(burst_period);
981
982 memcpy(&mvm->tof_data.range_req.ap[i], &ap, size);
983 goto out;
984 }
985
986 data = iwl_dbgfs_is_match("send_range_request=", buf);
987 if (data) {
988 ret = kstrtou32(data, 10, &value);
989 if (ret == 0 && value)
990 ret = iwl_mvm_tof_range_request_cmd(mvm, vif);
991 goto out;
992 }
993
994 ret = -EINVAL;
995out:
996 mutex_unlock(&mvm->mutex);
997 return ret ?: count;
998}
999
1000static ssize_t iwl_dbgfs_tof_range_request_read(struct file *file,
1001 char __user *user_buf,
1002 size_t count, loff_t *ppos)
1003{
1004 struct ieee80211_vif *vif = file->private_data;
1005 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1006 struct iwl_mvm *mvm = mvmvif->mvm;
1007 char buf[512];
1008 int pos = 0;
1009 const size_t bufsz = sizeof(buf);
1010 struct iwl_tof_range_req_cmd *cmd;
1011 int i;
1012
1013 cmd = &mvm->tof_data.range_req;
1014
1015 mutex_lock(&mvm->mutex);
1016
1017 pos += scnprintf(buf + pos, bufsz - pos, "request_id= %d\n",
1018 cmd->request_id);
1019 pos += scnprintf(buf + pos, bufsz - pos, "initiator= %d\n",
1020 cmd->initiator);
1021 pos += scnprintf(buf + pos, bufsz - pos, "one_sided_los_disable = %d\n",
1022 cmd->one_sided_los_disable);
1023 pos += scnprintf(buf + pos, bufsz - pos, "req_timeout= %d\n",
1024 cmd->req_timeout);
1025 pos += scnprintf(buf + pos, bufsz - pos, "report_policy= %d\n",
1026 cmd->report_policy);
1027 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_random= %d\n",
1028 cmd->macaddr_random);
1029 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_template= %pM\n",
1030 cmd->macaddr_template);
1031 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_mask= %pM\n",
1032 cmd->macaddr_mask);
1033 pos += scnprintf(buf + pos, bufsz - pos, "num_of_ap= %d\n",
1034 cmd->num_of_ap);
1035 for (i = 0; i < cmd->num_of_ap; i++) {
1036 struct iwl_tof_range_req_ap_entry *ap = &cmd->ap[i];
1037
1038 pos += scnprintf(buf + pos, bufsz - pos,
1039 "ap %.2d: channel_num=%hhd bw=%hhd"
1040 " control=%hhd bssid=%pM type=%hhd"
1041 " num_of_bursts=%hhd burst_period=%hd ftm=%hhd"
1042 " retries=%hhd tsf_delta=%d"
1043 " tsf_delta_direction=%hhd location_req=0x%hhx "
1044 " asap=%hhd enable=%hhd rssi=%hhd\n",
1045 i, ap->channel_num, ap->bandwidth,
1046 ap->ctrl_ch_position, ap->bssid,
1047 ap->measure_type, ap->num_of_bursts,
1048 ap->burst_period, ap->samples_per_burst,
1049 ap->retries_per_sample, ap->tsf_delta,
1050 ap->tsf_delta_direction,
1051 ap->location_req, ap->asap_mode,
1052 ap->enable_dyn_ack, ap->rssi);
1053 }
1054
1055 mutex_unlock(&mvm->mutex);
1056
1057 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1058}
1059
1060static ssize_t iwl_dbgfs_tof_range_req_ext_write(struct ieee80211_vif *vif,
1061 char *buf,
1062 size_t count, loff_t *ppos)
1063{
1064 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1065 struct iwl_mvm *mvm = mvmvif->mvm;
1066 u32 value;
1067 int ret = 0;
1068 char *data;
1069
1070 mutex_lock(&mvm->mutex);
1071
1072 data = iwl_dbgfs_is_match("tsf_timer_offset_msec=", buf);
1073 if (data) {
1074 ret = kstrtou32(data, 10, &value);
1075 if (ret == 0)
1076 mvm->tof_data.range_req_ext.tsf_timer_offset_msec =
1077 cpu_to_le16(value);
1078 goto out;
1079 }
1080
1081 data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
1082 if (data) {
1083 ret = kstrtou32(data, 10, &value);
1084 if (ret == 0)
1085 mvm->tof_data.range_req_ext.min_delta_ftm = value;
1086 goto out;
1087 }
1088
1089 data = iwl_dbgfs_is_match("ftm_format_and_bw20M=", buf);
1090 if (data) {
1091 ret = kstrtou32(data, 10, &value);
1092 if (ret == 0)
1093 mvm->tof_data.range_req_ext.ftm_format_and_bw20M =
1094 value;
1095 goto out;
1096 }
1097
1098 data = iwl_dbgfs_is_match("ftm_format_and_bw40M=", buf);
1099 if (data) {
1100 ret = kstrtou32(data, 10, &value);
1101 if (ret == 0)
1102 mvm->tof_data.range_req_ext.ftm_format_and_bw40M =
1103 value;
1104 goto out;
1105 }
1106
1107 data = iwl_dbgfs_is_match("ftm_format_and_bw80M=", buf);
1108 if (data) {
1109 ret = kstrtou32(data, 10, &value);
1110 if (ret == 0)
1111 mvm->tof_data.range_req_ext.ftm_format_and_bw80M =
1112 value;
1113 goto out;
1114 }
1115
1116 data = iwl_dbgfs_is_match("send_range_req_ext=", buf);
1117 if (data) {
1118 ret = kstrtou32(data, 10, &value);
1119 if (ret == 0 && value)
1120 ret = iwl_mvm_tof_range_request_ext_cmd(mvm, vif);
1121 goto out;
1122 }
1123
1124 ret = -EINVAL;
1125out:
1126 mutex_unlock(&mvm->mutex);
1127 return ret ?: count;
1128}
1129
1130static ssize_t iwl_dbgfs_tof_range_req_ext_read(struct file *file,
1131 char __user *user_buf,
1132 size_t count, loff_t *ppos)
1133{
1134 struct ieee80211_vif *vif = file->private_data;
1135 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1136 struct iwl_mvm *mvm = mvmvif->mvm;
1137 char buf[256];
1138 int pos = 0;
1139 const size_t bufsz = sizeof(buf);
1140 struct iwl_tof_range_req_ext_cmd *cmd;
1141
1142 cmd = &mvm->tof_data.range_req_ext;
1143
1144 mutex_lock(&mvm->mutex);
1145
1146 pos += scnprintf(buf + pos, bufsz - pos,
1147 "tsf_timer_offset_msec = %hd\n",
1148 cmd->tsf_timer_offset_msec);
1149 pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %hhd\n",
1150 cmd->min_delta_ftm);
1151 pos += scnprintf(buf + pos, bufsz - pos,
1152 "ftm_format_and_bw20M = %hhd\n",
1153 cmd->ftm_format_and_bw20M);
1154 pos += scnprintf(buf + pos, bufsz - pos,
1155 "ftm_format_and_bw40M = %hhd\n",
1156 cmd->ftm_format_and_bw40M);
1157 pos += scnprintf(buf + pos, bufsz - pos,
1158 "ftm_format_and_bw80M = %hhd\n",
1159 cmd->ftm_format_and_bw80M);
1160
1161 mutex_unlock(&mvm->mutex);
1162 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1163}
1164
1165static ssize_t iwl_dbgfs_tof_range_abort_write(struct ieee80211_vif *vif,
1166 char *buf,
1167 size_t count, loff_t *ppos)
1168{
1169 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1170 struct iwl_mvm *mvm = mvmvif->mvm;
1171 u32 value;
1172 int abort_id, ret = 0;
1173 char *data;
1174
1175 mutex_lock(&mvm->mutex);
1176
1177 data = iwl_dbgfs_is_match("abort_id=", buf);
1178 if (data) {
1179 ret = kstrtou32(data, 10, &value);
1180 if (ret == 0)
1181 mvm->tof_data.last_abort_id = value;
1182 goto out;
1183 }
1184
1185 data = iwl_dbgfs_is_match("send_range_abort=", buf);
1186 if (data) {
1187 ret = kstrtou32(data, 10, &value);
1188 if (ret == 0 && value) {
1189 abort_id = mvm->tof_data.last_abort_id;
1190 ret = iwl_mvm_tof_range_abort_cmd(mvm, abort_id);
1191 goto out;
1192 }
1193 }
1194
1195out:
1196 mutex_unlock(&mvm->mutex);
1197 return ret ?: count;
1198}
1199
1200static ssize_t iwl_dbgfs_tof_range_abort_read(struct file *file,
1201 char __user *user_buf,
1202 size_t count, loff_t *ppos)
1203{
1204 struct ieee80211_vif *vif = file->private_data;
1205 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1206 struct iwl_mvm *mvm = mvmvif->mvm;
1207 char buf[32];
1208 int pos = 0;
1209 const size_t bufsz = sizeof(buf);
1210 int last_abort_id;
1211
1212 mutex_lock(&mvm->mutex);
1213 last_abort_id = mvm->tof_data.last_abort_id;
1214 mutex_unlock(&mvm->mutex);
1215
1216 pos += scnprintf(buf + pos, bufsz - pos, "last_abort_id = %d\n",
1217 last_abort_id);
1218 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1219}
1220
1221static ssize_t iwl_dbgfs_tof_range_response_read(struct file *file,
1222 char __user *user_buf,
1223 size_t count, loff_t *ppos)
1224{ 527{
1225 struct ieee80211_vif *vif = file->private_data;
1226 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 528 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1227 struct iwl_mvm *mvm = mvmvif->mvm; 529 struct iwl_mvm *mvm = mvmvif->mvm;
1228 char *buf; 530 u8 value;
1229 int pos = 0; 531 int ret;
1230 const size_t bufsz = sizeof(struct iwl_tof_range_rsp_ntfy) + 256;
1231 struct iwl_tof_range_rsp_ntfy *cmd;
1232 int i, ret;
1233 532
1234 buf = kzalloc(bufsz, GFP_KERNEL); 533 ret = kstrtou8(buf, 0, &value);
1235 if (!buf) 534 if (ret)
1236 return -ENOMEM; 535 return ret;
536 if (value > 1)
537 return -EINVAL;
1237 538
1238 mutex_lock(&mvm->mutex); 539 mutex_lock(&mvm->mutex);
1239 cmd = &mvm->tof_data.range_resp; 540 iwl_mvm_update_low_latency(mvm, vif, value, LOW_LATENCY_DEBUGFS);
1240
1241 pos += scnprintf(buf + pos, bufsz - pos, "request_id = %d\n",
1242 cmd->request_id);
1243 pos += scnprintf(buf + pos, bufsz - pos, "status = %d\n",
1244 cmd->request_status);
1245 pos += scnprintf(buf + pos, bufsz - pos, "last_in_batch = %d\n",
1246 cmd->last_in_batch);
1247 pos += scnprintf(buf + pos, bufsz - pos, "num_of_aps = %d\n",
1248 cmd->num_of_aps);
1249 for (i = 0; i < cmd->num_of_aps; i++) {
1250 struct iwl_tof_range_rsp_ap_entry_ntfy *ap = &cmd->ap[i];
1251
1252 pos += scnprintf(buf + pos, bufsz - pos,
1253 "ap %.2d: bssid=%pM status=%hhd bw=%hhd"
1254 " rtt=%d rtt_var=%d rtt_spread=%d"
1255 " rssi=%hhd rssi_spread=%hhd"
1256 " range=%d range_var=%d"
1257 " time_stamp=%d\n",
1258 i, ap->bssid, ap->measure_status,
1259 ap->measure_bw,
1260 ap->rtt, ap->rtt_variance, ap->rtt_spread,
1261 ap->rssi, ap->rssi_spread, ap->range,
1262 ap->range_variance, ap->timestamp);
1263 }
1264 mutex_unlock(&mvm->mutex); 541 mutex_unlock(&mvm->mutex);
1265 542
1266 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 543 return count;
1267 kfree(buf);
1268 return ret;
1269} 544}
1270 545
1271static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf, 546static ssize_t
1272 size_t count, loff_t *ppos) 547iwl_dbgfs_low_latency_force_write(struct ieee80211_vif *vif, char *buf,
548 size_t count, loff_t *ppos)
1273{ 549{
1274 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 550 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1275 struct iwl_mvm *mvm = mvmvif->mvm; 551 struct iwl_mvm *mvm = mvmvif->mvm;
@@ -1279,13 +555,24 @@ static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
1279 ret = kstrtou8(buf, 0, &value); 555 ret = kstrtou8(buf, 0, &value);
1280 if (ret) 556 if (ret)
1281 return ret; 557 return ret;
1282 if (value > 1) 558
559 if (value > NUM_LOW_LATENCY_FORCE)
1283 return -EINVAL; 560 return -EINVAL;
1284 561
1285 mutex_lock(&mvm->mutex); 562 mutex_lock(&mvm->mutex);
1286 iwl_mvm_update_low_latency(mvm, vif, value, LOW_LATENCY_DEBUGFS); 563 if (value == LOW_LATENCY_FORCE_UNSET) {
564 iwl_mvm_update_low_latency(mvm, vif, false,
565 LOW_LATENCY_DEBUGFS_FORCE);
566 iwl_mvm_update_low_latency(mvm, vif, false,
567 LOW_LATENCY_DEBUGFS_FORCE_ENABLE);
568 } else {
569 iwl_mvm_update_low_latency(mvm, vif,
570 value == LOW_LATENCY_FORCE_ON,
571 LOW_LATENCY_DEBUGFS_FORCE);
572 iwl_mvm_update_low_latency(mvm, vif, true,
573 LOW_LATENCY_DEBUGFS_FORCE_ENABLE);
574 }
1287 mutex_unlock(&mvm->mutex); 575 mutex_unlock(&mvm->mutex);
1288
1289 return count; 576 return count;
1290} 577}
1291 578
@@ -1295,15 +582,25 @@ static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
1295{ 582{
1296 struct ieee80211_vif *vif = file->private_data; 583 struct ieee80211_vif *vif = file->private_data;
1297 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 584 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1298 char buf[30] = {}; 585 char format[] = "traffic=%d\ndbgfs=%d\nvcmd=%d\nvif_type=%d\n"
586 "dbgfs_force_enable=%d\ndbgfs_force=%d\nactual=%d\n";
587
588 /*
589 * all values in format are boolean so the size of format is enough
590 * for holding the result string
591 */
592 char buf[sizeof(format) + 1] = {};
1299 int len; 593 int len;
1300 594
1301 len = scnprintf(buf, sizeof(buf) - 1, 595 len = scnprintf(buf, sizeof(buf) - 1, format,
1302 "traffic=%d\ndbgfs=%d\nvcmd=%d\nvif_type=%d\n",
1303 !!(mvmvif->low_latency & LOW_LATENCY_TRAFFIC), 596 !!(mvmvif->low_latency & LOW_LATENCY_TRAFFIC),
1304 !!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS), 597 !!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS),
1305 !!(mvmvif->low_latency & LOW_LATENCY_VCMD), 598 !!(mvmvif->low_latency & LOW_LATENCY_VCMD),
1306 !!(mvmvif->low_latency & LOW_LATENCY_VIF_TYPE)); 599 !!(mvmvif->low_latency & LOW_LATENCY_VIF_TYPE),
600 !!(mvmvif->low_latency &
601 LOW_LATENCY_DEBUGFS_FORCE_ENABLE),
602 !!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE),
603 !!(mvmvif->low_latency_actual));
1307 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 604 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1308} 605}
1309 606
@@ -1456,14 +753,9 @@ MVM_DEBUGFS_READ_FILE_OPS(tx_pwr_lmt);
1456MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params, 32); 753MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params, 32);
1457MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params, 256); 754MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params, 256);
1458MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10); 755MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10);
756MVM_DEBUGFS_WRITE_FILE_OPS(low_latency_force, 10);
1459MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20); 757MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20);
1460MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10); 758MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10);
1461MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_enable, 32);
1462MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_request, 512);
1463MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_req_ext, 32);
1464MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_abort, 32);
1465MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
1466MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
1467MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32); 759MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
1468MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff); 760MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
1469 761
@@ -1497,6 +789,7 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1497 MVM_DEBUGFS_ADD_FILE_VIF(tx_pwr_lmt, mvmvif->dbgfs_dir, 0400); 789 MVM_DEBUGFS_ADD_FILE_VIF(tx_pwr_lmt, mvmvif->dbgfs_dir, 0400);
1498 MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir, 0400); 790 MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir, 0400);
1499 MVM_DEBUGFS_ADD_FILE_VIF(low_latency, mvmvif->dbgfs_dir, 0600); 791 MVM_DEBUGFS_ADD_FILE_VIF(low_latency, mvmvif->dbgfs_dir, 0600);
792 MVM_DEBUGFS_ADD_FILE_VIF(low_latency_force, mvmvif->dbgfs_dir, 0600);
1500 MVM_DEBUGFS_ADD_FILE_VIF(uapsd_misbehaving, mvmvif->dbgfs_dir, 0600); 793 MVM_DEBUGFS_ADD_FILE_VIF(uapsd_misbehaving, mvmvif->dbgfs_dir, 0600);
1501 MVM_DEBUGFS_ADD_FILE_VIF(rx_phyinfo, mvmvif->dbgfs_dir, 0600); 794 MVM_DEBUGFS_ADD_FILE_VIF(rx_phyinfo, mvmvif->dbgfs_dir, 0600);
1502 MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir, 0600); 795 MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir, 0600);
@@ -1506,24 +799,6 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1506 mvmvif == mvm->bf_allowed_vif) 799 mvmvif == mvm->bf_allowed_vif)
1507 MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600); 800 MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600);
1508 801
1509 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT) &&
1510 !vif->p2p && (vif->type != NL80211_IFTYPE_P2P_DEVICE)) {
1511 if (IWL_MVM_TOF_IS_RESPONDER && vif->type == NL80211_IFTYPE_AP)
1512 MVM_DEBUGFS_ADD_FILE_VIF(tof_responder_params,
1513 mvmvif->dbgfs_dir, 0600);
1514
1515 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_request, mvmvif->dbgfs_dir,
1516 0600);
1517 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_req_ext, mvmvif->dbgfs_dir,
1518 0600);
1519 MVM_DEBUGFS_ADD_FILE_VIF(tof_enable, mvmvif->dbgfs_dir,
1520 0600);
1521 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_abort, mvmvif->dbgfs_dir,
1522 0600);
1523 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_response, mvmvif->dbgfs_dir,
1524 0400);
1525 }
1526
1527 /* 802 /*
1528 * Create symlink for convenience pointing to interface specific 803 * Create symlink for convenience pointing to interface specific
1529 * debugfs entries for the driver. For example, under 804 * debugfs entries for the driver. For example, under
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 52c361a6124c..e136475a34f6 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -69,6 +69,7 @@
69#include "sta.h" 69#include "sta.h"
70#include "iwl-io.h" 70#include "iwl-io.h"
71#include "debugfs.h" 71#include "debugfs.h"
72#include "iwl-modparams.h"
72#include "fw/error-dump.h" 73#include "fw/error-dump.h"
73 74
74static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file, 75static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
@@ -1206,47 +1207,6 @@ static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1206 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1207 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1207} 1208}
1208 1209
1209/*
1210 * Enable / Disable continuous recording.
1211 * Cause the FW to start continuous recording, by sending the relevant hcmd.
1212 * Enable: input of every integer larger than 0, ENABLE_CONT_RECORDING.
1213 * Disable: for 0 as input, DISABLE_CONT_RECORDING.
1214 */
1215static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm,
1216 char *buf, size_t count,
1217 loff_t *ppos)
1218{
1219 struct iwl_trans *trans = mvm->trans;
1220 const struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg_dest_tlv;
1221 struct iwl_continuous_record_cmd cont_rec = {};
1222 int ret, rec_mode;
1223
1224 if (!iwl_mvm_firmware_running(mvm))
1225 return -EIO;
1226
1227 if (!dest)
1228 return -EOPNOTSUPP;
1229
1230 if (dest->monitor_mode != SMEM_MODE ||
1231 trans->cfg->device_family < IWL_DEVICE_FAMILY_8000)
1232 return -EOPNOTSUPP;
1233
1234 ret = kstrtoint(buf, 0, &rec_mode);
1235 if (ret)
1236 return ret;
1237
1238 cont_rec.record_mode.enable_recording = rec_mode ?
1239 cpu_to_le16(ENABLE_CONT_RECORDING) :
1240 cpu_to_le16(DISABLE_CONT_RECORDING);
1241
1242 mutex_lock(&mvm->mutex);
1243 ret = iwl_mvm_send_cmd_pdu(mvm, LDBG_CONFIG_CMD, 0,
1244 sizeof(cont_rec), &cont_rec);
1245 mutex_unlock(&mvm->mutex);
1246
1247 return ret ?: count;
1248}
1249
1250static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm, 1210static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1251 char *buf, size_t count, 1211 char *buf, size_t count,
1252 loff_t *ppos) 1212 loff_t *ppos)
@@ -1722,11 +1682,33 @@ iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1722 return ret ?: count; 1682 return ret ?: count;
1723} 1683}
1724 1684
1685struct iwl_mvm_sniffer_apply {
1686 struct iwl_mvm *mvm;
1687 u16 aid;
1688};
1689
1690static bool iwl_mvm_sniffer_apply(struct iwl_notif_wait_data *notif_data,
1691 struct iwl_rx_packet *pkt, void *data)
1692{
1693 struct iwl_mvm_sniffer_apply *apply = data;
1694
1695 apply->mvm->cur_aid = cpu_to_le16(apply->aid);
1696
1697 return true;
1698}
1699
1725static ssize_t 1700static ssize_t
1726iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf, 1701iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf,
1727 size_t count, loff_t *ppos) 1702 size_t count, loff_t *ppos)
1728{ 1703{
1704 struct iwl_notification_wait wait;
1729 struct iwl_he_monitor_cmd he_mon_cmd = {}; 1705 struct iwl_he_monitor_cmd he_mon_cmd = {};
1706 struct iwl_mvm_sniffer_apply apply = {
1707 .mvm = mvm,
1708 };
1709 u16 wait_cmds[] = {
1710 iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD, DATA_PATH_GROUP, 0),
1711 };
1730 u32 aid; 1712 u32 aid;
1731 int ret; 1713 int ret;
1732 1714
@@ -1742,10 +1724,30 @@ iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf,
1742 1724
1743 he_mon_cmd.aid = cpu_to_le16(aid); 1725 he_mon_cmd.aid = cpu_to_le16(aid);
1744 1726
1727 apply.aid = aid;
1728
1745 mutex_lock(&mvm->mutex); 1729 mutex_lock(&mvm->mutex);
1730
1731 /*
1732 * Use the notification waiter to get our function triggered
1733 * in sequence with other RX. This ensures that frames we get
1734 * on the RX queue _before_ the new configuration is applied
1735 * still have mvm->cur_aid pointing to the old AID, and that
1736 * frames on the RX queue _after_ the firmware processed the
1737 * new configuration (and sent the response, synchronously)
1738 * get mvm->cur_aid correctly set to the new AID.
1739 */
1740 iwl_init_notification_wait(&mvm->notif_wait, &wait,
1741 wait_cmds, ARRAY_SIZE(wait_cmds),
1742 iwl_mvm_sniffer_apply, &apply);
1743
1746 ret = iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD, 1744 ret = iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD,
1747 DATA_PATH_GROUP, 0), 0, 1745 DATA_PATH_GROUP, 0), 0,
1748 sizeof(he_mon_cmd), &he_mon_cmd); 1746 sizeof(he_mon_cmd), &he_mon_cmd);
1747
1748 /* no need to really wait, we already did anyway */
1749 iwl_remove_notification(&mvm->notif_wait, &wait);
1750
1749 mutex_unlock(&mvm->mutex); 1751 mutex_unlock(&mvm->mutex);
1750 1752
1751 return ret ?: count; 1753 return ret ?: count;
@@ -1800,7 +1802,6 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
1800MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8); 1802MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
1801MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8); 1803MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1802MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64); 1804MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
1803MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
1804MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8); 1805MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
1805MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl, 1806MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1806 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2)); 1807 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
@@ -2004,7 +2005,6 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
2004 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, 0200); 2005 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, 0200);
2005 MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, 0200); 2006 MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, 0200);
2006 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, 0200); 2007 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, 0200);
2007 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, 0200);
2008 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, 0200); 2008 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, 0200);
2009 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, 0200); 2009 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, 0200);
2010#ifdef CONFIG_ACPI 2010#ifdef CONFIG_ACPI
@@ -2071,6 +2071,9 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
2071 if (!debugfs_create_blob("nvm_phy_sku", 0400, 2071 if (!debugfs_create_blob("nvm_phy_sku", 0400,
2072 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob)) 2072 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
2073 goto err; 2073 goto err;
2074 if (!debugfs_create_blob("nvm_reg", S_IRUSR,
2075 mvm->debugfs_dir, &mvm->nvm_reg_blob))
2076 goto err;
2074 2077
2075 debugfs_create_file("mem", 0600, dbgfs_dir, mvm, &iwl_dbgfs_mem_ops); 2078 debugfs_create_file("mem", 0600, dbgfs_dir, mvm, &iwl_dbgfs_mem_ops);
2076 2079
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 143c7fcaea41..e3eb812e0248 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -8,6 +8,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 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright (C) 2018 Intel Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 14 * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright (C) 2018 Intel Corporation
33 * All rights reserved. 35 * All rights reserved.
34 * 36 *
35 * Redistribution and use in source and binary forms, with or without 37 * Redistribution and use in source and binary forms, with or without
@@ -89,7 +91,7 @@
89#include "fw/api/sf.h" 91#include "fw/api/sf.h"
90#include "fw/api/sta.h" 92#include "fw/api/sta.h"
91#include "fw/api/stats.h" 93#include "fw/api/stats.h"
92#include "fw/api/tof.h" 94#include "fw/api/location.h"
93#include "fw/api/tx.h" 95#include "fw/api/tx.h"
94 96
95#endif /* __fw_api_h__ */ 97#endif /* __fw_api_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 0d6c313b6669..d3dc9d276e0f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -293,9 +293,9 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
293 enum iwl_ucode_type ucode_type) 293 enum iwl_ucode_type ucode_type)
294{ 294{
295 struct iwl_notification_wait alive_wait; 295 struct iwl_notification_wait alive_wait;
296 struct iwl_mvm_alive_data alive_data; 296 struct iwl_mvm_alive_data alive_data = {};
297 const struct fw_img *fw; 297 const struct fw_img *fw;
298 int ret, i; 298 int ret;
299 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img; 299 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
300 static const u16 alive_cmd[] = { MVM_ALIVE }; 300 static const u16 alive_cmd[] = { MVM_ALIVE };
301 301
@@ -373,9 +373,6 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
373 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].tid_bitmap = 373 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].tid_bitmap =
374 BIT(IWL_MAX_TID_COUNT + 2); 374 BIT(IWL_MAX_TID_COUNT + 2);
375 375
376 for (i = 0; i < IEEE80211_MAX_QUEUES; i++)
377 atomic_set(&mvm->mac80211_queue_stop_count[i], 0);
378
379 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 376 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
380#ifdef CONFIG_IWLWIFI_DEBUGFS 377#ifdef CONFIG_IWLWIFI_DEBUGFS
381 iwl_fw_set_dbg_rec_on(&mvm->fwrt); 378 iwl_fw_set_dbg_rec_on(&mvm->fwrt);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 7779951a9533..7cfdd07d8736 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -97,11 +97,6 @@ struct iwl_mvm_mac_iface_iterator_data {
97 bool found_vif; 97 bool found_vif;
98}; 98};
99 99
100struct iwl_mvm_hw_queues_iface_iterator_data {
101 struct ieee80211_vif *exclude_vif;
102 unsigned long used_hw_queues;
103};
104
105static void iwl_mvm_mac_tsf_id_iter(void *_data, u8 *mac, 100static void iwl_mvm_mac_tsf_id_iter(void *_data, u8 *mac,
106 struct ieee80211_vif *vif) 101 struct ieee80211_vif *vif)
107{ 102{
@@ -208,61 +203,6 @@ static void iwl_mvm_mac_tsf_id_iter(void *_data, u8 *mac,
208 data->preferred_tsf = NUM_TSF_IDS; 203 data->preferred_tsf = NUM_TSF_IDS;
209} 204}
210 205
211/*
212 * Get the mask of the queues used by the vif
213 */
214u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif)
215{
216 u32 qmask = 0, ac;
217
218 if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
219 return BIT(IWL_MVM_OFFCHANNEL_QUEUE);
220
221 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
222 if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
223 qmask |= BIT(vif->hw_queue[ac]);
224 }
225
226 if (vif->type == NL80211_IFTYPE_AP ||
227 vif->type == NL80211_IFTYPE_ADHOC)
228 qmask |= BIT(vif->cab_queue);
229
230 return qmask;
231}
232
233static void iwl_mvm_iface_hw_queues_iter(void *_data, u8 *mac,
234 struct ieee80211_vif *vif)
235{
236 struct iwl_mvm_hw_queues_iface_iterator_data *data = _data;
237
238 /* exclude the given vif */
239 if (vif == data->exclude_vif)
240 return;
241
242 data->used_hw_queues |= iwl_mvm_mac_get_queues_mask(vif);
243}
244
245unsigned long iwl_mvm_get_used_hw_queues(struct iwl_mvm *mvm,
246 struct ieee80211_vif *exclude_vif)
247{
248 struct iwl_mvm_hw_queues_iface_iterator_data data = {
249 .exclude_vif = exclude_vif,
250 .used_hw_queues =
251 BIT(IWL_MVM_OFFCHANNEL_QUEUE) |
252 BIT(mvm->aux_queue) |
253 BIT(IWL_MVM_DQA_GCAST_QUEUE),
254 };
255
256 lockdep_assert_held(&mvm->mutex);
257
258 /* mark all VIF used hw queues */
259 ieee80211_iterate_active_interfaces_atomic(
260 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
261 iwl_mvm_iface_hw_queues_iter, &data);
262
263 return data.used_hw_queues;
264}
265
266static void iwl_mvm_mac_iface_iterator(void *_data, u8 *mac, 206static void iwl_mvm_mac_iface_iterator(void *_data, u8 *mac,
267 struct ieee80211_vif *vif) 207 struct ieee80211_vif *vif)
268{ 208{
@@ -360,8 +300,6 @@ int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
360 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, 300 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
361 iwl_mvm_mac_iface_iterator, &data); 301 iwl_mvm_mac_iface_iterator, &data);
362 302
363 used_hw_queues = iwl_mvm_get_used_hw_queues(mvm, vif);
364
365 /* 303 /*
366 * In the case we're getting here during resume, it's similar to 304 * In the case we're getting here during resume, it's similar to
367 * firmware restart, and with RESUME_ALL the iterator will find 305 * firmware restart, and with RESUME_ALL the iterator will find
@@ -416,9 +354,6 @@ int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
416 * the ones here - no real limit 354 * the ones here - no real limit
417 */ 355 */
418 queue_limit = IEEE80211_MAX_QUEUES; 356 queue_limit = IEEE80211_MAX_QUEUES;
419 BUILD_BUG_ON(IEEE80211_MAX_QUEUES >
420 BITS_PER_BYTE *
421 sizeof(mvm->hw_queue_to_mac80211[0]));
422 357
423 /* 358 /*
424 * Find available queues, and allocate them to the ACs. When in 359 * Find available queues, and allocate them to the ACs. When in
@@ -446,9 +381,6 @@ int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
446 * queue value (when queue is enabled). 381 * queue value (when queue is enabled).
447 */ 382 */
448 mvmvif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE; 383 mvmvif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE;
449 vif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE;
450 } else {
451 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
452 } 384 }
453 385
454 mvmvif->bcast_sta.sta_id = IWL_MVM_INVALID_STA; 386 mvmvif->bcast_sta.sta_id = IWL_MVM_INVALID_STA;
@@ -462,8 +394,6 @@ int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
462 394
463exit_fail: 395exit_fail:
464 memset(mvmvif, 0, sizeof(struct iwl_mvm_vif)); 396 memset(mvmvif, 0, sizeof(struct iwl_mvm_vif));
465 memset(vif->hw_queue, IEEE80211_INVAL_HW_QUEUE, sizeof(vif->hw_queue));
466 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
467 return ret; 397 return ret;
468} 398}
469 399
@@ -778,27 +708,9 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
778 708
779 if (vif->bss_conf.assoc && vif->bss_conf.he_support && 709 if (vif->bss_conf.assoc && vif->bss_conf.he_support &&
780 !iwlwifi_mod_params.disable_11ax) { 710 !iwlwifi_mod_params.disable_11ax) {
781 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
782 u8 sta_id = mvmvif->ap_sta_id;
783
784 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX); 711 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX);
785 if (sta_id != IWL_MVM_INVALID_STA) { 712 if (vif->bss_conf.twt_requester)
786 struct ieee80211_sta *sta; 713 ctxt_sta->data_policy |= cpu_to_le32(TWT_SUPPORTED);
787
788 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
789 lockdep_is_held(&mvm->mutex));
790
791 /*
792 * TODO: we should check the ext cap IE but it is
793 * unclear why the spec requires two bits (one in HE
794 * cap IE, and one in the ext cap IE). In the meantime
795 * rely on the HE cap IE only.
796 */
797 if (sta && (sta->he_cap.he_cap_elem.mac_cap_info[0] &
798 IEEE80211_HE_MAC_CAP0_TWT_RES))
799 ctxt_sta->data_policy |=
800 cpu_to_le32(TWT_SUPPORTED);
801 }
802 } 714 }
803 715
804 716
@@ -881,8 +793,6 @@ static int iwl_mvm_mac_ctxt_cmd_p2p_device(struct iwl_mvm *mvm,
881 793
882 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action); 794 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
883 795
884 cmd.protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT);
885
886 /* Override the filter flags to accept only probe requests */ 796 /* Override the filter flags to accept only probe requests */
887 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST); 797 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
888 798
@@ -1203,7 +1113,7 @@ static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
1203 1113
1204 if (!fw_has_api(&mvm->fw->ucode_capa, 1114 if (!fw_has_api(&mvm->fw->ucode_capa,
1205 IWL_UCODE_TLV_API_STA_TYPE)) 1115 IWL_UCODE_TLV_API_STA_TYPE))
1206 ctxt_ap->mcast_qid = cpu_to_le32(vif->cab_queue); 1116 ctxt_ap->mcast_qid = cpu_to_le32(mvmvif->cab_queue);
1207 1117
1208 /* 1118 /*
1209 * Only set the beacon time when the MAC is being added, when we 1119 * Only set the beacon time when the MAC is being added, when we
@@ -1435,7 +1345,7 @@ void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1435 agg_status = iwl_mvm_get_agg_status(mvm, beacon_notify_hdr); 1345 agg_status = iwl_mvm_get_agg_status(mvm, beacon_notify_hdr);
1436 status = le16_to_cpu(agg_status->status) & TX_STATUS_MSK; 1346 status = le16_to_cpu(agg_status->status) & TX_STATUS_MSK;
1437 IWL_DEBUG_RX(mvm, 1347 IWL_DEBUG_RX(mvm,
1438 "beacon status %#x retries:%d tsf:0x%16llX gp2:0x%X rate:%d\n", 1348 "beacon status %#x retries:%d tsf:0x%016llX gp2:0x%X rate:%d\n",
1439 status, beacon_notify_hdr->failure_frame, 1349 status, beacon_notify_hdr->failure_frame,
1440 le64_to_cpu(beacon->tsf), 1350 le64_to_cpu(beacon->tsf),
1441 mvm->ap_last_beacon_gp2, 1351 mvm->ap_last_beacon_gp2,
@@ -1472,35 +1382,48 @@ void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1472 } 1382 }
1473} 1383}
1474 1384
1475static void iwl_mvm_beacon_loss_iterator(void *_data, u8 *mac, 1385void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1476 struct ieee80211_vif *vif) 1386 struct iwl_rx_cmd_buffer *rxb)
1477{ 1387{
1478 struct iwl_missed_beacons_notif *missed_beacons = _data; 1388 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1479 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1389 struct iwl_missed_beacons_notif *mb = (void *)pkt->data;
1480 struct iwl_mvm *mvm = mvmvif->mvm;
1481 struct iwl_fw_dbg_trigger_missed_bcon *bcon_trig; 1390 struct iwl_fw_dbg_trigger_missed_bcon *bcon_trig;
1482 struct iwl_fw_dbg_trigger_tlv *trigger; 1391 struct iwl_fw_dbg_trigger_tlv *trigger;
1483 u32 stop_trig_missed_bcon, stop_trig_missed_bcon_since_rx; 1392 u32 stop_trig_missed_bcon, stop_trig_missed_bcon_since_rx;
1484 u32 rx_missed_bcon, rx_missed_bcon_since_rx; 1393 u32 rx_missed_bcon, rx_missed_bcon_since_rx;
1394 struct ieee80211_vif *vif;
1395 u32 id = le32_to_cpu(mb->mac_id);
1485 1396
1486 if (mvmvif->id != (u16)le32_to_cpu(missed_beacons->mac_id)) 1397 IWL_DEBUG_INFO(mvm,
1487 return; 1398 "missed bcn mac_id=%u, consecutive=%u (%u, %u, %u)\n",
1399 le32_to_cpu(mb->mac_id),
1400 le32_to_cpu(mb->consec_missed_beacons),
1401 le32_to_cpu(mb->consec_missed_beacons_since_last_rx),
1402 le32_to_cpu(mb->num_recvd_beacons),
1403 le32_to_cpu(mb->num_expected_beacons));
1404
1405 rcu_read_lock();
1406
1407 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
1408 if (!vif)
1409 goto out;
1488 1410
1489 rx_missed_bcon = le32_to_cpu(missed_beacons->consec_missed_beacons); 1411 rx_missed_bcon = le32_to_cpu(mb->consec_missed_beacons);
1490 rx_missed_bcon_since_rx = 1412 rx_missed_bcon_since_rx =
1491 le32_to_cpu(missed_beacons->consec_missed_beacons_since_last_rx); 1413 le32_to_cpu(mb->consec_missed_beacons_since_last_rx);
1492 /* 1414 /*
1493 * TODO: the threshold should be adjusted based on latency conditions, 1415 * TODO: the threshold should be adjusted based on latency conditions,
1494 * and/or in case of a CS flow on one of the other AP vifs. 1416 * and/or in case of a CS flow on one of the other AP vifs.
1495 */ 1417 */
1496 if (le32_to_cpu(missed_beacons->consec_missed_beacons_since_last_rx) > 1418 if (rx_missed_bcon > IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG)
1497 IWL_MVM_MISSED_BEACONS_THRESHOLD) 1419 iwl_mvm_connection_loss(mvm, vif, "missed beacons");
1420 else if (rx_missed_bcon_since_rx > IWL_MVM_MISSED_BEACONS_THRESHOLD)
1498 ieee80211_beacon_loss(vif); 1421 ieee80211_beacon_loss(vif);
1499 1422
1500 trigger = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), 1423 trigger = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
1501 FW_DBG_TRIGGER_MISSED_BEACONS); 1424 FW_DBG_TRIGGER_MISSED_BEACONS);
1502 if (!trigger) 1425 if (!trigger)
1503 return; 1426 goto out;
1504 1427
1505 bcon_trig = (void *)trigger->data; 1428 bcon_trig = (void *)trigger->data;
1506 stop_trig_missed_bcon = le32_to_cpu(bcon_trig->stop_consec_missed_bcon); 1429 stop_trig_missed_bcon = le32_to_cpu(bcon_trig->stop_consec_missed_bcon);
@@ -1512,28 +1435,11 @@ static void iwl_mvm_beacon_loss_iterator(void *_data, u8 *mac,
1512 if (rx_missed_bcon_since_rx >= stop_trig_missed_bcon_since_rx || 1435 if (rx_missed_bcon_since_rx >= stop_trig_missed_bcon_since_rx ||
1513 rx_missed_bcon >= stop_trig_missed_bcon) 1436 rx_missed_bcon >= stop_trig_missed_bcon)
1514 iwl_fw_dbg_collect_trig(&mvm->fwrt, trigger, NULL); 1437 iwl_fw_dbg_collect_trig(&mvm->fwrt, trigger, NULL);
1515}
1516
1517void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1518 struct iwl_rx_cmd_buffer *rxb)
1519{
1520 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1521 struct iwl_missed_beacons_notif *mb = (void *)pkt->data;
1522
1523 IWL_DEBUG_INFO(mvm,
1524 "missed bcn mac_id=%u, consecutive=%u (%u, %u, %u)\n",
1525 le32_to_cpu(mb->mac_id),
1526 le32_to_cpu(mb->consec_missed_beacons),
1527 le32_to_cpu(mb->consec_missed_beacons_since_last_rx),
1528 le32_to_cpu(mb->num_recvd_beacons),
1529 le32_to_cpu(mb->num_expected_beacons));
1530
1531 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
1532 IEEE80211_IFACE_ITER_NORMAL,
1533 iwl_mvm_beacon_loss_iterator,
1534 mb);
1535 1438
1536 iwl_fw_dbg_apply_point(&mvm->fwrt, IWL_FW_INI_APPLY_MISSED_BEACONS); 1439 iwl_fw_dbg_apply_point(&mvm->fwrt, IWL_FW_INI_APPLY_MISSED_BEACONS);
1440
1441out:
1442 rcu_read_unlock();
1537} 1443}
1538 1444
1539void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm, 1445void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
@@ -1575,16 +1481,29 @@ void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
1575 ieee80211_rx_napi(mvm->hw, NULL, skb, NULL); 1481 ieee80211_rx_napi(mvm->hw, NULL, skb, NULL);
1576} 1482}
1577 1483
1578static void iwl_mvm_probe_resp_data_iter(void *_data, u8 *mac, 1484void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1579 struct ieee80211_vif *vif) 1485 struct iwl_rx_cmd_buffer *rxb)
1580{ 1486{
1581 struct iwl_probe_resp_data_notif *notif = _data; 1487 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1582 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1488 struct iwl_probe_resp_data_notif *notif = (void *)pkt->data;
1583 struct iwl_probe_resp_data *old_data, *new_data; 1489 struct iwl_probe_resp_data *old_data, *new_data;
1490 int len = iwl_rx_packet_payload_len(pkt);
1491 u32 id = le32_to_cpu(notif->mac_id);
1492 struct ieee80211_vif *vif;
1493 struct iwl_mvm_vif *mvmvif;
1584 1494
1585 if (mvmvif->id != (u16)le32_to_cpu(notif->mac_id)) 1495 if (WARN_ON_ONCE(len < sizeof(*notif)))
1586 return; 1496 return;
1587 1497
1498 IWL_DEBUG_INFO(mvm, "Probe response data notif: noa %d, csa %d\n",
1499 notif->noa_active, notif->csa_counter);
1500
1501 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, false);
1502 if (!vif)
1503 return;
1504
1505 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1506
1588 new_data = kzalloc(sizeof(*new_data), GFP_KERNEL); 1507 new_data = kzalloc(sizeof(*new_data), GFP_KERNEL);
1589 if (!new_data) 1508 if (!new_data)
1590 return; 1509 return;
@@ -1615,25 +1534,6 @@ static void iwl_mvm_probe_resp_data_iter(void *_data, u8 *mac,
1615 ieee80211_csa_set_counter(vif, notif->csa_counter); 1534 ieee80211_csa_set_counter(vif, notif->csa_counter);
1616} 1535}
1617 1536
1618void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1619 struct iwl_rx_cmd_buffer *rxb)
1620{
1621 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1622 struct iwl_probe_resp_data_notif *notif = (void *)pkt->data;
1623 int len = iwl_rx_packet_payload_len(pkt);
1624
1625 if (WARN_ON_ONCE(len < sizeof(*notif)))
1626 return;
1627
1628 IWL_DEBUG_INFO(mvm, "Probe response data notif: noa %d, csa %d\n",
1629 notif->noa_active, notif->csa_counter);
1630
1631 ieee80211_iterate_active_interfaces(mvm->hw,
1632 IEEE80211_IFACE_ITER_ACTIVE,
1633 iwl_mvm_probe_resp_data_iter,
1634 notif);
1635}
1636
1637void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm, 1537void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm,
1638 struct iwl_rx_cmd_buffer *rxb) 1538 struct iwl_rx_cmd_buffer *rxb)
1639{ 1539{
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 97dc464379d2..c9effd7f0ef8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -395,6 +395,21 @@ int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm)
395 return ret; 395 return ret;
396} 396}
397 397
398const static u8 he_if_types_ext_capa_sta[] = {
399 [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING,
400 [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF,
401 [9] = WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT,
402};
403
404const static struct wiphy_iftype_ext_capab he_iftypes_ext_capa[] = {
405 {
406 .iftype = NL80211_IFTYPE_STATION,
407 .extended_capabilities = he_if_types_ext_capa_sta,
408 .extended_capabilities_mask = he_if_types_ext_capa_sta,
409 .extended_capabilities_len = sizeof(he_if_types_ext_capa_sta),
410 },
411};
412
398int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) 413int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
399{ 414{
400 struct ieee80211_hw *hw = mvm->hw; 415 struct ieee80211_hw *hw = mvm->hw;
@@ -410,7 +425,6 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
410 ieee80211_hw_set(hw, SIGNAL_DBM); 425 ieee80211_hw_set(hw, SIGNAL_DBM);
411 ieee80211_hw_set(hw, SPECTRUM_MGMT); 426 ieee80211_hw_set(hw, SPECTRUM_MGMT);
412 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); 427 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
413 ieee80211_hw_set(hw, QUEUE_CONTROL);
414 ieee80211_hw_set(hw, WANT_MONITOR_VIF); 428 ieee80211_hw_set(hw, WANT_MONITOR_VIF);
415 ieee80211_hw_set(hw, SUPPORTS_PS); 429 ieee80211_hw_set(hw, SUPPORTS_PS);
416 ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); 430 ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
@@ -424,6 +438,10 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
424 ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR); 438 ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
425 ieee80211_hw_set(hw, DEAUTH_NEED_MGD_TX_PREP); 439 ieee80211_hw_set(hw, DEAUTH_NEED_MGD_TX_PREP);
426 ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW); 440 ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
441 ieee80211_hw_set(hw, BUFF_MMPDU_TXQ);
442 ieee80211_hw_set(hw, STA_MMPDU_TXQ);
443 ieee80211_hw_set(hw, TX_AMSDU);
444 ieee80211_hw_set(hw, TX_FRAG_LIST);
427 445
428 if (iwl_mvm_has_tlc_offload(mvm)) { 446 if (iwl_mvm_has_tlc_offload(mvm)) {
429 ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW); 447 ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW);
@@ -469,6 +487,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
469 487
470 hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES; 488 hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES;
471 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; 489 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
490 hw->max_tx_fragments = mvm->trans->max_skb_frags;
472 491
473 BUILD_BUG_ON(ARRAY_SIZE(mvm->ciphers) < ARRAY_SIZE(mvm_ciphers) + 6); 492 BUILD_BUG_ON(ARRAY_SIZE(mvm->ciphers) < ARRAY_SIZE(mvm_ciphers) + 6);
474 memcpy(mvm->ciphers, mvm_ciphers, sizeof(mvm_ciphers)); 493 memcpy(mvm->ciphers, mvm_ciphers, sizeof(mvm_ciphers));
@@ -534,6 +553,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
534 hw->sta_data_size = sizeof(struct iwl_mvm_sta); 553 hw->sta_data_size = sizeof(struct iwl_mvm_sta);
535 hw->vif_data_size = sizeof(struct iwl_mvm_vif); 554 hw->vif_data_size = sizeof(struct iwl_mvm_vif);
536 hw->chanctx_data_size = sizeof(u16); 555 hw->chanctx_data_size = sizeof(u16);
556 hw->txq_data_size = sizeof(struct iwl_mvm_txq);
537 557
538 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 558 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
539 BIT(NL80211_IFTYPE_P2P_CLIENT) | 559 BIT(NL80211_IFTYPE_P2P_CLIENT) |
@@ -673,6 +693,13 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
673 NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE); 693 NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE);
674 } 694 }
675 695
696 if (mvm->nvm_data->sku_cap_11ax_enable &&
697 !iwlwifi_mod_params.disable_11ax) {
698 hw->wiphy->iftype_ext_capab = he_iftypes_ext_capa;
699 hw->wiphy->num_iftype_ext_capab =
700 ARRAY_SIZE(he_iftypes_ext_capa);
701 }
702
676 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; 703 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
677 704
678#ifdef CONFIG_PM_SLEEP 705#ifdef CONFIG_PM_SLEEP
@@ -776,7 +803,6 @@ static bool iwl_mvm_defer_tx(struct iwl_mvm *mvm,
776 goto out; 803 goto out;
777 804
778 __skb_queue_tail(&mvm->d0i3_tx, skb); 805 __skb_queue_tail(&mvm->d0i3_tx, skb);
779 ieee80211_stop_queues(mvm->hw);
780 806
781 /* trigger wakeup */ 807 /* trigger wakeup */
782 iwl_mvm_ref(mvm, IWL_MVM_REF_TX); 808 iwl_mvm_ref(mvm, IWL_MVM_REF_TX);
@@ -796,13 +822,15 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
796 struct ieee80211_sta *sta = control->sta; 822 struct ieee80211_sta *sta = control->sta;
797 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 823 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
798 struct ieee80211_hdr *hdr = (void *)skb->data; 824 struct ieee80211_hdr *hdr = (void *)skb->data;
825 bool offchannel = IEEE80211_SKB_CB(skb)->flags &
826 IEEE80211_TX_CTL_TX_OFFCHAN;
799 827
800 if (iwl_mvm_is_radio_killed(mvm)) { 828 if (iwl_mvm_is_radio_killed(mvm)) {
801 IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); 829 IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
802 goto drop; 830 goto drop;
803 } 831 }
804 832
805 if (info->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && 833 if (offchannel &&
806 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) && 834 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) &&
807 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) 835 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status))
808 goto drop; 836 goto drop;
@@ -815,8 +843,8 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
815 sta = NULL; 843 sta = NULL;
816 844
817 /* If there is no sta, and it's not offchannel - send through AP */ 845 /* If there is no sta, and it's not offchannel - send through AP */
818 if (info->control.vif->type == NL80211_IFTYPE_STATION && 846 if (!sta && info->control.vif->type == NL80211_IFTYPE_STATION &&
819 info->hw_queue != IWL_MVM_OFFCHANNEL_QUEUE && !sta) { 847 !offchannel) {
820 struct iwl_mvm_vif *mvmvif = 848 struct iwl_mvm_vif *mvmvif =
821 iwl_mvm_vif_from_mac80211(info->control.vif); 849 iwl_mvm_vif_from_mac80211(info->control.vif);
822 u8 ap_sta_id = READ_ONCE(mvmvif->ap_sta_id); 850 u8 ap_sta_id = READ_ONCE(mvmvif->ap_sta_id);
@@ -844,22 +872,95 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
844 ieee80211_free_txskb(hw, skb); 872 ieee80211_free_txskb(hw, skb);
845} 873}
846 874
847static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg) 875void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
848{ 876{
849 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) 877 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
850 return false; 878 struct iwl_mvm_txq *mvmtxq = iwl_mvm_txq_from_mac80211(txq);
851 return true; 879 struct sk_buff *skb = NULL;
880
881 /*
882 * No need for threads to be pending here, they can leave the first
883 * taker all the work.
884 *
885 * mvmtxq->tx_request logic:
886 *
887 * If 0, no one is currently TXing, set to 1 to indicate current thread
888 * will now start TX and other threads should quit.
889 *
890 * If 1, another thread is currently TXing, set to 2 to indicate to
891 * that thread that there was another request. Since that request may
892 * have raced with the check whether the queue is empty, the TXing
893 * thread should check the queue's status one more time before leaving.
894 * This check is done in order to not leave any TX hanging in the queue
895 * until the next TX invocation (which may not even happen).
896 *
897 * If 2, another thread is currently TXing, and it will already double
898 * check the queue, so do nothing.
899 */
900 if (atomic_fetch_add_unless(&mvmtxq->tx_request, 1, 2))
901 return;
902
903 rcu_read_lock();
904 do {
905 while (likely(!mvmtxq->stopped &&
906 (mvm->trans->system_pm_mode ==
907 IWL_PLAT_PM_MODE_DISABLED))) {
908 skb = ieee80211_tx_dequeue(hw, txq);
909
910 if (!skb)
911 break;
912
913 if (!txq->sta)
914 iwl_mvm_tx_skb_non_sta(mvm, skb);
915 else
916 iwl_mvm_tx_skb(mvm, skb, txq->sta);
917 }
918 } while (atomic_dec_return(&mvmtxq->tx_request));
919 rcu_read_unlock();
852} 920}
853 921
854static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg) 922static void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw *hw,
923 struct ieee80211_txq *txq)
855{ 924{
856 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) 925 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
857 return false; 926 struct iwl_mvm_txq *mvmtxq = iwl_mvm_txq_from_mac80211(txq);
858 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
859 return true;
860 927
861 /* enabled by default */ 928 /*
862 return true; 929 * Please note that racing is handled very carefully here:
930 * mvmtxq->txq_id is updated during allocation, and mvmtxq->list is
931 * deleted afterwards.
932 * This means that if:
933 * mvmtxq->txq_id != INVALID_QUEUE && list_empty(&mvmtxq->list):
934 * queue is allocated and we can TX.
935 * mvmtxq->txq_id != INVALID_QUEUE && !list_empty(&mvmtxq->list):
936 * a race, should defer the frame.
937 * mvmtxq->txq_id == INVALID_QUEUE && list_empty(&mvmtxq->list):
938 * need to allocate the queue and defer the frame.
939 * mvmtxq->txq_id == INVALID_QUEUE && !list_empty(&mvmtxq->list):
940 * queue is already scheduled for allocation, no need to allocate,
941 * should defer the frame.
942 */
943
944 /* If the queue is allocated TX and return. */
945 if (!txq->sta || mvmtxq->txq_id != IWL_MVM_INVALID_QUEUE) {
946 /*
947 * Check that list is empty to avoid a race where txq_id is
948 * already updated, but the queue allocation work wasn't
949 * finished
950 */
951 if (unlikely(txq->sta && !list_empty(&mvmtxq->list)))
952 return;
953
954 iwl_mvm_mac_itxq_xmit(hw, txq);
955 return;
956 }
957
958 /* The list is being deleted only after the queue is fully allocated. */
959 if (!list_empty(&mvmtxq->list))
960 return;
961
962 list_add_tail(&mvmtxq->list, &mvm->add_stream_txqs);
963 schedule_work(&mvm->add_stream_wk);
863} 964}
864 965
865#define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \ 966#define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \
@@ -974,7 +1075,7 @@ static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
974 mvmvif = iwl_mvm_vif_from_mac80211(vif); 1075 mvmvif = iwl_mvm_vif_from_mac80211(vif);
975 cancel_delayed_work(&mvmvif->uapsd_nonagg_detected_wk); 1076 cancel_delayed_work(&mvmvif->uapsd_nonagg_detected_wk);
976 } 1077 }
977 if (!iwl_enable_rx_ampdu(mvm->cfg)) { 1078 if (!iwl_enable_rx_ampdu()) {
978 ret = -EINVAL; 1079 ret = -EINVAL;
979 break; 1080 break;
980 } 1081 }
@@ -986,7 +1087,7 @@ static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
986 timeout); 1087 timeout);
987 break; 1088 break;
988 case IEEE80211_AMPDU_TX_START: 1089 case IEEE80211_AMPDU_TX_START:
989 if (!iwl_enable_tx_ampdu(mvm->cfg)) { 1090 if (!iwl_enable_tx_ampdu()) {
990 ret = -EINVAL; 1091 ret = -EINVAL;
991 break; 1092 break;
992 } 1093 }
@@ -1066,6 +1167,8 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
1066 1167
1067 iwl_mvm_stop_device(mvm); 1168 iwl_mvm_stop_device(mvm);
1068 1169
1170 mvm->cur_aid = 0;
1171
1069 mvm->scan_status = 0; 1172 mvm->scan_status = 0;
1070 mvm->ps_disabled = false; 1173 mvm->ps_disabled = false;
1071 mvm->calibrating = false; 1174 mvm->calibrating = false;
@@ -1085,7 +1188,6 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
1085 1188
1086 iwl_mvm_reset_phy_ctxts(mvm); 1189 iwl_mvm_reset_phy_ctxts(mvm);
1087 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); 1190 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
1088 memset(mvm->sta_deferred_frames, 0, sizeof(mvm->sta_deferred_frames));
1089 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); 1191 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
1090 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); 1192 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd));
1091 1193
@@ -1391,6 +1493,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1391 if (ret) 1493 if (ret)
1392 goto out_unlock; 1494 goto out_unlock;
1393 1495
1496 rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
1497
1394 /* Counting number of interfaces is needed for legacy PM */ 1498 /* Counting number of interfaces is needed for legacy PM */
1395 if (vif->type != NL80211_IFTYPE_P2P_DEVICE) 1499 if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
1396 mvm->vif_count++; 1500 mvm->vif_count++;
@@ -1582,6 +1686,8 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
1582 iwl_mvm_power_update_mac(mvm); 1686 iwl_mvm_power_update_mac(mvm);
1583 iwl_mvm_mac_ctxt_remove(mvm, vif); 1687 iwl_mvm_mac_ctxt_remove(mvm, vif);
1584 1688
1689 RCU_INIT_POINTER(mvm->vif_id_to_mac[mvmvif->id], NULL);
1690
1585 if (vif->type == NL80211_IFTYPE_MONITOR) 1691 if (vif->type == NL80211_IFTYPE_MONITOR)
1586 mvm->monitor_on = false; 1692 mvm->monitor_on = false;
1587 1693
@@ -2146,6 +2252,12 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
2146 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); 2252 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif);
2147 } 2253 }
2148 2254
2255 /* Update MU EDCA params */
2256 if (changes & BSS_CHANGED_QOS && mvmvif->associated &&
2257 bss_conf->assoc && vif->bss_conf.he_support &&
2258 !iwlwifi_mod_params.disable_11ax)
2259 iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->ap_sta_id);
2260
2149 /* 2261 /*
2150 * If we're not associated yet, take the (new) BSSID before associating 2262 * If we're not associated yet, take the (new) BSSID before associating
2151 * so the firmware knows. If we're already associated, then use the old 2263 * so the firmware knows. If we're already associated, then use the old
@@ -2672,7 +2784,7 @@ static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
2672 return; 2784 return;
2673 2785
2674 spin_lock_bh(&mvmsta->lock); 2786 spin_lock_bh(&mvmsta->lock);
2675 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { 2787 for (tid = 0; tid < ARRAY_SIZE(mvmsta->tid_data); tid++) {
2676 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; 2788 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
2677 2789
2678 if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE) 2790 if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE)
@@ -2861,32 +2973,6 @@ iwl_mvm_tdls_check_trigger(struct iwl_mvm *mvm,
2861 peer_addr, action); 2973 peer_addr, action);
2862} 2974}
2863 2975
2864static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm,
2865 struct iwl_mvm_sta *mvm_sta)
2866{
2867 struct iwl_mvm_tid_data *tid_data;
2868 struct sk_buff *skb;
2869 int i;
2870
2871 spin_lock_bh(&mvm_sta->lock);
2872 for (i = 0; i <= IWL_MAX_TID_COUNT; i++) {
2873 tid_data = &mvm_sta->tid_data[i];
2874
2875 while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) {
2876 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2877
2878 /*
2879 * The first deferred frame should've stopped the MAC
2880 * queues, so we should never get a second deferred
2881 * frame for the RA/TID.
2882 */
2883 iwl_mvm_start_mac_queues(mvm, BIT(info->hw_queue));
2884 ieee80211_free_txskb(mvm->hw, skb);
2885 }
2886 }
2887 spin_unlock_bh(&mvm_sta->lock);
2888}
2889
2890static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, 2976static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
2891 struct ieee80211_vif *vif, 2977 struct ieee80211_vif *vif,
2892 struct ieee80211_sta *sta, 2978 struct ieee80211_sta *sta,
@@ -2920,7 +3006,6 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
2920 */ 3006 */
2921 if (old_state == IEEE80211_STA_NONE && 3007 if (old_state == IEEE80211_STA_NONE &&
2922 new_state == IEEE80211_STA_NOTEXIST) { 3008 new_state == IEEE80211_STA_NOTEXIST) {
2923 iwl_mvm_purge_deferred_tx_frames(mvm, mvm_sta);
2924 flush_work(&mvm->add_stream_wk); 3009 flush_work(&mvm->add_stream_wk);
2925 3010
2926 /* 3011 /*
@@ -2967,6 +3052,8 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
2967 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, 3052 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
2968 NL80211_TDLS_SETUP); 3053 NL80211_TDLS_SETUP);
2969 } 3054 }
3055
3056 sta->max_rc_amsdu_len = 1;
2970 } else if (old_state == IEEE80211_STA_NONE && 3057 } else if (old_state == IEEE80211_STA_NONE &&
2971 new_state == IEEE80211_STA_AUTH) { 3058 new_state == IEEE80211_STA_AUTH) {
2972 /* 3059 /*
@@ -3036,6 +3123,16 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
3036 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, 3123 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
3037 NL80211_TDLS_DISABLE_LINK); 3124 NL80211_TDLS_DISABLE_LINK);
3038 } 3125 }
3126
3127 /* Remove STA key if this is an AP using WEP */
3128 if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) {
3129 int rm_ret = iwl_mvm_remove_sta_key(mvm, vif, sta,
3130 mvmvif->ap_wep_key);
3131
3132 if (!ret)
3133 ret = rm_ret;
3134 }
3135
3039 } else { 3136 } else {
3040 ret = -EIO; 3137 ret = -EIO;
3041 } 3138 }
@@ -3431,14 +3528,20 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
3431 .id_and_color = 3528 .id_and_color =
3432 cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)), 3529 cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)),
3433 .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id), 3530 .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id),
3434 /* Set the channel info data */ 3531 };
3435 .channel_info.band = (channel->band == NL80211_BAND_2GHZ) ? 3532 struct iwl_hs20_roc_req_tail *tail = iwl_mvm_chan_info_cmd_tail(mvm,
3436 PHY_BAND_24 : PHY_BAND_5, 3533 &aux_roc_req.channel_info);
3437 .channel_info.channel = channel->hw_value, 3534 u16 len = sizeof(aux_roc_req) - iwl_mvm_chan_info_padding(mvm);
3438 .channel_info.width = PHY_VHT_CHANNEL_MODE20, 3535
3439 /* Set the time and duration */ 3536 /* Set the channel info data */
3440 .apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg)), 3537 iwl_mvm_set_chan_info(mvm, &aux_roc_req.channel_info, channel->hw_value,
3441 }; 3538 (channel->band == NL80211_BAND_2GHZ) ?
3539 PHY_BAND_24 : PHY_BAND_5,
3540 PHY_VHT_CHANNEL_MODE20,
3541 0);
3542
3543 /* Set the time and duration */
3544 tail->apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg));
3442 3545
3443 delay = AUX_ROC_MIN_DELAY; 3546 delay = AUX_ROC_MIN_DELAY;
3444 req_dur = MSEC_TO_TU(duration); 3547 req_dur = MSEC_TO_TU(duration);
@@ -3463,15 +3566,15 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
3463 } 3566 }
3464 } 3567 }
3465 3568
3466 aux_roc_req.duration = cpu_to_le32(req_dur); 3569 tail->duration = cpu_to_le32(req_dur);
3467 aux_roc_req.apply_time_max_delay = cpu_to_le32(delay); 3570 tail->apply_time_max_delay = cpu_to_le32(delay);
3468 3571
3469 IWL_DEBUG_TE(mvm, 3572 IWL_DEBUG_TE(mvm,
3470 "ROC: Requesting to remain on channel %u for %ums (requested = %ums, max_delay = %ums, dtim_interval = %ums)\n", 3573 "ROC: Requesting to remain on channel %u for %ums (requested = %ums, max_delay = %ums, dtim_interval = %ums)\n",
3471 channel->hw_value, req_dur, duration, delay, 3574 channel->hw_value, req_dur, duration, delay,
3472 dtim_interval); 3575 dtim_interval);
3473 /* Set the node address */ 3576 /* Set the node address */
3474 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); 3577 memcpy(tail->node_addr, vif->addr, ETH_ALEN);
3475 3578
3476 lockdep_assert_held(&mvm->mutex); 3579 lockdep_assert_held(&mvm->mutex);
3477 3580
@@ -3502,7 +3605,7 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
3502 ARRAY_SIZE(time_event_response), 3605 ARRAY_SIZE(time_event_response),
3503 iwl_mvm_rx_aux_roc, te_data); 3606 iwl_mvm_rx_aux_roc, te_data);
3504 3607
3505 res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, sizeof(aux_roc_req), 3608 res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, len,
3506 &aux_roc_req); 3609 &aux_roc_req);
3507 3610
3508 if (res) { 3611 if (res) {
@@ -4656,8 +4759,35 @@ static void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw)
4656 mutex_unlock(&mvm->mutex); 4759 mutex_unlock(&mvm->mutex);
4657} 4760}
4658 4761
4762static bool iwl_mvm_can_hw_csum(struct sk_buff *skb)
4763{
4764 u8 protocol = ip_hdr(skb)->protocol;
4765
4766 if (!IS_ENABLED(CONFIG_INET))
4767 return false;
4768
4769 return protocol == IPPROTO_TCP || protocol == IPPROTO_UDP;
4770}
4771
4772static bool iwl_mvm_mac_can_aggregate(struct ieee80211_hw *hw,
4773 struct sk_buff *head,
4774 struct sk_buff *skb)
4775{
4776 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4777
4778 /* For now don't aggregate IPv6 in AMSDU */
4779 if (skb->protocol != htons(ETH_P_IP))
4780 return false;
4781
4782 if (!iwl_mvm_is_csum_supported(mvm))
4783 return true;
4784
4785 return iwl_mvm_can_hw_csum(skb) == iwl_mvm_can_hw_csum(head);
4786}
4787
4659const struct ieee80211_ops iwl_mvm_hw_ops = { 4788const struct ieee80211_ops iwl_mvm_hw_ops = {
4660 .tx = iwl_mvm_mac_tx, 4789 .tx = iwl_mvm_mac_tx,
4790 .wake_tx_queue = iwl_mvm_mac_wake_tx_queue,
4661 .ampdu_action = iwl_mvm_mac_ampdu_action, 4791 .ampdu_action = iwl_mvm_mac_ampdu_action,
4662 .start = iwl_mvm_mac_start, 4792 .start = iwl_mvm_mac_start,
4663 .reconfig_complete = iwl_mvm_mac_reconfig_complete, 4793 .reconfig_complete = iwl_mvm_mac_reconfig_complete,
@@ -4731,6 +4861,7 @@ const struct ieee80211_ops iwl_mvm_hw_ops = {
4731#endif 4861#endif
4732 .get_survey = iwl_mvm_mac_get_survey, 4862 .get_survey = iwl_mvm_mac_get_survey,
4733 .sta_statistics = iwl_mvm_mac_sta_statistics, 4863 .sta_statistics = iwl_mvm_mac_sta_statistics,
4864 .can_aggregate_in_amsdu = iwl_mvm_mac_can_aggregate,
4734#ifdef CONFIG_IWLWIFI_DEBUGFS 4865#ifdef CONFIG_IWLWIFI_DEBUGFS
4735 .sta_add_debugfs = iwl_mvm_sta_add_debugfs, 4866 .sta_add_debugfs = iwl_mvm_sta_add_debugfs,
4736#endif 4867#endif
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 1aa690e081ff..12e9ecc3ee27 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -83,7 +83,6 @@
83#include "sta.h" 83#include "sta.h"
84#include "fw-api.h" 84#include "fw-api.h"
85#include "constants.h" 85#include "constants.h"
86#include "tof.h"
87#include "fw/runtime.h" 86#include "fw/runtime.h"
88#include "fw/dbg.h" 87#include "fw/dbg.h"
89#include "fw/acpi.h" 88#include "fw/acpi.h"
@@ -95,6 +94,8 @@
95/* RSSI offset for WkP */ 94/* RSSI offset for WkP */
96#define IWL_RSSI_OFFSET 50 95#define IWL_RSSI_OFFSET 50
97#define IWL_MVM_MISSED_BEACONS_THRESHOLD 8 96#define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
97#define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16
98
98/* A TimeUnit is 1024 microsecond */ 99/* A TimeUnit is 1024 microsecond */
99#define MSEC_TO_TU(_msec) (_msec*1000/1024) 100#define MSEC_TO_TU(_msec) (_msec*1000/1024)
100 101
@@ -299,17 +300,38 @@ enum iwl_bt_force_ant_mode {
299}; 300};
300 301
301/** 302/**
303 * struct iwl_mvm_low_latency_force - low latency force mode set by debugfs
304 * @LOW_LATENCY_FORCE_UNSET: unset force mode
305 * @LOW_LATENCY_FORCE_ON: for low latency on
306 * @LOW_LATENCY_FORCE_OFF: for low latency off
307 * @NUM_LOW_LATENCY_FORCE: max num of modes
308 */
309enum iwl_mvm_low_latency_force {
310 LOW_LATENCY_FORCE_UNSET,
311 LOW_LATENCY_FORCE_ON,
312 LOW_LATENCY_FORCE_OFF,
313 NUM_LOW_LATENCY_FORCE
314};
315
316/**
302* struct iwl_mvm_low_latency_cause - low latency set causes 317* struct iwl_mvm_low_latency_cause - low latency set causes
303* @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected 318* @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected
304* @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs 319* @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs
305* @LOW_LATENCY_VCMD: low latency mode set from vendor command 320* @LOW_LATENCY_VCMD: low latency mode set from vendor command
306* @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap) 321* @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap)
322* @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled
323* the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE
324* @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs
325* set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag
326* in low_latency.
307*/ 327*/
308enum iwl_mvm_low_latency_cause { 328enum iwl_mvm_low_latency_cause {
309 LOW_LATENCY_TRAFFIC = BIT(0), 329 LOW_LATENCY_TRAFFIC = BIT(0),
310 LOW_LATENCY_DEBUGFS = BIT(1), 330 LOW_LATENCY_DEBUGFS = BIT(1),
311 LOW_LATENCY_VCMD = BIT(2), 331 LOW_LATENCY_VCMD = BIT(2),
312 LOW_LATENCY_VIF_TYPE = BIT(3), 332 LOW_LATENCY_VIF_TYPE = BIT(3),
333 LOW_LATENCY_DEBUGFS_FORCE_ENABLE = BIT(4),
334 LOW_LATENCY_DEBUGFS_FORCE = BIT(5),
313}; 335};
314 336
315/** 337/**
@@ -360,8 +382,10 @@ struct iwl_probe_resp_data {
360 * @pm_enabled - Indicate if MAC power management is allowed 382 * @pm_enabled - Indicate if MAC power management is allowed
361 * @monitor_active: indicates that monitor context is configured, and that the 383 * @monitor_active: indicates that monitor context is configured, and that the
362 * interface should get quota etc. 384 * interface should get quota etc.
363 * @low_latency: indicates low latency is set, see 385 * @low_latency: bit flags for low latency
364 * enum &iwl_mvm_low_latency_cause for causes. 386 * see enum &iwl_mvm_low_latency_cause for causes.
387 * @low_latency_actual: boolean, indicates low latency is set,
388 * as a result from low_latency bit flags and takes force into account.
365 * @ps_disabled: indicates that this interface requires PS to be disabled 389 * @ps_disabled: indicates that this interface requires PS to be disabled
366 * @queue_params: QoS params for this MAC 390 * @queue_params: QoS params for this MAC
367 * @bcast_sta: station used for broadcast packets. Used by the following 391 * @bcast_sta: station used for broadcast packets. Used by the following
@@ -393,7 +417,8 @@ struct iwl_mvm_vif {
393 bool ap_ibss_active; 417 bool ap_ibss_active;
394 bool pm_enabled; 418 bool pm_enabled;
395 bool monitor_active; 419 bool monitor_active;
396 u8 low_latency; 420 u8 low_latency: 6;
421 u8 low_latency_actual: 1;
397 bool ps_disabled; 422 bool ps_disabled;
398 struct iwl_mvm_vif_bf_data bf_data; 423 struct iwl_mvm_vif_bf_data bf_data;
399 424
@@ -778,6 +803,39 @@ struct iwl_mvm_geo_profile {
778 u8 values[ACPI_GEO_TABLE_SIZE]; 803 u8 values[ACPI_GEO_TABLE_SIZE];
779}; 804};
780 805
806struct iwl_mvm_txq {
807 struct list_head list;
808 u16 txq_id;
809 atomic_t tx_request;
810 bool stopped;
811};
812
813static inline struct iwl_mvm_txq *
814iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq)
815{
816 return (void *)txq->drv_priv;
817}
818
819static inline struct iwl_mvm_txq *
820iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid)
821{
822 if (tid == IWL_MAX_TID_COUNT)
823 tid = IEEE80211_NUM_TIDS;
824
825 return (void *)sta->txq[tid]->drv_priv;
826}
827
828/**
829 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid
830 *
831 * @sta_id: sta id
832 * @txq_tid: txq tid
833 */
834struct iwl_mvm_tvqm_txq_info {
835 u8 sta_id;
836 u8 txq_tid;
837};
838
781struct iwl_mvm_dqa_txq_info { 839struct iwl_mvm_dqa_txq_info {
782 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */ 840 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */
783 bool reserved; /* Is this the TXQ reserved for a STA */ 841 bool reserved; /* Is this the TXQ reserved for a STA */
@@ -843,13 +901,13 @@ struct iwl_mvm {
843 u64 on_time_scan; 901 u64 on_time_scan;
844 } radio_stats, accu_radio_stats; 902 } radio_stats, accu_radio_stats;
845 903
846 u16 hw_queue_to_mac80211[IWL_MAX_TVQM_QUEUES]; 904 struct list_head add_stream_txqs;
847 905 union {
848 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES]; 906 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES];
907 struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES];
908 };
849 struct work_struct add_stream_wk; /* To add streams to queues */ 909 struct work_struct add_stream_wk; /* To add streams to queues */
850 910
851 atomic_t mac80211_queue_stop_count[IEEE80211_MAX_QUEUES];
852
853 const char *nvm_file_name; 911 const char *nvm_file_name;
854 struct iwl_nvm_data *nvm_data; 912 struct iwl_nvm_data *nvm_data;
855 /* NVM sections */ 913 /* NVM sections */
@@ -863,7 +921,6 @@ struct iwl_mvm {
863 /* data related to data path */ 921 /* data related to data path */
864 struct iwl_rx_phy_info last_phy_info; 922 struct iwl_rx_phy_info last_phy_info;
865 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT]; 923 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
866 unsigned long sta_deferred_frames[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
867 u8 rx_ba_sessions; 924 u8 rx_ba_sessions;
868 925
869 /* configured by mac80211 */ 926 /* configured by mac80211 */
@@ -932,6 +989,7 @@ struct iwl_mvm {
932 struct debugfs_blob_wrapper nvm_calib_blob; 989 struct debugfs_blob_wrapper nvm_calib_blob;
933 struct debugfs_blob_wrapper nvm_prod_blob; 990 struct debugfs_blob_wrapper nvm_prod_blob;
934 struct debugfs_blob_wrapper nvm_phy_sku_blob; 991 struct debugfs_blob_wrapper nvm_phy_sku_blob;
992 struct debugfs_blob_wrapper nvm_reg_blob;
935 993
936 struct iwl_mvm_frame_stats drv_rx_stats; 994 struct iwl_mvm_frame_stats drv_rx_stats;
937 spinlock_t drv_stats_lock; 995 spinlock_t drv_stats_lock;
@@ -955,6 +1013,7 @@ struct iwl_mvm {
955 u8 refs[IWL_MVM_REF_COUNT]; 1013 u8 refs[IWL_MVM_REF_COUNT];
956 1014
957 u8 vif_count; 1015 u8 vif_count;
1016 struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];
958 1017
959 /* -1 for always, 0 for never, >0 for that many times */ 1018 /* -1 for always, 0 for never, >0 for that many times */
960 s8 fw_restart; 1019 s8 fw_restart;
@@ -1090,7 +1149,6 @@ struct iwl_mvm {
1090 1149
1091 u32 ciphers[IWL_MVM_NUM_CIPHERS]; 1150 u32 ciphers[IWL_MVM_NUM_CIPHERS];
1092 struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS]; 1151 struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS];
1093 struct iwl_mvm_tof_data tof_data;
1094 1152
1095 struct ieee80211_vif *nan_vif; 1153 struct ieee80211_vif *nan_vif;
1096#define IWL_MAX_BAID 32 1154#define IWL_MAX_BAID 32
@@ -1106,6 +1164,10 @@ struct iwl_mvm {
1106 1164
1107 /* does a monitor vif exist (only one can exist hence bool) */ 1165 /* does a monitor vif exist (only one can exist hence bool) */
1108 bool monitor_on; 1166 bool monitor_on;
1167
1168 /* sniffer data to include in radiotap */
1169 __le16 cur_aid;
1170
1109#ifdef CONFIG_ACPI 1171#ifdef CONFIG_ACPI
1110 struct iwl_mvm_sar_profile sar_profiles[ACPI_SAR_PROFILE_NUM]; 1172 struct iwl_mvm_sar_profile sar_profiles[ACPI_SAR_PROFILE_NUM];
1111 struct iwl_mvm_geo_profile geo_profiles[ACPI_NUM_GEO_PROFILES]; 1173 struct iwl_mvm_geo_profile geo_profiles[ACPI_NUM_GEO_PROFILES];
@@ -1150,7 +1212,6 @@ enum iwl_mvm_init_status {
1150 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0), 1212 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0),
1151 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1), 1213 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1),
1152 IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE = BIT(2), 1214 IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE = BIT(2),
1153 IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE = BIT(3),
1154}; 1215};
1155 1216
1156static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm) 1217static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
@@ -1207,6 +1268,19 @@ iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
1207 return iwl_mvm_sta_from_mac80211(sta); 1268 return iwl_mvm_sta_from_mac80211(sta);
1208} 1269}
1209 1270
1271static inline struct ieee80211_vif *
1272iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu)
1273{
1274 if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac)))
1275 return NULL;
1276
1277 if (rcu)
1278 return rcu_dereference(mvm->vif_id_to_mac[vif_id]);
1279
1280 return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id],
1281 lockdep_is_held(&mvm->mutex));
1282}
1283
1210static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm) 1284static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
1211{ 1285{
1212 return !iwlwifi_mod_params.d0i3_disable && 1286 return !iwlwifi_mod_params.d0i3_disable &&
@@ -1470,6 +1544,11 @@ void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
1470void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd, 1544void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
1471 struct ieee80211_tx_info *info, 1545 struct ieee80211_tx_info *info,
1472 struct ieee80211_sta *sta, __le16 fc); 1546 struct ieee80211_sta *sta, __le16 fc);
1547void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
1548unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
1549 struct ieee80211_sta *sta,
1550 unsigned int tid);
1551
1473#ifdef CONFIG_IWLWIFI_DEBUG 1552#ifdef CONFIG_IWLWIFI_DEBUG
1474const char *iwl_mvm_get_tx_fail_reason(u32 status); 1553const char *iwl_mvm_get_tx_fail_reason(u32 status);
1475#else 1554#else
@@ -1599,7 +1678,6 @@ int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1599int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1678int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1600 bool force_assoc_off, const u8 *bssid_override); 1679 bool force_assoc_off, const u8 *bssid_override);
1601int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1680int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1602u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif);
1603int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm, 1681int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
1604 struct ieee80211_vif *vif); 1682 struct ieee80211_vif *vif);
1605void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, 1683void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
@@ -1615,8 +1693,6 @@ void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,
1615 struct iwl_rx_cmd_buffer *rxb); 1693 struct iwl_rx_cmd_buffer *rxb);
1616void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm, 1694void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
1617 struct ieee80211_vif *vif); 1695 struct ieee80211_vif *vif);
1618unsigned long iwl_mvm_get_used_hw_queues(struct iwl_mvm *mvm,
1619 struct ieee80211_vif *exclude_vif);
1620void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm, 1696void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1621 struct iwl_rx_cmd_buffer *rxb); 1697 struct iwl_rx_cmd_buffer *rxb);
1622void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm, 1698void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm,
@@ -1870,17 +1946,43 @@ static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
1870 * binding, so this has no real impact. For now, just return 1946 * binding, so this has no real impact. For now, just return
1871 * the current desired low-latency state. 1947 * the current desired low-latency state.
1872 */ 1948 */
1873 return mvmvif->low_latency; 1949 return mvmvif->low_latency_actual;
1874} 1950}
1875 1951
1876static inline 1952static inline
1877void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set, 1953void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set,
1878 enum iwl_mvm_low_latency_cause cause) 1954 enum iwl_mvm_low_latency_cause cause)
1879{ 1955{
1956 u8 new_state;
1957
1880 if (set) 1958 if (set)
1881 mvmvif->low_latency |= cause; 1959 mvmvif->low_latency |= cause;
1882 else 1960 else
1883 mvmvif->low_latency &= ~cause; 1961 mvmvif->low_latency &= ~cause;
1962
1963 /*
1964 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are
1965 * allowed to actual mode.
1966 */
1967 if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE &&
1968 cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE)
1969 return;
1970
1971 if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set)
1972 /*
1973 * We enter force state
1974 */
1975 new_state = !!(mvmvif->low_latency &
1976 LOW_LATENCY_DEBUGFS_FORCE);
1977 else
1978 /*
1979 * Check if any other one set low latency
1980 */
1981 new_state = !!(mvmvif->low_latency &
1982 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE |
1983 LOW_LATENCY_DEBUGFS_FORCE));
1984
1985 mvmvif->low_latency_actual = new_state;
1884} 1986}
1885 1987
1886/* Return a bitmask with all the hw supported queues, except for the 1988/* Return a bitmask with all the hw supported queues, except for the
@@ -1895,6 +1997,16 @@ static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
1895static inline void iwl_mvm_stop_device(struct iwl_mvm *mvm) 1997static inline void iwl_mvm_stop_device(struct iwl_mvm *mvm)
1896{ 1998{
1897 lockdep_assert_held(&mvm->mutex); 1999 lockdep_assert_held(&mvm->mutex);
2000 /* If IWL_MVM_STATUS_HW_RESTART_REQUESTED bit is set then we received
2001 * an assert. Since we failed to bring the interface up, mac80211
2002 * will not attempt to reconfig the device,
2003 * which handles the dump collection in assert flow,
2004 * so trigger dump collection here.
2005 */
2006 if (test_and_clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED,
2007 &mvm->status))
2008 iwl_fw_dbg_collect_desc(&mvm->fwrt, &iwl_dump_desc_assert,
2009 false, 0);
1898 /* calling this function without using dump_start/end since at this 2010 /* calling this function without using dump_start/end since at this
1899 * point we already hold the op mode mutex 2011 * point we already hold the op mode mutex
1900 */ 2012 */
@@ -1906,10 +2018,6 @@ static inline void iwl_mvm_stop_device(struct iwl_mvm *mvm)
1906 iwl_trans_stop_device(mvm->trans); 2018 iwl_trans_stop_device(mvm->trans);
1907} 2019}
1908 2020
1909/* Stop/start all mac queues in a given bitmap */
1910void iwl_mvm_start_mac_queues(struct iwl_mvm *mvm, unsigned long mq);
1911void iwl_mvm_stop_mac_queues(struct iwl_mvm *mvm, unsigned long mq);
1912
1913/* Re-configure the SCD for a queue that has already been configured */ 2021/* Re-configure the SCD for a queue that has already been configured */
1914int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id, 2022int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id,
1915 int tid, int frame_limit, u16 ssn); 2023 int tid, int frame_limit, u16 ssn);
@@ -2015,4 +2123,59 @@ void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
2015 struct dentry *dir); 2123 struct dentry *dir);
2016#endif 2124#endif
2017 2125
2126/* Channel info utils */
2127static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
2128{
2129 return fw_has_capa(&mvm->fw->ucode_capa,
2130 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS);
2131}
2132
2133static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm,
2134 struct iwl_fw_channel_info *ci)
2135{
2136 return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ?
2137 sizeof(struct iwl_fw_channel_info) :
2138 sizeof(struct iwl_fw_channel_info_v1));
2139}
2140
2141static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm)
2142{
2143 return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 :
2144 sizeof(struct iwl_fw_channel_info) -
2145 sizeof(struct iwl_fw_channel_info_v1);
2146}
2147
2148static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm,
2149 struct iwl_fw_channel_info *ci,
2150 u32 chan, u8 band, u8 width,
2151 u8 ctrl_pos)
2152{
2153 if (iwl_mvm_has_ultra_hb_channel(mvm)) {
2154 ci->channel = cpu_to_le32(chan);
2155 ci->band = band;
2156 ci->width = width;
2157 ci->ctrl_pos = ctrl_pos;
2158 } else {
2159 struct iwl_fw_channel_info_v1 *ci_v1 =
2160 (struct iwl_fw_channel_info_v1 *)ci;
2161
2162 ci_v1->channel = chan;
2163 ci_v1->band = band;
2164 ci_v1->width = width;
2165 ci_v1->ctrl_pos = ctrl_pos;
2166 }
2167}
2168
2169static inline void
2170iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm,
2171 struct iwl_fw_channel_info *ci,
2172 struct cfg80211_chan_def *chandef)
2173{
2174 iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value,
2175 (chandef->chan->band == NL80211_BAND_2GHZ ?
2176 PHY_BAND_24 : PHY_BAND_5),
2177 iwl_mvm_get_channel_width(chandef),
2178 iwl_mvm_get_ctrl_pos(chandef));
2179}
2180
2018#endif /* __IWL_MVM_H__ */ 2181#endif /* __IWL_MVM_H__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 6fc5cc1f2b5b..7bdbd010ae6b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -179,7 +179,7 @@ static int iwl_nvm_read_chunk(struct iwl_mvm *mvm, u16 section,
179 IWL_DEBUG_EEPROM(mvm->trans->dev, 179 IWL_DEBUG_EEPROM(mvm->trans->dev,
180 "NVM access command failed with status %d (device: %s)\n", 180 "NVM access command failed with status %d (device: %s)\n",
181 ret, mvm->cfg->name); 181 ret, mvm->cfg->name);
182 ret = -EIO; 182 ret = -ENODATA;
183 } 183 }
184 goto exit; 184 goto exit;
185 } 185 }
@@ -380,8 +380,12 @@ int iwl_nvm_init(struct iwl_mvm *mvm)
380 /* we override the constness for initial read */ 380 /* we override the constness for initial read */
381 ret = iwl_nvm_read_section(mvm, section, nvm_buffer, 381 ret = iwl_nvm_read_section(mvm, section, nvm_buffer,
382 size_read); 382 size_read);
383 if (ret < 0) 383 if (ret == -ENODATA) {
384 ret = 0;
384 continue; 385 continue;
386 }
387 if (ret < 0)
388 break;
385 size_read += ret; 389 size_read += ret;
386 temp = kmemdup(nvm_buffer, ret, GFP_KERNEL); 390 temp = kmemdup(nvm_buffer, ret, GFP_KERNEL);
387 if (!temp) { 391 if (!temp) {
@@ -412,6 +416,11 @@ int iwl_nvm_init(struct iwl_mvm *mvm)
412 mvm->nvm_phy_sku_blob.data = temp; 416 mvm->nvm_phy_sku_blob.data = temp;
413 mvm->nvm_phy_sku_blob.size = ret; 417 mvm->nvm_phy_sku_blob.size = ret;
414 break; 418 break;
419 case NVM_SECTION_TYPE_REGULATORY_SDP:
420 case NVM_SECTION_TYPE_REGULATORY:
421 mvm->nvm_reg_blob.data = temp;
422 mvm->nvm_reg_blob.size = ret;
423 break;
415 default: 424 default:
416 if (section == mvm->cfg->nvm_hw_section_num) { 425 if (section == mvm->cfg->nvm_hw_section_num) {
417 mvm->nvm_hw_blob.data = temp; 426 mvm->nvm_hw_blob.data = temp;
@@ -454,7 +463,7 @@ int iwl_nvm_init(struct iwl_mvm *mvm)
454 IWL_DEBUG_EEPROM(mvm->trans->dev, "nvm version = %x\n", 463 IWL_DEBUG_EEPROM(mvm->trans->dev, "nvm version = %x\n",
455 mvm->nvm_data->nvm_version); 464 mvm->nvm_data->nvm_version);
456 465
457 return 0; 466 return ret < 0 ? ret : 0;
458} 467}
459 468
460struct iwl_mcc_update_resp * 469struct iwl_mcc_update_resp *
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 30c5127034a0..5e4f8b767d10 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -301,8 +301,6 @@ static const struct iwl_rx_handlers iwl_mvm_rx_handlers[] = {
301 RX_HANDLER_ASYNC_LOCKED), 301 RX_HANDLER_ASYNC_LOCKED),
302 RX_HANDLER(MFUART_LOAD_NOTIFICATION, iwl_mvm_rx_mfuart_notif, 302 RX_HANDLER(MFUART_LOAD_NOTIFICATION, iwl_mvm_rx_mfuart_notif,
303 RX_HANDLER_SYNC), 303 RX_HANDLER_SYNC),
304 RX_HANDLER(TOF_NOTIFICATION, iwl_mvm_tof_resp_handler,
305 RX_HANDLER_ASYNC_LOCKED),
306 RX_HANDLER_GRP(DEBUG_GROUP, MFU_ASSERT_DUMP_NTF, 304 RX_HANDLER_GRP(DEBUG_GROUP, MFU_ASSERT_DUMP_NTF,
307 iwl_mvm_mfu_assert_dump_notif, RX_HANDLER_SYNC), 305 iwl_mvm_mfu_assert_dump_notif, RX_HANDLER_SYNC),
308 RX_HANDLER_GRP(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF, 306 RX_HANDLER_GRP(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF,
@@ -329,8 +327,6 @@ static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = {
329 HCMD_NAME(SCAN_REQ_UMAC), 327 HCMD_NAME(SCAN_REQ_UMAC),
330 HCMD_NAME(SCAN_ABORT_UMAC), 328 HCMD_NAME(SCAN_ABORT_UMAC),
331 HCMD_NAME(SCAN_COMPLETE_UMAC), 329 HCMD_NAME(SCAN_COMPLETE_UMAC),
332 HCMD_NAME(TOF_CMD),
333 HCMD_NAME(TOF_NOTIFICATION),
334 HCMD_NAME(BA_WINDOW_STATUS_NOTIFICATION_ID), 330 HCMD_NAME(BA_WINDOW_STATUS_NOTIFICATION_ID),
335 HCMD_NAME(ADD_STA_KEY), 331 HCMD_NAME(ADD_STA_KEY),
336 HCMD_NAME(ADD_STA), 332 HCMD_NAME(ADD_STA),
@@ -449,6 +445,7 @@ static const struct iwl_hcmd_names iwl_mvm_data_path_names[] = {
449 HCMD_NAME(TRIGGER_RX_QUEUES_NOTIF_CMD), 445 HCMD_NAME(TRIGGER_RX_QUEUES_NOTIF_CMD),
450 HCMD_NAME(STA_HE_CTXT_CMD), 446 HCMD_NAME(STA_HE_CTXT_CMD),
451 HCMD_NAME(RFH_QUEUE_CONFIG_CMD), 447 HCMD_NAME(RFH_QUEUE_CONFIG_CMD),
448 HCMD_NAME(CHEST_COLLECTOR_FILTER_CONFIG_CMD),
452 HCMD_NAME(STA_PM_NOTIF), 449 HCMD_NAME(STA_PM_NOTIF),
453 HCMD_NAME(MU_GROUP_MGMT_NOTIF), 450 HCMD_NAME(MU_GROUP_MGMT_NOTIF),
454 HCMD_NAME(RX_QUEUES_NOTIFICATION), 451 HCMD_NAME(RX_QUEUES_NOTIFICATION),
@@ -464,6 +461,22 @@ static const struct iwl_hcmd_names iwl_mvm_debug_names[] = {
464/* Please keep this array *SORTED* by hex value. 461/* Please keep this array *SORTED* by hex value.
465 * Access is done through binary search 462 * Access is done through binary search
466 */ 463 */
464static const struct iwl_hcmd_names iwl_mvm_location_names[] = {
465 HCMD_NAME(TOF_RANGE_REQ_CMD),
466 HCMD_NAME(TOF_CONFIG_CMD),
467 HCMD_NAME(TOF_RANGE_ABORT_CMD),
468 HCMD_NAME(TOF_RANGE_REQ_EXT_CMD),
469 HCMD_NAME(TOF_RESPONDER_CONFIG_CMD),
470 HCMD_NAME(TOF_RESPONDER_DYN_CONFIG_CMD),
471 HCMD_NAME(TOF_LC_NOTIF),
472 HCMD_NAME(TOF_RESPONDER_STATS),
473 HCMD_NAME(TOF_MCSI_DEBUG_NOTIF),
474 HCMD_NAME(TOF_RANGE_RESPONSE_NOTIF),
475};
476
477/* Please keep this array *SORTED* by hex value.
478 * Access is done through binary search
479 */
467static const struct iwl_hcmd_names iwl_mvm_prot_offload_names[] = { 480static const struct iwl_hcmd_names iwl_mvm_prot_offload_names[] = {
468 HCMD_NAME(STORED_BEACON_NTF), 481 HCMD_NAME(STORED_BEACON_NTF),
469}; 482};
@@ -483,6 +496,7 @@ static const struct iwl_hcmd_arr iwl_mvm_groups[] = {
483 [MAC_CONF_GROUP] = HCMD_ARR(iwl_mvm_mac_conf_names), 496 [MAC_CONF_GROUP] = HCMD_ARR(iwl_mvm_mac_conf_names),
484 [PHY_OPS_GROUP] = HCMD_ARR(iwl_mvm_phy_names), 497 [PHY_OPS_GROUP] = HCMD_ARR(iwl_mvm_phy_names),
485 [DATA_PATH_GROUP] = HCMD_ARR(iwl_mvm_data_path_names), 498 [DATA_PATH_GROUP] = HCMD_ARR(iwl_mvm_data_path_names),
499 [LOCATION_GROUP] = HCMD_ARR(iwl_mvm_location_names),
486 [PROT_OFFLOAD_GROUP] = HCMD_ARR(iwl_mvm_prot_offload_names), 500 [PROT_OFFLOAD_GROUP] = HCMD_ARR(iwl_mvm_prot_offload_names),
487 [REGULATORY_AND_NVM_GROUP] = 501 [REGULATORY_AND_NVM_GROUP] =
488 HCMD_ARR(iwl_mvm_regulatory_and_nvm_names), 502 HCMD_ARR(iwl_mvm_regulatory_and_nvm_names),
@@ -685,6 +699,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
685 INIT_DELAYED_WORK(&mvm->tdls_cs.dwork, iwl_mvm_tdls_ch_switch_work); 699 INIT_DELAYED_WORK(&mvm->tdls_cs.dwork, iwl_mvm_tdls_ch_switch_work);
686 INIT_DELAYED_WORK(&mvm->scan_timeout_dwork, iwl_mvm_scan_timeout_wk); 700 INIT_DELAYED_WORK(&mvm->scan_timeout_dwork, iwl_mvm_scan_timeout_wk);
687 INIT_WORK(&mvm->add_stream_wk, iwl_mvm_add_new_dqa_stream_wk); 701 INIT_WORK(&mvm->add_stream_wk, iwl_mvm_add_new_dqa_stream_wk);
702 INIT_LIST_HEAD(&mvm->add_stream_txqs);
688 703
689 spin_lock_init(&mvm->d0i3_tx_lock); 704 spin_lock_init(&mvm->d0i3_tx_lock);
690 spin_lock_init(&mvm->refs_lock); 705 spin_lock_init(&mvm->refs_lock);
@@ -736,6 +751,9 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
736 trans_cfg.rx_buf_size = rb_size_default; 751 trans_cfg.rx_buf_size = rb_size_default;
737 } 752 }
738 753
754 BUILD_BUG_ON(sizeof(struct iwl_ldbg_config_cmd) !=
755 LDBG_CFG_COMMAND_SIZE);
756
739 trans->wide_cmd_header = true; 757 trans->wide_cmd_header = true;
740 trans_cfg.bc_table_dword = 758 trans_cfg.bc_table_dword =
741 mvm->trans->cfg->device_family < IWL_DEVICE_FAMILY_22560; 759 mvm->trans->cfg->device_family < IWL_DEVICE_FAMILY_22560;
@@ -842,8 +860,6 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
842 if (iwl_mvm_is_d0i3_supported(mvm)) 860 if (iwl_mvm_is_d0i3_supported(mvm))
843 iwl_trans_unref(mvm->trans); 861 iwl_trans_unref(mvm->trans);
844 862
845 iwl_mvm_tof_init(mvm);
846
847 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx); 863 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
848 864
849 return op_mode; 865 return op_mode;
@@ -909,8 +925,6 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
909 925
910 cancel_delayed_work_sync(&mvm->tcm.work); 926 cancel_delayed_work_sync(&mvm->tcm.work);
911 927
912 iwl_mvm_tof_clean(mvm);
913
914 iwl_fw_runtime_free(&mvm->fwrt); 928 iwl_fw_runtime_free(&mvm->fwrt);
915 mutex_destroy(&mvm->mutex); 929 mutex_destroy(&mvm->mutex);
916 mutex_destroy(&mvm->d0i3_suspend_mutex); 930 mutex_destroy(&mvm->d0i3_suspend_mutex);
@@ -1079,24 +1093,6 @@ static void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
1079 iwl_mvm_rx_common(mvm, rxb, pkt); 1093 iwl_mvm_rx_common(mvm, rxb, pkt);
1080} 1094}
1081 1095
1082void iwl_mvm_stop_mac_queues(struct iwl_mvm *mvm, unsigned long mq)
1083{
1084 int q;
1085
1086 if (WARN_ON_ONCE(!mq))
1087 return;
1088
1089 for_each_set_bit(q, &mq, IEEE80211_MAX_QUEUES) {
1090 if (atomic_inc_return(&mvm->mac80211_queue_stop_count[q]) > 1) {
1091 IWL_DEBUG_TX_QUEUES(mvm,
1092 "mac80211 %d already stopped\n", q);
1093 continue;
1094 }
1095
1096 ieee80211_stop_queue(mvm->hw, q);
1097 }
1098}
1099
1100static void iwl_mvm_async_cb(struct iwl_op_mode *op_mode, 1096static void iwl_mvm_async_cb(struct iwl_op_mode *op_mode,
1101 const struct iwl_device_cmd *cmd) 1097 const struct iwl_device_cmd *cmd)
1102{ 1098{
@@ -1109,38 +1105,66 @@ static void iwl_mvm_async_cb(struct iwl_op_mode *op_mode,
1109 iwl_trans_block_txq_ptrs(mvm->trans, false); 1105 iwl_trans_block_txq_ptrs(mvm->trans, false);
1110} 1106}
1111 1107
1112static void iwl_mvm_stop_sw_queue(struct iwl_op_mode *op_mode, int hw_queue) 1108static void iwl_mvm_queue_state_change(struct iwl_op_mode *op_mode,
1109 int hw_queue, bool start)
1113{ 1110{
1114 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1111 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
1115 unsigned long mq = mvm->hw_queue_to_mac80211[hw_queue]; 1112 struct ieee80211_sta *sta;
1113 struct ieee80211_txq *txq;
1114 struct iwl_mvm_txq *mvmtxq;
1115 int i;
1116 unsigned long tid_bitmap;
1117 struct iwl_mvm_sta *mvmsta;
1118 u8 sta_id;
1116 1119
1117 iwl_mvm_stop_mac_queues(mvm, mq); 1120 sta_id = iwl_mvm_has_new_tx_api(mvm) ?
1118} 1121 mvm->tvqm_info[hw_queue].sta_id :
1122 mvm->queue_info[hw_queue].ra_sta_id;
1119 1123
1120void iwl_mvm_start_mac_queues(struct iwl_mvm *mvm, unsigned long mq) 1124 if (WARN_ON_ONCE(sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id)))
1121{
1122 int q;
1123
1124 if (WARN_ON_ONCE(!mq))
1125 return; 1125 return;
1126 1126
1127 for_each_set_bit(q, &mq, IEEE80211_MAX_QUEUES) { 1127 rcu_read_lock();
1128 if (atomic_dec_return(&mvm->mac80211_queue_stop_count[q]) > 0) { 1128
1129 IWL_DEBUG_TX_QUEUES(mvm, 1129 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
1130 "mac80211 %d still stopped\n", q); 1130 if (IS_ERR_OR_NULL(sta))
1131 continue; 1131 goto out;
1132 } 1132 mvmsta = iwl_mvm_sta_from_mac80211(sta);
1133 1133
1134 ieee80211_wake_queue(mvm->hw, q); 1134 if (iwl_mvm_has_new_tx_api(mvm)) {
1135 int tid = mvm->tvqm_info[hw_queue].txq_tid;
1136
1137 tid_bitmap = BIT(tid);
1138 } else {
1139 tid_bitmap = mvm->queue_info[hw_queue].tid_bitmap;
1135 } 1140 }
1141
1142 for_each_set_bit(i, &tid_bitmap, IWL_MAX_TID_COUNT + 1) {
1143 int tid = i;
1144
1145 if (tid == IWL_MAX_TID_COUNT)
1146 tid = IEEE80211_NUM_TIDS;
1147
1148 txq = sta->txq[tid];
1149 mvmtxq = iwl_mvm_txq_from_mac80211(txq);
1150 mvmtxq->stopped = !start;
1151
1152 if (start && mvmsta->sta_state != IEEE80211_STA_NOTEXIST)
1153 iwl_mvm_mac_itxq_xmit(mvm->hw, txq);
1154 }
1155
1156out:
1157 rcu_read_unlock();
1136} 1158}
1137 1159
1138static void iwl_mvm_wake_sw_queue(struct iwl_op_mode *op_mode, int hw_queue) 1160static void iwl_mvm_stop_sw_queue(struct iwl_op_mode *op_mode, int hw_queue)
1139{ 1161{
1140 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1162 iwl_mvm_queue_state_change(op_mode, hw_queue, false);
1141 unsigned long mq = mvm->hw_queue_to_mac80211[hw_queue]; 1163}
1142 1164
1143 iwl_mvm_start_mac_queues(mvm, mq); 1165static void iwl_mvm_wake_sw_queue(struct iwl_op_mode *op_mode, int hw_queue)
1166{
1167 iwl_mvm_queue_state_change(op_mode, hw_queue, true);
1144} 1168}
1145 1169
1146static void iwl_mvm_set_rfkill_state(struct iwl_mvm *mvm) 1170static void iwl_mvm_set_rfkill_state(struct iwl_mvm *mvm)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
index 7f5434b34d0d..f369173db11c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
@@ -143,14 +143,11 @@ static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm,
143 u8 chains_static, u8 chains_dynamic) 143 u8 chains_static, u8 chains_dynamic)
144{ 144{
145 u8 active_cnt, idle_cnt; 145 u8 active_cnt, idle_cnt;
146 struct iwl_phy_context_cmd_tail *tail =
147 iwl_mvm_chan_info_cmd_tail(mvm, &cmd->ci);
146 148
147 /* Set the channel info data */ 149 /* Set the channel info data */
148 cmd->ci.band = (chandef->chan->band == NL80211_BAND_2GHZ ? 150 iwl_mvm_set_chan_info_chandef(mvm, &cmd->ci, chandef);
149 PHY_BAND_24 : PHY_BAND_5);
150
151 cmd->ci.channel = chandef->chan->hw_value;
152 cmd->ci.width = iwl_mvm_get_channel_width(chandef);
153 cmd->ci.ctrl_pos = iwl_mvm_get_ctrl_pos(chandef);
154 151
155 /* Set rx the chains */ 152 /* Set rx the chains */
156 idle_cnt = chains_static; 153 idle_cnt = chains_static;
@@ -168,17 +165,17 @@ static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm,
168 active_cnt = 2; 165 active_cnt = 2;
169 } 166 }
170 167
171 cmd->rxchain_info = cpu_to_le32(iwl_mvm_get_valid_rx_ant(mvm) << 168 tail->rxchain_info = cpu_to_le32(iwl_mvm_get_valid_rx_ant(mvm) <<
172 PHY_RX_CHAIN_VALID_POS); 169 PHY_RX_CHAIN_VALID_POS);
173 cmd->rxchain_info |= cpu_to_le32(idle_cnt << PHY_RX_CHAIN_CNT_POS); 170 tail->rxchain_info |= cpu_to_le32(idle_cnt << PHY_RX_CHAIN_CNT_POS);
174 cmd->rxchain_info |= cpu_to_le32(active_cnt << 171 tail->rxchain_info |= cpu_to_le32(active_cnt <<
175 PHY_RX_CHAIN_MIMO_CNT_POS); 172 PHY_RX_CHAIN_MIMO_CNT_POS);
176#ifdef CONFIG_IWLWIFI_DEBUGFS 173#ifdef CONFIG_IWLWIFI_DEBUGFS
177 if (unlikely(mvm->dbgfs_rx_phyinfo)) 174 if (unlikely(mvm->dbgfs_rx_phyinfo))
178 cmd->rxchain_info = cpu_to_le32(mvm->dbgfs_rx_phyinfo); 175 tail->rxchain_info = cpu_to_le32(mvm->dbgfs_rx_phyinfo);
179#endif 176#endif
180 177
181 cmd->txchain_info = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); 178 tail->txchain_info = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm));
182} 179}
183 180
184/* 181/*
@@ -195,6 +192,7 @@ static int iwl_mvm_phy_ctxt_apply(struct iwl_mvm *mvm,
195{ 192{
196 struct iwl_phy_context_cmd cmd; 193 struct iwl_phy_context_cmd cmd;
197 int ret; 194 int ret;
195 u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm);
198 196
199 /* Set the command header fields */ 197 /* Set the command header fields */
200 iwl_mvm_phy_ctxt_cmd_hdr(ctxt, &cmd, action, apply_time); 198 iwl_mvm_phy_ctxt_cmd_hdr(ctxt, &cmd, action, apply_time);
@@ -203,9 +201,7 @@ static int iwl_mvm_phy_ctxt_apply(struct iwl_mvm *mvm,
203 iwl_mvm_phy_ctxt_cmd_data(mvm, &cmd, chandef, 201 iwl_mvm_phy_ctxt_cmd_data(mvm, &cmd, chandef,
204 chains_static, chains_dynamic); 202 chains_static, chains_dynamic);
205 203
206 ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD, 0, 204 ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD, 0, len, &cmd);
207 sizeof(struct iwl_phy_context_cmd),
208 &cmd);
209 if (ret) 205 if (ret)
210 IWL_ERR(mvm, "PHY ctxt cmd error. ret=%d\n", ret); 206 IWL_ERR(mvm, "PHY ctxt cmd error. ret=%d\n", ret);
211 return ret; 207 return ret;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
index dabbc04853ac..a28283ff7295 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
@@ -149,14 +149,9 @@ static u16 rs_fw_set_config_flags(struct iwl_mvm *mvm,
149 149
150 if (he_cap && he_cap->has_he && 150 if (he_cap && he_cap->has_he &&
151 (he_cap->he_cap_elem.phy_cap_info[3] & 151 (he_cap->he_cap_elem.phy_cap_info[3] &
152 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK)) { 152 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK))
153 flags |= IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_1_MSK; 153 flags |= IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_1_MSK;
154 154
155 if (he_cap->he_cap_elem.phy_cap_info[3] &
156 IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2)
157 flags |= IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_2_MSK;
158 }
159
160 return flags; 155 return flags;
161} 156}
162 157
@@ -320,12 +315,26 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm,
320 315
321 if (flags & IWL_TLC_NOTIF_FLAG_AMSDU) { 316 if (flags & IWL_TLC_NOTIF_FLAG_AMSDU) {
322 u16 size = le32_to_cpu(notif->amsdu_size); 317 u16 size = le32_to_cpu(notif->amsdu_size);
318 int i;
323 319
324 if (WARN_ON(sta->max_amsdu_len < size)) 320 if (WARN_ON(sta->max_amsdu_len < size))
325 goto out; 321 goto out;
326 322
327 mvmsta->amsdu_enabled = le32_to_cpu(notif->amsdu_enabled); 323 mvmsta->amsdu_enabled = le32_to_cpu(notif->amsdu_enabled);
328 mvmsta->max_amsdu_len = size; 324 mvmsta->max_amsdu_len = size;
325 sta->max_rc_amsdu_len = mvmsta->max_amsdu_len;
326
327 for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
328 if (mvmsta->amsdu_enabled & BIT(i))
329 sta->max_tid_amsdu_len[i] =
330 iwl_mvm_max_amsdu_size(mvm, sta, i);
331 else
332 /*
333 * Not so elegant, but this will effectively
334 * prevent AMSDU on this TID
335 */
336 sta->max_tid_amsdu_len[i] = 1;
337 }
329 338
330 IWL_DEBUG_RATE(mvm, 339 IWL_DEBUG_RATE(mvm,
331 "AMSDU update. AMSDU size: %d, AMSDU selected size: %d, AMSDU TID bitmap 0x%X\n", 340 "AMSDU update. AMSDU size: %d, AMSDU selected size: %d, AMSDU TID bitmap 0x%X\n",
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index 089972280daa..09866f50857a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -1744,6 +1744,7 @@ static void rs_set_amsdu_len(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
1744 enum rs_action scale_action) 1744 enum rs_action scale_action)
1745{ 1745{
1746 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 1746 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
1747 int i;
1747 1748
1748 /* 1749 /*
1749 * In case TLC offload is not active amsdu_enabled is either 0xFFFF 1750 * In case TLC offload is not active amsdu_enabled is either 0xFFFF
@@ -1757,6 +1758,19 @@ static void rs_set_amsdu_len(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
1757 mvmsta->amsdu_enabled = 0xFFFF; 1758 mvmsta->amsdu_enabled = 0xFFFF;
1758 1759
1759 mvmsta->max_amsdu_len = sta->max_amsdu_len; 1760 mvmsta->max_amsdu_len = sta->max_amsdu_len;
1761 sta->max_rc_amsdu_len = mvmsta->max_amsdu_len;
1762
1763 for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
1764 if (mvmsta->amsdu_enabled)
1765 sta->max_tid_amsdu_len[i] =
1766 iwl_mvm_max_amsdu_size(mvm, sta, i);
1767 else
1768 /*
1769 * Not so elegant, but this will effectively
1770 * prevent AMSDU on this TID
1771 */
1772 sta->max_tid_amsdu_len[i] = 1;
1773 }
1760} 1774}
1761 1775
1762/* 1776/*
@@ -3332,12 +3346,12 @@ static void rs_fill_rates_for_column(struct iwl_mvm *mvm,
3332/* Building the rate table is non trivial. When we're in MIMO2/VHT/80Mhz/SGI 3346/* Building the rate table is non trivial. When we're in MIMO2/VHT/80Mhz/SGI
3333 * column the rate table should look like this: 3347 * column the rate table should look like this:
3334 * 3348 *
3335 * rate[0] 0x400D019 VHT | ANT: AB BW: 80Mhz MCS: 9 NSS: 2 SGI 3349 * rate[0] 0x400F019 VHT | ANT: AB BW: 80Mhz MCS: 9 NSS: 2 SGI
3336 * rate[1] 0x400D019 VHT | ANT: AB BW: 80Mhz MCS: 9 NSS: 2 SGI 3350 * rate[1] 0x400F019 VHT | ANT: AB BW: 80Mhz MCS: 9 NSS: 2 SGI
3337 * rate[2] 0x400D018 VHT | ANT: AB BW: 80Mhz MCS: 8 NSS: 2 SGI 3351 * rate[2] 0x400F018 VHT | ANT: AB BW: 80Mhz MCS: 8 NSS: 2 SGI
3338 * rate[3] 0x400D018 VHT | ANT: AB BW: 80Mhz MCS: 8 NSS: 2 SGI 3352 * rate[3] 0x400F018 VHT | ANT: AB BW: 80Mhz MCS: 8 NSS: 2 SGI
3339 * rate[4] 0x400D017 VHT | ANT: AB BW: 80Mhz MCS: 7 NSS: 2 SGI 3353 * rate[4] 0x400F017 VHT | ANT: AB BW: 80Mhz MCS: 7 NSS: 2 SGI
3340 * rate[5] 0x400D017 VHT | ANT: AB BW: 80Mhz MCS: 7 NSS: 2 SGI 3354 * rate[5] 0x400F017 VHT | ANT: AB BW: 80Mhz MCS: 7 NSS: 2 SGI
3341 * rate[6] 0x4005007 VHT | ANT: A BW: 80Mhz MCS: 7 NSS: 1 NGI 3355 * rate[6] 0x4005007 VHT | ANT: A BW: 80Mhz MCS: 7 NSS: 1 NGI
3342 * rate[7] 0x4009006 VHT | ANT: B BW: 80Mhz MCS: 6 NSS: 1 NGI 3356 * rate[7] 0x4009006 VHT | ANT: B BW: 80Mhz MCS: 6 NSS: 1 NGI
3343 * rate[8] 0x4005005 VHT | ANT: A BW: 80Mhz MCS: 5 NSS: 1 NGI 3357 * rate[8] 0x4005005 VHT | ANT: A BW: 80Mhz MCS: 5 NSS: 1 NGI
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
index 6653a238f32e..235ab26ca429 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
@@ -599,8 +599,8 @@ static void iwl_mvm_stat_iterator(void *_data, u8 *mac,
599 * data copied into the "data" struct, but rather the data from 599 * data copied into the "data" struct, but rather the data from
600 * the notification directly. 600 * the notification directly.
601 */ 601 */
602 if (iwl_mvm_is_cdb_supported(mvm)) { 602 if (iwl_mvm_has_new_rx_stats_api(mvm)) {
603 struct mvm_statistics_general_cdb *general = 603 struct mvm_statistics_general *general =
604 data->general; 604 data->general;
605 605
606 mvmvif->beacon_stats.num_beacons = 606 mvmvif->beacon_stats.num_beacons =
@@ -723,7 +723,7 @@ void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
723 else 723 else
724 expected_size = sizeof(struct iwl_notif_statistics_v10); 724 expected_size = sizeof(struct iwl_notif_statistics_v10);
725 } else { 725 } else {
726 expected_size = sizeof(struct iwl_notif_statistics_cdb); 726 expected_size = sizeof(struct iwl_notif_statistics);
727 } 727 }
728 728
729 if (WARN_ONCE(iwl_rx_packet_payload_len(pkt) != expected_size, 729 if (WARN_ONCE(iwl_rx_packet_payload_len(pkt) != expected_size,
@@ -753,7 +753,7 @@ void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
753 753
754 flags = stats->flag; 754 flags = stats->flag;
755 } else { 755 } else {
756 struct iwl_notif_statistics_cdb *stats = (void *)&pkt->data; 756 struct iwl_notif_statistics *stats = (void *)&pkt->data;
757 757
758 data.mac_id = stats->rx.general.mac_id; 758 data.mac_id = stats->rx.general.mac_id;
759 data.beacon_filter_average_energy = 759 data.beacon_filter_average_energy =
@@ -792,7 +792,7 @@ void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
792 bytes = (void *)&v11->load_stats.byte_count; 792 bytes = (void *)&v11->load_stats.byte_count;
793 air_time = (void *)&v11->load_stats.air_time; 793 air_time = (void *)&v11->load_stats.air_time;
794 } else { 794 } else {
795 struct iwl_notif_statistics_cdb *stats = (void *)&pkt->data; 795 struct iwl_notif_statistics *stats = (void *)&pkt->data;
796 796
797 energy = (void *)&stats->load_stats.avg_energy; 797 energy = (void *)&stats->load_stats.avg_energy;
798 bytes = (void *)&stats->load_stats.byte_count; 798 bytes = (void *)&stats->load_stats.byte_count;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 7bd8676508f5..2c56f73d688e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -192,27 +192,48 @@ static void iwl_mvm_create_skb(struct sk_buff *skb, struct ieee80211_hdr *hdr,
192 } 192 }
193} 193}
194 194
195static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm *mvm,
196 struct sk_buff *skb)
197{
198 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
199 struct ieee80211_vendor_radiotap *radiotap;
200 int size = sizeof(*radiotap) + sizeof(__le16);
201
202 if (!mvm->cur_aid)
203 return;
204
205 radiotap = skb_put(skb, size);
206 radiotap->align = 1;
207 /* Intel OUI */
208 radiotap->oui[0] = 0xf6;
209 radiotap->oui[1] = 0x54;
210 radiotap->oui[2] = 0x25;
211 /* radiotap sniffer config sub-namespace */
212 radiotap->subns = 1;
213 radiotap->present = 0x1;
214 radiotap->len = size - sizeof(*radiotap);
215 radiotap->pad = 0;
216
217 /* fill the data now */
218 memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid));
219
220 rx_status->flag |= RX_FLAG_RADIOTAP_VENDOR_DATA;
221}
222
195/* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */ 223/* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */
196static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm, 224static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm,
197 struct napi_struct *napi, 225 struct napi_struct *napi,
198 struct sk_buff *skb, int queue, 226 struct sk_buff *skb, int queue,
199 struct ieee80211_sta *sta) 227 struct ieee80211_sta *sta,
228 bool csi)
200{ 229{
201 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); 230 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
202 231
203 if (!(rx_status->flag & RX_FLAG_NO_PSDU) && 232 if (!(rx_status->flag & RX_FLAG_NO_PSDU) &&
204 iwl_mvm_check_pn(mvm, skb, queue, sta)) { 233 iwl_mvm_check_pn(mvm, skb, queue, sta))
205 kfree_skb(skb); 234 kfree_skb(skb);
206 } else { 235 else
207 unsigned int radiotap_len = 0;
208
209 if (rx_status->flag & RX_FLAG_RADIOTAP_HE)
210 radiotap_len += sizeof(struct ieee80211_radiotap_he);
211 if (rx_status->flag & RX_FLAG_RADIOTAP_HE_MU)
212 radiotap_len += sizeof(struct ieee80211_radiotap_he_mu);
213 __skb_push(skb, radiotap_len);
214 ieee80211_rx_napi(mvm->hw, sta, skb, napi); 236 ieee80211_rx_napi(mvm->hw, sta, skb, napi);
215 }
216} 237}
217 238
218static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm, 239static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
@@ -473,7 +494,7 @@ static void iwl_mvm_release_frames(struct iwl_mvm *mvm,
473 while ((skb = __skb_dequeue(skb_list))) { 494 while ((skb = __skb_dequeue(skb_list))) {
474 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, 495 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb,
475 reorder_buf->queue, 496 reorder_buf->queue,
476 sta); 497 sta, false);
477 reorder_buf->num_stored--; 498 reorder_buf->num_stored--;
478 } 499 }
479 } 500 }
@@ -666,6 +687,8 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
666 * This also covers the case of receiving a Block Ack Request 687 * This also covers the case of receiving a Block Ack Request
667 * outside a BA session; we'll pass it to mac80211 and that 688 * outside a BA session; we'll pass it to mac80211 and that
668 * then sends a delBA action frame. 689 * then sends a delBA action frame.
690 * This also covers pure monitor mode, in which case we won't
691 * have any BA sessions.
669 */ 692 */
670 if (baid == IWL_RX_REORDER_DATA_INVALID_BAID) 693 if (baid == IWL_RX_REORDER_DATA_INVALID_BAID)
671 return false; 694 return false;
@@ -1158,14 +1181,12 @@ static void iwl_mvm_rx_he(struct iwl_mvm *mvm, struct sk_buff *skb,
1158 /* temporarily hide the radiotap data */ 1181 /* temporarily hide the radiotap data */
1159 __skb_pull(skb, radiotap_len); 1182 __skb_pull(skb, radiotap_len);
1160 1183
1161 if (phy_data->info_type == IWL_RX_PHY_INFO_TYPE_HE_SU) { 1184 /* report the AMPDU-EOF bit on single frames */
1162 /* report the AMPDU-EOF bit on single frames */ 1185 if (!queue && !(phy_info & IWL_RX_MPDU_PHY_AMPDU)) {
1163 if (!queue && !(phy_info & IWL_RX_MPDU_PHY_AMPDU)) { 1186 rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
1164 rx_status->flag |= RX_FLAG_AMPDU_DETAILS; 1187 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1165 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; 1188 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF))
1166 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF)) 1189 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1167 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1168 }
1169 } 1190 }
1170 1191
1171 if (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) 1192 if (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD)
@@ -1178,9 +1199,7 @@ static void iwl_mvm_rx_he(struct iwl_mvm *mvm, struct sk_buff *skb,
1178 bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE; 1199 bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE;
1179 1200
1180 /* toggle is switched whenever new aggregation starts */ 1201 /* toggle is switched whenever new aggregation starts */
1181 if (toggle_bit != mvm->ampdu_toggle && 1202 if (toggle_bit != mvm->ampdu_toggle) {
1182 (he_type == RATE_MCS_HE_TYPE_MU ||
1183 he_type == RATE_MCS_HE_TYPE_SU)) {
1184 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; 1203 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1185 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF)) 1204 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF))
1186 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT; 1205 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
@@ -1314,6 +1333,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1314 .d4 = desc->phy_data4, 1333 .d4 = desc->phy_data4,
1315 .info_type = IWL_RX_PHY_INFO_TYPE_NONE, 1334 .info_type = IWL_RX_PHY_INFO_TYPE_NONE,
1316 }; 1335 };
1336 bool csi = false;
1317 1337
1318 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))) 1338 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
1319 return; 1339 return;
@@ -1412,7 +1432,8 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1412 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; 1432 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
1413 } 1433 }
1414 /* set the preamble flag if appropriate */ 1434 /* set the preamble flag if appropriate */
1415 if (phy_info & IWL_RX_MPDU_PHY_SHORT_PREAMBLE) 1435 if (rate_n_flags & RATE_MCS_CCK_MSK &&
1436 phy_info & IWL_RX_MPDU_PHY_SHORT_PREAMBLE)
1416 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; 1437 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE;
1417 1438
1418 if (likely(!(phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD))) { 1439 if (likely(!(phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD))) {
@@ -1441,14 +1462,23 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1441 bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE; 1462 bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE;
1442 1463
1443 rx_status->flag |= RX_FLAG_AMPDU_DETAILS; 1464 rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
1444 rx_status->ampdu_reference = mvm->ampdu_ref; 1465 /*
1445 /* toggle is switched whenever new aggregation starts */ 1466 * Toggle is switched whenever new aggregation starts. Make
1467 * sure ampdu_reference is never 0 so we can later use it to
1468 * see if the frame was really part of an A-MPDU or not.
1469 */
1446 if (toggle_bit != mvm->ampdu_toggle) { 1470 if (toggle_bit != mvm->ampdu_toggle) {
1447 mvm->ampdu_ref++; 1471 mvm->ampdu_ref++;
1472 if (mvm->ampdu_ref == 0)
1473 mvm->ampdu_ref++;
1448 mvm->ampdu_toggle = toggle_bit; 1474 mvm->ampdu_toggle = toggle_bit;
1449 } 1475 }
1476 rx_status->ampdu_reference = mvm->ampdu_ref;
1450 } 1477 }
1451 1478
1479 if (unlikely(mvm->monitor_on))
1480 iwl_mvm_add_rtap_sniffer_config(mvm, skb);
1481
1452 rcu_read_lock(); 1482 rcu_read_lock();
1453 1483
1454 if (desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_SRC_STA_FOUND)) { 1484 if (desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_SRC_STA_FOUND)) {
@@ -1602,7 +1632,8 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1602 1632
1603 iwl_mvm_create_skb(skb, hdr, len, crypt_len, rxb); 1633 iwl_mvm_create_skb(skb, hdr, len, crypt_len, rxb);
1604 if (!iwl_mvm_reorder(mvm, napi, queue, sta, skb, desc)) 1634 if (!iwl_mvm_reorder(mvm, napi, queue, sta, skb, desc))
1605 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta); 1635 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue,
1636 sta, csi);
1606out: 1637out:
1607 rcu_read_unlock(); 1638 rcu_read_unlock();
1608} 1639}
@@ -1705,15 +1736,24 @@ void iwl_mvm_rx_monitor_ndp(struct iwl_mvm *mvm, struct napi_struct *napi,
1705 } else if (rate_n_flags & RATE_MCS_VHT_MSK) { 1736 } else if (rate_n_flags & RATE_MCS_VHT_MSK) {
1706 u8 stbc = (rate_n_flags & RATE_MCS_STBC_MSK) >> 1737 u8 stbc = (rate_n_flags & RATE_MCS_STBC_MSK) >>
1707 RATE_MCS_STBC_POS; 1738 RATE_MCS_STBC_POS;
1708 rx_status->nss =
1709 ((rate_n_flags & RATE_VHT_MCS_NSS_MSK) >>
1710 RATE_VHT_MCS_NSS_POS) + 1;
1711 rx_status->rate_idx = rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK; 1739 rx_status->rate_idx = rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK;
1712 rx_status->encoding = RX_ENC_VHT; 1740 rx_status->encoding = RX_ENC_VHT;
1713 rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT; 1741 rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT;
1714 if (rate_n_flags & RATE_MCS_BF_MSK) 1742 if (rate_n_flags & RATE_MCS_BF_MSK)
1715 rx_status->enc_flags |= RX_ENC_FLAG_BF; 1743 rx_status->enc_flags |= RX_ENC_FLAG_BF;
1716 } else if (!(rate_n_flags & RATE_MCS_HE_MSK)) { 1744 /*
1745 * take the nss from the rx_vec since the rate_n_flags has
1746 * only 2 bits for the nss which gives a max of 4 ss but
1747 * there may be up to 8 spatial streams
1748 */
1749 rx_status->nss =
1750 le32_get_bits(desc->rx_vec[0],
1751 RX_NO_DATA_RX_VEC0_VHT_NSTS_MSK) + 1;
1752 } else if (rate_n_flags & RATE_MCS_HE_MSK) {
1753 rx_status->nss =
1754 le32_get_bits(desc->rx_vec[0],
1755 RX_NO_DATA_RX_VEC0_HE_NSTS_MSK) + 1;
1756 } else {
1717 int rate = iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags, 1757 int rate = iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags,
1718 rx_status->band); 1758 rx_status->band);
1719 1759
@@ -1726,7 +1766,7 @@ void iwl_mvm_rx_monitor_ndp(struct iwl_mvm *mvm, struct napi_struct *napi,
1726 rx_status->rate_idx = rate; 1766 rx_status->rate_idx = rate;
1727 } 1767 }
1728 1768
1729 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta); 1769 iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta, false);
1730out: 1770out:
1731 rcu_read_unlock(); 1771 rcu_read_unlock();
1732} 1772}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sf.c b/drivers/net/wireless/intel/iwlwifi/mvm/sf.c
index d1d76bb9a750..9da0dae78510 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sf.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sf.c
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10 * Copyright (C) 2018 Intel Corporation
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
@@ -28,6 +29,7 @@
28 * 29 *
29 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved. 30 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 31 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
32 * Copyright (C) 2018 Intel Corporation
31 * All rights reserved. 33 * All rights reserved.
32 * 34 *
33 * Redistribution and use in source and binary forms, with or without 35 * Redistribution and use in source and binary forms, with or without
@@ -64,7 +66,7 @@ struct iwl_mvm_active_iface_iterator_data {
64 struct ieee80211_vif *ignore_vif; 66 struct ieee80211_vif *ignore_vif;
65 u8 sta_vif_ap_sta_id; 67 u8 sta_vif_ap_sta_id;
66 enum iwl_sf_state sta_vif_state; 68 enum iwl_sf_state sta_vif_state;
67 int num_active_macs; 69 u32 num_active_macs;
68}; 70};
69 71
70/* 72/*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index e28009832da0..c5a01470a3bc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -356,24 +356,16 @@ static int iwl_mvm_invalidate_sta_queue(struct iwl_mvm *mvm, int queue,
356 return ret; 356 return ret;
357} 357}
358 358
359static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, 359static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
360 int mac80211_queue, u8 tid, u8 flags) 360 int queue, u8 tid, u8 flags)
361{ 361{
362 struct iwl_scd_txq_cfg_cmd cmd = { 362 struct iwl_scd_txq_cfg_cmd cmd = {
363 .scd_queue = queue, 363 .scd_queue = queue,
364 .action = SCD_CFG_DISABLE_QUEUE, 364 .action = SCD_CFG_DISABLE_QUEUE,
365 }; 365 };
366 bool remove_mac_queue = mac80211_queue != IEEE80211_INVAL_HW_QUEUE;
367 int ret; 366 int ret;
368 367
369 if (WARN_ON(remove_mac_queue && mac80211_queue >= IEEE80211_MAX_QUEUES))
370 return -EINVAL;
371
372 if (iwl_mvm_has_new_tx_api(mvm)) { 368 if (iwl_mvm_has_new_tx_api(mvm)) {
373 if (remove_mac_queue)
374 mvm->hw_queue_to_mac80211[queue] &=
375 ~BIT(mac80211_queue);
376
377 iwl_trans_txq_free(mvm->trans, queue); 369 iwl_trans_txq_free(mvm->trans, queue);
378 370
379 return 0; 371 return 0;
@@ -384,36 +376,15 @@ static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue,
384 376
385 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid); 377 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid);
386 378
387 /*
388 * If there is another TID with the same AC - don't remove the MAC queue
389 * from the mapping
390 */
391 if (tid < IWL_MAX_TID_COUNT) {
392 unsigned long tid_bitmap =
393 mvm->queue_info[queue].tid_bitmap;
394 int ac = tid_to_mac80211_ac[tid];
395 int i;
396
397 for_each_set_bit(i, &tid_bitmap, IWL_MAX_TID_COUNT) {
398 if (tid_to_mac80211_ac[i] == ac)
399 remove_mac_queue = false;
400 }
401 }
402
403 if (remove_mac_queue)
404 mvm->hw_queue_to_mac80211[queue] &=
405 ~BIT(mac80211_queue);
406
407 cmd.action = mvm->queue_info[queue].tid_bitmap ? 379 cmd.action = mvm->queue_info[queue].tid_bitmap ?
408 SCD_CFG_ENABLE_QUEUE : SCD_CFG_DISABLE_QUEUE; 380 SCD_CFG_ENABLE_QUEUE : SCD_CFG_DISABLE_QUEUE;
409 if (cmd.action == SCD_CFG_DISABLE_QUEUE) 381 if (cmd.action == SCD_CFG_DISABLE_QUEUE)
410 mvm->queue_info[queue].status = IWL_MVM_QUEUE_FREE; 382 mvm->queue_info[queue].status = IWL_MVM_QUEUE_FREE;
411 383
412 IWL_DEBUG_TX_QUEUES(mvm, 384 IWL_DEBUG_TX_QUEUES(mvm,
413 "Disabling TXQ #%d tids=0x%x (mac80211 map:0x%x)\n", 385 "Disabling TXQ #%d tids=0x%x\n",
414 queue, 386 queue,
415 mvm->queue_info[queue].tid_bitmap, 387 mvm->queue_info[queue].tid_bitmap);
416 mvm->hw_queue_to_mac80211[queue]);
417 388
418 /* If the queue is still enabled - nothing left to do in this func */ 389 /* If the queue is still enabled - nothing left to do in this func */
419 if (cmd.action == SCD_CFG_ENABLE_QUEUE) 390 if (cmd.action == SCD_CFG_ENABLE_QUEUE)
@@ -423,15 +394,19 @@ static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue,
423 cmd.tid = mvm->queue_info[queue].txq_tid; 394 cmd.tid = mvm->queue_info[queue].txq_tid;
424 395
425 /* Make sure queue info is correct even though we overwrite it */ 396 /* Make sure queue info is correct even though we overwrite it */
426 WARN(mvm->queue_info[queue].tid_bitmap || 397 WARN(mvm->queue_info[queue].tid_bitmap,
427 mvm->hw_queue_to_mac80211[queue], 398 "TXQ #%d info out-of-sync - tids=0x%x\n",
428 "TXQ #%d info out-of-sync - mac map=0x%x, tids=0x%x\n", 399 queue, mvm->queue_info[queue].tid_bitmap);
429 queue, mvm->hw_queue_to_mac80211[queue],
430 mvm->queue_info[queue].tid_bitmap);
431 400
432 /* If we are here - the queue is freed and we can zero out these vals */ 401 /* If we are here - the queue is freed and we can zero out these vals */
433 mvm->queue_info[queue].tid_bitmap = 0; 402 mvm->queue_info[queue].tid_bitmap = 0;
434 mvm->hw_queue_to_mac80211[queue] = 0; 403
404 if (sta) {
405 struct iwl_mvm_txq *mvmtxq =
406 iwl_mvm_txq_from_tid(sta, tid);
407
408 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE;
409 }
435 410
436 /* Regardless if this is a reserved TXQ for a STA - mark it as false */ 411 /* Regardless if this is a reserved TXQ for a STA - mark it as false */
437 mvm->queue_info[queue].reserved = false; 412 mvm->queue_info[queue].reserved = false;
@@ -517,9 +492,14 @@ static int iwl_mvm_remove_sta_queue_marking(struct iwl_mvm *mvm, int queue)
517 spin_lock_bh(&mvmsta->lock); 492 spin_lock_bh(&mvmsta->lock);
518 /* Unmap MAC queues and TIDs from this queue */ 493 /* Unmap MAC queues and TIDs from this queue */
519 for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) { 494 for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) {
495 struct iwl_mvm_txq *mvmtxq =
496 iwl_mvm_txq_from_tid(sta, tid);
497
520 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) 498 if (mvmsta->tid_data[tid].state == IWL_AGG_ON)
521 disable_agg_tids |= BIT(tid); 499 disable_agg_tids |= BIT(tid);
522 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE; 500 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE;
501
502 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE;
523 } 503 }
524 504
525 mvmsta->tfd_queue_msk &= ~BIT(queue); /* Don't use this queue anymore */ 505 mvmsta->tfd_queue_msk &= ~BIT(queue); /* Don't use this queue anymore */
@@ -541,10 +521,11 @@ static int iwl_mvm_remove_sta_queue_marking(struct iwl_mvm *mvm, int queue)
541} 521}
542 522
543static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue, 523static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
524 struct ieee80211_sta *old_sta,
544 u8 new_sta_id) 525 u8 new_sta_id)
545{ 526{
546 struct iwl_mvm_sta *mvmsta; 527 struct iwl_mvm_sta *mvmsta;
547 u8 txq_curr_ac, sta_id, tid; 528 u8 sta_id, tid;
548 unsigned long disable_agg_tids = 0; 529 unsigned long disable_agg_tids = 0;
549 bool same_sta; 530 bool same_sta;
550 int ret; 531 int ret;
@@ -554,7 +535,6 @@ static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
554 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) 535 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm)))
555 return -EINVAL; 536 return -EINVAL;
556 537
557 txq_curr_ac = mvm->queue_info[queue].mac80211_ac;
558 sta_id = mvm->queue_info[queue].ra_sta_id; 538 sta_id = mvm->queue_info[queue].ra_sta_id;
559 tid = mvm->queue_info[queue].txq_tid; 539 tid = mvm->queue_info[queue].txq_tid;
560 540
@@ -570,9 +550,7 @@ static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
570 iwl_mvm_invalidate_sta_queue(mvm, queue, 550 iwl_mvm_invalidate_sta_queue(mvm, queue,
571 disable_agg_tids, false); 551 disable_agg_tids, false);
572 552
573 ret = iwl_mvm_disable_txq(mvm, queue, 553 ret = iwl_mvm_disable_txq(mvm, old_sta, queue, tid, 0);
574 mvmsta->vif->hw_queue[txq_curr_ac],
575 tid, 0);
576 if (ret) { 554 if (ret) {
577 IWL_ERR(mvm, 555 IWL_ERR(mvm,
578 "Failed to free inactive queue %d (ret=%d)\n", 556 "Failed to free inactive queue %d (ret=%d)\n",
@@ -662,16 +640,15 @@ static int iwl_mvm_get_shared_queue(struct iwl_mvm *mvm,
662 * in such a case, otherwise - if no redirection required - it does nothing, 640 * in such a case, otherwise - if no redirection required - it does nothing,
663 * unless the %force param is true. 641 * unless the %force param is true.
664 */ 642 */
665static int iwl_mvm_scd_queue_redirect(struct iwl_mvm *mvm, int queue, int tid, 643static int iwl_mvm_redirect_queue(struct iwl_mvm *mvm, int queue, int tid,
666 int ac, int ssn, unsigned int wdg_timeout, 644 int ac, int ssn, unsigned int wdg_timeout,
667 bool force) 645 bool force, struct iwl_mvm_txq *txq)
668{ 646{
669 struct iwl_scd_txq_cfg_cmd cmd = { 647 struct iwl_scd_txq_cfg_cmd cmd = {
670 .scd_queue = queue, 648 .scd_queue = queue,
671 .action = SCD_CFG_DISABLE_QUEUE, 649 .action = SCD_CFG_DISABLE_QUEUE,
672 }; 650 };
673 bool shared_queue; 651 bool shared_queue;
674 unsigned long mq;
675 int ret; 652 int ret;
676 653
677 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) 654 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm)))
@@ -695,14 +672,14 @@ static int iwl_mvm_scd_queue_redirect(struct iwl_mvm *mvm, int queue, int tid,
695 cmd.sta_id = mvm->queue_info[queue].ra_sta_id; 672 cmd.sta_id = mvm->queue_info[queue].ra_sta_id;
696 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[mvm->queue_info[queue].mac80211_ac]; 673 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[mvm->queue_info[queue].mac80211_ac];
697 cmd.tid = mvm->queue_info[queue].txq_tid; 674 cmd.tid = mvm->queue_info[queue].txq_tid;
698 mq = mvm->hw_queue_to_mac80211[queue];
699 shared_queue = hweight16(mvm->queue_info[queue].tid_bitmap) > 1; 675 shared_queue = hweight16(mvm->queue_info[queue].tid_bitmap) > 1;
700 676
701 IWL_DEBUG_TX_QUEUES(mvm, "Redirecting TXQ #%d to FIFO #%d\n", 677 IWL_DEBUG_TX_QUEUES(mvm, "Redirecting TXQ #%d to FIFO #%d\n",
702 queue, iwl_mvm_ac_to_tx_fifo[ac]); 678 queue, iwl_mvm_ac_to_tx_fifo[ac]);
703 679
704 /* Stop MAC queues and wait for this queue to empty */ 680 /* Stop the queue and wait for it to empty */
705 iwl_mvm_stop_mac_queues(mvm, mq); 681 txq->stopped = true;
682
706 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(queue)); 683 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(queue));
707 if (ret) { 684 if (ret) {
708 IWL_ERR(mvm, "Error draining queue %d before reconfig\n", 685 IWL_ERR(mvm, "Error draining queue %d before reconfig\n",
@@ -743,8 +720,8 @@ static int iwl_mvm_scd_queue_redirect(struct iwl_mvm *mvm, int queue, int tid,
743 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true); 720 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true);
744 721
745out: 722out:
746 /* Continue using the MAC queues */ 723 /* Continue using the queue */
747 iwl_mvm_start_mac_queues(mvm, mq); 724 txq->stopped = false;
748 725
749 return ret; 726 return ret;
750} 727}
@@ -769,7 +746,7 @@ static int iwl_mvm_find_free_queue(struct iwl_mvm *mvm, u8 sta_id,
769 return -ENOSPC; 746 return -ENOSPC;
770} 747}
771 748
772static int iwl_mvm_tvqm_enable_txq(struct iwl_mvm *mvm, int mac80211_queue, 749static int iwl_mvm_tvqm_enable_txq(struct iwl_mvm *mvm,
773 u8 sta_id, u8 tid, unsigned int timeout) 750 u8 sta_id, u8 tid, unsigned int timeout)
774{ 751{
775 int queue, size = IWL_DEFAULT_QUEUE_SIZE; 752 int queue, size = IWL_DEFAULT_QUEUE_SIZE;
@@ -792,10 +769,7 @@ static int iwl_mvm_tvqm_enable_txq(struct iwl_mvm *mvm, int mac80211_queue,
792 IWL_DEBUG_TX_QUEUES(mvm, "Enabling TXQ #%d for sta %d tid %d\n", 769 IWL_DEBUG_TX_QUEUES(mvm, "Enabling TXQ #%d for sta %d tid %d\n",
793 queue, sta_id, tid); 770 queue, sta_id, tid);
794 771
795 mvm->hw_queue_to_mac80211[queue] |= BIT(mac80211_queue); 772 IWL_DEBUG_TX_QUEUES(mvm, "Enabling TXQ #%d\n", queue);
796 IWL_DEBUG_TX_QUEUES(mvm,
797 "Enabling TXQ #%d (mac80211 map:0x%x)\n",
798 queue, mvm->hw_queue_to_mac80211[queue]);
799 773
800 return queue; 774 return queue;
801} 775}
@@ -805,9 +779,10 @@ static int iwl_mvm_sta_alloc_queue_tvqm(struct iwl_mvm *mvm,
805 int tid) 779 int tid)
806{ 780{
807 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 781 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
782 struct iwl_mvm_txq *mvmtxq =
783 iwl_mvm_txq_from_tid(sta, tid);
808 unsigned int wdg_timeout = 784 unsigned int wdg_timeout =
809 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif, false, false); 785 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif, false, false);
810 u8 mac_queue = mvmsta->vif->hw_queue[ac];
811 int queue = -1; 786 int queue = -1;
812 787
813 lockdep_assert_held(&mvm->mutex); 788 lockdep_assert_held(&mvm->mutex);
@@ -815,11 +790,16 @@ static int iwl_mvm_sta_alloc_queue_tvqm(struct iwl_mvm *mvm,
815 IWL_DEBUG_TX_QUEUES(mvm, 790 IWL_DEBUG_TX_QUEUES(mvm,
816 "Allocating queue for sta %d on tid %d\n", 791 "Allocating queue for sta %d on tid %d\n",
817 mvmsta->sta_id, tid); 792 mvmsta->sta_id, tid);
818 queue = iwl_mvm_tvqm_enable_txq(mvm, mac_queue, mvmsta->sta_id, tid, 793 queue = iwl_mvm_tvqm_enable_txq(mvm, mvmsta->sta_id, tid, wdg_timeout);
819 wdg_timeout);
820 if (queue < 0) 794 if (queue < 0)
821 return queue; 795 return queue;
822 796
797 if (sta) {
798 mvmtxq->txq_id = queue;
799 mvm->tvqm_info[queue].txq_tid = tid;
800 mvm->tvqm_info[queue].sta_id = mvmsta->sta_id;
801 }
802
823 IWL_DEBUG_TX_QUEUES(mvm, "Allocated queue is %d\n", queue); 803 IWL_DEBUG_TX_QUEUES(mvm, "Allocated queue is %d\n", queue);
824 804
825 spin_lock_bh(&mvmsta->lock); 805 spin_lock_bh(&mvmsta->lock);
@@ -829,8 +809,9 @@ static int iwl_mvm_sta_alloc_queue_tvqm(struct iwl_mvm *mvm,
829 return 0; 809 return 0;
830} 810}
831 811
832static bool iwl_mvm_update_txq_mapping(struct iwl_mvm *mvm, int queue, 812static bool iwl_mvm_update_txq_mapping(struct iwl_mvm *mvm,
833 int mac80211_queue, u8 sta_id, u8 tid) 813 struct ieee80211_sta *sta,
814 int queue, u8 sta_id, u8 tid)
834{ 815{
835 bool enable_queue = true; 816 bool enable_queue = true;
836 817
@@ -845,14 +826,6 @@ static bool iwl_mvm_update_txq_mapping(struct iwl_mvm *mvm, int queue,
845 if (mvm->queue_info[queue].tid_bitmap) 826 if (mvm->queue_info[queue].tid_bitmap)
846 enable_queue = false; 827 enable_queue = false;
847 828
848 if (mac80211_queue != IEEE80211_INVAL_HW_QUEUE) {
849 WARN(mac80211_queue >=
850 BITS_PER_BYTE * sizeof(mvm->hw_queue_to_mac80211[0]),
851 "cannot track mac80211 queue %d (queue %d, sta %d, tid %d)\n",
852 mac80211_queue, queue, sta_id, tid);
853 mvm->hw_queue_to_mac80211[queue] |= BIT(mac80211_queue);
854 }
855
856 mvm->queue_info[queue].tid_bitmap |= BIT(tid); 829 mvm->queue_info[queue].tid_bitmap |= BIT(tid);
857 mvm->queue_info[queue].ra_sta_id = sta_id; 830 mvm->queue_info[queue].ra_sta_id = sta_id;
858 831
@@ -866,16 +839,22 @@ static bool iwl_mvm_update_txq_mapping(struct iwl_mvm *mvm, int queue,
866 mvm->queue_info[queue].txq_tid = tid; 839 mvm->queue_info[queue].txq_tid = tid;
867 } 840 }
868 841
842 if (sta) {
843 struct iwl_mvm_txq *mvmtxq =
844 iwl_mvm_txq_from_tid(sta, tid);
845
846 mvmtxq->txq_id = queue;
847 }
848
869 IWL_DEBUG_TX_QUEUES(mvm, 849 IWL_DEBUG_TX_QUEUES(mvm,
870 "Enabling TXQ #%d tids=0x%x (mac80211 map:0x%x)\n", 850 "Enabling TXQ #%d tids=0x%x\n",
871 queue, mvm->queue_info[queue].tid_bitmap, 851 queue, mvm->queue_info[queue].tid_bitmap);
872 mvm->hw_queue_to_mac80211[queue]);
873 852
874 return enable_queue; 853 return enable_queue;
875} 854}
876 855
877static bool iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, 856static bool iwl_mvm_enable_txq(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
878 int mac80211_queue, u16 ssn, 857 int queue, u16 ssn,
879 const struct iwl_trans_txq_scd_cfg *cfg, 858 const struct iwl_trans_txq_scd_cfg *cfg,
880 unsigned int wdg_timeout) 859 unsigned int wdg_timeout)
881{ 860{
@@ -895,8 +874,7 @@ static bool iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue,
895 return false; 874 return false;
896 875
897 /* Send the enabling command if we need to */ 876 /* Send the enabling command if we need to */
898 if (!iwl_mvm_update_txq_mapping(mvm, queue, mac80211_queue, 877 if (!iwl_mvm_update_txq_mapping(mvm, sta, queue, cfg->sta_id, cfg->tid))
899 cfg->sta_id, cfg->tid))
900 return false; 878 return false;
901 879
902 inc_ssn = iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, 880 inc_ssn = iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn,
@@ -989,9 +967,10 @@ static void iwl_mvm_unshare_queue(struct iwl_mvm *mvm, int queue)
989 967
990 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number); 968 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number);
991 969
992 ret = iwl_mvm_scd_queue_redirect(mvm, queue, tid, 970 ret = iwl_mvm_redirect_queue(mvm, queue, tid,
993 tid_to_mac80211_ac[tid], ssn, 971 tid_to_mac80211_ac[tid], ssn,
994 wdg_timeout, true); 972 wdg_timeout, true,
973 iwl_mvm_txq_from_tid(sta, tid));
995 if (ret) { 974 if (ret) {
996 IWL_ERR(mvm, "Failed to redirect TXQ %d\n", queue); 975 IWL_ERR(mvm, "Failed to redirect TXQ %d\n", queue);
997 return; 976 return;
@@ -1068,11 +1047,9 @@ static bool iwl_mvm_remove_inactive_tids(struct iwl_mvm *mvm,
1068 * Remove the ones that did. 1047 * Remove the ones that did.
1069 */ 1048 */
1070 for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) { 1049 for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) {
1071 int mac_queue = mvmsta->vif->hw_queue[tid_to_mac80211_ac[tid]];
1072 u16 tid_bitmap; 1050 u16 tid_bitmap;
1073 1051
1074 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE; 1052 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE;
1075 mvm->hw_queue_to_mac80211[queue] &= ~BIT(mac_queue);
1076 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid); 1053 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid);
1077 1054
1078 tid_bitmap = mvm->queue_info[queue].tid_bitmap; 1055 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
@@ -1105,10 +1082,6 @@ static bool iwl_mvm_remove_inactive_tids(struct iwl_mvm *mvm,
1105 * sure all TIDs have existing corresponding mac queues enabled 1082 * sure all TIDs have existing corresponding mac queues enabled
1106 */ 1083 */
1107 tid_bitmap = mvm->queue_info[queue].tid_bitmap; 1084 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
1108 for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) {
1109 mvm->hw_queue_to_mac80211[queue] |=
1110 BIT(mvmsta->vif->hw_queue[tid_to_mac80211_ac[tid]]);
1111 }
1112 1085
1113 /* If the queue is marked as shared - "unshare" it */ 1086 /* If the queue is marked as shared - "unshare" it */
1114 if (hweight16(mvm->queue_info[queue].tid_bitmap) == 1 && 1087 if (hweight16(mvm->queue_info[queue].tid_bitmap) == 1 &&
@@ -1136,6 +1109,7 @@ static int iwl_mvm_inactivity_check(struct iwl_mvm *mvm, u8 alloc_for_sta)
1136 unsigned long unshare_queues = 0; 1109 unsigned long unshare_queues = 0;
1137 unsigned long changetid_queues = 0; 1110 unsigned long changetid_queues = 0;
1138 int i, ret, free_queue = -ENOSPC; 1111 int i, ret, free_queue = -ENOSPC;
1112 struct ieee80211_sta *queue_owner = NULL;
1139 1113
1140 lockdep_assert_held(&mvm->mutex); 1114 lockdep_assert_held(&mvm->mutex);
1141 1115
@@ -1201,13 +1175,14 @@ static int iwl_mvm_inactivity_check(struct iwl_mvm *mvm, u8 alloc_for_sta)
1201 inactive_tid_bitmap, 1175 inactive_tid_bitmap,
1202 &unshare_queues, 1176 &unshare_queues,
1203 &changetid_queues); 1177 &changetid_queues);
1204 if (ret >= 0 && free_queue < 0) 1178 if (ret >= 0 && free_queue < 0) {
1179 queue_owner = sta;
1205 free_queue = ret; 1180 free_queue = ret;
1181 }
1206 /* only unlock sta lock - we still need the queue info lock */ 1182 /* only unlock sta lock - we still need the queue info lock */
1207 spin_unlock_bh(&mvmsta->lock); 1183 spin_unlock_bh(&mvmsta->lock);
1208 } 1184 }
1209 1185
1210 rcu_read_unlock();
1211 1186
1212 /* Reconfigure queues requiring reconfiguation */ 1187 /* Reconfigure queues requiring reconfiguation */
1213 for_each_set_bit(i, &unshare_queues, IWL_MAX_HW_QUEUES) 1188 for_each_set_bit(i, &unshare_queues, IWL_MAX_HW_QUEUES)
@@ -1216,18 +1191,21 @@ static int iwl_mvm_inactivity_check(struct iwl_mvm *mvm, u8 alloc_for_sta)
1216 iwl_mvm_change_queue_tid(mvm, i); 1191 iwl_mvm_change_queue_tid(mvm, i);
1217 1192
1218 if (free_queue >= 0 && alloc_for_sta != IWL_MVM_INVALID_STA) { 1193 if (free_queue >= 0 && alloc_for_sta != IWL_MVM_INVALID_STA) {
1219 ret = iwl_mvm_free_inactive_queue(mvm, free_queue, 1194 ret = iwl_mvm_free_inactive_queue(mvm, free_queue, queue_owner,
1220 alloc_for_sta); 1195 alloc_for_sta);
1221 if (ret) 1196 if (ret) {
1197 rcu_read_unlock();
1222 return ret; 1198 return ret;
1199 }
1223 } 1200 }
1224 1201
1202 rcu_read_unlock();
1203
1225 return free_queue; 1204 return free_queue;
1226} 1205}
1227 1206
1228static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm, 1207static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1229 struct ieee80211_sta *sta, u8 ac, int tid, 1208 struct ieee80211_sta *sta, u8 ac, int tid)
1230 struct ieee80211_hdr *hdr)
1231{ 1209{
1232 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 1210 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
1233 struct iwl_trans_txq_scd_cfg cfg = { 1211 struct iwl_trans_txq_scd_cfg cfg = {
@@ -1238,7 +1216,6 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1238 }; 1216 };
1239 unsigned int wdg_timeout = 1217 unsigned int wdg_timeout =
1240 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif, false, false); 1218 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif, false, false);
1241 u8 mac_queue = mvmsta->vif->hw_queue[ac];
1242 int queue = -1; 1219 int queue = -1;
1243 unsigned long disable_agg_tids = 0; 1220 unsigned long disable_agg_tids = 0;
1244 enum iwl_mvm_agg_state queue_state; 1221 enum iwl_mvm_agg_state queue_state;
@@ -1257,12 +1234,7 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1257 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number); 1234 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number);
1258 spin_unlock_bh(&mvmsta->lock); 1235 spin_unlock_bh(&mvmsta->lock);
1259 1236
1260 /* 1237 if (tid == IWL_MAX_TID_COUNT) {
1261 * Non-QoS, QoS NDP and MGMT frames should go to a MGMT queue, if one
1262 * exists
1263 */
1264 if (!ieee80211_is_data_qos(hdr->frame_control) ||
1265 ieee80211_is_qos_nullfunc(hdr->frame_control)) {
1266 queue = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id, 1238 queue = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id,
1267 IWL_MVM_DQA_MIN_MGMT_QUEUE, 1239 IWL_MVM_DQA_MIN_MGMT_QUEUE,
1268 IWL_MVM_DQA_MAX_MGMT_QUEUE); 1240 IWL_MVM_DQA_MAX_MGMT_QUEUE);
@@ -1341,8 +1313,7 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1341 } 1313 }
1342 } 1314 }
1343 1315
1344 inc_ssn = iwl_mvm_enable_txq(mvm, queue, mac_queue, 1316 inc_ssn = iwl_mvm_enable_txq(mvm, sta, queue, ssn, &cfg, wdg_timeout);
1345 ssn, &cfg, wdg_timeout);
1346 1317
1347 /* 1318 /*
1348 * Mark queue as shared in transport if shared 1319 * Mark queue as shared in transport if shared
@@ -1384,8 +1355,9 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1384 } 1355 }
1385 } else { 1356 } else {
1386 /* Redirect queue, if needed */ 1357 /* Redirect queue, if needed */
1387 ret = iwl_mvm_scd_queue_redirect(mvm, queue, tid, ac, ssn, 1358 ret = iwl_mvm_redirect_queue(mvm, queue, tid, ac, ssn,
1388 wdg_timeout, false); 1359 wdg_timeout, false,
1360 iwl_mvm_txq_from_tid(sta, tid));
1389 if (ret) 1361 if (ret)
1390 goto out_err; 1362 goto out_err;
1391 } 1363 }
@@ -1393,7 +1365,7 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
1393 return 0; 1365 return 0;
1394 1366
1395out_err: 1367out_err:
1396 iwl_mvm_disable_txq(mvm, queue, mac_queue, tid, 0); 1368 iwl_mvm_disable_txq(mvm, sta, queue, tid, 0);
1397 1369
1398 return ret; 1370 return ret;
1399} 1371}
@@ -1406,87 +1378,32 @@ static inline u8 iwl_mvm_tid_to_ac_queue(int tid)
1406 return tid_to_mac80211_ac[tid]; 1378 return tid_to_mac80211_ac[tid];
1407} 1379}
1408 1380
1409static void iwl_mvm_tx_deferred_stream(struct iwl_mvm *mvm,
1410 struct ieee80211_sta *sta, int tid)
1411{
1412 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
1413 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
1414 struct sk_buff *skb;
1415 struct ieee80211_hdr *hdr;
1416 struct sk_buff_head deferred_tx;
1417 u8 mac_queue;
1418 bool no_queue = false; /* Marks if there is a problem with the queue */
1419 u8 ac;
1420
1421 lockdep_assert_held(&mvm->mutex);
1422
1423 skb = skb_peek(&tid_data->deferred_tx_frames);
1424 if (!skb)
1425 return;
1426 hdr = (void *)skb->data;
1427
1428 ac = iwl_mvm_tid_to_ac_queue(tid);
1429 mac_queue = IEEE80211_SKB_CB(skb)->hw_queue;
1430
1431 if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE &&
1432 iwl_mvm_sta_alloc_queue(mvm, sta, ac, tid, hdr)) {
1433 IWL_ERR(mvm,
1434 "Can't alloc TXQ for sta %d tid %d - dropping frame\n",
1435 mvmsta->sta_id, tid);
1436
1437 /*
1438 * Mark queue as problematic so later the deferred traffic is
1439 * freed, as we can do nothing with it
1440 */
1441 no_queue = true;
1442 }
1443
1444 __skb_queue_head_init(&deferred_tx);
1445
1446 /* Disable bottom-halves when entering TX path */
1447 local_bh_disable();
1448 spin_lock(&mvmsta->lock);
1449 skb_queue_splice_init(&tid_data->deferred_tx_frames, &deferred_tx);
1450 mvmsta->deferred_traffic_tid_map &= ~BIT(tid);
1451 spin_unlock(&mvmsta->lock);
1452
1453 while ((skb = __skb_dequeue(&deferred_tx)))
1454 if (no_queue || iwl_mvm_tx_skb(mvm, skb, sta))
1455 ieee80211_free_txskb(mvm->hw, skb);
1456 local_bh_enable();
1457
1458 /* Wake queue */
1459 iwl_mvm_start_mac_queues(mvm, BIT(mac_queue));
1460}
1461
1462void iwl_mvm_add_new_dqa_stream_wk(struct work_struct *wk) 1381void iwl_mvm_add_new_dqa_stream_wk(struct work_struct *wk)
1463{ 1382{
1464 struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, 1383 struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm,
1465 add_stream_wk); 1384 add_stream_wk);
1466 struct ieee80211_sta *sta;
1467 struct iwl_mvm_sta *mvmsta;
1468 unsigned long deferred_tid_traffic;
1469 int sta_id, tid;
1470 1385
1471 mutex_lock(&mvm->mutex); 1386 mutex_lock(&mvm->mutex);
1472 1387
1473 iwl_mvm_inactivity_check(mvm, IWL_MVM_INVALID_STA); 1388 iwl_mvm_inactivity_check(mvm, IWL_MVM_INVALID_STA);
1474 1389
1475 /* Go over all stations with deferred traffic */ 1390 while (!list_empty(&mvm->add_stream_txqs)) {
1476 for_each_set_bit(sta_id, mvm->sta_deferred_frames, 1391 struct iwl_mvm_txq *mvmtxq;
1477 IWL_MVM_STATION_COUNT) { 1392 struct ieee80211_txq *txq;
1478 clear_bit(sta_id, mvm->sta_deferred_frames); 1393 u8 tid;
1479 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
1480 lockdep_is_held(&mvm->mutex));
1481 if (IS_ERR_OR_NULL(sta))
1482 continue;
1483 1394
1484 mvmsta = iwl_mvm_sta_from_mac80211(sta); 1395 mvmtxq = list_first_entry(&mvm->add_stream_txqs,
1485 deferred_tid_traffic = mvmsta->deferred_traffic_tid_map; 1396 struct iwl_mvm_txq, list);
1397
1398 txq = container_of((void *)mvmtxq, struct ieee80211_txq,
1399 drv_priv);
1400 tid = txq->tid;
1401 if (tid == IEEE80211_NUM_TIDS)
1402 tid = IWL_MAX_TID_COUNT;
1486 1403
1487 for_each_set_bit(tid, &deferred_tid_traffic, 1404 iwl_mvm_sta_alloc_queue(mvm, txq->sta, txq->ac, tid);
1488 IWL_MAX_TID_COUNT + 1) 1405 list_del_init(&mvmtxq->list);
1489 iwl_mvm_tx_deferred_stream(mvm, sta, tid); 1406 iwl_mvm_mac_itxq_xmit(mvm->hw, txq);
1490 } 1407 }
1491 1408
1492 mutex_unlock(&mvm->mutex); 1409 mutex_unlock(&mvm->mutex);
@@ -1542,10 +1459,11 @@ static int iwl_mvm_reserve_sta_stream(struct iwl_mvm *mvm,
1542 * Note that re-enabling aggregations isn't done in this function. 1459 * Note that re-enabling aggregations isn't done in this function.
1543 */ 1460 */
1544static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm, 1461static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm,
1545 struct iwl_mvm_sta *mvm_sta) 1462 struct ieee80211_sta *sta)
1546{ 1463{
1547 unsigned int wdg_timeout = 1464 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);
1548 iwl_mvm_get_wd_timeout(mvm, mvm_sta->vif, false, false); 1465 unsigned int wdg =
1466 iwl_mvm_get_wd_timeout(mvm, mvm_sta->vif, false, false);
1549 int i; 1467 int i;
1550 struct iwl_trans_txq_scd_cfg cfg = { 1468 struct iwl_trans_txq_scd_cfg cfg = {
1551 .sta_id = mvm_sta->sta_id, 1469 .sta_id = mvm_sta->sta_id,
@@ -1561,23 +1479,18 @@ static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm,
1561 struct iwl_mvm_tid_data *tid_data = &mvm_sta->tid_data[i]; 1479 struct iwl_mvm_tid_data *tid_data = &mvm_sta->tid_data[i];
1562 int txq_id = tid_data->txq_id; 1480 int txq_id = tid_data->txq_id;
1563 int ac; 1481 int ac;
1564 u8 mac_queue;
1565 1482
1566 if (txq_id == IWL_MVM_INVALID_QUEUE) 1483 if (txq_id == IWL_MVM_INVALID_QUEUE)
1567 continue; 1484 continue;
1568 1485
1569 skb_queue_head_init(&tid_data->deferred_tx_frames);
1570
1571 ac = tid_to_mac80211_ac[i]; 1486 ac = tid_to_mac80211_ac[i];
1572 mac_queue = mvm_sta->vif->hw_queue[ac];
1573 1487
1574 if (iwl_mvm_has_new_tx_api(mvm)) { 1488 if (iwl_mvm_has_new_tx_api(mvm)) {
1575 IWL_DEBUG_TX_QUEUES(mvm, 1489 IWL_DEBUG_TX_QUEUES(mvm,
1576 "Re-mapping sta %d tid %d\n", 1490 "Re-mapping sta %d tid %d\n",
1577 mvm_sta->sta_id, i); 1491 mvm_sta->sta_id, i);
1578 txq_id = iwl_mvm_tvqm_enable_txq(mvm, mac_queue, 1492 txq_id = iwl_mvm_tvqm_enable_txq(mvm, mvm_sta->sta_id,
1579 mvm_sta->sta_id, 1493 i, wdg);
1580 i, wdg_timeout);
1581 tid_data->txq_id = txq_id; 1494 tid_data->txq_id = txq_id;
1582 1495
1583 /* 1496 /*
@@ -1600,8 +1513,7 @@ static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm,
1600 "Re-mapping sta %d tid %d to queue %d\n", 1513 "Re-mapping sta %d tid %d to queue %d\n",
1601 mvm_sta->sta_id, i, txq_id); 1514 mvm_sta->sta_id, i, txq_id);
1602 1515
1603 iwl_mvm_enable_txq(mvm, txq_id, mac_queue, seq, &cfg, 1516 iwl_mvm_enable_txq(mvm, sta, txq_id, seq, &cfg, wdg);
1604 wdg_timeout);
1605 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_READY; 1517 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_READY;
1606 } 1518 }
1607 } 1519 }
@@ -1691,7 +1603,7 @@ int iwl_mvm_add_sta(struct iwl_mvm *mvm,
1691 if (ret) 1603 if (ret)
1692 goto err; 1604 goto err;
1693 1605
1694 iwl_mvm_realloc_queues_after_restart(mvm, mvm_sta); 1606 iwl_mvm_realloc_queues_after_restart(mvm, sta);
1695 sta_update = true; 1607 sta_update = true;
1696 sta_flags = iwl_mvm_has_new_tx_api(mvm) ? 0 : STA_MODIFY_QUEUES; 1608 sta_flags = iwl_mvm_has_new_tx_api(mvm) ? 0 : STA_MODIFY_QUEUES;
1697 goto update_fw; 1609 goto update_fw;
@@ -1724,9 +1636,17 @@ int iwl_mvm_add_sta(struct iwl_mvm *mvm,
1724 * frames until the queue is allocated 1636 * frames until the queue is allocated
1725 */ 1637 */
1726 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE; 1638 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE;
1727 skb_queue_head_init(&mvm_sta->tid_data[i].deferred_tx_frames);
1728 } 1639 }
1729 mvm_sta->deferred_traffic_tid_map = 0; 1640
1641 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
1642 struct iwl_mvm_txq *mvmtxq =
1643 iwl_mvm_txq_from_mac80211(sta->txq[i]);
1644
1645 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE;
1646 INIT_LIST_HEAD(&mvmtxq->list);
1647 atomic_set(&mvmtxq->tx_request, 0);
1648 }
1649
1730 mvm_sta->agg_tids = 0; 1650 mvm_sta->agg_tids = 0;
1731 1651
1732 if (iwl_mvm_has_new_rx_api(mvm) && 1652 if (iwl_mvm_has_new_rx_api(mvm) &&
@@ -1861,9 +1781,9 @@ static int iwl_mvm_rm_sta_common(struct iwl_mvm *mvm, u8 sta_id)
1861 1781
1862static void iwl_mvm_disable_sta_queues(struct iwl_mvm *mvm, 1782static void iwl_mvm_disable_sta_queues(struct iwl_mvm *mvm,
1863 struct ieee80211_vif *vif, 1783 struct ieee80211_vif *vif,
1864 struct iwl_mvm_sta *mvm_sta) 1784 struct ieee80211_sta *sta)
1865{ 1785{
1866 int ac; 1786 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);
1867 int i; 1787 int i;
1868 1788
1869 lockdep_assert_held(&mvm->mutex); 1789 lockdep_assert_held(&mvm->mutex);
@@ -1872,11 +1792,17 @@ static void iwl_mvm_disable_sta_queues(struct iwl_mvm *mvm,
1872 if (mvm_sta->tid_data[i].txq_id == IWL_MVM_INVALID_QUEUE) 1792 if (mvm_sta->tid_data[i].txq_id == IWL_MVM_INVALID_QUEUE)
1873 continue; 1793 continue;
1874 1794
1875 ac = iwl_mvm_tid_to_ac_queue(i); 1795 iwl_mvm_disable_txq(mvm, sta, mvm_sta->tid_data[i].txq_id, i,
1876 iwl_mvm_disable_txq(mvm, mvm_sta->tid_data[i].txq_id, 1796 0);
1877 vif->hw_queue[ac], i, 0);
1878 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE; 1797 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE;
1879 } 1798 }
1799
1800 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
1801 struct iwl_mvm_txq *mvmtxq =
1802 iwl_mvm_txq_from_mac80211(sta->txq[i]);
1803
1804 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE;
1805 }
1880} 1806}
1881 1807
1882int iwl_mvm_wait_sta_queues_empty(struct iwl_mvm *mvm, 1808int iwl_mvm_wait_sta_queues_empty(struct iwl_mvm *mvm,
@@ -1938,7 +1864,7 @@ int iwl_mvm_rm_sta(struct iwl_mvm *mvm,
1938 1864
1939 ret = iwl_mvm_drain_sta(mvm, mvm_sta, false); 1865 ret = iwl_mvm_drain_sta(mvm, mvm_sta, false);
1940 1866
1941 iwl_mvm_disable_sta_queues(mvm, vif, mvm_sta); 1867 iwl_mvm_disable_sta_queues(mvm, vif, sta);
1942 1868
1943 /* If there is a TXQ still marked as reserved - free it */ 1869 /* If there is a TXQ still marked as reserved - free it */
1944 if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) { 1870 if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) {
@@ -2044,7 +1970,7 @@ static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 *queue,
2044 1970
2045 if (iwl_mvm_has_new_tx_api(mvm)) { 1971 if (iwl_mvm_has_new_tx_api(mvm)) {
2046 int tvqm_queue = 1972 int tvqm_queue =
2047 iwl_mvm_tvqm_enable_txq(mvm, *queue, sta_id, 1973 iwl_mvm_tvqm_enable_txq(mvm, sta_id,
2048 IWL_MAX_TID_COUNT, 1974 IWL_MAX_TID_COUNT,
2049 wdg_timeout); 1975 wdg_timeout);
2050 *queue = tvqm_queue; 1976 *queue = tvqm_queue;
@@ -2057,7 +1983,7 @@ static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 *queue,
2057 .frame_limit = IWL_FRAME_LIMIT, 1983 .frame_limit = IWL_FRAME_LIMIT,
2058 }; 1984 };
2059 1985
2060 iwl_mvm_enable_txq(mvm, *queue, *queue, 0, &cfg, wdg_timeout); 1986 iwl_mvm_enable_txq(mvm, NULL, *queue, 0, &cfg, wdg_timeout);
2061 } 1987 }
2062} 1988}
2063 1989
@@ -2135,8 +2061,7 @@ int iwl_mvm_rm_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2135 2061
2136 lockdep_assert_held(&mvm->mutex); 2062 lockdep_assert_held(&mvm->mutex);
2137 2063
2138 iwl_mvm_disable_txq(mvm, mvm->snif_queue, mvm->snif_queue, 2064 iwl_mvm_disable_txq(mvm, NULL, mvm->snif_queue, IWL_MAX_TID_COUNT, 0);
2139 IWL_MAX_TID_COUNT, 0);
2140 ret = iwl_mvm_rm_sta_common(mvm, mvm->snif_sta.sta_id); 2065 ret = iwl_mvm_rm_sta_common(mvm, mvm->snif_sta.sta_id);
2141 if (ret) 2066 if (ret)
2142 IWL_WARN(mvm, "Failed sending remove station\n"); 2067 IWL_WARN(mvm, "Failed sending remove station\n");
@@ -2195,8 +2120,7 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2195 2120
2196 bsta->tfd_queue_msk |= BIT(queue); 2121 bsta->tfd_queue_msk |= BIT(queue);
2197 2122
2198 iwl_mvm_enable_txq(mvm, queue, vif->hw_queue[0], 0, 2123 iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg, wdg_timeout);
2199 &cfg, wdg_timeout);
2200 } 2124 }
2201 2125
2202 if (vif->type == NL80211_IFTYPE_ADHOC) 2126 if (vif->type == NL80211_IFTYPE_ADHOC)
@@ -2215,8 +2139,7 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2215 * to firmware so enable queue here - after the station was added 2139 * to firmware so enable queue here - after the station was added
2216 */ 2140 */
2217 if (iwl_mvm_has_new_tx_api(mvm)) { 2141 if (iwl_mvm_has_new_tx_api(mvm)) {
2218 queue = iwl_mvm_tvqm_enable_txq(mvm, vif->hw_queue[0], 2142 queue = iwl_mvm_tvqm_enable_txq(mvm, bsta->sta_id,
2219 bsta->sta_id,
2220 IWL_MAX_TID_COUNT, 2143 IWL_MAX_TID_COUNT,
2221 wdg_timeout); 2144 wdg_timeout);
2222 2145
@@ -2254,7 +2177,7 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm *mvm,
2254 return; 2177 return;
2255 } 2178 }
2256 2179
2257 iwl_mvm_disable_txq(mvm, queue, vif->hw_queue[0], IWL_MAX_TID_COUNT, 0); 2180 iwl_mvm_disable_txq(mvm, NULL, queue, IWL_MAX_TID_COUNT, 0);
2258 if (iwl_mvm_has_new_tx_api(mvm)) 2181 if (iwl_mvm_has_new_tx_api(mvm))
2259 return; 2182 return;
2260 2183
@@ -2377,10 +2300,8 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2377 * Note that this is done here as we want to avoid making DQA 2300 * Note that this is done here as we want to avoid making DQA
2378 * changes in mac80211 layer. 2301 * changes in mac80211 layer.
2379 */ 2302 */
2380 if (vif->type == NL80211_IFTYPE_ADHOC) { 2303 if (vif->type == NL80211_IFTYPE_ADHOC)
2381 vif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE; 2304 mvmvif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE;
2382 mvmvif->cab_queue = vif->cab_queue;
2383 }
2384 2305
2385 /* 2306 /*
2386 * While in previous FWs we had to exclude cab queue from TFD queue 2307 * While in previous FWs we had to exclude cab queue from TFD queue
@@ -2388,9 +2309,9 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2388 */ 2309 */
2389 if (!iwl_mvm_has_new_tx_api(mvm) && 2310 if (!iwl_mvm_has_new_tx_api(mvm) &&
2390 fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { 2311 fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) {
2391 iwl_mvm_enable_txq(mvm, vif->cab_queue, vif->cab_queue, 0, 2312 iwl_mvm_enable_txq(mvm, NULL, mvmvif->cab_queue, 0, &cfg,
2392 &cfg, timeout); 2313 timeout);
2393 msta->tfd_queue_msk |= BIT(vif->cab_queue); 2314 msta->tfd_queue_msk |= BIT(mvmvif->cab_queue);
2394 } 2315 }
2395 ret = iwl_mvm_add_int_sta_common(mvm, msta, maddr, 2316 ret = iwl_mvm_add_int_sta_common(mvm, msta, maddr,
2396 mvmvif->id, mvmvif->color); 2317 mvmvif->id, mvmvif->color);
@@ -2407,15 +2328,14 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2407 * tfd_queue_mask. 2328 * tfd_queue_mask.
2408 */ 2329 */
2409 if (iwl_mvm_has_new_tx_api(mvm)) { 2330 if (iwl_mvm_has_new_tx_api(mvm)) {
2410 int queue = iwl_mvm_tvqm_enable_txq(mvm, vif->cab_queue, 2331 int queue = iwl_mvm_tvqm_enable_txq(mvm, msta->sta_id,
2411 msta->sta_id,
2412 0, 2332 0,
2413 timeout); 2333 timeout);
2414 mvmvif->cab_queue = queue; 2334 mvmvif->cab_queue = queue;
2415 } else if (!fw_has_api(&mvm->fw->ucode_capa, 2335 } else if (!fw_has_api(&mvm->fw->ucode_capa,
2416 IWL_UCODE_TLV_API_STA_TYPE)) 2336 IWL_UCODE_TLV_API_STA_TYPE))
2417 iwl_mvm_enable_txq(mvm, vif->cab_queue, vif->cab_queue, 0, 2337 iwl_mvm_enable_txq(mvm, NULL, mvmvif->cab_queue, 0, &cfg,
2418 &cfg, timeout); 2338 timeout);
2419 2339
2420 if (mvmvif->ap_wep_key) { 2340 if (mvmvif->ap_wep_key) {
2421 u8 key_offset = iwl_mvm_set_fw_key_idx(mvm); 2341 u8 key_offset = iwl_mvm_set_fw_key_idx(mvm);
@@ -2446,8 +2366,7 @@ int iwl_mvm_rm_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2446 2366
2447 iwl_mvm_flush_sta(mvm, &mvmvif->mcast_sta, true, 0); 2367 iwl_mvm_flush_sta(mvm, &mvmvif->mcast_sta, true, 0);
2448 2368
2449 iwl_mvm_disable_txq(mvm, mvmvif->cab_queue, vif->cab_queue, 2369 iwl_mvm_disable_txq(mvm, NULL, mvmvif->cab_queue, 0, 0);
2450 0, 0);
2451 2370
2452 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id); 2371 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id);
2453 if (ret) 2372 if (ret)
@@ -2781,7 +2700,7 @@ int iwl_mvm_sta_tx_agg_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2781 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 2700 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
2782 struct iwl_mvm_tid_data *tid_data; 2701 struct iwl_mvm_tid_data *tid_data;
2783 u16 normalized_ssn; 2702 u16 normalized_ssn;
2784 int txq_id; 2703 u16 txq_id;
2785 int ret; 2704 int ret;
2786 2705
2787 if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT)) 2706 if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT))
@@ -2823,17 +2742,24 @@ int iwl_mvm_sta_tx_agg_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2823 */ 2742 */
2824 txq_id = mvmsta->tid_data[tid].txq_id; 2743 txq_id = mvmsta->tid_data[tid].txq_id;
2825 if (txq_id == IWL_MVM_INVALID_QUEUE) { 2744 if (txq_id == IWL_MVM_INVALID_QUEUE) {
2826 txq_id = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id, 2745 ret = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id,
2827 IWL_MVM_DQA_MIN_DATA_QUEUE, 2746 IWL_MVM_DQA_MIN_DATA_QUEUE,
2828 IWL_MVM_DQA_MAX_DATA_QUEUE); 2747 IWL_MVM_DQA_MAX_DATA_QUEUE);
2829 if (txq_id < 0) { 2748 if (ret < 0) {
2830 ret = txq_id;
2831 IWL_ERR(mvm, "Failed to allocate agg queue\n"); 2749 IWL_ERR(mvm, "Failed to allocate agg queue\n");
2832 goto out; 2750 goto out;
2833 } 2751 }
2834 2752
2753 txq_id = ret;
2754
2835 /* TXQ hasn't yet been enabled, so mark it only as reserved */ 2755 /* TXQ hasn't yet been enabled, so mark it only as reserved */
2836 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED; 2756 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED;
2757 } else if (WARN_ON(txq_id >= IWL_MAX_HW_QUEUES)) {
2758 ret = -ENXIO;
2759 IWL_ERR(mvm, "tid_id %d out of range (0, %d)!\n",
2760 tid, IWL_MAX_HW_QUEUES - 1);
2761 goto out;
2762
2837 } else if (unlikely(mvm->queue_info[txq_id].status == 2763 } else if (unlikely(mvm->queue_info[txq_id].status ==
2838 IWL_MVM_QUEUE_SHARED)) { 2764 IWL_MVM_QUEUE_SHARED)) {
2839 ret = -ENXIO; 2765 ret = -ENXIO;
@@ -2976,8 +2902,7 @@ int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2976 } 2902 }
2977 2903
2978 if (alloc_queue) 2904 if (alloc_queue)
2979 iwl_mvm_enable_txq(mvm, queue, 2905 iwl_mvm_enable_txq(mvm, sta, queue, ssn,
2980 vif->hw_queue[tid_to_mac80211_ac[tid]], ssn,
2981 &cfg, wdg_timeout); 2906 &cfg, wdg_timeout);
2982 2907
2983 /* Send ADD_STA command to enable aggs only if the queue isn't shared */ 2908 /* Send ADD_STA command to enable aggs only if the queue isn't shared */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
index d52cd888f77d..0614296244b3 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
@@ -297,7 +297,6 @@ enum iwl_mvm_agg_state {
297 297
298/** 298/**
299 * struct iwl_mvm_tid_data - holds the states for each RA / TID 299 * struct iwl_mvm_tid_data - holds the states for each RA / TID
300 * @deferred_tx_frames: deferred TX frames for this RA/TID
301 * @seq_number: the next WiFi sequence number to use 300 * @seq_number: the next WiFi sequence number to use
302 * @next_reclaimed: the WiFi sequence number of the next packet to be acked. 301 * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
303 * This is basically (last acked packet++). 302 * This is basically (last acked packet++).
@@ -318,7 +317,6 @@ enum iwl_mvm_agg_state {
318 * tpt_meas_start 317 * tpt_meas_start
319 */ 318 */
320struct iwl_mvm_tid_data { 319struct iwl_mvm_tid_data {
321 struct sk_buff_head deferred_tx_frames;
322 u16 seq_number; 320 u16 seq_number;
323 u16 next_reclaimed; 321 u16 next_reclaimed;
324 /* The rest is Tx AGG related */ 322 /* The rest is Tx AGG related */
@@ -427,8 +425,6 @@ struct iwl_mvm_sta {
427 struct iwl_mvm_key_pn __rcu *ptk_pn[4]; 425 struct iwl_mvm_key_pn __rcu *ptk_pn[4];
428 struct iwl_mvm_rxq_dup_data *dup_data; 426 struct iwl_mvm_rxq_dup_data *dup_data;
429 427
430 u16 deferred_traffic_tid_map;
431
432 u8 reserved_queue; 428 u8 reserved_queue;
433 429
434 /* Temporary, until the new TLC will control the Tx protection */ 430 /* Temporary, until the new TLC will control the Tx protection */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
index e02f4eb20359..859aa5a4e6b5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
@@ -399,6 +399,9 @@ iwl_mvm_tdls_config_channel_switch(struct iwl_mvm *mvm,
399 struct ieee80211_tx_info *info; 399 struct ieee80211_tx_info *info;
400 struct ieee80211_hdr *hdr; 400 struct ieee80211_hdr *hdr;
401 struct iwl_tdls_channel_switch_cmd cmd = {0}; 401 struct iwl_tdls_channel_switch_cmd cmd = {0};
402 struct iwl_tdls_channel_switch_cmd_tail *tail =
403 iwl_mvm_chan_info_cmd_tail(mvm, &cmd.ci);
404 u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm);
402 int ret; 405 int ret;
403 406
404 lockdep_assert_held(&mvm->mutex); 407 lockdep_assert_held(&mvm->mutex);
@@ -414,9 +417,9 @@ iwl_mvm_tdls_config_channel_switch(struct iwl_mvm *mvm,
414 } 417 }
415 418
416 cmd.switch_type = type; 419 cmd.switch_type = type;
417 cmd.timing.frame_timestamp = cpu_to_le32(timestamp); 420 tail->timing.frame_timestamp = cpu_to_le32(timestamp);
418 cmd.timing.switch_time = cpu_to_le32(switch_time); 421 tail->timing.switch_time = cpu_to_le32(switch_time);
419 cmd.timing.switch_timeout = cpu_to_le32(switch_timeout); 422 tail->timing.switch_timeout = cpu_to_le32(switch_timeout);
420 423
421 rcu_read_lock(); 424 rcu_read_lock();
422 sta = ieee80211_find_sta(vif, peer); 425 sta = ieee80211_find_sta(vif, peer);
@@ -448,21 +451,16 @@ iwl_mvm_tdls_config_channel_switch(struct iwl_mvm *mvm,
448 } 451 }
449 } 452 }
450 453
451 if (chandef) { 454 if (chandef)
452 cmd.ci.band = (chandef->chan->band == NL80211_BAND_2GHZ ? 455 iwl_mvm_set_chan_info_chandef(mvm, &cmd.ci, chandef);
453 PHY_BAND_24 : PHY_BAND_5);
454 cmd.ci.channel = chandef->chan->hw_value;
455 cmd.ci.width = iwl_mvm_get_channel_width(chandef);
456 cmd.ci.ctrl_pos = iwl_mvm_get_ctrl_pos(chandef);
457 }
458 456
459 /* keep quota calculation simple for now - 50% of DTIM for TDLS */ 457 /* keep quota calculation simple for now - 50% of DTIM for TDLS */
460 cmd.timing.max_offchan_duration = 458 tail->timing.max_offchan_duration =
461 cpu_to_le32(TU_TO_US(vif->bss_conf.dtim_period * 459 cpu_to_le32(TU_TO_US(vif->bss_conf.dtim_period *
462 vif->bss_conf.beacon_int) / 2); 460 vif->bss_conf.beacon_int) / 2);
463 461
464 /* Switch time is the first element in the switch-timing IE. */ 462 /* Switch time is the first element in the switch-timing IE. */
465 cmd.frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2); 463 tail->frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2);
466 464
467 info = IEEE80211_SKB_CB(skb); 465 info = IEEE80211_SKB_CB(skb);
468 hdr = (void *)skb->data; 466 hdr = (void *)skb->data;
@@ -472,20 +470,19 @@ iwl_mvm_tdls_config_channel_switch(struct iwl_mvm *mvm,
472 ret = -EINVAL; 470 ret = -EINVAL;
473 goto out; 471 goto out;
474 } 472 }
475 iwl_mvm_set_tx_cmd_ccmp(info, &cmd.frame.tx_cmd); 473 iwl_mvm_set_tx_cmd_ccmp(info, &tail->frame.tx_cmd);
476 } 474 }
477 475
478 iwl_mvm_set_tx_cmd(mvm, skb, &cmd.frame.tx_cmd, info, 476 iwl_mvm_set_tx_cmd(mvm, skb, &tail->frame.tx_cmd, info,
479 mvmsta->sta_id); 477 mvmsta->sta_id);
480 478
481 iwl_mvm_set_tx_cmd_rate(mvm, &cmd.frame.tx_cmd, info, sta, 479 iwl_mvm_set_tx_cmd_rate(mvm, &tail->frame.tx_cmd, info, sta,
482 hdr->frame_control); 480 hdr->frame_control);
483 rcu_read_unlock(); 481 rcu_read_unlock();
484 482
485 memcpy(cmd.frame.data, skb->data, skb->len); 483 memcpy(tail->frame.data, skb->data, skb->len);
486 484
487 ret = iwl_mvm_send_cmd_pdu(mvm, TDLS_CHANNEL_SWITCH_CMD, 0, 485 ret = iwl_mvm_send_cmd_pdu(mvm, TDLS_CHANNEL_SWITCH_CMD, 0, len, &cmd);
488 sizeof(cmd), &cmd);
489 if (ret) { 486 if (ret) {
490 IWL_ERR(mvm, "Failed to send TDLS_CHANNEL_SWITCH cmd: %d\n", 487 IWL_ERR(mvm, "Failed to send TDLS_CHANNEL_SWITCH cmd: %d\n",
491 ret); 488 ret);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
index e1a6f4e22253..5b34100e9099 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
@@ -334,6 +334,7 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
334 switch (te_data->vif->type) { 334 switch (te_data->vif->type) {
335 case NL80211_IFTYPE_P2P_DEVICE: 335 case NL80211_IFTYPE_P2P_DEVICE:
336 ieee80211_remain_on_channel_expired(mvm->hw); 336 ieee80211_remain_on_channel_expired(mvm->hw);
337 set_bit(IWL_MVM_STATUS_NEED_FLUSH_P2P, &mvm->status);
337 iwl_mvm_roc_finished(mvm); 338 iwl_mvm_roc_finished(mvm);
338 break; 339 break;
339 case NL80211_IFTYPE_STATION: 340 case NL80211_IFTYPE_STATION:
@@ -686,6 +687,8 @@ static void iwl_mvm_remove_aux_roc_te(struct iwl_mvm *mvm,
686 struct iwl_mvm_time_event_data *te_data) 687 struct iwl_mvm_time_event_data *te_data)
687{ 688{
688 struct iwl_hs20_roc_req aux_cmd = {}; 689 struct iwl_hs20_roc_req aux_cmd = {};
690 u16 len = sizeof(aux_cmd) - iwl_mvm_chan_info_padding(mvm);
691
689 u32 uid; 692 u32 uid;
690 int ret; 693 int ret;
691 694
@@ -699,7 +702,7 @@ static void iwl_mvm_remove_aux_roc_te(struct iwl_mvm *mvm,
699 IWL_DEBUG_TE(mvm, "Removing BSS AUX ROC TE 0x%x\n", 702 IWL_DEBUG_TE(mvm, "Removing BSS AUX ROC TE 0x%x\n",
700 le32_to_cpu(aux_cmd.event_unique_id)); 703 le32_to_cpu(aux_cmd.event_unique_id));
701 ret = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, 704 ret = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0,
702 sizeof(aux_cmd), &aux_cmd); 705 len, &aux_cmd);
703 706
704 if (WARN_ON(ret)) 707 if (WARN_ON(ret))
705 return; 708 return;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tof.c b/drivers/net/wireless/intel/iwlwifi/mvm/tof.c
deleted file mode 100644
index 01e0a999063b..000000000000
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tof.c
+++ /dev/null
@@ -1,305 +0,0 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 Intel Deutschland GmbH
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * The full GNU General Public License is included in this distribution
20 * in the file called COPYING.
21 *
22 * Contact Information:
23 * Intel Linux Wireless <linuxwifi@intel.com>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 * BSD LICENSE
27 *
28 * Copyright(c) 2015 Intel Deutschland GmbH
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
40 * distribution.
41 * * Neither the name Intel Corporation nor the names of its
42 * contributors may be used to endorse or promote products derived
43 * from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
57 *****************************************************************************/
58#include "mvm.h"
59#include "fw/api/tof.h"
60
61#define IWL_MVM_TOF_RANGE_REQ_MAX_ID 256
62
63void iwl_mvm_tof_init(struct iwl_mvm *mvm)
64{
65 struct iwl_mvm_tof_data *tof_data = &mvm->tof_data;
66
67 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
68 return;
69
70 memset(tof_data, 0, sizeof(*tof_data));
71
72 tof_data->tof_cfg.sub_grp_cmd_id = cpu_to_le32(TOF_CONFIG_CMD);
73
74#ifdef CONFIG_IWLWIFI_DEBUGFS
75 if (IWL_MVM_TOF_IS_RESPONDER) {
76 tof_data->responder_cfg.sub_grp_cmd_id =
77 cpu_to_le32(TOF_RESPONDER_CONFIG_CMD);
78 tof_data->responder_cfg.sta_id = IWL_MVM_INVALID_STA;
79 }
80#endif
81
82 tof_data->range_req.sub_grp_cmd_id = cpu_to_le32(TOF_RANGE_REQ_CMD);
83 tof_data->range_req.req_timeout = 1;
84 tof_data->range_req.initiator = 1;
85 tof_data->range_req.report_policy = 3;
86
87 tof_data->range_req_ext.sub_grp_cmd_id =
88 cpu_to_le32(TOF_RANGE_REQ_EXT_CMD);
89
90 mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
91 mvm->init_status |= IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE;
92}
93
94void iwl_mvm_tof_clean(struct iwl_mvm *mvm)
95{
96 struct iwl_mvm_tof_data *tof_data = &mvm->tof_data;
97
98 if (!fw_has_capa(&mvm->fw->ucode_capa,
99 IWL_UCODE_TLV_CAPA_TOF_SUPPORT) ||
100 !(mvm->init_status & IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE))
101 return;
102
103 memset(tof_data, 0, sizeof(*tof_data));
104 mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
105 mvm->init_status &= ~IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE;
106}
107
108static void iwl_tof_iterator(void *_data, u8 *mac,
109 struct ieee80211_vif *vif)
110{
111 bool *enabled = _data;
112
113 /* non bss vif exists */
114 if (ieee80211_vif_type_p2p(vif) != NL80211_IFTYPE_STATION)
115 *enabled = false;
116}
117
118int iwl_mvm_tof_config_cmd(struct iwl_mvm *mvm)
119{
120 struct iwl_tof_config_cmd *cmd = &mvm->tof_data.tof_cfg;
121 bool enabled;
122
123 lockdep_assert_held(&mvm->mutex);
124
125 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
126 return -EINVAL;
127
128 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
129 IEEE80211_IFACE_ITER_NORMAL,
130 iwl_tof_iterator, &enabled);
131 if (!enabled) {
132 IWL_DEBUG_INFO(mvm, "ToF is not supported (non bss vif)\n");
133 return -EINVAL;
134 }
135
136 mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
137 return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_CMD,
138 IWL_ALWAYS_LONG_GROUP, 0),
139 0, sizeof(*cmd), cmd);
140}
141
142int iwl_mvm_tof_range_abort_cmd(struct iwl_mvm *mvm, u8 id)
143{
144 struct iwl_tof_range_abort_cmd cmd = {
145 .sub_grp_cmd_id = cpu_to_le32(TOF_RANGE_ABORT_CMD),
146 .request_id = id,
147 };
148
149 lockdep_assert_held(&mvm->mutex);
150
151 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
152 return -EINVAL;
153
154 if (id != mvm->tof_data.active_range_request) {
155 IWL_ERR(mvm, "Invalid range request id %d (active %d)\n",
156 id, mvm->tof_data.active_range_request);
157 return -EINVAL;
158 }
159
160 /* after abort is sent there's no active request anymore */
161 mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
162
163 return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_CMD,
164 IWL_ALWAYS_LONG_GROUP, 0),
165 0, sizeof(cmd), &cmd);
166}
167
168#ifdef CONFIG_IWLWIFI_DEBUGFS
169int iwl_mvm_tof_responder_cmd(struct iwl_mvm *mvm,
170 struct ieee80211_vif *vif)
171{
172 struct iwl_tof_responder_config_cmd *cmd = &mvm->tof_data.responder_cfg;
173 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
174
175 lockdep_assert_held(&mvm->mutex);
176
177 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
178 return -EINVAL;
179
180 if (vif->p2p || vif->type != NL80211_IFTYPE_AP ||
181 !mvmvif->ap_ibss_active) {
182 IWL_ERR(mvm, "Cannot start responder, not in AP mode\n");
183 return -EIO;
184 }
185
186 cmd->sta_id = mvmvif->bcast_sta.sta_id;
187 memcpy(cmd->bssid, vif->addr, ETH_ALEN);
188 return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_CMD,
189 IWL_ALWAYS_LONG_GROUP, 0),
190 0, sizeof(*cmd), cmd);
191}
192#endif
193
194int iwl_mvm_tof_range_request_cmd(struct iwl_mvm *mvm,
195 struct ieee80211_vif *vif)
196{
197 struct iwl_host_cmd cmd = {
198 .id = iwl_cmd_id(TOF_CMD, IWL_ALWAYS_LONG_GROUP, 0),
199 .len = { sizeof(mvm->tof_data.range_req), },
200 /* no copy because of the command size */
201 .dataflags = { IWL_HCMD_DFL_NOCOPY, },
202 };
203
204 lockdep_assert_held(&mvm->mutex);
205
206 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
207 return -EINVAL;
208
209 if (ieee80211_vif_type_p2p(vif) != NL80211_IFTYPE_STATION) {
210 IWL_ERR(mvm, "Cannot send range request, not STA mode\n");
211 return -EIO;
212 }
213
214 /* nesting of range requests is not supported in FW */
215 if (mvm->tof_data.active_range_request !=
216 IWL_MVM_TOF_RANGE_REQ_MAX_ID) {
217 IWL_ERR(mvm, "Cannot send range req, already active req %d\n",
218 mvm->tof_data.active_range_request);
219 return -EIO;
220 }
221
222 mvm->tof_data.active_range_request = mvm->tof_data.range_req.request_id;
223
224 cmd.data[0] = &mvm->tof_data.range_req;
225 return iwl_mvm_send_cmd(mvm, &cmd);
226}
227
228int iwl_mvm_tof_range_request_ext_cmd(struct iwl_mvm *mvm,
229 struct ieee80211_vif *vif)
230{
231 lockdep_assert_held(&mvm->mutex);
232
233 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
234 return -EINVAL;
235
236 if (ieee80211_vif_type_p2p(vif) != NL80211_IFTYPE_STATION) {
237 IWL_ERR(mvm, "Cannot send ext range req, not in STA mode\n");
238 return -EIO;
239 }
240
241 return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_CMD,
242 IWL_ALWAYS_LONG_GROUP, 0),
243 0, sizeof(mvm->tof_data.range_req_ext),
244 &mvm->tof_data.range_req_ext);
245}
246
247static int iwl_mvm_tof_range_resp(struct iwl_mvm *mvm, void *data)
248{
249 struct iwl_tof_range_rsp_ntfy *resp = (void *)data;
250
251 if (resp->request_id != mvm->tof_data.active_range_request) {
252 IWL_ERR(mvm, "Request id mismatch, got %d, active %d\n",
253 resp->request_id, mvm->tof_data.active_range_request);
254 return -EIO;
255 }
256
257 memcpy(&mvm->tof_data.range_resp, resp,
258 sizeof(struct iwl_tof_range_rsp_ntfy));
259 mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
260
261 return 0;
262}
263
264static int iwl_mvm_tof_mcsi_notif(struct iwl_mvm *mvm, void *data)
265{
266 struct iwl_tof_mcsi_notif *resp = (struct iwl_tof_mcsi_notif *)data;
267
268 IWL_DEBUG_INFO(mvm, "MCSI notification, token %d\n", resp->token);
269 return 0;
270}
271
272static int iwl_mvm_tof_nb_report_notif(struct iwl_mvm *mvm, void *data)
273{
274 struct iwl_tof_neighbor_report *report =
275 (struct iwl_tof_neighbor_report *)data;
276
277 IWL_DEBUG_INFO(mvm, "NB report, bssid %pM, token %d, status 0x%x\n",
278 report->bssid, report->request_token, report->status);
279 return 0;
280}
281
282void iwl_mvm_tof_resp_handler(struct iwl_mvm *mvm,
283 struct iwl_rx_cmd_buffer *rxb)
284{
285 struct iwl_rx_packet *pkt = rxb_addr(rxb);
286 struct iwl_tof_gen_resp_cmd *resp = (void *)pkt->data;
287
288 lockdep_assert_held(&mvm->mutex);
289
290 switch (le32_to_cpu(resp->sub_grp_cmd_id)) {
291 case TOF_RANGE_RESPONSE_NOTIF:
292 iwl_mvm_tof_range_resp(mvm, resp->data);
293 break;
294 case TOF_MCSI_DEBUG_NOTIF:
295 iwl_mvm_tof_mcsi_notif(mvm, resp->data);
296 break;
297 case TOF_NEIGHBOR_REPORT_RSP_NOTIF:
298 iwl_mvm_tof_nb_report_notif(mvm, resp->data);
299 break;
300 default:
301 IWL_ERR(mvm, "Unknown sub-group command 0x%x\n",
302 resp->sub_grp_cmd_id);
303 break;
304 }
305}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tof.h b/drivers/net/wireless/intel/iwlwifi/mvm/tof.h
deleted file mode 100644
index 8138d0606c52..000000000000
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tof.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 Intel Deutschland GmbH
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * The full GNU General Public License is included in this distribution
20 * in the file called COPYING.
21 *
22 * Contact Information:
23 * Intel Linux Wireless <linuxwifi@intel.com>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 * BSD LICENSE
27 *
28 * Copyright(c) 2015 Intel Deutschland GmbH
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
40 * distribution.
41 * * Neither the name Intel Corporation nor the names of its
42 * contributors may be used to endorse or promote products derived
43 * from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
57 *****************************************************************************/
58#ifndef __tof_h__
59#define __tof_h__
60
61#include "fw/api/tof.h"
62
63struct iwl_mvm_tof_data {
64 struct iwl_tof_config_cmd tof_cfg;
65 struct iwl_tof_range_req_cmd range_req;
66 struct iwl_tof_range_req_ext_cmd range_req_ext;
67#ifdef CONFIG_IWLWIFI_DEBUGFS
68 struct iwl_tof_responder_config_cmd responder_cfg;
69#endif
70 struct iwl_tof_range_rsp_ntfy range_resp;
71 u8 last_abort_id;
72 u16 active_range_request;
73};
74
75void iwl_mvm_tof_init(struct iwl_mvm *mvm);
76void iwl_mvm_tof_clean(struct iwl_mvm *mvm);
77int iwl_mvm_tof_config_cmd(struct iwl_mvm *mvm);
78int iwl_mvm_tof_range_abort_cmd(struct iwl_mvm *mvm, u8 id);
79int iwl_mvm_tof_range_request_cmd(struct iwl_mvm *mvm,
80 struct ieee80211_vif *vif);
81void iwl_mvm_tof_resp_handler(struct iwl_mvm *mvm,
82 struct iwl_rx_cmd_buffer *rxb);
83int iwl_mvm_tof_range_request_ext_cmd(struct iwl_mvm *mvm,
84 struct ieee80211_vif *vif);
85#ifdef CONFIG_IWLWIFI_DEBUGFS
86int iwl_mvm_tof_responder_cmd(struct iwl_mvm *mvm,
87 struct ieee80211_vif *vif);
88#endif
89#endif /* __tof_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 995fe2a6abbb..ac62eb8c4b36 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -533,10 +533,11 @@ iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
533 533
534 /* 534 /*
535 * For data packets rate info comes from the fw. Only 535 * For data packets rate info comes from the fw. Only
536 * set rate/antenna during connection establishment. 536 * set rate/antenna during connection establishment or in case
537 * no station is given.
537 */ 538 */
538 if (sta && (!ieee80211_is_data(hdr->frame_control) || 539 if (!sta || !ieee80211_is_data(hdr->frame_control) ||
539 mvmsta->sta_state < IEEE80211_STA_AUTHORIZED)) { 540 mvmsta->sta_state < IEEE80211_STA_AUTHORIZED) {
540 flags |= IWL_TX_FLAGS_CMD_RATE; 541 flags |= IWL_TX_FLAGS_CMD_RATE;
541 rate_n_flags = 542 rate_n_flags =
542 iwl_mvm_get_tx_rate_n_flags(mvm, info, sta, 543 iwl_mvm_get_tx_rate_n_flags(mvm, info, sta,
@@ -602,11 +603,12 @@ static void iwl_mvm_skb_prepare_status(struct sk_buff *skb,
602} 603}
603 604
604static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm, 605static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm,
605 struct ieee80211_tx_info *info, __le16 fc) 606 struct ieee80211_tx_info *info,
607 struct ieee80211_hdr *hdr)
606{ 608{
607 struct iwl_mvm_vif *mvmvif; 609 struct iwl_mvm_vif *mvmvif =
608 610 iwl_mvm_vif_from_mac80211(info->control.vif);
609 mvmvif = iwl_mvm_vif_from_mac80211(info->control.vif); 611 __le16 fc = hdr->frame_control;
610 612
611 switch (info->control.vif->type) { 613 switch (info->control.vif->type) {
612 case NL80211_IFTYPE_AP: 614 case NL80211_IFTYPE_AP:
@@ -625,7 +627,9 @@ static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm,
625 (!ieee80211_is_bufferable_mmpdu(fc) || 627 (!ieee80211_is_bufferable_mmpdu(fc) ||
626 ieee80211_is_deauth(fc) || ieee80211_is_disassoc(fc))) 628 ieee80211_is_deauth(fc) || ieee80211_is_disassoc(fc)))
627 return mvm->probe_queue; 629 return mvm->probe_queue;
628 if (info->hw_queue == info->control.vif->cab_queue) 630
631 if (!ieee80211_has_order(fc) && !ieee80211_is_probe_req(fc) &&
632 is_multicast_ether_addr(hdr->addr1))
629 return mvmvif->cab_queue; 633 return mvmvif->cab_queue;
630 634
631 WARN_ONCE(info->control.vif->type != NL80211_IFTYPE_ADHOC, 635 WARN_ONCE(info->control.vif->type != NL80211_IFTYPE_ADHOC,
@@ -634,8 +638,6 @@ static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm,
634 case NL80211_IFTYPE_P2P_DEVICE: 638 case NL80211_IFTYPE_P2P_DEVICE:
635 if (ieee80211_is_mgmt(fc)) 639 if (ieee80211_is_mgmt(fc))
636 return mvm->p2p_dev_queue; 640 return mvm->p2p_dev_queue;
637 if (info->hw_queue == info->control.vif->cab_queue)
638 return mvmvif->cab_queue;
639 641
640 WARN_ON_ONCE(1); 642 WARN_ON_ONCE(1);
641 return mvm->p2p_dev_queue; 643 return mvm->p2p_dev_queue;
@@ -713,6 +715,8 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
713 u8 sta_id; 715 u8 sta_id;
714 int hdrlen = ieee80211_hdrlen(hdr->frame_control); 716 int hdrlen = ieee80211_hdrlen(hdr->frame_control);
715 __le16 fc = hdr->frame_control; 717 __le16 fc = hdr->frame_control;
718 bool offchannel = IEEE80211_SKB_CB(skb)->flags &
719 IEEE80211_TX_CTL_TX_OFFCHAN;
716 int queue = -1; 720 int queue = -1;
717 721
718 memcpy(&info, skb->cb, sizeof(info)); 722 memcpy(&info, skb->cb, sizeof(info));
@@ -720,11 +724,6 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
720 if (WARN_ON_ONCE(info.flags & IEEE80211_TX_CTL_AMPDU)) 724 if (WARN_ON_ONCE(info.flags & IEEE80211_TX_CTL_AMPDU))
721 return -1; 725 return -1;
722 726
723 if (WARN_ON_ONCE(info.flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
724 (!info.control.vif ||
725 info.hw_queue != info.control.vif->cab_queue)))
726 return -1;
727
728 if (info.control.vif) { 727 if (info.control.vif) {
729 struct iwl_mvm_vif *mvmvif = 728 struct iwl_mvm_vif *mvmvif =
730 iwl_mvm_vif_from_mac80211(info.control.vif); 729 iwl_mvm_vif_from_mac80211(info.control.vif);
@@ -737,14 +736,12 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
737 else 736 else
738 sta_id = mvmvif->mcast_sta.sta_id; 737 sta_id = mvmvif->mcast_sta.sta_id;
739 738
740 queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, 739 queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, hdr);
741 hdr->frame_control);
742
743 } else if (info.control.vif->type == NL80211_IFTYPE_MONITOR) { 740 } else if (info.control.vif->type == NL80211_IFTYPE_MONITOR) {
744 queue = mvm->snif_queue; 741 queue = mvm->snif_queue;
745 sta_id = mvm->snif_sta.sta_id; 742 sta_id = mvm->snif_sta.sta_id;
746 } else if (info.control.vif->type == NL80211_IFTYPE_STATION && 743 } else if (info.control.vif->type == NL80211_IFTYPE_STATION &&
747 info.hw_queue == IWL_MVM_OFFCHANNEL_QUEUE) { 744 offchannel) {
748 /* 745 /*
749 * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets 746 * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets
750 * that can be used in 2 different types of vifs, P2P & 747 * that can be used in 2 different types of vifs, P2P &
@@ -758,8 +755,10 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
758 } 755 }
759 } 756 }
760 757
761 if (queue < 0) 758 if (queue < 0) {
759 IWL_ERR(mvm, "No queue was found. Dropping TX\n");
762 return -1; 760 return -1;
761 }
763 762
764 if (unlikely(ieee80211_is_probe_resp(fc))) 763 if (unlikely(ieee80211_is_probe_resp(fc)))
765 iwl_mvm_probe_resp_set_noa(mvm, skb); 764 iwl_mvm_probe_resp_set_noa(mvm, skb);
@@ -781,6 +780,35 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
781 return 0; 780 return 0;
782} 781}
783 782
783unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
784 struct ieee80211_sta *sta, unsigned int tid)
785{
786 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
787 enum nl80211_band band = mvmsta->vif->bss_conf.chandef.chan->band;
788 u8 ac = tid_to_mac80211_ac[tid];
789 unsigned int txf;
790 int lmac = IWL_LMAC_24G_INDEX;
791
792 if (iwl_mvm_is_cdb_supported(mvm) &&
793 band == NL80211_BAND_5GHZ)
794 lmac = IWL_LMAC_5G_INDEX;
795
796 /* For HE redirect to trigger based fifos */
797 if (sta->he_cap.has_he && !WARN_ON(!iwl_mvm_has_new_tx_api(mvm)))
798 ac += 4;
799
800 txf = iwl_mvm_mac_ac_to_tx_fifo(mvm, ac);
801
802 /*
803 * Don't send an AMSDU that will be longer than the TXF.
804 * Add a security margin of 256 for the TX command + headers.
805 * We also want to have the start of the next packet inside the
806 * fifo to be able to send bursts.
807 */
808 return min_t(unsigned int, mvmsta->max_amsdu_len,
809 mvm->fwrt.smem_cfg.lmac[lmac].txfifo_size[txf] - 256);
810}
811
784#ifdef CONFIG_INET 812#ifdef CONFIG_INET
785 813
786static int 814static int
@@ -850,36 +878,6 @@ iwl_mvm_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
850 return 0; 878 return 0;
851} 879}
852 880
853static unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
854 struct ieee80211_sta *sta,
855 unsigned int tid)
856{
857 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
858 enum nl80211_band band = mvmsta->vif->bss_conf.chandef.chan->band;
859 u8 ac = tid_to_mac80211_ac[tid];
860 unsigned int txf;
861 int lmac = IWL_LMAC_24G_INDEX;
862
863 if (iwl_mvm_is_cdb_supported(mvm) &&
864 band == NL80211_BAND_5GHZ)
865 lmac = IWL_LMAC_5G_INDEX;
866
867 /* For HE redirect to trigger based fifos */
868 if (sta->he_cap.has_he && !WARN_ON(!iwl_mvm_has_new_tx_api(mvm)))
869 ac += 4;
870
871 txf = iwl_mvm_mac_ac_to_tx_fifo(mvm, ac);
872
873 /*
874 * Don't send an AMSDU that will be longer than the TXF.
875 * Add a security margin of 256 for the TX command + headers.
876 * We also want to have the start of the next packet inside the
877 * fifo to be able to send bursts.
878 */
879 return min_t(unsigned int, mvmsta->max_amsdu_len,
880 mvm->fwrt.smem_cfg.lmac[lmac].txfifo_size[txf] - 256);
881}
882
883static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb, 881static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
884 struct ieee80211_tx_info *info, 882 struct ieee80211_tx_info *info,
885 struct ieee80211_sta *sta, 883 struct ieee80211_sta *sta,
@@ -1002,34 +1000,6 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
1002} 1000}
1003#endif 1001#endif
1004 1002
1005static void iwl_mvm_tx_add_stream(struct iwl_mvm *mvm,
1006 struct iwl_mvm_sta *mvm_sta, u8 tid,
1007 struct sk_buff *skb)
1008{
1009 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1010 u8 mac_queue = info->hw_queue;
1011 struct sk_buff_head *deferred_tx_frames;
1012
1013 lockdep_assert_held(&mvm_sta->lock);
1014
1015 mvm_sta->deferred_traffic_tid_map |= BIT(tid);
1016 set_bit(mvm_sta->sta_id, mvm->sta_deferred_frames);
1017
1018 deferred_tx_frames = &mvm_sta->tid_data[tid].deferred_tx_frames;
1019
1020 skb_queue_tail(deferred_tx_frames, skb);
1021
1022 /*
1023 * The first deferred frame should've stopped the MAC queues, so we
1024 * should never get a second deferred frame for the RA/TID.
1025 * In case of GSO the first packet may have been split, so don't warn.
1026 */
1027 if (skb_queue_len(deferred_tx_frames) == 1) {
1028 iwl_mvm_stop_mac_queues(mvm, BIT(mac_queue));
1029 schedule_work(&mvm->add_stream_wk);
1030 }
1031}
1032
1033/* Check if there are any timed-out TIDs on a given shared TXQ */ 1003/* Check if there are any timed-out TIDs on a given shared TXQ */
1034static bool iwl_mvm_txq_should_update(struct iwl_mvm *mvm, int txq_id) 1004static bool iwl_mvm_txq_should_update(struct iwl_mvm *mvm, int txq_id)
1035{ 1005{
@@ -1054,7 +1024,12 @@ static void iwl_mvm_tx_airtime(struct iwl_mvm *mvm,
1054 int airtime) 1024 int airtime)
1055{ 1025{
1056 int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK; 1026 int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK;
1057 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac]; 1027 struct iwl_mvm_tcm_mac *mdata;
1028
1029 if (mac >= NUM_MAC_INDEX_DRIVER)
1030 return;
1031
1032 mdata = &mvm->tcm.data[mac];
1058 1033
1059 if (mvm->tcm.paused) 1034 if (mvm->tcm.paused)
1060 return; 1035 return;
@@ -1065,14 +1040,21 @@ static void iwl_mvm_tx_airtime(struct iwl_mvm *mvm,
1065 mdata->tx.airtime += airtime; 1040 mdata->tx.airtime += airtime;
1066} 1041}
1067 1042
1068static void iwl_mvm_tx_pkt_queued(struct iwl_mvm *mvm, 1043static int iwl_mvm_tx_pkt_queued(struct iwl_mvm *mvm,
1069 struct iwl_mvm_sta *mvmsta, int tid) 1044 struct iwl_mvm_sta *mvmsta, int tid)
1070{ 1045{
1071 u32 ac = tid_to_mac80211_ac[tid]; 1046 u32 ac = tid_to_mac80211_ac[tid];
1072 int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK; 1047 int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK;
1073 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac]; 1048 struct iwl_mvm_tcm_mac *mdata;
1049
1050 if (mac >= NUM_MAC_INDEX_DRIVER)
1051 return -EINVAL;
1052
1053 mdata = &mvm->tcm.data[mac];
1074 1054
1075 mdata->tx.pkts[ac]++; 1055 mdata->tx.pkts[ac]++;
1056
1057 return 0;
1076} 1058}
1077 1059
1078/* 1060/*
@@ -1088,7 +1070,7 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
1088 __le16 fc; 1070 __le16 fc;
1089 u16 seq_number = 0; 1071 u16 seq_number = 0;
1090 u8 tid = IWL_MAX_TID_COUNT; 1072 u8 tid = IWL_MAX_TID_COUNT;
1091 u16 txq_id = info->hw_queue; 1073 u16 txq_id;
1092 bool is_ampdu = false; 1074 bool is_ampdu = false;
1093 int hdrlen; 1075 int hdrlen;
1094 1076
@@ -1152,14 +1134,7 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
1152 1134
1153 WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM); 1135 WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM);
1154 1136
1155 /* Check if TXQ needs to be allocated or re-activated */ 1137 if (WARN_ON_ONCE(txq_id == IWL_MVM_INVALID_QUEUE)) {
1156 if (unlikely(txq_id == IWL_MVM_INVALID_QUEUE)) {
1157 iwl_mvm_tx_add_stream(mvm, mvmsta, tid, skb);
1158
1159 /*
1160 * The frame is now deferred, and the worker scheduled
1161 * will re-allocate it, so we can free it for now.
1162 */
1163 iwl_trans_free_tx_cmd(mvm->trans, dev_cmd); 1138 iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
1164 spin_unlock(&mvmsta->lock); 1139 spin_unlock(&mvmsta->lock);
1165 return 0; 1140 return 0;
@@ -1199,7 +1174,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
1199 1174
1200 spin_unlock(&mvmsta->lock); 1175 spin_unlock(&mvmsta->lock);
1201 1176
1202 iwl_mvm_tx_pkt_queued(mvm, mvmsta, tid == IWL_MAX_TID_COUNT ? 0 : tid); 1177 if (iwl_mvm_tx_pkt_queued(mvm, mvmsta,
1178 tid == IWL_MAX_TID_COUNT ? 0 : tid))
1179 goto drop;
1203 1180
1204 return 0; 1181 return 0;
1205 1182
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index d116c6ae18ff..211c4638d690 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -248,7 +248,7 @@ void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
248 IWL_ERR(mvm, "FW Error notification: seq 0x%04X service 0x%08X\n", 248 IWL_ERR(mvm, "FW Error notification: seq 0x%04X service 0x%08X\n",
249 le16_to_cpu(err_resp->bad_cmd_seq_num), 249 le16_to_cpu(err_resp->bad_cmd_seq_num),
250 le32_to_cpu(err_resp->error_service)); 250 le32_to_cpu(err_resp->error_service));
251 IWL_ERR(mvm, "FW Error notification: timestamp 0x%16llX\n", 251 IWL_ERR(mvm, "FW Error notification: timestamp 0x%016llX\n",
252 le64_to_cpu(err_resp->timestamp)); 252 le64_to_cpu(err_resp->timestamp));
253} 253}
254 254
@@ -463,6 +463,9 @@ static void iwl_mvm_dump_umac_error_log(struct iwl_mvm *mvm)
463 iwl_trans_read_mem_bytes(trans, mvm->umac_error_event_table, &table, 463 iwl_trans_read_mem_bytes(trans, mvm->umac_error_event_table, &table,
464 sizeof(table)); 464 sizeof(table));
465 465
466 if (table.valid)
467 mvm->fwrt.dump.umac_err_id = table.error_id;
468
466 if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) { 469 if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
467 IWL_ERR(trans, "Start IWL Error Log Dump:\n"); 470 IWL_ERR(trans, "Start IWL Error Log Dump:\n");
468 IWL_ERR(trans, "Status: 0x%08lX, count: %d\n", 471 IWL_ERR(trans, "Status: 0x%08lX, count: %d\n",
@@ -486,11 +489,11 @@ static void iwl_mvm_dump_umac_error_log(struct iwl_mvm *mvm)
486 IWL_ERR(mvm, "0x%08X | isr status reg\n", table.nic_isr_pref); 489 IWL_ERR(mvm, "0x%08X | isr status reg\n", table.nic_isr_pref);
487} 490}
488 491
489static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm *mvm, u32 base) 492static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm *mvm, u8 lmac_num)
490{ 493{
491 struct iwl_trans *trans = mvm->trans; 494 struct iwl_trans *trans = mvm->trans;
492 struct iwl_error_event_table table; 495 struct iwl_error_event_table table;
493 u32 val; 496 u32 val, base = mvm->error_event_table[lmac_num];
494 497
495 if (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) { 498 if (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) {
496 if (!base) 499 if (!base)
@@ -541,7 +544,7 @@ static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm *mvm, u32 base)
541 iwl_trans_read_mem_bytes(trans, base, &table, sizeof(table)); 544 iwl_trans_read_mem_bytes(trans, base, &table, sizeof(table));
542 545
543 if (table.valid) 546 if (table.valid)
544 mvm->fwrt.dump.rt_status = table.error_id; 547 mvm->fwrt.dump.lmac_err_id[lmac_num] = table.error_id;
545 548
546 if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) { 549 if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
547 IWL_ERR(trans, "Start IWL Error Log Dump:\n"); 550 IWL_ERR(trans, "Start IWL Error Log Dump:\n");
@@ -598,10 +601,10 @@ void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
598 return; 601 return;
599 } 602 }
600 603
601 iwl_mvm_dump_lmac_error_log(mvm, mvm->error_event_table[0]); 604 iwl_mvm_dump_lmac_error_log(mvm, 0);
602 605
603 if (mvm->error_event_table[1]) 606 if (mvm->error_event_table[1])
604 iwl_mvm_dump_lmac_error_log(mvm, mvm->error_event_table[1]); 607 iwl_mvm_dump_lmac_error_log(mvm, 1);
605 608
606 iwl_mvm_dump_umac_error_log(mvm); 609 iwl_mvm_dump_umac_error_log(mvm);
607} 610}
@@ -1133,19 +1136,14 @@ static void iwl_mvm_tcm_uapsd_nonagg_detected_wk(struct work_struct *wk)
1133 "AP isn't using AMPDU with uAPSD enabled"); 1136 "AP isn't using AMPDU with uAPSD enabled");
1134} 1137}
1135 1138
1136static void iwl_mvm_uapsd_agg_disconnect_iter(void *data, u8 *mac, 1139static void iwl_mvm_uapsd_agg_disconnect(struct iwl_mvm *mvm,
1137 struct ieee80211_vif *vif) 1140 struct ieee80211_vif *vif)
1138{ 1141{
1139 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1142 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1140 struct iwl_mvm *mvm = mvmvif->mvm;
1141 int *mac_id = data;
1142 1143
1143 if (vif->type != NL80211_IFTYPE_STATION) 1144 if (vif->type != NL80211_IFTYPE_STATION)
1144 return; 1145 return;
1145 1146
1146 if (mvmvif->id != *mac_id)
1147 return;
1148
1149 if (!vif->bss_conf.assoc) 1147 if (!vif->bss_conf.assoc)
1150 return; 1148 return;
1151 1149
@@ -1155,10 +1153,10 @@ static void iwl_mvm_uapsd_agg_disconnect_iter(void *data, u8 *mac,
1155 !mvmvif->queue_params[IEEE80211_AC_BK].uapsd) 1153 !mvmvif->queue_params[IEEE80211_AC_BK].uapsd)
1156 return; 1154 return;
1157 1155
1158 if (mvm->tcm.data[*mac_id].uapsd_nonagg_detect.detected) 1156 if (mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected)
1159 return; 1157 return;
1160 1158
1161 mvm->tcm.data[*mac_id].uapsd_nonagg_detect.detected = true; 1159 mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected = true;
1162 IWL_INFO(mvm, 1160 IWL_INFO(mvm,
1163 "detected AP should do aggregation but isn't, likely due to U-APSD\n"); 1161 "detected AP should do aggregation but isn't, likely due to U-APSD\n");
1164 schedule_delayed_work(&mvmvif->uapsd_nonagg_detected_wk, 15 * HZ); 1162 schedule_delayed_work(&mvmvif->uapsd_nonagg_detected_wk, 15 * HZ);
@@ -1171,6 +1169,7 @@ static void iwl_mvm_check_uapsd_agg_expected_tpt(struct iwl_mvm *mvm,
1171 u64 bytes = mvm->tcm.data[mac].uapsd_nonagg_detect.rx_bytes; 1169 u64 bytes = mvm->tcm.data[mac].uapsd_nonagg_detect.rx_bytes;
1172 u64 tpt; 1170 u64 tpt;
1173 unsigned long rate; 1171 unsigned long rate;
1172 struct ieee80211_vif *vif;
1174 1173
1175 rate = ewma_rate_read(&mvm->tcm.data[mac].uapsd_nonagg_detect.rate); 1174 rate = ewma_rate_read(&mvm->tcm.data[mac].uapsd_nonagg_detect.rate);
1176 1175
@@ -1199,9 +1198,11 @@ static void iwl_mvm_check_uapsd_agg_expected_tpt(struct iwl_mvm *mvm,
1199 return; 1198 return;
1200 } 1199 }
1201 1200
1202 ieee80211_iterate_active_interfaces_atomic( 1201 rcu_read_lock();
1203 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, 1202 vif = rcu_dereference(mvm->vif_id_to_mac[mac]);
1204 iwl_mvm_uapsd_agg_disconnect_iter, &mac); 1203 if (vif)
1204 iwl_mvm_uapsd_agg_disconnect(mvm, vif);
1205 rcu_read_unlock();
1205} 1206}
1206 1207
1207static void iwl_mvm_tcm_iterator(void *_data, u8 *mac, 1208static void iwl_mvm_tcm_iterator(void *_data, u8 *mac,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 353581ccc01e..a22e47639a4e 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -513,10 +513,10 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
513 {IWL_PCI_DEVICE(0x24FD, 0x9074, iwl8265_2ac_cfg)}, 513 {IWL_PCI_DEVICE(0x24FD, 0x9074, iwl8265_2ac_cfg)},
514 514
515/* 9000 Series */ 515/* 9000 Series */
516 {IWL_PCI_DEVICE(0x02F0, 0x0030, iwl9560_2ac_cfg_soc)}, 516 {IWL_PCI_DEVICE(0x02F0, 0x0030, iwl9560_2ac_160_cfg_soc)},
517 {IWL_PCI_DEVICE(0x02F0, 0x0034, iwl9560_2ac_cfg_soc)}, 517 {IWL_PCI_DEVICE(0x02F0, 0x0034, iwl9560_2ac_cfg_soc)},
518 {IWL_PCI_DEVICE(0x02F0, 0x0038, iwl9560_2ac_cfg_soc)}, 518 {IWL_PCI_DEVICE(0x02F0, 0x0038, iwl9560_2ac_160_cfg_soc)},
519 {IWL_PCI_DEVICE(0x02F0, 0x003C, iwl9560_2ac_cfg_soc)}, 519 {IWL_PCI_DEVICE(0x02F0, 0x003C, iwl9560_2ac_160_cfg_soc)},
520 {IWL_PCI_DEVICE(0x02F0, 0x0060, iwl9461_2ac_cfg_soc)}, 520 {IWL_PCI_DEVICE(0x02F0, 0x0060, iwl9461_2ac_cfg_soc)},
521 {IWL_PCI_DEVICE(0x02F0, 0x0064, iwl9461_2ac_cfg_soc)}, 521 {IWL_PCI_DEVICE(0x02F0, 0x0064, iwl9461_2ac_cfg_soc)},
522 {IWL_PCI_DEVICE(0x02F0, 0x00A0, iwl9462_2ac_cfg_soc)}, 522 {IWL_PCI_DEVICE(0x02F0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -531,17 +531,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
531 {IWL_PCI_DEVICE(0x02F0, 0x02A4, iwl9462_2ac_cfg_soc)}, 531 {IWL_PCI_DEVICE(0x02F0, 0x02A4, iwl9462_2ac_cfg_soc)},
532 {IWL_PCI_DEVICE(0x02F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 532 {IWL_PCI_DEVICE(0x02F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
533 {IWL_PCI_DEVICE(0x02F0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 533 {IWL_PCI_DEVICE(0x02F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
534 {IWL_PCI_DEVICE(0x02F0, 0x2030, iwl9560_2ac_cfg_soc)}, 534 {IWL_PCI_DEVICE(0x02F0, 0x2030, iwl9560_2ac_160_cfg_soc)},
535 {IWL_PCI_DEVICE(0x02F0, 0x2034, iwl9560_2ac_cfg_soc)}, 535 {IWL_PCI_DEVICE(0x02F0, 0x2034, iwl9560_2ac_160_cfg_soc)},
536 {IWL_PCI_DEVICE(0x02F0, 0x4030, iwl9560_2ac_cfg_soc)}, 536 {IWL_PCI_DEVICE(0x02F0, 0x4030, iwl9560_2ac_160_cfg_soc)},
537 {IWL_PCI_DEVICE(0x02F0, 0x4034, iwl9560_2ac_cfg_soc)}, 537 {IWL_PCI_DEVICE(0x02F0, 0x4034, iwl9560_2ac_160_cfg_soc)},
538 {IWL_PCI_DEVICE(0x02F0, 0x40A4, iwl9462_2ac_cfg_soc)}, 538 {IWL_PCI_DEVICE(0x02F0, 0x40A4, iwl9462_2ac_cfg_soc)},
539 {IWL_PCI_DEVICE(0x02F0, 0x4234, iwl9560_2ac_cfg_soc)}, 539 {IWL_PCI_DEVICE(0x02F0, 0x4234, iwl9560_2ac_cfg_soc)},
540 {IWL_PCI_DEVICE(0x02F0, 0x42A4, iwl9462_2ac_cfg_soc)}, 540 {IWL_PCI_DEVICE(0x02F0, 0x42A4, iwl9462_2ac_cfg_soc)},
541 {IWL_PCI_DEVICE(0x06F0, 0x0030, iwl9560_2ac_cfg_soc)}, 541 {IWL_PCI_DEVICE(0x06F0, 0x0030, iwl9560_2ac_160_cfg_soc)},
542 {IWL_PCI_DEVICE(0x06F0, 0x0034, iwl9560_2ac_cfg_soc)}, 542 {IWL_PCI_DEVICE(0x06F0, 0x0034, iwl9560_2ac_cfg_soc)},
543 {IWL_PCI_DEVICE(0x06F0, 0x0038, iwl9560_2ac_cfg_soc)}, 543 {IWL_PCI_DEVICE(0x06F0, 0x0038, iwl9560_2ac_160_cfg_soc)},
544 {IWL_PCI_DEVICE(0x06F0, 0x003C, iwl9560_2ac_cfg_soc)}, 544 {IWL_PCI_DEVICE(0x06F0, 0x003C, iwl9560_2ac_160_cfg_soc)},
545 {IWL_PCI_DEVICE(0x06F0, 0x0060, iwl9461_2ac_cfg_soc)}, 545 {IWL_PCI_DEVICE(0x06F0, 0x0060, iwl9461_2ac_cfg_soc)},
546 {IWL_PCI_DEVICE(0x06F0, 0x0064, iwl9461_2ac_cfg_soc)}, 546 {IWL_PCI_DEVICE(0x06F0, 0x0064, iwl9461_2ac_cfg_soc)},
547 {IWL_PCI_DEVICE(0x06F0, 0x00A0, iwl9462_2ac_cfg_soc)}, 547 {IWL_PCI_DEVICE(0x06F0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -556,20 +556,21 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
556 {IWL_PCI_DEVICE(0x06F0, 0x02A4, iwl9462_2ac_cfg_soc)}, 556 {IWL_PCI_DEVICE(0x06F0, 0x02A4, iwl9462_2ac_cfg_soc)},
557 {IWL_PCI_DEVICE(0x06F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 557 {IWL_PCI_DEVICE(0x06F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
558 {IWL_PCI_DEVICE(0x06F0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 558 {IWL_PCI_DEVICE(0x06F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
559 {IWL_PCI_DEVICE(0x06F0, 0x2030, iwl9560_2ac_cfg_soc)}, 559 {IWL_PCI_DEVICE(0x06F0, 0x2030, iwl9560_2ac_160_cfg_soc)},
560 {IWL_PCI_DEVICE(0x06F0, 0x2034, iwl9560_2ac_cfg_soc)}, 560 {IWL_PCI_DEVICE(0x06F0, 0x2034, iwl9560_2ac_160_cfg_soc)},
561 {IWL_PCI_DEVICE(0x06F0, 0x4030, iwl9560_2ac_cfg_soc)}, 561 {IWL_PCI_DEVICE(0x06F0, 0x4030, iwl9560_2ac_160_cfg_soc)},
562 {IWL_PCI_DEVICE(0x06F0, 0x4034, iwl9560_2ac_cfg_soc)}, 562 {IWL_PCI_DEVICE(0x06F0, 0x4034, iwl9560_2ac_160_cfg_soc)},
563 {IWL_PCI_DEVICE(0x06F0, 0x40A4, iwl9462_2ac_cfg_soc)}, 563 {IWL_PCI_DEVICE(0x06F0, 0x40A4, iwl9462_2ac_cfg_soc)},
564 {IWL_PCI_DEVICE(0x06F0, 0x4234, iwl9560_2ac_cfg_soc)}, 564 {IWL_PCI_DEVICE(0x06F0, 0x4234, iwl9560_2ac_cfg_soc)},
565 {IWL_PCI_DEVICE(0x06F0, 0x42A4, iwl9462_2ac_cfg_soc)}, 565 {IWL_PCI_DEVICE(0x06F0, 0x42A4, iwl9462_2ac_cfg_soc)},
566 {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)}, 566 {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_160_cfg)},
567 {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_cfg)}, 567 {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_160_cfg)},
568 {IWL_PCI_DEVICE(0x2526, 0x0018, iwl9260_2ac_cfg)}, 568 {IWL_PCI_DEVICE(0x2526, 0x0018, iwl9260_2ac_160_cfg)},
569 {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)}, 569 {IWL_PCI_DEVICE(0x2526, 0x001C, iwl9260_2ac_160_cfg)},
570 {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_160_cfg)},
570 {IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)}, 571 {IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)},
571 {IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_cfg)}, 572 {IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_160_cfg)},
572 {IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_cfg)}, 573 {IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_160_cfg)},
573 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, 574 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)},
574 {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)}, 575 {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)},
575 {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)}, 576 {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)},
@@ -593,24 +594,26 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
593 {IWL_PCI_DEVICE(0x2526, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 594 {IWL_PCI_DEVICE(0x2526, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
594 {IWL_PCI_DEVICE(0x2526, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 595 {IWL_PCI_DEVICE(0x2526, 0x1552, iwl9560_killer_2ac_cfg_soc)},
595 {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)}, 596 {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
596 {IWL_PCI_DEVICE(0x2526, 0x2030, iwl9560_2ac_cfg_soc)}, 597 {IWL_PCI_DEVICE(0x2526, 0x2030, iwl9560_2ac_160_cfg_soc)},
597 {IWL_PCI_DEVICE(0x2526, 0x2034, iwl9560_2ac_cfg_soc)}, 598 {IWL_PCI_DEVICE(0x2526, 0x2034, iwl9560_2ac_160_cfg_soc)},
598 {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_cfg)}, 599 {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_160_cfg)},
599 {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_cfg)}, 600 {IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)},
600 {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_cfg_soc)}, 601 {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_160_cfg)},
602 {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)},
601 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)}, 603 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)},
602 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)}, 604 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)},
603 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)}, 605 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)},
604 {IWL_PCI_DEVICE(0x2526, 0x8014, iwl9260_2ac_cfg)}, 606 {IWL_PCI_DEVICE(0x2526, 0x8014, iwl9260_2ac_160_cfg)},
605 {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)}, 607 {IWL_PCI_DEVICE(0x2526, 0x8010, iwl9260_2ac_160_cfg)},
608 {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_160_cfg)},
606 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, 609 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
607 {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)}, 610 {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
608 {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)}, 611 {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
609 {IWL_PCI_DEVICE(0x271B, 0x0214, iwl9260_2ac_cfg)}, 612 {IWL_PCI_DEVICE(0x271B, 0x0214, iwl9260_2ac_cfg)},
610 {IWL_PCI_DEVICE(0x271C, 0x0214, iwl9260_2ac_cfg)}, 613 {IWL_PCI_DEVICE(0x271C, 0x0214, iwl9260_2ac_cfg)},
611 {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_cfg)}, 614 {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_160_cfg)},
612 {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_cfg)}, 615 {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_160_cfg)},
613 {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_cfg)}, 616 {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_160_cfg)},
614 {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_soc)}, 617 {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_soc)},
615 {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_soc)}, 618 {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_soc)},
616 {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_soc)}, 619 {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -628,17 +631,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
628 {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)}, 631 {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)},
629 {IWL_PCI_DEVICE(0x2720, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 632 {IWL_PCI_DEVICE(0x2720, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
630 {IWL_PCI_DEVICE(0x2720, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 633 {IWL_PCI_DEVICE(0x2720, 0x1552, iwl9560_killer_2ac_cfg_soc)},
631 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_cfg_soc)}, 634 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_160_cfg_soc)},
632 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_cfg_soc)}, 635 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_160_cfg_soc)},
633 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_cfg)}, 636 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_160_cfg)},
634 {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_cfg_soc)}, 637 {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_160_cfg_soc)},
635 {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_soc)}, 638 {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_soc)},
636 {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_soc)}, 639 {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_soc)},
637 {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_soc)}, 640 {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_soc)},
638 {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_cfg_soc)}, 641 {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_160_cfg_soc)},
639 {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_soc)}, 642 {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_soc)},
640 {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_cfg_soc)}, 643 {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_160_cfg_soc)},
641 {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_cfg_soc)}, 644 {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_160_cfg_soc)},
642 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg_soc)}, 645 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg_soc)},
643 {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_soc)}, 646 {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_soc)},
644 {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_soc)}, 647 {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -656,17 +659,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
656 {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)}, 659 {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)},
657 {IWL_PCI_DEVICE(0x30DC, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 660 {IWL_PCI_DEVICE(0x30DC, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
658 {IWL_PCI_DEVICE(0x30DC, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 661 {IWL_PCI_DEVICE(0x30DC, 0x1552, iwl9560_killer_2ac_cfg_soc)},
659 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_cfg_soc)}, 662 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_160_cfg_soc)},
660 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_cfg_soc)}, 663 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_160_cfg_soc)},
661 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_cfg_soc)}, 664 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_160_cfg_soc)},
662 {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_cfg_soc)}, 665 {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_160_cfg_soc)},
663 {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_soc)}, 666 {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_soc)},
664 {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_soc)}, 667 {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_soc)},
665 {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_soc)}, 668 {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_soc)},
666 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg_shared_clk)}, 669 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_160_cfg_shared_clk)},
667 {IWL_PCI_DEVICE(0x31DC, 0x0034, iwl9560_2ac_cfg_shared_clk)}, 670 {IWL_PCI_DEVICE(0x31DC, 0x0034, iwl9560_2ac_cfg_shared_clk)},
668 {IWL_PCI_DEVICE(0x31DC, 0x0038, iwl9560_2ac_cfg_shared_clk)}, 671 {IWL_PCI_DEVICE(0x31DC, 0x0038, iwl9560_2ac_160_cfg_shared_clk)},
669 {IWL_PCI_DEVICE(0x31DC, 0x003C, iwl9560_2ac_cfg_shared_clk)}, 672 {IWL_PCI_DEVICE(0x31DC, 0x003C, iwl9560_2ac_160_cfg_shared_clk)},
670 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg_shared_clk)}, 673 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg_shared_clk)},
671 {IWL_PCI_DEVICE(0x31DC, 0x0064, iwl9461_2ac_cfg_shared_clk)}, 674 {IWL_PCI_DEVICE(0x31DC, 0x0064, iwl9461_2ac_cfg_shared_clk)},
672 {IWL_PCI_DEVICE(0x31DC, 0x00A0, iwl9462_2ac_cfg_shared_clk)}, 675 {IWL_PCI_DEVICE(0x31DC, 0x00A0, iwl9462_2ac_cfg_shared_clk)},
@@ -684,18 +687,18 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
684 {IWL_PCI_DEVICE(0x31DC, 0x1210, iwl9260_2ac_cfg)}, 687 {IWL_PCI_DEVICE(0x31DC, 0x1210, iwl9260_2ac_cfg)},
685 {IWL_PCI_DEVICE(0x31DC, 0x1551, iwl9560_killer_s_2ac_cfg_shared_clk)}, 688 {IWL_PCI_DEVICE(0x31DC, 0x1551, iwl9560_killer_s_2ac_cfg_shared_clk)},
686 {IWL_PCI_DEVICE(0x31DC, 0x1552, iwl9560_killer_2ac_cfg_shared_clk)}, 689 {IWL_PCI_DEVICE(0x31DC, 0x1552, iwl9560_killer_2ac_cfg_shared_clk)},
687 {IWL_PCI_DEVICE(0x31DC, 0x2030, iwl9560_2ac_cfg_shared_clk)}, 690 {IWL_PCI_DEVICE(0x31DC, 0x2030, iwl9560_2ac_160_cfg_shared_clk)},
688 {IWL_PCI_DEVICE(0x31DC, 0x2034, iwl9560_2ac_cfg_shared_clk)}, 691 {IWL_PCI_DEVICE(0x31DC, 0x2034, iwl9560_2ac_160_cfg_shared_clk)},
689 {IWL_PCI_DEVICE(0x31DC, 0x4030, iwl9560_2ac_cfg_shared_clk)}, 692 {IWL_PCI_DEVICE(0x31DC, 0x4030, iwl9560_2ac_160_cfg_shared_clk)},
690 {IWL_PCI_DEVICE(0x31DC, 0x4034, iwl9560_2ac_cfg_shared_clk)}, 693 {IWL_PCI_DEVICE(0x31DC, 0x4034, iwl9560_2ac_160_cfg_shared_clk)},
691 {IWL_PCI_DEVICE(0x31DC, 0x40A4, iwl9462_2ac_cfg_shared_clk)}, 694 {IWL_PCI_DEVICE(0x31DC, 0x40A4, iwl9462_2ac_cfg_shared_clk)},
692 {IWL_PCI_DEVICE(0x31DC, 0x4234, iwl9560_2ac_cfg_shared_clk)}, 695 {IWL_PCI_DEVICE(0x31DC, 0x4234, iwl9560_2ac_cfg_shared_clk)},
693 {IWL_PCI_DEVICE(0x31DC, 0x42A4, iwl9462_2ac_cfg_shared_clk)}, 696 {IWL_PCI_DEVICE(0x31DC, 0x42A4, iwl9462_2ac_cfg_shared_clk)},
694 697
695 {IWL_PCI_DEVICE(0x34F0, 0x0030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 698 {IWL_PCI_DEVICE(0x34F0, 0x0030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
696 {IWL_PCI_DEVICE(0x34F0, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 699 {IWL_PCI_DEVICE(0x34F0, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)},
697 {IWL_PCI_DEVICE(0x34F0, 0x0038, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 700 {IWL_PCI_DEVICE(0x34F0, 0x0038, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
698 {IWL_PCI_DEVICE(0x34F0, 0x003C, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 701 {IWL_PCI_DEVICE(0x34F0, 0x003C, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
699 {IWL_PCI_DEVICE(0x34F0, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 702 {IWL_PCI_DEVICE(0x34F0, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)},
700 {IWL_PCI_DEVICE(0x34F0, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 703 {IWL_PCI_DEVICE(0x34F0, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)},
701 {IWL_PCI_DEVICE(0x34F0, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 704 {IWL_PCI_DEVICE(0x34F0, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)},
@@ -710,18 +713,18 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
710 {IWL_PCI_DEVICE(0x34F0, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 713 {IWL_PCI_DEVICE(0x34F0, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
711 {IWL_PCI_DEVICE(0x34F0, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)}, 714 {IWL_PCI_DEVICE(0x34F0, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)},
712 {IWL_PCI_DEVICE(0x34F0, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)}, 715 {IWL_PCI_DEVICE(0x34F0, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)},
713 {IWL_PCI_DEVICE(0x34F0, 0x2030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 716 {IWL_PCI_DEVICE(0x34F0, 0x2030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
714 {IWL_PCI_DEVICE(0x34F0, 0x2034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 717 {IWL_PCI_DEVICE(0x34F0, 0x2034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
715 {IWL_PCI_DEVICE(0x34F0, 0x4030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 718 {IWL_PCI_DEVICE(0x34F0, 0x4030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
716 {IWL_PCI_DEVICE(0x34F0, 0x4034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 719 {IWL_PCI_DEVICE(0x34F0, 0x4034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
717 {IWL_PCI_DEVICE(0x34F0, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 720 {IWL_PCI_DEVICE(0x34F0, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
718 {IWL_PCI_DEVICE(0x34F0, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 721 {IWL_PCI_DEVICE(0x34F0, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)},
719 {IWL_PCI_DEVICE(0x34F0, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 722 {IWL_PCI_DEVICE(0x34F0, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
720 723
721 {IWL_PCI_DEVICE(0x3DF0, 0x0030, iwl9560_2ac_cfg_soc)}, 724 {IWL_PCI_DEVICE(0x3DF0, 0x0030, iwl9560_2ac_160_cfg_soc)},
722 {IWL_PCI_DEVICE(0x3DF0, 0x0034, iwl9560_2ac_cfg_soc)}, 725 {IWL_PCI_DEVICE(0x3DF0, 0x0034, iwl9560_2ac_cfg_soc)},
723 {IWL_PCI_DEVICE(0x3DF0, 0x0038, iwl9560_2ac_cfg_soc)}, 726 {IWL_PCI_DEVICE(0x3DF0, 0x0038, iwl9560_2ac_160_cfg_soc)},
724 {IWL_PCI_DEVICE(0x3DF0, 0x003C, iwl9560_2ac_cfg_soc)}, 727 {IWL_PCI_DEVICE(0x3DF0, 0x003C, iwl9560_2ac_160_cfg_soc)},
725 {IWL_PCI_DEVICE(0x3DF0, 0x0060, iwl9461_2ac_cfg_soc)}, 728 {IWL_PCI_DEVICE(0x3DF0, 0x0060, iwl9461_2ac_cfg_soc)},
726 {IWL_PCI_DEVICE(0x3DF0, 0x0064, iwl9461_2ac_cfg_soc)}, 729 {IWL_PCI_DEVICE(0x3DF0, 0x0064, iwl9461_2ac_cfg_soc)},
727 {IWL_PCI_DEVICE(0x3DF0, 0x00A0, iwl9462_2ac_cfg_soc)}, 730 {IWL_PCI_DEVICE(0x3DF0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -739,17 +742,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
739 {IWL_PCI_DEVICE(0x3DF0, 0x1210, iwl9260_2ac_cfg)}, 742 {IWL_PCI_DEVICE(0x3DF0, 0x1210, iwl9260_2ac_cfg)},
740 {IWL_PCI_DEVICE(0x3DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 743 {IWL_PCI_DEVICE(0x3DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
741 {IWL_PCI_DEVICE(0x3DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 744 {IWL_PCI_DEVICE(0x3DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
742 {IWL_PCI_DEVICE(0x3DF0, 0x2030, iwl9560_2ac_cfg_soc)}, 745 {IWL_PCI_DEVICE(0x3DF0, 0x2030, iwl9560_2ac_160_cfg_soc)},
743 {IWL_PCI_DEVICE(0x3DF0, 0x2034, iwl9560_2ac_cfg_soc)}, 746 {IWL_PCI_DEVICE(0x3DF0, 0x2034, iwl9560_2ac_160_cfg_soc)},
744 {IWL_PCI_DEVICE(0x3DF0, 0x4030, iwl9560_2ac_cfg_soc)}, 747 {IWL_PCI_DEVICE(0x3DF0, 0x4030, iwl9560_2ac_160_cfg_soc)},
745 {IWL_PCI_DEVICE(0x3DF0, 0x4034, iwl9560_2ac_cfg_soc)}, 748 {IWL_PCI_DEVICE(0x3DF0, 0x4034, iwl9560_2ac_160_cfg_soc)},
746 {IWL_PCI_DEVICE(0x3DF0, 0x40A4, iwl9462_2ac_cfg_soc)}, 749 {IWL_PCI_DEVICE(0x3DF0, 0x40A4, iwl9462_2ac_cfg_soc)},
747 {IWL_PCI_DEVICE(0x3DF0, 0x4234, iwl9560_2ac_cfg_soc)}, 750 {IWL_PCI_DEVICE(0x3DF0, 0x4234, iwl9560_2ac_cfg_soc)},
748 {IWL_PCI_DEVICE(0x3DF0, 0x42A4, iwl9462_2ac_cfg_soc)}, 751 {IWL_PCI_DEVICE(0x3DF0, 0x42A4, iwl9462_2ac_cfg_soc)},
749 {IWL_PCI_DEVICE(0x43F0, 0x0030, iwl9560_2ac_cfg_soc)}, 752 {IWL_PCI_DEVICE(0x43F0, 0x0030, iwl9560_2ac_160_cfg_soc)},
750 {IWL_PCI_DEVICE(0x43F0, 0x0034, iwl9560_2ac_cfg_soc)}, 753 {IWL_PCI_DEVICE(0x43F0, 0x0034, iwl9560_2ac_cfg_soc)},
751 {IWL_PCI_DEVICE(0x43F0, 0x0038, iwl9560_2ac_cfg_soc)}, 754 {IWL_PCI_DEVICE(0x43F0, 0x0038, iwl9560_2ac_160_cfg_soc)},
752 {IWL_PCI_DEVICE(0x43F0, 0x003C, iwl9560_2ac_cfg_soc)}, 755 {IWL_PCI_DEVICE(0x43F0, 0x003C, iwl9560_2ac_160_cfg_soc)},
753 {IWL_PCI_DEVICE(0x43F0, 0x0060, iwl9461_2ac_cfg_soc)}, 756 {IWL_PCI_DEVICE(0x43F0, 0x0060, iwl9461_2ac_cfg_soc)},
754 {IWL_PCI_DEVICE(0x43F0, 0x0064, iwl9461_2ac_cfg_soc)}, 757 {IWL_PCI_DEVICE(0x43F0, 0x0064, iwl9461_2ac_cfg_soc)},
755 {IWL_PCI_DEVICE(0x43F0, 0x00A0, iwl9462_2ac_cfg_soc)}, 758 {IWL_PCI_DEVICE(0x43F0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -767,19 +770,19 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
767 {IWL_PCI_DEVICE(0x43F0, 0x1210, iwl9260_2ac_cfg)}, 770 {IWL_PCI_DEVICE(0x43F0, 0x1210, iwl9260_2ac_cfg)},
768 {IWL_PCI_DEVICE(0x43F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 771 {IWL_PCI_DEVICE(0x43F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
769 {IWL_PCI_DEVICE(0x43F0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 772 {IWL_PCI_DEVICE(0x43F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
770 {IWL_PCI_DEVICE(0x43F0, 0x2030, iwl9560_2ac_cfg_soc)}, 773 {IWL_PCI_DEVICE(0x43F0, 0x2030, iwl9560_2ac_160_cfg_soc)},
771 {IWL_PCI_DEVICE(0x43F0, 0x2034, iwl9560_2ac_cfg_soc)}, 774 {IWL_PCI_DEVICE(0x43F0, 0x2034, iwl9560_2ac_160_cfg_soc)},
772 {IWL_PCI_DEVICE(0x43F0, 0x4030, iwl9560_2ac_cfg_soc)}, 775 {IWL_PCI_DEVICE(0x43F0, 0x4030, iwl9560_2ac_160_cfg_soc)},
773 {IWL_PCI_DEVICE(0x43F0, 0x4034, iwl9560_2ac_cfg_soc)}, 776 {IWL_PCI_DEVICE(0x43F0, 0x4034, iwl9560_2ac_160_cfg_soc)},
774 {IWL_PCI_DEVICE(0x43F0, 0x40A4, iwl9462_2ac_cfg_soc)}, 777 {IWL_PCI_DEVICE(0x43F0, 0x40A4, iwl9462_2ac_cfg_soc)},
775 {IWL_PCI_DEVICE(0x43F0, 0x4234, iwl9560_2ac_cfg_soc)}, 778 {IWL_PCI_DEVICE(0x43F0, 0x4234, iwl9560_2ac_cfg_soc)},
776 {IWL_PCI_DEVICE(0x43F0, 0x42A4, iwl9462_2ac_cfg_soc)}, 779 {IWL_PCI_DEVICE(0x43F0, 0x42A4, iwl9462_2ac_cfg_soc)},
777 {IWL_PCI_DEVICE(0x9DF0, 0x0000, iwl9460_2ac_cfg_soc)}, 780 {IWL_PCI_DEVICE(0x9DF0, 0x0000, iwl9460_2ac_cfg_soc)},
778 {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg_soc)}, 781 {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg_soc)},
779 {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg_soc)}, 782 {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_160_cfg_soc)},
780 {IWL_PCI_DEVICE(0x9DF0, 0x0034, iwl9560_2ac_cfg_soc)}, 783 {IWL_PCI_DEVICE(0x9DF0, 0x0034, iwl9560_2ac_cfg_soc)},
781 {IWL_PCI_DEVICE(0x9DF0, 0x0038, iwl9560_2ac_cfg_soc)}, 784 {IWL_PCI_DEVICE(0x9DF0, 0x0038, iwl9560_2ac_160_cfg_soc)},
782 {IWL_PCI_DEVICE(0x9DF0, 0x003C, iwl9560_2ac_cfg_soc)}, 785 {IWL_PCI_DEVICE(0x9DF0, 0x003C, iwl9560_2ac_160_cfg_soc)},
783 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg_soc)}, 786 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg_soc)},
784 {IWL_PCI_DEVICE(0x9DF0, 0x0064, iwl9461_2ac_cfg_soc)}, 787 {IWL_PCI_DEVICE(0x9DF0, 0x0064, iwl9461_2ac_cfg_soc)},
785 {IWL_PCI_DEVICE(0x9DF0, 0x00A0, iwl9462_2ac_cfg_soc)}, 788 {IWL_PCI_DEVICE(0x9DF0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -805,18 +808,18 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
805 {IWL_PCI_DEVICE(0x9DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 808 {IWL_PCI_DEVICE(0x9DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
806 {IWL_PCI_DEVICE(0x9DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 809 {IWL_PCI_DEVICE(0x9DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
807 {IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl9460_2ac_cfg_soc)}, 810 {IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl9460_2ac_cfg_soc)},
808 {IWL_PCI_DEVICE(0x9DF0, 0x2030, iwl9560_2ac_cfg_soc)}, 811 {IWL_PCI_DEVICE(0x9DF0, 0x2030, iwl9560_2ac_160_cfg_soc)},
809 {IWL_PCI_DEVICE(0x9DF0, 0x2034, iwl9560_2ac_cfg_soc)}, 812 {IWL_PCI_DEVICE(0x9DF0, 0x2034, iwl9560_2ac_160_cfg_soc)},
810 {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg_soc)}, 813 {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg_soc)},
811 {IWL_PCI_DEVICE(0x9DF0, 0x4030, iwl9560_2ac_cfg_soc)}, 814 {IWL_PCI_DEVICE(0x9DF0, 0x4030, iwl9560_2ac_160_cfg_soc)},
812 {IWL_PCI_DEVICE(0x9DF0, 0x4034, iwl9560_2ac_cfg_soc)}, 815 {IWL_PCI_DEVICE(0x9DF0, 0x4034, iwl9560_2ac_160_cfg_soc)},
813 {IWL_PCI_DEVICE(0x9DF0, 0x40A4, iwl9462_2ac_cfg_soc)}, 816 {IWL_PCI_DEVICE(0x9DF0, 0x40A4, iwl9462_2ac_cfg_soc)},
814 {IWL_PCI_DEVICE(0x9DF0, 0x4234, iwl9560_2ac_cfg_soc)}, 817 {IWL_PCI_DEVICE(0x9DF0, 0x4234, iwl9560_2ac_cfg_soc)},
815 {IWL_PCI_DEVICE(0x9DF0, 0x42A4, iwl9462_2ac_cfg_soc)}, 818 {IWL_PCI_DEVICE(0x9DF0, 0x42A4, iwl9462_2ac_cfg_soc)},
816 {IWL_PCI_DEVICE(0xA0F0, 0x0030, iwl9560_2ac_cfg_soc)}, 819 {IWL_PCI_DEVICE(0xA0F0, 0x0030, iwl9560_2ac_160_cfg_soc)},
817 {IWL_PCI_DEVICE(0xA0F0, 0x0034, iwl9560_2ac_cfg_soc)}, 820 {IWL_PCI_DEVICE(0xA0F0, 0x0034, iwl9560_2ac_cfg_soc)},
818 {IWL_PCI_DEVICE(0xA0F0, 0x0038, iwl9560_2ac_cfg_soc)}, 821 {IWL_PCI_DEVICE(0xA0F0, 0x0038, iwl9560_2ac_160_cfg_soc)},
819 {IWL_PCI_DEVICE(0xA0F0, 0x003C, iwl9560_2ac_cfg_soc)}, 822 {IWL_PCI_DEVICE(0xA0F0, 0x003C, iwl9560_2ac_160_cfg_soc)},
820 {IWL_PCI_DEVICE(0xA0F0, 0x0060, iwl9461_2ac_cfg_soc)}, 823 {IWL_PCI_DEVICE(0xA0F0, 0x0060, iwl9461_2ac_cfg_soc)},
821 {IWL_PCI_DEVICE(0xA0F0, 0x0064, iwl9461_2ac_cfg_soc)}, 824 {IWL_PCI_DEVICE(0xA0F0, 0x0064, iwl9461_2ac_cfg_soc)},
822 {IWL_PCI_DEVICE(0xA0F0, 0x00A0, iwl9462_2ac_cfg_soc)}, 825 {IWL_PCI_DEVICE(0xA0F0, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -834,17 +837,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
834 {IWL_PCI_DEVICE(0xA0F0, 0x1210, iwl9260_2ac_cfg)}, 837 {IWL_PCI_DEVICE(0xA0F0, 0x1210, iwl9260_2ac_cfg)},
835 {IWL_PCI_DEVICE(0xA0F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 838 {IWL_PCI_DEVICE(0xA0F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
836 {IWL_PCI_DEVICE(0xA0F0, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 839 {IWL_PCI_DEVICE(0xA0F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
837 {IWL_PCI_DEVICE(0xA0F0, 0x2030, iwl9560_2ac_cfg_soc)}, 840 {IWL_PCI_DEVICE(0xA0F0, 0x2030, iwl9560_2ac_160_cfg_soc)},
838 {IWL_PCI_DEVICE(0xA0F0, 0x2034, iwl9560_2ac_cfg_soc)}, 841 {IWL_PCI_DEVICE(0xA0F0, 0x2034, iwl9560_2ac_160_cfg_soc)},
839 {IWL_PCI_DEVICE(0xA0F0, 0x4030, iwl9560_2ac_cfg_soc)}, 842 {IWL_PCI_DEVICE(0xA0F0, 0x4030, iwl9560_2ac_160_cfg_soc)},
840 {IWL_PCI_DEVICE(0xA0F0, 0x4034, iwl9560_2ac_cfg_soc)}, 843 {IWL_PCI_DEVICE(0xA0F0, 0x4034, iwl9560_2ac_160_cfg_soc)},
841 {IWL_PCI_DEVICE(0xA0F0, 0x40A4, iwl9462_2ac_cfg_soc)}, 844 {IWL_PCI_DEVICE(0xA0F0, 0x40A4, iwl9462_2ac_cfg_soc)},
842 {IWL_PCI_DEVICE(0xA0F0, 0x4234, iwl9560_2ac_cfg_soc)}, 845 {IWL_PCI_DEVICE(0xA0F0, 0x4234, iwl9560_2ac_cfg_soc)},
843 {IWL_PCI_DEVICE(0xA0F0, 0x42A4, iwl9462_2ac_cfg_soc)}, 846 {IWL_PCI_DEVICE(0xA0F0, 0x42A4, iwl9462_2ac_cfg_soc)},
844 {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg_soc)}, 847 {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_160_cfg_soc)},
845 {IWL_PCI_DEVICE(0xA370, 0x0034, iwl9560_2ac_cfg_soc)}, 848 {IWL_PCI_DEVICE(0xA370, 0x0034, iwl9560_2ac_cfg_soc)},
846 {IWL_PCI_DEVICE(0xA370, 0x0038, iwl9560_2ac_cfg_soc)}, 849 {IWL_PCI_DEVICE(0xA370, 0x0038, iwl9560_2ac_160_cfg_soc)},
847 {IWL_PCI_DEVICE(0xA370, 0x003C, iwl9560_2ac_cfg_soc)}, 850 {IWL_PCI_DEVICE(0xA370, 0x003C, iwl9560_2ac_160_cfg_soc)},
848 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg_soc)}, 851 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg_soc)},
849 {IWL_PCI_DEVICE(0xA370, 0x0064, iwl9461_2ac_cfg_soc)}, 852 {IWL_PCI_DEVICE(0xA370, 0x0064, iwl9461_2ac_cfg_soc)},
850 {IWL_PCI_DEVICE(0xA370, 0x00A0, iwl9462_2ac_cfg_soc)}, 853 {IWL_PCI_DEVICE(0xA370, 0x00A0, iwl9462_2ac_cfg_soc)},
@@ -862,41 +865,88 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
862 {IWL_PCI_DEVICE(0xA370, 0x1210, iwl9260_2ac_cfg)}, 865 {IWL_PCI_DEVICE(0xA370, 0x1210, iwl9260_2ac_cfg)},
863 {IWL_PCI_DEVICE(0xA370, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 866 {IWL_PCI_DEVICE(0xA370, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
864 {IWL_PCI_DEVICE(0xA370, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 867 {IWL_PCI_DEVICE(0xA370, 0x1552, iwl9560_killer_2ac_cfg_soc)},
865 {IWL_PCI_DEVICE(0xA370, 0x2030, iwl9560_2ac_cfg_soc)}, 868 {IWL_PCI_DEVICE(0xA370, 0x2030, iwl9560_2ac_160_cfg_soc)},
866 {IWL_PCI_DEVICE(0xA370, 0x2034, iwl9560_2ac_cfg_soc)}, 869 {IWL_PCI_DEVICE(0xA370, 0x2034, iwl9560_2ac_160_cfg_soc)},
867 {IWL_PCI_DEVICE(0xA370, 0x4030, iwl9560_2ac_cfg_soc)}, 870 {IWL_PCI_DEVICE(0xA370, 0x4030, iwl9560_2ac_160_cfg_soc)},
868 {IWL_PCI_DEVICE(0xA370, 0x4034, iwl9560_2ac_cfg_soc)}, 871 {IWL_PCI_DEVICE(0xA370, 0x4034, iwl9560_2ac_160_cfg_soc)},
869 {IWL_PCI_DEVICE(0xA370, 0x40A4, iwl9462_2ac_cfg_soc)}, 872 {IWL_PCI_DEVICE(0xA370, 0x40A4, iwl9462_2ac_cfg_soc)},
870 {IWL_PCI_DEVICE(0xA370, 0x4234, iwl9560_2ac_cfg_soc)}, 873 {IWL_PCI_DEVICE(0xA370, 0x4234, iwl9560_2ac_cfg_soc)},
871 {IWL_PCI_DEVICE(0xA370, 0x42A4, iwl9462_2ac_cfg_soc)}, 874 {IWL_PCI_DEVICE(0xA370, 0x42A4, iwl9462_2ac_cfg_soc)},
872 875
873/* 22000 Series */ 876/* 22000 Series */
874 {IWL_PCI_DEVICE(0x2720, 0x0000, iwl22000_2ax_cfg_hr)}, 877 {IWL_PCI_DEVICE(0x02F0, 0x0070, iwl22560_2ax_cfg_hr)},
875 {IWL_PCI_DEVICE(0x2720, 0x0040, iwl22000_2ax_cfg_hr)}, 878 {IWL_PCI_DEVICE(0x02F0, 0x0074, iwl22560_2ax_cfg_hr)},
876 {IWL_PCI_DEVICE(0x2720, 0x0078, iwl22000_2ax_cfg_hr)}, 879 {IWL_PCI_DEVICE(0x02F0, 0x0078, iwl22560_2ax_cfg_hr)},
880 {IWL_PCI_DEVICE(0x02F0, 0x007C, iwl22560_2ax_cfg_hr)},
881 {IWL_PCI_DEVICE(0x02F0, 0x0310, iwl22560_2ax_cfg_hr)},
882 {IWL_PCI_DEVICE(0x02F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
883 {IWL_PCI_DEVICE(0x02F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
884 {IWL_PCI_DEVICE(0x02F0, 0x4070, iwl22560_2ax_cfg_hr)},
885 {IWL_PCI_DEVICE(0x06F0, 0x0070, iwl22560_2ax_cfg_hr)},
886 {IWL_PCI_DEVICE(0x06F0, 0x0074, iwl22560_2ax_cfg_hr)},
887 {IWL_PCI_DEVICE(0x06F0, 0x0078, iwl22560_2ax_cfg_hr)},
888 {IWL_PCI_DEVICE(0x06F0, 0x007C, iwl22560_2ax_cfg_hr)},
889 {IWL_PCI_DEVICE(0x06F0, 0x0310, iwl22560_2ax_cfg_hr)},
890 {IWL_PCI_DEVICE(0x06F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
891 {IWL_PCI_DEVICE(0x06F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
892 {IWL_PCI_DEVICE(0x06F0, 0x4070, iwl22560_2ax_cfg_hr)},
893 {IWL_PCI_DEVICE(0x2720, 0x0000, iwl22560_2ax_cfg_hr)},
894 {IWL_PCI_DEVICE(0x2720, 0x0030, iwl9560_2ac_160_cfg_soc)},
895 {IWL_PCI_DEVICE(0x2720, 0x0040, iwl22560_2ax_cfg_hr)},
877 {IWL_PCI_DEVICE(0x2720, 0x0070, iwl22000_2ac_cfg_hr_cdb)}, 896 {IWL_PCI_DEVICE(0x2720, 0x0070, iwl22000_2ac_cfg_hr_cdb)},
878 {IWL_PCI_DEVICE(0x2720, 0x0030, iwl22000_2ac_cfg_hr_cdb)}, 897 {IWL_PCI_DEVICE(0x2720, 0x0074, iwl22560_2ax_cfg_hr)},
879 {IWL_PCI_DEVICE(0x2720, 0x1080, iwl22000_2ax_cfg_hr)}, 898 {IWL_PCI_DEVICE(0x2720, 0x0078, iwl22560_2ax_cfg_hr)},
899 {IWL_PCI_DEVICE(0x2720, 0x007C, iwl22560_2ax_cfg_hr)},
880 {IWL_PCI_DEVICE(0x2720, 0x0090, iwl22000_2ac_cfg_hr_cdb)}, 900 {IWL_PCI_DEVICE(0x2720, 0x0090, iwl22000_2ac_cfg_hr_cdb)},
881 {IWL_PCI_DEVICE(0x2720, 0x0310, iwl22000_2ac_cfg_hr_cdb)}, 901 {IWL_PCI_DEVICE(0x2720, 0x0310, iwl22000_2ac_cfg_hr_cdb)},
882 {IWL_PCI_DEVICE(0x34F0, 0x0040, iwl22000_2ax_cfg_hr)}, 902 {IWL_PCI_DEVICE(0x2720, 0x0A10, iwl22000_2ac_cfg_hr_cdb)},
883 {IWL_PCI_DEVICE(0x34F0, 0x0070, iwl22000_2ax_cfg_hr)}, 903 {IWL_PCI_DEVICE(0x2720, 0x1080, iwl22560_2ax_cfg_hr)},
884 {IWL_PCI_DEVICE(0x34F0, 0x0078, iwl22000_2ax_cfg_hr)}, 904 {IWL_PCI_DEVICE(0x2720, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
885 {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22000_2ax_cfg_hr)}, 905 {IWL_PCI_DEVICE(0x2720, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
906 {IWL_PCI_DEVICE(0x2720, 0x4070, iwl22560_2ax_cfg_hr)},
907 {IWL_PCI_DEVICE(0x34F0, 0x0040, iwl22560_2ax_cfg_hr)},
908 {IWL_PCI_DEVICE(0x34F0, 0x0070, iwl22560_2ax_cfg_hr)},
909 {IWL_PCI_DEVICE(0x34F0, 0x0074, iwl22560_2ax_cfg_hr)},
910 {IWL_PCI_DEVICE(0x34F0, 0x0078, iwl22560_2ax_cfg_hr)},
911 {IWL_PCI_DEVICE(0x34F0, 0x007C, iwl22560_2ax_cfg_hr)},
912 {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22560_2ax_cfg_hr)},
913 {IWL_PCI_DEVICE(0x34F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
914 {IWL_PCI_DEVICE(0x34F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
915 {IWL_PCI_DEVICE(0x34F0, 0x4070, iwl22560_2ax_cfg_hr)},
886 {IWL_PCI_DEVICE(0x40C0, 0x0000, iwl22560_2ax_cfg_su_cdb)}, 916 {IWL_PCI_DEVICE(0x40C0, 0x0000, iwl22560_2ax_cfg_su_cdb)},
887 {IWL_PCI_DEVICE(0x40C0, 0x0010, iwl22560_2ax_cfg_su_cdb)}, 917 {IWL_PCI_DEVICE(0x40C0, 0x0010, iwl22560_2ax_cfg_su_cdb)},
888 {IWL_PCI_DEVICE(0x40c0, 0x0090, iwl22560_2ax_cfg_su_cdb)}, 918 {IWL_PCI_DEVICE(0x40c0, 0x0090, iwl22560_2ax_cfg_su_cdb)},
889 {IWL_PCI_DEVICE(0x40C0, 0x0310, iwl22560_2ax_cfg_su_cdb)}, 919 {IWL_PCI_DEVICE(0x40C0, 0x0310, iwl22560_2ax_cfg_su_cdb)},
890 {IWL_PCI_DEVICE(0x40C0, 0x0A10, iwl22560_2ax_cfg_su_cdb)}, 920 {IWL_PCI_DEVICE(0x40C0, 0x0A10, iwl22560_2ax_cfg_su_cdb)},
891 {IWL_PCI_DEVICE(0x43F0, 0x0040, iwl22000_2ax_cfg_hr)}, 921 {IWL_PCI_DEVICE(0x43F0, 0x0040, iwl22560_2ax_cfg_hr)},
892 {IWL_PCI_DEVICE(0x43F0, 0x0070, iwl22000_2ax_cfg_hr)}, 922 {IWL_PCI_DEVICE(0x43F0, 0x0070, iwl22560_2ax_cfg_hr)},
893 {IWL_PCI_DEVICE(0x43F0, 0x0078, iwl22000_2ax_cfg_hr)}, 923 {IWL_PCI_DEVICE(0x43F0, 0x0074, iwl22560_2ax_cfg_hr)},
894 {IWL_PCI_DEVICE(0xA0F0, 0x0000, iwl22000_2ax_cfg_hr)}, 924 {IWL_PCI_DEVICE(0x43F0, 0x0078, iwl22560_2ax_cfg_hr)},
895 {IWL_PCI_DEVICE(0xA0F0, 0x0040, iwl22000_2ax_cfg_hr)}, 925 {IWL_PCI_DEVICE(0x43F0, 0x007C, iwl22560_2ax_cfg_hr)},
896 {IWL_PCI_DEVICE(0xA0F0, 0x0070, iwl22000_2ax_cfg_hr)}, 926 {IWL_PCI_DEVICE(0x43F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
897 {IWL_PCI_DEVICE(0xA0F0, 0x0078, iwl22000_2ax_cfg_hr)}, 927 {IWL_PCI_DEVICE(0x43F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
898 {IWL_PCI_DEVICE(0xA0F0, 0x00B0, iwl22000_2ax_cfg_hr)}, 928 {IWL_PCI_DEVICE(0x43F0, 0x4070, iwl22560_2ax_cfg_hr)},
899 {IWL_PCI_DEVICE(0xA0F0, 0x0A10, iwl22000_2ax_cfg_hr)}, 929 {IWL_PCI_DEVICE(0xA0F0, 0x0000, iwl22560_2ax_cfg_hr)},
930 {IWL_PCI_DEVICE(0xA0F0, 0x0040, iwl22560_2ax_cfg_hr)},
931 {IWL_PCI_DEVICE(0xA0F0, 0x0070, iwl22560_2ax_cfg_hr)},
932 {IWL_PCI_DEVICE(0xA0F0, 0x0074, iwl22560_2ax_cfg_hr)},
933 {IWL_PCI_DEVICE(0xA0F0, 0x0078, iwl22560_2ax_cfg_hr)},
934 {IWL_PCI_DEVICE(0xA0F0, 0x007C, iwl22560_2ax_cfg_hr)},
935 {IWL_PCI_DEVICE(0xA0F0, 0x00B0, iwl22560_2ax_cfg_hr)},
936 {IWL_PCI_DEVICE(0xA0F0, 0x0A10, iwl22560_2ax_cfg_hr)},
937 {IWL_PCI_DEVICE(0xA0F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0)},
938 {IWL_PCI_DEVICE(0xA0F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
939 {IWL_PCI_DEVICE(0xA0F0, 0x4070, iwl22560_2ax_cfg_hr)},
940
941 {IWL_PCI_DEVICE(0x2723, 0x0080, iwl22260_2ax_cfg)},
942 {IWL_PCI_DEVICE(0x2723, 0x0084, iwl22260_2ax_cfg)},
943 {IWL_PCI_DEVICE(0x2723, 0x0088, iwl22260_2ax_cfg)},
944 {IWL_PCI_DEVICE(0x2723, 0x008C, iwl22260_2ax_cfg)},
945 {IWL_PCI_DEVICE(0x2723, 0x4080, iwl22260_2ax_cfg)},
946 {IWL_PCI_DEVICE(0x2723, 0x4088, iwl22260_2ax_cfg)},
947
948 {IWL_PCI_DEVICE(0x1a56, 0x1653, killer1650w_2ax_cfg)},
949 {IWL_PCI_DEVICE(0x1a56, 0x1654, killer1650x_2ax_cfg)},
900 950
901#endif /* CONFIG_IWLMVM */ 951#endif /* CONFIG_IWLMVM */
902 952
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index d6fc6ce73e0a..0d16bcc3141f 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -1,13 +1,15 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
3 * Copyright(c) 2003 - 2015 Intel Corporation. All rights reserved. 8 * Copyright(c) 2003 - 2015 Intel Corporation. All rights reserved.
4 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
5 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
6 * Copyright(c) 2018 Intel Corporation 11 * Copyright(c) 2018 Intel Corporation
7 * 12 *
8 * Portions of this file are derived from the ipw3945 project, as well
9 * as portions of the ieee80211 subsystem header files.
10 *
11 * This program is free software; you can redistribute it and/or modify it 13 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of version 2 of the GNU General Public License as 14 * under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
@@ -18,12 +20,46 @@
18 * more details. 20 * more details.
19 * 21 *
20 * The full GNU General Public License is included in this distribution in the 22 * The full GNU General Public License is included in this distribution in the
21 * file called LICENSE. 23 * file called COPYING.
22 * 24 *
23 * Contact Information: 25 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com> 26 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 * 28 *
29 * BSD LICENSE
30 *
31 * Copyright(c) 2003 - 2015 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 *
41 * * Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * * Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in
45 * the documentation and/or other materials provided with the
46 * distribution.
47 * * Neither the name Intel Corporation nor the names of its
48 * contributors may be used to endorse or promote products derived
49 * from this software without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *
27 *****************************************************************************/ 63 *****************************************************************************/
28#ifndef __iwl_trans_int_pcie_h__ 64#ifndef __iwl_trans_int_pcie_h__
29#define __iwl_trans_int_pcie_h__ 65#define __iwl_trans_int_pcie_h__
@@ -1029,8 +1065,6 @@ static inline int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans)
1029int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans); 1065int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans);
1030int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans); 1066int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans);
1031 1067
1032void iwl_pcie_enable_rx_wake(struct iwl_trans *trans, bool enable);
1033
1034void iwl_pcie_rx_allocator_work(struct work_struct *data); 1068void iwl_pcie_rx_allocator_work(struct work_struct *data);
1035 1069
1036/* common functions that are used by gen2 transport */ 1070/* common functions that are used by gen2 transport */
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 9e850c25877b..c260d1251b5f 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1,13 +1,15 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
4 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
5 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
6 * Copyright(c) 2018 Intel Corporation 11 * Copyright(c) 2018 Intel Corporation
7 * 12 *
8 * Portions of this file are derived from the ipw3945 project, as well
9 * as portions of the ieee80211 subsystem header files.
10 *
11 * This program is free software; you can redistribute it and/or modify it 13 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of version 2 of the GNU General Public License as 14 * under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
@@ -18,12 +20,46 @@
18 * more details. 20 * more details.
19 * 21 *
20 * The full GNU General Public License is included in this distribution in the 22 * The full GNU General Public License is included in this distribution in the
21 * file called LICENSE. 23 * file called COPYING.
22 * 24 *
23 * Contact Information: 25 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com> 26 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 * 28 *
29 * BSD LICENSE
30 *
31 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 *
41 * * Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * * Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in
45 * the documentation and/or other materials provided with the
46 * distribution.
47 * * Neither the name Intel Corporation nor the names of its
48 * contributors may be used to endorse or promote products derived
49 * from this software without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *
27 *****************************************************************************/ 63 *****************************************************************************/
28#include <linux/sched.h> 64#include <linux/sched.h>
29#include <linux/wait.h> 65#include <linux/wait.h>
@@ -256,6 +292,9 @@ static void iwl_pcie_restock_bd(struct iwl_trans *trans,
256 292
257 bd[rxq->write] = cpu_to_le64(rxb->page_dma | rxb->vid); 293 bd[rxq->write] = cpu_to_le64(rxb->page_dma | rxb->vid);
258 } 294 }
295
296 IWL_DEBUG_RX(trans, "Assigned virtual RB ID %u to queue %d index %d\n",
297 (u32)rxb->vid, rxq->id, rxq->write);
259} 298}
260 299
261/* 300/*
@@ -860,30 +899,6 @@ static void iwl_pcie_rx_hw_init(struct iwl_trans *trans, struct iwl_rxq *rxq)
860 iwl_set_bit(trans, CSR_INT_COALESCING, IWL_HOST_INT_OPER_MODE); 899 iwl_set_bit(trans, CSR_INT_COALESCING, IWL_HOST_INT_OPER_MODE);
861} 900}
862 901
863void iwl_pcie_enable_rx_wake(struct iwl_trans *trans, bool enable)
864{
865 if (trans->cfg->device_family != IWL_DEVICE_FAMILY_9000)
866 return;
867
868 if (CSR_HW_REV_STEP(trans->hw_rev) != SILICON_A_STEP)
869 return;
870
871 if (!trans->cfg->integrated)
872 return;
873
874 /*
875 * Turn on the chicken-bits that cause MAC wakeup for RX-related
876 * values.
877 * This costs some power, but needed for W/A 9000 integrated A-step
878 * bug where shadow registers are not in the retention list and their
879 * value is lost when NIC powers down
880 */
881 iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL,
882 CSR_MAC_SHADOW_REG_CTRL_RX_WAKE);
883 iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTL2,
884 CSR_MAC_SHADOW_REG_CTL2_RX_WAKE);
885}
886
887static void iwl_pcie_rx_mq_hw_init(struct iwl_trans *trans) 902static void iwl_pcie_rx_mq_hw_init(struct iwl_trans *trans)
888{ 903{
889 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 904 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
@@ -971,8 +986,6 @@ static void iwl_pcie_rx_mq_hw_init(struct iwl_trans *trans)
971 986
972 /* Set interrupt coalescing timer to default (2048 usecs) */ 987 /* Set interrupt coalescing timer to default (2048 usecs) */
973 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); 988 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
974
975 iwl_pcie_enable_rx_wake(trans, true);
976} 989}
977 990
978void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq) 991void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq)
@@ -1360,6 +1373,8 @@ static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans,
1360 if (rxb->invalid) 1373 if (rxb->invalid)
1361 goto out_err; 1374 goto out_err;
1362 1375
1376 IWL_DEBUG_RX(trans, "Got virtual RB ID %u\n", (u32)rxb->vid);
1377
1363 if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) 1378 if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
1364 rxb->size = le32_to_cpu(rxq->cd[i].size) & IWL_RX_CD_SIZE; 1379 rxb->size = le32_to_cpu(rxq->cd[i].size) & IWL_RX_CD_SIZE;
1365 1380
@@ -1411,11 +1426,12 @@ restart:
1411 emergency = true; 1426 emergency = true;
1412 } 1427 }
1413 1428
1429 IWL_DEBUG_RX(trans, "Q %d: HW = %d, SW = %d\n", rxq->id, r, i);
1430
1414 rxb = iwl_pcie_get_rxb(trans, rxq, i); 1431 rxb = iwl_pcie_get_rxb(trans, rxq, i);
1415 if (!rxb) 1432 if (!rxb)
1416 goto out; 1433 goto out;
1417 1434
1418 IWL_DEBUG_RX(trans, "Q %d: HW = %d, SW = %d\n", rxq->id, r, i);
1419 iwl_pcie_rx_handle_rb(trans, rxq, rxb, emergency, i); 1435 iwl_pcie_rx_handle_rb(trans, rxq, rxb, emergency, i);
1420 1436
1421 i = (i + 1) & (rxq->queue_size - 1); 1437 i = (i + 1) & (rxq->queue_size - 1);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index f97aea5ffc44..f74281508197 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1530,8 +1530,6 @@ static void iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test,
1530 iwl_clear_bit(trans, CSR_GP_CNTRL, 1530 iwl_clear_bit(trans, CSR_GP_CNTRL,
1531 BIT(trans->cfg->csr->flag_init_done)); 1531 BIT(trans->cfg->csr->flag_init_done));
1532 1532
1533 iwl_pcie_enable_rx_wake(trans, false);
1534
1535 if (reset) { 1533 if (reset) {
1536 /* 1534 /*
1537 * reset TX queues -- some of their registers reset during S3 1535 * reset TX queues -- some of their registers reset during S3
@@ -1558,8 +1556,6 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
1558 return 0; 1556 return 0;
1559 } 1557 }
1560 1558
1561 iwl_pcie_enable_rx_wake(trans, true);
1562
1563 iwl_set_bit(trans, CSR_GP_CNTRL, 1559 iwl_set_bit(trans, CSR_GP_CNTRL,
1564 BIT(trans->cfg->csr->flag_mac_access_req)); 1560 BIT(trans->cfg->csr->flag_mac_access_req));
1565 iwl_set_bit(trans, CSR_GP_CNTRL, 1561 iwl_set_bit(trans, CSR_GP_CNTRL,
@@ -1968,7 +1964,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
1968 struct iwl_trans_pcie_removal *removal = 1964 struct iwl_trans_pcie_removal *removal =
1969 container_of(wk, struct iwl_trans_pcie_removal, work); 1965 container_of(wk, struct iwl_trans_pcie_removal, work);
1970 struct pci_dev *pdev = removal->pdev; 1966 struct pci_dev *pdev = removal->pdev;
1971 char *prop[] = {"EVENT=INACCESSIBLE", NULL}; 1967 static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
1972 1968
1973 dev_err(&pdev->dev, "Device gone - attempting removal\n"); 1969 dev_err(&pdev->dev, "Device gone - attempting removal\n");
1974 kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop); 1970 kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
@@ -3118,7 +3114,7 @@ iwl_trans_pcie_dump_monitor(struct iwl_trans *trans,
3118 return len; 3114 return len;
3119} 3115}
3120 3116
3121static int iwl_trans_get_fw_monitor_len(struct iwl_trans *trans, int *len) 3117static int iwl_trans_get_fw_monitor_len(struct iwl_trans *trans, u32 *len)
3122{ 3118{
3123 if (trans->num_blocks) { 3119 if (trans->num_blocks) {
3124 *len += sizeof(struct iwl_fw_error_dump_data) + 3120 *len += sizeof(struct iwl_fw_error_dump_data) +
@@ -3173,8 +3169,7 @@ static struct iwl_trans_dump_data
3173 struct iwl_txq *cmdq = trans_pcie->txq[trans_pcie->cmd_queue]; 3169 struct iwl_txq *cmdq = trans_pcie->txq[trans_pcie->cmd_queue];
3174 struct iwl_fw_error_dump_txcmd *txcmd; 3170 struct iwl_fw_error_dump_txcmd *txcmd;
3175 struct iwl_trans_dump_data *dump_data; 3171 struct iwl_trans_dump_data *dump_data;
3176 u32 len, num_rbs = 0; 3172 u32 len, num_rbs = 0, monitor_len = 0;
3177 u32 monitor_len;
3178 int i, ptr; 3173 int i, ptr;
3179 bool dump_rbs = test_bit(STATUS_FW_ERROR, &trans->status) && 3174 bool dump_rbs = test_bit(STATUS_FW_ERROR, &trans->status) &&
3180 !trans->cfg->mq_rx_supported && 3175 !trans->cfg->mq_rx_supported &&
@@ -3191,19 +3186,8 @@ static struct iwl_trans_dump_data
3191 cmdq->n_window * (sizeof(*txcmd) + TFD_MAX_PAYLOAD_SIZE); 3186 cmdq->n_window * (sizeof(*txcmd) + TFD_MAX_PAYLOAD_SIZE);
3192 3187
3193 /* FW monitor */ 3188 /* FW monitor */
3194 monitor_len = iwl_trans_get_fw_monitor_len(trans, &len); 3189 if (dump_mask & BIT(IWL_FW_ERROR_DUMP_FW_MONITOR))
3195 3190 monitor_len = iwl_trans_get_fw_monitor_len(trans, &len);
3196 if (dump_mask == BIT(IWL_FW_ERROR_DUMP_FW_MONITOR)) {
3197 dump_data = vzalloc(len);
3198 if (!dump_data)
3199 return NULL;
3200
3201 data = (void *)dump_data->data;
3202 len = iwl_trans_pcie_dump_monitor(trans, &data, monitor_len);
3203 dump_data->len = len;
3204
3205 return dump_data;
3206 }
3207 3191
3208 /* CSR registers */ 3192 /* CSR registers */
3209 if (dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR)) 3193 if (dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR))
@@ -3569,24 +3553,15 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3569 } 3553 }
3570 } 3554 }
3571 3555
3572 /* 3556 IWL_DEBUG_INFO(trans, "HW REV: 0x%0x\n", trans->hw_rev);
3573 * 9000-series integrated A-step has a problem with suspend/resume
3574 * and sometimes even causes the whole platform to get stuck. This
3575 * workaround makes the hardware not go into the problematic state.
3576 */
3577 if (trans->cfg->integrated &&
3578 trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
3579 CSR_HW_REV_STEP(trans->hw_rev) == SILICON_A_STEP)
3580 iwl_set_bit(trans, CSR_HOST_CHICKEN,
3581 CSR_HOST_CHICKEN_PM_IDLE_SRC_DIS_SB_PME);
3582 3557
3583#if IS_ENABLED(CONFIG_IWLMVM) 3558#if IS_ENABLED(CONFIG_IWLMVM)
3584 trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID); 3559 trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID);
3585 3560
3586 if (cfg == &iwl22000_2ax_cfg_hr) { 3561 if (cfg == &iwl22560_2ax_cfg_hr) {
3587 if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3562 if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
3588 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) { 3563 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) {
3589 trans->cfg = &iwl22000_2ax_cfg_hr; 3564 trans->cfg = &iwl22560_2ax_cfg_hr;
3590 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3565 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
3591 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_JF)) { 3566 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_JF)) {
3592 trans->cfg = &iwl22000_2ax_cfg_jf; 3567 trans->cfg = &iwl22000_2ax_cfg_jf;
@@ -3602,7 +3577,9 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3602 goto out_no_pci; 3577 goto out_no_pci;
3603 } 3578 }
3604 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3579 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
3605 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) { 3580 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) &&
3581 (trans->cfg != &iwl22260_2ax_cfg ||
3582 trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0)) {
3606 u32 hw_status; 3583 u32 hw_status;
3607 3584
3608 hw_status = iwl_read_prph(trans, UMAG_GEN_HW_STATUS); 3585 hw_status = iwl_read_prph(trans, UMAG_GEN_HW_STATUS);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index 156ca1b1f621..f3d2e8fe920b 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -214,7 +214,11 @@ static int iwl_pcie_gen2_set_tb(struct iwl_trans *trans,
214{ 214{
215 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 215 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
216 int idx = iwl_pcie_gen2_get_num_tbs(trans, tfd); 216 int idx = iwl_pcie_gen2_get_num_tbs(trans, tfd);
217 struct iwl_tfh_tb *tb = &tfd->tbs[idx]; 217 struct iwl_tfh_tb *tb;
218
219 if (WARN_ON(idx >= IWL_TFH_NUM_TBS))
220 return -EINVAL;
221 tb = &tfd->tbs[idx];
218 222
219 /* Each TFD can point to a maximum max_tbs Tx buffers */ 223 /* Each TFD can point to a maximum max_tbs Tx buffers */
220 if (le16_to_cpu(tfd->num_tbs) >= trans_pcie->max_tbs) { 224 if (le16_to_cpu(tfd->num_tbs) >= trans_pcie->max_tbs) {
@@ -408,7 +412,7 @@ iwl_tfh_tfd *iwl_pcie_gen2_build_tx_amsdu(struct iwl_trans *trans,
408 goto out_err; 412 goto out_err;
409 413
410 /* building the A-MSDU might have changed this data, memcpy it now */ 414 /* building the A-MSDU might have changed this data, memcpy it now */
411 memcpy(&txq->first_tb_bufs[idx], &dev_cmd->hdr, IWL_FIRST_TB_SIZE); 415 memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE);
412 return tfd; 416 return tfd;
413 417
414out_err: 418out_err:
@@ -469,7 +473,7 @@ iwl_tfh_tfd *iwl_pcie_gen2_build_tx(struct iwl_trans *trans,
469 tb_phys = iwl_pcie_get_first_tb_dma(txq, idx); 473 tb_phys = iwl_pcie_get_first_tb_dma(txq, idx);
470 474
471 /* The first TB points to bi-directional DMA data */ 475 /* The first TB points to bi-directional DMA data */
472 memcpy(&txq->first_tb_bufs[idx], &dev_cmd->hdr, IWL_FIRST_TB_SIZE); 476 memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE);
473 477
474 iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); 478 iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE);
475 479
@@ -834,14 +838,14 @@ static int iwl_pcie_gen2_enqueue_hcmd(struct iwl_trans *trans,
834 838
835 /* start the TFD with the minimum copy bytes */ 839 /* start the TFD with the minimum copy bytes */
836 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE); 840 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE);
837 memcpy(&txq->first_tb_bufs[idx], &out_cmd->hdr, tb0_size); 841 memcpy(&txq->first_tb_bufs[idx], out_cmd, tb0_size);
838 iwl_pcie_gen2_set_tb(trans, tfd, iwl_pcie_get_first_tb_dma(txq, idx), 842 iwl_pcie_gen2_set_tb(trans, tfd, iwl_pcie_get_first_tb_dma(txq, idx),
839 tb0_size); 843 tb0_size);
840 844
841 /* map first command fragment, if any remains */ 845 /* map first command fragment, if any remains */
842 if (copy_size > tb0_size) { 846 if (copy_size > tb0_size) {
843 phys_addr = dma_map_single(trans->dev, 847 phys_addr = dma_map_single(trans->dev,
844 ((u8 *)&out_cmd->hdr) + tb0_size, 848 (u8 *)out_cmd + tb0_size,
845 copy_size - tb0_size, 849 copy_size - tb0_size,
846 DMA_TO_DEVICE); 850 DMA_TO_DEVICE);
847 if (dma_mapping_error(trans->dev, phys_addr)) { 851 if (dma_mapping_error(trans->dev, phys_addr)) {
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index ee990a7a5411..07395502f419 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -1,13 +1,15 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
4 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
5 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
6 * Copyright(c) 2018 Intel Corporation 11 * Copyright(c) 2018 Intel Corporation
7 * 12 *
8 * Portions of this file are derived from the ipw3945 project, as well
9 * as portions of the ieee80211 subsystem header files.
10 *
11 * This program is free software; you can redistribute it and/or modify it 13 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of version 2 of the GNU General Public License as 14 * under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
@@ -18,12 +20,46 @@
18 * more details. 20 * more details.
19 * 21 *
20 * The full GNU General Public License is included in this distribution in the 22 * The full GNU General Public License is included in this distribution in the
21 * file called LICENSE. 23 * file called COPYING.
22 * 24 *
23 * Contact Information: 25 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com> 26 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 * 28 *
29 * BSD LICENSE
30 *
31 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 *
41 * * Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * * Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in
45 * the documentation and/or other materials provided with the
46 * distribution.
47 * * Neither the name Intel Corporation nor the names of its
48 * contributors may be used to endorse or promote products derived
49 * from this software without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *
27 *****************************************************************************/ 63 *****************************************************************************/
28#include <linux/etherdevice.h> 64#include <linux/etherdevice.h>
29#include <linux/ieee80211.h> 65#include <linux/ieee80211.h>
@@ -2438,8 +2474,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2438 } 2474 }
2439 2475
2440 /* building the A-MSDU might have changed this data, so memcpy it now */ 2476 /* building the A-MSDU might have changed this data, so memcpy it now */
2441 memcpy(&txq->first_tb_bufs[txq->write_ptr], &dev_cmd->hdr, 2477 memcpy(&txq->first_tb_bufs[txq->write_ptr], dev_cmd, IWL_FIRST_TB_SIZE);
2442 IWL_FIRST_TB_SIZE);
2443 2478
2444 tfd = iwl_pcie_get_tfd(trans, txq, txq->write_ptr); 2479 tfd = iwl_pcie_get_tfd(trans, txq, txq->write_ptr);
2445 /* Set up entry for this TFD in Tx byte-count array */ 2480 /* Set up entry for this TFD in Tx byte-count array */
diff --git a/drivers/net/wireless/marvell/libertas/debugfs.c b/drivers/net/wireless/marvell/libertas/debugfs.c
index c83f44f9ddf1..fe14814af300 100644
--- a/drivers/net/wireless/marvell/libertas/debugfs.c
+++ b/drivers/net/wireless/marvell/libertas/debugfs.c
@@ -708,8 +708,6 @@ void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
708 goto exit; 708 goto exit;
709 709
710 priv->debugfs_dir = debugfs_create_dir(dev->name, lbs_dir); 710 priv->debugfs_dir = debugfs_create_dir(dev->name, lbs_dir);
711 if (!priv->debugfs_dir)
712 goto exit;
713 711
714 for (i=0; i<ARRAY_SIZE(debugfs_files); i++) { 712 for (i=0; i<ARRAY_SIZE(debugfs_files); i++) {
715 files = &debugfs_files[i]; 713 files = &debugfs_files[i];
@@ -721,8 +719,6 @@ void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
721 } 719 }
722 720
723 priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir); 721 priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir);
724 if (!priv->events_dir)
725 goto exit;
726 722
727 for (i=0; i<ARRAY_SIZE(debugfs_events_files); i++) { 723 for (i=0; i<ARRAY_SIZE(debugfs_events_files); i++) {
728 files = &debugfs_events_files[i]; 724 files = &debugfs_events_files[i];
@@ -734,8 +730,6 @@ void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
734 } 730 }
735 731
736 priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir); 732 priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir);
737 if (!priv->regs_dir)
738 goto exit;
739 733
740 for (i=0; i<ARRAY_SIZE(debugfs_regs_files); i++) { 734 for (i=0; i<ARRAY_SIZE(debugfs_regs_files); i++) {
741 files = &debugfs_regs_files[i]; 735 files = &debugfs_regs_files[i];
diff --git a/drivers/net/wireless/marvell/libertas/mesh.c b/drivers/net/wireless/marvell/libertas/mesh.c
index b0cb16ef8d1d..2315fdff56c2 100644
--- a/drivers/net/wireless/marvell/libertas/mesh.c
+++ b/drivers/net/wireless/marvell/libertas/mesh.c
@@ -797,7 +797,12 @@ static void lbs_persist_config_init(struct net_device *dev)
797{ 797{
798 int ret; 798 int ret;
799 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group); 799 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
800 if (ret)
801 pr_err("failed to create boot_opts_group.\n");
802
800 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group); 803 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
804 if (ret)
805 pr_err("failed to create mesh_ie_group.\n");
801} 806}
802 807
803static void lbs_persist_config_remove(struct net_device *dev) 808static void lbs_persist_config_remove(struct net_device *dev)
diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c b/drivers/net/wireless/marvell/libertas_tf/main.c
index 1d45da187b9b..a7cb7d06e5e6 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -676,7 +676,7 @@ int lbtf_remove_card(struct lbtf_private *priv)
676 ieee80211_unregister_hw(hw); 676 ieee80211_unregister_hw(hw);
677 ieee80211_free_hw(hw); 677 ieee80211_free_hw(hw);
678 678
679 lbtf_deb_leave(LBTF_DEB_MAIN); 679 lbtf_deb_leave(LBTF_DEB_MAIN);
680 return 0; 680 return 0;
681} 681}
682EXPORT_SYMBOL_GPL(lbtf_remove_card); 682EXPORT_SYMBOL_GPL(lbtf_remove_card);
diff --git a/drivers/net/wireless/marvell/mwifiex/Kconfig b/drivers/net/wireless/marvell/mwifiex/Kconfig
index 279167ddd293..524fd565cb2a 100644
--- a/drivers/net/wireless/marvell/mwifiex/Kconfig
+++ b/drivers/net/wireless/marvell/mwifiex/Kconfig
@@ -9,7 +9,7 @@ config MWIFIEX
9 mwifiex. 9 mwifiex.
10 10
11config MWIFIEX_SDIO 11config MWIFIEX_SDIO
12 tristate "Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897/SD8997" 12 tristate "Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897/SD8977/SD8997"
13 depends on MWIFIEX && MMC 13 depends on MWIFIEX && MMC
14 select FW_LOADER 14 select FW_LOADER
15 select WANT_DEV_COREDUMP 15 select WANT_DEV_COREDUMP
diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index cbe4493b3266..8ab114cf3467 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -922,9 +922,8 @@ mwifiex_reset_write(struct file *file,
922} 922}
923 923
924#define MWIFIEX_DFS_ADD_FILE(name) do { \ 924#define MWIFIEX_DFS_ADD_FILE(name) do { \
925 if (!debugfs_create_file(#name, 0644, priv->dfs_dev_dir, \ 925 debugfs_create_file(#name, 0644, priv->dfs_dev_dir, priv, \
926 priv, &mwifiex_dfs_##name##_fops)) \ 926 &mwifiex_dfs_##name##_fops); \
927 return; \
928} while (0); 927} while (0);
929 928
930#define MWIFIEX_DFS_FILE_OPS(name) \ 929#define MWIFIEX_DFS_FILE_OPS(name) \
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index d49fbd58afa7..a85648342d15 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -489,6 +489,8 @@ static void mwifiex_sdio_coredump(struct device *dev)
489#define SDIO_DEVICE_ID_MARVELL_8887 (0x9135) 489#define SDIO_DEVICE_ID_MARVELL_8887 (0x9135)
490/* Device ID for SD8801 */ 490/* Device ID for SD8801 */
491#define SDIO_DEVICE_ID_MARVELL_8801 (0x9139) 491#define SDIO_DEVICE_ID_MARVELL_8801 (0x9139)
492/* Device ID for SD8977 */
493#define SDIO_DEVICE_ID_MARVELL_8977 (0x9145)
492/* Device ID for SD8997 */ 494/* Device ID for SD8997 */
493#define SDIO_DEVICE_ID_MARVELL_8997 (0x9141) 495#define SDIO_DEVICE_ID_MARVELL_8997 (0x9141)
494 496
@@ -507,6 +509,8 @@ static const struct sdio_device_id mwifiex_ids[] = {
507 .driver_data = (unsigned long)&mwifiex_sdio_sd8887}, 509 .driver_data = (unsigned long)&mwifiex_sdio_sd8887},
508 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8801), 510 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8801),
509 .driver_data = (unsigned long)&mwifiex_sdio_sd8801}, 511 .driver_data = (unsigned long)&mwifiex_sdio_sd8801},
512 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8977),
513 .driver_data = (unsigned long)&mwifiex_sdio_sd8977},
510 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8997), 514 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8997),
511 .driver_data = (unsigned long)&mwifiex_sdio_sd8997}, 515 .driver_data = (unsigned long)&mwifiex_sdio_sd8997},
512 {}, 516 {},
@@ -2726,4 +2730,5 @@ MODULE_FIRMWARE(SD8787_DEFAULT_FW_NAME);
2726MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME); 2730MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME);
2727MODULE_FIRMWARE(SD8897_DEFAULT_FW_NAME); 2731MODULE_FIRMWARE(SD8897_DEFAULT_FW_NAME);
2728MODULE_FIRMWARE(SD8887_DEFAULT_FW_NAME); 2732MODULE_FIRMWARE(SD8887_DEFAULT_FW_NAME);
2733MODULE_FIRMWARE(SD8977_DEFAULT_FW_NAME);
2729MODULE_FIRMWARE(SD8997_DEFAULT_FW_NAME); 2734MODULE_FIRMWARE(SD8997_DEFAULT_FW_NAME);
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h
index dccf7fd1aef3..912de2cde8d9 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.h
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.h
@@ -36,6 +36,7 @@
36#define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta.bin" 36#define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta.bin"
37#define SD8887_DEFAULT_FW_NAME "mrvl/sd8887_uapsta.bin" 37#define SD8887_DEFAULT_FW_NAME "mrvl/sd8887_uapsta.bin"
38#define SD8801_DEFAULT_FW_NAME "mrvl/sd8801_uapsta.bin" 38#define SD8801_DEFAULT_FW_NAME "mrvl/sd8801_uapsta.bin"
39#define SD8977_DEFAULT_FW_NAME "mrvl/sd8977_uapsta.bin"
39#define SD8997_DEFAULT_FW_NAME "mrvl/sd8997_uapsta.bin" 40#define SD8997_DEFAULT_FW_NAME "mrvl/sd8997_uapsta.bin"
40 41
41#define BLOCK_MODE 1 42#define BLOCK_MODE 1
@@ -371,6 +372,59 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8897 = {
371 0x59, 0x5c, 0x5d}, 372 0x59, 0x5c, 0x5d},
372}; 373};
373 374
375static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8977 = {
376 .start_rd_port = 0,
377 .start_wr_port = 0,
378 .base_0_reg = 0xF8,
379 .base_1_reg = 0xF9,
380 .poll_reg = 0x5C,
381 .host_int_enable = UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK |
382 CMD_PORT_UPLD_INT_MASK | CMD_PORT_DNLD_INT_MASK,
383 .host_int_rsr_reg = 0x4,
384 .host_int_status_reg = 0x0C,
385 .host_int_mask_reg = 0x08,
386 .status_reg_0 = 0xE8,
387 .status_reg_1 = 0xE9,
388 .sdio_int_mask = 0xff,
389 .data_port_mask = 0xffffffff,
390 .io_port_0_reg = 0xE4,
391 .io_port_1_reg = 0xE5,
392 .io_port_2_reg = 0xE6,
393 .max_mp_regs = 196,
394 .rd_bitmap_l = 0x10,
395 .rd_bitmap_u = 0x11,
396 .rd_bitmap_1l = 0x12,
397 .rd_bitmap_1u = 0x13,
398 .wr_bitmap_l = 0x14,
399 .wr_bitmap_u = 0x15,
400 .wr_bitmap_1l = 0x16,
401 .wr_bitmap_1u = 0x17,
402 .rd_len_p0_l = 0x18,
403 .rd_len_p0_u = 0x19,
404 .card_misc_cfg_reg = 0xd8,
405 .card_cfg_2_1_reg = 0xd9,
406 .cmd_rd_len_0 = 0xc0,
407 .cmd_rd_len_1 = 0xc1,
408 .cmd_rd_len_2 = 0xc2,
409 .cmd_rd_len_3 = 0xc3,
410 .cmd_cfg_0 = 0xc4,
411 .cmd_cfg_1 = 0xc5,
412 .cmd_cfg_2 = 0xc6,
413 .cmd_cfg_3 = 0xc7,
414 .fw_dump_host_ready = 0xcc,
415 .fw_dump_ctrl = 0xf0,
416 .fw_dump_start = 0xf1,
417 .fw_dump_end = 0xf8,
418 .func1_dump_reg_start = 0x10,
419 .func1_dump_reg_end = 0x17,
420 .func1_scratch_reg = 0xe8,
421 .func1_spec_reg_num = 13,
422 .func1_spec_reg_table = {0x08, 0x58, 0x5C, 0x5D,
423 0x60, 0x61, 0x62, 0x64,
424 0x65, 0x66, 0x68, 0x69,
425 0x6a},
426};
427
374static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = { 428static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = {
375 .start_rd_port = 0, 429 .start_rd_port = 0,
376 .start_wr_port = 0, 430 .start_wr_port = 0,
@@ -532,6 +586,22 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8897 = {
532 .can_ext_scan = true, 586 .can_ext_scan = true,
533}; 587};
534 588
589static const struct mwifiex_sdio_device mwifiex_sdio_sd8977 = {
590 .firmware = SD8977_DEFAULT_FW_NAME,
591 .reg = &mwifiex_reg_sd8977,
592 .max_ports = 32,
593 .mp_agg_pkt_limit = 16,
594 .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K,
595 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
596 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
597 .supports_sdio_new_mode = true,
598 .has_control_mask = false,
599 .can_dump_fw = true,
600 .fw_dump_enh = true,
601 .can_auto_tdls = false,
602 .can_ext_scan = true,
603};
604
535static const struct mwifiex_sdio_device mwifiex_sdio_sd8997 = { 605static const struct mwifiex_sdio_device mwifiex_sdio_sd8997 = {
536 .firmware = SD8997_DEFAULT_FW_NAME, 606 .firmware = SD8997_DEFAULT_FW_NAME,
537 .reg = &mwifiex_reg_sd8997, 607 .reg = &mwifiex_reg_sd8997,
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index e2ba26378575..e769c8a555dd 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -300,7 +300,7 @@ int mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
300 if (q->queued + (n + 1) / 2 >= q->ndesc - 1) 300 if (q->queued + (n + 1) / 2 >= q->ndesc - 1)
301 goto unmap; 301 goto unmap;
302 302
303 return dev->queue_ops->add_buf(dev, q, buf, n, tx_info, skb, t); 303 return mt76_dma_add_buf(dev, q, buf, n, tx_info, skb, t);
304 304
305unmap: 305unmap:
306 ret = -ENOMEM; 306 ret = -ENOMEM;
@@ -318,7 +318,7 @@ free:
318EXPORT_SYMBOL_GPL(mt76_dma_tx_queue_skb); 318EXPORT_SYMBOL_GPL(mt76_dma_tx_queue_skb);
319 319
320static int 320static int
321mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q, bool napi) 321mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
322{ 322{
323 dma_addr_t addr; 323 dma_addr_t addr;
324 void *buf; 324 void *buf;
@@ -392,7 +392,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
392 392
393 mt76_dma_rx_cleanup(dev, q); 393 mt76_dma_rx_cleanup(dev, q);
394 mt76_dma_sync_idx(dev, q); 394 mt76_dma_sync_idx(dev, q);
395 mt76_dma_rx_fill(dev, q, false); 395 mt76_dma_rx_fill(dev, q);
396} 396}
397 397
398static void 398static void
@@ -417,10 +417,9 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
417static int 417static int
418mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) 418mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
419{ 419{
420 int len, data_len, done = 0;
420 struct sk_buff *skb; 421 struct sk_buff *skb;
421 unsigned char *data; 422 unsigned char *data;
422 int len;
423 int done = 0;
424 bool more; 423 bool more;
425 424
426 while (done < budget) { 425 while (done < budget) {
@@ -430,6 +429,19 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
430 if (!data) 429 if (!data)
431 break; 430 break;
432 431
432 if (q->rx_head)
433 data_len = q->buf_size;
434 else
435 data_len = SKB_WITH_OVERHEAD(q->buf_size);
436
437 if (data_len < len + q->buf_offset) {
438 dev_kfree_skb(q->rx_head);
439 q->rx_head = NULL;
440
441 skb_free_frag(data);
442 continue;
443 }
444
433 if (q->rx_head) { 445 if (q->rx_head) {
434 mt76_add_fragment(dev, q, data, len, more); 446 mt76_add_fragment(dev, q, data, len, more);
435 continue; 447 continue;
@@ -440,12 +452,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
440 skb_free_frag(data); 452 skb_free_frag(data);
441 continue; 453 continue;
442 } 454 }
443
444 skb_reserve(skb, q->buf_offset); 455 skb_reserve(skb, q->buf_offset);
445 if (skb->tail + len > skb->end) {
446 dev_kfree_skb(skb);
447 continue;
448 }
449 456
450 if (q == &dev->q_rx[MT_RXQ_MCU]) { 457 if (q == &dev->q_rx[MT_RXQ_MCU]) {
451 u32 *rxfce = (u32 *) skb->cb; 458 u32 *rxfce = (u32 *) skb->cb;
@@ -463,7 +470,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
463 dev->drv->rx_skb(dev, q - dev->q_rx, skb); 470 dev->drv->rx_skb(dev, q - dev->q_rx, skb);
464 } 471 }
465 472
466 mt76_dma_rx_fill(dev, q, true); 473 mt76_dma_rx_fill(dev, q);
467 return done; 474 return done;
468} 475}
469 476
@@ -504,7 +511,7 @@ mt76_dma_init(struct mt76_dev *dev)
504 for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) { 511 for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
505 netif_napi_add(&dev->napi_dev, &dev->napi[i], mt76_dma_rx_poll, 512 netif_napi_add(&dev->napi_dev, &dev->napi[i], mt76_dma_rx_poll,
506 64); 513 64);
507 mt76_dma_rx_fill(dev, &dev->q_rx[i], false); 514 mt76_dma_rx_fill(dev, &dev->q_rx[i]);
508 skb_queue_head_init(&dev->rx_skb[i]); 515 skb_queue_head_init(&dev->rx_skb[i]);
509 napi_enable(&dev->napi[i]); 516 napi_enable(&dev->napi[i]);
510 } 517 }
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 7b926dfa6b97..ee3b65a14870 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -328,6 +328,7 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
328 ieee80211_hw_set(hw, MFP_CAPABLE); 328 ieee80211_hw_set(hw, MFP_CAPABLE);
329 ieee80211_hw_set(hw, AP_LINK_PS); 329 ieee80211_hw_set(hw, AP_LINK_PS);
330 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); 330 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
331 ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
331 332
332 wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 333 wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
333 334
@@ -547,7 +548,7 @@ mt76_check_ccmp_pn(struct sk_buff *skb)
547} 548}
548 549
549static void 550static void
550mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb) 551mt76_check_sta(struct mt76_dev *dev, struct sk_buff *skb)
551{ 552{
552 struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb; 553 struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
553 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 554 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -566,6 +567,11 @@ mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb)
566 567
567 sta = container_of((void *) wcid, struct ieee80211_sta, drv_priv); 568 sta = container_of((void *) wcid, struct ieee80211_sta, drv_priv);
568 569
570 if (status->signal <= 0)
571 ewma_signal_add(&wcid->rssi, -status->signal);
572
573 wcid->inactive_count = 0;
574
569 if (!test_bit(MT_WCID_FLAG_CHECK_PS, &wcid->flags)) 575 if (!test_bit(MT_WCID_FLAG_CHECK_PS, &wcid->flags))
570 return; 576 return;
571 577
@@ -625,7 +631,7 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
625 __skb_queue_head_init(&frames); 631 __skb_queue_head_init(&frames);
626 632
627 while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) { 633 while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) {
628 mt76_check_ps(dev, skb); 634 mt76_check_sta(dev, skb);
629 mt76_rx_aggr_reorder(skb, &frames); 635 mt76_rx_aggr_reorder(skb, &frames);
630 } 636 }
631 637
@@ -659,6 +665,7 @@ mt76_sta_add(struct mt76_dev *dev, struct ieee80211_vif *vif,
659 mt76_txq_init(dev, sta->txq[i]); 665 mt76_txq_init(dev, sta->txq[i]);
660 } 666 }
661 667
668 ewma_signal_init(&wcid->rssi);
662 rcu_assign_pointer(dev->wcid[wcid->idx], wcid); 669 rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
663 670
664out: 671out:
@@ -709,3 +716,60 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
709 return 0; 716 return 0;
710} 717}
711EXPORT_SYMBOL_GPL(mt76_sta_state); 718EXPORT_SYMBOL_GPL(mt76_sta_state);
719
720int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
721 int *dbm)
722{
723 struct mt76_dev *dev = hw->priv;
724 int n_chains = __sw_hweight8(dev->antenna_mask);
725
726 *dbm = dev->txpower_cur / 2;
727
728 /* convert from per-chain power to combined
729 * output on 2x2 devices
730 */
731 if (n_chains > 1)
732 *dbm += 3;
733
734 return 0;
735}
736EXPORT_SYMBOL_GPL(mt76_get_txpower);
737
738static void
739__mt76_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
740{
741 if (vif->csa_active && ieee80211_csa_is_complete(vif))
742 ieee80211_csa_finish(vif);
743}
744
745void mt76_csa_finish(struct mt76_dev *dev)
746{
747 if (!dev->csa_complete)
748 return;
749
750 ieee80211_iterate_active_interfaces_atomic(dev->hw,
751 IEEE80211_IFACE_ITER_RESUME_ALL,
752 __mt76_csa_finish, dev);
753
754 dev->csa_complete = 0;
755}
756EXPORT_SYMBOL_GPL(mt76_csa_finish);
757
758static void
759__mt76_csa_check(void *priv, u8 *mac, struct ieee80211_vif *vif)
760{
761 struct mt76_dev *dev = priv;
762
763 if (!vif->csa_active)
764 return;
765
766 dev->csa_complete |= ieee80211_csa_is_complete(vif);
767}
768
769void mt76_csa_check(struct mt76_dev *dev)
770{
771 ieee80211_iterate_active_interfaces_atomic(dev->hw,
772 IEEE80211_IFACE_ITER_RESUME_ALL,
773 __mt76_csa_check, dev);
774}
775EXPORT_SYMBOL_GPL(mt76_csa_check);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 5cd508a68609..2bb9db4ed80a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -23,6 +23,7 @@
23#include <linux/skbuff.h> 23#include <linux/skbuff.h>
24#include <linux/leds.h> 24#include <linux/leds.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/average.h>
26#include <net/mac80211.h> 27#include <net/mac80211.h>
27#include "util.h" 28#include "util.h"
28 29
@@ -174,6 +175,8 @@ enum mt76_wcid_flags {
174 175
175#define MT76_N_WCIDS 128 176#define MT76_N_WCIDS 128
176 177
178DECLARE_EWMA(signal, 10, 8);
179
177struct mt76_wcid { 180struct mt76_wcid {
178 struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS]; 181 struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];
179 182
@@ -181,6 +184,9 @@ struct mt76_wcid {
181 184
182 unsigned long flags; 185 unsigned long flags;
183 186
187 struct ewma_signal rssi;
188 int inactive_count;
189
184 u8 idx; 190 u8 idx;
185 u8 hw_key_idx; 191 u8 hw_key_idx;
186 192
@@ -239,7 +245,9 @@ struct mt76_rx_tid {
239#define MT_TX_CB_TXS_FAILED BIT(2) 245#define MT_TX_CB_TXS_FAILED BIT(2)
240 246
241#define MT_PACKET_ID_MASK GENMASK(7, 0) 247#define MT_PACKET_ID_MASK GENMASK(7, 0)
242#define MT_PACKET_ID_NO_ACK MT_PACKET_ID_MASK 248#define MT_PACKET_ID_NO_ACK 0
249#define MT_PACKET_ID_NO_SKB 1
250#define MT_PACKET_ID_FIRST 2
243 251
244#define MT_TX_STATUS_SKB_TIMEOUT HZ 252#define MT_TX_STATUS_SKB_TIMEOUT HZ
245 253
@@ -421,6 +429,7 @@ struct mt76_dev {
421 struct mt76_queue q_tx[__MT_TXQ_MAX]; 429 struct mt76_queue q_tx[__MT_TXQ_MAX];
422 struct mt76_queue q_rx[__MT_RXQ_MAX]; 430 struct mt76_queue q_rx[__MT_RXQ_MAX];
423 const struct mt76_queue_ops *queue_ops; 431 const struct mt76_queue_ops *queue_ops;
432 int tx_dma_idx[4];
424 433
425 wait_queue_head_t tx_wait; 434 wait_queue_head_t tx_wait;
426 struct sk_buff_head status_list; 435 struct sk_buff_head status_list;
@@ -454,6 +463,8 @@ struct mt76_dev {
454 bool led_al; 463 bool led_al;
455 u8 led_pin; 464 u8 led_pin;
456 465
466 u8 csa_complete;
467
457 u32 rxfilter; 468 u32 rxfilter;
458 469
459 union { 470 union {
@@ -488,7 +499,7 @@ struct mt76_rx_status {
488 u8 rate_idx; 499 u8 rate_idx;
489 u8 nss; 500 u8 nss;
490 u8 band; 501 u8 band;
491 u8 signal; 502 s8 signal;
492 u8 chains; 503 u8 chains;
493 s8 chain_signal[IEEE80211_MAX_CHAINS]; 504 s8 chain_signal[IEEE80211_MAX_CHAINS];
494}; 505};
@@ -677,6 +688,14 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
677 688
678struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb); 689struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb);
679 690
691int mt76_get_min_avg_rssi(struct mt76_dev *dev);
692
693int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
694 int *dbm);
695
696void mt76_csa_check(struct mt76_dev *dev);
697void mt76_csa_finish(struct mt76_dev *dev);
698
680/* internal */ 699/* internal */
681void mt76_tx_free(struct mt76_dev *dev); 700void mt76_tx_free(struct mt76_dev *dev);
682struct mt76_txwi_cache *mt76_get_txwi(struct mt76_dev *dev); 701struct mt76_txwi_cache *mt76_get_txwi(struct mt76_dev *dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h
index a1657922758e..0290ba5869a5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h
@@ -88,6 +88,7 @@ static const struct mt76_reg_pair mt76x0_mac_reg_table[] = {
88 { MT_TX_PROT_CFG6, 0xe3f42004 }, 88 { MT_TX_PROT_CFG6, 0xe3f42004 },
89 { MT_TX_PROT_CFG7, 0xe3f42084 }, 89 { MT_TX_PROT_CFG7, 0xe3f42084 },
90 { MT_TX_PROT_CFG8, 0xe3f42104 }, 90 { MT_TX_PROT_CFG8, 0xe3f42104 },
91 { MT_VHT_HT_FBK_CFG1, 0xedcba980 },
91}; 92};
92 93
93static const struct mt76_reg_pair mt76x0_bbp_init_tab[] = { 94static const struct mt76_reg_pair mt76x0_bbp_init_tab[] = {
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index d895b6f3dc44..1472c8699b29 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -99,7 +99,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
99 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update, 99 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
100 .wake_tx_queue = mt76_wake_tx_queue, 100 .wake_tx_queue = mt76_wake_tx_queue,
101 .get_survey = mt76_get_survey, 101 .get_survey = mt76_get_survey,
102 .get_txpower = mt76x02_get_txpower, 102 .get_txpower = mt76_get_txpower,
103 .flush = mt76x0e_flush, 103 .flush = mt76x0e_flush,
104 .set_tim = mt76x0e_set_tim, 104 .set_tim = mt76x0e_set_tim,
105 .release_buffered_frames = mt76_release_buffered_frames, 105 .release_buffered_frames = mt76_release_buffered_frames,
@@ -141,6 +141,15 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
141 mt76_clear(dev, 0x110, BIT(9)); 141 mt76_clear(dev, 0x110, BIT(9));
142 mt76_set(dev, MT_MAX_LEN_CFG, BIT(13)); 142 mt76_set(dev, MT_MAX_LEN_CFG, BIT(13));
143 143
144 mt76_wr(dev, MT_CH_TIME_CFG,
145 MT_CH_TIME_CFG_TIMER_EN |
146 MT_CH_TIME_CFG_TX_AS_BUSY |
147 MT_CH_TIME_CFG_RX_AS_BUSY |
148 MT_CH_TIME_CFG_NAV_AS_BUSY |
149 MT_CH_TIME_CFG_EIFS_AS_BUSY |
150 MT_CH_CCA_RC_EN |
151 FIELD_PREP(MT_CH_TIME_CFG_CH_TIMER_CLR, 1));
152
144 err = mt76x0_register_device(dev); 153 err = mt76x0_register_device(dev);
145 if (err < 0) 154 if (err < 0)
146 return err; 155 return err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 1eb1a802ed20..5a4c6f34267e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -1013,6 +1013,8 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
1013 mt76x0_phy_calibrate(dev, false); 1013 mt76x0_phy_calibrate(dev, false);
1014 mt76x0_phy_set_txpower(dev); 1014 mt76x0_phy_set_txpower(dev);
1015 1015
1016 mt76x02_edcca_init(dev);
1017
1016 ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work, 1018 ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
1017 MT_CALIBRATE_INTERVAL); 1019 MT_CALIBRATE_INTERVAL);
1018 1020
@@ -1075,7 +1077,9 @@ mt76x0_phy_update_channel_gain(struct mt76x02_dev *dev)
1075 u8 gain_delta; 1077 u8 gain_delta;
1076 int low_gain; 1078 int low_gain;
1077 1079
1078 dev->cal.avg_rssi_all = mt76x02_phy_get_min_avg_rssi(dev); 1080 dev->cal.avg_rssi_all = mt76_get_min_avg_rssi(&dev->mt76);
1081 if (!dev->cal.avg_rssi_all)
1082 dev->cal.avg_rssi_all = -75;
1079 1083
1080 low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) + 1084 low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
1081 (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev)); 1085 (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index 0e6b43bb4678..f66e1b2f0980 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -155,7 +155,7 @@ static const struct ieee80211_ops mt76x0u_ops = {
155 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update, 155 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
156 .set_rts_threshold = mt76x02_set_rts_threshold, 156 .set_rts_threshold = mt76x02_set_rts_threshold,
157 .wake_tx_queue = mt76_wake_tx_queue, 157 .wake_tx_queue = mt76_wake_tx_queue,
158 .get_txpower = mt76x02_get_txpower, 158 .get_txpower = mt76_get_txpower,
159}; 159};
160 160
161static int mt76x0u_register_device(struct mt76x02_dev *dev) 161static int mt76x0u_register_device(struct mt76x02_dev *dev)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
index 9d7585029df9..f391d2d21fbc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
@@ -15,6 +15,7 @@
15 */ 15 */
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/firmware.h> 17#include <linux/firmware.h>
18#include <linux/module.h>
18 19
19#include "mt76x0.h" 20#include "mt76x0.h"
20#include "mcu.h" 21#include "mcu.h"
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 6782665049dd..6d96766a6ed3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -15,8 +15,8 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#ifndef __MT76X02_UTIL_H 18#ifndef __MT76x02_H
19#define __MT76X02_UTIL_H 19#define __MT76x02_H
20 20
21#include <linux/kfifo.h> 21#include <linux/kfifo.h>
22 22
@@ -28,6 +28,9 @@
28 28
29#define MT_CALIBRATE_INTERVAL HZ 29#define MT_CALIBRATE_INTERVAL HZ
30 30
31#define MT_WATCHDOG_TIME (HZ / 10)
32#define MT_TX_HANG_TH 10
33
31#define MT_MAX_CHAINS 2 34#define MT_MAX_CHAINS 2
32struct mt76x02_rx_freq_cal { 35struct mt76x02_rx_freq_cal {
33 s8 high_gain[MT_MAX_CHAINS]; 36 s8 high_gain[MT_MAX_CHAINS];
@@ -79,6 +82,7 @@ struct mt76x02_dev {
79 struct tasklet_struct pre_tbtt_tasklet; 82 struct tasklet_struct pre_tbtt_tasklet;
80 struct delayed_work cal_work; 83 struct delayed_work cal_work;
81 struct delayed_work mac_work; 84 struct delayed_work mac_work;
85 struct delayed_work wdt_work;
82 86
83 u32 aggr_stats[32]; 87 u32 aggr_stats[32];
84 88
@@ -89,6 +93,9 @@ struct mt76x02_dev {
89 u8 tbtt_count; 93 u8 tbtt_count;
90 u16 beacon_int; 94 u16 beacon_int;
91 95
96 u32 tx_hang_reset;
97 u8 tx_hang_check;
98
92 struct mt76x02_calibration cal; 99 struct mt76x02_calibration cal;
93 100
94 s8 target_power; 101 s8 target_power;
@@ -101,6 +108,12 @@ struct mt76x02_dev {
101 u8 slottime; 108 u8 slottime;
102 109
103 struct mt76x02_dfs_pattern_detector dfs_pd; 110 struct mt76x02_dfs_pattern_detector dfs_pd;
111
112 /* edcca monitor */
113 bool ed_tx_blocked;
114 bool ed_monitor;
115 u8 ed_trigger;
116 u8 ed_silent;
104}; 117};
105 118
106extern struct ieee80211_rate mt76x02_rates[12]; 119extern struct ieee80211_rate mt76x02_rates[12];
@@ -136,6 +149,7 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76x02_dev *dev,
136 const struct ieee80211_tx_rate *rate); 149 const struct ieee80211_tx_rate *rate);
137s8 mt76x02_tx_get_txpwr_adj(struct mt76x02_dev *dev, s8 txpwr, 150s8 mt76x02_tx_get_txpwr_adj(struct mt76x02_dev *dev, s8 txpwr,
138 s8 max_txpwr_adj); 151 s8 max_txpwr_adj);
152void mt76x02_wdt_work(struct work_struct *work);
139void mt76x02_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr); 153void mt76x02_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr);
140void mt76x02_set_tx_ackto(struct mt76x02_dev *dev); 154void mt76x02_set_tx_ackto(struct mt76x02_dev *dev);
141void mt76x02_set_coverage_class(struct ieee80211_hw *hw, 155void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
@@ -158,8 +172,6 @@ void mt76x02_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
158 const u8 *mac); 172 const u8 *mac);
159void mt76x02_sw_scan_complete(struct ieee80211_hw *hw, 173void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
160 struct ieee80211_vif *vif); 174 struct ieee80211_vif *vif);
161int mt76x02_get_txpower(struct ieee80211_hw *hw,
162 struct ieee80211_vif *vif, int *dbm);
163void mt76x02_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps); 175void mt76x02_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);
164void mt76x02_bss_info_changed(struct ieee80211_hw *hw, 176void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
165 struct ieee80211_vif *vif, 177 struct ieee80211_vif *vif,
@@ -224,4 +236,4 @@ mt76x02_rx_get_sta_wcid(struct mt76x02_sta *sta, bool unicast)
224 return &sta->vif->group_wcid; 236 return &sta->vif->group_wcid;
225} 237}
226 238
227#endif 239#endif /* __MT76x02_H */
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
index a9d52ba1e270..7580c5c986ff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
@@ -133,5 +133,7 @@ void mt76x02_init_debugfs(struct mt76x02_dev *dev)
133 read_txpower); 133 read_txpower);
134 134
135 debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc); 135 debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
136
137 debugfs_create_u32("tx_hang_reset", 0400, dir, &dev->tx_hang_reset);
136} 138}
137EXPORT_SYMBOL_GPL(mt76x02_init_debugfs); 139EXPORT_SYMBOL_GPL(mt76x02_init_debugfs);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c
index 054609c634a2..19fdcab746a0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c
@@ -881,12 +881,18 @@ mt76x02_dfs_set_domain(struct mt76x02_dev *dev,
881{ 881{
882 struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd; 882 struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd;
883 883
884 mutex_lock(&dev->mt76.mutex);
884 if (dfs_pd->region != region) { 885 if (dfs_pd->region != region) {
885 tasklet_disable(&dfs_pd->dfs_tasklet); 886 tasklet_disable(&dfs_pd->dfs_tasklet);
887
888 dev->ed_monitor = region == NL80211_DFS_ETSI;
889 mt76x02_edcca_init(dev);
890
886 dfs_pd->region = region; 891 dfs_pd->region = region;
887 mt76x02_dfs_init_params(dev); 892 mt76x02_dfs_init_params(dev);
888 tasklet_enable(&dfs_pd->dfs_tasklet); 893 tasklet_enable(&dfs_pd->dfs_tasklet);
889 } 894 }
895 mutex_unlock(&dev->mt76.mutex);
890} 896}
891 897
892void mt76x02_regd_notifier(struct wiphy *wiphy, 898void mt76x02_regd_notifier(struct wiphy *wiphy,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
index c08bf371e527..63fa27d2c404 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
@@ -130,10 +130,8 @@ static __le16
130mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev, 130mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev,
131 const struct ieee80211_tx_rate *rate, u8 *nss_val) 131 const struct ieee80211_tx_rate *rate, u8 *nss_val)
132{ 132{
133 u8 phy, rate_idx, nss, bw = 0;
133 u16 rateval; 134 u16 rateval;
134 u8 phy, rate_idx;
135 u8 nss = 1;
136 u8 bw = 0;
137 135
138 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { 136 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
139 rate_idx = rate->idx; 137 rate_idx = rate->idx;
@@ -164,7 +162,7 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev,
164 162
165 phy = val >> 8; 163 phy = val >> 8;
166 rate_idx = val & 0xff; 164 rate_idx = val & 0xff;
167 bw = 0; 165 nss = 1;
168 } 166 }
169 167
170 rateval = FIELD_PREP(MT_RXWI_RATE_INDEX, rate_idx); 168 rateval = FIELD_PREP(MT_RXWI_RATE_INDEX, rate_idx);
@@ -435,7 +433,7 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
435 } 433 }
436 434
437 if (wcid) { 435 if (wcid) {
438 if (stat->pktid) 436 if (stat->pktid >= MT_PACKET_ID_FIRST)
439 status.skb = mt76_tx_status_skb_get(mdev, wcid, 437 status.skb = mt76_tx_status_skb_get(mdev, wcid,
440 stat->pktid, &list); 438 stat->pktid, &list);
441 if (status.skb) 439 if (status.skb)
@@ -478,7 +476,9 @@ out:
478} 476}
479 477
480static int 478static int
481mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate) 479mt76x02_mac_process_rate(struct mt76x02_dev *dev,
480 struct mt76_rx_status *status,
481 u16 rate)
482{ 482{
483 u8 idx = FIELD_GET(MT_RXWI_RATE_INDEX, rate); 483 u8 idx = FIELD_GET(MT_RXWI_RATE_INDEX, rate);
484 484
@@ -510,11 +510,15 @@ mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate)
510 status->encoding = RX_ENC_HT; 510 status->encoding = RX_ENC_HT;
511 status->rate_idx = idx; 511 status->rate_idx = idx;
512 break; 512 break;
513 case MT_PHY_TYPE_VHT: 513 case MT_PHY_TYPE_VHT: {
514 u8 n_rxstream = dev->mt76.chainmask & 0xf;
515
514 status->encoding = RX_ENC_VHT; 516 status->encoding = RX_ENC_VHT;
515 status->rate_idx = FIELD_GET(MT_RATE_INDEX_VHT_IDX, idx); 517 status->rate_idx = FIELD_GET(MT_RATE_INDEX_VHT_IDX, idx);
516 status->nss = FIELD_GET(MT_RATE_INDEX_VHT_NSS, idx) + 1; 518 status->nss = min_t(u8, n_rxstream,
519 FIELD_GET(MT_RATE_INDEX_VHT_NSS, idx) + 1);
517 break; 520 break;
521 }
518 default: 522 default:
519 return -EINVAL; 523 return -EINVAL;
520 } 524 }
@@ -644,7 +648,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
644 648
645 status->chains = BIT(0); 649 status->chains = BIT(0);
646 signal = mt76x02_mac_get_rssi(dev, rxwi->rssi[0], 0); 650 signal = mt76x02_mac_get_rssi(dev, rxwi->rssi[0], 0);
647 for (i = 1; i < nstreams; i++) { 651 for (i = 0; i < nstreams; i++) {
648 status->chains |= BIT(i); 652 status->chains |= BIT(i);
649 status->chain_signal[i] = mt76x02_mac_get_rssi(dev, 653 status->chain_signal[i] = mt76x02_mac_get_rssi(dev,
650 rxwi->rssi[i], 654 rxwi->rssi[i],
@@ -658,12 +662,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
658 status->tid = FIELD_GET(MT_RXWI_TID, tid_sn); 662 status->tid = FIELD_GET(MT_RXWI_TID, tid_sn);
659 status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn); 663 status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn);
660 664
661 if (sta) { 665 return mt76x02_mac_process_rate(dev, status, rate);
662 ewma_signal_add(&sta->rssi, status->signal);
663 sta->inactive_count = 0;
664 }
665
666 return mt76x02_mac_process_rate(status, rate);
667} 666}
668 667
669void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq) 668void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq)
@@ -715,7 +714,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
715} 714}
716EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb); 715EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);
717 716
718void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val) 717void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, u32 val)
719{ 718{
720 u32 data = 0; 719 u32 data = 0;
721 720
@@ -729,20 +728,89 @@ void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val)
729 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 728 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
730 mt76_rmw(dev, MT_OFDM_PROT_CFG, 729 mt76_rmw(dev, MT_OFDM_PROT_CFG,
731 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 730 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
732 mt76_rmw(dev, MT_MM20_PROT_CFG, 731}
733 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 732
734 mt76_rmw(dev, MT_MM40_PROT_CFG, 733void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
735 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 734 int ht_mode)
736 mt76_rmw(dev, MT_GF20_PROT_CFG, 735{
737 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 736 int mode = ht_mode & IEEE80211_HT_OP_MODE_PROTECTION;
738 mt76_rmw(dev, MT_GF40_PROT_CFG, 737 bool non_gf = !!(ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
739 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 738 u32 prot[6];
740 mt76_rmw(dev, MT_TX_PROT_CFG6, 739 u32 vht_prot[3];
741 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 740 int i;
742 mt76_rmw(dev, MT_TX_PROT_CFG7, 741 u16 rts_thr;
743 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 742
744 mt76_rmw(dev, MT_TX_PROT_CFG8, 743 for (i = 0; i < ARRAY_SIZE(prot); i++) {
745 MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data); 744 prot[i] = mt76_rr(dev, MT_CCK_PROT_CFG + i * 4);
745 prot[i] &= ~MT_PROT_CFG_CTRL;
746 if (i >= 2)
747 prot[i] &= ~MT_PROT_CFG_RATE;
748 }
749
750 for (i = 0; i < ARRAY_SIZE(vht_prot); i++) {
751 vht_prot[i] = mt76_rr(dev, MT_TX_PROT_CFG6 + i * 4);
752 vht_prot[i] &= ~(MT_PROT_CFG_CTRL | MT_PROT_CFG_RATE);
753 }
754
755 rts_thr = mt76_get_field(dev, MT_TX_RTS_CFG, MT_TX_RTS_CFG_THRESH);
756
757 if (rts_thr != 0xffff)
758 prot[0] |= MT_PROT_CTRL_RTS_CTS;
759
760 if (legacy_prot) {
761 prot[1] |= MT_PROT_CTRL_CTS2SELF;
762
763 prot[2] |= MT_PROT_RATE_CCK_11;
764 prot[3] |= MT_PROT_RATE_CCK_11;
765 prot[4] |= MT_PROT_RATE_CCK_11;
766 prot[5] |= MT_PROT_RATE_CCK_11;
767
768 vht_prot[0] |= MT_PROT_RATE_CCK_11;
769 vht_prot[1] |= MT_PROT_RATE_CCK_11;
770 vht_prot[2] |= MT_PROT_RATE_CCK_11;
771 } else {
772 if (rts_thr != 0xffff)
773 prot[1] |= MT_PROT_CTRL_RTS_CTS;
774
775 prot[2] |= MT_PROT_RATE_OFDM_24;
776 prot[3] |= MT_PROT_RATE_DUP_OFDM_24;
777 prot[4] |= MT_PROT_RATE_OFDM_24;
778 prot[5] |= MT_PROT_RATE_DUP_OFDM_24;
779
780 vht_prot[0] |= MT_PROT_RATE_OFDM_24;
781 vht_prot[1] |= MT_PROT_RATE_DUP_OFDM_24;
782 vht_prot[2] |= MT_PROT_RATE_SGI_OFDM_24;
783 }
784
785 switch (mode) {
786 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
787 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
788 prot[2] |= MT_PROT_CTRL_RTS_CTS;
789 prot[3] |= MT_PROT_CTRL_RTS_CTS;
790 prot[4] |= MT_PROT_CTRL_RTS_CTS;
791 prot[5] |= MT_PROT_CTRL_RTS_CTS;
792 vht_prot[0] |= MT_PROT_CTRL_RTS_CTS;
793 vht_prot[1] |= MT_PROT_CTRL_RTS_CTS;
794 vht_prot[2] |= MT_PROT_CTRL_RTS_CTS;
795 break;
796 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
797 prot[3] |= MT_PROT_CTRL_RTS_CTS;
798 prot[5] |= MT_PROT_CTRL_RTS_CTS;
799 vht_prot[1] |= MT_PROT_CTRL_RTS_CTS;
800 vht_prot[2] |= MT_PROT_CTRL_RTS_CTS;
801 break;
802 }
803
804 if (non_gf) {
805 prot[4] |= MT_PROT_CTRL_RTS_CTS;
806 prot[5] |= MT_PROT_CTRL_RTS_CTS;
807 }
808
809 for (i = 0; i < ARRAY_SIZE(prot); i++)
810 mt76_wr(dev, MT_CCK_PROT_CFG + i * 4, prot[i]);
811
812 for (i = 0; i < ARRAY_SIZE(vht_prot); i++)
813 mt76_wr(dev, MT_TX_PROT_CFG6 + i * 4, vht_prot[i]);
746} 814}
747 815
748void mt76x02_update_channel(struct mt76_dev *mdev) 816void mt76x02_update_channel(struct mt76_dev *mdev)
@@ -774,8 +842,90 @@ static void mt76x02_check_mac_err(struct mt76x02_dev *dev)
774 842
775 mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_RESET_CSR); 843 mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_RESET_CSR);
776 udelay(10); 844 udelay(10);
777 mt76_clear(dev, MT_MAC_SYS_CTRL, 845 mt76_wr(dev, MT_MAC_SYS_CTRL,
778 MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX); 846 MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
847}
848
849static void
850mt76x02_edcca_tx_enable(struct mt76x02_dev *dev, bool enable)
851{
852 if (enable) {
853 u32 data;
854
855 mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);
856 mt76_set(dev, MT_AUTO_RSP_CFG, MT_AUTO_RSP_EN);
857 /* enable pa-lna */
858 data = mt76_rr(dev, MT_TX_PIN_CFG);
859 data |= MT_TX_PIN_CFG_TXANT |
860 MT_TX_PIN_CFG_RXANT |
861 MT_TX_PIN_RFTR_EN |
862 MT_TX_PIN_TRSW_EN;
863 mt76_wr(dev, MT_TX_PIN_CFG, data);
864 } else {
865 mt76_clear(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);
866 mt76_clear(dev, MT_AUTO_RSP_CFG, MT_AUTO_RSP_EN);
867 /* disable pa-lna */
868 mt76_clear(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT);
869 mt76_clear(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_RXANT);
870 }
871 dev->ed_tx_blocked = !enable;
872}
873
874void mt76x02_edcca_init(struct mt76x02_dev *dev)
875{
876 dev->ed_trigger = 0;
877 dev->ed_silent = 0;
878
879 if (dev->ed_monitor) {
880 struct ieee80211_channel *chan = dev->mt76.chandef.chan;
881 u8 ed_th = chan->band == NL80211_BAND_5GHZ ? 0x0e : 0x20;
882
883 mt76_clear(dev, MT_TX_LINK_CFG, MT_TX_CFACK_EN);
884 mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
885 mt76_rmw(dev, MT_BBP(AGC, 2), GENMASK(15, 0),
886 ed_th << 8 | ed_th);
887 if (!is_mt76x2(dev))
888 mt76_set(dev, MT_TXOP_HLDR_ET,
889 MT_TXOP_HLDR_TX40M_BLK_EN);
890 } else {
891 mt76_set(dev, MT_TX_LINK_CFG, MT_TX_CFACK_EN);
892 mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
893 if (is_mt76x2(dev)) {
894 mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070);
895 } else {
896 mt76_wr(dev, MT_BBP(AGC, 2), 0x003a6464);
897 mt76_clear(dev, MT_TXOP_HLDR_ET,
898 MT_TXOP_HLDR_TX40M_BLK_EN);
899 }
900 }
901 mt76x02_edcca_tx_enable(dev, true);
902}
903EXPORT_SYMBOL_GPL(mt76x02_edcca_init);
904
905#define MT_EDCCA_TH 90
906#define MT_EDCCA_BLOCK_TH 2
907static void mt76x02_edcca_check(struct mt76x02_dev *dev)
908{
909 u32 val, busy;
910
911 val = mt76_rr(dev, MT_ED_CCA_TIMER);
912 busy = (val * 100) / jiffies_to_usecs(MT_CALIBRATE_INTERVAL);
913 busy = min_t(u32, busy, 100);
914
915 if (busy > MT_EDCCA_TH) {
916 dev->ed_trigger++;
917 dev->ed_silent = 0;
918 } else {
919 dev->ed_silent++;
920 dev->ed_trigger = 0;
921 }
922
923 if (dev->ed_trigger > MT_EDCCA_BLOCK_TH &&
924 !dev->ed_tx_blocked)
925 mt76x02_edcca_tx_enable(dev, false);
926 else if (dev->ed_silent > MT_EDCCA_BLOCK_TH &&
927 dev->ed_tx_blocked)
928 mt76x02_edcca_tx_enable(dev, true);
779} 929}
780 930
781void mt76x02_mac_work(struct work_struct *work) 931void mt76x02_mac_work(struct work_struct *work)
@@ -784,6 +934,8 @@ void mt76x02_mac_work(struct work_struct *work)
784 mac_work.work); 934 mac_work.work);
785 int i, idx; 935 int i, idx;
786 936
937 mutex_lock(&dev->mt76.mutex);
938
787 mt76x02_update_channel(&dev->mt76); 939 mt76x02_update_channel(&dev->mt76);
788 for (i = 0, idx = 0; i < 16; i++) { 940 for (i = 0, idx = 0; i < 16; i++) {
789 u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i)); 941 u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
@@ -792,10 +944,14 @@ void mt76x02_mac_work(struct work_struct *work)
792 dev->aggr_stats[idx++] += val >> 16; 944 dev->aggr_stats[idx++] += val >> 16;
793 } 945 }
794 946
795 /* XXX: check beacon stuck for ap mode */
796 if (!dev->beacon_mask) 947 if (!dev->beacon_mask)
797 mt76x02_check_mac_err(dev); 948 mt76x02_check_mac_err(dev);
798 949
950 if (dev->ed_monitor)
951 mt76x02_edcca_check(dev);
952
953 mutex_unlock(&dev->mt76.mutex);
954
799 mt76_tx_status_check(&dev->mt76, NULL, false); 955 mt76_tx_status_check(&dev->mt76, NULL, false);
800 956
801 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work, 957 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
index 4e597004c445..940c07f665cd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
@@ -18,8 +18,6 @@
18#ifndef __MT76X02_MAC_H 18#ifndef __MT76X02_MAC_H
19#define __MT76X02_MAC_H 19#define __MT76X02_MAC_H
20 20
21#include <linux/average.h>
22
23struct mt76x02_dev; 21struct mt76x02_dev;
24 22
25struct mt76x02_tx_status { 23struct mt76x02_tx_status {
@@ -41,8 +39,6 @@ struct mt76x02_vif {
41 u8 idx; 39 u8 idx;
42}; 40};
43 41
44DECLARE_EWMA(signal, 10, 8);
45
46struct mt76x02_sta { 42struct mt76x02_sta {
47 struct mt76_wcid wcid; /* must be first */ 43 struct mt76_wcid wcid; /* must be first */
48 44
@@ -50,8 +46,6 @@ struct mt76x02_sta {
50 struct mt76x02_tx_status status; 46 struct mt76x02_tx_status status;
51 int n_frames; 47 int n_frames;
52 48
53 struct ewma_signal rssi;
54 int inactive_count;
55}; 49};
56 50
57#define MT_RXINFO_BA BIT(0) 51#define MT_RXINFO_BA BIT(0)
@@ -194,7 +188,9 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
194 struct mt76x02_tx_status *stat, u8 *update); 188 struct mt76x02_tx_status *stat, u8 *update);
195int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, 189int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
196 void *rxi); 190 void *rxi);
197void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val); 191void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
192 int ht_mode);
193void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, u32 val);
198void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr); 194void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr);
199void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, 195void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
200 struct sk_buff *skb, struct mt76_wcid *wcid, 196 struct sk_buff *skb, struct mt76_wcid *wcid,
@@ -210,4 +206,6 @@ int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
210 struct sk_buff *skb); 206 struct sk_buff *skb);
211void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, 207void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
212 bool val); 208 bool val);
209
210void mt76x02_edcca_init(struct mt76x02_dev *dev);
213#endif 211#endif
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
index 66315410aebe..374bc9d91f12 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
@@ -116,14 +116,20 @@ static void mt76x02_pre_tbtt_tasklet(unsigned long arg)
116 IEEE80211_IFACE_ITER_RESUME_ALL, 116 IEEE80211_IFACE_ITER_RESUME_ALL,
117 mt76x02_update_beacon_iter, dev); 117 mt76x02_update_beacon_iter, dev);
118 118
119 mt76_csa_check(&dev->mt76);
120
121 if (dev->mt76.csa_complete)
122 return;
123
119 do { 124 do {
120 nframes = skb_queue_len(&data.q); 125 nframes = skb_queue_len(&data.q);
121 ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev), 126 ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev),
122 IEEE80211_IFACE_ITER_RESUME_ALL, 127 IEEE80211_IFACE_ITER_RESUME_ALL,
123 mt76x02_add_buffered_bc, &data); 128 mt76x02_add_buffered_bc, &data);
124 } while (nframes != skb_queue_len(&data.q)); 129 } while (nframes != skb_queue_len(&data.q) &&
130 skb_queue_len(&data.q) < 8);
125 131
126 if (!nframes) 132 if (!skb_queue_len(&data.q))
127 return; 133 return;
128 134
129 for (i = 0; i < ARRAY_SIZE(data.tail); i++) { 135 for (i = 0; i < ARRAY_SIZE(data.tail); i++) {
@@ -308,8 +314,12 @@ irqreturn_t mt76x02_irq_handler(int irq, void *dev_instance)
308 tasklet_schedule(&dev->pre_tbtt_tasklet); 314 tasklet_schedule(&dev->pre_tbtt_tasklet);
309 315
310 /* send buffered multicast frames now */ 316 /* send buffered multicast frames now */
311 if (intr & MT_INT_TBTT) 317 if (intr & MT_INT_TBTT) {
312 mt76_queue_kick(dev, &dev->mt76.q_tx[MT_TXQ_PSD]); 318 if (dev->mt76.csa_complete)
319 mt76_csa_finish(&dev->mt76);
320 else
321 mt76_queue_kick(dev, &dev->mt76.q_tx[MT_TXQ_PSD]);
322 }
313 323
314 if (intr & MT_INT_TX_STAT) { 324 if (intr & MT_INT_TX_STAT) {
315 mt76x02_mac_poll_tx_status(dev, true); 325 mt76x02_mac_poll_tx_status(dev, true);
@@ -384,3 +394,127 @@ void mt76x02_mac_start(struct mt76x02_dev *dev)
384 MT_INT_TX_STAT); 394 MT_INT_TX_STAT);
385} 395}
386EXPORT_SYMBOL_GPL(mt76x02_mac_start); 396EXPORT_SYMBOL_GPL(mt76x02_mac_start);
397
398static bool mt76x02_tx_hang(struct mt76x02_dev *dev)
399{
400 u32 dma_idx, prev_dma_idx;
401 struct mt76_queue *q;
402 int i;
403
404 for (i = 0; i < 4; i++) {
405 q = &dev->mt76.q_tx[i];
406
407 if (!q->queued)
408 continue;
409
410 prev_dma_idx = dev->mt76.tx_dma_idx[i];
411 dma_idx = ioread32(&q->regs->dma_idx);
412 dev->mt76.tx_dma_idx[i] = dma_idx;
413
414 if (prev_dma_idx == dma_idx)
415 break;
416 }
417
418 return i < 4;
419}
420
421static void mt76x02_watchdog_reset(struct mt76x02_dev *dev)
422{
423 u32 mask = dev->mt76.mmio.irqmask;
424 int i;
425
426 ieee80211_stop_queues(dev->mt76.hw);
427 set_bit(MT76_RESET, &dev->mt76.state);
428
429 tasklet_disable(&dev->pre_tbtt_tasklet);
430 tasklet_disable(&dev->tx_tasklet);
431
432 for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++)
433 napi_disable(&dev->mt76.napi[i]);
434
435 mutex_lock(&dev->mt76.mutex);
436
437 if (dev->beacon_mask)
438 mt76_clear(dev, MT_BEACON_TIME_CFG,
439 MT_BEACON_TIME_CFG_BEACON_TX |
440 MT_BEACON_TIME_CFG_TBTT_EN);
441
442 mt76x02_irq_disable(dev, mask);
443
444 /* perform device reset */
445 mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
446 mt76_wr(dev, MT_MAC_SYS_CTRL, 0);
447 mt76_clear(dev, MT_WPDMA_GLO_CFG,
448 MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN);
449 usleep_range(5000, 10000);
450 mt76_wr(dev, MT_INT_SOURCE_CSR, 0xffffffff);
451
452 /* let fw reset DMA */
453 mt76_set(dev, 0x734, 0x3);
454
455 for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++)
456 mt76_queue_tx_cleanup(dev, i, true);
457
458 for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++)
459 mt76_queue_rx_reset(dev, i);
460
461 mt76_wr(dev, MT_MAC_SYS_CTRL,
462 MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
463 mt76_set(dev, MT_WPDMA_GLO_CFG,
464 MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN);
465 if (dev->ed_monitor)
466 mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
467
468 if (dev->beacon_mask)
469 mt76_set(dev, MT_BEACON_TIME_CFG,
470 MT_BEACON_TIME_CFG_BEACON_TX |
471 MT_BEACON_TIME_CFG_TBTT_EN);
472
473 mt76x02_irq_enable(dev, mask);
474
475 mutex_unlock(&dev->mt76.mutex);
476
477 clear_bit(MT76_RESET, &dev->mt76.state);
478
479 tasklet_enable(&dev->tx_tasklet);
480 tasklet_schedule(&dev->tx_tasklet);
481
482 tasklet_enable(&dev->pre_tbtt_tasklet);
483
484 for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++) {
485 napi_enable(&dev->mt76.napi[i]);
486 napi_schedule(&dev->mt76.napi[i]);
487 }
488
489 ieee80211_wake_queues(dev->mt76.hw);
490
491 mt76_txq_schedule_all(&dev->mt76);
492}
493
494static void mt76x02_check_tx_hang(struct mt76x02_dev *dev)
495{
496 if (mt76x02_tx_hang(dev)) {
497 if (++dev->tx_hang_check < MT_TX_HANG_TH)
498 return;
499
500 mt76x02_watchdog_reset(dev);
501
502 dev->tx_hang_reset++;
503 dev->tx_hang_check = 0;
504 memset(dev->mt76.tx_dma_idx, 0xff,
505 sizeof(dev->mt76.tx_dma_idx));
506 } else {
507 dev->tx_hang_check = 0;
508 }
509}
510
511void mt76x02_wdt_work(struct work_struct *work)
512{
513 struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
514 wdt_work.work);
515
516 mt76x02_check_tx_hang(dev);
517
518 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->wdt_work,
519 MT_WATCHDOG_TIME);
520}
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
index 977a8e7e26df..a020c757ba5c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
@@ -132,53 +132,6 @@ void mt76x02_phy_set_txpower(struct mt76x02_dev *dev, int txp_0, int txp_1)
132} 132}
133EXPORT_SYMBOL_GPL(mt76x02_phy_set_txpower); 133EXPORT_SYMBOL_GPL(mt76x02_phy_set_txpower);
134 134
135int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev)
136{
137 struct mt76x02_sta *sta;
138 struct mt76_wcid *wcid;
139 int i, j, min_rssi = 0;
140 s8 cur_rssi;
141
142 local_bh_disable();
143 rcu_read_lock();
144
145 for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid_mask); i++) {
146 unsigned long mask = dev->mt76.wcid_mask[i];
147
148 if (!mask)
149 continue;
150
151 for (j = i * BITS_PER_LONG; mask; j++, mask >>= 1) {
152 if (!(mask & 1))
153 continue;
154
155 wcid = rcu_dereference(dev->mt76.wcid[j]);
156 if (!wcid)
157 continue;
158
159 sta = container_of(wcid, struct mt76x02_sta, wcid);
160 spin_lock(&dev->mt76.rx_lock);
161 if (sta->inactive_count++ < 5)
162 cur_rssi = ewma_signal_read(&sta->rssi);
163 else
164 cur_rssi = 0;
165 spin_unlock(&dev->mt76.rx_lock);
166
167 if (cur_rssi < min_rssi)
168 min_rssi = cur_rssi;
169 }
170 }
171
172 rcu_read_unlock();
173 local_bh_enable();
174
175 if (!min_rssi)
176 return -75;
177
178 return min_rssi;
179}
180EXPORT_SYMBOL_GPL(mt76x02_phy_get_min_avg_rssi);
181
182void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl) 135void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl)
183{ 136{
184 int core_val, agc_val; 137 int core_val, agc_val;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
index 2b316cf7c70c..d2971db06f13 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
@@ -51,7 +51,6 @@ void mt76x02_limit_rate_power(struct mt76_rate_power *r, int limit);
51int mt76x02_get_max_rate_power(struct mt76_rate_power *r); 51int mt76x02_get_max_rate_power(struct mt76_rate_power *r);
52void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev); 52void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev);
53void mt76x02_phy_set_txdac(struct mt76x02_dev *dev); 53void mt76x02_phy_set_txdac(struct mt76x02_dev *dev);
54int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev);
55void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl); 54void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
56void mt76x02_phy_set_band(struct mt76x02_dev *dev, int band, 55void mt76x02_phy_set_band(struct mt76x02_dev *dev, int band,
57 bool primary_upper); 56 bool primary_upper);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
index f7de77d09d28..7401cb94fb72 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
@@ -230,6 +230,29 @@
230#define MT_COM_REG2 0x0738 230#define MT_COM_REG2 0x0738
231#define MT_COM_REG3 0x073C 231#define MT_COM_REG3 0x073C
232 232
233#define MT_LED_CTRL 0x0770
234#define MT_LED_CTRL_REPLAY(_n) BIT(0 + (8 * (_n)))
235#define MT_LED_CTRL_POLARITY(_n) BIT(1 + (8 * (_n)))
236#define MT_LED_CTRL_TX_BLINK_MODE(_n) BIT(2 + (8 * (_n)))
237#define MT_LED_CTRL_KICK(_n) BIT(7 + (8 * (_n)))
238
239#define MT_LED_TX_BLINK_0 0x0774
240#define MT_LED_TX_BLINK_1 0x0778
241
242#define MT_LED_S0_BASE 0x077C
243#define MT_LED_S0(_n) (MT_LED_S0_BASE + 8 * (_n))
244#define MT_LED_S1_BASE 0x0780
245#define MT_LED_S1(_n) (MT_LED_S1_BASE + 8 * (_n))
246#define MT_LED_STATUS_OFF_MASK GENMASK(31, 24)
247#define MT_LED_STATUS_OFF(_v) (((_v) << __ffs(MT_LED_STATUS_OFF_MASK)) & \
248 MT_LED_STATUS_OFF_MASK)
249#define MT_LED_STATUS_ON_MASK GENMASK(23, 16)
250#define MT_LED_STATUS_ON(_v) (((_v) << __ffs(MT_LED_STATUS_ON_MASK)) & \
251 MT_LED_STATUS_ON_MASK)
252#define MT_LED_STATUS_DURATION_MASK GENMASK(15, 8)
253#define MT_LED_STATUS_DURATION(_v) (((_v) << __ffs(MT_LED_STATUS_DURATION_MASK)) & \
254 MT_LED_STATUS_DURATION_MASK)
255
233#define MT_FCE_PSE_CTRL 0x0800 256#define MT_FCE_PSE_CTRL 0x0800
234#define MT_FCE_PARAMETERS 0x0804 257#define MT_FCE_PARAMETERS 0x0804
235#define MT_FCE_CSO 0x0808 258#define MT_FCE_CSO 0x0808
@@ -318,6 +341,7 @@
318#define MT_CH_TIME_CFG_NAV_AS_BUSY BIT(3) 341#define MT_CH_TIME_CFG_NAV_AS_BUSY BIT(3)
319#define MT_CH_TIME_CFG_EIFS_AS_BUSY BIT(4) 342#define MT_CH_TIME_CFG_EIFS_AS_BUSY BIT(4)
320#define MT_CH_TIME_CFG_MDRDY_CNT_EN BIT(5) 343#define MT_CH_TIME_CFG_MDRDY_CNT_EN BIT(5)
344#define MT_CH_CCA_RC_EN BIT(6)
321#define MT_CH_TIME_CFG_CH_TIMER_CLR GENMASK(9, 8) 345#define MT_CH_TIME_CFG_CH_TIMER_CLR GENMASK(9, 8)
322#define MT_CH_TIME_CFG_MDRDY_CLR GENMASK(11, 10) 346#define MT_CH_TIME_CFG_MDRDY_CLR GENMASK(11, 10)
323 347
@@ -378,6 +402,9 @@
378#define MT_TX_PWR_CFG_4 0x1324 402#define MT_TX_PWR_CFG_4 0x1324
379#define MT_TX_PIN_CFG 0x1328 403#define MT_TX_PIN_CFG 0x1328
380#define MT_TX_PIN_CFG_TXANT GENMASK(3, 0) 404#define MT_TX_PIN_CFG_TXANT GENMASK(3, 0)
405#define MT_TX_PIN_CFG_RXANT GENMASK(11, 8)
406#define MT_TX_PIN_RFTR_EN BIT(16)
407#define MT_TX_PIN_TRSW_EN BIT(18)
381 408
382#define MT_TX_BAND_CFG 0x132c 409#define MT_TX_BAND_CFG 0x132c
383#define MT_TX_BAND_CFG_UPPER_40M BIT(0) 410#define MT_TX_BAND_CFG_UPPER_40M BIT(0)
@@ -398,6 +425,7 @@
398#define MT_TXOP_CTRL_CFG 0x1340 425#define MT_TXOP_CTRL_CFG 0x1340
399#define MT_TXOP_TRUN_EN GENMASK(5, 0) 426#define MT_TXOP_TRUN_EN GENMASK(5, 0)
400#define MT_TXOP_EXT_CCA_DLY GENMASK(15, 8) 427#define MT_TXOP_EXT_CCA_DLY GENMASK(15, 8)
428#define MT_TXOP_ED_CCA_EN BIT(20)
401 429
402#define MT_TX_RTS_CFG 0x1344 430#define MT_TX_RTS_CFG 0x1344
403#define MT_TX_RTS_CFG_RETRY_LIMIT GENMASK(7, 0) 431#define MT_TX_RTS_CFG_RETRY_LIMIT GENMASK(7, 0)
@@ -409,6 +437,7 @@
409 437
410#define MT_TX_RETRY_CFG 0x134c 438#define MT_TX_RETRY_CFG 0x134c
411#define MT_TX_LINK_CFG 0x1350 439#define MT_TX_LINK_CFG 0x1350
440#define MT_TX_CFACK_EN BIT(12)
412#define MT_VHT_HT_FBK_CFG0 0x1354 441#define MT_VHT_HT_FBK_CFG0 0x1354
413#define MT_VHT_HT_FBK_CFG1 0x1358 442#define MT_VHT_HT_FBK_CFG1 0x1358
414#define MT_LG_FBK_CFG0 0x135c 443#define MT_LG_FBK_CFG0 0x135c
@@ -440,9 +469,10 @@
440#define MT_PROT_TXOP_ALLOW_GF40 BIT(25) 469#define MT_PROT_TXOP_ALLOW_GF40 BIT(25)
441#define MT_PROT_RTS_THR_EN BIT(26) 470#define MT_PROT_RTS_THR_EN BIT(26)
442#define MT_PROT_RATE_CCK_11 0x0003 471#define MT_PROT_RATE_CCK_11 0x0003
443#define MT_PROT_RATE_OFDM_6 0x4000 472#define MT_PROT_RATE_OFDM_6 0x2000
444#define MT_PROT_RATE_OFDM_24 0x4004 473#define MT_PROT_RATE_OFDM_24 0x2004
445#define MT_PROT_RATE_DUP_OFDM_24 0x4084 474#define MT_PROT_RATE_DUP_OFDM_24 0x2084
475#define MT_PROT_RATE_SGI_OFDM_24 0x2104
446#define MT_PROT_TXOP_ALLOW_ALL GENMASK(25, 20) 476#define MT_PROT_TXOP_ALLOW_ALL GENMASK(25, 20)
447#define MT_PROT_TXOP_ALLOW_BW20 (MT_PROT_TXOP_ALLOW_ALL & \ 477#define MT_PROT_TXOP_ALLOW_BW20 (MT_PROT_TXOP_ALLOW_ALL & \
448 ~MT_PROT_TXOP_ALLOW_MM40 & \ 478 ~MT_PROT_TXOP_ALLOW_MM40 & \
@@ -511,6 +541,7 @@
511#define MT_RX_FILTR_CFG_CTRL_RSV BIT(16) 541#define MT_RX_FILTR_CFG_CTRL_RSV BIT(16)
512 542
513#define MT_AUTO_RSP_CFG 0x1404 543#define MT_AUTO_RSP_CFG 0x1404
544#define MT_AUTO_RSP_EN BIT(0)
514#define MT_AUTO_RSP_PREAMB_SHORT BIT(4) 545#define MT_AUTO_RSP_PREAMB_SHORT BIT(4)
515#define MT_LEGACY_BASIC_RATE 0x1408 546#define MT_LEGACY_BASIC_RATE 0x1408
516#define MT_HT_BASIC_RATE 0x140c 547#define MT_HT_BASIC_RATE 0x140c
@@ -532,6 +563,7 @@
532#define MT_PN_PAD_MODE 0x150c 563#define MT_PN_PAD_MODE 0x150c
533 564
534#define MT_TXOP_HLDR_ET 0x1608 565#define MT_TXOP_HLDR_ET 0x1608
566#define MT_TXOP_HLDR_TX40M_BLK_EN BIT(1)
535 567
536#define MT_PROT_AUTO_TX_CFG 0x1648 568#define MT_PROT_AUTO_TX_CFG 0x1648
537#define MT_PROT_AUTO_TX_CFG_PROT_PADJ GENMASK(11, 8) 569#define MT_PROT_AUTO_TX_CFG_PROT_PADJ GENMASK(11, 8)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
index 4598cb2cc3ff..a5413a309a0a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
@@ -177,7 +177,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
177 if (ret < 0) 177 if (ret < 0)
178 return ret; 178 return ret;
179 179
180 if (pid && pid != MT_PACKET_ID_NO_ACK) 180 if (pid >= MT_PACKET_ID_FIRST)
181 qsel = MT_QSEL_MGMT; 181 qsel = MT_QSEL_MGMT;
182 182
183 *tx_info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) | 183 *tx_info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
index 81970cf777c0..098d05e109e7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
@@ -87,8 +87,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
87 pid = mt76_tx_status_skb_add(mdev, wcid, skb); 87 pid = mt76_tx_status_skb_add(mdev, wcid, skb);
88 txwi->pktid = pid; 88 txwi->pktid = pid;
89 89
90 if ((pid && pid != MT_PACKET_ID_NO_ACK) || 90 if (pid >= MT_PACKET_ID_FIRST || q2ep(q->hw_idx) == MT_EP_OUT_HCCA)
91 q2ep(q->hw_idx) == MT_EP_OUT_HCCA)
92 qsel = MT_QSEL_MGMT; 91 qsel = MT_QSEL_MGMT;
93 else 92 else
94 qsel = MT_QSEL_EDCA; 93 qsel = MT_QSEL_EDCA;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 38bd466cff16..062614ad0d51 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -75,6 +75,58 @@ static const struct ieee80211_iface_combination mt76x02_if_comb[] = {
75 } 75 }
76}; 76};
77 77
78static void
79mt76x02_led_set_config(struct mt76_dev *mdev, u8 delay_on,
80 u8 delay_off)
81{
82 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev,
83 mt76);
84 u32 val;
85
86 val = MT_LED_STATUS_DURATION(0xff) |
87 MT_LED_STATUS_OFF(delay_off) |
88 MT_LED_STATUS_ON(delay_on);
89
90 mt76_wr(dev, MT_LED_S0(mdev->led_pin), val);
91 mt76_wr(dev, MT_LED_S1(mdev->led_pin), val);
92
93 val = MT_LED_CTRL_REPLAY(mdev->led_pin) |
94 MT_LED_CTRL_KICK(mdev->led_pin);
95 if (mdev->led_al)
96 val |= MT_LED_CTRL_POLARITY(mdev->led_pin);
97 mt76_wr(dev, MT_LED_CTRL, val);
98}
99
100static int
101mt76x02_led_set_blink(struct led_classdev *led_cdev,
102 unsigned long *delay_on,
103 unsigned long *delay_off)
104{
105 struct mt76_dev *mdev = container_of(led_cdev, struct mt76_dev,
106 led_cdev);
107 u8 delta_on, delta_off;
108
109 delta_off = max_t(u8, *delay_off / 10, 1);
110 delta_on = max_t(u8, *delay_on / 10, 1);
111
112 mt76x02_led_set_config(mdev, delta_on, delta_off);
113
114 return 0;
115}
116
117static void
118mt76x02_led_set_brightness(struct led_classdev *led_cdev,
119 enum led_brightness brightness)
120{
121 struct mt76_dev *mdev = container_of(led_cdev, struct mt76_dev,
122 led_cdev);
123
124 if (!brightness)
125 mt76x02_led_set_config(mdev, 0, 0xff);
126 else
127 mt76x02_led_set_config(mdev, 0xff, 0);
128}
129
78void mt76x02_init_device(struct mt76x02_dev *dev) 130void mt76x02_init_device(struct mt76x02_dev *dev)
79{ 131{
80 struct ieee80211_hw *hw = mt76_hw(dev); 132 struct ieee80211_hw *hw = mt76_hw(dev);
@@ -93,6 +145,8 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
93 MT_DMA_HDR_LEN; 145 MT_DMA_HDR_LEN;
94 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 146 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
95 } else { 147 } else {
148 INIT_DELAYED_WORK(&dev->wdt_work, mt76x02_wdt_work);
149
96 mt76x02_dfs_init_detector(dev); 150 mt76x02_dfs_init_detector(dev);
97 151
98 wiphy->reg_notifier = mt76x02_regd_notifier; 152 wiphy->reg_notifier = mt76x02_regd_notifier;
@@ -106,7 +160,16 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
106#endif 160#endif
107 BIT(NL80211_IFTYPE_ADHOC); 161 BIT(NL80211_IFTYPE_ADHOC);
108 162
163 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
164
109 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS); 165 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
166
167 /* init led callbacks */
168 if (IS_ENABLED(CONFIG_MT76_LEDS)) {
169 dev->mt76.led_cdev.brightness_set =
170 mt76x02_led_set_brightness;
171 dev->mt76.led_cdev.blink_set = mt76x02_led_set_blink;
172 }
110 } 173 }
111 174
112 hw->sta_data_size = sizeof(struct mt76x02_sta); 175 hw->sta_data_size = sizeof(struct mt76x02_sta);
@@ -189,8 +252,6 @@ int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
189 if (vif->type == NL80211_IFTYPE_AP) 252 if (vif->type == NL80211_IFTYPE_AP)
190 set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags); 253 set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags);
191 254
192 ewma_signal_init(&msta->rssi);
193
194 return 0; 255 return 0;
195} 256}
196EXPORT_SYMBOL_GPL(mt76x02_sta_add); 257EXPORT_SYMBOL_GPL(mt76x02_sta_add);
@@ -463,7 +524,7 @@ int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
463 return -EINVAL; 524 return -EINVAL;
464 525
465 mutex_lock(&dev->mt76.mutex); 526 mutex_lock(&dev->mt76.mutex);
466 mt76x02_mac_set_tx_protection(dev, val); 527 mt76x02_mac_set_rts_thresh(dev, val);
467 mutex_unlock(&dev->mt76.mutex); 528 mutex_unlock(&dev->mt76.mutex);
468 529
469 return 0; 530 return 0;
@@ -546,24 +607,6 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
546} 607}
547EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete); 608EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
548 609
549int mt76x02_get_txpower(struct ieee80211_hw *hw,
550 struct ieee80211_vif *vif, int *dbm)
551{
552 struct mt76x02_dev *dev = hw->priv;
553 u8 nstreams = dev->mt76.chainmask & 0xf;
554
555 *dbm = dev->mt76.txpower_cur / 2;
556
557 /* convert from per-chain power to combined
558 * output on 2x2 devices
559 */
560 if (nstreams > 1)
561 *dbm += 3;
562
563 return 0;
564}
565EXPORT_SYMBOL_GPL(mt76x02_get_txpower);
566
567void mt76x02_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, 610void mt76x02_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta,
568 bool ps) 611 bool ps)
569{ 612{
@@ -661,6 +704,10 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
661 tasklet_enable(&dev->pre_tbtt_tasklet); 704 tasklet_enable(&dev->pre_tbtt_tasklet);
662 } 705 }
663 706
707 if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
708 mt76x02_mac_set_tx_protection(dev, info->use_cts_prot,
709 info->ht_operation_mode);
710
664 if (changed & BSS_CHANGED_BEACON_INT) { 711 if (changed & BSS_CHANGED_BEACON_INT) {
665 mt76_rmw_field(dev, MT_BEACON_TIME_CFG, 712 mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
666 MT_BEACON_TIME_CFG_INTVAL, 713 MT_BEACON_TIME_CFG_INTVAL,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c
index 54a9b5fac787..f8534362e2c8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c
@@ -143,6 +143,7 @@ void mt76_write_mac_initvals(struct mt76x02_dev *dev)
143 { MT_VHT_HT_FBK_CFG1, 0xedcba980 }, 143 { MT_VHT_HT_FBK_CFG1, 0xedcba980 },
144 { MT_PROT_AUTO_TX_CFG, 0x00830083 }, 144 { MT_PROT_AUTO_TX_CFG, 0x00830083 },
145 { MT_HT_CTRL_CFG, 0x000001ff }, 145 { MT_HT_CTRL_CFG, 0x000001ff },
146 { MT_TX_LINK_CFG, 0x00001020 },
146 }; 147 };
147 struct mt76_reg_pair prot_vals[] = { 148 struct mt76_reg_pair prot_vals[] = {
148 { MT_CCK_PROT_CFG, DEFAULT_PROT_CFG_CCK }, 149 { MT_CCK_PROT_CFG, DEFAULT_PROT_CFG_CCK },
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mcu.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mcu.h
index acfa2b570c7c..40ef43926c06 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mcu.h
@@ -26,29 +26,6 @@
26#define MT_MCU_PCIE_REMAP_BASE2 0x0744 26#define MT_MCU_PCIE_REMAP_BASE2 0x0744
27#define MT_MCU_PCIE_REMAP_BASE3 0x0748 27#define MT_MCU_PCIE_REMAP_BASE3 0x0748
28 28
29#define MT_LED_CTRL 0x0770
30#define MT_LED_CTRL_REPLAY(_n) BIT(0 + (8 * (_n)))
31#define MT_LED_CTRL_POLARITY(_n) BIT(1 + (8 * (_n)))
32#define MT_LED_CTRL_TX_BLINK_MODE(_n) BIT(2 + (8 * (_n)))
33#define MT_LED_CTRL_KICK(_n) BIT(7 + (8 * (_n)))
34
35#define MT_LED_TX_BLINK_0 0x0774
36#define MT_LED_TX_BLINK_1 0x0778
37
38#define MT_LED_S0_BASE 0x077C
39#define MT_LED_S0(_n) (MT_LED_S0_BASE + 8 * (_n))
40#define MT_LED_S1_BASE 0x0780
41#define MT_LED_S1(_n) (MT_LED_S1_BASE + 8 * (_n))
42#define MT_LED_STATUS_OFF_MASK GENMASK(31, 24)
43#define MT_LED_STATUS_OFF(_v) (((_v) << __ffs(MT_LED_STATUS_OFF_MASK)) & \
44 MT_LED_STATUS_OFF_MASK)
45#define MT_LED_STATUS_ON_MASK GENMASK(23, 16)
46#define MT_LED_STATUS_ON(_v) (((_v) << __ffs(MT_LED_STATUS_ON_MASK)) & \
47 MT_LED_STATUS_ON_MASK)
48#define MT_LED_STATUS_DURATION_MASK GENMASK(15, 8)
49#define MT_LED_STATUS_DURATION(_v) (((_v) << __ffs(MT_LED_STATUS_DURATION_MASK)) & \
50 MT_LED_STATUS_DURATION_MASK)
51
52#define MT_MCU_ROM_PATCH_OFFSET 0x80000 29#define MT_MCU_ROM_PATCH_OFFSET 0x80000
53#define MT_MCU_ROM_PATCH_ADDR 0x90000 30#define MT_MCU_ROM_PATCH_ADDR 0x90000
54 31
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
index b259e4b50f1e..28ec19acf9db 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
@@ -53,7 +53,6 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev);
53int mt76x2_register_device(struct mt76x02_dev *dev); 53int mt76x2_register_device(struct mt76x02_dev *dev);
54 54
55void mt76x2_phy_power_on(struct mt76x02_dev *dev); 55void mt76x2_phy_power_on(struct mt76x02_dev *dev);
56int mt76x2_init_hardware(struct mt76x02_dev *dev);
57void mt76x2_stop_hardware(struct mt76x02_dev *dev); 56void mt76x2_stop_hardware(struct mt76x02_dev *dev);
58int mt76x2_eeprom_init(struct mt76x02_dev *dev); 57int mt76x2_eeprom_init(struct mt76x02_dev *dev);
59int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel); 58int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index 7f4ea2d00f42..4347d5e7a915 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -151,6 +151,7 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
151 MT_CH_TIME_CFG_RX_AS_BUSY | 151 MT_CH_TIME_CFG_RX_AS_BUSY |
152 MT_CH_TIME_CFG_NAV_AS_BUSY | 152 MT_CH_TIME_CFG_NAV_AS_BUSY |
153 MT_CH_TIME_CFG_EIFS_AS_BUSY | 153 MT_CH_TIME_CFG_EIFS_AS_BUSY |
154 MT_CH_CCA_RC_EN |
154 FIELD_PREP(MT_CH_TIME_CFG_CH_TIMER_CLR, 1)); 155 FIELD_PREP(MT_CH_TIME_CFG_CH_TIMER_CLR, 1));
155 156
156 mt76x02_set_tx_ackto(dev); 157 mt76x02_set_tx_ackto(dev);
@@ -260,7 +261,7 @@ mt76x2_power_on(struct mt76x02_dev *dev)
260 mt76x2_power_on_rf(dev, 1); 261 mt76x2_power_on_rf(dev, 1);
261} 262}
262 263
263int mt76x2_init_hardware(struct mt76x02_dev *dev) 264static int mt76x2_init_hardware(struct mt76x02_dev *dev)
264{ 265{
265 int ret; 266 int ret;
266 267
@@ -300,6 +301,7 @@ void mt76x2_stop_hardware(struct mt76x02_dev *dev)
300{ 301{
301 cancel_delayed_work_sync(&dev->cal_work); 302 cancel_delayed_work_sync(&dev->cal_work);
302 cancel_delayed_work_sync(&dev->mac_work); 303 cancel_delayed_work_sync(&dev->mac_work);
304 cancel_delayed_work_sync(&dev->wdt_work);
303 mt76x02_mcu_set_radio_state(dev, false); 305 mt76x02_mcu_set_radio_state(dev, false);
304 mt76x2_mac_stop(dev, false); 306 mt76x2_mac_stop(dev, false);
305} 307}
@@ -340,54 +342,6 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
340 return dev; 342 return dev;
341} 343}
342 344
343static void mt76x2_led_set_config(struct mt76_dev *mt76, u8 delay_on,
344 u8 delay_off)
345{
346 struct mt76x02_dev *dev = container_of(mt76, struct mt76x02_dev,
347 mt76);
348 u32 val;
349
350 val = MT_LED_STATUS_DURATION(0xff) |
351 MT_LED_STATUS_OFF(delay_off) |
352 MT_LED_STATUS_ON(delay_on);
353
354 mt76_wr(dev, MT_LED_S0(mt76->led_pin), val);
355 mt76_wr(dev, MT_LED_S1(mt76->led_pin), val);
356
357 val = MT_LED_CTRL_REPLAY(mt76->led_pin) |
358 MT_LED_CTRL_KICK(mt76->led_pin);
359 if (mt76->led_al)
360 val |= MT_LED_CTRL_POLARITY(mt76->led_pin);
361 mt76_wr(dev, MT_LED_CTRL, val);
362}
363
364static int mt76x2_led_set_blink(struct led_classdev *led_cdev,
365 unsigned long *delay_on,
366 unsigned long *delay_off)
367{
368 struct mt76_dev *mt76 = container_of(led_cdev, struct mt76_dev,
369 led_cdev);
370 u8 delta_on, delta_off;
371
372 delta_off = max_t(u8, *delay_off / 10, 1);
373 delta_on = max_t(u8, *delay_on / 10, 1);
374
375 mt76x2_led_set_config(mt76, delta_on, delta_off);
376 return 0;
377}
378
379static void mt76x2_led_set_brightness(struct led_classdev *led_cdev,
380 enum led_brightness brightness)
381{
382 struct mt76_dev *mt76 = container_of(led_cdev, struct mt76_dev,
383 led_cdev);
384
385 if (!brightness)
386 mt76x2_led_set_config(mt76, 0, 0xff);
387 else
388 mt76x2_led_set_config(mt76, 0xff, 0);
389}
390
391int mt76x2_register_device(struct mt76x02_dev *dev) 345int mt76x2_register_device(struct mt76x02_dev *dev)
392{ 346{
393 int ret; 347 int ret;
@@ -402,12 +356,6 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
402 356
403 mt76x02_config_mac_addr_list(dev); 357 mt76x02_config_mac_addr_list(dev);
404 358
405 /* init led callbacks */
406 if (IS_ENABLED(CONFIG_MT76_LEDS)) {
407 dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness;
408 dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink;
409 }
410
411 ret = mt76_register_device(&dev->mt76, true, mt76x02_rates, 359 ret = mt76_register_device(&dev->mt76, true, mt76x02_rates,
412 ARRAY_SIZE(mt76x02_rates)); 360 ARRAY_SIZE(mt76x02_rates));
413 if (ret) 361 if (ret)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
index b54a32397486..06a26a152ba4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
@@ -34,6 +34,8 @@ mt76x2_start(struct ieee80211_hw *hw)
34 34
35 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work, 35 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
36 MT_CALIBRATE_INTERVAL); 36 MT_CALIBRATE_INTERVAL);
37 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->wdt_work,
38 MT_WATCHDOG_TIME);
37 39
38 set_bit(MT76_STATE_RUNNING, &dev->mt76.state); 40 set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
39 41
@@ -189,7 +191,7 @@ const struct ieee80211_ops mt76x2_ops = {
189 .sw_scan_complete = mt76x02_sw_scan_complete, 191 .sw_scan_complete = mt76x02_sw_scan_complete,
190 .flush = mt76x2_flush, 192 .flush = mt76x2_flush,
191 .ampdu_action = mt76x02_ampdu_action, 193 .ampdu_action = mt76x02_ampdu_action,
192 .get_txpower = mt76x02_get_txpower, 194 .get_txpower = mt76_get_txpower,
193 .wake_tx_queue = mt76_wake_tx_queue, 195 .wake_tx_queue = mt76_wake_tx_queue,
194 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update, 196 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
195 .release_buffered_frames = mt76_release_buffered_frames, 197 .release_buffered_frames = mt76_release_buffered_frames,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
index da7cd40f56ff..65ed62229a5b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
@@ -254,6 +254,8 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
254 0x38); 254 0x38);
255 } 255 }
256 256
257 mt76x02_edcca_init(dev);
258
257 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work, 259 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work,
258 MT_CALIBRATE_INTERVAL); 260 MT_CALIBRATE_INTERVAL);
259 261
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c
index c9634a774705..e2ee5e498da7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c
@@ -284,7 +284,9 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev)
284 int low_gain; 284 int low_gain;
285 u32 val; 285 u32 val;
286 286
287 dev->cal.avg_rssi_all = mt76x02_phy_get_min_avg_rssi(dev); 287 dev->cal.avg_rssi_all = mt76_get_min_avg_rssi(&dev->mt76);
288 if (!dev->cal.avg_rssi_all)
289 dev->cal.avg_rssi_all = -75;
288 290
289 low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) + 291 low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
290 (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev)); 292 (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index 2b48cc51a30d..286c7f451090 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -138,5 +138,5 @@ const struct ieee80211_ops mt76x2u_ops = {
138 .sw_scan_start = mt76x02_sw_scan, 138 .sw_scan_start = mt76x02_sw_scan,
139 .sw_scan_complete = mt76x02_sw_scan_complete, 139 .sw_scan_complete = mt76x02_sw_scan_complete,
140 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update, 140 .sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
141 .get_txpower = mt76x02_get_txpower, 141 .get_txpower = mt76_get_txpower,
142}; 142};
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
index 45a95ee3a415..152d41fe9ff5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
@@ -39,7 +39,7 @@ static void mt76x2u_mcu_load_ivb(struct mt76x02_dev *dev)
39static void mt76x2u_mcu_enable_patch(struct mt76x02_dev *dev) 39static void mt76x2u_mcu_enable_patch(struct mt76x02_dev *dev)
40{ 40{
41 struct mt76_usb *usb = &dev->mt76.usb; 41 struct mt76_usb *usb = &dev->mt76.usb;
42 const u8 data[] = { 42 static const u8 data[] = {
43 0x6f, 0xfc, 0x08, 0x01, 43 0x6f, 0xfc, 0x08, 0x01,
44 0x20, 0x04, 0x00, 0x00, 44 0x20, 0x04, 0x00, 0x00,
45 0x00, 0x09, 0x00, 45 0x00, 0x09, 0x00,
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index 7b711058807d..ef38e8626da9 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -170,21 +170,22 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
170 int pid; 170 int pid;
171 171
172 if (!wcid) 172 if (!wcid)
173 return 0; 173 return MT_PACKET_ID_NO_ACK;
174 174
175 if (info->flags & IEEE80211_TX_CTL_NO_ACK) 175 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
176 return MT_PACKET_ID_NO_ACK; 176 return MT_PACKET_ID_NO_ACK;
177 177
178 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS | 178 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
179 IEEE80211_TX_CTL_RATE_CTRL_PROBE))) 179 IEEE80211_TX_CTL_RATE_CTRL_PROBE)))
180 return 0; 180 return MT_PACKET_ID_NO_SKB;
181 181
182 spin_lock_bh(&dev->status_list.lock); 182 spin_lock_bh(&dev->status_list.lock);
183 183
184 memset(cb, 0, sizeof(*cb)); 184 memset(cb, 0, sizeof(*cb));
185 wcid->packet_id = (wcid->packet_id + 1) & MT_PACKET_ID_MASK; 185 wcid->packet_id = (wcid->packet_id + 1) & MT_PACKET_ID_MASK;
186 if (!wcid->packet_id || wcid->packet_id == MT_PACKET_ID_NO_ACK) 186 if (wcid->packet_id == MT_PACKET_ID_NO_ACK ||
187 wcid->packet_id = 1; 187 wcid->packet_id == MT_PACKET_ID_NO_SKB)
188 wcid->packet_id = MT_PACKET_ID_FIRST;
188 189
189 pid = wcid->packet_id; 190 pid = wcid->packet_id;
190 cb->wcid = wcid->idx; 191 cb->wcid = wcid->idx;
@@ -330,7 +331,8 @@ mt76_queue_ps_skb(struct mt76_dev *dev, struct ieee80211_sta *sta,
330 331
331 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; 332 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE;
332 if (last) 333 if (last)
333 info->flags |= IEEE80211_TX_STATUS_EOSP; 334 info->flags |= IEEE80211_TX_STATUS_EOSP |
335 IEEE80211_TX_CTL_REQ_TX_STATUS;
334 336
335 mt76_skb_set_moredata(skb, !last); 337 mt76_skb_set_moredata(skb, !last);
336 dev->queue_ops->tx_queue_skb(dev, hwq, skb, wcid, sta); 338 dev->queue_ops->tx_queue_skb(dev, hwq, skb, wcid, sta);
@@ -394,6 +396,11 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_queue *hwq,
394 bool probe; 396 bool probe;
395 int idx; 397 int idx;
396 398
399 if (test_bit(MT_WCID_FLAG_PS, &wcid->flags)) {
400 *empty = true;
401 return 0;
402 }
403
397 skb = mt76_txq_dequeue(dev, mtxq, false); 404 skb = mt76_txq_dequeue(dev, mtxq, false);
398 if (!skb) { 405 if (!skb) {
399 *empty = true; 406 *empty = true;
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index b061263453d4..6a2507524c6c 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -407,17 +407,15 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb)
407 if (len < 0) 407 if (len < 0)
408 return 0; 408 return 0;
409 409
410 data_len = min_t(int, len, urb->sg[0].length - MT_DMA_HDR_LEN);
411 if (MT_DMA_HDR_LEN + data_len > SKB_WITH_OVERHEAD(q->buf_size))
412 return 0;
413
410 skb = build_skb(data, q->buf_size); 414 skb = build_skb(data, q->buf_size);
411 if (!skb) 415 if (!skb)
412 return 0; 416 return 0;
413 417
414 data_len = min_t(int, len, urb->sg[0].length - MT_DMA_HDR_LEN);
415 skb_reserve(skb, MT_DMA_HDR_LEN); 418 skb_reserve(skb, MT_DMA_HDR_LEN);
416 if (skb->tail + data_len > skb->end) {
417 dev_kfree_skb(skb);
418 return 1;
419 }
420
421 __skb_put(skb, data_len); 419 __skb_put(skb, data_len);
422 len -= data_len; 420 len -= data_len;
423 421
@@ -585,6 +583,7 @@ static void mt76u_stop_rx(struct mt76_dev *dev)
585static void mt76u_tx_tasklet(unsigned long data) 583static void mt76u_tx_tasklet(unsigned long data)
586{ 584{
587 struct mt76_dev *dev = (struct mt76_dev *)data; 585 struct mt76_dev *dev = (struct mt76_dev *)data;
586 struct mt76_queue_entry entry;
588 struct mt76u_buf *buf; 587 struct mt76u_buf *buf;
589 struct mt76_queue *q; 588 struct mt76_queue *q;
590 bool wake; 589 bool wake;
@@ -599,17 +598,18 @@ static void mt76u_tx_tasklet(unsigned long data)
599 if (!buf->done || !q->queued) 598 if (!buf->done || !q->queued)
600 break; 599 break;
601 600
602 dev->drv->tx_complete_skb(dev, q,
603 &q->entry[q->head],
604 false);
605
606 if (q->entry[q->head].schedule) { 601 if (q->entry[q->head].schedule) {
607 q->entry[q->head].schedule = false; 602 q->entry[q->head].schedule = false;
608 q->swq_queued--; 603 q->swq_queued--;
609 } 604 }
610 605
606 entry = q->entry[q->head];
611 q->head = (q->head + 1) % q->ndesc; 607 q->head = (q->head + 1) % q->ndesc;
612 q->queued--; 608 q->queued--;
609
610 spin_unlock_bh(&q->lock);
611 dev->drv->tx_complete_skb(dev, q, &entry, false);
612 spin_lock_bh(&q->lock);
613 } 613 }
614 mt76_txq_schedule(dev, q); 614 mt76_txq_schedule(dev, q);
615 wake = i < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; 615 wake = i < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8;
diff --git a/drivers/net/wireless/mediatek/mt76/util.c b/drivers/net/wireless/mediatek/mt76/util.c
index 0c35b8db58cd..69270c1a9091 100644
--- a/drivers/net/wireless/mediatek/mt76/util.c
+++ b/drivers/net/wireless/mediatek/mt76/util.c
@@ -75,4 +75,46 @@ int mt76_wcid_alloc(unsigned long *mask, int size)
75} 75}
76EXPORT_SYMBOL_GPL(mt76_wcid_alloc); 76EXPORT_SYMBOL_GPL(mt76_wcid_alloc);
77 77
78int mt76_get_min_avg_rssi(struct mt76_dev *dev)
79{
80 struct mt76_wcid *wcid;
81 int i, j, min_rssi = 0;
82 s8 cur_rssi;
83
84 local_bh_disable();
85 rcu_read_lock();
86
87 for (i = 0; i < ARRAY_SIZE(dev->wcid_mask); i++) {
88 unsigned long mask = dev->wcid_mask[i];
89
90 if (!mask)
91 continue;
92
93 for (j = i * BITS_PER_LONG; mask; j++, mask >>= 1) {
94 if (!(mask & 1))
95 continue;
96
97 wcid = rcu_dereference(dev->wcid[j]);
98 if (!wcid)
99 continue;
100
101 spin_lock(&dev->rx_lock);
102 if (wcid->inactive_count++ < 5)
103 cur_rssi = -ewma_signal_read(&wcid->rssi);
104 else
105 cur_rssi = 0;
106 spin_unlock(&dev->rx_lock);
107
108 if (cur_rssi < min_rssi)
109 min_rssi = cur_rssi;
110 }
111 }
112
113 rcu_read_unlock();
114 local_bh_enable();
115
116 return min_rssi;
117}
118EXPORT_SYMBOL_GPL(mt76_get_min_avg_rssi);
119
78MODULE_LICENSE("Dual BSD/GPL"); 120MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c
index 7f3e3983b781..f7edeffb2b19 100644
--- a/drivers/net/wireless/mediatek/mt7601u/dma.c
+++ b/drivers/net/wireless/mediatek/mt7601u/dma.c
@@ -124,9 +124,9 @@ static u16 mt7601u_rx_next_seg_len(u8 *data, u32 data_len)
124 u16 dma_len = get_unaligned_le16(data); 124 u16 dma_len = get_unaligned_le16(data);
125 125
126 if (data_len < min_seg_len || 126 if (data_len < min_seg_len ||
127 WARN_ON(!dma_len) || 127 WARN_ON_ONCE(!dma_len) ||
128 WARN_ON(dma_len + MT_DMA_HDRS > data_len) || 128 WARN_ON_ONCE(dma_len + MT_DMA_HDRS > data_len) ||
129 WARN_ON(dma_len & 0x3)) 129 WARN_ON_ONCE(dma_len & 0x3))
130 return 0; 130 return 0;
131 131
132 return MT_DMA_HDRS + dma_len; 132 return MT_DMA_HDRS + dma_len;
diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.h b/drivers/net/wireless/mediatek/mt7601u/eeprom.h
index 662d12703b69..57b503ae63f1 100644
--- a/drivers/net/wireless/mediatek/mt7601u/eeprom.h
+++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.h
@@ -17,7 +17,7 @@
17 17
18struct mt7601u_dev; 18struct mt7601u_dev;
19 19
20#define MT7601U_EE_MAX_VER 0x0c 20#define MT7601U_EE_MAX_VER 0x0d
21#define MT7601U_EEPROM_SIZE 256 21#define MT7601U_EEPROM_SIZE 256
22 22
23#define MT7601U_DEFAULT_TX_POWER 6 23#define MT7601U_DEFAULT_TX_POWER 6
diff --git a/drivers/net/wireless/quantenna/Makefile b/drivers/net/wireless/quantenna/Makefile
index baebfbde119e..cea83d178d2e 100644
--- a/drivers/net/wireless/quantenna/Makefile
+++ b/drivers/net/wireless/quantenna/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Copyright (c) 2015-2016 Quantenna Communications, Inc. 3# Copyright (c) 2015-2016 Quantenna Communications, Inc.
3# All rights reserved. 4# All rights reserved.
diff --git a/drivers/net/wireless/quantenna/qtnfmac/bus.h b/drivers/net/wireless/quantenna/qtnfmac/bus.h
index 528ca7f5e070..14b569b6d1b5 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/bus.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/bus.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015 Quantenna Communications 2/* Copyright (c) 2015 Quantenna Communications. All rights reserved. */
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 3
17#ifndef QTNFMAC_BUS_H 4#ifndef QTNFMAC_BUS_H
18#define QTNFMAC_BUS_H 5#define QTNFMAC_BUS_H
@@ -135,7 +122,5 @@ static __always_inline void qtnf_bus_unlock(struct qtnf_bus *bus)
135 122
136int qtnf_core_attach(struct qtnf_bus *bus); 123int qtnf_core_attach(struct qtnf_bus *bus);
137void qtnf_core_detach(struct qtnf_bus *bus); 124void qtnf_core_detach(struct qtnf_bus *bus);
138void qtnf_txflowblock(struct device *dev, bool state);
139void qtnf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
140 125
141#endif /* QTNFMAC_BUS_H */ 126#endif /* QTNFMAC_BUS_H */
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 51b33ec78fac..45f4cef7de9c 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2012-2012 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include <linux/kernel.h> 4#include <linux/kernel.h>
18#include <linux/etherdevice.h> 5#include <linux/etherdevice.h>
@@ -122,7 +109,8 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
122 struct vif_params *params) 109 struct vif_params *params)
123{ 110{
124 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 111 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
125 u8 *mac_addr; 112 u8 *mac_addr = NULL;
113 int use4addr = 0;
126 int ret; 114 int ret;
127 115
128 ret = qtnf_validate_iface_combinations(wiphy, vif, type); 116 ret = qtnf_validate_iface_combinations(wiphy, vif, type);
@@ -132,14 +120,14 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
132 return ret; 120 return ret;
133 } 121 }
134 122
135 if (params) 123 if (params) {
136 mac_addr = params->macaddr; 124 mac_addr = params->macaddr;
137 else 125 use4addr = params->use_4addr;
138 mac_addr = NULL; 126 }
139 127
140 qtnf_scan_done(vif->mac, true); 128 qtnf_scan_done(vif->mac, true);
141 129
142 ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr); 130 ret = qtnf_cmd_send_change_intf_type(vif, type, use4addr, mac_addr);
143 if (ret) { 131 if (ret) {
144 pr_err("VIF%u.%u: failed to change type to %d\n", 132 pr_err("VIF%u.%u: failed to change type to %d\n",
145 vif->mac->macid, vif->vifid, type); 133 vif->mac->macid, vif->vifid, type);
@@ -190,6 +178,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
190 struct qtnf_wmac *mac; 178 struct qtnf_wmac *mac;
191 struct qtnf_vif *vif; 179 struct qtnf_vif *vif;
192 u8 *mac_addr = NULL; 180 u8 *mac_addr = NULL;
181 int use4addr = 0;
193 int ret; 182 int ret;
194 183
195 mac = wiphy_priv(wiphy); 184 mac = wiphy_priv(wiphy);
@@ -225,10 +214,12 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
225 return ERR_PTR(-ENOTSUPP); 214 return ERR_PTR(-ENOTSUPP);
226 } 215 }
227 216
228 if (params) 217 if (params) {
229 mac_addr = params->macaddr; 218 mac_addr = params->macaddr;
219 use4addr = params->use_4addr;
220 }
230 221
231 ret = qtnf_cmd_send_add_intf(vif, type, mac_addr); 222 ret = qtnf_cmd_send_add_intf(vif, type, use4addr, mac_addr);
232 if (ret) { 223 if (ret) {
233 pr_err("VIF%u.%u: failed to add VIF %pM\n", 224 pr_err("VIF%u.%u: failed to add VIF %pM\n",
234 mac->macid, vif->vifid, mac_addr); 225 mac->macid, vif->vifid, mac_addr);
@@ -359,11 +350,6 @@ static int qtnf_set_wiphy_params(struct wiphy *wiphy, u32 changed)
359 return -EFAULT; 350 return -EFAULT;
360 } 351 }
361 352
362 if (changed & (WIPHY_PARAM_RETRY_LONG | WIPHY_PARAM_RETRY_SHORT)) {
363 pr_err("MAC%u: can't modify retry params\n", mac->macid);
364 return -EOPNOTSUPP;
365 }
366
367 ret = qtnf_cmd_send_update_phy_params(mac, changed); 353 ret = qtnf_cmd_send_update_phy_params(mac, changed);
368 if (ret) 354 if (ret)
369 pr_err("MAC%u: failed to update PHY params\n", mac->macid); 355 pr_err("MAC%u: failed to update PHY params\n", mac->macid);
@@ -1107,7 +1093,8 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
1107 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | 1093 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
1108 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD | 1094 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
1109 WIPHY_FLAG_AP_UAPSD | 1095 WIPHY_FLAG_AP_UAPSD |
1110 WIPHY_FLAG_HAS_CHANNEL_SWITCH; 1096 WIPHY_FLAG_HAS_CHANNEL_SWITCH |
1097 WIPHY_FLAG_4ADDR_STATION;
1111 wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 1098 wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1112 1099
1113 if (hw_info->hw_capab & QLINK_HW_CAPAB_DFS_OFFLOAD) 1100 if (hw_info->hw_capab & QLINK_HW_CAPAB_DFS_OFFLOAD)
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
index b73425122a10..c374857283ac 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_CFG80211_H_ 4#ifndef _QTN_FMAC_CFG80211_H_
18#define _QTN_FMAC_CFG80211_H_ 5#define _QTN_FMAC_CFG80211_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 659e7649fe22..0f48f541de41 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1,17 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15 3
16#include <linux/types.h> 4#include <linux/types.h>
17#include <linux/skbuff.h> 5#include <linux/skbuff.h>
@@ -72,6 +60,8 @@ static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode)
72 return -EADDRINUSE; 60 return -EADDRINUSE;
73 case QLINK_CMD_RESULT_EADDRNOTAVAIL: 61 case QLINK_CMD_RESULT_EADDRNOTAVAIL:
74 return -EADDRNOTAVAIL; 62 return -EADDRNOTAVAIL;
63 case QLINK_CMD_RESULT_EBUSY:
64 return -EBUSY;
75 default: 65 default:
76 return -EFAULT; 66 return -EFAULT;
77 } 67 }
@@ -97,14 +87,12 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
97 vif_id = cmd->vifid; 87 vif_id = cmd->vifid;
98 cmd->mhdr.len = cpu_to_le16(cmd_skb->len); 88 cmd->mhdr.len = cpu_to_le16(cmd_skb->len);
99 89
100 pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id, 90 pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id, cmd_id);
101 le16_to_cpu(cmd->cmd_id));
102 91
103 if (bus->fw_state != QTNF_FW_STATE_ACTIVE && 92 if (bus->fw_state != QTNF_FW_STATE_ACTIVE &&
104 le16_to_cpu(cmd->cmd_id) != QLINK_CMD_FW_INIT) { 93 cmd_id != QLINK_CMD_FW_INIT) {
105 pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n", 94 pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n",
106 mac_id, vif_id, le16_to_cpu(cmd->cmd_id), 95 mac_id, vif_id, cmd_id, bus->fw_state);
107 bus->fw_state);
108 dev_kfree_skb(cmd_skb); 96 dev_kfree_skb(cmd_skb);
109 return -ENODEV; 97 return -ENODEV;
110 } 98 }
@@ -138,7 +126,7 @@ out:
138 return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result)); 126 return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result));
139 127
140 pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n", 128 pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n",
141 mac_id, vif_id, le16_to_cpu(cmd->cmd_id), ret); 129 mac_id, vif_id, cmd_id, ret);
142 130
143 return ret; 131 return ret;
144} 132}
@@ -732,6 +720,7 @@ out:
732 720
733static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif, 721static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
734 enum nl80211_iftype iftype, 722 enum nl80211_iftype iftype,
723 int use4addr,
735 u8 *mac_addr, 724 u8 *mac_addr,
736 enum qlink_cmd_type cmd_type) 725 enum qlink_cmd_type cmd_type)
737{ 726{
@@ -749,6 +738,7 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
749 qtnf_bus_lock(vif->mac->bus); 738 qtnf_bus_lock(vif->mac->bus);
750 739
751 cmd = (struct qlink_cmd_manage_intf *)cmd_skb->data; 740 cmd = (struct qlink_cmd_manage_intf *)cmd_skb->data;
741 cmd->intf_info.use4addr = use4addr;
752 742
753 switch (iftype) { 743 switch (iftype) {
754 case NL80211_IFTYPE_AP: 744 case NL80211_IFTYPE_AP:
@@ -784,17 +774,19 @@ out:
784 return ret; 774 return ret;
785} 775}
786 776
787int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, 777int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype,
788 enum nl80211_iftype iftype, u8 *mac_addr) 778 int use4addr, u8 *mac_addr)
789{ 779{
790 return qtnf_cmd_send_add_change_intf(vif, iftype, mac_addr, 780 return qtnf_cmd_send_add_change_intf(vif, iftype, use4addr, mac_addr,
791 QLINK_CMD_ADD_INTF); 781 QLINK_CMD_ADD_INTF);
792} 782}
793 783
794int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif, 784int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif,
795 enum nl80211_iftype iftype, u8 *mac_addr) 785 enum nl80211_iftype iftype,
786 int use4addr,
787 u8 *mac_addr)
796{ 788{
797 return qtnf_cmd_send_add_change_intf(vif, iftype, mac_addr, 789 return qtnf_cmd_send_add_change_intf(vif, iftype, use4addr, mac_addr,
798 QLINK_CMD_CHANGE_INTF); 790 QLINK_CMD_CHANGE_INTF);
799} 791}
800 792
@@ -914,9 +906,8 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,
914 if (WARN_ON(resp->n_reg_rules > NL80211_MAX_SUPP_REG_RULES)) 906 if (WARN_ON(resp->n_reg_rules > NL80211_MAX_SUPP_REG_RULES))
915 return -E2BIG; 907 return -E2BIG;
916 908
917 hwinfo->rd = kzalloc(sizeof(*hwinfo->rd) 909 hwinfo->rd = kzalloc(struct_size(hwinfo->rd, reg_rules,
918 + sizeof(struct ieee80211_reg_rule) 910 resp->n_reg_rules), GFP_KERNEL);
919 * resp->n_reg_rules, GFP_KERNEL);
920 911
921 if (!hwinfo->rd) 912 if (!hwinfo->rd)
922 return -ENOMEM; 913 return -ENOMEM;
@@ -1558,11 +1549,11 @@ static int qtnf_cmd_resp_proc_phy_params(struct qtnf_wmac *mac,
1558 switch (tlv_type) { 1549 switch (tlv_type) {
1559 case QTN_TLV_ID_FRAG_THRESH: 1550 case QTN_TLV_ID_FRAG_THRESH:
1560 phy_thr = (void *)tlv; 1551 phy_thr = (void *)tlv;
1561 mac_info->frag_thr = (u32)le16_to_cpu(phy_thr->thr); 1552 mac_info->frag_thr = le32_to_cpu(phy_thr->thr);
1562 break; 1553 break;
1563 case QTN_TLV_ID_RTS_THRESH: 1554 case QTN_TLV_ID_RTS_THRESH:
1564 phy_thr = (void *)tlv; 1555 phy_thr = (void *)tlv;
1565 mac_info->rts_thr = (u32)le16_to_cpu(phy_thr->thr); 1556 mac_info->rts_thr = le32_to_cpu(phy_thr->thr);
1566 break; 1557 break;
1567 case QTN_TLV_ID_SRETRY_LIMIT: 1558 case QTN_TLV_ID_SRETRY_LIMIT:
1568 limit = (void *)tlv; 1559 limit = (void *)tlv;
@@ -1810,15 +1801,23 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
1810 qtnf_bus_lock(mac->bus); 1801 qtnf_bus_lock(mac->bus);
1811 1802
1812 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) 1803 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
1813 qtnf_cmd_skb_put_tlv_u16(cmd_skb, QTN_TLV_ID_FRAG_THRESH, 1804 qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_FRAG_THRESH,
1814 wiphy->frag_threshold); 1805 wiphy->frag_threshold);
1815 if (changed & WIPHY_PARAM_RTS_THRESHOLD) 1806 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
1816 qtnf_cmd_skb_put_tlv_u16(cmd_skb, QTN_TLV_ID_RTS_THRESH, 1807 qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_RTS_THRESH,
1817 wiphy->rts_threshold); 1808 wiphy->rts_threshold);
1818 if (changed & WIPHY_PARAM_COVERAGE_CLASS) 1809 if (changed & WIPHY_PARAM_COVERAGE_CLASS)
1819 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS, 1810 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS,
1820 wiphy->coverage_class); 1811 wiphy->coverage_class);
1821 1812
1813 if (changed & WIPHY_PARAM_RETRY_LONG)
1814 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_LRETRY_LIMIT,
1815 wiphy->retry_long);
1816
1817 if (changed & WIPHY_PARAM_RETRY_SHORT)
1818 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_SRETRY_LIMIT,
1819 wiphy->retry_short);
1820
1822 ret = qtnf_cmd_send(mac->bus, cmd_skb); 1821 ret = qtnf_cmd_send(mac->bus, cmd_skb);
1823 if (ret) 1822 if (ret)
1824 goto out; 1823 goto out;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h
index 1ac41156c192..96dff643bbc4 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h
@@ -1,17 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2016 Quantenna Communications, Inc. 2/* Copyright (c) 2016 Quantenna Communications. All rights reserved. */
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15 3
16#ifndef QLINK_COMMANDS_H_ 4#ifndef QLINK_COMMANDS_H_
17#define QLINK_COMMANDS_H_ 5#define QLINK_COMMANDS_H_
@@ -26,9 +14,11 @@ void qtnf_cmd_send_deinit_fw(struct qtnf_bus *bus);
26int qtnf_cmd_get_hw_info(struct qtnf_bus *bus); 14int qtnf_cmd_get_hw_info(struct qtnf_bus *bus);
27int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac); 15int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac);
28int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype, 16int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype,
29 u8 *mac_addr); 17 int use4addr, u8 *mac_addr);
30int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif, 18int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif,
31 enum nl80211_iftype iftype, u8 *mac_addr); 19 enum nl80211_iftype iftype,
20 int use4addr,
21 u8 *mac_addr);
32int qtnf_cmd_send_del_intf(struct qtnf_vif *vif); 22int qtnf_cmd_send_del_intf(struct qtnf_vif *vif);
33int qtnf_cmd_band_info_get(struct qtnf_wmac *mac, 23int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
34 struct ieee80211_supported_band *band); 24 struct ieee80211_supported_band *band);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 5d18a4a917c9..ee1b75fda1dd 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include <linux/kernel.h> 4#include <linux/kernel.h>
18#include <linux/module.h> 5#include <linux/module.h>
@@ -195,6 +182,7 @@ static int qtnf_netdev_set_mac_address(struct net_device *ndev, void *addr)
195 qtnf_scan_done(vif->mac, true); 182 qtnf_scan_done(vif->mac, true);
196 183
197 ret = qtnf_cmd_send_change_intf_type(vif, vif->wdev.iftype, 184 ret = qtnf_cmd_send_change_intf_type(vif, vif->wdev.iftype,
185 vif->wdev.use_4addr,
198 sa->sa_data); 186 sa->sa_data);
199 187
200 if (ret) 188 if (ret)
@@ -545,7 +533,8 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
545 goto error; 533 goto error;
546 } 534 }
547 535
548 ret = qtnf_cmd_send_add_intf(vif, vif->wdev.iftype, vif->mac_addr); 536 ret = qtnf_cmd_send_add_intf(vif, vif->wdev.iftype,
537 vif->wdev.use_4addr, vif->mac_addr);
549 if (ret) { 538 if (ret) {
550 pr_err("MAC%u: failed to add VIF\n", macid); 539 pr_err("MAC%u: failed to add VIF\n", macid);
551 goto error; 540 goto error;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h
index 293055049caa..a31cff46e964 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_CORE_H_ 4#ifndef _QTN_FMAC_CORE_H_
18#define _QTN_FMAC_CORE_H_ 5#define _QTN_FMAC_CORE_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/debug.c b/drivers/net/wireless/quantenna/qtnfmac/debug.c
index 9f826b9ef5d9..598ece753a4b 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/debug.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/debug.c
@@ -1,32 +1,11 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include "debug.h" 4#include "debug.h"
18 5
19#undef pr_fmt
20#define pr_fmt(fmt) "qtnfmac dbg: %s: " fmt, __func__
21
22void qtnf_debugfs_init(struct qtnf_bus *bus, const char *name) 6void qtnf_debugfs_init(struct qtnf_bus *bus, const char *name)
23{ 7{
24 bus->dbg_dir = debugfs_create_dir(name, NULL); 8 bus->dbg_dir = debugfs_create_dir(name, NULL);
25
26 if (IS_ERR_OR_NULL(bus->dbg_dir)) {
27 pr_warn("failed to create debugfs root dir\n");
28 bus->dbg_dir = NULL;
29 }
30} 9}
31 10
32void qtnf_debugfs_remove(struct qtnf_bus *bus) 11void qtnf_debugfs_remove(struct qtnf_bus *bus)
@@ -38,9 +17,5 @@ void qtnf_debugfs_remove(struct qtnf_bus *bus)
38void qtnf_debugfs_add_entry(struct qtnf_bus *bus, const char *name, 17void qtnf_debugfs_add_entry(struct qtnf_bus *bus, const char *name,
39 int (*fn)(struct seq_file *seq, void *data)) 18 int (*fn)(struct seq_file *seq, void *data))
40{ 19{
41 struct dentry *entry; 20 debugfs_create_devm_seqfile(bus->dev, name, bus->dbg_dir, fn);
42
43 entry = debugfs_create_devm_seqfile(bus->dev, name, bus->dbg_dir, fn);
44 if (IS_ERR_OR_NULL(entry))
45 pr_warn("failed to add entry (%s)\n", name);
46} 21}
diff --git a/drivers/net/wireless/quantenna/qtnfmac/debug.h b/drivers/net/wireless/quantenna/qtnfmac/debug.h
index d6dd12b5d434..61b45536b83a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/debug.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/debug.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_DEBUG_H_ 4#ifndef _QTN_FMAC_DEBUG_H_
18#define _QTN_FMAC_DEBUG_H_ 5#define _QTN_FMAC_DEBUG_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 8b542b431b75..3fd1a9217737 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include <linux/kernel.h> 4#include <linux/kernel.h>
18#include <linux/module.h> 5#include <linux/module.h>
@@ -158,6 +145,12 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,
158 const struct qlink_event_bss_join *join_info, 145 const struct qlink_event_bss_join *join_info,
159 u16 len) 146 u16 len)
160{ 147{
148 struct wiphy *wiphy = priv_to_wiphy(vif->mac);
149 enum ieee80211_statuscode status = le16_to_cpu(join_info->status);
150 struct cfg80211_chan_def chandef;
151 struct cfg80211_bss *bss = NULL;
152 u8 *ie = NULL;
153
161 if (unlikely(len < sizeof(*join_info))) { 154 if (unlikely(len < sizeof(*join_info))) {
162 pr_err("VIF%u.%u: payload is too short (%u < %zu)\n", 155 pr_err("VIF%u.%u: payload is too short (%u < %zu)\n",
163 vif->mac->macid, vif->vifid, len, 156 vif->mac->macid, vif->vifid, len,
@@ -171,15 +164,80 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,
171 return -EPROTO; 164 return -EPROTO;
172 } 165 }
173 166
174 pr_debug("VIF%u.%u: BSSID:%pM\n", vif->mac->macid, vif->vifid, 167 pr_debug("VIF%u.%u: BSSID:%pM status:%u\n",
175 join_info->bssid); 168 vif->mac->macid, vif->vifid, join_info->bssid, status);
169
170 if (status == WLAN_STATUS_SUCCESS) {
171 qlink_chandef_q2cfg(wiphy, &join_info->chan, &chandef);
172 if (!cfg80211_chandef_valid(&chandef)) {
173 pr_warn("MAC%u.%u: bad channel freq=%u cf1=%u cf2=%u bw=%u\n",
174 vif->mac->macid, vif->vifid,
175 chandef.chan->center_freq,
176 chandef.center_freq1,
177 chandef.center_freq2,
178 chandef.width);
179 status = WLAN_STATUS_UNSPECIFIED_FAILURE;
180 goto done;
181 }
176 182
183 bss = cfg80211_get_bss(wiphy, chandef.chan, join_info->bssid,
184 NULL, 0, IEEE80211_BSS_TYPE_ESS,
185 IEEE80211_PRIVACY_ANY);
186 if (!bss) {
187 pr_warn("VIF%u.%u: add missing BSS:%pM chan:%u\n",
188 vif->mac->macid, vif->vifid,
189 join_info->bssid, chandef.chan->hw_value);
190
191 if (!vif->wdev.ssid_len) {
192 pr_warn("VIF%u.%u: SSID unknown for BSS:%pM\n",
193 vif->mac->macid, vif->vifid,
194 join_info->bssid);
195 status = WLAN_STATUS_UNSPECIFIED_FAILURE;
196 goto done;
197 }
198
199 ie = kzalloc(2 + vif->wdev.ssid_len, GFP_KERNEL);
200 if (!ie) {
201 pr_warn("VIF%u.%u: IE alloc failed for BSS:%pM\n",
202 vif->mac->macid, vif->vifid,
203 join_info->bssid);
204 status = WLAN_STATUS_UNSPECIFIED_FAILURE;
205 goto done;
206 }
207
208 ie[0] = WLAN_EID_SSID;
209 ie[1] = vif->wdev.ssid_len;
210 memcpy(ie + 2, vif->wdev.ssid, vif->wdev.ssid_len);
211
212 bss = cfg80211_inform_bss(wiphy, chandef.chan,
213 CFG80211_BSS_FTYPE_UNKNOWN,
214 join_info->bssid, 0,
215 WLAN_CAPABILITY_ESS, 100,
216 ie, 2 + vif->wdev.ssid_len,
217 0, GFP_KERNEL);
218 if (!bss) {
219 pr_warn("VIF%u.%u: can't connect to unknown BSS: %pM\n",
220 vif->mac->macid, vif->vifid,
221 join_info->bssid);
222 status = WLAN_STATUS_UNSPECIFIED_FAILURE;
223 goto done;
224 }
225 }
226 }
227
228done:
177 cfg80211_connect_result(vif->netdev, join_info->bssid, NULL, 0, NULL, 229 cfg80211_connect_result(vif->netdev, join_info->bssid, NULL, 0, NULL,
178 0, le16_to_cpu(join_info->status), GFP_KERNEL); 230 0, status, GFP_KERNEL);
231 if (bss) {
232 if (!ether_addr_equal(vif->bssid, join_info->bssid))
233 ether_addr_copy(vif->bssid, join_info->bssid);
234 cfg80211_put_bss(wiphy, bss);
235 }
179 236
180 if (le16_to_cpu(join_info->status) == WLAN_STATUS_SUCCESS) 237 if (status == WLAN_STATUS_SUCCESS)
181 netif_carrier_on(vif->netdev); 238 netif_carrier_on(vif->netdev);
182 239
240 kfree(ie);
183 return 0; 241 return 0;
184} 242}
185 243
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.h b/drivers/net/wireless/quantenna/qtnfmac/event.h
index ae759b602c2a..533ad99d045d 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_EVENT_H_ 4#ifndef _QTN_FMAC_EVENT_H_
18#define _QTN_FMAC_EVENT_H_ 5#define _QTN_FMAC_EVENT_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
index 598edb814421..cbcda57105f3 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
@@ -559,6 +559,9 @@ static irqreturn_t qtnf_pcie_topaz_interrupt(int irq, void *data)
559 if (!priv->msi_enabled && !qtnf_topaz_intx_asserted(ts)) 559 if (!priv->msi_enabled && !qtnf_topaz_intx_asserted(ts))
560 return IRQ_NONE; 560 return IRQ_NONE;
561 561
562 if (!priv->msi_enabled)
563 qtnf_deassert_intx(ts);
564
562 priv->pcie_irq_count++; 565 priv->pcie_irq_count++;
563 566
564 qtnf_shm_ipc_irq_handler(&priv->shm_ipc_ep_in); 567 qtnf_shm_ipc_irq_handler(&priv->shm_ipc_ep_in);
@@ -571,9 +574,6 @@ static irqreturn_t qtnf_pcie_topaz_interrupt(int irq, void *data)
571 574
572 tasklet_hi_schedule(&priv->reclaim_tq); 575 tasklet_hi_schedule(&priv->reclaim_tq);
573 576
574 if (!priv->msi_enabled)
575 qtnf_deassert_intx(ts);
576
577 return IRQ_HANDLED; 577 return IRQ_HANDLED;
578} 578}
579 579
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index 8d62addea895..27fdb5b01ee3 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -1,25 +1,12 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_QLINK_H_ 4#ifndef _QTN_QLINK_H_
18#define _QTN_QLINK_H_ 5#define _QTN_QLINK_H_
19 6
20#include <linux/ieee80211.h> 7#include <linux/ieee80211.h>
21 8
22#define QLINK_PROTO_VER 11 9#define QLINK_PROTO_VER 13
23 10
24#define QLINK_MACID_RSVD 0xFF 11#define QLINK_MACID_RSVD 0xFF
25#define QLINK_VIFID_RSVD 0xFF 12#define QLINK_VIFID_RSVD 0xFF
@@ -105,7 +92,8 @@ struct qlink_intf_info {
105 __le16 if_type; 92 __le16 if_type;
106 __le16 vlanid; 93 __le16 vlanid;
107 u8 mac_addr[ETH_ALEN]; 94 u8 mac_addr[ETH_ALEN];
108 u8 rsvd[2]; 95 u8 use4addr;
96 u8 rsvd[1];
109} __packed; 97} __packed;
110 98
111enum qlink_sta_flags { 99enum qlink_sta_flags {
@@ -733,6 +721,7 @@ enum qlink_cmd_result {
733 QLINK_CMD_RESULT_EALREADY, 721 QLINK_CMD_RESULT_EALREADY,
734 QLINK_CMD_RESULT_EADDRINUSE, 722 QLINK_CMD_RESULT_EADDRINUSE,
735 QLINK_CMD_RESULT_EADDRNOTAVAIL, 723 QLINK_CMD_RESULT_EADDRNOTAVAIL,
724 QLINK_CMD_RESULT_EBUSY,
736}; 725};
737 726
738/** 727/**
@@ -986,11 +975,13 @@ struct qlink_event_sta_deauth {
986/** 975/**
987 * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event 976 * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event
988 * 977 *
978 * @chan: new operating channel definition
989 * @bssid: BSSID of a BSS which interface tried to joined. 979 * @bssid: BSSID of a BSS which interface tried to joined.
990 * @status: status of joining attempt, see &enum ieee80211_statuscode. 980 * @status: status of joining attempt, see &enum ieee80211_statuscode.
991 */ 981 */
992struct qlink_event_bss_join { 982struct qlink_event_bss_join {
993 struct qlink_event ehdr; 983 struct qlink_event ehdr;
984 struct qlink_chandef chan;
994 u8 bssid[ETH_ALEN]; 985 u8 bssid[ETH_ALEN];
995 __le16 status; 986 __le16 status;
996} __packed; 987} __packed;
@@ -1182,7 +1173,7 @@ struct qlink_iface_limit_record {
1182 1173
1183struct qlink_tlv_frag_rts_thr { 1174struct qlink_tlv_frag_rts_thr {
1184 struct qlink_tlv_hdr hdr; 1175 struct qlink_tlv_hdr hdr;
1185 __le16 thr; 1176 __le32 thr;
1186} __packed; 1177} __packed;
1187 1178
1188struct qlink_tlv_rlimit { 1179struct qlink_tlv_rlimit {
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
index aeeda81b09ea..72bfd17cb687 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
@@ -1,17 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15 3
16#include <linux/nl80211.h> 4#include <linux/nl80211.h>
17 5
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
index 960d5d97492f..781ea7fe79f2 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_QLINK_UTIL_H_ 4#ifndef _QTN_FMAC_QLINK_UTIL_H_
18#define _QTN_FMAC_QLINK_UTIL_H_ 5#define _QTN_FMAC_QLINK_UTIL_H_
@@ -69,6 +56,17 @@ static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
69 memcpy(hdr->val, &tmp, sizeof(tmp)); 56 memcpy(hdr->val, &tmp, sizeof(tmp));
70} 57}
71 58
59static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb,
60 u16 tlv_id, u32 value)
61{
62 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
63 __le32 tmp = cpu_to_le32(value);
64
65 hdr->type = cpu_to_le16(tlv_id);
66 hdr->len = cpu_to_le16(sizeof(value));
67 memcpy(hdr->val, &tmp, sizeof(tmp));
68}
69
72u16 qlink_iface_type_to_nl_mask(u16 qlink_type); 70u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
73u8 qlink_chan_width_mask_to_nl(u16 qlink_mask); 71u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
74void qlink_chandef_q2cfg(struct wiphy *wiphy, 72void qlink_chandef_q2cfg(struct wiphy *wiphy,
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qtn_hw_ids.h b/drivers/net/wireless/quantenna/qtnfmac/qtn_hw_ids.h
index 40295a511224..82d879950b62 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qtn_hw_ids.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qtn_hw_ids.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_HW_IDS_H_ 4#ifndef _QTN_HW_IDS_H_
18#define _QTN_HW_IDS_H_ 5#define _QTN_HW_IDS_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.c b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.c
index 2ec334199c2b..ff678951d3b2 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include <linux/types.h> 4#include <linux/types.h>
18#include <linux/io.h> 5#include <linux/io.h>
diff --git a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.h b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.h
index c2a3702a9ee7..52cac5439b03 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_SHM_IPC_H_ 4#ifndef _QTN_FMAC_SHM_IPC_H_
18#define _QTN_FMAC_SHM_IPC_H_ 5#define _QTN_FMAC_SHM_IPC_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc_defs.h b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc_defs.h
index 95a5f89a8b1a..78be70df1218 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/shm_ipc_defs.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/shm_ipc_defs.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_SHM_IPC_DEFS_H_ 4#ifndef _QTN_FMAC_SHM_IPC_DEFS_H_
18#define _QTN_FMAC_SHM_IPC_DEFS_H_ 5#define _QTN_FMAC_SHM_IPC_DEFS_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/trans.c b/drivers/net/wireless/quantenna/qtnfmac/trans.c
index 345f34ec9750..95356e280e23 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/trans.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/trans.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include <linux/types.h> 4#include <linux/types.h>
18#include <linux/export.h> 5#include <linux/export.h>
diff --git a/drivers/net/wireless/quantenna/qtnfmac/trans.h b/drivers/net/wireless/quantenna/qtnfmac/trans.h
index 9a473e07af0f..c0b76f871b31 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/trans.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/trans.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#ifndef _QTN_FMAC_TRANS_H_ 4#ifndef _QTN_FMAC_TRANS_H_
18#define _QTN_FMAC_TRANS_H_ 5#define _QTN_FMAC_TRANS_H_
diff --git a/drivers/net/wireless/quantenna/qtnfmac/util.c b/drivers/net/wireless/quantenna/qtnfmac/util.c
index 3bc96b264769..cda6f5f3f38a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/util.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/util.c
@@ -1,18 +1,5 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 2/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16 3
17#include "util.h" 4#include "util.h"
18#include "qtn_hw_ids.h" 5#include "qtn_hw_ids.h"
diff --git a/drivers/net/wireless/quantenna/qtnfmac/util.h b/drivers/net/wireless/quantenna/qtnfmac/util.h
index b8744baac332..a14b7078a9c7 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/util.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/util.h
@@ -1,18 +1,5 @@
1/* 1/* SPDX-License-Identifier: GPL-2.0+ */
2 * Copyright (c) 2015 Quantenna Communications 2/* Copyright (c) 2015 Quantenna Communications. All rights reserved. */
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 3
17#ifndef QTNFMAC_UTIL_H 4#ifndef QTNFMAC_UTIL_H
18#define QTNFMAC_UTIL_H 5#define QTNFMAC_UTIL_H
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 0e95555aec62..7f813f6f8792 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -5477,7 +5477,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
5477 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); 5477 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
5478 rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002); 5478 rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002);
5479 rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F); 5479 rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F);
5480 rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x06060606); 5480 rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000);
5481 rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); 5481 rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0);
5482 rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0); 5482 rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0);
5483 rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C); 5483 rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
index 61ba573e8bf1..05a2e8da412c 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
@@ -656,36 +656,24 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
656 intf->driver_folder = 656 intf->driver_folder =
657 debugfs_create_dir(intf->rt2x00dev->ops->name, 657 debugfs_create_dir(intf->rt2x00dev->ops->name,
658 rt2x00dev->hw->wiphy->debugfsdir); 658 rt2x00dev->hw->wiphy->debugfsdir);
659 if (IS_ERR(intf->driver_folder) || !intf->driver_folder)
660 goto exit;
661 659
662 intf->driver_entry = 660 intf->driver_entry =
663 rt2x00debug_create_file_driver("driver", intf, &intf->driver_blob); 661 rt2x00debug_create_file_driver("driver", intf, &intf->driver_blob);
664 if (IS_ERR(intf->driver_entry) || !intf->driver_entry)
665 goto exit;
666 662
667 intf->chipset_entry = 663 intf->chipset_entry =
668 rt2x00debug_create_file_chipset("chipset", 664 rt2x00debug_create_file_chipset("chipset",
669 intf, &intf->chipset_blob); 665 intf, &intf->chipset_blob);
670 if (IS_ERR(intf->chipset_entry) || !intf->chipset_entry)
671 goto exit;
672 666
673 intf->dev_flags = debugfs_create_file("dev_flags", 0400, 667 intf->dev_flags = debugfs_create_file("dev_flags", 0400,
674 intf->driver_folder, intf, 668 intf->driver_folder, intf,
675 &rt2x00debug_fop_dev_flags); 669 &rt2x00debug_fop_dev_flags);
676 if (IS_ERR(intf->dev_flags) || !intf->dev_flags)
677 goto exit;
678 670
679 intf->cap_flags = debugfs_create_file("cap_flags", 0400, 671 intf->cap_flags = debugfs_create_file("cap_flags", 0400,
680 intf->driver_folder, intf, 672 intf->driver_folder, intf,
681 &rt2x00debug_fop_cap_flags); 673 &rt2x00debug_fop_cap_flags);
682 if (IS_ERR(intf->cap_flags) || !intf->cap_flags)
683 goto exit;
684 674
685 intf->register_folder = 675 intf->register_folder =
686 debugfs_create_dir("register", intf->driver_folder); 676 debugfs_create_dir("register", intf->driver_folder);
687 if (IS_ERR(intf->register_folder) || !intf->register_folder)
688 goto exit;
689 677
690#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \ 678#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \
691({ \ 679({ \
@@ -695,9 +683,6 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
695 0600, \ 683 0600, \
696 (__intf)->register_folder, \ 684 (__intf)->register_folder, \
697 &(__intf)->offset_##__name); \ 685 &(__intf)->offset_##__name); \
698 if (IS_ERR((__intf)->__name##_off_entry) || \
699 !(__intf)->__name##_off_entry) \
700 goto exit; \
701 \ 686 \
702 (__intf)->__name##_val_entry = \ 687 (__intf)->__name##_val_entry = \
703 debugfs_create_file(__stringify(__name) "_value", \ 688 debugfs_create_file(__stringify(__name) "_value", \
@@ -705,9 +690,6 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
705 (__intf)->register_folder, \ 690 (__intf)->register_folder, \
706 (__intf), \ 691 (__intf), \
707 &rt2x00debug_fop_##__name); \ 692 &rt2x00debug_fop_##__name); \
708 if (IS_ERR((__intf)->__name##_val_entry) || \
709 !(__intf)->__name##_val_entry) \
710 goto exit; \
711 } \ 693 } \
712}) 694})
713 695
@@ -721,15 +703,10 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
721 703
722 intf->queue_folder = 704 intf->queue_folder =
723 debugfs_create_dir("queue", intf->driver_folder); 705 debugfs_create_dir("queue", intf->driver_folder);
724 if (IS_ERR(intf->queue_folder) || !intf->queue_folder)
725 goto exit;
726 706
727 intf->queue_frame_dump_entry = 707 intf->queue_frame_dump_entry =
728 debugfs_create_file("dump", 0400, intf->queue_folder, 708 debugfs_create_file("dump", 0400, intf->queue_folder,
729 intf, &rt2x00debug_fop_queue_dump); 709 intf, &rt2x00debug_fop_queue_dump);
730 if (IS_ERR(intf->queue_frame_dump_entry)
731 || !intf->queue_frame_dump_entry)
732 goto exit;
733 710
734 skb_queue_head_init(&intf->frame_dump_skbqueue); 711 skb_queue_head_init(&intf->frame_dump_skbqueue);
735 init_waitqueue_head(&intf->frame_dump_waitqueue); 712 init_waitqueue_head(&intf->frame_dump_waitqueue);
@@ -747,10 +724,6 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
747#endif 724#endif
748 725
749 return; 726 return;
750
751exit:
752 rt2x00debug_deregister(rt2x00dev);
753 rt2x00_err(rt2x00dev, "Failed to register debug handler\n");
754} 727}
755 728
756void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev) 729void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt61pci.c b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
index 4c5de8fc8f12..52b9fc480f8b 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
@@ -321,97 +321,12 @@ static int rt61pci_config_shared_key(struct rt2x00_dev *rt2x00dev,
321 struct rt2x00lib_crypto *crypto, 321 struct rt2x00lib_crypto *crypto,
322 struct ieee80211_key_conf *key) 322 struct ieee80211_key_conf *key)
323{ 323{
324 struct hw_key_entry key_entry;
325 struct rt2x00_field32 field;
326 u32 mask;
327 u32 reg;
328
329 if (crypto->cmd == SET_KEY) {
330 /*
331 * rt2x00lib can't determine the correct free
332 * key_idx for shared keys. We have 1 register
333 * with key valid bits. The goal is simple, read
334 * the register, if that is full we have no slots
335 * left.
336 * Note that each BSS is allowed to have up to 4
337 * shared keys, so put a mask over the allowed
338 * entries.
339 */
340 mask = (0xf << crypto->bssidx);
341
342 reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR0);
343 reg &= mask;
344
345 if (reg && reg == mask)
346 return -ENOSPC;
347
348 key->hw_key_idx += reg ? ffz(reg) : 0;
349
350 /*
351 * Upload key to hardware
352 */
353 memcpy(key_entry.key, crypto->key,
354 sizeof(key_entry.key));
355 memcpy(key_entry.tx_mic, crypto->tx_mic,
356 sizeof(key_entry.tx_mic));
357 memcpy(key_entry.rx_mic, crypto->rx_mic,
358 sizeof(key_entry.rx_mic));
359
360 reg = SHARED_KEY_ENTRY(key->hw_key_idx);
361 rt2x00mmio_register_multiwrite(rt2x00dev, reg,
362 &key_entry, sizeof(key_entry));
363
364 /*
365 * The cipher types are stored over 2 registers.
366 * bssidx 0 and 1 keys are stored in SEC_CSR1 and
367 * bssidx 1 and 2 keys are stored in SEC_CSR5.
368 * Using the correct defines correctly will cause overhead,
369 * so just calculate the correct offset.
370 */
371 if (key->hw_key_idx < 8) {
372 field.bit_offset = (3 * key->hw_key_idx);
373 field.bit_mask = 0x7 << field.bit_offset;
374
375 reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR1);
376 rt2x00_set_field32(&reg, field, crypto->cipher);
377 rt2x00mmio_register_write(rt2x00dev, SEC_CSR1, reg);
378 } else {
379 field.bit_offset = (3 * (key->hw_key_idx - 8));
380 field.bit_mask = 0x7 << field.bit_offset;
381
382 reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR5);
383 rt2x00_set_field32(&reg, field, crypto->cipher);
384 rt2x00mmio_register_write(rt2x00dev, SEC_CSR5, reg);
385 }
386
387 /*
388 * The driver does not support the IV/EIV generation
389 * in hardware. However it doesn't support the IV/EIV
390 * inside the ieee80211 frame either, but requires it
391 * to be provided separately for the descriptor.
392 * rt2x00lib will cut the IV/EIV data out of all frames
393 * given to us by mac80211, but we must tell mac80211
394 * to generate the IV/EIV data.
395 */
396 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
397 }
398
399 /* 324 /*
400 * SEC_CSR0 contains only single-bit fields to indicate 325 * Let the software handle the shared keys,
401 * a particular key is valid. Because using the FIELD32() 326 * since the hardware decryption does not work reliably,
402 * defines directly will cause a lot of overhead, we use 327 * because the firmware does not know the key's keyidx.
403 * a calculation to determine the correct bit directly.
404 */ 328 */
405 mask = 1 << key->hw_key_idx; 329 return -EOPNOTSUPP;
406
407 reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR0);
408 if (crypto->cmd == SET_KEY)
409 reg |= mask;
410 else if (crypto->cmd == DISABLE_KEY)
411 reg &= ~mask;
412 rt2x00mmio_register_write(rt2x00dev, SEC_CSR0, reg);
413
414 return 0;
415} 330}
416 331
417static int rt61pci_config_pairwise_key(struct rt2x00_dev *rt2x00dev, 332static int rt61pci_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 33ad87528d9a..44a943d18b84 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -959,7 +959,7 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
959 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) { 959 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
960 /* This is the selective translation table, only 2 entries */ 960 /* This is the selective translation table, only 2 entries */
961 writeb(0xf8, 961 writeb(0xf8,
962 &((struct snaphdr_t __iomem *)ptx->var)->org[3]); 962 &((struct snaphdr_t __iomem *)ptx->var)->org[2]);
963 } 963 }
964 /* Copy body of ethernet packet without ethernet header */ 964 /* Copy body of ethernet packet without ethernet header */
965 memcpy_toio((void __iomem *)&ptx->var + 965 memcpy_toio((void __iomem *)&ptx->var +
@@ -2211,7 +2211,7 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
2211 untranslate(local, skb, total_len); 2211 untranslate(local, skb, total_len);
2212 } 2212 }
2213 } else { /* sniffer mode, so just pass whole packet */ 2213 } else { /* sniffer mode, so just pass whole packet */
2214 }; 2214 }
2215 2215
2216/************************/ 2216/************************/
2217 /* Now pick up the rest of the fragments if any */ 2217 /* Now pick up the rest of the fragments if any */
diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8180/Makefile b/drivers/net/wireless/realtek/rtl818x/rtl8180/Makefile
index 2966681efaef..5d6b06d3c02c 100644
--- a/drivers/net/wireless/realtek/rtl818x/rtl8180/Makefile
+++ b/drivers/net/wireless/realtek/rtl818x/rtl8180/Makefile
@@ -2,4 +2,4 @@ rtl818x_pci-objs := dev.o rtl8225.o sa2400.o max2820.o grf5101.o rtl8225se.o
2 2
3obj-$(CONFIG_RTL8180) += rtl818x_pci.o 3obj-$(CONFIG_RTL8180) += rtl818x_pci.o
4 4
5ccflags-y += -Idrivers/net/wireless/realtek/rtl818x 5ccflags-y += -I $(srctree)/$(src)/..
diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
index 225c1c8851cc..e2b1bfbcfbd4 100644
--- a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
@@ -803,7 +803,7 @@ static void rtl8180_config_cardbus(struct ieee80211_hw *dev)
803 rtl818x_iowrite16(priv, FEMR_SE, 0xffff); 803 rtl818x_iowrite16(priv, FEMR_SE, 0xffff);
804 } else { 804 } else {
805 reg16 = rtl818x_ioread16(priv, &priv->map->FEMR); 805 reg16 = rtl818x_ioread16(priv, &priv->map->FEMR);
806 reg16 |= (1 << 15) | (1 << 14) | (1 << 4); 806 reg16 |= (1 << 15) | (1 << 14) | (1 << 4);
807 rtl818x_iowrite16(priv, &priv->map->FEMR, reg16); 807 rtl818x_iowrite16(priv, &priv->map->FEMR, reg16);
808 } 808 }
809 809
diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/Makefile b/drivers/net/wireless/realtek/rtl818x/rtl8187/Makefile
index ff074912a095..95bac73ece7c 100644
--- a/drivers/net/wireless/realtek/rtl818x/rtl8187/Makefile
+++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/Makefile
@@ -2,4 +2,4 @@ rtl8187-objs := dev.o rtl8225.o leds.o rfkill.o
2 2
3obj-$(CONFIG_RTL8187) += rtl8187.o 3obj-$(CONFIG_RTL8187) += rtl8187.o
4 4
5ccflags-y += -Idrivers/net/wireless/realtek/rtl818x 5ccflags-y += -I $(srctree)/$(src)/..
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index ef9b502ce576..7aa68fe5d791 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2172,8 +2172,6 @@ label_lps_done:
2172 ; 2172 ;
2173 } 2173 }
2174 2174
2175 rtlpriv->link_info.num_rx_inperiod = 0;
2176 rtlpriv->link_info.num_tx_inperiod = 0;
2177 for (tid = 0; tid <= 7; tid++) 2175 for (tid = 0; tid <= 7; tid++)
2178 rtlpriv->link_info.tidtx_inperiod[tid] = 0; 2176 rtlpriv->link_info.tidtx_inperiod[tid] = 0;
2179 2177
@@ -2236,6 +2234,8 @@ label_lps_done:
2236 rtlpriv->btcoexist.btc_info.in_4way = false; 2234 rtlpriv->btcoexist.btc_info.in_4way = false;
2237 } 2235 }
2238 2236
2237 rtlpriv->link_info.num_rx_inperiod = 0;
2238 rtlpriv->link_info.num_tx_inperiod = 0;
2239 rtlpriv->link_info.bcn_rx_inperiod = 0; 2239 rtlpriv->link_info.bcn_rx_inperiod = 0;
2240 2240
2241 /* <6> scan list */ 2241 /* <6> scan list */
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index 4bf7967590ca..ce23339bf9fb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -1957,5 +1957,7 @@ void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
1957 dm_digtable->bt30_cur_igi = 0x32; 1957 dm_digtable->bt30_cur_igi = 0x32;
1958 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX; 1958 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
1959 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI; 1959 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
1960 dm_digtable->pre_cck_fa_state = 0;
1961 dm_digtable->cur_cck_fa_state = 0;
1960} 1962}
1961EXPORT_SYMBOL(rtl_dm_diginit); 1963EXPORT_SYMBOL(rtl_dm_diginit);
diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c b/drivers/net/wireless/realtek/rtlwifi/debug.c
index d70385be9976..8186650efc56 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.c
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
@@ -463,12 +463,9 @@ static const struct file_operations file_ops_common_write = {
463#define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \ 463#define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \
464 do { \ 464 do { \
465 rtl_debug_priv_ ##name.rtlpriv = rtlpriv; \ 465 rtl_debug_priv_ ##name.rtlpriv = rtlpriv; \
466 if (!debugfs_create_file(#name, mode, \ 466 debugfs_create_file(#name, mode, parent, \
467 parent, &rtl_debug_priv_ ##name, \ 467 &rtl_debug_priv_ ##name, \
468 &file_ops_ ##fopname)) \ 468 &file_ops_ ##fopname); \
469 pr_err("Unable to initialize debugfs:%s/%s\n", \
470 rtlpriv->dbg.debugfs_name, \
471 #name); \
472 } while (0) 469 } while (0)
473 470
474#define RTL_DEBUGFS_ADD(name) \ 471#define RTL_DEBUGFS_ADD(name) \
@@ -486,11 +483,6 @@ void rtl_debug_add_one(struct ieee80211_hw *hw)
486 483
487 rtlpriv->dbg.debugfs_dir = 484 rtlpriv->dbg.debugfs_dir =
488 debugfs_create_dir(rtlpriv->dbg.debugfs_name, debugfs_topdir); 485 debugfs_create_dir(rtlpriv->dbg.debugfs_name, debugfs_topdir);
489 if (!rtlpriv->dbg.debugfs_dir) {
490 pr_err("Unable to init debugfs:/%s/%s\n", rtlpriv->cfg->name,
491 rtlpriv->dbg.debugfs_name);
492 return;
493 }
494 486
495 parent = rtlpriv->dbg.debugfs_dir; 487 parent = rtlpriv->dbg.debugfs_dir;
496 488
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c
index 42a6fba90ba9..acfd54c6f8dd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c
@@ -151,8 +151,14 @@ static u8 rtl8723e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
151{ 151{
152 struct rtl_priv *rtlpriv = rtl_priv(hw); 152 struct rtl_priv *rtlpriv = rtl_priv(hw);
153 struct dig_t *dm_digtable = &rtlpriv->dm_digtable; 153 struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
154 struct rtl_mac *mac = rtl_mac(rtlpriv);
154 long rssi_val_min = 0; 155 long rssi_val_min = 0;
155 156
157 if (mac->link_state == MAC80211_LINKED &&
158 mac->opmode == NL80211_IFTYPE_STATION &&
159 rtlpriv->link_info.bcn_rx_inperiod == 0)
160 return 0;
161
156 if ((dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) && 162 if ((dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) &&
157 (dm_digtable->cursta_cstate == DIG_STA_CONNECT)) { 163 (dm_digtable->cursta_cstate == DIG_STA_CONNECT)) {
158 if (rtlpriv->dm.entry_min_undec_sm_pwdb != 0) 164 if (rtlpriv->dm.entry_min_undec_sm_pwdb != 0)
@@ -417,6 +423,8 @@ static void rtl8723e_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
417 } else { 423 } else {
418 rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); 424 rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd);
419 rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x47); 425 rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x47);
426 dm_digtable->pre_cck_fa_state = 0;
427 dm_digtable->cur_cck_fa_state = 0;
420 428
421 } 429 }
422 dm_digtable->pre_cck_pd_state = dm_digtable->cur_cck_pd_state; 430 dm_digtable->pre_cck_pd_state = dm_digtable->cur_cck_pd_state;
@@ -665,7 +673,7 @@ void rtl8723e_dm_check_txpower_tracking(struct ieee80211_hw *hw)
665void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw) 673void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
666{ 674{
667 struct rtl_priv *rtlpriv = rtl_priv(hw); 675 struct rtl_priv *rtlpriv = rtl_priv(hw);
668 struct rate_adaptive *p_ra = &(rtlpriv->ra); 676 struct rate_adaptive *p_ra = &rtlpriv->ra;
669 677
670 p_ra->ratr_state = DM_RATR_STA_INIT; 678 p_ra->ratr_state = DM_RATR_STA_INIT;
671 p_ra->pre_ratr_state = DM_RATR_STA_INIT; 679 p_ra->pre_ratr_state = DM_RATR_STA_INIT;
@@ -677,6 +685,89 @@ void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
677 685
678} 686}
679 687
688void rtl8723e_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
689{
690 struct rtl_priv *rtlpriv = rtl_priv(hw);
691 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
692 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
693 struct rate_adaptive *p_ra = &rtlpriv->ra;
694 u32 low_rssithresh_for_ra, high_rssithresh_for_ra;
695 struct ieee80211_sta *sta = NULL;
696
697 if (is_hal_stop(rtlhal)) {
698 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
699 " driver is going to unload\n");
700 return;
701 }
702
703 if (!rtlpriv->dm.useramask) {
704 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
705 " driver does not control rate adaptive mask\n");
706 return;
707 }
708
709 if (mac->link_state == MAC80211_LINKED &&
710 mac->opmode == NL80211_IFTYPE_STATION) {
711 switch (p_ra->pre_ratr_state) {
712 case DM_RATR_STA_HIGH:
713 high_rssithresh_for_ra = 50;
714 low_rssithresh_for_ra = 20;
715 break;
716 case DM_RATR_STA_MIDDLE:
717 high_rssithresh_for_ra = 55;
718 low_rssithresh_for_ra = 20;
719 break;
720 case DM_RATR_STA_LOW:
721 high_rssithresh_for_ra = 60;
722 low_rssithresh_for_ra = 25;
723 break;
724 default:
725 high_rssithresh_for_ra = 50;
726 low_rssithresh_for_ra = 20;
727 break;
728 }
729
730 if (rtlpriv->link_info.bcn_rx_inperiod == 0)
731 switch (p_ra->pre_ratr_state) {
732 case DM_RATR_STA_HIGH:
733 default:
734 p_ra->ratr_state = DM_RATR_STA_MIDDLE;
735 break;
736 case DM_RATR_STA_MIDDLE:
737 case DM_RATR_STA_LOW:
738 p_ra->ratr_state = DM_RATR_STA_LOW;
739 break;
740 }
741 else if (rtlpriv->dm.undec_sm_pwdb > high_rssithresh_for_ra)
742 p_ra->ratr_state = DM_RATR_STA_HIGH;
743 else if (rtlpriv->dm.undec_sm_pwdb > low_rssithresh_for_ra)
744 p_ra->ratr_state = DM_RATR_STA_MIDDLE;
745 else
746 p_ra->ratr_state = DM_RATR_STA_LOW;
747
748 if (p_ra->pre_ratr_state != p_ra->ratr_state) {
749 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
750 "RSSI = %ld\n",
751 rtlpriv->dm.undec_sm_pwdb);
752 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
753 "RSSI_LEVEL = %d\n", p_ra->ratr_state);
754 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
755 "PreState = %d, CurState = %d\n",
756 p_ra->pre_ratr_state, p_ra->ratr_state);
757
758 rcu_read_lock();
759 sta = rtl_find_sta(hw, mac->bssid);
760 if (sta)
761 rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
762 p_ra->ratr_state,
763 true);
764 rcu_read_unlock();
765
766 p_ra->pre_ratr_state = p_ra->ratr_state;
767 }
768 }
769}
770
680void rtl8723e_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal) 771void rtl8723e_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal)
681{ 772{
682 struct rtl_priv *rtlpriv = rtl_priv(hw); 773 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -826,7 +917,7 @@ void rtl8723e_dm_watchdog(struct ieee80211_hw *hw)
826 rtl8723e_dm_dynamic_bb_powersaving(hw); 917 rtl8723e_dm_dynamic_bb_powersaving(hw);
827 rtl8723e_dm_dynamic_txpower(hw); 918 rtl8723e_dm_dynamic_txpower(hw);
828 rtl8723e_dm_check_txpower_tracking(hw); 919 rtl8723e_dm_check_txpower_tracking(hw);
829 /* rtl92c_dm_refresh_rate_adaptive_mask(hw); */ 920 rtl8723e_dm_refresh_rate_adaptive_mask(hw);
830 rtl8723e_dm_bt_coexist(hw); 921 rtl8723e_dm_bt_coexist(hw);
831 rtl8723e_dm_check_edca_turbo(hw); 922 rtl8723e_dm_check_edca_turbo(hw);
832 } 923 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index 07b82700d1de..3103151dda2b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -266,8 +266,8 @@ static struct rtl_hal_ops rtl8723e_hal_ops = {
266static struct rtl_mod_params rtl8723e_mod_params = { 266static struct rtl_mod_params rtl8723e_mod_params = {
267 .sw_crypto = false, 267 .sw_crypto = false,
268 .inactiveps = true, 268 .inactiveps = true,
269 .swctrl_lps = false, 269 .swctrl_lps = true,
270 .fwctrl_lps = true, 270 .fwctrl_lps = false,
271 .aspm_support = 1, 271 .aspm_support = 1,
272 .debug_level = 0, 272 .debug_level = 0,
273 .debug_mask = 0, 273 .debug_mask = 0,
@@ -395,8 +395,8 @@ module_param_named(disable_watchdog, rtl8723e_mod_params.disable_watchdog,
395 bool, 0444); 395 bool, 0444);
396MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); 396MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
397MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n"); 397MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
398MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n"); 398MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 1)\n");
399MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n"); 399MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 0)\n");
400MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n"); 400MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
401MODULE_PARM_DESC(aspm, "Set to 1 to enable ASPM (default 1)\n"); 401MODULE_PARM_DESC(aspm, "Set to 1 to enable ASPM (default 1)\n");
402MODULE_PARM_DESC(debug_level, "Set debug level (0-5) (default 0)"); 402MODULE_PARM_DESC(debug_level, "Set debug level (0-5) (default 0)");
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
index 1263b12db5dc..11f94b1a436f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
@@ -332,7 +332,7 @@ static void _rtl8723be_phy_set_txpower_by_rate_base(struct ieee80211_hw *hw,
332 "Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_SetTxPowerByRateBase()\n", 332 "Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_SetTxPowerByRateBase()\n",
333 rate_section, path, txnum); 333 rate_section, path, txnum);
334 break; 334 break;
335 }; 335 }
336 } else { 336 } else {
337 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 337 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
338 "Invalid Band %d in PHY_SetTxPowerByRateBase()\n", 338 "Invalid Band %d in PHY_SetTxPowerByRateBase()\n",
@@ -374,7 +374,7 @@ static u8 _rtl8723be_phy_get_txpower_by_rate_base(struct ieee80211_hw *hw,
374 "Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n", 374 "Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
375 rate_section, path, txnum); 375 rate_section, path, txnum);
376 break; 376 break;
377 }; 377 }
378 } else { 378 } else {
379 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 379 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
380 "Invalid Band %d in PHY_GetTxPowerByRateBase()\n", 380 "Invalid Band %d in PHY_GetTxPowerByRateBase()\n",
@@ -694,7 +694,7 @@ static u8 _rtl8723be_get_rate_section_index(u32 regaddr)
694 else if (regaddr >= 0xE20 && regaddr <= 0xE4C) 694 else if (regaddr >= 0xE20 && regaddr <= 0xE4C)
695 index = (u8)((regaddr - 0xE20) / 4); 695 index = (u8)((regaddr - 0xE20) / 4);
696 break; 696 break;
697 }; 697 }
698 return index; 698 return index;
699} 699}
700 700
diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
index 8c6ca8e689e4..d0c35f3e2012 100644
--- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c
+++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
@@ -297,11 +297,6 @@ int rsi_init_dbgfs(struct rsi_hw *adapter)
297 297
298 dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL); 298 dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL);
299 299
300 if (!dev_dbgfs->subdir) {
301 kfree(dev_dbgfs);
302 return -ENOMEM;
303 }
304
305 for (ii = 0; ii < adapter->num_debugfs_entries; ii++) { 300 for (ii = 0; ii < adapter->num_debugfs_entries; ii++) {
306 files = &dev_debugfs_files[ii]; 301 files = &dev_debugfs_files[ii];
307 dev_dbgfs->rsi_files[ii] = 302 dev_dbgfs->rsi_files[ii] =
diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c
index 182b06629371..1dbaab2a96b7 100644
--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
+++ b/drivers/net/wireless/rsi/rsi_91x_hal.c
@@ -100,6 +100,9 @@ int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
100 mgmt_desc->frame_type = TX_DOT11_MGMT; 100 mgmt_desc->frame_type = TX_DOT11_MGMT;
101 mgmt_desc->header_len = MIN_802_11_HDR_LEN; 101 mgmt_desc->header_len = MIN_802_11_HDR_LEN;
102 mgmt_desc->xtend_desc_size = header_size - FRAME_DESC_SZ; 102 mgmt_desc->xtend_desc_size = header_size - FRAME_DESC_SZ;
103
104 if (ieee80211_is_probe_req(wh->frame_control))
105 mgmt_desc->frame_info = cpu_to_le16(RSI_INSERT_SEQ_IN_FW);
103 mgmt_desc->frame_info |= cpu_to_le16(RATE_INFO_ENABLE); 106 mgmt_desc->frame_info |= cpu_to_le16(RATE_INFO_ENABLE);
104 if (is_broadcast_ether_addr(wh->addr1)) 107 if (is_broadcast_ether_addr(wh->addr1))
105 mgmt_desc->frame_info |= cpu_to_le16(RSI_BROADCAST_PKT); 108 mgmt_desc->frame_info |= cpu_to_le16(RSI_BROADCAST_PKT);
diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index e56fc83faf0e..aded1ae4fad5 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -229,6 +229,68 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
229 /* sbands->ht_cap.mcs.rx_highest = 0x82; */ 229 /* sbands->ht_cap.mcs.rx_highest = 0x82; */
230} 230}
231 231
232static int rsi_mac80211_hw_scan_start(struct ieee80211_hw *hw,
233 struct ieee80211_vif *vif,
234 struct ieee80211_scan_request *hw_req)
235{
236 struct cfg80211_scan_request *scan_req = &hw_req->req;
237 struct rsi_hw *adapter = hw->priv;
238 struct rsi_common *common = adapter->priv;
239 struct ieee80211_bss_conf *bss = &vif->bss_conf;
240
241 rsi_dbg(INFO_ZONE, "***** Hardware scan start *****\n");
242
243 if (common->fsm_state != FSM_MAC_INIT_DONE)
244 return -ENODEV;
245
246 if ((common->wow_flags & RSI_WOW_ENABLED) ||
247 scan_req->n_channels == 0)
248 return -EINVAL;
249
250 /* Scan already in progress. So return */
251 if (common->bgscan_en)
252 return -EBUSY;
253
254 /* If STA is not connected, return with special value 1, in order
255 * to start sw_scan in mac80211
256 */
257 if (!bss->assoc)
258 return 1;
259
260 mutex_lock(&common->mutex);
261 common->hwscan = scan_req;
262 if (!rsi_send_bgscan_params(common, RSI_START_BGSCAN)) {
263 if (!rsi_send_bgscan_probe_req(common, vif)) {
264 rsi_dbg(INFO_ZONE, "Background scan started...\n");
265 common->bgscan_en = true;
266 }
267 }
268 mutex_unlock(&common->mutex);
269
270 return 0;
271}
272
273static void rsi_mac80211_cancel_hw_scan(struct ieee80211_hw *hw,
274 struct ieee80211_vif *vif)
275{
276 struct rsi_hw *adapter = hw->priv;
277 struct rsi_common *common = adapter->priv;
278 struct cfg80211_scan_info info;
279
280 rsi_dbg(INFO_ZONE, "***** Hardware scan stop *****\n");
281 mutex_lock(&common->mutex);
282
283 if (common->bgscan_en) {
284 if (!rsi_send_bgscan_params(common, RSI_STOP_BGSCAN))
285 common->bgscan_en = false;
286 info.aborted = false;
287 ieee80211_scan_completed(adapter->hw, &info);
288 rsi_dbg(INFO_ZONE, "Back ground scan cancelled\b\n");
289 }
290 common->hwscan = NULL;
291 mutex_unlock(&common->mutex);
292}
293
232/** 294/**
233 * rsi_mac80211_detach() - This function is used to de-initialize the 295 * rsi_mac80211_detach() - This function is used to de-initialize the
234 * Mac80211 stack. 296 * Mac80211 stack.
@@ -1917,6 +1979,8 @@ static const struct ieee80211_ops mac80211_ops = {
1917 .suspend = rsi_mac80211_suspend, 1979 .suspend = rsi_mac80211_suspend,
1918 .resume = rsi_mac80211_resume, 1980 .resume = rsi_mac80211_resume,
1919#endif 1981#endif
1982 .hw_scan = rsi_mac80211_hw_scan_start,
1983 .cancel_hw_scan = rsi_mac80211_cancel_hw_scan,
1920}; 1984};
1921 1985
1922/** 1986/**
@@ -1999,6 +2063,9 @@ int rsi_mac80211_attach(struct rsi_common *common)
1999 common->max_stations = wiphy->max_ap_assoc_sta; 2063 common->max_stations = wiphy->max_ap_assoc_sta;
2000 rsi_dbg(ERR_ZONE, "Max Stations Allowed = %d\n", common->max_stations); 2064 rsi_dbg(ERR_ZONE, "Max Stations Allowed = %d\n", common->max_stations);
2001 hw->sta_data_size = sizeof(struct rsi_sta); 2065 hw->sta_data_size = sizeof(struct rsi_sta);
2066
2067 wiphy->max_scan_ssids = RSI_MAX_SCAN_SSIDS;
2068 wiphy->max_scan_ie_len = RSI_MAX_SCAN_IE_LEN;
2002 wiphy->flags = WIPHY_FLAG_REPORTS_OBSS; 2069 wiphy->flags = WIPHY_FLAG_REPORTS_OBSS;
2003 wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 2070 wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
2004 wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; 2071 wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER;
diff --git a/drivers/net/wireless/rsi/rsi_91x_main.c b/drivers/net/wireless/rsi/rsi_91x_main.c
index 01d99ed985ee..ca3a55ed72e4 100644
--- a/drivers/net/wireless/rsi/rsi_91x_main.c
+++ b/drivers/net/wireless/rsi/rsi_91x_main.c
@@ -328,6 +328,7 @@ struct rsi_hw *rsi_91x_init(u16 oper_mode)
328 } 328 }
329 329
330 rsi_default_ps_params(adapter); 330 rsi_default_ps_params(adapter);
331 init_bgscan_params(common);
331 spin_lock_init(&adapter->ps_lock); 332 spin_lock_init(&adapter->ps_lock);
332 timer_setup(&common->roc_timer, rsi_roc_timeout, 0); 333 timer_setup(&common->roc_timer, rsi_roc_timeout, 0);
333 init_completion(&common->wlan_init_completion); 334 init_completion(&common->wlan_init_completion);
diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 1095df7d9573..404241424a62 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
18#include <linux/timer.h>
18#include "rsi_mgmt.h" 19#include "rsi_mgmt.h"
19#include "rsi_common.h" 20#include "rsi_common.h"
20#include "rsi_ps.h" 21#include "rsi_ps.h"
@@ -236,6 +237,18 @@ static void rsi_set_default_parameters(struct rsi_common *common)
236 common->dtim_cnt = RSI_DTIM_COUNT; 237 common->dtim_cnt = RSI_DTIM_COUNT;
237} 238}
238 239
240void init_bgscan_params(struct rsi_common *common)
241{
242 memset((u8 *)&common->bgscan, 0, sizeof(struct rsi_bgscan_params));
243 common->bgscan.bgscan_threshold = RSI_DEF_BGSCAN_THRLD;
244 common->bgscan.roam_threshold = RSI_DEF_ROAM_THRLD;
245 common->bgscan.bgscan_periodicity = RSI_BGSCAN_PERIODICITY;
246 common->bgscan.num_bgscan_channels = 0;
247 common->bgscan.two_probe = 1;
248 common->bgscan.active_scan_duration = RSI_ACTIVE_SCAN_TIME;
249 common->bgscan.passive_scan_duration = RSI_PASSIVE_SCAN_TIME;
250}
251
239/** 252/**
240 * rsi_set_contention_vals() - This function sets the contention values for the 253 * rsi_set_contention_vals() - This function sets the contention values for the
241 * backoff procedure. 254 * backoff procedure.
@@ -1628,6 +1641,107 @@ int rsi_send_wowlan_request(struct rsi_common *common, u16 flags,
1628} 1641}
1629#endif 1642#endif
1630 1643
1644int rsi_send_bgscan_params(struct rsi_common *common, int enable)
1645{
1646 struct rsi_bgscan_params *params = &common->bgscan;
1647 struct cfg80211_scan_request *scan_req = common->hwscan;
1648 struct rsi_bgscan_config *bgscan;
1649 struct sk_buff *skb;
1650 u16 frame_len = sizeof(*bgscan);
1651 u8 i;
1652
1653 rsi_dbg(MGMT_TX_ZONE, "%s: Sending bgscan params frame\n", __func__);
1654
1655 skb = dev_alloc_skb(frame_len);
1656 if (!skb)
1657 return -ENOMEM;
1658 memset(skb->data, 0, frame_len);
1659
1660 bgscan = (struct rsi_bgscan_config *)skb->data;
1661 rsi_set_len_qno(&bgscan->desc_dword0.len_qno,
1662 (frame_len - FRAME_DESC_SZ), RSI_WIFI_MGMT_Q);
1663 bgscan->desc_dword0.frame_type = BG_SCAN_PARAMS;
1664 bgscan->bgscan_threshold = cpu_to_le16(params->bgscan_threshold);
1665 bgscan->roam_threshold = cpu_to_le16(params->roam_threshold);
1666 if (enable)
1667 bgscan->bgscan_periodicity =
1668 cpu_to_le16(params->bgscan_periodicity);
1669 bgscan->active_scan_duration =
1670 cpu_to_le16(params->active_scan_duration);
1671 bgscan->passive_scan_duration =
1672 cpu_to_le16(params->passive_scan_duration);
1673 bgscan->two_probe = params->two_probe;
1674
1675 bgscan->num_bgscan_channels = scan_req->n_channels;
1676 for (i = 0; i < bgscan->num_bgscan_channels; i++)
1677 bgscan->channels2scan[i] =
1678 cpu_to_le16(scan_req->channels[i]->hw_value);
1679
1680 skb_put(skb, frame_len);
1681
1682 return rsi_send_internal_mgmt_frame(common, skb);
1683}
1684
1685/* This function sends the probe request to be used by firmware in
1686 * background scan
1687 */
1688int rsi_send_bgscan_probe_req(struct rsi_common *common,
1689 struct ieee80211_vif *vif)
1690{
1691 struct cfg80211_scan_request *scan_req = common->hwscan;
1692 struct rsi_bgscan_probe *bgscan;
1693 struct sk_buff *skb;
1694 struct sk_buff *probereq_skb;
1695 u16 frame_len = sizeof(*bgscan);
1696 size_t ssid_len = 0;
1697 u8 *ssid = NULL;
1698
1699 rsi_dbg(MGMT_TX_ZONE,
1700 "%s: Sending bgscan probe req frame\n", __func__);
1701
1702 if (common->priv->sc_nvifs <= 0)
1703 return -ENODEV;
1704
1705 if (scan_req->n_ssids) {
1706 ssid = scan_req->ssids[0].ssid;
1707 ssid_len = scan_req->ssids[0].ssid_len;
1708 }
1709
1710 skb = dev_alloc_skb(frame_len + MAX_BGSCAN_PROBE_REQ_LEN);
1711 if (!skb)
1712 return -ENOMEM;
1713 memset(skb->data, 0, frame_len + MAX_BGSCAN_PROBE_REQ_LEN);
1714
1715 bgscan = (struct rsi_bgscan_probe *)skb->data;
1716 bgscan->desc_dword0.frame_type = BG_SCAN_PROBE_REQ;
1717 bgscan->flags = cpu_to_le16(HOST_BG_SCAN_TRIG);
1718 if (common->band == NL80211_BAND_5GHZ) {
1719 bgscan->mgmt_rate = cpu_to_le16(RSI_RATE_6);
1720 bgscan->def_chan = cpu_to_le16(40);
1721 } else {
1722 bgscan->mgmt_rate = cpu_to_le16(RSI_RATE_1);
1723 bgscan->def_chan = cpu_to_le16(11);
1724 }
1725 bgscan->channel_scan_time = cpu_to_le16(RSI_CHANNEL_SCAN_TIME);
1726
1727 probereq_skb = ieee80211_probereq_get(common->priv->hw, vif->addr, ssid,
1728 ssid_len, scan_req->ie_len);
1729
1730 memcpy(&skb->data[frame_len], probereq_skb->data, probereq_skb->len);
1731
1732 bgscan->probe_req_length = cpu_to_le16(probereq_skb->len);
1733
1734 rsi_set_len_qno(&bgscan->desc_dword0.len_qno,
1735 (frame_len - FRAME_DESC_SZ + probereq_skb->len),
1736 RSI_WIFI_MGMT_Q);
1737
1738 skb_put(skb, frame_len + probereq_skb->len);
1739
1740 dev_kfree_skb(probereq_skb);
1741
1742 return rsi_send_internal_mgmt_frame(common, skb);
1743}
1744
1631/** 1745/**
1632 * rsi_handle_ta_confirm_type() - This function handles the confirm frames. 1746 * rsi_handle_ta_confirm_type() - This function handles the confirm frames.
1633 * @common: Pointer to the driver private structure. 1747 * @common: Pointer to the driver private structure.
@@ -1771,9 +1885,28 @@ static int rsi_handle_ta_confirm_type(struct rsi_common *common,
1771 return 0; 1885 return 0;
1772 } 1886 }
1773 break; 1887 break;
1888
1889 case SCAN_REQUEST:
1890 rsi_dbg(INFO_ZONE, "Set channel confirm\n");
1891 break;
1892
1774 case WAKEUP_SLEEP_REQUEST: 1893 case WAKEUP_SLEEP_REQUEST:
1775 rsi_dbg(INFO_ZONE, "Wakeup/Sleep confirmation.\n"); 1894 rsi_dbg(INFO_ZONE, "Wakeup/Sleep confirmation.\n");
1776 return rsi_handle_ps_confirm(adapter, msg); 1895 return rsi_handle_ps_confirm(adapter, msg);
1896
1897 case BG_SCAN_PROBE_REQ:
1898 rsi_dbg(INFO_ZONE, "BG scan complete event\n");
1899 if (common->bgscan_en) {
1900 struct cfg80211_scan_info info;
1901
1902 if (!rsi_send_bgscan_params(common, RSI_STOP_BGSCAN))
1903 common->bgscan_en = 0;
1904 info.aborted = false;
1905 ieee80211_scan_completed(adapter->hw, &info);
1906 }
1907 rsi_dbg(INFO_ZONE, "Background scan completed\n");
1908 break;
1909
1777 default: 1910 default:
1778 rsi_dbg(INFO_ZONE, "%s: Invalid TA confirm pkt received\n", 1911 rsi_dbg(INFO_ZONE, "%s: Invalid TA confirm pkt received\n",
1779 __func__); 1912 __func__);
diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
index 5733e440ecaf..b412b65eb1f4 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
@@ -230,16 +230,19 @@ static void rsi_reset_card(struct sdio_func *pfunction)
230 rsi_dbg(ERR_ZONE, "%s: CMD0 failed : %d\n", __func__, err); 230 rsi_dbg(ERR_ZONE, "%s: CMD0 failed : %d\n", __func__, err);
231 231
232 /* Issue CMD5, arg = 0 */ 232 /* Issue CMD5, arg = 0 */
233 err = rsi_issue_sdiocommand(pfunction, SD_IO_SEND_OP_COND, 0, 233 if (!host->ocr_avail) {
234 (MMC_RSP_R4 | MMC_CMD_BCR), &resp); 234 err = rsi_issue_sdiocommand(pfunction, SD_IO_SEND_OP_COND, 0,
235 if (err) 235 (MMC_RSP_R4 | MMC_CMD_BCR), &resp);
236 rsi_dbg(ERR_ZONE, "%s: CMD5 failed : %d\n", __func__, err); 236 if (err)
237 card->ocr = resp; 237 rsi_dbg(ERR_ZONE, "%s: CMD5 failed : %d\n",
238 __func__, err);
238 239
240 host->ocr_avail = resp;
241 }
239 /* Issue CMD5, arg = ocr. Wait till card is ready */ 242 /* Issue CMD5, arg = ocr. Wait till card is ready */
240 for (i = 0; i < 100; i++) { 243 for (i = 0; i < 100; i++) {
241 err = rsi_issue_sdiocommand(pfunction, SD_IO_SEND_OP_COND, 244 err = rsi_issue_sdiocommand(pfunction, SD_IO_SEND_OP_COND,
242 card->ocr, 245 host->ocr_avail,
243 (MMC_RSP_R4 | MMC_CMD_BCR), &resp); 246 (MMC_RSP_R4 | MMC_CMD_BCR), &resp);
244 if (err) { 247 if (err) {
245 rsi_dbg(ERR_ZONE, "%s: CMD5 failed : %d\n", 248 rsi_dbg(ERR_ZONE, "%s: CMD5 failed : %d\n",
diff --git a/drivers/net/wireless/rsi/rsi_main.h b/drivers/net/wireless/rsi/rsi_main.h
index a084f224bb03..4dc0c0123469 100644
--- a/drivers/net/wireless/rsi/rsi_main.h
+++ b/drivers/net/wireless/rsi/rsi_main.h
@@ -164,6 +164,24 @@ struct transmit_q_stats {
164 u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2]; 164 u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
165}; 165};
166 166
167#define MAX_BGSCAN_CHANNELS_DUAL_BAND 38
168#define MAX_BGSCAN_PROBE_REQ_LEN 0x64
169#define RSI_DEF_BGSCAN_THRLD 0x0
170#define RSI_DEF_ROAM_THRLD 0xa
171#define RSI_BGSCAN_PERIODICITY 0x1e
172#define RSI_ACTIVE_SCAN_TIME 0x14
173#define RSI_PASSIVE_SCAN_TIME 0x46
174#define RSI_CHANNEL_SCAN_TIME 20
175struct rsi_bgscan_params {
176 u16 bgscan_threshold;
177 u16 roam_threshold;
178 u16 bgscan_periodicity;
179 u8 num_bgscan_channels;
180 u8 two_probe;
181 u16 active_scan_duration;
182 u16 passive_scan_duration;
183};
184
167struct vif_priv { 185struct vif_priv {
168 bool is_ht; 186 bool is_ht;
169 bool sgi; 187 bool sgi;
@@ -289,6 +307,10 @@ struct rsi_common {
289 307
290 bool eapol4_confirm; 308 bool eapol4_confirm;
291 void *bt_adapter; 309 void *bt_adapter;
310
311 struct cfg80211_scan_request *hwscan;
312 struct rsi_bgscan_params bgscan;
313 u8 bgscan_en;
292}; 314};
293 315
294struct eepromrw_info { 316struct eepromrw_info {
diff --git a/drivers/net/wireless/rsi/rsi_mgmt.h b/drivers/net/wireless/rsi/rsi_mgmt.h
index 359fbdf85739..ea83faa15c7e 100644
--- a/drivers/net/wireless/rsi/rsi_mgmt.h
+++ b/drivers/net/wireless/rsi/rsi_mgmt.h
@@ -228,6 +228,9 @@
228#define RSI_MAX_TX_AGGR_FRMS 8 228#define RSI_MAX_TX_AGGR_FRMS 8
229#define RSI_MAX_RX_AGGR_FRMS 8 229#define RSI_MAX_RX_AGGR_FRMS 8
230 230
231#define RSI_MAX_SCAN_SSIDS 16
232#define RSI_MAX_SCAN_IE_LEN 256
233
231enum opmode { 234enum opmode {
232 RSI_OPMODE_UNSUPPORTED = -1, 235 RSI_OPMODE_UNSUPPORTED = -1,
233 RSI_OPMODE_AP = 0, 236 RSI_OPMODE_AP = 0,
@@ -623,6 +626,34 @@ struct rsi_wowlan_req {
623 u16 host_sleep_status; 626 u16 host_sleep_status;
624} __packed; 627} __packed;
625 628
629#define RSI_START_BGSCAN 1
630#define RSI_STOP_BGSCAN 0
631#define HOST_BG_SCAN_TRIG BIT(4)
632struct rsi_bgscan_config {
633 struct rsi_cmd_desc_dword0 desc_dword0;
634 __le64 reserved;
635 __le32 reserved1;
636 __le16 bgscan_threshold;
637 __le16 roam_threshold;
638 __le16 bgscan_periodicity;
639 u8 num_bgscan_channels;
640 u8 two_probe;
641 __le16 active_scan_duration;
642 __le16 passive_scan_duration;
643 __le16 channels2scan[MAX_BGSCAN_CHANNELS_DUAL_BAND];
644} __packed;
645
646struct rsi_bgscan_probe {
647 struct rsi_cmd_desc_dword0 desc_dword0;
648 __le64 reserved;
649 __le32 reserved1;
650 __le16 mgmt_rate;
651 __le16 flags;
652 __le16 def_chan;
653 __le16 channel_scan_time;
654 __le16 probe_req_length;
655} __packed;
656
626static inline u32 rsi_get_queueno(u8 *addr, u16 offset) 657static inline u32 rsi_get_queueno(u8 *addr, u16 offset)
627{ 658{
628 return (le16_to_cpu(*(__le16 *)&addr[offset]) & 0x7000) >> 12; 659 return (le16_to_cpu(*(__le16 *)&addr[offset]) & 0x7000) >> 12;
@@ -694,4 +725,8 @@ int rsi_send_wowlan_request(struct rsi_common *common, u16 flags,
694#endif 725#endif
695int rsi_send_ps_request(struct rsi_hw *adapter, bool enable, 726int rsi_send_ps_request(struct rsi_hw *adapter, bool enable,
696 struct ieee80211_vif *vif); 727 struct ieee80211_vif *vif);
728void init_bgscan_params(struct rsi_common *common);
729int rsi_send_bgscan_params(struct rsi_common *common, int enable);
730int rsi_send_bgscan_probe_req(struct rsi_common *common,
731 struct ieee80211_vif *vif);
697#endif 732#endif
diff --git a/drivers/net/wireless/st/cw1200/debug.c b/drivers/net/wireless/st/cw1200/debug.c
index 2231ba08bc1f..d94266d9d0b8 100644
--- a/drivers/net/wireless/st/cw1200/debug.c
+++ b/drivers/net/wireless/st/cw1200/debug.c
@@ -371,28 +371,14 @@ int cw1200_debug_init(struct cw1200_common *priv)
371 371
372 d->debugfs_phy = debugfs_create_dir("cw1200", 372 d->debugfs_phy = debugfs_create_dir("cw1200",
373 priv->hw->wiphy->debugfsdir); 373 priv->hw->wiphy->debugfsdir);
374 if (!d->debugfs_phy) 374 debugfs_create_file("status", 0400, d->debugfs_phy, priv,
375 goto err; 375 &cw1200_status_fops);
376 376 debugfs_create_file("counters", 0400, d->debugfs_phy, priv,
377 if (!debugfs_create_file("status", 0400, d->debugfs_phy, 377 &cw1200_counters_fops);
378 priv, &cw1200_status_fops)) 378 debugfs_create_file("wsm_dumps", 0200, d->debugfs_phy, priv,
379 goto err; 379 &fops_wsm_dumps);
380
381 if (!debugfs_create_file("counters", 0400, d->debugfs_phy,
382 priv, &cw1200_counters_fops))
383 goto err;
384
385 if (!debugfs_create_file("wsm_dumps", 0200, d->debugfs_phy,
386 priv, &fops_wsm_dumps))
387 goto err;
388 380
389 return 0; 381 return 0;
390
391err:
392 priv->debug = NULL;
393 debugfs_remove_recursive(d->debugfs_phy);
394 kfree(d);
395 return ret;
396} 382}
397 383
398void cw1200_debug_release(struct cw1200_common *priv) 384void cw1200_debug_release(struct cw1200_common *priv)
diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
index 30e7646d04af..b7881232499c 100644
--- a/drivers/net/wireless/st/cw1200/fwio.c
+++ b/drivers/net/wireless/st/cw1200/fwio.c
@@ -465,8 +465,8 @@ int cw1200_load_firmware(struct cw1200_common *priv)
465 465
466 if (!(val32 & ST90TDS_CONFIG_ACCESS_MODE_BIT)) { 466 if (!(val32 & ST90TDS_CONFIG_ACCESS_MODE_BIT)) {
467 pr_err("Device is already in QUEUE mode!\n"); 467 pr_err("Device is already in QUEUE mode!\n");
468 ret = -EINVAL; 468 ret = -EINVAL;
469 goto out; 469 goto out;
470 } 470 }
471 471
472 switch (priv->hw_type) { 472 switch (priv->hw_type) {
diff --git a/drivers/net/wireless/st/cw1200/queue.c b/drivers/net/wireless/st/cw1200/queue.c
index 7c31b63b8258..7895efefa95d 100644
--- a/drivers/net/wireless/st/cw1200/queue.c
+++ b/drivers/net/wireless/st/cw1200/queue.c
@@ -283,7 +283,6 @@ int cw1200_queue_put(struct cw1200_queue *queue,
283 struct cw1200_txpriv *txpriv) 283 struct cw1200_txpriv *txpriv)
284{ 284{
285 int ret = 0; 285 int ret = 0;
286 LIST_HEAD(gc_list);
287 struct cw1200_queue_stats *stats = queue->stats; 286 struct cw1200_queue_stats *stats = queue->stats;
288 287
289 if (txpriv->link_id >= queue->stats->map_capacity) 288 if (txpriv->link_id >= queue->stats->map_capacity)
diff --git a/drivers/net/wireless/st/cw1200/scan.c b/drivers/net/wireless/st/cw1200/scan.c
index 0a9eac93dd01..71e9b91cf15b 100644
--- a/drivers/net/wireless/st/cw1200/scan.c
+++ b/drivers/net/wireless/st/cw1200/scan.c
@@ -84,8 +84,11 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,
84 84
85 frame.skb = ieee80211_probereq_get(hw, priv->vif->addr, NULL, 0, 85 frame.skb = ieee80211_probereq_get(hw, priv->vif->addr, NULL, 0,
86 req->ie_len); 86 req->ie_len);
87 if (!frame.skb) 87 if (!frame.skb) {
88 mutex_unlock(&priv->conf_mutex);
89 up(&priv->scan.lock);
88 return -ENOMEM; 90 return -ENOMEM;
91 }
89 92
90 if (req->ie_len) 93 if (req->ie_len)
91 skb_put_data(frame.skb, req->ie, req->ie_len); 94 skb_put_data(frame.skb, req->ie, req->ie_len);
diff --git a/drivers/net/wireless/ti/wl1251/debugfs.c b/drivers/net/wireless/ti/wl1251/debugfs.c
index 448da1f8c22f..c99b23aaa70e 100644
--- a/drivers/net/wireless/ti/wl1251/debugfs.c
+++ b/drivers/net/wireless/ti/wl1251/debugfs.c
@@ -54,11 +54,6 @@ static const struct file_operations name## _ops = { \
54#define DEBUGFS_ADD(name, parent) \ 54#define DEBUGFS_ADD(name, parent) \
55 wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \ 55 wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
56 wl, &name## _ops); \ 56 wl, &name## _ops); \
57 if (IS_ERR(wl->debugfs.name)) { \
58 ret = PTR_ERR(wl->debugfs.name); \
59 wl->debugfs.name = NULL; \
60 goto out; \
61 }
62 57
63#define DEBUGFS_DEL(name) \ 58#define DEBUGFS_DEL(name) \
64 do { \ 59 do { \
@@ -354,10 +349,8 @@ static void wl1251_debugfs_delete_files(struct wl1251 *wl)
354 DEBUGFS_DEL(excessive_retries); 349 DEBUGFS_DEL(excessive_retries);
355} 350}
356 351
357static int wl1251_debugfs_add_files(struct wl1251 *wl) 352static void wl1251_debugfs_add_files(struct wl1251 *wl)
358{ 353{
359 int ret = 0;
360
361 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); 354 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
362 355
363 DEBUGFS_FWSTATS_ADD(rx, out_of_mem); 356 DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
@@ -453,12 +446,6 @@ static int wl1251_debugfs_add_files(struct wl1251 *wl)
453 DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir); 446 DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir);
454 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir); 447 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
455 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir); 448 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
456
457out:
458 if (ret < 0)
459 wl1251_debugfs_delete_files(wl);
460
461 return ret;
462} 449}
463 450
464void wl1251_debugfs_reset(struct wl1251 *wl) 451void wl1251_debugfs_reset(struct wl1251 *wl)
@@ -471,56 +458,20 @@ void wl1251_debugfs_reset(struct wl1251 *wl)
471 458
472int wl1251_debugfs_init(struct wl1251 *wl) 459int wl1251_debugfs_init(struct wl1251 *wl)
473{ 460{
474 int ret; 461 wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), GFP_KERNEL);
462 if (!wl->stats.fw_stats)
463 return -ENOMEM;
475 464
476 wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); 465 wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
477 466
478 if (IS_ERR(wl->debugfs.rootdir)) {
479 ret = PTR_ERR(wl->debugfs.rootdir);
480 wl->debugfs.rootdir = NULL;
481 goto err;
482 }
483
484 wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics", 467 wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
485 wl->debugfs.rootdir); 468 wl->debugfs.rootdir);
486 469
487 if (IS_ERR(wl->debugfs.fw_statistics)) {
488 ret = PTR_ERR(wl->debugfs.fw_statistics);
489 wl->debugfs.fw_statistics = NULL;
490 goto err_root;
491 }
492
493 wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
494 GFP_KERNEL);
495
496 if (!wl->stats.fw_stats) {
497 ret = -ENOMEM;
498 goto err_fw;
499 }
500
501 wl->stats.fw_stats_update = jiffies; 470 wl->stats.fw_stats_update = jiffies;
502 471
503 ret = wl1251_debugfs_add_files(wl); 472 wl1251_debugfs_add_files(wl);
504
505 if (ret < 0)
506 goto err_file;
507 473
508 return 0; 474 return 0;
509
510err_file:
511 kfree(wl->stats.fw_stats);
512 wl->stats.fw_stats = NULL;
513
514err_fw:
515 debugfs_remove(wl->debugfs.fw_statistics);
516 wl->debugfs.fw_statistics = NULL;
517
518err_root:
519 debugfs_remove(wl->debugfs.rootdir);
520 wl->debugfs.rootdir = NULL;
521
522err:
523 return ret;
524} 475}
525 476
526void wl1251_debugfs_exit(struct wl1251 *wl) 477void wl1251_debugfs_exit(struct wl1251 *wl)
diff --git a/drivers/net/wireless/ti/wl12xx/debugfs.c b/drivers/net/wireless/ti/wl12xx/debugfs.c
index 0521cbf858cf..6c3c04eca8fd 100644
--- a/drivers/net/wireless/ti/wl12xx/debugfs.c
+++ b/drivers/net/wireless/ti/wl12xx/debugfs.c
@@ -125,20 +125,10 @@ WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u");
125int wl12xx_debugfs_add_files(struct wl1271 *wl, 125int wl12xx_debugfs_add_files(struct wl1271 *wl,
126 struct dentry *rootdir) 126 struct dentry *rootdir)
127{ 127{
128 int ret = 0; 128 struct dentry *stats, *moddir;
129 struct dentry *entry, *stats, *moddir;
130 129
131 moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir); 130 moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir);
132 if (!moddir || IS_ERR(moddir)) {
133 entry = moddir;
134 goto err;
135 }
136
137 stats = debugfs_create_dir("fw_stats", moddir); 131 stats = debugfs_create_dir("fw_stats", moddir);
138 if (!stats || IS_ERR(stats)) {
139 entry = stats;
140 goto err;
141 }
142 132
143 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); 133 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
144 134
@@ -232,12 +222,4 @@ int wl12xx_debugfs_add_files(struct wl1271 *wl,
232 DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data); 222 DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
233 223
234 return 0; 224 return 0;
235
236err:
237 if (IS_ERR(entry))
238 ret = PTR_ERR(entry);
239 else
240 ret = -ENOMEM;
241
242 return ret;
243} 225}
diff --git a/drivers/net/wireless/ti/wl18xx/debugfs.c b/drivers/net/wireless/ti/wl18xx/debugfs.c
index 597e934c4630..5f4ec997ca59 100644
--- a/drivers/net/wireless/ti/wl18xx/debugfs.c
+++ b/drivers/net/wireless/ti/wl18xx/debugfs.c
@@ -422,20 +422,10 @@ static const struct file_operations radar_debug_mode_ops = {
422int wl18xx_debugfs_add_files(struct wl1271 *wl, 422int wl18xx_debugfs_add_files(struct wl1271 *wl,
423 struct dentry *rootdir) 423 struct dentry *rootdir)
424{ 424{
425 int ret = 0; 425 struct dentry *stats, *moddir;
426 struct dentry *entry, *stats, *moddir;
427 426
428 moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir); 427 moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir);
429 if (!moddir || IS_ERR(moddir)) {
430 entry = moddir;
431 goto err;
432 }
433
434 stats = debugfs_create_dir("fw_stats", moddir); 428 stats = debugfs_create_dir("fw_stats", moddir);
435 if (!stats || IS_ERR(stats)) {
436 entry = stats;
437 goto err;
438 }
439 429
440 DEBUGFS_ADD(clear_fw_stats, stats); 430 DEBUGFS_ADD(clear_fw_stats, stats);
441 431
@@ -590,12 +580,4 @@ int wl18xx_debugfs_add_files(struct wl1271 *wl,
590 DEBUGFS_ADD(dynamic_fw_traces, moddir); 580 DEBUGFS_ADD(dynamic_fw_traces, moddir);
591 581
592 return 0; 582 return 0;
593
594err:
595 if (IS_ERR(entry))
596 ret = PTR_ERR(entry);
597 else
598 ret = -ENOMEM;
599
600 return ret;
601} 583}
diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
index 903968735a74..348be0aed97e 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.c
+++ b/drivers/net/wireless/ti/wlcore/cmd.c
@@ -1427,7 +1427,7 @@ int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1427 ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0); 1427 ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0);
1428 if (ret < 0) { 1428 if (ret < 0) {
1429 wl1271_warning("could not set keys"); 1429 wl1271_warning("could not set keys");
1430 goto out; 1430 goto out;
1431 } 1431 }
1432 1432
1433out: 1433out:
diff --git a/drivers/net/wireless/ti/wlcore/debugfs.c b/drivers/net/wireless/ti/wlcore/debugfs.c
index aeb74e74698e..68acd901d384 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.c
+++ b/drivers/net/wireless/ti/wlcore/debugfs.c
@@ -1301,11 +1301,10 @@ static const struct file_operations fw_logger_ops = {
1301 .llseek = default_llseek, 1301 .llseek = default_llseek,
1302}; 1302};
1303 1303
1304static int wl1271_debugfs_add_files(struct wl1271 *wl, 1304static void wl1271_debugfs_add_files(struct wl1271 *wl,
1305 struct dentry *rootdir) 1305 struct dentry *rootdir)
1306{ 1306{
1307 int ret = 0; 1307 struct dentry *streaming;
1308 struct dentry *entry, *streaming;
1309 1308
1310 DEBUGFS_ADD(tx_queue_len, rootdir); 1309 DEBUGFS_ADD(tx_queue_len, rootdir);
1311 DEBUGFS_ADD(retry_count, rootdir); 1310 DEBUGFS_ADD(retry_count, rootdir);
@@ -1330,23 +1329,11 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl,
1330 DEBUGFS_ADD(fw_logger, rootdir); 1329 DEBUGFS_ADD(fw_logger, rootdir);
1331 1330
1332 streaming = debugfs_create_dir("rx_streaming", rootdir); 1331 streaming = debugfs_create_dir("rx_streaming", rootdir);
1333 if (!streaming || IS_ERR(streaming))
1334 goto err;
1335 1332
1336 DEBUGFS_ADD_PREFIX(rx_streaming, interval, streaming); 1333 DEBUGFS_ADD_PREFIX(rx_streaming, interval, streaming);
1337 DEBUGFS_ADD_PREFIX(rx_streaming, always, streaming); 1334 DEBUGFS_ADD_PREFIX(rx_streaming, always, streaming);
1338 1335
1339 DEBUGFS_ADD_PREFIX(dev, mem, rootdir); 1336 DEBUGFS_ADD_PREFIX(dev, mem, rootdir);
1340
1341 return 0;
1342
1343err:
1344 if (IS_ERR(entry))
1345 ret = PTR_ERR(entry);
1346 else
1347 ret = -ENOMEM;
1348
1349 return ret;
1350} 1337}
1351 1338
1352void wl1271_debugfs_reset(struct wl1271 *wl) 1339void wl1271_debugfs_reset(struct wl1271 *wl)
@@ -1367,11 +1354,6 @@ int wl1271_debugfs_init(struct wl1271 *wl)
1367 rootdir = debugfs_create_dir(KBUILD_MODNAME, 1354 rootdir = debugfs_create_dir(KBUILD_MODNAME,
1368 wl->hw->wiphy->debugfsdir); 1355 wl->hw->wiphy->debugfsdir);
1369 1356
1370 if (IS_ERR(rootdir)) {
1371 ret = PTR_ERR(rootdir);
1372 goto out;
1373 }
1374
1375 wl->stats.fw_stats = kzalloc(wl->stats.fw_stats_len, GFP_KERNEL); 1357 wl->stats.fw_stats = kzalloc(wl->stats.fw_stats_len, GFP_KERNEL);
1376 if (!wl->stats.fw_stats) { 1358 if (!wl->stats.fw_stats) {
1377 ret = -ENOMEM; 1359 ret = -ENOMEM;
@@ -1380,9 +1362,7 @@ int wl1271_debugfs_init(struct wl1271 *wl)
1380 1362
1381 wl->stats.fw_stats_update = jiffies; 1363 wl->stats.fw_stats_update = jiffies;
1382 1364
1383 ret = wl1271_debugfs_add_files(wl, rootdir); 1365 wl1271_debugfs_add_files(wl, rootdir);
1384 if (ret < 0)
1385 goto out_exit;
1386 1366
1387 ret = wlcore_debugfs_init(wl, rootdir); 1367 ret = wlcore_debugfs_init(wl, rootdir);
1388 if (ret < 0) 1368 if (ret < 0)
diff --git a/drivers/net/wireless/ti/wlcore/debugfs.h b/drivers/net/wireless/ti/wlcore/debugfs.h
index bf14676e6515..a4952c4f587e 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.h
+++ b/drivers/net/wireless/ti/wlcore/debugfs.h
@@ -53,19 +53,15 @@ static const struct file_operations name## _ops = { \
53 53
54#define DEBUGFS_ADD(name, parent) \ 54#define DEBUGFS_ADD(name, parent) \
55 do { \ 55 do { \
56 entry = debugfs_create_file(#name, 0400, parent, \ 56 debugfs_create_file(#name, 0400, parent, \
57 wl, &name## _ops); \ 57 wl, &name## _ops); \
58 if (!entry || IS_ERR(entry)) \
59 goto err; \
60 } while (0) 58 } while (0)
61 59
62 60
63#define DEBUGFS_ADD_PREFIX(prefix, name, parent) \ 61#define DEBUGFS_ADD_PREFIX(prefix, name, parent) \
64 do { \ 62 do { \
65 entry = debugfs_create_file(#name, 0400, parent, \ 63 debugfs_create_file(#name, 0400, parent, \
66 wl, &prefix## _## name## _ops); \ 64 wl, &prefix## _## name## _ops); \
67 if (!entry || IS_ERR(entry)) \
68 goto err; \
69 } while (0) 65 } while (0)
70 66
71#define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \ 67#define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index 26b187336875..2e12de813a5b 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -1085,8 +1085,11 @@ static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt)
1085 goto out; 1085 goto out;
1086 1086
1087 ret = wl12xx_fetch_firmware(wl, plt); 1087 ret = wl12xx_fetch_firmware(wl, plt);
1088 if (ret < 0) 1088 if (ret < 0) {
1089 goto out; 1089 kfree(wl->fw_status);
1090 kfree(wl->raw_fw_status);
1091 kfree(wl->tx_res_if);
1092 }
1090 1093
1091out: 1094out:
1092 return ret; 1095 return ret;
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index ef61f3607e99..60b94b944e9f 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -332,6 +332,8 @@ extern int bcma_arch_register_fallback_sprom(
332 struct ssb_sprom *out)); 332 struct ssb_sprom *out));
333 333
334struct bcma_bus { 334struct bcma_bus {
335 struct device *dev;
336
335 /* The MMIO area. */ 337 /* The MMIO area. */
336 void __iomem *mmio; 338 void __iomem *mmio;
337 339
@@ -339,14 +341,7 @@ struct bcma_bus {
339 341
340 enum bcma_hosttype hosttype; 342 enum bcma_hosttype hosttype;
341 bool host_is_pcie2; /* Used for BCMA_HOSTTYPE_PCI only */ 343 bool host_is_pcie2; /* Used for BCMA_HOSTTYPE_PCI only */
342 union { 344 struct pci_dev *host_pci; /* PCI bus pointer (BCMA_HOSTTYPE_PCI only) */
343 /* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
344 struct pci_dev *host_pci;
345 /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
346 struct sdio_func *host_sdio;
347 /* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */
348 struct platform_device *host_pdev;
349 };
350 345
351 struct bcma_chipinfo chipinfo; 346 struct bcma_chipinfo chipinfo;
352 347