aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-11-21 16:39:45 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 16:39:45 -0500
commit53b15ef3c2a6bac8e3d9bb58c5689d731ed9593b (patch)
tree6b3194af697d91ac4c2ab1c716bd30c972cf4949 /drivers
parentb48c5ec53ef9f0fe617aafa94a752f528fdad149 (diff)
parent9e6f3f472c8f95021ad048acc7cd3e40a827f8ce (diff)
Merge tag 'master-2014-11-20' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next
John W. Linville says: ==================== pull request: wireless-next 2014-11-21 Please pull this batch of updates intended for the 3.19 stream... For the mac80211 bits, Johannes says: "It has been a while since my last pull request, so we accumulated another relatively large set of changes: * TDLS off-channel support set from Arik/Liad, with some support patches I did * custom regulatory fixes from Arik * minstrel VHT fix (and a small optimisation) from Felix * add back radiotap vendor namespace support (myself) * random MAC address scanning for cfg80211/mac80211/hwsim (myself) * CSA improvements (Luca) * WoWLAN Net Detect (wake on network found) support (Luca) * and lots of other smaller changes from many people" For the Bluetooth bits, Johan says: "Here's another set of patches for 3.19. Most of it is again fixes and cleanups to ieee802154 related code from Alexander Aring. We've also got better handling of hardware error events along with a proper API for HCI drivers to notify the HCI core of such situations. There's also a minor fix for mgmt events as well as a sparse warning fix. The code for sending HCI commands synchronously also gets a fix where we might loose the completion event in the case of very fast HW (particularly easily reproducible with an emulated HCI device)." And... "Here's another bluetooth-next pull request for 3.19. We've got: - Various fixes, cleanups and improvements to ieee802154/mac802154 - Support for a Broadcom BCM20702A1 variant - Lots of lockdep fixes - Fixed handling of LE CoC errors that should trigger SMP" For the Atheros bits, Kalle says: "One ath6kl patch and rest for ath10k, but nothing really major which stands out. Most notable: o fix resume (Bartosz) o firmware restart is now faster and more reliable (Michal) o it's now possible to test hardware restart functionality without crashing the firmware using hw-restart parameter with simulate_fw_crash debugfs file (Michal)" On top of that...both ath9k and mwifiex get their usual level of updates. Of note is the ath9k spectral scan work from Oleksij Rempel. I also pulled from the wireless tree in order to avoid some merge issues. Please let me know if there are problems! ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bcma/driver_chipcommon.c2
-rw-r--r--drivers/bcma/driver_gpio.c4
-rw-r--r--drivers/bcma/driver_mips.c11
-rw-r--r--drivers/bcma/driver_pci_host.c4
-rw-r--r--drivers/bcma/main.c72
-rw-r--r--drivers/bluetooth/btusb.c9
-rw-r--r--drivers/bluetooth/hci_ath.c2
-rw-r--r--drivers/bluetooth/hci_h5.c13
-rw-r--r--drivers/net/ieee802154/at86rf230.c91
-rw-r--r--drivers/net/ieee802154/cc2520.c1
-rw-r--r--drivers/net/ieee802154/fakelb.c3
-rw-r--r--drivers/net/wireless/ath/ath.h11
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.c9
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c30
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h5
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c7
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c99
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_tx.c4
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c27
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.h1
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c364
-rw-r--r--drivers/net/wireless/ath/ath10k/trace.h109
-rw-r--r--drivers/net/wireless/ath/ath10k/txrx.c3
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.c16
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c6
-rw-r--r--drivers/net/wireless/ath/ath6kl/usb.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig2
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile6
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_phy.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_hw.c51
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/ar953x_initvals.h498
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h11
-rw-r--r--drivers/net/wireless/ath/ath9k/channel.c23
-rw-r--r--drivers/net/wireless/ath/ath9k/common-spectral.c (renamed from drivers/net/wireless/ath/ath9k/spectral.c)165
-rw-r--r--drivers/net/wireless/ath/ath9k/common-spectral.h (renamed from drivers/net/wireless/ath/ath9k/spectral.h)29
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/gpio.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h5
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_debug.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c16
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c68
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h7
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c57
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c171
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h3
-rw-r--r--drivers/net/wireless/ath/wcn36xx/main.c7
-rw-r--r--drivers/net/wireless/b43/main.c7
-rw-r--r--drivers/net/wireless/b43/phy_common.c4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c6
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/firmware.c3
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c3
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c7
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c3
-rw-r--r--drivers/net/wireless/cw1200/scan.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c20
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c3
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c279
-rw-r--r--drivers/net/wireless/mac80211_hwsim.h3
-rw-r--r--drivers/net/wireless/mwifiex/11n.h4
-rw-r--r--drivers/net/wireless/mwifiex/Kconfig2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c6
-rw-r--r--drivers/net/wireless/mwifiex/decl.h5
-rw-r--r--drivers/net/wireless/mwifiex/fw.h1
-rw-r--r--drivers/net/wireless/mwifiex/init.c19
-rw-r--r--drivers/net/wireless/mwifiex/join.c4
-rw-r--r--drivers/net/wireless/mwifiex/main.c49
-rw-r--r--drivers/net/wireless/mwifiex/main.h44
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c2
-rw-r--r--drivers/net/wireless/mwifiex/sdio.h7
-rw-r--r--drivers/net/wireless/mwifiex/sta_event.c9
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c4
-rw-r--r--drivers/net/wireless/mwifiex/sta_rx.c3
-rw-r--r--drivers/net/wireless/mwifiex/tdls.c288
-rw-r--r--drivers/net/wireless/mwifiex/txrx.c4
-rw-r--r--drivers/net/wireless/mwifiex/uap_cmd.c2
-rw-r--r--drivers/net/wireless/mwifiex/usb.c51
-rw-r--r--drivers/net/wireless/mwifiex/usb.h3
-rw-r--r--drivers/net/wireless/mwifiex/util.c38
-rw-r--r--drivers/net/wireless/mwl8k.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c50
-rw-r--r--drivers/net/wireless/rtlwifi/core.c7
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c19
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c16
-rw-r--r--drivers/net/wireless/ti/wl1251/main.c2
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.c15
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.h2
-rw-r--r--drivers/staging/vt6656/main_usb.c7
99 files changed, 2324 insertions, 844 deletions
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c
index b068f98920a8..19f679667ca4 100644
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -339,7 +339,7 @@ void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
339 return; 339 return;
340 } 340 }
341 341
342 irq = bcma_core_irq(cc->core); 342 irq = bcma_core_irq(cc->core, 0);
343 343
344 /* Determine the registers of the UARTs */ 344 /* Determine the registers of the UARTs */
345 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART); 345 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c
index 706b9ae0dcfb..598a6cd9028a 100644
--- a/drivers/bcma/driver_gpio.c
+++ b/drivers/bcma/driver_gpio.c
@@ -152,7 +152,7 @@ static int bcma_gpio_irq_domain_init(struct bcma_drv_cc *cc)
152 handle_simple_irq); 152 handle_simple_irq);
153 } 153 }
154 154
155 hwirq = bcma_core_irq(cc->core); 155 hwirq = bcma_core_irq(cc->core, 0);
156 err = request_irq(hwirq, bcma_gpio_irq_handler, IRQF_SHARED, "gpio", 156 err = request_irq(hwirq, bcma_gpio_irq_handler, IRQF_SHARED, "gpio",
157 cc); 157 cc);
158 if (err) 158 if (err)
@@ -183,7 +183,7 @@ static void bcma_gpio_irq_domain_exit(struct bcma_drv_cc *cc)
183 return; 183 return;
184 184
185 bcma_cc_mask32(cc, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO); 185 bcma_cc_mask32(cc, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO);
186 free_irq(bcma_core_irq(cc->core), cc); 186 free_irq(bcma_core_irq(cc->core, 0), cc);
187 for (gpio = 0; gpio < chip->ngpio; gpio++) { 187 for (gpio = 0; gpio < chip->ngpio; gpio++) {
188 int irq = irq_find_mapping(cc->irq_domain, gpio); 188 int irq = irq_find_mapping(cc->irq_domain, gpio);
189 189
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
index 004d6aa671ce..5ec69c3d409d 100644
--- a/drivers/bcma/driver_mips.c
+++ b/drivers/bcma/driver_mips.c
@@ -115,7 +115,7 @@ static u32 bcma_core_mips_irqflag(struct bcma_device *dev)
115 * If disabled, 5 is returned. 115 * If disabled, 5 is returned.
116 * If not supported, 6 is returned. 116 * If not supported, 6 is returned.
117 */ 117 */
118static unsigned int bcma_core_mips_irq(struct bcma_device *dev) 118unsigned int bcma_core_mips_irq(struct bcma_device *dev)
119{ 119{
120 struct bcma_device *mdev = dev->bus->drv_mips.core; 120 struct bcma_device *mdev = dev->bus->drv_mips.core;
121 u32 irqflag; 121 u32 irqflag;
@@ -133,13 +133,6 @@ static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
133 return 5; 133 return 5;
134} 134}
135 135
136unsigned int bcma_core_irq(struct bcma_device *dev)
137{
138 unsigned int mips_irq = bcma_core_mips_irq(dev);
139 return mips_irq <= 4 ? mips_irq + 2 : 0;
140}
141EXPORT_SYMBOL(bcma_core_irq);
142
143static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq) 136static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
144{ 137{
145 unsigned int oldirq = bcma_core_mips_irq(dev); 138 unsigned int oldirq = bcma_core_mips_irq(dev);
@@ -423,7 +416,7 @@ void bcma_core_mips_init(struct bcma_drv_mips *mcore)
423 break; 416 break;
424 default: 417 default:
425 list_for_each_entry(core, &bus->cores, list) { 418 list_for_each_entry(core, &bus->cores, list) {
426 core->irq = bcma_core_irq(core); 419 core->irq = bcma_core_irq(core, 0);
427 } 420 }
428 bcma_err(bus, 421 bcma_err(bus,
429 "Unknown device (0x%x) found, can not configure IRQs\n", 422 "Unknown device (0x%x) found, can not configure IRQs\n",
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index c3d7b03c2fdc..c8a6b741967b 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -593,7 +593,7 @@ int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
593 pr_info("PCI: Fixing up device %s\n", pci_name(dev)); 593 pr_info("PCI: Fixing up device %s\n", pci_name(dev));
594 594
595 /* Fix up interrupt lines */ 595 /* Fix up interrupt lines */
596 dev->irq = bcma_core_irq(pc_host->pdev->core); 596 dev->irq = bcma_core_irq(pc_host->pdev->core, 0);
597 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 597 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
598 598
599 readrq = pcie_get_readrq(dev); 599 readrq = pcie_get_readrq(dev);
@@ -617,6 +617,6 @@ int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
617 617
618 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, 618 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
619 pci_ops); 619 pci_ops);
620 return bcma_core_irq(pc_host->pdev->core); 620 return bcma_core_irq(pc_host->pdev->core, 0);
621} 621}
622EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq); 622EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index a15e0bcfb397..534e1337766d 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -11,6 +11,7 @@
11#include <linux/bcma/bcma.h> 11#include <linux/bcma/bcma.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/of_address.h> 13#include <linux/of_address.h>
14#include <linux/of_irq.h>
14 15
15MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); 16MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
16MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
@@ -153,6 +154,46 @@ static struct device_node *bcma_of_find_child_device(struct platform_device *par
153 return NULL; 154 return NULL;
154} 155}
155 156
157static int bcma_of_irq_parse(struct platform_device *parent,
158 struct bcma_device *core,
159 struct of_phandle_args *out_irq, int num)
160{
161 __be32 laddr[1];
162 int rc;
163
164 if (core->dev.of_node) {
165 rc = of_irq_parse_one(core->dev.of_node, num, out_irq);
166 if (!rc)
167 return rc;
168 }
169
170 out_irq->np = parent->dev.of_node;
171 out_irq->args_count = 1;
172 out_irq->args[0] = num;
173
174 laddr[0] = cpu_to_be32(core->addr);
175 return of_irq_parse_raw(laddr, out_irq);
176}
177
178static unsigned int bcma_of_get_irq(struct platform_device *parent,
179 struct bcma_device *core, int num)
180{
181 struct of_phandle_args out_irq;
182 int ret;
183
184 if (!parent || !parent->dev.of_node)
185 return 0;
186
187 ret = bcma_of_irq_parse(parent, core, &out_irq, num);
188 if (ret) {
189 bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n",
190 ret);
191 return 0;
192 }
193
194 return irq_create_of_mapping(&out_irq);
195}
196
156static void bcma_of_fill_device(struct platform_device *parent, 197static void bcma_of_fill_device(struct platform_device *parent,
157 struct bcma_device *core) 198 struct bcma_device *core)
158{ 199{
@@ -161,14 +202,45 @@ static void bcma_of_fill_device(struct platform_device *parent,
161 node = bcma_of_find_child_device(parent, core); 202 node = bcma_of_find_child_device(parent, core);
162 if (node) 203 if (node)
163 core->dev.of_node = node; 204 core->dev.of_node = node;
205
206 core->irq = bcma_of_get_irq(parent, core, 0);
164} 207}
165#else 208#else
166static void bcma_of_fill_device(struct platform_device *parent, 209static void bcma_of_fill_device(struct platform_device *parent,
167 struct bcma_device *core) 210 struct bcma_device *core)
168{ 211{
169} 212}
213static inline unsigned int bcma_of_get_irq(struct platform_device *parent,
214 struct bcma_device *core, int num)
215{
216 return 0;
217}
170#endif /* CONFIG_OF */ 218#endif /* CONFIG_OF */
171 219
220unsigned int bcma_core_irq(struct bcma_device *core, int num)
221{
222 struct bcma_bus *bus = core->bus;
223 unsigned int mips_irq;
224
225 switch (bus->hosttype) {
226 case BCMA_HOSTTYPE_PCI:
227 return bus->host_pci->irq;
228 case BCMA_HOSTTYPE_SOC:
229 if (bus->drv_mips.core && num == 0) {
230 mips_irq = bcma_core_mips_irq(core);
231 return mips_irq <= 4 ? mips_irq + 2 : 0;
232 }
233 if (bus->host_pdev)
234 return bcma_of_get_irq(bus->host_pdev, core, num);
235 return 0;
236 case BCMA_HOSTTYPE_SDIO:
237 return 0;
238 }
239
240 return 0;
241}
242EXPORT_SYMBOL(bcma_core_irq);
243
172void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) 244void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
173{ 245{
174 core->dev.release = bcma_release_core_dev; 246 core->dev.release = bcma_release_core_dev;
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 03ce301fca92..7c13d7a8d83c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -106,6 +106,8 @@ static const struct usb_device_id btusb_table[] = {
106 { USB_DEVICE(0x0b05, 0x17b5) }, 106 { USB_DEVICE(0x0b05, 0x17b5) },
107 { USB_DEVICE(0x0b05, 0x17cb) }, 107 { USB_DEVICE(0x0b05, 0x17cb) },
108 { USB_DEVICE(0x413c, 0x8197) }, 108 { USB_DEVICE(0x413c, 0x8197) },
109 { USB_DEVICE(0x13d3, 0x3404),
110 .driver_info = BTUSB_BCM_PATCHRAM },
109 111
110 /* Foxconn - Hon Hai */ 112 /* Foxconn - Hon Hai */
111 { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) }, 113 { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
@@ -299,6 +301,8 @@ struct btusb_data {
299 unsigned int sco_num; 301 unsigned int sco_num;
300 int isoc_altsetting; 302 int isoc_altsetting;
301 int suspend_count; 303 int suspend_count;
304
305 int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
302}; 306};
303 307
304static inline void btusb_free_frags(struct btusb_data *data) 308static inline void btusb_free_frags(struct btusb_data *data)
@@ -590,7 +594,7 @@ static void btusb_bulk_complete(struct urb *urb)
590 if (urb->status == 0) { 594 if (urb->status == 0) {
591 hdev->stat.byte_rx += urb->actual_length; 595 hdev->stat.byte_rx += urb->actual_length;
592 596
593 if (btusb_recv_bulk(data, urb->transfer_buffer, 597 if (data->recv_bulk(data, urb->transfer_buffer,
594 urb->actual_length) < 0) { 598 urb->actual_length) < 0) {
595 BT_ERR("%s corrupted ACL packet", hdev->name); 599 BT_ERR("%s corrupted ACL packet", hdev->name);
596 hdev->stat.err_rx++; 600 hdev->stat.err_rx++;
@@ -2012,6 +2016,8 @@ static int btusb_probe(struct usb_interface *intf,
2012 init_usb_anchor(&data->isoc_anchor); 2016 init_usb_anchor(&data->isoc_anchor);
2013 spin_lock_init(&data->rxlock); 2017 spin_lock_init(&data->rxlock);
2014 2018
2019 data->recv_bulk = btusb_recv_bulk;
2020
2015 hdev = hci_alloc_dev(); 2021 hdev = hci_alloc_dev();
2016 if (!hdev) 2022 if (!hdev)
2017 return -ENOMEM; 2023 return -ENOMEM;
@@ -2035,6 +2041,7 @@ static int btusb_probe(struct usb_interface *intf,
2035 if (id->driver_info & BTUSB_BCM_PATCHRAM) { 2041 if (id->driver_info & BTUSB_BCM_PATCHRAM) {
2036 hdev->setup = btusb_setup_bcm_patchram; 2042 hdev->setup = btusb_setup_bcm_patchram;
2037 hdev->set_bdaddr = btusb_set_bdaddr_bcm; 2043 hdev->set_bdaddr = btusb_set_bdaddr_bcm;
2044 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
2038 } 2045 }
2039 2046
2040 if (id->driver_info & BTUSB_INTEL) { 2047 if (id->driver_info & BTUSB_INTEL) {
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
index 0bc8a6a6a148..2ff6dfd2d3f0 100644
--- a/drivers/bluetooth/hci_ath.c
+++ b/drivers/bluetooth/hci_ath.c
@@ -74,7 +74,7 @@ static int ath_wakeup_ar3k(struct tty_struct *tty)
74 74
75 status = tty->driver->ops->tiocmget(tty); 75 status = tty->driver->ops->tiocmget(tty);
76 76
77 /* Disable Automatic RTSCTS */ 77 /* Enable Automatic RTSCTS */
78 ktermios.c_cflag |= CRTSCTS; 78 ktermios.c_cflag |= CRTSCTS;
79 status = tty_set_termios(tty, &ktermios); 79 status = tty_set_termios(tty, &ktermios);
80 80
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 20bdd71559b1..ec0fa7732c0d 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -171,8 +171,6 @@ wakeup:
171static void h5_peer_reset(struct hci_uart *hu) 171static void h5_peer_reset(struct hci_uart *hu)
172{ 172{
173 struct h5 *h5 = hu->priv; 173 struct h5 *h5 = hu->priv;
174 struct sk_buff *skb;
175 const unsigned char hard_err[] = { 0x10, 0x01, 0x00 };
176 174
177 BT_ERR("Peer device has reset"); 175 BT_ERR("Peer device has reset");
178 176
@@ -187,15 +185,8 @@ static void h5_peer_reset(struct hci_uart *hu)
187 h5->tx_seq = 0; 185 h5->tx_seq = 0;
188 h5->tx_ack = 0; 186 h5->tx_ack = 0;
189 187
190 skb = bt_skb_alloc(3, GFP_ATOMIC); 188 /* Send reset request to upper stack */
191 if (!skb) 189 hci_reset_dev(hu->hdev);
192 return;
193
194 bt_cb(skb)->pkt_type = HCI_EVENT_PKT;
195 memcpy(skb_put(skb, 3), hard_err, 3);
196
197 /* Send Hardware Error to upper stack */
198 hci_recv_frame(hu->hdev, skb);
199} 190}
200 191
201static int h5_open(struct hci_uart *hu) 192static int h5_open(struct hci_uart *hu)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 9ad2d432ef43..1c0135620c62 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -46,10 +46,6 @@ struct at86rf2xx_chip_data {
46 u16 t_off_to_tx_on; 46 u16 t_off_to_tx_on;
47 u16 t_frame; 47 u16 t_frame;
48 u16 t_p_ack; 48 u16 t_p_ack;
49 /* short interframe spacing time */
50 u16 t_sifs;
51 /* long interframe spacing time */
52 u16 t_lifs;
53 /* completion timeout for tx in msecs */ 49 /* completion timeout for tx in msecs */
54 u16 t_tx_timeout; 50 u16 t_tx_timeout;
55 int rssi_base_val; 51 int rssi_base_val;
@@ -719,19 +715,10 @@ at86rf230_tx_complete(void *context)
719 715
720 enable_irq(lp->spi->irq); 716 enable_irq(lp->spi->irq);
721 717
722 if (lp->max_frame_retries <= 0) { 718 if (lp->max_frame_retries <= 0)
723 /* Interfame spacing time, which is phy depend. 719 ieee802154_xmit_complete(lp->hw, skb, true);
724 * TODO 720 else
725 * Move this handling in MAC 802.15.4 layer. 721 ieee802154_xmit_complete(lp->hw, skb, false);
726 * This is currently a workaround to avoid fragmenation issues.
727 */
728 if (skb->len > 18)
729 udelay(lp->data->t_lifs);
730 else
731 udelay(lp->data->t_sifs);
732 }
733
734 ieee802154_xmit_complete(lp->hw, skb);
735} 722}
736 723
737static void 724static void
@@ -1038,6 +1025,36 @@ at86rf212_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
1038 if (rc < 0) 1025 if (rc < 0)
1039 return rc; 1026 return rc;
1040 1027
1028 /* This sets the symbol_duration according frequency on the 212.
1029 * TODO move this handling while set channel and page in cfg802154.
1030 * We can do that, this timings are according 802.15.4 standard.
1031 * If we do that in cfg802154, this is a more generic calculation.
1032 *
1033 * This should also protected from ifs_timer. Means cancel timer and
1034 * init with a new value. For now, this is okay.
1035 */
1036 if (channel == 0) {
1037 if (page == 0) {
1038 /* SUB:0 and BPSK:0 -> BPSK-20 */
1039 lp->hw->phy->symbol_duration = 50;
1040 } else {
1041 /* SUB:1 and BPSK:0 -> BPSK-40 */
1042 lp->hw->phy->symbol_duration = 25;
1043 }
1044 } else {
1045 if (page == 0)
1046 /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
1047 lp->hw->phy->symbol_duration = 40;
1048 else
1049 /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
1050 lp->hw->phy->symbol_duration = 16;
1051 }
1052
1053 lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
1054 lp->hw->phy->symbol_duration;
1055 lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
1056 lp->hw->phy->symbol_duration;
1057
1041 return at86rf230_write_subreg(lp, SR_CHANNEL, channel); 1058 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
1042} 1059}
1043 1060
@@ -1047,23 +1064,11 @@ at86rf230_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
1047 struct at86rf230_local *lp = hw->priv; 1064 struct at86rf230_local *lp = hw->priv;
1048 int rc; 1065 int rc;
1049 1066
1050 if (page < 0 || page > 31 ||
1051 !(lp->hw->phy->channels_supported[page] & BIT(channel))) {
1052 WARN_ON(1);
1053 return -EINVAL;
1054 }
1055
1056 rc = lp->data->set_channel(lp, page, channel); 1067 rc = lp->data->set_channel(lp, page, channel);
1057 if (rc < 0)
1058 return rc;
1059
1060 /* Wait for PLL */ 1068 /* Wait for PLL */
1061 usleep_range(lp->data->t_channel_switch, 1069 usleep_range(lp->data->t_channel_switch,
1062 lp->data->t_channel_switch + 10); 1070 lp->data->t_channel_switch + 10);
1063 hw->phy->current_channel = channel; 1071 return rc;
1064 hw->phy->current_page = page;
1065
1066 return 0;
1067} 1072}
1068 1073
1069static int 1074static int
@@ -1179,9 +1184,6 @@ at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
1179 struct at86rf230_local *lp = hw->priv; 1184 struct at86rf230_local *lp = hw->priv;
1180 int rc; 1185 int rc;
1181 1186
1182 if (min_be > max_be || max_be > 8 || retries > 5)
1183 return -EINVAL;
1184
1185 rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be); 1187 rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be);
1186 if (rc) 1188 if (rc)
1187 return rc; 1189 return rc;
@@ -1199,9 +1201,6 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
1199 struct at86rf230_local *lp = hw->priv; 1201 struct at86rf230_local *lp = hw->priv;
1200 int rc = 0; 1202 int rc = 0;
1201 1203
1202 if (retries < -1 || retries > 15)
1203 return -EINVAL;
1204
1205 lp->tx_aret = retries >= 0; 1204 lp->tx_aret = retries >= 0;
1206 lp->max_frame_retries = retries; 1205 lp->max_frame_retries = retries;
1207 1206
@@ -1263,8 +1262,6 @@ static struct at86rf2xx_chip_data at86rf233_data = {
1263 .t_off_to_tx_on = 80, 1262 .t_off_to_tx_on = 80,
1264 .t_frame = 4096, 1263 .t_frame = 4096,
1265 .t_p_ack = 545, 1264 .t_p_ack = 545,
1266 .t_sifs = 192,
1267 .t_lifs = 640,
1268 .t_tx_timeout = 2000, 1265 .t_tx_timeout = 2000,
1269 .rssi_base_val = -91, 1266 .rssi_base_val = -91,
1270 .set_channel = at86rf23x_set_channel, 1267 .set_channel = at86rf23x_set_channel,
@@ -1279,8 +1276,6 @@ static struct at86rf2xx_chip_data at86rf231_data = {
1279 .t_off_to_tx_on = 110, 1276 .t_off_to_tx_on = 110,
1280 .t_frame = 4096, 1277 .t_frame = 4096,
1281 .t_p_ack = 545, 1278 .t_p_ack = 545,
1282 .t_sifs = 192,
1283 .t_lifs = 640,
1284 .t_tx_timeout = 2000, 1279 .t_tx_timeout = 2000,
1285 .rssi_base_val = -91, 1280 .rssi_base_val = -91,
1286 .set_channel = at86rf23x_set_channel, 1281 .set_channel = at86rf23x_set_channel,
@@ -1295,8 +1290,6 @@ static struct at86rf2xx_chip_data at86rf212_data = {
1295 .t_off_to_tx_on = 200, 1290 .t_off_to_tx_on = 200,
1296 .t_frame = 4096, 1291 .t_frame = 4096,
1297 .t_p_ack = 545, 1292 .t_p_ack = 545,
1298 .t_sifs = 192,
1299 .t_lifs = 640,
1300 .t_tx_timeout = 2000, 1293 .t_tx_timeout = 2000,
1301 .rssi_base_val = -100, 1294 .rssi_base_val = -100,
1302 .set_channel = at86rf212_set_channel, 1295 .set_channel = at86rf212_set_channel,
@@ -1358,7 +1351,11 @@ static int at86rf230_hw_init(struct at86rf230_local *lp)
1358 return -EINVAL; 1351 return -EINVAL;
1359 } 1352 }
1360 1353
1361 return 0; 1354 /* Force setting slotted operation bit to 0. Sometimes the atben
1355 * sets this bit and I don't know why. We set this always force
1356 * to zero while probing.
1357 */
1358 return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
1362} 1359}
1363 1360
1364static struct at86rf230_platform_data * 1361static struct at86rf230_platform_data *
@@ -1427,6 +1424,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)
1427 chip = "at86rf231"; 1424 chip = "at86rf231";
1428 lp->data = &at86rf231_data; 1425 lp->data = &at86rf231_data;
1429 lp->hw->phy->channels_supported[0] = 0x7FFF800; 1426 lp->hw->phy->channels_supported[0] = 0x7FFF800;
1427 lp->hw->phy->current_channel = 11;
1428 lp->hw->phy->symbol_duration = 16;
1430 break; 1429 break;
1431 case 7: 1430 case 7:
1432 chip = "at86rf212"; 1431 chip = "at86rf212";
@@ -1435,6 +1434,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)
1435 lp->hw->flags |= IEEE802154_HW_LBT; 1434 lp->hw->flags |= IEEE802154_HW_LBT;
1436 lp->hw->phy->channels_supported[0] = 0x00007FF; 1435 lp->hw->phy->channels_supported[0] = 0x00007FF;
1437 lp->hw->phy->channels_supported[2] = 0x00007FF; 1436 lp->hw->phy->channels_supported[2] = 0x00007FF;
1437 lp->hw->phy->current_channel = 5;
1438 lp->hw->phy->symbol_duration = 25;
1438 } else { 1439 } else {
1439 rc = -ENOTSUPP; 1440 rc = -ENOTSUPP;
1440 } 1441 }
@@ -1443,6 +1444,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)
1443 chip = "at86rf233"; 1444 chip = "at86rf233";
1444 lp->data = &at86rf233_data; 1445 lp->data = &at86rf233_data;
1445 lp->hw->phy->channels_supported[0] = 0x7FFF800; 1446 lp->hw->phy->channels_supported[0] = 0x7FFF800;
1447 lp->hw->phy->current_channel = 13;
1448 lp->hw->phy->symbol_duration = 16;
1446 break; 1449 break;
1447 default: 1450 default:
1448 chip = "unkown"; 1451 chip = "unkown";
@@ -1530,6 +1533,8 @@ static int at86rf230_probe(struct spi_device *spi)
1530 lp->hw = hw; 1533 lp->hw = hw;
1531 lp->spi = spi; 1534 lp->spi = spi;
1532 hw->parent = &spi->dev; 1535 hw->parent = &spi->dev;
1536 hw->vif_data_size = sizeof(*lp);
1537 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
1533 1538
1534 lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config); 1539 lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
1535 if (IS_ERR(lp->regmap)) { 1540 if (IS_ERR(lp->regmap)) {
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 340671b747b1..ccbb082f3391 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -651,6 +651,7 @@ static int cc2520_register(struct cc2520_private *priv)
651 priv->hw->priv = priv; 651 priv->hw->priv = priv;
652 priv->hw->parent = &priv->spi->dev; 652 priv->hw->parent = &priv->spi->dev;
653 priv->hw->extra_tx_headroom = 0; 653 priv->hw->extra_tx_headroom = 0;
654 priv->hw->vif_data_size = sizeof(*priv);
654 655
655 /* We do support only 2.4 Ghz */ 656 /* We do support only 2.4 Ghz */
656 priv->hw->phy->channels_supported[0] = 0x7FFF800; 657 priv->hw->phy->channels_supported[0] = 0x7FFF800;
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index 6e62286cef78..96947d724189 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -58,9 +58,6 @@ fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
58{ 58{
59 pr_debug("set channel to %d\n", channel); 59 pr_debug("set channel to %d\n", channel);
60 60
61 hw->phy->current_page = page;
62 hw->phy->current_channel = channel;
63
64 return 0; 61 return 0;
65} 62}
66 63
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 999d24ff242f..ccba4fea7269 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -135,6 +135,11 @@ struct ath_ops {
135struct ath_common; 135struct ath_common;
136struct ath_bus_ops; 136struct ath_bus_ops;
137 137
138struct ath_ps_ops {
139 void (*wakeup)(struct ath_common *common);
140 void (*restore)(struct ath_common *common);
141};
142
138struct ath_common { 143struct ath_common {
139 void *ah; 144 void *ah;
140 void *priv; 145 void *priv;
@@ -169,6 +174,7 @@ struct ath_common {
169 struct ath_regulatory reg_world_copy; 174 struct ath_regulatory reg_world_copy;
170 const struct ath_ops *ops; 175 const struct ath_ops *ops;
171 const struct ath_bus_ops *bus_ops; 176 const struct ath_bus_ops *bus_ops;
177 const struct ath_ps_ops *ps_ops;
172 178
173 bool btcoex_enabled; 179 bool btcoex_enabled;
174 bool disable_ani; 180 bool disable_ani;
@@ -178,6 +184,11 @@ struct ath_common {
178 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; 184 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
179}; 185};
180 186
187static inline const struct ath_ps_ops *ath_ps_ops(struct ath_common *common)
188{
189 return common->ps_ops;
190}
191
181struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, 192struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
182 u32 len, 193 u32 len,
183 gfp_t gfp_mask); 194 gfp_t gfp_mask);
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index 9b89ac133946..a156e6e48708 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -558,6 +558,7 @@ int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state,
558 558
559 /* sanity */ 559 /* sanity */
560 dest_ring->per_transfer_context[sw_index] = NULL; 560 dest_ring->per_transfer_context[sw_index] = NULL;
561 desc->nbytes = 0;
561 562
562 /* Update sw_index */ 563 /* Update sw_index */
563 sw_index = CE_RING_IDX_INCR(nentries_mask, sw_index); 564 sw_index = CE_RING_IDX_INCR(nentries_mask, sw_index);
@@ -835,8 +836,8 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
835 836
836 nentries = roundup_pow_of_two(attr->src_nentries); 837 nentries = roundup_pow_of_two(attr->src_nentries);
837 838
838 memset(src_ring->per_transfer_context, 0, 839 memset(src_ring->base_addr_owner_space, 0,
839 nentries * sizeof(*src_ring->per_transfer_context)); 840 nentries * sizeof(struct ce_desc));
840 841
841 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); 842 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr);
842 src_ring->sw_index &= src_ring->nentries_mask; 843 src_ring->sw_index &= src_ring->nentries_mask;
@@ -872,8 +873,8 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
872 873
873 nentries = roundup_pow_of_two(attr->dest_nentries); 874 nentries = roundup_pow_of_two(attr->dest_nentries);
874 875
875 memset(dest_ring->per_transfer_context, 0, 876 memset(dest_ring->base_addr_owner_space, 0,
876 nentries * sizeof(*dest_ring->per_transfer_context)); 877 nentries * sizeof(struct ce_desc));
877 878
878 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr); 879 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr);
879 dest_ring->sw_index &= dest_ring->nentries_mask; 880 dest_ring->sw_index &= dest_ring->nentries_mask;
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 5c23d00f7d60..f660553c6c48 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -31,12 +31,17 @@
31unsigned int ath10k_debug_mask; 31unsigned int ath10k_debug_mask;
32static bool uart_print; 32static bool uart_print;
33static unsigned int ath10k_p2p; 33static unsigned int ath10k_p2p;
34static bool skip_otp;
35
34module_param_named(debug_mask, ath10k_debug_mask, uint, 0644); 36module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);
35module_param(uart_print, bool, 0644); 37module_param(uart_print, bool, 0644);
36module_param_named(p2p, ath10k_p2p, uint, 0644); 38module_param_named(p2p, ath10k_p2p, uint, 0644);
39module_param(skip_otp, bool, 0644);
40
37MODULE_PARM_DESC(debug_mask, "Debugging mask"); 41MODULE_PARM_DESC(debug_mask, "Debugging mask");
38MODULE_PARM_DESC(uart_print, "Uart target debugging"); 42MODULE_PARM_DESC(uart_print, "Uart target debugging");
39MODULE_PARM_DESC(p2p, "Enable ath10k P2P support"); 43MODULE_PARM_DESC(p2p, "Enable ath10k P2P support");
44MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode");
40 45
41static const struct ath10k_hw_params ath10k_hw_params_list[] = { 46static const struct ath10k_hw_params ath10k_hw_params_list[] = {
42 { 47 {
@@ -280,7 +285,7 @@ static int ath10k_download_and_run_otp(struct ath10k *ar)
280 285
281 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot otp execute result %d\n", result); 286 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot otp execute result %d\n", result);
282 287
283 if (result != 0) { 288 if (!skip_otp && result != 0) {
284 ath10k_err(ar, "otp calibration failed: %d", result); 289 ath10k_err(ar, "otp calibration failed: %d", result);
285 return -EINVAL; 290 return -EINVAL;
286 } 291 }
@@ -744,6 +749,25 @@ static void ath10k_core_restart(struct work_struct *work)
744{ 749{
745 struct ath10k *ar = container_of(work, struct ath10k, restart_work); 750 struct ath10k *ar = container_of(work, struct ath10k, restart_work);
746 751
752 set_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
753
754 /* Place a barrier to make sure the compiler doesn't reorder
755 * CRASH_FLUSH and calling other functions.
756 */
757 barrier();
758
759 ieee80211_stop_queues(ar->hw);
760 ath10k_drain_tx(ar);
761 complete_all(&ar->scan.started);
762 complete_all(&ar->scan.completed);
763 complete_all(&ar->scan.on_channel);
764 complete_all(&ar->offchan_tx_completed);
765 complete_all(&ar->install_key_done);
766 complete_all(&ar->vdev_setup_done);
767 wake_up(&ar->htt.empty_tx_wq);
768 wake_up(&ar->wmi.tx_credits_wq);
769 wake_up(&ar->peer_mapping_wq);
770
747 mutex_lock(&ar->conf_mutex); 771 mutex_lock(&ar->conf_mutex);
748 772
749 switch (ar->state) { 773 switch (ar->state) {
@@ -781,6 +805,8 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
781 805
782 lockdep_assert_held(&ar->conf_mutex); 806 lockdep_assert_held(&ar->conf_mutex);
783 807
808 clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
809
784 ath10k_bmi_start(ar); 810 ath10k_bmi_start(ar);
785 811
786 if (ath10k_init_configure_target(ar)) { 812 if (ath10k_init_configure_target(ar)) {
@@ -1185,6 +1211,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
1185 1211
1186 INIT_LIST_HEAD(&ar->peers); 1212 INIT_LIST_HEAD(&ar->peers);
1187 init_waitqueue_head(&ar->peer_mapping_wq); 1213 init_waitqueue_head(&ar->peer_mapping_wq);
1214 init_waitqueue_head(&ar->htt.empty_tx_wq);
1215 init_waitqueue_head(&ar->wmi.tx_credits_wq);
1188 1216
1189 init_completion(&ar->offchan_tx_completed); 1217 init_completion(&ar->offchan_tx_completed);
1190 INIT_WORK(&ar->offchan_tx_work, ath10k_offchan_tx_work); 1218 INIT_WORK(&ar->offchan_tx_work, ath10k_offchan_tx_work);
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 4ca6dc94dd05..8f86bd34e823 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -386,6 +386,11 @@ enum ath10k_dev_flags {
386 /* Indicates that ath10k device is during CAC phase of DFS */ 386 /* Indicates that ath10k device is during CAC phase of DFS */
387 ATH10K_CAC_RUNNING, 387 ATH10K_CAC_RUNNING,
388 ATH10K_FLAG_CORE_REGISTERED, 388 ATH10K_FLAG_CORE_REGISTERED,
389
390 /* Device has crashed and needs to restart. This indicates any pending
391 * waiters should immediately cancel instead of waiting for a time out.
392 */
393 ATH10K_FLAG_CRASH_FLUSH,
389}; 394};
390 395
391enum ath10k_cal_mode { 396enum ath10k_cal_mode {
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 9147dd36dcdd..a8f5a72ba259 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -695,7 +695,8 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
695 "To simulate firmware crash write one of the keywords to this file:\n" 695 "To simulate firmware crash write one of the keywords to this file:\n"
696 "`soft` - this will send WMI_FORCE_FW_HANG_ASSERT to firmware if FW supports that command.\n" 696 "`soft` - this will send WMI_FORCE_FW_HANG_ASSERT to firmware if FW supports that command.\n"
697 "`hard` - this will send to firmware command with illegal parameters causing firmware crash.\n" 697 "`hard` - this will send to firmware command with illegal parameters causing firmware crash.\n"
698 "`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n"; 698 "`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n"
699 "`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
699 700
700 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 701 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
701} 702}
@@ -748,6 +749,10 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
748 } else if (!strcmp(buf, "assert")) { 749 } else if (!strcmp(buf, "assert")) {
749 ath10k_info(ar, "simulating firmware assert crash\n"); 750 ath10k_info(ar, "simulating firmware assert crash\n");
750 ret = ath10k_debug_fw_assert(ar); 751 ret = ath10k_debug_fw_assert(ar);
752 } else if (!strcmp(buf, "hw-restart")) {
753 ath10k_info(ar, "user requested hw restart\n");
754 queue_work(ar->workqueue, &ar->restart_work);
755 ret = 0;
751 } else { 756 } else {
752 ret = -EINVAL; 757 ret = -EINVAL;
753 goto exit; 758 goto exit;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index fbb3175d4d6e..52c630672718 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -291,8 +291,12 @@ static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt)
291 htt->rx_ring.sw_rd_idx.msdu_payld = idx; 291 htt->rx_ring.sw_rd_idx.msdu_payld = idx;
292 htt->rx_ring.fill_cnt--; 292 htt->rx_ring.fill_cnt--;
293 293
294 trace_ath10k_htt_rx_pop_msdu(ar, msdu->data, msdu->len + 294 dma_unmap_single(htt->ar->dev,
295 skb_tailroom(msdu)); 295 ATH10K_SKB_CB(msdu)->paddr,
296 msdu->len + skb_tailroom(msdu),
297 DMA_FROM_DEVICE);
298 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt rx netbuf pop: ",
299 msdu->data, msdu->len + skb_tailroom(msdu));
296 300
297 return msdu; 301 return msdu;
298} 302}
@@ -319,7 +323,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
319 int msdu_len, msdu_chaining = 0; 323 int msdu_len, msdu_chaining = 0;
320 struct sk_buff *msdu, *next; 324 struct sk_buff *msdu, *next;
321 struct htt_rx_desc *rx_desc; 325 struct htt_rx_desc *rx_desc;
322 u32 tsf;
323 326
324 lockdep_assert_held(&htt->rx_ring.lock); 327 lockdep_assert_held(&htt->rx_ring.lock);
325 328
@@ -332,14 +335,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
332 while (msdu) { 335 while (msdu) {
333 int last_msdu, msdu_len_invalid, msdu_chained; 336 int last_msdu, msdu_len_invalid, msdu_chained;
334 337
335 dma_unmap_single(htt->ar->dev,
336 ATH10K_SKB_CB(msdu)->paddr,
337 msdu->len + skb_tailroom(msdu),
338 DMA_FROM_DEVICE);
339
340 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt rx pop: ",
341 msdu->data, msdu->len + skb_tailroom(msdu));
342
343 rx_desc = (struct htt_rx_desc *)msdu->data; 338 rx_desc = (struct htt_rx_desc *)msdu->data;
344 339
345 /* FIXME: we must report msdu payload since this is what caller 340 /* FIXME: we must report msdu payload since this is what caller
@@ -430,14 +425,14 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
430 while (msdu_chained--) { 425 while (msdu_chained--) {
431 struct sk_buff *next = ath10k_htt_rx_netbuf_pop(htt); 426 struct sk_buff *next = ath10k_htt_rx_netbuf_pop(htt);
432 427
433 dma_unmap_single(htt->ar->dev, 428 if (!next) {
434 ATH10K_SKB_CB(next)->paddr, 429 ath10k_warn(ar, "failed to pop chained msdu\n");
435 next->len + skb_tailroom(next), 430 ath10k_htt_rx_free_msdu_chain(*head_msdu);
436 DMA_FROM_DEVICE); 431 *head_msdu = NULL;
437 432 msdu = NULL;
438 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, 433 htt->rx_confused = true;
439 "htt rx chained: ", next->data, 434 break;
440 next->len + skb_tailroom(next)); 435 }
441 436
442 skb_trim(next, 0); 437 skb_trim(next, 0);
443 skb_put(next, min(msdu_len, HTT_RX_BUF_SIZE)); 438 skb_put(next, min(msdu_len, HTT_RX_BUF_SIZE));
@@ -451,8 +446,7 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
451 last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) & 446 last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) &
452 RX_MSDU_END_INFO0_LAST_MSDU; 447 RX_MSDU_END_INFO0_LAST_MSDU;
453 448
454 tsf = __le32_to_cpu(rx_desc->ppdu_end.tsf_timestamp); 449 trace_ath10k_htt_rx_desc(ar, &rx_desc->attention,
455 trace_ath10k_htt_rx_desc(ar, tsf, &rx_desc->attention,
456 sizeof(*rx_desc) - sizeof(u32)); 450 sizeof(*rx_desc) - sizeof(u32));
457 if (last_msdu) { 451 if (last_msdu) {
458 msdu->next = NULL; 452 msdu->next = NULL;
@@ -499,6 +493,8 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt)
499 size_t size; 493 size_t size;
500 struct timer_list *timer = &htt->rx_ring.refill_retry_timer; 494 struct timer_list *timer = &htt->rx_ring.refill_retry_timer;
501 495
496 htt->rx_confused = false;
497
502 htt->rx_ring.size = ath10k_htt_rx_ring_size(htt); 498 htt->rx_ring.size = ath10k_htt_rx_ring_size(htt);
503 if (!is_power_of_2(htt->rx_ring.size)) { 499 if (!is_power_of_2(htt->rx_ring.size)) {
504 ath10k_warn(ar, "htt rx ring size is not power of 2\n"); 500 ath10k_warn(ar, "htt rx ring size is not power of 2\n");
@@ -588,41 +584,47 @@ static int ath10k_htt_rx_crypto_param_len(struct ath10k *ar,
588 enum htt_rx_mpdu_encrypt_type type) 584 enum htt_rx_mpdu_encrypt_type type)
589{ 585{
590 switch (type) { 586 switch (type) {
587 case HTT_RX_MPDU_ENCRYPT_NONE:
588 return 0;
591 case HTT_RX_MPDU_ENCRYPT_WEP40: 589 case HTT_RX_MPDU_ENCRYPT_WEP40:
592 case HTT_RX_MPDU_ENCRYPT_WEP104: 590 case HTT_RX_MPDU_ENCRYPT_WEP104:
593 return 4; 591 return IEEE80211_WEP_IV_LEN;
594 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC: 592 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
595 case HTT_RX_MPDU_ENCRYPT_WEP128: /* not tested */
596 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA: 593 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
597 case HTT_RX_MPDU_ENCRYPT_WAPI: /* not tested */ 594 return IEEE80211_TKIP_IV_LEN;
598 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2: 595 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
599 return 8; 596 return IEEE80211_CCMP_HDR_LEN;
600 case HTT_RX_MPDU_ENCRYPT_NONE: 597 case HTT_RX_MPDU_ENCRYPT_WEP128:
601 return 0; 598 case HTT_RX_MPDU_ENCRYPT_WAPI:
599 break;
602 } 600 }
603 601
604 ath10k_warn(ar, "unknown encryption type %d\n", type); 602 ath10k_warn(ar, "unsupported encryption type %d\n", type);
605 return 0; 603 return 0;
606} 604}
607 605
606#define MICHAEL_MIC_LEN 8
607
608static int ath10k_htt_rx_crypto_tail_len(struct ath10k *ar, 608static int ath10k_htt_rx_crypto_tail_len(struct ath10k *ar,
609 enum htt_rx_mpdu_encrypt_type type) 609 enum htt_rx_mpdu_encrypt_type type)
610{ 610{
611 switch (type) { 611 switch (type) {
612 case HTT_RX_MPDU_ENCRYPT_NONE: 612 case HTT_RX_MPDU_ENCRYPT_NONE:
613 return 0;
613 case HTT_RX_MPDU_ENCRYPT_WEP40: 614 case HTT_RX_MPDU_ENCRYPT_WEP40:
614 case HTT_RX_MPDU_ENCRYPT_WEP104: 615 case HTT_RX_MPDU_ENCRYPT_WEP104:
615 case HTT_RX_MPDU_ENCRYPT_WEP128: 616 return IEEE80211_WEP_ICV_LEN;
616 case HTT_RX_MPDU_ENCRYPT_WAPI:
617 return 0;
618 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC: 617 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
619 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA: 618 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
620 return 4; 619 return IEEE80211_TKIP_ICV_LEN;
621 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2: 620 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
622 return 8; 621 return IEEE80211_CCMP_MIC_LEN;
622 case HTT_RX_MPDU_ENCRYPT_WEP128:
623 case HTT_RX_MPDU_ENCRYPT_WAPI:
624 break;
623 } 625 }
624 626
625 ath10k_warn(ar, "unknown encryption type %d\n", type); 627 ath10k_warn(ar, "unsupported encryption type %d\n", type);
626 return 0; 628 return 0;
627} 629}
628 630
@@ -899,6 +901,8 @@ static void ath10k_process_rx(struct ath10k *ar,
899 !!(status->flag & RX_FLAG_AMSDU_MORE)); 901 !!(status->flag & RX_FLAG_AMSDU_MORE));
900 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ", 902 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ",
901 skb->data, skb->len); 903 skb->data, skb->len);
904 trace_ath10k_rx_hdr(ar, skb->data, skb->len);
905 trace_ath10k_rx_payload(ar, skb->data, skb->len);
902 906
903 ieee80211_rx(ar->hw, skb); 907 ieee80211_rx(ar->hw, skb);
904} 908}
@@ -1176,7 +1180,6 @@ static int ath10k_unchain_msdu(struct sk_buff *msdu_head)
1176 1180
1177static bool ath10k_htt_rx_amsdu_allowed(struct ath10k_htt *htt, 1181static bool ath10k_htt_rx_amsdu_allowed(struct ath10k_htt *htt,
1178 struct sk_buff *head, 1182 struct sk_buff *head,
1179 enum htt_rx_mpdu_status status,
1180 bool channel_set, 1183 bool channel_set,
1181 u32 attention) 1184 u32 attention)
1182{ 1185{
@@ -1200,22 +1203,11 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k_htt *htt,
1200 } 1203 }
1201 1204
1202 /* Skip mgmt frames while we handle this in WMI */ 1205 /* Skip mgmt frames while we handle this in WMI */
1203 if (status == HTT_RX_IND_MPDU_STATUS_MGMT_CTRL || 1206 if (attention & RX_ATTENTION_FLAGS_MGMT_TYPE) {
1204 attention & RX_ATTENTION_FLAGS_MGMT_TYPE) {
1205 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx mgmt ctrl\n"); 1207 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx mgmt ctrl\n");
1206 return false; 1208 return false;
1207 } 1209 }
1208 1210
1209 if (status != HTT_RX_IND_MPDU_STATUS_OK &&
1210 status != HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR &&
1211 status != HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER &&
1212 !htt->ar->monitor_started) {
1213 ath10k_dbg(ar, ATH10K_DBG_HTT,
1214 "htt rx ignoring frame w/ status %d\n",
1215 status);
1216 return false;
1217 }
1218
1219 if (test_bit(ATH10K_CAC_RUNNING, &htt->ar->dev_flags)) { 1211 if (test_bit(ATH10K_CAC_RUNNING, &htt->ar->dev_flags)) {
1220 ath10k_dbg(ar, ATH10K_DBG_HTT, 1212 ath10k_dbg(ar, ATH10K_DBG_HTT,
1221 "htt rx CAC running\n"); 1213 "htt rx CAC running\n");
@@ -1231,8 +1223,6 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
1231 struct ath10k *ar = htt->ar; 1223 struct ath10k *ar = htt->ar;
1232 struct ieee80211_rx_status *rx_status = &htt->rx_status; 1224 struct ieee80211_rx_status *rx_status = &htt->rx_status;
1233 struct htt_rx_indication_mpdu_range *mpdu_ranges; 1225 struct htt_rx_indication_mpdu_range *mpdu_ranges;
1234 struct htt_rx_desc *rxd;
1235 enum htt_rx_mpdu_status status;
1236 struct ieee80211_hdr *hdr; 1226 struct ieee80211_hdr *hdr;
1237 int num_mpdu_ranges; 1227 int num_mpdu_ranges;
1238 u32 attention; 1228 u32 attention;
@@ -1280,8 +1270,6 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
1280 num_mpdu_ranges)); 1270 num_mpdu_ranges));
1281 1271
1282 for (i = 0; i < num_mpdu_ranges; i++) { 1272 for (i = 0; i < num_mpdu_ranges; i++) {
1283 status = mpdu_ranges[i].mpdu_range_status;
1284
1285 for (j = 0; j < mpdu_ranges[i].mpdu_count; j++) { 1273 for (j = 0; j < mpdu_ranges[i].mpdu_count; j++) {
1286 struct sk_buff *msdu_head, *msdu_tail; 1274 struct sk_buff *msdu_head, *msdu_tail;
1287 1275
@@ -1302,12 +1290,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
1302 continue; 1290 continue;
1303 } 1291 }
1304 1292
1305 rxd = container_of((void *)msdu_head->data,
1306 struct htt_rx_desc,
1307 msdu_payload);
1308
1309 if (!ath10k_htt_rx_amsdu_allowed(htt, msdu_head, 1293 if (!ath10k_htt_rx_amsdu_allowed(htt, msdu_head,
1310 status,
1311 channel_set, 1294 channel_set,
1312 attention)) { 1295 attention)) {
1313 ath10k_htt_rx_free_msdu_chain(msdu_head); 1296 ath10k_htt_rx_free_msdu_chain(msdu_head);
@@ -1372,6 +1355,8 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
1372 &attention); 1355 &attention);
1373 spin_unlock_bh(&htt->rx_ring.lock); 1356 spin_unlock_bh(&htt->rx_ring.lock);
1374 1357
1358 tasklet_schedule(&htt->rx_replenish_task);
1359
1375 ath10k_dbg(ar, ATH10K_DBG_HTT_DUMP, "htt rx frag ahead\n"); 1360 ath10k_dbg(ar, ATH10K_DBG_HTT_DUMP, "htt rx frag ahead\n");
1376 1361
1377 if (ret) { 1362 if (ret) {
@@ -1433,7 +1418,7 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
1433 /* last fragment of TKIP frags has MIC */ 1418 /* last fragment of TKIP frags has MIC */
1434 if (!ieee80211_has_morefrags(hdr->frame_control) && 1419 if (!ieee80211_has_morefrags(hdr->frame_control) &&
1435 enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA) 1420 enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
1436 trim += 8; 1421 trim += MICHAEL_MIC_LEN;
1437 1422
1438 if (trim > msdu_head->len) { 1423 if (trim > msdu_head->len) {
1439 ath10k_warn(ar, "htt rx fragment: trailer longer than the frame itself? drop\n"); 1424 ath10k_warn(ar, "htt rx fragment: trailer longer than the frame itself? drop\n");
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index b0df470250a2..5b7e42f7377c 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -92,7 +92,6 @@ int ath10k_htt_tx_alloc(struct ath10k_htt *htt)
92 struct ath10k *ar = htt->ar; 92 struct ath10k *ar = htt->ar;
93 93
94 spin_lock_init(&htt->tx_lock); 94 spin_lock_init(&htt->tx_lock);
95 init_waitqueue_head(&htt->empty_tx_wq);
96 95
97 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, htt->ar->fw_features)) 96 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, htt->ar->fw_features))
98 htt->max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC; 97 htt->max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC;
@@ -564,7 +563,8 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
564 (u32)skb_cb->paddr, vdev_id, tid); 563 (u32)skb_cb->paddr, vdev_id, tid);
565 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ", 564 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ",
566 msdu->data, msdu->len); 565 msdu->data, msdu->len);
567 trace_ath10k_htt_tx_msdu(ar, msdu->data, msdu->len); 566 trace_ath10k_tx_hdr(ar, msdu->data, msdu->len);
567 trace_ath10k_tx_payload(ar, msdu->data, msdu->len);
568 568
569 sg_items[0].transfer_id = 0; 569 sg_items[0].transfer_id = 0;
570 sg_items[0].transfer_context = NULL; 570 sg_items[0].transfer_context = NULL;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 61b006f42f95..1245ac8c5c6f 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -519,6 +519,9 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
519 519
520 lockdep_assert_held(&ar->conf_mutex); 520 lockdep_assert_held(&ar->conf_mutex);
521 521
522 if (test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
523 return -ESHUTDOWN;
524
522 ret = wait_for_completion_timeout(&ar->vdev_setup_done, 525 ret = wait_for_completion_timeout(&ar->vdev_setup_done,
523 ATH10K_VDEV_SETUP_TIMEOUT_HZ); 526 ATH10K_VDEV_SETUP_TIMEOUT_HZ);
524 if (ret == 0) 527 if (ret == 0)
@@ -551,6 +554,8 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
551 arg.channel.max_reg_power = channel->max_reg_power * 2; 554 arg.channel.max_reg_power = channel->max_reg_power * 2;
552 arg.channel.max_antenna_gain = channel->max_antenna_gain * 2; 555 arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
553 556
557 reinit_completion(&ar->vdev_setup_done);
558
554 ret = ath10k_wmi_vdev_start(ar, &arg); 559 ret = ath10k_wmi_vdev_start(ar, &arg);
555 if (ret) { 560 if (ret) {
556 ath10k_warn(ar, "failed to request monitor vdev %i start: %d\n", 561 ath10k_warn(ar, "failed to request monitor vdev %i start: %d\n",
@@ -598,6 +603,8 @@ static int ath10k_monitor_vdev_stop(struct ath10k *ar)
598 ath10k_warn(ar, "failed to put down monitor vdev %i: %d\n", 603 ath10k_warn(ar, "failed to put down monitor vdev %i: %d\n",
599 ar->monitor_vdev_id, ret); 604 ar->monitor_vdev_id, ret);
600 605
606 reinit_completion(&ar->vdev_setup_done);
607
601 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id); 608 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id);
602 if (ret) 609 if (ret)
603 ath10k_warn(ar, "failed to to request monitor vdev %i stop: %d\n", 610 ath10k_warn(ar, "failed to to request monitor vdev %i stop: %d\n",
@@ -2350,7 +2357,7 @@ static void ath10k_tx(struct ieee80211_hw *hw,
2350} 2357}
2351 2358
2352/* Must not be called with conf_mutex held as workers can use that also. */ 2359/* Must not be called with conf_mutex held as workers can use that also. */
2353static void ath10k_drain_tx(struct ath10k *ar) 2360void ath10k_drain_tx(struct ath10k *ar)
2354{ 2361{
2355 /* make sure rcu-protected mac80211 tx path itself is drained */ 2362 /* make sure rcu-protected mac80211 tx path itself is drained */
2356 synchronize_net(); 2363 synchronize_net();
@@ -3307,9 +3314,10 @@ static void ath10k_cancel_hw_scan(struct ieee80211_hw *hw,
3307 struct ath10k *ar = hw->priv; 3314 struct ath10k *ar = hw->priv;
3308 3315
3309 mutex_lock(&ar->conf_mutex); 3316 mutex_lock(&ar->conf_mutex);
3310 cancel_delayed_work_sync(&ar->scan.timeout);
3311 ath10k_scan_abort(ar); 3317 ath10k_scan_abort(ar);
3312 mutex_unlock(&ar->conf_mutex); 3318 mutex_unlock(&ar->conf_mutex);
3319
3320 cancel_delayed_work_sync(&ar->scan.timeout);
3313} 3321}
3314 3322
3315static void ath10k_set_key_h_def_keyidx(struct ath10k *ar, 3323static void ath10k_set_key_h_def_keyidx(struct ath10k *ar,
@@ -3826,10 +3834,11 @@ static int ath10k_cancel_remain_on_channel(struct ieee80211_hw *hw)
3826 struct ath10k *ar = hw->priv; 3834 struct ath10k *ar = hw->priv;
3827 3835
3828 mutex_lock(&ar->conf_mutex); 3836 mutex_lock(&ar->conf_mutex);
3829 cancel_delayed_work_sync(&ar->scan.timeout);
3830 ath10k_scan_abort(ar); 3837 ath10k_scan_abort(ar);
3831 mutex_unlock(&ar->conf_mutex); 3838 mutex_unlock(&ar->conf_mutex);
3832 3839
3840 cancel_delayed_work_sync(&ar->scan.timeout);
3841
3833 return 0; 3842 return 0;
3834} 3843}
3835 3844
@@ -3872,7 +3881,7 @@ static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
3872 ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d fragmentation threshold %d\n", 3881 ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d fragmentation threshold %d\n",
3873 arvif->vdev_id, value); 3882 arvif->vdev_id, value);
3874 3883
3875 ret = ath10k_mac_set_rts(arvif, value); 3884 ret = ath10k_mac_set_frag(arvif, value);
3876 if (ret) { 3885 if (ret) {
3877 ath10k_warn(ar, "failed to set fragmentation threshold for vdev %d: %d\n", 3886 ath10k_warn(ar, "failed to set fragmentation threshold for vdev %d: %d\n",
3878 arvif->vdev_id, ret); 3887 arvif->vdev_id, ret);
@@ -3908,7 +3917,9 @@ static void ath10k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3908 empty = (ar->htt.num_pending_tx == 0); 3917 empty = (ar->htt.num_pending_tx == 0);
3909 spin_unlock_bh(&ar->htt.tx_lock); 3918 spin_unlock_bh(&ar->htt.tx_lock);
3910 3919
3911 skip = (ar->state == ATH10K_STATE_WEDGED); 3920 skip = (ar->state == ATH10K_STATE_WEDGED) ||
3921 test_bit(ATH10K_FLAG_CRASH_FLUSH,
3922 &ar->dev_flags);
3912 3923
3913 (empty || skip); 3924 (empty || skip);
3914 }), ATH10K_FLUSH_TIMEOUT_HZ); 3925 }), ATH10K_FLUSH_TIMEOUT_HZ);
@@ -4009,6 +4020,7 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw,
4009 if (ar->state == ATH10K_STATE_RESTARTED) { 4020 if (ar->state == ATH10K_STATE_RESTARTED) {
4010 ath10k_info(ar, "device successfully recovered\n"); 4021 ath10k_info(ar, "device successfully recovered\n");
4011 ar->state = ATH10K_STATE_ON; 4022 ar->state = ATH10K_STATE_ON;
4023 ieee80211_wake_queues(ar->hw);
4012 } 4024 }
4013 4025
4014 mutex_unlock(&ar->conf_mutex); 4026 mutex_unlock(&ar->conf_mutex);
@@ -4044,6 +4056,9 @@ static int ath10k_get_survey(struct ieee80211_hw *hw, int idx,
4044 4056
4045 survey->channel = &sband->channels[idx]; 4057 survey->channel = &sband->channels[idx];
4046 4058
4059 if (ar->rx_channel == survey->channel)
4060 survey->filled |= SURVEY_INFO_IN_USE;
4061
4047exit: 4062exit:
4048 mutex_unlock(&ar->conf_mutex); 4063 mutex_unlock(&ar->conf_mutex);
4049 return ret; 4064 return ret;
@@ -4917,6 +4932,8 @@ int ath10k_mac_register(struct ath10k *ar)
4917 ar->hw->wiphy->max_remain_on_channel_duration = 5000; 4932 ar->hw->wiphy->max_remain_on_channel_duration = 5000;
4918 4933
4919 ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 4934 ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
4935 ar->hw->wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE;
4936
4920 /* 4937 /*
4921 * on LL hardware queues are managed entirely by the FW 4938 * on LL hardware queues are managed entirely by the FW
4922 * so we only advertise to mac we can do the queues thing 4939 * so we only advertise to mac we can do the queues thing
diff --git a/drivers/net/wireless/ath/ath10k/mac.h b/drivers/net/wireless/ath/ath10k/mac.h
index 965c51117499..4e3c989aa841 100644
--- a/drivers/net/wireless/ath/ath10k/mac.h
+++ b/drivers/net/wireless/ath/ath10k/mac.h
@@ -40,6 +40,7 @@ void ath10k_mgmt_over_wmi_tx_purge(struct ath10k *ar);
40void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work); 40void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work);
41void ath10k_halt(struct ath10k *ar); 41void ath10k_halt(struct ath10k *ar);
42void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif); 42void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif);
43void ath10k_drain_tx(struct ath10k *ar);
43 44
44static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) 45static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif)
45{ 46{
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 4a4740b4bdc0..3a6b8a5ca96c 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1196,64 +1196,74 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
1196 return 0; 1196 return 0;
1197} 1197}
1198 1198
1199static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info) 1199static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pci_pipe)
1200{ 1200{
1201 struct ath10k *ar; 1201 struct ath10k *ar;
1202 struct ath10k_pci *ar_pci; 1202 struct ath10k_ce_pipe *ce_pipe;
1203 struct ath10k_ce_pipe *ce_hdl; 1203 struct ath10k_ce_ring *ce_ring;
1204 u32 buf_sz; 1204 struct sk_buff *skb;
1205 struct sk_buff *netbuf; 1205 int i;
1206 u32 ce_data;
1207 1206
1208 buf_sz = pipe_info->buf_sz; 1207 ar = pci_pipe->hif_ce_state;
1208 ce_pipe = pci_pipe->ce_hdl;
1209 ce_ring = ce_pipe->dest_ring;
1209 1210
1210 /* Unused Copy Engine */ 1211 if (!ce_ring)
1211 if (buf_sz == 0)
1212 return; 1212 return;
1213 1213
1214 ar = pipe_info->hif_ce_state; 1214 if (!pci_pipe->buf_sz)
1215 ar_pci = ath10k_pci_priv(ar); 1215 return;
1216 ce_hdl = pipe_info->ce_hdl;
1217 1216
1218 while (ath10k_ce_revoke_recv_next(ce_hdl, (void **)&netbuf, 1217 for (i = 0; i < ce_ring->nentries; i++) {
1219 &ce_data) == 0) { 1218 skb = ce_ring->per_transfer_context[i];
1220 dma_unmap_single(ar->dev, ATH10K_SKB_CB(netbuf)->paddr, 1219 if (!skb)
1221 netbuf->len + skb_tailroom(netbuf), 1220 continue;
1221
1222 ce_ring->per_transfer_context[i] = NULL;
1223
1224 dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr,
1225 skb->len + skb_tailroom(skb),
1222 DMA_FROM_DEVICE); 1226 DMA_FROM_DEVICE);
1223 dev_kfree_skb_any(netbuf); 1227 dev_kfree_skb_any(skb);
1224 } 1228 }
1225} 1229}
1226 1230
1227static void ath10k_pci_tx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info) 1231static void ath10k_pci_tx_pipe_cleanup(struct ath10k_pci_pipe *pci_pipe)
1228{ 1232{
1229 struct ath10k *ar; 1233 struct ath10k *ar;
1230 struct ath10k_pci *ar_pci; 1234 struct ath10k_pci *ar_pci;
1231 struct ath10k_ce_pipe *ce_hdl; 1235 struct ath10k_ce_pipe *ce_pipe;
1232 struct sk_buff *netbuf; 1236 struct ath10k_ce_ring *ce_ring;
1233 u32 ce_data; 1237 struct ce_desc *ce_desc;
1234 unsigned int nbytes; 1238 struct sk_buff *skb;
1235 unsigned int id; 1239 unsigned int id;
1236 u32 buf_sz; 1240 int i;
1237 1241
1238 buf_sz = pipe_info->buf_sz; 1242 ar = pci_pipe->hif_ce_state;
1243 ar_pci = ath10k_pci_priv(ar);
1244 ce_pipe = pci_pipe->ce_hdl;
1245 ce_ring = ce_pipe->src_ring;
1239 1246
1240 /* Unused Copy Engine */ 1247 if (!ce_ring)
1241 if (buf_sz == 0)
1242 return; 1248 return;
1243 1249
1244 ar = pipe_info->hif_ce_state; 1250 if (!pci_pipe->buf_sz)
1245 ar_pci = ath10k_pci_priv(ar); 1251 return;
1246 ce_hdl = pipe_info->ce_hdl;
1247 1252
1248 while (ath10k_ce_cancel_send_next(ce_hdl, (void **)&netbuf, 1253 ce_desc = ce_ring->shadow_base;
1249 &ce_data, &nbytes, &id) == 0) { 1254 if (WARN_ON(!ce_desc))
1250 /* no need to call tx completion for NULL pointers */ 1255 return;
1251 if (!netbuf) 1256
1257 for (i = 0; i < ce_ring->nentries; i++) {
1258 skb = ce_ring->per_transfer_context[i];
1259 if (!skb)
1252 continue; 1260 continue;
1253 1261
1254 ar_pci->msg_callbacks_current.tx_completion(ar, 1262 ce_ring->per_transfer_context[i] = NULL;
1255 netbuf, 1263 id = MS(__le16_to_cpu(ce_desc[i].flags),
1256 id); 1264 CE_DESC_FLAGS_META_DATA);
1265
1266 ar_pci->msg_callbacks_current.tx_completion(ar, skb, id);
1257 } 1267 }
1258} 1268}
1259 1269
@@ -1432,6 +1442,9 @@ static void ath10k_pci_bmi_recv_data(struct ath10k_ce_pipe *ce_state)
1432 &nbytes, &transfer_id, &flags)) 1442 &nbytes, &transfer_id, &flags))
1433 return; 1443 return;
1434 1444
1445 if (WARN_ON_ONCE(!xfer))
1446 return;
1447
1435 if (!xfer->wait_for_resp) { 1448 if (!xfer->wait_for_resp) {
1436 ath10k_warn(ar, "unexpected: BMI data received; ignoring\n"); 1449 ath10k_warn(ar, "unexpected: BMI data received; ignoring\n");
1437 return; 1450 return;
@@ -1707,99 +1720,167 @@ static void ath10k_pci_warm_reset_si0(struct ath10k *ar)
1707 msleep(10); 1720 msleep(10);
1708} 1721}
1709 1722
1710static int ath10k_pci_warm_reset(struct ath10k *ar) 1723static void ath10k_pci_warm_reset_cpu(struct ath10k *ar)
1711{ 1724{
1712 u32 val; 1725 u32 val;
1713 1726
1714 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset\n"); 1727 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, 0);
1715
1716 spin_lock_bh(&ar->data_lock);
1717
1718 ar->stats.fw_warm_reset_counter++;
1719
1720 spin_unlock_bh(&ar->data_lock);
1721
1722 /* debug */
1723 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
1724 PCIE_INTR_CAUSE_ADDRESS);
1725 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot host cpu intr cause: 0x%08x\n",
1726 val);
1727 1728
1728 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + 1729 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
1729 CPU_INTR_ADDRESS); 1730 SOC_RESET_CONTROL_ADDRESS);
1730 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target cpu intr cause: 0x%08x\n", 1731 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
1731 val); 1732 val | SOC_RESET_CONTROL_CPU_WARM_RST_MASK);
1733}
1732 1734
1733 /* disable pending irqs */ 1735static void ath10k_pci_warm_reset_ce(struct ath10k *ar)
1734 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + 1736{
1735 PCIE_INTR_ENABLE_ADDRESS, 0); 1737 u32 val;
1736 1738
1737 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + 1739 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
1738 PCIE_INTR_CLR_ADDRESS, ~0); 1740 SOC_RESET_CONTROL_ADDRESS);
1739 1741
1740 msleep(100); 1742 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
1743 val | SOC_RESET_CONTROL_CE_RST_MASK);
1744 msleep(10);
1745 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
1746 val & ~SOC_RESET_CONTROL_CE_RST_MASK);
1747}
1741 1748
1742 /* clear fw indicator */ 1749static void ath10k_pci_warm_reset_clear_lf(struct ath10k *ar)
1743 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, 0); 1750{
1751 u32 val;
1744 1752
1745 /* clear target LF timer interrupts */
1746 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + 1753 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
1747 SOC_LF_TIMER_CONTROL0_ADDRESS); 1754 SOC_LF_TIMER_CONTROL0_ADDRESS);
1748 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + 1755 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS +
1749 SOC_LF_TIMER_CONTROL0_ADDRESS, 1756 SOC_LF_TIMER_CONTROL0_ADDRESS,
1750 val & ~SOC_LF_TIMER_CONTROL0_ENABLE_MASK); 1757 val & ~SOC_LF_TIMER_CONTROL0_ENABLE_MASK);
1758}
1751 1759
1752 /* reset CE */ 1760static int ath10k_pci_warm_reset(struct ath10k *ar)
1753 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + 1761{
1754 SOC_RESET_CONTROL_ADDRESS); 1762 int ret;
1755 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
1756 val | SOC_RESET_CONTROL_CE_RST_MASK);
1757 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
1758 SOC_RESET_CONTROL_ADDRESS);
1759 msleep(10);
1760 1763
1761 /* unreset CE */ 1764 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset\n");
1762 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS, 1765
1763 val & ~SOC_RESET_CONTROL_CE_RST_MASK); 1766 spin_lock_bh(&ar->data_lock);
1764 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + 1767 ar->stats.fw_warm_reset_counter++;
1765 SOC_RESET_CONTROL_ADDRESS); 1768 spin_unlock_bh(&ar->data_lock);
1766 msleep(10);
1767 1769
1770 ath10k_pci_irq_disable(ar);
1771
1772 /* Make sure the target CPU is not doing anything dangerous, e.g. if it
1773 * were to access copy engine while host performs copy engine reset
1774 * then it is possible for the device to confuse pci-e controller to
1775 * the point of bringing host system to a complete stop (i.e. hang).
1776 */
1768 ath10k_pci_warm_reset_si0(ar); 1777 ath10k_pci_warm_reset_si0(ar);
1778 ath10k_pci_warm_reset_cpu(ar);
1779 ath10k_pci_init_pipes(ar);
1780 ath10k_pci_wait_for_target_init(ar);
1769 1781
1770 /* debug */ 1782 ath10k_pci_warm_reset_clear_lf(ar);
1771 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + 1783 ath10k_pci_warm_reset_ce(ar);
1772 PCIE_INTR_CAUSE_ADDRESS); 1784 ath10k_pci_warm_reset_cpu(ar);
1773 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot host cpu intr cause: 0x%08x\n", 1785 ath10k_pci_init_pipes(ar);
1774 val);
1775 1786
1776 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + 1787 ret = ath10k_pci_wait_for_target_init(ar);
1777 CPU_INTR_ADDRESS); 1788 if (ret) {
1778 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target cpu intr cause: 0x%08x\n", 1789 ath10k_warn(ar, "failed to wait for target init: %d\n", ret);
1779 val); 1790 return ret;
1791 }
1780 1792
1781 /* CPU warm reset */ 1793 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset complete\n");
1782 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
1783 SOC_RESET_CONTROL_ADDRESS);
1784 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
1785 val | SOC_RESET_CONTROL_CPU_WARM_RST_MASK);
1786 1794
1787 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + 1795 return 0;
1788 SOC_RESET_CONTROL_ADDRESS); 1796}
1789 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target reset state: 0x%08x\n",
1790 val);
1791 1797
1792 msleep(100); 1798static int ath10k_pci_chip_reset(struct ath10k *ar)
1799{
1800 int i, ret;
1801 u32 val;
1793 1802
1794 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset complete\n"); 1803 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset\n");
1804
1805 /* Some hardware revisions (e.g. CUS223v2) has issues with cold reset.
1806 * It is thus preferred to use warm reset which is safer but may not be
1807 * able to recover the device from all possible fail scenarios.
1808 *
1809 * Warm reset doesn't always work on first try so attempt it a few
1810 * times before giving up.
1811 */
1812 for (i = 0; i < ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS; i++) {
1813 ret = ath10k_pci_warm_reset(ar);
1814 if (ret) {
1815 ath10k_warn(ar, "failed to warm reset attempt %d of %d: %d\n",
1816 i + 1, ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS,
1817 ret);
1818 continue;
1819 }
1820
1821 /* FIXME: Sometimes copy engine doesn't recover after warm
1822 * reset. In most cases this needs cold reset. In some of these
1823 * cases the device is in such a state that a cold reset may
1824 * lock up the host.
1825 *
1826 * Reading any host interest register via copy engine is
1827 * sufficient to verify if device is capable of booting
1828 * firmware blob.
1829 */
1830 ret = ath10k_pci_init_pipes(ar);
1831 if (ret) {
1832 ath10k_warn(ar, "failed to init copy engine: %d\n",
1833 ret);
1834 continue;
1835 }
1836
1837 ret = ath10k_pci_diag_read32(ar, QCA988X_HOST_INTEREST_ADDRESS,
1838 &val);
1839 if (ret) {
1840 ath10k_warn(ar, "failed to poke copy engine: %d\n",
1841 ret);
1842 continue;
1843 }
1844
1845 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset complete (warm)\n");
1846 return 0;
1847 }
1848
1849 if (ath10k_pci_reset_mode == ATH10K_PCI_RESET_WARM_ONLY) {
1850 ath10k_warn(ar, "refusing cold reset as requested\n");
1851 return -EPERM;
1852 }
1853
1854 ret = ath10k_pci_cold_reset(ar);
1855 if (ret) {
1856 ath10k_warn(ar, "failed to cold reset: %d\n", ret);
1857 return ret;
1858 }
1859
1860 ret = ath10k_pci_wait_for_target_init(ar);
1861 if (ret) {
1862 ath10k_warn(ar, "failed to wait for target after cold reset: %d\n",
1863 ret);
1864 return ret;
1865 }
1866
1867 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset complete (cold)\n");
1795 1868
1796 return 0; 1869 return 0;
1797} 1870}
1798 1871
1799static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset) 1872static int ath10k_pci_hif_power_up(struct ath10k *ar)
1800{ 1873{
1801 int ret; 1874 int ret;
1802 1875
1876 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n");
1877
1878 ret = ath10k_pci_wake(ar);
1879 if (ret) {
1880 ath10k_err(ar, "failed to wake up target: %d\n", ret);
1881 return ret;
1882 }
1883
1803 /* 1884 /*
1804 * Bring the target up cleanly. 1885 * Bring the target up cleanly.
1805 * 1886 *
@@ -1810,26 +1891,16 @@ static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset)
1810 * is in an unexpected state. We try to catch that here in order to 1891 * is in an unexpected state. We try to catch that here in order to
1811 * reset the Target and retry the probe. 1892 * reset the Target and retry the probe.
1812 */ 1893 */
1813 if (cold_reset) 1894 ret = ath10k_pci_chip_reset(ar);
1814 ret = ath10k_pci_cold_reset(ar);
1815 else
1816 ret = ath10k_pci_warm_reset(ar);
1817
1818 if (ret) { 1895 if (ret) {
1819 ath10k_err(ar, "failed to reset target: %d\n", ret); 1896 ath10k_err(ar, "failed to reset chip: %d\n", ret);
1820 goto err; 1897 goto err_sleep;
1821 } 1898 }
1822 1899
1823 ret = ath10k_pci_init_pipes(ar); 1900 ret = ath10k_pci_init_pipes(ar);
1824 if (ret) { 1901 if (ret) {
1825 ath10k_err(ar, "failed to initialize CE: %d\n", ret); 1902 ath10k_err(ar, "failed to initialize CE: %d\n", ret);
1826 goto err; 1903 goto err_sleep;
1827 }
1828
1829 ret = ath10k_pci_wait_for_target_init(ar);
1830 if (ret) {
1831 ath10k_err(ar, "failed to wait for target to init: %d\n", ret);
1832 goto err_ce;
1833 } 1904 }
1834 1905
1835 ret = ath10k_pci_init_config(ar); 1906 ret = ath10k_pci_init_config(ar);
@@ -1848,73 +1919,21 @@ static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset)
1848 1919
1849err_ce: 1920err_ce:
1850 ath10k_pci_ce_deinit(ar); 1921 ath10k_pci_ce_deinit(ar);
1851 ath10k_pci_warm_reset(ar);
1852err:
1853 return ret;
1854}
1855
1856static int ath10k_pci_hif_power_up_warm(struct ath10k *ar)
1857{
1858 int i, ret;
1859
1860 /*
1861 * Sometime warm reset succeeds after retries.
1862 *
1863 * FIXME: It might be possible to tune ath10k_pci_warm_reset() to work
1864 * at first try.
1865 */
1866 for (i = 0; i < ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS; i++) {
1867 ret = __ath10k_pci_hif_power_up(ar, false);
1868 if (ret == 0)
1869 break;
1870
1871 ath10k_warn(ar, "failed to warm reset (attempt %d out of %d): %d\n",
1872 i + 1, ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS, ret);
1873 }
1874 1922
1923err_sleep:
1924 ath10k_pci_sleep(ar);
1875 return ret; 1925 return ret;
1876} 1926}
1877 1927
1878static int ath10k_pci_hif_power_up(struct ath10k *ar)
1879{
1880 int ret;
1881
1882 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n");
1883
1884 /*
1885 * Hardware CUS232 version 2 has some issues with cold reset and the
1886 * preferred (and safer) way to perform a device reset is through a
1887 * warm reset.
1888 *
1889 * Warm reset doesn't always work though so fall back to cold reset may
1890 * be necessary.
1891 */
1892 ret = ath10k_pci_hif_power_up_warm(ar);
1893 if (ret) {
1894 ath10k_warn(ar, "failed to power up target using warm reset: %d\n",
1895 ret);
1896
1897 if (ath10k_pci_reset_mode == ATH10K_PCI_RESET_WARM_ONLY)
1898 return ret;
1899
1900 ath10k_warn(ar, "trying cold reset\n");
1901
1902 ret = __ath10k_pci_hif_power_up(ar, true);
1903 if (ret) {
1904 ath10k_err(ar, "failed to power up target using cold reset too (%d)\n",
1905 ret);
1906 return ret;
1907 }
1908 }
1909
1910 return 0;
1911}
1912
1913static void ath10k_pci_hif_power_down(struct ath10k *ar) 1928static void ath10k_pci_hif_power_down(struct ath10k *ar)
1914{ 1929{
1915 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n"); 1930 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n");
1916 1931
1917 ath10k_pci_warm_reset(ar); 1932 /* Currently hif_power_up performs effectively a reset and hif_stop
1933 * resets the chip as well so there's no point in resetting here.
1934 */
1935
1936 ath10k_pci_sleep(ar);
1918} 1937}
1919 1938
1920#ifdef CONFIG_PM 1939#ifdef CONFIG_PM
@@ -2516,6 +2535,8 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2516 goto err_deinit_irq; 2535 goto err_deinit_irq;
2517 } 2536 }
2518 2537
2538 ath10k_pci_sleep(ar);
2539
2519 ret = ath10k_core_register(ar, chip_id); 2540 ret = ath10k_core_register(ar, chip_id);
2520 if (ret) { 2541 if (ret) {
2521 ath10k_err(ar, "failed to register driver core: %d\n", ret); 2542 ath10k_err(ar, "failed to register driver core: %d\n", ret);
@@ -2567,7 +2588,6 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
2567 ath10k_pci_deinit_irq(ar); 2588 ath10k_pci_deinit_irq(ar);
2568 ath10k_pci_ce_deinit(ar); 2589 ath10k_pci_ce_deinit(ar);
2569 ath10k_pci_free_pipes(ar); 2590 ath10k_pci_free_pipes(ar);
2570 ath10k_pci_sleep(ar);
2571 ath10k_pci_release(ar); 2591 ath10k_pci_release(ar);
2572 ath10k_core_destroy(ar); 2592 ath10k_core_destroy(ar);
2573} 2593}
diff --git a/drivers/net/wireless/ath/ath10k/trace.h b/drivers/net/wireless/ath/ath10k/trace.h
index 9d34e7f6c455..ceea5668f3f6 100644
--- a/drivers/net/wireless/ath/ath10k/trace.h
+++ b/drivers/net/wireless/ath/ath10k/trace.h
@@ -20,6 +20,13 @@
20#include <linux/tracepoint.h> 20#include <linux/tracepoint.h>
21#include "core.h" 21#include "core.h"
22 22
23#if !defined(_TRACE_H_)
24static inline u32 ath10k_frm_hdr_len(void *buf)
25{
26 return ieee80211_hdrlen(((struct ieee80211_hdr *)buf)->frame_control);
27}
28#endif
29
23#define _TRACE_H_ 30#define _TRACE_H_
24 31
25/* create empty functions when tracing is disabled */ 32/* create empty functions when tracing is disabled */
@@ -281,36 +288,6 @@ TRACE_EVENT(ath10k_htt_pktlog,
281 ) 288 )
282); 289);
283 290
284TRACE_EVENT(ath10k_htt_rx_desc,
285 TP_PROTO(struct ath10k *ar, u32 tsf, void *rxdesc, u16 len),
286
287 TP_ARGS(ar, tsf, rxdesc, len),
288
289 TP_STRUCT__entry(
290 __string(device, dev_name(ar->dev))
291 __string(driver, dev_driver_string(ar->dev))
292 __field(u32, tsf)
293 __field(u16, len)
294 __dynamic_array(u8, rxdesc, len)
295 ),
296
297 TP_fast_assign(
298 __assign_str(device, dev_name(ar->dev));
299 __assign_str(driver, dev_driver_string(ar->dev));
300 __entry->tsf = tsf;
301 __entry->len = len;
302 memcpy(__get_dynamic_array(rxdesc), rxdesc, len);
303 ),
304
305 TP_printk(
306 "%s %s %u len %hu",
307 __get_str(driver),
308 __get_str(device),
309 __entry->tsf,
310 __entry->len
311 )
312);
313
314TRACE_EVENT(ath10k_htt_tx, 291TRACE_EVENT(ath10k_htt_tx,
315 TP_PROTO(struct ath10k *ar, u16 msdu_id, u16 msdu_len, 292 TP_PROTO(struct ath10k *ar, u16 msdu_id, u16 msdu_len,
316 u8 vdev_id, u8 tid), 293 u8 vdev_id, u8 tid),
@@ -371,7 +348,7 @@ TRACE_EVENT(ath10k_txrx_tx_unref,
371 ) 348 )
372); 349);
373 350
374DECLARE_EVENT_CLASS(ath10k_data_event, 351DECLARE_EVENT_CLASS(ath10k_hdr_event,
375 TP_PROTO(struct ath10k *ar, void *data, size_t len), 352 TP_PROTO(struct ath10k *ar, void *data, size_t len),
376 353
377 TP_ARGS(ar, data, len), 354 TP_ARGS(ar, data, len),
@@ -380,14 +357,14 @@ DECLARE_EVENT_CLASS(ath10k_data_event,
380 __string(device, dev_name(ar->dev)) 357 __string(device, dev_name(ar->dev))
381 __string(driver, dev_driver_string(ar->dev)) 358 __string(driver, dev_driver_string(ar->dev))
382 __field(size_t, len) 359 __field(size_t, len)
383 __dynamic_array(u8, data, len) 360 __dynamic_array(u8, data, ath10k_frm_hdr_len(data))
384 ), 361 ),
385 362
386 TP_fast_assign( 363 TP_fast_assign(
387 __assign_str(device, dev_name(ar->dev)); 364 __assign_str(device, dev_name(ar->dev));
388 __assign_str(driver, dev_driver_string(ar->dev)); 365 __assign_str(driver, dev_driver_string(ar->dev));
389 __entry->len = len; 366 __entry->len = ath10k_frm_hdr_len(data);
390 memcpy(__get_dynamic_array(data), data, len); 367 memcpy(__get_dynamic_array(data), data, __entry->len);
391 ), 368 ),
392 369
393 TP_printk( 370 TP_printk(
@@ -398,25 +375,81 @@ DECLARE_EVENT_CLASS(ath10k_data_event,
398 ) 375 )
399); 376);
400 377
401DEFINE_EVENT(ath10k_data_event, ath10k_htt_tx_msdu, 378DECLARE_EVENT_CLASS(ath10k_payload_event,
379 TP_PROTO(struct ath10k *ar, void *data, size_t len),
380
381 TP_ARGS(ar, data, len),
382
383 TP_STRUCT__entry(
384 __string(device, dev_name(ar->dev))
385 __string(driver, dev_driver_string(ar->dev))
386 __field(size_t, len)
387 __dynamic_array(u8, payload, (len - ath10k_frm_hdr_len(data)))
388 ),
389
390 TP_fast_assign(
391 __assign_str(device, dev_name(ar->dev));
392 __assign_str(driver, dev_driver_string(ar->dev));
393 __entry->len = len - ath10k_frm_hdr_len(data);
394 memcpy(__get_dynamic_array(payload),
395 data + ath10k_frm_hdr_len(data), __entry->len);
396 ),
397
398 TP_printk(
399 "%s %s len %zu\n",
400 __get_str(driver),
401 __get_str(device),
402 __entry->len
403 )
404);
405
406DEFINE_EVENT(ath10k_hdr_event, ath10k_tx_hdr,
402 TP_PROTO(struct ath10k *ar, void *data, size_t len), 407 TP_PROTO(struct ath10k *ar, void *data, size_t len),
403 TP_ARGS(ar, data, len) 408 TP_ARGS(ar, data, len)
404); 409);
405 410
406DEFINE_EVENT(ath10k_data_event, ath10k_htt_rx_pop_msdu, 411DEFINE_EVENT(ath10k_payload_event, ath10k_tx_payload,
407 TP_PROTO(struct ath10k *ar, void *data, size_t len), 412 TP_PROTO(struct ath10k *ar, void *data, size_t len),
408 TP_ARGS(ar, data, len) 413 TP_ARGS(ar, data, len)
409); 414);
410 415
411DEFINE_EVENT(ath10k_data_event, ath10k_wmi_mgmt_tx, 416DEFINE_EVENT(ath10k_hdr_event, ath10k_rx_hdr,
412 TP_PROTO(struct ath10k *ar, void *data, size_t len), 417 TP_PROTO(struct ath10k *ar, void *data, size_t len),
413 TP_ARGS(ar, data, len) 418 TP_ARGS(ar, data, len)
414); 419);
415 420
416DEFINE_EVENT(ath10k_data_event, ath10k_wmi_bcn_tx, 421DEFINE_EVENT(ath10k_payload_event, ath10k_rx_payload,
417 TP_PROTO(struct ath10k *ar, void *data, size_t len), 422 TP_PROTO(struct ath10k *ar, void *data, size_t len),
418 TP_ARGS(ar, data, len) 423 TP_ARGS(ar, data, len)
419); 424);
425
426TRACE_EVENT(ath10k_htt_rx_desc,
427 TP_PROTO(struct ath10k *ar, void *data, size_t len),
428
429 TP_ARGS(ar, data, len),
430
431 TP_STRUCT__entry(
432 __string(device, dev_name(ar->dev))
433 __string(driver, dev_driver_string(ar->dev))
434 __field(u16, len)
435 __dynamic_array(u8, rxdesc, len)
436 ),
437
438 TP_fast_assign(
439 __assign_str(device, dev_name(ar->dev));
440 __assign_str(driver, dev_driver_string(ar->dev));
441 __entry->len = len;
442 memcpy(__get_dynamic_array(rxdesc), data, len);
443 ),
444
445 TP_printk(
446 "%s %s rxdesc len %d",
447 __get_str(driver),
448 __get_str(device),
449 __entry->len
450 )
451);
452
420#endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 453#endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
421 454
422/* we don't want to use include/trace/events */ 455/* we don't want to use include/trace/events */
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index f9c90e37bc7c..7579de8e7a8c 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -146,7 +146,8 @@ static int ath10k_wait_for_peer_common(struct ath10k *ar, int vdev_id,
146 mapped = !!ath10k_peer_find(ar, vdev_id, addr); 146 mapped = !!ath10k_peer_find(ar, vdev_id, addr);
147 spin_unlock_bh(&ar->data_lock); 147 spin_unlock_bh(&ar->data_lock);
148 148
149 mapped == expect_mapped; 149 (mapped == expect_mapped ||
150 test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags));
150 }), 3*HZ); 151 }), 3*HZ);
151 152
152 if (ret <= 0) 153 if (ret <= 0)
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index ae746cece211..c2bc8282f6cb 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -779,6 +779,10 @@ int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
779 ath10k_wmi_tx_beacons_nowait(ar); 779 ath10k_wmi_tx_beacons_nowait(ar);
780 780
781 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id); 781 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
782
783 if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
784 ret = -ESHUTDOWN;
785
782 (ret != -EAGAIN); 786 (ret != -EAGAIN);
783 }), 3*HZ); 787 }), 3*HZ);
784 788
@@ -834,7 +838,8 @@ int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
834 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n", 838 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
835 wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE, 839 wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE,
836 fc & IEEE80211_FCTL_STYPE); 840 fc & IEEE80211_FCTL_STYPE);
837 trace_ath10k_wmi_mgmt_tx(ar, skb->data, skb->len); 841 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
842 trace_ath10k_tx_payload(ar, skb->data, skb->len);
838 843
839 /* Send the management frame buffer to the target */ 844 /* Send the management frame buffer to the target */
840 ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid); 845 ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid);
@@ -1893,7 +1898,9 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
1893 arvif->beacon = bcn; 1898 arvif->beacon = bcn;
1894 arvif->beacon_sent = false; 1899 arvif->beacon_sent = false;
1895 1900
1896 trace_ath10k_wmi_bcn_tx(ar, bcn->data, bcn->len); 1901 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
1902 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
1903
1897 ath10k_wmi_tx_beacon_nowait(arvif); 1904 ath10k_wmi_tx_beacon_nowait(arvif);
1898skip: 1905skip:
1899 spin_unlock_bh(&ar->data_lock); 1906 spin_unlock_bh(&ar->data_lock);
@@ -4187,9 +4194,9 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
4187 4194
4188 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 4195 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
4189 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) 4196 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features))
4190 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
4191 else
4192 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg); 4197 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
4198 else
4199 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
4193 } else { 4200 } else {
4194 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg); 4201 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
4195 } 4202 }
@@ -4398,7 +4405,6 @@ int ath10k_wmi_attach(struct ath10k *ar)
4398 4405
4399 init_completion(&ar->wmi.service_ready); 4406 init_completion(&ar->wmi.service_ready);
4400 init_completion(&ar->wmi.unified_ready); 4407 init_completion(&ar->wmi.unified_ready);
4401 init_waitqueue_head(&ar->wmi.tx_credits_wq);
4402 4408
4403 return 0; 4409 return 0;
4404} 4410}
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index ab2709a43768..19eab2a69ad5 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -547,7 +547,9 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
547 547
548 548
549static void 549static void
550ath5k_sw_scan_start(struct ieee80211_hw *hw) 550ath5k_sw_scan_start(struct ieee80211_hw *hw,
551 struct ieee80211_vif *vif,
552 const u8 *mac_addr)
551{ 553{
552 struct ath5k_hw *ah = hw->priv; 554 struct ath5k_hw *ah = hw->priv;
553 if (!ah->assoc) 555 if (!ah->assoc)
@@ -556,7 +558,7 @@ ath5k_sw_scan_start(struct ieee80211_hw *hw)
556 558
557 559
558static void 560static void
559ath5k_sw_scan_complete(struct ieee80211_hw *hw) 561ath5k_sw_scan_complete(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
560{ 562{
561 struct ath5k_hw *ah = hw->priv; 563 struct ath5k_hw *ah = hw->priv;
562 ath5k_hw_set_ledstate(ah, ah->assoc ? 564 ath5k_hw_set_ledstate(ah, ah->assoc ?
diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c
index a6a5e40b3e98..9da3594fd010 100644
--- a/drivers/net/wireless/ath/ath6kl/usb.c
+++ b/drivers/net/wireless/ath/ath6kl/usb.c
@@ -1193,18 +1193,10 @@ static int ath6kl_usb_pm_resume(struct usb_interface *interface)
1193 return 0; 1193 return 0;
1194} 1194}
1195 1195
1196static int ath6kl_usb_pm_reset_resume(struct usb_interface *intf)
1197{
1198 if (usb_get_intfdata(intf))
1199 ath6kl_usb_remove(intf);
1200 return 0;
1201}
1202
1203#else 1196#else
1204 1197
1205#define ath6kl_usb_pm_suspend NULL 1198#define ath6kl_usb_pm_suspend NULL
1206#define ath6kl_usb_pm_resume NULL 1199#define ath6kl_usb_pm_resume NULL
1207#define ath6kl_usb_pm_reset_resume NULL
1208 1200
1209#endif 1201#endif
1210 1202
@@ -1222,7 +1214,6 @@ static struct usb_driver ath6kl_usb_driver = {
1222 .probe = ath6kl_usb_probe, 1214 .probe = ath6kl_usb_probe,
1223 .suspend = ath6kl_usb_pm_suspend, 1215 .suspend = ath6kl_usb_pm_suspend,
1224 .resume = ath6kl_usb_pm_resume, 1216 .resume = ath6kl_usb_pm_resume,
1225 .reset_resume = ath6kl_usb_pm_reset_resume,
1226 .disconnect = ath6kl_usb_remove, 1217 .disconnect = ath6kl_usb_remove,
1227 .id_table = ath6kl_usb_ids, 1218 .id_table = ath6kl_usb_ids,
1228 .supports_autosuspend = true, 1219 .supports_autosuspend = true,
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index ca101d7cb99f..fee0cadb0f5e 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -3,6 +3,8 @@ config ATH9K_HW
3config ATH9K_COMMON 3config ATH9K_COMMON
4 tristate 4 tristate
5 select ATH_COMMON 5 select ATH_COMMON
6 select DEBUG_FS
7 select RELAY
6config ATH9K_DFS_DEBUGFS 8config ATH9K_DFS_DEBUGFS
7 def_bool y 9 def_bool y
8 depends on ATH9K_DEBUGFS && ATH9K_DFS_CERTIFIED 10 depends on ATH9K_DEBUGFS && ATH9K_DFS_CERTIFIED
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 22b934b07bd4..473972288a84 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -16,8 +16,7 @@ ath9k-$(CONFIG_ATH9K_DFS_CERTIFIED) += dfs.o
16ath9k-$(CONFIG_ATH9K_TX99) += tx99.o 16ath9k-$(CONFIG_ATH9K_TX99) += tx99.o
17ath9k-$(CONFIG_ATH9K_WOW) += wow.o 17ath9k-$(CONFIG_ATH9K_WOW) += wow.o
18 18
19ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o \ 19ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o
20 spectral.o
21 20
22ath9k-$(CONFIG_ATH9K_STATION_STATISTICS) += debug_sta.o 21ath9k-$(CONFIG_ATH9K_STATION_STATISTICS) += debug_sta.o
23 22
@@ -59,7 +58,8 @@ obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o
59ath9k_common-y:= common.o \ 58ath9k_common-y:= common.o \
60 common-init.o \ 59 common-init.o \
61 common-beacon.o \ 60 common-beacon.o \
62 common-debug.o 61 common-debug.o \
62 common-spectral.o
63 63
64ath9k_htc-y += htc_hst.o \ 64ath9k_htc-y += htc_hst.o \
65 hif_usb.o \ 65 hif_usb.o \
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 9a2afa2c690b..fc08162b5820 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -643,9 +643,12 @@ static void ar9002_hw_spectral_scan_config(struct ath_hw *ah,
643 * and fix otherwise. 643 * and fix otherwise.
644 */ 644 */
645 count = param->count; 645 count = param->count;
646 if (param->endless) 646 if (param->endless) {
647 count = 0x80; 647 if (AR_SREV_9271(ah))
648 else if (count & 0x80) 648 count = 0;
649 else
650 count = 0x80;
651 } else if (count & 0x80)
649 count = 0x7f; 652 count = 0x7f;
650 653
651 REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN, 654 REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 80c6eacbda53..e726e405152c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -4079,27 +4079,28 @@ static int ar9003_hw_get_thermometer(struct ath_hw *ah)
4079 4079
4080static void ar9003_hw_thermometer_apply(struct ath_hw *ah) 4080static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
4081{ 4081{
4082 struct ath9k_hw_capabilities *pCap = &ah->caps;
4082 int thermometer = ar9003_hw_get_thermometer(ah); 4083 int thermometer = ar9003_hw_get_thermometer(ah);
4083 u8 therm_on = (thermometer < 0) ? 0 : 1; 4084 u8 therm_on = (thermometer < 0) ? 0 : 1;
4084 4085
4085 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, 4086 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
4086 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on); 4087 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4087 if (ah->caps.tx_chainmask & BIT(1)) 4088 if (pCap->chip_chainmask & BIT(1))
4088 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, 4089 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
4089 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on); 4090 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4090 if (ah->caps.tx_chainmask & BIT(2)) 4091 if (pCap->chip_chainmask & BIT(2))
4091 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, 4092 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
4092 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on); 4093 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4093 4094
4094 therm_on = (thermometer < 0) ? 0 : (thermometer == 0); 4095 therm_on = (thermometer < 0) ? 0 : (thermometer == 0);
4095 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, 4096 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
4096 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on); 4097 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
4097 if (ah->caps.tx_chainmask & BIT(1)) { 4098 if (pCap->chip_chainmask & BIT(1)) {
4098 therm_on = (thermometer < 0) ? 0 : (thermometer == 1); 4099 therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
4099 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, 4100 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
4100 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on); 4101 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
4101 } 4102 }
4102 if (ah->caps.tx_chainmask & BIT(2)) { 4103 if (pCap->chip_chainmask & BIT(2)) {
4103 therm_on = (thermometer < 0) ? 0 : (thermometer == 2); 4104 therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
4104 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, 4105 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
4105 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on); 4106 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index cb09102245b2..06ad2172030e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -333,12 +333,29 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
333 qca953x_1p0_soc_preamble); 333 qca953x_1p0_soc_preamble);
334 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 334 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
335 qca953x_1p0_soc_postamble); 335 qca953x_1p0_soc_postamble);
336 INIT_INI_ARRAY(&ah->iniModesRxGain, 336
337 qca953x_1p0_common_wo_xlna_rx_gain_table); 337 if (AR_SREV_9531_20(ah)) {
338 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 338 INIT_INI_ARRAY(&ah->iniModesRxGain,
339 qca953x_1p0_common_wo_xlna_rx_gain_bounds); 339 qca953x_2p0_common_wo_xlna_rx_gain_table);
340 INIT_INI_ARRAY(&ah->iniModesTxGain, 340 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
341 qca953x_1p0_modes_no_xpa_tx_gain_table); 341 qca953x_2p0_common_wo_xlna_rx_gain_bounds);
342 } else {
343 INIT_INI_ARRAY(&ah->iniModesRxGain,
344 qca953x_1p0_common_wo_xlna_rx_gain_table);
345 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
346 qca953x_1p0_common_wo_xlna_rx_gain_bounds);
347 }
348
349 if (AR_SREV_9531_20(ah))
350 INIT_INI_ARRAY(&ah->iniModesTxGain,
351 qca953x_2p0_modes_no_xpa_tx_gain_table);
352 else if (AR_SREV_9531_11(ah))
353 INIT_INI_ARRAY(&ah->iniModesTxGain,
354 qca953x_1p1_modes_no_xpa_tx_gain_table);
355 else
356 INIT_INI_ARRAY(&ah->iniModesTxGain,
357 qca953x_1p0_modes_no_xpa_tx_gain_table);
358
342 INIT_INI_ARRAY(&ah->iniModesFastClock, 359 INIT_INI_ARRAY(&ah->iniModesFastClock,
343 qca953x_1p0_modes_fast_clock); 360 qca953x_1p0_modes_fast_clock);
344 } else if (AR_SREV_9580(ah)) { 361 } else if (AR_SREV_9580(ah)) {
@@ -518,9 +535,15 @@ static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
518 else if (AR_SREV_9550(ah)) 535 else if (AR_SREV_9550(ah))
519 INIT_INI_ARRAY(&ah->iniModesTxGain, 536 INIT_INI_ARRAY(&ah->iniModesTxGain,
520 ar955x_1p0_modes_xpa_tx_gain_table); 537 ar955x_1p0_modes_xpa_tx_gain_table);
521 else if (AR_SREV_9531(ah)) 538 else if (AR_SREV_9531_10(ah))
539 INIT_INI_ARRAY(&ah->iniModesTxGain,
540 qca953x_1p0_modes_xpa_tx_gain_table);
541 else if (AR_SREV_9531_11(ah))
522 INIT_INI_ARRAY(&ah->iniModesTxGain, 542 INIT_INI_ARRAY(&ah->iniModesTxGain,
523 qca953x_1p0_modes_xpa_tx_gain_table); 543 qca953x_1p1_modes_xpa_tx_gain_table);
544 else if (AR_SREV_9531_20(ah))
545 INIT_INI_ARRAY(&ah->iniModesTxGain,
546 qca953x_2p0_modes_xpa_tx_gain_table);
524 else if (AR_SREV_9580(ah)) 547 else if (AR_SREV_9580(ah))
525 INIT_INI_ARRAY(&ah->iniModesTxGain, 548 INIT_INI_ARRAY(&ah->iniModesTxGain,
526 ar9580_1p0_lowest_ob_db_tx_gain_table); 549 ar9580_1p0_lowest_ob_db_tx_gain_table);
@@ -562,7 +585,10 @@ static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
562 INIT_INI_ARRAY(&ah->iniModesTxGain, 585 INIT_INI_ARRAY(&ah->iniModesTxGain,
563 ar955x_1p0_modes_no_xpa_tx_gain_table); 586 ar955x_1p0_modes_no_xpa_tx_gain_table);
564 else if (AR_SREV_9531(ah)) { 587 else if (AR_SREV_9531(ah)) {
565 if (AR_SREV_9531_11(ah)) 588 if (AR_SREV_9531_20(ah))
589 INIT_INI_ARRAY(&ah->iniModesTxGain,
590 qca953x_2p0_modes_no_xpa_tx_gain_table);
591 else if (AR_SREV_9531_11(ah))
566 INIT_INI_ARRAY(&ah->iniModesTxGain, 592 INIT_INI_ARRAY(&ah->iniModesTxGain,
567 qca953x_1p1_modes_no_xpa_tx_gain_table); 593 qca953x_1p1_modes_no_xpa_tx_gain_table);
568 else 594 else
@@ -789,11 +815,16 @@ static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
789 ar955x_1p0_common_wo_xlna_rx_gain_table); 815 ar955x_1p0_common_wo_xlna_rx_gain_table);
790 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 816 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
791 ar955x_1p0_common_wo_xlna_rx_gain_bounds); 817 ar955x_1p0_common_wo_xlna_rx_gain_bounds);
792 } else if (AR_SREV_9531(ah)) { 818 } else if (AR_SREV_9531_10(ah) || AR_SREV_9531_11(ah)) {
793 INIT_INI_ARRAY(&ah->iniModesRxGain, 819 INIT_INI_ARRAY(&ah->iniModesRxGain,
794 qca953x_1p0_common_wo_xlna_rx_gain_table); 820 qca953x_1p0_common_wo_xlna_rx_gain_table);
795 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 821 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
796 qca953x_1p0_common_wo_xlna_rx_gain_bounds); 822 qca953x_1p0_common_wo_xlna_rx_gain_bounds);
823 } else if (AR_SREV_9531_20(ah)) {
824 INIT_INI_ARRAY(&ah->iniModesRxGain,
825 qca953x_2p0_common_wo_xlna_rx_gain_table);
826 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
827 qca953x_2p0_common_wo_xlna_rx_gain_bounds);
797 } else if (AR_SREV_9580(ah)) 828 } else if (AR_SREV_9580(ah))
798 INIT_INI_ARRAY(&ah->iniModesRxGain, 829 INIT_INI_ARRAY(&ah->iniModesRxGain,
799 ar9580_1p0_wo_xlna_rx_gain_table); 830 ar9580_1p0_wo_xlna_rx_gain_table);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 9bdaa0afc37f..2df6d2ee70c2 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -664,6 +664,19 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
664 ah->enabled_cals |= TX_CL_CAL; 664 ah->enabled_cals |= TX_CL_CAL;
665 else 665 else
666 ah->enabled_cals &= ~TX_CL_CAL; 666 ah->enabled_cals &= ~TX_CL_CAL;
667
668 if (AR_SREV_9340(ah) || AR_SREV_9531(ah) || AR_SREV_9550(ah)) {
669 if (ah->is_clk_25mhz) {
670 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
671 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
672 REG_WRITE(ah, AR_SLP32_INC, 0x0001e7ae);
673 } else {
674 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x261 << 1);
675 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f400);
676 REG_WRITE(ah, AR_SLP32_INC, 0x0001e800);
677 }
678 udelay(100);
679 }
667} 680}
668 681
669static void ar9003_hw_prog_ini(struct ath_hw *ah, 682static void ar9003_hw_prog_ini(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath/ath9k/ar953x_initvals.h b/drivers/net/wireless/ath/ath9k/ar953x_initvals.h
index 812a9d787bf3..159cc6fd2362 100644
--- a/drivers/net/wireless/ath/ath9k/ar953x_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar953x_initvals.h
@@ -20,6 +20,8 @@
20 20
21#define qca953x_1p0_mac_postamble ar9300_2p2_mac_postamble 21#define qca953x_1p0_mac_postamble ar9300_2p2_mac_postamble
22 22
23#define qca953x_1p0_soc_preamble ar955x_1p0_soc_preamble
24
23#define qca953x_1p0_soc_postamble ar9300_2p2_soc_postamble 25#define qca953x_1p0_soc_postamble ar9300_2p2_soc_postamble
24 26
25#define qca953x_1p0_common_rx_gain_table ar9300Common_rx_gain_table_2p2 27#define qca953x_1p0_common_rx_gain_table ar9300Common_rx_gain_table_2p2
@@ -28,6 +30,10 @@
28 30
29#define qca953x_1p0_modes_fast_clock ar9300Modes_fast_clock_2p2 31#define qca953x_1p0_modes_fast_clock ar9300Modes_fast_clock_2p2
30 32
33#define qca953x_1p0_common_wo_xlna_rx_gain_bounds ar955x_1p0_common_wo_xlna_rx_gain_bounds
34
35#define qca953x_1p0_common_rx_gain_bounds ar955x_1p0_common_rx_gain_bounds
36
31static const u32 qca953x_1p0_mac_core[][2] = { 37static const u32 qca953x_1p0_mac_core[][2] = {
32 /* Addr allmodes */ 38 /* Addr allmodes */
33 {0x00000008, 0x00000000}, 39 {0x00000008, 0x00000000},
@@ -490,35 +496,6 @@ static const u32 qca953x_1p0_radio_postamble[][5] = {
490 {0x00016540, 0x10804008, 0x10804008, 0x50804000, 0x50804000}, 496 {0x00016540, 0x10804008, 0x10804008, 0x50804000, 0x50804000},
491}; 497};
492 498
493static const u32 qca953x_1p0_soc_preamble[][2] = {
494 /* Addr allmodes */
495 {0x00007000, 0x00000000},
496 {0x00007004, 0x00000000},
497 {0x00007008, 0x00000000},
498 {0x0000700c, 0x00000000},
499 {0x0000701c, 0x00000000},
500 {0x00007020, 0x00000000},
501 {0x00007024, 0x00000000},
502 {0x00007028, 0x00000000},
503 {0x0000702c, 0x00000000},
504 {0x00007030, 0x00000000},
505 {0x00007034, 0x00000002},
506 {0x00007038, 0x000004c2},
507 {0x00007048, 0x00000000},
508};
509
510static const u32 qca953x_1p0_common_rx_gain_bounds[][5] = {
511 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
512 {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27},
513 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302018, 0x50302018},
514};
515
516static const u32 qca953x_1p0_common_wo_xlna_rx_gain_bounds[][5] = {
517 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
518 {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27},
519 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
520};
521
522static const u32 qca953x_1p0_modes_xpa_tx_gain_table[][2] = { 499static const u32 qca953x_1p0_modes_xpa_tx_gain_table[][2] = {
523 /* Addr allmodes */ 500 /* Addr allmodes */
524 {0x0000a2dc, 0xfffd5aaa}, 501 {0x0000a2dc, 0xfffd5aaa},
@@ -715,8 +692,73 @@ static const u32 qca953x_1p1_modes_no_xpa_tx_gain_table[][2] = {
715 {0x00016448, 0x6c927a70}, 692 {0x00016448, 0x6c927a70},
716}; 693};
717 694
695static const u32 qca953x_1p1_modes_xpa_tx_gain_table[][2] = {
696 /* Addr allmodes */
697 {0x0000a2dc, 0xfffb52aa},
698 {0x0000a2e0, 0xfffd64cc},
699 {0x0000a2e4, 0xfffe80f0},
700 {0x0000a2e8, 0xffffff00},
701 {0x0000a410, 0x000050d5},
702 {0x0000a500, 0x00000000},
703 {0x0000a504, 0x04000002},
704 {0x0000a508, 0x08000004},
705 {0x0000a50c, 0x0c000006},
706 {0x0000a510, 0x1000000a},
707 {0x0000a514, 0x1400000c},
708 {0x0000a518, 0x1800000e},
709 {0x0000a51c, 0x1c000048},
710 {0x0000a520, 0x2000004a},
711 {0x0000a524, 0x2400004c},
712 {0x0000a528, 0x2800004e},
713 {0x0000a52c, 0x2b00024a},
714 {0x0000a530, 0x2f00024c},
715 {0x0000a534, 0x3300024e},
716 {0x0000a538, 0x36000668},
717 {0x0000a53c, 0x38000669},
718 {0x0000a540, 0x3a000868},
719 {0x0000a544, 0x3d00086a},
720 {0x0000a548, 0x4000086c},
721 {0x0000a54c, 0x4200086e},
722 {0x0000a550, 0x43000a6e},
723 {0x0000a554, 0x43000a6e},
724 {0x0000a558, 0x43000a6e},
725 {0x0000a55c, 0x43000a6e},
726 {0x0000a560, 0x43000a6e},
727 {0x0000a564, 0x43000a6e},
728 {0x0000a568, 0x43000a6e},
729 {0x0000a56c, 0x43000a6e},
730 {0x0000a570, 0x43000a6e},
731 {0x0000a574, 0x43000a6e},
732 {0x0000a578, 0x43000a6e},
733 {0x0000a57c, 0x43000a6e},
734 {0x0000a600, 0x00000000},
735 {0x0000a604, 0x00000000},
736 {0x0000a608, 0x00000000},
737 {0x0000a60c, 0x03804000},
738 {0x0000a610, 0x03804e01},
739 {0x0000a614, 0x03804e01},
740 {0x0000a618, 0x03804e01},
741 {0x0000a61c, 0x04009002},
742 {0x0000a620, 0x04009002},
743 {0x0000a624, 0x04009002},
744 {0x0000a628, 0x04009002},
745 {0x0000a62c, 0x04009002},
746 {0x0000a630, 0x04009002},
747 {0x0000a634, 0x04009002},
748 {0x0000a638, 0x04009002},
749 {0x0000a63c, 0x04009002},
750 {0x0000b2dc, 0xfffb52aa},
751 {0x0000b2e0, 0xfffd64cc},
752 {0x0000b2e4, 0xfffe80f0},
753 {0x0000b2e8, 0xffffff00},
754 {0x00016044, 0x024922db},
755 {0x00016048, 0x6c927a70},
756 {0x00016444, 0x024922db},
757 {0x00016448, 0x6c927a70},
758};
759
718static const u32 qca953x_2p0_baseband_core[][2] = { 760static const u32 qca953x_2p0_baseband_core[][2] = {
719 /* Addr allmodes */ 761 /* Addr allmodes */
720 {0x00009800, 0xafe68e30}, 762 {0x00009800, 0xafe68e30},
721 {0x00009804, 0xfd14e000}, 763 {0x00009804, 0xfd14e000},
722 {0x00009808, 0x9c0a9f6b}, 764 {0x00009808, 0x9c0a9f6b},
@@ -914,4 +956,400 @@ static const u32 qca953x_2p0_baseband_postamble[][5] = {
914 {0x0000b284, 0x00000000, 0x00000000, 0x00000010, 0x00000010}, 956 {0x0000b284, 0x00000000, 0x00000000, 0x00000010, 0x00000010},
915}; 957};
916 958
959static const u32 qca953x_2p0_common_wo_xlna_rx_gain_table[][2] = {
960 /* Addr allmodes */
961 {0x0000a000, 0x00010000},
962 {0x0000a004, 0x00030002},
963 {0x0000a008, 0x00050004},
964 {0x0000a00c, 0x00810080},
965 {0x0000a010, 0x00830082},
966 {0x0000a014, 0x01810180},
967 {0x0000a018, 0x01830182},
968 {0x0000a01c, 0x01850184},
969 {0x0000a020, 0x01890188},
970 {0x0000a024, 0x018b018a},
971 {0x0000a028, 0x018d018c},
972 {0x0000a02c, 0x03820190},
973 {0x0000a030, 0x03840383},
974 {0x0000a034, 0x03880385},
975 {0x0000a038, 0x038a0389},
976 {0x0000a03c, 0x038c038b},
977 {0x0000a040, 0x0390038d},
978 {0x0000a044, 0x03920391},
979 {0x0000a048, 0x03940393},
980 {0x0000a04c, 0x03960395},
981 {0x0000a050, 0x00000000},
982 {0x0000a054, 0x00000000},
983 {0x0000a058, 0x00000000},
984 {0x0000a05c, 0x00000000},
985 {0x0000a060, 0x00000000},
986 {0x0000a064, 0x00000000},
987 {0x0000a068, 0x00000000},
988 {0x0000a06c, 0x00000000},
989 {0x0000a070, 0x00000000},
990 {0x0000a074, 0x00000000},
991 {0x0000a078, 0x00000000},
992 {0x0000a07c, 0x00000000},
993 {0x0000a080, 0x29292929},
994 {0x0000a084, 0x29292929},
995 {0x0000a088, 0x29292929},
996 {0x0000a08c, 0x29292929},
997 {0x0000a090, 0x22292929},
998 {0x0000a094, 0x1d1d2222},
999 {0x0000a098, 0x0c111117},
1000 {0x0000a09c, 0x00030303},
1001 {0x0000a0a0, 0x00000000},
1002 {0x0000a0a4, 0x00000000},
1003 {0x0000a0a8, 0x00000000},
1004 {0x0000a0ac, 0x00000000},
1005 {0x0000a0b0, 0x00000000},
1006 {0x0000a0b4, 0x00000000},
1007 {0x0000a0b8, 0x00000000},
1008 {0x0000a0bc, 0x00000000},
1009 {0x0000a0c0, 0x001f0000},
1010 {0x0000a0c4, 0x01000101},
1011 {0x0000a0c8, 0x011e011f},
1012 {0x0000a0cc, 0x011c011d},
1013 {0x0000a0d0, 0x02030204},
1014 {0x0000a0d4, 0x02010202},
1015 {0x0000a0d8, 0x021f0200},
1016 {0x0000a0dc, 0x0302021e},
1017 {0x0000a0e0, 0x03000301},
1018 {0x0000a0e4, 0x031e031f},
1019 {0x0000a0e8, 0x0402031d},
1020 {0x0000a0ec, 0x04000401},
1021 {0x0000a0f0, 0x041e041f},
1022 {0x0000a0f4, 0x0502041d},
1023 {0x0000a0f8, 0x05000501},
1024 {0x0000a0fc, 0x051e051f},
1025 {0x0000a100, 0x06010602},
1026 {0x0000a104, 0x061f0600},
1027 {0x0000a108, 0x061d061e},
1028 {0x0000a10c, 0x07020703},
1029 {0x0000a110, 0x07000701},
1030 {0x0000a114, 0x00000000},
1031 {0x0000a118, 0x00000000},
1032 {0x0000a11c, 0x00000000},
1033 {0x0000a120, 0x00000000},
1034 {0x0000a124, 0x00000000},
1035 {0x0000a128, 0x00000000},
1036 {0x0000a12c, 0x00000000},
1037 {0x0000a130, 0x00000000},
1038 {0x0000a134, 0x00000000},
1039 {0x0000a138, 0x00000000},
1040 {0x0000a13c, 0x00000000},
1041 {0x0000a140, 0x001f0000},
1042 {0x0000a144, 0x01000101},
1043 {0x0000a148, 0x011e011f},
1044 {0x0000a14c, 0x011c011d},
1045 {0x0000a150, 0x02030204},
1046 {0x0000a154, 0x02010202},
1047 {0x0000a158, 0x021f0200},
1048 {0x0000a15c, 0x0302021e},
1049 {0x0000a160, 0x03000301},
1050 {0x0000a164, 0x031e031f},
1051 {0x0000a168, 0x0402031d},
1052 {0x0000a16c, 0x04000401},
1053 {0x0000a170, 0x041e041f},
1054 {0x0000a174, 0x0502041d},
1055 {0x0000a178, 0x05000501},
1056 {0x0000a17c, 0x051e051f},
1057 {0x0000a180, 0x06010602},
1058 {0x0000a184, 0x061f0600},
1059 {0x0000a188, 0x061d061e},
1060 {0x0000a18c, 0x07020703},
1061 {0x0000a190, 0x07000701},
1062 {0x0000a194, 0x00000000},
1063 {0x0000a198, 0x00000000},
1064 {0x0000a19c, 0x00000000},
1065 {0x0000a1a0, 0x00000000},
1066 {0x0000a1a4, 0x00000000},
1067 {0x0000a1a8, 0x00000000},
1068 {0x0000a1ac, 0x00000000},
1069 {0x0000a1b0, 0x00000000},
1070 {0x0000a1b4, 0x00000000},
1071 {0x0000a1b8, 0x00000000},
1072 {0x0000a1bc, 0x00000000},
1073 {0x0000a1c0, 0x00000000},
1074 {0x0000a1c4, 0x00000000},
1075 {0x0000a1c8, 0x00000000},
1076 {0x0000a1cc, 0x00000000},
1077 {0x0000a1d0, 0x00000000},
1078 {0x0000a1d4, 0x00000000},
1079 {0x0000a1d8, 0x00000000},
1080 {0x0000a1dc, 0x00000000},
1081 {0x0000a1e0, 0x00000000},
1082 {0x0000a1e4, 0x00000000},
1083 {0x0000a1e8, 0x00000000},
1084 {0x0000a1ec, 0x00000000},
1085 {0x0000a1f0, 0x00000396},
1086 {0x0000a1f4, 0x00000396},
1087 {0x0000a1f8, 0x00000396},
1088 {0x0000a1fc, 0x00000196},
1089 {0x0000b000, 0x00010000},
1090 {0x0000b004, 0x00030002},
1091 {0x0000b008, 0x00050004},
1092 {0x0000b00c, 0x00810080},
1093 {0x0000b010, 0x00830082},
1094 {0x0000b014, 0x01810180},
1095 {0x0000b018, 0x01830182},
1096 {0x0000b01c, 0x01850184},
1097 {0x0000b020, 0x02810280},
1098 {0x0000b024, 0x02830282},
1099 {0x0000b028, 0x02850284},
1100 {0x0000b02c, 0x02890288},
1101 {0x0000b030, 0x028b028a},
1102 {0x0000b034, 0x0388028c},
1103 {0x0000b038, 0x038a0389},
1104 {0x0000b03c, 0x038c038b},
1105 {0x0000b040, 0x0390038d},
1106 {0x0000b044, 0x03920391},
1107 {0x0000b048, 0x03940393},
1108 {0x0000b04c, 0x03960395},
1109 {0x0000b050, 0x00000000},
1110 {0x0000b054, 0x00000000},
1111 {0x0000b058, 0x00000000},
1112 {0x0000b05c, 0x00000000},
1113 {0x0000b060, 0x00000000},
1114 {0x0000b064, 0x00000000},
1115 {0x0000b068, 0x00000000},
1116 {0x0000b06c, 0x00000000},
1117 {0x0000b070, 0x00000000},
1118 {0x0000b074, 0x00000000},
1119 {0x0000b078, 0x00000000},
1120 {0x0000b07c, 0x00000000},
1121 {0x0000b080, 0x32323232},
1122 {0x0000b084, 0x2f2f3232},
1123 {0x0000b088, 0x23282a2d},
1124 {0x0000b08c, 0x1c1e2123},
1125 {0x0000b090, 0x14171919},
1126 {0x0000b094, 0x0e0e1214},
1127 {0x0000b098, 0x03050707},
1128 {0x0000b09c, 0x00030303},
1129 {0x0000b0a0, 0x00000000},
1130 {0x0000b0a4, 0x00000000},
1131 {0x0000b0a8, 0x00000000},
1132 {0x0000b0ac, 0x00000000},
1133 {0x0000b0b0, 0x00000000},
1134 {0x0000b0b4, 0x00000000},
1135 {0x0000b0b8, 0x00000000},
1136 {0x0000b0bc, 0x00000000},
1137 {0x0000b0c0, 0x003f0020},
1138 {0x0000b0c4, 0x00400041},
1139 {0x0000b0c8, 0x0140005f},
1140 {0x0000b0cc, 0x0160015f},
1141 {0x0000b0d0, 0x017e017f},
1142 {0x0000b0d4, 0x02410242},
1143 {0x0000b0d8, 0x025f0240},
1144 {0x0000b0dc, 0x027f0260},
1145 {0x0000b0e0, 0x0341027e},
1146 {0x0000b0e4, 0x035f0340},
1147 {0x0000b0e8, 0x037f0360},
1148 {0x0000b0ec, 0x04400441},
1149 {0x0000b0f0, 0x0460045f},
1150 {0x0000b0f4, 0x0541047f},
1151 {0x0000b0f8, 0x055f0540},
1152 {0x0000b0fc, 0x057f0560},
1153 {0x0000b100, 0x06400641},
1154 {0x0000b104, 0x0660065f},
1155 {0x0000b108, 0x067e067f},
1156 {0x0000b10c, 0x07410742},
1157 {0x0000b110, 0x075f0740},
1158 {0x0000b114, 0x077f0760},
1159 {0x0000b118, 0x07800781},
1160 {0x0000b11c, 0x07a0079f},
1161 {0x0000b120, 0x07c107bf},
1162 {0x0000b124, 0x000007c0},
1163 {0x0000b128, 0x00000000},
1164 {0x0000b12c, 0x00000000},
1165 {0x0000b130, 0x00000000},
1166 {0x0000b134, 0x00000000},
1167 {0x0000b138, 0x00000000},
1168 {0x0000b13c, 0x00000000},
1169 {0x0000b140, 0x003f0020},
1170 {0x0000b144, 0x00400041},
1171 {0x0000b148, 0x0140005f},
1172 {0x0000b14c, 0x0160015f},
1173 {0x0000b150, 0x017e017f},
1174 {0x0000b154, 0x02410242},
1175 {0x0000b158, 0x025f0240},
1176 {0x0000b15c, 0x027f0260},
1177 {0x0000b160, 0x0341027e},
1178 {0x0000b164, 0x035f0340},
1179 {0x0000b168, 0x037f0360},
1180 {0x0000b16c, 0x04400441},
1181 {0x0000b170, 0x0460045f},
1182 {0x0000b174, 0x0541047f},
1183 {0x0000b178, 0x055f0540},
1184 {0x0000b17c, 0x057f0560},
1185 {0x0000b180, 0x06400641},
1186 {0x0000b184, 0x0660065f},
1187 {0x0000b188, 0x067e067f},
1188 {0x0000b18c, 0x07410742},
1189 {0x0000b190, 0x075f0740},
1190 {0x0000b194, 0x077f0760},
1191 {0x0000b198, 0x07800781},
1192 {0x0000b19c, 0x07a0079f},
1193 {0x0000b1a0, 0x07c107bf},
1194 {0x0000b1a4, 0x000007c0},
1195 {0x0000b1a8, 0x00000000},
1196 {0x0000b1ac, 0x00000000},
1197 {0x0000b1b0, 0x00000000},
1198 {0x0000b1b4, 0x00000000},
1199 {0x0000b1b8, 0x00000000},
1200 {0x0000b1bc, 0x00000000},
1201 {0x0000b1c0, 0x00000000},
1202 {0x0000b1c4, 0x00000000},
1203 {0x0000b1c8, 0x00000000},
1204 {0x0000b1cc, 0x00000000},
1205 {0x0000b1d0, 0x00000000},
1206 {0x0000b1d4, 0x00000000},
1207 {0x0000b1d8, 0x00000000},
1208 {0x0000b1dc, 0x00000000},
1209 {0x0000b1e0, 0x00000000},
1210 {0x0000b1e4, 0x00000000},
1211 {0x0000b1e8, 0x00000000},
1212 {0x0000b1ec, 0x00000000},
1213 {0x0000b1f0, 0x00000396},
1214 {0x0000b1f4, 0x00000396},
1215 {0x0000b1f8, 0x00000396},
1216 {0x0000b1fc, 0x00000196},
1217};
1218
1219static const u32 qca953x_2p0_common_wo_xlna_rx_gain_bounds[][5] = {
1220 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
1221 {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27},
1222 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
1223};
1224
1225static const u32 qca953x_2p0_modes_xpa_tx_gain_table[][2] = {
1226 /* Addr allmodes */
1227 {0x0000a2dc, 0xfffb52aa},
1228 {0x0000a2e0, 0xfffd64cc},
1229 {0x0000a2e4, 0xfffe80f0},
1230 {0x0000a2e8, 0xffffff00},
1231 {0x0000a410, 0x000050d5},
1232 {0x0000a500, 0x00000000},
1233 {0x0000a504, 0x04000002},
1234 {0x0000a508, 0x08000004},
1235 {0x0000a50c, 0x0c000006},
1236 {0x0000a510, 0x1000000a},
1237 {0x0000a514, 0x1400000c},
1238 {0x0000a518, 0x1800000e},
1239 {0x0000a51c, 0x1c000048},
1240 {0x0000a520, 0x2000004a},
1241 {0x0000a524, 0x2400004c},
1242 {0x0000a528, 0x2800004e},
1243 {0x0000a52c, 0x2b00024a},
1244 {0x0000a530, 0x2f00024c},
1245 {0x0000a534, 0x3300024e},
1246 {0x0000a538, 0x36000668},
1247 {0x0000a53c, 0x38000669},
1248 {0x0000a540, 0x3a000868},
1249 {0x0000a544, 0x3d00086a},
1250 {0x0000a548, 0x4000086c},
1251 {0x0000a54c, 0x4200086e},
1252 {0x0000a550, 0x43000a6e},
1253 {0x0000a554, 0x43000a6e},
1254 {0x0000a558, 0x43000a6e},
1255 {0x0000a55c, 0x43000a6e},
1256 {0x0000a560, 0x43000a6e},
1257 {0x0000a564, 0x43000a6e},
1258 {0x0000a568, 0x43000a6e},
1259 {0x0000a56c, 0x43000a6e},
1260 {0x0000a570, 0x43000a6e},
1261 {0x0000a574, 0x43000a6e},
1262 {0x0000a578, 0x43000a6e},
1263 {0x0000a57c, 0x43000a6e},
1264 {0x0000a600, 0x00000000},
1265 {0x0000a604, 0x00000000},
1266 {0x0000a608, 0x00000000},
1267 {0x0000a60c, 0x03804000},
1268 {0x0000a610, 0x03804e01},
1269 {0x0000a614, 0x03804e01},
1270 {0x0000a618, 0x03804e01},
1271 {0x0000a61c, 0x04009002},
1272 {0x0000a620, 0x04009002},
1273 {0x0000a624, 0x04009002},
1274 {0x0000a628, 0x04009002},
1275 {0x0000a62c, 0x04009002},
1276 {0x0000a630, 0x04009002},
1277 {0x0000a634, 0x04009002},
1278 {0x0000a638, 0x04009002},
1279 {0x0000a63c, 0x04009002},
1280 {0x0000b2dc, 0xfffb52aa},
1281 {0x0000b2e0, 0xfffd64cc},
1282 {0x0000b2e4, 0xfffe80f0},
1283 {0x0000b2e8, 0xffffff00},
1284 {0x00016044, 0x024922db},
1285 {0x00016048, 0x6c927a70},
1286 {0x00016444, 0x024922db},
1287 {0x00016448, 0x6c927a70},
1288};
1289
1290static const u32 qca953x_2p0_modes_no_xpa_tx_gain_table[][2] = {
1291 /* Addr allmodes */
1292 {0x0000a2dc, 0xffd5f552},
1293 {0x0000a2e0, 0xffe60664},
1294 {0x0000a2e4, 0xfff80780},
1295 {0x0000a2e8, 0xfffff800},
1296 {0x0000a410, 0x000050de},
1297 {0x0000a500, 0x00000061},
1298 {0x0000a504, 0x04000063},
1299 {0x0000a508, 0x08000065},
1300 {0x0000a50c, 0x0c000261},
1301 {0x0000a510, 0x10000263},
1302 {0x0000a514, 0x14000265},
1303 {0x0000a518, 0x18000482},
1304 {0x0000a51c, 0x1b000484},
1305 {0x0000a520, 0x1f000486},
1306 {0x0000a524, 0x240008c2},
1307 {0x0000a528, 0x28000cc1},
1308 {0x0000a52c, 0x2d000ce3},
1309 {0x0000a530, 0x31000ce5},
1310 {0x0000a534, 0x350010e5},
1311 {0x0000a538, 0x360012e5},
1312 {0x0000a53c, 0x380014e5},
1313 {0x0000a540, 0x3b0018e5},
1314 {0x0000a544, 0x3d001d04},
1315 {0x0000a548, 0x3e001d05},
1316 {0x0000a54c, 0x40001d07},
1317 {0x0000a550, 0x42001f27},
1318 {0x0000a554, 0x43001f67},
1319 {0x0000a558, 0x46001fe7},
1320 {0x0000a55c, 0x47001f2b},
1321 {0x0000a560, 0x49001f0d},
1322 {0x0000a564, 0x4b001ed2},
1323 {0x0000a568, 0x4c001ed4},
1324 {0x0000a56c, 0x4e001f15},
1325 {0x0000a570, 0x4f001ff6},
1326 {0x0000a574, 0x4f001ff6},
1327 {0x0000a578, 0x4f001ff6},
1328 {0x0000a57c, 0x4f001ff6},
1329 {0x0000a600, 0x00000000},
1330 {0x0000a604, 0x00000000},
1331 {0x0000a608, 0x00000000},
1332 {0x0000a60c, 0x00804201},
1333 {0x0000a610, 0x01008201},
1334 {0x0000a614, 0x0180c402},
1335 {0x0000a618, 0x0180c603},
1336 {0x0000a61c, 0x0180c603},
1337 {0x0000a620, 0x01c10603},
1338 {0x0000a624, 0x01c10704},
1339 {0x0000a628, 0x02c18b05},
1340 {0x0000a62c, 0x02c14c07},
1341 {0x0000a630, 0x01008704},
1342 {0x0000a634, 0x01c10402},
1343 {0x0000a638, 0x0301cc07},
1344 {0x0000a63c, 0x0301cc07},
1345 {0x0000b2dc, 0xffd5f552},
1346 {0x0000b2e0, 0xffe60664},
1347 {0x0000b2e4, 0xfff80780},
1348 {0x0000b2e8, 0xfffff800},
1349 {0x00016044, 0x049242db},
1350 {0x00016048, 0x6c927a70},
1351 {0x00016444, 0x049242db},
1352 {0x00016448, 0x6c927a70},
1353};
1354
917#endif /* INITVALS_953X_H */ 1355#endif /* INITVALS_953X_H */
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 85d74ff0767c..abe8bd6b972d 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -28,7 +28,6 @@
28#include "debug.h" 28#include "debug.h"
29#include "mci.h" 29#include "mci.h"
30#include "dfs.h" 30#include "dfs.h"
31#include "spectral.h"
32 31
33struct ath_node; 32struct ath_node;
34struct ath_vif; 33struct ath_vif;
@@ -347,6 +346,7 @@ struct ath_chanctx {
347 346
348 int flush_timeout; 347 int flush_timeout;
349 u16 txpower; 348 u16 txpower;
349 u16 cur_txpower;
350 bool offchannel; 350 bool offchannel;
351 bool stopped; 351 bool stopped;
352 bool active; 352 bool active;
@@ -381,6 +381,7 @@ enum ath_chanctx_state {
381 381
382struct ath_chanctx_sched { 382struct ath_chanctx_sched {
383 bool beacon_pending; 383 bool beacon_pending;
384 bool beacon_adjust;
384 bool offchannel_pending; 385 bool offchannel_pending;
385 bool wait_switch; 386 bool wait_switch;
386 bool force_noa_update; 387 bool force_noa_update;
@@ -931,6 +932,7 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
931#define ATH9K_PCI_AR9565_2ANT 0x0100 932#define ATH9K_PCI_AR9565_2ANT 0x0100
932#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200 933#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200
933#define ATH9K_PCI_KILLER 0x0400 934#define ATH9K_PCI_KILLER 0x0400
935#define ATH9K_PCI_LED_ACT_HI 0x0800
934 936
935/* 937/*
936 * Default cache line size, in bytes. 938 * Default cache line size, in bytes.
@@ -987,7 +989,6 @@ struct ath_softc {
987 u8 gtt_cnt; 989 u8 gtt_cnt;
988 u32 intrstatus; 990 u32 intrstatus;
989 u16 ps_flags; /* PS_* */ 991 u16 ps_flags; /* PS_* */
990 u16 curtxpow;
991 bool ps_enabled; 992 bool ps_enabled;
992 bool ps_idle; 993 bool ps_idle;
993 short nbcnvifs; 994 short nbcnvifs;
@@ -1028,10 +1029,8 @@ struct ath_softc {
1028 struct dfs_pattern_detector *dfs_detector; 1029 struct dfs_pattern_detector *dfs_detector;
1029 u64 dfs_prev_pulse_ts; 1030 u64 dfs_prev_pulse_ts;
1030 u32 wow_enabled; 1031 u32 wow_enabled;
1031 /* relay(fs) channel for spectral scan */ 1032
1032 struct rchan *rfs_chan_spec_scan; 1033 struct ath_spec_scan_priv spec_priv;
1033 enum spectral_mode spectral_mode;
1034 struct ath_spec_scan spec_config;
1035 1034
1036 struct ieee80211_vif *tx99_vif; 1035 struct ieee80211_vif *tx99_vif;
1037 struct sk_buff *tx99_skb; 1036 struct sk_buff *tx99_skb;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index c7234d5dda34..206665059d66 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -92,8 +92,8 @@ static int ath_set_channel(struct ath_softc *sc)
92 } else { 92 } else {
93 /* perform spectral scan if requested. */ 93 /* perform spectral scan if requested. */
94 if (test_bit(ATH_OP_SCANNING, &common->op_flags) && 94 if (test_bit(ATH_OP_SCANNING, &common->op_flags) &&
95 sc->spectral_mode == SPECTRAL_CHANSCAN) 95 sc->spec_priv.spectral_mode == SPECTRAL_CHANSCAN)
96 ath9k_spectral_scan_trigger(hw); 96 ath9k_cmn_spectral_scan_trigger(common, &sc->spec_priv);
97 } 97 }
98 98
99 return 0; 99 return 0;
@@ -659,6 +659,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
659 sc->sched.beacon_miss = 0; 659 sc->sched.beacon_miss = 0;
660 660
661 if (sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE || 661 if (sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE ||
662 !sc->sched.beacon_adjust ||
662 !sc->cur_chan->tsf_val) 663 !sc->cur_chan->tsf_val)
663 break; 664 break;
664 665
@@ -672,7 +673,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
672 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL); 673 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
673 tsf_time += ath9k_hw_gettsf32(ah); 674 tsf_time += ath9k_hw_gettsf32(ah);
674 675
675 676 sc->sched.beacon_adjust = false;
676 ath_chanctx_setup_timer(sc, tsf_time); 677 ath_chanctx_setup_timer(sc, tsf_time);
677 break; 678 break;
678 case ATH_CHANCTX_EVENT_AUTHORIZED: 679 case ATH_CHANCTX_EVENT_AUTHORIZED:
@@ -717,6 +718,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
717 718
718 ath_chanctx_setup_timer(sc, tsf_time); 719 ath_chanctx_setup_timer(sc, tsf_time);
719 sc->sched.beacon_pending = true; 720 sc->sched.beacon_pending = true;
721 sc->sched.beacon_adjust = true;
720 break; 722 break;
721 case ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL: 723 case ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL:
722 if (sc->cur_chan == &sc->offchannel.chan || 724 if (sc->cur_chan == &sc->offchannel.chan ||
@@ -900,6 +902,11 @@ void ath_offchannel_next(struct ath_softc *sc)
900 sc->offchannel.state = ATH_OFFCHANNEL_ROC_START; 902 sc->offchannel.state = ATH_OFFCHANNEL_ROC_START;
901 ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan); 903 ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan);
902 } else { 904 } else {
905 spin_lock_bh(&sc->chan_lock);
906 sc->sched.offchannel_pending = false;
907 sc->sched.wait_switch = false;
908 spin_unlock_bh(&sc->chan_lock);
909
903 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false), 910 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
904 NULL); 911 NULL);
905 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; 912 sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
@@ -919,8 +926,7 @@ void ath_roc_complete(struct ath_softc *sc, bool abort)
919 926
920 sc->offchannel.roc_vif = NULL; 927 sc->offchannel.roc_vif = NULL;
921 sc->offchannel.roc_chan = NULL; 928 sc->offchannel.roc_chan = NULL;
922 if (abort) 929 ieee80211_remain_on_channel_expired(sc->hw);
923 ieee80211_remain_on_channel_expired(sc->hw);
924 ath_offchannel_next(sc); 930 ath_offchannel_next(sc);
925 ath9k_ps_restore(sc); 931 ath9k_ps_restore(sc);
926} 932}
@@ -957,7 +963,7 @@ static void ath_scan_send_probe(struct ath_softc *sc,
957 struct ieee80211_tx_info *info; 963 struct ieee80211_tx_info *info;
958 int band = sc->offchannel.chan.chandef.chan->band; 964 int band = sc->offchannel.chan.chandef.chan->band;
959 965
960 skb = ieee80211_probereq_get(sc->hw, vif, 966 skb = ieee80211_probereq_get(sc->hw, vif->addr,
961 ssid->ssid, ssid->ssid_len, req->ie_len); 967 ssid->ssid, ssid->ssid_len, req->ie_len);
962 if (!skb) 968 if (!skb)
963 return; 969 return;
@@ -1051,10 +1057,8 @@ static void ath_offchannel_timer(unsigned long data)
1051 break; 1057 break;
1052 case ATH_OFFCHANNEL_ROC_START: 1058 case ATH_OFFCHANNEL_ROC_START:
1053 case ATH_OFFCHANNEL_ROC_WAIT: 1059 case ATH_OFFCHANNEL_ROC_WAIT:
1054 ctx = ath_chanctx_get_oper_chan(sc, false);
1055 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE; 1060 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
1056 ieee80211_remain_on_channel_expired(sc->hw); 1061 ath_roc_complete(sc, false);
1057 ath_chanctx_switch(sc, ctx, NULL);
1058 break; 1062 break;
1059 default: 1063 default:
1060 break; 1064 break;
@@ -1184,7 +1188,6 @@ static void ath_offchannel_channel_change(struct ath_softc *sc)
1184 ieee80211_ready_on_channel(sc->hw); 1188 ieee80211_ready_on_channel(sc->hw);
1185 break; 1189 break;
1186 case ATH_OFFCHANNEL_ROC_DONE: 1190 case ATH_OFFCHANNEL_ROC_DONE:
1187 ath_roc_complete(sc, false);
1188 break; 1191 break;
1189 default: 1192 default:
1190 break; 1193 break;
diff --git a/drivers/net/wireless/ath/ath9k/spectral.c b/drivers/net/wireless/ath/ath9k/common-spectral.c
index 8f68426ca653..ec93ddf0863a 100644
--- a/drivers/net/wireless/ath/ath9k/spectral.c
+++ b/drivers/net/wireless/ath/ath9k/common-spectral.c
@@ -24,23 +24,24 @@ static s8 fix_rssi_inv_only(u8 rssi_val)
24 return (s8) rssi_val; 24 return (s8) rssi_val;
25} 25}
26 26
27static void ath_debug_send_fft_sample(struct ath_softc *sc, 27static void ath_debug_send_fft_sample(struct ath_spec_scan_priv *spec_priv,
28 struct fft_sample_tlv *fft_sample_tlv) 28 struct fft_sample_tlv *fft_sample_tlv)
29{ 29{
30 int length; 30 int length;
31 if (!sc->rfs_chan_spec_scan) 31 if (!spec_priv->rfs_chan_spec_scan)
32 return; 32 return;
33 33
34 length = __be16_to_cpu(fft_sample_tlv->length) + 34 length = __be16_to_cpu(fft_sample_tlv->length) +
35 sizeof(*fft_sample_tlv); 35 sizeof(*fft_sample_tlv);
36 relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length); 36 relay_write(spec_priv->rfs_chan_spec_scan, fft_sample_tlv, length);
37} 37}
38 38
39/* returns 1 if this was a spectral frame, even if not handled. */ 39/* returns 1 if this was a spectral frame, even if not handled. */
40int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr, 40int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
41 struct ath_rx_status *rs, u64 tsf) 41 struct ath_rx_status *rs, u64 tsf)
42{ 42{
43 struct ath_hw *ah = sc->sc_ah; 43 struct ath_hw *ah = spec_priv->ah;
44 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
44 u8 num_bins, *bins, *vdata = (u8 *)hdr; 45 u8 num_bins, *bins, *vdata = (u8 *)hdr;
45 struct fft_sample_ht20 fft_sample_20; 46 struct fft_sample_ht20 fft_sample_20;
46 struct fft_sample_ht20_40 fft_sample_40; 47 struct fft_sample_ht20_40 fft_sample_40;
@@ -67,7 +68,7 @@ int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
67 if (!(radar_info->pulse_bw_info & SPECTRAL_SCAN_BITMASK)) 68 if (!(radar_info->pulse_bw_info & SPECTRAL_SCAN_BITMASK))
68 return 0; 69 return 0;
69 70
70 chan_type = cfg80211_get_chandef_type(&sc->hw->conf.chandef); 71 chan_type = cfg80211_get_chandef_type(&common->hw->conf.chandef);
71 if ((chan_type == NL80211_CHAN_HT40MINUS) || 72 if ((chan_type == NL80211_CHAN_HT40MINUS) ||
72 (chan_type == NL80211_CHAN_HT40PLUS)) { 73 (chan_type == NL80211_CHAN_HT40PLUS)) {
73 fft_len = SPECTRAL_HT20_40_TOTAL_DATA_LEN; 74 fft_len = SPECTRAL_HT20_40_TOTAL_DATA_LEN;
@@ -199,10 +200,11 @@ int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
199 tlv = (struct fft_sample_tlv *)&fft_sample_20; 200 tlv = (struct fft_sample_tlv *)&fft_sample_20;
200 } 201 }
201 202
202 ath_debug_send_fft_sample(sc, tlv); 203 ath_debug_send_fft_sample(spec_priv, tlv);
203 204
204 return 1; 205 return 1;
205} 206}
207EXPORT_SYMBOL(ath_cmn_process_fft);
206 208
207/*********************/ 209/*********************/
208/* spectral_scan_ctl */ 210/* spectral_scan_ctl */
@@ -211,11 +213,11 @@ int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
211static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf, 213static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
212 size_t count, loff_t *ppos) 214 size_t count, loff_t *ppos)
213{ 215{
214 struct ath_softc *sc = file->private_data; 216 struct ath_spec_scan_priv *spec_priv = file->private_data;
215 char *mode = ""; 217 char *mode = "";
216 unsigned int len; 218 unsigned int len;
217 219
218 switch (sc->spectral_mode) { 220 switch (spec_priv->spectral_mode) {
219 case SPECTRAL_DISABLED: 221 case SPECTRAL_DISABLED:
220 mode = "disable"; 222 mode = "disable";
221 break; 223 break;
@@ -233,12 +235,84 @@ static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
233 return simple_read_from_buffer(user_buf, count, ppos, mode, len); 235 return simple_read_from_buffer(user_buf, count, ppos, mode, len);
234} 236}
235 237
238void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
239 struct ath_spec_scan_priv *spec_priv)
240{
241 struct ath_hw *ah = spec_priv->ah;
242 u32 rxfilter;
243
244 if (config_enabled(CONFIG_ATH9K_TX99))
245 return;
246
247 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
248 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
249 return;
250 }
251
252 ath_ps_ops(common)->wakeup(common);
253 rxfilter = ath9k_hw_getrxfilter(ah);
254 ath9k_hw_setrxfilter(ah, rxfilter |
255 ATH9K_RX_FILTER_PHYRADAR |
256 ATH9K_RX_FILTER_PHYERR);
257
258 /* TODO: usually this should not be neccesary, but for some reason
259 * (or in some mode?) the trigger must be called after the
260 * configuration, otherwise the register will have its values reset
261 * (on my ar9220 to value 0x01002310)
262 */
263 ath9k_cmn_spectral_scan_config(common, spec_priv, spec_priv->spectral_mode);
264 ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
265 ath_ps_ops(common)->restore(common);
266}
267EXPORT_SYMBOL(ath9k_cmn_spectral_scan_trigger);
268
269int ath9k_cmn_spectral_scan_config(struct ath_common *common,
270 struct ath_spec_scan_priv *spec_priv,
271 enum spectral_mode spectral_mode)
272{
273 struct ath_hw *ah = spec_priv->ah;
274
275 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
276 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
277 return -1;
278 }
279
280 switch (spectral_mode) {
281 case SPECTRAL_DISABLED:
282 spec_priv->spec_config.enabled = 0;
283 break;
284 case SPECTRAL_BACKGROUND:
285 /* send endless samples.
286 * TODO: is this really useful for "background"?
287 */
288 spec_priv->spec_config.endless = 1;
289 spec_priv->spec_config.enabled = 1;
290 break;
291 case SPECTRAL_CHANSCAN:
292 case SPECTRAL_MANUAL:
293 spec_priv->spec_config.endless = 0;
294 spec_priv->spec_config.enabled = 1;
295 break;
296 default:
297 return -1;
298 }
299
300 ath_ps_ops(common)->wakeup(common);
301 ath9k_hw_ops(ah)->spectral_scan_config(ah, &spec_priv->spec_config);
302 ath_ps_ops(common)->restore(common);
303
304 spec_priv->spectral_mode = spectral_mode;
305
306 return 0;
307}
308EXPORT_SYMBOL(ath9k_cmn_spectral_scan_config);
309
236static ssize_t write_file_spec_scan_ctl(struct file *file, 310static ssize_t write_file_spec_scan_ctl(struct file *file,
237 const char __user *user_buf, 311 const char __user *user_buf,
238 size_t count, loff_t *ppos) 312 size_t count, loff_t *ppos)
239{ 313{
240 struct ath_softc *sc = file->private_data; 314 struct ath_spec_scan_priv *spec_priv = file->private_data;
241 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 315 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
242 char buf[32]; 316 char buf[32];
243 ssize_t len; 317 ssize_t len;
244 318
@@ -252,18 +326,18 @@ static ssize_t write_file_spec_scan_ctl(struct file *file,
252 buf[len] = '\0'; 326 buf[len] = '\0';
253 327
254 if (strncmp("trigger", buf, 7) == 0) { 328 if (strncmp("trigger", buf, 7) == 0) {
255 ath9k_spectral_scan_trigger(sc->hw); 329 ath9k_cmn_spectral_scan_trigger(common, spec_priv);
256 } else if (strncmp("background", buf, 10) == 0) { 330 } else if (strncmp("background", buf, 10) == 0) {
257 ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND); 331 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_BACKGROUND);
258 ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n"); 332 ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n");
259 } else if (strncmp("chanscan", buf, 8) == 0) { 333 } else if (strncmp("chanscan", buf, 8) == 0) {
260 ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN); 334 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_CHANSCAN);
261 ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n"); 335 ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n");
262 } else if (strncmp("manual", buf, 6) == 0) { 336 } else if (strncmp("manual", buf, 6) == 0) {
263 ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL); 337 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_MANUAL);
264 ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n"); 338 ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n");
265 } else if (strncmp("disable", buf, 7) == 0) { 339 } else if (strncmp("disable", buf, 7) == 0) {
266 ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED); 340 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_DISABLED);
267 ath_dbg(common, CONFIG, "spectral scan: disabled\n"); 341 ath_dbg(common, CONFIG, "spectral scan: disabled\n");
268 } else { 342 } else {
269 return -EINVAL; 343 return -EINVAL;
@@ -288,11 +362,11 @@ static ssize_t read_file_spectral_short_repeat(struct file *file,
288 char __user *user_buf, 362 char __user *user_buf,
289 size_t count, loff_t *ppos) 363 size_t count, loff_t *ppos)
290{ 364{
291 struct ath_softc *sc = file->private_data; 365 struct ath_spec_scan_priv *spec_priv = file->private_data;
292 char buf[32]; 366 char buf[32];
293 unsigned int len; 367 unsigned int len;
294 368
295 len = sprintf(buf, "%d\n", sc->spec_config.short_repeat); 369 len = sprintf(buf, "%d\n", spec_priv->spec_config.short_repeat);
296 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 370 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
297} 371}
298 372
@@ -300,7 +374,7 @@ static ssize_t write_file_spectral_short_repeat(struct file *file,
300 const char __user *user_buf, 374 const char __user *user_buf,
301 size_t count, loff_t *ppos) 375 size_t count, loff_t *ppos)
302{ 376{
303 struct ath_softc *sc = file->private_data; 377 struct ath_spec_scan_priv *spec_priv = file->private_data;
304 unsigned long val; 378 unsigned long val;
305 char buf[32]; 379 char buf[32];
306 ssize_t len; 380 ssize_t len;
@@ -316,7 +390,7 @@ static ssize_t write_file_spectral_short_repeat(struct file *file,
316 if (val > 1) 390 if (val > 1)
317 return -EINVAL; 391 return -EINVAL;
318 392
319 sc->spec_config.short_repeat = val; 393 spec_priv->spec_config.short_repeat = val;
320 return count; 394 return count;
321} 395}
322 396
@@ -336,11 +410,11 @@ static ssize_t read_file_spectral_count(struct file *file,
336 char __user *user_buf, 410 char __user *user_buf,
337 size_t count, loff_t *ppos) 411 size_t count, loff_t *ppos)
338{ 412{
339 struct ath_softc *sc = file->private_data; 413 struct ath_spec_scan_priv *spec_priv = file->private_data;
340 char buf[32]; 414 char buf[32];
341 unsigned int len; 415 unsigned int len;
342 416
343 len = sprintf(buf, "%d\n", sc->spec_config.count); 417 len = sprintf(buf, "%d\n", spec_priv->spec_config.count);
344 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 418 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
345} 419}
346 420
@@ -348,7 +422,7 @@ static ssize_t write_file_spectral_count(struct file *file,
348 const char __user *user_buf, 422 const char __user *user_buf,
349 size_t count, loff_t *ppos) 423 size_t count, loff_t *ppos)
350{ 424{
351 struct ath_softc *sc = file->private_data; 425 struct ath_spec_scan_priv *spec_priv = file->private_data;
352 unsigned long val; 426 unsigned long val;
353 char buf[32]; 427 char buf[32];
354 ssize_t len; 428 ssize_t len;
@@ -364,7 +438,7 @@ static ssize_t write_file_spectral_count(struct file *file,
364 if (val > 255) 438 if (val > 255)
365 return -EINVAL; 439 return -EINVAL;
366 440
367 sc->spec_config.count = val; 441 spec_priv->spec_config.count = val;
368 return count; 442 return count;
369} 443}
370 444
@@ -384,11 +458,11 @@ static ssize_t read_file_spectral_period(struct file *file,
384 char __user *user_buf, 458 char __user *user_buf,
385 size_t count, loff_t *ppos) 459 size_t count, loff_t *ppos)
386{ 460{
387 struct ath_softc *sc = file->private_data; 461 struct ath_spec_scan_priv *spec_priv = file->private_data;
388 char buf[32]; 462 char buf[32];
389 unsigned int len; 463 unsigned int len;
390 464
391 len = sprintf(buf, "%d\n", sc->spec_config.period); 465 len = sprintf(buf, "%d\n", spec_priv->spec_config.period);
392 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 466 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
393} 467}
394 468
@@ -396,7 +470,7 @@ static ssize_t write_file_spectral_period(struct file *file,
396 const char __user *user_buf, 470 const char __user *user_buf,
397 size_t count, loff_t *ppos) 471 size_t count, loff_t *ppos)
398{ 472{
399 struct ath_softc *sc = file->private_data; 473 struct ath_spec_scan_priv *spec_priv = file->private_data;
400 unsigned long val; 474 unsigned long val;
401 char buf[32]; 475 char buf[32];
402 ssize_t len; 476 ssize_t len;
@@ -412,7 +486,7 @@ static ssize_t write_file_spectral_period(struct file *file,
412 if (val > 255) 486 if (val > 255)
413 return -EINVAL; 487 return -EINVAL;
414 488
415 sc->spec_config.period = val; 489 spec_priv->spec_config.period = val;
416 return count; 490 return count;
417} 491}
418 492
@@ -432,11 +506,11 @@ static ssize_t read_file_spectral_fft_period(struct file *file,
432 char __user *user_buf, 506 char __user *user_buf,
433 size_t count, loff_t *ppos) 507 size_t count, loff_t *ppos)
434{ 508{
435 struct ath_softc *sc = file->private_data; 509 struct ath_spec_scan_priv *spec_priv = file->private_data;
436 char buf[32]; 510 char buf[32];
437 unsigned int len; 511 unsigned int len;
438 512
439 len = sprintf(buf, "%d\n", sc->spec_config.fft_period); 513 len = sprintf(buf, "%d\n", spec_priv->spec_config.fft_period);
440 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 514 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
441} 515}
442 516
@@ -444,7 +518,7 @@ static ssize_t write_file_spectral_fft_period(struct file *file,
444 const char __user *user_buf, 518 const char __user *user_buf,
445 size_t count, loff_t *ppos) 519 size_t count, loff_t *ppos)
446{ 520{
447 struct ath_softc *sc = file->private_data; 521 struct ath_spec_scan_priv *spec_priv = file->private_data;
448 unsigned long val; 522 unsigned long val;
449 char buf[32]; 523 char buf[32];
450 ssize_t len; 524 ssize_t len;
@@ -460,7 +534,7 @@ static ssize_t write_file_spectral_fft_period(struct file *file,
460 if (val > 15) 534 if (val > 15)
461 return -EINVAL; 535 return -EINVAL;
462 536
463 sc->spec_config.fft_period = val; 537 spec_priv->spec_config.fft_period = val;
464 return count; 538 return count;
465} 539}
466 540
@@ -506,38 +580,41 @@ static struct rchan_callbacks rfs_spec_scan_cb = {
506/* Debug Init/Deinit */ 580/* Debug Init/Deinit */
507/*********************/ 581/*********************/
508 582
509void ath9k_spectral_deinit_debug(struct ath_softc *sc) 583void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
510{ 584{
511 if (config_enabled(CONFIG_ATH9K_DEBUGFS) && sc->rfs_chan_spec_scan) { 585 if (config_enabled(CONFIG_ATH9K_DEBUGFS) && spec_priv->rfs_chan_spec_scan) {
512 relay_close(sc->rfs_chan_spec_scan); 586 relay_close(spec_priv->rfs_chan_spec_scan);
513 sc->rfs_chan_spec_scan = NULL; 587 spec_priv->rfs_chan_spec_scan = NULL;
514 } 588 }
515} 589}
590EXPORT_SYMBOL(ath9k_cmn_spectral_deinit_debug);
516 591
517void ath9k_spectral_init_debug(struct ath_softc *sc) 592void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv,
593 struct dentry *debugfs_phy)
518{ 594{
519 sc->rfs_chan_spec_scan = relay_open("spectral_scan", 595 spec_priv->rfs_chan_spec_scan = relay_open("spectral_scan",
520 sc->debug.debugfs_phy, 596 debugfs_phy,
521 1024, 256, &rfs_spec_scan_cb, 597 1024, 256, &rfs_spec_scan_cb,
522 NULL); 598 NULL);
523 debugfs_create_file("spectral_scan_ctl", 599 debugfs_create_file("spectral_scan_ctl",
524 S_IRUSR | S_IWUSR, 600 S_IRUSR | S_IWUSR,
525 sc->debug.debugfs_phy, sc, 601 debugfs_phy, spec_priv,
526 &fops_spec_scan_ctl); 602 &fops_spec_scan_ctl);
527 debugfs_create_file("spectral_short_repeat", 603 debugfs_create_file("spectral_short_repeat",
528 S_IRUSR | S_IWUSR, 604 S_IRUSR | S_IWUSR,
529 sc->debug.debugfs_phy, sc, 605 debugfs_phy, spec_priv,
530 &fops_spectral_short_repeat); 606 &fops_spectral_short_repeat);
531 debugfs_create_file("spectral_count", 607 debugfs_create_file("spectral_count",
532 S_IRUSR | S_IWUSR, 608 S_IRUSR | S_IWUSR,
533 sc->debug.debugfs_phy, sc, 609 debugfs_phy, spec_priv,
534 &fops_spectral_count); 610 &fops_spectral_count);
535 debugfs_create_file("spectral_period", 611 debugfs_create_file("spectral_period",
536 S_IRUSR | S_IWUSR, 612 S_IRUSR | S_IWUSR,
537 sc->debug.debugfs_phy, sc, 613 debugfs_phy, spec_priv,
538 &fops_spectral_period); 614 &fops_spectral_period);
539 debugfs_create_file("spectral_fft_period", 615 debugfs_create_file("spectral_fft_period",
540 S_IRUSR | S_IWUSR, 616 S_IRUSR | S_IWUSR,
541 sc->debug.debugfs_phy, sc, 617 debugfs_phy, spec_priv,
542 &fops_spectral_fft_period); 618 &fops_spectral_fft_period);
543} 619}
620EXPORT_SYMBOL(ath9k_cmn_spectral_init_debug);
diff --git a/drivers/net/wireless/ath/ath9k/spectral.h b/drivers/net/wireless/ath/ath9k/common-spectral.h
index 7b410c6858b0..82d9dd29652c 100644
--- a/drivers/net/wireless/ath/ath9k/spectral.h
+++ b/drivers/net/wireless/ath/ath9k/common-spectral.h
@@ -92,6 +92,13 @@ struct ath_ht20_40_fft_packet {
92 struct ath_radar_info radar_info; 92 struct ath_radar_info radar_info;
93} __packed; 93} __packed;
94 94
95struct ath_spec_scan_priv {
96 struct ath_hw *ah;
97 /* relay(fs) channel for spectral scan */
98 struct rchan *rfs_chan_spec_scan;
99 enum spectral_mode spectral_mode;
100 struct ath_spec_scan spec_config;
101};
95 102
96#define SPECTRAL_HT20_40_TOTAL_DATA_LEN (sizeof(struct ath_ht20_40_fft_packet)) 103#define SPECTRAL_HT20_40_TOTAL_DATA_LEN (sizeof(struct ath_ht20_40_fft_packet))
97 104
@@ -123,23 +130,15 @@ static inline u8 spectral_bitmap_weight(u8 *bins)
123 return bins[0] & 0x3f; 130 return bins[0] & 0x3f;
124} 131}
125 132
126void ath9k_spectral_init_debug(struct ath_softc *sc); 133void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv, struct dentry *debugfs_phy);
127void ath9k_spectral_deinit_debug(struct ath_softc *sc); 134void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv);
128 135
129void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw); 136void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
130int ath9k_spectral_scan_config(struct ieee80211_hw *hw, 137 struct ath_spec_scan_priv *spec_priv);
138int ath9k_cmn_spectral_scan_config(struct ath_common *common,
139 struct ath_spec_scan_priv *spec_priv,
131 enum spectral_mode spectral_mode); 140 enum spectral_mode spectral_mode);
132 141int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
133#ifdef CONFIG_ATH9K_DEBUGFS
134int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
135 struct ath_rx_status *rs, u64 tsf); 142 struct ath_rx_status *rs, u64 tsf);
136#else
137static inline int ath_process_fft(struct ath_softc *sc,
138 struct ieee80211_hdr *hdr,
139 struct ath_rx_status *rs, u64 tsf)
140{
141 return 0;
142}
143#endif /* CONFIG_ATH9K_DEBUGFS */
144 143
145#endif /* SPECTRAL_H */ 144#endif /* SPECTRAL_H */
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index 33b0c7aef2ea..e8c699446470 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -159,7 +159,7 @@ void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
159 if (test_bit(keyix, common->keymap)) 159 if (test_bit(keyix, common->keymap))
160 rxs->flag |= RX_FLAG_DECRYPTED; 160 rxs->flag |= RX_FLAG_DECRYPTED;
161 } 161 }
162 if (ah->sw_mgmt_crypto && 162 if (ah->sw_mgmt_crypto_rx &&
163 (rxs->flag & RX_FLAG_DECRYPTED) && 163 (rxs->flag & RX_FLAG_DECRYPTED) &&
164 ieee80211_is_mgmt(fc)) 164 ieee80211_is_mgmt(fc))
165 /* Use software decrypt for management frames. */ 165 /* Use software decrypt for management frames. */
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index ffc454b18637..2b79a568e803 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -24,6 +24,7 @@
24#include "common-init.h" 24#include "common-init.h"
25#include "common-beacon.h" 25#include "common-beacon.h"
26#include "common-debug.h" 26#include "common-debug.h"
27#include "common-spectral.h"
27 28
28/* Common header for Atheros 802.11n base driver cores */ 29/* Common header for Atheros 802.11n base driver cores */
29 30
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index c9afc15cd4d3..696e3d5309c6 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -828,13 +828,14 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
828 828
829 i = 0; 829 i = 0;
830 ath_for_each_chanctx(sc, ctx) { 830 ath_for_each_chanctx(sc, ctx) {
831 if (!ctx->assigned || list_empty(&ctx->vifs)) 831 if (list_empty(&ctx->vifs))
832 continue; 832 continue;
833 ath9k_calculate_iter_data(sc, ctx, &iter_data); 833 ath9k_calculate_iter_data(sc, ctx, &iter_data);
834 834
835 len += scnprintf(buf + len, sizeof(buf) - len, 835 len += scnprintf(buf + len, sizeof(buf) - len,
836 "VIF-COUNTS: CTX %i AP: %i STA: %i MESH: %i WDS: %i", 836 "VIFS: CTX %i(%i) AP: %i STA: %i MESH: %i WDS: %i",
837 i++, iter_data.naps, iter_data.nstations, 837 i++, (int)(ctx->assigned), iter_data.naps,
838 iter_data.nstations,
838 iter_data.nmeshes, iter_data.nwds); 839 iter_data.nmeshes, iter_data.nwds);
839 len += scnprintf(buf + len, sizeof(buf) - len, 840 len += scnprintf(buf + len, sizeof(buf) - len,
840 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 841 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
@@ -1310,7 +1311,7 @@ void ath9k_get_et_stats(struct ieee80211_hw *hw,
1310 1311
1311void ath9k_deinit_debug(struct ath_softc *sc) 1312void ath9k_deinit_debug(struct ath_softc *sc)
1312{ 1313{
1313 ath9k_spectral_deinit_debug(sc); 1314 ath9k_cmn_spectral_deinit_debug(&sc->spec_priv);
1314} 1315}
1315 1316
1316int ath9k_init_debug(struct ath_hw *ah) 1317int ath9k_init_debug(struct ath_hw *ah)
@@ -1330,7 +1331,7 @@ int ath9k_init_debug(struct ath_hw *ah)
1330 1331
1331 ath9k_dfs_init_debug(sc); 1332 ath9k_dfs_init_debug(sc);
1332 ath9k_tx99_init_debug(sc); 1333 ath9k_tx99_init_debug(sc);
1333 ath9k_spectral_init_debug(sc); 1334 ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy);
1334 1335
1335 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1336 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1336 &fops_dma); 1337 &fops_dma);
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index b1956bf6e01e..2fef7a480fec 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -25,7 +25,12 @@ static void ath_led_brightness(struct led_classdev *led_cdev,
25 enum led_brightness brightness) 25 enum led_brightness brightness)
26{ 26{
27 struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); 27 struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
28 ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF)); 28 u32 val = (brightness == LED_OFF);
29
30 if (sc->sc_ah->config.led_active_high)
31 val = !val;
32
33 ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val);
29} 34}
30 35
31void ath_deinit_leds(struct ath_softc *sc) 36void ath_deinit_leds(struct ath_softc *sc)
@@ -82,7 +87,7 @@ void ath_fill_led_pin(struct ath_softc *sc)
82 ath9k_hw_cfg_output(ah, ah->led_pin, AR_GPIO_OUTPUT_MUX_AS_OUTPUT); 87 ath9k_hw_cfg_output(ah, ah->led_pin, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
83 88
84 /* LED off, active low */ 89 /* LED off, active low */
85 ath9k_hw_set_gpio(ah, ah->led_pin, 1); 90 ath9k_hw_set_gpio(ah, ah->led_pin, (ah->config.led_active_high) ? 0 : 1);
86} 91}
87#endif 92#endif
88 93
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 09a5d72f3ff5..9dde265d3f84 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -481,6 +481,7 @@ struct ath9k_htc_priv {
481 unsigned long op_flags; 481 unsigned long op_flags;
482 482
483 struct ath9k_hw_cal_data caldata; 483 struct ath9k_hw_cal_data caldata;
484 struct ath_spec_scan_priv spec_priv;
484 485
485 spinlock_t beacon_lock; 486 spinlock_t beacon_lock;
486 struct ath_beacon_config cur_beacon_conf; 487 struct ath_beacon_config cur_beacon_conf;
@@ -625,8 +626,12 @@ int ath9k_htc_resume(struct htc_target *htc_handle);
625#endif 626#endif
626#ifdef CONFIG_ATH9K_HTC_DEBUGFS 627#ifdef CONFIG_ATH9K_HTC_DEBUGFS
627int ath9k_htc_init_debug(struct ath_hw *ah); 628int ath9k_htc_init_debug(struct ath_hw *ah);
629void ath9k_htc_deinit_debug(struct ath9k_htc_priv *priv);
628#else 630#else
629static inline int ath9k_htc_init_debug(struct ath_hw *ah) { return 0; }; 631static inline int ath9k_htc_init_debug(struct ath_hw *ah) { return 0; };
632static inline void ath9k_htc_deinit_debug(struct ath9k_htc_priv *priv)
633{
634}
630#endif /* CONFIG_ATH9K_HTC_DEBUGFS */ 635#endif /* CONFIG_ATH9K_HTC_DEBUGFS */
631 636
632#endif /* HTC_H */ 637#endif /* HTC_H */
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index 8b529e4b8ac4..8cef1edcc621 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -490,6 +490,10 @@ void ath9k_htc_get_et_stats(struct ieee80211_hw *hw,
490 WARN_ON(i != ATH9K_HTC_SSTATS_LEN); 490 WARN_ON(i != ATH9K_HTC_SSTATS_LEN);
491} 491}
492 492
493void ath9k_htc_deinit_debug(struct ath9k_htc_priv *priv)
494{
495 ath9k_cmn_spectral_deinit_debug(&priv->spec_priv);
496}
493 497
494int ath9k_htc_init_debug(struct ath_hw *ah) 498int ath9k_htc_init_debug(struct ath_hw *ah)
495{ 499{
@@ -501,6 +505,8 @@ int ath9k_htc_init_debug(struct ath_hw *ah)
501 if (!priv->debug.debugfs_phy) 505 if (!priv->debug.debugfs_phy)
502 return -ENOMEM; 506 return -ENOMEM;
503 507
508 ath9k_cmn_spectral_init_debug(&priv->spec_priv, priv->debug.debugfs_phy);
509
504 debugfs_create_file("tgt_int_stats", S_IRUSR, priv->debug.debugfs_phy, 510 debugfs_create_file("tgt_int_stats", S_IRUSR, priv->debug.debugfs_phy,
505 priv, &fops_tgt_int_stats); 511 priv, &fops_tgt_int_stats);
506 debugfs_create_file("tgt_tx_stats", S_IRUSR, priv->debug.debugfs_phy, 512 debugfs_create_file("tgt_tx_stats", S_IRUSR, priv->debug.debugfs_phy,
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 4014c4be6e79..e8fa9448da24 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -53,6 +53,21 @@ static const struct ieee80211_tpt_blink ath9k_htc_tpt_blink[] = {
53}; 53};
54#endif 54#endif
55 55
56static void ath9k_htc_op_ps_wakeup(struct ath_common *common)
57{
58 ath9k_htc_ps_wakeup((struct ath9k_htc_priv *) common->priv);
59}
60
61static void ath9k_htc_op_ps_restore(struct ath_common *common)
62{
63 ath9k_htc_ps_restore((struct ath9k_htc_priv *) common->priv);
64}
65
66static struct ath_ps_ops ath9k_htc_ps_ops = {
67 .wakeup = ath9k_htc_op_ps_wakeup,
68 .restore = ath9k_htc_op_ps_restore,
69};
70
56static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv) 71static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
57{ 72{
58 int time_left; 73 int time_left;
@@ -87,6 +102,7 @@ static void ath9k_deinit_device(struct ath9k_htc_priv *priv)
87 102
88 wiphy_rfkill_stop_polling(hw->wiphy); 103 wiphy_rfkill_stop_polling(hw->wiphy);
89 ath9k_deinit_leds(priv); 104 ath9k_deinit_leds(priv);
105 ath9k_htc_deinit_debug(priv);
90 ieee80211_unregister_hw(hw); 106 ieee80211_unregister_hw(hw);
91 ath9k_rx_cleanup(priv); 107 ath9k_rx_cleanup(priv);
92 ath9k_tx_cleanup(priv); 108 ath9k_tx_cleanup(priv);
@@ -449,6 +465,14 @@ static void ath9k_init_misc(struct ath9k_htc_priv *priv)
449 465
450 common->last_rssi = ATH_RSSI_DUMMY_MARKER; 466 common->last_rssi = ATH_RSSI_DUMMY_MARKER;
451 priv->ah->opmode = NL80211_IFTYPE_STATION; 467 priv->ah->opmode = NL80211_IFTYPE_STATION;
468
469 priv->spec_priv.ah = priv->ah;
470 priv->spec_priv.spec_config.enabled = 0;
471 priv->spec_priv.spec_config.short_repeat = false;
472 priv->spec_priv.spec_config.count = 8;
473 priv->spec_priv.spec_config.endless = false;
474 priv->spec_priv.spec_config.period = 0x12;
475 priv->spec_priv.spec_config.fft_period = 0x02;
452} 476}
453 477
454static int ath9k_init_priv(struct ath9k_htc_priv *priv, 478static int ath9k_init_priv(struct ath9k_htc_priv *priv,
@@ -478,6 +502,7 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv,
478 502
479 common = ath9k_hw_common(ah); 503 common = ath9k_hw_common(ah);
480 common->ops = &ah->reg_ops; 504 common->ops = &ah->reg_ops;
505 common->ps_ops = &ath9k_htc_ps_ops;
481 common->bus_ops = &ath9k_usb_bus_ops; 506 common->bus_ops = &ath9k_usb_bus_ops;
482 common->ah = ah; 507 common->ah = ah;
483 common->hw = priv->hw; 508 common->hw = priv->hw;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 994fff1ff519..92d5a6c5a225 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -314,6 +314,10 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
314 mod_timer(&priv->tx.cleanup_timer, 314 mod_timer(&priv->tx.cleanup_timer,
315 jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL)); 315 jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
316 316
317 /* perform spectral scan if requested. */
318 if (test_bit(ATH_OP_SCANNING, &common->op_flags) &&
319 priv->spec_priv.spectral_mode == SPECTRAL_CHANSCAN)
320 ath9k_cmn_spectral_scan_trigger(common, &priv->spec_priv);
317err: 321err:
318 ath9k_htc_ps_restore(priv); 322 ath9k_htc_ps_restore(priv);
319 return ret; 323 return ret;
@@ -1443,7 +1447,7 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw,
1443 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 1447 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1444 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) 1448 if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
1445 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 1449 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1446 if (priv->ah->sw_mgmt_crypto && 1450 if (priv->ah->sw_mgmt_crypto_tx &&
1447 key->cipher == WLAN_CIPHER_SUITE_CCMP) 1451 key->cipher == WLAN_CIPHER_SUITE_CCMP)
1448 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; 1452 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1449 ret = 0; 1453 ret = 0;
@@ -1687,7 +1691,9 @@ static int ath9k_htc_ampdu_action(struct ieee80211_hw *hw,
1687 return ret; 1691 return ret;
1688} 1692}
1689 1693
1690static void ath9k_htc_sw_scan_start(struct ieee80211_hw *hw) 1694static void ath9k_htc_sw_scan_start(struct ieee80211_hw *hw,
1695 struct ieee80211_vif *vif,
1696 const u8 *mac_addr)
1691{ 1697{
1692 struct ath9k_htc_priv *priv = hw->priv; 1698 struct ath9k_htc_priv *priv = hw->priv;
1693 struct ath_common *common = ath9k_hw_common(priv->ah); 1699 struct ath_common *common = ath9k_hw_common(priv->ah);
@@ -1701,7 +1707,8 @@ static void ath9k_htc_sw_scan_start(struct ieee80211_hw *hw)
1701 mutex_unlock(&priv->mutex); 1707 mutex_unlock(&priv->mutex);
1702} 1708}
1703 1709
1704static void ath9k_htc_sw_scan_complete(struct ieee80211_hw *hw) 1710static void ath9k_htc_sw_scan_complete(struct ieee80211_hw *hw,
1711 struct ieee80211_vif *vif)
1705{ 1712{
1706 struct ath9k_htc_priv *priv = hw->priv; 1713 struct ath9k_htc_priv *priv = hw->priv;
1707 struct ath_common *common = ath9k_hw_common(priv->ah); 1714 struct ath_common *common = ath9k_hw_common(priv->ah);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index f0484b1b617e..a0f58e2aa553 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -946,7 +946,7 @@ static inline void convert_htc_flag(struct ath_rx_status *rx_stats,
946static void rx_status_htc_to_ath(struct ath_rx_status *rx_stats, 946static void rx_status_htc_to_ath(struct ath_rx_status *rx_stats,
947 struct ath_htc_rx_status *rxstatus) 947 struct ath_htc_rx_status *rxstatus)
948{ 948{
949 rx_stats->rs_datalen = rxstatus->rs_datalen; 949 rx_stats->rs_datalen = be16_to_cpu(rxstatus->rs_datalen);
950 rx_stats->rs_status = rxstatus->rs_status; 950 rx_stats->rs_status = rxstatus->rs_status;
951 rx_stats->rs_phyerr = rxstatus->rs_phyerr; 951 rx_stats->rs_phyerr = rxstatus->rs_phyerr;
952 rx_stats->rs_rssi = rxstatus->rs_rssi; 952 rx_stats->rs_rssi = rxstatus->rs_rssi;
@@ -1012,6 +1012,20 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
1012 * separately to avoid doing two lookups for a rate for each frame. 1012 * separately to avoid doing two lookups for a rate for each frame.
1013 */ 1013 */
1014 hdr = (struct ieee80211_hdr *)skb->data; 1014 hdr = (struct ieee80211_hdr *)skb->data;
1015
1016 /*
1017 * Process PHY errors and return so that the packet
1018 * can be dropped.
1019 */
1020 if (rx_stats.rs_status & ATH9K_RXERR_PHY) {
1021 /* TODO: Not using DFS processing now. */
1022 if (ath_cmn_process_fft(&priv->spec_priv, hdr,
1023 &rx_stats, rx_status->mactime)) {
1024 /* TODO: Code to collect spectral scan statistics */
1025 }
1026 goto rx_next;
1027 }
1028
1015 if (!ath9k_cmn_rx_accept(common, hdr, rx_status, &rx_stats, 1029 if (!ath9k_cmn_rx_accept(common, hdr, rx_status, &rx_stats,
1016 &decrypt_error, priv->rxfilter)) 1030 &decrypt_error, priv->rxfilter))
1017 goto rx_next; 1031 goto rx_next;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index ee9fb52cec62..6d4b273469b1 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -870,19 +870,6 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
870 udelay(RTC_PLL_SETTLE_DELAY); 870 udelay(RTC_PLL_SETTLE_DELAY);
871 871
872 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK); 872 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK);
873
874 if (AR_SREV_9340(ah) || AR_SREV_9550(ah)) {
875 if (ah->is_clk_25mhz) {
876 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
877 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
878 REG_WRITE(ah, AR_SLP32_INC, 0x0001e7ae);
879 } else {
880 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x261 << 1);
881 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f400);
882 REG_WRITE(ah, AR_SLP32_INC, 0x0001e800);
883 }
884 udelay(100);
885 }
886} 873}
887 874
888static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, 875static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
@@ -1598,16 +1585,22 @@ static void ath9k_hw_init_mfp(struct ath_hw *ah)
1598 * frames when constructing CCMP AAD. */ 1585 * frames when constructing CCMP AAD. */
1599 REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT, 1586 REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT,
1600 0xc7ff); 1587 0xc7ff);
1601 ah->sw_mgmt_crypto = false; 1588 if (AR_SREV_9271(ah) || AR_DEVID_7010(ah))
1589 ah->sw_mgmt_crypto_tx = true;
1590 else
1591 ah->sw_mgmt_crypto_tx = false;
1592 ah->sw_mgmt_crypto_rx = false;
1602 } else if (AR_SREV_9160_10_OR_LATER(ah)) { 1593 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
1603 /* Disable hardware crypto for management frames */ 1594 /* Disable hardware crypto for management frames */
1604 REG_CLR_BIT(ah, AR_PCU_MISC_MODE2, 1595 REG_CLR_BIT(ah, AR_PCU_MISC_MODE2,
1605 AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE); 1596 AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE);
1606 REG_SET_BIT(ah, AR_PCU_MISC_MODE2, 1597 REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
1607 AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT); 1598 AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT);
1608 ah->sw_mgmt_crypto = true; 1599 ah->sw_mgmt_crypto_tx = true;
1600 ah->sw_mgmt_crypto_rx = true;
1609 } else { 1601 } else {
1610 ah->sw_mgmt_crypto = true; 1602 ah->sw_mgmt_crypto_tx = true;
1603 ah->sw_mgmt_crypto_rx = true;
1611 } 1604 }
1612} 1605}
1613 1606
@@ -1954,6 +1947,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1954 1947
1955 REGWRITE_BUFFER_FLUSH(ah); 1948 REGWRITE_BUFFER_FLUSH(ah);
1956 1949
1950 ath9k_hw_gen_timer_start_tsf2(ah);
1951
1957 ath9k_hw_init_desc(ah); 1952 ath9k_hw_init_desc(ah);
1958 1953
1959 if (ath9k_hw_btcoex_is_enabled(ah)) 1954 if (ath9k_hw_btcoex_is_enabled(ah))
@@ -2333,7 +2328,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2333 struct ath9k_hw_capabilities *pCap = &ah->caps; 2328 struct ath9k_hw_capabilities *pCap = &ah->caps;
2334 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); 2329 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
2335 struct ath_common *common = ath9k_hw_common(ah); 2330 struct ath_common *common = ath9k_hw_common(ah);
2336 unsigned int chip_chainmask;
2337 2331
2338 u16 eeval; 2332 u16 eeval;
2339 u8 ant_div_ctl1, tx_chainmask, rx_chainmask; 2333 u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
@@ -2377,15 +2371,16 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2377 AR_SREV_9285(ah) || 2371 AR_SREV_9285(ah) ||
2378 AR_SREV_9330(ah) || 2372 AR_SREV_9330(ah) ||
2379 AR_SREV_9565(ah)) 2373 AR_SREV_9565(ah))
2380 chip_chainmask = 1; 2374 pCap->chip_chainmask = 1;
2381 else if (AR_SREV_9462(ah))
2382 chip_chainmask = 3;
2383 else if (!AR_SREV_9280_20_OR_LATER(ah)) 2375 else if (!AR_SREV_9280_20_OR_LATER(ah))
2384 chip_chainmask = 7; 2376 pCap->chip_chainmask = 7;
2385 else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah)) 2377 else if (!AR_SREV_9300_20_OR_LATER(ah) ||
2386 chip_chainmask = 3; 2378 AR_SREV_9340(ah) ||
2379 AR_SREV_9462(ah) ||
2380 AR_SREV_9531(ah))
2381 pCap->chip_chainmask = 3;
2387 else 2382 else
2388 chip_chainmask = 7; 2383 pCap->chip_chainmask = 7;
2389 2384
2390 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK); 2385 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
2391 /* 2386 /*
@@ -2403,8 +2398,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2403 /* Use rx_chainmask from EEPROM. */ 2398 /* Use rx_chainmask from EEPROM. */
2404 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK); 2399 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
2405 2400
2406 pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask); 2401 pCap->tx_chainmask = fixup_chainmask(pCap->chip_chainmask, pCap->tx_chainmask);
2407 pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask); 2402 pCap->rx_chainmask = fixup_chainmask(pCap->chip_chainmask, pCap->rx_chainmask);
2408 ah->txchainmask = pCap->tx_chainmask; 2403 ah->txchainmask = pCap->tx_chainmask;
2409 ah->rxchainmask = pCap->rx_chainmask; 2404 ah->rxchainmask = pCap->rx_chainmask;
2410 2405
@@ -2918,6 +2913,16 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah)
2918} 2913}
2919EXPORT_SYMBOL(ath9k_hw_gettsf32); 2914EXPORT_SYMBOL(ath9k_hw_gettsf32);
2920 2915
2916void ath9k_hw_gen_timer_start_tsf2(struct ath_hw *ah)
2917{
2918 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
2919
2920 if (timer_table->tsf2_enabled) {
2921 REG_SET_BIT(ah, AR_DIRECT_CONNECT, AR_DC_AP_STA_EN);
2922 REG_SET_BIT(ah, AR_RESET_TSF, AR_RESET_TSF2_ONCE);
2923 }
2924}
2925
2921struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, 2926struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
2922 void (*trigger)(void *), 2927 void (*trigger)(void *),
2923 void (*overflow)(void *), 2928 void (*overflow)(void *),
@@ -2928,7 +2933,11 @@ struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
2928 struct ath_gen_timer *timer; 2933 struct ath_gen_timer *timer;
2929 2934
2930 if ((timer_index < AR_FIRST_NDP_TIMER) || 2935 if ((timer_index < AR_FIRST_NDP_TIMER) ||
2931 (timer_index >= ATH_MAX_GEN_TIMER)) 2936 (timer_index >= ATH_MAX_GEN_TIMER))
2937 return NULL;
2938
2939 if ((timer_index > AR_FIRST_NDP_TIMER) &&
2940 !AR_SREV_9300_20_OR_LATER(ah))
2932 return NULL; 2941 return NULL;
2933 2942
2934 timer = kzalloc(sizeof(struct ath_gen_timer), GFP_KERNEL); 2943 timer = kzalloc(sizeof(struct ath_gen_timer), GFP_KERNEL);
@@ -2942,6 +2951,11 @@ struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
2942 timer->overflow = overflow; 2951 timer->overflow = overflow;
2943 timer->arg = arg; 2952 timer->arg = arg;
2944 2953
2954 if ((timer_index > AR_FIRST_NDP_TIMER) && !timer_table->tsf2_enabled) {
2955 timer_table->tsf2_enabled = true;
2956 ath9k_hw_gen_timer_start_tsf2(ah);
2957 }
2958
2945 return timer; 2959 return timer;
2946} 2960}
2947EXPORT_SYMBOL(ath_gen_timer_alloc); 2961EXPORT_SYMBOL(ath_gen_timer_alloc);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index e49721e85f6a..4cf9e0ac0743 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -276,6 +276,7 @@ struct ath9k_hw_capabilities {
276 u16 rts_aggr_limit; 276 u16 rts_aggr_limit;
277 u8 tx_chainmask; 277 u8 tx_chainmask;
278 u8 rx_chainmask; 278 u8 rx_chainmask;
279 u8 chip_chainmask;
279 u8 max_txchains; 280 u8 max_txchains;
280 u8 max_rxchains; 281 u8 max_rxchains;
281 u8 num_gpio_pins; 282 u8 num_gpio_pins;
@@ -329,6 +330,7 @@ struct ath9k_ops_config {
329 bool alt_mingainidx; 330 bool alt_mingainidx;
330 bool no_pll_pwrsave; 331 bool no_pll_pwrsave;
331 bool tx_gain_buffalo; 332 bool tx_gain_buffalo;
333 bool led_active_high;
332}; 334};
333 335
334enum ath9k_int { 336enum ath9k_int {
@@ -524,6 +526,7 @@ struct ath_gen_timer {
524struct ath_gen_timer_table { 526struct ath_gen_timer_table {
525 struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER]; 527 struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER];
526 u16 timer_mask; 528 u16 timer_mask;
529 bool tsf2_enabled;
527}; 530};
528 531
529struct ath_hw_antcomb_conf { 532struct ath_hw_antcomb_conf {
@@ -753,7 +756,8 @@ struct ath_hw {
753 } eeprom; 756 } eeprom;
754 const struct eeprom_ops *eep_ops; 757 const struct eeprom_ops *eep_ops;
755 758
756 bool sw_mgmt_crypto; 759 bool sw_mgmt_crypto_tx;
760 bool sw_mgmt_crypto_rx;
757 bool is_pciexpress; 761 bool is_pciexpress;
758 bool aspm_enabled; 762 bool aspm_enabled;
759 bool is_monitoring; 763 bool is_monitoring;
@@ -1035,6 +1039,7 @@ void ath9k_hw_gen_timer_start(struct ath_hw *ah,
1035 struct ath_gen_timer *timer, 1039 struct ath_gen_timer *timer,
1036 u32 timer_next, 1040 u32 timer_next,
1037 u32 timer_period); 1041 u32 timer_period);
1042void ath9k_hw_gen_timer_start_tsf2(struct ath_hw *ah);
1038void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer); 1043void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer);
1039 1044
1040void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer); 1045void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer);
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index a4d69a059753..59d679cebc89 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -88,6 +88,21 @@ static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = {
88 88
89static void ath9k_deinit_softc(struct ath_softc *sc); 89static void ath9k_deinit_softc(struct ath_softc *sc);
90 90
91static void ath9k_op_ps_wakeup(struct ath_common *common)
92{
93 ath9k_ps_wakeup((struct ath_softc *) common->priv);
94}
95
96static void ath9k_op_ps_restore(struct ath_common *common)
97{
98 ath9k_ps_restore((struct ath_softc *) common->priv);
99}
100
101static struct ath_ps_ops ath9k_ps_ops = {
102 .wakeup = ath9k_op_ps_wakeup,
103 .restore = ath9k_op_ps_restore,
104};
105
91/* 106/*
92 * Read and write, they both share the same lock. We do this to serialize 107 * Read and write, they both share the same lock. We do this to serialize
93 * reads and writes on Atheros 802.11n PCI devices only. This is required 108 * reads and writes on Atheros 802.11n PCI devices only. This is required
@@ -172,17 +187,20 @@ static void ath9k_reg_notifier(struct wiphy *wiphy,
172 ath_reg_notifier_apply(wiphy, request, reg); 187 ath_reg_notifier_apply(wiphy, request, reg);
173 188
174 /* Set tx power */ 189 /* Set tx power */
175 if (ah->curchan) { 190 if (!ah->curchan)
176 sc->cur_chan->txpower = 2 * ah->curchan->chan->max_power; 191 return;
177 ath9k_ps_wakeup(sc); 192
178 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false); 193 sc->cur_chan->txpower = 2 * ah->curchan->chan->max_power;
179 sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit; 194 ath9k_ps_wakeup(sc);
180 /* synchronize DFS detector if regulatory domain changed */ 195 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
181 if (sc->dfs_detector != NULL) 196 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
182 sc->dfs_detector->set_dfs_domain(sc->dfs_detector, 197 sc->cur_chan->txpower,
183 request->dfs_region); 198 &sc->cur_chan->cur_txpower);
184 ath9k_ps_restore(sc); 199 /* synchronize DFS detector if regulatory domain changed */
185 } 200 if (sc->dfs_detector != NULL)
201 sc->dfs_detector->set_dfs_domain(sc->dfs_detector,
202 request->dfs_region);
203 ath9k_ps_restore(sc);
186} 204}
187 205
188/* 206/*
@@ -348,12 +366,13 @@ static void ath9k_init_misc(struct ath_softc *sc)
348 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) 366 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
349 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; 367 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;
350 368
351 sc->spec_config.enabled = 0; 369 sc->spec_priv.ah = sc->sc_ah;
352 sc->spec_config.short_repeat = true; 370 sc->spec_priv.spec_config.enabled = 0;
353 sc->spec_config.count = 8; 371 sc->spec_priv.spec_config.short_repeat = true;
354 sc->spec_config.endless = false; 372 sc->spec_priv.spec_config.count = 8;
355 sc->spec_config.period = 0xFF; 373 sc->spec_priv.spec_config.endless = false;
356 sc->spec_config.fft_period = 0xF; 374 sc->spec_priv.spec_config.period = 0xFF;
375 sc->spec_priv.spec_config.fft_period = 0xF;
357} 376}
358 377
359static void ath9k_init_pcoem_platform(struct ath_softc *sc) 378static void ath9k_init_pcoem_platform(struct ath_softc *sc)
@@ -422,6 +441,9 @@ static void ath9k_init_pcoem_platform(struct ath_softc *sc)
422 ah->config.no_pll_pwrsave = true; 441 ah->config.no_pll_pwrsave = true;
423 ath_info(common, "Disable PLL PowerSave\n"); 442 ath_info(common, "Disable PLL PowerSave\n");
424 } 443 }
444
445 if (sc->driver_data & ATH9K_PCI_LED_ACT_HI)
446 ah->config.led_active_high = true;
425} 447}
426 448
427static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob, 449static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob,
@@ -539,6 +561,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
539 561
540 common->ops = &ah->reg_ops; 562 common->ops = &ah->reg_ops;
541 common->bus_ops = bus_ops; 563 common->bus_ops = bus_ops;
564 common->ps_ops = &ath9k_ps_ops;
542 common->ah = ah; 565 common->ah = ah;
543 common->hw = sc->hw; 566 common->hw = sc->hw;
544 common->priv = sc; 567 common->priv = sc;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index a91ee92d9d3f..7c63976b5b0c 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -233,8 +233,9 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
233 233
234 ath9k_calculate_summary_state(sc, sc->cur_chan); 234 ath9k_calculate_summary_state(sc, sc->cur_chan);
235 ath_startrecv(sc); 235 ath_startrecv(sc);
236 ath9k_cmn_update_txpow(ah, sc->curtxpow, 236 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
237 sc->cur_chan->txpower, &sc->curtxpow); 237 sc->cur_chan->txpower,
238 &sc->cur_chan->cur_txpower);
238 clear_bit(ATH_OP_HW_RESET, &common->op_flags); 239 clear_bit(ATH_OP_HW_RESET, &common->op_flags);
239 240
240 if (!sc->cur_chan->offchannel && start) { 241 if (!sc->cur_chan->offchannel && start) {
@@ -726,7 +727,8 @@ static int ath9k_start(struct ieee80211_hw *hw)
726 if (ah->led_pin >= 0) { 727 if (ah->led_pin >= 0) {
727 ath9k_hw_cfg_output(ah, ah->led_pin, 728 ath9k_hw_cfg_output(ah, ah->led_pin,
728 AR_GPIO_OUTPUT_MUX_AS_OUTPUT); 729 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
729 ath9k_hw_set_gpio(ah, ah->led_pin, 0); 730 ath9k_hw_set_gpio(ah, ah->led_pin,
731 (ah->config.led_active_high) ? 1 : 0);
730 } 732 }
731 733
732 /* 734 /*
@@ -868,7 +870,8 @@ static void ath9k_stop(struct ieee80211_hw *hw)
868 spin_lock_bh(&sc->sc_pcu_lock); 870 spin_lock_bh(&sc->sc_pcu_lock);
869 871
870 if (ah->led_pin >= 0) { 872 if (ah->led_pin >= 0) {
871 ath9k_hw_set_gpio(ah, ah->led_pin, 1); 873 ath9k_hw_set_gpio(ah, ah->led_pin,
874 (ah->config.led_active_high) ? 0 : 1);
872 ath9k_hw_cfg_gpio_input(ah, ah->led_pin); 875 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
873 } 876 }
874 877
@@ -1187,7 +1190,8 @@ static void ath9k_assign_hw_queues(struct ieee80211_hw *hw,
1187 for (i = 0; i < IEEE80211_NUM_ACS; i++) 1190 for (i = 0; i < IEEE80211_NUM_ACS; i++)
1188 vif->hw_queue[i] = i; 1191 vif->hw_queue[i] = i;
1189 1192
1190 if (vif->type == NL80211_IFTYPE_AP) 1193 if (vif->type == NL80211_IFTYPE_AP ||
1194 vif->type == NL80211_IFTYPE_MESH_POINT)
1191 vif->cab_queue = hw->queues - 2; 1195 vif->cab_queue = hw->queues - 2;
1192 else 1196 else
1193 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE; 1197 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
@@ -1339,78 +1343,6 @@ static void ath9k_disable_ps(struct ath_softc *sc)
1339 ath_dbg(common, PS, "PowerSave disabled\n"); 1343 ath_dbg(common, PS, "PowerSave disabled\n");
1340} 1344}
1341 1345
1342void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw)
1343{
1344 struct ath_softc *sc = hw->priv;
1345 struct ath_hw *ah = sc->sc_ah;
1346 struct ath_common *common = ath9k_hw_common(ah);
1347 u32 rxfilter;
1348
1349 if (config_enabled(CONFIG_ATH9K_TX99))
1350 return;
1351
1352 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
1353 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
1354 return;
1355 }
1356
1357 ath9k_ps_wakeup(sc);
1358 rxfilter = ath9k_hw_getrxfilter(ah);
1359 ath9k_hw_setrxfilter(ah, rxfilter |
1360 ATH9K_RX_FILTER_PHYRADAR |
1361 ATH9K_RX_FILTER_PHYERR);
1362
1363 /* TODO: usually this should not be neccesary, but for some reason
1364 * (or in some mode?) the trigger must be called after the
1365 * configuration, otherwise the register will have its values reset
1366 * (on my ar9220 to value 0x01002310)
1367 */
1368 ath9k_spectral_scan_config(hw, sc->spectral_mode);
1369 ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
1370 ath9k_ps_restore(sc);
1371}
1372
1373int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
1374 enum spectral_mode spectral_mode)
1375{
1376 struct ath_softc *sc = hw->priv;
1377 struct ath_hw *ah = sc->sc_ah;
1378 struct ath_common *common = ath9k_hw_common(ah);
1379
1380 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
1381 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
1382 return -1;
1383 }
1384
1385 switch (spectral_mode) {
1386 case SPECTRAL_DISABLED:
1387 sc->spec_config.enabled = 0;
1388 break;
1389 case SPECTRAL_BACKGROUND:
1390 /* send endless samples.
1391 * TODO: is this really useful for "background"?
1392 */
1393 sc->spec_config.endless = 1;
1394 sc->spec_config.enabled = 1;
1395 break;
1396 case SPECTRAL_CHANSCAN:
1397 case SPECTRAL_MANUAL:
1398 sc->spec_config.endless = 0;
1399 sc->spec_config.enabled = 1;
1400 break;
1401 default:
1402 return -1;
1403 }
1404
1405 ath9k_ps_wakeup(sc);
1406 ath9k_hw_ops(ah)->spectral_scan_config(ah, &sc->spec_config);
1407 ath9k_ps_restore(sc);
1408
1409 sc->spectral_mode = spectral_mode;
1410
1411 return 0;
1412}
1413
1414static int ath9k_config(struct ieee80211_hw *hw, u32 changed) 1346static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1415{ 1347{
1416 struct ath_softc *sc = hw->priv; 1348 struct ath_softc *sc = hw->priv;
@@ -1471,8 +1403,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1471 if (changed & IEEE80211_CONF_CHANGE_POWER) { 1403 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1472 ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level); 1404 ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
1473 sc->cur_chan->txpower = 2 * conf->power_level; 1405 sc->cur_chan->txpower = 2 * conf->power_level;
1474 ath9k_cmn_update_txpow(ah, sc->curtxpow, 1406 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
1475 sc->cur_chan->txpower, &sc->curtxpow); 1407 sc->cur_chan->txpower,
1408 &sc->cur_chan->cur_txpower);
1476 } 1409 }
1477 1410
1478 mutex_unlock(&sc->mutex); 1411 mutex_unlock(&sc->mutex);
@@ -1727,7 +1660,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
1727 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 1660 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1728 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) 1661 if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
1729 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 1662 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1730 if (sc->sc_ah->sw_mgmt_crypto && 1663 if (sc->sc_ah->sw_mgmt_crypto_tx &&
1731 key->cipher == WLAN_CIPHER_SUITE_CCMP) 1664 key->cipher == WLAN_CIPHER_SUITE_CCMP)
1732 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; 1665 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1733 ret = 0; 1666 ret = 0;
@@ -2250,14 +2183,17 @@ static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
2250 return 0; 2183 return 0;
2251} 2184}
2252 2185
2253static void ath9k_sw_scan_start(struct ieee80211_hw *hw) 2186static void ath9k_sw_scan_start(struct ieee80211_hw *hw,
2187 struct ieee80211_vif *vif,
2188 const u8 *mac_addr)
2254{ 2189{
2255 struct ath_softc *sc = hw->priv; 2190 struct ath_softc *sc = hw->priv;
2256 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2191 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2257 set_bit(ATH_OP_SCANNING, &common->op_flags); 2192 set_bit(ATH_OP_SCANNING, &common->op_flags);
2258} 2193}
2259 2194
2260static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) 2195static void ath9k_sw_scan_complete(struct ieee80211_hw *hw,
2196 struct ieee80211_vif *vif)
2261{ 2197{
2262 struct ath_softc *sc = hw->priv; 2198 struct ath_softc *sc = hw->priv;
2263 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2199 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -2266,6 +2202,28 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2266 2202
2267#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT 2203#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
2268 2204
2205static void ath9k_cancel_pending_offchannel(struct ath_softc *sc)
2206{
2207 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2208
2209 if (sc->offchannel.roc_vif) {
2210 ath_dbg(common, CHAN_CTX,
2211 "%s: Aborting RoC\n", __func__);
2212
2213 del_timer_sync(&sc->offchannel.timer);
2214 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2215 ath_roc_complete(sc, true);
2216 }
2217
2218 if (test_bit(ATH_OP_SCANNING, &common->op_flags)) {
2219 ath_dbg(common, CHAN_CTX,
2220 "%s: Aborting HW scan\n", __func__);
2221
2222 del_timer_sync(&sc->offchannel.timer);
2223 ath_scan_complete(sc, true);
2224 }
2225}
2226
2269static int ath9k_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2227static int ath9k_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2270 struct ieee80211_scan_request *hw_req) 2228 struct ieee80211_scan_request *hw_req)
2271{ 2229{
@@ -2452,6 +2410,8 @@ static int ath9k_assign_vif_chanctx(struct ieee80211_hw *hw,
2452 struct ath_chanctx *ctx = ath_chanctx_get(conf); 2410 struct ath_chanctx *ctx = ath_chanctx_get(conf);
2453 int i; 2411 int i;
2454 2412
2413 ath9k_cancel_pending_offchannel(sc);
2414
2455 mutex_lock(&sc->mutex); 2415 mutex_lock(&sc->mutex);
2456 2416
2457 ath_dbg(common, CHAN_CTX, 2417 ath_dbg(common, CHAN_CTX,
@@ -2481,6 +2441,8 @@ static void ath9k_unassign_vif_chanctx(struct ieee80211_hw *hw,
2481 struct ath_chanctx *ctx = ath_chanctx_get(conf); 2441 struct ath_chanctx *ctx = ath_chanctx_get(conf);
2482 int ac; 2442 int ac;
2483 2443
2444 ath9k_cancel_pending_offchannel(sc);
2445
2484 mutex_lock(&sc->mutex); 2446 mutex_lock(&sc->mutex);
2485 2447
2486 ath_dbg(common, CHAN_CTX, 2448 ath_dbg(common, CHAN_CTX,
@@ -2526,18 +2488,7 @@ static void ath9k_mgd_prepare_tx(struct ieee80211_hw *hw,
2526 if (!changed) 2488 if (!changed)
2527 goto out; 2489 goto out;
2528 2490
2529 if (test_bit(ATH_OP_SCANNING, &common->op_flags)) { 2491 ath9k_cancel_pending_offchannel(sc);
2530 ath_dbg(common, CHAN_CTX,
2531 "%s: Aborting HW scan\n", __func__);
2532
2533 mutex_unlock(&sc->mutex);
2534
2535 del_timer_sync(&sc->offchannel.timer);
2536 ath_scan_complete(sc, true);
2537 flush_work(&sc->chanctx_work);
2538
2539 mutex_lock(&sc->mutex);
2540 }
2541 2492
2542 go_ctx = ath_is_go_chanctx_present(sc); 2493 go_ctx = ath_is_go_chanctx_present(sc);
2543 2494
@@ -2552,13 +2503,22 @@ static void ath9k_mgd_prepare_tx(struct ieee80211_hw *hw,
2552 beacon_int = TU_TO_USEC(cur_conf->beacon_interval); 2503 beacon_int = TU_TO_USEC(cur_conf->beacon_interval);
2553 spin_unlock_bh(&sc->chan_lock); 2504 spin_unlock_bh(&sc->chan_lock);
2554 2505
2555 timeout = usecs_to_jiffies(beacon_int); 2506 timeout = usecs_to_jiffies(beacon_int * 2);
2556 init_completion(&sc->go_beacon); 2507 init_completion(&sc->go_beacon);
2557 2508
2509 mutex_unlock(&sc->mutex);
2510
2558 if (wait_for_completion_timeout(&sc->go_beacon, 2511 if (wait_for_completion_timeout(&sc->go_beacon,
2559 timeout) == 0) 2512 timeout) == 0) {
2560 ath_dbg(common, CHAN_CTX, 2513 ath_dbg(common, CHAN_CTX,
2561 "Failed to send new NoA\n"); 2514 "Failed to send new NoA\n");
2515
2516 spin_lock_bh(&sc->chan_lock);
2517 sc->sched.mgd_prepare_tx = false;
2518 spin_unlock_bh(&sc->chan_lock);
2519 }
2520
2521 mutex_lock(&sc->mutex);
2562 } 2522 }
2563 2523
2564 ath_dbg(common, CHAN_CTX, 2524 ath_dbg(common, CHAN_CTX,
@@ -2594,6 +2554,24 @@ void ath9k_fill_chanctx_ops(void)
2594 2554
2595#endif 2555#endif
2596 2556
2557static int ath9k_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2558 int *dbm)
2559{
2560 struct ath_softc *sc = hw->priv;
2561 struct ath_vif *avp = (void *)vif->drv_priv;
2562
2563 mutex_lock(&sc->mutex);
2564 if (avp->chanctx)
2565 *dbm = avp->chanctx->cur_txpower;
2566 else
2567 *dbm = sc->cur_chan->cur_txpower;
2568 mutex_unlock(&sc->mutex);
2569
2570 *dbm /= 2;
2571
2572 return 0;
2573}
2574
2597struct ieee80211_ops ath9k_ops = { 2575struct ieee80211_ops ath9k_ops = {
2598 .tx = ath9k_tx, 2576 .tx = ath9k_tx,
2599 .start = ath9k_start, 2577 .start = ath9k_start,
@@ -2640,4 +2618,5 @@ struct ieee80211_ops ath9k_ops = {
2640#endif 2618#endif
2641 .sw_scan_start = ath9k_sw_scan_start, 2619 .sw_scan_start = ath9k_sw_scan_start,
2642 .sw_scan_complete = ath9k_sw_scan_complete, 2620 .sw_scan_complete = ath9k_sw_scan_complete,
2621 .get_txpower = ath9k_get_txpower,
2643}; 2622};
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index e3f60d5c5263..f009b5b57e5e 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -657,7 +657,9 @@ static const struct pci_device_id ath_pci_id_table[] = {
657 0x0036, 657 0x0036,
658 PCI_VENDOR_ID_DELL, 658 PCI_VENDOR_ID_DELL,
659 0x020E), 659 0x020E),
660 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV }, 660 .driver_data = ATH9K_PCI_AR9565_2ANT |
661 ATH9K_PCI_BT_ANT_DIV |
662 ATH9K_PCI_LED_ACT_HI},
661 663
662 /* PCI-E AR9565 (WB335) */ 664 /* PCI-E AR9565 (WB335) */
663 { PCI_VDEVICE(ATHEROS, 0x0036), 665 { PCI_VDEVICE(ATHEROS, 0x0036),
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 6914e21816e4..7395afbc5124 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -870,7 +870,7 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
870 */ 870 */
871 if (rx_stats->rs_status & ATH9K_RXERR_PHY) { 871 if (rx_stats->rs_status & ATH9K_RXERR_PHY) {
872 ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime); 872 ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime);
873 if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime)) 873 if (ath_cmn_process_fft(&sc->spec_priv, hdr, rx_stats, rx_status->mactime))
874 RX_STAT_INC(rx_spectral); 874 RX_STAT_INC(rx_spectral);
875 875
876 return -EINVAL; 876 return -EINVAL;
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 1c0b1c1c5350..ced36b475acc 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -1605,6 +1605,7 @@ enum {
1605 1605
1606#define AR_RESET_TSF 0x8020 1606#define AR_RESET_TSF 0x8020
1607#define AR_RESET_TSF_ONCE 0x01000000 1607#define AR_RESET_TSF_ONCE 0x01000000
1608#define AR_RESET_TSF2_ONCE 0x02000000
1608 1609
1609#define AR_MAX_CFP_DUR 0x8038 1610#define AR_MAX_CFP_DUR 0x8038
1610#define AR_CFP_VAL 0x0000FFFF 1611#define AR_CFP_VAL 0x0000FFFF
@@ -1966,6 +1967,8 @@ enum {
1966#define AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET 0x80000000 1967#define AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET 0x80000000
1967#define AR_MAC_PCU_GEN_TIMER_TSF_SEL 0x83d8 1968#define AR_MAC_PCU_GEN_TIMER_TSF_SEL 0x83d8
1968 1969
1970#define AR_DIRECT_CONNECT 0x83a0
1971#define AR_DC_AP_STA_EN 0x00000001
1969 1972
1970#define AR_AES_MUTE_MASK0 0x805c 1973#define AR_AES_MUTE_MASK0 0x805c
1971#define AR_AES_MUTE_MASK0_FC 0x0000FFFF 1974#define AR_AES_MUTE_MASK0_FC 0x0000FFFF
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index b71d2b33532d..267c35d1f699 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -494,7 +494,9 @@ out:
494 return ret; 494 return ret;
495} 495}
496 496
497static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw) 497static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw,
498 struct ieee80211_vif *vif,
499 const u8 *mac_addr)
498{ 500{
499 struct wcn36xx *wcn = hw->priv; 501 struct wcn36xx *wcn = hw->priv;
500 502
@@ -502,7 +504,8 @@ static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw)
502 wcn36xx_smd_start_scan(wcn); 504 wcn36xx_smd_start_scan(wcn);
503} 505}
504 506
505static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw) 507static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw,
508 struct ieee80211_vif *vif)
506{ 509{
507 struct wcn36xx *wcn = hw->priv; 510 struct wcn36xx *wcn = hw->priv;
508 511
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 5d4173ee55bc..47731cb0d815 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5110,7 +5110,9 @@ static void b43_op_sta_notify(struct ieee80211_hw *hw,
5110 B43_WARN_ON(!vif || wl->vif != vif); 5110 B43_WARN_ON(!vif || wl->vif != vif);
5111} 5111}
5112 5112
5113static void b43_op_sw_scan_start_notifier(struct ieee80211_hw *hw) 5113static void b43_op_sw_scan_start_notifier(struct ieee80211_hw *hw,
5114 struct ieee80211_vif *vif,
5115 const u8 *mac_addr)
5114{ 5116{
5115 struct b43_wl *wl = hw_to_b43_wl(hw); 5117 struct b43_wl *wl = hw_to_b43_wl(hw);
5116 struct b43_wldev *dev; 5118 struct b43_wldev *dev;
@@ -5124,7 +5126,8 @@ static void b43_op_sw_scan_start_notifier(struct ieee80211_hw *hw)
5124 mutex_unlock(&wl->mutex); 5126 mutex_unlock(&wl->mutex);
5125} 5127}
5126 5128
5127static void b43_op_sw_scan_complete_notifier(struct ieee80211_hw *hw) 5129static void b43_op_sw_scan_complete_notifier(struct ieee80211_hw *hw,
5130 struct ieee80211_vif *vif)
5128{ 5131{
5129 struct b43_wl *wl = hw_to_b43_wl(hw); 5132 struct b43_wl *wl = hw_to_b43_wl(hw);
5130 struct b43_wldev *dev; 5133 struct b43_wldev *dev;
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 1dfc682a8055..ee27b06074e1 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -300,9 +300,7 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
300 300
301void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg) 301void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
302{ 302{
303 assert_mac_suspended(dev); 303 b43_phy_write(dev, destreg, b43_phy_read(dev, srcreg));
304 dev->phy.ops->phy_write(dev, destreg,
305 dev->phy.ops->phy_read(dev, srcreg));
306} 304}
307 305
308void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask) 306void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
index e418969679c9..f8a9dfa657ba 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
@@ -299,6 +299,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
299 primary_offset = ch->center_freq1 - ch->chan->center_freq; 299 primary_offset = ch->center_freq1 - ch->chan->center_freq;
300 switch (ch->width) { 300 switch (ch->width) {
301 case NL80211_CHAN_WIDTH_20: 301 case NL80211_CHAN_WIDTH_20:
302 case NL80211_CHAN_WIDTH_20_NOHT:
302 ch_inf.bw = BRCMU_CHAN_BW_20; 303 ch_inf.bw = BRCMU_CHAN_BW_20;
303 WARN_ON(primary_offset != 0); 304 WARN_ON(primary_offset != 0);
304 break; 305 break;
@@ -323,6 +324,10 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
323 ch_inf.sb = BRCMU_CHAN_SB_LU; 324 ch_inf.sb = BRCMU_CHAN_SB_LU;
324 } 325 }
325 break; 326 break;
327 case NL80211_CHAN_WIDTH_80P80:
328 case NL80211_CHAN_WIDTH_160:
329 case NL80211_CHAN_WIDTH_5:
330 case NL80211_CHAN_WIDTH_10:
326 default: 331 default:
327 WARN_ON_ONCE(1); 332 WARN_ON_ONCE(1);
328 } 333 }
@@ -333,6 +338,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
333 case IEEE80211_BAND_5GHZ: 338 case IEEE80211_BAND_5GHZ:
334 ch_inf.band = BRCMU_CHAN_BAND_5G; 339 ch_inf.band = BRCMU_CHAN_BAND_5G;
335 break; 340 break;
341 case IEEE80211_BAND_60GHZ:
336 default: 342 default:
337 WARN_ON_ONCE(1); 343 WARN_ON_ONCE(1);
338 } 344 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 0f157f151282..1ff787d1a36b 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
262 262
263fail: 263fail:
264 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev)); 264 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
265 if (fwctx->code) 265 release_firmware(fwctx->code);
266 release_firmware(fwctx->code);
267 device_release_driver(fwctx->dev); 266 device_release_driver(fwctx->dev);
268 kfree(fwctx); 267 kfree(fwctx);
269} 268}
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 02d39ce8dbca..9f783db34ae5 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -518,8 +518,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
518 memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ? 518 memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
519 len : msgbuf->ioctl_resp_ret_len); 519 len : msgbuf->ioctl_resp_ret_len);
520 } 520 }
521 if (skb) 521 brcmu_pkt_buf_free_skb(skb);
522 brcmu_pkt_buf_free_skb(skb);
523 522
524 return msgbuf->ioctl_resp_status; 523 return msgbuf->ioctl_resp_status;
525} 524}
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 43c71bfaa474..f95b52442281 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -764,7 +764,9 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw,
764 return; 764 return;
765} 765}
766 766
767static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw) 767static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw,
768 struct ieee80211_vif *vif,
769 const u8 *mac_addr)
768{ 770{
769 struct brcms_info *wl = hw->priv; 771 struct brcms_info *wl = hw->priv;
770 spin_lock_bh(&wl->lock); 772 spin_lock_bh(&wl->lock);
@@ -773,7 +775,8 @@ static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw)
773 return; 775 return;
774} 776}
775 777
776static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw) 778static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw,
779 struct ieee80211_vif *vif)
777{ 780{
778 struct brcms_info *wl = hw->priv; 781 struct brcms_info *wl = hw->priv;
779 spin_lock_bh(&wl->lock); 782 spin_lock_bh(&wl->lock);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index bc9be78faafa..738cfaca1e0f 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
1009 if (txh) 1009 if (txh)
1010 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, 1010 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
1011 sizeof(*txh)); 1011 sizeof(*txh));
1012 if (p) 1012 brcmu_pkt_buf_free_skb(p);
1013 brcmu_pkt_buf_free_skb(p);
1014 } 1013 }
1015 1014
1016 if (dma && queue < NFIFO) { 1015 if (dma && queue < NFIFO) {
diff --git a/drivers/net/wireless/cw1200/scan.c b/drivers/net/wireless/cw1200/scan.c
index b2fb6c632092..f2e276faca70 100644
--- a/drivers/net/wireless/cw1200/scan.c
+++ b/drivers/net/wireless/cw1200/scan.c
@@ -78,7 +78,7 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,
78 if (req->n_ssids > WSM_SCAN_MAX_NUM_OF_SSIDS) 78 if (req->n_ssids > WSM_SCAN_MAX_NUM_OF_SSIDS)
79 return -EINVAL; 79 return -EINVAL;
80 80
81 frame.skb = ieee80211_probereq_get(hw, priv->vif, NULL, 0, 81 frame.skb = ieee80211_probereq_get(hw, priv->vif->addr, NULL, 0,
82 req->ie_len); 82 req->ie_len);
83 if (!frame.skb) 83 if (!frame.skb)
84 return -ENOMEM; 84 return -ENOMEM;
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 5cd59a43e1da..fb2a8628b8fc 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -603,16 +603,6 @@ static int iwl_mvm_cancel_regular_scan(struct iwl_mvm *mvm)
603 SCAN_COMPLETE_NOTIFICATION }; 603 SCAN_COMPLETE_NOTIFICATION };
604 int ret; 604 int ret;
605 605
606 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
607 return 0;
608
609 if (iwl_mvm_is_radio_killed(mvm)) {
610 ieee80211_scan_completed(mvm->hw, true);
611 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
612 mvm->scan_status = IWL_MVM_SCAN_NONE;
613 return 0;
614 }
615
616 iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_abort, 606 iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_abort,
617 scan_abort_notif, 607 scan_abort_notif,
618 ARRAY_SIZE(scan_abort_notif), 608 ARRAY_SIZE(scan_abort_notif),
@@ -1431,6 +1421,16 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
1431 1421
1432int iwl_mvm_cancel_scan(struct iwl_mvm *mvm) 1422int iwl_mvm_cancel_scan(struct iwl_mvm *mvm)
1433{ 1423{
1424 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
1425 return 0;
1426
1427 if (iwl_mvm_is_radio_killed(mvm)) {
1428 ieee80211_scan_completed(mvm->hw, true);
1429 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
1430 mvm->scan_status = IWL_MVM_SCAN_NONE;
1431 return 0;
1432 }
1433
1434 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) 1434 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN)
1435 return iwl_mvm_scan_offload_stop(mvm, true); 1435 return iwl_mvm_scan_offload_stop(mvm, true);
1436 return iwl_mvm_cancel_regular_scan(mvm); 1436 return iwl_mvm_cancel_regular_scan(mvm);
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 836725e92687..ea8efed25c6a 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -1898,8 +1898,7 @@ static u32 iwl_trans_pcie_dump_prph(struct iwl_trans *trans,
1898 int reg; 1898 int reg;
1899 __le32 *val; 1899 __le32 *val;
1900 1900
1901 prph_len += sizeof(*data) + sizeof(*prph) + 1901 prph_len += sizeof(**data) + sizeof(*prph) + num_bytes_in_chunk;
1902 num_bytes_in_chunk;
1903 1902
1904 (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PRPH); 1903 (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PRPH);
1905 (*data)->len = cpu_to_le32(sizeof(*prph) + 1904 (*data)->len = cpu_to_le32(sizeof(*prph) +
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 77fbf3035038..2371d11e4190 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -415,6 +415,8 @@ struct mac80211_hwsim_data {
415 bool destroy_on_close; 415 bool destroy_on_close;
416 struct work_struct destroy_work; 416 struct work_struct destroy_work;
417 u32 portid; 417 u32 portid;
418 char alpha2[2];
419 const struct ieee80211_regdomain *regd;
418 420
419 struct ieee80211_channel *tmp_chan; 421 struct ieee80211_channel *tmp_chan;
420 struct delayed_work roc_done; 422 struct delayed_work roc_done;
@@ -422,6 +424,7 @@ struct mac80211_hwsim_data {
422 struct cfg80211_scan_request *hw_scan_request; 424 struct cfg80211_scan_request *hw_scan_request;
423 struct ieee80211_vif *hw_scan_vif; 425 struct ieee80211_vif *hw_scan_vif;
424 int scan_chan_idx; 426 int scan_chan_idx;
427 u8 scan_addr[ETH_ALEN];
425 428
426 struct ieee80211_channel *channel; 429 struct ieee80211_channel *channel;
427 u64 beacon_int /* beacon interval in us */; 430 u64 beacon_int /* beacon interval in us */;
@@ -830,6 +833,9 @@ static bool mac80211_hwsim_addr_match(struct mac80211_hwsim_data *data,
830 .ret = false, 833 .ret = false,
831 }; 834 };
832 835
836 if (data->scanning && memcmp(addr, data->scan_addr, ETH_ALEN) == 0)
837 return true;
838
833 memcpy(md.addr, addr, ETH_ALEN); 839 memcpy(md.addr, addr, ETH_ALEN);
834 840
835 ieee80211_iterate_active_interfaces_atomic(data->hw, 841 ieee80211_iterate_active_interfaces_atomic(data->hw,
@@ -984,6 +990,53 @@ static void mac80211_hwsim_tx_iter(void *_data, u8 *addr,
984 data->receive = true; 990 data->receive = true;
985} 991}
986 992
993static void mac80211_hwsim_add_vendor_rtap(struct sk_buff *skb)
994{
995 /*
996 * To enable this code, #define the HWSIM_RADIOTAP_OUI,
997 * e.g. like this:
998 * #define HWSIM_RADIOTAP_OUI "\x02\x00\x00"
999 * (but you should use a valid OUI, not that)
1000 *
1001 * If anyone wants to 'donate' a radiotap OUI/subns code
1002 * please send a patch removing this #ifdef and changing
1003 * the values accordingly.
1004 */
1005#ifdef HWSIM_RADIOTAP_OUI
1006 struct ieee80211_vendor_radiotap *rtap;
1007
1008 /*
1009 * Note that this code requires the headroom in the SKB
1010 * that was allocated earlier.
1011 */
1012 rtap = (void *)skb_push(skb, sizeof(*rtap) + 8 + 4);
1013 rtap->oui[0] = HWSIM_RADIOTAP_OUI[0];
1014 rtap->oui[1] = HWSIM_RADIOTAP_OUI[1];
1015 rtap->oui[2] = HWSIM_RADIOTAP_OUI[2];
1016 rtap->subns = 127;
1017
1018 /*
1019 * Radiotap vendor namespaces can (and should) also be
1020 * split into fields by using the standard radiotap
1021 * presence bitmap mechanism. Use just BIT(0) here for
1022 * the presence bitmap.
1023 */
1024 rtap->present = BIT(0);
1025 /* We have 8 bytes of (dummy) data */
1026 rtap->len = 8;
1027 /* For testing, also require it to be aligned */
1028 rtap->align = 8;
1029 /* And also test that padding works, 4 bytes */
1030 rtap->pad = 4;
1031 /* push the data */
1032 memcpy(rtap->data, "ABCDEFGH", 8);
1033 /* make sure to clear padding, mac80211 doesn't */
1034 memset(rtap->data + 8, 0, 4);
1035
1036 IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_RADIOTAP_VENDOR_DATA;
1037#endif
1038}
1039
987static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, 1040static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
988 struct sk_buff *skb, 1041 struct sk_buff *skb,
989 struct ieee80211_channel *chan) 1042 struct ieee80211_channel *chan)
@@ -1098,6 +1151,9 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
1098 rx_status.mactime = now + data2->tsf_offset; 1151 rx_status.mactime = now + data2->tsf_offset;
1099 1152
1100 memcpy(IEEE80211_SKB_RXCB(nskb), &rx_status, sizeof(rx_status)); 1153 memcpy(IEEE80211_SKB_RXCB(nskb), &rx_status, sizeof(rx_status));
1154
1155 mac80211_hwsim_add_vendor_rtap(nskb);
1156
1101 data2->rx_pkts++; 1157 data2->rx_pkts++;
1102 data2->rx_bytes += nskb->len; 1158 data2->rx_bytes += nskb->len;
1103 ieee80211_rx_irqsafe(data2->hw, nskb); 1159 ieee80211_rx_irqsafe(data2->hw, nskb);
@@ -1752,7 +1808,7 @@ static void hw_scan_work(struct work_struct *work)
1752 struct sk_buff *probe; 1808 struct sk_buff *probe;
1753 1809
1754 probe = ieee80211_probereq_get(hwsim->hw, 1810 probe = ieee80211_probereq_get(hwsim->hw,
1755 hwsim->hw_scan_vif, 1811 hwsim->scan_addr,
1756 req->ssids[i].ssid, 1812 req->ssids[i].ssid,
1757 req->ssids[i].ssid_len, 1813 req->ssids[i].ssid_len,
1758 req->ie_len); 1814 req->ie_len);
@@ -1790,6 +1846,12 @@ static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
1790 hwsim->hw_scan_request = req; 1846 hwsim->hw_scan_request = req;
1791 hwsim->hw_scan_vif = vif; 1847 hwsim->hw_scan_vif = vif;
1792 hwsim->scan_chan_idx = 0; 1848 hwsim->scan_chan_idx = 0;
1849 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
1850 get_random_mask_addr(hwsim->scan_addr,
1851 hw_req->req.mac_addr,
1852 hw_req->req.mac_addr_mask);
1853 else
1854 memcpy(hwsim->scan_addr, vif->addr, ETH_ALEN);
1793 mutex_unlock(&hwsim->mutex); 1855 mutex_unlock(&hwsim->mutex);
1794 1856
1795 wiphy_debug(hw->wiphy, "hwsim hw_scan request\n"); 1857 wiphy_debug(hw->wiphy, "hwsim hw_scan request\n");
@@ -1816,7 +1878,9 @@ static void mac80211_hwsim_cancel_hw_scan(struct ieee80211_hw *hw,
1816 mutex_unlock(&hwsim->mutex); 1878 mutex_unlock(&hwsim->mutex);
1817} 1879}
1818 1880
1819static void mac80211_hwsim_sw_scan(struct ieee80211_hw *hw) 1881static void mac80211_hwsim_sw_scan(struct ieee80211_hw *hw,
1882 struct ieee80211_vif *vif,
1883 const u8 *mac_addr)
1820{ 1884{
1821 struct mac80211_hwsim_data *hwsim = hw->priv; 1885 struct mac80211_hwsim_data *hwsim = hw->priv;
1822 1886
@@ -1828,13 +1892,16 @@ static void mac80211_hwsim_sw_scan(struct ieee80211_hw *hw)
1828 } 1892 }
1829 1893
1830 printk(KERN_DEBUG "hwsim sw_scan request, prepping stuff\n"); 1894 printk(KERN_DEBUG "hwsim sw_scan request, prepping stuff\n");
1895
1896 memcpy(hwsim->scan_addr, mac_addr, ETH_ALEN);
1831 hwsim->scanning = true; 1897 hwsim->scanning = true;
1832 1898
1833out: 1899out:
1834 mutex_unlock(&hwsim->mutex); 1900 mutex_unlock(&hwsim->mutex);
1835} 1901}
1836 1902
1837static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw) 1903static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw,
1904 struct ieee80211_vif *vif)
1838{ 1905{
1839 struct mac80211_hwsim_data *hwsim = hw->priv; 1906 struct mac80211_hwsim_data *hwsim = hw->priv;
1840 1907
@@ -1842,6 +1909,7 @@ static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw)
1842 1909
1843 printk(KERN_DEBUG "hwsim sw_scan_complete\n"); 1910 printk(KERN_DEBUG "hwsim sw_scan_complete\n");
1844 hwsim->scanning = false; 1911 hwsim->scanning = false;
1912 memset(hwsim->scan_addr, 0, ETH_ALEN);
1845 1913
1846 mutex_unlock(&hwsim->mutex); 1914 mutex_unlock(&hwsim->mutex);
1847} 1915}
@@ -2057,36 +2125,26 @@ static void hwsim_mcast_config_msg(struct sk_buff *mcast_skb,
2057 HWSIM_MCGRP_CONFIG, GFP_KERNEL); 2125 HWSIM_MCGRP_CONFIG, GFP_KERNEL);
2058} 2126}
2059 2127
2060static struct sk_buff *build_radio_msg(int cmd, int id, 2128static int append_radio_msg(struct sk_buff *skb, int id,
2061 struct hwsim_new_radio_params *param) 2129 struct hwsim_new_radio_params *param)
2062{ 2130{
2063 struct sk_buff *skb;
2064 void *data;
2065 int ret; 2131 int ret;
2066 2132
2067 skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
2068 if (!skb)
2069 return NULL;
2070
2071 data = genlmsg_put(skb, 0, 0, &hwsim_genl_family, 0, cmd);
2072 if (!data)
2073 goto error;
2074
2075 ret = nla_put_u32(skb, HWSIM_ATTR_RADIO_ID, id); 2133 ret = nla_put_u32(skb, HWSIM_ATTR_RADIO_ID, id);
2076 if (ret < 0) 2134 if (ret < 0)
2077 goto error; 2135 return ret;
2078 2136
2079 if (param->channels) { 2137 if (param->channels) {
2080 ret = nla_put_u32(skb, HWSIM_ATTR_CHANNELS, param->channels); 2138 ret = nla_put_u32(skb, HWSIM_ATTR_CHANNELS, param->channels);
2081 if (ret < 0) 2139 if (ret < 0)
2082 goto error; 2140 return ret;
2083 } 2141 }
2084 2142
2085 if (param->reg_alpha2) { 2143 if (param->reg_alpha2) {
2086 ret = nla_put(skb, HWSIM_ATTR_REG_HINT_ALPHA2, 2, 2144 ret = nla_put(skb, HWSIM_ATTR_REG_HINT_ALPHA2, 2,
2087 param->reg_alpha2); 2145 param->reg_alpha2);
2088 if (ret < 0) 2146 if (ret < 0)
2089 goto error; 2147 return ret;
2090 } 2148 }
2091 2149
2092 if (param->regd) { 2150 if (param->regd) {
@@ -2099,54 +2157,64 @@ static struct sk_buff *build_radio_msg(int cmd, int id,
2099 if (i < ARRAY_SIZE(hwsim_world_regdom_custom)) { 2157 if (i < ARRAY_SIZE(hwsim_world_regdom_custom)) {
2100 ret = nla_put_u32(skb, HWSIM_ATTR_REG_CUSTOM_REG, i); 2158 ret = nla_put_u32(skb, HWSIM_ATTR_REG_CUSTOM_REG, i);
2101 if (ret < 0) 2159 if (ret < 0)
2102 goto error; 2160 return ret;
2103 } 2161 }
2104 } 2162 }
2105 2163
2106 if (param->reg_strict) { 2164 if (param->reg_strict) {
2107 ret = nla_put_flag(skb, HWSIM_ATTR_REG_STRICT_REG); 2165 ret = nla_put_flag(skb, HWSIM_ATTR_REG_STRICT_REG);
2108 if (ret < 0) 2166 if (ret < 0)
2109 goto error; 2167 return ret;
2110 } 2168 }
2111 2169
2112 if (param->p2p_device) { 2170 if (param->p2p_device) {
2113 ret = nla_put_flag(skb, HWSIM_ATTR_SUPPORT_P2P_DEVICE); 2171 ret = nla_put_flag(skb, HWSIM_ATTR_SUPPORT_P2P_DEVICE);
2114 if (ret < 0) 2172 if (ret < 0)
2115 goto error; 2173 return ret;
2116 } 2174 }
2117 2175
2118 if (param->use_chanctx) { 2176 if (param->use_chanctx) {
2119 ret = nla_put_flag(skb, HWSIM_ATTR_USE_CHANCTX); 2177 ret = nla_put_flag(skb, HWSIM_ATTR_USE_CHANCTX);
2120 if (ret < 0) 2178 if (ret < 0)
2121 goto error; 2179 return ret;
2122 } 2180 }
2123 2181
2124 if (param->hwname) { 2182 if (param->hwname) {
2125 ret = nla_put(skb, HWSIM_ATTR_RADIO_NAME, 2183 ret = nla_put(skb, HWSIM_ATTR_RADIO_NAME,
2126 strlen(param->hwname), param->hwname); 2184 strlen(param->hwname), param->hwname);
2127 if (ret < 0) 2185 if (ret < 0)
2128 goto error; 2186 return ret;
2129 } 2187 }
2130 2188
2131 genlmsg_end(skb, data); 2189 return 0;
2132
2133 return skb;
2134
2135error:
2136 nlmsg_free(skb);
2137 return NULL;
2138} 2190}
2139 2191
2140static void hswim_mcast_new_radio(int id, struct genl_info *info, 2192static void hwsim_mcast_new_radio(int id, struct genl_info *info,
2141 struct hwsim_new_radio_params *param) 2193 struct hwsim_new_radio_params *param)
2142{ 2194{
2143 struct sk_buff *mcast_skb; 2195 struct sk_buff *mcast_skb;
2196 void *data;
2144 2197
2145 mcast_skb = build_radio_msg(HWSIM_CMD_NEW_RADIO, id, param); 2198 mcast_skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
2146 if (!mcast_skb) 2199 if (!mcast_skb)
2147 return; 2200 return;
2148 2201
2202 data = genlmsg_put(mcast_skb, 0, 0, &hwsim_genl_family, 0,
2203 HWSIM_CMD_NEW_RADIO);
2204 if (!data)
2205 goto out_err;
2206
2207 if (append_radio_msg(mcast_skb, id, param) < 0)
2208 goto out_err;
2209
2210 genlmsg_end(mcast_skb, data);
2211
2149 hwsim_mcast_config_msg(mcast_skb, info); 2212 hwsim_mcast_config_msg(mcast_skb, info);
2213 return;
2214
2215out_err:
2216 genlmsg_cancel(mcast_skb, data);
2217 nlmsg_free(mcast_skb);
2150} 2218}
2151 2219
2152static int mac80211_hwsim_new_radio(struct genl_info *info, 2220static int mac80211_hwsim_new_radio(struct genl_info *info,
@@ -2267,7 +2335,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
2267 hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | 2335 hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR |
2268 NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | 2336 NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
2269 NL80211_FEATURE_STATIC_SMPS | 2337 NL80211_FEATURE_STATIC_SMPS |
2270 NL80211_FEATURE_DYNAMIC_SMPS; 2338 NL80211_FEATURE_DYNAMIC_SMPS |
2339 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
2271 2340
2272 /* ask mac80211 to reserve space for magic */ 2341 /* ask mac80211 to reserve space for magic */
2273 hw->vif_data_size = sizeof(struct hwsim_vif_priv); 2342 hw->vif_data_size = sizeof(struct hwsim_vif_priv);
@@ -2353,6 +2422,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
2353 if (param->reg_strict) 2422 if (param->reg_strict)
2354 hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 2423 hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
2355 if (param->regd) { 2424 if (param->regd) {
2425 data->regd = param->regd;
2356 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; 2426 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
2357 wiphy_apply_custom_regulatory(hw->wiphy, param->regd); 2427 wiphy_apply_custom_regulatory(hw->wiphy, param->regd);
2358 /* give the regulatory workqueue a chance to run */ 2428 /* give the regulatory workqueue a chance to run */
@@ -2371,8 +2441,11 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
2371 2441
2372 wiphy_debug(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr); 2442 wiphy_debug(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr);
2373 2443
2374 if (param->reg_alpha2) 2444 if (param->reg_alpha2) {
2445 data->alpha2[0] = param->reg_alpha2[0];
2446 data->alpha2[1] = param->reg_alpha2[1];
2375 regulatory_hint(hw->wiphy, param->reg_alpha2); 2447 regulatory_hint(hw->wiphy, param->reg_alpha2);
2448 }
2376 2449
2377 data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir); 2450 data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir);
2378 debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps); 2451 debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps);
@@ -2392,7 +2465,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
2392 spin_unlock_bh(&hwsim_radio_lock); 2465 spin_unlock_bh(&hwsim_radio_lock);
2393 2466
2394 if (idx > 0) 2467 if (idx > 0)
2395 hswim_mcast_new_radio(idx, info, param); 2468 hwsim_mcast_new_radio(idx, info, param);
2396 2469
2397 return idx; 2470 return idx;
2398 2471
@@ -2426,12 +2499,10 @@ static void hwsim_mcast_del_radio(int id, const char *hwname,
2426 if (ret < 0) 2499 if (ret < 0)
2427 goto error; 2500 goto error;
2428 2501
2429 if (hwname) { 2502 ret = nla_put(skb, HWSIM_ATTR_RADIO_NAME, strlen(hwname),
2430 ret = nla_put(skb, HWSIM_ATTR_RADIO_NAME, strlen(hwname), 2503 hwname);
2431 hwname); 2504 if (ret < 0)
2432 if (ret < 0) 2505 goto error;
2433 goto error;
2434 }
2435 2506
2436 genlmsg_end(skb, data); 2507 genlmsg_end(skb, data);
2437 2508
@@ -2455,6 +2526,44 @@ static void mac80211_hwsim_del_radio(struct mac80211_hwsim_data *data,
2455 ieee80211_free_hw(data->hw); 2526 ieee80211_free_hw(data->hw);
2456} 2527}
2457 2528
2529static int mac80211_hwsim_get_radio(struct sk_buff *skb,
2530 struct mac80211_hwsim_data *data,
2531 u32 portid, u32 seq,
2532 struct netlink_callback *cb, int flags)
2533{
2534 void *hdr;
2535 struct hwsim_new_radio_params param = { };
2536 int res = -EMSGSIZE;
2537
2538 hdr = genlmsg_put(skb, portid, seq, &hwsim_genl_family, flags,
2539 HWSIM_CMD_GET_RADIO);
2540 if (!hdr)
2541 return -EMSGSIZE;
2542
2543 if (cb)
2544 genl_dump_check_consistent(cb, hdr, &hwsim_genl_family);
2545
2546 param.reg_alpha2 = data->alpha2;
2547 param.reg_strict = !!(data->hw->wiphy->regulatory_flags &
2548 REGULATORY_STRICT_REG);
2549 param.p2p_device = !!(data->hw->wiphy->interface_modes &
2550 BIT(NL80211_IFTYPE_P2P_DEVICE));
2551 param.use_chanctx = data->use_chanctx;
2552 param.regd = data->regd;
2553 param.channels = data->channels;
2554 param.hwname = wiphy_name(data->hw->wiphy);
2555
2556 res = append_radio_msg(skb, data->idx, &param);
2557 if (res < 0)
2558 goto out_err;
2559
2560 return genlmsg_end(skb, hdr);
2561
2562out_err:
2563 genlmsg_cancel(skb, hdr);
2564 return res;
2565}
2566
2458static void mac80211_hwsim_free(void) 2567static void mac80211_hwsim_free(void)
2459{ 2568{
2460 struct mac80211_hwsim_data *data; 2569 struct mac80211_hwsim_data *data;
@@ -2465,7 +2574,8 @@ static void mac80211_hwsim_free(void)
2465 list))) { 2574 list))) {
2466 list_del(&data->list); 2575 list_del(&data->list);
2467 spin_unlock_bh(&hwsim_radio_lock); 2576 spin_unlock_bh(&hwsim_radio_lock);
2468 mac80211_hwsim_del_radio(data, NULL, NULL); 2577 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy),
2578 NULL);
2469 spin_lock_bh(&hwsim_radio_lock); 2579 spin_lock_bh(&hwsim_radio_lock);
2470 } 2580 }
2471 spin_unlock_bh(&hwsim_radio_lock); 2581 spin_unlock_bh(&hwsim_radio_lock);
@@ -2744,14 +2854,14 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
2744 if (data->idx != idx) 2854 if (data->idx != idx)
2745 continue; 2855 continue;
2746 } else { 2856 } else {
2747 if (hwname && 2857 if (strcmp(hwname, wiphy_name(data->hw->wiphy)))
2748 strcmp(hwname, wiphy_name(data->hw->wiphy)))
2749 continue; 2858 continue;
2750 } 2859 }
2751 2860
2752 list_del(&data->list); 2861 list_del(&data->list);
2753 spin_unlock_bh(&hwsim_radio_lock); 2862 spin_unlock_bh(&hwsim_radio_lock);
2754 mac80211_hwsim_del_radio(data, hwname, info); 2863 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy),
2864 info);
2755 return 0; 2865 return 0;
2756 } 2866 }
2757 spin_unlock_bh(&hwsim_radio_lock); 2867 spin_unlock_bh(&hwsim_radio_lock);
@@ -2759,6 +2869,77 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
2759 return -ENODEV; 2869 return -ENODEV;
2760} 2870}
2761 2871
2872static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info)
2873{
2874 struct mac80211_hwsim_data *data;
2875 struct sk_buff *skb;
2876 int idx, res = -ENODEV;
2877
2878 if (!info->attrs[HWSIM_ATTR_RADIO_ID])
2879 return -EINVAL;
2880 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
2881
2882 spin_lock_bh(&hwsim_radio_lock);
2883 list_for_each_entry(data, &hwsim_radios, list) {
2884 if (data->idx != idx)
2885 continue;
2886
2887 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2888 if (!skb) {
2889 res = -ENOMEM;
2890 goto out_err;
2891 }
2892
2893 res = mac80211_hwsim_get_radio(skb, data, info->snd_portid,
2894 info->snd_seq, NULL, 0);
2895 if (res < 0) {
2896 nlmsg_free(skb);
2897 goto out_err;
2898 }
2899
2900 genlmsg_reply(skb, info);
2901 break;
2902 }
2903
2904out_err:
2905 spin_unlock_bh(&hwsim_radio_lock);
2906
2907 return res;
2908}
2909
2910static int hwsim_dump_radio_nl(struct sk_buff *skb,
2911 struct netlink_callback *cb)
2912{
2913 int idx = cb->args[0];
2914 struct mac80211_hwsim_data *data = NULL;
2915 int res;
2916
2917 spin_lock_bh(&hwsim_radio_lock);
2918
2919 if (idx == hwsim_radio_idx)
2920 goto done;
2921
2922 list_for_each_entry(data, &hwsim_radios, list) {
2923 if (data->idx < idx)
2924 continue;
2925
2926 res = mac80211_hwsim_get_radio(skb, data,
2927 NETLINK_CB(cb->skb).portid,
2928 cb->nlh->nlmsg_seq, cb,
2929 NLM_F_MULTI);
2930 if (res < 0)
2931 break;
2932
2933 idx = data->idx + 1;
2934 }
2935
2936 cb->args[0] = idx;
2937
2938done:
2939 spin_unlock_bh(&hwsim_radio_lock);
2940 return skb->len;
2941}
2942
2762/* Generic Netlink operations array */ 2943/* Generic Netlink operations array */
2763static const struct genl_ops hwsim_ops[] = { 2944static const struct genl_ops hwsim_ops[] = {
2764 { 2945 {
@@ -2789,6 +2970,12 @@ static const struct genl_ops hwsim_ops[] = {
2789 .doit = hwsim_del_radio_nl, 2970 .doit = hwsim_del_radio_nl,
2790 .flags = GENL_ADMIN_PERM, 2971 .flags = GENL_ADMIN_PERM,
2791 }, 2972 },
2973 {
2974 .cmd = HWSIM_CMD_GET_RADIO,
2975 .policy = hwsim_genl_policy,
2976 .doit = hwsim_get_radio_nl,
2977 .dumpit = hwsim_dump_radio_nl,
2978 },
2792}; 2979};
2793 2980
2794static void destroy_radio(struct work_struct *work) 2981static void destroy_radio(struct work_struct *work)
@@ -2796,7 +2983,7 @@ static void destroy_radio(struct work_struct *work)
2796 struct mac80211_hwsim_data *data = 2983 struct mac80211_hwsim_data *data =
2797 container_of(work, struct mac80211_hwsim_data, destroy_work); 2984 container_of(work, struct mac80211_hwsim_data, destroy_work);
2798 2985
2799 mac80211_hwsim_del_radio(data, NULL, NULL); 2986 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), NULL);
2800} 2987}
2801 2988
2802static void remove_user_radios(u32 portid) 2989static void remove_user_radios(u32 portid)
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index f08debdd639b..66e1c73bd507 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -69,6 +69,8 @@ enum hwsim_tx_control_flags {
69 * returns the radio ID (>= 0) or negative on errors, if successful 69 * returns the radio ID (>= 0) or negative on errors, if successful
70 * then multicast the result 70 * then multicast the result
71 * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted 71 * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
72 * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
73 * %HWSIM_ATTR_RADIO_ID
72 * @__HWSIM_CMD_MAX: enum limit 74 * @__HWSIM_CMD_MAX: enum limit
73 */ 75 */
74enum { 76enum {
@@ -78,6 +80,7 @@ enum {
78 HWSIM_CMD_TX_INFO_FRAME, 80 HWSIM_CMD_TX_INFO_FRAME,
79 HWSIM_CMD_NEW_RADIO, 81 HWSIM_CMD_NEW_RADIO,
80 HWSIM_CMD_DEL_RADIO, 82 HWSIM_CMD_DEL_RADIO,
83 HWSIM_CMD_GET_RADIO,
81 __HWSIM_CMD_MAX, 84 __HWSIM_CMD_MAX,
82}; 85};
83#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1) 86#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
diff --git a/drivers/net/wireless/mwifiex/11n.h b/drivers/net/wireless/mwifiex/11n.h
index 2ee268b632be..f275675cdbd3 100644
--- a/drivers/net/wireless/mwifiex/11n.h
+++ b/drivers/net/wireless/mwifiex/11n.h
@@ -84,6 +84,8 @@ mwifiex_is_amsdu_in_ampdu_allowed(struct mwifiex_private *priv,
84{ 84{
85 struct mwifiex_tx_ba_stream_tbl *tx_tbl; 85 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
86 86
87 if (is_broadcast_ether_addr(ptr->ra))
88 return false;
87 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra); 89 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
88 if (tx_tbl) 90 if (tx_tbl)
89 return tx_tbl->amsdu; 91 return tx_tbl->amsdu;
@@ -96,6 +98,8 @@ static inline u8
96mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, 98mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
97 struct mwifiex_ra_list_tbl *ptr, int tid) 99 struct mwifiex_ra_list_tbl *ptr, int tid)
98{ 100{
101 if (is_broadcast_ether_addr(ptr->ra))
102 return false;
99 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { 103 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
100 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid); 104 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
101 } else { 105 } else {
diff --git a/drivers/net/wireless/mwifiex/Kconfig b/drivers/net/wireless/mwifiex/Kconfig
index e70d0df9b0da..aa01c9bc77f9 100644
--- a/drivers/net/wireless/mwifiex/Kconfig
+++ b/drivers/net/wireless/mwifiex/Kconfig
@@ -31,7 +31,7 @@ config MWIFIEX_PCIE
31 mwifiex_pcie. 31 mwifiex_pcie.
32 32
33config MWIFIEX_USB 33config MWIFIEX_USB
34 tristate "Marvell WiFi-Ex Driver for USB8797/8897" 34 tristate "Marvell WiFi-Ex Driver for USB8766/8797/8897"
35 depends on MWIFIEX && USB 35 depends on MWIFIEX && USB
36 select FW_LOADER 36 select FW_LOADER
37 ---help--- 37 ---help---
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index f63abfd8acd7..17f0ee02d6e7 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1806,6 +1806,10 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
1806 dev_dbg(priv->adapter->dev, 1806 dev_dbg(priv->adapter->dev,
1807 "info: associated to bssid %pM successfully\n", 1807 "info: associated to bssid %pM successfully\n",
1808 priv->cfg_bssid); 1808 priv->cfg_bssid);
1809 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
1810 priv->adapter->auto_tdls &&
1811 priv->bss_type == MWIFIEX_BSS_TYPE_STA)
1812 mwifiex_setup_auto_tdls_timer(priv);
1809 } else { 1813 } else {
1810 dev_dbg(priv->adapter->dev, 1814 dev_dbg(priv->adapter->dev,
1811 "info: association to bssid %pM failed\n", 1815 "info: association to bssid %pM failed\n",
@@ -2677,11 +2681,13 @@ mwifiex_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2677 dev_dbg(priv->adapter->dev, 2681 dev_dbg(priv->adapter->dev,
2678 "Send TDLS Setup Request to %pM status_code=%d\n", peer, 2682 "Send TDLS Setup Request to %pM status_code=%d\n", peer,
2679 status_code); 2683 status_code);
2684 mwifiex_add_auto_tdls_peer(priv, peer);
2680 ret = mwifiex_send_tdls_data_frame(priv, peer, action_code, 2685 ret = mwifiex_send_tdls_data_frame(priv, peer, action_code,
2681 dialog_token, status_code, 2686 dialog_token, status_code,
2682 extra_ies, extra_ies_len); 2687 extra_ies, extra_ies_len);
2683 break; 2688 break;
2684 case WLAN_TDLS_SETUP_RESPONSE: 2689 case WLAN_TDLS_SETUP_RESPONSE:
2690 mwifiex_add_auto_tdls_peer(priv, peer);
2685 dev_dbg(priv->adapter->dev, 2691 dev_dbg(priv->adapter->dev,
2686 "Send TDLS Setup Response to %pM status_code=%d\n", 2692 "Send TDLS Setup Response to %pM status_code=%d\n",
2687 peer, status_code); 2693 peer, status_code);
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index f53e5b50d3d8..fc0b1ed80a6a 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -85,6 +85,11 @@
85#define MWIFIEX_TDLS_CREATE_LINK 0x02 85#define MWIFIEX_TDLS_CREATE_LINK 0x02
86#define MWIFIEX_TDLS_CONFIG_LINK 0x03 86#define MWIFIEX_TDLS_CONFIG_LINK 0x03
87 87
88#define MWIFIEX_TDLS_RSSI_HIGH 50
89#define MWIFIEX_TDLS_RSSI_LOW 55
90#define MWIFIEX_TDLS_MAX_FAIL_COUNT 4
91#define MWIFIEX_AUTO_TDLS_IDLE_TIME 10
92
88enum mwifiex_bss_type { 93enum mwifiex_bss_type {
89 MWIFIEX_BSS_TYPE_STA = 0, 94 MWIFIEX_BSS_TYPE_STA = 0,
90 MWIFIEX_BSS_TYPE_UAP = 1, 95 MWIFIEX_BSS_TYPE_UAP = 1,
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
index 7f922a882c13..e095f371545a 100644
--- a/drivers/net/wireless/mwifiex/fw.h
+++ b/drivers/net/wireless/mwifiex/fw.h
@@ -584,6 +584,7 @@ struct rxpd {
584 * [Bit 7] Reserved 584 * [Bit 7] Reserved
585 */ 585 */
586 u8 ht_info; 586 u8 ht_info;
587 u8 reserved[3];
587 u8 flags; 588 u8 flags;
588} __packed; 589} __packed;
589 590
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c
index 580aa45ec4bc..cc15ab81aa66 100644
--- a/drivers/net/wireless/mwifiex/init.c
+++ b/drivers/net/wireless/mwifiex/init.c
@@ -137,6 +137,7 @@ int mwifiex_init_priv(struct mwifiex_private *priv)
137 priv->csa_expire_time = 0; 137 priv->csa_expire_time = 0;
138 priv->del_list_idx = 0; 138 priv->del_list_idx = 0;
139 priv->hs2_enabled = false; 139 priv->hs2_enabled = false;
140 priv->check_tdls_tx = false;
140 memcpy(priv->tos_to_tid_inv, tos_to_tid_inv, MAX_NUM_TID); 141 memcpy(priv->tos_to_tid_inv, tos_to_tid_inv, MAX_NUM_TID);
141 142
142 return mwifiex_add_bss_prio_tbl(priv); 143 return mwifiex_add_bss_prio_tbl(priv);
@@ -366,6 +367,7 @@ static void mwifiex_free_lock_list(struct mwifiex_adapter *adapter)
366 list_del(&priv->tx_ba_stream_tbl_ptr); 367 list_del(&priv->tx_ba_stream_tbl_ptr);
367 list_del(&priv->rx_reorder_tbl_ptr); 368 list_del(&priv->rx_reorder_tbl_ptr);
368 list_del(&priv->sta_list); 369 list_del(&priv->sta_list);
370 list_del(&priv->auto_tdls_list);
369 } 371 }
370 } 372 }
371} 373}
@@ -434,6 +436,7 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
434 spin_lock_init(&priv->wmm.ra_list_spinlock); 436 spin_lock_init(&priv->wmm.ra_list_spinlock);
435 spin_lock_init(&priv->curr_bcn_buf_lock); 437 spin_lock_init(&priv->curr_bcn_buf_lock);
436 spin_lock_init(&priv->sta_list_spinlock); 438 spin_lock_init(&priv->sta_list_spinlock);
439 spin_lock_init(&priv->auto_tdls_lock);
437 } 440 }
438 } 441 }
439 442
@@ -449,7 +452,6 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
449 spin_lock_init(&adapter->scan_pending_q_lock); 452 spin_lock_init(&adapter->scan_pending_q_lock);
450 spin_lock_init(&adapter->rx_proc_lock); 453 spin_lock_init(&adapter->rx_proc_lock);
451 454
452 skb_queue_head_init(&adapter->usb_rx_data_q);
453 skb_queue_head_init(&adapter->rx_data_q); 455 skb_queue_head_init(&adapter->rx_data_q);
454 456
455 for (i = 0; i < adapter->priv_num; ++i) { 457 for (i = 0; i < adapter->priv_num; ++i) {
@@ -466,6 +468,7 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
466 INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr); 468 INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr);
467 INIT_LIST_HEAD(&priv->rx_reorder_tbl_ptr); 469 INIT_LIST_HEAD(&priv->rx_reorder_tbl_ptr);
468 INIT_LIST_HEAD(&priv->sta_list); 470 INIT_LIST_HEAD(&priv->sta_list);
471 INIT_LIST_HEAD(&priv->auto_tdls_list);
469 skb_queue_head_init(&priv->tdls_txq); 472 skb_queue_head_init(&priv->tdls_txq);
470 473
471 spin_lock_init(&priv->tx_ba_stream_tbl_lock); 474 spin_lock_init(&priv->tx_ba_stream_tbl_lock);
@@ -646,6 +649,7 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
646 if (adapter->priv[i]) { 649 if (adapter->priv[i]) {
647 priv = adapter->priv[i]; 650 priv = adapter->priv[i];
648 651
652 mwifiex_clean_auto_tdls(priv);
649 mwifiex_clean_txrx(priv); 653 mwifiex_clean_txrx(priv);
650 mwifiex_delete_bss_prio_tbl(priv); 654 mwifiex_delete_bss_prio_tbl(priv);
651 } 655 }
@@ -668,19 +672,6 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
668 672
669 spin_lock(&adapter->mwifiex_lock); 673 spin_lock(&adapter->mwifiex_lock);
670 674
671 if (adapter->if_ops.data_complete) {
672 while ((skb = skb_dequeue(&adapter->usb_rx_data_q))) {
673 struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
674
675 priv = adapter->priv[rx_info->bss_num];
676 if (priv)
677 priv->stats.rx_dropped++;
678
679 dev_kfree_skb_any(skb);
680 adapter->if_ops.data_complete(adapter);
681 }
682 }
683
684 mwifiex_adapter_cleanup(adapter); 675 mwifiex_adapter_cleanup(adapter);
685 676
686 spin_unlock(&adapter->mwifiex_lock); 677 spin_unlock(&adapter->mwifiex_lock);
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
index 8d6c25908b6d..411a6c2f4aca 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -880,9 +880,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
880 880
881 /* Set Capability info */ 881 /* Set Capability info */
882 bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_IBSS; 882 bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_IBSS;
883 tmp_cap = le16_to_cpu(adhoc_start->cap_info_bitmap); 883 tmp_cap = WLAN_CAPABILITY_IBSS;
884 tmp_cap &= ~WLAN_CAPABILITY_ESS;
885 tmp_cap |= WLAN_CAPABILITY_IBSS;
886 884
887 /* Set up privacy in bss_desc */ 885 /* Set up privacy in bss_desc */
888 if (priv->sec_info.encryption_mode) { 886 if (priv->sec_info.encryption_mode) {
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index f26420dbab6f..0e50120eb807 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -28,6 +28,11 @@ const char driver_version[] = "mwifiex " VERSION " (%s) ";
28static char *cal_data_cfg; 28static char *cal_data_cfg;
29module_param(cal_data_cfg, charp, 0); 29module_param(cal_data_cfg, charp, 0);
30 30
31static unsigned short driver_mode;
32module_param(driver_mode, ushort, 0);
33MODULE_PARM_DESC(driver_mode,
34 "station=0x1(default), ap-sta=0x3, station-p2p=0x5, ap-sta-p2p=0x7");
35
31/* 36/*
32 * This function registers the device and performs all the necessary 37 * This function registers the device and performs all the necessary
33 * initializations. 38 * initializations.
@@ -146,6 +151,8 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
146 atomic_dec(&adapter->rx_pending); 151 atomic_dec(&adapter->rx_pending);
147 if (adapter->delay_main_work && 152 if (adapter->delay_main_work &&
148 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) { 153 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) {
154 if (adapter->if_ops.submit_rem_rx_urbs)
155 adapter->if_ops.submit_rem_rx_urbs(adapter);
149 adapter->delay_main_work = false; 156 adapter->delay_main_work = false;
150 queue_work(adapter->workqueue, &adapter->main_work); 157 queue_work(adapter->workqueue, &adapter->main_work);
151 } 158 }
@@ -178,7 +185,6 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
178{ 185{
179 int ret = 0; 186 int ret = 0;
180 unsigned long flags; 187 unsigned long flags;
181 struct sk_buff *skb;
182 188
183 spin_lock_irqsave(&adapter->main_proc_lock, flags); 189 spin_lock_irqsave(&adapter->main_proc_lock, flags);
184 190
@@ -253,11 +259,6 @@ process_start:
253 } 259 }
254 } 260 }
255 261
256 /* Check Rx data for USB */
257 if (adapter->iface_type == MWIFIEX_USB)
258 while ((skb = skb_dequeue(&adapter->usb_rx_data_q)))
259 mwifiex_handle_rx_packet(adapter, skb);
260
261 /* Check for event */ 262 /* Check for event */
262 if (adapter->event_received) { 263 if (adapter->event_received) {
263 adapter->event_received = false; 264 adapter->event_received = false;
@@ -453,6 +454,11 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
453 goto err_init_fw; 454 goto err_init_fw;
454 } 455 }
455 456
457 if (driver_mode) {
458 driver_mode &= MWIFIEX_DRIVER_MODE_BITMASK;
459 driver_mode |= MWIFIEX_DRIVER_MODE_STA;
460 }
461
456 rtnl_lock(); 462 rtnl_lock();
457 /* Create station interface by default */ 463 /* Create station interface by default */
458 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", 464 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d",
@@ -462,6 +468,28 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
462 rtnl_unlock(); 468 rtnl_unlock();
463 goto err_add_intf; 469 goto err_add_intf;
464 } 470 }
471
472 if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) {
473 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d",
474 NL80211_IFTYPE_AP, NULL, NULL);
475 if (IS_ERR(wdev)) {
476 dev_err(adapter->dev, "cannot create AP interface\n");
477 rtnl_unlock();
478 goto err_add_intf;
479 }
480 }
481
482 if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) {
483 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d",
484 NL80211_IFTYPE_P2P_CLIENT, NULL,
485 NULL);
486 if (IS_ERR(wdev)) {
487 dev_err(adapter->dev,
488 "cannot create p2p client interface\n");
489 rtnl_unlock();
490 goto err_add_intf;
491 }
492 }
465 rtnl_unlock(); 493 rtnl_unlock();
466 494
467 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); 495 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
@@ -634,6 +662,13 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
634 */ 662 */
635 __net_timestamp(skb); 663 __net_timestamp(skb);
636 664
665 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
666 priv->bss_type == MWIFIEX_BSS_TYPE_STA &&
667 !ether_addr_equal_unaligned(priv->cfg_bssid, skb->data)) {
668 if (priv->adapter->auto_tdls && priv->check_tdls_tx)
669 mwifiex_tdls_check_tx(priv, skb);
670 }
671
637 mwifiex_queue_tx_pkt(priv, skb); 672 mwifiex_queue_tx_pkt(priv, skb);
638 673
639 return 0; 674 return 0;
@@ -864,7 +899,7 @@ mwifiex_add_card(void *card, struct semaphore *sem,
864 adapter->cmd_wait_q.status = 0; 899 adapter->cmd_wait_q.status = 0;
865 adapter->scan_wait_q_woken = false; 900 adapter->scan_wait_q_woken = false;
866 901
867 if (num_possible_cpus() > 1) { 902 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) {
868 adapter->rx_work_enabled = true; 903 adapter->rx_work_enabled = true;
869 pr_notice("rx work enabled, cpus %d\n", num_possible_cpus()); 904 pr_notice("rx work enabled, cpus %d\n", num_possible_cpus());
870 } 905 }
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index cb393195eee1..5a690d5210f0 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -48,6 +48,11 @@ enum {
48 MWIFIEX_SYNC_CMD 48 MWIFIEX_SYNC_CMD
49}; 49};
50 50
51#define MWIFIEX_DRIVER_MODE_STA BIT(0)
52#define MWIFIEX_DRIVER_MODE_UAP BIT(1)
53#define MWIFIEX_DRIVER_MODE_P2P BIT(2)
54#define MWIFIEX_DRIVER_MODE_BITMASK (BIT(0) | BIT(1) | BIT(2))
55
51#define MWIFIEX_MAX_AP 64 56#define MWIFIEX_MAX_AP 64
52 57
53#define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ) 58#define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
@@ -106,10 +111,7 @@ enum {
106 */ 111 */
107#define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \ 112#define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
108 adapter->event_received || \ 113 adapter->event_received || \
109 ((adapter->iface_type != MWIFIEX_USB) && \ 114 adapter->data_received)
110 adapter->data_received) || \
111 ((adapter->iface_type == MWIFIEX_USB) && \
112 !skb_queue_empty(&adapter->usb_rx_data_q)))
113 115
114#define MWIFIEX_TYPE_CMD 1 116#define MWIFIEX_TYPE_CMD 1
115#define MWIFIEX_TYPE_DATA 0 117#define MWIFIEX_TYPE_DATA 0
@@ -504,8 +506,11 @@ struct mwifiex_private {
504 struct mwifiex_wmm_desc wmm; 506 struct mwifiex_wmm_desc wmm;
505 atomic_t wmm_tx_pending[IEEE80211_NUM_ACS]; 507 atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
506 struct list_head sta_list; 508 struct list_head sta_list;
507 /* spin lock for associated station list */ 509 /* spin lock for associated station/TDLS peers list */
508 spinlock_t sta_list_spinlock; 510 spinlock_t sta_list_spinlock;
511 struct list_head auto_tdls_list;
512 /* spin lock for auto TDLS peer list */
513 spinlock_t auto_tdls_lock;
509 struct list_head tx_ba_stream_tbl_ptr; 514 struct list_head tx_ba_stream_tbl_ptr;
510 /* spin lock for tx_ba_stream_tbl_ptr queue */ 515 /* spin lock for tx_ba_stream_tbl_ptr queue */
511 spinlock_t tx_ba_stream_tbl_lock; 516 spinlock_t tx_ba_stream_tbl_lock;
@@ -570,6 +575,9 @@ struct mwifiex_private {
570 bool hs2_enabled; 575 bool hs2_enabled;
571 struct station_parameters *sta_params; 576 struct station_parameters *sta_params;
572 struct sk_buff_head tdls_txq; 577 struct sk_buff_head tdls_txq;
578 u8 check_tdls_tx;
579 struct timer_list auto_tdls_timer;
580 bool auto_tdls_timer_active;
573}; 581};
574 582
575enum mwifiex_ba_status { 583enum mwifiex_ba_status {
@@ -670,6 +678,17 @@ struct mwifiex_sta_node {
670 struct mwifiex_tdls_capab tdls_cap; 678 struct mwifiex_tdls_capab tdls_cap;
671}; 679};
672 680
681struct mwifiex_auto_tdls_peer {
682 struct list_head list;
683 u8 mac_addr[ETH_ALEN];
684 u8 tdls_status;
685 int rssi;
686 long rssi_jiffies;
687 u8 failure_count;
688 u8 do_discover;
689 u8 do_setup;
690};
691
673struct mwifiex_if_ops { 692struct mwifiex_if_ops {
674 int (*init_if) (struct mwifiex_adapter *); 693 int (*init_if) (struct mwifiex_adapter *);
675 void (*cleanup_if) (struct mwifiex_adapter *); 694 void (*cleanup_if) (struct mwifiex_adapter *);
@@ -690,13 +709,13 @@ struct mwifiex_if_ops {
690 void (*cleanup_mpa_buf) (struct mwifiex_adapter *); 709 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
691 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *); 710 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
692 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *); 711 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
693 int (*data_complete) (struct mwifiex_adapter *);
694 int (*init_fw_port) (struct mwifiex_adapter *); 712 int (*init_fw_port) (struct mwifiex_adapter *);
695 int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *); 713 int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
696 void (*card_reset) (struct mwifiex_adapter *); 714 void (*card_reset) (struct mwifiex_adapter *);
697 void (*fw_dump)(struct mwifiex_adapter *); 715 void (*fw_dump)(struct mwifiex_adapter *);
698 int (*clean_pcie_ring) (struct mwifiex_adapter *adapter); 716 int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
699 void (*iface_work)(struct work_struct *work); 717 void (*iface_work)(struct work_struct *work);
718 void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
700}; 719};
701 720
702struct mwifiex_adapter { 721struct mwifiex_adapter {
@@ -767,7 +786,6 @@ struct mwifiex_adapter {
767 spinlock_t scan_pending_q_lock; 786 spinlock_t scan_pending_q_lock;
768 /* spin lock for RX processing routine */ 787 /* spin lock for RX processing routine */
769 spinlock_t rx_proc_lock; 788 spinlock_t rx_proc_lock;
770 struct sk_buff_head usb_rx_data_q;
771 u32 scan_processing; 789 u32 scan_processing;
772 u16 region_code; 790 u16 region_code;
773 struct mwifiex_802_11d_domain_reg domain_reg; 791 struct mwifiex_802_11d_domain_reg domain_reg;
@@ -848,6 +866,7 @@ struct mwifiex_adapter {
848 struct mwifiex_chan_stats *chan_stats; 866 struct mwifiex_chan_stats *chan_stats;
849 u32 num_in_chan_stats; 867 u32 num_in_chan_stats;
850 int survey_idx; 868 int survey_idx;
869 bool auto_tdls;
851}; 870};
852 871
853int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); 872int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
@@ -1305,6 +1324,17 @@ u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1305 u32 pri_chan, u8 chan_bw); 1324 u32 pri_chan, u8 chan_bw);
1306int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter); 1325int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
1307 1326
1327int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1328void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1329void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1330 const u8 *mac, u8 link_status);
1331void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1332 u8 *mac, s8 snr, s8 nflr);
1333void mwifiex_check_auto_tdls(unsigned long context);
1334void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1335void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1336void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1337
1308#ifdef CONFIG_DEBUG_FS 1338#ifdef CONFIG_DEBUG_FS
1309void mwifiex_debugfs_init(void); 1339void mwifiex_debugfs_init(void);
1310void mwifiex_debugfs_remove(void); 1340void mwifiex_debugfs_remove(void);
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index b25766b43b9f..933dae137850 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -106,6 +106,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
106 card->mp_tx_agg_buf_size = data->mp_tx_agg_buf_size; 106 card->mp_tx_agg_buf_size = data->mp_tx_agg_buf_size;
107 card->mp_rx_agg_buf_size = data->mp_rx_agg_buf_size; 107 card->mp_rx_agg_buf_size = data->mp_rx_agg_buf_size;
108 card->supports_fw_dump = data->supports_fw_dump; 108 card->supports_fw_dump = data->supports_fw_dump;
109 card->auto_tdls = data->auto_tdls;
109 } 110 }
110 111
111 sdio_claim_host(func); 112 sdio_claim_host(func);
@@ -1880,6 +1881,7 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
1880 return -1; 1881 return -1;
1881 } 1882 }
1882 1883
1884 adapter->auto_tdls = card->auto_tdls;
1883 return ret; 1885 return ret;
1884} 1886}
1885 1887
diff --git a/drivers/net/wireless/mwifiex/sdio.h b/drivers/net/wireless/mwifiex/sdio.h
index 20cd9adc98d3..54c07156dd78 100644
--- a/drivers/net/wireless/mwifiex/sdio.h
+++ b/drivers/net/wireless/mwifiex/sdio.h
@@ -246,6 +246,7 @@ struct sdio_mmc_card {
246 u8 curr_wr_port; 246 u8 curr_wr_port;
247 247
248 u8 *mp_regs; 248 u8 *mp_regs;
249 u8 auto_tdls;
249 250
250 struct mwifiex_sdio_mpa_tx mpa_tx; 251 struct mwifiex_sdio_mpa_tx mpa_tx;
251 struct mwifiex_sdio_mpa_rx mpa_rx; 252 struct mwifiex_sdio_mpa_rx mpa_rx;
@@ -262,6 +263,7 @@ struct mwifiex_sdio_device {
262 u16 tx_buf_size; 263 u16 tx_buf_size;
263 u32 mp_tx_agg_buf_size; 264 u32 mp_tx_agg_buf_size;
264 u32 mp_rx_agg_buf_size; 265 u32 mp_rx_agg_buf_size;
266 u8 auto_tdls;
265}; 267};
266 268
267static const struct mwifiex_sdio_card_reg mwifiex_reg_sd87xx = { 269static const struct mwifiex_sdio_card_reg mwifiex_reg_sd87xx = {
@@ -387,6 +389,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8786 = {
387 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 389 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
388 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 390 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
389 .supports_fw_dump = false, 391 .supports_fw_dump = false,
392 .auto_tdls = false,
390}; 393};
391 394
392static const struct mwifiex_sdio_device mwifiex_sdio_sd8787 = { 395static const struct mwifiex_sdio_device mwifiex_sdio_sd8787 = {
@@ -400,6 +403,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8787 = {
400 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 403 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
401 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 404 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
402 .supports_fw_dump = false, 405 .supports_fw_dump = false,
406 .auto_tdls = false,
403}; 407};
404 408
405static const struct mwifiex_sdio_device mwifiex_sdio_sd8797 = { 409static const struct mwifiex_sdio_device mwifiex_sdio_sd8797 = {
@@ -413,6 +417,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8797 = {
413 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 417 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
414 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K, 418 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
415 .supports_fw_dump = false, 419 .supports_fw_dump = false,
420 .auto_tdls = false,
416}; 421};
417 422
418static const struct mwifiex_sdio_device mwifiex_sdio_sd8897 = { 423static const struct mwifiex_sdio_device mwifiex_sdio_sd8897 = {
@@ -426,6 +431,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8897 = {
426 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K, 431 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
427 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K, 432 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
428 .supports_fw_dump = true, 433 .supports_fw_dump = true,
434 .auto_tdls = false,
429}; 435};
430 436
431static const struct mwifiex_sdio_device mwifiex_sdio_sd8887 = { 437static const struct mwifiex_sdio_device mwifiex_sdio_sd8887 = {
@@ -439,6 +445,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8887 = {
439 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K, 445 .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
440 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K, 446 .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
441 .supports_fw_dump = false, 447 .supports_fw_dump = false,
448 .auto_tdls = true,
442}; 449};
443 450
444/* 451/*
diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c
index f1c240eca0cd..204ecc8faa5b 100644
--- a/drivers/net/wireless/mwifiex/sta_event.c
+++ b/drivers/net/wireless/mwifiex/sta_event.c
@@ -55,9 +55,13 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
55 priv->scan_block = false; 55 priv->scan_block = false;
56 56
57 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && 57 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
58 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) 58 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
59 mwifiex_disable_all_tdls_links(priv); 59 mwifiex_disable_all_tdls_links(priv);
60 60
61 if (priv->adapter->auto_tdls)
62 mwifiex_clean_auto_tdls(priv);
63 }
64
61 /* Free Tx and Rx packets, report disconnect to upper layer */ 65 /* Free Tx and Rx packets, report disconnect to upper layer */
62 mwifiex_clean_txrx(priv); 66 mwifiex_clean_txrx(priv);
63 67
@@ -163,9 +167,6 @@ static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
163 NL80211_TDLS_TEARDOWN, 167 NL80211_TDLS_TEARDOWN,
164 le16_to_cpu(tdls_evt->u.reason_code), 168 le16_to_cpu(tdls_evt->u.reason_code),
165 GFP_KERNEL); 169 GFP_KERNEL);
166 ret = mwifiex_tdls_oper(priv, tdls_evt->peer_mac,
167 MWIFIEX_TDLS_DISABLE_LINK);
168 queue_work(adapter->workqueue, &adapter->main_work);
169 break; 170 break;
170 default: 171 default:
171 break; 172 break;
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 92f3eb839866..1626868a4b5c 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -1026,12 +1026,12 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1026 int max_len) 1026 int max_len)
1027{ 1027{
1028 union { 1028 union {
1029 u32 l; 1029 __le32 l;
1030 u8 c[4]; 1030 u8 c[4];
1031 } ver; 1031 } ver;
1032 char fw_ver[32]; 1032 char fw_ver[32];
1033 1033
1034 ver.l = adapter->fw_release_number; 1034 ver.l = cpu_to_le32(adapter->fw_release_number);
1035 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]); 1035 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1036 1036
1037 snprintf(version, max_len, driver_version, fw_ver); 1037 snprintf(version, max_len, driver_version, fw_ver);
diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c
index 9ceb1dbe34c5..c2ad3b63ae70 100644
--- a/drivers/net/wireless/mwifiex/sta_rx.c
+++ b/drivers/net/wireless/mwifiex/sta_rx.c
@@ -232,6 +232,9 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_private *priv,
232 if (sta_ptr) 232 if (sta_ptr)
233 sta_ptr->rx_seq[local_rx_pd->priority] = 233 sta_ptr->rx_seq[local_rx_pd->priority] =
234 le16_to_cpu(local_rx_pd->seq_num); 234 le16_to_cpu(local_rx_pd->seq_num);
235 mwifiex_auto_tdls_update_peer_signal(priv, ta,
236 local_rx_pd->snr,
237 local_rx_pd->nf);
235 } 238 }
236 } else { 239 } else {
237 if (rx_pkt_type != PKT_TYPE_BAR) 240 if (rx_pkt_type != PKT_TYPE_BAR)
diff --git a/drivers/net/wireless/mwifiex/tdls.c b/drivers/net/wireless/mwifiex/tdls.c
index e2949077f5b5..22884b429be7 100644
--- a/drivers/net/wireless/mwifiex/tdls.c
+++ b/drivers/net/wireless/mwifiex/tdls.c
@@ -24,6 +24,7 @@
24#define TDLS_REQ_FIX_LEN 6 24#define TDLS_REQ_FIX_LEN 6
25#define TDLS_RESP_FIX_LEN 8 25#define TDLS_RESP_FIX_LEN 8
26#define TDLS_CONFIRM_FIX_LEN 6 26#define TDLS_CONFIRM_FIX_LEN 6
27#define MWIFIEX_TDLS_WMM_INFO_SIZE 7
27 28
28static void mwifiex_restore_tdls_packets(struct mwifiex_private *priv, 29static void mwifiex_restore_tdls_packets(struct mwifiex_private *priv,
29 const u8 *mac, u8 status) 30 const u8 *mac, u8 status)
@@ -367,6 +368,55 @@ static void mwifiex_tdls_add_qos_capab(struct sk_buff *skb)
367 *pos++ = MWIFIEX_TDLS_DEF_QOS_CAPAB; 368 *pos++ = MWIFIEX_TDLS_DEF_QOS_CAPAB;
368} 369}
369 370
371static void
372mwifiex_tdls_add_wmm_param_ie(struct mwifiex_private *priv, struct sk_buff *skb)
373{
374 struct ieee80211_wmm_param_ie *wmm;
375 u8 ac_vi[] = {0x42, 0x43, 0x5e, 0x00};
376 u8 ac_vo[] = {0x62, 0x32, 0x2f, 0x00};
377 u8 ac_be[] = {0x03, 0xa4, 0x00, 0x00};
378 u8 ac_bk[] = {0x27, 0xa4, 0x00, 0x00};
379
380 wmm = (void *)skb_put(skb, sizeof(*wmm));
381 memset(wmm, 0, sizeof(*wmm));
382
383 wmm->element_id = WLAN_EID_VENDOR_SPECIFIC;
384 wmm->len = sizeof(*wmm) - 2;
385 wmm->oui[0] = 0x00; /* Microsoft OUI 00:50:F2 */
386 wmm->oui[1] = 0x50;
387 wmm->oui[2] = 0xf2;
388 wmm->oui_type = 2; /* WME */
389 wmm->oui_subtype = 1; /* WME param */
390 wmm->version = 1; /* WME ver */
391 wmm->qos_info = 0; /* U-APSD not in use */
392
393 /* use default WMM AC parameters for TDLS link*/
394 memcpy(&wmm->ac[0], ac_be, sizeof(ac_be));
395 memcpy(&wmm->ac[1], ac_bk, sizeof(ac_bk));
396 memcpy(&wmm->ac[2], ac_vi, sizeof(ac_vi));
397 memcpy(&wmm->ac[3], ac_vo, sizeof(ac_vo));
398}
399
400static void
401mwifiex_add_wmm_info_ie(struct mwifiex_private *priv, struct sk_buff *skb,
402 u8 qosinfo)
403{
404 u8 *buf;
405
406 buf = (void *)skb_put(skb, MWIFIEX_TDLS_WMM_INFO_SIZE +
407 sizeof(struct ieee_types_header));
408
409 *buf++ = WLAN_EID_VENDOR_SPECIFIC;
410 *buf++ = 7; /* len */
411 *buf++ = 0x00; /* Microsoft OUI 00:50:F2 */
412 *buf++ = 0x50;
413 *buf++ = 0xf2;
414 *buf++ = 2; /* WME */
415 *buf++ = 0; /* WME info */
416 *buf++ = 1; /* WME ver */
417 *buf++ = qosinfo; /* U-APSD no in use */
418}
419
370static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv, 420static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
371 const u8 *peer, u8 action_code, 421 const u8 *peer, u8 action_code,
372 u8 dialog_token, 422 u8 dialog_token,
@@ -421,6 +471,7 @@ static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
421 471
422 mwifiex_tdls_add_ext_capab(priv, skb); 472 mwifiex_tdls_add_ext_capab(priv, skb);
423 mwifiex_tdls_add_qos_capab(skb); 473 mwifiex_tdls_add_qos_capab(skb);
474 mwifiex_add_wmm_info_ie(priv, skb, 0);
424 break; 475 break;
425 476
426 case WLAN_TDLS_SETUP_RESPONSE: 477 case WLAN_TDLS_SETUP_RESPONSE:
@@ -458,6 +509,7 @@ static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
458 509
459 mwifiex_tdls_add_ext_capab(priv, skb); 510 mwifiex_tdls_add_ext_capab(priv, skb);
460 mwifiex_tdls_add_qos_capab(skb); 511 mwifiex_tdls_add_qos_capab(skb);
512 mwifiex_add_wmm_info_ie(priv, skb, 0);
461 break; 513 break;
462 514
463 case WLAN_TDLS_SETUP_CONFIRM: 515 case WLAN_TDLS_SETUP_CONFIRM:
@@ -466,6 +518,8 @@ static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
466 skb_put(skb, sizeof(tf->u.setup_cfm)); 518 skb_put(skb, sizeof(tf->u.setup_cfm));
467 tf->u.setup_cfm.status_code = cpu_to_le16(status_code); 519 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
468 tf->u.setup_cfm.dialog_token = dialog_token; 520 tf->u.setup_cfm.dialog_token = dialog_token;
521
522 mwifiex_tdls_add_wmm_param_ie(priv, skb);
469 if (priv->adapter->is_hw_11ac_capable) { 523 if (priv->adapter->is_hw_11ac_capable) {
470 ret = mwifiex_tdls_add_vht_oper(priv, peer, skb); 524 ret = mwifiex_tdls_add_vht_oper(priv, peer, skb);
471 if (ret) { 525 if (ret) {
@@ -544,6 +598,7 @@ int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
544 sizeof(struct ieee_types_bss_co_2040) + 598 sizeof(struct ieee_types_bss_co_2040) +
545 sizeof(struct ieee80211_ht_operation) + 599 sizeof(struct ieee80211_ht_operation) +
546 sizeof(struct ieee80211_tdls_lnkie) + 600 sizeof(struct ieee80211_tdls_lnkie) +
601 sizeof(struct ieee80211_wmm_param_ie) +
547 extra_ies_len; 602 extra_ies_len;
548 603
549 if (priv->adapter->is_hw_11ac_capable) 604 if (priv->adapter->is_hw_11ac_capable)
@@ -973,6 +1028,7 @@ mwifiex_tdls_process_disable_link(struct mwifiex_private *priv, const u8 *peer)
973 } 1028 }
974 1029
975 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN); 1030 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN);
1031 mwifiex_auto_tdls_update_peer_status(priv, peer, TDLS_NOT_SETUP);
976 memcpy(&tdls_oper.peer_mac, peer, ETH_ALEN); 1032 memcpy(&tdls_oper.peer_mac, peer, ETH_ALEN);
977 tdls_oper.tdls_action = MWIFIEX_TDLS_DISABLE_LINK; 1033 tdls_oper.tdls_action = MWIFIEX_TDLS_DISABLE_LINK;
978 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER, 1034 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER,
@@ -1017,6 +1073,8 @@ mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, const u8 *peer)
1017 1073
1018 memset(sta_ptr->rx_seq, 0xff, sizeof(sta_ptr->rx_seq)); 1074 memset(sta_ptr->rx_seq, 0xff, sizeof(sta_ptr->rx_seq));
1019 mwifiex_restore_tdls_packets(priv, peer, TDLS_SETUP_COMPLETE); 1075 mwifiex_restore_tdls_packets(priv, peer, TDLS_SETUP_COMPLETE);
1076 mwifiex_auto_tdls_update_peer_status(priv, peer,
1077 TDLS_SETUP_COMPLETE);
1020 } else { 1078 } else {
1021 dev_dbg(priv->adapter->dev, 1079 dev_dbg(priv->adapter->dev,
1022 "tdls: enable link %pM failed\n", peer); 1080 "tdls: enable link %pM failed\n", peer);
@@ -1030,6 +1088,8 @@ mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, const u8 *peer)
1030 mwifiex_del_sta_entry(priv, peer); 1088 mwifiex_del_sta_entry(priv, peer);
1031 } 1089 }
1032 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN); 1090 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN);
1091 mwifiex_auto_tdls_update_peer_status(priv, peer,
1092 TDLS_NOT_SETUP);
1033 1093
1034 return -1; 1094 return -1;
1035 } 1095 }
@@ -1097,3 +1157,231 @@ void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv)
1097 1157
1098 mwifiex_del_all_sta_list(priv); 1158 mwifiex_del_all_sta_list(priv);
1099} 1159}
1160
1161int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb)
1162{
1163 struct mwifiex_auto_tdls_peer *peer;
1164 unsigned long flags;
1165 u8 mac[ETH_ALEN];
1166
1167 ether_addr_copy(mac, skb->data);
1168
1169 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1170 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1171 if (!memcmp(mac, peer->mac_addr, ETH_ALEN)) {
1172 if (peer->rssi <= MWIFIEX_TDLS_RSSI_HIGH &&
1173 peer->tdls_status == TDLS_NOT_SETUP &&
1174 (peer->failure_count <
1175 MWIFIEX_TDLS_MAX_FAIL_COUNT)) {
1176 peer->tdls_status = TDLS_SETUP_INPROGRESS;
1177 dev_dbg(priv->adapter->dev,
1178 "setup TDLS link, peer=%pM rssi=%d\n",
1179 peer->mac_addr, peer->rssi);
1180
1181 cfg80211_tdls_oper_request(priv->netdev,
1182 peer->mac_addr,
1183 NL80211_TDLS_SETUP,
1184 0, GFP_ATOMIC);
1185 peer->do_setup = false;
1186 priv->check_tdls_tx = false;
1187 } else if (peer->failure_count <
1188 MWIFIEX_TDLS_MAX_FAIL_COUNT &&
1189 peer->do_discover) {
1190 mwifiex_send_tdls_data_frame(priv,
1191 peer->mac_addr,
1192 WLAN_TDLS_DISCOVERY_REQUEST,
1193 1, 0, NULL, 0);
1194 peer->do_discover = false;
1195 }
1196 }
1197 }
1198 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1199
1200 return 0;
1201}
1202
1203void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv)
1204{
1205 struct mwifiex_auto_tdls_peer *peer, *tmp_node;
1206 unsigned long flags;
1207
1208 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1209 list_for_each_entry_safe(peer, tmp_node, &priv->auto_tdls_list, list) {
1210 list_del(&peer->list);
1211 kfree(peer);
1212 }
1213
1214 INIT_LIST_HEAD(&priv->auto_tdls_list);
1215 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1216 priv->check_tdls_tx = false;
1217}
1218
1219void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac)
1220{
1221 struct mwifiex_auto_tdls_peer *tdls_peer;
1222 unsigned long flags;
1223
1224 if (!priv->adapter->auto_tdls)
1225 return;
1226
1227 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1228 list_for_each_entry(tdls_peer, &priv->auto_tdls_list, list) {
1229 if (!memcmp(tdls_peer->mac_addr, mac, ETH_ALEN)) {
1230 tdls_peer->tdls_status = TDLS_SETUP_INPROGRESS;
1231 tdls_peer->rssi_jiffies = jiffies;
1232 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1233 return;
1234 }
1235 }
1236
1237 /* create new TDLS peer */
1238 tdls_peer = kzalloc(sizeof(*tdls_peer), GFP_ATOMIC);
1239 if (tdls_peer) {
1240 ether_addr_copy(tdls_peer->mac_addr, mac);
1241 tdls_peer->tdls_status = TDLS_SETUP_INPROGRESS;
1242 tdls_peer->rssi_jiffies = jiffies;
1243 INIT_LIST_HEAD(&tdls_peer->list);
1244 list_add_tail(&tdls_peer->list, &priv->auto_tdls_list);
1245 dev_dbg(priv->adapter->dev, "Add auto TDLS peer= %pM to list\n",
1246 mac);
1247 }
1248
1249 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1250}
1251
1252void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1253 const u8 *mac, u8 link_status)
1254{
1255 struct mwifiex_auto_tdls_peer *peer;
1256 unsigned long flags;
1257
1258 if (!priv->adapter->auto_tdls)
1259 return;
1260
1261 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1262 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1263 if (!memcmp(peer->mac_addr, mac, ETH_ALEN)) {
1264 if ((link_status == TDLS_NOT_SETUP) &&
1265 (peer->tdls_status == TDLS_SETUP_INPROGRESS))
1266 peer->failure_count++;
1267 else if (link_status == TDLS_SETUP_COMPLETE)
1268 peer->failure_count = 0;
1269
1270 peer->tdls_status = link_status;
1271 break;
1272 }
1273 }
1274 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1275}
1276
1277void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1278 u8 *mac, s8 snr, s8 nflr)
1279{
1280 struct mwifiex_auto_tdls_peer *peer;
1281 unsigned long flags;
1282
1283 if (!priv->adapter->auto_tdls)
1284 return;
1285
1286 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1287 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1288 if (!memcmp(peer->mac_addr, mac, ETH_ALEN)) {
1289 peer->rssi = nflr - snr;
1290 peer->rssi_jiffies = jiffies;
1291 break;
1292 }
1293 }
1294 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1295}
1296
1297void mwifiex_check_auto_tdls(unsigned long context)
1298{
1299 struct mwifiex_private *priv = (struct mwifiex_private *)context;
1300 struct mwifiex_auto_tdls_peer *tdls_peer;
1301 unsigned long flags;
1302 u16 reason = WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED;
1303
1304 if (WARN_ON_ONCE(!priv || !priv->adapter)) {
1305 pr_err("mwifiex: %s: adapter or private structure is NULL\n",
1306 __func__);
1307 return;
1308 }
1309
1310 if (unlikely(!priv->adapter->auto_tdls))
1311 return;
1312
1313 if (!priv->auto_tdls_timer_active) {
1314 dev_dbg(priv->adapter->dev,
1315 "auto TDLS timer inactive; return");
1316 return;
1317 }
1318
1319 priv->check_tdls_tx = false;
1320
1321 if (list_empty(&priv->auto_tdls_list)) {
1322 mod_timer(&priv->auto_tdls_timer,
1323 jiffies +
1324 msecs_to_jiffies(MWIFIEX_TIMER_10S));
1325 return;
1326 }
1327
1328 spin_lock_irqsave(&priv->auto_tdls_lock, flags);
1329 list_for_each_entry(tdls_peer, &priv->auto_tdls_list, list) {
1330 if ((jiffies - tdls_peer->rssi_jiffies) >
1331 (MWIFIEX_AUTO_TDLS_IDLE_TIME * HZ)) {
1332 tdls_peer->rssi = 0;
1333 tdls_peer->do_discover = true;
1334 priv->check_tdls_tx = true;
1335 }
1336
1337 if (((tdls_peer->rssi >= MWIFIEX_TDLS_RSSI_LOW) ||
1338 !tdls_peer->rssi) &&
1339 tdls_peer->tdls_status == TDLS_SETUP_COMPLETE) {
1340 tdls_peer->tdls_status = TDLS_LINK_TEARDOWN;
1341 dev_dbg(priv->adapter->dev,
1342 "teardown TDLS link,peer=%pM rssi=%d\n",
1343 tdls_peer->mac_addr, -tdls_peer->rssi);
1344 tdls_peer->do_discover = true;
1345 priv->check_tdls_tx = true;
1346 cfg80211_tdls_oper_request(priv->netdev,
1347 tdls_peer->mac_addr,
1348 NL80211_TDLS_TEARDOWN,
1349 reason, GFP_ATOMIC);
1350 } else if (tdls_peer->rssi &&
1351 tdls_peer->rssi <= MWIFIEX_TDLS_RSSI_HIGH &&
1352 tdls_peer->tdls_status == TDLS_NOT_SETUP &&
1353 tdls_peer->failure_count <
1354 MWIFIEX_TDLS_MAX_FAIL_COUNT) {
1355 priv->check_tdls_tx = true;
1356 tdls_peer->do_setup = true;
1357 dev_dbg(priv->adapter->dev,
1358 "check TDLS with peer=%pM rssi=%d\n",
1359 tdls_peer->mac_addr, -tdls_peer->rssi);
1360 }
1361 }
1362 spin_unlock_irqrestore(&priv->auto_tdls_lock, flags);
1363
1364 mod_timer(&priv->auto_tdls_timer,
1365 jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S));
1366}
1367
1368void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv)
1369{
1370 init_timer(&priv->auto_tdls_timer);
1371 priv->auto_tdls_timer.function = mwifiex_check_auto_tdls;
1372 priv->auto_tdls_timer.data = (unsigned long)priv;
1373 priv->auto_tdls_timer_active = true;
1374 mod_timer(&priv->auto_tdls_timer,
1375 jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S));
1376}
1377
1378void mwifiex_clean_auto_tdls(struct mwifiex_private *priv)
1379{
1380 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
1381 priv->adapter->auto_tdls &&
1382 priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1383 priv->auto_tdls_timer_active = false;
1384 del_timer(&priv->auto_tdls_timer);
1385 mwifiex_flush_auto_tdls_list(priv);
1386 }
1387}
diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c
index 96a2126cc44b..a5983fc4e83a 100644
--- a/drivers/net/wireless/mwifiex/txrx.c
+++ b/drivers/net/wireless/mwifiex/txrx.c
@@ -64,10 +64,6 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
64 else 64 else
65 ret = mwifiex_process_sta_rx_packet(priv, skb); 65 ret = mwifiex_process_sta_rx_packet(priv, skb);
66 66
67 /* Decrement RX pending counter for each packet */
68 if (adapter->if_ops.data_complete)
69 adapter->if_ops.data_complete(adapter);
70
71 return ret; 67 return ret;
72} 68}
73EXPORT_SYMBOL_GPL(mwifiex_handle_rx_packet); 69EXPORT_SYMBOL_GPL(mwifiex_handle_rx_packet);
diff --git a/drivers/net/wireless/mwifiex/uap_cmd.c b/drivers/net/wireless/mwifiex/uap_cmd.c
index 300bab438011..0f347fdefa0a 100644
--- a/drivers/net/wireless/mwifiex/uap_cmd.c
+++ b/drivers/net/wireless/mwifiex/uap_cmd.c
@@ -167,7 +167,7 @@ mwifiex_set_ht_params(struct mwifiex_private *priv,
167 ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, params->beacon.tail, 167 ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, params->beacon.tail,
168 params->beacon.tail_len); 168 params->beacon.tail_len);
169 if (ht_ie) { 169 if (ht_ie) {
170 memcpy(&bss_cfg->ht_cap, ht_ie + 2, 170 memcpy(&bss_cfg->ht_cap, ht_ie,
171 sizeof(struct ieee80211_ht_cap)); 171 sizeof(struct ieee80211_ht_cap));
172 cap_info = le16_to_cpu(bss_cfg->ht_cap.cap_info); 172 cap_info = le16_to_cpu(bss_cfg->ht_cap.cap_info);
173 memset(&bss_cfg->ht_cap.mcs, 0, 173 memset(&bss_cfg->ht_cap.mcs, 0,
diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
index 4371e12b36f3..1b56495ec872 100644
--- a/drivers/net/wireless/mwifiex/usb.c
+++ b/drivers/net/wireless/mwifiex/usb.c
@@ -27,6 +27,11 @@ static struct mwifiex_if_ops usb_ops;
27static struct semaphore add_remove_card_sem; 27static struct semaphore add_remove_card_sem;
28 28
29static struct usb_device_id mwifiex_usb_table[] = { 29static struct usb_device_id mwifiex_usb_table[] = {
30 /* 8766 */
31 {USB_DEVICE(USB8XXX_VID, USB8766_PID_1)},
32 {USB_DEVICE_AND_INTERFACE_INFO(USB8XXX_VID, USB8766_PID_2,
33 USB_CLASS_VENDOR_SPEC,
34 USB_SUBCLASS_VENDOR_SPEC, 0xff)},
30 /* 8797 */ 35 /* 8797 */
31 {USB_DEVICE(USB8XXX_VID, USB8797_PID_1)}, 36 {USB_DEVICE(USB8XXX_VID, USB8797_PID_1)},
32 {USB_DEVICE_AND_INTERFACE_INFO(USB8XXX_VID, USB8797_PID_2, 37 {USB_DEVICE_AND_INTERFACE_INFO(USB8XXX_VID, USB8797_PID_2,
@@ -125,8 +130,10 @@ static int mwifiex_usb_recv(struct mwifiex_adapter *adapter,
125 dev_err(dev, "DATA: skb->len too large\n"); 130 dev_err(dev, "DATA: skb->len too large\n");
126 return -1; 131 return -1;
127 } 132 }
128 skb_queue_tail(&adapter->usb_rx_data_q, skb); 133
134 skb_queue_tail(&adapter->rx_data_q, skb);
129 adapter->data_received = true; 135 adapter->data_received = true;
136 atomic_inc(&adapter->rx_pending);
130 break; 137 break;
131 default: 138 default:
132 dev_err(dev, "%s: unknown endport %#x\n", __func__, ep); 139 dev_err(dev, "%s: unknown endport %#x\n", __func__, ep);
@@ -176,7 +183,6 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
176 else 183 else
177 skb_put(skb, recv_length - skb->len); 184 skb_put(skb, recv_length - skb->len);
178 185
179 atomic_inc(&adapter->rx_pending);
180 status = mwifiex_usb_recv(adapter, skb, context->ep); 186 status = mwifiex_usb_recv(adapter, skb, context->ep);
181 187
182 dev_dbg(adapter->dev, "info: recv_length=%d, status=%d\n", 188 dev_dbg(adapter->dev, "info: recv_length=%d, status=%d\n",
@@ -191,7 +197,6 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
191 if (card->rx_cmd_ep == context->ep) 197 if (card->rx_cmd_ep == context->ep)
192 return; 198 return;
193 } else { 199 } else {
194 atomic_dec(&adapter->rx_pending);
195 if (status == -1) 200 if (status == -1)
196 dev_err(adapter->dev, 201 dev_err(adapter->dev,
197 "received data processing failed!\n"); 202 "received data processing failed!\n");
@@ -222,7 +227,13 @@ setup_for_next:
222 else 227 else
223 size = MWIFIEX_RX_DATA_BUF_SIZE; 228 size = MWIFIEX_RX_DATA_BUF_SIZE;
224 229
225 mwifiex_usb_submit_rx_urb(context, size); 230 if (card->rx_cmd_ep == context->ep) {
231 mwifiex_usb_submit_rx_urb(context, size);
232 } else {
233 context->skb = NULL;
234 if (atomic_read(&adapter->rx_pending) <= HIGH_RX_PENDING)
235 mwifiex_usb_submit_rx_urb(context, size);
236 }
226 237
227 return; 238 return;
228} 239}
@@ -348,10 +359,12 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
348 359
349 /* PID_1 is used for firmware downloading only */ 360 /* PID_1 is used for firmware downloading only */
350 switch (id_product) { 361 switch (id_product) {
362 case USB8766_PID_1:
351 case USB8797_PID_1: 363 case USB8797_PID_1:
352 case USB8897_PID_1: 364 case USB8897_PID_1:
353 card->usb_boot_state = USB8XXX_FW_DNLD; 365 card->usb_boot_state = USB8XXX_FW_DNLD;
354 break; 366 break;
367 case USB8766_PID_2:
355 case USB8797_PID_2: 368 case USB8797_PID_2:
356 case USB8897_PID_2: 369 case USB8897_PID_2:
357 card->usb_boot_state = USB8XXX_FW_READY; 370 card->usb_boot_state = USB8XXX_FW_READY;
@@ -780,6 +793,11 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
780 adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K; 793 adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K;
781 strcpy(adapter->fw_name, USB8897_DEFAULT_FW_NAME); 794 strcpy(adapter->fw_name, USB8897_DEFAULT_FW_NAME);
782 break; 795 break;
796 case USB8766_PID_1:
797 case USB8766_PID_2:
798 adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K;
799 strcpy(adapter->fw_name, USB8766_DEFAULT_FW_NAME);
800 break;
783 case USB8797_PID_1: 801 case USB8797_PID_1:
784 case USB8797_PID_2: 802 case USB8797_PID_2:
785 default: 803 default:
@@ -962,19 +980,11 @@ static void mwifiex_submit_rx_urb(struct mwifiex_adapter *adapter, u8 ep)
962static int mwifiex_usb_cmd_event_complete(struct mwifiex_adapter *adapter, 980static int mwifiex_usb_cmd_event_complete(struct mwifiex_adapter *adapter,
963 struct sk_buff *skb) 981 struct sk_buff *skb)
964{ 982{
965 atomic_dec(&adapter->rx_pending);
966 mwifiex_submit_rx_urb(adapter, MWIFIEX_USB_EP_CMD_EVENT); 983 mwifiex_submit_rx_urb(adapter, MWIFIEX_USB_EP_CMD_EVENT);
967 984
968 return 0; 985 return 0;
969} 986}
970 987
971static int mwifiex_usb_data_complete(struct mwifiex_adapter *adapter)
972{
973 atomic_dec(&adapter->rx_pending);
974
975 return 0;
976}
977
978/* This function wakes up the card. */ 988/* This function wakes up the card. */
979static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) 989static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
980{ 990{
@@ -986,6 +996,20 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
986 return 0; 996 return 0;
987} 997}
988 998
999static void mwifiex_usb_submit_rem_rx_urbs(struct mwifiex_adapter *adapter)
1000{
1001 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card;
1002 int i;
1003 struct urb_context *ctx;
1004
1005 for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) {
1006 if (card->rx_data_list[i].skb)
1007 continue;
1008 ctx = &card->rx_data_list[i];
1009 mwifiex_usb_submit_rx_urb(ctx, MWIFIEX_RX_DATA_BUF_SIZE);
1010 }
1011}
1012
989static struct mwifiex_if_ops usb_ops = { 1013static struct mwifiex_if_ops usb_ops = {
990 .register_dev = mwifiex_register_dev, 1014 .register_dev = mwifiex_register_dev,
991 .unregister_dev = mwifiex_unregister_dev, 1015 .unregister_dev = mwifiex_unregister_dev,
@@ -996,8 +1020,8 @@ static struct mwifiex_if_ops usb_ops = {
996 .dnld_fw = mwifiex_usb_dnld_fw, 1020 .dnld_fw = mwifiex_usb_dnld_fw,
997 .cmdrsp_complete = mwifiex_usb_cmd_event_complete, 1021 .cmdrsp_complete = mwifiex_usb_cmd_event_complete,
998 .event_complete = mwifiex_usb_cmd_event_complete, 1022 .event_complete = mwifiex_usb_cmd_event_complete,
999 .data_complete = mwifiex_usb_data_complete,
1000 .host_to_card = mwifiex_usb_host_to_card, 1023 .host_to_card = mwifiex_usb_host_to_card,
1024 .submit_rem_rx_urbs = mwifiex_usb_submit_rem_rx_urbs,
1001}; 1025};
1002 1026
1003/* This function initializes the USB driver module. 1027/* This function initializes the USB driver module.
@@ -1048,5 +1072,6 @@ MODULE_AUTHOR("Marvell International Ltd.");
1048MODULE_DESCRIPTION("Marvell WiFi-Ex USB Driver version" USB_VERSION); 1072MODULE_DESCRIPTION("Marvell WiFi-Ex USB Driver version" USB_VERSION);
1049MODULE_VERSION(USB_VERSION); 1073MODULE_VERSION(USB_VERSION);
1050MODULE_LICENSE("GPL v2"); 1074MODULE_LICENSE("GPL v2");
1075MODULE_FIRMWARE(USB8766_DEFAULT_FW_NAME);
1051MODULE_FIRMWARE(USB8797_DEFAULT_FW_NAME); 1076MODULE_FIRMWARE(USB8797_DEFAULT_FW_NAME);
1052MODULE_FIRMWARE(USB8897_DEFAULT_FW_NAME); 1077MODULE_FIRMWARE(USB8897_DEFAULT_FW_NAME);
diff --git a/drivers/net/wireless/mwifiex/usb.h b/drivers/net/wireless/mwifiex/usb.h
index 4c41c2a193c5..a7cbba1355af 100644
--- a/drivers/net/wireless/mwifiex/usb.h
+++ b/drivers/net/wireless/mwifiex/usb.h
@@ -24,6 +24,8 @@
24 24
25#define USB8XXX_VID 0x1286 25#define USB8XXX_VID 0x1286
26 26
27#define USB8766_PID_1 0x2041
28#define USB8766_PID_2 0x2042
27#define USB8797_PID_1 0x2043 29#define USB8797_PID_1 0x2043
28#define USB8797_PID_2 0x2044 30#define USB8797_PID_2 0x2044
29#define USB8897_PID_1 0x2045 31#define USB8897_PID_1 0x2045
@@ -37,6 +39,7 @@
37#define MWIFIEX_RX_DATA_URB 6 39#define MWIFIEX_RX_DATA_URB 6
38#define MWIFIEX_USB_TIMEOUT 100 40#define MWIFIEX_USB_TIMEOUT 100
39 41
42#define USB8766_DEFAULT_FW_NAME "mrvl/usb8766_uapsta.bin"
40#define USB8797_DEFAULT_FW_NAME "mrvl/usb8797_uapsta.bin" 43#define USB8797_DEFAULT_FW_NAME "mrvl/usb8797_uapsta.bin"
41#define USB8897_DEFAULT_FW_NAME "mrvl/usb8897_uapsta.bin" 44#define USB8897_DEFAULT_FW_NAME "mrvl/usb8897_uapsta.bin"
42 45
diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c
index ec79c49de097..a113ef8f0b8b 100644
--- a/drivers/net/wireless/mwifiex/util.c
+++ b/drivers/net/wireless/mwifiex/util.c
@@ -141,6 +141,38 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv,
141 return 0; 141 return 0;
142} 142}
143 143
144static int
145mwifiex_parse_mgmt_packet(struct mwifiex_private *priv, u8 *payload, u16 len,
146 struct rxpd *rx_pd)
147{
148 u16 stype;
149 u8 category, action_code;
150 struct ieee80211_hdr *ieee_hdr = (void *)payload;
151
152 stype = (cpu_to_le16(ieee_hdr->frame_control) & IEEE80211_FCTL_STYPE);
153
154 switch (stype) {
155 case IEEE80211_STYPE_ACTION:
156 category = *(payload + sizeof(struct ieee80211_hdr));
157 action_code = *(payload + sizeof(struct ieee80211_hdr) + 1);
158 if (category == WLAN_CATEGORY_PUBLIC &&
159 action_code == WLAN_PUB_ACTION_TDLS_DISCOVER_RES) {
160 dev_dbg(priv->adapter->dev,
161 "TDLS discovery response %pM nf=%d, snr=%d\n",
162 ieee_hdr->addr2, rx_pd->nf, rx_pd->snr);
163 mwifiex_auto_tdls_update_peer_signal(priv,
164 ieee_hdr->addr2,
165 rx_pd->snr,
166 rx_pd->nf);
167 }
168 break;
169 default:
170 dev_dbg(priv->adapter->dev,
171 "unknown mgmt frame subytpe %#x\n", stype);
172 }
173
174 return 0;
175}
144/* 176/*
145 * This function processes the received management packet and send it 177 * This function processes the received management packet and send it
146 * to the kernel. 178 * to the kernel.
@@ -151,6 +183,7 @@ mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
151{ 183{
152 struct rxpd *rx_pd; 184 struct rxpd *rx_pd;
153 u16 pkt_len; 185 u16 pkt_len;
186 struct ieee80211_hdr *ieee_hdr;
154 187
155 if (!skb) 188 if (!skb)
156 return -1; 189 return -1;
@@ -162,6 +195,11 @@ mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
162 195
163 pkt_len = le16_to_cpu(rx_pd->rx_pkt_length); 196 pkt_len = le16_to_cpu(rx_pd->rx_pkt_length);
164 197
198 ieee_hdr = (void *)skb->data;
199 if (ieee80211_is_mgmt(ieee_hdr->frame_control)) {
200 mwifiex_parse_mgmt_packet(priv, (u8 *)ieee_hdr,
201 pkt_len, rx_pd);
202 }
165 /* Remove address4 */ 203 /* Remove address4 */
166 memmove(skb->data + sizeof(struct ieee80211_hdr_3addr), 204 memmove(skb->data + sizeof(struct ieee80211_hdr_3addr),
167 skb->data + sizeof(struct ieee80211_hdr), 205 skb->data + sizeof(struct ieee80211_hdr),
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index ef1104476bd8..b8d1e04aa9b9 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -5548,7 +5548,9 @@ mwl8k_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5548 return rc; 5548 return rc;
5549} 5549}
5550 5550
5551static void mwl8k_sw_scan_start(struct ieee80211_hw *hw) 5551static void mwl8k_sw_scan_start(struct ieee80211_hw *hw,
5552 struct ieee80211_vif *vif,
5553 const u8 *mac_addr)
5552{ 5554{
5553 struct mwl8k_priv *priv = hw->priv; 5555 struct mwl8k_priv *priv = hw->priv;
5554 u8 tmp; 5556 u8 tmp;
@@ -5565,7 +5567,8 @@ static void mwl8k_sw_scan_start(struct ieee80211_hw *hw)
5565 priv->sw_scan_start = true; 5567 priv->sw_scan_start = true;
5566} 5568}
5567 5569
5568static void mwl8k_sw_scan_complete(struct ieee80211_hw *hw) 5570static void mwl8k_sw_scan_complete(struct ieee80211_hw *hw,
5571 struct ieee80211_vif *vif)
5569{ 5572{
5570 struct mwl8k_priv *priv = hw->priv; 5573 struct mwl8k_priv *priv = hw->priv;
5571 u8 tmp; 5574 u8 tmp;
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index d13f25cd70d5..1ff81afb672c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -1437,8 +1437,11 @@ int rt2x00mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1437 struct ieee80211_sta *sta); 1437 struct ieee80211_sta *sta);
1438int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1438int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1439 struct ieee80211_sta *sta); 1439 struct ieee80211_sta *sta);
1440void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw); 1440void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw,
1441void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw); 1441 struct ieee80211_vif *vif,
1442 const u8 *mac_addr);
1443void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw,
1444 struct ieee80211_vif *vif);
1442int rt2x00mac_get_stats(struct ieee80211_hw *hw, 1445int rt2x00mac_get_stats(struct ieee80211_hw *hw,
1443 struct ieee80211_low_level_stats *stats); 1446 struct ieee80211_low_level_stats *stats);
1444void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, 1447void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index ad6e5a8d1e10..cb40245a0695 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -568,7 +568,9 @@ int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
568} 568}
569EXPORT_SYMBOL_GPL(rt2x00mac_sta_remove); 569EXPORT_SYMBOL_GPL(rt2x00mac_sta_remove);
570 570
571void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw) 571void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw,
572 struct ieee80211_vif *vif,
573 const u8 *mac_addr)
572{ 574{
573 struct rt2x00_dev *rt2x00dev = hw->priv; 575 struct rt2x00_dev *rt2x00dev = hw->priv;
574 set_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags); 576 set_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags);
@@ -576,7 +578,8 @@ void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw)
576} 578}
577EXPORT_SYMBOL_GPL(rt2x00mac_sw_scan_start); 579EXPORT_SYMBOL_GPL(rt2x00mac_sw_scan_start);
578 580
579void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw) 581void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw,
582 struct ieee80211_vif *vif)
580{ 583{
581 struct rt2x00_dev *rt2x00dev = hw->priv; 584 struct rt2x00_dev *rt2x00dev = hw->priv;
582 clear_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags); 585 clear_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 8e68f87ab13c..66ff36447b94 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -158,55 +158,29 @@ void rt2x00queue_align_frame(struct sk_buff *skb)
158 skb_trim(skb, frame_length); 158 skb_trim(skb, frame_length);
159} 159}
160 160
161void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length) 161/*
162 * H/W needs L2 padding between the header and the paylod if header size
163 * is not 4 bytes aligned.
164 */
165void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int hdr_len)
162{ 166{
163 unsigned int payload_length = skb->len - header_length; 167 unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
164 unsigned int header_align = ALIGN_SIZE(skb, 0);
165 unsigned int payload_align = ALIGN_SIZE(skb, header_length);
166 unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
167 168
168 /* 169 if (!l2pad)
169 * Adjust the header alignment if the payload needs to be moved more
170 * than the header.
171 */
172 if (payload_align > header_align)
173 header_align += 4;
174
175 /* There is nothing to do if no alignment is needed */
176 if (!header_align)
177 return; 170 return;
178 171
179 /* Reserve the amount of space needed in front of the frame */ 172 skb_push(skb, l2pad);
180 skb_push(skb, header_align); 173 memmove(skb->data, skb->data + l2pad, hdr_len);
181
182 /*
183 * Move the header.
184 */
185 memmove(skb->data, skb->data + header_align, header_length);
186
187 /* Move the payload, if present and if required */
188 if (payload_length && payload_align)
189 memmove(skb->data + header_length + l2pad,
190 skb->data + header_length + l2pad + payload_align,
191 payload_length);
192
193 /* Trim the skb to the correct size */
194 skb_trim(skb, header_length + l2pad + payload_length);
195} 174}
196 175
197void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length) 176void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int hdr_len)
198{ 177{
199 /* 178 unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
200 * L2 padding is only present if the skb contains more than just the
201 * IEEE 802.11 header.
202 */
203 unsigned int l2pad = (skb->len > header_length) ?
204 L2PAD_SIZE(header_length) : 0;
205 179
206 if (!l2pad) 180 if (!l2pad)
207 return; 181 return;
208 182
209 memmove(skb->data + l2pad, skb->data, header_length); 183 memmove(skb->data + l2pad, skb->data, hdr_len);
210 skb_pull(skb, l2pad); 184 skb_pull(skb, l2pad);
211} 185}
212 186
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index 07dae0d44abc..af52f0bdb71e 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -1361,7 +1361,9 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1361 return 0; 1361 return 0;
1362} 1362}
1363 1363
1364static void rtl_op_sw_scan_start(struct ieee80211_hw *hw) 1364static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
1365 struct ieee80211_vif *vif,
1366 const u8 *mac_addr)
1365{ 1367{
1366 struct rtl_priv *rtlpriv = rtl_priv(hw); 1368 struct rtl_priv *rtlpriv = rtl_priv(hw);
1367 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1369 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -1396,7 +1398,8 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
1396 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0); 1398 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1397} 1399}
1398 1400
1399static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) 1401static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
1402 struct ieee80211_vif *vif)
1400{ 1403{
1401 struct rtl_priv *rtlpriv = rtl_priv(hw); 1404 struct rtl_priv *rtlpriv = rtl_priv(hw);
1402 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1405 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 25daa8715219..61f5d36eca6a 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -842,7 +842,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
842 break; 842 break;
843 } 843 }
844 /* handle command packet here */ 844 /* handle command packet here */
845 if (rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) { 845 if (rtlpriv->cfg->ops->rx_command_packet &&
846 rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
846 dev_kfree_skb_any(skb); 847 dev_kfree_skb_any(skb);
847 goto end; 848 goto end;
848 } 849 }
@@ -1127,9 +1128,14 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1127 1128
1128 __skb_queue_tail(&ring->queue, pskb); 1129 __skb_queue_tail(&ring->queue, pskb);
1129 1130
1130 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN, 1131 if (rtlpriv->use_new_trx_flow) {
1131 &temp_one); 1132 temp_one = 4;
1132 1133 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pbuffer_desc, true,
1134 HW_DESC_OWN, (u8 *)&temp_one);
1135 } else {
1136 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
1137 &temp_one);
1138 }
1133 return; 1139 return;
1134} 1140}
1135 1141
@@ -1370,9 +1376,9 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1370 ring->desc = NULL; 1376 ring->desc = NULL;
1371 if (rtlpriv->use_new_trx_flow) { 1377 if (rtlpriv->use_new_trx_flow) {
1372 pci_free_consistent(rtlpci->pdev, 1378 pci_free_consistent(rtlpci->pdev,
1373 sizeof(*ring->desc) * ring->entries, 1379 sizeof(*ring->buffer_desc) * ring->entries,
1374 ring->buffer_desc, ring->buffer_desc_dma); 1380 ring->buffer_desc, ring->buffer_desc_dma);
1375 ring->desc = NULL; 1381 ring->buffer_desc = NULL;
1376 } 1382 }
1377} 1383}
1378 1384
@@ -1543,7 +1549,6 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1543 true, 1549 true,
1544 HW_DESC_TXBUFF_ADDR), 1550 HW_DESC_TXBUFF_ADDR),
1545 skb->len, PCI_DMA_TODEVICE); 1551 skb->len, PCI_DMA_TODEVICE);
1546 ring->idx = (ring->idx + 1) % ring->entries;
1547 kfree_skb(skb); 1552 kfree_skb(skb);
1548 ring->idx = (ring->idx + 1) % ring->entries; 1553 ring->idx = (ring->idx + 1) % ring->entries;
1549 } 1554 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
index 00e067044c08..5761d5b49e39 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -1201,6 +1201,9 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
1201 1201
1202 } 1202 }
1203 1203
1204 if (type != NL80211_IFTYPE_AP &&
1205 rtlpriv->mac80211.link_state < MAC80211_LINKED)
1206 bt_msr = rtl_read_byte(rtlpriv, MSR) & ~MSR_LINK_MASK;
1204 rtl_write_byte(rtlpriv, (MSR), bt_msr); 1207 rtl_write_byte(rtlpriv, (MSR), bt_msr);
1205 1208
1206 temp = rtl_read_dword(rtlpriv, TCR); 1209 temp = rtl_read_dword(rtlpriv, TCR);
@@ -1262,6 +1265,7 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
1262 rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]); 1265 rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]);
1263 /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */ 1266 /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
1264 rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F); 1267 rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
1268 rtlpci->irq_enabled = true;
1265} 1269}
1266 1270
1267void rtl92se_disable_interrupt(struct ieee80211_hw *hw) 1271void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
@@ -1276,8 +1280,7 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
1276 rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1280 rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1277 rtl_write_dword(rtlpriv, INTA_MASK, 0); 1281 rtl_write_dword(rtlpriv, INTA_MASK, 0);
1278 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0); 1282 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
1279 1283 rtlpci->irq_enabled = false;
1280 synchronize_irq(rtlpci->pdev->irq);
1281} 1284}
1282 1285
1283static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data) 1286static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
index 77c5b5f35244..4b4612fe2fdb 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
@@ -399,6 +399,8 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
399 case 2: 399 case 2:
400 currentcmd = &postcommoncmd[*step]; 400 currentcmd = &postcommoncmd[*step];
401 break; 401 break;
402 default:
403 return true;
402 } 404 }
403 405
404 if (currentcmd->cmdid == CMDID_END) { 406 if (currentcmd->cmdid == CMDID_END) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index aadba29c167a..fb003868bdef 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -236,6 +236,19 @@ static void rtl92s_deinit_sw_vars(struct ieee80211_hw *hw)
236 } 236 }
237} 237}
238 238
239static bool rtl92se_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue,
240 u16 index)
241{
242 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
243 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
244 u8 *entry = (u8 *)(&ring->desc[ring->idx]);
245 u8 own = (u8)rtl92se_get_desc(entry, true, HW_DESC_OWN);
246
247 if (own)
248 return false;
249 return true;
250}
251
239static struct rtl_hal_ops rtl8192se_hal_ops = { 252static struct rtl_hal_ops rtl8192se_hal_ops = {
240 .init_sw_vars = rtl92s_init_sw_vars, 253 .init_sw_vars = rtl92s_init_sw_vars,
241 .deinit_sw_vars = rtl92s_deinit_sw_vars, 254 .deinit_sw_vars = rtl92s_deinit_sw_vars,
@@ -269,6 +282,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
269 .led_control = rtl92se_led_control, 282 .led_control = rtl92se_led_control,
270 .set_desc = rtl92se_set_desc, 283 .set_desc = rtl92se_set_desc,
271 .get_desc = rtl92se_get_desc, 284 .get_desc = rtl92se_get_desc,
285 .is_tx_desc_closed = rtl92se_is_tx_desc_closed,
272 .tx_polling = rtl92se_tx_polling, 286 .tx_polling = rtl92se_tx_polling,
273 .enable_hw_sec = rtl92se_enable_hw_security_config, 287 .enable_hw_sec = rtl92se_enable_hw_security_config,
274 .set_key = rtl92se_set_key, 288 .set_key = rtl92se_set_key,
@@ -306,6 +320,8 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
306 .maps[MAC_RCR_ACRC32] = RCR_ACRC32, 320 .maps[MAC_RCR_ACRC32] = RCR_ACRC32,
307 .maps[MAC_RCR_ACF] = RCR_ACF, 321 .maps[MAC_RCR_ACF] = RCR_ACF,
308 .maps[MAC_RCR_AAP] = RCR_AAP, 322 .maps[MAC_RCR_AAP] = RCR_AAP,
323 .maps[MAC_HIMR] = INTA_MASK,
324 .maps[MAC_HIMRE] = INTA_MASK + 4,
309 325
310 .maps[EFUSE_TEST] = REG_EFUSE_TEST, 326 .maps[EFUSE_TEST] = REG_EFUSE_TEST,
311 .maps[EFUSE_CTRL] = REG_EFUSE_CTRL, 327 .maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c
index 38234851457e..0b30a7b4d663 100644
--- a/drivers/net/wireless/ti/wl1251/main.c
+++ b/drivers/net/wireless/ti/wl1251/main.c
@@ -1029,7 +1029,7 @@ static int wl1251_op_hw_scan(struct ieee80211_hw *hw,
1029 goto out_sleep; 1029 goto out_sleep;
1030 } 1030 }
1031 1031
1032 skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len, 1032 skb = ieee80211_probereq_get(wl->hw, wl->vif->addr, ssid, ssid_len,
1033 req->ie_len); 1033 req->ie_len);
1034 if (!skb) { 1034 if (!skb) {
1035 ret = -ENOMEM; 1035 ret = -ENOMEM;
diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
index 05604ee31224..b82661962d33 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.c
+++ b/drivers/net/wireless/ti/wlcore/cmd.c
@@ -64,6 +64,9 @@ static int __wlcore_cmd_send(struct wl1271 *wl, u16 id, void *buf,
64 id != CMD_STOP_FWLOGGER)) 64 id != CMD_STOP_FWLOGGER))
65 return -EIO; 65 return -EIO;
66 66
67 if (WARN_ON_ONCE(len < sizeof(*cmd)))
68 return -EIO;
69
67 cmd = buf; 70 cmd = buf;
68 cmd->id = cpu_to_le16(id); 71 cmd->id = cpu_to_le16(id);
69 cmd->status = 0; 72 cmd->status = 0;
@@ -128,8 +131,9 @@ static int __wlcore_cmd_send(struct wl1271 *wl, u16 id, void *buf,
128 * send command to fw and return cmd status on success 131 * send command to fw and return cmd status on success
129 * valid_rets contains a bitmap of allowed error codes 132 * valid_rets contains a bitmap of allowed error codes
130 */ 133 */
131int wlcore_cmd_send_failsafe(struct wl1271 *wl, u16 id, void *buf, size_t len, 134static int wlcore_cmd_send_failsafe(struct wl1271 *wl, u16 id, void *buf,
132 size_t res_len, unsigned long valid_rets) 135 size_t len, size_t res_len,
136 unsigned long valid_rets)
133{ 137{
134 int ret = __wlcore_cmd_send(wl, id, buf, len, res_len); 138 int ret = __wlcore_cmd_send(wl, id, buf, len, res_len);
135 139
@@ -150,7 +154,6 @@ fail:
150 wl12xx_queue_recovery_work(wl); 154 wl12xx_queue_recovery_work(wl);
151 return ret; 155 return ret;
152} 156}
153EXPORT_SYMBOL_GPL(wl1271_cmd_send);
154 157
155/* 158/*
156 * wrapper for wlcore_cmd_send that accept only CMD_STATUS_SUCCESS 159 * wrapper for wlcore_cmd_send that accept only CMD_STATUS_SUCCESS
@@ -165,6 +168,7 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
165 return ret; 168 return ret;
166 return 0; 169 return 0;
167} 170}
171EXPORT_SYMBOL_GPL(wl1271_cmd_send);
168 172
169/* 173/*
170 * Poll the mailbox event field until any of the bits in the mask is set or a 174 * Poll the mailbox event field until any of the bits in the mask is set or a
@@ -891,6 +895,9 @@ int wlcore_cmd_configure_failsafe(struct wl1271 *wl, u16 id, void *buf,
891 895
892 wl1271_debug(DEBUG_CMD, "cmd configure (%d)", id); 896 wl1271_debug(DEBUG_CMD, "cmd configure (%d)", id);
893 897
898 if (WARN_ON_ONCE(len < sizeof(*acx)))
899 return -EIO;
900
894 acx->id = cpu_to_le16(id); 901 acx->id = cpu_to_le16(id);
895 902
896 /* payload length, does not include any headers */ 903 /* payload length, does not include any headers */
@@ -1138,7 +1145,7 @@ int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1138 1145
1139 wl1271_debug(DEBUG_SCAN, "build probe request band %d", band); 1146 wl1271_debug(DEBUG_SCAN, "build probe request band %d", band);
1140 1147
1141 skb = ieee80211_probereq_get(wl->hw, vif, ssid, ssid_len, 1148 skb = ieee80211_probereq_get(wl->hw, vif->addr, ssid, ssid_len,
1142 ie0_len + ie1_len); 1149 ie0_len + ie1_len);
1143 if (!skb) { 1150 if (!skb) {
1144 ret = -ENOMEM; 1151 ret = -ENOMEM;
diff --git a/drivers/net/wireless/ti/wlcore/cmd.h b/drivers/net/wireless/ti/wlcore/cmd.h
index ca6a28b03f8f..453684a71d30 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.h
+++ b/drivers/net/wireless/ti/wlcore/cmd.h
@@ -31,8 +31,6 @@ struct acx_header;
31 31
32int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, 32int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33 size_t res_len); 33 size_t res_len);
34int wlcore_cmd_send_failsafe(struct wl1271 *wl, u16 id, void *buf, size_t len,
35 size_t res_len, unsigned long valid_rets);
36int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, 34int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type,
37 u8 *role_id); 35 u8 *role_id);
38int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); 36int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id);
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 2fbff907ce8a..dbc311c3dc37 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -856,7 +856,9 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
856 return 0; 856 return 0;
857} 857}
858 858
859static void vnt_sw_scan_start(struct ieee80211_hw *hw) 859static void vnt_sw_scan_start(struct ieee80211_hw *hw,
860 struct ieee80211_vif *vif,
861 const u8 *addr)
860{ 862{
861 struct vnt_private *priv = hw->priv; 863 struct vnt_private *priv = hw->priv;
862 864
@@ -865,7 +867,8 @@ static void vnt_sw_scan_start(struct ieee80211_hw *hw)
865 vnt_update_pre_ed_threshold(priv, true); 867 vnt_update_pre_ed_threshold(priv, true);
866} 868}
867 869
868static void vnt_sw_scan_complete(struct ieee80211_hw *hw) 870static void vnt_sw_scan_complete(struct ieee80211_hw *hw,
871 struct ieee80211_vif *vif)
869{ 872{
870 struct vnt_private *priv = hw->priv; 873 struct vnt_private *priv = hw->priv;
871 874