diff options
320 files changed, 11836 insertions, 5611 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index bf61e04291ab..2116b9a9374a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1406,7 +1406,7 @@ ATHEROS ATH6KL WIRELESS DRIVER | |||
1406 | M: Kalle Valo <kvalo@qca.qualcomm.com> | 1406 | M: Kalle Valo <kvalo@qca.qualcomm.com> |
1407 | L: linux-wireless@vger.kernel.org | 1407 | L: linux-wireless@vger.kernel.org |
1408 | W: http://wireless.kernel.org/en/users/Drivers/ath6kl | 1408 | W: http://wireless.kernel.org/en/users/Drivers/ath6kl |
1409 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath6kl.git | 1409 | T: git git://github.com/kvalo/ath.git |
1410 | S: Supported | 1410 | S: Supported |
1411 | F: drivers/net/wireless/ath/ath6kl/ | 1411 | F: drivers/net/wireless/ath/ath6kl/ |
1412 | 1412 | ||
@@ -4362,7 +4362,7 @@ F: drivers/net/wireless/iwlegacy/ | |||
4362 | 4362 | ||
4363 | INTEL WIRELESS WIFI LINK (iwlwifi) | 4363 | INTEL WIRELESS WIFI LINK (iwlwifi) |
4364 | M: Johannes Berg <johannes.berg@intel.com> | 4364 | M: Johannes Berg <johannes.berg@intel.com> |
4365 | M: Wey-Yi Guy <wey-yi.w.guy@intel.com> | 4365 | M: Emmanuel Grumbach <emmanuel.grumbach@intel.com> |
4366 | M: Intel Linux Wireless <ilw@linux.intel.com> | 4366 | M: Intel Linux Wireless <ilw@linux.intel.com> |
4367 | L: linux-wireless@vger.kernel.org | 4367 | L: linux-wireless@vger.kernel.org |
4368 | W: http://intellinuxwireless.org | 4368 | W: http://intellinuxwireless.org |
@@ -5791,7 +5791,7 @@ M: Aloisio Almeida Jr <aloisio.almeida@openbossa.org> | |||
5791 | M: Samuel Ortiz <sameo@linux.intel.com> | 5791 | M: Samuel Ortiz <sameo@linux.intel.com> |
5792 | L: linux-wireless@vger.kernel.org | 5792 | L: linux-wireless@vger.kernel.org |
5793 | L: linux-nfc@lists.01.org (moderated for non-subscribers) | 5793 | L: linux-nfc@lists.01.org (moderated for non-subscribers) |
5794 | S: Maintained | 5794 | S: Supported |
5795 | F: net/nfc/ | 5795 | F: net/nfc/ |
5796 | F: include/net/nfc/ | 5796 | F: include/net/nfc/ |
5797 | F: include/uapi/linux/nfc.h | 5797 | F: include/uapi/linux/nfc.h |
@@ -6719,6 +6719,14 @@ T: git git://linuxtv.org/anttip/media_tree.git | |||
6719 | S: Maintained | 6719 | S: Maintained |
6720 | F: drivers/media/tuners/qt1010* | 6720 | F: drivers/media/tuners/qt1010* |
6721 | 6721 | ||
6722 | QUALCOMM ATHEROS ATH10K WIRELESS DRIVER | ||
6723 | M: Kalle Valo <kvalo@qca.qualcomm.com> | ||
6724 | L: ath10k@lists.infradead.org | ||
6725 | W: http://wireless.kernel.org/en/users/Drivers/ath10k | ||
6726 | T: git git://github.com/kvalo/ath.git | ||
6727 | S: Supported | ||
6728 | F: drivers/net/wireless/ath/ath10k/ | ||
6729 | |||
6722 | QUALCOMM HEXAGON ARCHITECTURE | 6730 | QUALCOMM HEXAGON ARCHITECTURE |
6723 | M: Richard Kuo <rkuo@codeaurora.org> | 6731 | M: Richard Kuo <rkuo@codeaurora.org> |
6724 | L: linux-hexagon@vger.kernel.org | 6732 | L: linux-hexagon@vger.kernel.org |
@@ -8264,7 +8272,7 @@ S: Maintained | |||
8264 | F: sound/soc/codecs/twl4030* | 8272 | F: sound/soc/codecs/twl4030* |
8265 | 8273 | ||
8266 | TI WILINK WIRELESS DRIVERS | 8274 | TI WILINK WIRELESS DRIVERS |
8267 | M: Luciano Coelho <coelho@ti.com> | 8275 | M: Luciano Coelho <luca@coelho.fi> |
8268 | L: linux-wireless@vger.kernel.org | 8276 | L: linux-wireless@vger.kernel.org |
8269 | W: http://wireless.kernel.org/en/users/Drivers/wl12xx | 8277 | W: http://wireless.kernel.org/en/users/Drivers/wl12xx |
8270 | W: http://wireless.kernel.org/en/users/Drivers/wl1251 | 8278 | W: http://wireless.kernel.org/en/users/Drivers/wl1251 |
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig index 380a2003231e..7c081b38ef3e 100644 --- a/drivers/bcma/Kconfig +++ b/drivers/bcma/Kconfig | |||
@@ -35,8 +35,14 @@ config BCMA_DRIVER_PCI_HOSTMODE | |||
35 | PCI core hostmode operation (external PCI bus). | 35 | PCI core hostmode operation (external PCI bus). |
36 | 36 | ||
37 | config BCMA_HOST_SOC | 37 | config BCMA_HOST_SOC |
38 | bool | 38 | bool "Support for BCMA in a SoC" |
39 | depends on BCMA_DRIVER_MIPS | 39 | depends on BCMA |
40 | help | ||
41 | Host interface for a Broadcom AIX bus directly mapped into | ||
42 | the memory. This only works with the Broadcom SoCs from the | ||
43 | BCM47XX line. | ||
44 | |||
45 | If unsure, say N | ||
40 | 46 | ||
41 | config BCMA_DRIVER_MIPS | 47 | config BCMA_DRIVER_MIPS |
42 | bool "BCMA Broadcom MIPS core driver" | 48 | bool "BCMA Broadcom MIPS core driver" |
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index cf7a476a519f..c9fd6943ce45 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c | |||
@@ -31,7 +31,7 @@ static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data) | |||
31 | pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data); | 31 | pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data); |
32 | } | 32 | } |
33 | 33 | ||
34 | static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy) | 34 | static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy) |
35 | { | 35 | { |
36 | u32 v; | 36 | u32 v; |
37 | int i; | 37 | int i; |
@@ -55,7 +55,7 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy) | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address) | 58 | static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address) |
59 | { | 59 | { |
60 | int max_retries = 10; | 60 | int max_retries = 10; |
61 | u16 ret = 0; | 61 | u16 ret = 0; |
@@ -98,7 +98,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address) | |||
98 | return ret; | 98 | return ret; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, | 101 | static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device, |
102 | u8 address, u16 data) | 102 | u8 address, u16 data) |
103 | { | 103 | { |
104 | int max_retries = 10; | 104 | int max_retries = 10; |
@@ -137,6 +137,13 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, | |||
137 | pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0); | 137 | pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0); |
138 | } | 138 | } |
139 | 139 | ||
140 | static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device, | ||
141 | u8 address, u16 data) | ||
142 | { | ||
143 | bcma_pcie_mdio_write(pc, device, address, data); | ||
144 | return bcma_pcie_mdio_read(pc, device, address); | ||
145 | } | ||
146 | |||
140 | /************************************************** | 147 | /************************************************** |
141 | * Workarounds. | 148 | * Workarounds. |
142 | **************************************************/ | 149 | **************************************************/ |
@@ -203,6 +210,25 @@ static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc) | |||
203 | } | 210 | } |
204 | } | 211 | } |
205 | 212 | ||
213 | static void bcma_core_pci_power_save(struct bcma_drv_pci *pc, bool up) | ||
214 | { | ||
215 | u16 data; | ||
216 | |||
217 | if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) { | ||
218 | data = up ? 0x74 : 0x7C; | ||
219 | bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, | ||
220 | BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64); | ||
221 | bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, | ||
222 | BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data); | ||
223 | } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) { | ||
224 | data = up ? 0x75 : 0x7D; | ||
225 | bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, | ||
226 | BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65); | ||
227 | bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, | ||
228 | BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data); | ||
229 | } | ||
230 | } | ||
231 | |||
206 | /************************************************** | 232 | /************************************************** |
207 | * Init. | 233 | * Init. |
208 | **************************************************/ | 234 | **************************************************/ |
@@ -262,7 +288,7 @@ out: | |||
262 | } | 288 | } |
263 | EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl); | 289 | EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl); |
264 | 290 | ||
265 | void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend) | 291 | static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend) |
266 | { | 292 | { |
267 | u32 w; | 293 | u32 w; |
268 | 294 | ||
@@ -274,4 +300,33 @@ void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend) | |||
274 | bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w); | 300 | bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w); |
275 | bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG); | 301 | bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG); |
276 | } | 302 | } |
277 | EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer); | 303 | |
304 | void bcma_core_pci_up(struct bcma_bus *bus) | ||
305 | { | ||
306 | struct bcma_drv_pci *pc; | ||
307 | |||
308 | if (bus->hosttype != BCMA_HOSTTYPE_PCI) | ||
309 | return; | ||
310 | |||
311 | pc = &bus->drv_pci[0]; | ||
312 | |||
313 | bcma_core_pci_power_save(pc, true); | ||
314 | |||
315 | bcma_core_pci_extend_L1timer(pc, true); | ||
316 | } | ||
317 | EXPORT_SYMBOL_GPL(bcma_core_pci_up); | ||
318 | |||
319 | void bcma_core_pci_down(struct bcma_bus *bus) | ||
320 | { | ||
321 | struct bcma_drv_pci *pc; | ||
322 | |||
323 | if (bus->hosttype != BCMA_HOSTTYPE_PCI) | ||
324 | return; | ||
325 | |||
326 | pc = &bus->drv_pci[0]; | ||
327 | |||
328 | bcma_core_pci_extend_L1timer(pc, false); | ||
329 | |||
330 | bcma_core_pci_power_save(pc, false); | ||
331 | } | ||
332 | EXPORT_SYMBOL_GPL(bcma_core_pci_down); | ||
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c index 30629a3d44cc..c3d7b03c2fdc 100644 --- a/drivers/bcma/driver_pci_host.c +++ b/drivers/bcma/driver_pci_host.c | |||
@@ -581,6 +581,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses); | |||
581 | int bcma_core_pci_plat_dev_init(struct pci_dev *dev) | 581 | int bcma_core_pci_plat_dev_init(struct pci_dev *dev) |
582 | { | 582 | { |
583 | struct bcma_drv_pci_host *pc_host; | 583 | struct bcma_drv_pci_host *pc_host; |
584 | int readrq; | ||
584 | 585 | ||
585 | if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { | 586 | if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { |
586 | /* This is not a device on the PCI-core bridge. */ | 587 | /* This is not a device on the PCI-core bridge. */ |
@@ -595,6 +596,11 @@ int bcma_core_pci_plat_dev_init(struct pci_dev *dev) | |||
595 | dev->irq = bcma_core_irq(pc_host->pdev->core); | 596 | dev->irq = bcma_core_irq(pc_host->pdev->core); |
596 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); | 597 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); |
597 | 598 | ||
599 | readrq = pcie_get_readrq(dev); | ||
600 | if (readrq > 128) { | ||
601 | pr_info("change PCIe max read request size from %i to 128\n", readrq); | ||
602 | pcie_set_readrq(dev, 128); | ||
603 | } | ||
598 | return 0; | 604 | return 0; |
599 | } | 605 | } |
600 | EXPORT_SYMBOL(bcma_core_pci_plat_dev_init); | 606 | EXPORT_SYMBOL(bcma_core_pci_plat_dev_init); |
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 0067422ec17d..90ee350442a9 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c | |||
@@ -237,7 +237,7 @@ int bcma_bus_register(struct bcma_bus *bus) | |||
237 | err = bcma_bus_scan(bus); | 237 | err = bcma_bus_scan(bus); |
238 | if (err) { | 238 | if (err) { |
239 | bcma_err(bus, "Failed to scan: %d\n", err); | 239 | bcma_err(bus, "Failed to scan: %d\n", err); |
240 | return -1; | 240 | return err; |
241 | } | 241 | } |
242 | 242 | ||
243 | /* Early init CC core */ | 243 | /* Early init CC core */ |
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c index 8bffa5c9818c..cd6b20fce680 100644 --- a/drivers/bcma/scan.c +++ b/drivers/bcma/scan.c | |||
@@ -32,6 +32,18 @@ static const struct bcma_device_id_name bcma_bcm_device_names[] = { | |||
32 | { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" }, | 32 | { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" }, |
33 | { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" }, | 33 | { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" }, |
34 | { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" }, | 34 | { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" }, |
35 | { BCMA_CORE_PCIEG2, "PCIe Gen 2" }, | ||
36 | { BCMA_CORE_DMA, "DMA" }, | ||
37 | { BCMA_CORE_SDIO3, "SDIO3" }, | ||
38 | { BCMA_CORE_USB20, "USB 2.0" }, | ||
39 | { BCMA_CORE_USB30, "USB 3.0" }, | ||
40 | { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" }, | ||
41 | { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" }, | ||
42 | { BCMA_CORE_ROM, "ROM" }, | ||
43 | { BCMA_CORE_NAND, "NAND flash controller" }, | ||
44 | { BCMA_CORE_QSPI, "SPI flash controller" }, | ||
45 | { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" }, | ||
46 | { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" }, | ||
35 | { BCMA_CORE_AMEMC, "AMEMC (DDR)" }, | 47 | { BCMA_CORE_AMEMC, "AMEMC (DDR)" }, |
36 | { BCMA_CORE_ALTA, "ALTA (I2S)" }, | 48 | { BCMA_CORE_ALTA, "ALTA (I2S)" }, |
37 | { BCMA_CORE_INVALID, "Invalid" }, | 49 | { BCMA_CORE_INVALID, "Invalid" }, |
@@ -201,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr) | |||
201 | return ent; | 213 | return ent; |
202 | } | 214 | } |
203 | 215 | ||
204 | static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, | 216 | static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, |
205 | u32 type, u8 port) | 217 | u32 type, u8 port) |
206 | { | 218 | { |
207 | u32 addrl, addrh, sizel, sizeh = 0; | 219 | u32 addrl, addrh, sizel, sizeh = 0; |
@@ -213,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
213 | ((ent & SCAN_ADDR_TYPE) != type) || | 225 | ((ent & SCAN_ADDR_TYPE) != type) || |
214 | (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) { | 226 | (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) { |
215 | bcma_erom_push_ent(eromptr); | 227 | bcma_erom_push_ent(eromptr); |
216 | return -EINVAL; | 228 | return (u32)-EINVAL; |
217 | } | 229 | } |
218 | 230 | ||
219 | addrl = ent & SCAN_ADDR_ADDR; | 231 | addrl = ent & SCAN_ADDR_ADDR; |
@@ -261,7 +273,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
261 | struct bcma_device_id *match, int core_num, | 273 | struct bcma_device_id *match, int core_num, |
262 | struct bcma_device *core) | 274 | struct bcma_device *core) |
263 | { | 275 | { |
264 | s32 tmp; | 276 | u32 tmp; |
265 | u8 i, j; | 277 | u8 i, j; |
266 | s32 cia, cib; | 278 | s32 cia, cib; |
267 | u8 ports[2], wrappers[2]; | 279 | u8 ports[2], wrappers[2]; |
@@ -339,11 +351,11 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
339 | * the main register space for the core | 351 | * the main register space for the core |
340 | */ | 352 | */ |
341 | tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0); | 353 | tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0); |
342 | if (tmp <= 0) { | 354 | if (tmp == 0 || IS_ERR_VALUE(tmp)) { |
343 | /* Try again to see if it is a bridge */ | 355 | /* Try again to see if it is a bridge */ |
344 | tmp = bcma_erom_get_addr_desc(bus, eromptr, | 356 | tmp = bcma_erom_get_addr_desc(bus, eromptr, |
345 | SCAN_ADDR_TYPE_BRIDGE, 0); | 357 | SCAN_ADDR_TYPE_BRIDGE, 0); |
346 | if (tmp <= 0) { | 358 | if (tmp == 0 || IS_ERR_VALUE(tmp)) { |
347 | return -EILSEQ; | 359 | return -EILSEQ; |
348 | } else { | 360 | } else { |
349 | bcma_info(bus, "Bridge found\n"); | 361 | bcma_info(bus, "Bridge found\n"); |
@@ -357,7 +369,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
357 | for (j = 0; ; j++) { | 369 | for (j = 0; ; j++) { |
358 | tmp = bcma_erom_get_addr_desc(bus, eromptr, | 370 | tmp = bcma_erom_get_addr_desc(bus, eromptr, |
359 | SCAN_ADDR_TYPE_SLAVE, i); | 371 | SCAN_ADDR_TYPE_SLAVE, i); |
360 | if (tmp < 0) { | 372 | if (IS_ERR_VALUE(tmp)) { |
361 | /* no more entries for port _i_ */ | 373 | /* no more entries for port _i_ */ |
362 | /* pr_debug("erom: slave port %d " | 374 | /* pr_debug("erom: slave port %d " |
363 | * "has %d descriptors\n", i, j); */ | 375 | * "has %d descriptors\n", i, j); */ |
@@ -374,7 +386,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
374 | for (j = 0; ; j++) { | 386 | for (j = 0; ; j++) { |
375 | tmp = bcma_erom_get_addr_desc(bus, eromptr, | 387 | tmp = bcma_erom_get_addr_desc(bus, eromptr, |
376 | SCAN_ADDR_TYPE_MWRAP, i); | 388 | SCAN_ADDR_TYPE_MWRAP, i); |
377 | if (tmp < 0) { | 389 | if (IS_ERR_VALUE(tmp)) { |
378 | /* no more entries for port _i_ */ | 390 | /* no more entries for port _i_ */ |
379 | /* pr_debug("erom: master wrapper %d " | 391 | /* pr_debug("erom: master wrapper %d " |
380 | * "has %d descriptors\n", i, j); */ | 392 | * "has %d descriptors\n", i, j); */ |
@@ -392,7 +404,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, | |||
392 | for (j = 0; ; j++) { | 404 | for (j = 0; ; j++) { |
393 | tmp = bcma_erom_get_addr_desc(bus, eromptr, | 405 | tmp = bcma_erom_get_addr_desc(bus, eromptr, |
394 | SCAN_ADDR_TYPE_SWRAP, i + hack); | 406 | SCAN_ADDR_TYPE_SWRAP, i + hack); |
395 | if (tmp < 0) { | 407 | if (IS_ERR_VALUE(tmp)) { |
396 | /* no more entries for port _i_ */ | 408 | /* no more entries for port _i_ */ |
397 | /* pr_debug("erom: master wrapper %d " | 409 | /* pr_debug("erom: master wrapper %d " |
398 | * has %d descriptors\n", i, j); */ | 410 | * has %d descriptors\n", i, j); */ |
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 11f467c00d0a..a12b923bbaca 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c | |||
@@ -91,6 +91,10 @@ static struct usb_device_id ath3k_table[] = { | |||
91 | { USB_DEVICE(0x0489, 0xe04e) }, | 91 | { USB_DEVICE(0x0489, 0xe04e) }, |
92 | { USB_DEVICE(0x0489, 0xe056) }, | 92 | { USB_DEVICE(0x0489, 0xe056) }, |
93 | { USB_DEVICE(0x0489, 0xe04d) }, | 93 | { USB_DEVICE(0x0489, 0xe04d) }, |
94 | { USB_DEVICE(0x04c5, 0x1330) }, | ||
95 | { USB_DEVICE(0x13d3, 0x3402) }, | ||
96 | { USB_DEVICE(0x0cf3, 0x3121) }, | ||
97 | { USB_DEVICE(0x0cf3, 0xe003) }, | ||
94 | 98 | ||
95 | /* Atheros AR5BBU12 with sflash firmware */ | 99 | /* Atheros AR5BBU12 with sflash firmware */ |
96 | { USB_DEVICE(0x0489, 0xE02C) }, | 100 | { USB_DEVICE(0x0489, 0xE02C) }, |
@@ -128,6 +132,10 @@ static struct usb_device_id ath3k_blist_tbl[] = { | |||
128 | { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, | 132 | { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, |
129 | { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, | 133 | { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, |
130 | { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 }, | 134 | { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 }, |
135 | { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 }, | ||
136 | { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 }, | ||
137 | { USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 }, | ||
138 | { USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 }, | ||
131 | 139 | ||
132 | /* Atheros AR5BBU22 with sflash firmware */ | 140 | /* Atheros AR5BBU22 with sflash firmware */ |
133 | { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, | 141 | { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, |
@@ -193,24 +201,44 @@ error: | |||
193 | 201 | ||
194 | static int ath3k_get_state(struct usb_device *udev, unsigned char *state) | 202 | static int ath3k_get_state(struct usb_device *udev, unsigned char *state) |
195 | { | 203 | { |
196 | int pipe = 0; | 204 | int ret, pipe = 0; |
205 | char *buf; | ||
206 | |||
207 | buf = kmalloc(sizeof(*buf), GFP_KERNEL); | ||
208 | if (!buf) | ||
209 | return -ENOMEM; | ||
197 | 210 | ||
198 | pipe = usb_rcvctrlpipe(udev, 0); | 211 | pipe = usb_rcvctrlpipe(udev, 0); |
199 | return usb_control_msg(udev, pipe, ATH3K_GETSTATE, | 212 | ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE, |
200 | USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, | 213 | USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, |
201 | state, 0x01, USB_CTRL_SET_TIMEOUT); | 214 | buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT); |
215 | |||
216 | *state = *buf; | ||
217 | kfree(buf); | ||
218 | |||
219 | return ret; | ||
202 | } | 220 | } |
203 | 221 | ||
204 | static int ath3k_get_version(struct usb_device *udev, | 222 | static int ath3k_get_version(struct usb_device *udev, |
205 | struct ath3k_version *version) | 223 | struct ath3k_version *version) |
206 | { | 224 | { |
207 | int pipe = 0; | 225 | int ret, pipe = 0; |
226 | struct ath3k_version *buf; | ||
227 | const int size = sizeof(*buf); | ||
228 | |||
229 | buf = kmalloc(size, GFP_KERNEL); | ||
230 | if (!buf) | ||
231 | return -ENOMEM; | ||
208 | 232 | ||
209 | pipe = usb_rcvctrlpipe(udev, 0); | 233 | pipe = usb_rcvctrlpipe(udev, 0); |
210 | return usb_control_msg(udev, pipe, ATH3K_GETVERSION, | 234 | ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION, |
211 | USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, version, | 235 | USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, |
212 | sizeof(struct ath3k_version), | 236 | buf, size, USB_CTRL_SET_TIMEOUT); |
213 | USB_CTRL_SET_TIMEOUT); | 237 | |
238 | memcpy(version, buf, size); | ||
239 | kfree(buf); | ||
240 | |||
241 | return ret; | ||
214 | } | 242 | } |
215 | 243 | ||
216 | static int ath3k_load_fwfile(struct usb_device *udev, | 244 | static int ath3k_load_fwfile(struct usb_device *udev, |
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c index db2c3c305df8..023d35e3c7a7 100644 --- a/drivers/bluetooth/btmrvl_debugfs.c +++ b/drivers/bluetooth/btmrvl_debugfs.c | |||
@@ -43,7 +43,7 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file, | |||
43 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | 43 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
44 | return -EFAULT; | 44 | return -EFAULT; |
45 | 45 | ||
46 | ret = strict_strtol(buf, 10, &result); | 46 | ret = kstrtol(buf, 10, &result); |
47 | if (ret) | 47 | if (ret) |
48 | return ret; | 48 | return ret; |
49 | 49 | ||
@@ -89,7 +89,7 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, | |||
89 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | 89 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
90 | return -EFAULT; | 90 | return -EFAULT; |
91 | 91 | ||
92 | ret = strict_strtol(buf, 10, &result); | 92 | ret = kstrtol(buf, 10, &result); |
93 | if (ret) | 93 | if (ret) |
94 | return ret; | 94 | return ret; |
95 | 95 | ||
@@ -135,7 +135,7 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, | |||
135 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | 135 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
136 | return -EFAULT; | 136 | return -EFAULT; |
137 | 137 | ||
138 | ret = strict_strtol(buf, 10, &result); | 138 | ret = kstrtol(buf, 10, &result); |
139 | if (ret) | 139 | if (ret) |
140 | return ret; | 140 | return ret; |
141 | 141 | ||
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 75c262694632..00da6df9f71e 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c | |||
@@ -486,7 +486,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card) | |||
486 | if (firmwarelen - offset < txlen) | 486 | if (firmwarelen - offset < txlen) |
487 | txlen = firmwarelen - offset; | 487 | txlen = firmwarelen - offset; |
488 | 488 | ||
489 | tx_blocks = (txlen + blksz_dl - 1) / blksz_dl; | 489 | tx_blocks = DIV_ROUND_UP(txlen, blksz_dl); |
490 | 490 | ||
491 | memcpy(fwbuf, &firmware[offset], txlen); | 491 | memcpy(fwbuf, &firmware[offset], txlen); |
492 | } | 492 | } |
@@ -873,7 +873,7 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv, | |||
873 | } | 873 | } |
874 | 874 | ||
875 | blksz = SDIO_BLOCK_SIZE; | 875 | blksz = SDIO_BLOCK_SIZE; |
876 | buf_block_len = (nb + blksz - 1) / blksz; | 876 | buf_block_len = DIV_ROUND_UP(nb, blksz); |
877 | 877 | ||
878 | sdio_claim_host(card->func); | 878 | sdio_claim_host(card->func); |
879 | 879 | ||
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index de4cf4daa2f4..8e16f0af6358 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -154,6 +154,10 @@ static struct usb_device_id blacklist_table[] = { | |||
154 | { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, | 154 | { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, |
155 | { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, | 155 | { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, |
156 | { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 }, | 156 | { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 }, |
157 | { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 }, | ||
158 | { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 }, | ||
159 | { USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 }, | ||
160 | { USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 }, | ||
157 | 161 | ||
158 | /* Atheros AR5BBU12 with sflash firmware */ | 162 | /* Atheros AR5BBU12 with sflash firmware */ |
159 | { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, | 163 | { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, |
@@ -1095,7 +1099,7 @@ static int btusb_setup_intel_patching(struct hci_dev *hdev, | |||
1095 | if (IS_ERR(skb)) { | 1099 | if (IS_ERR(skb)) { |
1096 | BT_ERR("%s sending Intel patch command (0x%4.4x) failed (%ld)", | 1100 | BT_ERR("%s sending Intel patch command (0x%4.4x) failed (%ld)", |
1097 | hdev->name, cmd->opcode, PTR_ERR(skb)); | 1101 | hdev->name, cmd->opcode, PTR_ERR(skb)); |
1098 | return -PTR_ERR(skb); | 1102 | return PTR_ERR(skb); |
1099 | } | 1103 | } |
1100 | 1104 | ||
1101 | /* It ensures that the returned event matches the event data read from | 1105 | /* It ensures that the returned event matches the event data read from |
@@ -1147,7 +1151,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1147 | if (IS_ERR(skb)) { | 1151 | if (IS_ERR(skb)) { |
1148 | BT_ERR("%s sending initial HCI reset command failed (%ld)", | 1152 | BT_ERR("%s sending initial HCI reset command failed (%ld)", |
1149 | hdev->name, PTR_ERR(skb)); | 1153 | hdev->name, PTR_ERR(skb)); |
1150 | return -PTR_ERR(skb); | 1154 | return PTR_ERR(skb); |
1151 | } | 1155 | } |
1152 | kfree_skb(skb); | 1156 | kfree_skb(skb); |
1153 | 1157 | ||
@@ -1161,7 +1165,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1161 | if (IS_ERR(skb)) { | 1165 | if (IS_ERR(skb)) { |
1162 | BT_ERR("%s reading Intel fw version command failed (%ld)", | 1166 | BT_ERR("%s reading Intel fw version command failed (%ld)", |
1163 | hdev->name, PTR_ERR(skb)); | 1167 | hdev->name, PTR_ERR(skb)); |
1164 | return -PTR_ERR(skb); | 1168 | return PTR_ERR(skb); |
1165 | } | 1169 | } |
1166 | 1170 | ||
1167 | if (skb->len != sizeof(*ver)) { | 1171 | if (skb->len != sizeof(*ver)) { |
@@ -1219,7 +1223,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1219 | BT_ERR("%s entering Intel manufacturer mode failed (%ld)", | 1223 | BT_ERR("%s entering Intel manufacturer mode failed (%ld)", |
1220 | hdev->name, PTR_ERR(skb)); | 1224 | hdev->name, PTR_ERR(skb)); |
1221 | release_firmware(fw); | 1225 | release_firmware(fw); |
1222 | return -PTR_ERR(skb); | 1226 | return PTR_ERR(skb); |
1223 | } | 1227 | } |
1224 | 1228 | ||
1225 | if (skb->data[0]) { | 1229 | if (skb->data[0]) { |
@@ -1276,7 +1280,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1276 | if (IS_ERR(skb)) { | 1280 | if (IS_ERR(skb)) { |
1277 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1281 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1278 | hdev->name, PTR_ERR(skb)); | 1282 | hdev->name, PTR_ERR(skb)); |
1279 | return -PTR_ERR(skb); | 1283 | return PTR_ERR(skb); |
1280 | } | 1284 | } |
1281 | kfree_skb(skb); | 1285 | kfree_skb(skb); |
1282 | 1286 | ||
@@ -1292,7 +1296,7 @@ exit_mfg_disable: | |||
1292 | if (IS_ERR(skb)) { | 1296 | if (IS_ERR(skb)) { |
1293 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1297 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1294 | hdev->name, PTR_ERR(skb)); | 1298 | hdev->name, PTR_ERR(skb)); |
1295 | return -PTR_ERR(skb); | 1299 | return PTR_ERR(skb); |
1296 | } | 1300 | } |
1297 | kfree_skb(skb); | 1301 | kfree_skb(skb); |
1298 | 1302 | ||
@@ -1310,7 +1314,7 @@ exit_mfg_deactivate: | |||
1310 | if (IS_ERR(skb)) { | 1314 | if (IS_ERR(skb)) { |
1311 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1315 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1312 | hdev->name, PTR_ERR(skb)); | 1316 | hdev->name, PTR_ERR(skb)); |
1313 | return -PTR_ERR(skb); | 1317 | return PTR_ERR(skb); |
1314 | } | 1318 | } |
1315 | kfree_skb(skb); | 1319 | kfree_skb(skb); |
1316 | 1320 | ||
diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig index 1d680baf43d6..7b839bf5bb7a 100644 --- a/drivers/net/ethernet/broadcom/Kconfig +++ b/drivers/net/ethernet/broadcom/Kconfig | |||
@@ -130,7 +130,7 @@ config BNX2X_SRIOV | |||
130 | 130 | ||
131 | config BGMAC | 131 | config BGMAC |
132 | tristate "BCMA bus GBit core support" | 132 | tristate "BCMA bus GBit core support" |
133 | depends on BCMA_HOST_SOC && HAS_DMA | 133 | depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX |
134 | ---help--- | 134 | ---help--- |
135 | This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. | 135 | This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. |
136 | They can be found on BCM47xx SoCs and provide gigabit ethernet. | 136 | They can be found on BCM47xx SoCs and provide gigabit ethernet. |
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index daeafeff186b..e0ba7cd14252 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h | |||
@@ -159,7 +159,7 @@ struct ath_common { | |||
159 | 159 | ||
160 | bool btcoex_enabled; | 160 | bool btcoex_enabled; |
161 | bool disable_ani; | 161 | bool disable_ani; |
162 | bool antenna_diversity; | 162 | bool bt_ant_diversity; |
163 | }; | 163 | }; |
164 | 164 | ||
165 | struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, | 165 | struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, |
diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index cde58fe96254..82e8088ca9b4 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config ATH10K | 1 | config ATH10K |
2 | tristate "Atheros 802.11ac wireless cards support" | 2 | tristate "Atheros 802.11ac wireless cards support" |
3 | depends on MAC80211 | 3 | depends on MAC80211 && HAS_DMA |
4 | select ATH_COMMON | 4 | select ATH_COMMON |
5 | ---help--- | 5 | ---help--- |
6 | This module adds support for wireless adapters based on | 6 | This module adds support for wireless adapters based on |
diff --git a/drivers/net/wireless/ath/ath10k/bmi.c b/drivers/net/wireless/ath/ath10k/bmi.c index 1a2ef51b69d9..744da6d1c405 100644 --- a/drivers/net/wireless/ath/ath10k/bmi.c +++ b/drivers/net/wireless/ath/ath10k/bmi.c | |||
@@ -20,6 +20,12 @@ | |||
20 | #include "debug.h" | 20 | #include "debug.h" |
21 | #include "htc.h" | 21 | #include "htc.h" |
22 | 22 | ||
23 | void ath10k_bmi_start(struct ath10k *ar) | ||
24 | { | ||
25 | ath10k_dbg(ATH10K_DBG_CORE, "BMI started\n"); | ||
26 | ar->bmi.done_sent = false; | ||
27 | } | ||
28 | |||
23 | int ath10k_bmi_done(struct ath10k *ar) | 29 | int ath10k_bmi_done(struct ath10k *ar) |
24 | { | 30 | { |
25 | struct bmi_cmd cmd; | 31 | struct bmi_cmd cmd; |
@@ -105,7 +111,8 @@ int ath10k_bmi_read_memory(struct ath10k *ar, | |||
105 | ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, | 111 | ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, |
106 | &resp, &rxlen); | 112 | &resp, &rxlen); |
107 | if (ret) { | 113 | if (ret) { |
108 | ath10k_warn("unable to read from the device\n"); | 114 | ath10k_warn("unable to read from the device (%d)\n", |
115 | ret); | ||
109 | return ret; | 116 | return ret; |
110 | } | 117 | } |
111 | 118 | ||
@@ -149,7 +156,8 @@ int ath10k_bmi_write_memory(struct ath10k *ar, | |||
149 | ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, hdrlen + txlen, | 156 | ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, hdrlen + txlen, |
150 | NULL, NULL); | 157 | NULL, NULL); |
151 | if (ret) { | 158 | if (ret) { |
152 | ath10k_warn("unable to write to the device\n"); | 159 | ath10k_warn("unable to write to the device (%d)\n", |
160 | ret); | ||
153 | return ret; | 161 | return ret; |
154 | } | 162 | } |
155 | 163 | ||
diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h index 32c56aa33a5e..8d81ce1cec21 100644 --- a/drivers/net/wireless/ath/ath10k/bmi.h +++ b/drivers/net/wireless/ath/ath10k/bmi.h | |||
@@ -184,6 +184,7 @@ struct bmi_target_info { | |||
184 | #define BMI_CE_NUM_TO_TARG 0 | 184 | #define BMI_CE_NUM_TO_TARG 0 |
185 | #define BMI_CE_NUM_TO_HOST 1 | 185 | #define BMI_CE_NUM_TO_HOST 1 |
186 | 186 | ||
187 | void ath10k_bmi_start(struct ath10k *ar); | ||
187 | int ath10k_bmi_done(struct ath10k *ar); | 188 | int ath10k_bmi_done(struct ath10k *ar); |
188 | int ath10k_bmi_get_target_info(struct ath10k *ar, | 189 | int ath10k_bmi_get_target_info(struct ath10k *ar, |
189 | struct bmi_target_info *target_info); | 190 | struct bmi_target_info *target_info); |
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c index 61a8ac70d3ca..f8b969f518f8 100644 --- a/drivers/net/wireless/ath/ath10k/ce.c +++ b/drivers/net/wireless/ath/ath10k/ce.c | |||
@@ -79,7 +79,7 @@ static inline void ath10k_ce_src_ring_write_index_set(struct ath10k *ar, | |||
79 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | 79 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
80 | void __iomem *indicator_addr; | 80 | void __iomem *indicator_addr; |
81 | 81 | ||
82 | if (!test_bit(ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND, ar_pci->features)) { | 82 | if (!test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) { |
83 | ath10k_pci_write32(ar, ce_ctrl_addr + SR_WR_INDEX_ADDRESS, n); | 83 | ath10k_pci_write32(ar, ce_ctrl_addr + SR_WR_INDEX_ADDRESS, n); |
84 | return; | 84 | return; |
85 | } | 85 | } |
@@ -637,6 +637,7 @@ static int ath10k_ce_completed_send_next_nolock(struct ce_state *ce_state, | |||
637 | ath10k_pci_wake(ar); | 637 | ath10k_pci_wake(ar); |
638 | src_ring->hw_index = | 638 | src_ring->hw_index = |
639 | ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); | 639 | ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); |
640 | src_ring->hw_index &= nentries_mask; | ||
640 | ath10k_pci_sleep(ar); | 641 | ath10k_pci_sleep(ar); |
641 | } | 642 | } |
642 | read_index = src_ring->hw_index; | 643 | read_index = src_ring->hw_index; |
@@ -950,10 +951,12 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, | |||
950 | 951 | ||
951 | ath10k_pci_wake(ar); | 952 | ath10k_pci_wake(ar); |
952 | src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); | 953 | src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); |
954 | src_ring->sw_index &= src_ring->nentries_mask; | ||
953 | src_ring->hw_index = src_ring->sw_index; | 955 | src_ring->hw_index = src_ring->sw_index; |
954 | 956 | ||
955 | src_ring->write_index = | 957 | src_ring->write_index = |
956 | ath10k_ce_src_ring_write_index_get(ar, ctrl_addr); | 958 | ath10k_ce_src_ring_write_index_get(ar, ctrl_addr); |
959 | src_ring->write_index &= src_ring->nentries_mask; | ||
957 | ath10k_pci_sleep(ar); | 960 | ath10k_pci_sleep(ar); |
958 | 961 | ||
959 | src_ring->per_transfer_context = (void **)ptr; | 962 | src_ring->per_transfer_context = (void **)ptr; |
@@ -1035,8 +1038,10 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar, | |||
1035 | 1038 | ||
1036 | ath10k_pci_wake(ar); | 1039 | ath10k_pci_wake(ar); |
1037 | dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr); | 1040 | dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr); |
1041 | dest_ring->sw_index &= dest_ring->nentries_mask; | ||
1038 | dest_ring->write_index = | 1042 | dest_ring->write_index = |
1039 | ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr); | 1043 | ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr); |
1044 | dest_ring->write_index &= dest_ring->nentries_mask; | ||
1040 | ath10k_pci_sleep(ar); | 1045 | ath10k_pci_sleep(ar); |
1041 | 1046 | ||
1042 | dest_ring->per_transfer_context = (void **)ptr; | 1047 | dest_ring->per_transfer_context = (void **)ptr; |
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 2b3426b1ff3f..7226c23b9569 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c | |||
@@ -100,7 +100,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar) | |||
100 | goto conn_fail; | 100 | goto conn_fail; |
101 | 101 | ||
102 | /* Start HTC */ | 102 | /* Start HTC */ |
103 | status = ath10k_htc_start(ar->htc); | 103 | status = ath10k_htc_start(&ar->htc); |
104 | if (status) | 104 | if (status) |
105 | goto conn_fail; | 105 | goto conn_fail; |
106 | 106 | ||
@@ -116,7 +116,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar) | |||
116 | return 0; | 116 | return 0; |
117 | 117 | ||
118 | timeout: | 118 | timeout: |
119 | ath10k_htc_stop(ar->htc); | 119 | ath10k_htc_stop(&ar->htc); |
120 | conn_fail: | 120 | conn_fail: |
121 | return status; | 121 | return status; |
122 | } | 122 | } |
@@ -247,19 +247,11 @@ static int ath10k_push_board_ext_data(struct ath10k *ar, | |||
247 | 247 | ||
248 | static int ath10k_download_board_data(struct ath10k *ar) | 248 | static int ath10k_download_board_data(struct ath10k *ar) |
249 | { | 249 | { |
250 | const struct firmware *fw = ar->board_data; | ||
250 | u32 board_data_size = QCA988X_BOARD_DATA_SZ; | 251 | u32 board_data_size = QCA988X_BOARD_DATA_SZ; |
251 | u32 address; | 252 | u32 address; |
252 | const struct firmware *fw; | ||
253 | int ret; | 253 | int ret; |
254 | 254 | ||
255 | fw = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, | ||
256 | ar->hw_params.fw.board); | ||
257 | if (IS_ERR(fw)) { | ||
258 | ath10k_err("could not fetch board data fw file (%ld)\n", | ||
259 | PTR_ERR(fw)); | ||
260 | return PTR_ERR(fw); | ||
261 | } | ||
262 | |||
263 | ret = ath10k_push_board_ext_data(ar, fw); | 255 | ret = ath10k_push_board_ext_data(ar, fw); |
264 | if (ret) { | 256 | if (ret) { |
265 | ath10k_err("could not push board ext data (%d)\n", ret); | 257 | ath10k_err("could not push board ext data (%d)\n", ret); |
@@ -286,32 +278,20 @@ static int ath10k_download_board_data(struct ath10k *ar) | |||
286 | } | 278 | } |
287 | 279 | ||
288 | exit: | 280 | exit: |
289 | release_firmware(fw); | ||
290 | return ret; | 281 | return ret; |
291 | } | 282 | } |
292 | 283 | ||
293 | static int ath10k_download_and_run_otp(struct ath10k *ar) | 284 | static int ath10k_download_and_run_otp(struct ath10k *ar) |
294 | { | 285 | { |
295 | const struct firmware *fw; | 286 | const struct firmware *fw = ar->otp; |
296 | u32 address; | 287 | u32 address = ar->hw_params.patch_load_addr; |
297 | u32 exec_param; | 288 | u32 exec_param; |
298 | int ret; | 289 | int ret; |
299 | 290 | ||
300 | /* OTP is optional */ | 291 | /* OTP is optional */ |
301 | 292 | ||
302 | if (ar->hw_params.fw.otp == NULL) { | 293 | if (!ar->otp) |
303 | ath10k_info("otp file not defined\n"); | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | address = ar->hw_params.patch_load_addr; | ||
308 | |||
309 | fw = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, | ||
310 | ar->hw_params.fw.otp); | ||
311 | if (IS_ERR(fw)) { | ||
312 | ath10k_warn("could not fetch otp (%ld)\n", PTR_ERR(fw)); | ||
313 | return 0; | 294 | return 0; |
314 | } | ||
315 | 295 | ||
316 | ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); | 296 | ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); |
317 | if (ret) { | 297 | if (ret) { |
@@ -327,28 +307,17 @@ static int ath10k_download_and_run_otp(struct ath10k *ar) | |||
327 | } | 307 | } |
328 | 308 | ||
329 | exit: | 309 | exit: |
330 | release_firmware(fw); | ||
331 | return ret; | 310 | return ret; |
332 | } | 311 | } |
333 | 312 | ||
334 | static int ath10k_download_fw(struct ath10k *ar) | 313 | static int ath10k_download_fw(struct ath10k *ar) |
335 | { | 314 | { |
336 | const struct firmware *fw; | 315 | const struct firmware *fw = ar->firmware; |
337 | u32 address; | 316 | u32 address; |
338 | int ret; | 317 | int ret; |
339 | 318 | ||
340 | if (ar->hw_params.fw.fw == NULL) | ||
341 | return -EINVAL; | ||
342 | |||
343 | address = ar->hw_params.patch_load_addr; | 319 | address = ar->hw_params.patch_load_addr; |
344 | 320 | ||
345 | fw = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, | ||
346 | ar->hw_params.fw.fw); | ||
347 | if (IS_ERR(fw)) { | ||
348 | ath10k_err("could not fetch fw (%ld)\n", PTR_ERR(fw)); | ||
349 | return PTR_ERR(fw); | ||
350 | } | ||
351 | |||
352 | ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); | 321 | ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); |
353 | if (ret) { | 322 | if (ret) { |
354 | ath10k_err("could not write fw (%d)\n", ret); | 323 | ath10k_err("could not write fw (%d)\n", ret); |
@@ -356,7 +325,74 @@ static int ath10k_download_fw(struct ath10k *ar) | |||
356 | } | 325 | } |
357 | 326 | ||
358 | exit: | 327 | exit: |
359 | release_firmware(fw); | 328 | return ret; |
329 | } | ||
330 | |||
331 | static void ath10k_core_free_firmware_files(struct ath10k *ar) | ||
332 | { | ||
333 | if (ar->board_data && !IS_ERR(ar->board_data)) | ||
334 | release_firmware(ar->board_data); | ||
335 | |||
336 | if (ar->otp && !IS_ERR(ar->otp)) | ||
337 | release_firmware(ar->otp); | ||
338 | |||
339 | if (ar->firmware && !IS_ERR(ar->firmware)) | ||
340 | release_firmware(ar->firmware); | ||
341 | |||
342 | ar->board_data = NULL; | ||
343 | ar->otp = NULL; | ||
344 | ar->firmware = NULL; | ||
345 | } | ||
346 | |||
347 | static int ath10k_core_fetch_firmware_files(struct ath10k *ar) | ||
348 | { | ||
349 | int ret = 0; | ||
350 | |||
351 | if (ar->hw_params.fw.fw == NULL) { | ||
352 | ath10k_err("firmware file not defined\n"); | ||
353 | return -EINVAL; | ||
354 | } | ||
355 | |||
356 | if (ar->hw_params.fw.board == NULL) { | ||
357 | ath10k_err("board data file not defined"); | ||
358 | return -EINVAL; | ||
359 | } | ||
360 | |||
361 | ar->board_data = ath10k_fetch_fw_file(ar, | ||
362 | ar->hw_params.fw.dir, | ||
363 | ar->hw_params.fw.board); | ||
364 | if (IS_ERR(ar->board_data)) { | ||
365 | ret = PTR_ERR(ar->board_data); | ||
366 | ath10k_err("could not fetch board data (%d)\n", ret); | ||
367 | goto err; | ||
368 | } | ||
369 | |||
370 | ar->firmware = ath10k_fetch_fw_file(ar, | ||
371 | ar->hw_params.fw.dir, | ||
372 | ar->hw_params.fw.fw); | ||
373 | if (IS_ERR(ar->firmware)) { | ||
374 | ret = PTR_ERR(ar->firmware); | ||
375 | ath10k_err("could not fetch firmware (%d)\n", ret); | ||
376 | goto err; | ||
377 | } | ||
378 | |||
379 | /* OTP may be undefined. If so, don't fetch it at all */ | ||
380 | if (ar->hw_params.fw.otp == NULL) | ||
381 | return 0; | ||
382 | |||
383 | ar->otp = ath10k_fetch_fw_file(ar, | ||
384 | ar->hw_params.fw.dir, | ||
385 | ar->hw_params.fw.otp); | ||
386 | if (IS_ERR(ar->otp)) { | ||
387 | ret = PTR_ERR(ar->otp); | ||
388 | ath10k_err("could not fetch otp (%d)\n", ret); | ||
389 | goto err; | ||
390 | } | ||
391 | |||
392 | return 0; | ||
393 | |||
394 | err: | ||
395 | ath10k_core_free_firmware_files(ar); | ||
360 | return ret; | 396 | return ret; |
361 | } | 397 | } |
362 | 398 | ||
@@ -440,8 +476,35 @@ static int ath10k_init_hw_params(struct ath10k *ar) | |||
440 | return 0; | 476 | return 0; |
441 | } | 477 | } |
442 | 478 | ||
479 | static void ath10k_core_restart(struct work_struct *work) | ||
480 | { | ||
481 | struct ath10k *ar = container_of(work, struct ath10k, restart_work); | ||
482 | |||
483 | mutex_lock(&ar->conf_mutex); | ||
484 | |||
485 | switch (ar->state) { | ||
486 | case ATH10K_STATE_ON: | ||
487 | ath10k_halt(ar); | ||
488 | ar->state = ATH10K_STATE_RESTARTING; | ||
489 | ieee80211_restart_hw(ar->hw); | ||
490 | break; | ||
491 | case ATH10K_STATE_OFF: | ||
492 | /* this can happen if driver is being unloaded */ | ||
493 | ath10k_warn("cannot restart a device that hasn't been started\n"); | ||
494 | break; | ||
495 | case ATH10K_STATE_RESTARTING: | ||
496 | case ATH10K_STATE_RESTARTED: | ||
497 | ar->state = ATH10K_STATE_WEDGED; | ||
498 | /* fall through */ | ||
499 | case ATH10K_STATE_WEDGED: | ||
500 | ath10k_warn("device is wedged, will not restart\n"); | ||
501 | break; | ||
502 | } | ||
503 | |||
504 | mutex_unlock(&ar->conf_mutex); | ||
505 | } | ||
506 | |||
443 | struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, | 507 | struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, |
444 | enum ath10k_bus bus, | ||
445 | const struct ath10k_hif_ops *hif_ops) | 508 | const struct ath10k_hif_ops *hif_ops) |
446 | { | 509 | { |
447 | struct ath10k *ar; | 510 | struct ath10k *ar; |
@@ -458,9 +521,6 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, | |||
458 | 521 | ||
459 | ar->hif.priv = hif_priv; | 522 | ar->hif.priv = hif_priv; |
460 | ar->hif.ops = hif_ops; | 523 | ar->hif.ops = hif_ops; |
461 | ar->hif.bus = bus; | ||
462 | |||
463 | ar->free_vdev_map = 0xFF; /* 8 vdevs */ | ||
464 | 524 | ||
465 | init_completion(&ar->scan.started); | 525 | init_completion(&ar->scan.started); |
466 | init_completion(&ar->scan.completed); | 526 | init_completion(&ar->scan.completed); |
@@ -487,6 +547,8 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, | |||
487 | 547 | ||
488 | init_waitqueue_head(&ar->event_queue); | 548 | init_waitqueue_head(&ar->event_queue); |
489 | 549 | ||
550 | INIT_WORK(&ar->restart_work, ath10k_core_restart); | ||
551 | |||
490 | return ar; | 552 | return ar; |
491 | 553 | ||
492 | err_wq: | 554 | err_wq: |
@@ -504,24 +566,11 @@ void ath10k_core_destroy(struct ath10k *ar) | |||
504 | } | 566 | } |
505 | EXPORT_SYMBOL(ath10k_core_destroy); | 567 | EXPORT_SYMBOL(ath10k_core_destroy); |
506 | 568 | ||
507 | 569 | int ath10k_core_start(struct ath10k *ar) | |
508 | int ath10k_core_register(struct ath10k *ar) | ||
509 | { | 570 | { |
510 | struct ath10k_htc_ops htc_ops; | ||
511 | struct bmi_target_info target_info; | ||
512 | int status; | 571 | int status; |
513 | 572 | ||
514 | memset(&target_info, 0, sizeof(target_info)); | 573 | ath10k_bmi_start(ar); |
515 | status = ath10k_bmi_get_target_info(ar, &target_info); | ||
516 | if (status) | ||
517 | goto err; | ||
518 | |||
519 | ar->target_version = target_info.version; | ||
520 | ar->hw->wiphy->hw_version = target_info.version; | ||
521 | |||
522 | status = ath10k_init_hw_params(ar); | ||
523 | if (status) | ||
524 | goto err; | ||
525 | 574 | ||
526 | if (ath10k_init_configure_target(ar)) { | 575 | if (ath10k_init_configure_target(ar)) { |
527 | status = -EINVAL; | 576 | status = -EINVAL; |
@@ -536,32 +585,32 @@ int ath10k_core_register(struct ath10k *ar) | |||
536 | if (status) | 585 | if (status) |
537 | goto err; | 586 | goto err; |
538 | 587 | ||
539 | htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete; | 588 | ar->htc.htc_ops.target_send_suspend_complete = |
589 | ath10k_send_suspend_complete; | ||
540 | 590 | ||
541 | ar->htc = ath10k_htc_create(ar, &htc_ops); | 591 | status = ath10k_htc_init(ar); |
542 | if (IS_ERR(ar->htc)) { | 592 | if (status) { |
543 | status = PTR_ERR(ar->htc); | 593 | ath10k_err("could not init HTC (%d)\n", status); |
544 | ath10k_err("could not create HTC (%d)\n", status); | ||
545 | goto err; | 594 | goto err; |
546 | } | 595 | } |
547 | 596 | ||
548 | status = ath10k_bmi_done(ar); | 597 | status = ath10k_bmi_done(ar); |
549 | if (status) | 598 | if (status) |
550 | goto err_htc_destroy; | 599 | goto err; |
551 | 600 | ||
552 | status = ath10k_wmi_attach(ar); | 601 | status = ath10k_wmi_attach(ar); |
553 | if (status) { | 602 | if (status) { |
554 | ath10k_err("WMI attach failed: %d\n", status); | 603 | ath10k_err("WMI attach failed: %d\n", status); |
555 | goto err_htc_destroy; | 604 | goto err; |
556 | } | 605 | } |
557 | 606 | ||
558 | status = ath10k_htc_wait_target(ar->htc); | 607 | status = ath10k_htc_wait_target(&ar->htc); |
559 | if (status) | 608 | if (status) |
560 | goto err_wmi_detach; | 609 | goto err_wmi_detach; |
561 | 610 | ||
562 | ar->htt = ath10k_htt_attach(ar); | 611 | status = ath10k_htt_attach(ar); |
563 | if (!ar->htt) { | 612 | if (status) { |
564 | status = -ENOMEM; | 613 | ath10k_err("could not attach htt (%d)\n", status); |
565 | goto err_wmi_detach; | 614 | goto err_wmi_detach; |
566 | } | 615 | } |
567 | 616 | ||
@@ -588,77 +637,127 @@ int ath10k_core_register(struct ath10k *ar) | |||
588 | goto err_disconnect_htc; | 637 | goto err_disconnect_htc; |
589 | } | 638 | } |
590 | 639 | ||
591 | status = ath10k_htt_attach_target(ar->htt); | 640 | status = ath10k_htt_attach_target(&ar->htt); |
592 | if (status) | ||
593 | goto err_disconnect_htc; | ||
594 | |||
595 | status = ath10k_mac_register(ar); | ||
596 | if (status) | 641 | if (status) |
597 | goto err_disconnect_htc; | 642 | goto err_disconnect_htc; |
598 | 643 | ||
599 | status = ath10k_debug_create(ar); | 644 | ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1; |
600 | if (status) { | ||
601 | ath10k_err("unable to initialize debugfs\n"); | ||
602 | goto err_unregister_mac; | ||
603 | } | ||
604 | 645 | ||
605 | return 0; | 646 | return 0; |
606 | 647 | ||
607 | err_unregister_mac: | ||
608 | ath10k_mac_unregister(ar); | ||
609 | err_disconnect_htc: | 648 | err_disconnect_htc: |
610 | ath10k_htc_stop(ar->htc); | 649 | ath10k_htc_stop(&ar->htc); |
611 | err_htt_detach: | 650 | err_htt_detach: |
612 | ath10k_htt_detach(ar->htt); | 651 | ath10k_htt_detach(&ar->htt); |
613 | err_wmi_detach: | 652 | err_wmi_detach: |
614 | ath10k_wmi_detach(ar); | 653 | ath10k_wmi_detach(ar); |
615 | err_htc_destroy: | ||
616 | ath10k_htc_destroy(ar->htc); | ||
617 | err: | 654 | err: |
618 | return status; | 655 | return status; |
619 | } | 656 | } |
620 | EXPORT_SYMBOL(ath10k_core_register); | 657 | EXPORT_SYMBOL(ath10k_core_start); |
621 | 658 | ||
622 | void ath10k_core_unregister(struct ath10k *ar) | 659 | void ath10k_core_stop(struct ath10k *ar) |
623 | { | 660 | { |
624 | /* We must unregister from mac80211 before we stop HTC and HIF. | 661 | ath10k_htc_stop(&ar->htc); |
625 | * Otherwise we will fail to submit commands to FW and mac80211 will be | 662 | ath10k_htt_detach(&ar->htt); |
626 | * unhappy about callback failures. */ | ||
627 | ath10k_mac_unregister(ar); | ||
628 | ath10k_htc_stop(ar->htc); | ||
629 | ath10k_htt_detach(ar->htt); | ||
630 | ath10k_wmi_detach(ar); | 663 | ath10k_wmi_detach(ar); |
631 | ath10k_htc_destroy(ar->htc); | ||
632 | } | 664 | } |
633 | EXPORT_SYMBOL(ath10k_core_unregister); | 665 | EXPORT_SYMBOL(ath10k_core_stop); |
634 | 666 | ||
635 | int ath10k_core_target_suspend(struct ath10k *ar) | 667 | /* mac80211 manages fw/hw initialization through start/stop hooks. However in |
668 | * order to know what hw capabilities should be advertised to mac80211 it is | ||
669 | * necessary to load the firmware (and tear it down immediately since start | ||
670 | * hook will try to init it again) before registering */ | ||
671 | static int ath10k_core_probe_fw(struct ath10k *ar) | ||
636 | { | 672 | { |
637 | int ret; | 673 | struct bmi_target_info target_info; |
674 | int ret = 0; | ||
675 | |||
676 | ret = ath10k_hif_power_up(ar); | ||
677 | if (ret) { | ||
678 | ath10k_err("could not start pci hif (%d)\n", ret); | ||
679 | return ret; | ||
680 | } | ||
638 | 681 | ||
639 | ath10k_dbg(ATH10K_DBG_CORE, "%s: called", __func__); | 682 | memset(&target_info, 0, sizeof(target_info)); |
683 | ret = ath10k_bmi_get_target_info(ar, &target_info); | ||
684 | if (ret) { | ||
685 | ath10k_err("could not get target info (%d)\n", ret); | ||
686 | ath10k_hif_power_down(ar); | ||
687 | return ret; | ||
688 | } | ||
640 | 689 | ||
641 | ret = ath10k_wmi_pdev_suspend_target(ar); | 690 | ar->target_version = target_info.version; |
642 | if (ret) | 691 | ar->hw->wiphy->hw_version = target_info.version; |
643 | ath10k_warn("could not suspend target (%d)\n", ret); | ||
644 | 692 | ||
645 | return ret; | 693 | ret = ath10k_init_hw_params(ar); |
694 | if (ret) { | ||
695 | ath10k_err("could not get hw params (%d)\n", ret); | ||
696 | ath10k_hif_power_down(ar); | ||
697 | return ret; | ||
698 | } | ||
699 | |||
700 | ret = ath10k_core_fetch_firmware_files(ar); | ||
701 | if (ret) { | ||
702 | ath10k_err("could not fetch firmware files (%d)\n", ret); | ||
703 | ath10k_hif_power_down(ar); | ||
704 | return ret; | ||
705 | } | ||
706 | |||
707 | ret = ath10k_core_start(ar); | ||
708 | if (ret) { | ||
709 | ath10k_err("could not init core (%d)\n", ret); | ||
710 | ath10k_core_free_firmware_files(ar); | ||
711 | ath10k_hif_power_down(ar); | ||
712 | return ret; | ||
713 | } | ||
714 | |||
715 | ath10k_core_stop(ar); | ||
716 | ath10k_hif_power_down(ar); | ||
717 | return 0; | ||
646 | } | 718 | } |
647 | EXPORT_SYMBOL(ath10k_core_target_suspend); | ||
648 | 719 | ||
649 | int ath10k_core_target_resume(struct ath10k *ar) | 720 | int ath10k_core_register(struct ath10k *ar) |
650 | { | 721 | { |
651 | int ret; | 722 | int status; |
652 | 723 | ||
653 | ath10k_dbg(ATH10K_DBG_CORE, "%s: called", __func__); | 724 | status = ath10k_core_probe_fw(ar); |
725 | if (status) { | ||
726 | ath10k_err("could not probe fw (%d)\n", status); | ||
727 | return status; | ||
728 | } | ||
654 | 729 | ||
655 | ret = ath10k_wmi_pdev_resume_target(ar); | 730 | status = ath10k_mac_register(ar); |
656 | if (ret) | 731 | if (status) { |
657 | ath10k_warn("could not resume target (%d)\n", ret); | 732 | ath10k_err("could not register to mac80211 (%d)\n", status); |
733 | goto err_release_fw; | ||
734 | } | ||
658 | 735 | ||
659 | return ret; | 736 | status = ath10k_debug_create(ar); |
737 | if (status) { | ||
738 | ath10k_err("unable to initialize debugfs\n"); | ||
739 | goto err_unregister_mac; | ||
740 | } | ||
741 | |||
742 | return 0; | ||
743 | |||
744 | err_unregister_mac: | ||
745 | ath10k_mac_unregister(ar); | ||
746 | err_release_fw: | ||
747 | ath10k_core_free_firmware_files(ar); | ||
748 | return status; | ||
749 | } | ||
750 | EXPORT_SYMBOL(ath10k_core_register); | ||
751 | |||
752 | void ath10k_core_unregister(struct ath10k *ar) | ||
753 | { | ||
754 | /* We must unregister from mac80211 before we stop HTC and HIF. | ||
755 | * Otherwise we will fail to submit commands to FW and mac80211 will be | ||
756 | * unhappy about callback failures. */ | ||
757 | ath10k_mac_unregister(ar); | ||
758 | ath10k_core_free_firmware_files(ar); | ||
660 | } | 759 | } |
661 | EXPORT_SYMBOL(ath10k_core_target_resume); | 760 | EXPORT_SYMBOL(ath10k_core_unregister); |
662 | 761 | ||
663 | MODULE_AUTHOR("Qualcomm Atheros"); | 762 | MODULE_AUTHOR("Qualcomm Atheros"); |
664 | MODULE_DESCRIPTION("Core module for QCA988X PCIe devices."); | 763 | MODULE_DESCRIPTION("Core module for QCA988X PCIe devices."); |
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 539336d1be4b..e4bba563ed42 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
25 | 25 | ||
26 | #include "htt.h" | ||
26 | #include "htc.h" | 27 | #include "htc.h" |
27 | #include "hw.h" | 28 | #include "hw.h" |
28 | #include "targaddrs.h" | 29 | #include "targaddrs.h" |
@@ -37,16 +38,13 @@ | |||
37 | #define ATH10K_SCAN_ID 0 | 38 | #define ATH10K_SCAN_ID 0 |
38 | #define WMI_READY_TIMEOUT (5 * HZ) | 39 | #define WMI_READY_TIMEOUT (5 * HZ) |
39 | #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ) | 40 | #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ) |
41 | #define ATH10K_NUM_CHANS 38 | ||
40 | 42 | ||
41 | /* Antenna noise floor */ | 43 | /* Antenna noise floor */ |
42 | #define ATH10K_DEFAULT_NOISE_FLOOR -95 | 44 | #define ATH10K_DEFAULT_NOISE_FLOOR -95 |
43 | 45 | ||
44 | struct ath10k; | 46 | struct ath10k; |
45 | 47 | ||
46 | enum ath10k_bus { | ||
47 | ATH10K_BUS_PCI, | ||
48 | }; | ||
49 | |||
50 | struct ath10k_skb_cb { | 48 | struct ath10k_skb_cb { |
51 | dma_addr_t paddr; | 49 | dma_addr_t paddr; |
52 | bool is_mapped; | 50 | bool is_mapped; |
@@ -250,6 +248,28 @@ struct ath10k_debug { | |||
250 | struct completion event_stats_compl; | 248 | struct completion event_stats_compl; |
251 | }; | 249 | }; |
252 | 250 | ||
251 | enum ath10k_state { | ||
252 | ATH10K_STATE_OFF = 0, | ||
253 | ATH10K_STATE_ON, | ||
254 | |||
255 | /* When doing firmware recovery the device is first powered down. | ||
256 | * mac80211 is supposed to call in to start() hook later on. It is | ||
257 | * however possible that driver unloading and firmware crash overlap. | ||
258 | * mac80211 can wait on conf_mutex in stop() while the device is | ||
259 | * stopped in ath10k_core_restart() work holding conf_mutex. The state | ||
260 | * RESTARTED means that the device is up and mac80211 has started hw | ||
261 | * reconfiguration. Once mac80211 is done with the reconfiguration we | ||
262 | * set the state to STATE_ON in restart_complete(). */ | ||
263 | ATH10K_STATE_RESTARTING, | ||
264 | ATH10K_STATE_RESTARTED, | ||
265 | |||
266 | /* The device has crashed while restarting hw. This state is like ON | ||
267 | * but commands are blocked in HTC and -ECOMM response is given. This | ||
268 | * prevents completion timeouts and makes the driver more responsive to | ||
269 | * userspace commands. This is also prevents recursive recovery. */ | ||
270 | ATH10K_STATE_WEDGED, | ||
271 | }; | ||
272 | |||
253 | struct ath10k { | 273 | struct ath10k { |
254 | struct ath_common ath_common; | 274 | struct ath_common ath_common; |
255 | struct ieee80211_hw *hw; | 275 | struct ieee80211_hw *hw; |
@@ -266,6 +286,7 @@ struct ath10k { | |||
266 | u32 hw_max_tx_power; | 286 | u32 hw_max_tx_power; |
267 | u32 ht_cap_info; | 287 | u32 ht_cap_info; |
268 | u32 vht_cap_info; | 288 | u32 vht_cap_info; |
289 | u32 num_rf_chains; | ||
269 | 290 | ||
270 | struct targetdef *targetdef; | 291 | struct targetdef *targetdef; |
271 | struct hostdef *hostdef; | 292 | struct hostdef *hostdef; |
@@ -274,19 +295,16 @@ struct ath10k { | |||
274 | 295 | ||
275 | struct { | 296 | struct { |
276 | void *priv; | 297 | void *priv; |
277 | enum ath10k_bus bus; | ||
278 | const struct ath10k_hif_ops *ops; | 298 | const struct ath10k_hif_ops *ops; |
279 | } hif; | 299 | } hif; |
280 | 300 | ||
281 | struct ath10k_wmi wmi; | ||
282 | |||
283 | wait_queue_head_t event_queue; | 301 | wait_queue_head_t event_queue; |
284 | bool is_target_paused; | 302 | bool is_target_paused; |
285 | 303 | ||
286 | struct ath10k_bmi bmi; | 304 | struct ath10k_bmi bmi; |
287 | 305 | struct ath10k_wmi wmi; | |
288 | struct ath10k_htc *htc; | 306 | struct ath10k_htc htc; |
289 | struct ath10k_htt *htt; | 307 | struct ath10k_htt htt; |
290 | 308 | ||
291 | struct ath10k_hw_params { | 309 | struct ath10k_hw_params { |
292 | u32 id; | 310 | u32 id; |
@@ -301,6 +319,10 @@ struct ath10k { | |||
301 | } fw; | 319 | } fw; |
302 | } hw_params; | 320 | } hw_params; |
303 | 321 | ||
322 | const struct firmware *board_data; | ||
323 | const struct firmware *otp; | ||
324 | const struct firmware *firmware; | ||
325 | |||
304 | struct { | 326 | struct { |
305 | struct completion started; | 327 | struct completion started; |
306 | struct completion completed; | 328 | struct completion completed; |
@@ -350,20 +372,28 @@ struct ath10k { | |||
350 | struct completion offchan_tx_completed; | 372 | struct completion offchan_tx_completed; |
351 | struct sk_buff *offchan_tx_skb; | 373 | struct sk_buff *offchan_tx_skb; |
352 | 374 | ||
375 | enum ath10k_state state; | ||
376 | |||
377 | struct work_struct restart_work; | ||
378 | |||
379 | /* cycle count is reported twice for each visited channel during scan. | ||
380 | * access protected by data_lock */ | ||
381 | u32 survey_last_rx_clear_count; | ||
382 | u32 survey_last_cycle_count; | ||
383 | struct survey_info survey[ATH10K_NUM_CHANS]; | ||
384 | |||
353 | #ifdef CONFIG_ATH10K_DEBUGFS | 385 | #ifdef CONFIG_ATH10K_DEBUGFS |
354 | struct ath10k_debug debug; | 386 | struct ath10k_debug debug; |
355 | #endif | 387 | #endif |
356 | }; | 388 | }; |
357 | 389 | ||
358 | struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, | 390 | struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, |
359 | enum ath10k_bus bus, | ||
360 | const struct ath10k_hif_ops *hif_ops); | 391 | const struct ath10k_hif_ops *hif_ops); |
361 | void ath10k_core_destroy(struct ath10k *ar); | 392 | void ath10k_core_destroy(struct ath10k *ar); |
362 | 393 | ||
394 | int ath10k_core_start(struct ath10k *ar); | ||
395 | void ath10k_core_stop(struct ath10k *ar); | ||
363 | int ath10k_core_register(struct ath10k *ar); | 396 | int ath10k_core_register(struct ath10k *ar); |
364 | void ath10k_core_unregister(struct ath10k *ar); | 397 | void ath10k_core_unregister(struct ath10k *ar); |
365 | 398 | ||
366 | int ath10k_core_target_suspend(struct ath10k *ar); | ||
367 | int ath10k_core_target_resume(struct ath10k *ar); | ||
368 | |||
369 | #endif /* _CORE_H_ */ | 399 | #endif /* _CORE_H_ */ |
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index 499034b873d1..3d65594fa098 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c | |||
@@ -161,7 +161,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar, | |||
161 | struct wmi_pdev_stats *ps; | 161 | struct wmi_pdev_stats *ps; |
162 | int i; | 162 | int i; |
163 | 163 | ||
164 | mutex_lock(&ar->conf_mutex); | 164 | spin_lock_bh(&ar->data_lock); |
165 | 165 | ||
166 | stats = &ar->debug.target_stats; | 166 | stats = &ar->debug.target_stats; |
167 | 167 | ||
@@ -259,6 +259,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar, | |||
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | spin_unlock_bh(&ar->data_lock); | ||
262 | mutex_unlock(&ar->conf_mutex); | 263 | mutex_unlock(&ar->conf_mutex); |
263 | complete(&ar->debug.event_stats_compl); | 264 | complete(&ar->debug.event_stats_compl); |
264 | } | 265 | } |
@@ -268,35 +269,35 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf, | |||
268 | { | 269 | { |
269 | struct ath10k *ar = file->private_data; | 270 | struct ath10k *ar = file->private_data; |
270 | struct ath10k_target_stats *fw_stats; | 271 | struct ath10k_target_stats *fw_stats; |
271 | char *buf; | 272 | char *buf = NULL; |
272 | unsigned int len = 0, buf_len = 2500; | 273 | unsigned int len = 0, buf_len = 2500; |
273 | ssize_t ret_cnt; | 274 | ssize_t ret_cnt = 0; |
274 | long left; | 275 | long left; |
275 | int i; | 276 | int i; |
276 | int ret; | 277 | int ret; |
277 | 278 | ||
278 | fw_stats = &ar->debug.target_stats; | 279 | fw_stats = &ar->debug.target_stats; |
279 | 280 | ||
281 | mutex_lock(&ar->conf_mutex); | ||
282 | |||
283 | if (ar->state != ATH10K_STATE_ON) | ||
284 | goto exit; | ||
285 | |||
280 | buf = kzalloc(buf_len, GFP_KERNEL); | 286 | buf = kzalloc(buf_len, GFP_KERNEL); |
281 | if (!buf) | 287 | if (!buf) |
282 | return -ENOMEM; | 288 | goto exit; |
283 | 289 | ||
284 | ret = ath10k_wmi_request_stats(ar, WMI_REQUEST_PEER_STAT); | 290 | ret = ath10k_wmi_request_stats(ar, WMI_REQUEST_PEER_STAT); |
285 | if (ret) { | 291 | if (ret) { |
286 | ath10k_warn("could not request stats (%d)\n", ret); | 292 | ath10k_warn("could not request stats (%d)\n", ret); |
287 | kfree(buf); | 293 | goto exit; |
288 | return -EIO; | ||
289 | } | 294 | } |
290 | 295 | ||
291 | left = wait_for_completion_timeout(&ar->debug.event_stats_compl, 1*HZ); | 296 | left = wait_for_completion_timeout(&ar->debug.event_stats_compl, 1*HZ); |
297 | if (left <= 0) | ||
298 | goto exit; | ||
292 | 299 | ||
293 | if (left <= 0) { | 300 | spin_lock_bh(&ar->data_lock); |
294 | kfree(buf); | ||
295 | return -ETIMEDOUT; | ||
296 | } | ||
297 | |||
298 | mutex_lock(&ar->conf_mutex); | ||
299 | |||
300 | len += scnprintf(buf + len, buf_len - len, "\n"); | 301 | len += scnprintf(buf + len, buf_len - len, "\n"); |
301 | len += scnprintf(buf + len, buf_len - len, "%30s\n", | 302 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
302 | "ath10k PDEV stats"); | 303 | "ath10k PDEV stats"); |
@@ -424,14 +425,15 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf, | |||
424 | fw_stats->peer_stat[i].peer_tx_rate); | 425 | fw_stats->peer_stat[i].peer_tx_rate); |
425 | len += scnprintf(buf + len, buf_len - len, "\n"); | 426 | len += scnprintf(buf + len, buf_len - len, "\n"); |
426 | } | 427 | } |
428 | spin_unlock_bh(&ar->data_lock); | ||
427 | 429 | ||
428 | if (len > buf_len) | 430 | if (len > buf_len) |
429 | len = buf_len; | 431 | len = buf_len; |
430 | 432 | ||
431 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 433 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
432 | 434 | ||
435 | exit: | ||
433 | mutex_unlock(&ar->conf_mutex); | 436 | mutex_unlock(&ar->conf_mutex); |
434 | |||
435 | kfree(buf); | 437 | kfree(buf); |
436 | return ret_cnt; | 438 | return ret_cnt; |
437 | } | 439 | } |
@@ -443,6 +445,60 @@ static const struct file_operations fops_fw_stats = { | |||
443 | .llseek = default_llseek, | 445 | .llseek = default_llseek, |
444 | }; | 446 | }; |
445 | 447 | ||
448 | static ssize_t ath10k_read_simulate_fw_crash(struct file *file, | ||
449 | char __user *user_buf, | ||
450 | size_t count, loff_t *ppos) | ||
451 | { | ||
452 | const char buf[] = "To simulate firmware crash write the keyword" | ||
453 | " `crash` to this file.\nThis will force firmware" | ||
454 | " to report a crash to the host system.\n"; | ||
455 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | ||
456 | } | ||
457 | |||
458 | static ssize_t ath10k_write_simulate_fw_crash(struct file *file, | ||
459 | const char __user *user_buf, | ||
460 | size_t count, loff_t *ppos) | ||
461 | { | ||
462 | struct ath10k *ar = file->private_data; | ||
463 | char buf[32] = {}; | ||
464 | int ret; | ||
465 | |||
466 | mutex_lock(&ar->conf_mutex); | ||
467 | |||
468 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); | ||
469 | if (strcmp(buf, "crash") && strcmp(buf, "crash\n")) { | ||
470 | ret = -EINVAL; | ||
471 | goto exit; | ||
472 | } | ||
473 | |||
474 | if (ar->state != ATH10K_STATE_ON && | ||
475 | ar->state != ATH10K_STATE_RESTARTED) { | ||
476 | ret = -ENETDOWN; | ||
477 | goto exit; | ||
478 | } | ||
479 | |||
480 | ath10k_info("simulating firmware crash\n"); | ||
481 | |||
482 | ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0); | ||
483 | if (ret) | ||
484 | ath10k_warn("failed to force fw hang (%d)\n", ret); | ||
485 | |||
486 | if (ret == 0) | ||
487 | ret = count; | ||
488 | |||
489 | exit: | ||
490 | mutex_unlock(&ar->conf_mutex); | ||
491 | return ret; | ||
492 | } | ||
493 | |||
494 | static const struct file_operations fops_simulate_fw_crash = { | ||
495 | .read = ath10k_read_simulate_fw_crash, | ||
496 | .write = ath10k_write_simulate_fw_crash, | ||
497 | .open = simple_open, | ||
498 | .owner = THIS_MODULE, | ||
499 | .llseek = default_llseek, | ||
500 | }; | ||
501 | |||
446 | int ath10k_debug_create(struct ath10k *ar) | 502 | int ath10k_debug_create(struct ath10k *ar) |
447 | { | 503 | { |
448 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k", | 504 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k", |
@@ -459,6 +515,9 @@ int ath10k_debug_create(struct ath10k *ar) | |||
459 | debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar, | 515 | debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar, |
460 | &fops_wmi_services); | 516 | &fops_wmi_services); |
461 | 517 | ||
518 | debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy, | ||
519 | ar, &fops_simulate_fw_crash); | ||
520 | |||
462 | return 0; | 521 | return 0; |
463 | } | 522 | } |
464 | #endif /* CONFIG_ATH10K_DEBUGFS */ | 523 | #endif /* CONFIG_ATH10K_DEBUGFS */ |
diff --git a/drivers/net/wireless/ath/ath10k/hif.h b/drivers/net/wireless/ath/ath10k/hif.h index 73a24d44d1b4..dcdea68bcc0a 100644 --- a/drivers/net/wireless/ath/ath10k/hif.h +++ b/drivers/net/wireless/ath/ath10k/hif.h | |||
@@ -46,8 +46,11 @@ struct ath10k_hif_ops { | |||
46 | void *request, u32 request_len, | 46 | void *request, u32 request_len, |
47 | void *response, u32 *response_len); | 47 | void *response, u32 *response_len); |
48 | 48 | ||
49 | /* Post BMI phase, after FW is loaded. Starts regular operation */ | ||
49 | int (*start)(struct ath10k *ar); | 50 | int (*start)(struct ath10k *ar); |
50 | 51 | ||
52 | /* Clean up what start() did. This does not revert to BMI phase. If | ||
53 | * desired so, call power_down() and power_up() */ | ||
51 | void (*stop)(struct ath10k *ar); | 54 | void (*stop)(struct ath10k *ar); |
52 | 55 | ||
53 | int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id, | 56 | int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id, |
@@ -66,10 +69,20 @@ struct ath10k_hif_ops { | |||
66 | */ | 69 | */ |
67 | void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force); | 70 | void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force); |
68 | 71 | ||
69 | void (*init)(struct ath10k *ar, | 72 | void (*set_callbacks)(struct ath10k *ar, |
70 | struct ath10k_hif_cb *callbacks); | 73 | struct ath10k_hif_cb *callbacks); |
71 | 74 | ||
72 | u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id); | 75 | u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id); |
76 | |||
77 | /* Power up the device and enter BMI transfer mode for FW download */ | ||
78 | int (*power_up)(struct ath10k *ar); | ||
79 | |||
80 | /* Power down the device and free up resources. stop() must be called | ||
81 | * before this if start() was called earlier */ | ||
82 | void (*power_down)(struct ath10k *ar); | ||
83 | |||
84 | int (*suspend)(struct ath10k *ar); | ||
85 | int (*resume)(struct ath10k *ar); | ||
73 | }; | 86 | }; |
74 | 87 | ||
75 | 88 | ||
@@ -122,10 +135,10 @@ static inline void ath10k_hif_send_complete_check(struct ath10k *ar, | |||
122 | ar->hif.ops->send_complete_check(ar, pipe_id, force); | 135 | ar->hif.ops->send_complete_check(ar, pipe_id, force); |
123 | } | 136 | } |
124 | 137 | ||
125 | static inline void ath10k_hif_init(struct ath10k *ar, | 138 | static inline void ath10k_hif_set_callbacks(struct ath10k *ar, |
126 | struct ath10k_hif_cb *callbacks) | 139 | struct ath10k_hif_cb *callbacks) |
127 | { | 140 | { |
128 | ar->hif.ops->init(ar, callbacks); | 141 | ar->hif.ops->set_callbacks(ar, callbacks); |
129 | } | 142 | } |
130 | 143 | ||
131 | static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar, | 144 | static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar, |
@@ -134,4 +147,30 @@ static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar, | |||
134 | return ar->hif.ops->get_free_queue_number(ar, pipe_id); | 147 | return ar->hif.ops->get_free_queue_number(ar, pipe_id); |
135 | } | 148 | } |
136 | 149 | ||
150 | static inline int ath10k_hif_power_up(struct ath10k *ar) | ||
151 | { | ||
152 | return ar->hif.ops->power_up(ar); | ||
153 | } | ||
154 | |||
155 | static inline void ath10k_hif_power_down(struct ath10k *ar) | ||
156 | { | ||
157 | ar->hif.ops->power_down(ar); | ||
158 | } | ||
159 | |||
160 | static inline int ath10k_hif_suspend(struct ath10k *ar) | ||
161 | { | ||
162 | if (!ar->hif.ops->suspend) | ||
163 | return -EOPNOTSUPP; | ||
164 | |||
165 | return ar->hif.ops->suspend(ar); | ||
166 | } | ||
167 | |||
168 | static inline int ath10k_hif_resume(struct ath10k *ar) | ||
169 | { | ||
170 | if (!ar->hif.ops->resume) | ||
171 | return -EOPNOTSUPP; | ||
172 | |||
173 | return ar->hif.ops->resume(ar); | ||
174 | } | ||
175 | |||
137 | #endif /* _HIF_H_ */ | 176 | #endif /* _HIF_H_ */ |
diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c index 74363c949392..ef3329ef52f3 100644 --- a/drivers/net/wireless/ath/ath10k/htc.c +++ b/drivers/net/wireless/ath/ath10k/htc.c | |||
@@ -246,15 +246,22 @@ int ath10k_htc_send(struct ath10k_htc *htc, | |||
246 | { | 246 | { |
247 | struct ath10k_htc_ep *ep = &htc->endpoint[eid]; | 247 | struct ath10k_htc_ep *ep = &htc->endpoint[eid]; |
248 | 248 | ||
249 | if (htc->ar->state == ATH10K_STATE_WEDGED) | ||
250 | return -ECOMM; | ||
251 | |||
249 | if (eid >= ATH10K_HTC_EP_COUNT) { | 252 | if (eid >= ATH10K_HTC_EP_COUNT) { |
250 | ath10k_warn("Invalid endpoint id: %d\n", eid); | 253 | ath10k_warn("Invalid endpoint id: %d\n", eid); |
251 | return -ENOENT; | 254 | return -ENOENT; |
252 | } | 255 | } |
253 | 256 | ||
254 | skb_push(skb, sizeof(struct ath10k_htc_hdr)); | ||
255 | |||
256 | spin_lock_bh(&htc->tx_lock); | 257 | spin_lock_bh(&htc->tx_lock); |
258 | if (htc->stopped) { | ||
259 | spin_unlock_bh(&htc->tx_lock); | ||
260 | return -ESHUTDOWN; | ||
261 | } | ||
262 | |||
257 | __skb_queue_tail(&ep->tx_queue, skb); | 263 | __skb_queue_tail(&ep->tx_queue, skb); |
264 | skb_push(skb, sizeof(struct ath10k_htc_hdr)); | ||
258 | spin_unlock_bh(&htc->tx_lock); | 265 | spin_unlock_bh(&htc->tx_lock); |
259 | 266 | ||
260 | queue_work(htc->ar->workqueue, &ep->send_work); | 267 | queue_work(htc->ar->workqueue, &ep->send_work); |
@@ -265,25 +272,19 @@ static int ath10k_htc_tx_completion_handler(struct ath10k *ar, | |||
265 | struct sk_buff *skb, | 272 | struct sk_buff *skb, |
266 | unsigned int eid) | 273 | unsigned int eid) |
267 | { | 274 | { |
268 | struct ath10k_htc *htc = ar->htc; | 275 | struct ath10k_htc *htc = &ar->htc; |
269 | struct ath10k_htc_ep *ep = &htc->endpoint[eid]; | 276 | struct ath10k_htc_ep *ep = &htc->endpoint[eid]; |
270 | bool stopping; | ||
271 | 277 | ||
272 | ath10k_htc_notify_tx_completion(ep, skb); | 278 | ath10k_htc_notify_tx_completion(ep, skb); |
273 | /* the skb now belongs to the completion handler */ | 279 | /* the skb now belongs to the completion handler */ |
274 | 280 | ||
281 | /* note: when using TX credit flow, the re-checking of queues happens | ||
282 | * when credits flow back from the target. in the non-TX credit case, | ||
283 | * we recheck after the packet completes */ | ||
275 | spin_lock_bh(&htc->tx_lock); | 284 | spin_lock_bh(&htc->tx_lock); |
276 | stopping = htc->stopping; | 285 | if (!ep->tx_credit_flow_enabled && !htc->stopped) |
277 | spin_unlock_bh(&htc->tx_lock); | ||
278 | |||
279 | if (!ep->tx_credit_flow_enabled && !stopping) | ||
280 | /* | ||
281 | * note: when using TX credit flow, the re-checking of | ||
282 | * queues happens when credits flow back from the target. | ||
283 | * in the non-TX credit case, we recheck after the packet | ||
284 | * completes | ||
285 | */ | ||
286 | queue_work(ar->workqueue, &ep->send_work); | 286 | queue_work(ar->workqueue, &ep->send_work); |
287 | spin_unlock_bh(&htc->tx_lock); | ||
287 | 288 | ||
288 | return 0; | 289 | return 0; |
289 | } | 290 | } |
@@ -414,7 +415,7 @@ static int ath10k_htc_rx_completion_handler(struct ath10k *ar, | |||
414 | u8 pipe_id) | 415 | u8 pipe_id) |
415 | { | 416 | { |
416 | int status = 0; | 417 | int status = 0; |
417 | struct ath10k_htc *htc = ar->htc; | 418 | struct ath10k_htc *htc = &ar->htc; |
418 | struct ath10k_htc_hdr *hdr; | 419 | struct ath10k_htc_hdr *hdr; |
419 | struct ath10k_htc_ep *ep; | 420 | struct ath10k_htc_ep *ep; |
420 | u16 payload_len; | 421 | u16 payload_len; |
@@ -751,8 +752,9 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc, | |||
751 | tx_alloc = ath10k_htc_get_credit_allocation(htc, | 752 | tx_alloc = ath10k_htc_get_credit_allocation(htc, |
752 | conn_req->service_id); | 753 | conn_req->service_id); |
753 | if (!tx_alloc) | 754 | if (!tx_alloc) |
754 | ath10k_warn("HTC Service %s does not allocate target credits\n", | 755 | ath10k_dbg(ATH10K_DBG_HTC, |
755 | htc_service_name(conn_req->service_id)); | 756 | "HTC Service %s does not allocate target credits\n", |
757 | htc_service_name(conn_req->service_id)); | ||
756 | 758 | ||
757 | skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); | 759 | skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); |
758 | if (!skb) { | 760 | if (!skb) { |
@@ -947,7 +949,7 @@ void ath10k_htc_stop(struct ath10k_htc *htc) | |||
947 | struct ath10k_htc_ep *ep; | 949 | struct ath10k_htc_ep *ep; |
948 | 950 | ||
949 | spin_lock_bh(&htc->tx_lock); | 951 | spin_lock_bh(&htc->tx_lock); |
950 | htc->stopping = true; | 952 | htc->stopped = true; |
951 | spin_unlock_bh(&htc->tx_lock); | 953 | spin_unlock_bh(&htc->tx_lock); |
952 | 954 | ||
953 | for (i = ATH10K_HTC_EP_0; i < ATH10K_HTC_EP_COUNT; i++) { | 955 | for (i = ATH10K_HTC_EP_0; i < ATH10K_HTC_EP_COUNT; i++) { |
@@ -956,26 +958,18 @@ void ath10k_htc_stop(struct ath10k_htc *htc) | |||
956 | } | 958 | } |
957 | 959 | ||
958 | ath10k_hif_stop(htc->ar); | 960 | ath10k_hif_stop(htc->ar); |
959 | ath10k_htc_reset_endpoint_states(htc); | ||
960 | } | 961 | } |
961 | 962 | ||
962 | /* registered target arrival callback from the HIF layer */ | 963 | /* registered target arrival callback from the HIF layer */ |
963 | struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, | 964 | int ath10k_htc_init(struct ath10k *ar) |
964 | struct ath10k_htc_ops *htc_ops) | ||
965 | { | 965 | { |
966 | struct ath10k_hif_cb htc_callbacks; | 966 | struct ath10k_hif_cb htc_callbacks; |
967 | struct ath10k_htc_ep *ep = NULL; | 967 | struct ath10k_htc_ep *ep = NULL; |
968 | struct ath10k_htc *htc = NULL; | 968 | struct ath10k_htc *htc = &ar->htc; |
969 | |||
970 | /* FIXME: use struct ath10k instead */ | ||
971 | htc = kzalloc(sizeof(struct ath10k_htc), GFP_KERNEL); | ||
972 | if (!htc) | ||
973 | return ERR_PTR(-ENOMEM); | ||
974 | 969 | ||
975 | spin_lock_init(&htc->tx_lock); | 970 | spin_lock_init(&htc->tx_lock); |
976 | 971 | ||
977 | memcpy(&htc->htc_ops, htc_ops, sizeof(struct ath10k_htc_ops)); | 972 | htc->stopped = false; |
978 | |||
979 | ath10k_htc_reset_endpoint_states(htc); | 973 | ath10k_htc_reset_endpoint_states(htc); |
980 | 974 | ||
981 | /* setup HIF layer callbacks */ | 975 | /* setup HIF layer callbacks */ |
@@ -986,15 +980,10 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, | |||
986 | /* Get HIF default pipe for HTC message exchange */ | 980 | /* Get HIF default pipe for HTC message exchange */ |
987 | ep = &htc->endpoint[ATH10K_HTC_EP_0]; | 981 | ep = &htc->endpoint[ATH10K_HTC_EP_0]; |
988 | 982 | ||
989 | ath10k_hif_init(ar, &htc_callbacks); | 983 | ath10k_hif_set_callbacks(ar, &htc_callbacks); |
990 | ath10k_hif_get_default_pipe(ar, &ep->ul_pipe_id, &ep->dl_pipe_id); | 984 | ath10k_hif_get_default_pipe(ar, &ep->ul_pipe_id, &ep->dl_pipe_id); |
991 | 985 | ||
992 | init_completion(&htc->ctl_resp); | 986 | init_completion(&htc->ctl_resp); |
993 | 987 | ||
994 | return htc; | 988 | return 0; |
995 | } | ||
996 | |||
997 | void ath10k_htc_destroy(struct ath10k_htc *htc) | ||
998 | { | ||
999 | kfree(htc); | ||
1000 | } | 989 | } |
diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h index fa45844b59fb..e1dd8c761853 100644 --- a/drivers/net/wireless/ath/ath10k/htc.h +++ b/drivers/net/wireless/ath/ath10k/htc.h | |||
@@ -335,7 +335,7 @@ struct ath10k_htc { | |||
335 | struct ath10k *ar; | 335 | struct ath10k *ar; |
336 | struct ath10k_htc_ep endpoint[ATH10K_HTC_EP_COUNT]; | 336 | struct ath10k_htc_ep endpoint[ATH10K_HTC_EP_COUNT]; |
337 | 337 | ||
338 | /* protects endpoint and stopping fields */ | 338 | /* protects endpoint and stopped fields */ |
339 | spinlock_t tx_lock; | 339 | spinlock_t tx_lock; |
340 | 340 | ||
341 | struct ath10k_htc_ops htc_ops; | 341 | struct ath10k_htc_ops htc_ops; |
@@ -349,11 +349,10 @@ struct ath10k_htc { | |||
349 | struct ath10k_htc_svc_tx_credits service_tx_alloc[ATH10K_HTC_EP_COUNT]; | 349 | struct ath10k_htc_svc_tx_credits service_tx_alloc[ATH10K_HTC_EP_COUNT]; |
350 | int target_credit_size; | 350 | int target_credit_size; |
351 | 351 | ||
352 | bool stopping; | 352 | bool stopped; |
353 | }; | 353 | }; |
354 | 354 | ||
355 | struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, | 355 | int ath10k_htc_init(struct ath10k *ar); |
356 | struct ath10k_htc_ops *htc_ops); | ||
357 | int ath10k_htc_wait_target(struct ath10k_htc *htc); | 356 | int ath10k_htc_wait_target(struct ath10k_htc *htc); |
358 | int ath10k_htc_start(struct ath10k_htc *htc); | 357 | int ath10k_htc_start(struct ath10k_htc *htc); |
359 | int ath10k_htc_connect_service(struct ath10k_htc *htc, | 358 | int ath10k_htc_connect_service(struct ath10k_htc *htc, |
@@ -362,7 +361,6 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc, | |||
362 | int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid, | 361 | int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid, |
363 | struct sk_buff *packet); | 362 | struct sk_buff *packet); |
364 | void ath10k_htc_stop(struct ath10k_htc *htc); | 363 | void ath10k_htc_stop(struct ath10k_htc *htc); |
365 | void ath10k_htc_destroy(struct ath10k_htc *htc); | ||
366 | struct sk_buff *ath10k_htc_alloc_skb(int size); | 364 | struct sk_buff *ath10k_htc_alloc_skb(int size); |
367 | 365 | ||
368 | #endif | 366 | #endif |
diff --git a/drivers/net/wireless/ath/ath10k/htt.c b/drivers/net/wireless/ath/ath10k/htt.c index 185a5468a2f2..39342c5cfcb2 100644 --- a/drivers/net/wireless/ath/ath10k/htt.c +++ b/drivers/net/wireless/ath/ath10k/htt.c | |||
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/if_ether.h> | ||
19 | 20 | ||
20 | #include "htt.h" | 21 | #include "htt.h" |
21 | #include "core.h" | 22 | #include "core.h" |
@@ -36,7 +37,7 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt) | |||
36 | /* connect to control service */ | 37 | /* connect to control service */ |
37 | conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG; | 38 | conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG; |
38 | 39 | ||
39 | status = ath10k_htc_connect_service(htt->ar->htc, &conn_req, | 40 | status = ath10k_htc_connect_service(&htt->ar->htc, &conn_req, |
40 | &conn_resp); | 41 | &conn_resp); |
41 | 42 | ||
42 | if (status) | 43 | if (status) |
@@ -47,15 +48,11 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt) | |||
47 | return 0; | 48 | return 0; |
48 | } | 49 | } |
49 | 50 | ||
50 | struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) | 51 | int ath10k_htt_attach(struct ath10k *ar) |
51 | { | 52 | { |
52 | struct ath10k_htt *htt; | 53 | struct ath10k_htt *htt = &ar->htt; |
53 | int ret; | 54 | int ret; |
54 | 55 | ||
55 | htt = kzalloc(sizeof(*htt), GFP_KERNEL); | ||
56 | if (!htt) | ||
57 | return NULL; | ||
58 | |||
59 | htt->ar = ar; | 56 | htt->ar = ar; |
60 | htt->max_throughput_mbps = 800; | 57 | htt->max_throughput_mbps = 800; |
61 | 58 | ||
@@ -65,8 +62,11 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) | |||
65 | * since ath10k_htt_rx_attach involves sending a rx ring configure | 62 | * since ath10k_htt_rx_attach involves sending a rx ring configure |
66 | * message to the target. | 63 | * message to the target. |
67 | */ | 64 | */ |
68 | if (ath10k_htt_htc_attach(htt)) | 65 | ret = ath10k_htt_htc_attach(htt); |
66 | if (ret) { | ||
67 | ath10k_err("could not attach htt htc (%d)\n", ret); | ||
69 | goto err_htc_attach; | 68 | goto err_htc_attach; |
69 | } | ||
70 | 70 | ||
71 | ret = ath10k_htt_tx_attach(htt); | 71 | ret = ath10k_htt_tx_attach(htt); |
72 | if (ret) { | 72 | if (ret) { |
@@ -74,8 +74,11 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) | |||
74 | goto err_htc_attach; | 74 | goto err_htc_attach; |
75 | } | 75 | } |
76 | 76 | ||
77 | if (ath10k_htt_rx_attach(htt)) | 77 | ret = ath10k_htt_rx_attach(htt); |
78 | if (ret) { | ||
79 | ath10k_err("could not attach htt rx (%d)\n", ret); | ||
78 | goto err_rx_attach; | 80 | goto err_rx_attach; |
81 | } | ||
79 | 82 | ||
80 | /* | 83 | /* |
81 | * Prefetch enough data to satisfy target | 84 | * Prefetch enough data to satisfy target |
@@ -89,13 +92,12 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) | |||
89 | 8 + /* llc snap */ | 92 | 8 + /* llc snap */ |
90 | 2; /* ip4 dscp or ip6 priority */ | 93 | 2; /* ip4 dscp or ip6 priority */ |
91 | 94 | ||
92 | return htt; | 95 | return 0; |
93 | 96 | ||
94 | err_rx_attach: | 97 | err_rx_attach: |
95 | ath10k_htt_tx_detach(htt); | 98 | ath10k_htt_tx_detach(htt); |
96 | err_htc_attach: | 99 | err_htc_attach: |
97 | kfree(htt); | 100 | return ret; |
98 | return NULL; | ||
99 | } | 101 | } |
100 | 102 | ||
101 | #define HTT_TARGET_VERSION_TIMEOUT_HZ (3*HZ) | 103 | #define HTT_TARGET_VERSION_TIMEOUT_HZ (3*HZ) |
@@ -148,5 +150,4 @@ void ath10k_htt_detach(struct ath10k_htt *htt) | |||
148 | { | 150 | { |
149 | ath10k_htt_rx_detach(htt); | 151 | ath10k_htt_rx_detach(htt); |
150 | ath10k_htt_tx_detach(htt); | 152 | ath10k_htt_tx_detach(htt); |
151 | kfree(htt); | ||
152 | } | 153 | } |
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index a7a7aa040536..318be4629cde 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include <linux/bug.h> | 21 | #include <linux/bug.h> |
22 | 22 | ||
23 | #include "core.h" | ||
24 | #include "htc.h" | 23 | #include "htc.h" |
25 | #include "rx_desc.h" | 24 | #include "rx_desc.h" |
26 | 25 | ||
@@ -1317,7 +1316,7 @@ struct htt_rx_desc { | |||
1317 | #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */ | 1316 | #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */ |
1318 | #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1) | 1317 | #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1) |
1319 | 1318 | ||
1320 | struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar); | 1319 | int ath10k_htt_attach(struct ath10k *ar); |
1321 | int ath10k_htt_attach_target(struct ath10k_htt *htt); | 1320 | int ath10k_htt_attach_target(struct ath10k_htt *htt); |
1322 | void ath10k_htt_detach(struct ath10k_htt *htt); | 1321 | void ath10k_htt_detach(struct ath10k_htt *htt); |
1323 | 1322 | ||
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index de058d7adca8..e784c40b904b 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "core.h" | ||
18 | #include "htc.h" | 19 | #include "htc.h" |
19 | #include "htt.h" | 20 | #include "htt.h" |
20 | #include "txrx.h" | 21 | #include "txrx.h" |
@@ -803,6 +804,37 @@ static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb) | |||
803 | return false; | 804 | return false; |
804 | } | 805 | } |
805 | 806 | ||
807 | static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb) | ||
808 | { | ||
809 | struct htt_rx_desc *rxd; | ||
810 | u32 flags, info; | ||
811 | bool is_ip4, is_ip6; | ||
812 | bool is_tcp, is_udp; | ||
813 | bool ip_csum_ok, tcpudp_csum_ok; | ||
814 | |||
815 | rxd = (void *)skb->data - sizeof(*rxd); | ||
816 | flags = __le32_to_cpu(rxd->attention.flags); | ||
817 | info = __le32_to_cpu(rxd->msdu_start.info1); | ||
818 | |||
819 | is_ip4 = !!(info & RX_MSDU_START_INFO1_IPV4_PROTO); | ||
820 | is_ip6 = !!(info & RX_MSDU_START_INFO1_IPV6_PROTO); | ||
821 | is_tcp = !!(info & RX_MSDU_START_INFO1_TCP_PROTO); | ||
822 | is_udp = !!(info & RX_MSDU_START_INFO1_UDP_PROTO); | ||
823 | ip_csum_ok = !(flags & RX_ATTENTION_FLAGS_IP_CHKSUM_FAIL); | ||
824 | tcpudp_csum_ok = !(flags & RX_ATTENTION_FLAGS_TCP_UDP_CHKSUM_FAIL); | ||
825 | |||
826 | if (!is_ip4 && !is_ip6) | ||
827 | return CHECKSUM_NONE; | ||
828 | if (!is_tcp && !is_udp) | ||
829 | return CHECKSUM_NONE; | ||
830 | if (!ip_csum_ok) | ||
831 | return CHECKSUM_NONE; | ||
832 | if (!tcpudp_csum_ok) | ||
833 | return CHECKSUM_NONE; | ||
834 | |||
835 | return CHECKSUM_UNNECESSARY; | ||
836 | } | ||
837 | |||
806 | static void ath10k_htt_rx_handler(struct ath10k_htt *htt, | 838 | static void ath10k_htt_rx_handler(struct ath10k_htt *htt, |
807 | struct htt_rx_indication *rx) | 839 | struct htt_rx_indication *rx) |
808 | { | 840 | { |
@@ -814,6 +846,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, | |||
814 | u8 *fw_desc; | 846 | u8 *fw_desc; |
815 | int i, j; | 847 | int i, j; |
816 | int ret; | 848 | int ret; |
849 | int ip_summed; | ||
817 | 850 | ||
818 | memset(&info, 0, sizeof(info)); | 851 | memset(&info, 0, sizeof(info)); |
819 | 852 | ||
@@ -888,6 +921,11 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, | |||
888 | continue; | 921 | continue; |
889 | } | 922 | } |
890 | 923 | ||
924 | /* The skb is not yet processed and it may be | ||
925 | * reallocated. Since the offload is in the original | ||
926 | * skb extract the checksum now and assign it later */ | ||
927 | ip_summed = ath10k_htt_rx_get_csum_state(msdu_head); | ||
928 | |||
891 | info.skb = msdu_head; | 929 | info.skb = msdu_head; |
892 | info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head); | 930 | info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head); |
893 | info.signal = ATH10K_DEFAULT_NOISE_FLOOR; | 931 | info.signal = ATH10K_DEFAULT_NOISE_FLOOR; |
@@ -913,6 +951,8 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, | |||
913 | if (ath10k_htt_rx_hdr_is_amsdu((void *)info.skb->data)) | 951 | if (ath10k_htt_rx_hdr_is_amsdu((void *)info.skb->data)) |
914 | ath10k_dbg(ATH10K_DBG_HTT, "htt mpdu is amsdu\n"); | 952 | ath10k_dbg(ATH10K_DBG_HTT, "htt mpdu is amsdu\n"); |
915 | 953 | ||
954 | info.skb->ip_summed = ip_summed; | ||
955 | |||
916 | ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt mpdu: ", | 956 | ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt mpdu: ", |
917 | info.skb->data, info.skb->len); | 957 | info.skb->data, info.skb->len); |
918 | ath10k_process_rx(htt->ar, &info); | 958 | ath10k_process_rx(htt->ar, &info); |
@@ -979,6 +1019,7 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt, | |||
979 | info.status = HTT_RX_IND_MPDU_STATUS_OK; | 1019 | info.status = HTT_RX_IND_MPDU_STATUS_OK; |
980 | info.encrypt_type = MS(__le32_to_cpu(rxd->mpdu_start.info0), | 1020 | info.encrypt_type = MS(__le32_to_cpu(rxd->mpdu_start.info0), |
981 | RX_MPDU_START_INFO0_ENCRYPT_TYPE); | 1021 | RX_MPDU_START_INFO0_ENCRYPT_TYPE); |
1022 | info.skb->ip_summed = ath10k_htt_rx_get_csum_state(info.skb); | ||
982 | 1023 | ||
983 | if (tkip_mic_err) { | 1024 | if (tkip_mic_err) { |
984 | ath10k_warn("tkip mic error\n"); | 1025 | ath10k_warn("tkip mic error\n"); |
@@ -1036,7 +1077,7 @@ end: | |||
1036 | 1077 | ||
1037 | void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) | 1078 | void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) |
1038 | { | 1079 | { |
1039 | struct ath10k_htt *htt = ar->htt; | 1080 | struct ath10k_htt *htt = &ar->htt; |
1040 | struct htt_resp *resp = (struct htt_resp *)skb->data; | 1081 | struct htt_resp *resp = (struct htt_resp *)skb->data; |
1041 | 1082 | ||
1042 | /* confirm alignment */ | 1083 | /* confirm alignment */ |
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c index ef79106db247..656c2546b294 100644 --- a/drivers/net/wireless/ath/ath10k/htt_tx.c +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c | |||
@@ -92,7 +92,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt) | |||
92 | 92 | ||
93 | /* At the beginning free queue number should hint us the maximum | 93 | /* At the beginning free queue number should hint us the maximum |
94 | * queue length */ | 94 | * queue length */ |
95 | pipe = htt->ar->htc->endpoint[htt->eid].ul_pipe_id; | 95 | pipe = htt->ar->htc.endpoint[htt->eid].ul_pipe_id; |
96 | htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar, | 96 | htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar, |
97 | pipe); | 97 | pipe); |
98 | 98 | ||
@@ -153,7 +153,7 @@ void ath10k_htt_tx_detach(struct ath10k_htt *htt) | |||
153 | void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) | 153 | void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) |
154 | { | 154 | { |
155 | struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); | 155 | struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); |
156 | struct ath10k_htt *htt = ar->htt; | 156 | struct ath10k_htt *htt = &ar->htt; |
157 | 157 | ||
158 | if (skb_cb->htt.is_conf) { | 158 | if (skb_cb->htt.is_conf) { |
159 | dev_kfree_skb_any(skb); | 159 | dev_kfree_skb_any(skb); |
@@ -194,7 +194,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt) | |||
194 | 194 | ||
195 | ATH10K_SKB_CB(skb)->htt.is_conf = true; | 195 | ATH10K_SKB_CB(skb)->htt.is_conf = true; |
196 | 196 | ||
197 | ret = ath10k_htc_send(htt->ar->htc, htt->eid, skb); | 197 | ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb); |
198 | if (ret) { | 198 | if (ret) { |
199 | dev_kfree_skb_any(skb); | 199 | dev_kfree_skb_any(skb); |
200 | return ret; | 200 | return ret; |
@@ -281,7 +281,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt) | |||
281 | 281 | ||
282 | ATH10K_SKB_CB(skb)->htt.is_conf = true; | 282 | ATH10K_SKB_CB(skb)->htt.is_conf = true; |
283 | 283 | ||
284 | ret = ath10k_htc_send(htt->ar->htc, htt->eid, skb); | 284 | ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb); |
285 | if (ret) { | 285 | if (ret) { |
286 | dev_kfree_skb_any(skb); | 286 | dev_kfree_skb_any(skb); |
287 | return ret; | 287 | return ret; |
@@ -346,7 +346,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) | |||
346 | skb_cb->htt.refcount = 2; | 346 | skb_cb->htt.refcount = 2; |
347 | skb_cb->htt.msdu = msdu; | 347 | skb_cb->htt.msdu = msdu; |
348 | 348 | ||
349 | res = ath10k_htc_send(htt->ar->htc, htt->eid, txdesc); | 349 | res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc); |
350 | if (res) | 350 | if (res) |
351 | goto err; | 351 | goto err; |
352 | 352 | ||
@@ -465,6 +465,8 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) | |||
465 | flags1 = 0; | 465 | flags1 = 0; |
466 | flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID); | 466 | flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID); |
467 | flags1 |= SM((u16)tid, HTT_DATA_TX_DESC_FLAGS1_EXT_TID); | 467 | flags1 |= SM((u16)tid, HTT_DATA_TX_DESC_FLAGS1_EXT_TID); |
468 | flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD; | ||
469 | flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD; | ||
468 | 470 | ||
469 | frags_paddr = ATH10K_SKB_CB(txfrag)->paddr; | 471 | frags_paddr = ATH10K_SKB_CB(txfrag)->paddr; |
470 | 472 | ||
@@ -486,7 +488,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) | |||
486 | skb_cb->htt.txfrag = txfrag; | 488 | skb_cb->htt.txfrag = txfrag; |
487 | skb_cb->htt.msdu = msdu; | 489 | skb_cb->htt.msdu = msdu; |
488 | 490 | ||
489 | res = ath10k_htc_send(htt->ar->htc, htt->eid, txdesc); | 491 | res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc); |
490 | if (res) | 492 | if (res) |
491 | goto err; | 493 | goto err; |
492 | 494 | ||
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index da5c333d0d4b..cf2ba4d850c9 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <net/mac80211.h> | 20 | #include <net/mac80211.h> |
21 | #include <linux/etherdevice.h> | 21 | #include <linux/etherdevice.h> |
22 | 22 | ||
23 | #include "hif.h" | ||
23 | #include "core.h" | 24 | #include "core.h" |
24 | #include "debug.h" | 25 | #include "debug.h" |
25 | #include "wmi.h" | 26 | #include "wmi.h" |
@@ -43,6 +44,8 @@ static int ath10k_send_key(struct ath10k_vif *arvif, | |||
43 | .macaddr = macaddr, | 44 | .macaddr = macaddr, |
44 | }; | 45 | }; |
45 | 46 | ||
47 | lockdep_assert_held(&arvif->ar->conf_mutex); | ||
48 | |||
46 | if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) | 49 | if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) |
47 | arg.key_flags = WMI_KEY_PAIRWISE; | 50 | arg.key_flags = WMI_KEY_PAIRWISE; |
48 | else | 51 | else |
@@ -87,6 +90,8 @@ static int ath10k_install_key(struct ath10k_vif *arvif, | |||
87 | struct ath10k *ar = arvif->ar; | 90 | struct ath10k *ar = arvif->ar; |
88 | int ret; | 91 | int ret; |
89 | 92 | ||
93 | lockdep_assert_held(&ar->conf_mutex); | ||
94 | |||
90 | INIT_COMPLETION(ar->install_key_done); | 95 | INIT_COMPLETION(ar->install_key_done); |
91 | 96 | ||
92 | ret = ath10k_send_key(arvif, key, cmd, macaddr); | 97 | ret = ath10k_send_key(arvif, key, cmd, macaddr); |
@@ -327,6 +332,29 @@ static int ath10k_peer_create(struct ath10k *ar, u32 vdev_id, const u8 *addr) | |||
327 | return 0; | 332 | return 0; |
328 | } | 333 | } |
329 | 334 | ||
335 | static int ath10k_mac_set_rts(struct ath10k_vif *arvif, u32 value) | ||
336 | { | ||
337 | if (value != 0xFFFFFFFF) | ||
338 | value = min_t(u32, arvif->ar->hw->wiphy->rts_threshold, | ||
339 | ATH10K_RTS_MAX); | ||
340 | |||
341 | return ath10k_wmi_vdev_set_param(arvif->ar, arvif->vdev_id, | ||
342 | WMI_VDEV_PARAM_RTS_THRESHOLD, | ||
343 | value); | ||
344 | } | ||
345 | |||
346 | static int ath10k_mac_set_frag(struct ath10k_vif *arvif, u32 value) | ||
347 | { | ||
348 | if (value != 0xFFFFFFFF) | ||
349 | value = clamp_t(u32, arvif->ar->hw->wiphy->frag_threshold, | ||
350 | ATH10K_FRAGMT_THRESHOLD_MIN, | ||
351 | ATH10K_FRAGMT_THRESHOLD_MAX); | ||
352 | |||
353 | return ath10k_wmi_vdev_set_param(arvif->ar, arvif->vdev_id, | ||
354 | WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD, | ||
355 | value); | ||
356 | } | ||
357 | |||
330 | static int ath10k_peer_delete(struct ath10k *ar, u32 vdev_id, const u8 *addr) | 358 | static int ath10k_peer_delete(struct ath10k *ar, u32 vdev_id, const u8 *addr) |
331 | { | 359 | { |
332 | int ret; | 360 | int ret; |
@@ -364,6 +392,20 @@ static void ath10k_peer_cleanup(struct ath10k *ar, u32 vdev_id) | |||
364 | spin_unlock_bh(&ar->data_lock); | 392 | spin_unlock_bh(&ar->data_lock); |
365 | } | 393 | } |
366 | 394 | ||
395 | static void ath10k_peer_cleanup_all(struct ath10k *ar) | ||
396 | { | ||
397 | struct ath10k_peer *peer, *tmp; | ||
398 | |||
399 | lockdep_assert_held(&ar->conf_mutex); | ||
400 | |||
401 | spin_lock_bh(&ar->data_lock); | ||
402 | list_for_each_entry_safe(peer, tmp, &ar->peers, list) { | ||
403 | list_del(&peer->list); | ||
404 | kfree(peer); | ||
405 | } | ||
406 | spin_unlock_bh(&ar->data_lock); | ||
407 | } | ||
408 | |||
367 | /************************/ | 409 | /************************/ |
368 | /* Interface management */ | 410 | /* Interface management */ |
369 | /************************/ | 411 | /************************/ |
@@ -372,6 +414,8 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar) | |||
372 | { | 414 | { |
373 | int ret; | 415 | int ret; |
374 | 416 | ||
417 | lockdep_assert_held(&ar->conf_mutex); | ||
418 | |||
375 | ret = wait_for_completion_timeout(&ar->vdev_setup_done, | 419 | ret = wait_for_completion_timeout(&ar->vdev_setup_done, |
376 | ATH10K_VDEV_SETUP_TIMEOUT_HZ); | 420 | ATH10K_VDEV_SETUP_TIMEOUT_HZ); |
377 | if (ret == 0) | 421 | if (ret == 0) |
@@ -605,6 +649,8 @@ static void ath10k_control_beaconing(struct ath10k_vif *arvif, | |||
605 | { | 649 | { |
606 | int ret = 0; | 650 | int ret = 0; |
607 | 651 | ||
652 | lockdep_assert_held(&arvif->ar->conf_mutex); | ||
653 | |||
608 | if (!info->enable_beacon) { | 654 | if (!info->enable_beacon) { |
609 | ath10k_vdev_stop(arvif); | 655 | ath10k_vdev_stop(arvif); |
610 | return; | 656 | return; |
@@ -631,6 +677,8 @@ static void ath10k_control_ibss(struct ath10k_vif *arvif, | |||
631 | { | 677 | { |
632 | int ret = 0; | 678 | int ret = 0; |
633 | 679 | ||
680 | lockdep_assert_held(&arvif->ar->conf_mutex); | ||
681 | |||
634 | if (!info->ibss_joined) { | 682 | if (!info->ibss_joined) { |
635 | ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, self_peer); | 683 | ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, self_peer); |
636 | if (ret) | 684 | if (ret) |
@@ -680,6 +728,8 @@ static void ath10k_ps_iter(void *data, u8 *mac, struct ieee80211_vif *vif) | |||
680 | enum wmi_sta_ps_mode psmode; | 728 | enum wmi_sta_ps_mode psmode; |
681 | int ret; | 729 | int ret; |
682 | 730 | ||
731 | lockdep_assert_held(&arvif->ar->conf_mutex); | ||
732 | |||
683 | if (vif->type != NL80211_IFTYPE_STATION) | 733 | if (vif->type != NL80211_IFTYPE_STATION) |
684 | return; | 734 | return; |
685 | 735 | ||
@@ -722,6 +772,8 @@ static void ath10k_peer_assoc_h_basic(struct ath10k *ar, | |||
722 | struct ieee80211_bss_conf *bss_conf, | 772 | struct ieee80211_bss_conf *bss_conf, |
723 | struct wmi_peer_assoc_complete_arg *arg) | 773 | struct wmi_peer_assoc_complete_arg *arg) |
724 | { | 774 | { |
775 | lockdep_assert_held(&ar->conf_mutex); | ||
776 | |||
725 | memcpy(arg->addr, sta->addr, ETH_ALEN); | 777 | memcpy(arg->addr, sta->addr, ETH_ALEN); |
726 | arg->vdev_id = arvif->vdev_id; | 778 | arg->vdev_id = arvif->vdev_id; |
727 | arg->peer_aid = sta->aid; | 779 | arg->peer_aid = sta->aid; |
@@ -764,6 +816,8 @@ static void ath10k_peer_assoc_h_crypto(struct ath10k *ar, | |||
764 | const u8 *rsnie = NULL; | 816 | const u8 *rsnie = NULL; |
765 | const u8 *wpaie = NULL; | 817 | const u8 *wpaie = NULL; |
766 | 818 | ||
819 | lockdep_assert_held(&ar->conf_mutex); | ||
820 | |||
767 | bss = cfg80211_get_bss(ar->hw->wiphy, ar->hw->conf.chandef.chan, | 821 | bss = cfg80211_get_bss(ar->hw->wiphy, ar->hw->conf.chandef.chan, |
768 | info->bssid, NULL, 0, 0, 0); | 822 | info->bssid, NULL, 0, 0, 0); |
769 | if (bss) { | 823 | if (bss) { |
@@ -804,6 +858,8 @@ static void ath10k_peer_assoc_h_rates(struct ath10k *ar, | |||
804 | u32 ratemask; | 858 | u32 ratemask; |
805 | int i; | 859 | int i; |
806 | 860 | ||
861 | lockdep_assert_held(&ar->conf_mutex); | ||
862 | |||
807 | sband = ar->hw->wiphy->bands[ar->hw->conf.chandef.chan->band]; | 863 | sband = ar->hw->wiphy->bands[ar->hw->conf.chandef.chan->band]; |
808 | ratemask = sta->supp_rates[ar->hw->conf.chandef.chan->band]; | 864 | ratemask = sta->supp_rates[ar->hw->conf.chandef.chan->band]; |
809 | rates = sband->bitrates; | 865 | rates = sband->bitrates; |
@@ -827,6 +883,8 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar, | |||
827 | int smps; | 883 | int smps; |
828 | int i, n; | 884 | int i, n; |
829 | 885 | ||
886 | lockdep_assert_held(&ar->conf_mutex); | ||
887 | |||
830 | if (!ht_cap->ht_supported) | 888 | if (!ht_cap->ht_supported) |
831 | return; | 889 | return; |
832 | 890 | ||
@@ -905,6 +963,8 @@ static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar, | |||
905 | u32 uapsd = 0; | 963 | u32 uapsd = 0; |
906 | u32 max_sp = 0; | 964 | u32 max_sp = 0; |
907 | 965 | ||
966 | lockdep_assert_held(&ar->conf_mutex); | ||
967 | |||
908 | if (sta->wme) | 968 | if (sta->wme) |
909 | arg->peer_flags |= WMI_PEER_QOS; | 969 | arg->peer_flags |= WMI_PEER_QOS; |
910 | 970 | ||
@@ -1056,6 +1116,8 @@ static int ath10k_peer_assoc(struct ath10k *ar, | |||
1056 | { | 1116 | { |
1057 | struct wmi_peer_assoc_complete_arg arg; | 1117 | struct wmi_peer_assoc_complete_arg arg; |
1058 | 1118 | ||
1119 | lockdep_assert_held(&ar->conf_mutex); | ||
1120 | |||
1059 | memset(&arg, 0, sizeof(struct wmi_peer_assoc_complete_arg)); | 1121 | memset(&arg, 0, sizeof(struct wmi_peer_assoc_complete_arg)); |
1060 | 1122 | ||
1061 | ath10k_peer_assoc_h_basic(ar, arvif, sta, bss_conf, &arg); | 1123 | ath10k_peer_assoc_h_basic(ar, arvif, sta, bss_conf, &arg); |
@@ -1079,6 +1141,8 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw, | |||
1079 | struct ieee80211_sta *ap_sta; | 1141 | struct ieee80211_sta *ap_sta; |
1080 | int ret; | 1142 | int ret; |
1081 | 1143 | ||
1144 | lockdep_assert_held(&ar->conf_mutex); | ||
1145 | |||
1082 | rcu_read_lock(); | 1146 | rcu_read_lock(); |
1083 | 1147 | ||
1084 | ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); | 1148 | ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); |
@@ -1119,6 +1183,8 @@ static void ath10k_bss_disassoc(struct ieee80211_hw *hw, | |||
1119 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); | 1183 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); |
1120 | int ret; | 1184 | int ret; |
1121 | 1185 | ||
1186 | lockdep_assert_held(&ar->conf_mutex); | ||
1187 | |||
1122 | /* | 1188 | /* |
1123 | * For some reason, calling VDEV-DOWN before VDEV-STOP | 1189 | * For some reason, calling VDEV-DOWN before VDEV-STOP |
1124 | * makes the FW to send frames via HTT after disassociation. | 1190 | * makes the FW to send frames via HTT after disassociation. |
@@ -1152,6 +1218,8 @@ static int ath10k_station_assoc(struct ath10k *ar, struct ath10k_vif *arvif, | |||
1152 | { | 1218 | { |
1153 | int ret = 0; | 1219 | int ret = 0; |
1154 | 1220 | ||
1221 | lockdep_assert_held(&ar->conf_mutex); | ||
1222 | |||
1155 | ret = ath10k_peer_assoc(ar, arvif, sta, NULL); | 1223 | ret = ath10k_peer_assoc(ar, arvif, sta, NULL); |
1156 | if (ret) { | 1224 | if (ret) { |
1157 | ath10k_warn("WMI peer assoc failed for %pM\n", sta->addr); | 1225 | ath10k_warn("WMI peer assoc failed for %pM\n", sta->addr); |
@@ -1172,6 +1240,8 @@ static int ath10k_station_disassoc(struct ath10k *ar, struct ath10k_vif *arvif, | |||
1172 | { | 1240 | { |
1173 | int ret = 0; | 1241 | int ret = 0; |
1174 | 1242 | ||
1243 | lockdep_assert_held(&ar->conf_mutex); | ||
1244 | |||
1175 | ret = ath10k_clear_peer_keys(arvif, sta->addr); | 1245 | ret = ath10k_clear_peer_keys(arvif, sta->addr); |
1176 | if (ret) { | 1246 | if (ret) { |
1177 | ath10k_warn("could not clear all peer wep keys (%d)\n", ret); | 1247 | ath10k_warn("could not clear all peer wep keys (%d)\n", ret); |
@@ -1198,6 +1268,8 @@ static int ath10k_update_channel_list(struct ath10k *ar) | |||
1198 | int ret; | 1268 | int ret; |
1199 | int i; | 1269 | int i; |
1200 | 1270 | ||
1271 | lockdep_assert_held(&ar->conf_mutex); | ||
1272 | |||
1201 | bands = hw->wiphy->bands; | 1273 | bands = hw->wiphy->bands; |
1202 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | 1274 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
1203 | if (!bands[band]) | 1275 | if (!bands[band]) |
@@ -1276,21 +1348,19 @@ static int ath10k_update_channel_list(struct ath10k *ar) | |||
1276 | return ret; | 1348 | return ret; |
1277 | } | 1349 | } |
1278 | 1350 | ||
1279 | static void ath10k_reg_notifier(struct wiphy *wiphy, | 1351 | static void ath10k_regd_update(struct ath10k *ar) |
1280 | struct regulatory_request *request) | ||
1281 | { | 1352 | { |
1282 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | ||
1283 | struct reg_dmn_pair_mapping *regpair; | 1353 | struct reg_dmn_pair_mapping *regpair; |
1284 | struct ath10k *ar = hw->priv; | ||
1285 | int ret; | 1354 | int ret; |
1286 | 1355 | ||
1287 | ath_reg_notifier_apply(wiphy, request, &ar->ath_common.regulatory); | 1356 | lockdep_assert_held(&ar->conf_mutex); |
1288 | 1357 | ||
1289 | ret = ath10k_update_channel_list(ar); | 1358 | ret = ath10k_update_channel_list(ar); |
1290 | if (ret) | 1359 | if (ret) |
1291 | ath10k_warn("could not update channel list (%d)\n", ret); | 1360 | ath10k_warn("could not update channel list (%d)\n", ret); |
1292 | 1361 | ||
1293 | regpair = ar->ath_common.regulatory.regpair; | 1362 | regpair = ar->ath_common.regulatory.regpair; |
1363 | |||
1294 | /* Target allows setting up per-band regdomain but ath_common provides | 1364 | /* Target allows setting up per-band regdomain but ath_common provides |
1295 | * a combined one only */ | 1365 | * a combined one only */ |
1296 | ret = ath10k_wmi_pdev_set_regdomain(ar, | 1366 | ret = ath10k_wmi_pdev_set_regdomain(ar, |
@@ -1303,6 +1373,20 @@ static void ath10k_reg_notifier(struct wiphy *wiphy, | |||
1303 | ath10k_warn("could not set pdev regdomain (%d)\n", ret); | 1373 | ath10k_warn("could not set pdev regdomain (%d)\n", ret); |
1304 | } | 1374 | } |
1305 | 1375 | ||
1376 | static void ath10k_reg_notifier(struct wiphy *wiphy, | ||
1377 | struct regulatory_request *request) | ||
1378 | { | ||
1379 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | ||
1380 | struct ath10k *ar = hw->priv; | ||
1381 | |||
1382 | ath_reg_notifier_apply(wiphy, request, &ar->ath_common.regulatory); | ||
1383 | |||
1384 | mutex_lock(&ar->conf_mutex); | ||
1385 | if (ar->state == ATH10K_STATE_ON) | ||
1386 | ath10k_regd_update(ar); | ||
1387 | mutex_unlock(&ar->conf_mutex); | ||
1388 | } | ||
1389 | |||
1306 | /***************/ | 1390 | /***************/ |
1307 | /* TX handlers */ | 1391 | /* TX handlers */ |
1308 | /***************/ | 1392 | /***************/ |
@@ -1322,9 +1406,9 @@ static void ath10k_tx_h_qos_workaround(struct ieee80211_hw *hw, | |||
1322 | return; | 1406 | return; |
1323 | 1407 | ||
1324 | qos_ctl = ieee80211_get_qos_ctl(hdr); | 1408 | qos_ctl = ieee80211_get_qos_ctl(hdr); |
1325 | memmove(qos_ctl, qos_ctl + IEEE80211_QOS_CTL_LEN, | 1409 | memmove(skb->data + IEEE80211_QOS_CTL_LEN, |
1326 | skb->len - ieee80211_hdrlen(hdr->frame_control)); | 1410 | skb->data, (void *)qos_ctl - (void *)skb->data); |
1327 | skb_trim(skb, skb->len - IEEE80211_QOS_CTL_LEN); | 1411 | skb_pull(skb, IEEE80211_QOS_CTL_LEN); |
1328 | } | 1412 | } |
1329 | 1413 | ||
1330 | static void ath10k_tx_h_update_wep_key(struct sk_buff *skb) | 1414 | static void ath10k_tx_h_update_wep_key(struct sk_buff *skb) |
@@ -1397,15 +1481,15 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb) | |||
1397 | int ret; | 1481 | int ret; |
1398 | 1482 | ||
1399 | if (ieee80211_is_mgmt(hdr->frame_control)) | 1483 | if (ieee80211_is_mgmt(hdr->frame_control)) |
1400 | ret = ath10k_htt_mgmt_tx(ar->htt, skb); | 1484 | ret = ath10k_htt_mgmt_tx(&ar->htt, skb); |
1401 | else if (ieee80211_is_nullfunc(hdr->frame_control)) | 1485 | else if (ieee80211_is_nullfunc(hdr->frame_control)) |
1402 | /* FW does not report tx status properly for NullFunc frames | 1486 | /* FW does not report tx status properly for NullFunc frames |
1403 | * unless they are sent through mgmt tx path. mac80211 sends | 1487 | * unless they are sent through mgmt tx path. mac80211 sends |
1404 | * those frames when it detects link/beacon loss and depends on | 1488 | * those frames when it detects link/beacon loss and depends on |
1405 | * the tx status to be correct. */ | 1489 | * the tx status to be correct. */ |
1406 | ret = ath10k_htt_mgmt_tx(ar->htt, skb); | 1490 | ret = ath10k_htt_mgmt_tx(&ar->htt, skb); |
1407 | else | 1491 | else |
1408 | ret = ath10k_htt_tx(ar->htt, skb); | 1492 | ret = ath10k_htt_tx(&ar->htt, skb); |
1409 | 1493 | ||
1410 | if (ret) { | 1494 | if (ret) { |
1411 | ath10k_warn("tx failed (%d). dropping packet.\n", ret); | 1495 | ath10k_warn("tx failed (%d). dropping packet.\n", ret); |
@@ -1552,6 +1636,10 @@ static int ath10k_abort_scan(struct ath10k *ar) | |||
1552 | ret = ath10k_wmi_stop_scan(ar, &arg); | 1636 | ret = ath10k_wmi_stop_scan(ar, &arg); |
1553 | if (ret) { | 1637 | if (ret) { |
1554 | ath10k_warn("could not submit wmi stop scan (%d)\n", ret); | 1638 | ath10k_warn("could not submit wmi stop scan (%d)\n", ret); |
1639 | spin_lock_bh(&ar->data_lock); | ||
1640 | ar->scan.in_progress = false; | ||
1641 | ath10k_offchan_tx_purge(ar); | ||
1642 | spin_unlock_bh(&ar->data_lock); | ||
1555 | return -EIO; | 1643 | return -EIO; |
1556 | } | 1644 | } |
1557 | 1645 | ||
@@ -1645,10 +1733,14 @@ static void ath10k_tx(struct ieee80211_hw *hw, | |||
1645 | tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; | 1733 | tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; |
1646 | } | 1734 | } |
1647 | 1735 | ||
1648 | ath10k_tx_h_qos_workaround(hw, control, skb); | 1736 | /* it makes no sense to process injected frames like that */ |
1649 | ath10k_tx_h_update_wep_key(skb); | 1737 | if (info->control.vif && |
1650 | ath10k_tx_h_add_p2p_noa_ie(ar, skb); | 1738 | info->control.vif->type != NL80211_IFTYPE_MONITOR) { |
1651 | ath10k_tx_h_seq_no(skb); | 1739 | ath10k_tx_h_qos_workaround(hw, control, skb); |
1740 | ath10k_tx_h_update_wep_key(skb); | ||
1741 | ath10k_tx_h_add_p2p_noa_ie(ar, skb); | ||
1742 | ath10k_tx_h_seq_no(skb); | ||
1743 | } | ||
1652 | 1744 | ||
1653 | memset(ATH10K_SKB_CB(skb), 0, sizeof(*ATH10K_SKB_CB(skb))); | 1745 | memset(ATH10K_SKB_CB(skb), 0, sizeof(*ATH10K_SKB_CB(skb))); |
1654 | ATH10K_SKB_CB(skb)->htt.vdev_id = vdev_id; | 1746 | ATH10K_SKB_CB(skb)->htt.vdev_id = vdev_id; |
@@ -1673,10 +1765,57 @@ static void ath10k_tx(struct ieee80211_hw *hw, | |||
1673 | /* | 1765 | /* |
1674 | * Initialize various parameters with default vaules. | 1766 | * Initialize various parameters with default vaules. |
1675 | */ | 1767 | */ |
1768 | void ath10k_halt(struct ath10k *ar) | ||
1769 | { | ||
1770 | lockdep_assert_held(&ar->conf_mutex); | ||
1771 | |||
1772 | del_timer_sync(&ar->scan.timeout); | ||
1773 | ath10k_offchan_tx_purge(ar); | ||
1774 | ath10k_peer_cleanup_all(ar); | ||
1775 | ath10k_core_stop(ar); | ||
1776 | ath10k_hif_power_down(ar); | ||
1777 | |||
1778 | spin_lock_bh(&ar->data_lock); | ||
1779 | if (ar->scan.in_progress) { | ||
1780 | del_timer(&ar->scan.timeout); | ||
1781 | ar->scan.in_progress = false; | ||
1782 | ieee80211_scan_completed(ar->hw, true); | ||
1783 | } | ||
1784 | spin_unlock_bh(&ar->data_lock); | ||
1785 | } | ||
1786 | |||
1676 | static int ath10k_start(struct ieee80211_hw *hw) | 1787 | static int ath10k_start(struct ieee80211_hw *hw) |
1677 | { | 1788 | { |
1678 | struct ath10k *ar = hw->priv; | 1789 | struct ath10k *ar = hw->priv; |
1679 | int ret; | 1790 | int ret = 0; |
1791 | |||
1792 | mutex_lock(&ar->conf_mutex); | ||
1793 | |||
1794 | if (ar->state != ATH10K_STATE_OFF && | ||
1795 | ar->state != ATH10K_STATE_RESTARTING) { | ||
1796 | ret = -EINVAL; | ||
1797 | goto exit; | ||
1798 | } | ||
1799 | |||
1800 | ret = ath10k_hif_power_up(ar); | ||
1801 | if (ret) { | ||
1802 | ath10k_err("could not init hif (%d)\n", ret); | ||
1803 | ar->state = ATH10K_STATE_OFF; | ||
1804 | goto exit; | ||
1805 | } | ||
1806 | |||
1807 | ret = ath10k_core_start(ar); | ||
1808 | if (ret) { | ||
1809 | ath10k_err("could not init core (%d)\n", ret); | ||
1810 | ath10k_hif_power_down(ar); | ||
1811 | ar->state = ATH10K_STATE_OFF; | ||
1812 | goto exit; | ||
1813 | } | ||
1814 | |||
1815 | if (ar->state == ATH10K_STATE_OFF) | ||
1816 | ar->state = ATH10K_STATE_ON; | ||
1817 | else if (ar->state == ATH10K_STATE_RESTARTING) | ||
1818 | ar->state = ATH10K_STATE_RESTARTED; | ||
1680 | 1819 | ||
1681 | ret = ath10k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_PMF_QOS, 1); | 1820 | ret = ath10k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_PMF_QOS, 1); |
1682 | if (ret) | 1821 | if (ret) |
@@ -1688,6 +1827,10 @@ static int ath10k_start(struct ieee80211_hw *hw) | |||
1688 | ath10k_warn("could not init WMI_PDEV_PARAM_DYNAMIC_BW (%d)\n", | 1827 | ath10k_warn("could not init WMI_PDEV_PARAM_DYNAMIC_BW (%d)\n", |
1689 | ret); | 1828 | ret); |
1690 | 1829 | ||
1830 | ath10k_regd_update(ar); | ||
1831 | |||
1832 | exit: | ||
1833 | mutex_unlock(&ar->conf_mutex); | ||
1691 | return 0; | 1834 | return 0; |
1692 | } | 1835 | } |
1693 | 1836 | ||
@@ -1695,18 +1838,48 @@ static void ath10k_stop(struct ieee80211_hw *hw) | |||
1695 | { | 1838 | { |
1696 | struct ath10k *ar = hw->priv; | 1839 | struct ath10k *ar = hw->priv; |
1697 | 1840 | ||
1698 | /* avoid leaks in case FW never confirms scan for offchannel */ | 1841 | mutex_lock(&ar->conf_mutex); |
1842 | if (ar->state == ATH10K_STATE_ON || | ||
1843 | ar->state == ATH10K_STATE_RESTARTED || | ||
1844 | ar->state == ATH10K_STATE_WEDGED) | ||
1845 | ath10k_halt(ar); | ||
1846 | |||
1847 | ar->state = ATH10K_STATE_OFF; | ||
1848 | mutex_unlock(&ar->conf_mutex); | ||
1849 | |||
1699 | cancel_work_sync(&ar->offchan_tx_work); | 1850 | cancel_work_sync(&ar->offchan_tx_work); |
1700 | ath10k_offchan_tx_purge(ar); | 1851 | cancel_work_sync(&ar->restart_work); |
1701 | } | 1852 | } |
1702 | 1853 | ||
1703 | static int ath10k_config(struct ieee80211_hw *hw, u32 changed) | 1854 | static void ath10k_config_ps(struct ath10k *ar) |
1704 | { | 1855 | { |
1705 | struct ath10k_generic_iter ar_iter; | 1856 | struct ath10k_generic_iter ar_iter; |
1857 | |||
1858 | lockdep_assert_held(&ar->conf_mutex); | ||
1859 | |||
1860 | /* During HW reconfiguration mac80211 reports all interfaces that were | ||
1861 | * running until reconfiguration was started. Since FW doesn't have any | ||
1862 | * vdevs at this point we must not iterate over this interface list. | ||
1863 | * This setting will be updated upon add_interface(). */ | ||
1864 | if (ar->state == ATH10K_STATE_RESTARTED) | ||
1865 | return; | ||
1866 | |||
1867 | memset(&ar_iter, 0, sizeof(struct ath10k_generic_iter)); | ||
1868 | ar_iter.ar = ar; | ||
1869 | |||
1870 | ieee80211_iterate_active_interfaces_atomic( | ||
1871 | ar->hw, IEEE80211_IFACE_ITER_NORMAL, | ||
1872 | ath10k_ps_iter, &ar_iter); | ||
1873 | |||
1874 | if (ar_iter.ret) | ||
1875 | ath10k_warn("failed to set ps config (%d)\n", ar_iter.ret); | ||
1876 | } | ||
1877 | |||
1878 | static int ath10k_config(struct ieee80211_hw *hw, u32 changed) | ||
1879 | { | ||
1706 | struct ath10k *ar = hw->priv; | 1880 | struct ath10k *ar = hw->priv; |
1707 | struct ieee80211_conf *conf = &hw->conf; | 1881 | struct ieee80211_conf *conf = &hw->conf; |
1708 | int ret = 0; | 1882 | int ret = 0; |
1709 | u32 flags; | ||
1710 | 1883 | ||
1711 | mutex_lock(&ar->conf_mutex); | 1884 | mutex_lock(&ar->conf_mutex); |
1712 | 1885 | ||
@@ -1718,18 +1891,8 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed) | |||
1718 | spin_unlock_bh(&ar->data_lock); | 1891 | spin_unlock_bh(&ar->data_lock); |
1719 | } | 1892 | } |
1720 | 1893 | ||
1721 | if (changed & IEEE80211_CONF_CHANGE_PS) { | 1894 | if (changed & IEEE80211_CONF_CHANGE_PS) |
1722 | memset(&ar_iter, 0, sizeof(struct ath10k_generic_iter)); | 1895 | ath10k_config_ps(ar); |
1723 | ar_iter.ar = ar; | ||
1724 | flags = IEEE80211_IFACE_ITER_RESUME_ALL; | ||
1725 | |||
1726 | ieee80211_iterate_active_interfaces_atomic(hw, | ||
1727 | flags, | ||
1728 | ath10k_ps_iter, | ||
1729 | &ar_iter); | ||
1730 | |||
1731 | ret = ar_iter.ret; | ||
1732 | } | ||
1733 | 1896 | ||
1734 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) { | 1897 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) { |
1735 | if (conf->flags & IEEE80211_CONF_MONITOR) | 1898 | if (conf->flags & IEEE80211_CONF_MONITOR) |
@@ -1738,6 +1901,7 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed) | |||
1738 | ret = ath10k_monitor_destroy(ar); | 1901 | ret = ath10k_monitor_destroy(ar); |
1739 | } | 1902 | } |
1740 | 1903 | ||
1904 | ath10k_wmi_flush_tx(ar); | ||
1741 | mutex_unlock(&ar->conf_mutex); | 1905 | mutex_unlock(&ar->conf_mutex); |
1742 | return ret; | 1906 | return ret; |
1743 | } | 1907 | } |
@@ -1761,6 +1925,8 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, | |||
1761 | 1925 | ||
1762 | mutex_lock(&ar->conf_mutex); | 1926 | mutex_lock(&ar->conf_mutex); |
1763 | 1927 | ||
1928 | memset(arvif, 0, sizeof(*arvif)); | ||
1929 | |||
1764 | arvif->ar = ar; | 1930 | arvif->ar = ar; |
1765 | arvif->vif = vif; | 1931 | arvif->vif = vif; |
1766 | 1932 | ||
@@ -1859,6 +2025,16 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, | |||
1859 | ath10k_warn("Failed to set PSPOLL count: %d\n", ret); | 2025 | ath10k_warn("Failed to set PSPOLL count: %d\n", ret); |
1860 | } | 2026 | } |
1861 | 2027 | ||
2028 | ret = ath10k_mac_set_rts(arvif, ar->hw->wiphy->rts_threshold); | ||
2029 | if (ret) | ||
2030 | ath10k_warn("failed to set rts threshold for vdev %d (%d)\n", | ||
2031 | arvif->vdev_id, ret); | ||
2032 | |||
2033 | ret = ath10k_mac_set_frag(arvif, ar->hw->wiphy->frag_threshold); | ||
2034 | if (ret) | ||
2035 | ath10k_warn("failed to set frag threshold for vdev %d (%d)\n", | ||
2036 | arvif->vdev_id, ret); | ||
2037 | |||
1862 | if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) | 2038 | if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) |
1863 | ar->monitor_present = true; | 2039 | ar->monitor_present = true; |
1864 | 2040 | ||
@@ -2164,6 +2340,8 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw, | |||
2164 | arg.ssids[i].len = req->ssids[i].ssid_len; | 2340 | arg.ssids[i].len = req->ssids[i].ssid_len; |
2165 | arg.ssids[i].ssid = req->ssids[i].ssid; | 2341 | arg.ssids[i].ssid = req->ssids[i].ssid; |
2166 | } | 2342 | } |
2343 | } else { | ||
2344 | arg.scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE; | ||
2167 | } | 2345 | } |
2168 | 2346 | ||
2169 | if (req->n_channels) { | 2347 | if (req->n_channels) { |
@@ -2363,6 +2541,8 @@ static int ath10k_conf_tx_uapsd(struct ath10k *ar, struct ieee80211_vif *vif, | |||
2363 | u32 value = 0; | 2541 | u32 value = 0; |
2364 | int ret = 0; | 2542 | int ret = 0; |
2365 | 2543 | ||
2544 | lockdep_assert_held(&ar->conf_mutex); | ||
2545 | |||
2366 | if (arvif->vdev_type != WMI_VDEV_TYPE_STA) | 2546 | if (arvif->vdev_type != WMI_VDEV_TYPE_STA) |
2367 | return 0; | 2547 | return 0; |
2368 | 2548 | ||
@@ -2558,11 +2738,16 @@ static void ath10k_set_rts_iter(void *data, u8 *mac, struct ieee80211_vif *vif) | |||
2558 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); | 2738 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); |
2559 | u32 rts = ar_iter->ar->hw->wiphy->rts_threshold; | 2739 | u32 rts = ar_iter->ar->hw->wiphy->rts_threshold; |
2560 | 2740 | ||
2561 | rts = min_t(u32, rts, ATH10K_RTS_MAX); | 2741 | lockdep_assert_held(&arvif->ar->conf_mutex); |
2562 | 2742 | ||
2563 | ar_iter->ret = ath10k_wmi_vdev_set_param(ar_iter->ar, arvif->vdev_id, | 2743 | /* During HW reconfiguration mac80211 reports all interfaces that were |
2564 | WMI_VDEV_PARAM_RTS_THRESHOLD, | 2744 | * running until reconfiguration was started. Since FW doesn't have any |
2565 | rts); | 2745 | * vdevs at this point we must not iterate over this interface list. |
2746 | * This setting will be updated upon add_interface(). */ | ||
2747 | if (ar_iter->ar->state == ATH10K_STATE_RESTARTED) | ||
2748 | return; | ||
2749 | |||
2750 | ar_iter->ret = ath10k_mac_set_rts(arvif, rts); | ||
2566 | if (ar_iter->ret) | 2751 | if (ar_iter->ret) |
2567 | ath10k_warn("Failed to set RTS threshold for VDEV: %d\n", | 2752 | ath10k_warn("Failed to set RTS threshold for VDEV: %d\n", |
2568 | arvif->vdev_id); | 2753 | arvif->vdev_id); |
@@ -2581,8 +2766,9 @@ static int ath10k_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |||
2581 | ar_iter.ar = ar; | 2766 | ar_iter.ar = ar; |
2582 | 2767 | ||
2583 | mutex_lock(&ar->conf_mutex); | 2768 | mutex_lock(&ar->conf_mutex); |
2584 | ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_RESUME_ALL, | 2769 | ieee80211_iterate_active_interfaces_atomic( |
2585 | ath10k_set_rts_iter, &ar_iter); | 2770 | hw, IEEE80211_IFACE_ITER_NORMAL, |
2771 | ath10k_set_rts_iter, &ar_iter); | ||
2586 | mutex_unlock(&ar->conf_mutex); | 2772 | mutex_unlock(&ar->conf_mutex); |
2587 | 2773 | ||
2588 | return ar_iter.ret; | 2774 | return ar_iter.ret; |
@@ -2593,17 +2779,17 @@ static void ath10k_set_frag_iter(void *data, u8 *mac, struct ieee80211_vif *vif) | |||
2593 | struct ath10k_generic_iter *ar_iter = data; | 2779 | struct ath10k_generic_iter *ar_iter = data; |
2594 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); | 2780 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); |
2595 | u32 frag = ar_iter->ar->hw->wiphy->frag_threshold; | 2781 | u32 frag = ar_iter->ar->hw->wiphy->frag_threshold; |
2596 | int ret; | ||
2597 | 2782 | ||
2598 | frag = clamp_t(u32, frag, | 2783 | lockdep_assert_held(&arvif->ar->conf_mutex); |
2599 | ATH10K_FRAGMT_THRESHOLD_MIN, | ||
2600 | ATH10K_FRAGMT_THRESHOLD_MAX); | ||
2601 | 2784 | ||
2602 | ret = ath10k_wmi_vdev_set_param(ar_iter->ar, arvif->vdev_id, | 2785 | /* During HW reconfiguration mac80211 reports all interfaces that were |
2603 | WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD, | 2786 | * running until reconfiguration was started. Since FW doesn't have any |
2604 | frag); | 2787 | * vdevs at this point we must not iterate over this interface list. |
2788 | * This setting will be updated upon add_interface(). */ | ||
2789 | if (ar_iter->ar->state == ATH10K_STATE_RESTARTED) | ||
2790 | return; | ||
2605 | 2791 | ||
2606 | ar_iter->ret = ret; | 2792 | ar_iter->ret = ath10k_mac_set_frag(arvif, frag); |
2607 | if (ar_iter->ret) | 2793 | if (ar_iter->ret) |
2608 | ath10k_warn("Failed to set frag threshold for VDEV: %d\n", | 2794 | ath10k_warn("Failed to set frag threshold for VDEV: %d\n", |
2609 | arvif->vdev_id); | 2795 | arvif->vdev_id); |
@@ -2622,8 +2808,9 @@ static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value) | |||
2622 | ar_iter.ar = ar; | 2808 | ar_iter.ar = ar; |
2623 | 2809 | ||
2624 | mutex_lock(&ar->conf_mutex); | 2810 | mutex_lock(&ar->conf_mutex); |
2625 | ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_RESUME_ALL, | 2811 | ieee80211_iterate_active_interfaces_atomic( |
2626 | ath10k_set_frag_iter, &ar_iter); | 2812 | hw, IEEE80211_IFACE_ITER_NORMAL, |
2813 | ath10k_set_frag_iter, &ar_iter); | ||
2627 | mutex_unlock(&ar->conf_mutex); | 2814 | mutex_unlock(&ar->conf_mutex); |
2628 | 2815 | ||
2629 | return ar_iter.ret; | 2816 | return ar_iter.ret; |
@@ -2632,6 +2819,7 @@ static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value) | |||
2632 | static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop) | 2819 | static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop) |
2633 | { | 2820 | { |
2634 | struct ath10k *ar = hw->priv; | 2821 | struct ath10k *ar = hw->priv; |
2822 | bool skip; | ||
2635 | int ret; | 2823 | int ret; |
2636 | 2824 | ||
2637 | /* mac80211 doesn't care if we really xmit queued frames or not | 2825 | /* mac80211 doesn't care if we really xmit queued frames or not |
@@ -2639,16 +2827,29 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop) | |||
2639 | if (drop) | 2827 | if (drop) |
2640 | return; | 2828 | return; |
2641 | 2829 | ||
2642 | ret = wait_event_timeout(ar->htt->empty_tx_wq, ({ | 2830 | mutex_lock(&ar->conf_mutex); |
2831 | |||
2832 | if (ar->state == ATH10K_STATE_WEDGED) | ||
2833 | goto skip; | ||
2834 | |||
2835 | ret = wait_event_timeout(ar->htt.empty_tx_wq, ({ | ||
2643 | bool empty; | 2836 | bool empty; |
2644 | spin_lock_bh(&ar->htt->tx_lock); | 2837 | |
2645 | empty = bitmap_empty(ar->htt->used_msdu_ids, | 2838 | spin_lock_bh(&ar->htt.tx_lock); |
2646 | ar->htt->max_num_pending_tx); | 2839 | empty = bitmap_empty(ar->htt.used_msdu_ids, |
2647 | spin_unlock_bh(&ar->htt->tx_lock); | 2840 | ar->htt.max_num_pending_tx); |
2648 | (empty); | 2841 | spin_unlock_bh(&ar->htt.tx_lock); |
2842 | |||
2843 | skip = (ar->state == ATH10K_STATE_WEDGED); | ||
2844 | |||
2845 | (empty || skip); | ||
2649 | }), ATH10K_FLUSH_TIMEOUT_HZ); | 2846 | }), ATH10K_FLUSH_TIMEOUT_HZ); |
2650 | if (ret <= 0) | 2847 | |
2848 | if (ret <= 0 || skip) | ||
2651 | ath10k_warn("tx not flushed\n"); | 2849 | ath10k_warn("tx not flushed\n"); |
2850 | |||
2851 | skip: | ||
2852 | mutex_unlock(&ar->conf_mutex); | ||
2652 | } | 2853 | } |
2653 | 2854 | ||
2654 | /* TODO: Implement this function properly | 2855 | /* TODO: Implement this function properly |
@@ -2660,6 +2861,118 @@ static int ath10k_tx_last_beacon(struct ieee80211_hw *hw) | |||
2660 | return 1; | 2861 | return 1; |
2661 | } | 2862 | } |
2662 | 2863 | ||
2864 | #ifdef CONFIG_PM | ||
2865 | static int ath10k_suspend(struct ieee80211_hw *hw, | ||
2866 | struct cfg80211_wowlan *wowlan) | ||
2867 | { | ||
2868 | struct ath10k *ar = hw->priv; | ||
2869 | int ret; | ||
2870 | |||
2871 | ar->is_target_paused = false; | ||
2872 | |||
2873 | ret = ath10k_wmi_pdev_suspend_target(ar); | ||
2874 | if (ret) { | ||
2875 | ath10k_warn("could not suspend target (%d)\n", ret); | ||
2876 | return 1; | ||
2877 | } | ||
2878 | |||
2879 | ret = wait_event_interruptible_timeout(ar->event_queue, | ||
2880 | ar->is_target_paused == true, | ||
2881 | 1 * HZ); | ||
2882 | if (ret < 0) { | ||
2883 | ath10k_warn("suspend interrupted (%d)\n", ret); | ||
2884 | goto resume; | ||
2885 | } else if (ret == 0) { | ||
2886 | ath10k_warn("suspend timed out - target pause event never came\n"); | ||
2887 | goto resume; | ||
2888 | } | ||
2889 | |||
2890 | ret = ath10k_hif_suspend(ar); | ||
2891 | if (ret) { | ||
2892 | ath10k_warn("could not suspend hif (%d)\n", ret); | ||
2893 | goto resume; | ||
2894 | } | ||
2895 | |||
2896 | return 0; | ||
2897 | resume: | ||
2898 | ret = ath10k_wmi_pdev_resume_target(ar); | ||
2899 | if (ret) | ||
2900 | ath10k_warn("could not resume target (%d)\n", ret); | ||
2901 | return 1; | ||
2902 | } | ||
2903 | |||
2904 | static int ath10k_resume(struct ieee80211_hw *hw) | ||
2905 | { | ||
2906 | struct ath10k *ar = hw->priv; | ||
2907 | int ret; | ||
2908 | |||
2909 | ret = ath10k_hif_resume(ar); | ||
2910 | if (ret) { | ||
2911 | ath10k_warn("could not resume hif (%d)\n", ret); | ||
2912 | return 1; | ||
2913 | } | ||
2914 | |||
2915 | ret = ath10k_wmi_pdev_resume_target(ar); | ||
2916 | if (ret) { | ||
2917 | ath10k_warn("could not resume target (%d)\n", ret); | ||
2918 | return 1; | ||
2919 | } | ||
2920 | |||
2921 | return 0; | ||
2922 | } | ||
2923 | #endif | ||
2924 | |||
2925 | static void ath10k_restart_complete(struct ieee80211_hw *hw) | ||
2926 | { | ||
2927 | struct ath10k *ar = hw->priv; | ||
2928 | |||
2929 | mutex_lock(&ar->conf_mutex); | ||
2930 | |||
2931 | /* If device failed to restart it will be in a different state, e.g. | ||
2932 | * ATH10K_STATE_WEDGED */ | ||
2933 | if (ar->state == ATH10K_STATE_RESTARTED) { | ||
2934 | ath10k_info("device successfully recovered\n"); | ||
2935 | ar->state = ATH10K_STATE_ON; | ||
2936 | } | ||
2937 | |||
2938 | mutex_unlock(&ar->conf_mutex); | ||
2939 | } | ||
2940 | |||
2941 | static int ath10k_get_survey(struct ieee80211_hw *hw, int idx, | ||
2942 | struct survey_info *survey) | ||
2943 | { | ||
2944 | struct ath10k *ar = hw->priv; | ||
2945 | struct ieee80211_supported_band *sband; | ||
2946 | struct survey_info *ar_survey = &ar->survey[idx]; | ||
2947 | int ret = 0; | ||
2948 | |||
2949 | mutex_lock(&ar->conf_mutex); | ||
2950 | |||
2951 | sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ]; | ||
2952 | if (sband && idx >= sband->n_channels) { | ||
2953 | idx -= sband->n_channels; | ||
2954 | sband = NULL; | ||
2955 | } | ||
2956 | |||
2957 | if (!sband) | ||
2958 | sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ]; | ||
2959 | |||
2960 | if (!sband || idx >= sband->n_channels) { | ||
2961 | ret = -ENOENT; | ||
2962 | goto exit; | ||
2963 | } | ||
2964 | |||
2965 | spin_lock_bh(&ar->data_lock); | ||
2966 | memcpy(survey, ar_survey, sizeof(*survey)); | ||
2967 | spin_unlock_bh(&ar->data_lock); | ||
2968 | |||
2969 | survey->channel = &sband->channels[idx]; | ||
2970 | |||
2971 | exit: | ||
2972 | mutex_unlock(&ar->conf_mutex); | ||
2973 | return ret; | ||
2974 | } | ||
2975 | |||
2663 | static const struct ieee80211_ops ath10k_ops = { | 2976 | static const struct ieee80211_ops ath10k_ops = { |
2664 | .tx = ath10k_tx, | 2977 | .tx = ath10k_tx, |
2665 | .start = ath10k_start, | 2978 | .start = ath10k_start, |
@@ -2680,6 +2993,12 @@ static const struct ieee80211_ops ath10k_ops = { | |||
2680 | .set_frag_threshold = ath10k_set_frag_threshold, | 2993 | .set_frag_threshold = ath10k_set_frag_threshold, |
2681 | .flush = ath10k_flush, | 2994 | .flush = ath10k_flush, |
2682 | .tx_last_beacon = ath10k_tx_last_beacon, | 2995 | .tx_last_beacon = ath10k_tx_last_beacon, |
2996 | .restart_complete = ath10k_restart_complete, | ||
2997 | .get_survey = ath10k_get_survey, | ||
2998 | #ifdef CONFIG_PM | ||
2999 | .suspend = ath10k_suspend, | ||
3000 | .resume = ath10k_resume, | ||
3001 | #endif | ||
2683 | }; | 3002 | }; |
2684 | 3003 | ||
2685 | #define RATETAB_ENT(_rate, _rateid, _flags) { \ | 3004 | #define RATETAB_ENT(_rate, _rateid, _flags) { \ |
@@ -2797,9 +3116,15 @@ static const struct ieee80211_iface_limit ath10k_if_limits[] = { | |||
2797 | .max = 8, | 3116 | .max = 8, |
2798 | .types = BIT(NL80211_IFTYPE_STATION) | 3117 | .types = BIT(NL80211_IFTYPE_STATION) |
2799 | | BIT(NL80211_IFTYPE_P2P_CLIENT) | 3118 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
2800 | | BIT(NL80211_IFTYPE_P2P_GO) | 3119 | }, |
2801 | | BIT(NL80211_IFTYPE_AP) | 3120 | { |
2802 | } | 3121 | .max = 3, |
3122 | .types = BIT(NL80211_IFTYPE_P2P_GO) | ||
3123 | }, | ||
3124 | { | ||
3125 | .max = 7, | ||
3126 | .types = BIT(NL80211_IFTYPE_AP) | ||
3127 | }, | ||
2803 | }; | 3128 | }; |
2804 | 3129 | ||
2805 | static const struct ieee80211_iface_combination ath10k_if_comb = { | 3130 | static const struct ieee80211_iface_combination ath10k_if_comb = { |
@@ -2814,19 +3139,18 @@ static struct ieee80211_sta_vht_cap ath10k_create_vht_cap(struct ath10k *ar) | |||
2814 | { | 3139 | { |
2815 | struct ieee80211_sta_vht_cap vht_cap = {0}; | 3140 | struct ieee80211_sta_vht_cap vht_cap = {0}; |
2816 | u16 mcs_map; | 3141 | u16 mcs_map; |
3142 | int i; | ||
2817 | 3143 | ||
2818 | vht_cap.vht_supported = 1; | 3144 | vht_cap.vht_supported = 1; |
2819 | vht_cap.cap = ar->vht_cap_info; | 3145 | vht_cap.cap = ar->vht_cap_info; |
2820 | 3146 | ||
2821 | /* FIXME: check dynamically how many streams board supports */ | 3147 | mcs_map = 0; |
2822 | mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 | | 3148 | for (i = 0; i < 8; i++) { |
2823 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 2 | | 3149 | if (i < ar->num_rf_chains) |
2824 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 4 | | 3150 | mcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << (i*2); |
2825 | IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 | | 3151 | else |
2826 | IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 | | 3152 | mcs_map |= IEEE80211_VHT_MCS_NOT_SUPPORTED << (i*2); |
2827 | IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 | | 3153 | } |
2828 | IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 | | ||
2829 | IEEE80211_VHT_MCS_NOT_SUPPORTED << 14; | ||
2830 | 3154 | ||
2831 | vht_cap.vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); | 3155 | vht_cap.vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); |
2832 | vht_cap.vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); | 3156 | vht_cap.vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); |
@@ -2889,7 +3213,7 @@ static struct ieee80211_sta_ht_cap ath10k_get_ht_cap(struct ath10k *ar) | |||
2889 | if (ar->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_MASK) | 3213 | if (ar->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_MASK) |
2890 | ht_cap.cap |= IEEE80211_HT_CAP_MAX_AMSDU; | 3214 | ht_cap.cap |= IEEE80211_HT_CAP_MAX_AMSDU; |
2891 | 3215 | ||
2892 | for (i = 0; i < WMI_MAX_SPATIAL_STREAM; i++) | 3216 | for (i = 0; i < ar->num_rf_chains; i++) |
2893 | ht_cap.mcs.rx_mask[i] = 0xFF; | 3217 | ht_cap.mcs.rx_mask[i] = 0xFF; |
2894 | 3218 | ||
2895 | ht_cap.mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED; | 3219 | ht_cap.mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED; |
@@ -2948,8 +3272,10 @@ int ath10k_mac_register(struct ath10k *ar) | |||
2948 | channels = kmemdup(ath10k_2ghz_channels, | 3272 | channels = kmemdup(ath10k_2ghz_channels, |
2949 | sizeof(ath10k_2ghz_channels), | 3273 | sizeof(ath10k_2ghz_channels), |
2950 | GFP_KERNEL); | 3274 | GFP_KERNEL); |
2951 | if (!channels) | 3275 | if (!channels) { |
2952 | return -ENOMEM; | 3276 | ret = -ENOMEM; |
3277 | goto err_free; | ||
3278 | } | ||
2953 | 3279 | ||
2954 | band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; | 3280 | band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; |
2955 | band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels); | 3281 | band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels); |
@@ -2968,11 +3294,8 @@ int ath10k_mac_register(struct ath10k *ar) | |||
2968 | sizeof(ath10k_5ghz_channels), | 3294 | sizeof(ath10k_5ghz_channels), |
2969 | GFP_KERNEL); | 3295 | GFP_KERNEL); |
2970 | if (!channels) { | 3296 | if (!channels) { |
2971 | if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) { | 3297 | ret = -ENOMEM; |
2972 | band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; | 3298 | goto err_free; |
2973 | kfree(band->channels); | ||
2974 | } | ||
2975 | return -ENOMEM; | ||
2976 | } | 3299 | } |
2977 | 3300 | ||
2978 | band = &ar->mac.sbands[IEEE80211_BAND_5GHZ]; | 3301 | band = &ar->mac.sbands[IEEE80211_BAND_5GHZ]; |
@@ -3032,29 +3355,36 @@ int ath10k_mac_register(struct ath10k *ar) | |||
3032 | ar->hw->wiphy->iface_combinations = &ath10k_if_comb; | 3355 | ar->hw->wiphy->iface_combinations = &ath10k_if_comb; |
3033 | ar->hw->wiphy->n_iface_combinations = 1; | 3356 | ar->hw->wiphy->n_iface_combinations = 1; |
3034 | 3357 | ||
3358 | ar->hw->netdev_features = NETIF_F_HW_CSUM; | ||
3359 | |||
3035 | ret = ath_regd_init(&ar->ath_common.regulatory, ar->hw->wiphy, | 3360 | ret = ath_regd_init(&ar->ath_common.regulatory, ar->hw->wiphy, |
3036 | ath10k_reg_notifier); | 3361 | ath10k_reg_notifier); |
3037 | if (ret) { | 3362 | if (ret) { |
3038 | ath10k_err("Regulatory initialization failed\n"); | 3363 | ath10k_err("Regulatory initialization failed\n"); |
3039 | return ret; | 3364 | goto err_free; |
3040 | } | 3365 | } |
3041 | 3366 | ||
3042 | ret = ieee80211_register_hw(ar->hw); | 3367 | ret = ieee80211_register_hw(ar->hw); |
3043 | if (ret) { | 3368 | if (ret) { |
3044 | ath10k_err("ieee80211 registration failed: %d\n", ret); | 3369 | ath10k_err("ieee80211 registration failed: %d\n", ret); |
3045 | return ret; | 3370 | goto err_free; |
3046 | } | 3371 | } |
3047 | 3372 | ||
3048 | if (!ath_is_world_regd(&ar->ath_common.regulatory)) { | 3373 | if (!ath_is_world_regd(&ar->ath_common.regulatory)) { |
3049 | ret = regulatory_hint(ar->hw->wiphy, | 3374 | ret = regulatory_hint(ar->hw->wiphy, |
3050 | ar->ath_common.regulatory.alpha2); | 3375 | ar->ath_common.regulatory.alpha2); |
3051 | if (ret) | 3376 | if (ret) |
3052 | goto exit; | 3377 | goto err_unregister; |
3053 | } | 3378 | } |
3054 | 3379 | ||
3055 | return 0; | 3380 | return 0; |
3056 | exit: | 3381 | |
3382 | err_unregister: | ||
3057 | ieee80211_unregister_hw(ar->hw); | 3383 | ieee80211_unregister_hw(ar->hw); |
3384 | err_free: | ||
3385 | kfree(ar->mac.sbands[IEEE80211_BAND_2GHZ].channels); | ||
3386 | kfree(ar->mac.sbands[IEEE80211_BAND_5GHZ].channels); | ||
3387 | |||
3058 | return ret; | 3388 | return ret; |
3059 | } | 3389 | } |
3060 | 3390 | ||
diff --git a/drivers/net/wireless/ath/ath10k/mac.h b/drivers/net/wireless/ath/ath10k/mac.h index 27fc92e58829..6fce9bfb19a5 100644 --- a/drivers/net/wireless/ath/ath10k/mac.h +++ b/drivers/net/wireless/ath/ath10k/mac.h | |||
@@ -34,6 +34,7 @@ struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id); | |||
34 | void ath10k_reset_scan(unsigned long ptr); | 34 | void ath10k_reset_scan(unsigned long ptr); |
35 | void ath10k_offchan_tx_purge(struct ath10k *ar); | 35 | void ath10k_offchan_tx_purge(struct ath10k *ar); |
36 | void ath10k_offchan_tx_work(struct work_struct *work); | 36 | void ath10k_offchan_tx_work(struct work_struct *work); |
37 | void ath10k_halt(struct ath10k *ar); | ||
37 | 38 | ||
38 | static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) | 39 | static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) |
39 | { | 40 | { |
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 33af4672c909..e2f9ef50b1bd 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "ce.h" | 32 | #include "ce.h" |
33 | #include "pci.h" | 33 | #include "pci.h" |
34 | 34 | ||
35 | unsigned int ath10k_target_ps; | 35 | static unsigned int ath10k_target_ps; |
36 | module_param(ath10k_target_ps, uint, 0644); | 36 | module_param(ath10k_target_ps, uint, 0644); |
37 | MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option"); | 37 | MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option"); |
38 | 38 | ||
@@ -54,6 +54,10 @@ static int ath10k_pci_post_rx_pipe(struct hif_ce_pipe_info *pipe_info, | |||
54 | int num); | 54 | int num); |
55 | static void ath10k_pci_rx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info); | 55 | static void ath10k_pci_rx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info); |
56 | static void ath10k_pci_stop_ce(struct ath10k *ar); | 56 | static void ath10k_pci_stop_ce(struct ath10k *ar); |
57 | static void ath10k_pci_device_reset(struct ath10k *ar); | ||
58 | static int ath10k_pci_reset_target(struct ath10k *ar); | ||
59 | static int ath10k_pci_start_intr(struct ath10k *ar); | ||
60 | static void ath10k_pci_stop_intr(struct ath10k *ar); | ||
57 | 61 | ||
58 | static const struct ce_attr host_ce_config_wlan[] = { | 62 | static const struct ce_attr host_ce_config_wlan[] = { |
59 | /* host->target HTC control and raw streams */ | 63 | /* host->target HTC control and raw streams */ |
@@ -718,6 +722,8 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar) | |||
718 | reg_dump_values[i + 1], | 722 | reg_dump_values[i + 1], |
719 | reg_dump_values[i + 2], | 723 | reg_dump_values[i + 2], |
720 | reg_dump_values[i + 3]); | 724 | reg_dump_values[i + 3]); |
725 | |||
726 | ieee80211_queue_work(ar->hw, &ar->restart_work); | ||
721 | } | 727 | } |
722 | 728 | ||
723 | static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, | 729 | static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, |
@@ -744,8 +750,8 @@ static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, | |||
744 | ath10k_ce_per_engine_service(ar, pipe); | 750 | ath10k_ce_per_engine_service(ar, pipe); |
745 | } | 751 | } |
746 | 752 | ||
747 | static void ath10k_pci_hif_post_init(struct ath10k *ar, | 753 | static void ath10k_pci_hif_set_callbacks(struct ath10k *ar, |
748 | struct ath10k_hif_cb *callbacks) | 754 | struct ath10k_hif_cb *callbacks) |
749 | { | 755 | { |
750 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | 756 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
751 | 757 | ||
@@ -1250,10 +1256,25 @@ static void ath10k_pci_ce_deinit(struct ath10k *ar) | |||
1250 | } | 1256 | } |
1251 | } | 1257 | } |
1252 | 1258 | ||
1259 | static void ath10k_pci_disable_irqs(struct ath10k *ar) | ||
1260 | { | ||
1261 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1262 | int i; | ||
1263 | |||
1264 | for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++) | ||
1265 | disable_irq(ar_pci->pdev->irq + i); | ||
1266 | } | ||
1267 | |||
1253 | static void ath10k_pci_hif_stop(struct ath10k *ar) | 1268 | static void ath10k_pci_hif_stop(struct ath10k *ar) |
1254 | { | 1269 | { |
1270 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1271 | |||
1255 | ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); | 1272 | ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); |
1256 | 1273 | ||
1274 | /* Irqs are never explicitly re-enabled. They are implicitly re-enabled | ||
1275 | * by ath10k_pci_start_intr(). */ | ||
1276 | ath10k_pci_disable_irqs(ar); | ||
1277 | |||
1257 | ath10k_pci_stop_ce(ar); | 1278 | ath10k_pci_stop_ce(ar); |
1258 | 1279 | ||
1259 | /* At this point, asynchronous threads are stopped, the target should | 1280 | /* At this point, asynchronous threads are stopped, the target should |
@@ -1263,7 +1284,8 @@ static void ath10k_pci_hif_stop(struct ath10k *ar) | |||
1263 | ath10k_pci_process_ce(ar); | 1284 | ath10k_pci_process_ce(ar); |
1264 | ath10k_pci_cleanup_ce(ar); | 1285 | ath10k_pci_cleanup_ce(ar); |
1265 | ath10k_pci_buffer_cleanup(ar); | 1286 | ath10k_pci_buffer_cleanup(ar); |
1266 | ath10k_pci_ce_deinit(ar); | 1287 | |
1288 | ar_pci->started = 0; | ||
1267 | } | 1289 | } |
1268 | 1290 | ||
1269 | static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, | 1291 | static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, |
@@ -1735,6 +1757,124 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar) | |||
1735 | ath10k_pci_sleep(ar); | 1757 | ath10k_pci_sleep(ar); |
1736 | } | 1758 | } |
1737 | 1759 | ||
1760 | static int ath10k_pci_hif_power_up(struct ath10k *ar) | ||
1761 | { | ||
1762 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1763 | int ret; | ||
1764 | |||
1765 | ret = ath10k_pci_start_intr(ar); | ||
1766 | if (ret) { | ||
1767 | ath10k_err("could not start interrupt handling (%d)\n", ret); | ||
1768 | goto err; | ||
1769 | } | ||
1770 | |||
1771 | /* | ||
1772 | * Bring the target up cleanly. | ||
1773 | * | ||
1774 | * The target may be in an undefined state with an AUX-powered Target | ||
1775 | * and a Host in WoW mode. If the Host crashes, loses power, or is | ||
1776 | * restarted (without unloading the driver) then the Target is left | ||
1777 | * (aux) powered and running. On a subsequent driver load, the Target | ||
1778 | * is in an unexpected state. We try to catch that here in order to | ||
1779 | * reset the Target and retry the probe. | ||
1780 | */ | ||
1781 | ath10k_pci_device_reset(ar); | ||
1782 | |||
1783 | ret = ath10k_pci_reset_target(ar); | ||
1784 | if (ret) | ||
1785 | goto err_irq; | ||
1786 | |||
1787 | if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) | ||
1788 | /* Force AWAKE forever */ | ||
1789 | ath10k_do_pci_wake(ar); | ||
1790 | |||
1791 | ret = ath10k_pci_ce_init(ar); | ||
1792 | if (ret) | ||
1793 | goto err_ps; | ||
1794 | |||
1795 | ret = ath10k_pci_init_config(ar); | ||
1796 | if (ret) | ||
1797 | goto err_ce; | ||
1798 | |||
1799 | ret = ath10k_pci_wake_target_cpu(ar); | ||
1800 | if (ret) { | ||
1801 | ath10k_err("could not wake up target CPU (%d)\n", ret); | ||
1802 | goto err_ce; | ||
1803 | } | ||
1804 | |||
1805 | return 0; | ||
1806 | |||
1807 | err_ce: | ||
1808 | ath10k_pci_ce_deinit(ar); | ||
1809 | err_ps: | ||
1810 | if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) | ||
1811 | ath10k_do_pci_sleep(ar); | ||
1812 | err_irq: | ||
1813 | ath10k_pci_stop_intr(ar); | ||
1814 | err: | ||
1815 | return ret; | ||
1816 | } | ||
1817 | |||
1818 | static void ath10k_pci_hif_power_down(struct ath10k *ar) | ||
1819 | { | ||
1820 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1821 | |||
1822 | ath10k_pci_stop_intr(ar); | ||
1823 | |||
1824 | ath10k_pci_ce_deinit(ar); | ||
1825 | if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) | ||
1826 | ath10k_do_pci_sleep(ar); | ||
1827 | } | ||
1828 | |||
1829 | #ifdef CONFIG_PM | ||
1830 | |||
1831 | #define ATH10K_PCI_PM_CONTROL 0x44 | ||
1832 | |||
1833 | static int ath10k_pci_hif_suspend(struct ath10k *ar) | ||
1834 | { | ||
1835 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1836 | struct pci_dev *pdev = ar_pci->pdev; | ||
1837 | u32 val; | ||
1838 | |||
1839 | pci_read_config_dword(pdev, ATH10K_PCI_PM_CONTROL, &val); | ||
1840 | |||
1841 | if ((val & 0x000000ff) != 0x3) { | ||
1842 | pci_save_state(pdev); | ||
1843 | pci_disable_device(pdev); | ||
1844 | pci_write_config_dword(pdev, ATH10K_PCI_PM_CONTROL, | ||
1845 | (val & 0xffffff00) | 0x03); | ||
1846 | } | ||
1847 | |||
1848 | return 0; | ||
1849 | } | ||
1850 | |||
1851 | static int ath10k_pci_hif_resume(struct ath10k *ar) | ||
1852 | { | ||
1853 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1854 | struct pci_dev *pdev = ar_pci->pdev; | ||
1855 | u32 val; | ||
1856 | |||
1857 | pci_read_config_dword(pdev, ATH10K_PCI_PM_CONTROL, &val); | ||
1858 | |||
1859 | if ((val & 0x000000ff) != 0) { | ||
1860 | pci_restore_state(pdev); | ||
1861 | pci_write_config_dword(pdev, ATH10K_PCI_PM_CONTROL, | ||
1862 | val & 0xffffff00); | ||
1863 | /* | ||
1864 | * Suspend/Resume resets the PCI configuration space, | ||
1865 | * so we have to re-disable the RETRY_TIMEOUT register (0x41) | ||
1866 | * to keep PCI Tx retries from interfering with C3 CPU state | ||
1867 | */ | ||
1868 | pci_read_config_dword(pdev, 0x40, &val); | ||
1869 | |||
1870 | if ((val & 0x0000ff00) != 0) | ||
1871 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); | ||
1872 | } | ||
1873 | |||
1874 | return 0; | ||
1875 | } | ||
1876 | #endif | ||
1877 | |||
1738 | static const struct ath10k_hif_ops ath10k_pci_hif_ops = { | 1878 | static const struct ath10k_hif_ops ath10k_pci_hif_ops = { |
1739 | .send_head = ath10k_pci_hif_send_head, | 1879 | .send_head = ath10k_pci_hif_send_head, |
1740 | .exchange_bmi_msg = ath10k_pci_hif_exchange_bmi_msg, | 1880 | .exchange_bmi_msg = ath10k_pci_hif_exchange_bmi_msg, |
@@ -1743,8 +1883,14 @@ static const struct ath10k_hif_ops ath10k_pci_hif_ops = { | |||
1743 | .map_service_to_pipe = ath10k_pci_hif_map_service_to_pipe, | 1883 | .map_service_to_pipe = ath10k_pci_hif_map_service_to_pipe, |
1744 | .get_default_pipe = ath10k_pci_hif_get_default_pipe, | 1884 | .get_default_pipe = ath10k_pci_hif_get_default_pipe, |
1745 | .send_complete_check = ath10k_pci_hif_send_complete_check, | 1885 | .send_complete_check = ath10k_pci_hif_send_complete_check, |
1746 | .init = ath10k_pci_hif_post_init, | 1886 | .set_callbacks = ath10k_pci_hif_set_callbacks, |
1747 | .get_free_queue_number = ath10k_pci_hif_get_free_queue_number, | 1887 | .get_free_queue_number = ath10k_pci_hif_get_free_queue_number, |
1888 | .power_up = ath10k_pci_hif_power_up, | ||
1889 | .power_down = ath10k_pci_hif_power_down, | ||
1890 | #ifdef CONFIG_PM | ||
1891 | .suspend = ath10k_pci_hif_suspend, | ||
1892 | .resume = ath10k_pci_hif_resume, | ||
1893 | #endif | ||
1748 | }; | 1894 | }; |
1749 | 1895 | ||
1750 | static void ath10k_pci_ce_tasklet(unsigned long ptr) | 1896 | static void ath10k_pci_ce_tasklet(unsigned long ptr) |
@@ -1872,8 +2018,13 @@ static int ath10k_pci_start_intr_msix(struct ath10k *ar, int num) | |||
1872 | ret = request_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, | 2018 | ret = request_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, |
1873 | ath10k_pci_msi_fw_handler, | 2019 | ath10k_pci_msi_fw_handler, |
1874 | IRQF_SHARED, "ath10k_pci", ar); | 2020 | IRQF_SHARED, "ath10k_pci", ar); |
1875 | if (ret) | 2021 | if (ret) { |
2022 | ath10k_warn("request_irq(%d) failed %d\n", | ||
2023 | ar_pci->pdev->irq + MSI_ASSIGN_FW, ret); | ||
2024 | |||
2025 | pci_disable_msi(ar_pci->pdev); | ||
1876 | return ret; | 2026 | return ret; |
2027 | } | ||
1877 | 2028 | ||
1878 | for (i = MSI_ASSIGN_CE_INITIAL; i <= MSI_ASSIGN_CE_MAX; i++) { | 2029 | for (i = MSI_ASSIGN_CE_INITIAL; i <= MSI_ASSIGN_CE_MAX; i++) { |
1879 | ret = request_irq(ar_pci->pdev->irq + i, | 2030 | ret = request_irq(ar_pci->pdev->irq + i, |
@@ -2059,9 +2210,9 @@ static int ath10k_pci_reset_target(struct ath10k *ar) | |||
2059 | return 0; | 2210 | return 0; |
2060 | } | 2211 | } |
2061 | 2212 | ||
2062 | static void ath10k_pci_device_reset(struct ath10k_pci *ar_pci) | 2213 | static void ath10k_pci_device_reset(struct ath10k *ar) |
2063 | { | 2214 | { |
2064 | struct ath10k *ar = ar_pci->ar; | 2215 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
2065 | void __iomem *mem = ar_pci->mem; | 2216 | void __iomem *mem = ar_pci->mem; |
2066 | int i; | 2217 | int i; |
2067 | u32 val; | 2218 | u32 val; |
@@ -2118,9 +2269,12 @@ static void ath10k_pci_dump_features(struct ath10k_pci *ar_pci) | |||
2118 | case ATH10K_PCI_FEATURE_MSI_X: | 2269 | case ATH10K_PCI_FEATURE_MSI_X: |
2119 | ath10k_dbg(ATH10K_DBG_PCI, "device supports MSI-X\n"); | 2270 | ath10k_dbg(ATH10K_DBG_PCI, "device supports MSI-X\n"); |
2120 | break; | 2271 | break; |
2121 | case ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND: | 2272 | case ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND: |
2122 | ath10k_dbg(ATH10K_DBG_PCI, "QCA988X_1.0 workaround enabled\n"); | 2273 | ath10k_dbg(ATH10K_DBG_PCI, "QCA988X_1.0 workaround enabled\n"); |
2123 | break; | 2274 | break; |
2275 | case ATH10K_PCI_FEATURE_SOC_POWER_SAVE: | ||
2276 | ath10k_dbg(ATH10K_DBG_PCI, "QCA98XX SoC power save enabled\n"); | ||
2277 | break; | ||
2124 | } | 2278 | } |
2125 | } | 2279 | } |
2126 | } | 2280 | } |
@@ -2145,7 +2299,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2145 | 2299 | ||
2146 | switch (pci_dev->device) { | 2300 | switch (pci_dev->device) { |
2147 | case QCA988X_1_0_DEVICE_ID: | 2301 | case QCA988X_1_0_DEVICE_ID: |
2148 | set_bit(ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND, ar_pci->features); | 2302 | set_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features); |
2149 | break; | 2303 | break; |
2150 | case QCA988X_2_0_DEVICE_ID: | 2304 | case QCA988X_2_0_DEVICE_ID: |
2151 | set_bit(ATH10K_PCI_FEATURE_MSI_X, ar_pci->features); | 2305 | set_bit(ATH10K_PCI_FEATURE_MSI_X, ar_pci->features); |
@@ -2156,10 +2310,12 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2156 | goto err_ar_pci; | 2310 | goto err_ar_pci; |
2157 | } | 2311 | } |
2158 | 2312 | ||
2313 | if (ath10k_target_ps) | ||
2314 | set_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features); | ||
2315 | |||
2159 | ath10k_pci_dump_features(ar_pci); | 2316 | ath10k_pci_dump_features(ar_pci); |
2160 | 2317 | ||
2161 | ar = ath10k_core_create(ar_pci, ar_pci->dev, ATH10K_BUS_PCI, | 2318 | ar = ath10k_core_create(ar_pci, ar_pci->dev, &ath10k_pci_hif_ops); |
2162 | &ath10k_pci_hif_ops); | ||
2163 | if (!ar) { | 2319 | if (!ar) { |
2164 | ath10k_err("ath10k_core_create failed!\n"); | 2320 | ath10k_err("ath10k_core_create failed!\n"); |
2165 | ret = -EINVAL; | 2321 | ret = -EINVAL; |
@@ -2167,7 +2323,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2167 | } | 2323 | } |
2168 | 2324 | ||
2169 | /* Enable QCA988X_1.0 HW workarounds */ | 2325 | /* Enable QCA988X_1.0 HW workarounds */ |
2170 | if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND, ar_pci->features)) | 2326 | if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) |
2171 | spin_lock_init(&ar_pci->hw_v1_workaround_lock); | 2327 | spin_lock_init(&ar_pci->hw_v1_workaround_lock); |
2172 | 2328 | ||
2173 | ar_pci->ar = ar; | 2329 | ar_pci->ar = ar; |
@@ -2241,62 +2397,14 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2241 | 2397 | ||
2242 | ar_pci->cacheline_sz = dma_get_cache_alignment(); | 2398 | ar_pci->cacheline_sz = dma_get_cache_alignment(); |
2243 | 2399 | ||
2244 | ret = ath10k_pci_start_intr(ar); | ||
2245 | if (ret) { | ||
2246 | ath10k_err("could not start interrupt handling (%d)\n", ret); | ||
2247 | goto err_iomap; | ||
2248 | } | ||
2249 | |||
2250 | /* | ||
2251 | * Bring the target up cleanly. | ||
2252 | * | ||
2253 | * The target may be in an undefined state with an AUX-powered Target | ||
2254 | * and a Host in WoW mode. If the Host crashes, loses power, or is | ||
2255 | * restarted (without unloading the driver) then the Target is left | ||
2256 | * (aux) powered and running. On a subsequent driver load, the Target | ||
2257 | * is in an unexpected state. We try to catch that here in order to | ||
2258 | * reset the Target and retry the probe. | ||
2259 | */ | ||
2260 | ath10k_pci_device_reset(ar_pci); | ||
2261 | |||
2262 | ret = ath10k_pci_reset_target(ar); | ||
2263 | if (ret) | ||
2264 | goto err_intr; | ||
2265 | |||
2266 | if (ath10k_target_ps) { | ||
2267 | ath10k_dbg(ATH10K_DBG_PCI, "on-chip power save enabled\n"); | ||
2268 | } else { | ||
2269 | /* Force AWAKE forever */ | ||
2270 | ath10k_dbg(ATH10K_DBG_PCI, "on-chip power save disabled\n"); | ||
2271 | ath10k_do_pci_wake(ar); | ||
2272 | } | ||
2273 | |||
2274 | ret = ath10k_pci_ce_init(ar); | ||
2275 | if (ret) | ||
2276 | goto err_intr; | ||
2277 | |||
2278 | ret = ath10k_pci_init_config(ar); | ||
2279 | if (ret) | ||
2280 | goto err_ce; | ||
2281 | |||
2282 | ret = ath10k_pci_wake_target_cpu(ar); | ||
2283 | if (ret) { | ||
2284 | ath10k_err("could not wake up target CPU (%d)\n", ret); | ||
2285 | goto err_ce; | ||
2286 | } | ||
2287 | |||
2288 | ret = ath10k_core_register(ar); | 2400 | ret = ath10k_core_register(ar); |
2289 | if (ret) { | 2401 | if (ret) { |
2290 | ath10k_err("could not register driver core (%d)\n", ret); | 2402 | ath10k_err("could not register driver core (%d)\n", ret); |
2291 | goto err_ce; | 2403 | goto err_iomap; |
2292 | } | 2404 | } |
2293 | 2405 | ||
2294 | return 0; | 2406 | return 0; |
2295 | 2407 | ||
2296 | err_ce: | ||
2297 | ath10k_pci_ce_deinit(ar); | ||
2298 | err_intr: | ||
2299 | ath10k_pci_stop_intr(ar); | ||
2300 | err_iomap: | 2408 | err_iomap: |
2301 | pci_iounmap(pdev, mem); | 2409 | pci_iounmap(pdev, mem); |
2302 | err_master: | 2410 | err_master: |
@@ -2333,7 +2441,6 @@ static void ath10k_pci_remove(struct pci_dev *pdev) | |||
2333 | tasklet_kill(&ar_pci->msi_fw_err); | 2441 | tasklet_kill(&ar_pci->msi_fw_err); |
2334 | 2442 | ||
2335 | ath10k_core_unregister(ar); | 2443 | ath10k_core_unregister(ar); |
2336 | ath10k_pci_stop_intr(ar); | ||
2337 | 2444 | ||
2338 | pci_set_drvdata(pdev, NULL); | 2445 | pci_set_drvdata(pdev, NULL); |
2339 | pci_iounmap(pdev, ar_pci->mem); | 2446 | pci_iounmap(pdev, ar_pci->mem); |
@@ -2345,128 +2452,6 @@ static void ath10k_pci_remove(struct pci_dev *pdev) | |||
2345 | kfree(ar_pci); | 2452 | kfree(ar_pci); |
2346 | } | 2453 | } |
2347 | 2454 | ||
2348 | #if defined(CONFIG_PM_SLEEP) | ||
2349 | |||
2350 | #define ATH10K_PCI_PM_CONTROL 0x44 | ||
2351 | |||
2352 | static int ath10k_pci_suspend(struct device *device) | ||
2353 | { | ||
2354 | struct pci_dev *pdev = to_pci_dev(device); | ||
2355 | struct ath10k *ar = pci_get_drvdata(pdev); | ||
2356 | struct ath10k_pci *ar_pci; | ||
2357 | u32 val; | ||
2358 | int ret, retval; | ||
2359 | |||
2360 | ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); | ||
2361 | |||
2362 | if (!ar) | ||
2363 | return -ENODEV; | ||
2364 | |||
2365 | ar_pci = ath10k_pci_priv(ar); | ||
2366 | if (!ar_pci) | ||
2367 | return -ENODEV; | ||
2368 | |||
2369 | if (ath10k_core_target_suspend(ar)) | ||
2370 | return -EBUSY; | ||
2371 | |||
2372 | ret = wait_event_interruptible_timeout(ar->event_queue, | ||
2373 | ar->is_target_paused == true, | ||
2374 | 1 * HZ); | ||
2375 | if (ret < 0) { | ||
2376 | ath10k_warn("suspend interrupted (%d)\n", ret); | ||
2377 | retval = ret; | ||
2378 | goto resume; | ||
2379 | } else if (ret == 0) { | ||
2380 | ath10k_warn("suspend timed out - target pause event never came\n"); | ||
2381 | retval = EIO; | ||
2382 | goto resume; | ||
2383 | } | ||
2384 | |||
2385 | /* | ||
2386 | * reset is_target_paused and host can check that in next time, | ||
2387 | * or it will always be TRUE and host just skip the waiting | ||
2388 | * condition, it causes target assert due to host already | ||
2389 | * suspend | ||
2390 | */ | ||
2391 | ar->is_target_paused = false; | ||
2392 | |||
2393 | pci_read_config_dword(pdev, ATH10K_PCI_PM_CONTROL, &val); | ||
2394 | |||
2395 | if ((val & 0x000000ff) != 0x3) { | ||
2396 | pci_save_state(pdev); | ||
2397 | pci_disable_device(pdev); | ||
2398 | pci_write_config_dword(pdev, ATH10K_PCI_PM_CONTROL, | ||
2399 | (val & 0xffffff00) | 0x03); | ||
2400 | } | ||
2401 | |||
2402 | return 0; | ||
2403 | resume: | ||
2404 | ret = ath10k_core_target_resume(ar); | ||
2405 | if (ret) | ||
2406 | ath10k_warn("could not resume (%d)\n", ret); | ||
2407 | |||
2408 | return retval; | ||
2409 | } | ||
2410 | |||
2411 | static int ath10k_pci_resume(struct device *device) | ||
2412 | { | ||
2413 | struct pci_dev *pdev = to_pci_dev(device); | ||
2414 | struct ath10k *ar = pci_get_drvdata(pdev); | ||
2415 | struct ath10k_pci *ar_pci; | ||
2416 | int ret; | ||
2417 | u32 val; | ||
2418 | |||
2419 | ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); | ||
2420 | |||
2421 | if (!ar) | ||
2422 | return -ENODEV; | ||
2423 | ar_pci = ath10k_pci_priv(ar); | ||
2424 | |||
2425 | if (!ar_pci) | ||
2426 | return -ENODEV; | ||
2427 | |||
2428 | ret = pci_enable_device(pdev); | ||
2429 | if (ret) { | ||
2430 | ath10k_warn("cannot enable PCI device: %d\n", ret); | ||
2431 | return ret; | ||
2432 | } | ||
2433 | |||
2434 | pci_read_config_dword(pdev, ATH10K_PCI_PM_CONTROL, &val); | ||
2435 | |||
2436 | if ((val & 0x000000ff) != 0) { | ||
2437 | pci_restore_state(pdev); | ||
2438 | pci_write_config_dword(pdev, ATH10K_PCI_PM_CONTROL, | ||
2439 | val & 0xffffff00); | ||
2440 | /* | ||
2441 | * Suspend/Resume resets the PCI configuration space, | ||
2442 | * so we have to re-disable the RETRY_TIMEOUT register (0x41) | ||
2443 | * to keep PCI Tx retries from interfering with C3 CPU state | ||
2444 | */ | ||
2445 | pci_read_config_dword(pdev, 0x40, &val); | ||
2446 | |||
2447 | if ((val & 0x0000ff00) != 0) | ||
2448 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); | ||
2449 | } | ||
2450 | |||
2451 | ret = ath10k_core_target_resume(ar); | ||
2452 | if (ret) | ||
2453 | ath10k_warn("target resume failed: %d\n", ret); | ||
2454 | |||
2455 | return ret; | ||
2456 | } | ||
2457 | |||
2458 | static SIMPLE_DEV_PM_OPS(ath10k_dev_pm_ops, | ||
2459 | ath10k_pci_suspend, | ||
2460 | ath10k_pci_resume); | ||
2461 | |||
2462 | #define ATH10K_PCI_PM_OPS (&ath10k_dev_pm_ops) | ||
2463 | |||
2464 | #else | ||
2465 | |||
2466 | #define ATH10K_PCI_PM_OPS NULL | ||
2467 | |||
2468 | #endif /* CONFIG_PM_SLEEP */ | ||
2469 | |||
2470 | MODULE_DEVICE_TABLE(pci, ath10k_pci_id_table); | 2455 | MODULE_DEVICE_TABLE(pci, ath10k_pci_id_table); |
2471 | 2456 | ||
2472 | static struct pci_driver ath10k_pci_driver = { | 2457 | static struct pci_driver ath10k_pci_driver = { |
@@ -2474,7 +2459,6 @@ static struct pci_driver ath10k_pci_driver = { | |||
2474 | .id_table = ath10k_pci_id_table, | 2459 | .id_table = ath10k_pci_id_table, |
2475 | .probe = ath10k_pci_probe, | 2460 | .probe = ath10k_pci_probe, |
2476 | .remove = ath10k_pci_remove, | 2461 | .remove = ath10k_pci_remove, |
2477 | .driver.pm = ATH10K_PCI_PM_OPS, | ||
2478 | }; | 2462 | }; |
2479 | 2463 | ||
2480 | static int __init ath10k_pci_init(void) | 2464 | static int __init ath10k_pci_init(void) |
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h index d2a055a07dc6..871bb339d56d 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h | |||
@@ -152,7 +152,8 @@ struct service_to_pipe { | |||
152 | 152 | ||
153 | enum ath10k_pci_features { | 153 | enum ath10k_pci_features { |
154 | ATH10K_PCI_FEATURE_MSI_X = 0, | 154 | ATH10K_PCI_FEATURE_MSI_X = 0, |
155 | ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND = 1, | 155 | ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND = 1, |
156 | ATH10K_PCI_FEATURE_SOC_POWER_SAVE = 2, | ||
156 | 157 | ||
157 | /* keep last */ | 158 | /* keep last */ |
158 | ATH10K_PCI_FEATURE_COUNT | 159 | ATH10K_PCI_FEATURE_COUNT |
@@ -311,7 +312,7 @@ static inline void ath10k_pci_write32(struct ath10k *ar, u32 offset, | |||
311 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | 312 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
312 | void __iomem *addr = ar_pci->mem; | 313 | void __iomem *addr = ar_pci->mem; |
313 | 314 | ||
314 | if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WARKAROUND, ar_pci->features)) { | 315 | if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) { |
315 | unsigned long irq_flags; | 316 | unsigned long irq_flags; |
316 | 317 | ||
317 | spin_lock_irqsave(&ar_pci->hw_v1_workaround_lock, irq_flags); | 318 | spin_lock_irqsave(&ar_pci->hw_v1_workaround_lock, irq_flags); |
@@ -335,20 +336,22 @@ static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset) | |||
335 | return ioread32(ar_pci->mem + offset); | 336 | return ioread32(ar_pci->mem + offset); |
336 | } | 337 | } |
337 | 338 | ||
338 | extern unsigned int ath10k_target_ps; | ||
339 | |||
340 | void ath10k_do_pci_wake(struct ath10k *ar); | 339 | void ath10k_do_pci_wake(struct ath10k *ar); |
341 | void ath10k_do_pci_sleep(struct ath10k *ar); | 340 | void ath10k_do_pci_sleep(struct ath10k *ar); |
342 | 341 | ||
343 | static inline void ath10k_pci_wake(struct ath10k *ar) | 342 | static inline void ath10k_pci_wake(struct ath10k *ar) |
344 | { | 343 | { |
345 | if (ath10k_target_ps) | 344 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
345 | |||
346 | if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) | ||
346 | ath10k_do_pci_wake(ar); | 347 | ath10k_do_pci_wake(ar); |
347 | } | 348 | } |
348 | 349 | ||
349 | static inline void ath10k_pci_sleep(struct ath10k *ar) | 350 | static inline void ath10k_pci_sleep(struct ath10k *ar) |
350 | { | 351 | { |
351 | if (ath10k_target_ps) | 352 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
353 | |||
354 | if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) | ||
352 | ath10k_do_pci_sleep(ar); | 355 | ath10k_do_pci_sleep(ar); |
353 | } | 356 | } |
354 | 357 | ||
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 7d4b7987422d..55f90c761868 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c | |||
@@ -27,6 +27,13 @@ void ath10k_wmi_flush_tx(struct ath10k *ar) | |||
27 | { | 27 | { |
28 | int ret; | 28 | int ret; |
29 | 29 | ||
30 | lockdep_assert_held(&ar->conf_mutex); | ||
31 | |||
32 | if (ar->state == ATH10K_STATE_WEDGED) { | ||
33 | ath10k_warn("wmi flush skipped - device is wedged anyway\n"); | ||
34 | return; | ||
35 | } | ||
36 | |||
30 | ret = wait_event_timeout(ar->wmi.wq, | 37 | ret = wait_event_timeout(ar->wmi.wq, |
31 | atomic_read(&ar->wmi.pending_tx_count) == 0, | 38 | atomic_read(&ar->wmi.pending_tx_count) == 0, |
32 | 5*HZ); | 39 | 5*HZ); |
@@ -111,7 +118,7 @@ static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, | |||
111 | 118 | ||
112 | trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len); | 119 | trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len); |
113 | 120 | ||
114 | status = ath10k_htc_send(ar->htc, ar->wmi.eid, skb); | 121 | status = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb); |
115 | if (status) { | 122 | if (status) { |
116 | dev_kfree_skb_any(skb); | 123 | dev_kfree_skb_any(skb); |
117 | atomic_dec(&ar->wmi.pending_tx_count); | 124 | atomic_dec(&ar->wmi.pending_tx_count); |
@@ -383,9 +390,82 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) | |||
383 | return 0; | 390 | return 0; |
384 | } | 391 | } |
385 | 392 | ||
393 | static int freq_to_idx(struct ath10k *ar, int freq) | ||
394 | { | ||
395 | struct ieee80211_supported_band *sband; | ||
396 | int band, ch, idx = 0; | ||
397 | |||
398 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { | ||
399 | sband = ar->hw->wiphy->bands[band]; | ||
400 | if (!sband) | ||
401 | continue; | ||
402 | |||
403 | for (ch = 0; ch < sband->n_channels; ch++, idx++) | ||
404 | if (sband->channels[ch].center_freq == freq) | ||
405 | goto exit; | ||
406 | } | ||
407 | |||
408 | exit: | ||
409 | return idx; | ||
410 | } | ||
411 | |||
386 | static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb) | 412 | static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb) |
387 | { | 413 | { |
388 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_CHAN_INFO_EVENTID\n"); | 414 | struct wmi_chan_info_event *ev; |
415 | struct survey_info *survey; | ||
416 | u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count; | ||
417 | int idx; | ||
418 | |||
419 | ev = (struct wmi_chan_info_event *)skb->data; | ||
420 | |||
421 | err_code = __le32_to_cpu(ev->err_code); | ||
422 | freq = __le32_to_cpu(ev->freq); | ||
423 | cmd_flags = __le32_to_cpu(ev->cmd_flags); | ||
424 | noise_floor = __le32_to_cpu(ev->noise_floor); | ||
425 | rx_clear_count = __le32_to_cpu(ev->rx_clear_count); | ||
426 | cycle_count = __le32_to_cpu(ev->cycle_count); | ||
427 | |||
428 | ath10k_dbg(ATH10K_DBG_WMI, | ||
429 | "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n", | ||
430 | err_code, freq, cmd_flags, noise_floor, rx_clear_count, | ||
431 | cycle_count); | ||
432 | |||
433 | spin_lock_bh(&ar->data_lock); | ||
434 | |||
435 | if (!ar->scan.in_progress) { | ||
436 | ath10k_warn("chan info event without a scan request?\n"); | ||
437 | goto exit; | ||
438 | } | ||
439 | |||
440 | idx = freq_to_idx(ar, freq); | ||
441 | if (idx >= ARRAY_SIZE(ar->survey)) { | ||
442 | ath10k_warn("chan info: invalid frequency %d (idx %d out of bounds)\n", | ||
443 | freq, idx); | ||
444 | goto exit; | ||
445 | } | ||
446 | |||
447 | if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) { | ||
448 | /* During scanning chan info is reported twice for each | ||
449 | * visited channel. The reported cycle count is global | ||
450 | * and per-channel cycle count must be calculated */ | ||
451 | |||
452 | cycle_count -= ar->survey_last_cycle_count; | ||
453 | rx_clear_count -= ar->survey_last_rx_clear_count; | ||
454 | |||
455 | survey = &ar->survey[idx]; | ||
456 | survey->channel_time = WMI_CHAN_INFO_MSEC(cycle_count); | ||
457 | survey->channel_time_rx = WMI_CHAN_INFO_MSEC(rx_clear_count); | ||
458 | survey->noise = noise_floor; | ||
459 | survey->filled = SURVEY_INFO_CHANNEL_TIME | | ||
460 | SURVEY_INFO_CHANNEL_TIME_RX | | ||
461 | SURVEY_INFO_NOISE_DBM; | ||
462 | } | ||
463 | |||
464 | ar->survey_last_rx_clear_count = rx_clear_count; | ||
465 | ar->survey_last_cycle_count = cycle_count; | ||
466 | |||
467 | exit: | ||
468 | spin_unlock_bh(&ar->data_lock); | ||
389 | } | 469 | } |
390 | 470 | ||
391 | static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb) | 471 | static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb) |
@@ -501,8 +581,8 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, | |||
501 | ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies, | 581 | ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies, |
502 | (u8 *)skb_tail_pointer(bcn) - ies); | 582 | (u8 *)skb_tail_pointer(bcn) - ies); |
503 | if (!ie) { | 583 | if (!ie) { |
504 | /* highly unlikely for mac80211 */ | 584 | if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS) |
505 | ath10k_warn("no tim ie found;\n"); | 585 | ath10k_warn("no tim ie found;\n"); |
506 | return; | 586 | return; |
507 | } | 587 | } |
508 | 588 | ||
@@ -861,6 +941,13 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, | |||
861 | (__le32_to_cpu(ev->sw_version_1) & 0xffff0000) >> 16; | 941 | (__le32_to_cpu(ev->sw_version_1) & 0xffff0000) >> 16; |
862 | ar->fw_version_build = (__le32_to_cpu(ev->sw_version_1) & 0x0000ffff); | 942 | ar->fw_version_build = (__le32_to_cpu(ev->sw_version_1) & 0x0000ffff); |
863 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); | 943 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); |
944 | ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); | ||
945 | |||
946 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { | ||
947 | ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n", | ||
948 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); | ||
949 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; | ||
950 | } | ||
864 | 951 | ||
865 | ar->ath_common.regulatory.current_rd = | 952 | ar->ath_common.regulatory.current_rd = |
866 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); | 953 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); |
@@ -885,7 +972,7 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, | |||
885 | } | 972 | } |
886 | 973 | ||
887 | ath10k_dbg(ATH10K_DBG_WMI, | 974 | ath10k_dbg(ATH10K_DBG_WMI, |
888 | "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u\n", | 975 | "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n", |
889 | __le32_to_cpu(ev->sw_version), | 976 | __le32_to_cpu(ev->sw_version), |
890 | __le32_to_cpu(ev->sw_version_1), | 977 | __le32_to_cpu(ev->sw_version_1), |
891 | __le32_to_cpu(ev->abi_version), | 978 | __le32_to_cpu(ev->abi_version), |
@@ -894,7 +981,8 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, | |||
894 | __le32_to_cpu(ev->vht_cap_info), | 981 | __le32_to_cpu(ev->vht_cap_info), |
895 | __le32_to_cpu(ev->vht_supp_mcs), | 982 | __le32_to_cpu(ev->vht_supp_mcs), |
896 | __le32_to_cpu(ev->sys_cap_info), | 983 | __le32_to_cpu(ev->sys_cap_info), |
897 | __le32_to_cpu(ev->num_mem_reqs)); | 984 | __le32_to_cpu(ev->num_mem_reqs), |
985 | __le32_to_cpu(ev->num_rf_chains)); | ||
898 | 986 | ||
899 | complete(&ar->wmi.service_ready); | 987 | complete(&ar->wmi.service_ready); |
900 | } | 988 | } |
@@ -1114,7 +1202,7 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar) | |||
1114 | /* connect to control service */ | 1202 | /* connect to control service */ |
1115 | conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; | 1203 | conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; |
1116 | 1204 | ||
1117 | status = ath10k_htc_connect_service(ar->htc, &conn_req, &conn_resp); | 1205 | status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); |
1118 | if (status) { | 1206 | if (status) { |
1119 | ath10k_warn("failed to connect to WMI CONTROL service status: %d\n", | 1207 | ath10k_warn("failed to connect to WMI CONTROL service status: %d\n", |
1120 | status); | 1208 | status); |
@@ -1748,6 +1836,9 @@ int ath10k_wmi_vdev_install_key(struct ath10k *ar, | |||
1748 | if (arg->key_data) | 1836 | if (arg->key_data) |
1749 | memcpy(cmd->key_data, arg->key_data, arg->key_len); | 1837 | memcpy(cmd->key_data, arg->key_data, arg->key_len); |
1750 | 1838 | ||
1839 | ath10k_dbg(ATH10K_DBG_WMI, | ||
1840 | "wmi vdev install key idx %d cipher %d len %d\n", | ||
1841 | arg->key_idx, arg->key_cipher, arg->key_len); | ||
1751 | return ath10k_wmi_cmd_send(ar, skb, WMI_VDEV_INSTALL_KEY_CMDID); | 1842 | return ath10k_wmi_cmd_send(ar, skb, WMI_VDEV_INSTALL_KEY_CMDID); |
1752 | } | 1843 | } |
1753 | 1844 | ||
@@ -2011,6 +2102,9 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar, | |||
2011 | cmd->peer_vht_rates.tx_mcs_set = | 2102 | cmd->peer_vht_rates.tx_mcs_set = |
2012 | __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); | 2103 | __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); |
2013 | 2104 | ||
2105 | ath10k_dbg(ATH10K_DBG_WMI, | ||
2106 | "wmi peer assoc vdev %d addr %pM\n", | ||
2107 | arg->vdev_id, arg->addr); | ||
2014 | return ath10k_wmi_cmd_send(ar, skb, WMI_PEER_ASSOC_CMDID); | 2108 | return ath10k_wmi_cmd_send(ar, skb, WMI_PEER_ASSOC_CMDID); |
2015 | } | 2109 | } |
2016 | 2110 | ||
@@ -2079,3 +2173,22 @@ int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id) | |||
2079 | ath10k_dbg(ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id); | 2173 | ath10k_dbg(ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id); |
2080 | return ath10k_wmi_cmd_send(ar, skb, WMI_REQUEST_STATS_CMDID); | 2174 | return ath10k_wmi_cmd_send(ar, skb, WMI_REQUEST_STATS_CMDID); |
2081 | } | 2175 | } |
2176 | |||
2177 | int ath10k_wmi_force_fw_hang(struct ath10k *ar, | ||
2178 | enum wmi_force_fw_hang_type type, u32 delay_ms) | ||
2179 | { | ||
2180 | struct wmi_force_fw_hang_cmd *cmd; | ||
2181 | struct sk_buff *skb; | ||
2182 | |||
2183 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); | ||
2184 | if (!skb) | ||
2185 | return -ENOMEM; | ||
2186 | |||
2187 | cmd = (struct wmi_force_fw_hang_cmd *)skb->data; | ||
2188 | cmd->type = __cpu_to_le32(type); | ||
2189 | cmd->delay_ms = __cpu_to_le32(delay_ms); | ||
2190 | |||
2191 | ath10k_dbg(ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n", | ||
2192 | type, delay_ms); | ||
2193 | return ath10k_wmi_cmd_send(ar, skb, WMI_FORCE_FW_HANG_CMDID); | ||
2194 | } | ||
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 9555f5a0e041..2c5a4f8daf2e 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h | |||
@@ -416,6 +416,7 @@ enum wmi_cmd_id { | |||
416 | WMI_PDEV_FTM_INTG_CMDID, | 416 | WMI_PDEV_FTM_INTG_CMDID, |
417 | WMI_VDEV_SET_KEEPALIVE_CMDID, | 417 | WMI_VDEV_SET_KEEPALIVE_CMDID, |
418 | WMI_VDEV_GET_KEEPALIVE_CMDID, | 418 | WMI_VDEV_GET_KEEPALIVE_CMDID, |
419 | WMI_FORCE_FW_HANG_CMDID, | ||
419 | 420 | ||
420 | /* GPIO Configuration */ | 421 | /* GPIO Configuration */ |
421 | WMI_GPIO_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_GPIO), | 422 | WMI_GPIO_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_GPIO), |
@@ -2930,6 +2931,11 @@ struct wmi_chan_info_event { | |||
2930 | __le32 cycle_count; | 2931 | __le32 cycle_count; |
2931 | } __packed; | 2932 | } __packed; |
2932 | 2933 | ||
2934 | #define WMI_CHAN_INFO_FLAG_COMPLETE BIT(0) | ||
2935 | |||
2936 | /* FIXME: empirically extrapolated */ | ||
2937 | #define WMI_CHAN_INFO_MSEC(x) ((x) / 76595) | ||
2938 | |||
2933 | /* Beacon filter wmi command info */ | 2939 | /* Beacon filter wmi command info */ |
2934 | #define BCN_FLT_MAX_SUPPORTED_IES 256 | 2940 | #define BCN_FLT_MAX_SUPPORTED_IES 256 |
2935 | #define BCN_FLT_MAX_ELEMS_IE_LIST (BCN_FLT_MAX_SUPPORTED_IES / 32) | 2941 | #define BCN_FLT_MAX_ELEMS_IE_LIST (BCN_FLT_MAX_SUPPORTED_IES / 32) |
@@ -2972,6 +2978,22 @@ struct wmi_sta_keepalive_cmd { | |||
2972 | struct wmi_sta_keepalive_arp_resp arp_resp; | 2978 | struct wmi_sta_keepalive_arp_resp arp_resp; |
2973 | } __packed; | 2979 | } __packed; |
2974 | 2980 | ||
2981 | enum wmi_force_fw_hang_type { | ||
2982 | WMI_FORCE_FW_HANG_ASSERT = 1, | ||
2983 | WMI_FORCE_FW_HANG_NO_DETECT, | ||
2984 | WMI_FORCE_FW_HANG_CTRL_EP_FULL, | ||
2985 | WMI_FORCE_FW_HANG_EMPTY_POINT, | ||
2986 | WMI_FORCE_FW_HANG_STACK_OVERFLOW, | ||
2987 | WMI_FORCE_FW_HANG_INFINITE_LOOP, | ||
2988 | }; | ||
2989 | |||
2990 | #define WMI_FORCE_FW_HANG_RANDOM_TIME 0xFFFFFFFF | ||
2991 | |||
2992 | struct wmi_force_fw_hang_cmd { | ||
2993 | __le32 type; | ||
2994 | __le32 delay_ms; | ||
2995 | } __packed; | ||
2996 | |||
2975 | #define ATH10K_RTS_MAX 2347 | 2997 | #define ATH10K_RTS_MAX 2347 |
2976 | #define ATH10K_FRAGMT_THRESHOLD_MIN 540 | 2998 | #define ATH10K_FRAGMT_THRESHOLD_MIN 540 |
2977 | #define ATH10K_FRAGMT_THRESHOLD_MAX 2346 | 2999 | #define ATH10K_FRAGMT_THRESHOLD_MAX 2346 |
@@ -3048,5 +3070,7 @@ int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg *arg); | |||
3048 | int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, | 3070 | int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, |
3049 | const struct wmi_pdev_set_wmm_params_arg *arg); | 3071 | const struct wmi_pdev_set_wmm_params_arg *arg); |
3050 | int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id); | 3072 | int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id); |
3073 | int ath10k_wmi_force_fw_hang(struct ath10k *ar, | ||
3074 | enum wmi_force_fw_hang_type type, u32 delay_ms); | ||
3051 | 3075 | ||
3052 | #endif /* _WMI_H_ */ | 3076 | #endif /* _WMI_H_ */ |
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 2d691b8b95b9..74bd54d6aceb 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/average.h> | 29 | #include <linux/average.h> |
30 | #include <linux/leds.h> | 30 | #include <linux/leds.h> |
31 | #include <net/mac80211.h> | 31 | #include <net/mac80211.h> |
32 | #include <net/cfg80211.h> | ||
32 | 33 | ||
33 | /* RX/TX descriptor hw structs | 34 | /* RX/TX descriptor hw structs |
34 | * TODO: Driver part should only see sw structs */ | 35 | * TODO: Driver part should only see sw structs */ |
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index ce67ab791eae..48161edec8de 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/etherdevice.h> | 56 | #include <linux/etherdevice.h> |
57 | #include <linux/nl80211.h> | 57 | #include <linux/nl80211.h> |
58 | 58 | ||
59 | #include <net/cfg80211.h> | ||
59 | #include <net/ieee80211_radiotap.h> | 60 | #include <net/ieee80211_radiotap.h> |
60 | 61 | ||
61 | #include <asm/unaligned.h> | 62 | #include <asm/unaligned.h> |
@@ -165,28 +166,36 @@ static const struct ieee80211_rate ath5k_rates[] = { | |||
165 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | 166 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
166 | { .bitrate = 60, | 167 | { .bitrate = 60, |
167 | .hw_value = ATH5K_RATE_CODE_6M, | 168 | .hw_value = ATH5K_RATE_CODE_6M, |
168 | .flags = 0 }, | 169 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
170 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
169 | { .bitrate = 90, | 171 | { .bitrate = 90, |
170 | .hw_value = ATH5K_RATE_CODE_9M, | 172 | .hw_value = ATH5K_RATE_CODE_9M, |
171 | .flags = 0 }, | 173 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
174 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
172 | { .bitrate = 120, | 175 | { .bitrate = 120, |
173 | .hw_value = ATH5K_RATE_CODE_12M, | 176 | .hw_value = ATH5K_RATE_CODE_12M, |
174 | .flags = 0 }, | 177 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
178 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
175 | { .bitrate = 180, | 179 | { .bitrate = 180, |
176 | .hw_value = ATH5K_RATE_CODE_18M, | 180 | .hw_value = ATH5K_RATE_CODE_18M, |
177 | .flags = 0 }, | 181 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
182 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
178 | { .bitrate = 240, | 183 | { .bitrate = 240, |
179 | .hw_value = ATH5K_RATE_CODE_24M, | 184 | .hw_value = ATH5K_RATE_CODE_24M, |
180 | .flags = 0 }, | 185 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
186 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
181 | { .bitrate = 360, | 187 | { .bitrate = 360, |
182 | .hw_value = ATH5K_RATE_CODE_36M, | 188 | .hw_value = ATH5K_RATE_CODE_36M, |
183 | .flags = 0 }, | 189 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
190 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
184 | { .bitrate = 480, | 191 | { .bitrate = 480, |
185 | .hw_value = ATH5K_RATE_CODE_48M, | 192 | .hw_value = ATH5K_RATE_CODE_48M, |
186 | .flags = 0 }, | 193 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
194 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
187 | { .bitrate = 540, | 195 | { .bitrate = 540, |
188 | .hw_value = ATH5K_RATE_CODE_54M, | 196 | .hw_value = ATH5K_RATE_CODE_54M, |
189 | .flags = 0 }, | 197 | .flags = IEEE80211_RATE_SUPPORTS_5MHZ | |
198 | IEEE80211_RATE_SUPPORTS_10MHZ }, | ||
190 | }; | 199 | }; |
191 | 200 | ||
192 | static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) | 201 | static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) |
@@ -435,11 +444,27 @@ ath5k_setup_bands(struct ieee80211_hw *hw) | |||
435 | * Called with ah->lock. | 444 | * Called with ah->lock. |
436 | */ | 445 | */ |
437 | int | 446 | int |
438 | ath5k_chan_set(struct ath5k_hw *ah, struct ieee80211_channel *chan) | 447 | ath5k_chan_set(struct ath5k_hw *ah, struct cfg80211_chan_def *chandef) |
439 | { | 448 | { |
440 | ATH5K_DBG(ah, ATH5K_DEBUG_RESET, | 449 | ATH5K_DBG(ah, ATH5K_DEBUG_RESET, |
441 | "channel set, resetting (%u -> %u MHz)\n", | 450 | "channel set, resetting (%u -> %u MHz)\n", |
442 | ah->curchan->center_freq, chan->center_freq); | 451 | ah->curchan->center_freq, chandef->chan->center_freq); |
452 | |||
453 | switch (chandef->width) { | ||
454 | case NL80211_CHAN_WIDTH_20: | ||
455 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
456 | ah->ah_bwmode = AR5K_BWMODE_DEFAULT; | ||
457 | break; | ||
458 | case NL80211_CHAN_WIDTH_5: | ||
459 | ah->ah_bwmode = AR5K_BWMODE_5MHZ; | ||
460 | break; | ||
461 | case NL80211_CHAN_WIDTH_10: | ||
462 | ah->ah_bwmode = AR5K_BWMODE_10MHZ; | ||
463 | break; | ||
464 | default: | ||
465 | WARN_ON(1); | ||
466 | return -EINVAL; | ||
467 | } | ||
443 | 468 | ||
444 | /* | 469 | /* |
445 | * To switch channels clear any pending DMA operations; | 470 | * To switch channels clear any pending DMA operations; |
@@ -447,7 +472,7 @@ ath5k_chan_set(struct ath5k_hw *ah, struct ieee80211_channel *chan) | |||
447 | * hardware at the new frequency, and then re-enable | 472 | * hardware at the new frequency, and then re-enable |
448 | * the relevant bits of the h/w. | 473 | * the relevant bits of the h/w. |
449 | */ | 474 | */ |
450 | return ath5k_reset(ah, chan, true); | 475 | return ath5k_reset(ah, chandef->chan, true); |
451 | } | 476 | } |
452 | 477 | ||
453 | void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) | 478 | void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) |
@@ -1400,6 +1425,16 @@ ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb, | |||
1400 | 1425 | ||
1401 | rxs->rate_idx = ath5k_hw_to_driver_rix(ah, rs->rs_rate); | 1426 | rxs->rate_idx = ath5k_hw_to_driver_rix(ah, rs->rs_rate); |
1402 | rxs->flag |= ath5k_rx_decrypted(ah, skb, rs); | 1427 | rxs->flag |= ath5k_rx_decrypted(ah, skb, rs); |
1428 | switch (ah->ah_bwmode) { | ||
1429 | case AR5K_BWMODE_5MHZ: | ||
1430 | rxs->flag |= RX_FLAG_5MHZ; | ||
1431 | break; | ||
1432 | case AR5K_BWMODE_10MHZ: | ||
1433 | rxs->flag |= RX_FLAG_10MHZ; | ||
1434 | break; | ||
1435 | default: | ||
1436 | break; | ||
1437 | } | ||
1403 | 1438 | ||
1404 | if (rxs->rate_idx >= 0 && rs->rs_rate == | 1439 | if (rxs->rate_idx >= 0 && rs->rs_rate == |
1405 | ah->sbands[ah->curchan->band].bitrates[rxs->rate_idx].hw_value_short) | 1440 | ah->sbands[ah->curchan->band].bitrates[rxs->rate_idx].hw_value_short) |
@@ -2507,6 +2542,8 @@ ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops) | |||
2507 | /* SW support for IBSS_RSN is provided by mac80211 */ | 2542 | /* SW support for IBSS_RSN is provided by mac80211 */ |
2508 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; | 2543 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
2509 | 2544 | ||
2545 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ; | ||
2546 | |||
2510 | /* both antennas can be configured as RX or TX */ | 2547 | /* both antennas can be configured as RX or TX */ |
2511 | hw->wiphy->available_antennas_tx = 0x3; | 2548 | hw->wiphy->available_antennas_tx = 0x3; |
2512 | hw->wiphy->available_antennas_rx = 0x3; | 2549 | hw->wiphy->available_antennas_rx = 0x3; |
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h index ca9a83ceeee1..97469d0fbad7 100644 --- a/drivers/net/wireless/ath/ath5k/base.h +++ b/drivers/net/wireless/ath/ath5k/base.h | |||
@@ -101,7 +101,7 @@ void ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable); | |||
101 | 101 | ||
102 | void ath5k_update_bssid_mask_and_opmode(struct ath5k_hw *ah, | 102 | void ath5k_update_bssid_mask_and_opmode(struct ath5k_hw *ah, |
103 | struct ieee80211_vif *vif); | 103 | struct ieee80211_vif *vif); |
104 | int ath5k_chan_set(struct ath5k_hw *ah, struct ieee80211_channel *chan); | 104 | int ath5k_chan_set(struct ath5k_hw *ah, struct cfg80211_chan_def *chandef); |
105 | void ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf); | 105 | void ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf); |
106 | void ath5k_rxbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf); | 106 | void ath5k_rxbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf); |
107 | void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, | 107 | void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, |
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index 9d00dab666a8..b8d031ae63c2 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c | |||
@@ -245,9 +245,11 @@ static ssize_t write_file_beacon(struct file *file, | |||
245 | struct ath5k_hw *ah = file->private_data; | 245 | struct ath5k_hw *ah = file->private_data; |
246 | char buf[20]; | 246 | char buf[20]; |
247 | 247 | ||
248 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 248 | count = min_t(size_t, count, sizeof(buf) - 1); |
249 | if (copy_from_user(buf, userbuf, count)) | ||
249 | return -EFAULT; | 250 | return -EFAULT; |
250 | 251 | ||
252 | buf[count] = '\0'; | ||
251 | if (strncmp(buf, "disable", 7) == 0) { | 253 | if (strncmp(buf, "disable", 7) == 0) { |
252 | AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE); | 254 | AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE); |
253 | pr_info("debugfs disable beacons\n"); | 255 | pr_info("debugfs disable beacons\n"); |
@@ -345,9 +347,11 @@ static ssize_t write_file_debug(struct file *file, | |||
345 | unsigned int i; | 347 | unsigned int i; |
346 | char buf[20]; | 348 | char buf[20]; |
347 | 349 | ||
348 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 350 | count = min_t(size_t, count, sizeof(buf) - 1); |
351 | if (copy_from_user(buf, userbuf, count)) | ||
349 | return -EFAULT; | 352 | return -EFAULT; |
350 | 353 | ||
354 | buf[count] = '\0'; | ||
351 | for (i = 0; i < ARRAY_SIZE(dbg_info); i++) { | 355 | for (i = 0; i < ARRAY_SIZE(dbg_info); i++) { |
352 | if (strncmp(buf, dbg_info[i].name, | 356 | if (strncmp(buf, dbg_info[i].name, |
353 | strlen(dbg_info[i].name)) == 0) { | 357 | strlen(dbg_info[i].name)) == 0) { |
@@ -448,9 +452,11 @@ static ssize_t write_file_antenna(struct file *file, | |||
448 | unsigned int i; | 452 | unsigned int i; |
449 | char buf[20]; | 453 | char buf[20]; |
450 | 454 | ||
451 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 455 | count = min_t(size_t, count, sizeof(buf) - 1); |
456 | if (copy_from_user(buf, userbuf, count)) | ||
452 | return -EFAULT; | 457 | return -EFAULT; |
453 | 458 | ||
459 | buf[count] = '\0'; | ||
454 | if (strncmp(buf, "diversity", 9) == 0) { | 460 | if (strncmp(buf, "diversity", 9) == 0) { |
455 | ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT); | 461 | ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT); |
456 | pr_info("debug: enable diversity\n"); | 462 | pr_info("debug: enable diversity\n"); |
@@ -619,9 +625,11 @@ static ssize_t write_file_frameerrors(struct file *file, | |||
619 | struct ath5k_statistics *st = &ah->stats; | 625 | struct ath5k_statistics *st = &ah->stats; |
620 | char buf[20]; | 626 | char buf[20]; |
621 | 627 | ||
622 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 628 | count = min_t(size_t, count, sizeof(buf) - 1); |
629 | if (copy_from_user(buf, userbuf, count)) | ||
623 | return -EFAULT; | 630 | return -EFAULT; |
624 | 631 | ||
632 | buf[count] = '\0'; | ||
625 | if (strncmp(buf, "clear", 5) == 0) { | 633 | if (strncmp(buf, "clear", 5) == 0) { |
626 | st->rxerr_crc = 0; | 634 | st->rxerr_crc = 0; |
627 | st->rxerr_phy = 0; | 635 | st->rxerr_phy = 0; |
@@ -766,9 +774,11 @@ static ssize_t write_file_ani(struct file *file, | |||
766 | struct ath5k_hw *ah = file->private_data; | 774 | struct ath5k_hw *ah = file->private_data; |
767 | char buf[20]; | 775 | char buf[20]; |
768 | 776 | ||
769 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 777 | count = min_t(size_t, count, sizeof(buf) - 1); |
778 | if (copy_from_user(buf, userbuf, count)) | ||
770 | return -EFAULT; | 779 | return -EFAULT; |
771 | 780 | ||
781 | buf[count] = '\0'; | ||
772 | if (strncmp(buf, "sens-low", 8) == 0) { | 782 | if (strncmp(buf, "sens-low", 8) == 0) { |
773 | ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_HIGH); | 783 | ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_HIGH); |
774 | } else if (strncmp(buf, "sens-high", 9) == 0) { | 784 | } else if (strncmp(buf, "sens-high", 9) == 0) { |
@@ -862,9 +872,11 @@ static ssize_t write_file_queue(struct file *file, | |||
862 | struct ath5k_hw *ah = file->private_data; | 872 | struct ath5k_hw *ah = file->private_data; |
863 | char buf[20]; | 873 | char buf[20]; |
864 | 874 | ||
865 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) | 875 | count = min_t(size_t, count, sizeof(buf) - 1); |
876 | if (copy_from_user(buf, userbuf, count)) | ||
866 | return -EFAULT; | 877 | return -EFAULT; |
867 | 878 | ||
879 | buf[count] = '\0'; | ||
868 | if (strncmp(buf, "start", 5) == 0) | 880 | if (strncmp(buf, "start", 5) == 0) |
869 | ieee80211_wake_queues(ah->hw); | 881 | ieee80211_wake_queues(ah->hw); |
870 | else if (strncmp(buf, "stop", 4) == 0) | 882 | else if (strncmp(buf, "stop", 4) == 0) |
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c index 81b686c6a376..4ee01f654235 100644 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c | |||
@@ -202,7 +202,7 @@ ath5k_config(struct ieee80211_hw *hw, u32 changed) | |||
202 | mutex_lock(&ah->lock); | 202 | mutex_lock(&ah->lock); |
203 | 203 | ||
204 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | 204 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
205 | ret = ath5k_chan_set(ah, conf->chandef.chan); | 205 | ret = ath5k_chan_set(ah, &conf->chandef); |
206 | if (ret < 0) | 206 | if (ret < 0) |
207 | goto unlock; | 207 | goto unlock; |
208 | } | 208 | } |
@@ -325,7 +325,7 @@ ath5k_prepare_multicast(struct ieee80211_hw *hw, | |||
325 | struct netdev_hw_addr *ha; | 325 | struct netdev_hw_addr *ha; |
326 | 326 | ||
327 | mfilt[0] = 0; | 327 | mfilt[0] = 0; |
328 | mfilt[1] = 1; | 328 | mfilt[1] = 0; |
329 | 329 | ||
330 | netdev_hw_addr_list_for_each(ha, mc_list) { | 330 | netdev_hw_addr_list_for_each(ha, mc_list) { |
331 | /* calculate XOR of eight 6-bit values */ | 331 | /* calculate XOR of eight 6-bit values */ |
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c index 1f16b4227d8f..c60d36aa13e2 100644 --- a/drivers/net/wireless/ath/ath5k/pcu.c +++ b/drivers/net/wireless/ath/ath5k/pcu.c | |||
@@ -144,11 +144,13 @@ ath5k_hw_get_frame_duration(struct ath5k_hw *ah, enum ieee80211_band band, | |||
144 | sifs = AR5K_INIT_SIFS_HALF_RATE; | 144 | sifs = AR5K_INIT_SIFS_HALF_RATE; |
145 | preamble *= 2; | 145 | preamble *= 2; |
146 | sym_time *= 2; | 146 | sym_time *= 2; |
147 | bitrate = DIV_ROUND_UP(bitrate, 2); | ||
147 | break; | 148 | break; |
148 | case AR5K_BWMODE_5MHZ: | 149 | case AR5K_BWMODE_5MHZ: |
149 | sifs = AR5K_INIT_SIFS_QUARTER_RATE; | 150 | sifs = AR5K_INIT_SIFS_QUARTER_RATE; |
150 | preamble *= 4; | 151 | preamble *= 4; |
151 | sym_time *= 4; | 152 | sym_time *= 4; |
153 | bitrate = DIV_ROUND_UP(bitrate, 4); | ||
152 | break; | 154 | break; |
153 | default: | 155 | default: |
154 | sifs = AR5K_INIT_SIFS_DEFAULT_BG; | 156 | sifs = AR5K_INIT_SIFS_DEFAULT_BG; |
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index 65fe929529a8..0583c69d26db 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c | |||
@@ -566,9 +566,11 @@ int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time) | |||
566 | { | 566 | { |
567 | struct ieee80211_channel *channel = ah->ah_current_channel; | 567 | struct ieee80211_channel *channel = ah->ah_current_channel; |
568 | enum ieee80211_band band; | 568 | enum ieee80211_band band; |
569 | struct ieee80211_supported_band *sband; | ||
569 | struct ieee80211_rate *rate; | 570 | struct ieee80211_rate *rate; |
570 | u32 ack_tx_time, eifs, eifs_clock, sifs, sifs_clock; | 571 | u32 ack_tx_time, eifs, eifs_clock, sifs, sifs_clock; |
571 | u32 slot_time_clock = ath5k_hw_htoclock(ah, slot_time); | 572 | u32 slot_time_clock = ath5k_hw_htoclock(ah, slot_time); |
573 | u32 rate_flags, i; | ||
572 | 574 | ||
573 | if (slot_time < 6 || slot_time_clock > AR5K_SLOT_TIME_MAX) | 575 | if (slot_time < 6 || slot_time_clock > AR5K_SLOT_TIME_MAX) |
574 | return -EINVAL; | 576 | return -EINVAL; |
@@ -605,7 +607,28 @@ int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time) | |||
605 | else | 607 | else |
606 | band = IEEE80211_BAND_2GHZ; | 608 | band = IEEE80211_BAND_2GHZ; |
607 | 609 | ||
608 | rate = &ah->sbands[band].bitrates[0]; | 610 | switch (ah->ah_bwmode) { |
611 | case AR5K_BWMODE_5MHZ: | ||
612 | rate_flags = IEEE80211_RATE_SUPPORTS_5MHZ; | ||
613 | break; | ||
614 | case AR5K_BWMODE_10MHZ: | ||
615 | rate_flags = IEEE80211_RATE_SUPPORTS_10MHZ; | ||
616 | break; | ||
617 | default: | ||
618 | rate_flags = 0; | ||
619 | break; | ||
620 | } | ||
621 | sband = &ah->sbands[band]; | ||
622 | rate = NULL; | ||
623 | for (i = 0; i < sband->n_bitrates; i++) { | ||
624 | if ((rate_flags & sband->bitrates[i].flags) != rate_flags) | ||
625 | continue; | ||
626 | rate = &sband->bitrates[i]; | ||
627 | break; | ||
628 | } | ||
629 | if (WARN_ON(!rate)) | ||
630 | return -EINVAL; | ||
631 | |||
609 | ack_tx_time = ath5k_hw_get_frame_duration(ah, band, 10, rate, false); | 632 | ack_tx_time = ath5k_hw_get_frame_duration(ah, band, 10, rate, false); |
610 | 633 | ||
611 | /* ack_tx_time includes an SIFS already */ | 634 | /* ack_tx_time includes an SIFS already */ |
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 6a67881f94d6..4f316bdcbab5 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c | |||
@@ -1836,6 +1836,9 @@ void ath6kl_stop_txrx(struct ath6kl *ar) | |||
1836 | 1836 | ||
1837 | clear_bit(WMI_READY, &ar->flag); | 1837 | clear_bit(WMI_READY, &ar->flag); |
1838 | 1838 | ||
1839 | if (ar->fw_recovery.enable) | ||
1840 | del_timer_sync(&ar->fw_recovery.hb_timer); | ||
1841 | |||
1839 | /* | 1842 | /* |
1840 | * After wmi_shudown all WMI events will be dropped. We | 1843 | * After wmi_shudown all WMI events will be dropped. We |
1841 | * need to cleanup the buffers allocated in AP mode and | 1844 | * need to cleanup the buffers allocated in AP mode and |
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d4fcfcad57d0..5839fc23bdc7 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c | |||
@@ -29,6 +29,9 @@ struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 *node_addr) | |||
29 | struct ath6kl_sta *conn = NULL; | 29 | struct ath6kl_sta *conn = NULL; |
30 | u8 i, max_conn; | 30 | u8 i, max_conn; |
31 | 31 | ||
32 | if (is_zero_ether_addr(node_addr)) | ||
33 | return NULL; | ||
34 | |||
32 | max_conn = (vif->nw_type == AP_NETWORK) ? AP_MAX_NUM_STA : 0; | 35 | max_conn = (vif->nw_type == AP_NETWORK) ? AP_MAX_NUM_STA : 0; |
33 | 36 | ||
34 | for (i = 0; i < max_conn; i++) { | 37 | for (i = 0; i < max_conn; i++) { |
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index d491a3178986..7944c25c9a43 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig | |||
@@ -56,7 +56,7 @@ config ATH9K_AHB | |||
56 | 56 | ||
57 | config ATH9K_DEBUGFS | 57 | config ATH9K_DEBUGFS |
58 | bool "Atheros ath9k debugging" | 58 | bool "Atheros ath9k debugging" |
59 | depends on ATH9K | 59 | depends on ATH9K && DEBUG_FS |
60 | select MAC80211_DEBUGFS | 60 | select MAC80211_DEBUGFS |
61 | select RELAY | 61 | select RELAY |
62 | ---help--- | 62 | ---help--- |
@@ -96,6 +96,16 @@ config ATH9K_LEGACY_RATE_CONTROL | |||
96 | has to be passed to mac80211 using the module parameter, | 96 | has to be passed to mac80211 using the module parameter, |
97 | ieee80211_default_rc_algo. | 97 | ieee80211_default_rc_algo. |
98 | 98 | ||
99 | config ATH9K_RFKILL | ||
100 | bool "Atheros ath9k rfkill support" if EXPERT | ||
101 | depends on ATH9K | ||
102 | depends on RFKILL=y || RFKILL=ATH9K | ||
103 | default y | ||
104 | help | ||
105 | Say Y to have ath9k poll the RF-Kill GPIO every couple of | ||
106 | seconds. Turn off to save power, but enable it if you have | ||
107 | a platform that can toggle the RF-Kill GPIO. | ||
108 | |||
99 | config ATH9K_HTC | 109 | config ATH9K_HTC |
100 | tristate "Atheros HTC based wireless cards support" | 110 | tristate "Atheros HTC based wireless cards support" |
101 | depends on USB && MAC80211 | 111 | depends on USB && MAC80211 |
diff --git a/drivers/net/wireless/ath/ath9k/antenna.c b/drivers/net/wireless/ath/ath9k/antenna.c index 664844c5d3d5..dd1cc73d7946 100644 --- a/drivers/net/wireless/ath/ath9k/antenna.c +++ b/drivers/net/wireless/ath/ath9k/antenna.c | |||
@@ -16,37 +16,119 @@ | |||
16 | 16 | ||
17 | #include "ath9k.h" | 17 | #include "ath9k.h" |
18 | 18 | ||
19 | static inline bool ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta, | 19 | /* |
20 | * AR9285 | ||
21 | * ====== | ||
22 | * | ||
23 | * EEPROM has 2 4-bit fields containing the card configuration. | ||
24 | * | ||
25 | * antdiv_ctl1: | ||
26 | * ------------ | ||
27 | * bb_enable_ant_div_lnadiv : 1 | ||
28 | * bb_ant_div_alt_gaintb : 1 | ||
29 | * bb_ant_div_main_gaintb : 1 | ||
30 | * bb_enable_ant_fast_div : 1 | ||
31 | * | ||
32 | * antdiv_ctl2: | ||
33 | * ----------- | ||
34 | * bb_ant_div_alt_lnaconf : 2 | ||
35 | * bb_ant_div_main_lnaconf : 2 | ||
36 | * | ||
37 | * The EEPROM bits are used as follows: | ||
38 | * ------------------------------------ | ||
39 | * | ||
40 | * bb_enable_ant_div_lnadiv - Enable LNA path rx antenna diversity/combining. | ||
41 | * Set in AR_PHY_MULTICHAIN_GAIN_CTL. | ||
42 | * | ||
43 | * bb_ant_div_[alt/main]_gaintb - 0 -> Antenna config Alt/Main uses gaintable 0 | ||
44 | * 1 -> Antenna config Alt/Main uses gaintable 1 | ||
45 | * Set in AR_PHY_MULTICHAIN_GAIN_CTL. | ||
46 | * | ||
47 | * bb_enable_ant_fast_div - Enable fast antenna diversity. | ||
48 | * Set in AR_PHY_CCK_DETECT. | ||
49 | * | ||
50 | * bb_ant_div_[alt/main]_lnaconf - Alt/Main LNA diversity/combining input config. | ||
51 | * Set in AR_PHY_MULTICHAIN_GAIN_CTL. | ||
52 | * 10=LNA1 | ||
53 | * 01=LNA2 | ||
54 | * 11=LNA1+LNA2 | ||
55 | * 00=LNA1-LNA2 | ||
56 | * | ||
57 | * AR9485 / AR9565 / AR9331 | ||
58 | * ======================== | ||
59 | * | ||
60 | * The same bits are present in the EEPROM, but the location in the | ||
61 | * EEPROM is different (ant_div_control in ar9300_BaseExtension_1). | ||
62 | * | ||
63 | * ant_div_alt_lnaconf ==> bit 0~1 | ||
64 | * ant_div_main_lnaconf ==> bit 2~3 | ||
65 | * ant_div_alt_gaintb ==> bit 4 | ||
66 | * ant_div_main_gaintb ==> bit 5 | ||
67 | * enable_ant_div_lnadiv ==> bit 6 | ||
68 | * enable_ant_fast_div ==> bit 7 | ||
69 | */ | ||
70 | |||
71 | static inline bool ath_is_alt_ant_ratio_better(struct ath_ant_comb *antcomb, | ||
72 | int alt_ratio, int maxdelta, | ||
20 | int mindelta, int main_rssi_avg, | 73 | int mindelta, int main_rssi_avg, |
21 | int alt_rssi_avg, int pkt_count) | 74 | int alt_rssi_avg, int pkt_count) |
22 | { | 75 | { |
23 | return (((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) && | 76 | if (pkt_count <= 50) |
24 | (alt_rssi_avg > main_rssi_avg + maxdelta)) || | 77 | return false; |
25 | (alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50); | 78 | |
79 | if (alt_rssi_avg > main_rssi_avg + mindelta) | ||
80 | return true; | ||
81 | |||
82 | if (alt_ratio >= antcomb->ant_ratio2 && | ||
83 | alt_rssi_avg >= antcomb->low_rssi_thresh && | ||
84 | (alt_rssi_avg > main_rssi_avg + maxdelta)) | ||
85 | return true; | ||
86 | |||
87 | return false; | ||
26 | } | 88 | } |
27 | 89 | ||
28 | static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio, | 90 | static inline bool ath_ant_div_comb_alt_check(struct ath_hw_antcomb_conf *conf, |
29 | int curr_main_set, int curr_alt_set, | 91 | struct ath_ant_comb *antcomb, |
30 | int alt_rssi_avg, int main_rssi_avg) | 92 | int alt_ratio, int alt_rssi_avg, |
93 | int main_rssi_avg) | ||
31 | { | 94 | { |
32 | bool result = false; | 95 | bool result, set1, set2; |
33 | switch (div_group) { | 96 | |
97 | result = set1 = set2 = false; | ||
98 | |||
99 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2 && | ||
100 | conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA1) | ||
101 | set1 = true; | ||
102 | |||
103 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA1 && | ||
104 | conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
105 | set2 = true; | ||
106 | |||
107 | switch (conf->div_group) { | ||
34 | case 0: | 108 | case 0: |
35 | if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) | 109 | if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) |
36 | result = true; | 110 | result = true; |
37 | break; | 111 | break; |
38 | case 1: | 112 | case 1: |
39 | case 2: | 113 | case 2: |
40 | if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) && | 114 | if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh) |
41 | (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) && | 115 | break; |
42 | (alt_rssi_avg >= (main_rssi_avg - 5))) || | 116 | |
43 | ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) && | 117 | if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 5))) || |
44 | (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) && | 118 | (set2 && (alt_rssi_avg >= (main_rssi_avg - 2))) || |
45 | (alt_rssi_avg >= (main_rssi_avg - 2)))) && | 119 | (alt_ratio > antcomb->ant_ratio)) |
46 | (alt_rssi_avg >= 4)) | ||
47 | result = true; | 120 | result = true; |
48 | else | 121 | |
49 | result = false; | 122 | break; |
123 | case 3: | ||
124 | if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh) | ||
125 | break; | ||
126 | |||
127 | if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 3))) || | ||
128 | (set2 && (alt_rssi_avg >= (main_rssi_avg + 3))) || | ||
129 | (alt_ratio > antcomb->ant_ratio)) | ||
130 | result = true; | ||
131 | |||
50 | break; | 132 | break; |
51 | } | 133 | } |
52 | 134 | ||
@@ -108,6 +190,74 @@ static void ath_lnaconf_alt_good_scan(struct ath_ant_comb *antcomb, | |||
108 | } | 190 | } |
109 | } | 191 | } |
110 | 192 | ||
193 | static void ath_ant_set_alt_ratio(struct ath_ant_comb *antcomb, | ||
194 | struct ath_hw_antcomb_conf *conf) | ||
195 | { | ||
196 | /* set alt to the conf with maximun ratio */ | ||
197 | if (antcomb->first_ratio && antcomb->second_ratio) { | ||
198 | if (antcomb->rssi_second > antcomb->rssi_third) { | ||
199 | /* first alt*/ | ||
200 | if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
201 | (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) | ||
202 | /* Set alt LNA1 or LNA2*/ | ||
203 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
204 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
205 | else | ||
206 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
207 | else | ||
208 | /* Set alt to A+B or A-B */ | ||
209 | conf->alt_lna_conf = | ||
210 | antcomb->first_quick_scan_conf; | ||
211 | } else if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
212 | (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) { | ||
213 | /* Set alt LNA1 or LNA2 */ | ||
214 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
215 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
216 | else | ||
217 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
218 | } else { | ||
219 | /* Set alt to A+B or A-B */ | ||
220 | conf->alt_lna_conf = antcomb->second_quick_scan_conf; | ||
221 | } | ||
222 | } else if (antcomb->first_ratio) { | ||
223 | /* first alt */ | ||
224 | if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
225 | (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) | ||
226 | /* Set alt LNA1 or LNA2 */ | ||
227 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
228 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
229 | else | ||
230 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
231 | else | ||
232 | /* Set alt to A+B or A-B */ | ||
233 | conf->alt_lna_conf = antcomb->first_quick_scan_conf; | ||
234 | } else if (antcomb->second_ratio) { | ||
235 | /* second alt */ | ||
236 | if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
237 | (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) | ||
238 | /* Set alt LNA1 or LNA2 */ | ||
239 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
240 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
241 | else | ||
242 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
243 | else | ||
244 | /* Set alt to A+B or A-B */ | ||
245 | conf->alt_lna_conf = antcomb->second_quick_scan_conf; | ||
246 | } else { | ||
247 | /* main is largest */ | ||
248 | if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
249 | (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)) | ||
250 | /* Set alt LNA1 or LNA2 */ | ||
251 | if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2) | ||
252 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
253 | else | ||
254 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
255 | else | ||
256 | /* Set alt to A+B or A-B */ | ||
257 | conf->alt_lna_conf = antcomb->main_conf; | ||
258 | } | ||
259 | } | ||
260 | |||
111 | static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | 261 | static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, |
112 | struct ath_hw_antcomb_conf *div_ant_conf, | 262 | struct ath_hw_antcomb_conf *div_ant_conf, |
113 | int main_rssi_avg, int alt_rssi_avg, | 263 | int main_rssi_avg, int alt_rssi_avg, |
@@ -129,7 +279,7 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
129 | 279 | ||
130 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { | 280 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { |
131 | /* main is LNA1 */ | 281 | /* main is LNA1 */ |
132 | if (ath_is_alt_ant_ratio_better(alt_ratio, | 282 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
133 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, | 283 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, |
134 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, | 284 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, |
135 | main_rssi_avg, alt_rssi_avg, | 285 | main_rssi_avg, alt_rssi_avg, |
@@ -138,7 +288,7 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
138 | else | 288 | else |
139 | antcomb->first_ratio = false; | 289 | antcomb->first_ratio = false; |
140 | } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { | 290 | } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { |
141 | if (ath_is_alt_ant_ratio_better(alt_ratio, | 291 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
142 | ATH_ANT_DIV_COMB_LNA1_DELTA_MID, | 292 | ATH_ANT_DIV_COMB_LNA1_DELTA_MID, |
143 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, | 293 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, |
144 | main_rssi_avg, alt_rssi_avg, | 294 | main_rssi_avg, alt_rssi_avg, |
@@ -147,11 +297,11 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
147 | else | 297 | else |
148 | antcomb->first_ratio = false; | 298 | antcomb->first_ratio = false; |
149 | } else { | 299 | } else { |
150 | if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) && | 300 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
151 | (alt_rssi_avg > main_rssi_avg + | 301 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, |
152 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) || | 302 | 0, |
153 | (alt_rssi_avg > main_rssi_avg)) && | 303 | main_rssi_avg, alt_rssi_avg, |
154 | (antcomb->total_pkt_count > 50)) | 304 | antcomb->total_pkt_count)) |
155 | antcomb->first_ratio = true; | 305 | antcomb->first_ratio = true; |
156 | else | 306 | else |
157 | antcomb->first_ratio = false; | 307 | antcomb->first_ratio = false; |
@@ -164,17 +314,21 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
164 | antcomb->rssi_first = main_rssi_avg; | 314 | antcomb->rssi_first = main_rssi_avg; |
165 | antcomb->rssi_third = alt_rssi_avg; | 315 | antcomb->rssi_third = alt_rssi_avg; |
166 | 316 | ||
167 | if (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) | 317 | switch(antcomb->second_quick_scan_conf) { |
318 | case ATH_ANT_DIV_COMB_LNA1: | ||
168 | antcomb->rssi_lna1 = alt_rssi_avg; | 319 | antcomb->rssi_lna1 = alt_rssi_avg; |
169 | else if (antcomb->second_quick_scan_conf == | 320 | break; |
170 | ATH_ANT_DIV_COMB_LNA2) | 321 | case ATH_ANT_DIV_COMB_LNA2: |
171 | antcomb->rssi_lna2 = alt_rssi_avg; | 322 | antcomb->rssi_lna2 = alt_rssi_avg; |
172 | else if (antcomb->second_quick_scan_conf == | 323 | break; |
173 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2) { | 324 | case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2: |
174 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) | 325 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) |
175 | antcomb->rssi_lna2 = main_rssi_avg; | 326 | antcomb->rssi_lna2 = main_rssi_avg; |
176 | else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) | 327 | else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) |
177 | antcomb->rssi_lna1 = main_rssi_avg; | 328 | antcomb->rssi_lna1 = main_rssi_avg; |
329 | break; | ||
330 | default: | ||
331 | break; | ||
178 | } | 332 | } |
179 | 333 | ||
180 | if (antcomb->rssi_lna2 > antcomb->rssi_lna1 + | 334 | if (antcomb->rssi_lna2 > antcomb->rssi_lna1 + |
@@ -184,7 +338,7 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
184 | div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | 338 | div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; |
185 | 339 | ||
186 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { | 340 | if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { |
187 | if (ath_is_alt_ant_ratio_better(alt_ratio, | 341 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
188 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, | 342 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, |
189 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, | 343 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, |
190 | main_rssi_avg, alt_rssi_avg, | 344 | main_rssi_avg, alt_rssi_avg, |
@@ -193,7 +347,7 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
193 | else | 347 | else |
194 | antcomb->second_ratio = false; | 348 | antcomb->second_ratio = false; |
195 | } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { | 349 | } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { |
196 | if (ath_is_alt_ant_ratio_better(alt_ratio, | 350 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
197 | ATH_ANT_DIV_COMB_LNA1_DELTA_MID, | 351 | ATH_ANT_DIV_COMB_LNA1_DELTA_MID, |
198 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, | 352 | ATH_ANT_DIV_COMB_LNA1_DELTA_LOW, |
199 | main_rssi_avg, alt_rssi_avg, | 353 | main_rssi_avg, alt_rssi_avg, |
@@ -202,105 +356,18 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, | |||
202 | else | 356 | else |
203 | antcomb->second_ratio = false; | 357 | antcomb->second_ratio = false; |
204 | } else { | 358 | } else { |
205 | if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) && | 359 | if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, |
206 | (alt_rssi_avg > main_rssi_avg + | 360 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI, |
207 | ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) || | 361 | 0, |
208 | (alt_rssi_avg > main_rssi_avg)) && | 362 | main_rssi_avg, alt_rssi_avg, |
209 | (antcomb->total_pkt_count > 50)) | 363 | antcomb->total_pkt_count)) |
210 | antcomb->second_ratio = true; | 364 | antcomb->second_ratio = true; |
211 | else | 365 | else |
212 | antcomb->second_ratio = false; | 366 | antcomb->second_ratio = false; |
213 | } | 367 | } |
214 | 368 | ||
215 | /* set alt to the conf with maximun ratio */ | 369 | ath_ant_set_alt_ratio(antcomb, div_ant_conf); |
216 | if (antcomb->first_ratio && antcomb->second_ratio) { | 370 | |
217 | if (antcomb->rssi_second > antcomb->rssi_third) { | ||
218 | /* first alt*/ | ||
219 | if ((antcomb->first_quick_scan_conf == | ||
220 | ATH_ANT_DIV_COMB_LNA1) || | ||
221 | (antcomb->first_quick_scan_conf == | ||
222 | ATH_ANT_DIV_COMB_LNA2)) | ||
223 | /* Set alt LNA1 or LNA2*/ | ||
224 | if (div_ant_conf->main_lna_conf == | ||
225 | ATH_ANT_DIV_COMB_LNA2) | ||
226 | div_ant_conf->alt_lna_conf = | ||
227 | ATH_ANT_DIV_COMB_LNA1; | ||
228 | else | ||
229 | div_ant_conf->alt_lna_conf = | ||
230 | ATH_ANT_DIV_COMB_LNA2; | ||
231 | else | ||
232 | /* Set alt to A+B or A-B */ | ||
233 | div_ant_conf->alt_lna_conf = | ||
234 | antcomb->first_quick_scan_conf; | ||
235 | } else if ((antcomb->second_quick_scan_conf == | ||
236 | ATH_ANT_DIV_COMB_LNA1) || | ||
237 | (antcomb->second_quick_scan_conf == | ||
238 | ATH_ANT_DIV_COMB_LNA2)) { | ||
239 | /* Set alt LNA1 or LNA2 */ | ||
240 | if (div_ant_conf->main_lna_conf == | ||
241 | ATH_ANT_DIV_COMB_LNA2) | ||
242 | div_ant_conf->alt_lna_conf = | ||
243 | ATH_ANT_DIV_COMB_LNA1; | ||
244 | else | ||
245 | div_ant_conf->alt_lna_conf = | ||
246 | ATH_ANT_DIV_COMB_LNA2; | ||
247 | } else { | ||
248 | /* Set alt to A+B or A-B */ | ||
249 | div_ant_conf->alt_lna_conf = | ||
250 | antcomb->second_quick_scan_conf; | ||
251 | } | ||
252 | } else if (antcomb->first_ratio) { | ||
253 | /* first alt */ | ||
254 | if ((antcomb->first_quick_scan_conf == | ||
255 | ATH_ANT_DIV_COMB_LNA1) || | ||
256 | (antcomb->first_quick_scan_conf == | ||
257 | ATH_ANT_DIV_COMB_LNA2)) | ||
258 | /* Set alt LNA1 or LNA2 */ | ||
259 | if (div_ant_conf->main_lna_conf == | ||
260 | ATH_ANT_DIV_COMB_LNA2) | ||
261 | div_ant_conf->alt_lna_conf = | ||
262 | ATH_ANT_DIV_COMB_LNA1; | ||
263 | else | ||
264 | div_ant_conf->alt_lna_conf = | ||
265 | ATH_ANT_DIV_COMB_LNA2; | ||
266 | else | ||
267 | /* Set alt to A+B or A-B */ | ||
268 | div_ant_conf->alt_lna_conf = | ||
269 | antcomb->first_quick_scan_conf; | ||
270 | } else if (antcomb->second_ratio) { | ||
271 | /* second alt */ | ||
272 | if ((antcomb->second_quick_scan_conf == | ||
273 | ATH_ANT_DIV_COMB_LNA1) || | ||
274 | (antcomb->second_quick_scan_conf == | ||
275 | ATH_ANT_DIV_COMB_LNA2)) | ||
276 | /* Set alt LNA1 or LNA2 */ | ||
277 | if (div_ant_conf->main_lna_conf == | ||
278 | ATH_ANT_DIV_COMB_LNA2) | ||
279 | div_ant_conf->alt_lna_conf = | ||
280 | ATH_ANT_DIV_COMB_LNA1; | ||
281 | else | ||
282 | div_ant_conf->alt_lna_conf = | ||
283 | ATH_ANT_DIV_COMB_LNA2; | ||
284 | else | ||
285 | /* Set alt to A+B or A-B */ | ||
286 | div_ant_conf->alt_lna_conf = | ||
287 | antcomb->second_quick_scan_conf; | ||
288 | } else { | ||
289 | /* main is largest */ | ||
290 | if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) || | ||
291 | (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)) | ||
292 | /* Set alt LNA1 or LNA2 */ | ||
293 | if (div_ant_conf->main_lna_conf == | ||
294 | ATH_ANT_DIV_COMB_LNA2) | ||
295 | div_ant_conf->alt_lna_conf = | ||
296 | ATH_ANT_DIV_COMB_LNA1; | ||
297 | else | ||
298 | div_ant_conf->alt_lna_conf = | ||
299 | ATH_ANT_DIV_COMB_LNA2; | ||
300 | else | ||
301 | /* Set alt to A+B or A-B */ | ||
302 | div_ant_conf->alt_lna_conf = antcomb->main_conf; | ||
303 | } | ||
304 | break; | 371 | break; |
305 | default: | 372 | default: |
306 | break; | 373 | break; |
@@ -430,8 +497,7 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, | |||
430 | ant_conf->fast_div_bias = 0x1; | 497 | ant_conf->fast_div_bias = 0x1; |
431 | break; | 498 | break; |
432 | case 0x10: /* LNA2 A-B */ | 499 | case 0x10: /* LNA2 A-B */ |
433 | if (!(antcomb->scan) && | 500 | if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) |
434 | (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) | ||
435 | ant_conf->fast_div_bias = 0x1; | 501 | ant_conf->fast_div_bias = 0x1; |
436 | else | 502 | else |
437 | ant_conf->fast_div_bias = 0x2; | 503 | ant_conf->fast_div_bias = 0x2; |
@@ -440,15 +506,13 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, | |||
440 | ant_conf->fast_div_bias = 0x1; | 506 | ant_conf->fast_div_bias = 0x1; |
441 | break; | 507 | break; |
442 | case 0x13: /* LNA2 A+B */ | 508 | case 0x13: /* LNA2 A+B */ |
443 | if (!(antcomb->scan) && | 509 | if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) |
444 | (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) | ||
445 | ant_conf->fast_div_bias = 0x1; | 510 | ant_conf->fast_div_bias = 0x1; |
446 | else | 511 | else |
447 | ant_conf->fast_div_bias = 0x2; | 512 | ant_conf->fast_div_bias = 0x2; |
448 | break; | 513 | break; |
449 | case 0x20: /* LNA1 A-B */ | 514 | case 0x20: /* LNA1 A-B */ |
450 | if (!(antcomb->scan) && | 515 | if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) |
451 | (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) | ||
452 | ant_conf->fast_div_bias = 0x1; | 516 | ant_conf->fast_div_bias = 0x1; |
453 | else | 517 | else |
454 | ant_conf->fast_div_bias = 0x2; | 518 | ant_conf->fast_div_bias = 0x2; |
@@ -457,8 +521,7 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, | |||
457 | ant_conf->fast_div_bias = 0x1; | 521 | ant_conf->fast_div_bias = 0x1; |
458 | break; | 522 | break; |
459 | case 0x23: /* LNA1 A+B */ | 523 | case 0x23: /* LNA1 A+B */ |
460 | if (!(antcomb->scan) && | 524 | if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) |
461 | (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) | ||
462 | ant_conf->fast_div_bias = 0x1; | 525 | ant_conf->fast_div_bias = 0x1; |
463 | else | 526 | else |
464 | ant_conf->fast_div_bias = 0x2; | 527 | ant_conf->fast_div_bias = 0x2; |
@@ -475,6 +538,9 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, | |||
475 | default: | 538 | default: |
476 | break; | 539 | break; |
477 | } | 540 | } |
541 | |||
542 | if (antcomb->fast_div_bias) | ||
543 | ant_conf->fast_div_bias = antcomb->fast_div_bias; | ||
478 | } else if (ant_conf->div_group == 3) { | 544 | } else if (ant_conf->div_group == 3) { |
479 | switch ((ant_conf->main_lna_conf << 4) | | 545 | switch ((ant_conf->main_lna_conf << 4) | |
480 | ant_conf->alt_lna_conf) { | 546 | ant_conf->alt_lna_conf) { |
@@ -540,6 +606,138 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, | |||
540 | } | 606 | } |
541 | } | 607 | } |
542 | 608 | ||
609 | static void ath_ant_try_scan(struct ath_ant_comb *antcomb, | ||
610 | struct ath_hw_antcomb_conf *conf, | ||
611 | int curr_alt_set, int alt_rssi_avg, | ||
612 | int main_rssi_avg) | ||
613 | { | ||
614 | switch (curr_alt_set) { | ||
615 | case ATH_ANT_DIV_COMB_LNA2: | ||
616 | antcomb->rssi_lna2 = alt_rssi_avg; | ||
617 | antcomb->rssi_lna1 = main_rssi_avg; | ||
618 | antcomb->scan = true; | ||
619 | /* set to A+B */ | ||
620 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
621 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
622 | break; | ||
623 | case ATH_ANT_DIV_COMB_LNA1: | ||
624 | antcomb->rssi_lna1 = alt_rssi_avg; | ||
625 | antcomb->rssi_lna2 = main_rssi_avg; | ||
626 | antcomb->scan = true; | ||
627 | /* set to A+B */ | ||
628 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
629 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
630 | break; | ||
631 | case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2: | ||
632 | antcomb->rssi_add = alt_rssi_avg; | ||
633 | antcomb->scan = true; | ||
634 | /* set to A-B */ | ||
635 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
636 | break; | ||
637 | case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2: | ||
638 | antcomb->rssi_sub = alt_rssi_avg; | ||
639 | antcomb->scan = false; | ||
640 | if (antcomb->rssi_lna2 > | ||
641 | (antcomb->rssi_lna1 + ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) { | ||
642 | /* use LNA2 as main LNA */ | ||
643 | if ((antcomb->rssi_add > antcomb->rssi_lna1) && | ||
644 | (antcomb->rssi_add > antcomb->rssi_sub)) { | ||
645 | /* set to A+B */ | ||
646 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
647 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
648 | } else if (antcomb->rssi_sub > | ||
649 | antcomb->rssi_lna1) { | ||
650 | /* set to A-B */ | ||
651 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
652 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
653 | } else { | ||
654 | /* set to LNA1 */ | ||
655 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
656 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
657 | } | ||
658 | } else { | ||
659 | /* use LNA1 as main LNA */ | ||
660 | if ((antcomb->rssi_add > antcomb->rssi_lna2) && | ||
661 | (antcomb->rssi_add > antcomb->rssi_sub)) { | ||
662 | /* set to A+B */ | ||
663 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
664 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
665 | } else if (antcomb->rssi_sub > | ||
666 | antcomb->rssi_lna1) { | ||
667 | /* set to A-B */ | ||
668 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
669 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
670 | } else { | ||
671 | /* set to LNA2 */ | ||
672 | conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
673 | conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
674 | } | ||
675 | } | ||
676 | break; | ||
677 | default: | ||
678 | break; | ||
679 | } | ||
680 | } | ||
681 | |||
682 | static bool ath_ant_try_switch(struct ath_hw_antcomb_conf *div_ant_conf, | ||
683 | struct ath_ant_comb *antcomb, | ||
684 | int alt_ratio, int alt_rssi_avg, | ||
685 | int main_rssi_avg, int curr_main_set, | ||
686 | int curr_alt_set) | ||
687 | { | ||
688 | bool ret = false; | ||
689 | |||
690 | if (ath_ant_div_comb_alt_check(div_ant_conf, antcomb, alt_ratio, | ||
691 | alt_rssi_avg, main_rssi_avg)) { | ||
692 | if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) { | ||
693 | /* | ||
694 | * Switch main and alt LNA. | ||
695 | */ | ||
696 | div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
697 | div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
698 | } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) { | ||
699 | div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
700 | div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
701 | } | ||
702 | |||
703 | ret = true; | ||
704 | } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) && | ||
705 | (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) { | ||
706 | /* | ||
707 | Set alt to another LNA. | ||
708 | */ | ||
709 | if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) | ||
710 | div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
711 | else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) | ||
712 | div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
713 | |||
714 | ret = true; | ||
715 | } | ||
716 | |||
717 | return ret; | ||
718 | } | ||
719 | |||
720 | static bool ath_ant_short_scan_check(struct ath_ant_comb *antcomb) | ||
721 | { | ||
722 | int alt_ratio; | ||
723 | |||
724 | if (!antcomb->scan || !antcomb->alt_good) | ||
725 | return false; | ||
726 | |||
727 | if (time_after(jiffies, antcomb->scan_start_time + | ||
728 | msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR))) | ||
729 | return true; | ||
730 | |||
731 | if (antcomb->total_pkt_count == ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) { | ||
732 | alt_ratio = ((antcomb->alt_recv_cnt * 100) / | ||
733 | antcomb->total_pkt_count); | ||
734 | if (alt_ratio < antcomb->ant_ratio) | ||
735 | return true; | ||
736 | } | ||
737 | |||
738 | return false; | ||
739 | } | ||
740 | |||
543 | void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs) | 741 | void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs) |
544 | { | 742 | { |
545 | struct ath_hw_antcomb_conf div_ant_conf; | 743 | struct ath_hw_antcomb_conf div_ant_conf; |
@@ -549,41 +747,46 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs) | |||
549 | int main_rssi = rs->rs_rssi_ctl0; | 747 | int main_rssi = rs->rs_rssi_ctl0; |
550 | int alt_rssi = rs->rs_rssi_ctl1; | 748 | int alt_rssi = rs->rs_rssi_ctl1; |
551 | int rx_ant_conf, main_ant_conf; | 749 | int rx_ant_conf, main_ant_conf; |
552 | bool short_scan = false; | 750 | bool short_scan = false, ret; |
553 | 751 | ||
554 | rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) & | 752 | rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) & |
555 | ATH_ANT_RX_MASK; | 753 | ATH_ANT_RX_MASK; |
556 | main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) & | 754 | main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) & |
557 | ATH_ANT_RX_MASK; | 755 | ATH_ANT_RX_MASK; |
558 | 756 | ||
757 | if (alt_rssi >= antcomb->low_rssi_thresh) { | ||
758 | antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO; | ||
759 | antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2; | ||
760 | } else { | ||
761 | antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI; | ||
762 | antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI; | ||
763 | } | ||
764 | |||
559 | /* Record packet only when both main_rssi and alt_rssi is positive */ | 765 | /* Record packet only when both main_rssi and alt_rssi is positive */ |
560 | if (main_rssi > 0 && alt_rssi > 0) { | 766 | if (main_rssi > 0 && alt_rssi > 0) { |
561 | antcomb->total_pkt_count++; | 767 | antcomb->total_pkt_count++; |
562 | antcomb->main_total_rssi += main_rssi; | 768 | antcomb->main_total_rssi += main_rssi; |
563 | antcomb->alt_total_rssi += alt_rssi; | 769 | antcomb->alt_total_rssi += alt_rssi; |
770 | |||
564 | if (main_ant_conf == rx_ant_conf) | 771 | if (main_ant_conf == rx_ant_conf) |
565 | antcomb->main_recv_cnt++; | 772 | antcomb->main_recv_cnt++; |
566 | else | 773 | else |
567 | antcomb->alt_recv_cnt++; | 774 | antcomb->alt_recv_cnt++; |
568 | } | 775 | } |
569 | 776 | ||
570 | /* Short scan check */ | 777 | if (main_ant_conf == rx_ant_conf) { |
571 | if (antcomb->scan && antcomb->alt_good) { | 778 | ANT_STAT_INC(ANT_MAIN, recv_cnt); |
572 | if (time_after(jiffies, antcomb->scan_start_time + | 779 | ANT_LNA_INC(ANT_MAIN, rx_ant_conf); |
573 | msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR))) | 780 | } else { |
574 | short_scan = true; | 781 | ANT_STAT_INC(ANT_ALT, recv_cnt); |
575 | else | 782 | ANT_LNA_INC(ANT_ALT, rx_ant_conf); |
576 | if (antcomb->total_pkt_count == | ||
577 | ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) { | ||
578 | alt_ratio = ((antcomb->alt_recv_cnt * 100) / | ||
579 | antcomb->total_pkt_count); | ||
580 | if (alt_ratio < ATH_ANT_DIV_COMB_ALT_ANT_RATIO) | ||
581 | short_scan = true; | ||
582 | } | ||
583 | } | 783 | } |
584 | 784 | ||
785 | /* Short scan check */ | ||
786 | short_scan = ath_ant_short_scan_check(antcomb); | ||
787 | |||
585 | if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) || | 788 | if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) || |
586 | rs->rs_moreaggr) && !short_scan) | 789 | rs->rs_moreaggr) && !short_scan) |
587 | return; | 790 | return; |
588 | 791 | ||
589 | if (antcomb->total_pkt_count) { | 792 | if (antcomb->total_pkt_count) { |
@@ -595,15 +798,13 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs) | |||
595 | antcomb->total_pkt_count); | 798 | antcomb->total_pkt_count); |
596 | } | 799 | } |
597 | 800 | ||
598 | |||
599 | ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf); | 801 | ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf); |
600 | curr_alt_set = div_ant_conf.alt_lna_conf; | 802 | curr_alt_set = div_ant_conf.alt_lna_conf; |
601 | curr_main_set = div_ant_conf.main_lna_conf; | 803 | curr_main_set = div_ant_conf.main_lna_conf; |
602 | |||
603 | antcomb->count++; | 804 | antcomb->count++; |
604 | 805 | ||
605 | if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) { | 806 | if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) { |
606 | if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) { | 807 | if (alt_ratio > antcomb->ant_ratio) { |
607 | ath_lnaconf_alt_good_scan(antcomb, div_ant_conf, | 808 | ath_lnaconf_alt_good_scan(antcomb, div_ant_conf, |
608 | main_rssi_avg); | 809 | main_rssi_avg); |
609 | antcomb->alt_good = true; | 810 | antcomb->alt_good = true; |
@@ -617,153 +818,47 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs) | |||
617 | } | 818 | } |
618 | 819 | ||
619 | if (!antcomb->scan) { | 820 | if (!antcomb->scan) { |
620 | if (ath_ant_div_comb_alt_check(div_ant_conf.div_group, | 821 | ret = ath_ant_try_switch(&div_ant_conf, antcomb, alt_ratio, |
621 | alt_ratio, curr_main_set, curr_alt_set, | 822 | alt_rssi_avg, main_rssi_avg, |
622 | alt_rssi_avg, main_rssi_avg)) { | 823 | curr_main_set, curr_alt_set); |
623 | if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) { | 824 | if (ret) |
624 | /* Switch main and alt LNA */ | ||
625 | div_ant_conf.main_lna_conf = | ||
626 | ATH_ANT_DIV_COMB_LNA2; | ||
627 | div_ant_conf.alt_lna_conf = | ||
628 | ATH_ANT_DIV_COMB_LNA1; | ||
629 | } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) { | ||
630 | div_ant_conf.main_lna_conf = | ||
631 | ATH_ANT_DIV_COMB_LNA1; | ||
632 | div_ant_conf.alt_lna_conf = | ||
633 | ATH_ANT_DIV_COMB_LNA2; | ||
634 | } | ||
635 | |||
636 | goto div_comb_done; | ||
637 | } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) && | ||
638 | (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) { | ||
639 | /* Set alt to another LNA */ | ||
640 | if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) | ||
641 | div_ant_conf.alt_lna_conf = | ||
642 | ATH_ANT_DIV_COMB_LNA1; | ||
643 | else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) | ||
644 | div_ant_conf.alt_lna_conf = | ||
645 | ATH_ANT_DIV_COMB_LNA2; | ||
646 | |||
647 | goto div_comb_done; | ||
648 | } | ||
649 | |||
650 | if ((alt_rssi_avg < (main_rssi_avg + | ||
651 | div_ant_conf.lna1_lna2_delta))) | ||
652 | goto div_comb_done; | 825 | goto div_comb_done; |
653 | } | 826 | } |
654 | 827 | ||
828 | if (!antcomb->scan && | ||
829 | (alt_rssi_avg < (main_rssi_avg + div_ant_conf.lna1_lna2_delta))) | ||
830 | goto div_comb_done; | ||
831 | |||
655 | if (!antcomb->scan_not_start) { | 832 | if (!antcomb->scan_not_start) { |
656 | switch (curr_alt_set) { | 833 | ath_ant_try_scan(antcomb, &div_ant_conf, curr_alt_set, |
657 | case ATH_ANT_DIV_COMB_LNA2: | 834 | alt_rssi_avg, main_rssi_avg); |
658 | antcomb->rssi_lna2 = alt_rssi_avg; | ||
659 | antcomb->rssi_lna1 = main_rssi_avg; | ||
660 | antcomb->scan = true; | ||
661 | /* set to A+B */ | ||
662 | div_ant_conf.main_lna_conf = | ||
663 | ATH_ANT_DIV_COMB_LNA1; | ||
664 | div_ant_conf.alt_lna_conf = | ||
665 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
666 | break; | ||
667 | case ATH_ANT_DIV_COMB_LNA1: | ||
668 | antcomb->rssi_lna1 = alt_rssi_avg; | ||
669 | antcomb->rssi_lna2 = main_rssi_avg; | ||
670 | antcomb->scan = true; | ||
671 | /* set to A+B */ | ||
672 | div_ant_conf.main_lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
673 | div_ant_conf.alt_lna_conf = | ||
674 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
675 | break; | ||
676 | case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2: | ||
677 | antcomb->rssi_add = alt_rssi_avg; | ||
678 | antcomb->scan = true; | ||
679 | /* set to A-B */ | ||
680 | div_ant_conf.alt_lna_conf = | ||
681 | ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
682 | break; | ||
683 | case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2: | ||
684 | antcomb->rssi_sub = alt_rssi_avg; | ||
685 | antcomb->scan = false; | ||
686 | if (antcomb->rssi_lna2 > | ||
687 | (antcomb->rssi_lna1 + | ||
688 | ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) { | ||
689 | /* use LNA2 as main LNA */ | ||
690 | if ((antcomb->rssi_add > antcomb->rssi_lna1) && | ||
691 | (antcomb->rssi_add > antcomb->rssi_sub)) { | ||
692 | /* set to A+B */ | ||
693 | div_ant_conf.main_lna_conf = | ||
694 | ATH_ANT_DIV_COMB_LNA2; | ||
695 | div_ant_conf.alt_lna_conf = | ||
696 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
697 | } else if (antcomb->rssi_sub > | ||
698 | antcomb->rssi_lna1) { | ||
699 | /* set to A-B */ | ||
700 | div_ant_conf.main_lna_conf = | ||
701 | ATH_ANT_DIV_COMB_LNA2; | ||
702 | div_ant_conf.alt_lna_conf = | ||
703 | ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
704 | } else { | ||
705 | /* set to LNA1 */ | ||
706 | div_ant_conf.main_lna_conf = | ||
707 | ATH_ANT_DIV_COMB_LNA2; | ||
708 | div_ant_conf.alt_lna_conf = | ||
709 | ATH_ANT_DIV_COMB_LNA1; | ||
710 | } | ||
711 | } else { | ||
712 | /* use LNA1 as main LNA */ | ||
713 | if ((antcomb->rssi_add > antcomb->rssi_lna2) && | ||
714 | (antcomb->rssi_add > antcomb->rssi_sub)) { | ||
715 | /* set to A+B */ | ||
716 | div_ant_conf.main_lna_conf = | ||
717 | ATH_ANT_DIV_COMB_LNA1; | ||
718 | div_ant_conf.alt_lna_conf = | ||
719 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; | ||
720 | } else if (antcomb->rssi_sub > | ||
721 | antcomb->rssi_lna1) { | ||
722 | /* set to A-B */ | ||
723 | div_ant_conf.main_lna_conf = | ||
724 | ATH_ANT_DIV_COMB_LNA1; | ||
725 | div_ant_conf.alt_lna_conf = | ||
726 | ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; | ||
727 | } else { | ||
728 | /* set to LNA2 */ | ||
729 | div_ant_conf.main_lna_conf = | ||
730 | ATH_ANT_DIV_COMB_LNA1; | ||
731 | div_ant_conf.alt_lna_conf = | ||
732 | ATH_ANT_DIV_COMB_LNA2; | ||
733 | } | ||
734 | } | ||
735 | break; | ||
736 | default: | ||
737 | break; | ||
738 | } | ||
739 | } else { | 835 | } else { |
740 | if (!antcomb->alt_good) { | 836 | if (!antcomb->alt_good) { |
741 | antcomb->scan_not_start = false; | 837 | antcomb->scan_not_start = false; |
742 | /* Set alt to another LNA */ | 838 | /* Set alt to another LNA */ |
743 | if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) { | 839 | if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) { |
744 | div_ant_conf.main_lna_conf = | 840 | div_ant_conf.main_lna_conf = |
745 | ATH_ANT_DIV_COMB_LNA2; | 841 | ATH_ANT_DIV_COMB_LNA2; |
746 | div_ant_conf.alt_lna_conf = | 842 | div_ant_conf.alt_lna_conf = |
747 | ATH_ANT_DIV_COMB_LNA1; | 843 | ATH_ANT_DIV_COMB_LNA1; |
748 | } else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) { | 844 | } else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) { |
749 | div_ant_conf.main_lna_conf = | 845 | div_ant_conf.main_lna_conf = |
750 | ATH_ANT_DIV_COMB_LNA1; | 846 | ATH_ANT_DIV_COMB_LNA1; |
751 | div_ant_conf.alt_lna_conf = | 847 | div_ant_conf.alt_lna_conf = |
752 | ATH_ANT_DIV_COMB_LNA2; | 848 | ATH_ANT_DIV_COMB_LNA2; |
753 | } | 849 | } |
754 | goto div_comb_done; | 850 | goto div_comb_done; |
755 | } | 851 | } |
852 | ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf, | ||
853 | main_rssi_avg, alt_rssi_avg, | ||
854 | alt_ratio); | ||
855 | antcomb->quick_scan_cnt++; | ||
756 | } | 856 | } |
757 | 857 | ||
758 | ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf, | ||
759 | main_rssi_avg, alt_rssi_avg, | ||
760 | alt_ratio); | ||
761 | |||
762 | antcomb->quick_scan_cnt++; | ||
763 | |||
764 | div_comb_done: | 858 | div_comb_done: |
765 | ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio); | 859 | ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio); |
766 | ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf); | 860 | ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf); |
861 | ath9k_debug_stat_ant(sc, &div_ant_conf, main_rssi_avg, alt_rssi_avg); | ||
767 | 862 | ||
768 | antcomb->scan_start_time = jiffies; | 863 | antcomb->scan_start_time = jiffies; |
769 | antcomb->total_pkt_count = 0; | 864 | antcomb->total_pkt_count = 0; |
@@ -772,26 +867,3 @@ div_comb_done: | |||
772 | antcomb->main_recv_cnt = 0; | 867 | antcomb->main_recv_cnt = 0; |
773 | antcomb->alt_recv_cnt = 0; | 868 | antcomb->alt_recv_cnt = 0; |
774 | } | 869 | } |
775 | |||
776 | void ath_ant_comb_update(struct ath_softc *sc) | ||
777 | { | ||
778 | struct ath_hw *ah = sc->sc_ah; | ||
779 | struct ath_common *common = ath9k_hw_common(ah); | ||
780 | struct ath_hw_antcomb_conf div_ant_conf; | ||
781 | u8 lna_conf; | ||
782 | |||
783 | ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); | ||
784 | |||
785 | if (sc->ant_rx == 1) | ||
786 | lna_conf = ATH_ANT_DIV_COMB_LNA1; | ||
787 | else | ||
788 | lna_conf = ATH_ANT_DIV_COMB_LNA2; | ||
789 | |||
790 | div_ant_conf.main_lna_conf = lna_conf; | ||
791 | div_ant_conf.alt_lna_conf = lna_conf; | ||
792 | |||
793 | ath9k_hw_antdiv_comb_conf_set(ah, &div_ant_conf); | ||
794 | |||
795 | if (common->antenna_diversity) | ||
796 | ath9k_hw_antctrl_shared_chain_lnadiv(ah, true); | ||
797 | } | ||
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index d1acfe98918a..1576d58291d4 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c | |||
@@ -610,7 +610,15 @@ static void ar5008_hw_override_ini(struct ath_hw *ah, | |||
610 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); | 610 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
611 | 611 | ||
612 | if (AR_SREV_9280_20_OR_LATER(ah)) { | 612 | if (AR_SREV_9280_20_OR_LATER(ah)) { |
613 | val = REG_READ(ah, AR_PCU_MISC_MODE2); | 613 | /* |
614 | * For AR9280 and above, there is a new feature that allows | ||
615 | * Multicast search based on both MAC Address and Key ID. | ||
616 | * By default, this feature is enabled. But since the driver | ||
617 | * is not using this feature, we switch it off; otherwise | ||
618 | * multicast search based on MAC addr only will fail. | ||
619 | */ | ||
620 | val = REG_READ(ah, AR_PCU_MISC_MODE2) & | ||
621 | (~AR_ADHOC_MCAST_KEYID_ENABLE); | ||
614 | 622 | ||
615 | if (!AR_SREV_9271(ah)) | 623 | if (!AR_SREV_9271(ah)) |
616 | val &= ~AR_PCU_MISC_MODE2_HWWAR1; | 624 | val &= ~AR_PCU_MISC_MODE2_HWWAR1; |
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 8dc2d089cdef..fb61b081d172 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c | |||
@@ -269,13 +269,12 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah, | |||
269 | if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) | 269 | if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) |
270 | val |= AR_WA_D3_L1_DISABLE; | 270 | val |= AR_WA_D3_L1_DISABLE; |
271 | } else { | 271 | } else { |
272 | if (((AR_SREV_9285(ah) || | 272 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) { |
273 | AR_SREV_9271(ah) || | 273 | if (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE) |
274 | AR_SREV_9287(ah)) && | 274 | val |= AR_WA_D3_L1_DISABLE; |
275 | (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) || | 275 | } else if (AR_SREV_9280(ah)) { |
276 | (AR_SREV_9280(ah) && | 276 | if (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE) |
277 | (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) { | 277 | val |= AR_WA_D3_L1_DISABLE; |
278 | val |= AR_WA_D3_L1_DISABLE; | ||
279 | } | 278 | } |
280 | } | 279 | } |
281 | 280 | ||
@@ -297,24 +296,18 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah, | |||
297 | } else { | 296 | } else { |
298 | if (ah->config.pcie_waen) { | 297 | if (ah->config.pcie_waen) { |
299 | val = ah->config.pcie_waen; | 298 | val = ah->config.pcie_waen; |
300 | if (!power_off) | 299 | val &= (~AR_WA_D3_L1_DISABLE); |
301 | val &= (~AR_WA_D3_L1_DISABLE); | ||
302 | } else { | 300 | } else { |
303 | if (AR_SREV_9285(ah) || | 301 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) { |
304 | AR_SREV_9271(ah) || | ||
305 | AR_SREV_9287(ah)) { | ||
306 | val = AR9285_WA_DEFAULT; | 302 | val = AR9285_WA_DEFAULT; |
307 | if (!power_off) | 303 | val &= (~AR_WA_D3_L1_DISABLE); |
308 | val &= (~AR_WA_D3_L1_DISABLE); | 304 | } else if (AR_SREV_9280(ah)) { |
309 | } | ||
310 | else if (AR_SREV_9280(ah)) { | ||
311 | /* | 305 | /* |
312 | * For AR9280 chips, bit 22 of 0x4004 | 306 | * For AR9280 chips, bit 22 of 0x4004 |
313 | * needs to be set. | 307 | * needs to be set. |
314 | */ | 308 | */ |
315 | val = AR9280_WA_DEFAULT; | 309 | val = AR9280_WA_DEFAULT; |
316 | if (!power_off) | 310 | val &= (~AR_WA_D3_L1_DISABLE); |
317 | val &= (~AR_WA_D3_L1_DISABLE); | ||
318 | } else { | 311 | } else { |
319 | val = AR_WA_DEFAULT; | 312 | val = AR_WA_DEFAULT; |
320 | } | 313 | } |
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c index f4003512d8d5..1fc1fa955d44 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c | |||
@@ -555,6 +555,69 @@ static void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah, | |||
555 | REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); | 555 | REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); |
556 | } | 556 | } |
557 | 557 | ||
558 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | ||
559 | |||
560 | static void ar9002_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) | ||
561 | { | ||
562 | struct ath_btcoex_hw *btcoex = &ah->btcoex_hw; | ||
563 | u8 antdiv_ctrl1, antdiv_ctrl2; | ||
564 | u32 regval; | ||
565 | |||
566 | if (enable) { | ||
567 | antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE; | ||
568 | antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE; | ||
569 | |||
570 | /* | ||
571 | * Don't disable BT ant to allow BB to control SWCOM. | ||
572 | */ | ||
573 | btcoex->bt_coex_mode2 &= (~(AR_BT_DISABLE_BT_ANT)); | ||
574 | REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2); | ||
575 | |||
576 | REG_WRITE(ah, AR_PHY_SWITCH_COM, ATH_BT_COEX_ANT_DIV_SWITCH_COM); | ||
577 | REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000); | ||
578 | } else { | ||
579 | /* | ||
580 | * Disable antenna diversity, use LNA1 only. | ||
581 | */ | ||
582 | antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A; | ||
583 | antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A; | ||
584 | |||
585 | /* | ||
586 | * Disable BT Ant. to allow concurrent BT and WLAN receive. | ||
587 | */ | ||
588 | btcoex->bt_coex_mode2 |= AR_BT_DISABLE_BT_ANT; | ||
589 | REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2); | ||
590 | |||
591 | /* | ||
592 | * Program SWCOM table to make sure RF switch always parks | ||
593 | * at BT side. | ||
594 | */ | ||
595 | REG_WRITE(ah, AR_PHY_SWITCH_COM, 0); | ||
596 | REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000); | ||
597 | } | ||
598 | |||
599 | regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); | ||
600 | regval &= (~(AR_PHY_9285_ANT_DIV_CTL_ALL)); | ||
601 | /* | ||
602 | * Clear ant_fast_div_bias [14:9] since for WB195, | ||
603 | * the main LNA is always LNA1. | ||
604 | */ | ||
605 | regval &= (~(AR_PHY_9285_FAST_DIV_BIAS)); | ||
606 | regval |= SM(antdiv_ctrl1, AR_PHY_9285_ANT_DIV_CTL); | ||
607 | regval |= SM(antdiv_ctrl2, AR_PHY_9285_ANT_DIV_ALT_LNACONF); | ||
608 | regval |= SM((antdiv_ctrl2 >> 2), AR_PHY_9285_ANT_DIV_MAIN_LNACONF); | ||
609 | regval |= SM((antdiv_ctrl1 >> 1), AR_PHY_9285_ANT_DIV_ALT_GAINTB); | ||
610 | regval |= SM((antdiv_ctrl1 >> 2), AR_PHY_9285_ANT_DIV_MAIN_GAINTB); | ||
611 | REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); | ||
612 | |||
613 | regval = REG_READ(ah, AR_PHY_CCK_DETECT); | ||
614 | regval &= (~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); | ||
615 | regval |= SM((antdiv_ctrl1 >> 3), AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); | ||
616 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); | ||
617 | } | ||
618 | |||
619 | #endif | ||
620 | |||
558 | static void ar9002_hw_spectral_scan_config(struct ath_hw *ah, | 621 | static void ar9002_hw_spectral_scan_config(struct ath_hw *ah, |
559 | struct ath_spec_scan *param) | 622 | struct ath_spec_scan *param) |
560 | { | 623 | { |
@@ -634,5 +697,9 @@ void ar9002_hw_attach_phy_ops(struct ath_hw *ah) | |||
634 | ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger; | 697 | ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger; |
635 | ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait; | 698 | ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait; |
636 | 699 | ||
700 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | ||
701 | ops->set_bt_ant_diversity = ar9002_hw_set_bt_ant_diversity; | ||
702 | #endif | ||
703 | |||
637 | ar9002_hw_set_nf_limits(ah); | 704 | ar9002_hw_set_nf_limits(ah); |
638 | } | 705 | } |
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.h b/drivers/net/wireless/ath/ath9k/ar9002_phy.h index f9eb2c357169..6314ae2e93e3 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h | |||
@@ -317,13 +317,15 @@ | |||
317 | #define AR_PHY_9285_ANT_DIV_ALT_GAINTB_S 29 | 317 | #define AR_PHY_9285_ANT_DIV_ALT_GAINTB_S 29 |
318 | #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB 0x40000000 | 318 | #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB 0x40000000 |
319 | #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB_S 30 | 319 | #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB_S 30 |
320 | #define AR_PHY_9285_ANT_DIV_LNA1 2 | ||
321 | #define AR_PHY_9285_ANT_DIV_LNA2 1 | ||
322 | #define AR_PHY_9285_ANT_DIV_LNA1_PLUS_LNA2 3 | ||
323 | #define AR_PHY_9285_ANT_DIV_LNA1_MINUS_LNA2 0 | ||
324 | #define AR_PHY_9285_ANT_DIV_GAINTB_0 0 | 320 | #define AR_PHY_9285_ANT_DIV_GAINTB_0 0 |
325 | #define AR_PHY_9285_ANT_DIV_GAINTB_1 1 | 321 | #define AR_PHY_9285_ANT_DIV_GAINTB_1 1 |
326 | 322 | ||
323 | #define ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE 0x0b | ||
324 | #define ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE 0x09 | ||
325 | #define ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A 0x04 | ||
326 | #define ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A 0x09 | ||
327 | #define ATH_BT_COEX_ANT_DIV_SWITCH_COM 0x66666666 | ||
328 | |||
327 | #define AR_PHY_EXT_CCA0 0x99b8 | 329 | #define AR_PHY_EXT_CCA0 0x99b8 |
328 | #define AR_PHY_EXT_CCA0_THRESH62 0x000000FF | 330 | #define AR_PHY_EXT_CCA0_THRESH62 0x000000FF |
329 | #define AR_PHY_EXT_CCA0_THRESH62_S 0 | 331 | #define AR_PHY_EXT_CCA0_THRESH62_S 0 |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index d105e43d22e1..f4864807e15b 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | |||
@@ -3541,13 +3541,12 @@ static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz) | |||
3541 | return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt); | 3541 | return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt); |
3542 | } | 3542 | } |
3543 | 3543 | ||
3544 | 3544 | u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) | |
3545 | static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) | ||
3546 | { | 3545 | { |
3547 | return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon); | 3546 | return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon); |
3548 | } | 3547 | } |
3549 | 3548 | ||
3550 | static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) | 3549 | u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) |
3551 | { | 3550 | { |
3552 | return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2); | 3551 | return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2); |
3553 | } | 3552 | } |
@@ -3561,6 +3560,7 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain, | |||
3561 | 3560 | ||
3562 | static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) | 3561 | static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) |
3563 | { | 3562 | { |
3563 | struct ath_common *common = ath9k_hw_common(ah); | ||
3564 | struct ath9k_hw_capabilities *pCap = &ah->caps; | 3564 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
3565 | int chain; | 3565 | int chain; |
3566 | u32 regval, value, gpio; | 3566 | u32 regval, value, gpio; |
@@ -3614,6 +3614,11 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) | |||
3614 | } | 3614 | } |
3615 | 3615 | ||
3616 | value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz); | 3616 | value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz); |
3617 | if (AR_SREV_9485(ah) && common->bt_ant_diversity) { | ||
3618 | value &= ~AR_SWITCH_TABLE_COM2_ALL; | ||
3619 | value |= ah->config.ant_ctrl_comm2g_switch_enable; | ||
3620 | |||
3621 | } | ||
3617 | REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value); | 3622 | REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value); |
3618 | 3623 | ||
3619 | if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) { | 3624 | if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) { |
@@ -3645,8 +3650,11 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) | |||
3645 | regval &= (~AR_PHY_ANT_DIV_LNADIV); | 3650 | regval &= (~AR_PHY_ANT_DIV_LNADIV); |
3646 | regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S; | 3651 | regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S; |
3647 | 3652 | ||
3653 | if (AR_SREV_9485(ah) && common->bt_ant_diversity) | ||
3654 | regval |= AR_ANT_DIV_ENABLE; | ||
3655 | |||
3648 | if (AR_SREV_9565(ah)) { | 3656 | if (AR_SREV_9565(ah)) { |
3649 | if (ah->shared_chain_lnadiv) { | 3657 | if (common->bt_ant_diversity) { |
3650 | regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S); | 3658 | regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S); |
3651 | } else { | 3659 | } else { |
3652 | regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S); | 3660 | regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S); |
@@ -3656,10 +3664,14 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) | |||
3656 | 3664 | ||
3657 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | 3665 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); |
3658 | 3666 | ||
3659 | /*enable fast_div */ | 3667 | /* enable fast_div */ |
3660 | regval = REG_READ(ah, AR_PHY_CCK_DETECT); | 3668 | regval = REG_READ(ah, AR_PHY_CCK_DETECT); |
3661 | regval &= (~AR_FAST_DIV_ENABLE); | 3669 | regval &= (~AR_FAST_DIV_ENABLE); |
3662 | regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; | 3670 | regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; |
3671 | |||
3672 | if (AR_SREV_9485(ah) && common->bt_ant_diversity) | ||
3673 | regval |= AR_FAST_DIV_ENABLE; | ||
3674 | |||
3663 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); | 3675 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); |
3664 | 3676 | ||
3665 | if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { | 3677 | if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { |
@@ -3673,9 +3685,9 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) | |||
3673 | AR_PHY_ANT_DIV_ALT_GAINTB | | 3685 | AR_PHY_ANT_DIV_ALT_GAINTB | |
3674 | AR_PHY_ANT_DIV_MAIN_GAINTB)); | 3686 | AR_PHY_ANT_DIV_MAIN_GAINTB)); |
3675 | /* by default use LNA1 for the main antenna */ | 3687 | /* by default use LNA1 for the main antenna */ |
3676 | regval |= (AR_PHY_ANT_DIV_LNA1 << | 3688 | regval |= (ATH_ANT_DIV_COMB_LNA1 << |
3677 | AR_PHY_ANT_DIV_MAIN_LNACONF_S); | 3689 | AR_PHY_ANT_DIV_MAIN_LNACONF_S); |
3678 | regval |= (AR_PHY_ANT_DIV_LNA2 << | 3690 | regval |= (ATH_ANT_DIV_COMB_LNA2 << |
3679 | AR_PHY_ANT_DIV_ALT_LNACONF_S); | 3691 | AR_PHY_ANT_DIV_ALT_LNACONF_S); |
3680 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | 3692 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); |
3681 | } | 3693 | } |
@@ -3813,6 +3825,11 @@ static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan) | |||
3813 | else | 3825 | else |
3814 | value = ar9003_hw_atten_chain_get_margin(ah, i, chan); | 3826 | value = ar9003_hw_atten_chain_get_margin(ah, i, chan); |
3815 | 3827 | ||
3828 | if (ah->config.alt_mingainidx) | ||
3829 | REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0, | ||
3830 | AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, | ||
3831 | value); | ||
3832 | |||
3816 | REG_RMW_FIELD(ah, ext_atten_reg[i], | 3833 | REG_RMW_FIELD(ah, ext_atten_reg[i], |
3817 | AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, | 3834 | AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, |
3818 | value); | 3835 | value); |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h index 874f6570bd1c..75d4fb41962f 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | |||
@@ -334,6 +334,8 @@ struct ar9300_eeprom { | |||
334 | 334 | ||
335 | s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah); | 335 | s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah); |
336 | s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah); | 336 | s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah); |
337 | u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz); | ||
338 | u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz); | ||
337 | 339 | ||
338 | u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz); | 340 | u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz); |
339 | 341 | ||
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c index d402cb32283f..608bb4824e2a 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c | |||
@@ -153,7 +153,7 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) | |||
153 | if (!ah->is_clk_25mhz) | 153 | if (!ah->is_clk_25mhz) |
154 | INIT_INI_ARRAY(&ah->iniAdditional, | 154 | INIT_INI_ARRAY(&ah->iniAdditional, |
155 | ar9340_1p0_radio_core_40M); | 155 | ar9340_1p0_radio_core_40M); |
156 | } else if (AR_SREV_9485_11(ah)) { | 156 | } else if (AR_SREV_9485_11_OR_LATER(ah)) { |
157 | /* mac */ | 157 | /* mac */ |
158 | INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], | 158 | INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], |
159 | ar9485_1_1_mac_core); | 159 | ar9485_1_1_mac_core); |
@@ -424,7 +424,7 @@ static void ar9003_tx_gain_table_mode0(struct ath_hw *ah) | |||
424 | else if (AR_SREV_9340(ah)) | 424 | else if (AR_SREV_9340(ah)) |
425 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 425 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
426 | ar9340Modes_lowest_ob_db_tx_gain_table_1p0); | 426 | ar9340Modes_lowest_ob_db_tx_gain_table_1p0); |
427 | else if (AR_SREV_9485_11(ah)) | 427 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
428 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 428 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
429 | ar9485_modes_lowest_ob_db_tx_gain_1_1); | 429 | ar9485_modes_lowest_ob_db_tx_gain_1_1); |
430 | else if (AR_SREV_9550(ah)) | 430 | else if (AR_SREV_9550(ah)) |
@@ -458,7 +458,7 @@ static void ar9003_tx_gain_table_mode1(struct ath_hw *ah) | |||
458 | else if (AR_SREV_9340(ah)) | 458 | else if (AR_SREV_9340(ah)) |
459 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 459 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
460 | ar9340Modes_high_ob_db_tx_gain_table_1p0); | 460 | ar9340Modes_high_ob_db_tx_gain_table_1p0); |
461 | else if (AR_SREV_9485_11(ah)) | 461 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
462 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 462 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
463 | ar9485Modes_high_ob_db_tx_gain_1_1); | 463 | ar9485Modes_high_ob_db_tx_gain_1_1); |
464 | else if (AR_SREV_9580(ah)) | 464 | else if (AR_SREV_9580(ah)) |
@@ -492,7 +492,7 @@ static void ar9003_tx_gain_table_mode2(struct ath_hw *ah) | |||
492 | else if (AR_SREV_9340(ah)) | 492 | else if (AR_SREV_9340(ah)) |
493 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 493 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
494 | ar9340Modes_low_ob_db_tx_gain_table_1p0); | 494 | ar9340Modes_low_ob_db_tx_gain_table_1p0); |
495 | else if (AR_SREV_9485_11(ah)) | 495 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
496 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 496 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
497 | ar9485Modes_low_ob_db_tx_gain_1_1); | 497 | ar9485Modes_low_ob_db_tx_gain_1_1); |
498 | else if (AR_SREV_9580(ah)) | 498 | else if (AR_SREV_9580(ah)) |
@@ -517,7 +517,7 @@ static void ar9003_tx_gain_table_mode3(struct ath_hw *ah) | |||
517 | else if (AR_SREV_9340(ah)) | 517 | else if (AR_SREV_9340(ah)) |
518 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 518 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
519 | ar9340Modes_high_power_tx_gain_table_1p0); | 519 | ar9340Modes_high_power_tx_gain_table_1p0); |
520 | else if (AR_SREV_9485_11(ah)) | 520 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
521 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 521 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
522 | ar9485Modes_high_power_tx_gain_1_1); | 522 | ar9485Modes_high_power_tx_gain_1_1); |
523 | else if (AR_SREV_9580(ah)) | 523 | else if (AR_SREV_9580(ah)) |
@@ -552,7 +552,7 @@ static void ar9003_tx_gain_table_mode4(struct ath_hw *ah) | |||
552 | 552 | ||
553 | static void ar9003_tx_gain_table_mode5(struct ath_hw *ah) | 553 | static void ar9003_tx_gain_table_mode5(struct ath_hw *ah) |
554 | { | 554 | { |
555 | if (AR_SREV_9485_11(ah)) | 555 | if (AR_SREV_9485_11_OR_LATER(ah)) |
556 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 556 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
557 | ar9485Modes_green_ob_db_tx_gain_1_1); | 557 | ar9485Modes_green_ob_db_tx_gain_1_1); |
558 | else if (AR_SREV_9340(ah)) | 558 | else if (AR_SREV_9340(ah)) |
@@ -571,7 +571,7 @@ static void ar9003_tx_gain_table_mode6(struct ath_hw *ah) | |||
571 | if (AR_SREV_9340(ah)) | 571 | if (AR_SREV_9340(ah)) |
572 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 572 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
573 | ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0); | 573 | ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0); |
574 | else if (AR_SREV_9485_11(ah)) | 574 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
575 | INIT_INI_ARRAY(&ah->iniModesTxGain, | 575 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
576 | ar9485Modes_green_spur_ob_db_tx_gain_1_1); | 576 | ar9485Modes_green_spur_ob_db_tx_gain_1_1); |
577 | else if (AR_SREV_9580(ah)) | 577 | else if (AR_SREV_9580(ah)) |
@@ -611,7 +611,7 @@ static void ar9003_rx_gain_table_mode0(struct ath_hw *ah) | |||
611 | else if (AR_SREV_9340(ah)) | 611 | else if (AR_SREV_9340(ah)) |
612 | INIT_INI_ARRAY(&ah->iniModesRxGain, | 612 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
613 | ar9340Common_rx_gain_table_1p0); | 613 | ar9340Common_rx_gain_table_1p0); |
614 | else if (AR_SREV_9485_11(ah)) | 614 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
615 | INIT_INI_ARRAY(&ah->iniModesRxGain, | 615 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
616 | ar9485_common_rx_gain_1_1); | 616 | ar9485_common_rx_gain_1_1); |
617 | else if (AR_SREV_9550(ah)) { | 617 | else if (AR_SREV_9550(ah)) { |
@@ -644,7 +644,7 @@ static void ar9003_rx_gain_table_mode1(struct ath_hw *ah) | |||
644 | else if (AR_SREV_9340(ah)) | 644 | else if (AR_SREV_9340(ah)) |
645 | INIT_INI_ARRAY(&ah->iniModesRxGain, | 645 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
646 | ar9340Common_wo_xlna_rx_gain_table_1p0); | 646 | ar9340Common_wo_xlna_rx_gain_table_1p0); |
647 | else if (AR_SREV_9485_11(ah)) | 647 | else if (AR_SREV_9485_11_OR_LATER(ah)) |
648 | INIT_INI_ARRAY(&ah->iniModesRxGain, | 648 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
649 | ar9485Common_wo_xlna_rx_gain_1_1); | 649 | ar9485Common_wo_xlna_rx_gain_1_1); |
650 | else if (AR_SREV_9462_21(ah)) | 650 | else if (AR_SREV_9462_21(ah)) |
@@ -745,16 +745,25 @@ static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah) | |||
745 | static void ar9003_hw_configpcipowersave(struct ath_hw *ah, | 745 | static void ar9003_hw_configpcipowersave(struct ath_hw *ah, |
746 | bool power_off) | 746 | bool power_off) |
747 | { | 747 | { |
748 | /* | ||
749 | * Increase L1 Entry Latency. Some WB222 boards don't have | ||
750 | * this change in eeprom/OTP. | ||
751 | * | ||
752 | */ | ||
753 | if (AR_SREV_9462(ah)) { | ||
754 | u32 val = ah->config.aspm_l1_fix; | ||
755 | if ((val & 0xff000000) == 0x17000000) { | ||
756 | val &= 0x00ffffff; | ||
757 | val |= 0x27000000; | ||
758 | REG_WRITE(ah, 0x570c, val); | ||
759 | } | ||
760 | } | ||
761 | |||
748 | /* Nothing to do on restore for 11N */ | 762 | /* Nothing to do on restore for 11N */ |
749 | if (!power_off /* !restore */) { | 763 | if (!power_off /* !restore */) { |
750 | /* set bit 19 to allow forcing of pcie core into L1 state */ | 764 | /* set bit 19 to allow forcing of pcie core into L1 state */ |
751 | REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); | 765 | REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); |
752 | 766 | REG_WRITE(ah, AR_WA, ah->WARegVal); | |
753 | /* Several PCIe massages to ensure proper behaviour */ | ||
754 | if (ah->config.pcie_waen) | ||
755 | REG_WRITE(ah, AR_WA, ah->config.pcie_waen); | ||
756 | else | ||
757 | REG_WRITE(ah, AR_WA, ah->WARegVal); | ||
758 | } | 767 | } |
759 | 768 | ||
760 | /* | 769 | /* |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 5163abd3937c..f6c5c1b50471 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c | |||
@@ -491,6 +491,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, | |||
491 | rxs->rs_rate = MS(rxsp->status1, AR_RxRate); | 491 | rxs->rs_rate = MS(rxsp->status1, AR_RxRate); |
492 | rxs->rs_more = (rxsp->status2 & AR_RxMore) ? 1 : 0; | 492 | rxs->rs_more = (rxsp->status2 & AR_RxMore) ? 1 : 0; |
493 | 493 | ||
494 | rxs->rs_firstaggr = (rxsp->status11 & AR_RxFirstAggr) ? 1 : 0; | ||
494 | rxs->rs_isaggr = (rxsp->status11 & AR_RxAggr) ? 1 : 0; | 495 | rxs->rs_isaggr = (rxsp->status11 & AR_RxAggr) ? 1 : 0; |
495 | rxs->rs_moreaggr = (rxsp->status11 & AR_RxMoreAggr) ? 1 : 0; | 496 | rxs->rs_moreaggr = (rxsp->status11 & AR_RxMoreAggr) ? 1 : 0; |
496 | rxs->rs_antenna = (MS(rxsp->status4, AR_RxAntenna) & 0x7); | 497 | rxs->rs_antenna = (MS(rxsp->status4, AR_RxAntenna) & 0x7); |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 1f694ab3cc78..46b910a857d9 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c | |||
@@ -632,6 +632,22 @@ static void ar9003_hw_override_ini(struct ath_hw *ah) | |||
632 | 632 | ||
633 | REG_SET_BIT(ah, AR_PHY_CCK_DETECT, | 633 | REG_SET_BIT(ah, AR_PHY_CCK_DETECT, |
634 | AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); | 634 | AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); |
635 | |||
636 | if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) { | ||
637 | REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE, | ||
638 | AR_GLB_SWREG_DISCONT_EN_BT_WLAN); | ||
639 | |||
640 | if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0, | ||
641 | AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) | ||
642 | ah->enabled_cals |= TX_IQ_CAL; | ||
643 | else | ||
644 | ah->enabled_cals &= ~TX_IQ_CAL; | ||
645 | |||
646 | if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) | ||
647 | ah->enabled_cals |= TX_CL_CAL; | ||
648 | else | ||
649 | ah->enabled_cals &= ~TX_CL_CAL; | ||
650 | } | ||
635 | } | 651 | } |
636 | 652 | ||
637 | static void ar9003_hw_prog_ini(struct ath_hw *ah, | 653 | static void ar9003_hw_prog_ini(struct ath_hw *ah, |
@@ -814,29 +830,12 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, | |||
814 | if (chan->channel == 2484) | 830 | if (chan->channel == 2484) |
815 | ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1); | 831 | ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1); |
816 | 832 | ||
817 | if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) | ||
818 | REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE, | ||
819 | AR_GLB_SWREG_DISCONT_EN_BT_WLAN); | ||
820 | |||
821 | ah->modes_index = modesIndex; | 833 | ah->modes_index = modesIndex; |
822 | ar9003_hw_override_ini(ah); | 834 | ar9003_hw_override_ini(ah); |
823 | ar9003_hw_set_channel_regs(ah, chan); | 835 | ar9003_hw_set_channel_regs(ah, chan); |
824 | ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); | 836 | ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); |
825 | ath9k_hw_apply_txpower(ah, chan, false); | 837 | ath9k_hw_apply_txpower(ah, chan, false); |
826 | 838 | ||
827 | if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) { | ||
828 | if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0, | ||
829 | AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) | ||
830 | ah->enabled_cals |= TX_IQ_CAL; | ||
831 | else | ||
832 | ah->enabled_cals &= ~TX_IQ_CAL; | ||
833 | |||
834 | if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) | ||
835 | ah->enabled_cals |= TX_CL_CAL; | ||
836 | else | ||
837 | ah->enabled_cals &= ~TX_CL_CAL; | ||
838 | } | ||
839 | |||
840 | return 0; | 839 | return 0; |
841 | } | 840 | } |
842 | 841 | ||
@@ -1173,6 +1172,10 @@ skip_ws_det: | |||
1173 | * is_on == 0 means MRC CCK is OFF (more noise imm) | 1172 | * is_on == 0 means MRC CCK is OFF (more noise imm) |
1174 | */ | 1173 | */ |
1175 | bool is_on = param ? 1 : 0; | 1174 | bool is_on = param ? 1 : 0; |
1175 | |||
1176 | if (ah->caps.rx_chainmask == 1) | ||
1177 | break; | ||
1178 | |||
1176 | REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, | 1179 | REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, |
1177 | AR_PHY_MRC_CCK_ENABLE, is_on); | 1180 | AR_PHY_MRC_CCK_ENABLE, is_on); |
1178 | REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, | 1181 | REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, |
@@ -1413,65 +1416,111 @@ static void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah, | |||
1413 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | 1416 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); |
1414 | } | 1417 | } |
1415 | 1418 | ||
1416 | static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah, | 1419 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
1417 | bool enable) | 1420 | |
1421 | static void ar9003_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) | ||
1418 | { | 1422 | { |
1423 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
1419 | u8 ant_div_ctl1; | 1424 | u8 ant_div_ctl1; |
1420 | u32 regval; | 1425 | u32 regval; |
1421 | 1426 | ||
1422 | if (!AR_SREV_9565(ah)) | 1427 | if (!AR_SREV_9485(ah) && !AR_SREV_9565(ah)) |
1423 | return; | 1428 | return; |
1424 | 1429 | ||
1425 | ah->shared_chain_lnadiv = enable; | 1430 | if (AR_SREV_9485(ah)) { |
1431 | regval = ar9003_hw_ant_ctrl_common_2_get(ah, | ||
1432 | IS_CHAN_2GHZ(ah->curchan)); | ||
1433 | if (enable) { | ||
1434 | regval &= ~AR_SWITCH_TABLE_COM2_ALL; | ||
1435 | regval |= ah->config.ant_ctrl_comm2g_switch_enable; | ||
1436 | } | ||
1437 | REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, | ||
1438 | AR_SWITCH_TABLE_COM2_ALL, regval); | ||
1439 | } | ||
1440 | |||
1426 | ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); | 1441 | ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); |
1427 | 1442 | ||
1443 | /* | ||
1444 | * Set MAIN/ALT LNA conf. | ||
1445 | * Set MAIN/ALT gain_tb. | ||
1446 | */ | ||
1428 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); | 1447 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); |
1429 | regval &= (~AR_ANT_DIV_CTRL_ALL); | 1448 | regval &= (~AR_ANT_DIV_CTRL_ALL); |
1430 | regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S; | 1449 | regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S; |
1431 | regval &= ~AR_PHY_ANT_DIV_LNADIV; | ||
1432 | regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S; | ||
1433 | |||
1434 | if (enable) | ||
1435 | regval |= AR_ANT_DIV_ENABLE; | ||
1436 | |||
1437 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | 1450 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); |
1438 | 1451 | ||
1439 | regval = REG_READ(ah, AR_PHY_CCK_DETECT); | 1452 | if (AR_SREV_9485_11_OR_LATER(ah)) { |
1440 | regval &= ~AR_FAST_DIV_ENABLE; | 1453 | /* |
1441 | regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; | 1454 | * Enable LNA diversity. |
1442 | 1455 | */ | |
1443 | if (enable) | ||
1444 | regval |= AR_FAST_DIV_ENABLE; | ||
1445 | |||
1446 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); | ||
1447 | |||
1448 | if (enable) { | ||
1449 | REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL, | ||
1450 | (1 << AR_PHY_ANT_SW_RX_PROT_S)); | ||
1451 | if (ah->curchan && IS_CHAN_2GHZ(ah->curchan)) | ||
1452 | REG_SET_BIT(ah, AR_PHY_RESTART, | ||
1453 | AR_PHY_RESTART_ENABLE_DIV_M2FLAG); | ||
1454 | REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, | ||
1455 | AR_BTCOEX_WL_LNADIV_FORCE_ON); | ||
1456 | } else { | ||
1457 | REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE); | ||
1458 | REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, | ||
1459 | (1 << AR_PHY_ANT_SW_RX_PROT_S)); | ||
1460 | REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE); | ||
1461 | REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV, | ||
1462 | AR_BTCOEX_WL_LNADIV_FORCE_ON); | ||
1463 | |||
1464 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); | 1456 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); |
1465 | regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF | | 1457 | regval &= ~AR_PHY_ANT_DIV_LNADIV; |
1466 | AR_PHY_ANT_DIV_ALT_LNACONF | | 1458 | regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S; |
1467 | AR_PHY_ANT_DIV_MAIN_GAINTB | | 1459 | if (enable) |
1468 | AR_PHY_ANT_DIV_ALT_GAINTB); | 1460 | regval |= AR_ANT_DIV_ENABLE; |
1469 | regval |= (AR_PHY_ANT_DIV_LNA1 << AR_PHY_ANT_DIV_MAIN_LNACONF_S); | 1461 | |
1470 | regval |= (AR_PHY_ANT_DIV_LNA2 << AR_PHY_ANT_DIV_ALT_LNACONF_S); | ||
1471 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | 1462 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); |
1463 | |||
1464 | /* | ||
1465 | * Enable fast antenna diversity. | ||
1466 | */ | ||
1467 | regval = REG_READ(ah, AR_PHY_CCK_DETECT); | ||
1468 | regval &= ~AR_FAST_DIV_ENABLE; | ||
1469 | regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; | ||
1470 | if (enable) | ||
1471 | regval |= AR_FAST_DIV_ENABLE; | ||
1472 | |||
1473 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); | ||
1474 | |||
1475 | if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { | ||
1476 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); | ||
1477 | regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF | | ||
1478 | AR_PHY_ANT_DIV_ALT_LNACONF | | ||
1479 | AR_PHY_ANT_DIV_ALT_GAINTB | | ||
1480 | AR_PHY_ANT_DIV_MAIN_GAINTB)); | ||
1481 | /* | ||
1482 | * Set MAIN to LNA1 and ALT to LNA2 at the | ||
1483 | * beginning. | ||
1484 | */ | ||
1485 | regval |= (ATH_ANT_DIV_COMB_LNA1 << | ||
1486 | AR_PHY_ANT_DIV_MAIN_LNACONF_S); | ||
1487 | regval |= (ATH_ANT_DIV_COMB_LNA2 << | ||
1488 | AR_PHY_ANT_DIV_ALT_LNACONF_S); | ||
1489 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | ||
1490 | } | ||
1491 | } else if (AR_SREV_9565(ah)) { | ||
1492 | if (enable) { | ||
1493 | REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL, | ||
1494 | (1 << AR_PHY_ANT_SW_RX_PROT_S)); | ||
1495 | if (ah->curchan && IS_CHAN_2GHZ(ah->curchan)) | ||
1496 | REG_SET_BIT(ah, AR_PHY_RESTART, | ||
1497 | AR_PHY_RESTART_ENABLE_DIV_M2FLAG); | ||
1498 | REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, | ||
1499 | AR_BTCOEX_WL_LNADIV_FORCE_ON); | ||
1500 | } else { | ||
1501 | REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE); | ||
1502 | REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, | ||
1503 | (1 << AR_PHY_ANT_SW_RX_PROT_S)); | ||
1504 | REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE); | ||
1505 | REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV, | ||
1506 | AR_BTCOEX_WL_LNADIV_FORCE_ON); | ||
1507 | |||
1508 | regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); | ||
1509 | regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF | | ||
1510 | AR_PHY_ANT_DIV_ALT_LNACONF | | ||
1511 | AR_PHY_ANT_DIV_MAIN_GAINTB | | ||
1512 | AR_PHY_ANT_DIV_ALT_GAINTB); | ||
1513 | regval |= (ATH_ANT_DIV_COMB_LNA1 << | ||
1514 | AR_PHY_ANT_DIV_MAIN_LNACONF_S); | ||
1515 | regval |= (ATH_ANT_DIV_COMB_LNA2 << | ||
1516 | AR_PHY_ANT_DIV_ALT_LNACONF_S); | ||
1517 | REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); | ||
1518 | } | ||
1472 | } | 1519 | } |
1473 | } | 1520 | } |
1474 | 1521 | ||
1522 | #endif | ||
1523 | |||
1475 | static int ar9003_hw_fast_chan_change(struct ath_hw *ah, | 1524 | static int ar9003_hw_fast_chan_change(struct ath_hw *ah, |
1476 | struct ath9k_channel *chan, | 1525 | struct ath9k_channel *chan, |
1477 | u8 *ini_reloaded) | 1526 | u8 *ini_reloaded) |
@@ -1518,6 +1567,18 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah, | |||
1518 | 1567 | ||
1519 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); | 1568 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); |
1520 | 1569 | ||
1570 | if (AR_SREV_9462_20_OR_LATER(ah)) { | ||
1571 | /* | ||
1572 | * CUS217 mix LNA mode. | ||
1573 | */ | ||
1574 | if (ar9003_hw_get_rx_gain_idx(ah) == 2) { | ||
1575 | REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_core, | ||
1576 | 1, regWrites); | ||
1577 | REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_postamble, | ||
1578 | modesIndex, regWrites); | ||
1579 | } | ||
1580 | } | ||
1581 | |||
1521 | /* | 1582 | /* |
1522 | * For 5GHz channels requiring Fast Clock, apply | 1583 | * For 5GHz channels requiring Fast Clock, apply |
1523 | * different modal values. | 1584 | * different modal values. |
@@ -1528,7 +1589,11 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah, | |||
1528 | if (AR_SREV_9565(ah)) | 1589 | if (AR_SREV_9565(ah)) |
1529 | REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites); | 1590 | REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites); |
1530 | 1591 | ||
1531 | REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites); | 1592 | /* |
1593 | * JAPAN regulatory. | ||
1594 | */ | ||
1595 | if (chan->channel == 2484) | ||
1596 | ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1); | ||
1532 | 1597 | ||
1533 | ah->modes_index = modesIndex; | 1598 | ah->modes_index = modesIndex; |
1534 | *ini_reloaded = true; | 1599 | *ini_reloaded = true; |
@@ -1631,11 +1696,14 @@ void ar9003_hw_attach_phy_ops(struct ath_hw *ah) | |||
1631 | 1696 | ||
1632 | ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get; | 1697 | ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get; |
1633 | ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set; | 1698 | ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set; |
1634 | ops->antctrl_shared_chain_lnadiv = ar9003_hw_antctrl_shared_chain_lnadiv; | ||
1635 | ops->spectral_scan_config = ar9003_hw_spectral_scan_config; | 1699 | ops->spectral_scan_config = ar9003_hw_spectral_scan_config; |
1636 | ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger; | 1700 | ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger; |
1637 | ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait; | 1701 | ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait; |
1638 | 1702 | ||
1703 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | ||
1704 | ops->set_bt_ant_diversity = ar9003_hw_set_bt_ant_diversity; | ||
1705 | #endif | ||
1706 | |||
1639 | ar9003_hw_set_nf_limits(ah); | 1707 | ar9003_hw_set_nf_limits(ah); |
1640 | ar9003_hw_set_radar_conf(ah); | 1708 | ar9003_hw_set_radar_conf(ah); |
1641 | memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs)); | 1709 | memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs)); |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index d4d39f305a0b..6fd752321e36 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h | |||
@@ -148,6 +148,8 @@ | |||
148 | #define AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S 28 | 148 | #define AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S 28 |
149 | #define AR_PHY_EXT_CCA_THRESH62 0x007F0000 | 149 | #define AR_PHY_EXT_CCA_THRESH62 0x007F0000 |
150 | #define AR_PHY_EXT_CCA_THRESH62_S 16 | 150 | #define AR_PHY_EXT_CCA_THRESH62_S 16 |
151 | #define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX 0x0000FF00 | ||
152 | #define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX_S 8 | ||
151 | #define AR_PHY_EXT_MINCCA_PWR 0x01FF0000 | 153 | #define AR_PHY_EXT_MINCCA_PWR 0x01FF0000 |
152 | #define AR_PHY_EXT_MINCCA_PWR_S 16 | 154 | #define AR_PHY_EXT_MINCCA_PWR_S 16 |
153 | #define AR_PHY_EXT_CYCPWR_THR1 0x0000FE00L | 155 | #define AR_PHY_EXT_CYCPWR_THR1 0x0000FE00L |
@@ -296,11 +298,6 @@ | |||
296 | #define AR_PHY_ANT_DIV_MAIN_GAINTB 0x40000000 | 298 | #define AR_PHY_ANT_DIV_MAIN_GAINTB 0x40000000 |
297 | #define AR_PHY_ANT_DIV_MAIN_GAINTB_S 30 | 299 | #define AR_PHY_ANT_DIV_MAIN_GAINTB_S 30 |
298 | 300 | ||
299 | #define AR_PHY_ANT_DIV_LNA1_MINUS_LNA2 0x0 | ||
300 | #define AR_PHY_ANT_DIV_LNA2 0x1 | ||
301 | #define AR_PHY_ANT_DIV_LNA1 0x2 | ||
302 | #define AR_PHY_ANT_DIV_LNA1_PLUS_LNA2 0x3 | ||
303 | |||
304 | #define AR_PHY_EXTCHN_PWRTHR1 (AR_AGC_BASE + 0x2c) | 301 | #define AR_PHY_EXTCHN_PWRTHR1 (AR_AGC_BASE + 0x2c) |
305 | #define AR_PHY_EXT_CHN_WIN (AR_AGC_BASE + 0x30) | 302 | #define AR_PHY_EXT_CHN_WIN (AR_AGC_BASE + 0x30) |
306 | #define AR_PHY_20_40_DET_THR (AR_AGC_BASE + 0x34) | 303 | #define AR_PHY_20_40_DET_THR (AR_AGC_BASE + 0x34) |
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index c1224b5a257b..2ee35f677c0e 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -72,17 +72,12 @@ struct ath_config { | |||
72 | /*************************/ | 72 | /*************************/ |
73 | 73 | ||
74 | #define ATH_TXBUF_RESET(_bf) do { \ | 74 | #define ATH_TXBUF_RESET(_bf) do { \ |
75 | (_bf)->bf_stale = false; \ | ||
76 | (_bf)->bf_lastbf = NULL; \ | 75 | (_bf)->bf_lastbf = NULL; \ |
77 | (_bf)->bf_next = NULL; \ | 76 | (_bf)->bf_next = NULL; \ |
78 | memset(&((_bf)->bf_state), 0, \ | 77 | memset(&((_bf)->bf_state), 0, \ |
79 | sizeof(struct ath_buf_state)); \ | 78 | sizeof(struct ath_buf_state)); \ |
80 | } while (0) | 79 | } while (0) |
81 | 80 | ||
82 | #define ATH_RXBUF_RESET(_bf) do { \ | ||
83 | (_bf)->bf_stale = false; \ | ||
84 | } while (0) | ||
85 | |||
86 | /** | 81 | /** |
87 | * enum buffer_type - Buffer type flags | 82 | * enum buffer_type - Buffer type flags |
88 | * | 83 | * |
@@ -137,7 +132,8 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, | |||
137 | #define ATH_AGGR_ENCRYPTDELIM 10 | 132 | #define ATH_AGGR_ENCRYPTDELIM 10 |
138 | /* minimum h/w qdepth to be sustained to maximize aggregation */ | 133 | /* minimum h/w qdepth to be sustained to maximize aggregation */ |
139 | #define ATH_AGGR_MIN_QDEPTH 2 | 134 | #define ATH_AGGR_MIN_QDEPTH 2 |
140 | #define ATH_AMPDU_SUBFRAME_DEFAULT 32 | 135 | /* minimum h/w qdepth for non-aggregated traffic */ |
136 | #define ATH_NON_AGGR_MIN_QDEPTH 8 | ||
141 | 137 | ||
142 | #define IEEE80211_SEQ_SEQ_SHIFT 4 | 138 | #define IEEE80211_SEQ_SEQ_SHIFT 4 |
143 | #define IEEE80211_SEQ_MAX 4096 | 139 | #define IEEE80211_SEQ_MAX 4096 |
@@ -174,12 +170,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, | |||
174 | 170 | ||
175 | #define ATH_TX_COMPLETE_POLL_INT 1000 | 171 | #define ATH_TX_COMPLETE_POLL_INT 1000 |
176 | 172 | ||
177 | enum ATH_AGGR_STATUS { | ||
178 | ATH_AGGR_DONE, | ||
179 | ATH_AGGR_BAW_CLOSED, | ||
180 | ATH_AGGR_LIMITED, | ||
181 | }; | ||
182 | |||
183 | #define ATH_TXFIFO_DEPTH 8 | 173 | #define ATH_TXFIFO_DEPTH 8 |
184 | struct ath_txq { | 174 | struct ath_txq { |
185 | int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */ | 175 | int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */ |
@@ -201,10 +191,10 @@ struct ath_txq { | |||
201 | 191 | ||
202 | struct ath_atx_ac { | 192 | struct ath_atx_ac { |
203 | struct ath_txq *txq; | 193 | struct ath_txq *txq; |
204 | int sched; | ||
205 | struct list_head list; | 194 | struct list_head list; |
206 | struct list_head tid_q; | 195 | struct list_head tid_q; |
207 | bool clear_ps_filter; | 196 | bool clear_ps_filter; |
197 | bool sched; | ||
208 | }; | 198 | }; |
209 | 199 | ||
210 | struct ath_frame_info { | 200 | struct ath_frame_info { |
@@ -212,14 +202,16 @@ struct ath_frame_info { | |||
212 | int framelen; | 202 | int framelen; |
213 | enum ath9k_key_type keytype; | 203 | enum ath9k_key_type keytype; |
214 | u8 keyix; | 204 | u8 keyix; |
215 | u8 retries; | ||
216 | u8 rtscts_rate; | 205 | u8 rtscts_rate; |
206 | u8 retries : 7; | ||
207 | u8 baw_tracked : 1; | ||
217 | }; | 208 | }; |
218 | 209 | ||
219 | struct ath_buf_state { | 210 | struct ath_buf_state { |
220 | u8 bf_type; | 211 | u8 bf_type; |
221 | u8 bfs_paprd; | 212 | u8 bfs_paprd; |
222 | u8 ndelim; | 213 | u8 ndelim; |
214 | bool stale; | ||
223 | u16 seqno; | 215 | u16 seqno; |
224 | unsigned long bfs_paprd_timestamp; | 216 | unsigned long bfs_paprd_timestamp; |
225 | }; | 217 | }; |
@@ -233,7 +225,6 @@ struct ath_buf { | |||
233 | void *bf_desc; /* virtual addr of desc */ | 225 | void *bf_desc; /* virtual addr of desc */ |
234 | dma_addr_t bf_daddr; /* physical addr of desc */ | 226 | dma_addr_t bf_daddr; /* physical addr of desc */ |
235 | dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */ | 227 | dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */ |
236 | bool bf_stale; | ||
237 | struct ieee80211_tx_rate rates[4]; | 228 | struct ieee80211_tx_rate rates[4]; |
238 | struct ath_buf_state bf_state; | 229 | struct ath_buf_state bf_state; |
239 | }; | 230 | }; |
@@ -241,16 +232,18 @@ struct ath_buf { | |||
241 | struct ath_atx_tid { | 232 | struct ath_atx_tid { |
242 | struct list_head list; | 233 | struct list_head list; |
243 | struct sk_buff_head buf_q; | 234 | struct sk_buff_head buf_q; |
235 | struct sk_buff_head retry_q; | ||
244 | struct ath_node *an; | 236 | struct ath_node *an; |
245 | struct ath_atx_ac *ac; | 237 | struct ath_atx_ac *ac; |
246 | unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)]; | 238 | unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)]; |
247 | int bar_index; | ||
248 | u16 seq_start; | 239 | u16 seq_start; |
249 | u16 seq_next; | 240 | u16 seq_next; |
250 | u16 baw_size; | 241 | u16 baw_size; |
251 | int tidno; | 242 | u8 tidno; |
252 | int baw_head; /* first un-acked tx buffer */ | 243 | int baw_head; /* first un-acked tx buffer */ |
253 | int baw_tail; /* next unused tx buffer slot */ | 244 | int baw_tail; /* next unused tx buffer slot */ |
245 | |||
246 | s8 bar_index; | ||
254 | bool sched; | 247 | bool sched; |
255 | bool paused; | 248 | bool paused; |
256 | bool active; | 249 | bool active; |
@@ -262,16 +255,13 @@ struct ath_node { | |||
262 | struct ieee80211_vif *vif; /* interface with which we're associated */ | 255 | struct ieee80211_vif *vif; /* interface with which we're associated */ |
263 | struct ath_atx_tid tid[IEEE80211_NUM_TIDS]; | 256 | struct ath_atx_tid tid[IEEE80211_NUM_TIDS]; |
264 | struct ath_atx_ac ac[IEEE80211_NUM_ACS]; | 257 | struct ath_atx_ac ac[IEEE80211_NUM_ACS]; |
265 | int ps_key; | ||
266 | 258 | ||
267 | u16 maxampdu; | 259 | u16 maxampdu; |
268 | u8 mpdudensity; | 260 | u8 mpdudensity; |
261 | s8 ps_key; | ||
269 | 262 | ||
270 | bool sleeping; | 263 | bool sleeping; |
271 | 264 | bool no_ps_filter; | |
272 | #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS) | ||
273 | struct dentry *node_stat; | ||
274 | #endif | ||
275 | }; | 265 | }; |
276 | 266 | ||
277 | struct ath_tx_control { | 267 | struct ath_tx_control { |
@@ -317,6 +307,7 @@ struct ath_rx { | |||
317 | struct ath_descdma rxdma; | 307 | struct ath_descdma rxdma; |
318 | struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX]; | 308 | struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX]; |
319 | 309 | ||
310 | struct ath_buf *buf_hold; | ||
320 | struct sk_buff *frag; | 311 | struct sk_buff *frag; |
321 | 312 | ||
322 | u32 ampdu_ref; | 313 | u32 ampdu_ref; |
@@ -367,6 +358,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw, | |||
367 | /********/ | 358 | /********/ |
368 | 359 | ||
369 | struct ath_vif { | 360 | struct ath_vif { |
361 | struct ath_node mcast_node; | ||
370 | int av_bslot; | 362 | int av_bslot; |
371 | bool primary_sta_vif; | 363 | bool primary_sta_vif; |
372 | __le64 tsf_adjust; /* TSF adjustment for staggered beacons */ | 364 | __le64 tsf_adjust; /* TSF adjustment for staggered beacons */ |
@@ -428,6 +420,7 @@ void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif); | |||
428 | void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif); | 420 | void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif); |
429 | void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif); | 421 | void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif); |
430 | void ath9k_set_beacon(struct ath_softc *sc); | 422 | void ath9k_set_beacon(struct ath_softc *sc); |
423 | bool ath9k_csa_is_finished(struct ath_softc *sc); | ||
431 | 424 | ||
432 | /*******************/ | 425 | /*******************/ |
433 | /* Link Monitoring */ | 426 | /* Link Monitoring */ |
@@ -585,19 +578,14 @@ static inline void ath_fill_led_pin(struct ath_softc *sc) | |||
585 | #define ATH_ANT_DIV_COMB_MAX_COUNT 100 | 578 | #define ATH_ANT_DIV_COMB_MAX_COUNT 100 |
586 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 | 579 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 |
587 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 | 580 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 |
581 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50 | ||
582 | #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50 | ||
588 | 583 | ||
589 | #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1 | 584 | #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1 |
590 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 | 585 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 |
591 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 | 586 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 |
592 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 | 587 | #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 |
593 | 588 | ||
594 | enum ath9k_ant_div_comb_lna_conf { | ||
595 | ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2, | ||
596 | ATH_ANT_DIV_COMB_LNA2, | ||
597 | ATH_ANT_DIV_COMB_LNA1, | ||
598 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2, | ||
599 | }; | ||
600 | |||
601 | struct ath_ant_comb { | 589 | struct ath_ant_comb { |
602 | u16 count; | 590 | u16 count; |
603 | u16 total_pkt_count; | 591 | u16 total_pkt_count; |
@@ -614,27 +602,36 @@ struct ath_ant_comb { | |||
614 | int rssi_first; | 602 | int rssi_first; |
615 | int rssi_second; | 603 | int rssi_second; |
616 | int rssi_third; | 604 | int rssi_third; |
605 | int ant_ratio; | ||
606 | int ant_ratio2; | ||
617 | bool alt_good; | 607 | bool alt_good; |
618 | int quick_scan_cnt; | 608 | int quick_scan_cnt; |
619 | int main_conf; | 609 | enum ath9k_ant_div_comb_lna_conf main_conf; |
620 | enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf; | 610 | enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf; |
621 | enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf; | 611 | enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf; |
622 | bool first_ratio; | 612 | bool first_ratio; |
623 | bool second_ratio; | 613 | bool second_ratio; |
624 | unsigned long scan_start_time; | 614 | unsigned long scan_start_time; |
615 | |||
616 | /* | ||
617 | * Card-specific config values. | ||
618 | */ | ||
619 | int low_rssi_thresh; | ||
620 | int fast_div_bias; | ||
625 | }; | 621 | }; |
626 | 622 | ||
627 | void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs); | 623 | void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs); |
628 | void ath_ant_comb_update(struct ath_softc *sc); | ||
629 | 624 | ||
630 | /********************/ | 625 | /********************/ |
631 | /* Main driver core */ | 626 | /* Main driver core */ |
632 | /********************/ | 627 | /********************/ |
633 | 628 | ||
634 | #define ATH9K_PCI_CUS198 0x0001 | 629 | #define ATH9K_PCI_CUS198 0x0001 |
635 | #define ATH9K_PCI_CUS230 0x0002 | 630 | #define ATH9K_PCI_CUS230 0x0002 |
636 | #define ATH9K_PCI_CUS217 0x0004 | 631 | #define ATH9K_PCI_CUS217 0x0004 |
637 | #define ATH9K_PCI_WOW 0x0008 | 632 | #define ATH9K_PCI_WOW 0x0008 |
633 | #define ATH9K_PCI_BT_ANT_DIV 0x0010 | ||
634 | #define ATH9K_PCI_D3_L1_WAR 0x0020 | ||
638 | 635 | ||
639 | /* | 636 | /* |
640 | * Default cache line size, in bytes. | 637 | * Default cache line size, in bytes. |
@@ -761,6 +758,7 @@ struct ath_softc { | |||
761 | #endif | 758 | #endif |
762 | 759 | ||
763 | struct ath_descdma txsdma; | 760 | struct ath_descdma txsdma; |
761 | struct ieee80211_vif *csa_vif; | ||
764 | 762 | ||
765 | struct ath_ant_comb ant_comb; | 763 | struct ath_ant_comb ant_comb; |
766 | u8 ant_tx, ant_rx; | 764 | u8 ant_tx, ant_rx; |
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 1a17732bb089..b5c16b3a37b9 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c | |||
@@ -291,6 +291,23 @@ void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif) | |||
291 | (unsigned long long)tsfadjust, avp->av_bslot); | 291 | (unsigned long long)tsfadjust, avp->av_bslot); |
292 | } | 292 | } |
293 | 293 | ||
294 | bool ath9k_csa_is_finished(struct ath_softc *sc) | ||
295 | { | ||
296 | struct ieee80211_vif *vif; | ||
297 | |||
298 | vif = sc->csa_vif; | ||
299 | if (!vif || !vif->csa_active) | ||
300 | return false; | ||
301 | |||
302 | if (!ieee80211_csa_is_complete(vif)) | ||
303 | return false; | ||
304 | |||
305 | ieee80211_csa_finish(vif); | ||
306 | |||
307 | sc->csa_vif = NULL; | ||
308 | return true; | ||
309 | } | ||
310 | |||
294 | void ath9k_beacon_tasklet(unsigned long data) | 311 | void ath9k_beacon_tasklet(unsigned long data) |
295 | { | 312 | { |
296 | struct ath_softc *sc = (struct ath_softc *)data; | 313 | struct ath_softc *sc = (struct ath_softc *)data; |
@@ -336,6 +353,10 @@ void ath9k_beacon_tasklet(unsigned long data) | |||
336 | return; | 353 | return; |
337 | } | 354 | } |
338 | 355 | ||
356 | /* EDMA devices check that in the tx completion function. */ | ||
357 | if (!edma && ath9k_csa_is_finished(sc)) | ||
358 | return; | ||
359 | |||
339 | slot = ath9k_beacon_choose_slot(sc); | 360 | slot = ath9k_beacon_choose_slot(sc); |
340 | vif = sc->beacon.bslot[slot]; | 361 | vif = sc->beacon.bslot[slot]; |
341 | 362 | ||
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c index 344fdde1d7a3..d3063c21e16c 100644 --- a/drivers/net/wireless/ath/ath9k/common.c +++ b/drivers/net/wireless/ath/ath9k/common.c | |||
@@ -49,37 +49,40 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb) | |||
49 | } | 49 | } |
50 | EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype); | 50 | EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype); |
51 | 51 | ||
52 | static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan, | 52 | static u32 ath9k_get_extchanmode(struct cfg80211_chan_def *chandef) |
53 | enum nl80211_channel_type channel_type) | ||
54 | { | 53 | { |
55 | u32 chanmode = 0; | 54 | u32 chanmode = 0; |
56 | 55 | ||
57 | switch (chan->band) { | 56 | switch (chandef->chan->band) { |
58 | case IEEE80211_BAND_2GHZ: | 57 | case IEEE80211_BAND_2GHZ: |
59 | switch (channel_type) { | 58 | switch (chandef->width) { |
60 | case NL80211_CHAN_NO_HT: | 59 | case NL80211_CHAN_WIDTH_20_NOHT: |
61 | case NL80211_CHAN_HT20: | 60 | case NL80211_CHAN_WIDTH_20: |
62 | chanmode = CHANNEL_G_HT20; | 61 | chanmode = CHANNEL_G_HT20; |
63 | break; | 62 | break; |
64 | case NL80211_CHAN_HT40PLUS: | 63 | case NL80211_CHAN_WIDTH_40: |
65 | chanmode = CHANNEL_G_HT40PLUS; | 64 | if (chandef->center_freq1 > chandef->chan->center_freq) |
65 | chanmode = CHANNEL_G_HT40PLUS; | ||
66 | else | ||
67 | chanmode = CHANNEL_G_HT40MINUS; | ||
66 | break; | 68 | break; |
67 | case NL80211_CHAN_HT40MINUS: | 69 | default: |
68 | chanmode = CHANNEL_G_HT40MINUS; | ||
69 | break; | 70 | break; |
70 | } | 71 | } |
71 | break; | 72 | break; |
72 | case IEEE80211_BAND_5GHZ: | 73 | case IEEE80211_BAND_5GHZ: |
73 | switch (channel_type) { | 74 | switch (chandef->width) { |
74 | case NL80211_CHAN_NO_HT: | 75 | case NL80211_CHAN_WIDTH_20_NOHT: |
75 | case NL80211_CHAN_HT20: | 76 | case NL80211_CHAN_WIDTH_20: |
76 | chanmode = CHANNEL_A_HT20; | 77 | chanmode = CHANNEL_A_HT20; |
77 | break; | 78 | break; |
78 | case NL80211_CHAN_HT40PLUS: | 79 | case NL80211_CHAN_WIDTH_40: |
79 | chanmode = CHANNEL_A_HT40PLUS; | 80 | if (chandef->center_freq1 > chandef->chan->center_freq) |
81 | chanmode = CHANNEL_A_HT40PLUS; | ||
82 | else | ||
83 | chanmode = CHANNEL_A_HT40MINUS; | ||
80 | break; | 84 | break; |
81 | case NL80211_CHAN_HT40MINUS: | 85 | default: |
82 | chanmode = CHANNEL_A_HT40MINUS; | ||
83 | break; | 86 | break; |
84 | } | 87 | } |
85 | break; | 88 | break; |
@@ -94,13 +97,12 @@ static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan, | |||
94 | * Update internal channel flags. | 97 | * Update internal channel flags. |
95 | */ | 98 | */ |
96 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, | 99 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, |
97 | struct ieee80211_channel *chan, | 100 | struct cfg80211_chan_def *chandef) |
98 | enum nl80211_channel_type channel_type) | ||
99 | { | 101 | { |
100 | ichan->channel = chan->center_freq; | 102 | ichan->channel = chandef->chan->center_freq; |
101 | ichan->chan = chan; | 103 | ichan->chan = chandef->chan; |
102 | 104 | ||
103 | if (chan->band == IEEE80211_BAND_2GHZ) { | 105 | if (chandef->chan->band == IEEE80211_BAND_2GHZ) { |
104 | ichan->chanmode = CHANNEL_G; | 106 | ichan->chanmode = CHANNEL_G; |
105 | ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM; | 107 | ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM; |
106 | } else { | 108 | } else { |
@@ -108,8 +110,22 @@ void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, | |||
108 | ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; | 110 | ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; |
109 | } | 111 | } |
110 | 112 | ||
111 | if (channel_type != NL80211_CHAN_NO_HT) | 113 | switch (chandef->width) { |
112 | ichan->chanmode = ath9k_get_extchanmode(chan, channel_type); | 114 | case NL80211_CHAN_WIDTH_5: |
115 | ichan->channelFlags |= CHANNEL_QUARTER; | ||
116 | break; | ||
117 | case NL80211_CHAN_WIDTH_10: | ||
118 | ichan->channelFlags |= CHANNEL_HALF; | ||
119 | break; | ||
120 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
121 | break; | ||
122 | case NL80211_CHAN_WIDTH_20: | ||
123 | case NL80211_CHAN_WIDTH_40: | ||
124 | ichan->chanmode = ath9k_get_extchanmode(chandef); | ||
125 | break; | ||
126 | default: | ||
127 | WARN_ON(1); | ||
128 | } | ||
113 | } | 129 | } |
114 | EXPORT_SYMBOL(ath9k_cmn_update_ichannel); | 130 | EXPORT_SYMBOL(ath9k_cmn_update_ichannel); |
115 | 131 | ||
@@ -125,8 +141,7 @@ struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, | |||
125 | 141 | ||
126 | chan_idx = curchan->hw_value; | 142 | chan_idx = curchan->hw_value; |
127 | channel = &ah->channels[chan_idx]; | 143 | channel = &ah->channels[chan_idx]; |
128 | ath9k_cmn_update_ichannel(channel, curchan, | 144 | ath9k_cmn_update_ichannel(channel, &hw->conf.chandef); |
129 | cfg80211_get_chandef_type(&hw->conf.chandef)); | ||
130 | 145 | ||
131 | return channel; | 146 | return channel; |
132 | } | 147 | } |
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h index 207d06995b15..e039bcbfbd79 100644 --- a/drivers/net/wireless/ath/ath9k/common.h +++ b/drivers/net/wireless/ath/ath9k/common.h | |||
@@ -44,8 +44,7 @@ | |||
44 | 44 | ||
45 | int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); | 45 | int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); |
46 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, | 46 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, |
47 | struct ieee80211_channel *chan, | 47 | struct cfg80211_chan_def *chandef); |
48 | enum nl80211_channel_type channel_type); | ||
49 | struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, | 48 | struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, |
50 | struct ath_hw *ah); | 49 | struct ath_hw *ah); |
51 | int ath9k_cmn_count_streams(unsigned int chainmask, int max); | 50 | int ath9k_cmn_count_streams(unsigned int chainmask, int max); |
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 87454f6c7b4f..c088744a6bfb 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -88,90 +88,6 @@ static const struct file_operations fops_debug = { | |||
88 | 88 | ||
89 | #define DMA_BUF_LEN 1024 | 89 | #define DMA_BUF_LEN 1024 |
90 | 90 | ||
91 | static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, | ||
92 | size_t count, loff_t *ppos) | ||
93 | { | ||
94 | struct ath_softc *sc = file->private_data; | ||
95 | struct ath_hw *ah = sc->sc_ah; | ||
96 | char buf[32]; | ||
97 | unsigned int len; | ||
98 | |||
99 | len = sprintf(buf, "0x%08x\n", ah->txchainmask); | ||
100 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
101 | } | ||
102 | |||
103 | static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, | ||
104 | size_t count, loff_t *ppos) | ||
105 | { | ||
106 | struct ath_softc *sc = file->private_data; | ||
107 | struct ath_hw *ah = sc->sc_ah; | ||
108 | unsigned long mask; | ||
109 | char buf[32]; | ||
110 | ssize_t len; | ||
111 | |||
112 | len = min(count, sizeof(buf) - 1); | ||
113 | if (copy_from_user(buf, user_buf, len)) | ||
114 | return -EFAULT; | ||
115 | |||
116 | buf[len] = '\0'; | ||
117 | if (kstrtoul(buf, 0, &mask)) | ||
118 | return -EINVAL; | ||
119 | |||
120 | ah->txchainmask = mask; | ||
121 | ah->caps.tx_chainmask = mask; | ||
122 | return count; | ||
123 | } | ||
124 | |||
125 | static const struct file_operations fops_tx_chainmask = { | ||
126 | .read = read_file_tx_chainmask, | ||
127 | .write = write_file_tx_chainmask, | ||
128 | .open = simple_open, | ||
129 | .owner = THIS_MODULE, | ||
130 | .llseek = default_llseek, | ||
131 | }; | ||
132 | |||
133 | |||
134 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, | ||
135 | size_t count, loff_t *ppos) | ||
136 | { | ||
137 | struct ath_softc *sc = file->private_data; | ||
138 | struct ath_hw *ah = sc->sc_ah; | ||
139 | char buf[32]; | ||
140 | unsigned int len; | ||
141 | |||
142 | len = sprintf(buf, "0x%08x\n", ah->rxchainmask); | ||
143 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
144 | } | ||
145 | |||
146 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, | ||
147 | size_t count, loff_t *ppos) | ||
148 | { | ||
149 | struct ath_softc *sc = file->private_data; | ||
150 | struct ath_hw *ah = sc->sc_ah; | ||
151 | unsigned long mask; | ||
152 | char buf[32]; | ||
153 | ssize_t len; | ||
154 | |||
155 | len = min(count, sizeof(buf) - 1); | ||
156 | if (copy_from_user(buf, user_buf, len)) | ||
157 | return -EFAULT; | ||
158 | |||
159 | buf[len] = '\0'; | ||
160 | if (kstrtoul(buf, 0, &mask)) | ||
161 | return -EINVAL; | ||
162 | |||
163 | ah->rxchainmask = mask; | ||
164 | ah->caps.rx_chainmask = mask; | ||
165 | return count; | ||
166 | } | ||
167 | |||
168 | static const struct file_operations fops_rx_chainmask = { | ||
169 | .read = read_file_rx_chainmask, | ||
170 | .write = write_file_rx_chainmask, | ||
171 | .open = simple_open, | ||
172 | .owner = THIS_MODULE, | ||
173 | .llseek = default_llseek, | ||
174 | }; | ||
175 | 91 | ||
176 | static ssize_t read_file_ani(struct file *file, char __user *user_buf, | 92 | static ssize_t read_file_ani(struct file *file, char __user *user_buf, |
177 | size_t count, loff_t *ppos) | 93 | size_t count, loff_t *ppos) |
@@ -270,25 +186,29 @@ static const struct file_operations fops_ani = { | |||
270 | .llseek = default_llseek, | 186 | .llseek = default_llseek, |
271 | }; | 187 | }; |
272 | 188 | ||
273 | static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf, | 189 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
274 | size_t count, loff_t *ppos) | 190 | |
191 | static ssize_t read_file_bt_ant_diversity(struct file *file, | ||
192 | char __user *user_buf, | ||
193 | size_t count, loff_t *ppos) | ||
275 | { | 194 | { |
276 | struct ath_softc *sc = file->private_data; | 195 | struct ath_softc *sc = file->private_data; |
277 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 196 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
278 | char buf[32]; | 197 | char buf[32]; |
279 | unsigned int len; | 198 | unsigned int len; |
280 | 199 | ||
281 | len = sprintf(buf, "%d\n", common->antenna_diversity); | 200 | len = sprintf(buf, "%d\n", common->bt_ant_diversity); |
282 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | 201 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
283 | } | 202 | } |
284 | 203 | ||
285 | static ssize_t write_file_ant_diversity(struct file *file, | 204 | static ssize_t write_file_bt_ant_diversity(struct file *file, |
286 | const char __user *user_buf, | 205 | const char __user *user_buf, |
287 | size_t count, loff_t *ppos) | 206 | size_t count, loff_t *ppos) |
288 | { | 207 | { |
289 | struct ath_softc *sc = file->private_data; | 208 | struct ath_softc *sc = file->private_data; |
290 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 209 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
291 | unsigned long antenna_diversity; | 210 | struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; |
211 | unsigned long bt_ant_diversity; | ||
292 | char buf[32]; | 212 | char buf[32]; |
293 | ssize_t len; | 213 | ssize_t len; |
294 | 214 | ||
@@ -296,26 +216,147 @@ static ssize_t write_file_ant_diversity(struct file *file, | |||
296 | if (copy_from_user(buf, user_buf, len)) | 216 | if (copy_from_user(buf, user_buf, len)) |
297 | return -EFAULT; | 217 | return -EFAULT; |
298 | 218 | ||
299 | if (!AR_SREV_9565(sc->sc_ah)) | 219 | if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) |
300 | goto exit; | 220 | goto exit; |
301 | 221 | ||
302 | buf[len] = '\0'; | 222 | buf[len] = '\0'; |
303 | if (kstrtoul(buf, 0, &antenna_diversity)) | 223 | if (kstrtoul(buf, 0, &bt_ant_diversity)) |
304 | return -EINVAL; | 224 | return -EINVAL; |
305 | 225 | ||
306 | common->antenna_diversity = !!antenna_diversity; | 226 | common->bt_ant_diversity = !!bt_ant_diversity; |
307 | ath9k_ps_wakeup(sc); | 227 | ath9k_ps_wakeup(sc); |
308 | ath_ant_comb_update(sc); | 228 | ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity); |
309 | ath_dbg(common, CONFIG, "Antenna diversity: %d\n", | 229 | ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", |
310 | common->antenna_diversity); | 230 | common->bt_ant_diversity); |
311 | ath9k_ps_restore(sc); | 231 | ath9k_ps_restore(sc); |
312 | exit: | 232 | exit: |
313 | return count; | 233 | return count; |
314 | } | 234 | } |
315 | 235 | ||
316 | static const struct file_operations fops_ant_diversity = { | 236 | static const struct file_operations fops_bt_ant_diversity = { |
317 | .read = read_file_ant_diversity, | 237 | .read = read_file_bt_ant_diversity, |
318 | .write = write_file_ant_diversity, | 238 | .write = write_file_bt_ant_diversity, |
239 | .open = simple_open, | ||
240 | .owner = THIS_MODULE, | ||
241 | .llseek = default_llseek, | ||
242 | }; | ||
243 | |||
244 | #endif | ||
245 | |||
246 | void ath9k_debug_stat_ant(struct ath_softc *sc, | ||
247 | struct ath_hw_antcomb_conf *div_ant_conf, | ||
248 | int main_rssi_avg, int alt_rssi_avg) | ||
249 | { | ||
250 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; | ||
251 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; | ||
252 | |||
253 | as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; | ||
254 | as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; | ||
255 | |||
256 | as_main->rssi_avg = main_rssi_avg; | ||
257 | as_alt->rssi_avg = alt_rssi_avg; | ||
258 | } | ||
259 | |||
260 | static ssize_t read_file_antenna_diversity(struct file *file, | ||
261 | char __user *user_buf, | ||
262 | size_t count, loff_t *ppos) | ||
263 | { | ||
264 | struct ath_softc *sc = file->private_data; | ||
265 | struct ath_hw *ah = sc->sc_ah; | ||
266 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
267 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; | ||
268 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; | ||
269 | struct ath_hw_antcomb_conf div_ant_conf; | ||
270 | unsigned int len = 0, size = 1024; | ||
271 | ssize_t retval = 0; | ||
272 | char *buf; | ||
273 | char *lna_conf_str[4] = {"LNA1_MINUS_LNA2", | ||
274 | "LNA2", | ||
275 | "LNA1", | ||
276 | "LNA1_PLUS_LNA2"}; | ||
277 | |||
278 | buf = kzalloc(size, GFP_KERNEL); | ||
279 | if (buf == NULL) | ||
280 | return -ENOMEM; | ||
281 | |||
282 | if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { | ||
283 | len += snprintf(buf + len, size - len, "%s\n", | ||
284 | "Antenna Diversity Combining is disabled"); | ||
285 | goto exit; | ||
286 | } | ||
287 | |||
288 | ath9k_ps_wakeup(sc); | ||
289 | ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); | ||
290 | len += snprintf(buf + len, size - len, "Current MAIN config : %s\n", | ||
291 | lna_conf_str[div_ant_conf.main_lna_conf]); | ||
292 | len += snprintf(buf + len, size - len, "Current ALT config : %s\n", | ||
293 | lna_conf_str[div_ant_conf.alt_lna_conf]); | ||
294 | len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", | ||
295 | as_main->rssi_avg); | ||
296 | len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", | ||
297 | as_alt->rssi_avg); | ||
298 | ath9k_ps_restore(sc); | ||
299 | |||
300 | len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n"); | ||
301 | len += snprintf(buf + len, size - len, "-------------------\n"); | ||
302 | |||
303 | len += snprintf(buf + len, size - len, "%30s%15s\n", | ||
304 | "MAIN", "ALT"); | ||
305 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
306 | "TOTAL COUNT", | ||
307 | as_main->recv_cnt, | ||
308 | as_alt->recv_cnt); | ||
309 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
310 | "LNA1", | ||
311 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], | ||
312 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); | ||
313 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
314 | "LNA2", | ||
315 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], | ||
316 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); | ||
317 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
318 | "LNA1 + LNA2", | ||
319 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], | ||
320 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); | ||
321 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
322 | "LNA1 - LNA2", | ||
323 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], | ||
324 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); | ||
325 | |||
326 | len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); | ||
327 | len += snprintf(buf + len, size - len, "--------------------\n"); | ||
328 | |||
329 | len += snprintf(buf + len, size - len, "%30s%15s\n", | ||
330 | "MAIN", "ALT"); | ||
331 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
332 | "LNA1", | ||
333 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], | ||
334 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); | ||
335 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
336 | "LNA2", | ||
337 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], | ||
338 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); | ||
339 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
340 | "LNA1 + LNA2", | ||
341 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], | ||
342 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); | ||
343 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", | ||
344 | "LNA1 - LNA2", | ||
345 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], | ||
346 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); | ||
347 | |||
348 | exit: | ||
349 | if (len > size) | ||
350 | len = size; | ||
351 | |||
352 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
353 | kfree(buf); | ||
354 | |||
355 | return retval; | ||
356 | } | ||
357 | |||
358 | static const struct file_operations fops_antenna_diversity = { | ||
359 | .read = read_file_antenna_diversity, | ||
319 | .open = simple_open, | 360 | .open = simple_open, |
320 | .owner = THIS_MODULE, | 361 | .owner = THIS_MODULE, |
321 | .llseek = default_llseek, | 362 | .llseek = default_llseek, |
@@ -607,6 +648,28 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | |||
607 | return retval; | 648 | return retval; |
608 | } | 649 | } |
609 | 650 | ||
651 | static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq, | ||
652 | char *buf, ssize_t size) | ||
653 | { | ||
654 | ssize_t len = 0; | ||
655 | |||
656 | ath_txq_lock(sc, txq); | ||
657 | |||
658 | len += snprintf(buf + len, size - len, "%s: %d ", | ||
659 | "qnum", txq->axq_qnum); | ||
660 | len += snprintf(buf + len, size - len, "%s: %2d ", | ||
661 | "qdepth", txq->axq_depth); | ||
662 | len += snprintf(buf + len, size - len, "%s: %2d ", | ||
663 | "ampdu-depth", txq->axq_ampdu_depth); | ||
664 | len += snprintf(buf + len, size - len, "%s: %3d ", | ||
665 | "pending", txq->pending_frames); | ||
666 | len += snprintf(buf + len, size - len, "%s: %d\n", | ||
667 | "stopped", txq->stopped); | ||
668 | |||
669 | ath_txq_unlock(sc, txq); | ||
670 | return len; | ||
671 | } | ||
672 | |||
610 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, | 673 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, |
611 | size_t count, loff_t *ppos) | 674 | size_t count, loff_t *ppos) |
612 | { | 675 | { |
@@ -624,24 +687,13 @@ static ssize_t read_file_queues(struct file *file, char __user *user_buf, | |||
624 | 687 | ||
625 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { | 688 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
626 | txq = sc->tx.txq_map[i]; | 689 | txq = sc->tx.txq_map[i]; |
627 | len += snprintf(buf + len, size - len, "(%s): ", qname[i]); | 690 | len += snprintf(buf + len, size - len, "(%s): ", qname[i]); |
628 | 691 | len += print_queue(sc, txq, buf + len, size - len); | |
629 | ath_txq_lock(sc, txq); | ||
630 | |||
631 | len += snprintf(buf + len, size - len, "%s: %d ", | ||
632 | "qnum", txq->axq_qnum); | ||
633 | len += snprintf(buf + len, size - len, "%s: %2d ", | ||
634 | "qdepth", txq->axq_depth); | ||
635 | len += snprintf(buf + len, size - len, "%s: %2d ", | ||
636 | "ampdu-depth", txq->axq_ampdu_depth); | ||
637 | len += snprintf(buf + len, size - len, "%s: %3d ", | ||
638 | "pending", txq->pending_frames); | ||
639 | len += snprintf(buf + len, size - len, "%s: %d\n", | ||
640 | "stopped", txq->stopped); | ||
641 | |||
642 | ath_txq_unlock(sc, txq); | ||
643 | } | 692 | } |
644 | 693 | ||
694 | len += snprintf(buf + len, size - len, "(CAB): "); | ||
695 | len += print_queue(sc, sc->beacon.cabq, buf + len, size - len); | ||
696 | |||
645 | if (len > size) | 697 | if (len > size) |
646 | len = size; | 698 | len = size; |
647 | 699 | ||
@@ -1589,17 +1641,7 @@ void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, | |||
1589 | struct dentry *dir) | 1641 | struct dentry *dir) |
1590 | { | 1642 | { |
1591 | struct ath_node *an = (struct ath_node *)sta->drv_priv; | 1643 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
1592 | an->node_stat = debugfs_create_file("node_stat", S_IRUGO, | 1644 | debugfs_create_file("node_stat", S_IRUGO, dir, an, &fops_node_stat); |
1593 | dir, an, &fops_node_stat); | ||
1594 | } | ||
1595 | |||
1596 | void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, | ||
1597 | struct ieee80211_vif *vif, | ||
1598 | struct ieee80211_sta *sta, | ||
1599 | struct dentry *dir) | ||
1600 | { | ||
1601 | struct ath_node *an = (struct ath_node *)sta->drv_priv; | ||
1602 | debugfs_remove(an->node_stat); | ||
1603 | } | 1645 | } |
1604 | 1646 | ||
1605 | /* Ethtool support for get-stats */ | 1647 | /* Ethtool support for get-stats */ |
@@ -1770,10 +1812,10 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1770 | &fops_reset); | 1812 | &fops_reset); |
1771 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, | 1813 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
1772 | &fops_recv); | 1814 | &fops_recv); |
1773 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, | 1815 | debugfs_create_u8("rx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
1774 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); | 1816 | &ah->rxchainmask); |
1775 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, | 1817 | debugfs_create_u8("tx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
1776 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); | 1818 | &ah->txchainmask); |
1777 | debugfs_create_file("ani", S_IRUSR | S_IWUSR, | 1819 | debugfs_create_file("ani", S_IRUSR | S_IWUSR, |
1778 | sc->debug.debugfs_phy, sc, &fops_ani); | 1820 | sc->debug.debugfs_phy, sc, &fops_ani); |
1779 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | 1821 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
@@ -1814,9 +1856,11 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1814 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); | 1856 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
1815 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, | 1857 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
1816 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); | 1858 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
1817 | debugfs_create_file("diversity", S_IRUSR | S_IWUSR, | 1859 | debugfs_create_file("antenna_diversity", S_IRUSR, |
1818 | sc->debug.debugfs_phy, sc, &fops_ant_diversity); | 1860 | sc->debug.debugfs_phy, sc, &fops_antenna_diversity); |
1819 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | 1861 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
1862 | debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, | ||
1863 | sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); | ||
1820 | debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, | 1864 | debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, |
1821 | &fops_btcoex); | 1865 | &fops_btcoex); |
1822 | #endif | 1866 | #endif |
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index fc679198a0f3..6e1556fa2f3e 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h | |||
@@ -28,9 +28,13 @@ struct fft_sample_tlv; | |||
28 | #ifdef CONFIG_ATH9K_DEBUGFS | 28 | #ifdef CONFIG_ATH9K_DEBUGFS |
29 | #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ | 29 | #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ |
30 | #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++ | 30 | #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++ |
31 | #define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++ | ||
32 | #define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++; | ||
31 | #else | 33 | #else |
32 | #define TX_STAT_INC(q, c) do { } while (0) | 34 | #define TX_STAT_INC(q, c) do { } while (0) |
33 | #define RESET_STAT_INC(sc, type) do { } while (0) | 35 | #define RESET_STAT_INC(sc, type) do { } while (0) |
36 | #define ANT_STAT_INC(i, c) do { } while (0) | ||
37 | #define ANT_LNA_INC(i, c) do { } while (0) | ||
34 | #endif | 38 | #endif |
35 | 39 | ||
36 | enum ath_reset_type { | 40 | enum ath_reset_type { |
@@ -243,11 +247,22 @@ struct ath_rx_stats { | |||
243 | u32 rx_spectral; | 247 | u32 rx_spectral; |
244 | }; | 248 | }; |
245 | 249 | ||
250 | #define ANT_MAIN 0 | ||
251 | #define ANT_ALT 1 | ||
252 | |||
253 | struct ath_antenna_stats { | ||
254 | u32 recv_cnt; | ||
255 | u32 rssi_avg; | ||
256 | u32 lna_recv_cnt[4]; | ||
257 | u32 lna_attempt_cnt[4]; | ||
258 | }; | ||
259 | |||
246 | struct ath_stats { | 260 | struct ath_stats { |
247 | struct ath_interrupt_stats istats; | 261 | struct ath_interrupt_stats istats; |
248 | struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; | 262 | struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; |
249 | struct ath_rx_stats rxstats; | 263 | struct ath_rx_stats rxstats; |
250 | struct ath_dfs_stats dfs_stats; | 264 | struct ath_dfs_stats dfs_stats; |
265 | struct ath_antenna_stats ant_stats[2]; | ||
251 | u32 reset[__RESET_TYPE_MAX]; | 266 | u32 reset[__RESET_TYPE_MAX]; |
252 | }; | 267 | }; |
253 | 268 | ||
@@ -277,14 +292,11 @@ void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, | |||
277 | struct ieee80211_vif *vif, | 292 | struct ieee80211_vif *vif, |
278 | struct ieee80211_sta *sta, | 293 | struct ieee80211_sta *sta, |
279 | struct dentry *dir); | 294 | struct dentry *dir); |
280 | void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, | ||
281 | struct ieee80211_vif *vif, | ||
282 | struct ieee80211_sta *sta, | ||
283 | struct dentry *dir); | ||
284 | |||
285 | void ath_debug_send_fft_sample(struct ath_softc *sc, | 295 | void ath_debug_send_fft_sample(struct ath_softc *sc, |
286 | struct fft_sample_tlv *fft_sample); | 296 | struct fft_sample_tlv *fft_sample); |
287 | 297 | void ath9k_debug_stat_ant(struct ath_softc *sc, | |
298 | struct ath_hw_antcomb_conf *div_ant_conf, | ||
299 | int main_rssi_avg, int alt_rssi_avg); | ||
288 | #else | 300 | #else |
289 | 301 | ||
290 | #define RX_STAT_INC(c) /* NOP */ | 302 | #define RX_STAT_INC(c) /* NOP */ |
@@ -297,12 +309,10 @@ static inline int ath9k_init_debug(struct ath_hw *ah) | |||
297 | static inline void ath9k_deinit_debug(struct ath_softc *sc) | 309 | static inline void ath9k_deinit_debug(struct ath_softc *sc) |
298 | { | 310 | { |
299 | } | 311 | } |
300 | |||
301 | static inline void ath_debug_stat_interrupt(struct ath_softc *sc, | 312 | static inline void ath_debug_stat_interrupt(struct ath_softc *sc, |
302 | enum ath9k_int status) | 313 | enum ath9k_int status) |
303 | { | 314 | { |
304 | } | 315 | } |
305 | |||
306 | static inline void ath_debug_stat_tx(struct ath_softc *sc, | 316 | static inline void ath_debug_stat_tx(struct ath_softc *sc, |
307 | struct ath_buf *bf, | 317 | struct ath_buf *bf, |
308 | struct ath_tx_status *ts, | 318 | struct ath_tx_status *ts, |
@@ -310,11 +320,16 @@ static inline void ath_debug_stat_tx(struct ath_softc *sc, | |||
310 | unsigned int flags) | 320 | unsigned int flags) |
311 | { | 321 | { |
312 | } | 322 | } |
313 | |||
314 | static inline void ath_debug_stat_rx(struct ath_softc *sc, | 323 | static inline void ath_debug_stat_rx(struct ath_softc *sc, |
315 | struct ath_rx_status *rs) | 324 | struct ath_rx_status *rs) |
316 | { | 325 | { |
317 | } | 326 | } |
327 | static inline void ath9k_debug_stat_ant(struct ath_softc *sc, | ||
328 | struct ath_hw_antcomb_conf *div_ant_conf, | ||
329 | int main_rssi_avg, int alt_rssi_avg) | ||
330 | { | ||
331 | |||
332 | } | ||
318 | 333 | ||
319 | #endif /* CONFIG_ATH9K_DEBUGFS */ | 334 | #endif /* CONFIG_ATH9K_DEBUGFS */ |
320 | 335 | ||
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c index c2bfd748eed8..9ea8e4b779c9 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c | |||
@@ -812,6 +812,7 @@ static void ath9k_hw_4k_set_gain(struct ath_hw *ah, | |||
812 | static void ath9k_hw_4k_set_board_values(struct ath_hw *ah, | 812 | static void ath9k_hw_4k_set_board_values(struct ath_hw *ah, |
813 | struct ath9k_channel *chan) | 813 | struct ath9k_channel *chan) |
814 | { | 814 | { |
815 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
815 | struct modal_eep_4k_header *pModal; | 816 | struct modal_eep_4k_header *pModal; |
816 | struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k; | 817 | struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k; |
817 | struct base_eep_header_4k *pBase = &eep->baseEepHeader; | 818 | struct base_eep_header_4k *pBase = &eep->baseEepHeader; |
@@ -858,6 +859,24 @@ static void ath9k_hw_4k_set_board_values(struct ath_hw *ah, | |||
858 | 859 | ||
859 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regVal); | 860 | REG_WRITE(ah, AR_PHY_CCK_DETECT, regVal); |
860 | regVal = REG_READ(ah, AR_PHY_CCK_DETECT); | 861 | regVal = REG_READ(ah, AR_PHY_CCK_DETECT); |
862 | |||
863 | if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { | ||
864 | /* | ||
865 | * If diversity combining is enabled, | ||
866 | * set MAIN to LNA1 and ALT to LNA2 initially. | ||
867 | */ | ||
868 | regVal = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); | ||
869 | regVal &= (~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF | | ||
870 | AR_PHY_9285_ANT_DIV_ALT_LNACONF)); | ||
871 | |||
872 | regVal |= (ATH_ANT_DIV_COMB_LNA1 << | ||
873 | AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S); | ||
874 | regVal |= (ATH_ANT_DIV_COMB_LNA2 << | ||
875 | AR_PHY_9285_ANT_DIV_ALT_LNACONF_S); | ||
876 | regVal &= (~(AR_PHY_9285_FAST_DIV_BIAS)); | ||
877 | regVal |= (0 << AR_PHY_9285_FAST_DIV_BIAS_S); | ||
878 | REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regVal); | ||
879 | } | ||
861 | } | 880 | } |
862 | 881 | ||
863 | if (pModal->version >= 2) { | 882 | if (pModal->version >= 2) { |
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index 9e582e14da74..6d5d716adc1b 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c | |||
@@ -115,10 +115,10 @@ static int hif_usb_send_regout(struct hif_device_usb *hif_dev, | |||
115 | cmd->skb = skb; | 115 | cmd->skb = skb; |
116 | cmd->hif_dev = hif_dev; | 116 | cmd->hif_dev = hif_dev; |
117 | 117 | ||
118 | usb_fill_bulk_urb(urb, hif_dev->udev, | 118 | usb_fill_int_urb(urb, hif_dev->udev, |
119 | usb_sndbulkpipe(hif_dev->udev, USB_REG_OUT_PIPE), | 119 | usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE), |
120 | skb->data, skb->len, | 120 | skb->data, skb->len, |
121 | hif_usb_regout_cb, cmd); | 121 | hif_usb_regout_cb, cmd, 1); |
122 | 122 | ||
123 | usb_anchor_urb(urb, &hif_dev->regout_submitted); | 123 | usb_anchor_urb(urb, &hif_dev->regout_submitted); |
124 | ret = usb_submit_urb(urb, GFP_KERNEL); | 124 | ret = usb_submit_urb(urb, GFP_KERNEL); |
@@ -723,11 +723,11 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb) | |||
723 | return; | 723 | return; |
724 | } | 724 | } |
725 | 725 | ||
726 | usb_fill_bulk_urb(urb, hif_dev->udev, | 726 | usb_fill_int_urb(urb, hif_dev->udev, |
727 | usb_rcvbulkpipe(hif_dev->udev, | 727 | usb_rcvintpipe(hif_dev->udev, |
728 | USB_REG_IN_PIPE), | 728 | USB_REG_IN_PIPE), |
729 | nskb->data, MAX_REG_IN_BUF_SIZE, | 729 | nskb->data, MAX_REG_IN_BUF_SIZE, |
730 | ath9k_hif_usb_reg_in_cb, nskb); | 730 | ath9k_hif_usb_reg_in_cb, nskb, 1); |
731 | } | 731 | } |
732 | 732 | ||
733 | resubmit: | 733 | resubmit: |
@@ -909,11 +909,11 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev) | |||
909 | goto err_skb; | 909 | goto err_skb; |
910 | } | 910 | } |
911 | 911 | ||
912 | usb_fill_bulk_urb(urb, hif_dev->udev, | 912 | usb_fill_int_urb(urb, hif_dev->udev, |
913 | usb_rcvbulkpipe(hif_dev->udev, | 913 | usb_rcvintpipe(hif_dev->udev, |
914 | USB_REG_IN_PIPE), | 914 | USB_REG_IN_PIPE), |
915 | skb->data, MAX_REG_IN_BUF_SIZE, | 915 | skb->data, MAX_REG_IN_BUF_SIZE, |
916 | ath9k_hif_usb_reg_in_cb, skb); | 916 | ath9k_hif_usb_reg_in_cb, skb, 1); |
917 | 917 | ||
918 | /* Anchor URB */ | 918 | /* Anchor URB */ |
919 | usb_anchor_urb(urb, &hif_dev->reg_in_submitted); | 919 | usb_anchor_urb(urb, &hif_dev->reg_in_submitted); |
@@ -1031,9 +1031,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) | |||
1031 | 1031 | ||
1032 | static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev) | 1032 | static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev) |
1033 | { | 1033 | { |
1034 | struct usb_host_interface *alt = &hif_dev->interface->altsetting[0]; | 1034 | int ret; |
1035 | struct usb_endpoint_descriptor *endp; | ||
1036 | int ret, idx; | ||
1037 | 1035 | ||
1038 | ret = ath9k_hif_usb_download_fw(hif_dev); | 1036 | ret = ath9k_hif_usb_download_fw(hif_dev); |
1039 | if (ret) { | 1037 | if (ret) { |
@@ -1043,20 +1041,6 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev) | |||
1043 | return ret; | 1041 | return ret; |
1044 | } | 1042 | } |
1045 | 1043 | ||
1046 | /* On downloading the firmware to the target, the USB descriptor of EP4 | ||
1047 | * is 'patched' to change the type of the endpoint to Bulk. This will | ||
1048 | * bring down CPU usage during the scan period. | ||
1049 | */ | ||
1050 | for (idx = 0; idx < alt->desc.bNumEndpoints; idx++) { | ||
1051 | endp = &alt->endpoint[idx].desc; | ||
1052 | if ((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
1053 | == USB_ENDPOINT_XFER_INT) { | ||
1054 | endp->bmAttributes &= ~USB_ENDPOINT_XFERTYPE_MASK; | ||
1055 | endp->bmAttributes |= USB_ENDPOINT_XFER_BULK; | ||
1056 | endp->bInterval = 0; | ||
1057 | } | ||
1058 | } | ||
1059 | |||
1060 | /* Alloc URBs */ | 1044 | /* Alloc URBs */ |
1061 | ret = ath9k_hif_usb_alloc_urbs(hif_dev); | 1045 | ret = ath9k_hif_usb_alloc_urbs(hif_dev); |
1062 | if (ret) { | 1046 | if (ret) { |
@@ -1082,7 +1066,7 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev) | |||
1082 | struct device *dev = &hif_dev->udev->dev; | 1066 | struct device *dev = &hif_dev->udev->dev; |
1083 | struct device *parent = dev->parent; | 1067 | struct device *parent = dev->parent; |
1084 | 1068 | ||
1085 | complete(&hif_dev->fw_done); | 1069 | complete_all(&hif_dev->fw_done); |
1086 | 1070 | ||
1087 | if (parent) | 1071 | if (parent) |
1088 | device_lock(parent); | 1072 | device_lock(parent); |
@@ -1131,7 +1115,7 @@ static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context) | |||
1131 | 1115 | ||
1132 | release_firmware(fw); | 1116 | release_firmware(fw); |
1133 | hif_dev->flags |= HIF_USB_READY; | 1117 | hif_dev->flags |= HIF_USB_READY; |
1134 | complete(&hif_dev->fw_done); | 1118 | complete_all(&hif_dev->fw_done); |
1135 | 1119 | ||
1136 | return; | 1120 | return; |
1137 | 1121 | ||
@@ -1268,7 +1252,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev) | |||
1268 | if (!buf) | 1252 | if (!buf) |
1269 | return; | 1253 | return; |
1270 | 1254 | ||
1271 | ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE), | 1255 | ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE), |
1272 | buf, 4, NULL, HZ); | 1256 | buf, 4, NULL, HZ); |
1273 | if (ret) | 1257 | if (ret) |
1274 | dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n"); | 1258 | dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n"); |
@@ -1295,7 +1279,9 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface) | |||
1295 | 1279 | ||
1296 | usb_set_intfdata(interface, NULL); | 1280 | usb_set_intfdata(interface, NULL); |
1297 | 1281 | ||
1298 | if (!unplugged && (hif_dev->flags & HIF_USB_START)) | 1282 | /* If firmware was loaded we should drop it |
1283 | * go back to first stage bootloader. */ | ||
1284 | if (!unplugged && (hif_dev->flags & HIF_USB_READY)) | ||
1299 | ath9k_hif_usb_reboot(udev); | 1285 | ath9k_hif_usb_reboot(udev); |
1300 | 1286 | ||
1301 | kfree(hif_dev); | 1287 | kfree(hif_dev); |
@@ -1316,7 +1302,10 @@ static int ath9k_hif_usb_suspend(struct usb_interface *interface, | |||
1316 | if (!(hif_dev->flags & HIF_USB_START)) | 1302 | if (!(hif_dev->flags & HIF_USB_START)) |
1317 | ath9k_htc_suspend(hif_dev->htc_handle); | 1303 | ath9k_htc_suspend(hif_dev->htc_handle); |
1318 | 1304 | ||
1319 | ath9k_hif_usb_dealloc_urbs(hif_dev); | 1305 | wait_for_completion(&hif_dev->fw_done); |
1306 | |||
1307 | if (hif_dev->flags & HIF_USB_READY) | ||
1308 | ath9k_hif_usb_dealloc_urbs(hif_dev); | ||
1320 | 1309 | ||
1321 | return 0; | 1310 | return 0; |
1322 | } | 1311 | } |
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index 71a183ffc77f..c3676bf1d6c4 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c | |||
@@ -861,6 +861,7 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv, | |||
861 | if (error != 0) | 861 | if (error != 0) |
862 | goto err_rx; | 862 | goto err_rx; |
863 | 863 | ||
864 | ath9k_hw_disable(priv->ah); | ||
864 | #ifdef CONFIG_MAC80211_LEDS | 865 | #ifdef CONFIG_MAC80211_LEDS |
865 | /* must be initialized before ieee80211_register_hw */ | 866 | /* must be initialized before ieee80211_register_hw */ |
866 | priv->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(priv->hw, | 867 | priv->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(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 5c1bec18c9e3..d44258172c0f 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c | |||
@@ -1203,16 +1203,13 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed) | |||
1203 | 1203 | ||
1204 | if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) { | 1204 | if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) { |
1205 | struct ieee80211_channel *curchan = hw->conf.chandef.chan; | 1205 | struct ieee80211_channel *curchan = hw->conf.chandef.chan; |
1206 | enum nl80211_channel_type channel_type = | ||
1207 | cfg80211_get_chandef_type(&hw->conf.chandef); | ||
1208 | int pos = curchan->hw_value; | 1206 | int pos = curchan->hw_value; |
1209 | 1207 | ||
1210 | ath_dbg(common, CONFIG, "Set channel: %d MHz\n", | 1208 | ath_dbg(common, CONFIG, "Set channel: %d MHz\n", |
1211 | curchan->center_freq); | 1209 | curchan->center_freq); |
1212 | 1210 | ||
1213 | ath9k_cmn_update_ichannel(&priv->ah->channels[pos], | 1211 | ath9k_cmn_update_ichannel(&priv->ah->channels[pos], |
1214 | hw->conf.chandef.chan, | 1212 | &hw->conf.chandef); |
1215 | channel_type); | ||
1216 | 1213 | ||
1217 | if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { | 1214 | if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { |
1218 | ath_err(common, "Unable to set channel\n"); | 1215 | ath_err(common, "Unable to set channel\n"); |
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c index e602c9519709..c028df76b564 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | |||
@@ -448,6 +448,7 @@ static void ath9k_htc_tx_process(struct ath9k_htc_priv *priv, | |||
448 | struct ieee80211_conf *cur_conf = &priv->hw->conf; | 448 | struct ieee80211_conf *cur_conf = &priv->hw->conf; |
449 | bool txok; | 449 | bool txok; |
450 | int slot; | 450 | int slot; |
451 | int hdrlen, padsize; | ||
451 | 452 | ||
452 | slot = strip_drv_header(priv, skb); | 453 | slot = strip_drv_header(priv, skb); |
453 | if (slot < 0) { | 454 | if (slot < 0) { |
@@ -504,6 +505,15 @@ send_mac80211: | |||
504 | 505 | ||
505 | ath9k_htc_tx_clear_slot(priv, slot); | 506 | ath9k_htc_tx_clear_slot(priv, slot); |
506 | 507 | ||
508 | /* Remove padding before handing frame back to mac80211 */ | ||
509 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | ||
510 | |||
511 | padsize = hdrlen & 3; | ||
512 | if (padsize && skb->len > hdrlen + padsize) { | ||
513 | memmove(skb->data + padsize, skb->data, hdrlen); | ||
514 | skb_pull(skb, padsize); | ||
515 | } | ||
516 | |||
507 | /* Send status to mac80211 */ | 517 | /* Send status to mac80211 */ |
508 | ieee80211_tx_status(priv->hw, skb); | 518 | ieee80211_tx_status(priv->hw, skb); |
509 | } | 519 | } |
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h index 14b701140b49..83f4927aeaca 100644 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h | |||
@@ -78,13 +78,16 @@ static inline void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah, | |||
78 | ath9k_hw_ops(ah)->antdiv_comb_conf_set(ah, antconf); | 78 | ath9k_hw_ops(ah)->antdiv_comb_conf_set(ah, antconf); |
79 | } | 79 | } |
80 | 80 | ||
81 | static inline void ath9k_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah, | 81 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
82 | bool enable) | 82 | |
83 | static inline void ath9k_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) | ||
83 | { | 84 | { |
84 | if (ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv) | 85 | if (ath9k_hw_ops(ah)->set_bt_ant_diversity) |
85 | ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv(ah, enable); | 86 | ath9k_hw_ops(ah)->set_bt_ant_diversity(ah, enable); |
86 | } | 87 | } |
87 | 88 | ||
89 | #endif | ||
90 | |||
88 | /* Private hardware call ops */ | 91 | /* Private hardware call ops */ |
89 | 92 | ||
90 | /* PHY ops */ | 93 | /* PHY ops */ |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 4ca0cb060106..2670bf6cb066 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -450,7 +450,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah) | |||
450 | ah->config.ack_6mb = 0x0; | 450 | ah->config.ack_6mb = 0x0; |
451 | ah->config.cwm_ignore_extcca = 0; | 451 | ah->config.cwm_ignore_extcca = 0; |
452 | ah->config.pcie_clock_req = 0; | 452 | ah->config.pcie_clock_req = 0; |
453 | ah->config.pcie_waen = 0; | ||
454 | ah->config.analog_shiftreg = 1; | 453 | ah->config.analog_shiftreg = 1; |
455 | 454 | ||
456 | for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { | 455 | for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { |
@@ -1069,7 +1068,7 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah) | |||
1069 | if (IS_CHAN_A_FAST_CLOCK(ah, chan)) | 1068 | if (IS_CHAN_A_FAST_CLOCK(ah, chan)) |
1070 | tx_lat += 11; | 1069 | tx_lat += 11; |
1071 | 1070 | ||
1072 | sifstime *= 2; | 1071 | sifstime = 32; |
1073 | ack_offset = 16; | 1072 | ack_offset = 16; |
1074 | slottime = 13; | 1073 | slottime = 13; |
1075 | } else if (IS_CHAN_QUARTER_RATE(chan)) { | 1074 | } else if (IS_CHAN_QUARTER_RATE(chan)) { |
@@ -1079,7 +1078,7 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah) | |||
1079 | if (IS_CHAN_A_FAST_CLOCK(ah, chan)) | 1078 | if (IS_CHAN_A_FAST_CLOCK(ah, chan)) |
1080 | tx_lat += 22; | 1079 | tx_lat += 22; |
1081 | 1080 | ||
1082 | sifstime *= 4; | 1081 | sifstime = 64; |
1083 | ack_offset = 32; | 1082 | ack_offset = 32; |
1084 | slottime = 21; | 1083 | slottime = 21; |
1085 | } else { | 1084 | } else { |
@@ -1116,7 +1115,6 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah) | |||
1116 | ctstimeout += 48 - sifstime - ah->slottime; | 1115 | ctstimeout += 48 - sifstime - ah->slottime; |
1117 | } | 1116 | } |
1118 | 1117 | ||
1119 | |||
1120 | ath9k_hw_set_sifs_time(ah, sifstime); | 1118 | ath9k_hw_set_sifs_time(ah, sifstime); |
1121 | ath9k_hw_setslottime(ah, slottime); | 1119 | ath9k_hw_setslottime(ah, slottime); |
1122 | ath9k_hw_set_ack_timeout(ah, acktimeout); | 1120 | ath9k_hw_set_ack_timeout(ah, acktimeout); |
@@ -1496,16 +1494,18 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1496 | struct ath9k_channel *chan) | 1494 | struct ath9k_channel *chan) |
1497 | { | 1495 | { |
1498 | struct ath_common *common = ath9k_hw_common(ah); | 1496 | struct ath_common *common = ath9k_hw_common(ah); |
1497 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
1498 | bool band_switch = false, mode_diff = false; | ||
1499 | u8 ini_reloaded = 0; | ||
1499 | u32 qnum; | 1500 | u32 qnum; |
1500 | int r; | 1501 | int r; |
1501 | bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); | ||
1502 | bool band_switch, mode_diff; | ||
1503 | u8 ini_reloaded; | ||
1504 | 1502 | ||
1505 | band_switch = (chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ)) != | 1503 | if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) { |
1506 | (ah->curchan->channelFlags & (CHANNEL_2GHZ | | 1504 | u32 cur = ah->curchan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ); |
1507 | CHANNEL_5GHZ)); | 1505 | u32 new = chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ); |
1508 | mode_diff = (chan->chanmode != ah->curchan->chanmode); | 1506 | band_switch = (cur != new); |
1507 | mode_diff = (chan->chanmode != ah->curchan->chanmode); | ||
1508 | } | ||
1509 | 1509 | ||
1510 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { | 1510 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { |
1511 | if (ath9k_hw_numtxpending(ah, qnum)) { | 1511 | if (ath9k_hw_numtxpending(ah, qnum)) { |
@@ -1520,11 +1520,12 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1520 | return false; | 1520 | return false; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | if (edma && (band_switch || mode_diff)) { | 1523 | if (band_switch || mode_diff) { |
1524 | ath9k_hw_mark_phy_inactive(ah); | 1524 | ath9k_hw_mark_phy_inactive(ah); |
1525 | udelay(5); | 1525 | udelay(5); |
1526 | 1526 | ||
1527 | ath9k_hw_init_pll(ah, NULL); | 1527 | if (band_switch) |
1528 | ath9k_hw_init_pll(ah, chan); | ||
1528 | 1529 | ||
1529 | if (ath9k_hw_fast_chan_change(ah, chan, &ini_reloaded)) { | 1530 | if (ath9k_hw_fast_chan_change(ah, chan, &ini_reloaded)) { |
1530 | ath_err(common, "Failed to do fast channel change\n"); | 1531 | ath_err(common, "Failed to do fast channel change\n"); |
@@ -1541,22 +1542,21 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1541 | } | 1542 | } |
1542 | ath9k_hw_set_clockrate(ah); | 1543 | ath9k_hw_set_clockrate(ah); |
1543 | ath9k_hw_apply_txpower(ah, chan, false); | 1544 | ath9k_hw_apply_txpower(ah, chan, false); |
1544 | ath9k_hw_rfbus_done(ah); | ||
1545 | 1545 | ||
1546 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) | 1546 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
1547 | ath9k_hw_set_delta_slope(ah, chan); | 1547 | ath9k_hw_set_delta_slope(ah, chan); |
1548 | 1548 | ||
1549 | ath9k_hw_spur_mitigate_freq(ah, chan); | 1549 | ath9k_hw_spur_mitigate_freq(ah, chan); |
1550 | 1550 | ||
1551 | if (edma && (band_switch || mode_diff)) { | 1551 | if (band_switch || ini_reloaded) |
1552 | ah->ah_flags |= AH_FASTCC; | 1552 | ah->eep_ops->set_board_values(ah, chan); |
1553 | if (band_switch || ini_reloaded) | ||
1554 | ah->eep_ops->set_board_values(ah, chan); | ||
1555 | 1553 | ||
1556 | ath9k_hw_init_bb(ah, chan); | 1554 | ath9k_hw_init_bb(ah, chan); |
1555 | ath9k_hw_rfbus_done(ah); | ||
1557 | 1556 | ||
1558 | if (band_switch || ini_reloaded) | 1557 | if (band_switch || ini_reloaded) { |
1559 | ath9k_hw_init_cal(ah, chan); | 1558 | ah->ah_flags |= AH_FASTCC; |
1559 | ath9k_hw_init_cal(ah, chan); | ||
1560 | ah->ah_flags &= ~AH_FASTCC; | 1560 | ah->ah_flags &= ~AH_FASTCC; |
1561 | } | 1561 | } |
1562 | 1562 | ||
@@ -1778,16 +1778,11 @@ static void ath9k_hw_init_desc(struct ath_hw *ah) | |||
1778 | /* | 1778 | /* |
1779 | * Fast channel change: | 1779 | * Fast channel change: |
1780 | * (Change synthesizer based on channel freq without resetting chip) | 1780 | * (Change synthesizer based on channel freq without resetting chip) |
1781 | * | ||
1782 | * Don't do FCC when | ||
1783 | * - Flag is not set | ||
1784 | * - Chip is just coming out of full sleep | ||
1785 | * - Channel to be set is same as current channel | ||
1786 | * - Channel flags are different, (eg.,moving from 2GHz to 5GHz channel) | ||
1787 | */ | 1781 | */ |
1788 | static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) | 1782 | static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) |
1789 | { | 1783 | { |
1790 | struct ath_common *common = ath9k_hw_common(ah); | 1784 | struct ath_common *common = ath9k_hw_common(ah); |
1785 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
1791 | int ret; | 1786 | int ret; |
1792 | 1787 | ||
1793 | if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI) | 1788 | if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI) |
@@ -1806,9 +1801,21 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) | |||
1806 | (CHANNEL_HALF | CHANNEL_QUARTER)) | 1801 | (CHANNEL_HALF | CHANNEL_QUARTER)) |
1807 | goto fail; | 1802 | goto fail; |
1808 | 1803 | ||
1809 | if ((chan->channelFlags & CHANNEL_ALL) != | 1804 | /* |
1810 | (ah->curchan->channelFlags & CHANNEL_ALL)) | 1805 | * If cross-band fcc is not supoprted, bail out if |
1811 | goto fail; | 1806 | * either channelFlags or chanmode differ. |
1807 | * | ||
1808 | * chanmode will be different if the HT operating mode | ||
1809 | * changes because of CSA. | ||
1810 | */ | ||
1811 | if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH)) { | ||
1812 | if ((chan->channelFlags & CHANNEL_ALL) != | ||
1813 | (ah->curchan->channelFlags & CHANNEL_ALL)) | ||
1814 | goto fail; | ||
1815 | |||
1816 | if (chan->chanmode != ah->curchan->chanmode) | ||
1817 | goto fail; | ||
1818 | } | ||
1812 | 1819 | ||
1813 | if (!ath9k_hw_check_alive(ah)) | 1820 | if (!ath9k_hw_check_alive(ah)) |
1814 | goto fail; | 1821 | goto fail; |
@@ -2047,7 +2054,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2047 | 2054 | ||
2048 | ath9k_hw_apply_gpio_override(ah); | 2055 | ath9k_hw_apply_gpio_override(ah); |
2049 | 2056 | ||
2050 | if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv) | 2057 | if (AR_SREV_9565(ah) && common->bt_ant_diversity) |
2051 | REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON); | 2058 | REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON); |
2052 | 2059 | ||
2053 | return 0; | 2060 | return 0; |
@@ -2504,7 +2511,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
2504 | else | 2511 | else |
2505 | pCap->rts_aggr_limit = (8 * 1024); | 2512 | pCap->rts_aggr_limit = (8 * 1024); |
2506 | 2513 | ||
2507 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | 2514 | #ifdef CONFIG_ATH9K_RFKILL |
2508 | ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT); | 2515 | ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT); |
2509 | if (ah->rfsilent & EEP_RFSILENT_ENABLED) { | 2516 | if (ah->rfsilent & EEP_RFSILENT_ENABLED) { |
2510 | ah->rfkill_gpio = | 2517 | ah->rfkill_gpio = |
@@ -2550,34 +2557,28 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
2550 | if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah)) | 2557 | if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah)) |
2551 | pCap->hw_caps |= ATH9K_HW_CAP_SGI_20; | 2558 | pCap->hw_caps |= ATH9K_HW_CAP_SGI_20; |
2552 | 2559 | ||
2553 | if (AR_SREV_9285(ah)) | 2560 | if (AR_SREV_9285(ah)) { |
2554 | if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) { | 2561 | if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) { |
2555 | ant_div_ctl1 = | 2562 | ant_div_ctl1 = |
2556 | ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); | 2563 | ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); |
2557 | if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) | 2564 | if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) { |
2558 | pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB; | 2565 | pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB; |
2566 | ath_info(common, "Enable LNA combining\n"); | ||
2567 | } | ||
2559 | } | 2568 | } |
2569 | } | ||
2570 | |||
2560 | if (AR_SREV_9300_20_OR_LATER(ah)) { | 2571 | if (AR_SREV_9300_20_OR_LATER(ah)) { |
2561 | if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE)) | 2572 | if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE)) |
2562 | pCap->hw_caps |= ATH9K_HW_CAP_APM; | 2573 | pCap->hw_caps |= ATH9K_HW_CAP_APM; |
2563 | } | 2574 | } |
2564 | 2575 | ||
2565 | |||
2566 | if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) { | 2576 | if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) { |
2567 | ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); | 2577 | ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); |
2568 | /* | 2578 | if ((ant_div_ctl1 >> 0x6) == 0x3) { |
2569 | * enable the diversity-combining algorithm only when | ||
2570 | * both enable_lna_div and enable_fast_div are set | ||
2571 | * Table for Diversity | ||
2572 | * ant_div_alt_lnaconf bit 0-1 | ||
2573 | * ant_div_main_lnaconf bit 2-3 | ||
2574 | * ant_div_alt_gaintb bit 4 | ||
2575 | * ant_div_main_gaintb bit 5 | ||
2576 | * enable_ant_div_lnadiv bit 6 | ||
2577 | * enable_ant_fast_div bit 7 | ||
2578 | */ | ||
2579 | if ((ant_div_ctl1 >> 0x6) == 0x3) | ||
2580 | pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB; | 2579 | pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB; |
2580 | ath_info(common, "Enable LNA combining\n"); | ||
2581 | } | ||
2581 | } | 2582 | } |
2582 | 2583 | ||
2583 | if (ath9k_hw_dfs_tested(ah)) | 2584 | if (ath9k_hw_dfs_tested(ah)) |
@@ -2610,6 +2611,13 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
2610 | ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) | 2611 | ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) |
2611 | pCap->hw_caps |= ATH9K_HW_CAP_PAPRD; | 2612 | pCap->hw_caps |= ATH9K_HW_CAP_PAPRD; |
2612 | 2613 | ||
2614 | /* | ||
2615 | * Fast channel change across bands is available | ||
2616 | * only for AR9462 and AR9565. | ||
2617 | */ | ||
2618 | if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) | ||
2619 | pCap->hw_caps |= ATH9K_HW_CAP_FCC_BAND_SWITCH; | ||
2620 | |||
2613 | return 0; | 2621 | return 0; |
2614 | } | 2622 | } |
2615 | 2623 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index cd74b3afef7d..69a907b55a73 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h | |||
@@ -247,6 +247,8 @@ enum ath9k_hw_caps { | |||
247 | ATH9K_HW_CAP_DFS = BIT(16), | 247 | ATH9K_HW_CAP_DFS = BIT(16), |
248 | ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(17), | 248 | ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(17), |
249 | ATH9K_HW_CAP_PAPRD = BIT(18), | 249 | ATH9K_HW_CAP_PAPRD = BIT(18), |
250 | ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(19), | ||
251 | ATH9K_HW_CAP_BT_ANT_DIV = BIT(20), | ||
250 | }; | 252 | }; |
251 | 253 | ||
252 | /* | 254 | /* |
@@ -309,8 +311,11 @@ struct ath9k_ops_config { | |||
309 | u16 ani_poll_interval; /* ANI poll interval in ms */ | 311 | u16 ani_poll_interval; /* ANI poll interval in ms */ |
310 | 312 | ||
311 | /* Platform specific config */ | 313 | /* Platform specific config */ |
314 | u32 aspm_l1_fix; | ||
312 | u32 xlna_gpio; | 315 | u32 xlna_gpio; |
316 | u32 ant_ctrl_comm2g_switch_enable; | ||
313 | bool xatten_margin_cfg; | 317 | bool xatten_margin_cfg; |
318 | bool alt_mingainidx; | ||
314 | }; | 319 | }; |
315 | 320 | ||
316 | enum ath9k_int { | 321 | enum ath9k_int { |
@@ -716,11 +721,14 @@ struct ath_hw_ops { | |||
716 | struct ath_hw_antcomb_conf *antconf); | 721 | struct ath_hw_antcomb_conf *antconf); |
717 | void (*antdiv_comb_conf_set)(struct ath_hw *ah, | 722 | void (*antdiv_comb_conf_set)(struct ath_hw *ah, |
718 | struct ath_hw_antcomb_conf *antconf); | 723 | struct ath_hw_antcomb_conf *antconf); |
719 | void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable); | ||
720 | void (*spectral_scan_config)(struct ath_hw *ah, | 724 | void (*spectral_scan_config)(struct ath_hw *ah, |
721 | struct ath_spec_scan *param); | 725 | struct ath_spec_scan *param); |
722 | void (*spectral_scan_trigger)(struct ath_hw *ah); | 726 | void (*spectral_scan_trigger)(struct ath_hw *ah); |
723 | void (*spectral_scan_wait)(struct ath_hw *ah); | 727 | void (*spectral_scan_wait)(struct ath_hw *ah); |
728 | |||
729 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | ||
730 | void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable); | ||
731 | #endif | ||
724 | }; | 732 | }; |
725 | 733 | ||
726 | struct ath_nf_limits { | 734 | struct ath_nf_limits { |
@@ -765,7 +773,6 @@ struct ath_hw { | |||
765 | bool aspm_enabled; | 773 | bool aspm_enabled; |
766 | bool is_monitoring; | 774 | bool is_monitoring; |
767 | bool need_an_top2_fixup; | 775 | bool need_an_top2_fixup; |
768 | bool shared_chain_lnadiv; | ||
769 | u16 tx_trig_level; | 776 | u16 tx_trig_level; |
770 | 777 | ||
771 | u32 nf_regs[6]; | 778 | u32 nf_regs[6]; |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 16f8b201642b..9a1f349f9260 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -53,9 +53,9 @@ static int ath9k_btcoex_enable; | |||
53 | module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444); | 53 | module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444); |
54 | MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); | 54 | MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); |
55 | 55 | ||
56 | static int ath9k_enable_diversity; | 56 | static int ath9k_bt_ant_diversity; |
57 | module_param_named(enable_diversity, ath9k_enable_diversity, int, 0444); | 57 | module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444); |
58 | MODULE_PARM_DESC(enable_diversity, "Enable Antenna diversity for AR9565"); | 58 | MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity"); |
59 | 59 | ||
60 | bool is_ath9k_unloaded; | 60 | bool is_ath9k_unloaded; |
61 | /* We use the hw_value as an index into our private channel structure */ | 61 | /* We use the hw_value as an index into our private channel structure */ |
@@ -146,14 +146,22 @@ static struct ieee80211_rate ath9k_legacy_rates[] = { | |||
146 | RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), | 146 | RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), |
147 | RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), | 147 | RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), |
148 | RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), | 148 | RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), |
149 | RATE(60, 0x0b, 0), | 149 | RATE(60, 0x0b, (IEEE80211_RATE_SUPPORTS_5MHZ | |
150 | RATE(90, 0x0f, 0), | 150 | IEEE80211_RATE_SUPPORTS_10MHZ)), |
151 | RATE(120, 0x0a, 0), | 151 | RATE(90, 0x0f, (IEEE80211_RATE_SUPPORTS_5MHZ | |
152 | RATE(180, 0x0e, 0), | 152 | IEEE80211_RATE_SUPPORTS_10MHZ)), |
153 | RATE(240, 0x09, 0), | 153 | RATE(120, 0x0a, (IEEE80211_RATE_SUPPORTS_5MHZ | |
154 | RATE(360, 0x0d, 0), | 154 | IEEE80211_RATE_SUPPORTS_10MHZ)), |
155 | RATE(480, 0x08, 0), | 155 | RATE(180, 0x0e, (IEEE80211_RATE_SUPPORTS_5MHZ | |
156 | RATE(540, 0x0c, 0), | 156 | IEEE80211_RATE_SUPPORTS_10MHZ)), |
157 | RATE(240, 0x09, (IEEE80211_RATE_SUPPORTS_5MHZ | | ||
158 | IEEE80211_RATE_SUPPORTS_10MHZ)), | ||
159 | RATE(360, 0x0d, (IEEE80211_RATE_SUPPORTS_5MHZ | | ||
160 | IEEE80211_RATE_SUPPORTS_10MHZ)), | ||
161 | RATE(480, 0x08, (IEEE80211_RATE_SUPPORTS_5MHZ | | ||
162 | IEEE80211_RATE_SUPPORTS_10MHZ)), | ||
163 | RATE(540, 0x0c, (IEEE80211_RATE_SUPPORTS_5MHZ | | ||
164 | IEEE80211_RATE_SUPPORTS_10MHZ)), | ||
157 | }; | 165 | }; |
158 | 166 | ||
159 | #ifdef CONFIG_MAC80211_LEDS | 167 | #ifdef CONFIG_MAC80211_LEDS |
@@ -516,6 +524,7 @@ static void ath9k_init_misc(struct ath_softc *sc) | |||
516 | static void ath9k_init_platform(struct ath_softc *sc) | 524 | static void ath9k_init_platform(struct ath_softc *sc) |
517 | { | 525 | { |
518 | struct ath_hw *ah = sc->sc_ah; | 526 | struct ath_hw *ah = sc->sc_ah; |
527 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
519 | struct ath_common *common = ath9k_hw_common(ah); | 528 | struct ath_common *common = ath9k_hw_common(ah); |
520 | 529 | ||
521 | if (common->bus_ops->ath_bus_type != ATH_PCI) | 530 | if (common->bus_ops->ath_bus_type != ATH_PCI) |
@@ -525,12 +534,27 @@ static void ath9k_init_platform(struct ath_softc *sc) | |||
525 | ATH9K_PCI_CUS230)) { | 534 | ATH9K_PCI_CUS230)) { |
526 | ah->config.xlna_gpio = 9; | 535 | ah->config.xlna_gpio = 9; |
527 | ah->config.xatten_margin_cfg = true; | 536 | ah->config.xatten_margin_cfg = true; |
537 | ah->config.alt_mingainidx = true; | ||
538 | ah->config.ant_ctrl_comm2g_switch_enable = 0x000BBB88; | ||
539 | sc->ant_comb.low_rssi_thresh = 20; | ||
540 | sc->ant_comb.fast_div_bias = 3; | ||
528 | 541 | ||
529 | ath_info(common, "Set parameters for %s\n", | 542 | ath_info(common, "Set parameters for %s\n", |
530 | (sc->driver_data & ATH9K_PCI_CUS198) ? | 543 | (sc->driver_data & ATH9K_PCI_CUS198) ? |
531 | "CUS198" : "CUS230"); | 544 | "CUS198" : "CUS230"); |
532 | } else if (sc->driver_data & ATH9K_PCI_CUS217) { | 545 | } |
546 | |||
547 | if (sc->driver_data & ATH9K_PCI_CUS217) | ||
533 | ath_info(common, "CUS217 card detected\n"); | 548 | ath_info(common, "CUS217 card detected\n"); |
549 | |||
550 | if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) { | ||
551 | pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV; | ||
552 | ath_info(common, "Set BT/WLAN RX diversity capability\n"); | ||
553 | } | ||
554 | |||
555 | if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) { | ||
556 | ah->config.pcie_waen = 0x0040473b; | ||
557 | ath_info(common, "Enable WAR for ASPM D3/L1\n"); | ||
534 | } | 558 | } |
535 | } | 559 | } |
536 | 560 | ||
@@ -584,6 +608,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, | |||
584 | { | 608 | { |
585 | struct ath9k_platform_data *pdata = sc->dev->platform_data; | 609 | struct ath9k_platform_data *pdata = sc->dev->platform_data; |
586 | struct ath_hw *ah = NULL; | 610 | struct ath_hw *ah = NULL; |
611 | struct ath9k_hw_capabilities *pCap; | ||
587 | struct ath_common *common; | 612 | struct ath_common *common; |
588 | int ret = 0, i; | 613 | int ret = 0, i; |
589 | int csz = 0; | 614 | int csz = 0; |
@@ -600,6 +625,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, | |||
600 | ah->reg_ops.rmw = ath9k_reg_rmw; | 625 | ah->reg_ops.rmw = ath9k_reg_rmw; |
601 | atomic_set(&ah->intr_ref_cnt, -1); | 626 | atomic_set(&ah->intr_ref_cnt, -1); |
602 | sc->sc_ah = ah; | 627 | sc->sc_ah = ah; |
628 | pCap = &ah->caps; | ||
603 | 629 | ||
604 | sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET); | 630 | sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET); |
605 | 631 | ||
@@ -631,11 +657,15 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, | |||
631 | ath9k_init_platform(sc); | 657 | ath9k_init_platform(sc); |
632 | 658 | ||
633 | /* | 659 | /* |
634 | * Enable Antenna diversity only when BTCOEX is disabled | 660 | * Enable WLAN/BT RX Antenna diversity only when: |
635 | * and the user manually requests the feature. | 661 | * |
662 | * - BTCOEX is disabled. | ||
663 | * - the user manually requests the feature. | ||
664 | * - the HW cap is set using the platform data. | ||
636 | */ | 665 | */ |
637 | if (!common->btcoex_enabled && ath9k_enable_diversity) | 666 | if (!common->btcoex_enabled && ath9k_bt_ant_diversity && |
638 | common->antenna_diversity = 1; | 667 | (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) |
668 | common->bt_ant_diversity = 1; | ||
639 | 669 | ||
640 | spin_lock_init(&common->cc_lock); | 670 | spin_lock_init(&common->cc_lock); |
641 | 671 | ||
@@ -710,13 +740,15 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band) | |||
710 | struct ieee80211_supported_band *sband; | 740 | struct ieee80211_supported_band *sband; |
711 | struct ieee80211_channel *chan; | 741 | struct ieee80211_channel *chan; |
712 | struct ath_hw *ah = sc->sc_ah; | 742 | struct ath_hw *ah = sc->sc_ah; |
743 | struct cfg80211_chan_def chandef; | ||
713 | int i; | 744 | int i; |
714 | 745 | ||
715 | sband = &sc->sbands[band]; | 746 | sband = &sc->sbands[band]; |
716 | for (i = 0; i < sband->n_channels; i++) { | 747 | for (i = 0; i < sband->n_channels; i++) { |
717 | chan = &sband->channels[i]; | 748 | chan = &sband->channels[i]; |
718 | ah->curchan = &ah->channels[chan->hw_value]; | 749 | ah->curchan = &ah->channels[chan->hw_value]; |
719 | ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20); | 750 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20); |
751 | ath9k_cmn_update_ichannel(ah->curchan, &chandef); | ||
720 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); | 752 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); |
721 | } | 753 | } |
722 | } | 754 | } |
@@ -802,7 +834,8 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
802 | IEEE80211_HW_PS_NULLFUNC_STACK | | 834 | IEEE80211_HW_PS_NULLFUNC_STACK | |
803 | IEEE80211_HW_SPECTRUM_MGMT | | 835 | IEEE80211_HW_SPECTRUM_MGMT | |
804 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | | 836 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
805 | IEEE80211_HW_SUPPORTS_RC_TABLE; | 837 | IEEE80211_HW_SUPPORTS_RC_TABLE | |
838 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; | ||
806 | 839 | ||
807 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { | 840 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { |
808 | hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION; | 841 | hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION; |
@@ -834,6 +867,8 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
834 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; | 867 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
835 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; | 868 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; |
836 | hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; | 869 | hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
870 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ; | ||
871 | hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; | ||
837 | 872 | ||
838 | #ifdef CONFIG_PM_SLEEP | 873 | #ifdef CONFIG_PM_SLEEP |
839 | if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) && | 874 | if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) && |
diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c index fff5d3ccc663..2f831db396ac 100644 --- a/drivers/net/wireless/ath/ath9k/link.c +++ b/drivers/net/wireless/ath/ath9k/link.c | |||
@@ -41,7 +41,7 @@ void ath_tx_complete_poll_work(struct work_struct *work) | |||
41 | txq->axq_tx_inprogress = true; | 41 | txq->axq_tx_inprogress = true; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | ath_txq_unlock_complete(sc, txq); | 44 | ath_txq_unlock(sc, txq); |
45 | } | 45 | } |
46 | 46 | ||
47 | if (needreset) { | 47 | if (needreset) { |
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index 2ef05ebffbcf..a3eff0986a3f 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c | |||
@@ -583,9 +583,9 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds, | |||
583 | rs->rs_rate = MS(ads.ds_rxstatus0, AR_RxRate); | 583 | rs->rs_rate = MS(ads.ds_rxstatus0, AR_RxRate); |
584 | rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0; | 584 | rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0; |
585 | 585 | ||
586 | rs->rs_firstaggr = (ads.ds_rxstatus8 & AR_RxFirstAggr) ? 1 : 0; | ||
586 | rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0; | 587 | rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0; |
587 | rs->rs_moreaggr = | 588 | rs->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0; |
588 | (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0; | ||
589 | rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna); | 589 | rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna); |
590 | 590 | ||
591 | /* directly mapped flags for ieee80211_rx_status */ | 591 | /* directly mapped flags for ieee80211_rx_status */ |
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h index b02dfce964b4..bfccaceed44e 100644 --- a/drivers/net/wireless/ath/ath9k/mac.h +++ b/drivers/net/wireless/ath/ath9k/mac.h | |||
@@ -140,6 +140,7 @@ struct ath_rx_status { | |||
140 | int8_t rs_rssi_ext1; | 140 | int8_t rs_rssi_ext1; |
141 | int8_t rs_rssi_ext2; | 141 | int8_t rs_rssi_ext2; |
142 | u8 rs_isaggr; | 142 | u8 rs_isaggr; |
143 | u8 rs_firstaggr; | ||
143 | u8 rs_moreaggr; | 144 | u8 rs_moreaggr; |
144 | u8 rs_num_delims; | 145 | u8 rs_num_delims; |
145 | u8 rs_flags; | 146 | u8 rs_flags; |
@@ -569,6 +570,7 @@ struct ar5416_desc { | |||
569 | #define AR_RxAggr 0x00020000 | 570 | #define AR_RxAggr 0x00020000 |
570 | #define AR_PostDelimCRCErr 0x00040000 | 571 | #define AR_PostDelimCRCErr 0x00040000 |
571 | #define AR_RxStatusRsvd71 0x3ff80000 | 572 | #define AR_RxStatusRsvd71 0x3ff80000 |
573 | #define AR_RxFirstAggr 0x20000000 | ||
572 | #define AR_DecryptBusyErr 0x40000000 | 574 | #define AR_DecryptBusyErr 0x40000000 |
573 | #define AR_KeyMiss 0x80000000 | 575 | #define AR_KeyMiss 0x80000000 |
574 | 576 | ||
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 1adb803a9d86..e4f65900132d 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -173,8 +173,7 @@ static void ath_restart_work(struct ath_softc *sc) | |||
173 | { | 173 | { |
174 | ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); | 174 | ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); |
175 | 175 | ||
176 | if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) || | 176 | if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah)) |
177 | AR_SREV_9550(sc->sc_ah)) | ||
178 | ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, | 177 | ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, |
179 | msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); | 178 | msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); |
180 | 179 | ||
@@ -238,9 +237,6 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start) | |||
238 | ath_restart_work(sc); | 237 | ath_restart_work(sc); |
239 | } | 238 | } |
240 | 239 | ||
241 | if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3) | ||
242 | ath_ant_comb_update(sc); | ||
243 | |||
244 | ieee80211_wake_queues(sc->hw); | 240 | ieee80211_wake_queues(sc->hw); |
245 | 241 | ||
246 | return true; | 242 | return true; |
@@ -966,6 +962,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, | |||
966 | struct ath_softc *sc = hw->priv; | 962 | struct ath_softc *sc = hw->priv; |
967 | struct ath_hw *ah = sc->sc_ah; | 963 | struct ath_hw *ah = sc->sc_ah; |
968 | struct ath_common *common = ath9k_hw_common(ah); | 964 | struct ath_common *common = ath9k_hw_common(ah); |
965 | struct ath_vif *avp = (void *)vif->drv_priv; | ||
966 | struct ath_node *an = &avp->mcast_node; | ||
969 | 967 | ||
970 | mutex_lock(&sc->mutex); | 968 | mutex_lock(&sc->mutex); |
971 | 969 | ||
@@ -979,6 +977,12 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, | |||
979 | if (ath9k_uses_beacons(vif->type)) | 977 | if (ath9k_uses_beacons(vif->type)) |
980 | ath9k_beacon_assign_slot(sc, vif); | 978 | ath9k_beacon_assign_slot(sc, vif); |
981 | 979 | ||
980 | an->sc = sc; | ||
981 | an->sta = NULL; | ||
982 | an->vif = vif; | ||
983 | an->no_ps_filter = true; | ||
984 | ath_tx_node_init(sc, an); | ||
985 | |||
982 | mutex_unlock(&sc->mutex); | 986 | mutex_unlock(&sc->mutex); |
983 | return 0; | 987 | return 0; |
984 | } | 988 | } |
@@ -1016,6 +1020,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, | |||
1016 | { | 1020 | { |
1017 | struct ath_softc *sc = hw->priv; | 1021 | struct ath_softc *sc = hw->priv; |
1018 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 1022 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
1023 | struct ath_vif *avp = (void *)vif->drv_priv; | ||
1019 | 1024 | ||
1020 | ath_dbg(common, CONFIG, "Detach Interface\n"); | 1025 | ath_dbg(common, CONFIG, "Detach Interface\n"); |
1021 | 1026 | ||
@@ -1026,10 +1031,15 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, | |||
1026 | if (ath9k_uses_beacons(vif->type)) | 1031 | if (ath9k_uses_beacons(vif->type)) |
1027 | ath9k_beacon_remove_slot(sc, vif); | 1032 | ath9k_beacon_remove_slot(sc, vif); |
1028 | 1033 | ||
1034 | if (sc->csa_vif == vif) | ||
1035 | sc->csa_vif = NULL; | ||
1036 | |||
1029 | ath9k_ps_wakeup(sc); | 1037 | ath9k_ps_wakeup(sc); |
1030 | ath9k_calculate_summary_state(hw, NULL); | 1038 | ath9k_calculate_summary_state(hw, NULL); |
1031 | ath9k_ps_restore(sc); | 1039 | ath9k_ps_restore(sc); |
1032 | 1040 | ||
1041 | ath_tx_node_cleanup(sc, &avp->mcast_node); | ||
1042 | |||
1033 | mutex_unlock(&sc->mutex); | 1043 | mutex_unlock(&sc->mutex); |
1034 | } | 1044 | } |
1035 | 1045 | ||
@@ -1193,8 +1203,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1193 | 1203 | ||
1194 | if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { | 1204 | if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { |
1195 | struct ieee80211_channel *curchan = hw->conf.chandef.chan; | 1205 | struct ieee80211_channel *curchan = hw->conf.chandef.chan; |
1196 | enum nl80211_channel_type channel_type = | ||
1197 | cfg80211_get_chandef_type(&conf->chandef); | ||
1198 | int pos = curchan->hw_value; | 1206 | int pos = curchan->hw_value; |
1199 | int old_pos = -1; | 1207 | int old_pos = -1; |
1200 | unsigned long flags; | 1208 | unsigned long flags; |
@@ -1202,8 +1210,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1202 | if (ah->curchan) | 1210 | if (ah->curchan) |
1203 | old_pos = ah->curchan - &ah->channels[0]; | 1211 | old_pos = ah->curchan - &ah->channels[0]; |
1204 | 1212 | ||
1205 | ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n", | 1213 | ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n", |
1206 | curchan->center_freq, channel_type); | 1214 | curchan->center_freq, hw->conf.chandef.width); |
1207 | 1215 | ||
1208 | /* update survey stats for the old channel before switching */ | 1216 | /* update survey stats for the old channel before switching */ |
1209 | spin_lock_irqsave(&common->cc_lock, flags); | 1217 | spin_lock_irqsave(&common->cc_lock, flags); |
@@ -1211,7 +1219,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1211 | spin_unlock_irqrestore(&common->cc_lock, flags); | 1219 | spin_unlock_irqrestore(&common->cc_lock, flags); |
1212 | 1220 | ||
1213 | ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos], | 1221 | ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos], |
1214 | curchan, channel_type); | 1222 | &conf->chandef); |
1215 | 1223 | ||
1216 | /* | 1224 | /* |
1217 | * If the operating channel changes, change the survey in-use flags | 1225 | * If the operating channel changes, change the survey in-use flags |
@@ -1374,9 +1382,6 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw, | |||
1374 | struct ath_softc *sc = hw->priv; | 1382 | struct ath_softc *sc = hw->priv; |
1375 | struct ath_node *an = (struct ath_node *) sta->drv_priv; | 1383 | struct ath_node *an = (struct ath_node *) sta->drv_priv; |
1376 | 1384 | ||
1377 | if (!sta->ht_cap.ht_supported) | ||
1378 | return; | ||
1379 | |||
1380 | switch (cmd) { | 1385 | switch (cmd) { |
1381 | case STA_NOTIFY_SLEEP: | 1386 | case STA_NOTIFY_SLEEP: |
1382 | an->sleeping = true; | 1387 | an->sleeping = true; |
@@ -2315,6 +2320,19 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) | |||
2315 | clear_bit(SC_OP_SCANNING, &sc->sc_flags); | 2320 | clear_bit(SC_OP_SCANNING, &sc->sc_flags); |
2316 | } | 2321 | } |
2317 | 2322 | ||
2323 | static void ath9k_channel_switch_beacon(struct ieee80211_hw *hw, | ||
2324 | struct ieee80211_vif *vif, | ||
2325 | struct cfg80211_chan_def *chandef) | ||
2326 | { | ||
2327 | struct ath_softc *sc = hw->priv; | ||
2328 | |||
2329 | /* mac80211 does not support CSA in multi-if cases (yet) */ | ||
2330 | if (WARN_ON(sc->csa_vif)) | ||
2331 | return; | ||
2332 | |||
2333 | sc->csa_vif = vif; | ||
2334 | } | ||
2335 | |||
2318 | struct ieee80211_ops ath9k_ops = { | 2336 | struct ieee80211_ops ath9k_ops = { |
2319 | .tx = ath9k_tx, | 2337 | .tx = ath9k_tx, |
2320 | .start = ath9k_start, | 2338 | .start = ath9k_start, |
@@ -2359,8 +2377,8 @@ struct ieee80211_ops ath9k_ops = { | |||
2359 | 2377 | ||
2360 | #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS) | 2378 | #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS) |
2361 | .sta_add_debugfs = ath9k_sta_add_debugfs, | 2379 | .sta_add_debugfs = ath9k_sta_add_debugfs, |
2362 | .sta_remove_debugfs = ath9k_sta_remove_debugfs, | ||
2363 | #endif | 2380 | #endif |
2364 | .sw_scan_start = ath9k_sw_scan_start, | 2381 | .sw_scan_start = ath9k_sw_scan_start, |
2365 | .sw_scan_complete = ath9k_sw_scan_complete, | 2382 | .sw_scan_complete = ath9k_sw_scan_complete, |
2383 | .channel_switch_beacon = ath9k_channel_switch_beacon, | ||
2366 | }; | 2384 | }; |
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index c585c9b35973..d089a7cf01c4 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c | |||
@@ -29,6 +29,60 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { | |||
29 | { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */ | 29 | { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */ |
30 | { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */ | 30 | { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */ |
31 | { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */ | 31 | { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */ |
32 | |||
33 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
34 | 0x002A, | ||
35 | PCI_VENDOR_ID_AZWAVE, | ||
36 | 0x1C71), | ||
37 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
38 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
39 | 0x002A, | ||
40 | PCI_VENDOR_ID_FOXCONN, | ||
41 | 0xE01F), | ||
42 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
43 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
44 | 0x002A, | ||
45 | 0x11AD, /* LITEON */ | ||
46 | 0x6632), | ||
47 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
48 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
49 | 0x002A, | ||
50 | 0x11AD, /* LITEON */ | ||
51 | 0x6642), | ||
52 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
53 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
54 | 0x002A, | ||
55 | PCI_VENDOR_ID_QMI, | ||
56 | 0x0306), | ||
57 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
58 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
59 | 0x002A, | ||
60 | 0x185F, /* WNC */ | ||
61 | 0x309D), | ||
62 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
63 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
64 | 0x002A, | ||
65 | 0x10CF, /* Fujitsu */ | ||
66 | 0x147C), | ||
67 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
68 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
69 | 0x002A, | ||
70 | 0x10CF, /* Fujitsu */ | ||
71 | 0x147D), | ||
72 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
73 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
74 | 0x002A, | ||
75 | 0x10CF, /* Fujitsu */ | ||
76 | 0x1536), | ||
77 | .driver_data = ATH9K_PCI_D3_L1_WAR }, | ||
78 | |||
79 | /* AR9285 card for Asus */ | ||
80 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
81 | 0x002B, | ||
82 | PCI_VENDOR_ID_AZWAVE, | ||
83 | 0x2C37), | ||
84 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
85 | |||
32 | { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */ | 86 | { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */ |
33 | { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */ | 87 | { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */ |
34 | { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */ | 88 | { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */ |
@@ -40,29 +94,106 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { | |||
40 | 0x0032, | 94 | 0x0032, |
41 | PCI_VENDOR_ID_AZWAVE, | 95 | PCI_VENDOR_ID_AZWAVE, |
42 | 0x2086), | 96 | 0x2086), |
43 | .driver_data = ATH9K_PCI_CUS198 }, | 97 | .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, |
44 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | 98 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, |
45 | 0x0032, | 99 | 0x0032, |
46 | PCI_VENDOR_ID_AZWAVE, | 100 | PCI_VENDOR_ID_AZWAVE, |
47 | 0x1237), | 101 | 0x1237), |
48 | .driver_data = ATH9K_PCI_CUS198 }, | 102 | .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, |
49 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | 103 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, |
50 | 0x0032, | 104 | 0x0032, |
51 | PCI_VENDOR_ID_AZWAVE, | 105 | PCI_VENDOR_ID_AZWAVE, |
52 | 0x2126), | 106 | 0x2126), |
53 | .driver_data = ATH9K_PCI_CUS198 }, | 107 | .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, |
108 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
109 | 0x0032, | ||
110 | PCI_VENDOR_ID_AZWAVE, | ||
111 | 0x126A), | ||
112 | .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, | ||
54 | 113 | ||
55 | /* PCI-E CUS230 */ | 114 | /* PCI-E CUS230 */ |
56 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | 115 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, |
57 | 0x0032, | 116 | 0x0032, |
58 | PCI_VENDOR_ID_AZWAVE, | 117 | PCI_VENDOR_ID_AZWAVE, |
59 | 0x2152), | 118 | 0x2152), |
60 | .driver_data = ATH9K_PCI_CUS230 }, | 119 | .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV }, |
61 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | 120 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, |
62 | 0x0032, | 121 | 0x0032, |
63 | PCI_VENDOR_ID_FOXCONN, | 122 | PCI_VENDOR_ID_FOXCONN, |
64 | 0xE075), | 123 | 0xE075), |
65 | .driver_data = ATH9K_PCI_CUS230 }, | 124 | .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV }, |
125 | |||
126 | /* WB225 */ | ||
127 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
128 | 0x0032, | ||
129 | PCI_VENDOR_ID_ATHEROS, | ||
130 | 0x3119), | ||
131 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
132 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
133 | 0x0032, | ||
134 | PCI_VENDOR_ID_ATHEROS, | ||
135 | 0x3122), | ||
136 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
137 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
138 | 0x0032, | ||
139 | 0x185F, /* WNC */ | ||
140 | 0x3119), | ||
141 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
142 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
143 | 0x0032, | ||
144 | 0x185F, /* WNC */ | ||
145 | 0x3027), | ||
146 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
147 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
148 | 0x0032, | ||
149 | PCI_VENDOR_ID_SAMSUNG, | ||
150 | 0x4105), | ||
151 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
152 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
153 | 0x0032, | ||
154 | PCI_VENDOR_ID_SAMSUNG, | ||
155 | 0x4106), | ||
156 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
157 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
158 | 0x0032, | ||
159 | PCI_VENDOR_ID_SAMSUNG, | ||
160 | 0x410D), | ||
161 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
162 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
163 | 0x0032, | ||
164 | PCI_VENDOR_ID_SAMSUNG, | ||
165 | 0x410E), | ||
166 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
167 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
168 | 0x0032, | ||
169 | PCI_VENDOR_ID_SAMSUNG, | ||
170 | 0x410F), | ||
171 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
172 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
173 | 0x0032, | ||
174 | PCI_VENDOR_ID_SAMSUNG, | ||
175 | 0xC706), | ||
176 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
177 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
178 | 0x0032, | ||
179 | PCI_VENDOR_ID_SAMSUNG, | ||
180 | 0xC680), | ||
181 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
182 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
183 | 0x0032, | ||
184 | PCI_VENDOR_ID_SAMSUNG, | ||
185 | 0xC708), | ||
186 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
187 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
188 | 0x0032, | ||
189 | PCI_VENDOR_ID_LENOVO, | ||
190 | 0x3218), | ||
191 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
192 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, | ||
193 | 0x0032, | ||
194 | PCI_VENDOR_ID_LENOVO, | ||
195 | 0x3219), | ||
196 | .driver_data = ATH9K_PCI_BT_ANT_DIV }, | ||
66 | 197 | ||
67 | { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */ | 198 | { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */ |
68 | { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */ | 199 | { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */ |
@@ -229,6 +360,22 @@ static void ath_pci_aspm_init(struct ath_common *common) | |||
229 | return; | 360 | return; |
230 | } | 361 | } |
231 | 362 | ||
363 | /* | ||
364 | * 0x70c - Ack Frequency Register. | ||
365 | * | ||
366 | * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY. | ||
367 | * | ||
368 | * 000 : 1 us | ||
369 | * 001 : 2 us | ||
370 | * 010 : 4 us | ||
371 | * 011 : 8 us | ||
372 | * 100 : 16 us | ||
373 | * 101 : 32 us | ||
374 | * 110/111 : 64 us | ||
375 | */ | ||
376 | if (AR_SREV_9462(ah)) | ||
377 | pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix); | ||
378 | |||
232 | pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); | 379 | pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); |
233 | if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) { | 380 | if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) { |
234 | ah->aspm_enabled = true; | 381 | ah->aspm_enabled = true; |
diff --git a/drivers/net/wireless/ath/ath9k/phy.h b/drivers/net/wireless/ath/ath9k/phy.h index 8b380305b0fc..4a1b99238ec2 100644 --- a/drivers/net/wireless/ath/ath9k/phy.h +++ b/drivers/net/wireless/ath/ath9k/phy.h | |||
@@ -48,4 +48,11 @@ | |||
48 | #define AR_PHY_PLL_CONTROL 0x16180 | 48 | #define AR_PHY_PLL_CONTROL 0x16180 |
49 | #define AR_PHY_PLL_MODE 0x16184 | 49 | #define AR_PHY_PLL_MODE 0x16184 |
50 | 50 | ||
51 | enum ath9k_ant_div_comb_lna_conf { | ||
52 | ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2, | ||
53 | ATH_ANT_DIV_COMB_LNA2, | ||
54 | ATH_ANT_DIV_COMB_LNA1, | ||
55 | ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2, | ||
56 | }; | ||
57 | |||
51 | #endif | 58 | #endif |
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index a3c4ca0c94bf..d3d7c51fa6c8 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c | |||
@@ -1282,9 +1282,14 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
1282 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 1282 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
1283 | struct ath_rate_priv *ath_rc_priv = priv_sta; | 1283 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
1284 | int i, j = 0; | 1284 | int i, j = 0; |
1285 | u32 rate_flags = ieee80211_chandef_rate_flags(&sc->hw->conf.chandef); | ||
1285 | 1286 | ||
1286 | for (i = 0; i < sband->n_bitrates; i++) { | 1287 | for (i = 0; i < sband->n_bitrates; i++) { |
1287 | if (sta->supp_rates[sband->band] & BIT(i)) { | 1288 | if (sta->supp_rates[sband->band] & BIT(i)) { |
1289 | if ((rate_flags & sband->bitrates[i].flags) | ||
1290 | != rate_flags) | ||
1291 | continue; | ||
1292 | |||
1288 | ath_rc_priv->neg_rates.rs_rates[j] | 1293 | ath_rc_priv->neg_rates.rs_rates[j] |
1289 | = (sband->bitrates[i].bitrate * 2) / 10; | 1294 | = (sband->bitrates[i].bitrate * 2) / 10; |
1290 | j++; | 1295 | j++; |
@@ -1326,8 +1331,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband, | |||
1326 | ath_rc_init(sc, priv_sta); | 1331 | ath_rc_init(sc, priv_sta); |
1327 | 1332 | ||
1328 | ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, | 1333 | ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, |
1329 | "Operating HT Bandwidth changed to: %d\n", | 1334 | "Operating Bandwidth changed to: %d\n", |
1330 | cfg80211_get_chandef_type(&sc->hw->conf.chandef)); | 1335 | sc->hw->conf.chandef.width); |
1331 | } | 1336 | } |
1332 | } | 1337 | } |
1333 | 1338 | ||
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 865e043e8aa6..4ee472a5a4e4 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -42,8 +42,6 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf) | |||
42 | struct ath_desc *ds; | 42 | struct ath_desc *ds; |
43 | struct sk_buff *skb; | 43 | struct sk_buff *skb; |
44 | 44 | ||
45 | ATH_RXBUF_RESET(bf); | ||
46 | |||
47 | ds = bf->bf_desc; | 45 | ds = bf->bf_desc; |
48 | ds->ds_link = 0; /* link to null */ | 46 | ds->ds_link = 0; /* link to null */ |
49 | ds->ds_data = bf->bf_buf_addr; | 47 | ds->ds_data = bf->bf_buf_addr; |
@@ -70,6 +68,14 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf) | |||
70 | sc->rx.rxlink = &ds->ds_link; | 68 | sc->rx.rxlink = &ds->ds_link; |
71 | } | 69 | } |
72 | 70 | ||
71 | static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_buf *bf) | ||
72 | { | ||
73 | if (sc->rx.buf_hold) | ||
74 | ath_rx_buf_link(sc, sc->rx.buf_hold); | ||
75 | |||
76 | sc->rx.buf_hold = bf; | ||
77 | } | ||
78 | |||
73 | static void ath_setdefantenna(struct ath_softc *sc, u32 antenna) | 79 | static void ath_setdefantenna(struct ath_softc *sc, u32 antenna) |
74 | { | 80 | { |
75 | /* XXX block beacon interrupts */ | 81 | /* XXX block beacon interrupts */ |
@@ -117,7 +123,6 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc, | |||
117 | 123 | ||
118 | skb = bf->bf_mpdu; | 124 | skb = bf->bf_mpdu; |
119 | 125 | ||
120 | ATH_RXBUF_RESET(bf); | ||
121 | memset(skb->data, 0, ah->caps.rx_status_len); | 126 | memset(skb->data, 0, ah->caps.rx_status_len); |
122 | dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, | 127 | dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, |
123 | ah->caps.rx_status_len, DMA_TO_DEVICE); | 128 | ah->caps.rx_status_len, DMA_TO_DEVICE); |
@@ -185,7 +190,7 @@ static void ath_rx_edma_cleanup(struct ath_softc *sc) | |||
185 | 190 | ||
186 | static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size) | 191 | static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size) |
187 | { | 192 | { |
188 | skb_queue_head_init(&rx_edma->rx_fifo); | 193 | __skb_queue_head_init(&rx_edma->rx_fifo); |
189 | rx_edma->rx_fifo_hwsize = size; | 194 | rx_edma->rx_fifo_hwsize = size; |
190 | } | 195 | } |
191 | 196 | ||
@@ -432,6 +437,7 @@ int ath_startrecv(struct ath_softc *sc) | |||
432 | if (list_empty(&sc->rx.rxbuf)) | 437 | if (list_empty(&sc->rx.rxbuf)) |
433 | goto start_recv; | 438 | goto start_recv; |
434 | 439 | ||
440 | sc->rx.buf_hold = NULL; | ||
435 | sc->rx.rxlink = NULL; | 441 | sc->rx.rxlink = NULL; |
436 | list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { | 442 | list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { |
437 | ath_rx_buf_link(sc, bf); | 443 | ath_rx_buf_link(sc, bf); |
@@ -677,6 +683,9 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc, | |||
677 | } | 683 | } |
678 | 684 | ||
679 | bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list); | 685 | bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list); |
686 | if (bf == sc->rx.buf_hold) | ||
687 | return NULL; | ||
688 | |||
680 | ds = bf->bf_desc; | 689 | ds = bf->bf_desc; |
681 | 690 | ||
682 | /* | 691 | /* |
@@ -755,7 +764,6 @@ static bool ath9k_rx_accept(struct ath_common *common, | |||
755 | bool is_mc, is_valid_tkip, strip_mic, mic_error; | 764 | bool is_mc, is_valid_tkip, strip_mic, mic_error; |
756 | struct ath_hw *ah = common->ah; | 765 | struct ath_hw *ah = common->ah; |
757 | __le16 fc; | 766 | __le16 fc; |
758 | u8 rx_status_len = ah->caps.rx_status_len; | ||
759 | 767 | ||
760 | fc = hdr->frame_control; | 768 | fc = hdr->frame_control; |
761 | 769 | ||
@@ -777,25 +785,6 @@ static bool ath9k_rx_accept(struct ath_common *common, | |||
777 | !test_bit(rx_stats->rs_keyix, common->ccmp_keymap)) | 785 | !test_bit(rx_stats->rs_keyix, common->ccmp_keymap)) |
778 | rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS; | 786 | rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS; |
779 | 787 | ||
780 | if (!rx_stats->rs_datalen) { | ||
781 | RX_STAT_INC(rx_len_err); | ||
782 | return false; | ||
783 | } | ||
784 | |||
785 | /* | ||
786 | * rs_status follows rs_datalen so if rs_datalen is too large | ||
787 | * we can take a hint that hardware corrupted it, so ignore | ||
788 | * those frames. | ||
789 | */ | ||
790 | if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) { | ||
791 | RX_STAT_INC(rx_len_err); | ||
792 | return false; | ||
793 | } | ||
794 | |||
795 | /* Only use error bits from the last fragment */ | ||
796 | if (rx_stats->rs_more) | ||
797 | return true; | ||
798 | |||
799 | mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) && | 788 | mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) && |
800 | !ieee80211_has_morefrags(fc) && | 789 | !ieee80211_has_morefrags(fc) && |
801 | !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) && | 790 | !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) && |
@@ -814,8 +803,6 @@ static bool ath9k_rx_accept(struct ath_common *common, | |||
814 | rxs->flag |= RX_FLAG_FAILED_FCS_CRC; | 803 | rxs->flag |= RX_FLAG_FAILED_FCS_CRC; |
815 | mic_error = false; | 804 | mic_error = false; |
816 | } | 805 | } |
817 | if (rx_stats->rs_status & ATH9K_RXERR_PHY) | ||
818 | return false; | ||
819 | 806 | ||
820 | if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) || | 807 | if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) || |
821 | (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) { | 808 | (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) { |
@@ -865,6 +852,17 @@ static int ath9k_process_rate(struct ath_common *common, | |||
865 | band = hw->conf.chandef.chan->band; | 852 | band = hw->conf.chandef.chan->band; |
866 | sband = hw->wiphy->bands[band]; | 853 | sband = hw->wiphy->bands[band]; |
867 | 854 | ||
855 | switch (hw->conf.chandef.width) { | ||
856 | case NL80211_CHAN_WIDTH_5: | ||
857 | rxs->flag |= RX_FLAG_5MHZ; | ||
858 | break; | ||
859 | case NL80211_CHAN_WIDTH_10: | ||
860 | rxs->flag |= RX_FLAG_10MHZ; | ||
861 | break; | ||
862 | default: | ||
863 | break; | ||
864 | } | ||
865 | |||
868 | if (rx_stats->rs_rate & 0x80) { | 866 | if (rx_stats->rs_rate & 0x80) { |
869 | /* HT rate */ | 867 | /* HT rate */ |
870 | rxs->flag |= RX_FLAG_HT; | 868 | rxs->flag |= RX_FLAG_HT; |
@@ -898,129 +896,65 @@ static int ath9k_process_rate(struct ath_common *common, | |||
898 | 896 | ||
899 | static void ath9k_process_rssi(struct ath_common *common, | 897 | static void ath9k_process_rssi(struct ath_common *common, |
900 | struct ieee80211_hw *hw, | 898 | struct ieee80211_hw *hw, |
901 | struct ieee80211_hdr *hdr, | 899 | struct ath_rx_status *rx_stats, |
902 | struct ath_rx_status *rx_stats) | 900 | struct ieee80211_rx_status *rxs) |
903 | { | 901 | { |
904 | struct ath_softc *sc = hw->priv; | 902 | struct ath_softc *sc = hw->priv; |
905 | struct ath_hw *ah = common->ah; | 903 | struct ath_hw *ah = common->ah; |
906 | int last_rssi; | 904 | int last_rssi; |
907 | int rssi = rx_stats->rs_rssi; | 905 | int rssi = rx_stats->rs_rssi; |
908 | 906 | ||
909 | if (!rx_stats->is_mybeacon || | 907 | /* |
910 | ((ah->opmode != NL80211_IFTYPE_STATION) && | 908 | * RSSI is not available for subframes in an A-MPDU. |
911 | (ah->opmode != NL80211_IFTYPE_ADHOC))) | 909 | */ |
910 | if (rx_stats->rs_moreaggr) { | ||
911 | rxs->flag |= RX_FLAG_NO_SIGNAL_VAL; | ||
912 | return; | 912 | return; |
913 | 913 | } | |
914 | if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr) | ||
915 | ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi); | ||
916 | |||
917 | last_rssi = sc->last_rssi; | ||
918 | if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) | ||
919 | rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER); | ||
920 | if (rssi < 0) | ||
921 | rssi = 0; | ||
922 | |||
923 | /* Update Beacon RSSI, this is used by ANI. */ | ||
924 | ah->stats.avgbrssi = rssi; | ||
925 | } | ||
926 | |||
927 | /* | ||
928 | * For Decrypt or Demic errors, we only mark packet status here and always push | ||
929 | * up the frame up to let mac80211 handle the actual error case, be it no | ||
930 | * decryption key or real decryption error. This let us keep statistics there. | ||
931 | */ | ||
932 | static int ath9k_rx_skb_preprocess(struct ath_softc *sc, | ||
933 | struct ieee80211_hdr *hdr, | ||
934 | struct ath_rx_status *rx_stats, | ||
935 | struct ieee80211_rx_status *rx_status, | ||
936 | bool *decrypt_error) | ||
937 | { | ||
938 | struct ieee80211_hw *hw = sc->hw; | ||
939 | struct ath_hw *ah = sc->sc_ah; | ||
940 | struct ath_common *common = ath9k_hw_common(ah); | ||
941 | bool discard_current = sc->rx.discard_next; | ||
942 | |||
943 | sc->rx.discard_next = rx_stats->rs_more; | ||
944 | if (discard_current) | ||
945 | return -EINVAL; | ||
946 | 914 | ||
947 | /* | 915 | /* |
948 | * everything but the rate is checked here, the rate check is done | 916 | * Check if the RSSI for the last subframe in an A-MPDU |
949 | * separately to avoid doing two lookups for a rate for each frame. | 917 | * or an unaggregated frame is valid. |
950 | */ | 918 | */ |
951 | if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) | 919 | if (rx_stats->rs_rssi == ATH9K_RSSI_BAD) { |
952 | return -EINVAL; | 920 | rxs->flag |= RX_FLAG_NO_SIGNAL_VAL; |
953 | 921 | return; | |
954 | /* Only use status info from the last fragment */ | 922 | } |
955 | if (rx_stats->rs_more) | ||
956 | return 0; | ||
957 | 923 | ||
958 | if (ath9k_process_rate(common, hw, rx_stats, rx_status)) | 924 | /* |
959 | return -EINVAL; | 925 | * Update Beacon RSSI, this is used by ANI. |
926 | */ | ||
927 | if (rx_stats->is_mybeacon && | ||
928 | ((ah->opmode == NL80211_IFTYPE_STATION) || | ||
929 | (ah->opmode == NL80211_IFTYPE_ADHOC))) { | ||
930 | ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi); | ||
931 | last_rssi = sc->last_rssi; | ||
960 | 932 | ||
961 | ath9k_process_rssi(common, hw, hdr, rx_stats); | 933 | if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) |
934 | rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER); | ||
935 | if (rssi < 0) | ||
936 | rssi = 0; | ||
962 | 937 | ||
963 | rx_status->band = hw->conf.chandef.chan->band; | 938 | ah->stats.avgbrssi = rssi; |
964 | rx_status->freq = hw->conf.chandef.chan->center_freq; | 939 | } |
965 | rx_status->signal = ah->noise + rx_stats->rs_rssi; | ||
966 | rx_status->antenna = rx_stats->rs_antenna; | ||
967 | rx_status->flag |= RX_FLAG_MACTIME_END; | ||
968 | if (rx_stats->rs_moreaggr) | ||
969 | rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL; | ||
970 | 940 | ||
971 | sc->rx.discard_next = false; | 941 | rxs->signal = ah->noise + rx_stats->rs_rssi; |
972 | return 0; | ||
973 | } | 942 | } |
974 | 943 | ||
975 | static void ath9k_rx_skb_postprocess(struct ath_common *common, | 944 | static void ath9k_process_tsf(struct ath_rx_status *rs, |
976 | struct sk_buff *skb, | 945 | struct ieee80211_rx_status *rxs, |
977 | struct ath_rx_status *rx_stats, | 946 | u64 tsf) |
978 | struct ieee80211_rx_status *rxs, | ||
979 | bool decrypt_error) | ||
980 | { | 947 | { |
981 | struct ath_hw *ah = common->ah; | 948 | u32 tsf_lower = tsf & 0xffffffff; |
982 | struct ieee80211_hdr *hdr; | ||
983 | int hdrlen, padpos, padsize; | ||
984 | u8 keyix; | ||
985 | __le16 fc; | ||
986 | |||
987 | /* see if any padding is done by the hw and remove it */ | ||
988 | hdr = (struct ieee80211_hdr *) skb->data; | ||
989 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | ||
990 | fc = hdr->frame_control; | ||
991 | padpos = ieee80211_hdrlen(fc); | ||
992 | |||
993 | /* The MAC header is padded to have 32-bit boundary if the | ||
994 | * packet payload is non-zero. The general calculation for | ||
995 | * padsize would take into account odd header lengths: | ||
996 | * padsize = (4 - padpos % 4) % 4; However, since only | ||
997 | * even-length headers are used, padding can only be 0 or 2 | ||
998 | * bytes and we can optimize this a bit. In addition, we must | ||
999 | * not try to remove padding from short control frames that do | ||
1000 | * not have payload. */ | ||
1001 | padsize = padpos & 3; | ||
1002 | if (padsize && skb->len>=padpos+padsize+FCS_LEN) { | ||
1003 | memmove(skb->data + padsize, skb->data, padpos); | ||
1004 | skb_pull(skb, padsize); | ||
1005 | } | ||
1006 | 949 | ||
1007 | keyix = rx_stats->rs_keyix; | 950 | rxs->mactime = (tsf & ~0xffffffffULL) | rs->rs_tstamp; |
951 | if (rs->rs_tstamp > tsf_lower && | ||
952 | unlikely(rs->rs_tstamp - tsf_lower > 0x10000000)) | ||
953 | rxs->mactime -= 0x100000000ULL; | ||
1008 | 954 | ||
1009 | if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error && | 955 | if (rs->rs_tstamp < tsf_lower && |
1010 | ieee80211_has_protected(fc)) { | 956 | unlikely(tsf_lower - rs->rs_tstamp > 0x10000000)) |
1011 | rxs->flag |= RX_FLAG_DECRYPTED; | 957 | rxs->mactime += 0x100000000ULL; |
1012 | } else if (ieee80211_has_protected(fc) | ||
1013 | && !decrypt_error && skb->len >= hdrlen + 4) { | ||
1014 | keyix = skb->data[hdrlen + 3] >> 6; | ||
1015 | |||
1016 | if (test_bit(keyix, common->keymap)) | ||
1017 | rxs->flag |= RX_FLAG_DECRYPTED; | ||
1018 | } | ||
1019 | if (ah->sw_mgmt_crypto && | ||
1020 | (rxs->flag & RX_FLAG_DECRYPTED) && | ||
1021 | ieee80211_is_mgmt(fc)) | ||
1022 | /* Use software decrypt for management frames. */ | ||
1023 | rxs->flag &= ~RX_FLAG_DECRYPTED; | ||
1024 | } | 958 | } |
1025 | 959 | ||
1026 | #ifdef CONFIG_ATH9K_DEBUGFS | 960 | #ifdef CONFIG_ATH9K_DEBUGFS |
@@ -1133,6 +1067,234 @@ static int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr, | |||
1133 | #endif | 1067 | #endif |
1134 | } | 1068 | } |
1135 | 1069 | ||
1070 | static bool ath9k_is_mybeacon(struct ath_softc *sc, struct ieee80211_hdr *hdr) | ||
1071 | { | ||
1072 | struct ath_hw *ah = sc->sc_ah; | ||
1073 | struct ath_common *common = ath9k_hw_common(ah); | ||
1074 | |||
1075 | if (ieee80211_is_beacon(hdr->frame_control)) { | ||
1076 | RX_STAT_INC(rx_beacons); | ||
1077 | if (!is_zero_ether_addr(common->curbssid) && | ||
1078 | ether_addr_equal(hdr->addr3, common->curbssid)) | ||
1079 | return true; | ||
1080 | } | ||
1081 | |||
1082 | return false; | ||
1083 | } | ||
1084 | |||
1085 | /* | ||
1086 | * For Decrypt or Demic errors, we only mark packet status here and always push | ||
1087 | * up the frame up to let mac80211 handle the actual error case, be it no | ||
1088 | * decryption key or real decryption error. This let us keep statistics there. | ||
1089 | */ | ||
1090 | static int ath9k_rx_skb_preprocess(struct ath_softc *sc, | ||
1091 | struct sk_buff *skb, | ||
1092 | struct ath_rx_status *rx_stats, | ||
1093 | struct ieee80211_rx_status *rx_status, | ||
1094 | bool *decrypt_error, u64 tsf) | ||
1095 | { | ||
1096 | struct ieee80211_hw *hw = sc->hw; | ||
1097 | struct ath_hw *ah = sc->sc_ah; | ||
1098 | struct ath_common *common = ath9k_hw_common(ah); | ||
1099 | struct ieee80211_hdr *hdr; | ||
1100 | bool discard_current = sc->rx.discard_next; | ||
1101 | int ret = 0; | ||
1102 | |||
1103 | /* | ||
1104 | * Discard corrupt descriptors which are marked in | ||
1105 | * ath_get_next_rx_buf(). | ||
1106 | */ | ||
1107 | sc->rx.discard_next = rx_stats->rs_more; | ||
1108 | if (discard_current) | ||
1109 | return -EINVAL; | ||
1110 | |||
1111 | /* | ||
1112 | * Discard zero-length packets. | ||
1113 | */ | ||
1114 | if (!rx_stats->rs_datalen) { | ||
1115 | RX_STAT_INC(rx_len_err); | ||
1116 | return -EINVAL; | ||
1117 | } | ||
1118 | |||
1119 | /* | ||
1120 | * rs_status follows rs_datalen so if rs_datalen is too large | ||
1121 | * we can take a hint that hardware corrupted it, so ignore | ||
1122 | * those frames. | ||
1123 | */ | ||
1124 | if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) { | ||
1125 | RX_STAT_INC(rx_len_err); | ||
1126 | return -EINVAL; | ||
1127 | } | ||
1128 | |||
1129 | /* Only use status info from the last fragment */ | ||
1130 | if (rx_stats->rs_more) | ||
1131 | return 0; | ||
1132 | |||
1133 | /* | ||
1134 | * Return immediately if the RX descriptor has been marked | ||
1135 | * as corrupt based on the various error bits. | ||
1136 | * | ||
1137 | * This is different from the other corrupt descriptor | ||
1138 | * condition handled above. | ||
1139 | */ | ||
1140 | if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) { | ||
1141 | ret = -EINVAL; | ||
1142 | goto exit; | ||
1143 | } | ||
1144 | |||
1145 | hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len); | ||
1146 | |||
1147 | ath9k_process_tsf(rx_stats, rx_status, tsf); | ||
1148 | ath_debug_stat_rx(sc, rx_stats); | ||
1149 | |||
1150 | /* | ||
1151 | * Process PHY errors and return so that the packet | ||
1152 | * can be dropped. | ||
1153 | */ | ||
1154 | if (rx_stats->rs_status & ATH9K_RXERR_PHY) { | ||
1155 | ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime); | ||
1156 | if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime)) | ||
1157 | RX_STAT_INC(rx_spectral); | ||
1158 | |||
1159 | ret = -EINVAL; | ||
1160 | goto exit; | ||
1161 | } | ||
1162 | |||
1163 | /* | ||
1164 | * everything but the rate is checked here, the rate check is done | ||
1165 | * separately to avoid doing two lookups for a rate for each frame. | ||
1166 | */ | ||
1167 | if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) { | ||
1168 | ret = -EINVAL; | ||
1169 | goto exit; | ||
1170 | } | ||
1171 | |||
1172 | rx_stats->is_mybeacon = ath9k_is_mybeacon(sc, hdr); | ||
1173 | if (rx_stats->is_mybeacon) { | ||
1174 | sc->hw_busy_count = 0; | ||
1175 | ath_start_rx_poll(sc, 3); | ||
1176 | } | ||
1177 | |||
1178 | if (ath9k_process_rate(common, hw, rx_stats, rx_status)) { | ||
1179 | ret =-EINVAL; | ||
1180 | goto exit; | ||
1181 | } | ||
1182 | |||
1183 | ath9k_process_rssi(common, hw, rx_stats, rx_status); | ||
1184 | |||
1185 | rx_status->band = hw->conf.chandef.chan->band; | ||
1186 | rx_status->freq = hw->conf.chandef.chan->center_freq; | ||
1187 | rx_status->antenna = rx_stats->rs_antenna; | ||
1188 | rx_status->flag |= RX_FLAG_MACTIME_END; | ||
1189 | |||
1190 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | ||
1191 | if (ieee80211_is_data_present(hdr->frame_control) && | ||
1192 | !ieee80211_is_qos_nullfunc(hdr->frame_control)) | ||
1193 | sc->rx.num_pkts++; | ||
1194 | #endif | ||
1195 | |||
1196 | exit: | ||
1197 | sc->rx.discard_next = false; | ||
1198 | return ret; | ||
1199 | } | ||
1200 | |||
1201 | static void ath9k_rx_skb_postprocess(struct ath_common *common, | ||
1202 | struct sk_buff *skb, | ||
1203 | struct ath_rx_status *rx_stats, | ||
1204 | struct ieee80211_rx_status *rxs, | ||
1205 | bool decrypt_error) | ||
1206 | { | ||
1207 | struct ath_hw *ah = common->ah; | ||
1208 | struct ieee80211_hdr *hdr; | ||
1209 | int hdrlen, padpos, padsize; | ||
1210 | u8 keyix; | ||
1211 | __le16 fc; | ||
1212 | |||
1213 | /* see if any padding is done by the hw and remove it */ | ||
1214 | hdr = (struct ieee80211_hdr *) skb->data; | ||
1215 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | ||
1216 | fc = hdr->frame_control; | ||
1217 | padpos = ieee80211_hdrlen(fc); | ||
1218 | |||
1219 | /* The MAC header is padded to have 32-bit boundary if the | ||
1220 | * packet payload is non-zero. The general calculation for | ||
1221 | * padsize would take into account odd header lengths: | ||
1222 | * padsize = (4 - padpos % 4) % 4; However, since only | ||
1223 | * even-length headers are used, padding can only be 0 or 2 | ||
1224 | * bytes and we can optimize this a bit. In addition, we must | ||
1225 | * not try to remove padding from short control frames that do | ||
1226 | * not have payload. */ | ||
1227 | padsize = padpos & 3; | ||
1228 | if (padsize && skb->len>=padpos+padsize+FCS_LEN) { | ||
1229 | memmove(skb->data + padsize, skb->data, padpos); | ||
1230 | skb_pull(skb, padsize); | ||
1231 | } | ||
1232 | |||
1233 | keyix = rx_stats->rs_keyix; | ||
1234 | |||
1235 | if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error && | ||
1236 | ieee80211_has_protected(fc)) { | ||
1237 | rxs->flag |= RX_FLAG_DECRYPTED; | ||
1238 | } else if (ieee80211_has_protected(fc) | ||
1239 | && !decrypt_error && skb->len >= hdrlen + 4) { | ||
1240 | keyix = skb->data[hdrlen + 3] >> 6; | ||
1241 | |||
1242 | if (test_bit(keyix, common->keymap)) | ||
1243 | rxs->flag |= RX_FLAG_DECRYPTED; | ||
1244 | } | ||
1245 | if (ah->sw_mgmt_crypto && | ||
1246 | (rxs->flag & RX_FLAG_DECRYPTED) && | ||
1247 | ieee80211_is_mgmt(fc)) | ||
1248 | /* Use software decrypt for management frames. */ | ||
1249 | rxs->flag &= ~RX_FLAG_DECRYPTED; | ||
1250 | } | ||
1251 | |||
1252 | /* | ||
1253 | * Run the LNA combining algorithm only in these cases: | ||
1254 | * | ||
1255 | * Standalone WLAN cards with both LNA/Antenna diversity | ||
1256 | * enabled in the EEPROM. | ||
1257 | * | ||
1258 | * WLAN+BT cards which are in the supported card list | ||
1259 | * in ath_pci_id_table and the user has loaded the | ||
1260 | * driver with "bt_ant_diversity" set to true. | ||
1261 | */ | ||
1262 | static void ath9k_antenna_check(struct ath_softc *sc, | ||
1263 | struct ath_rx_status *rs) | ||
1264 | { | ||
1265 | struct ath_hw *ah = sc->sc_ah; | ||
1266 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
1267 | struct ath_common *common = ath9k_hw_common(ah); | ||
1268 | |||
1269 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) | ||
1270 | return; | ||
1271 | |||
1272 | /* | ||
1273 | * All MPDUs in an aggregate will use the same LNA | ||
1274 | * as the first MPDU. | ||
1275 | */ | ||
1276 | if (rs->rs_isaggr && !rs->rs_firstaggr) | ||
1277 | return; | ||
1278 | |||
1279 | /* | ||
1280 | * Change the default rx antenna if rx diversity | ||
1281 | * chooses the other antenna 3 times in a row. | ||
1282 | */ | ||
1283 | if (sc->rx.defant != rs->rs_antenna) { | ||
1284 | if (++sc->rx.rxotherant >= 3) | ||
1285 | ath_setdefantenna(sc, rs->rs_antenna); | ||
1286 | } else { | ||
1287 | sc->rx.rxotherant = 0; | ||
1288 | } | ||
1289 | |||
1290 | if (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV) { | ||
1291 | if (common->bt_ant_diversity) | ||
1292 | ath_ant_comb_scan(sc, rs); | ||
1293 | } else { | ||
1294 | ath_ant_comb_scan(sc, rs); | ||
1295 | } | ||
1296 | } | ||
1297 | |||
1136 | static void ath9k_apply_ampdu_details(struct ath_softc *sc, | 1298 | static void ath9k_apply_ampdu_details(struct ath_softc *sc, |
1137 | struct ath_rx_status *rs, struct ieee80211_rx_status *rxs) | 1299 | struct ath_rx_status *rs, struct ieee80211_rx_status *rxs) |
1138 | { | 1300 | { |
@@ -1159,15 +1321,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1159 | struct ath_hw *ah = sc->sc_ah; | 1321 | struct ath_hw *ah = sc->sc_ah; |
1160 | struct ath_common *common = ath9k_hw_common(ah); | 1322 | struct ath_common *common = ath9k_hw_common(ah); |
1161 | struct ieee80211_hw *hw = sc->hw; | 1323 | struct ieee80211_hw *hw = sc->hw; |
1162 | struct ieee80211_hdr *hdr; | ||
1163 | int retval; | 1324 | int retval; |
1164 | struct ath_rx_status rs; | 1325 | struct ath_rx_status rs; |
1165 | enum ath9k_rx_qtype qtype; | 1326 | enum ath9k_rx_qtype qtype; |
1166 | bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); | 1327 | bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); |
1167 | int dma_type; | 1328 | int dma_type; |
1168 | u8 rx_status_len = ah->caps.rx_status_len; | ||
1169 | u64 tsf = 0; | 1329 | u64 tsf = 0; |
1170 | u32 tsf_lower = 0; | ||
1171 | unsigned long flags; | 1330 | unsigned long flags; |
1172 | dma_addr_t new_buf_addr; | 1331 | dma_addr_t new_buf_addr; |
1173 | 1332 | ||
@@ -1179,7 +1338,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1179 | qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP; | 1338 | qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP; |
1180 | 1339 | ||
1181 | tsf = ath9k_hw_gettsf64(ah); | 1340 | tsf = ath9k_hw_gettsf64(ah); |
1182 | tsf_lower = tsf & 0xffffffff; | ||
1183 | 1341 | ||
1184 | do { | 1342 | do { |
1185 | bool decrypt_error = false; | 1343 | bool decrypt_error = false; |
@@ -1206,55 +1364,14 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1206 | else | 1364 | else |
1207 | hdr_skb = skb; | 1365 | hdr_skb = skb; |
1208 | 1366 | ||
1209 | hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len); | ||
1210 | rxs = IEEE80211_SKB_RXCB(hdr_skb); | 1367 | rxs = IEEE80211_SKB_RXCB(hdr_skb); |
1211 | if (ieee80211_is_beacon(hdr->frame_control)) { | ||
1212 | RX_STAT_INC(rx_beacons); | ||
1213 | if (!is_zero_ether_addr(common->curbssid) && | ||
1214 | ether_addr_equal(hdr->addr3, common->curbssid)) | ||
1215 | rs.is_mybeacon = true; | ||
1216 | else | ||
1217 | rs.is_mybeacon = false; | ||
1218 | } | ||
1219 | else | ||
1220 | rs.is_mybeacon = false; | ||
1221 | |||
1222 | if (ieee80211_is_data_present(hdr->frame_control) && | ||
1223 | !ieee80211_is_qos_nullfunc(hdr->frame_control)) | ||
1224 | sc->rx.num_pkts++; | ||
1225 | |||
1226 | ath_debug_stat_rx(sc, &rs); | ||
1227 | |||
1228 | memset(rxs, 0, sizeof(struct ieee80211_rx_status)); | 1368 | memset(rxs, 0, sizeof(struct ieee80211_rx_status)); |
1229 | 1369 | ||
1230 | rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; | 1370 | retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs, |
1231 | if (rs.rs_tstamp > tsf_lower && | 1371 | &decrypt_error, tsf); |
1232 | unlikely(rs.rs_tstamp - tsf_lower > 0x10000000)) | ||
1233 | rxs->mactime -= 0x100000000ULL; | ||
1234 | |||
1235 | if (rs.rs_tstamp < tsf_lower && | ||
1236 | unlikely(tsf_lower - rs.rs_tstamp > 0x10000000)) | ||
1237 | rxs->mactime += 0x100000000ULL; | ||
1238 | |||
1239 | if (rs.rs_phyerr == ATH9K_PHYERR_RADAR) | ||
1240 | ath9k_dfs_process_phyerr(sc, hdr, &rs, rxs->mactime); | ||
1241 | |||
1242 | if (rs.rs_status & ATH9K_RXERR_PHY) { | ||
1243 | if (ath_process_fft(sc, hdr, &rs, rxs->mactime)) { | ||
1244 | RX_STAT_INC(rx_spectral); | ||
1245 | goto requeue_drop_frag; | ||
1246 | } | ||
1247 | } | ||
1248 | |||
1249 | retval = ath9k_rx_skb_preprocess(sc, hdr, &rs, rxs, | ||
1250 | &decrypt_error); | ||
1251 | if (retval) | 1372 | if (retval) |
1252 | goto requeue_drop_frag; | 1373 | goto requeue_drop_frag; |
1253 | 1374 | ||
1254 | if (rs.is_mybeacon) { | ||
1255 | sc->hw_busy_count = 0; | ||
1256 | ath_start_rx_poll(sc, 3); | ||
1257 | } | ||
1258 | /* Ensure we always have an skb to requeue once we are done | 1375 | /* Ensure we always have an skb to requeue once we are done |
1259 | * processing the current buffer's skb */ | 1376 | * processing the current buffer's skb */ |
1260 | requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC); | 1377 | requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC); |
@@ -1308,8 +1425,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1308 | sc->rx.frag = skb; | 1425 | sc->rx.frag = skb; |
1309 | goto requeue; | 1426 | goto requeue; |
1310 | } | 1427 | } |
1311 | if (rs.rs_status & ATH9K_RXERR_CORRUPT_DESC) | ||
1312 | goto requeue_drop_frag; | ||
1313 | 1428 | ||
1314 | if (sc->rx.frag) { | 1429 | if (sc->rx.frag) { |
1315 | int space = skb->len - skb_tailroom(hdr_skb); | 1430 | int space = skb->len - skb_tailroom(hdr_skb); |
@@ -1328,22 +1443,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1328 | skb = hdr_skb; | 1443 | skb = hdr_skb; |
1329 | } | 1444 | } |
1330 | 1445 | ||
1331 | |||
1332 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { | ||
1333 | |||
1334 | /* | ||
1335 | * change the default rx antenna if rx diversity | ||
1336 | * chooses the other antenna 3 times in a row. | ||
1337 | */ | ||
1338 | if (sc->rx.defant != rs.rs_antenna) { | ||
1339 | if (++sc->rx.rxotherant >= 3) | ||
1340 | ath_setdefantenna(sc, rs.rs_antenna); | ||
1341 | } else { | ||
1342 | sc->rx.rxotherant = 0; | ||
1343 | } | ||
1344 | |||
1345 | } | ||
1346 | |||
1347 | if (rxs->flag & RX_FLAG_MMIC_STRIPPED) | 1446 | if (rxs->flag & RX_FLAG_MMIC_STRIPPED) |
1348 | skb_trim(skb, skb->len - 8); | 1447 | skb_trim(skb, skb->len - 8); |
1349 | 1448 | ||
@@ -1355,8 +1454,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1355 | ath_rx_ps(sc, skb, rs.is_mybeacon); | 1454 | ath_rx_ps(sc, skb, rs.is_mybeacon); |
1356 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | 1455 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
1357 | 1456 | ||
1358 | if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx == 3) | 1457 | ath9k_antenna_check(sc, &rs); |
1359 | ath_ant_comb_scan(sc, &rs); | ||
1360 | 1458 | ||
1361 | ath9k_apply_ampdu_details(sc, &rs, rxs); | 1459 | ath9k_apply_ampdu_details(sc, &rs, rxs); |
1362 | 1460 | ||
@@ -1375,7 +1473,7 @@ requeue: | |||
1375 | if (edma) { | 1473 | if (edma) { |
1376 | ath_rx_edma_buf_link(sc, qtype); | 1474 | ath_rx_edma_buf_link(sc, qtype); |
1377 | } else { | 1475 | } else { |
1378 | ath_rx_buf_link(sc, bf); | 1476 | ath_rx_buf_relink(sc, bf); |
1379 | ath9k_hw_rxena(ah); | 1477 | ath9k_hw_rxena(ah); |
1380 | } | 1478 | } |
1381 | } while (1); | 1479 | } while (1); |
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h index 5af97442ac37..a13b2d143d9e 100644 --- a/drivers/net/wireless/ath/ath9k/reg.h +++ b/drivers/net/wireless/ath/ath9k/reg.h | |||
@@ -893,9 +893,9 @@ | |||
893 | 893 | ||
894 | #define AR_SREV_9485(_ah) \ | 894 | #define AR_SREV_9485(_ah) \ |
895 | (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485)) | 895 | (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485)) |
896 | #define AR_SREV_9485_11(_ah) \ | 896 | #define AR_SREV_9485_11_OR_LATER(_ah) \ |
897 | (AR_SREV_9485(_ah) && \ | 897 | (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485) && \ |
898 | ((_ah)->hw_version.macRev == AR_SREV_REVISION_9485_11)) | 898 | ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9485_11)) |
899 | #define AR_SREV_9485_OR_LATER(_ah) \ | 899 | #define AR_SREV_9485_OR_LATER(_ah) \ |
900 | (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485)) | 900 | (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485)) |
901 | 901 | ||
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index c59ae43b9b35..35b515fe3ffa 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c | |||
@@ -135,6 +135,9 @@ static struct ath_frame_info *get_frame_info(struct sk_buff *skb) | |||
135 | 135 | ||
136 | static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) | 136 | static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) |
137 | { | 137 | { |
138 | if (!tid->an->sta) | ||
139 | return; | ||
140 | |||
138 | ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno, | 141 | ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno, |
139 | seqno << IEEE80211_SEQ_SEQ_SHIFT); | 142 | seqno << IEEE80211_SEQ_SEQ_SHIFT); |
140 | } | 143 | } |
@@ -146,6 +149,93 @@ static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, | |||
146 | ARRAY_SIZE(bf->rates)); | 149 | ARRAY_SIZE(bf->rates)); |
147 | } | 150 | } |
148 | 151 | ||
152 | static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq, | ||
153 | struct sk_buff *skb) | ||
154 | { | ||
155 | int q; | ||
156 | |||
157 | q = skb_get_queue_mapping(skb); | ||
158 | if (txq == sc->tx.uapsdq) | ||
159 | txq = sc->tx.txq_map[q]; | ||
160 | |||
161 | if (txq != sc->tx.txq_map[q]) | ||
162 | return; | ||
163 | |||
164 | if (WARN_ON(--txq->pending_frames < 0)) | ||
165 | txq->pending_frames = 0; | ||
166 | |||
167 | if (txq->stopped && | ||
168 | txq->pending_frames < sc->tx.txq_max_pending[q]) { | ||
169 | ieee80211_wake_queue(sc->hw, q); | ||
170 | txq->stopped = false; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | static struct ath_atx_tid * | ||
175 | ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb) | ||
176 | { | ||
177 | struct ieee80211_hdr *hdr; | ||
178 | u8 tidno = 0; | ||
179 | |||
180 | hdr = (struct ieee80211_hdr *) skb->data; | ||
181 | if (ieee80211_is_data_qos(hdr->frame_control)) | ||
182 | tidno = ieee80211_get_qos_ctl(hdr)[0]; | ||
183 | |||
184 | tidno &= IEEE80211_QOS_CTL_TID_MASK; | ||
185 | return ATH_AN_2_TID(an, tidno); | ||
186 | } | ||
187 | |||
188 | static bool ath_tid_has_buffered(struct ath_atx_tid *tid) | ||
189 | { | ||
190 | return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q); | ||
191 | } | ||
192 | |||
193 | static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid) | ||
194 | { | ||
195 | struct sk_buff *skb; | ||
196 | |||
197 | skb = __skb_dequeue(&tid->retry_q); | ||
198 | if (!skb) | ||
199 | skb = __skb_dequeue(&tid->buf_q); | ||
200 | |||
201 | return skb; | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * ath_tx_tid_change_state: | ||
206 | * - clears a-mpdu flag of previous session | ||
207 | * - force sequence number allocation to fix next BlockAck Window | ||
208 | */ | ||
209 | static void | ||
210 | ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid) | ||
211 | { | ||
212 | struct ath_txq *txq = tid->ac->txq; | ||
213 | struct ieee80211_tx_info *tx_info; | ||
214 | struct sk_buff *skb, *tskb; | ||
215 | struct ath_buf *bf; | ||
216 | struct ath_frame_info *fi; | ||
217 | |||
218 | skb_queue_walk_safe(&tid->buf_q, skb, tskb) { | ||
219 | fi = get_frame_info(skb); | ||
220 | bf = fi->bf; | ||
221 | |||
222 | tx_info = IEEE80211_SKB_CB(skb); | ||
223 | tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
224 | |||
225 | if (bf) | ||
226 | continue; | ||
227 | |||
228 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | ||
229 | if (!bf) { | ||
230 | __skb_unlink(skb, &tid->buf_q); | ||
231 | ath_txq_skb_done(sc, txq, skb); | ||
232 | ieee80211_free_txskb(sc->hw, skb); | ||
233 | continue; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | } | ||
238 | |||
149 | static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) | 239 | static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) |
150 | { | 240 | { |
151 | struct ath_txq *txq = tid->ac->txq; | 241 | struct ath_txq *txq = tid->ac->txq; |
@@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) | |||
160 | 250 | ||
161 | memset(&ts, 0, sizeof(ts)); | 251 | memset(&ts, 0, sizeof(ts)); |
162 | 252 | ||
163 | while ((skb = __skb_dequeue(&tid->buf_q))) { | 253 | while ((skb = __skb_dequeue(&tid->retry_q))) { |
164 | fi = get_frame_info(skb); | 254 | fi = get_frame_info(skb); |
165 | bf = fi->bf; | 255 | bf = fi->bf; |
166 | |||
167 | if (!bf) { | 256 | if (!bf) { |
168 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | 257 | ath_txq_skb_done(sc, txq, skb); |
169 | if (!bf) { | 258 | ieee80211_free_txskb(sc->hw, skb); |
170 | ieee80211_free_txskb(sc->hw, skb); | 259 | continue; |
171 | continue; | ||
172 | } | ||
173 | } | 260 | } |
174 | 261 | ||
175 | if (fi->retries) { | 262 | if (fi->baw_tracked) { |
176 | list_add_tail(&bf->list, &bf_head); | ||
177 | ath_tx_update_baw(sc, tid, bf->bf_state.seqno); | 263 | ath_tx_update_baw(sc, tid, bf->bf_state.seqno); |
178 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); | ||
179 | sendbar = true; | 264 | sendbar = true; |
180 | } else { | ||
181 | ath_set_rates(tid->an->vif, tid->an->sta, bf); | ||
182 | ath_tx_send_normal(sc, txq, NULL, skb); | ||
183 | } | 265 | } |
266 | |||
267 | list_add_tail(&bf->list, &bf_head); | ||
268 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); | ||
184 | } | 269 | } |
185 | 270 | ||
186 | if (sendbar) { | 271 | if (sendbar) { |
@@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
209 | } | 294 | } |
210 | 295 | ||
211 | static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid, | 296 | static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid, |
212 | u16 seqno) | 297 | struct ath_buf *bf) |
213 | { | 298 | { |
299 | struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); | ||
300 | u16 seqno = bf->bf_state.seqno; | ||
214 | int index, cindex; | 301 | int index, cindex; |
215 | 302 | ||
216 | index = ATH_BA_INDEX(tid->seq_start, seqno); | 303 | index = ATH_BA_INDEX(tid->seq_start, seqno); |
217 | cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); | 304 | cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); |
218 | __set_bit(cindex, tid->tx_buf); | 305 | __set_bit(cindex, tid->tx_buf); |
306 | fi->baw_tracked = 1; | ||
219 | 307 | ||
220 | if (index >= ((tid->baw_tail - tid->baw_head) & | 308 | if (index >= ((tid->baw_tail - tid->baw_head) & |
221 | (ATH_TID_MAX_BUFS - 1))) { | 309 | (ATH_TID_MAX_BUFS - 1))) { |
@@ -224,12 +312,6 @@ static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
224 | } | 312 | } |
225 | } | 313 | } |
226 | 314 | ||
227 | /* | ||
228 | * TODO: For frame(s) that are in the retry state, we will reuse the | ||
229 | * sequence number(s) without setting the retry bit. The | ||
230 | * alternative is to give up on these and BAR the receiver's window | ||
231 | * forward. | ||
232 | */ | ||
233 | static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, | 315 | static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, |
234 | struct ath_atx_tid *tid) | 316 | struct ath_atx_tid *tid) |
235 | 317 | ||
@@ -243,7 +325,7 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, | |||
243 | memset(&ts, 0, sizeof(ts)); | 325 | memset(&ts, 0, sizeof(ts)); |
244 | INIT_LIST_HEAD(&bf_head); | 326 | INIT_LIST_HEAD(&bf_head); |
245 | 327 | ||
246 | while ((skb = __skb_dequeue(&tid->buf_q))) { | 328 | while ((skb = ath_tid_dequeue(tid))) { |
247 | fi = get_frame_info(skb); | 329 | fi = get_frame_info(skb); |
248 | bf = fi->bf; | 330 | bf = fi->bf; |
249 | 331 | ||
@@ -253,14 +335,8 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, | |||
253 | } | 335 | } |
254 | 336 | ||
255 | list_add_tail(&bf->list, &bf_head); | 337 | list_add_tail(&bf->list, &bf_head); |
256 | |||
257 | ath_tx_update_baw(sc, tid, bf->bf_state.seqno); | ||
258 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); | 338 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); |
259 | } | 339 | } |
260 | |||
261 | tid->seq_next = tid->seq_start; | ||
262 | tid->baw_tail = tid->baw_head; | ||
263 | tid->bar_index = -1; | ||
264 | } | 340 | } |
265 | 341 | ||
266 | static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq, | 342 | static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq, |
@@ -380,7 +456,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
380 | struct ieee80211_tx_rate rates[4]; | 456 | struct ieee80211_tx_rate rates[4]; |
381 | struct ath_frame_info *fi; | 457 | struct ath_frame_info *fi; |
382 | int nframes; | 458 | int nframes; |
383 | u8 tidno; | ||
384 | bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH); | 459 | bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH); |
385 | int i, retries; | 460 | int i, retries; |
386 | int bar_index = -1; | 461 | int bar_index = -1; |
@@ -406,7 +481,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
406 | while (bf) { | 481 | while (bf) { |
407 | bf_next = bf->bf_next; | 482 | bf_next = bf->bf_next; |
408 | 483 | ||
409 | if (!bf->bf_stale || bf_next != NULL) | 484 | if (!bf->bf_state.stale || bf_next != NULL) |
410 | list_move_tail(&bf->list, &bf_head); | 485 | list_move_tail(&bf->list, &bf_head); |
411 | 486 | ||
412 | ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0); | 487 | ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0); |
@@ -417,8 +492,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
417 | } | 492 | } |
418 | 493 | ||
419 | an = (struct ath_node *)sta->drv_priv; | 494 | an = (struct ath_node *)sta->drv_priv; |
420 | tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK; | 495 | tid = ath_get_skb_tid(sc, an, skb); |
421 | tid = ATH_AN_2_TID(an, tidno); | ||
422 | seq_first = tid->seq_start; | 496 | seq_first = tid->seq_start; |
423 | isba = ts->ts_flags & ATH9K_TX_BA; | 497 | isba = ts->ts_flags & ATH9K_TX_BA; |
424 | 498 | ||
@@ -430,7 +504,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
430 | * Only BlockAcks have a TID and therefore normal Acks cannot be | 504 | * Only BlockAcks have a TID and therefore normal Acks cannot be |
431 | * checked | 505 | * checked |
432 | */ | 506 | */ |
433 | if (isba && tidno != ts->tid) | 507 | if (isba && tid->tidno != ts->tid) |
434 | txok = false; | 508 | txok = false; |
435 | 509 | ||
436 | isaggr = bf_isaggr(bf); | 510 | isaggr = bf_isaggr(bf); |
@@ -466,7 +540,8 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
466 | tx_info = IEEE80211_SKB_CB(skb); | 540 | tx_info = IEEE80211_SKB_CB(skb); |
467 | fi = get_frame_info(skb); | 541 | fi = get_frame_info(skb); |
468 | 542 | ||
469 | if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) { | 543 | if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) || |
544 | !tid->active) { | ||
470 | /* | 545 | /* |
471 | * Outside of the current BlockAck window, | 546 | * Outside of the current BlockAck window, |
472 | * maybe part of a previous session | 547 | * maybe part of a previous session |
@@ -499,7 +574,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
499 | * not a holding desc. | 574 | * not a holding desc. |
500 | */ | 575 | */ |
501 | INIT_LIST_HEAD(&bf_head); | 576 | INIT_LIST_HEAD(&bf_head); |
502 | if (bf_next != NULL || !bf_last->bf_stale) | 577 | if (bf_next != NULL || !bf_last->bf_state.stale) |
503 | list_move_tail(&bf->list, &bf_head); | 578 | list_move_tail(&bf->list, &bf_head); |
504 | 579 | ||
505 | if (!txpending) { | 580 | if (!txpending) { |
@@ -523,7 +598,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
523 | ieee80211_sta_eosp(sta); | 598 | ieee80211_sta_eosp(sta); |
524 | } | 599 | } |
525 | /* retry the un-acked ones */ | 600 | /* retry the un-acked ones */ |
526 | if (bf->bf_next == NULL && bf_last->bf_stale) { | 601 | if (bf->bf_next == NULL && bf_last->bf_state.stale) { |
527 | struct ath_buf *tbf; | 602 | struct ath_buf *tbf; |
528 | 603 | ||
529 | tbf = ath_clone_txbuf(sc, bf_last); | 604 | tbf = ath_clone_txbuf(sc, bf_last); |
@@ -560,7 +635,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
560 | if (an->sleeping) | 635 | if (an->sleeping) |
561 | ieee80211_sta_set_buffered(sta, tid->tidno, true); | 636 | ieee80211_sta_set_buffered(sta, tid->tidno, true); |
562 | 637 | ||
563 | skb_queue_splice(&bf_pending, &tid->buf_q); | 638 | skb_queue_splice_tail(&bf_pending, &tid->retry_q); |
564 | if (!an->sleeping) { | 639 | if (!an->sleeping) { |
565 | ath_tx_queue_tid(txq, tid); | 640 | ath_tx_queue_tid(txq, tid); |
566 | 641 | ||
@@ -618,7 +693,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, | |||
618 | } else | 693 | } else |
619 | ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok); | 694 | ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok); |
620 | 695 | ||
621 | if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush) | 696 | if (!flush) |
622 | ath_txq_schedule(sc, txq); | 697 | ath_txq_schedule(sc, txq); |
623 | } | 698 | } |
624 | 699 | ||
@@ -792,15 +867,20 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
792 | 867 | ||
793 | static struct ath_buf * | 868 | static struct ath_buf * |
794 | ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, | 869 | ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, |
795 | struct ath_atx_tid *tid) | 870 | struct ath_atx_tid *tid, struct sk_buff_head **q) |
796 | { | 871 | { |
872 | struct ieee80211_tx_info *tx_info; | ||
797 | struct ath_frame_info *fi; | 873 | struct ath_frame_info *fi; |
798 | struct sk_buff *skb; | 874 | struct sk_buff *skb; |
799 | struct ath_buf *bf; | 875 | struct ath_buf *bf; |
800 | u16 seqno; | 876 | u16 seqno; |
801 | 877 | ||
802 | while (1) { | 878 | while (1) { |
803 | skb = skb_peek(&tid->buf_q); | 879 | *q = &tid->retry_q; |
880 | if (skb_queue_empty(*q)) | ||
881 | *q = &tid->buf_q; | ||
882 | |||
883 | skb = skb_peek(*q); | ||
804 | if (!skb) | 884 | if (!skb) |
805 | break; | 885 | break; |
806 | 886 | ||
@@ -808,13 +888,26 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, | |||
808 | bf = fi->bf; | 888 | bf = fi->bf; |
809 | if (!fi->bf) | 889 | if (!fi->bf) |
810 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | 890 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); |
891 | else | ||
892 | bf->bf_state.stale = false; | ||
811 | 893 | ||
812 | if (!bf) { | 894 | if (!bf) { |
813 | __skb_unlink(skb, &tid->buf_q); | 895 | __skb_unlink(skb, *q); |
896 | ath_txq_skb_done(sc, txq, skb); | ||
814 | ieee80211_free_txskb(sc->hw, skb); | 897 | ieee80211_free_txskb(sc->hw, skb); |
815 | continue; | 898 | continue; |
816 | } | 899 | } |
817 | 900 | ||
901 | bf->bf_next = NULL; | ||
902 | bf->bf_lastbf = bf; | ||
903 | |||
904 | tx_info = IEEE80211_SKB_CB(skb); | ||
905 | tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT; | ||
906 | if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) { | ||
907 | bf->bf_state.bf_type = 0; | ||
908 | return bf; | ||
909 | } | ||
910 | |||
818 | bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR; | 911 | bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR; |
819 | seqno = bf->bf_state.seqno; | 912 | seqno = bf->bf_state.seqno; |
820 | 913 | ||
@@ -828,73 +921,52 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, | |||
828 | 921 | ||
829 | INIT_LIST_HEAD(&bf_head); | 922 | INIT_LIST_HEAD(&bf_head); |
830 | list_add(&bf->list, &bf_head); | 923 | list_add(&bf->list, &bf_head); |
831 | __skb_unlink(skb, &tid->buf_q); | 924 | __skb_unlink(skb, *q); |
832 | ath_tx_update_baw(sc, tid, seqno); | 925 | ath_tx_update_baw(sc, tid, seqno); |
833 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); | 926 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); |
834 | continue; | 927 | continue; |
835 | } | 928 | } |
836 | 929 | ||
837 | bf->bf_next = NULL; | ||
838 | bf->bf_lastbf = bf; | ||
839 | return bf; | 930 | return bf; |
840 | } | 931 | } |
841 | 932 | ||
842 | return NULL; | 933 | return NULL; |
843 | } | 934 | } |
844 | 935 | ||
845 | static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc, | 936 | static bool |
846 | struct ath_txq *txq, | 937 | ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq, |
847 | struct ath_atx_tid *tid, | 938 | struct ath_atx_tid *tid, struct list_head *bf_q, |
848 | struct list_head *bf_q, | 939 | struct ath_buf *bf_first, struct sk_buff_head *tid_q, |
849 | int *aggr_len) | 940 | int *aggr_len) |
850 | { | 941 | { |
851 | #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4) | 942 | #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4) |
852 | struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL; | 943 | struct ath_buf *bf = bf_first, *bf_prev = NULL; |
853 | int rl = 0, nframes = 0, ndelim, prev_al = 0; | 944 | int nframes = 0, ndelim; |
854 | u16 aggr_limit = 0, al = 0, bpad = 0, | 945 | u16 aggr_limit = 0, al = 0, bpad = 0, |
855 | al_delta, h_baw = tid->baw_size / 2; | 946 | al_delta, h_baw = tid->baw_size / 2; |
856 | enum ATH_AGGR_STATUS status = ATH_AGGR_DONE; | ||
857 | struct ieee80211_tx_info *tx_info; | 947 | struct ieee80211_tx_info *tx_info; |
858 | struct ath_frame_info *fi; | 948 | struct ath_frame_info *fi; |
859 | struct sk_buff *skb; | 949 | struct sk_buff *skb; |
950 | bool closed = false; | ||
860 | 951 | ||
861 | do { | 952 | bf = bf_first; |
862 | bf = ath_tx_get_tid_subframe(sc, txq, tid); | 953 | aggr_limit = ath_lookup_rate(sc, bf, tid); |
863 | if (!bf) { | ||
864 | status = ATH_AGGR_BAW_CLOSED; | ||
865 | break; | ||
866 | } | ||
867 | 954 | ||
955 | do { | ||
868 | skb = bf->bf_mpdu; | 956 | skb = bf->bf_mpdu; |
869 | fi = get_frame_info(skb); | 957 | fi = get_frame_info(skb); |
870 | 958 | ||
871 | if (!bf_first) | ||
872 | bf_first = bf; | ||
873 | |||
874 | if (!rl) { | ||
875 | ath_set_rates(tid->an->vif, tid->an->sta, bf); | ||
876 | aggr_limit = ath_lookup_rate(sc, bf, tid); | ||
877 | rl = 1; | ||
878 | } | ||
879 | |||
880 | /* do not exceed aggregation limit */ | 959 | /* do not exceed aggregation limit */ |
881 | al_delta = ATH_AGGR_DELIM_SZ + fi->framelen; | 960 | al_delta = ATH_AGGR_DELIM_SZ + fi->framelen; |
961 | if (nframes) { | ||
962 | if (aggr_limit < al + bpad + al_delta || | ||
963 | ath_lookup_legacy(bf) || nframes >= h_baw) | ||
964 | break; | ||
882 | 965 | ||
883 | if (nframes && | 966 | tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); |
884 | ((aggr_limit < (al + bpad + al_delta + prev_al)) || | 967 | if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) || |
885 | ath_lookup_legacy(bf))) { | 968 | !(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) |
886 | status = ATH_AGGR_LIMITED; | 969 | break; |
887 | break; | ||
888 | } | ||
889 | |||
890 | tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); | ||
891 | if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) | ||
892 | break; | ||
893 | |||
894 | /* do not exceed subframe limit */ | ||
895 | if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) { | ||
896 | status = ATH_AGGR_LIMITED; | ||
897 | break; | ||
898 | } | 970 | } |
899 | 971 | ||
900 | /* add padding for previous frame to aggregation length */ | 972 | /* add padding for previous frame to aggregation length */ |
@@ -912,22 +984,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc, | |||
912 | bf->bf_next = NULL; | 984 | bf->bf_next = NULL; |
913 | 985 | ||
914 | /* link buffers of this frame to the aggregate */ | 986 | /* link buffers of this frame to the aggregate */ |
915 | if (!fi->retries) | 987 | if (!fi->baw_tracked) |
916 | ath_tx_addto_baw(sc, tid, bf->bf_state.seqno); | 988 | ath_tx_addto_baw(sc, tid, bf); |
917 | bf->bf_state.ndelim = ndelim; | 989 | bf->bf_state.ndelim = ndelim; |
918 | 990 | ||
919 | __skb_unlink(skb, &tid->buf_q); | 991 | __skb_unlink(skb, tid_q); |
920 | list_add_tail(&bf->list, bf_q); | 992 | list_add_tail(&bf->list, bf_q); |
921 | if (bf_prev) | 993 | if (bf_prev) |
922 | bf_prev->bf_next = bf; | 994 | bf_prev->bf_next = bf; |
923 | 995 | ||
924 | bf_prev = bf; | 996 | bf_prev = bf; |
925 | 997 | ||
926 | } while (!skb_queue_empty(&tid->buf_q)); | 998 | bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); |
999 | if (!bf) { | ||
1000 | closed = true; | ||
1001 | break; | ||
1002 | } | ||
1003 | } while (ath_tid_has_buffered(tid)); | ||
1004 | |||
1005 | bf = bf_first; | ||
1006 | bf->bf_lastbf = bf_prev; | ||
1007 | |||
1008 | if (bf == bf_prev) { | ||
1009 | al = get_frame_info(bf->bf_mpdu)->framelen; | ||
1010 | bf->bf_state.bf_type = BUF_AMPDU; | ||
1011 | } else { | ||
1012 | TX_STAT_INC(txq->axq_qnum, a_aggr); | ||
1013 | } | ||
927 | 1014 | ||
928 | *aggr_len = al; | 1015 | *aggr_len = al; |
929 | 1016 | ||
930 | return status; | 1017 | return closed; |
931 | #undef PADBYTES | 1018 | #undef PADBYTES |
932 | } | 1019 | } |
933 | 1020 | ||
@@ -999,7 +1086,7 @@ void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop) | |||
999 | } | 1086 | } |
1000 | 1087 | ||
1001 | static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, | 1088 | static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, |
1002 | struct ath_tx_info *info, int len) | 1089 | struct ath_tx_info *info, int len, bool rts) |
1003 | { | 1090 | { |
1004 | struct ath_hw *ah = sc->sc_ah; | 1091 | struct ath_hw *ah = sc->sc_ah; |
1005 | struct sk_buff *skb; | 1092 | struct sk_buff *skb; |
@@ -1008,6 +1095,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, | |||
1008 | const struct ieee80211_rate *rate; | 1095 | const struct ieee80211_rate *rate; |
1009 | struct ieee80211_hdr *hdr; | 1096 | struct ieee80211_hdr *hdr; |
1010 | struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); | 1097 | struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); |
1098 | u32 rts_thresh = sc->hw->wiphy->rts_threshold; | ||
1011 | int i; | 1099 | int i; |
1012 | u8 rix = 0; | 1100 | u8 rix = 0; |
1013 | 1101 | ||
@@ -1030,7 +1118,17 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, | |||
1030 | rix = rates[i].idx; | 1118 | rix = rates[i].idx; |
1031 | info->rates[i].Tries = rates[i].count; | 1119 | info->rates[i].Tries = rates[i].count; |
1032 | 1120 | ||
1033 | if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) { | 1121 | /* |
1122 | * Handle RTS threshold for unaggregated HT frames. | ||
1123 | */ | ||
1124 | if (bf_isampdu(bf) && !bf_isaggr(bf) && | ||
1125 | (rates[i].flags & IEEE80211_TX_RC_MCS) && | ||
1126 | unlikely(rts_thresh != (u32) -1)) { | ||
1127 | if (!rts_thresh || (len > rts_thresh)) | ||
1128 | rts = true; | ||
1129 | } | ||
1130 | |||
1131 | if (rts || rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) { | ||
1034 | info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; | 1132 | info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; |
1035 | info->flags |= ATH9K_TXDESC_RTSENA; | 1133 | info->flags |= ATH9K_TXDESC_RTSENA; |
1036 | } else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { | 1134 | } else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { |
@@ -1123,6 +1221,8 @@ static void ath_tx_fill_desc(struct ath_softc *sc, struct ath_buf *bf, | |||
1123 | struct ath_hw *ah = sc->sc_ah; | 1221 | struct ath_hw *ah = sc->sc_ah; |
1124 | struct ath_buf *bf_first = NULL; | 1222 | struct ath_buf *bf_first = NULL; |
1125 | struct ath_tx_info info; | 1223 | struct ath_tx_info info; |
1224 | u32 rts_thresh = sc->hw->wiphy->rts_threshold; | ||
1225 | bool rts = false; | ||
1126 | 1226 | ||
1127 | memset(&info, 0, sizeof(info)); | 1227 | memset(&info, 0, sizeof(info)); |
1128 | info.is_first = true; | 1228 | info.is_first = true; |
@@ -1159,7 +1259,22 @@ static void ath_tx_fill_desc(struct ath_softc *sc, struct ath_buf *bf, | |||
1159 | info.flags |= (u32) bf->bf_state.bfs_paprd << | 1259 | info.flags |= (u32) bf->bf_state.bfs_paprd << |
1160 | ATH9K_TXDESC_PAPRD_S; | 1260 | ATH9K_TXDESC_PAPRD_S; |
1161 | 1261 | ||
1162 | ath_buf_set_rate(sc, bf, &info, len); | 1262 | /* |
1263 | * mac80211 doesn't handle RTS threshold for HT because | ||
1264 | * the decision has to be taken based on AMPDU length | ||
1265 | * and aggregation is done entirely inside ath9k. | ||
1266 | * Set the RTS/CTS flag for the first subframe based | ||
1267 | * on the threshold. | ||
1268 | */ | ||
1269 | if (aggr && (bf == bf_first) && | ||
1270 | unlikely(rts_thresh != (u32) -1)) { | ||
1271 | /* | ||
1272 | * "len" is the size of the entire AMPDU. | ||
1273 | */ | ||
1274 | if (!rts_thresh || (len > rts_thresh)) | ||
1275 | rts = true; | ||
1276 | } | ||
1277 | ath_buf_set_rate(sc, bf, &info, len, rts); | ||
1163 | } | 1278 | } |
1164 | 1279 | ||
1165 | info.buf_addr[0] = bf->bf_buf_addr; | 1280 | info.buf_addr[0] = bf->bf_buf_addr; |
@@ -1188,53 +1303,86 @@ static void ath_tx_fill_desc(struct ath_softc *sc, struct ath_buf *bf, | |||
1188 | } | 1303 | } |
1189 | } | 1304 | } |
1190 | 1305 | ||
1191 | static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq, | 1306 | static void |
1192 | struct ath_atx_tid *tid) | 1307 | ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq, |
1308 | struct ath_atx_tid *tid, struct list_head *bf_q, | ||
1309 | struct ath_buf *bf_first, struct sk_buff_head *tid_q) | ||
1193 | { | 1310 | { |
1194 | struct ath_buf *bf; | 1311 | struct ath_buf *bf = bf_first, *bf_prev = NULL; |
1195 | enum ATH_AGGR_STATUS status; | 1312 | struct sk_buff *skb; |
1196 | struct ieee80211_tx_info *tx_info; | 1313 | int nframes = 0; |
1197 | struct list_head bf_q; | ||
1198 | int aggr_len; | ||
1199 | 1314 | ||
1200 | do { | 1315 | do { |
1201 | if (skb_queue_empty(&tid->buf_q)) | 1316 | struct ieee80211_tx_info *tx_info; |
1202 | return; | 1317 | skb = bf->bf_mpdu; |
1203 | 1318 | ||
1204 | INIT_LIST_HEAD(&bf_q); | 1319 | nframes++; |
1320 | __skb_unlink(skb, tid_q); | ||
1321 | list_add_tail(&bf->list, bf_q); | ||
1322 | if (bf_prev) | ||
1323 | bf_prev->bf_next = bf; | ||
1324 | bf_prev = bf; | ||
1205 | 1325 | ||
1206 | status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len); | 1326 | if (nframes >= 2) |
1327 | break; | ||
1207 | 1328 | ||
1208 | /* | 1329 | bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); |
1209 | * no frames picked up to be aggregated; | 1330 | if (!bf) |
1210 | * block-ack window is not open. | ||
1211 | */ | ||
1212 | if (list_empty(&bf_q)) | ||
1213 | break; | 1331 | break; |
1214 | 1332 | ||
1215 | bf = list_first_entry(&bf_q, struct ath_buf, list); | ||
1216 | bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list); | ||
1217 | tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); | 1333 | tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); |
1334 | if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) | ||
1335 | break; | ||
1218 | 1336 | ||
1219 | if (tid->ac->clear_ps_filter) { | 1337 | ath_set_rates(tid->an->vif, tid->an->sta, bf); |
1220 | tid->ac->clear_ps_filter = false; | 1338 | } while (1); |
1221 | tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1339 | } |
1222 | } else { | ||
1223 | tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT; | ||
1224 | } | ||
1225 | 1340 | ||
1226 | /* if only one frame, send as non-aggregate */ | 1341 | static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq, |
1227 | if (bf == bf->bf_lastbf) { | 1342 | struct ath_atx_tid *tid, bool *stop) |
1228 | aggr_len = get_frame_info(bf->bf_mpdu)->framelen; | 1343 | { |
1229 | bf->bf_state.bf_type = BUF_AMPDU; | 1344 | struct ath_buf *bf; |
1230 | } else { | 1345 | struct ieee80211_tx_info *tx_info; |
1231 | TX_STAT_INC(txq->axq_qnum, a_aggr); | 1346 | struct sk_buff_head *tid_q; |
1232 | } | 1347 | struct list_head bf_q; |
1348 | int aggr_len = 0; | ||
1349 | bool aggr, last = true; | ||
1350 | |||
1351 | if (!ath_tid_has_buffered(tid)) | ||
1352 | return false; | ||
1353 | |||
1354 | INIT_LIST_HEAD(&bf_q); | ||
1355 | |||
1356 | bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); | ||
1357 | if (!bf) | ||
1358 | return false; | ||
1359 | |||
1360 | tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); | ||
1361 | aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU); | ||
1362 | if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) || | ||
1363 | (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) { | ||
1364 | *stop = true; | ||
1365 | return false; | ||
1366 | } | ||
1367 | |||
1368 | ath_set_rates(tid->an->vif, tid->an->sta, bf); | ||
1369 | if (aggr) | ||
1370 | last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf, | ||
1371 | tid_q, &aggr_len); | ||
1372 | else | ||
1373 | ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q); | ||
1374 | |||
1375 | if (list_empty(&bf_q)) | ||
1376 | return false; | ||
1233 | 1377 | ||
1234 | ath_tx_fill_desc(sc, bf, txq, aggr_len); | 1378 | if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) { |
1235 | ath_tx_txqaddbuf(sc, txq, &bf_q, false); | 1379 | tid->ac->clear_ps_filter = false; |
1236 | } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH && | 1380 | tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1237 | status != ATH_AGGR_BAW_CLOSED); | 1381 | } |
1382 | |||
1383 | ath_tx_fill_desc(sc, bf, txq, aggr_len); | ||
1384 | ath_tx_txqaddbuf(sc, txq, &bf_q, false); | ||
1385 | return true; | ||
1238 | } | 1386 | } |
1239 | 1387 | ||
1240 | int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | 1388 | int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, |
@@ -1258,6 +1406,9 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1258 | an->mpdudensity = density; | 1406 | an->mpdudensity = density; |
1259 | } | 1407 | } |
1260 | 1408 | ||
1409 | /* force sequence number allocation for pending frames */ | ||
1410 | ath_tx_tid_change_state(sc, txtid); | ||
1411 | |||
1261 | txtid->active = true; | 1412 | txtid->active = true; |
1262 | txtid->paused = true; | 1413 | txtid->paused = true; |
1263 | *ssn = txtid->seq_start = txtid->seq_next; | 1414 | *ssn = txtid->seq_start = txtid->seq_next; |
@@ -1277,8 +1428,9 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) | |||
1277 | 1428 | ||
1278 | ath_txq_lock(sc, txq); | 1429 | ath_txq_lock(sc, txq); |
1279 | txtid->active = false; | 1430 | txtid->active = false; |
1280 | txtid->paused = true; | 1431 | txtid->paused = false; |
1281 | ath_tx_flush_tid(sc, txtid); | 1432 | ath_tx_flush_tid(sc, txtid); |
1433 | ath_tx_tid_change_state(sc, txtid); | ||
1282 | ath_txq_unlock_complete(sc, txq); | 1434 | ath_txq_unlock_complete(sc, txq); |
1283 | } | 1435 | } |
1284 | 1436 | ||
@@ -1302,7 +1454,7 @@ void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, | |||
1302 | 1454 | ||
1303 | ath_txq_lock(sc, txq); | 1455 | ath_txq_lock(sc, txq); |
1304 | 1456 | ||
1305 | buffered = !skb_queue_empty(&tid->buf_q); | 1457 | buffered = ath_tid_has_buffered(tid); |
1306 | 1458 | ||
1307 | tid->sched = false; | 1459 | tid->sched = false; |
1308 | list_del(&tid->list); | 1460 | list_del(&tid->list); |
@@ -1334,7 +1486,7 @@ void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an) | |||
1334 | ath_txq_lock(sc, txq); | 1486 | ath_txq_lock(sc, txq); |
1335 | ac->clear_ps_filter = true; | 1487 | ac->clear_ps_filter = true; |
1336 | 1488 | ||
1337 | if (!skb_queue_empty(&tid->buf_q) && !tid->paused) { | 1489 | if (!tid->paused && ath_tid_has_buffered(tid)) { |
1338 | ath_tx_queue_tid(txq, tid); | 1490 | ath_tx_queue_tid(txq, tid); |
1339 | ath_txq_schedule(sc, txq); | 1491 | ath_txq_schedule(sc, txq); |
1340 | } | 1492 | } |
@@ -1359,7 +1511,7 @@ void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1359 | tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; | 1511 | tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; |
1360 | tid->paused = false; | 1512 | tid->paused = false; |
1361 | 1513 | ||
1362 | if (!skb_queue_empty(&tid->buf_q)) { | 1514 | if (ath_tid_has_buffered(tid)) { |
1363 | ath_tx_queue_tid(txq, tid); | 1515 | ath_tx_queue_tid(txq, tid); |
1364 | ath_txq_schedule(sc, txq); | 1516 | ath_txq_schedule(sc, txq); |
1365 | } | 1517 | } |
@@ -1379,6 +1531,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw, | |||
1379 | struct ieee80211_tx_info *info; | 1531 | struct ieee80211_tx_info *info; |
1380 | struct list_head bf_q; | 1532 | struct list_head bf_q; |
1381 | struct ath_buf *bf_tail = NULL, *bf; | 1533 | struct ath_buf *bf_tail = NULL, *bf; |
1534 | struct sk_buff_head *tid_q; | ||
1382 | int sent = 0; | 1535 | int sent = 0; |
1383 | int i; | 1536 | int i; |
1384 | 1537 | ||
@@ -1394,15 +1547,15 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw, | |||
1394 | continue; | 1547 | continue; |
1395 | 1548 | ||
1396 | ath_txq_lock(sc, tid->ac->txq); | 1549 | ath_txq_lock(sc, tid->ac->txq); |
1397 | while (!skb_queue_empty(&tid->buf_q) && nframes > 0) { | 1550 | while (nframes > 0) { |
1398 | bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid); | 1551 | bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q); |
1399 | if (!bf) | 1552 | if (!bf) |
1400 | break; | 1553 | break; |
1401 | 1554 | ||
1402 | __skb_unlink(bf->bf_mpdu, &tid->buf_q); | 1555 | __skb_unlink(bf->bf_mpdu, tid_q); |
1403 | list_add_tail(&bf->list, &bf_q); | 1556 | list_add_tail(&bf->list, &bf_q); |
1404 | ath_set_rates(tid->an->vif, tid->an->sta, bf); | 1557 | ath_set_rates(tid->an->vif, tid->an->sta, bf); |
1405 | ath_tx_addto_baw(sc, tid, bf->bf_state.seqno); | 1558 | ath_tx_addto_baw(sc, tid, bf); |
1406 | bf->bf_state.bf_type &= ~BUF_AGGR; | 1559 | bf->bf_state.bf_type &= ~BUF_AGGR; |
1407 | if (bf_tail) | 1560 | if (bf_tail) |
1408 | bf_tail->bf_next = bf; | 1561 | bf_tail->bf_next = bf; |
@@ -1412,7 +1565,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw, | |||
1412 | sent++; | 1565 | sent++; |
1413 | TX_STAT_INC(txq->axq_qnum, a_queued_hw); | 1566 | TX_STAT_INC(txq->axq_qnum, a_queued_hw); |
1414 | 1567 | ||
1415 | if (skb_queue_empty(&tid->buf_q)) | 1568 | if (an->sta && !ath_tid_has_buffered(tid)) |
1416 | ieee80211_sta_set_buffered(an->sta, i, false); | 1569 | ieee80211_sta_set_buffered(an->sta, i, false); |
1417 | } | 1570 | } |
1418 | ath_txq_unlock_complete(sc, tid->ac->txq); | 1571 | ath_txq_unlock_complete(sc, tid->ac->txq); |
@@ -1571,7 +1724,7 @@ static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq, | |||
1571 | while (!list_empty(list)) { | 1724 | while (!list_empty(list)) { |
1572 | bf = list_first_entry(list, struct ath_buf, list); | 1725 | bf = list_first_entry(list, struct ath_buf, list); |
1573 | 1726 | ||
1574 | if (bf->bf_stale) { | 1727 | if (bf->bf_state.stale) { |
1575 | list_del(&bf->list); | 1728 | list_del(&bf->list); |
1576 | 1729 | ||
1577 | ath_tx_return_buffer(sc, bf); | 1730 | ath_tx_return_buffer(sc, bf); |
@@ -1665,25 +1818,27 @@ void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq) | |||
1665 | */ | 1818 | */ |
1666 | void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) | 1819 | void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) |
1667 | { | 1820 | { |
1668 | struct ath_atx_ac *ac, *ac_tmp, *last_ac; | 1821 | struct ath_atx_ac *ac, *last_ac; |
1669 | struct ath_atx_tid *tid, *last_tid; | 1822 | struct ath_atx_tid *tid, *last_tid; |
1823 | bool sent = false; | ||
1670 | 1824 | ||
1671 | if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) || | 1825 | if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) || |
1672 | list_empty(&txq->axq_acq) || | 1826 | list_empty(&txq->axq_acq)) |
1673 | txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) | ||
1674 | return; | 1827 | return; |
1675 | 1828 | ||
1676 | rcu_read_lock(); | 1829 | rcu_read_lock(); |
1677 | 1830 | ||
1678 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list); | ||
1679 | last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list); | 1831 | last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list); |
1832 | while (!list_empty(&txq->axq_acq)) { | ||
1833 | bool stop = false; | ||
1680 | 1834 | ||
1681 | list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) { | 1835 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list); |
1682 | last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list); | 1836 | last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list); |
1683 | list_del(&ac->list); | 1837 | list_del(&ac->list); |
1684 | ac->sched = false; | 1838 | ac->sched = false; |
1685 | 1839 | ||
1686 | while (!list_empty(&ac->tid_q)) { | 1840 | while (!list_empty(&ac->tid_q)) { |
1841 | |||
1687 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, | 1842 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, |
1688 | list); | 1843 | list); |
1689 | list_del(&tid->list); | 1844 | list_del(&tid->list); |
@@ -1692,17 +1847,17 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) | |||
1692 | if (tid->paused) | 1847 | if (tid->paused) |
1693 | continue; | 1848 | continue; |
1694 | 1849 | ||
1695 | ath_tx_sched_aggr(sc, txq, tid); | 1850 | if (ath_tx_sched_aggr(sc, txq, tid, &stop)) |
1851 | sent = true; | ||
1696 | 1852 | ||
1697 | /* | 1853 | /* |
1698 | * add tid to round-robin queue if more frames | 1854 | * add tid to round-robin queue if more frames |
1699 | * are pending for the tid | 1855 | * are pending for the tid |
1700 | */ | 1856 | */ |
1701 | if (!skb_queue_empty(&tid->buf_q)) | 1857 | if (ath_tid_has_buffered(tid)) |
1702 | ath_tx_queue_tid(txq, tid); | 1858 | ath_tx_queue_tid(txq, tid); |
1703 | 1859 | ||
1704 | if (tid == last_tid || | 1860 | if (stop || tid == last_tid) |
1705 | txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) | ||
1706 | break; | 1861 | break; |
1707 | } | 1862 | } |
1708 | 1863 | ||
@@ -1711,9 +1866,17 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) | |||
1711 | list_add_tail(&ac->list, &txq->axq_acq); | 1866 | list_add_tail(&ac->list, &txq->axq_acq); |
1712 | } | 1867 | } |
1713 | 1868 | ||
1714 | if (ac == last_ac || | 1869 | if (stop) |
1715 | txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) | ||
1716 | break; | 1870 | break; |
1871 | |||
1872 | if (ac == last_ac) { | ||
1873 | if (!sent) | ||
1874 | break; | ||
1875 | |||
1876 | sent = false; | ||
1877 | last_ac = list_entry(txq->axq_acq.prev, | ||
1878 | struct ath_atx_ac, list); | ||
1879 | } | ||
1717 | } | 1880 | } |
1718 | 1881 | ||
1719 | rcu_read_unlock(); | 1882 | rcu_read_unlock(); |
@@ -1792,57 +1955,6 @@ static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq, | |||
1792 | } | 1955 | } |
1793 | } | 1956 | } |
1794 | 1957 | ||
1795 | static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq, | ||
1796 | struct ath_atx_tid *tid, struct sk_buff *skb, | ||
1797 | struct ath_tx_control *txctl) | ||
1798 | { | ||
1799 | struct ath_frame_info *fi = get_frame_info(skb); | ||
1800 | struct list_head bf_head; | ||
1801 | struct ath_buf *bf; | ||
1802 | |||
1803 | /* | ||
1804 | * Do not queue to h/w when any of the following conditions is true: | ||
1805 | * - there are pending frames in software queue | ||
1806 | * - the TID is currently paused for ADDBA/BAR request | ||
1807 | * - seqno is not within block-ack window | ||
1808 | * - h/w queue depth exceeds low water mark | ||
1809 | */ | ||
1810 | if ((!skb_queue_empty(&tid->buf_q) || tid->paused || | ||
1811 | !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) || | ||
1812 | txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) && | ||
1813 | txq != sc->tx.uapsdq) { | ||
1814 | /* | ||
1815 | * Add this frame to software queue for scheduling later | ||
1816 | * for aggregation. | ||
1817 | */ | ||
1818 | TX_STAT_INC(txq->axq_qnum, a_queued_sw); | ||
1819 | __skb_queue_tail(&tid->buf_q, skb); | ||
1820 | if (!txctl->an || !txctl->an->sleeping) | ||
1821 | ath_tx_queue_tid(txq, tid); | ||
1822 | return; | ||
1823 | } | ||
1824 | |||
1825 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | ||
1826 | if (!bf) { | ||
1827 | ieee80211_free_txskb(sc->hw, skb); | ||
1828 | return; | ||
1829 | } | ||
1830 | |||
1831 | ath_set_rates(tid->an->vif, tid->an->sta, bf); | ||
1832 | bf->bf_state.bf_type = BUF_AMPDU; | ||
1833 | INIT_LIST_HEAD(&bf_head); | ||
1834 | list_add(&bf->list, &bf_head); | ||
1835 | |||
1836 | /* Add sub-frame to BAW */ | ||
1837 | ath_tx_addto_baw(sc, tid, bf->bf_state.seqno); | ||
1838 | |||
1839 | /* Queue to h/w without aggregation */ | ||
1840 | TX_STAT_INC(txq->axq_qnum, a_queued_hw); | ||
1841 | bf->bf_lastbf = bf; | ||
1842 | ath_tx_fill_desc(sc, bf, txq, fi->framelen); | ||
1843 | ath_tx_txqaddbuf(sc, txq, &bf_head, false); | ||
1844 | } | ||
1845 | |||
1846 | static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq, | 1958 | static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq, |
1847 | struct ath_atx_tid *tid, struct sk_buff *skb) | 1959 | struct ath_atx_tid *tid, struct sk_buff *skb) |
1848 | { | 1960 | { |
@@ -1985,6 +2097,7 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1985 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 2097 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1986 | struct ieee80211_sta *sta = txctl->sta; | 2098 | struct ieee80211_sta *sta = txctl->sta; |
1987 | struct ieee80211_vif *vif = info->control.vif; | 2099 | struct ieee80211_vif *vif = info->control.vif; |
2100 | struct ath_vif *avp; | ||
1988 | struct ath_softc *sc = hw->priv; | 2101 | struct ath_softc *sc = hw->priv; |
1989 | int frmlen = skb->len + FCS_LEN; | 2102 | int frmlen = skb->len + FCS_LEN; |
1990 | int padpos, padsize; | 2103 | int padpos, padsize; |
@@ -1992,6 +2105,10 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1992 | /* NOTE: sta can be NULL according to net/mac80211.h */ | 2105 | /* NOTE: sta can be NULL according to net/mac80211.h */ |
1993 | if (sta) | 2106 | if (sta) |
1994 | txctl->an = (struct ath_node *)sta->drv_priv; | 2107 | txctl->an = (struct ath_node *)sta->drv_priv; |
2108 | else if (vif && ieee80211_is_data(hdr->frame_control)) { | ||
2109 | avp = (void *)vif->drv_priv; | ||
2110 | txctl->an = &avp->mcast_node; | ||
2111 | } | ||
1995 | 2112 | ||
1996 | if (info->control.hw_key) | 2113 | if (info->control.hw_key) |
1997 | frmlen += info->control.hw_key->icv_len; | 2114 | frmlen += info->control.hw_key->icv_len; |
@@ -2041,7 +2158,6 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2041 | struct ath_txq *txq = txctl->txq; | 2158 | struct ath_txq *txq = txctl->txq; |
2042 | struct ath_atx_tid *tid = NULL; | 2159 | struct ath_atx_tid *tid = NULL; |
2043 | struct ath_buf *bf; | 2160 | struct ath_buf *bf; |
2044 | u8 tidno; | ||
2045 | int q; | 2161 | int q; |
2046 | int ret; | 2162 | int ret; |
2047 | 2163 | ||
@@ -2069,27 +2185,31 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2069 | ath_txq_unlock(sc, txq); | 2185 | ath_txq_unlock(sc, txq); |
2070 | txq = sc->tx.uapsdq; | 2186 | txq = sc->tx.uapsdq; |
2071 | ath_txq_lock(sc, txq); | 2187 | ath_txq_lock(sc, txq); |
2072 | } | 2188 | } else if (txctl->an && |
2073 | 2189 | ieee80211_is_data_present(hdr->frame_control)) { | |
2074 | if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) { | 2190 | tid = ath_get_skb_tid(sc, txctl->an, skb); |
2075 | tidno = ieee80211_get_qos_ctl(hdr)[0] & | ||
2076 | IEEE80211_QOS_CTL_TID_MASK; | ||
2077 | tid = ATH_AN_2_TID(txctl->an, tidno); | ||
2078 | 2191 | ||
2079 | WARN_ON(tid->ac->txq != txctl->txq); | 2192 | WARN_ON(tid->ac->txq != txctl->txq); |
2080 | } | ||
2081 | 2193 | ||
2082 | if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) { | 2194 | if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) |
2195 | tid->ac->clear_ps_filter = true; | ||
2196 | |||
2083 | /* | 2197 | /* |
2084 | * Try aggregation if it's a unicast data frame | 2198 | * Add this frame to software queue for scheduling later |
2085 | * and the destination is HT capable. | 2199 | * for aggregation. |
2086 | */ | 2200 | */ |
2087 | ath_tx_send_ampdu(sc, txq, tid, skb, txctl); | 2201 | TX_STAT_INC(txq->axq_qnum, a_queued_sw); |
2202 | __skb_queue_tail(&tid->buf_q, skb); | ||
2203 | if (!txctl->an->sleeping) | ||
2204 | ath_tx_queue_tid(txq, tid); | ||
2205 | |||
2206 | ath_txq_schedule(sc, txq); | ||
2088 | goto out; | 2207 | goto out; |
2089 | } | 2208 | } |
2090 | 2209 | ||
2091 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | 2210 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); |
2092 | if (!bf) { | 2211 | if (!bf) { |
2212 | ath_txq_skb_done(sc, txq, skb); | ||
2093 | if (txctl->paprd) | 2213 | if (txctl->paprd) |
2094 | dev_kfree_skb_any(skb); | 2214 | dev_kfree_skb_any(skb); |
2095 | else | 2215 | else |
@@ -2142,7 +2262,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
2142 | 2262 | ||
2143 | bf->bf_lastbf = bf; | 2263 | bf->bf_lastbf = bf; |
2144 | ath_set_rates(vif, NULL, bf); | 2264 | ath_set_rates(vif, NULL, bf); |
2145 | ath_buf_set_rate(sc, bf, &info, fi->framelen); | 2265 | ath_buf_set_rate(sc, bf, &info, fi->framelen, false); |
2146 | duration += info.rates[0].PktDuration; | 2266 | duration += info.rates[0].PktDuration; |
2147 | if (bf_tail) | 2267 | if (bf_tail) |
2148 | bf_tail->bf_next = bf; | 2268 | bf_tail->bf_next = bf; |
@@ -2189,7 +2309,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, | |||
2189 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 2309 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
2190 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 2310 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
2191 | struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data; | 2311 | struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data; |
2192 | int q, padpos, padsize; | 2312 | int padpos, padsize; |
2193 | unsigned long flags; | 2313 | unsigned long flags; |
2194 | 2314 | ||
2195 | ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb); | 2315 | ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb); |
@@ -2225,21 +2345,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, | |||
2225 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | 2345 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
2226 | 2346 | ||
2227 | __skb_queue_tail(&txq->complete_q, skb); | 2347 | __skb_queue_tail(&txq->complete_q, skb); |
2228 | 2348 | ath_txq_skb_done(sc, txq, skb); | |
2229 | q = skb_get_queue_mapping(skb); | ||
2230 | if (txq == sc->tx.uapsdq) | ||
2231 | txq = sc->tx.txq_map[q]; | ||
2232 | |||
2233 | if (txq == sc->tx.txq_map[q]) { | ||
2234 | if (WARN_ON(--txq->pending_frames < 0)) | ||
2235 | txq->pending_frames = 0; | ||
2236 | |||
2237 | if (txq->stopped && | ||
2238 | txq->pending_frames < sc->tx.txq_max_pending[q]) { | ||
2239 | ieee80211_wake_queue(sc->hw, q); | ||
2240 | txq->stopped = false; | ||
2241 | } | ||
2242 | } | ||
2243 | } | 2349 | } |
2244 | 2350 | ||
2245 | static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, | 2351 | static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, |
@@ -2360,8 +2466,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) | |||
2360 | 2466 | ||
2361 | if (list_empty(&txq->axq_q)) { | 2467 | if (list_empty(&txq->axq_q)) { |
2362 | txq->axq_link = NULL; | 2468 | txq->axq_link = NULL; |
2363 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) | 2469 | ath_txq_schedule(sc, txq); |
2364 | ath_txq_schedule(sc, txq); | ||
2365 | break; | 2470 | break; |
2366 | } | 2471 | } |
2367 | bf = list_first_entry(&txq->axq_q, struct ath_buf, list); | 2472 | bf = list_first_entry(&txq->axq_q, struct ath_buf, list); |
@@ -2375,7 +2480,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) | |||
2375 | * it with the STALE flag. | 2480 | * it with the STALE flag. |
2376 | */ | 2481 | */ |
2377 | bf_held = NULL; | 2482 | bf_held = NULL; |
2378 | if (bf->bf_stale) { | 2483 | if (bf->bf_state.stale) { |
2379 | bf_held = bf; | 2484 | bf_held = bf; |
2380 | if (list_is_last(&bf_held->list, &txq->axq_q)) | 2485 | if (list_is_last(&bf_held->list, &txq->axq_q)) |
2381 | break; | 2486 | break; |
@@ -2399,7 +2504,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) | |||
2399 | * however leave the last descriptor back as the holding | 2504 | * however leave the last descriptor back as the holding |
2400 | * descriptor for hw. | 2505 | * descriptor for hw. |
2401 | */ | 2506 | */ |
2402 | lastbf->bf_stale = true; | 2507 | lastbf->bf_state.stale = true; |
2403 | INIT_LIST_HEAD(&bf_head); | 2508 | INIT_LIST_HEAD(&bf_head); |
2404 | if (!list_is_singular(&lastbf->list)) | 2509 | if (!list_is_singular(&lastbf->list)) |
2405 | list_cut_position(&bf_head, | 2510 | list_cut_position(&bf_head, |
@@ -2454,6 +2559,8 @@ void ath_tx_edma_tasklet(struct ath_softc *sc) | |||
2454 | if (ts.qid == sc->beacon.beaconq) { | 2559 | if (ts.qid == sc->beacon.beaconq) { |
2455 | sc->beacon.tx_processed = true; | 2560 | sc->beacon.tx_processed = true; |
2456 | sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK); | 2561 | sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK); |
2562 | |||
2563 | ath9k_csa_is_finished(sc); | ||
2457 | continue; | 2564 | continue; |
2458 | } | 2565 | } |
2459 | 2566 | ||
@@ -2470,7 +2577,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc) | |||
2470 | } | 2577 | } |
2471 | 2578 | ||
2472 | bf = list_first_entry(fifo_list, struct ath_buf, list); | 2579 | bf = list_first_entry(fifo_list, struct ath_buf, list); |
2473 | if (bf->bf_stale) { | 2580 | if (bf->bf_state.stale) { |
2474 | list_del(&bf->list); | 2581 | list_del(&bf->list); |
2475 | ath_tx_return_buffer(sc, bf); | 2582 | ath_tx_return_buffer(sc, bf); |
2476 | bf = list_first_entry(fifo_list, struct ath_buf, list); | 2583 | bf = list_first_entry(fifo_list, struct ath_buf, list); |
@@ -2492,7 +2599,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc) | |||
2492 | ath_tx_txqaddbuf(sc, txq, &bf_q, true); | 2599 | ath_tx_txqaddbuf(sc, txq, &bf_q, true); |
2493 | } | 2600 | } |
2494 | } else { | 2601 | } else { |
2495 | lastbf->bf_stale = true; | 2602 | lastbf->bf_state.stale = true; |
2496 | if (bf != lastbf) | 2603 | if (bf != lastbf) |
2497 | list_cut_position(&bf_head, fifo_list, | 2604 | list_cut_position(&bf_head, fifo_list, |
2498 | lastbf->list.prev); | 2605 | lastbf->list.prev); |
@@ -2583,6 +2690,7 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) | |||
2583 | tid->paused = false; | 2690 | tid->paused = false; |
2584 | tid->active = false; | 2691 | tid->active = false; |
2585 | __skb_queue_head_init(&tid->buf_q); | 2692 | __skb_queue_head_init(&tid->buf_q); |
2693 | __skb_queue_head_init(&tid->retry_q); | ||
2586 | acno = TID_TO_WME_AC(tidno); | 2694 | acno = TID_TO_WME_AC(tidno); |
2587 | tid->ac = &an->ac[acno]; | 2695 | tid->ac = &an->ac[acno]; |
2588 | } | 2696 | } |
@@ -2590,6 +2698,7 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) | |||
2590 | for (acno = 0, ac = &an->ac[acno]; | 2698 | for (acno = 0, ac = &an->ac[acno]; |
2591 | acno < IEEE80211_NUM_ACS; acno++, ac++) { | 2699 | acno < IEEE80211_NUM_ACS; acno++, ac++) { |
2592 | ac->sched = false; | 2700 | ac->sched = false; |
2701 | ac->clear_ps_filter = true; | ||
2593 | ac->txq = sc->tx.txq_map[acno]; | 2702 | ac->txq = sc->tx.txq_map[acno]; |
2594 | INIT_LIST_HEAD(&ac->tid_q); | 2703 | INIT_LIST_HEAD(&ac->tid_q); |
2595 | } | 2704 | } |
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 4a33c6e39ca2..349fa22a921a 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c | |||
@@ -1860,7 +1860,8 @@ void *carl9170_alloc(size_t priv_size) | |||
1860 | IEEE80211_HW_PS_NULLFUNC_STACK | | 1860 | IEEE80211_HW_PS_NULLFUNC_STACK | |
1861 | IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC | | 1861 | IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC | |
1862 | IEEE80211_HW_SUPPORTS_RC_TABLE | | 1862 | IEEE80211_HW_SUPPORTS_RC_TABLE | |
1863 | IEEE80211_HW_SIGNAL_DBM; | 1863 | IEEE80211_HW_SIGNAL_DBM | |
1864 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; | ||
1864 | 1865 | ||
1865 | if (!modparam_noht) { | 1866 | if (!modparam_noht) { |
1866 | /* | 1867 | /* |
diff --git a/drivers/net/wireless/ath/wil6210/Makefile b/drivers/net/wireless/ath/wil6210/Makefile index f891d514d881..990dd42ae79e 100644 --- a/drivers/net/wireless/ath/wil6210/Makefile +++ b/drivers/net/wireless/ath/wil6210/Makefile | |||
@@ -11,9 +11,6 @@ wil6210-y += txrx.o | |||
11 | wil6210-y += debug.o | 11 | wil6210-y += debug.o |
12 | wil6210-$(CONFIG_WIL6210_TRACING) += trace.o | 12 | wil6210-$(CONFIG_WIL6210_TRACING) += trace.o |
13 | 13 | ||
14 | ifeq (, $(findstring -W,$(EXTRA_CFLAGS))) | ||
15 | subdir-ccflags-y += -Werror | ||
16 | endif | ||
17 | # for tracing framework to find trace.h | 14 | # for tracing framework to find trace.h |
18 | CFLAGS_trace.o := -I$(src) | 15 | CFLAGS_trace.o := -I$(src) |
19 | 16 | ||
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index e8308ec30970..1caa31992a7e 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c | |||
@@ -51,7 +51,7 @@ static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil, | |||
51 | if ((i % 64) == 0 && (i != 0)) | 51 | if ((i % 64) == 0 && (i != 0)) |
52 | seq_printf(s, "\n"); | 52 | seq_printf(s, "\n"); |
53 | seq_printf(s, "%s", (d->dma.status & BIT(0)) ? | 53 | seq_printf(s, "%s", (d->dma.status & BIT(0)) ? |
54 | "S" : (vring->ctx[i] ? "H" : "h")); | 54 | "S" : (vring->ctx[i].skb ? "H" : "h")); |
55 | } | 55 | } |
56 | seq_printf(s, "\n"); | 56 | seq_printf(s, "\n"); |
57 | } | 57 | } |
@@ -145,7 +145,7 @@ static void wil_print_ring(struct seq_file *s, const char *prefix, | |||
145 | le16_to_cpu(hdr.type), hdr.flags); | 145 | le16_to_cpu(hdr.type), hdr.flags); |
146 | if (len <= MAX_MBOXITEM_SIZE) { | 146 | if (len <= MAX_MBOXITEM_SIZE) { |
147 | int n = 0; | 147 | int n = 0; |
148 | unsigned char printbuf[16 * 3 + 2]; | 148 | char printbuf[16 * 3 + 2]; |
149 | unsigned char databuf[MAX_MBOXITEM_SIZE]; | 149 | unsigned char databuf[MAX_MBOXITEM_SIZE]; |
150 | void __iomem *src = wmi_buffer(wil, d.addr) + | 150 | void __iomem *src = wmi_buffer(wil, d.addr) + |
151 | sizeof(struct wil6210_mbox_hdr); | 151 | sizeof(struct wil6210_mbox_hdr); |
@@ -406,7 +406,7 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data) | |||
406 | volatile struct vring_tx_desc *d = | 406 | volatile struct vring_tx_desc *d = |
407 | &(vring->va[dbg_txdesc_index].tx); | 407 | &(vring->va[dbg_txdesc_index].tx); |
408 | volatile u32 *u = (volatile u32 *)d; | 408 | volatile u32 *u = (volatile u32 *)d; |
409 | struct sk_buff *skb = vring->ctx[dbg_txdesc_index]; | 409 | struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb; |
410 | 410 | ||
411 | seq_printf(s, "Tx[%3d] = {\n", dbg_txdesc_index); | 411 | seq_printf(s, "Tx[%3d] = {\n", dbg_txdesc_index); |
412 | seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n", | 412 | seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n", |
@@ -416,7 +416,7 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data) | |||
416 | seq_printf(s, " SKB = %p\n", skb); | 416 | seq_printf(s, " SKB = %p\n", skb); |
417 | 417 | ||
418 | if (skb) { | 418 | if (skb) { |
419 | unsigned char printbuf[16 * 3 + 2]; | 419 | char printbuf[16 * 3 + 2]; |
420 | int i = 0; | 420 | int i = 0; |
421 | int len = le16_to_cpu(d->dma.length); | 421 | int len = le16_to_cpu(d->dma.length); |
422 | void *p = skb->data; | 422 | void *p = skb->data; |
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c index 29dd1e58cb17..717178f09aa8 100644 --- a/drivers/net/wireless/ath/wil6210/netdev.c +++ b/drivers/net/wireless/ath/wil6210/netdev.c | |||
@@ -127,6 +127,8 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr) | |||
127 | 127 | ||
128 | ndev->netdev_ops = &wil_netdev_ops; | 128 | ndev->netdev_ops = &wil_netdev_ops; |
129 | ndev->ieee80211_ptr = wdev; | 129 | ndev->ieee80211_ptr = wdev; |
130 | ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM; | ||
131 | ndev->features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM; | ||
130 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); | 132 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); |
131 | wdev->netdev = ndev; | 133 | wdev->netdev = ndev; |
132 | 134 | ||
diff --git a/drivers/net/wireless/ath/wil6210/trace.h b/drivers/net/wireless/ath/wil6210/trace.h index eff1239be53a..e59239d22b94 100644 --- a/drivers/net/wireless/ath/wil6210/trace.h +++ b/drivers/net/wireless/ath/wil6210/trace.h | |||
@@ -37,36 +37,40 @@ static inline void trace_ ## name(proto) {} | |||
37 | #endif /* !CONFIG_WIL6210_TRACING || defined(__CHECKER__) */ | 37 | #endif /* !CONFIG_WIL6210_TRACING || defined(__CHECKER__) */ |
38 | 38 | ||
39 | DECLARE_EVENT_CLASS(wil6210_wmi, | 39 | DECLARE_EVENT_CLASS(wil6210_wmi, |
40 | TP_PROTO(u16 id, void *buf, u16 buf_len), | 40 | TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len), |
41 | 41 | ||
42 | TP_ARGS(id, buf, buf_len), | 42 | TP_ARGS(wmi, buf, buf_len), |
43 | 43 | ||
44 | TP_STRUCT__entry( | 44 | TP_STRUCT__entry( |
45 | __field(u8, mid) | ||
45 | __field(u16, id) | 46 | __field(u16, id) |
47 | __field(u32, timestamp) | ||
46 | __field(u16, buf_len) | 48 | __field(u16, buf_len) |
47 | __dynamic_array(u8, buf, buf_len) | 49 | __dynamic_array(u8, buf, buf_len) |
48 | ), | 50 | ), |
49 | 51 | ||
50 | TP_fast_assign( | 52 | TP_fast_assign( |
51 | __entry->id = id; | 53 | __entry->mid = wmi->mid; |
54 | __entry->id = le16_to_cpu(wmi->id); | ||
55 | __entry->timestamp = le32_to_cpu(wmi->timestamp); | ||
52 | __entry->buf_len = buf_len; | 56 | __entry->buf_len = buf_len; |
53 | memcpy(__get_dynamic_array(buf), buf, buf_len); | 57 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
54 | ), | 58 | ), |
55 | 59 | ||
56 | TP_printk( | 60 | TP_printk( |
57 | "id 0x%04x len %d", | 61 | "MID %d id 0x%04x len %d timestamp %d", |
58 | __entry->id, __entry->buf_len | 62 | __entry->mid, __entry->id, __entry->buf_len, __entry->timestamp |
59 | ) | 63 | ) |
60 | ); | 64 | ); |
61 | 65 | ||
62 | DEFINE_EVENT(wil6210_wmi, wil6210_wmi_cmd, | 66 | DEFINE_EVENT(wil6210_wmi, wil6210_wmi_cmd, |
63 | TP_PROTO(u16 id, void *buf, u16 buf_len), | 67 | TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len), |
64 | TP_ARGS(id, buf, buf_len) | 68 | TP_ARGS(wmi, buf, buf_len) |
65 | ); | 69 | ); |
66 | 70 | ||
67 | DEFINE_EVENT(wil6210_wmi, wil6210_wmi_event, | 71 | DEFINE_EVENT(wil6210_wmi, wil6210_wmi_event, |
68 | TP_PROTO(u16 id, void *buf, u16 buf_len), | 72 | TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len), |
69 | TP_ARGS(id, buf, buf_len) | 73 | TP_ARGS(wmi, buf, buf_len) |
70 | ); | 74 | ); |
71 | 75 | ||
72 | #define WIL6210_MSG_MAX (200) | 76 | #define WIL6210_MSG_MAX (200) |
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c index d240b24e1ccf..d505b2676a73 100644 --- a/drivers/net/wireless/ath/wil6210/txrx.c +++ b/drivers/net/wireless/ath/wil6210/txrx.c | |||
@@ -18,6 +18,9 @@ | |||
18 | #include <net/ieee80211_radiotap.h> | 18 | #include <net/ieee80211_radiotap.h> |
19 | #include <linux/if_arp.h> | 19 | #include <linux/if_arp.h> |
20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
21 | #include <linux/ip.h> | ||
22 | #include <linux/ipv6.h> | ||
23 | #include <net/ipv6.h> | ||
21 | 24 | ||
22 | #include "wil6210.h" | 25 | #include "wil6210.h" |
23 | #include "wmi.h" | 26 | #include "wmi.h" |
@@ -70,7 +73,7 @@ static int wil_vring_alloc(struct wil6210_priv *wil, struct vring *vring) | |||
70 | 73 | ||
71 | vring->swhead = 0; | 74 | vring->swhead = 0; |
72 | vring->swtail = 0; | 75 | vring->swtail = 0; |
73 | vring->ctx = kzalloc(vring->size * sizeof(vring->ctx[0]), GFP_KERNEL); | 76 | vring->ctx = kcalloc(vring->size, sizeof(vring->ctx[0]), GFP_KERNEL); |
74 | if (!vring->ctx) { | 77 | if (!vring->ctx) { |
75 | vring->va = NULL; | 78 | vring->va = NULL; |
76 | return -ENOMEM; | 79 | return -ENOMEM; |
@@ -108,39 +111,39 @@ static void wil_vring_free(struct wil6210_priv *wil, struct vring *vring, | |||
108 | 111 | ||
109 | while (!wil_vring_is_empty(vring)) { | 112 | while (!wil_vring_is_empty(vring)) { |
110 | dma_addr_t pa; | 113 | dma_addr_t pa; |
111 | struct sk_buff *skb; | ||
112 | u16 dmalen; | 114 | u16 dmalen; |
115 | struct wil_ctx *ctx; | ||
113 | 116 | ||
114 | if (tx) { | 117 | if (tx) { |
115 | struct vring_tx_desc dd, *d = ⅆ | 118 | struct vring_tx_desc dd, *d = ⅆ |
116 | volatile struct vring_tx_desc *_d = | 119 | volatile struct vring_tx_desc *_d = |
117 | &vring->va[vring->swtail].tx; | 120 | &vring->va[vring->swtail].tx; |
118 | 121 | ||
122 | ctx = &vring->ctx[vring->swtail]; | ||
119 | *d = *_d; | 123 | *d = *_d; |
120 | pa = wil_desc_addr(&d->dma.addr); | 124 | pa = wil_desc_addr(&d->dma.addr); |
121 | dmalen = le16_to_cpu(d->dma.length); | 125 | dmalen = le16_to_cpu(d->dma.length); |
122 | skb = vring->ctx[vring->swtail]; | 126 | if (vring->ctx[vring->swtail].mapped_as_page) { |
123 | if (skb) { | ||
124 | dma_unmap_single(dev, pa, dmalen, | ||
125 | DMA_TO_DEVICE); | ||
126 | dev_kfree_skb_any(skb); | ||
127 | vring->ctx[vring->swtail] = NULL; | ||
128 | } else { | ||
129 | dma_unmap_page(dev, pa, dmalen, | 127 | dma_unmap_page(dev, pa, dmalen, |
130 | DMA_TO_DEVICE); | 128 | DMA_TO_DEVICE); |
129 | } else { | ||
130 | dma_unmap_single(dev, pa, dmalen, | ||
131 | DMA_TO_DEVICE); | ||
131 | } | 132 | } |
133 | if (ctx->skb) | ||
134 | dev_kfree_skb_any(ctx->skb); | ||
132 | vring->swtail = wil_vring_next_tail(vring); | 135 | vring->swtail = wil_vring_next_tail(vring); |
133 | } else { /* rx */ | 136 | } else { /* rx */ |
134 | struct vring_rx_desc dd, *d = ⅆ | 137 | struct vring_rx_desc dd, *d = ⅆ |
135 | volatile struct vring_rx_desc *_d = | 138 | volatile struct vring_rx_desc *_d = |
136 | &vring->va[vring->swtail].rx; | 139 | &vring->va[vring->swhead].rx; |
137 | 140 | ||
141 | ctx = &vring->ctx[vring->swhead]; | ||
138 | *d = *_d; | 142 | *d = *_d; |
139 | pa = wil_desc_addr(&d->dma.addr); | 143 | pa = wil_desc_addr(&d->dma.addr); |
140 | dmalen = le16_to_cpu(d->dma.length); | 144 | dmalen = le16_to_cpu(d->dma.length); |
141 | skb = vring->ctx[vring->swhead]; | ||
142 | dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); | 145 | dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); |
143 | kfree_skb(skb); | 146 | kfree_skb(ctx->skb); |
144 | wil_vring_advance_head(vring, 1); | 147 | wil_vring_advance_head(vring, 1); |
145 | } | 148 | } |
146 | } | 149 | } |
@@ -187,7 +190,7 @@ static int wil_vring_alloc_skb(struct wil6210_priv *wil, struct vring *vring, | |||
187 | d->dma.status = 0; /* BIT(0) should be 0 for HW_OWNED */ | 190 | d->dma.status = 0; /* BIT(0) should be 0 for HW_OWNED */ |
188 | d->dma.length = cpu_to_le16(sz); | 191 | d->dma.length = cpu_to_le16(sz); |
189 | *_d = *d; | 192 | *_d = *d; |
190 | vring->ctx[i] = skb; | 193 | vring->ctx[i].skb = skb; |
191 | 194 | ||
192 | return 0; | 195 | return 0; |
193 | } | 196 | } |
@@ -352,11 +355,11 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil, | |||
352 | return NULL; | 355 | return NULL; |
353 | } | 356 | } |
354 | 357 | ||
355 | skb = vring->ctx[vring->swhead]; | 358 | skb = vring->ctx[vring->swhead].skb; |
356 | d = wil_skb_rxdesc(skb); | 359 | d = wil_skb_rxdesc(skb); |
357 | *d = *_d; | 360 | *d = *_d; |
358 | pa = wil_desc_addr(&d->dma.addr); | 361 | pa = wil_desc_addr(&d->dma.addr); |
359 | vring->ctx[vring->swhead] = NULL; | 362 | vring->ctx[vring->swhead].skb = NULL; |
360 | wil_vring_advance_head(vring, 1); | 363 | wil_vring_advance_head(vring, 1); |
361 | 364 | ||
362 | dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE); | 365 | dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE); |
@@ -407,6 +410,21 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil, | |||
407 | return NULL; | 410 | return NULL; |
408 | } | 411 | } |
409 | 412 | ||
413 | /* L4 IDENT is on when HW calculated checksum, check status | ||
414 | * and in case of error drop the packet | ||
415 | * higher stack layers will handle retransmission (if required) | ||
416 | */ | ||
417 | if (d->dma.status & RX_DMA_STATUS_L4_IDENT) { | ||
418 | /* L4 protocol identified, csum calculated */ | ||
419 | if ((d->dma.error & RX_DMA_ERROR_L4_ERR) == 0) | ||
420 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
421 | /* If HW reports bad checksum, let IP stack re-check it | ||
422 | * For example, HW don't understand Microsoft IP stack that | ||
423 | * mis-calculates TCP checksum - if it should be 0x0, | ||
424 | * it writes 0xffff in violation of RFC 1624 | ||
425 | */ | ||
426 | } | ||
427 | |||
410 | ds_bits = wil_rxdesc_ds_bits(d); | 428 | ds_bits = wil_rxdesc_ds_bits(d); |
411 | if (ds_bits == 1) { | 429 | if (ds_bits == 1) { |
412 | /* | 430 | /* |
@@ -646,6 +664,53 @@ static int wil_tx_desc_map(struct vring_tx_desc *d, dma_addr_t pa, u32 len, | |||
646 | return 0; | 664 | return 0; |
647 | } | 665 | } |
648 | 666 | ||
667 | static int wil_tx_desc_offload_cksum_set(struct wil6210_priv *wil, | ||
668 | struct vring_tx_desc *d, | ||
669 | struct sk_buff *skb) | ||
670 | { | ||
671 | int protocol; | ||
672 | |||
673 | if (skb->ip_summed != CHECKSUM_PARTIAL) | ||
674 | return 0; | ||
675 | |||
676 | switch (skb->protocol) { | ||
677 | case cpu_to_be16(ETH_P_IP): | ||
678 | protocol = ip_hdr(skb)->protocol; | ||
679 | break; | ||
680 | case cpu_to_be16(ETH_P_IPV6): | ||
681 | protocol = ipv6_hdr(skb)->nexthdr; | ||
682 | break; | ||
683 | default: | ||
684 | return -EINVAL; | ||
685 | } | ||
686 | |||
687 | switch (protocol) { | ||
688 | case IPPROTO_TCP: | ||
689 | d->dma.d0 |= (2 << DMA_CFG_DESC_TX_0_L4_TYPE_POS); | ||
690 | /* L4 header len: TCP header length */ | ||
691 | d->dma.d0 |= | ||
692 | (tcp_hdrlen(skb) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK); | ||
693 | break; | ||
694 | case IPPROTO_UDP: | ||
695 | /* L4 header len: UDP header length */ | ||
696 | d->dma.d0 |= | ||
697 | (sizeof(struct udphdr) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK); | ||
698 | break; | ||
699 | default: | ||
700 | return -EINVAL; | ||
701 | } | ||
702 | |||
703 | d->dma.ip_length = skb_network_header_len(skb); | ||
704 | d->dma.b11 = ETH_HLEN; /* MAC header length */ | ||
705 | d->dma.b11 |= BIT(DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS); | ||
706 | /* Enable TCP/UDP checksum */ | ||
707 | d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_POS); | ||
708 | /* Calculate pseudo-header */ | ||
709 | d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_POS); | ||
710 | |||
711 | return 0; | ||
712 | } | ||
713 | |||
649 | static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | 714 | static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, |
650 | struct sk_buff *skb) | 715 | struct sk_buff *skb) |
651 | { | 716 | { |
@@ -655,7 +720,7 @@ static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | |||
655 | u32 swhead = vring->swhead; | 720 | u32 swhead = vring->swhead; |
656 | int avail = wil_vring_avail_tx(vring); | 721 | int avail = wil_vring_avail_tx(vring); |
657 | int nr_frags = skb_shinfo(skb)->nr_frags; | 722 | int nr_frags = skb_shinfo(skb)->nr_frags; |
658 | uint f; | 723 | uint f = 0; |
659 | int vring_index = vring - wil->vring_tx; | 724 | int vring_index = vring - wil->vring_tx; |
660 | uint i = swhead; | 725 | uint i = swhead; |
661 | dma_addr_t pa; | 726 | dma_addr_t pa; |
@@ -686,13 +751,20 @@ static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | |||
686 | return -EINVAL; | 751 | return -EINVAL; |
687 | /* 1-st segment */ | 752 | /* 1-st segment */ |
688 | wil_tx_desc_map(d, pa, skb_headlen(skb), vring_index); | 753 | wil_tx_desc_map(d, pa, skb_headlen(skb), vring_index); |
754 | /* Process TCP/UDP checksum offloading */ | ||
755 | if (wil_tx_desc_offload_cksum_set(wil, d, skb)) { | ||
756 | wil_err(wil, "VRING #%d Failed to set cksum, drop packet\n", | ||
757 | vring_index); | ||
758 | goto dma_error; | ||
759 | } | ||
760 | |||
689 | d->mac.d[2] |= ((nr_frags + 1) << | 761 | d->mac.d[2] |= ((nr_frags + 1) << |
690 | MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS); | 762 | MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS); |
691 | if (nr_frags) | 763 | if (nr_frags) |
692 | *_d = *d; | 764 | *_d = *d; |
693 | 765 | ||
694 | /* middle segments */ | 766 | /* middle segments */ |
695 | for (f = 0; f < nr_frags; f++) { | 767 | for (; f < nr_frags; f++) { |
696 | const struct skb_frag_struct *frag = | 768 | const struct skb_frag_struct *frag = |
697 | &skb_shinfo(skb)->frags[f]; | 769 | &skb_shinfo(skb)->frags[f]; |
698 | int len = skb_frag_size(frag); | 770 | int len = skb_frag_size(frag); |
@@ -703,7 +775,7 @@ static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | |||
703 | if (unlikely(dma_mapping_error(dev, pa))) | 775 | if (unlikely(dma_mapping_error(dev, pa))) |
704 | goto dma_error; | 776 | goto dma_error; |
705 | wil_tx_desc_map(d, pa, len, vring_index); | 777 | wil_tx_desc_map(d, pa, len, vring_index); |
706 | vring->ctx[i] = NULL; | 778 | vring->ctx[i].mapped_as_page = 1; |
707 | *_d = *d; | 779 | *_d = *d; |
708 | } | 780 | } |
709 | /* for the last seg only */ | 781 | /* for the last seg only */ |
@@ -712,6 +784,12 @@ static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | |||
712 | d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS); | 784 | d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS); |
713 | *_d = *d; | 785 | *_d = *d; |
714 | 786 | ||
787 | /* hold reference to skb | ||
788 | * to prevent skb release before accounting | ||
789 | * in case of immediate "tx done" | ||
790 | */ | ||
791 | vring->ctx[i].skb = skb_get(skb); | ||
792 | |||
715 | wil_hex_dump_txrx("Tx ", DUMP_PREFIX_NONE, 32, 4, | 793 | wil_hex_dump_txrx("Tx ", DUMP_PREFIX_NONE, 32, 4, |
716 | (const void *)d, sizeof(*d), false); | 794 | (const void *)d, sizeof(*d), false); |
717 | 795 | ||
@@ -720,29 +798,31 @@ static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring, | |||
720 | wil_dbg_txrx(wil, "Tx swhead %d -> %d\n", swhead, vring->swhead); | 798 | wil_dbg_txrx(wil, "Tx swhead %d -> %d\n", swhead, vring->swhead); |
721 | trace_wil6210_tx(vring_index, swhead, skb->len, nr_frags); | 799 | trace_wil6210_tx(vring_index, swhead, skb->len, nr_frags); |
722 | iowrite32(vring->swhead, wil->csr + HOSTADDR(vring->hwtail)); | 800 | iowrite32(vring->swhead, wil->csr + HOSTADDR(vring->hwtail)); |
723 | /* hold reference to skb | ||
724 | * to prevent skb release before accounting | ||
725 | * in case of immediate "tx done" | ||
726 | */ | ||
727 | vring->ctx[i] = skb_get(skb); | ||
728 | 801 | ||
729 | return 0; | 802 | return 0; |
730 | dma_error: | 803 | dma_error: |
731 | /* unmap what we have mapped */ | 804 | /* unmap what we have mapped */ |
732 | /* Note: increment @f to operate with positive index */ | 805 | nr_frags = f + 1; /* frags mapped + one for skb head */ |
733 | for (f++; f > 0; f--) { | 806 | for (f = 0; f < nr_frags; f++) { |
734 | u16 dmalen; | 807 | u16 dmalen; |
808 | struct wil_ctx *ctx; | ||
735 | 809 | ||
736 | i = (swhead + f) % vring->size; | 810 | i = (swhead + f) % vring->size; |
811 | ctx = &vring->ctx[i]; | ||
737 | _d = &(vring->va[i].tx); | 812 | _d = &(vring->va[i].tx); |
738 | *d = *_d; | 813 | *d = *_d; |
739 | _d->dma.status = TX_DMA_STATUS_DU; | 814 | _d->dma.status = TX_DMA_STATUS_DU; |
740 | pa = wil_desc_addr(&d->dma.addr); | 815 | pa = wil_desc_addr(&d->dma.addr); |
741 | dmalen = le16_to_cpu(d->dma.length); | 816 | dmalen = le16_to_cpu(d->dma.length); |
742 | if (vring->ctx[i]) | 817 | if (ctx->mapped_as_page) |
743 | dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE); | ||
744 | else | ||
745 | dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE); | 818 | dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE); |
819 | else | ||
820 | dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE); | ||
821 | |||
822 | if (ctx->skb) | ||
823 | dev_kfree_skb_any(ctx->skb); | ||
824 | |||
825 | memset(ctx, 0, sizeof(*ctx)); | ||
746 | } | 826 | } |
747 | 827 | ||
748 | return -EINVAL; | 828 | return -EINVAL; |
@@ -821,8 +901,9 @@ int wil_tx_complete(struct wil6210_priv *wil, int ringid) | |||
821 | &vring->va[vring->swtail].tx; | 901 | &vring->va[vring->swtail].tx; |
822 | struct vring_tx_desc dd, *d = ⅆ | 902 | struct vring_tx_desc dd, *d = ⅆ |
823 | dma_addr_t pa; | 903 | dma_addr_t pa; |
824 | struct sk_buff *skb; | ||
825 | u16 dmalen; | 904 | u16 dmalen; |
905 | struct wil_ctx *ctx = &vring->ctx[vring->swtail]; | ||
906 | struct sk_buff *skb = ctx->skb; | ||
826 | 907 | ||
827 | *d = *_d; | 908 | *d = *_d; |
828 | 909 | ||
@@ -840,7 +921,11 @@ int wil_tx_complete(struct wil6210_priv *wil, int ringid) | |||
840 | (const void *)d, sizeof(*d), false); | 921 | (const void *)d, sizeof(*d), false); |
841 | 922 | ||
842 | pa = wil_desc_addr(&d->dma.addr); | 923 | pa = wil_desc_addr(&d->dma.addr); |
843 | skb = vring->ctx[vring->swtail]; | 924 | if (ctx->mapped_as_page) |
925 | dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE); | ||
926 | else | ||
927 | dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE); | ||
928 | |||
844 | if (skb) { | 929 | if (skb) { |
845 | if (d->dma.error == 0) { | 930 | if (d->dma.error == 0) { |
846 | ndev->stats.tx_packets++; | 931 | ndev->stats.tx_packets++; |
@@ -849,16 +934,15 @@ int wil_tx_complete(struct wil6210_priv *wil, int ringid) | |||
849 | ndev->stats.tx_errors++; | 934 | ndev->stats.tx_errors++; |
850 | } | 935 | } |
851 | 936 | ||
852 | dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE); | ||
853 | dev_kfree_skb_any(skb); | 937 | dev_kfree_skb_any(skb); |
854 | vring->ctx[vring->swtail] = NULL; | ||
855 | } else { | ||
856 | dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE); | ||
857 | } | 938 | } |
858 | d->dma.addr.addr_low = 0; | 939 | memset(ctx, 0, sizeof(*ctx)); |
859 | d->dma.addr.addr_high = 0; | 940 | /* |
860 | d->dma.length = 0; | 941 | * There is no need to touch HW descriptor: |
861 | d->dma.status = TX_DMA_STATUS_DU; | 942 | * - ststus bit TX_DMA_STATUS_DU is set by design, |
943 | * so hardware will not try to process this desc., | ||
944 | * - rest of descriptor will be initialized on Tx. | ||
945 | */ | ||
862 | vring->swtail = wil_vring_next_tail(vring); | 946 | vring->swtail = wil_vring_next_tail(vring); |
863 | done++; | 947 | done++; |
864 | } | 948 | } |
diff --git a/drivers/net/wireless/ath/wil6210/txrx.h b/drivers/net/wireless/ath/wil6210/txrx.h index 859aea68a1fa..b3828279204c 100644 --- a/drivers/net/wireless/ath/wil6210/txrx.h +++ b/drivers/net/wireless/ath/wil6210/txrx.h | |||
@@ -235,7 +235,16 @@ struct vring_tx_mac { | |||
235 | 235 | ||
236 | #define DMA_CFG_DESC_TX_0_L4_TYPE_POS 30 | 236 | #define DMA_CFG_DESC_TX_0_L4_TYPE_POS 30 |
237 | #define DMA_CFG_DESC_TX_0_L4_TYPE_LEN 2 | 237 | #define DMA_CFG_DESC_TX_0_L4_TYPE_LEN 2 |
238 | #define DMA_CFG_DESC_TX_0_L4_TYPE_MSK 0xC0000000 | 238 | #define DMA_CFG_DESC_TX_0_L4_TYPE_MSK 0xC0000000 /* L4 type: 0-UDP, 2-TCP */ |
239 | |||
240 | |||
241 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_POS 0 | ||
242 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_LEN 7 | ||
243 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_MSK 0x7F /* MAC hdr len */ | ||
244 | |||
245 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS 7 | ||
246 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_LEN 1 | ||
247 | #define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_MSK 0x80 /* 1-IPv4, 0-IPv6 */ | ||
239 | 248 | ||
240 | 249 | ||
241 | #define TX_DMA_STATUS_DU BIT(0) | 250 | #define TX_DMA_STATUS_DU BIT(0) |
@@ -334,8 +343,17 @@ struct vring_rx_mac { | |||
334 | 343 | ||
335 | #define RX_DMA_D0_CMD_DMA_IT BIT(10) | 344 | #define RX_DMA_D0_CMD_DMA_IT BIT(10) |
336 | 345 | ||
346 | /* Error field, offload bits */ | ||
347 | #define RX_DMA_ERROR_L3_ERR BIT(4) | ||
348 | #define RX_DMA_ERROR_L4_ERR BIT(5) | ||
349 | |||
350 | |||
351 | /* Status field */ | ||
337 | #define RX_DMA_STATUS_DU BIT(0) | 352 | #define RX_DMA_STATUS_DU BIT(0) |
338 | #define RX_DMA_STATUS_ERROR BIT(2) | 353 | #define RX_DMA_STATUS_ERROR BIT(2) |
354 | |||
355 | #define RX_DMA_STATUS_L3_IDENT BIT(4) | ||
356 | #define RX_DMA_STATUS_L4_IDENT BIT(5) | ||
339 | #define RX_DMA_STATUS_PHY_INFO BIT(6) | 357 | #define RX_DMA_STATUS_PHY_INFO BIT(6) |
340 | 358 | ||
341 | struct vring_rx_dma { | 359 | struct vring_rx_dma { |
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h index 44fdab51de7e..c4a51638736a 100644 --- a/drivers/net/wireless/ath/wil6210/wil6210.h +++ b/drivers/net/wireless/ath/wil6210/wil6210.h | |||
@@ -156,11 +156,22 @@ struct wil6210_mbox_hdr { | |||
156 | /* max. value for wil6210_mbox_hdr.len */ | 156 | /* max. value for wil6210_mbox_hdr.len */ |
157 | #define MAX_MBOXITEM_SIZE (240) | 157 | #define MAX_MBOXITEM_SIZE (240) |
158 | 158 | ||
159 | /** | ||
160 | * struct wil6210_mbox_hdr_wmi - WMI header | ||
161 | * | ||
162 | * @mid: MAC ID | ||
163 | * 00 - default, created by FW | ||
164 | * 01..0f - WiFi ports, driver to create | ||
165 | * 10..fe - debug | ||
166 | * ff - broadcast | ||
167 | * @id: command/event ID | ||
168 | * @timestamp: FW fills for events, free-running msec timer | ||
169 | */ | ||
159 | struct wil6210_mbox_hdr_wmi { | 170 | struct wil6210_mbox_hdr_wmi { |
160 | u8 reserved0[2]; | 171 | u8 mid; |
172 | u8 reserved; | ||
161 | __le16 id; | 173 | __le16 id; |
162 | __le16 info1; /* bits [0..3] - device_id, rest - unused */ | 174 | __le32 timestamp; |
163 | u8 reserved1[2]; | ||
164 | } __packed; | 175 | } __packed; |
165 | 176 | ||
166 | struct pending_wmi_event { | 177 | struct pending_wmi_event { |
@@ -172,6 +183,14 @@ struct pending_wmi_event { | |||
172 | } __packed event; | 183 | } __packed event; |
173 | }; | 184 | }; |
174 | 185 | ||
186 | /** | ||
187 | * struct wil_ctx - software context for Vring descriptor | ||
188 | */ | ||
189 | struct wil_ctx { | ||
190 | struct sk_buff *skb; | ||
191 | u8 mapped_as_page:1; | ||
192 | }; | ||
193 | |||
175 | union vring_desc; | 194 | union vring_desc; |
176 | 195 | ||
177 | struct vring { | 196 | struct vring { |
@@ -181,7 +200,7 @@ struct vring { | |||
181 | u32 swtail; | 200 | u32 swtail; |
182 | u32 swhead; | 201 | u32 swhead; |
183 | u32 hwtail; /* write here to inform hw */ | 202 | u32 hwtail; /* write here to inform hw */ |
184 | void **ctx; /* void *ctx[size] - software context */ | 203 | struct wil_ctx *ctx; /* ctx[size] - software context */ |
185 | }; | 204 | }; |
186 | 205 | ||
187 | enum { /* for wil6210_priv.status */ | 206 | enum { /* for wil6210_priv.status */ |
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c index 21c791ee8178..063963ee422a 100644 --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c | |||
@@ -172,8 +172,8 @@ static int __wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len) | |||
172 | .len = cpu_to_le16(sizeof(cmd.wmi) + len), | 172 | .len = cpu_to_le16(sizeof(cmd.wmi) + len), |
173 | }, | 173 | }, |
174 | .wmi = { | 174 | .wmi = { |
175 | .mid = 0, | ||
175 | .id = cpu_to_le16(cmdid), | 176 | .id = cpu_to_le16(cmdid), |
176 | .info1 = 0, | ||
177 | }, | 177 | }, |
178 | }; | 178 | }; |
179 | struct wil6210_mbox_ring *r = &wil->mbox_ctl.tx; | 179 | struct wil6210_mbox_ring *r = &wil->mbox_ctl.tx; |
@@ -248,7 +248,7 @@ static int __wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len) | |||
248 | iowrite32(r->head = next_head, wil->csr + HOST_MBOX + | 248 | iowrite32(r->head = next_head, wil->csr + HOST_MBOX + |
249 | offsetof(struct wil6210_mbox_ctl, tx.head)); | 249 | offsetof(struct wil6210_mbox_ctl, tx.head)); |
250 | 250 | ||
251 | trace_wil6210_wmi_cmd(cmdid, buf, len); | 251 | trace_wil6210_wmi_cmd(&cmd.wmi, buf, len); |
252 | 252 | ||
253 | /* interrupt to FW */ | 253 | /* interrupt to FW */ |
254 | iowrite32(SW_INT_MBOX, wil->csr + HOST_SW_INT); | 254 | iowrite32(SW_INT_MBOX, wil->csr + HOST_SW_INT); |
@@ -640,9 +640,13 @@ void wmi_recv_cmd(struct wil6210_priv *wil) | |||
640 | hdr.flags); | 640 | hdr.flags); |
641 | if ((hdr.type == WIL_MBOX_HDR_TYPE_WMI) && | 641 | if ((hdr.type == WIL_MBOX_HDR_TYPE_WMI) && |
642 | (len >= sizeof(struct wil6210_mbox_hdr_wmi))) { | 642 | (len >= sizeof(struct wil6210_mbox_hdr_wmi))) { |
643 | u16 id = le16_to_cpu(evt->event.wmi.id); | 643 | struct wil6210_mbox_hdr_wmi *wmi = &evt->event.wmi; |
644 | wil_dbg_wmi(wil, "WMI event 0x%04x\n", id); | 644 | u16 id = le16_to_cpu(wmi->id); |
645 | trace_wil6210_wmi_event(id, &evt->event.wmi, len); | 645 | u32 tstamp = le32_to_cpu(wmi->timestamp); |
646 | wil_dbg_wmi(wil, "WMI event 0x%04x MID %d @%d msec\n", | ||
647 | id, wmi->mid, tstamp); | ||
648 | trace_wil6210_wmi_event(wmi, &wmi[1], | ||
649 | len - sizeof(*wmi)); | ||
646 | } | 650 | } |
647 | wil_hex_dump_wmi("evt ", DUMP_PREFIX_OFFSET, 16, 1, | 651 | wil_hex_dump_wmi("evt ", DUMP_PREFIX_OFFSET, 16, 1, |
648 | &evt->event.hdr, sizeof(hdr) + len, true); | 652 | &evt->event.hdr, sizeof(hdr) + len, true); |
@@ -920,6 +924,12 @@ int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring) | |||
920 | cmd.sniffer_cfg.phy_support = | 924 | cmd.sniffer_cfg.phy_support = |
921 | cpu_to_le32((wil->monitor_flags & MONITOR_FLAG_CONTROL) | 925 | cpu_to_le32((wil->monitor_flags & MONITOR_FLAG_CONTROL) |
922 | ? WMI_SNIFFER_CP : WMI_SNIFFER_DP); | 926 | ? WMI_SNIFFER_CP : WMI_SNIFFER_DP); |
927 | } else { | ||
928 | /* Initialize offload (in non-sniffer mode). | ||
929 | * Linux IP stack always calculates IP checksum | ||
930 | * HW always calculate TCP/UDP checksum | ||
931 | */ | ||
932 | cmd.l3_l4_ctrl |= (1 << L3_L4_CTRL_TCPIP_CHECKSUM_EN_POS); | ||
923 | } | 933 | } |
924 | /* typical time for secure PCP is 840ms */ | 934 | /* typical time for secure PCP is 840ms */ |
925 | rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd), | 935 | rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd), |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 0e933bb71543..ccd24f0acb8d 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -4645,6 +4645,19 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) | |||
4645 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, | 4645 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, |
4646 | B43_MACCTL_PSM_JMP0); | 4646 | B43_MACCTL_PSM_JMP0); |
4647 | 4647 | ||
4648 | switch (dev->dev->bus_type) { | ||
4649 | #ifdef CONFIG_B43_BCMA | ||
4650 | case B43_BUS_BCMA: | ||
4651 | bcma_core_pci_down(dev->dev->bdev->bus); | ||
4652 | break; | ||
4653 | #endif | ||
4654 | #ifdef CONFIG_B43_SSB | ||
4655 | case B43_BUS_SSB: | ||
4656 | /* TODO */ | ||
4657 | break; | ||
4658 | #endif | ||
4659 | } | ||
4660 | |||
4648 | b43_dma_free(dev); | 4661 | b43_dma_free(dev); |
4649 | b43_pio_free(dev); | 4662 | b43_pio_free(dev); |
4650 | b43_chip_exit(dev); | 4663 | b43_chip_exit(dev); |
@@ -4684,6 +4697,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4684 | case B43_BUS_BCMA: | 4697 | case B43_BUS_BCMA: |
4685 | bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0], | 4698 | bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0], |
4686 | dev->dev->bdev, true); | 4699 | dev->dev->bdev, true); |
4700 | bcma_core_pci_up(dev->dev->bdev->bus); | ||
4687 | break; | 4701 | break; |
4688 | #endif | 4702 | #endif |
4689 | #ifdef CONFIG_B43_SSB | 4703 | #ifdef CONFIG_B43_SSB |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index e3f3c48f86d4..e13b1a65c65f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | |||
@@ -592,6 +592,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
592 | uint flags, u8 *buf, uint nbytes) | 592 | uint flags, u8 *buf, uint nbytes) |
593 | { | 593 | { |
594 | struct sk_buff *mypkt; | 594 | struct sk_buff *mypkt; |
595 | struct sk_buff_head pktq; | ||
595 | int err; | 596 | int err; |
596 | 597 | ||
597 | mypkt = brcmu_pkt_buf_get_skb(nbytes); | 598 | mypkt = brcmu_pkt_buf_get_skb(nbytes); |
@@ -602,7 +603,10 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
602 | } | 603 | } |
603 | 604 | ||
604 | memcpy(mypkt->data, buf, nbytes); | 605 | memcpy(mypkt->data, buf, nbytes); |
605 | err = brcmf_sdcard_send_pkt(sdiodev, addr, fn, flags, mypkt); | 606 | __skb_queue_head_init(&pktq); |
607 | __skb_queue_tail(&pktq, mypkt); | ||
608 | err = brcmf_sdcard_send_pkt(sdiodev, addr, fn, flags, &pktq); | ||
609 | __skb_dequeue_tail(&pktq); | ||
606 | 610 | ||
607 | brcmu_pkt_buf_free_skb(mypkt); | 611 | brcmu_pkt_buf_free_skb(mypkt); |
608 | return err; | 612 | return err; |
@@ -611,22 +615,18 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
611 | 615 | ||
612 | int | 616 | int |
613 | brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | 617 | brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, |
614 | uint flags, struct sk_buff *pkt) | 618 | uint flags, struct sk_buff_head *pktq) |
615 | { | 619 | { |
616 | uint width; | 620 | uint width; |
617 | int err = 0; | 621 | int err = 0; |
618 | struct sk_buff_head pkt_list; | ||
619 | 622 | ||
620 | brcmf_dbg(SDIO, "fun = %d, addr = 0x%x, size = %d\n", | 623 | brcmf_dbg(SDIO, "fun = %d, addr = 0x%x, size = %d\n", |
621 | fn, addr, pkt->len); | 624 | fn, addr, pktq->qlen); |
622 | 625 | ||
623 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; | 626 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; |
624 | brcmf_sdio_addrprep(sdiodev, width, &addr); | 627 | brcmf_sdio_addrprep(sdiodev, width, &addr); |
625 | 628 | ||
626 | skb_queue_head_init(&pkt_list); | 629 | err = brcmf_sdio_buffrw(sdiodev, fn, true, addr, pktq); |
627 | skb_queue_tail(&pkt_list, pkt); | ||
628 | err = brcmf_sdio_buffrw(sdiodev, fn, true, addr, &pkt_list); | ||
629 | skb_dequeue_tail(&pkt_list); | ||
630 | 630 | ||
631 | return err; | 631 | return err; |
632 | } | 632 | } |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 289e386f01f6..64f4a2bc8dde 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | |||
@@ -350,7 +350,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, | |||
350 | 350 | ||
351 | sdiodev->bus_if = bus_if; | 351 | sdiodev->bus_if = bus_if; |
352 | bus_if->bus_priv.sdio = sdiodev; | 352 | bus_if->bus_priv.sdio = sdiodev; |
353 | bus_if->align = BRCMF_SDALIGN; | ||
354 | dev_set_drvdata(&func->dev, bus_if); | 353 | dev_set_drvdata(&func->dev, bus_if); |
355 | dev_set_drvdata(&sdiodev->func[1]->dev, bus_if); | 354 | dev_set_drvdata(&sdiodev->func[1]->dev, bus_if); |
356 | sdiodev->dev = &sdiodev->func[1]->dev; | 355 | sdiodev->dev = &sdiodev->func[1]->dev; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 86cbfe2c7c6c..2eb9e642c9bf 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h | |||
@@ -194,6 +194,8 @@ | |||
194 | #define BRCMF_E_IF_DEL 2 | 194 | #define BRCMF_E_IF_DEL 2 |
195 | #define BRCMF_E_IF_CHANGE 3 | 195 | #define BRCMF_E_IF_CHANGE 3 |
196 | 196 | ||
197 | #define BRCMF_E_IF_FLAG_NOIF 1 | ||
198 | |||
197 | #define BRCMF_E_IF_ROLE_STA 0 | 199 | #define BRCMF_E_IF_ROLE_STA 0 |
198 | #define BRCMF_E_IF_ROLE_AP 1 | 200 | #define BRCMF_E_IF_ROLE_AP 1 |
199 | #define BRCMF_E_IF_ROLE_WDS 2 | 201 | #define BRCMF_E_IF_ROLE_WDS 2 |
@@ -209,6 +211,8 @@ | |||
209 | #define BRCMF_DCMD_MEDLEN 1536 | 211 | #define BRCMF_DCMD_MEDLEN 1536 |
210 | #define BRCMF_DCMD_MAXLEN 8192 | 212 | #define BRCMF_DCMD_MAXLEN 8192 |
211 | 213 | ||
214 | #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS 256 | ||
215 | |||
212 | /* Pattern matching filter. Specifies an offset within received packets to | 216 | /* Pattern matching filter. Specifies an offset within received packets to |
213 | * start matching, the pattern to match, the size of the pattern, and a bitmask | 217 | * start matching, the pattern to match, the size of the pattern, and a bitmask |
214 | * that indicates which bits within the pattern should be matched. | 218 | * that indicates which bits within the pattern should be matched. |
@@ -505,6 +509,25 @@ struct brcmf_dcmd { | |||
505 | uint needed; /* bytes needed (optional) */ | 509 | uint needed; /* bytes needed (optional) */ |
506 | }; | 510 | }; |
507 | 511 | ||
512 | /** | ||
513 | * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info | ||
514 | * | ||
515 | * @pktslots: dynamic allocated array for ordering AMPDU packets. | ||
516 | * @flow_id: AMPDU flow identifier. | ||
517 | * @cur_idx: last AMPDU index from firmware. | ||
518 | * @exp_idx: expected next AMPDU index. | ||
519 | * @max_idx: maximum amount of packets per AMPDU. | ||
520 | * @pend_pkts: number of packets currently in @pktslots. | ||
521 | */ | ||
522 | struct brcmf_ampdu_rx_reorder { | ||
523 | struct sk_buff **pktslots; | ||
524 | u8 flow_id; | ||
525 | u8 cur_idx; | ||
526 | u8 exp_idx; | ||
527 | u8 max_idx; | ||
528 | u8 pend_pkts; | ||
529 | }; | ||
530 | |||
508 | /* Forward decls for struct brcmf_pub (see below) */ | 531 | /* Forward decls for struct brcmf_pub (see below) */ |
509 | struct brcmf_proto; /* device communication protocol info */ | 532 | struct brcmf_proto; /* device communication protocol info */ |
510 | struct brcmf_cfg80211_dev; /* cfg80211 device info */ | 533 | struct brcmf_cfg80211_dev; /* cfg80211 device info */ |
@@ -536,9 +559,10 @@ struct brcmf_pub { | |||
536 | 559 | ||
537 | struct brcmf_fweh_info fweh; | 560 | struct brcmf_fweh_info fweh; |
538 | 561 | ||
539 | bool fw_signals; | ||
540 | struct brcmf_fws_info *fws; | 562 | struct brcmf_fws_info *fws; |
541 | spinlock_t fws_spinlock; | 563 | |
564 | struct brcmf_ampdu_rx_reorder | ||
565 | *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS]; | ||
542 | #ifdef DEBUG | 566 | #ifdef DEBUG |
543 | struct dentry *dbgfs_dir; | 567 | struct dentry *dbgfs_dir; |
544 | #endif | 568 | #endif |
@@ -604,6 +628,9 @@ struct brcmf_if { | |||
604 | wait_queue_head_t pend_8021x_wait; | 628 | wait_queue_head_t pend_8021x_wait; |
605 | }; | 629 | }; |
606 | 630 | ||
631 | struct brcmf_skb_reorder_data { | ||
632 | u8 *reorder; | ||
633 | }; | ||
607 | 634 | ||
608 | extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); | 635 | extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); |
609 | 636 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index 080395f49fa5..f7c1985844e4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | |||
@@ -36,7 +36,11 @@ struct brcmf_bus_dcmd { | |||
36 | * | 36 | * |
37 | * @init: prepare for communication with dongle. | 37 | * @init: prepare for communication with dongle. |
38 | * @stop: clear pending frames, disable data flow. | 38 | * @stop: clear pending frames, disable data flow. |
39 | * @txdata: send a data frame to the dongle (callee disposes skb). | 39 | * @txdata: send a data frame to the dongle. When the data |
40 | * has been transferred, the common driver must be | ||
41 | * notified using brcmf_txcomplete(). The common | ||
42 | * driver calls this function with interrupts | ||
43 | * disabled. | ||
40 | * @txctl: transmit a control request message to dongle. | 44 | * @txctl: transmit a control request message to dongle. |
41 | * @rxctl: receive a control response message from dongle. | 45 | * @rxctl: receive a control response message from dongle. |
42 | * @gettxq: obtain a reference of bus transmit queue (optional). | 46 | * @gettxq: obtain a reference of bus transmit queue (optional). |
@@ -65,7 +69,6 @@ struct brcmf_bus_ops { | |||
65 | * @maxctl: maximum size for rxctl request message. | 69 | * @maxctl: maximum size for rxctl request message. |
66 | * @tx_realloc: number of tx packets realloced for headroom. | 70 | * @tx_realloc: number of tx packets realloced for headroom. |
67 | * @dstats: dongle-based statistical data. | 71 | * @dstats: dongle-based statistical data. |
68 | * @align: alignment requirement for the bus. | ||
69 | * @dcmd_list: bus/device specific dongle initialization commands. | 72 | * @dcmd_list: bus/device specific dongle initialization commands. |
70 | * @chip: device identifier of the dongle chip. | 73 | * @chip: device identifier of the dongle chip. |
71 | * @chiprev: revision of the dongle chip. | 74 | * @chiprev: revision of the dongle chip. |
@@ -80,7 +83,6 @@ struct brcmf_bus { | |||
80 | enum brcmf_bus_state state; | 83 | enum brcmf_bus_state state; |
81 | uint maxctl; | 84 | uint maxctl; |
82 | unsigned long tx_realloc; | 85 | unsigned long tx_realloc; |
83 | u8 align; | ||
84 | u32 chip; | 86 | u32 chip; |
85 | u32 chiprev; | 87 | u32 chiprev; |
86 | struct list_head dcmd_list; | 88 | struct list_head dcmd_list; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 8e8975562ec3..e067aec1fbf1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | |||
@@ -38,6 +38,19 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
38 | 38 | ||
39 | #define MAX_WAIT_FOR_8021X_TX 50 /* msecs */ | 39 | #define MAX_WAIT_FOR_8021X_TX 50 /* msecs */ |
40 | 40 | ||
41 | /* AMPDU rx reordering definitions */ | ||
42 | #define BRCMF_RXREORDER_FLOWID_OFFSET 0 | ||
43 | #define BRCMF_RXREORDER_MAXIDX_OFFSET 2 | ||
44 | #define BRCMF_RXREORDER_FLAGS_OFFSET 4 | ||
45 | #define BRCMF_RXREORDER_CURIDX_OFFSET 6 | ||
46 | #define BRCMF_RXREORDER_EXPIDX_OFFSET 8 | ||
47 | |||
48 | #define BRCMF_RXREORDER_DEL_FLOW 0x01 | ||
49 | #define BRCMF_RXREORDER_FLUSH_ALL 0x02 | ||
50 | #define BRCMF_RXREORDER_CURIDX_VALID 0x04 | ||
51 | #define BRCMF_RXREORDER_EXPIDX_VALID 0x08 | ||
52 | #define BRCMF_RXREORDER_NEW_HOLE 0x10 | ||
53 | |||
41 | /* Error bits */ | 54 | /* Error bits */ |
42 | int brcmf_msg_level; | 55 | int brcmf_msg_level; |
43 | module_param_named(debug, brcmf_msg_level, int, S_IRUSR | S_IWUSR); | 56 | module_param_named(debug, brcmf_msg_level, int, S_IRUSR | S_IWUSR); |
@@ -242,7 +255,7 @@ void brcmf_txflowblock_if(struct brcmf_if *ifp, | |||
242 | { | 255 | { |
243 | unsigned long flags; | 256 | unsigned long flags; |
244 | 257 | ||
245 | if (!ifp) | 258 | if (!ifp || !ifp->ndev) |
246 | return; | 259 | return; |
247 | 260 | ||
248 | brcmf_dbg(TRACE, "enter: idx=%d stop=0x%X reason=%d state=%d\n", | 261 | brcmf_dbg(TRACE, "enter: idx=%d stop=0x%X reason=%d state=%d\n", |
@@ -265,17 +278,234 @@ void brcmf_txflowblock(struct device *dev, bool state) | |||
265 | { | 278 | { |
266 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); | 279 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); |
267 | struct brcmf_pub *drvr = bus_if->drvr; | 280 | struct brcmf_pub *drvr = bus_if->drvr; |
268 | int i; | ||
269 | 281 | ||
270 | brcmf_dbg(TRACE, "Enter\n"); | 282 | brcmf_dbg(TRACE, "Enter\n"); |
271 | 283 | ||
272 | if (brcmf_fws_fc_active(drvr->fws)) { | 284 | brcmf_fws_bus_blocked(drvr, state); |
273 | brcmf_fws_bus_blocked(drvr, state); | 285 | } |
286 | |||
287 | static void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb) | ||
288 | { | ||
289 | skb->dev = ifp->ndev; | ||
290 | skb->protocol = eth_type_trans(skb, skb->dev); | ||
291 | |||
292 | if (skb->pkt_type == PACKET_MULTICAST) | ||
293 | ifp->stats.multicast++; | ||
294 | |||
295 | /* Process special event packets */ | ||
296 | brcmf_fweh_process_skb(ifp->drvr, skb); | ||
297 | |||
298 | if (!(ifp->ndev->flags & IFF_UP)) { | ||
299 | brcmu_pkt_buf_free_skb(skb); | ||
300 | return; | ||
301 | } | ||
302 | |||
303 | ifp->stats.rx_bytes += skb->len; | ||
304 | ifp->stats.rx_packets++; | ||
305 | |||
306 | brcmf_dbg(DATA, "rx proto=0x%X\n", ntohs(skb->protocol)); | ||
307 | if (in_interrupt()) | ||
308 | netif_rx(skb); | ||
309 | else | ||
310 | /* If the receive is not processed inside an ISR, | ||
311 | * the softirqd must be woken explicitly to service | ||
312 | * the NET_RX_SOFTIRQ. This is handled by netif_rx_ni(). | ||
313 | */ | ||
314 | netif_rx_ni(skb); | ||
315 | } | ||
316 | |||
317 | static void brcmf_rxreorder_get_skb_list(struct brcmf_ampdu_rx_reorder *rfi, | ||
318 | u8 start, u8 end, | ||
319 | struct sk_buff_head *skb_list) | ||
320 | { | ||
321 | /* initialize return list */ | ||
322 | __skb_queue_head_init(skb_list); | ||
323 | |||
324 | if (rfi->pend_pkts == 0) { | ||
325 | brcmf_dbg(INFO, "no packets in reorder queue\n"); | ||
326 | return; | ||
327 | } | ||
328 | |||
329 | do { | ||
330 | if (rfi->pktslots[start]) { | ||
331 | __skb_queue_tail(skb_list, rfi->pktslots[start]); | ||
332 | rfi->pktslots[start] = NULL; | ||
333 | } | ||
334 | start++; | ||
335 | if (start > rfi->max_idx) | ||
336 | start = 0; | ||
337 | } while (start != end); | ||
338 | rfi->pend_pkts -= skb_queue_len(skb_list); | ||
339 | } | ||
340 | |||
341 | static void brcmf_rxreorder_process_info(struct brcmf_if *ifp, u8 *reorder_data, | ||
342 | struct sk_buff *pkt) | ||
343 | { | ||
344 | u8 flow_id, max_idx, cur_idx, exp_idx, end_idx; | ||
345 | struct brcmf_ampdu_rx_reorder *rfi; | ||
346 | struct sk_buff_head reorder_list; | ||
347 | struct sk_buff *pnext; | ||
348 | u8 flags; | ||
349 | u32 buf_size; | ||
350 | |||
351 | flow_id = reorder_data[BRCMF_RXREORDER_FLOWID_OFFSET]; | ||
352 | flags = reorder_data[BRCMF_RXREORDER_FLAGS_OFFSET]; | ||
353 | |||
354 | /* validate flags and flow id */ | ||
355 | if (flags == 0xFF) { | ||
356 | brcmf_err("invalid flags...so ignore this packet\n"); | ||
357 | brcmf_netif_rx(ifp, pkt); | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | rfi = ifp->drvr->reorder_flows[flow_id]; | ||
362 | if (flags & BRCMF_RXREORDER_DEL_FLOW) { | ||
363 | brcmf_dbg(INFO, "flow-%d: delete\n", | ||
364 | flow_id); | ||
365 | |||
366 | if (rfi == NULL) { | ||
367 | brcmf_dbg(INFO, "received flags to cleanup, but no flow (%d) yet\n", | ||
368 | flow_id); | ||
369 | brcmf_netif_rx(ifp, pkt); | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, rfi->exp_idx, | ||
374 | &reorder_list); | ||
375 | /* add the last packet */ | ||
376 | __skb_queue_tail(&reorder_list, pkt); | ||
377 | kfree(rfi); | ||
378 | ifp->drvr->reorder_flows[flow_id] = NULL; | ||
379 | goto netif_rx; | ||
380 | } | ||
381 | /* from here on we need a flow reorder instance */ | ||
382 | if (rfi == NULL) { | ||
383 | buf_size = sizeof(*rfi); | ||
384 | max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; | ||
385 | |||
386 | buf_size += (max_idx + 1) * sizeof(pkt); | ||
387 | |||
388 | /* allocate space for flow reorder info */ | ||
389 | brcmf_dbg(INFO, "flow-%d: start, maxidx %d\n", | ||
390 | flow_id, max_idx); | ||
391 | rfi = kzalloc(buf_size, GFP_ATOMIC); | ||
392 | if (rfi == NULL) { | ||
393 | brcmf_err("failed to alloc buffer\n"); | ||
394 | brcmf_netif_rx(ifp, pkt); | ||
395 | return; | ||
396 | } | ||
397 | |||
398 | ifp->drvr->reorder_flows[flow_id] = rfi; | ||
399 | rfi->pktslots = (struct sk_buff **)(rfi+1); | ||
400 | rfi->max_idx = max_idx; | ||
401 | } | ||
402 | if (flags & BRCMF_RXREORDER_NEW_HOLE) { | ||
403 | if (rfi->pend_pkts) { | ||
404 | brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, | ||
405 | rfi->exp_idx, | ||
406 | &reorder_list); | ||
407 | WARN_ON(rfi->pend_pkts); | ||
408 | } else { | ||
409 | __skb_queue_head_init(&reorder_list); | ||
410 | } | ||
411 | rfi->cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; | ||
412 | rfi->exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; | ||
413 | rfi->max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; | ||
414 | rfi->pktslots[rfi->cur_idx] = pkt; | ||
415 | rfi->pend_pkts++; | ||
416 | brcmf_dbg(DATA, "flow-%d: new hole %d (%d), pending %d\n", | ||
417 | flow_id, rfi->cur_idx, rfi->exp_idx, rfi->pend_pkts); | ||
418 | } else if (flags & BRCMF_RXREORDER_CURIDX_VALID) { | ||
419 | cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; | ||
420 | exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; | ||
421 | |||
422 | if ((exp_idx == rfi->exp_idx) && (cur_idx != rfi->exp_idx)) { | ||
423 | /* still in the current hole */ | ||
424 | /* enqueue the current on the buffer chain */ | ||
425 | if (rfi->pktslots[cur_idx] != NULL) { | ||
426 | brcmf_dbg(INFO, "HOLE: ERROR buffer pending..free it\n"); | ||
427 | brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); | ||
428 | rfi->pktslots[cur_idx] = NULL; | ||
429 | } | ||
430 | rfi->pktslots[cur_idx] = pkt; | ||
431 | rfi->pend_pkts++; | ||
432 | rfi->cur_idx = cur_idx; | ||
433 | brcmf_dbg(DATA, "flow-%d: store pkt %d (%d), pending %d\n", | ||
434 | flow_id, cur_idx, exp_idx, rfi->pend_pkts); | ||
435 | |||
436 | /* can return now as there is no reorder | ||
437 | * list to process. | ||
438 | */ | ||
439 | return; | ||
440 | } | ||
441 | if (rfi->exp_idx == cur_idx) { | ||
442 | if (rfi->pktslots[cur_idx] != NULL) { | ||
443 | brcmf_dbg(INFO, "error buffer pending..free it\n"); | ||
444 | brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); | ||
445 | rfi->pktslots[cur_idx] = NULL; | ||
446 | } | ||
447 | rfi->pktslots[cur_idx] = pkt; | ||
448 | rfi->pend_pkts++; | ||
449 | |||
450 | /* got the expected one. flush from current to expected | ||
451 | * and update expected | ||
452 | */ | ||
453 | brcmf_dbg(DATA, "flow-%d: expected %d (%d), pending %d\n", | ||
454 | flow_id, cur_idx, exp_idx, rfi->pend_pkts); | ||
455 | |||
456 | rfi->cur_idx = cur_idx; | ||
457 | rfi->exp_idx = exp_idx; | ||
458 | |||
459 | brcmf_rxreorder_get_skb_list(rfi, cur_idx, exp_idx, | ||
460 | &reorder_list); | ||
461 | brcmf_dbg(DATA, "flow-%d: freeing buffers %d, pending %d\n", | ||
462 | flow_id, skb_queue_len(&reorder_list), | ||
463 | rfi->pend_pkts); | ||
464 | } else { | ||
465 | u8 end_idx; | ||
466 | |||
467 | brcmf_dbg(DATA, "flow-%d (0x%x): both moved, old %d/%d, new %d/%d\n", | ||
468 | flow_id, flags, rfi->cur_idx, rfi->exp_idx, | ||
469 | cur_idx, exp_idx); | ||
470 | if (flags & BRCMF_RXREORDER_FLUSH_ALL) | ||
471 | end_idx = rfi->exp_idx; | ||
472 | else | ||
473 | end_idx = exp_idx; | ||
474 | |||
475 | /* flush pkts first */ | ||
476 | brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, | ||
477 | &reorder_list); | ||
478 | |||
479 | if (exp_idx == ((cur_idx + 1) % (rfi->max_idx + 1))) { | ||
480 | __skb_queue_tail(&reorder_list, pkt); | ||
481 | } else { | ||
482 | rfi->pktslots[cur_idx] = pkt; | ||
483 | rfi->pend_pkts++; | ||
484 | } | ||
485 | rfi->exp_idx = exp_idx; | ||
486 | rfi->cur_idx = cur_idx; | ||
487 | } | ||
274 | } else { | 488 | } else { |
275 | for (i = 0; i < BRCMF_MAX_IFS; i++) | 489 | /* explicity window move updating the expected index */ |
276 | brcmf_txflowblock_if(drvr->iflist[i], | 490 | exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; |
277 | BRCMF_NETIF_STOP_REASON_BLOCK_BUS, | 491 | |
278 | state); | 492 | brcmf_dbg(DATA, "flow-%d (0x%x): change expected: %d -> %d\n", |
493 | flow_id, flags, rfi->exp_idx, exp_idx); | ||
494 | if (flags & BRCMF_RXREORDER_FLUSH_ALL) | ||
495 | end_idx = rfi->exp_idx; | ||
496 | else | ||
497 | end_idx = exp_idx; | ||
498 | |||
499 | brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, | ||
500 | &reorder_list); | ||
501 | __skb_queue_tail(&reorder_list, pkt); | ||
502 | /* set the new expected idx */ | ||
503 | rfi->exp_idx = exp_idx; | ||
504 | } | ||
505 | netif_rx: | ||
506 | skb_queue_walk_safe(&reorder_list, pkt, pnext) { | ||
507 | __skb_unlink(pkt, &reorder_list); | ||
508 | brcmf_netif_rx(ifp, pkt); | ||
279 | } | 509 | } |
280 | } | 510 | } |
281 | 511 | ||
@@ -285,16 +515,18 @@ void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list) | |||
285 | struct brcmf_if *ifp; | 515 | struct brcmf_if *ifp; |
286 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); | 516 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); |
287 | struct brcmf_pub *drvr = bus_if->drvr; | 517 | struct brcmf_pub *drvr = bus_if->drvr; |
518 | struct brcmf_skb_reorder_data *rd; | ||
288 | u8 ifidx; | 519 | u8 ifidx; |
289 | int ret; | 520 | int ret; |
290 | 521 | ||
291 | brcmf_dbg(DATA, "Enter\n"); | 522 | brcmf_dbg(DATA, "Enter: %s: count=%u\n", dev_name(dev), |
523 | skb_queue_len(skb_list)); | ||
292 | 524 | ||
293 | skb_queue_walk_safe(skb_list, skb, pnext) { | 525 | skb_queue_walk_safe(skb_list, skb, pnext) { |
294 | skb_unlink(skb, skb_list); | 526 | skb_unlink(skb, skb_list); |
295 | 527 | ||
296 | /* process and remove protocol-specific header */ | 528 | /* process and remove protocol-specific header */ |
297 | ret = brcmf_proto_hdrpull(drvr, drvr->fw_signals, &ifidx, skb); | 529 | ret = brcmf_proto_hdrpull(drvr, true, &ifidx, skb); |
298 | ifp = drvr->iflist[ifidx]; | 530 | ifp = drvr->iflist[ifidx]; |
299 | 531 | ||
300 | if (ret || !ifp || !ifp->ndev) { | 532 | if (ret || !ifp || !ifp->ndev) { |
@@ -304,31 +536,11 @@ void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list) | |||
304 | continue; | 536 | continue; |
305 | } | 537 | } |
306 | 538 | ||
307 | skb->dev = ifp->ndev; | 539 | rd = (struct brcmf_skb_reorder_data *)skb->cb; |
308 | skb->protocol = eth_type_trans(skb, skb->dev); | 540 | if (rd->reorder) |
309 | 541 | brcmf_rxreorder_process_info(ifp, rd->reorder, skb); | |
310 | if (skb->pkt_type == PACKET_MULTICAST) | ||
311 | ifp->stats.multicast++; | ||
312 | |||
313 | /* Process special event packets */ | ||
314 | brcmf_fweh_process_skb(drvr, skb); | ||
315 | |||
316 | if (!(ifp->ndev->flags & IFF_UP)) { | ||
317 | brcmu_pkt_buf_free_skb(skb); | ||
318 | continue; | ||
319 | } | ||
320 | |||
321 | ifp->stats.rx_bytes += skb->len; | ||
322 | ifp->stats.rx_packets++; | ||
323 | |||
324 | if (in_interrupt()) | ||
325 | netif_rx(skb); | ||
326 | else | 542 | else |
327 | /* If the receive is not processed inside an ISR, | 543 | brcmf_netif_rx(ifp, skb); |
328 | * the softirqd must be woken explicitly to service the | ||
329 | * NET_RX_SOFTIRQ. This is handled by netif_rx_ni(). | ||
330 | */ | ||
331 | netif_rx_ni(skb); | ||
332 | } | 544 | } |
333 | } | 545 | } |
334 | 546 | ||
@@ -889,7 +1101,6 @@ int brcmf_bus_start(struct device *dev) | |||
889 | if (ret < 0) | 1101 | if (ret < 0) |
890 | goto fail; | 1102 | goto fail; |
891 | 1103 | ||
892 | drvr->fw_signals = true; | ||
893 | ret = brcmf_fws_init(drvr); | 1104 | ret = brcmf_fws_init(drvr); |
894 | if (ret < 0) | 1105 | if (ret < 0) |
895 | goto fail; | 1106 | goto fail; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 264111968320..1aa75d5951b8 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |||
@@ -201,13 +201,6 @@ struct rte_console { | |||
201 | #define SFC_CRC4WOOS (1 << 2) /* CRC error for write out of sync */ | 201 | #define SFC_CRC4WOOS (1 << 2) /* CRC error for write out of sync */ |
202 | #define SFC_ABORTALL (1 << 3) /* Abort all in-progress frames */ | 202 | #define SFC_ABORTALL (1 << 3) /* Abort all in-progress frames */ |
203 | 203 | ||
204 | /* HW frame tag */ | ||
205 | #define SDPCM_FRAMETAG_LEN 4 /* 2 bytes len, 2 bytes check val */ | ||
206 | |||
207 | /* Total length of frame header for dongle protocol */ | ||
208 | #define SDPCM_HDRLEN (SDPCM_FRAMETAG_LEN + SDPCM_SWHEADER_LEN) | ||
209 | #define SDPCM_RESERVE (SDPCM_HDRLEN + BRCMF_SDALIGN) | ||
210 | |||
211 | /* | 204 | /* |
212 | * Software allocation of To SB Mailbox resources | 205 | * Software allocation of To SB Mailbox resources |
213 | */ | 206 | */ |
@@ -250,38 +243,6 @@ struct rte_console { | |||
250 | /* Current protocol version */ | 243 | /* Current protocol version */ |
251 | #define SDPCM_PROT_VERSION 4 | 244 | #define SDPCM_PROT_VERSION 4 |
252 | 245 | ||
253 | /* SW frame header */ | ||
254 | #define SDPCM_PACKET_SEQUENCE(p) (((u8 *)p)[0] & 0xff) | ||
255 | |||
256 | #define SDPCM_CHANNEL_MASK 0x00000f00 | ||
257 | #define SDPCM_CHANNEL_SHIFT 8 | ||
258 | #define SDPCM_PACKET_CHANNEL(p) (((u8 *)p)[1] & 0x0f) | ||
259 | |||
260 | #define SDPCM_NEXTLEN_OFFSET 2 | ||
261 | |||
262 | /* Data Offset from SOF (HW Tag, SW Tag, Pad) */ | ||
263 | #define SDPCM_DOFFSET_OFFSET 3 /* Data Offset */ | ||
264 | #define SDPCM_DOFFSET_VALUE(p) (((u8 *)p)[SDPCM_DOFFSET_OFFSET] & 0xff) | ||
265 | #define SDPCM_DOFFSET_MASK 0xff000000 | ||
266 | #define SDPCM_DOFFSET_SHIFT 24 | ||
267 | #define SDPCM_FCMASK_OFFSET 4 /* Flow control */ | ||
268 | #define SDPCM_FCMASK_VALUE(p) (((u8 *)p)[SDPCM_FCMASK_OFFSET] & 0xff) | ||
269 | #define SDPCM_WINDOW_OFFSET 5 /* Credit based fc */ | ||
270 | #define SDPCM_WINDOW_VALUE(p) (((u8 *)p)[SDPCM_WINDOW_OFFSET] & 0xff) | ||
271 | |||
272 | #define SDPCM_SWHEADER_LEN 8 /* SW header is 64 bits */ | ||
273 | |||
274 | /* logical channel numbers */ | ||
275 | #define SDPCM_CONTROL_CHANNEL 0 /* Control channel Id */ | ||
276 | #define SDPCM_EVENT_CHANNEL 1 /* Asyc Event Indication Channel Id */ | ||
277 | #define SDPCM_DATA_CHANNEL 2 /* Data Xmit/Recv Channel Id */ | ||
278 | #define SDPCM_GLOM_CHANNEL 3 /* For coalesced packets */ | ||
279 | #define SDPCM_TEST_CHANNEL 15 /* Reserved for test/debug packets */ | ||
280 | |||
281 | #define SDPCM_SEQUENCE_WRAP 256 /* wrap-around val for 8bit frame seq */ | ||
282 | |||
283 | #define SDPCM_GLOMDESC(p) (((u8 *)p)[1] & 0x80) | ||
284 | |||
285 | /* | 246 | /* |
286 | * Shared structure between dongle and the host. | 247 | * Shared structure between dongle and the host. |
287 | * The structure contains pointers to trap or assert information. | 248 | * The structure contains pointers to trap or assert information. |
@@ -396,8 +357,8 @@ struct sdpcm_shared_le { | |||
396 | __le32 brpt_addr; | 357 | __le32 brpt_addr; |
397 | }; | 358 | }; |
398 | 359 | ||
399 | /* SDIO read frame info */ | 360 | /* dongle SDIO bus specific header info */ |
400 | struct brcmf_sdio_read { | 361 | struct brcmf_sdio_hdrinfo { |
401 | u8 seq_num; | 362 | u8 seq_num; |
402 | u8 channel; | 363 | u8 channel; |
403 | u16 len; | 364 | u16 len; |
@@ -431,7 +392,7 @@ struct brcmf_sdio { | |||
431 | u8 hdrbuf[MAX_HDR_READ + BRCMF_SDALIGN]; | 392 | u8 hdrbuf[MAX_HDR_READ + BRCMF_SDALIGN]; |
432 | u8 *rxhdr; /* Header of current rx frame (in hdrbuf) */ | 393 | u8 *rxhdr; /* Header of current rx frame (in hdrbuf) */ |
433 | u8 rx_seq; /* Receive sequence number (expected) */ | 394 | u8 rx_seq; /* Receive sequence number (expected) */ |
434 | struct brcmf_sdio_read cur_read; | 395 | struct brcmf_sdio_hdrinfo cur_read; |
435 | /* info of current read frame */ | 396 | /* info of current read frame */ |
436 | bool rxskip; /* Skip receive (awaiting NAK ACK) */ | 397 | bool rxskip; /* Skip receive (awaiting NAK ACK) */ |
437 | bool rxpending; /* Data frame pending in dongle */ | 398 | bool rxpending; /* Data frame pending in dongle */ |
@@ -500,6 +461,8 @@ struct brcmf_sdio { | |||
500 | struct brcmf_sdio_count sdcnt; | 461 | struct brcmf_sdio_count sdcnt; |
501 | bool sr_enabled; /* SaveRestore enabled */ | 462 | bool sr_enabled; /* SaveRestore enabled */ |
502 | bool sleeping; /* SDIO bus sleeping */ | 463 | bool sleeping; /* SDIO bus sleeping */ |
464 | |||
465 | u8 tx_hdrlen; /* sdio bus header length for tx packet */ | ||
503 | }; | 466 | }; |
504 | 467 | ||
505 | /* clkstate */ | 468 | /* clkstate */ |
@@ -510,7 +473,6 @@ struct brcmf_sdio { | |||
510 | 473 | ||
511 | #ifdef DEBUG | 474 | #ifdef DEBUG |
512 | static int qcount[NUMPRIO]; | 475 | static int qcount[NUMPRIO]; |
513 | static int tx_packets[NUMPRIO]; | ||
514 | #endif /* DEBUG */ | 476 | #endif /* DEBUG */ |
515 | 477 | ||
516 | #define DEFAULT_SDIO_DRIVE_STRENGTH 6 /* in milliamps */ | 478 | #define DEFAULT_SDIO_DRIVE_STRENGTH 6 /* in milliamps */ |
@@ -1043,18 +1005,63 @@ static void brcmf_sdbrcm_free_glom(struct brcmf_sdio *bus) | |||
1043 | } | 1005 | } |
1044 | } | 1006 | } |
1045 | 1007 | ||
1046 | static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | 1008 | /** |
1047 | struct brcmf_sdio_read *rd, | 1009 | * brcmfmac sdio bus specific header |
1048 | enum brcmf_sdio_frmtype type) | 1010 | * This is the lowest layer header wrapped on the packets transmitted between |
1011 | * host and WiFi dongle which contains information needed for SDIO core and | ||
1012 | * firmware | ||
1013 | * | ||
1014 | * It consists of 2 parts: hw header and software header | ||
1015 | * hardware header (frame tag) - 4 bytes | ||
1016 | * Byte 0~1: Frame length | ||
1017 | * Byte 2~3: Checksum, bit-wise inverse of frame length | ||
1018 | * software header - 8 bytes | ||
1019 | * Byte 0: Rx/Tx sequence number | ||
1020 | * Byte 1: 4 MSB Channel number, 4 LSB arbitrary flag | ||
1021 | * Byte 2: Length of next data frame, reserved for Tx | ||
1022 | * Byte 3: Data offset | ||
1023 | * Byte 4: Flow control bits, reserved for Tx | ||
1024 | * Byte 5: Maximum Sequence number allowed by firmware for Tx, N/A for Tx packet | ||
1025 | * Byte 6~7: Reserved | ||
1026 | */ | ||
1027 | #define SDPCM_HWHDR_LEN 4 | ||
1028 | #define SDPCM_SWHDR_LEN 8 | ||
1029 | #define SDPCM_HDRLEN (SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN) | ||
1030 | /* software header */ | ||
1031 | #define SDPCM_SEQ_MASK 0x000000ff | ||
1032 | #define SDPCM_SEQ_WRAP 256 | ||
1033 | #define SDPCM_CHANNEL_MASK 0x00000f00 | ||
1034 | #define SDPCM_CHANNEL_SHIFT 8 | ||
1035 | #define SDPCM_CONTROL_CHANNEL 0 /* Control */ | ||
1036 | #define SDPCM_EVENT_CHANNEL 1 /* Asyc Event Indication */ | ||
1037 | #define SDPCM_DATA_CHANNEL 2 /* Data Xmit/Recv */ | ||
1038 | #define SDPCM_GLOM_CHANNEL 3 /* Coalesced packets */ | ||
1039 | #define SDPCM_TEST_CHANNEL 15 /* Test/debug packets */ | ||
1040 | #define SDPCM_GLOMDESC(p) (((u8 *)p)[1] & 0x80) | ||
1041 | #define SDPCM_NEXTLEN_MASK 0x00ff0000 | ||
1042 | #define SDPCM_NEXTLEN_SHIFT 16 | ||
1043 | #define SDPCM_DOFFSET_MASK 0xff000000 | ||
1044 | #define SDPCM_DOFFSET_SHIFT 24 | ||
1045 | #define SDPCM_FCMASK_MASK 0x000000ff | ||
1046 | #define SDPCM_WINDOW_MASK 0x0000ff00 | ||
1047 | #define SDPCM_WINDOW_SHIFT 8 | ||
1048 | |||
1049 | static inline u8 brcmf_sdio_getdatoffset(u8 *swheader) | ||
1050 | { | ||
1051 | u32 hdrvalue; | ||
1052 | hdrvalue = *(u32 *)swheader; | ||
1053 | return (u8)((hdrvalue & SDPCM_DOFFSET_MASK) >> SDPCM_DOFFSET_SHIFT); | ||
1054 | } | ||
1055 | |||
1056 | static int brcmf_sdio_hdparse(struct brcmf_sdio *bus, u8 *header, | ||
1057 | struct brcmf_sdio_hdrinfo *rd, | ||
1058 | enum brcmf_sdio_frmtype type) | ||
1049 | { | 1059 | { |
1050 | u16 len, checksum; | 1060 | u16 len, checksum; |
1051 | u8 rx_seq, fc, tx_seq_max; | 1061 | u8 rx_seq, fc, tx_seq_max; |
1062 | u32 swheader; | ||
1052 | 1063 | ||
1053 | /* | 1064 | /* hw header */ |
1054 | * 4 bytes hardware header (frame tag) | ||
1055 | * Byte 0~1: Frame length | ||
1056 | * Byte 2~3: Checksum, bit-wise inverse of frame length | ||
1057 | */ | ||
1058 | len = get_unaligned_le16(header); | 1065 | len = get_unaligned_le16(header); |
1059 | checksum = get_unaligned_le16(header + sizeof(u16)); | 1066 | checksum = get_unaligned_le16(header + sizeof(u16)); |
1060 | /* All zero means no more to read */ | 1067 | /* All zero means no more to read */ |
@@ -1083,24 +1090,16 @@ static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | |||
1083 | } | 1090 | } |
1084 | rd->len = len; | 1091 | rd->len = len; |
1085 | 1092 | ||
1086 | /* | 1093 | /* software header */ |
1087 | * 8 bytes hardware header | 1094 | header += SDPCM_HWHDR_LEN; |
1088 | * Byte 0: Rx sequence number | 1095 | swheader = le32_to_cpu(*(__le32 *)header); |
1089 | * Byte 1: 4 MSB Channel number, 4 LSB arbitrary flag | 1096 | if (type == BRCMF_SDIO_FT_SUPER && SDPCM_GLOMDESC(header)) { |
1090 | * Byte 2: Length of next data frame | ||
1091 | * Byte 3: Data offset | ||
1092 | * Byte 4: Flow control bits | ||
1093 | * Byte 5: Maximum Sequence number allow for Tx | ||
1094 | * Byte 6~7: Reserved | ||
1095 | */ | ||
1096 | if (type == BRCMF_SDIO_FT_SUPER && | ||
1097 | SDPCM_GLOMDESC(&header[SDPCM_FRAMETAG_LEN])) { | ||
1098 | brcmf_err("Glom descriptor found in superframe head\n"); | 1097 | brcmf_err("Glom descriptor found in superframe head\n"); |
1099 | rd->len = 0; | 1098 | rd->len = 0; |
1100 | return -EINVAL; | 1099 | return -EINVAL; |
1101 | } | 1100 | } |
1102 | rx_seq = SDPCM_PACKET_SEQUENCE(&header[SDPCM_FRAMETAG_LEN]); | 1101 | rx_seq = (u8)(swheader & SDPCM_SEQ_MASK); |
1103 | rd->channel = SDPCM_PACKET_CHANNEL(&header[SDPCM_FRAMETAG_LEN]); | 1102 | rd->channel = (swheader & SDPCM_CHANNEL_MASK) >> SDPCM_CHANNEL_SHIFT; |
1104 | if (len > MAX_RX_DATASZ && rd->channel != SDPCM_CONTROL_CHANNEL && | 1103 | if (len > MAX_RX_DATASZ && rd->channel != SDPCM_CONTROL_CHANNEL && |
1105 | type != BRCMF_SDIO_FT_SUPER) { | 1104 | type != BRCMF_SDIO_FT_SUPER) { |
1106 | brcmf_err("HW header length too long\n"); | 1105 | brcmf_err("HW header length too long\n"); |
@@ -1120,7 +1119,7 @@ static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | |||
1120 | rd->len = 0; | 1119 | rd->len = 0; |
1121 | return -EINVAL; | 1120 | return -EINVAL; |
1122 | } | 1121 | } |
1123 | rd->dat_offset = SDPCM_DOFFSET_VALUE(&header[SDPCM_FRAMETAG_LEN]); | 1122 | rd->dat_offset = brcmf_sdio_getdatoffset(header); |
1124 | if (rd->dat_offset < SDPCM_HDRLEN || rd->dat_offset > rd->len) { | 1123 | if (rd->dat_offset < SDPCM_HDRLEN || rd->dat_offset > rd->len) { |
1125 | brcmf_err("seq %d: bad data offset\n", rx_seq); | 1124 | brcmf_err("seq %d: bad data offset\n", rx_seq); |
1126 | bus->sdcnt.rx_badhdr++; | 1125 | bus->sdcnt.rx_badhdr++; |
@@ -1137,14 +1136,15 @@ static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | |||
1137 | /* no need to check the reset for subframe */ | 1136 | /* no need to check the reset for subframe */ |
1138 | if (type == BRCMF_SDIO_FT_SUB) | 1137 | if (type == BRCMF_SDIO_FT_SUB) |
1139 | return 0; | 1138 | return 0; |
1140 | rd->len_nxtfrm = header[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; | 1139 | rd->len_nxtfrm = (swheader & SDPCM_NEXTLEN_MASK) >> SDPCM_NEXTLEN_SHIFT; |
1141 | if (rd->len_nxtfrm << 4 > MAX_RX_DATASZ) { | 1140 | if (rd->len_nxtfrm << 4 > MAX_RX_DATASZ) { |
1142 | /* only warm for NON glom packet */ | 1141 | /* only warm for NON glom packet */ |
1143 | if (rd->channel != SDPCM_GLOM_CHANNEL) | 1142 | if (rd->channel != SDPCM_GLOM_CHANNEL) |
1144 | brcmf_err("seq %d: next length error\n", rx_seq); | 1143 | brcmf_err("seq %d: next length error\n", rx_seq); |
1145 | rd->len_nxtfrm = 0; | 1144 | rd->len_nxtfrm = 0; |
1146 | } | 1145 | } |
1147 | fc = SDPCM_FCMASK_VALUE(&header[SDPCM_FRAMETAG_LEN]); | 1146 | swheader = le32_to_cpu(*(__le32 *)(header + 4)); |
1147 | fc = swheader & SDPCM_FCMASK_MASK; | ||
1148 | if (bus->flowcontrol != fc) { | 1148 | if (bus->flowcontrol != fc) { |
1149 | if (~bus->flowcontrol & fc) | 1149 | if (~bus->flowcontrol & fc) |
1150 | bus->sdcnt.fc_xoff++; | 1150 | bus->sdcnt.fc_xoff++; |
@@ -1153,7 +1153,7 @@ static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | |||
1153 | bus->sdcnt.fc_rcvd++; | 1153 | bus->sdcnt.fc_rcvd++; |
1154 | bus->flowcontrol = fc; | 1154 | bus->flowcontrol = fc; |
1155 | } | 1155 | } |
1156 | tx_seq_max = SDPCM_WINDOW_VALUE(&header[SDPCM_FRAMETAG_LEN]); | 1156 | tx_seq_max = (swheader & SDPCM_WINDOW_MASK) >> SDPCM_WINDOW_SHIFT; |
1157 | if ((u8)(tx_seq_max - bus->tx_seq) > 0x40) { | 1157 | if ((u8)(tx_seq_max - bus->tx_seq) > 0x40) { |
1158 | brcmf_err("seq %d: max tx seq number error\n", rx_seq); | 1158 | brcmf_err("seq %d: max tx seq number error\n", rx_seq); |
1159 | tx_seq_max = bus->tx_seq + 2; | 1159 | tx_seq_max = bus->tx_seq + 2; |
@@ -1163,18 +1163,40 @@ static int brcmf_sdio_hdparser(struct brcmf_sdio *bus, u8 *header, | |||
1163 | return 0; | 1163 | return 0; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | static inline void brcmf_sdio_update_hwhdr(u8 *header, u16 frm_length) | ||
1167 | { | ||
1168 | *(__le16 *)header = cpu_to_le16(frm_length); | ||
1169 | *(((__le16 *)header) + 1) = cpu_to_le16(~frm_length); | ||
1170 | } | ||
1171 | |||
1172 | static void brcmf_sdio_hdpack(struct brcmf_sdio *bus, u8 *header, | ||
1173 | struct brcmf_sdio_hdrinfo *hd_info) | ||
1174 | { | ||
1175 | u32 sw_header; | ||
1176 | |||
1177 | brcmf_sdio_update_hwhdr(header, hd_info->len); | ||
1178 | |||
1179 | sw_header = bus->tx_seq; | ||
1180 | sw_header |= (hd_info->channel << SDPCM_CHANNEL_SHIFT) & | ||
1181 | SDPCM_CHANNEL_MASK; | ||
1182 | sw_header |= (hd_info->dat_offset << SDPCM_DOFFSET_SHIFT) & | ||
1183 | SDPCM_DOFFSET_MASK; | ||
1184 | *(((__le32 *)header) + 1) = cpu_to_le32(sw_header); | ||
1185 | *(((__le32 *)header) + 2) = 0; | ||
1186 | } | ||
1187 | |||
1166 | static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | 1188 | static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) |
1167 | { | 1189 | { |
1168 | u16 dlen, totlen; | 1190 | u16 dlen, totlen; |
1169 | u8 *dptr, num = 0; | 1191 | u8 *dptr, num = 0; |
1170 | 1192 | u32 align = 0; | |
1171 | u16 sublen; | 1193 | u16 sublen; |
1172 | struct sk_buff *pfirst, *pnext; | 1194 | struct sk_buff *pfirst, *pnext; |
1173 | 1195 | ||
1174 | int errcode; | 1196 | int errcode; |
1175 | u8 doff, sfdoff; | 1197 | u8 doff, sfdoff; |
1176 | 1198 | ||
1177 | struct brcmf_sdio_read rd_new; | 1199 | struct brcmf_sdio_hdrinfo rd_new; |
1178 | 1200 | ||
1179 | /* If packets, issue read(s) and send up packet chain */ | 1201 | /* If packets, issue read(s) and send up packet chain */ |
1180 | /* Return sequence numbers consumed? */ | 1202 | /* Return sequence numbers consumed? */ |
@@ -1182,6 +1204,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1182 | brcmf_dbg(SDIO, "start: glomd %p glom %p\n", | 1204 | brcmf_dbg(SDIO, "start: glomd %p glom %p\n", |
1183 | bus->glomd, skb_peek(&bus->glom)); | 1205 | bus->glomd, skb_peek(&bus->glom)); |
1184 | 1206 | ||
1207 | if (bus->sdiodev->pdata) | ||
1208 | align = bus->sdiodev->pdata->sd_sgentry_align; | ||
1209 | if (align < 4) | ||
1210 | align = 4; | ||
1211 | |||
1185 | /* If there's a descriptor, generate the packet chain */ | 1212 | /* If there's a descriptor, generate the packet chain */ |
1186 | if (bus->glomd) { | 1213 | if (bus->glomd) { |
1187 | pfirst = pnext = NULL; | 1214 | pfirst = pnext = NULL; |
@@ -1205,9 +1232,9 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1205 | pnext = NULL; | 1232 | pnext = NULL; |
1206 | break; | 1233 | break; |
1207 | } | 1234 | } |
1208 | if (sublen % BRCMF_SDALIGN) { | 1235 | if (sublen % align) { |
1209 | brcmf_err("sublen %d not multiple of %d\n", | 1236 | brcmf_err("sublen %d not multiple of %d\n", |
1210 | sublen, BRCMF_SDALIGN); | 1237 | sublen, align); |
1211 | } | 1238 | } |
1212 | totlen += sublen; | 1239 | totlen += sublen; |
1213 | 1240 | ||
@@ -1220,7 +1247,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1220 | } | 1247 | } |
1221 | 1248 | ||
1222 | /* Allocate/chain packet for next subframe */ | 1249 | /* Allocate/chain packet for next subframe */ |
1223 | pnext = brcmu_pkt_buf_get_skb(sublen + BRCMF_SDALIGN); | 1250 | pnext = brcmu_pkt_buf_get_skb(sublen + align); |
1224 | if (pnext == NULL) { | 1251 | if (pnext == NULL) { |
1225 | brcmf_err("bcm_pkt_buf_get_skb failed, num %d len %d\n", | 1252 | brcmf_err("bcm_pkt_buf_get_skb failed, num %d len %d\n", |
1226 | num, sublen); | 1253 | num, sublen); |
@@ -1229,7 +1256,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1229 | skb_queue_tail(&bus->glom, pnext); | 1256 | skb_queue_tail(&bus->glom, pnext); |
1230 | 1257 | ||
1231 | /* Adhere to start alignment requirements */ | 1258 | /* Adhere to start alignment requirements */ |
1232 | pkt_align(pnext, sublen, BRCMF_SDALIGN); | 1259 | pkt_align(pnext, sublen, align); |
1233 | } | 1260 | } |
1234 | 1261 | ||
1235 | /* If all allocations succeeded, save packet chain | 1262 | /* If all allocations succeeded, save packet chain |
@@ -1305,8 +1332,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1305 | rd_new.seq_num = rxseq; | 1332 | rd_new.seq_num = rxseq; |
1306 | rd_new.len = dlen; | 1333 | rd_new.len = dlen; |
1307 | sdio_claim_host(bus->sdiodev->func[1]); | 1334 | sdio_claim_host(bus->sdiodev->func[1]); |
1308 | errcode = brcmf_sdio_hdparser(bus, pfirst->data, &rd_new, | 1335 | errcode = brcmf_sdio_hdparse(bus, pfirst->data, &rd_new, |
1309 | BRCMF_SDIO_FT_SUPER); | 1336 | BRCMF_SDIO_FT_SUPER); |
1310 | sdio_release_host(bus->sdiodev->func[1]); | 1337 | sdio_release_host(bus->sdiodev->func[1]); |
1311 | bus->cur_read.len = rd_new.len_nxtfrm << 4; | 1338 | bus->cur_read.len = rd_new.len_nxtfrm << 4; |
1312 | 1339 | ||
@@ -1324,8 +1351,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1324 | rd_new.len = pnext->len; | 1351 | rd_new.len = pnext->len; |
1325 | rd_new.seq_num = rxseq++; | 1352 | rd_new.seq_num = rxseq++; |
1326 | sdio_claim_host(bus->sdiodev->func[1]); | 1353 | sdio_claim_host(bus->sdiodev->func[1]); |
1327 | errcode = brcmf_sdio_hdparser(bus, pnext->data, &rd_new, | 1354 | errcode = brcmf_sdio_hdparse(bus, pnext->data, &rd_new, |
1328 | BRCMF_SDIO_FT_SUB); | 1355 | BRCMF_SDIO_FT_SUB); |
1329 | sdio_release_host(bus->sdiodev->func[1]); | 1356 | sdio_release_host(bus->sdiodev->func[1]); |
1330 | brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), | 1357 | brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), |
1331 | pnext->data, 32, "subframe:\n"); | 1358 | pnext->data, 32, "subframe:\n"); |
@@ -1357,7 +1384,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) | |||
1357 | skb_queue_walk_safe(&bus->glom, pfirst, pnext) { | 1384 | skb_queue_walk_safe(&bus->glom, pfirst, pnext) { |
1358 | dptr = (u8 *) (pfirst->data); | 1385 | dptr = (u8 *) (pfirst->data); |
1359 | sublen = get_unaligned_le16(dptr); | 1386 | sublen = get_unaligned_le16(dptr); |
1360 | doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); | 1387 | doff = brcmf_sdio_getdatoffset(&dptr[SDPCM_HWHDR_LEN]); |
1361 | 1388 | ||
1362 | brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(), | 1389 | brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(), |
1363 | dptr, pfirst->len, | 1390 | dptr, pfirst->len, |
@@ -1535,7 +1562,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) | |||
1535 | uint rxleft = 0; /* Remaining number of frames allowed */ | 1562 | uint rxleft = 0; /* Remaining number of frames allowed */ |
1536 | int ret; /* Return code from calls */ | 1563 | int ret; /* Return code from calls */ |
1537 | uint rxcount = 0; /* Total frames read */ | 1564 | uint rxcount = 0; /* Total frames read */ |
1538 | struct brcmf_sdio_read *rd = &bus->cur_read, rd_new; | 1565 | struct brcmf_sdio_hdrinfo *rd = &bus->cur_read, rd_new; |
1539 | u8 head_read = 0; | 1566 | u8 head_read = 0; |
1540 | 1567 | ||
1541 | brcmf_dbg(TRACE, "Enter\n"); | 1568 | brcmf_dbg(TRACE, "Enter\n"); |
@@ -1583,8 +1610,8 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) | |||
1583 | bus->rxhdr, SDPCM_HDRLEN, | 1610 | bus->rxhdr, SDPCM_HDRLEN, |
1584 | "RxHdr:\n"); | 1611 | "RxHdr:\n"); |
1585 | 1612 | ||
1586 | if (brcmf_sdio_hdparser(bus, bus->rxhdr, rd, | 1613 | if (brcmf_sdio_hdparse(bus, bus->rxhdr, rd, |
1587 | BRCMF_SDIO_FT_NORMAL)) { | 1614 | BRCMF_SDIO_FT_NORMAL)) { |
1588 | sdio_release_host(bus->sdiodev->func[1]); | 1615 | sdio_release_host(bus->sdiodev->func[1]); |
1589 | if (!bus->rxpending) | 1616 | if (!bus->rxpending) |
1590 | break; | 1617 | break; |
@@ -1648,8 +1675,8 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) | |||
1648 | memcpy(bus->rxhdr, pkt->data, SDPCM_HDRLEN); | 1675 | memcpy(bus->rxhdr, pkt->data, SDPCM_HDRLEN); |
1649 | rd_new.seq_num = rd->seq_num; | 1676 | rd_new.seq_num = rd->seq_num; |
1650 | sdio_claim_host(bus->sdiodev->func[1]); | 1677 | sdio_claim_host(bus->sdiodev->func[1]); |
1651 | if (brcmf_sdio_hdparser(bus, bus->rxhdr, &rd_new, | 1678 | if (brcmf_sdio_hdparse(bus, bus->rxhdr, &rd_new, |
1652 | BRCMF_SDIO_FT_NORMAL)) { | 1679 | BRCMF_SDIO_FT_NORMAL)) { |
1653 | rd->len = 0; | 1680 | rd->len = 0; |
1654 | brcmu_pkt_buf_free_skb(pkt); | 1681 | brcmu_pkt_buf_free_skb(pkt); |
1655 | } | 1682 | } |
@@ -1693,7 +1720,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) | |||
1693 | 1720 | ||
1694 | /* Save superframe descriptor and allocate packet frame */ | 1721 | /* Save superframe descriptor and allocate packet frame */ |
1695 | if (rd->channel == SDPCM_GLOM_CHANNEL) { | 1722 | if (rd->channel == SDPCM_GLOM_CHANNEL) { |
1696 | if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { | 1723 | if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_HWHDR_LEN])) { |
1697 | brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", | 1724 | brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", |
1698 | rd->len); | 1725 | rd->len); |
1699 | brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), | 1726 | brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), |
@@ -1759,85 +1786,168 @@ brcmf_sdbrcm_wait_event_wakeup(struct brcmf_sdio *bus) | |||
1759 | return; | 1786 | return; |
1760 | } | 1787 | } |
1761 | 1788 | ||
1789 | /* flag marking a dummy skb added for DMA alignment requirement */ | ||
1790 | #define DUMMY_SKB_FLAG 0x10000 | ||
1791 | /* bit mask of data length chopped from the previous packet */ | ||
1792 | #define DUMMY_SKB_CHOP_LEN_MASK 0xffff | ||
1793 | /** | ||
1794 | * brcmf_sdio_txpkt_prep - packet preparation for transmit | ||
1795 | * @bus: brcmf_sdio structure pointer | ||
1796 | * @pktq: packet list pointer | ||
1797 | * @chan: virtual channel to transmit the packet | ||
1798 | * | ||
1799 | * Processes to be applied to the packet | ||
1800 | * - Align data buffer pointer | ||
1801 | * - Align data buffer length | ||
1802 | * - Prepare header | ||
1803 | * Return: negative value if there is error | ||
1804 | */ | ||
1805 | static int | ||
1806 | brcmf_sdio_txpkt_prep(struct brcmf_sdio *bus, struct sk_buff_head *pktq, | ||
1807 | uint chan) | ||
1808 | { | ||
1809 | u16 head_pad, tail_pad, tail_chop, head_align, sg_align; | ||
1810 | int ntail; | ||
1811 | struct sk_buff *pkt_next, *pkt_new; | ||
1812 | u8 *dat_buf; | ||
1813 | unsigned blksize = bus->sdiodev->func[SDIO_FUNC_2]->cur_blksize; | ||
1814 | struct brcmf_sdio_hdrinfo hd_info = {0}; | ||
1815 | |||
1816 | /* SDIO ADMA requires at least 32 bit alignment */ | ||
1817 | head_align = 4; | ||
1818 | sg_align = 4; | ||
1819 | if (bus->sdiodev->pdata) { | ||
1820 | head_align = bus->sdiodev->pdata->sd_head_align > 4 ? | ||
1821 | bus->sdiodev->pdata->sd_head_align : 4; | ||
1822 | sg_align = bus->sdiodev->pdata->sd_sgentry_align > 4 ? | ||
1823 | bus->sdiodev->pdata->sd_sgentry_align : 4; | ||
1824 | } | ||
1825 | /* sg entry alignment should be a divisor of block size */ | ||
1826 | WARN_ON(blksize % sg_align); | ||
1827 | |||
1828 | pkt_next = pktq->next; | ||
1829 | dat_buf = (u8 *)(pkt_next->data); | ||
1830 | |||
1831 | /* Check head padding */ | ||
1832 | head_pad = ((unsigned long)dat_buf % head_align); | ||
1833 | if (head_pad) { | ||
1834 | if (skb_headroom(pkt_next) < head_pad) { | ||
1835 | bus->sdiodev->bus_if->tx_realloc++; | ||
1836 | head_pad = 0; | ||
1837 | if (skb_cow(pkt_next, head_pad)) | ||
1838 | return -ENOMEM; | ||
1839 | } | ||
1840 | skb_push(pkt_next, head_pad); | ||
1841 | dat_buf = (u8 *)(pkt_next->data); | ||
1842 | memset(dat_buf, 0, head_pad + bus->tx_hdrlen); | ||
1843 | } | ||
1844 | |||
1845 | /* Check tail padding */ | ||
1846 | pkt_new = NULL; | ||
1847 | tail_chop = pkt_next->len % sg_align; | ||
1848 | tail_pad = sg_align - tail_chop; | ||
1849 | tail_pad += blksize - (pkt_next->len + tail_pad) % blksize; | ||
1850 | if (skb_tailroom(pkt_next) < tail_pad && pkt_next->len > blksize) { | ||
1851 | pkt_new = brcmu_pkt_buf_get_skb(tail_pad + tail_chop); | ||
1852 | if (pkt_new == NULL) | ||
1853 | return -ENOMEM; | ||
1854 | memcpy(pkt_new->data, | ||
1855 | pkt_next->data + pkt_next->len - tail_chop, | ||
1856 | tail_chop); | ||
1857 | *(u32 *)(pkt_new->cb) = DUMMY_SKB_FLAG + tail_chop; | ||
1858 | skb_trim(pkt_next, pkt_next->len - tail_chop); | ||
1859 | __skb_queue_after(pktq, pkt_next, pkt_new); | ||
1860 | } else { | ||
1861 | ntail = pkt_next->data_len + tail_pad - | ||
1862 | (pkt_next->end - pkt_next->tail); | ||
1863 | if (skb_cloned(pkt_next) || ntail > 0) | ||
1864 | if (pskb_expand_head(pkt_next, 0, ntail, GFP_ATOMIC)) | ||
1865 | return -ENOMEM; | ||
1866 | if (skb_linearize(pkt_next)) | ||
1867 | return -ENOMEM; | ||
1868 | dat_buf = (u8 *)(pkt_next->data); | ||
1869 | __skb_put(pkt_next, tail_pad); | ||
1870 | } | ||
1871 | |||
1872 | /* Now prep the header */ | ||
1873 | if (pkt_new) | ||
1874 | hd_info.len = pkt_next->len + tail_chop; | ||
1875 | else | ||
1876 | hd_info.len = pkt_next->len - tail_pad; | ||
1877 | hd_info.channel = chan; | ||
1878 | hd_info.dat_offset = head_pad + bus->tx_hdrlen; | ||
1879 | brcmf_sdio_hdpack(bus, dat_buf, &hd_info); | ||
1880 | |||
1881 | if (BRCMF_BYTES_ON() && | ||
1882 | ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) || | ||
1883 | (BRCMF_DATA_ON() && chan != SDPCM_CONTROL_CHANNEL))) | ||
1884 | brcmf_dbg_hex_dump(true, pkt_next, hd_info.len, "Tx Frame:\n"); | ||
1885 | else if (BRCMF_HDRS_ON()) | ||
1886 | brcmf_dbg_hex_dump(true, pkt_next, head_pad + bus->tx_hdrlen, | ||
1887 | "Tx Header:\n"); | ||
1888 | |||
1889 | return 0; | ||
1890 | } | ||
1891 | |||
1892 | /** | ||
1893 | * brcmf_sdio_txpkt_postp - packet post processing for transmit | ||
1894 | * @bus: brcmf_sdio structure pointer | ||
1895 | * @pktq: packet list pointer | ||
1896 | * | ||
1897 | * Processes to be applied to the packet | ||
1898 | * - Remove head padding | ||
1899 | * - Remove tail padding | ||
1900 | */ | ||
1901 | static void | ||
1902 | brcmf_sdio_txpkt_postp(struct brcmf_sdio *bus, struct sk_buff_head *pktq) | ||
1903 | { | ||
1904 | u8 *hdr; | ||
1905 | u32 dat_offset; | ||
1906 | u32 dummy_flags, chop_len; | ||
1907 | struct sk_buff *pkt_next, *tmp, *pkt_prev; | ||
1908 | |||
1909 | skb_queue_walk_safe(pktq, pkt_next, tmp) { | ||
1910 | dummy_flags = *(u32 *)(pkt_next->cb); | ||
1911 | if (dummy_flags & DUMMY_SKB_FLAG) { | ||
1912 | chop_len = dummy_flags & DUMMY_SKB_CHOP_LEN_MASK; | ||
1913 | if (chop_len) { | ||
1914 | pkt_prev = pkt_next->prev; | ||
1915 | memcpy(pkt_prev->data + pkt_prev->len, | ||
1916 | pkt_next->data, chop_len); | ||
1917 | skb_put(pkt_prev, chop_len); | ||
1918 | } | ||
1919 | __skb_unlink(pkt_next, pktq); | ||
1920 | brcmu_pkt_buf_free_skb(pkt_next); | ||
1921 | } else { | ||
1922 | hdr = pkt_next->data + SDPCM_HWHDR_LEN; | ||
1923 | dat_offset = le32_to_cpu(*(__le32 *)hdr); | ||
1924 | dat_offset = (dat_offset & SDPCM_DOFFSET_MASK) >> | ||
1925 | SDPCM_DOFFSET_SHIFT; | ||
1926 | skb_pull(pkt_next, dat_offset); | ||
1927 | } | ||
1928 | } | ||
1929 | } | ||
1930 | |||
1762 | /* Writes a HW/SW header into the packet and sends it. */ | 1931 | /* Writes a HW/SW header into the packet and sends it. */ |
1763 | /* Assumes: (a) header space already there, (b) caller holds lock */ | 1932 | /* Assumes: (a) header space already there, (b) caller holds lock */ |
1764 | static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, | 1933 | static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, |
1765 | uint chan) | 1934 | uint chan) |
1766 | { | 1935 | { |
1767 | int ret; | 1936 | int ret; |
1768 | u8 *frame; | ||
1769 | u16 len, pad = 0; | ||
1770 | u32 swheader; | ||
1771 | int i; | 1937 | int i; |
1938 | struct sk_buff_head localq; | ||
1772 | 1939 | ||
1773 | brcmf_dbg(TRACE, "Enter\n"); | 1940 | brcmf_dbg(TRACE, "Enter\n"); |
1774 | 1941 | ||
1775 | frame = (u8 *) (pkt->data); | 1942 | __skb_queue_head_init(&localq); |
1776 | 1943 | __skb_queue_tail(&localq, pkt); | |
1777 | /* Add alignment padding, allocate new packet if needed */ | 1944 | ret = brcmf_sdio_txpkt_prep(bus, &localq, chan); |
1778 | pad = ((unsigned long)frame % BRCMF_SDALIGN); | 1945 | if (ret) |
1779 | if (pad) { | 1946 | goto done; |
1780 | if (skb_headroom(pkt) < pad) { | ||
1781 | brcmf_dbg(INFO, "insufficient headroom %d for %d pad\n", | ||
1782 | skb_headroom(pkt), pad); | ||
1783 | bus->sdiodev->bus_if->tx_realloc++; | ||
1784 | ret = skb_cow(pkt, BRCMF_SDALIGN); | ||
1785 | if (ret) | ||
1786 | goto done; | ||
1787 | pad = ((unsigned long)frame % BRCMF_SDALIGN); | ||
1788 | } | ||
1789 | skb_push(pkt, pad); | ||
1790 | frame = (u8 *) (pkt->data); | ||
1791 | memset(frame, 0, pad + SDPCM_HDRLEN); | ||
1792 | } | ||
1793 | /* precondition: pad < BRCMF_SDALIGN */ | ||
1794 | |||
1795 | /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ | ||
1796 | len = (u16) (pkt->len); | ||
1797 | *(__le16 *) frame = cpu_to_le16(len); | ||
1798 | *(((__le16 *) frame) + 1) = cpu_to_le16(~len); | ||
1799 | |||
1800 | /* Software tag: channel, sequence number, data offset */ | ||
1801 | swheader = | ||
1802 | ((chan << SDPCM_CHANNEL_SHIFT) & SDPCM_CHANNEL_MASK) | bus->tx_seq | | ||
1803 | (((pad + | ||
1804 | SDPCM_HDRLEN) << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); | ||
1805 | |||
1806 | *(((__le32 *) frame) + 1) = cpu_to_le32(swheader); | ||
1807 | *(((__le32 *) frame) + 2) = 0; | ||
1808 | |||
1809 | #ifdef DEBUG | ||
1810 | tx_packets[pkt->priority]++; | ||
1811 | #endif | ||
1812 | |||
1813 | brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && | ||
1814 | ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) || | ||
1815 | (BRCMF_DATA_ON() && chan != SDPCM_CONTROL_CHANNEL)), | ||
1816 | frame, len, "Tx Frame:\n"); | ||
1817 | brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && | ||
1818 | ((BRCMF_CTL_ON() && | ||
1819 | chan == SDPCM_CONTROL_CHANNEL) || | ||
1820 | (BRCMF_DATA_ON() && | ||
1821 | chan != SDPCM_CONTROL_CHANNEL))) && | ||
1822 | BRCMF_HDRS_ON(), | ||
1823 | frame, min_t(u16, len, 16), "TxHdr:\n"); | ||
1824 | |||
1825 | /* Raise len to next SDIO block to eliminate tail command */ | ||
1826 | if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { | ||
1827 | u16 pad = bus->blocksize - (len % bus->blocksize); | ||
1828 | if ((pad <= bus->roundup) && (pad < bus->blocksize)) | ||
1829 | len += pad; | ||
1830 | } else if (len % BRCMF_SDALIGN) { | ||
1831 | len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); | ||
1832 | } | ||
1833 | |||
1834 | /* Some controllers have trouble with odd bytes -- round to even */ | ||
1835 | if (len & (ALIGNMENT - 1)) | ||
1836 | len = roundup(len, ALIGNMENT); | ||
1837 | 1947 | ||
1838 | sdio_claim_host(bus->sdiodev->func[1]); | 1948 | sdio_claim_host(bus->sdiodev->func[1]); |
1839 | ret = brcmf_sdcard_send_pkt(bus->sdiodev, bus->sdiodev->sbwad, | 1949 | ret = brcmf_sdcard_send_pkt(bus->sdiodev, bus->sdiodev->sbwad, |
1840 | SDIO_FUNC_2, F2SYNC, pkt); | 1950 | SDIO_FUNC_2, F2SYNC, &localq); |
1841 | bus->sdcnt.f2txdata++; | 1951 | bus->sdcnt.f2txdata++; |
1842 | 1952 | ||
1843 | if (ret < 0) { | 1953 | if (ret < 0) { |
@@ -1865,11 +1975,11 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, | |||
1865 | } | 1975 | } |
1866 | sdio_release_host(bus->sdiodev->func[1]); | 1976 | sdio_release_host(bus->sdiodev->func[1]); |
1867 | if (ret == 0) | 1977 | if (ret == 0) |
1868 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; | 1978 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQ_WRAP; |
1869 | 1979 | ||
1870 | done: | 1980 | done: |
1871 | /* restore pkt buffer pointer before calling tx complete routine */ | 1981 | brcmf_sdio_txpkt_postp(bus, &localq); |
1872 | skb_pull(pkt, SDPCM_HDRLEN + pad); | 1982 | __skb_dequeue_tail(&localq); |
1873 | brcmf_txcomplete(bus->sdiodev->dev, pkt, ret == 0); | 1983 | brcmf_txcomplete(bus->sdiodev->dev, pkt, ret == 0); |
1874 | return ret; | 1984 | return ret; |
1875 | } | 1985 | } |
@@ -1880,7 +1990,6 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) | |||
1880 | u32 intstatus = 0; | 1990 | u32 intstatus = 0; |
1881 | int ret = 0, prec_out; | 1991 | int ret = 0, prec_out; |
1882 | uint cnt = 0; | 1992 | uint cnt = 0; |
1883 | uint datalen; | ||
1884 | u8 tx_prec_map; | 1993 | u8 tx_prec_map; |
1885 | 1994 | ||
1886 | brcmf_dbg(TRACE, "Enter\n"); | 1995 | brcmf_dbg(TRACE, "Enter\n"); |
@@ -1896,7 +2005,6 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) | |||
1896 | break; | 2005 | break; |
1897 | } | 2006 | } |
1898 | spin_unlock_bh(&bus->txqlock); | 2007 | spin_unlock_bh(&bus->txqlock); |
1899 | datalen = pkt->len - SDPCM_HDRLEN; | ||
1900 | 2008 | ||
1901 | ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL); | 2009 | ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL); |
1902 | 2010 | ||
@@ -2221,7 +2329,7 @@ static void brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) | |||
2221 | } | 2329 | } |
2222 | 2330 | ||
2223 | } else { | 2331 | } else { |
2224 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; | 2332 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQ_WRAP; |
2225 | } | 2333 | } |
2226 | sdio_release_host(bus->sdiodev->func[1]); | 2334 | sdio_release_host(bus->sdiodev->func[1]); |
2227 | bus->ctrl_frame_stat = false; | 2335 | bus->ctrl_frame_stat = false; |
@@ -2276,13 +2384,14 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) | |||
2276 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); | 2384 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); |
2277 | struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; | 2385 | struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; |
2278 | struct brcmf_sdio *bus = sdiodev->bus; | 2386 | struct brcmf_sdio *bus = sdiodev->bus; |
2387 | ulong flags; | ||
2279 | 2388 | ||
2280 | brcmf_dbg(TRACE, "Enter\n"); | 2389 | brcmf_dbg(TRACE, "Enter\n"); |
2281 | 2390 | ||
2282 | datalen = pkt->len; | 2391 | datalen = pkt->len; |
2283 | 2392 | ||
2284 | /* Add space for the header */ | 2393 | /* Add space for the header */ |
2285 | skb_push(pkt, SDPCM_HDRLEN); | 2394 | skb_push(pkt, bus->tx_hdrlen); |
2286 | /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ | 2395 | /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ |
2287 | 2396 | ||
2288 | prec = prio2prec((pkt->priority & PRIOMASK)); | 2397 | prec = prio2prec((pkt->priority & PRIOMASK)); |
@@ -2293,10 +2402,9 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) | |||
2293 | bus->sdcnt.fcqueued++; | 2402 | bus->sdcnt.fcqueued++; |
2294 | 2403 | ||
2295 | /* Priority based enq */ | 2404 | /* Priority based enq */ |
2296 | spin_lock_bh(&bus->txqlock); | 2405 | spin_lock_irqsave(&bus->txqlock, flags); |
2297 | if (!brcmf_c_prec_enq(bus->sdiodev->dev, &bus->txq, pkt, prec)) { | 2406 | if (!brcmf_c_prec_enq(bus->sdiodev->dev, &bus->txq, pkt, prec)) { |
2298 | skb_pull(pkt, SDPCM_HDRLEN); | 2407 | skb_pull(pkt, bus->tx_hdrlen); |
2299 | brcmf_txcomplete(bus->sdiodev->dev, pkt, false); | ||
2300 | brcmf_err("out of bus->txq !!!\n"); | 2408 | brcmf_err("out of bus->txq !!!\n"); |
2301 | ret = -ENOSR; | 2409 | ret = -ENOSR; |
2302 | } else { | 2410 | } else { |
@@ -2307,7 +2415,7 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) | |||
2307 | bus->txoff = true; | 2415 | bus->txoff = true; |
2308 | brcmf_txflowblock(bus->sdiodev->dev, true); | 2416 | brcmf_txflowblock(bus->sdiodev->dev, true); |
2309 | } | 2417 | } |
2310 | spin_unlock_bh(&bus->txqlock); | 2418 | spin_unlock_irqrestore(&bus->txqlock, flags); |
2311 | 2419 | ||
2312 | #ifdef DEBUG | 2420 | #ifdef DEBUG |
2313 | if (pktq_plen(&bus->txq, prec) > qcount[prec]) | 2421 | if (pktq_plen(&bus->txq, prec) > qcount[prec]) |
@@ -2436,7 +2544,7 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) | |||
2436 | return ret; | 2544 | return ret; |
2437 | } | 2545 | } |
2438 | 2546 | ||
2439 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; | 2547 | bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQ_WRAP; |
2440 | 2548 | ||
2441 | return ret; | 2549 | return ret; |
2442 | } | 2550 | } |
@@ -2446,19 +2554,19 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) | |||
2446 | { | 2554 | { |
2447 | u8 *frame; | 2555 | u8 *frame; |
2448 | u16 len; | 2556 | u16 len; |
2449 | u32 swheader; | ||
2450 | uint retries = 0; | 2557 | uint retries = 0; |
2451 | u8 doff = 0; | 2558 | u8 doff = 0; |
2452 | int ret = -1; | 2559 | int ret = -1; |
2453 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); | 2560 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); |
2454 | struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; | 2561 | struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; |
2455 | struct brcmf_sdio *bus = sdiodev->bus; | 2562 | struct brcmf_sdio *bus = sdiodev->bus; |
2563 | struct brcmf_sdio_hdrinfo hd_info = {0}; | ||
2456 | 2564 | ||
2457 | brcmf_dbg(TRACE, "Enter\n"); | 2565 | brcmf_dbg(TRACE, "Enter\n"); |
2458 | 2566 | ||
2459 | /* Back the pointer to make a room for bus header */ | 2567 | /* Back the pointer to make a room for bus header */ |
2460 | frame = msg - SDPCM_HDRLEN; | 2568 | frame = msg - bus->tx_hdrlen; |
2461 | len = (msglen += SDPCM_HDRLEN); | 2569 | len = (msglen += bus->tx_hdrlen); |
2462 | 2570 | ||
2463 | /* Add alignment padding (optional for ctl frames) */ | 2571 | /* Add alignment padding (optional for ctl frames) */ |
2464 | doff = ((unsigned long)frame % BRCMF_SDALIGN); | 2572 | doff = ((unsigned long)frame % BRCMF_SDALIGN); |
@@ -2466,10 +2574,10 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) | |||
2466 | frame -= doff; | 2574 | frame -= doff; |
2467 | len += doff; | 2575 | len += doff; |
2468 | msglen += doff; | 2576 | msglen += doff; |
2469 | memset(frame, 0, doff + SDPCM_HDRLEN); | 2577 | memset(frame, 0, doff + bus->tx_hdrlen); |
2470 | } | 2578 | } |
2471 | /* precondition: doff < BRCMF_SDALIGN */ | 2579 | /* precondition: doff < BRCMF_SDALIGN */ |
2472 | doff += SDPCM_HDRLEN; | 2580 | doff += bus->tx_hdrlen; |
2473 | 2581 | ||
2474 | /* Round send length to next SDIO block */ | 2582 | /* Round send length to next SDIO block */ |
2475 | if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { | 2583 | if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { |
@@ -2491,18 +2599,10 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) | |||
2491 | brcmf_sdbrcm_bus_sleep(bus, false, false); | 2599 | brcmf_sdbrcm_bus_sleep(bus, false, false); |
2492 | sdio_release_host(bus->sdiodev->func[1]); | 2600 | sdio_release_host(bus->sdiodev->func[1]); |
2493 | 2601 | ||
2494 | /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ | 2602 | hd_info.len = (u16)msglen; |
2495 | *(__le16 *) frame = cpu_to_le16((u16) msglen); | 2603 | hd_info.channel = SDPCM_CONTROL_CHANNEL; |
2496 | *(((__le16 *) frame) + 1) = cpu_to_le16(~msglen); | 2604 | hd_info.dat_offset = doff; |
2497 | 2605 | brcmf_sdio_hdpack(bus, frame, &hd_info); | |
2498 | /* Software tag: channel, sequence number, data offset */ | ||
2499 | swheader = | ||
2500 | ((SDPCM_CONTROL_CHANNEL << SDPCM_CHANNEL_SHIFT) & | ||
2501 | SDPCM_CHANNEL_MASK) | ||
2502 | | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & | ||
2503 | SDPCM_DOFFSET_MASK); | ||
2504 | put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); | ||
2505 | put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); | ||
2506 | 2606 | ||
2507 | if (!data_ok(bus)) { | 2607 | if (!data_ok(bus)) { |
2508 | brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", | 2608 | brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", |
@@ -3733,7 +3833,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) | |||
3733 | struct brcmf_sdio *bus; | 3833 | struct brcmf_sdio *bus; |
3734 | struct brcmf_bus_dcmd *dlst; | 3834 | struct brcmf_bus_dcmd *dlst; |
3735 | u32 dngl_txglom; | 3835 | u32 dngl_txglom; |
3736 | u32 dngl_txglomalign; | 3836 | u32 txglomalign = 0; |
3737 | u8 idx; | 3837 | u8 idx; |
3738 | 3838 | ||
3739 | brcmf_dbg(TRACE, "Enter\n"); | 3839 | brcmf_dbg(TRACE, "Enter\n"); |
@@ -3752,7 +3852,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) | |||
3752 | bus->txbound = BRCMF_TXBOUND; | 3852 | bus->txbound = BRCMF_TXBOUND; |
3753 | bus->rxbound = BRCMF_RXBOUND; | 3853 | bus->rxbound = BRCMF_RXBOUND; |
3754 | bus->txminmax = BRCMF_TXMINMAX; | 3854 | bus->txminmax = BRCMF_TXMINMAX; |
3755 | bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; | 3855 | bus->tx_seq = SDPCM_SEQ_WRAP - 1; |
3756 | 3856 | ||
3757 | INIT_WORK(&bus->datawork, brcmf_sdio_dataworker); | 3857 | INIT_WORK(&bus->datawork, brcmf_sdio_dataworker); |
3758 | bus->brcmf_wq = create_singlethread_workqueue("brcmf_wq"); | 3858 | bus->brcmf_wq = create_singlethread_workqueue("brcmf_wq"); |
@@ -3794,8 +3894,11 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) | |||
3794 | bus->sdiodev->bus_if->chip = bus->ci->chip; | 3894 | bus->sdiodev->bus_if->chip = bus->ci->chip; |
3795 | bus->sdiodev->bus_if->chiprev = bus->ci->chiprev; | 3895 | bus->sdiodev->bus_if->chiprev = bus->ci->chiprev; |
3796 | 3896 | ||
3797 | /* Attach to the brcmf/OS/network interface */ | 3897 | /* default sdio bus header length for tx packet */ |
3798 | ret = brcmf_attach(SDPCM_RESERVE, bus->sdiodev->dev); | 3898 | bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; |
3899 | |||
3900 | /* Attach to the common layer, reserve hdr space */ | ||
3901 | ret = brcmf_attach(bus->tx_hdrlen, bus->sdiodev->dev); | ||
3799 | if (ret != 0) { | 3902 | if (ret != 0) { |
3800 | brcmf_err("brcmf_attach failed\n"); | 3903 | brcmf_err("brcmf_attach failed\n"); |
3801 | goto fail; | 3904 | goto fail; |
@@ -3827,9 +3930,13 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) | |||
3827 | dlst->param_len = sizeof(u32); | 3930 | dlst->param_len = sizeof(u32); |
3828 | } else { | 3931 | } else { |
3829 | /* otherwise, set txglomalign */ | 3932 | /* otherwise, set txglomalign */ |
3830 | dngl_txglomalign = bus->sdiodev->bus_if->align; | 3933 | if (sdiodev->pdata) |
3934 | txglomalign = sdiodev->pdata->sd_sgentry_align; | ||
3935 | /* SDIO ADMA requires at least 32 bit alignment */ | ||
3936 | if (txglomalign < 4) | ||
3937 | txglomalign = 4; | ||
3831 | dlst->name = "bus:txglomalign"; | 3938 | dlst->name = "bus:txglomalign"; |
3832 | dlst->param = (char *)&dngl_txglomalign; | 3939 | dlst->param = (char *)&txglomalign; |
3833 | dlst->param_len = sizeof(u32); | 3940 | dlst->param_len = sizeof(u32); |
3834 | } | 3941 | } |
3835 | list_add(&dlst->list, &bus->sdiodev->bus_if->dcmd_list); | 3942 | list_add(&dlst->list, &bus->sdiodev->bus_if->dcmd_list); |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c index 83ee53a7c76e..fad77dd2a3a5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c | |||
@@ -185,6 +185,10 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr, | |||
185 | ifevent->action, ifevent->ifidx, ifevent->bssidx, | 185 | ifevent->action, ifevent->ifidx, ifevent->bssidx, |
186 | ifevent->flags, ifevent->role); | 186 | ifevent->flags, ifevent->role); |
187 | 187 | ||
188 | if (ifevent->flags & BRCMF_E_IF_FLAG_NOIF) { | ||
189 | brcmf_dbg(EVENT, "event can be ignored\n"); | ||
190 | return; | ||
191 | } | ||
188 | if (ifevent->ifidx >= BRCMF_MAX_IFS) { | 192 | if (ifevent->ifidx >= BRCMF_MAX_IFS) { |
189 | brcmf_err("invalid interface index: %u\n", | 193 | brcmf_err("invalid interface index: %u\n", |
190 | ifevent->ifidx); | 194 | ifevent->ifidx); |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h index 665ef69e974b..ecabb04f33c3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h | |||
@@ -69,4 +69,25 @@ struct brcmf_fil_bss_enable_le { | |||
69 | __le32 enable; | 69 | __le32 enable; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | /** | ||
73 | * struct tdls_iovar - common structure for tdls iovars. | ||
74 | * | ||
75 | * @ea: ether address of peer station. | ||
76 | * @mode: mode value depending on specific tdls iovar. | ||
77 | * @chanspec: channel specification. | ||
78 | * @pad: unused (for future use). | ||
79 | */ | ||
80 | struct brcmf_tdls_iovar_le { | ||
81 | u8 ea[ETH_ALEN]; /* Station address */ | ||
82 | u8 mode; /* mode: depends on iovar */ | ||
83 | __le16 chanspec; | ||
84 | __le32 pad; /* future */ | ||
85 | }; | ||
86 | |||
87 | enum brcmf_tdls_manual_ep_ops { | ||
88 | BRCMF_TDLS_MANUAL_EP_CREATE = 1, | ||
89 | BRCMF_TDLS_MANUAL_EP_DELETE = 3, | ||
90 | BRCMF_TDLS_MANUAL_EP_DISCOVERY = 6 | ||
91 | }; | ||
92 | |||
72 | #endif /* FWIL_TYPES_H_ */ | 93 | #endif /* FWIL_TYPES_H_ */ |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c index f0d9f7f6c83d..82f9140f3d35 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c | |||
@@ -422,9 +422,12 @@ struct brcmf_fws_macdesc_table { | |||
422 | 422 | ||
423 | struct brcmf_fws_info { | 423 | struct brcmf_fws_info { |
424 | struct brcmf_pub *drvr; | 424 | struct brcmf_pub *drvr; |
425 | spinlock_t spinlock; | ||
426 | ulong flags; | ||
425 | struct brcmf_fws_stats stats; | 427 | struct brcmf_fws_stats stats; |
426 | struct brcmf_fws_hanger hanger; | 428 | struct brcmf_fws_hanger hanger; |
427 | enum brcmf_fws_fcmode fcmode; | 429 | enum brcmf_fws_fcmode fcmode; |
430 | bool fw_signals; | ||
428 | bool bcmc_credit_check; | 431 | bool bcmc_credit_check; |
429 | struct brcmf_fws_macdesc_table desc; | 432 | struct brcmf_fws_macdesc_table desc; |
430 | struct workqueue_struct *fws_wq; | 433 | struct workqueue_struct *fws_wq; |
@@ -483,6 +486,18 @@ static int brcmf_fws_get_tlv_len(struct brcmf_fws_info *fws, | |||
483 | } | 486 | } |
484 | #undef BRCMF_FWS_TLV_DEF | 487 | #undef BRCMF_FWS_TLV_DEF |
485 | 488 | ||
489 | static void brcmf_fws_lock(struct brcmf_fws_info *fws) | ||
490 | __acquires(&fws->spinlock) | ||
491 | { | ||
492 | spin_lock_irqsave(&fws->spinlock, fws->flags); | ||
493 | } | ||
494 | |||
495 | static void brcmf_fws_unlock(struct brcmf_fws_info *fws) | ||
496 | __releases(&fws->spinlock) | ||
497 | { | ||
498 | spin_unlock_irqrestore(&fws->spinlock, fws->flags); | ||
499 | } | ||
500 | |||
486 | static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg) | 501 | static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg) |
487 | { | 502 | { |
488 | u32 ifidx = brcmf_skb_if_flags_get_field(skb, INDEX); | 503 | u32 ifidx = brcmf_skb_if_flags_get_field(skb, INDEX); |
@@ -869,8 +884,11 @@ static bool brcmf_fws_tim_update(struct brcmf_fws_info *fws, | |||
869 | skcb->state = BRCMF_FWS_SKBSTATE_TIM; | 884 | skcb->state = BRCMF_FWS_SKBSTATE_TIM; |
870 | bus = fws->drvr->bus_if; | 885 | bus = fws->drvr->bus_if; |
871 | err = brcmf_fws_hdrpush(fws, skb); | 886 | err = brcmf_fws_hdrpush(fws, skb); |
872 | if (err == 0) | 887 | if (err == 0) { |
888 | brcmf_fws_unlock(fws); | ||
873 | err = brcmf_bus_txdata(bus, skb); | 889 | err = brcmf_bus_txdata(bus, skb); |
890 | brcmf_fws_lock(fws); | ||
891 | } | ||
874 | if (err) | 892 | if (err) |
875 | brcmu_pkt_buf_free_skb(skb); | 893 | brcmu_pkt_buf_free_skb(skb); |
876 | return true; | 894 | return true; |
@@ -905,26 +923,10 @@ static int brcmf_fws_rssi_indicate(struct brcmf_fws_info *fws, s8 rssi) | |||
905 | return 0; | 923 | return 0; |
906 | } | 924 | } |
907 | 925 | ||
908 | /* using macro so sparse checking does not complain | ||
909 | * about locking imbalance. | ||
910 | */ | ||
911 | #define brcmf_fws_lock(drvr, flags) \ | ||
912 | do { \ | ||
913 | flags = 0; \ | ||
914 | spin_lock_irqsave(&((drvr)->fws_spinlock), (flags)); \ | ||
915 | } while (0) | ||
916 | |||
917 | /* using macro so sparse checking does not complain | ||
918 | * about locking imbalance. | ||
919 | */ | ||
920 | #define brcmf_fws_unlock(drvr, flags) \ | ||
921 | spin_unlock_irqrestore(&((drvr)->fws_spinlock), (flags)) | ||
922 | |||
923 | static | 926 | static |
924 | int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) | 927 | int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) |
925 | { | 928 | { |
926 | struct brcmf_fws_mac_descriptor *entry, *existing; | 929 | struct brcmf_fws_mac_descriptor *entry, *existing; |
927 | ulong flags; | ||
928 | u8 mac_handle; | 930 | u8 mac_handle; |
929 | u8 ifidx; | 931 | u8 ifidx; |
930 | u8 *addr; | 932 | u8 *addr; |
@@ -938,10 +940,10 @@ int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) | |||
938 | if (entry->occupied) { | 940 | if (entry->occupied) { |
939 | brcmf_dbg(TRACE, "deleting %s mac %pM\n", | 941 | brcmf_dbg(TRACE, "deleting %s mac %pM\n", |
940 | entry->name, addr); | 942 | entry->name, addr); |
941 | brcmf_fws_lock(fws->drvr, flags); | 943 | brcmf_fws_lock(fws); |
942 | brcmf_fws_macdesc_cleanup(fws, entry, -1); | 944 | brcmf_fws_macdesc_cleanup(fws, entry, -1); |
943 | brcmf_fws_macdesc_deinit(entry); | 945 | brcmf_fws_macdesc_deinit(entry); |
944 | brcmf_fws_unlock(fws->drvr, flags); | 946 | brcmf_fws_unlock(fws); |
945 | } else | 947 | } else |
946 | fws->stats.mac_update_failed++; | 948 | fws->stats.mac_update_failed++; |
947 | return 0; | 949 | return 0; |
@@ -950,13 +952,13 @@ int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) | |||
950 | existing = brcmf_fws_macdesc_lookup(fws, addr); | 952 | existing = brcmf_fws_macdesc_lookup(fws, addr); |
951 | if (IS_ERR(existing)) { | 953 | if (IS_ERR(existing)) { |
952 | if (!entry->occupied) { | 954 | if (!entry->occupied) { |
953 | brcmf_fws_lock(fws->drvr, flags); | 955 | brcmf_fws_lock(fws); |
954 | entry->mac_handle = mac_handle; | 956 | entry->mac_handle = mac_handle; |
955 | brcmf_fws_macdesc_init(entry, addr, ifidx); | 957 | brcmf_fws_macdesc_init(entry, addr, ifidx); |
956 | brcmf_fws_macdesc_set_name(fws, entry); | 958 | brcmf_fws_macdesc_set_name(fws, entry); |
957 | brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT, | 959 | brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT, |
958 | BRCMF_FWS_PSQ_LEN); | 960 | BRCMF_FWS_PSQ_LEN); |
959 | brcmf_fws_unlock(fws->drvr, flags); | 961 | brcmf_fws_unlock(fws); |
960 | brcmf_dbg(TRACE, "add %s mac %pM\n", entry->name, addr); | 962 | brcmf_dbg(TRACE, "add %s mac %pM\n", entry->name, addr); |
961 | } else { | 963 | } else { |
962 | fws->stats.mac_update_failed++; | 964 | fws->stats.mac_update_failed++; |
@@ -964,13 +966,13 @@ int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) | |||
964 | } else { | 966 | } else { |
965 | if (entry != existing) { | 967 | if (entry != existing) { |
966 | brcmf_dbg(TRACE, "copy mac %s\n", existing->name); | 968 | brcmf_dbg(TRACE, "copy mac %s\n", existing->name); |
967 | brcmf_fws_lock(fws->drvr, flags); | 969 | brcmf_fws_lock(fws); |
968 | memcpy(entry, existing, | 970 | memcpy(entry, existing, |
969 | offsetof(struct brcmf_fws_mac_descriptor, psq)); | 971 | offsetof(struct brcmf_fws_mac_descriptor, psq)); |
970 | entry->mac_handle = mac_handle; | 972 | entry->mac_handle = mac_handle; |
971 | brcmf_fws_macdesc_deinit(existing); | 973 | brcmf_fws_macdesc_deinit(existing); |
972 | brcmf_fws_macdesc_set_name(fws, entry); | 974 | brcmf_fws_macdesc_set_name(fws, entry); |
973 | brcmf_fws_unlock(fws->drvr, flags); | 975 | brcmf_fws_unlock(fws); |
974 | brcmf_dbg(TRACE, "relocate %s mac %pM\n", entry->name, | 976 | brcmf_dbg(TRACE, "relocate %s mac %pM\n", entry->name, |
975 | addr); | 977 | addr); |
976 | } else { | 978 | } else { |
@@ -986,7 +988,6 @@ static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info *fws, | |||
986 | u8 type, u8 *data) | 988 | u8 type, u8 *data) |
987 | { | 989 | { |
988 | struct brcmf_fws_mac_descriptor *entry; | 990 | struct brcmf_fws_mac_descriptor *entry; |
989 | ulong flags; | ||
990 | u8 mac_handle; | 991 | u8 mac_handle; |
991 | int ret; | 992 | int ret; |
992 | 993 | ||
@@ -996,7 +997,7 @@ static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info *fws, | |||
996 | fws->stats.mac_ps_update_failed++; | 997 | fws->stats.mac_ps_update_failed++; |
997 | return -ESRCH; | 998 | return -ESRCH; |
998 | } | 999 | } |
999 | brcmf_fws_lock(fws->drvr, flags); | 1000 | brcmf_fws_lock(fws); |
1000 | /* a state update should wipe old credits */ | 1001 | /* a state update should wipe old credits */ |
1001 | entry->requested_credit = 0; | 1002 | entry->requested_credit = 0; |
1002 | entry->requested_packet = 0; | 1003 | entry->requested_packet = 0; |
@@ -1011,7 +1012,7 @@ static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info *fws, | |||
1011 | brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_VO, true); | 1012 | brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_VO, true); |
1012 | ret = BRCMF_FWS_RET_OK_NOSCHEDULE; | 1013 | ret = BRCMF_FWS_RET_OK_NOSCHEDULE; |
1013 | } | 1014 | } |
1014 | brcmf_fws_unlock(fws->drvr, flags); | 1015 | brcmf_fws_unlock(fws); |
1015 | return ret; | 1016 | return ret; |
1016 | } | 1017 | } |
1017 | 1018 | ||
@@ -1019,7 +1020,6 @@ static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info *fws, | |||
1019 | u8 type, u8 *data) | 1020 | u8 type, u8 *data) |
1020 | { | 1021 | { |
1021 | struct brcmf_fws_mac_descriptor *entry; | 1022 | struct brcmf_fws_mac_descriptor *entry; |
1022 | ulong flags; | ||
1023 | u8 ifidx; | 1023 | u8 ifidx; |
1024 | int ret; | 1024 | int ret; |
1025 | 1025 | ||
@@ -1038,7 +1038,7 @@ static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info *fws, | |||
1038 | 1038 | ||
1039 | brcmf_dbg(TRACE, "%s (%d): %s\n", brcmf_fws_get_tlv_name(type), type, | 1039 | brcmf_dbg(TRACE, "%s (%d): %s\n", brcmf_fws_get_tlv_name(type), type, |
1040 | entry->name); | 1040 | entry->name); |
1041 | brcmf_fws_lock(fws->drvr, flags); | 1041 | brcmf_fws_lock(fws); |
1042 | switch (type) { | 1042 | switch (type) { |
1043 | case BRCMF_FWS_TYPE_INTERFACE_OPEN: | 1043 | case BRCMF_FWS_TYPE_INTERFACE_OPEN: |
1044 | entry->state = BRCMF_FWS_STATE_OPEN; | 1044 | entry->state = BRCMF_FWS_STATE_OPEN; |
@@ -1050,10 +1050,10 @@ static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info *fws, | |||
1050 | break; | 1050 | break; |
1051 | default: | 1051 | default: |
1052 | ret = -EINVAL; | 1052 | ret = -EINVAL; |
1053 | brcmf_fws_unlock(fws->drvr, flags); | 1053 | brcmf_fws_unlock(fws); |
1054 | goto fail; | 1054 | goto fail; |
1055 | } | 1055 | } |
1056 | brcmf_fws_unlock(fws->drvr, flags); | 1056 | brcmf_fws_unlock(fws); |
1057 | return ret; | 1057 | return ret; |
1058 | 1058 | ||
1059 | fail: | 1059 | fail: |
@@ -1065,7 +1065,6 @@ static int brcmf_fws_request_indicate(struct brcmf_fws_info *fws, u8 type, | |||
1065 | u8 *data) | 1065 | u8 *data) |
1066 | { | 1066 | { |
1067 | struct brcmf_fws_mac_descriptor *entry; | 1067 | struct brcmf_fws_mac_descriptor *entry; |
1068 | ulong flags; | ||
1069 | 1068 | ||
1070 | entry = &fws->desc.nodes[data[1] & 0x1F]; | 1069 | entry = &fws->desc.nodes[data[1] & 0x1F]; |
1071 | if (!entry->occupied) { | 1070 | if (!entry->occupied) { |
@@ -1079,14 +1078,14 @@ static int brcmf_fws_request_indicate(struct brcmf_fws_info *fws, u8 type, | |||
1079 | brcmf_dbg(TRACE, "%s (%d): %s cnt %d bmp %d\n", | 1078 | brcmf_dbg(TRACE, "%s (%d): %s cnt %d bmp %d\n", |
1080 | brcmf_fws_get_tlv_name(type), type, entry->name, | 1079 | brcmf_fws_get_tlv_name(type), type, entry->name, |
1081 | data[0], data[2]); | 1080 | data[0], data[2]); |
1082 | brcmf_fws_lock(fws->drvr, flags); | 1081 | brcmf_fws_lock(fws); |
1083 | if (type == BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT) | 1082 | if (type == BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT) |
1084 | entry->requested_credit = data[0]; | 1083 | entry->requested_credit = data[0]; |
1085 | else | 1084 | else |
1086 | entry->requested_packet = data[0]; | 1085 | entry->requested_packet = data[0]; |
1087 | 1086 | ||
1088 | entry->ac_bitmap = data[2]; | 1087 | entry->ac_bitmap = data[2]; |
1089 | brcmf_fws_unlock(fws->drvr, flags); | 1088 | brcmf_fws_unlock(fws); |
1090 | return BRCMF_FWS_RET_OK_SCHEDULE; | 1089 | return BRCMF_FWS_RET_OK_SCHEDULE; |
1091 | } | 1090 | } |
1092 | 1091 | ||
@@ -1160,7 +1159,8 @@ static void brcmf_fws_return_credits(struct brcmf_fws_info *fws, | |||
1160 | static void brcmf_fws_schedule_deq(struct brcmf_fws_info *fws) | 1159 | static void brcmf_fws_schedule_deq(struct brcmf_fws_info *fws) |
1161 | { | 1160 | { |
1162 | /* only schedule dequeue when there are credits for delayed traffic */ | 1161 | /* only schedule dequeue when there are credits for delayed traffic */ |
1163 | if (fws->fifo_credit_map & fws->fifo_delay_map) | 1162 | if ((fws->fifo_credit_map & fws->fifo_delay_map) || |
1163 | (!brcmf_fws_fc_active(fws) && fws->fifo_delay_map)) | ||
1164 | queue_work(fws->fws_wq, &fws->fws_dequeue_work); | 1164 | queue_work(fws->fws_wq, &fws->fws_dequeue_work); |
1165 | } | 1165 | } |
1166 | 1166 | ||
@@ -1383,7 +1383,6 @@ brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot, | |||
1383 | static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info *fws, | 1383 | static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info *fws, |
1384 | u8 *data) | 1384 | u8 *data) |
1385 | { | 1385 | { |
1386 | ulong flags; | ||
1387 | int i; | 1386 | int i; |
1388 | 1387 | ||
1389 | if (fws->fcmode != BRCMF_FWS_FCMODE_EXPLICIT_CREDIT) { | 1388 | if (fws->fcmode != BRCMF_FWS_FCMODE_EXPLICIT_CREDIT) { |
@@ -1392,19 +1391,18 @@ static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info *fws, | |||
1392 | } | 1391 | } |
1393 | 1392 | ||
1394 | brcmf_dbg(DATA, "enter: data %pM\n", data); | 1393 | brcmf_dbg(DATA, "enter: data %pM\n", data); |
1395 | brcmf_fws_lock(fws->drvr, flags); | 1394 | brcmf_fws_lock(fws); |
1396 | for (i = 0; i < BRCMF_FWS_FIFO_COUNT; i++) | 1395 | for (i = 0; i < BRCMF_FWS_FIFO_COUNT; i++) |
1397 | brcmf_fws_return_credits(fws, i, data[i]); | 1396 | brcmf_fws_return_credits(fws, i, data[i]); |
1398 | 1397 | ||
1399 | brcmf_dbg(DATA, "map: credit %x delay %x\n", fws->fifo_credit_map, | 1398 | brcmf_dbg(DATA, "map: credit %x delay %x\n", fws->fifo_credit_map, |
1400 | fws->fifo_delay_map); | 1399 | fws->fifo_delay_map); |
1401 | brcmf_fws_unlock(fws->drvr, flags); | 1400 | brcmf_fws_unlock(fws); |
1402 | return BRCMF_FWS_RET_OK_SCHEDULE; | 1401 | return BRCMF_FWS_RET_OK_SCHEDULE; |
1403 | } | 1402 | } |
1404 | 1403 | ||
1405 | static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 *data) | 1404 | static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 *data) |
1406 | { | 1405 | { |
1407 | ulong lflags; | ||
1408 | __le32 status_le; | 1406 | __le32 status_le; |
1409 | u32 status; | 1407 | u32 status; |
1410 | u32 hslot; | 1408 | u32 hslot; |
@@ -1418,9 +1416,9 @@ static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 *data) | |||
1418 | hslot = brcmf_txstatus_get_field(status, HSLOT); | 1416 | hslot = brcmf_txstatus_get_field(status, HSLOT); |
1419 | genbit = brcmf_txstatus_get_field(status, GENERATION); | 1417 | genbit = brcmf_txstatus_get_field(status, GENERATION); |
1420 | 1418 | ||
1421 | brcmf_fws_lock(fws->drvr, lflags); | 1419 | brcmf_fws_lock(fws); |
1422 | brcmf_fws_txs_process(fws, flags, hslot, genbit); | 1420 | brcmf_fws_txs_process(fws, flags, hslot, genbit); |
1423 | brcmf_fws_unlock(fws->drvr, lflags); | 1421 | brcmf_fws_unlock(fws); |
1424 | return BRCMF_FWS_RET_OK_NOSCHEDULE; | 1422 | return BRCMF_FWS_RET_OK_NOSCHEDULE; |
1425 | } | 1423 | } |
1426 | 1424 | ||
@@ -1440,7 +1438,6 @@ static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp, | |||
1440 | { | 1438 | { |
1441 | struct brcmf_fws_info *fws = ifp->drvr->fws; | 1439 | struct brcmf_fws_info *fws = ifp->drvr->fws; |
1442 | int i; | 1440 | int i; |
1443 | ulong flags; | ||
1444 | u8 *credits = data; | 1441 | u8 *credits = data; |
1445 | 1442 | ||
1446 | if (e->datalen < BRCMF_FWS_FIFO_COUNT) { | 1443 | if (e->datalen < BRCMF_FWS_FIFO_COUNT) { |
@@ -1453,7 +1450,7 @@ static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp, | |||
1453 | fws->creditmap_received = true; | 1450 | fws->creditmap_received = true; |
1454 | 1451 | ||
1455 | brcmf_dbg(TRACE, "enter: credits %pM\n", credits); | 1452 | brcmf_dbg(TRACE, "enter: credits %pM\n", credits); |
1456 | brcmf_fws_lock(ifp->drvr, flags); | 1453 | brcmf_fws_lock(fws); |
1457 | for (i = 0; i < ARRAY_SIZE(fws->fifo_credit); i++) { | 1454 | for (i = 0; i < ARRAY_SIZE(fws->fifo_credit); i++) { |
1458 | if (*credits) | 1455 | if (*credits) |
1459 | fws->fifo_credit_map |= 1 << i; | 1456 | fws->fifo_credit_map |= 1 << i; |
@@ -1462,7 +1459,7 @@ static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp, | |||
1462 | fws->fifo_credit[i] = *credits++; | 1459 | fws->fifo_credit[i] = *credits++; |
1463 | } | 1460 | } |
1464 | brcmf_fws_schedule_deq(fws); | 1461 | brcmf_fws_schedule_deq(fws); |
1465 | brcmf_fws_unlock(ifp->drvr, flags); | 1462 | brcmf_fws_unlock(fws); |
1466 | return 0; | 1463 | return 0; |
1467 | } | 1464 | } |
1468 | 1465 | ||
@@ -1471,18 +1468,18 @@ static int brcmf_fws_notify_bcmc_credit_support(struct brcmf_if *ifp, | |||
1471 | void *data) | 1468 | void *data) |
1472 | { | 1469 | { |
1473 | struct brcmf_fws_info *fws = ifp->drvr->fws; | 1470 | struct brcmf_fws_info *fws = ifp->drvr->fws; |
1474 | ulong flags; | ||
1475 | 1471 | ||
1476 | brcmf_fws_lock(ifp->drvr, flags); | 1472 | brcmf_fws_lock(fws); |
1477 | if (fws) | 1473 | if (fws) |
1478 | fws->bcmc_credit_check = true; | 1474 | fws->bcmc_credit_check = true; |
1479 | brcmf_fws_unlock(ifp->drvr, flags); | 1475 | brcmf_fws_unlock(fws); |
1480 | return 0; | 1476 | return 0; |
1481 | } | 1477 | } |
1482 | 1478 | ||
1483 | int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len, | 1479 | int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len, |
1484 | struct sk_buff *skb) | 1480 | struct sk_buff *skb) |
1485 | { | 1481 | { |
1482 | struct brcmf_skb_reorder_data *rd; | ||
1486 | struct brcmf_fws_info *fws = drvr->fws; | 1483 | struct brcmf_fws_info *fws = drvr->fws; |
1487 | u8 *signal_data; | 1484 | u8 *signal_data; |
1488 | s16 data_len; | 1485 | s16 data_len; |
@@ -1497,8 +1494,10 @@ int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len, | |||
1497 | 1494 | ||
1498 | WARN_ON(signal_len > skb->len); | 1495 | WARN_ON(signal_len > skb->len); |
1499 | 1496 | ||
1497 | if (!signal_len) | ||
1498 | return 0; | ||
1500 | /* if flow control disabled, skip to packet data and leave */ | 1499 | /* if flow control disabled, skip to packet data and leave */ |
1501 | if (!signal_len || !drvr->fw_signals) { | 1500 | if (!fws->fw_signals) { |
1502 | skb_pull(skb, signal_len); | 1501 | skb_pull(skb, signal_len); |
1503 | return 0; | 1502 | return 0; |
1504 | } | 1503 | } |
@@ -1536,9 +1535,12 @@ int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len, | |||
1536 | 1535 | ||
1537 | err = BRCMF_FWS_RET_OK_NOSCHEDULE; | 1536 | err = BRCMF_FWS_RET_OK_NOSCHEDULE; |
1538 | switch (type) { | 1537 | switch (type) { |
1539 | case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS: | ||
1540 | case BRCMF_FWS_TYPE_COMP_TXSTATUS: | 1538 | case BRCMF_FWS_TYPE_COMP_TXSTATUS: |
1541 | break; | 1539 | break; |
1540 | case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS: | ||
1541 | rd = (struct brcmf_skb_reorder_data *)skb->cb; | ||
1542 | rd->reorder = data; | ||
1543 | break; | ||
1542 | case BRCMF_FWS_TYPE_MACDESC_ADD: | 1544 | case BRCMF_FWS_TYPE_MACDESC_ADD: |
1543 | case BRCMF_FWS_TYPE_MACDESC_DEL: | 1545 | case BRCMF_FWS_TYPE_MACDESC_DEL: |
1544 | brcmf_fws_macdesc_indicate(fws, type, data); | 1546 | brcmf_fws_macdesc_indicate(fws, type, data); |
@@ -1694,17 +1696,22 @@ static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo, | |||
1694 | return PTR_ERR(entry); | 1696 | return PTR_ERR(entry); |
1695 | 1697 | ||
1696 | brcmf_fws_precommit_skb(fws, fifo, skb); | 1698 | brcmf_fws_precommit_skb(fws, fifo, skb); |
1699 | entry->transit_count++; | ||
1700 | if (entry->suppressed) | ||
1701 | entry->suppr_transit_count++; | ||
1702 | brcmf_fws_unlock(fws); | ||
1697 | rc = brcmf_bus_txdata(bus, skb); | 1703 | rc = brcmf_bus_txdata(bus, skb); |
1704 | brcmf_fws_lock(fws); | ||
1698 | brcmf_dbg(DATA, "%s flags %X htod %X bus_tx %d\n", entry->name, | 1705 | brcmf_dbg(DATA, "%s flags %X htod %X bus_tx %d\n", entry->name, |
1699 | skcb->if_flags, skcb->htod, rc); | 1706 | skcb->if_flags, skcb->htod, rc); |
1700 | if (rc < 0) { | 1707 | if (rc < 0) { |
1708 | entry->transit_count--; | ||
1709 | if (entry->suppressed) | ||
1710 | entry->suppr_transit_count--; | ||
1701 | brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb); | 1711 | brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb); |
1702 | goto rollback; | 1712 | goto rollback; |
1703 | } | 1713 | } |
1704 | 1714 | ||
1705 | entry->transit_count++; | ||
1706 | if (entry->suppressed) | ||
1707 | entry->suppr_transit_count++; | ||
1708 | fws->stats.pkt2bus++; | 1715 | fws->stats.pkt2bus++; |
1709 | fws->stats.send_pkts[fifo]++; | 1716 | fws->stats.send_pkts[fifo]++; |
1710 | if (brcmf_skb_if_flags_get_field(skb, REQUESTED)) | 1717 | if (brcmf_skb_if_flags_get_field(skb, REQUESTED)) |
@@ -1741,26 +1748,19 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb) | |||
1741 | struct brcmf_fws_info *fws = drvr->fws; | 1748 | struct brcmf_fws_info *fws = drvr->fws; |
1742 | struct brcmf_skbuff_cb *skcb = brcmf_skbcb(skb); | 1749 | struct brcmf_skbuff_cb *skcb = brcmf_skbcb(skb); |
1743 | struct ethhdr *eh = (struct ethhdr *)(skb->data); | 1750 | struct ethhdr *eh = (struct ethhdr *)(skb->data); |
1744 | ulong flags; | ||
1745 | int fifo = BRCMF_FWS_FIFO_BCMC; | 1751 | int fifo = BRCMF_FWS_FIFO_BCMC; |
1746 | bool multicast = is_multicast_ether_addr(eh->h_dest); | 1752 | bool multicast = is_multicast_ether_addr(eh->h_dest); |
1753 | bool pae = eh->h_proto == htons(ETH_P_PAE); | ||
1747 | 1754 | ||
1755 | brcmf_dbg(DATA, "tx proto=0x%X\n", ntohs(eh->h_proto)); | ||
1748 | /* determine the priority */ | 1756 | /* determine the priority */ |
1749 | if (!skb->priority) | 1757 | if (!skb->priority) |
1750 | skb->priority = cfg80211_classify8021d(skb); | 1758 | skb->priority = cfg80211_classify8021d(skb); |
1751 | 1759 | ||
1752 | drvr->tx_multicast += !!multicast; | 1760 | drvr->tx_multicast += !!multicast; |
1753 | if (ntohs(eh->h_proto) == ETH_P_PAE) | 1761 | if (pae) |
1754 | atomic_inc(&ifp->pend_8021x_cnt); | 1762 | atomic_inc(&ifp->pend_8021x_cnt); |
1755 | 1763 | ||
1756 | if (!brcmf_fws_fc_active(fws)) { | ||
1757 | /* If the protocol uses a data header, apply it */ | ||
1758 | brcmf_proto_hdrpush(drvr, ifp->ifidx, 0, skb); | ||
1759 | |||
1760 | /* Use bus module to send data frame */ | ||
1761 | return brcmf_bus_txdata(drvr->bus_if, skb); | ||
1762 | } | ||
1763 | |||
1764 | /* set control buffer information */ | 1764 | /* set control buffer information */ |
1765 | skcb->if_flags = 0; | 1765 | skcb->if_flags = 0; |
1766 | skcb->state = BRCMF_FWS_SKBSTATE_NEW; | 1766 | skcb->state = BRCMF_FWS_SKBSTATE_NEW; |
@@ -1768,7 +1768,7 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb) | |||
1768 | if (!multicast) | 1768 | if (!multicast) |
1769 | fifo = brcmf_fws_prio2fifo[skb->priority]; | 1769 | fifo = brcmf_fws_prio2fifo[skb->priority]; |
1770 | 1770 | ||
1771 | brcmf_fws_lock(drvr, flags); | 1771 | brcmf_fws_lock(fws); |
1772 | if (fifo != BRCMF_FWS_FIFO_AC_BE && fifo < BRCMF_FWS_FIFO_BCMC) | 1772 | if (fifo != BRCMF_FWS_FIFO_AC_BE && fifo < BRCMF_FWS_FIFO_BCMC) |
1773 | fws->borrow_defer_timestamp = jiffies + | 1773 | fws->borrow_defer_timestamp = jiffies + |
1774 | BRCMF_FWS_BORROW_DEFER_PERIOD; | 1774 | BRCMF_FWS_BORROW_DEFER_PERIOD; |
@@ -1781,9 +1781,14 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb) | |||
1781 | brcmf_fws_schedule_deq(fws); | 1781 | brcmf_fws_schedule_deq(fws); |
1782 | } else { | 1782 | } else { |
1783 | brcmf_err("drop skb: no hanger slot\n"); | 1783 | brcmf_err("drop skb: no hanger slot\n"); |
1784 | if (pae) { | ||
1785 | atomic_dec(&ifp->pend_8021x_cnt); | ||
1786 | if (waitqueue_active(&ifp->pend_8021x_wait)) | ||
1787 | wake_up(&ifp->pend_8021x_wait); | ||
1788 | } | ||
1784 | brcmu_pkt_buf_free_skb(skb); | 1789 | brcmu_pkt_buf_free_skb(skb); |
1785 | } | 1790 | } |
1786 | brcmf_fws_unlock(drvr, flags); | 1791 | brcmf_fws_unlock(fws); |
1787 | return 0; | 1792 | return 0; |
1788 | } | 1793 | } |
1789 | 1794 | ||
@@ -1803,7 +1808,7 @@ void brcmf_fws_add_interface(struct brcmf_if *ifp) | |||
1803 | struct brcmf_fws_info *fws = ifp->drvr->fws; | 1808 | struct brcmf_fws_info *fws = ifp->drvr->fws; |
1804 | struct brcmf_fws_mac_descriptor *entry; | 1809 | struct brcmf_fws_mac_descriptor *entry; |
1805 | 1810 | ||
1806 | if (!ifp->ndev || !ifp->drvr->fw_signals) | 1811 | if (!ifp->ndev) |
1807 | return; | 1812 | return; |
1808 | 1813 | ||
1809 | entry = &fws->desc.iface[ifp->ifidx]; | 1814 | entry = &fws->desc.iface[ifp->ifidx]; |
@@ -1818,31 +1823,54 @@ void brcmf_fws_add_interface(struct brcmf_if *ifp) | |||
1818 | void brcmf_fws_del_interface(struct brcmf_if *ifp) | 1823 | void brcmf_fws_del_interface(struct brcmf_if *ifp) |
1819 | { | 1824 | { |
1820 | struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc; | 1825 | struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc; |
1821 | ulong flags; | ||
1822 | 1826 | ||
1823 | if (!entry) | 1827 | if (!entry) |
1824 | return; | 1828 | return; |
1825 | 1829 | ||
1826 | brcmf_fws_lock(ifp->drvr, flags); | 1830 | brcmf_fws_lock(ifp->drvr->fws); |
1827 | ifp->fws_desc = NULL; | 1831 | ifp->fws_desc = NULL; |
1828 | brcmf_dbg(TRACE, "deleting %s\n", entry->name); | 1832 | brcmf_dbg(TRACE, "deleting %s\n", entry->name); |
1829 | brcmf_fws_macdesc_deinit(entry); | 1833 | brcmf_fws_macdesc_deinit(entry); |
1830 | brcmf_fws_cleanup(ifp->drvr->fws, ifp->ifidx); | 1834 | brcmf_fws_cleanup(ifp->drvr->fws, ifp->ifidx); |
1831 | brcmf_fws_unlock(ifp->drvr, flags); | 1835 | brcmf_fws_unlock(ifp->drvr->fws); |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | static void brcmf_fws_dequeue_worker(struct work_struct *worker) | 1838 | static void brcmf_fws_dequeue_worker(struct work_struct *worker) |
1835 | { | 1839 | { |
1836 | struct brcmf_fws_info *fws; | 1840 | struct brcmf_fws_info *fws; |
1841 | struct brcmf_pub *drvr; | ||
1837 | struct sk_buff *skb; | 1842 | struct sk_buff *skb; |
1838 | ulong flags; | ||
1839 | int fifo; | 1843 | int fifo; |
1844 | u32 hslot; | ||
1845 | u32 ifidx; | ||
1846 | int ret; | ||
1840 | 1847 | ||
1841 | fws = container_of(worker, struct brcmf_fws_info, fws_dequeue_work); | 1848 | fws = container_of(worker, struct brcmf_fws_info, fws_dequeue_work); |
1849 | drvr = fws->drvr; | ||
1842 | 1850 | ||
1843 | brcmf_fws_lock(fws->drvr, flags); | 1851 | brcmf_fws_lock(fws); |
1844 | for (fifo = BRCMF_FWS_FIFO_BCMC; fifo >= 0 && !fws->bus_flow_blocked; | 1852 | for (fifo = BRCMF_FWS_FIFO_BCMC; fifo >= 0 && !fws->bus_flow_blocked; |
1845 | fifo--) { | 1853 | fifo--) { |
1854 | if (!brcmf_fws_fc_active(fws)) { | ||
1855 | while ((skb = brcmf_fws_deq(fws, fifo)) != NULL) { | ||
1856 | hslot = brcmf_skb_htod_tag_get_field(skb, | ||
1857 | HSLOT); | ||
1858 | brcmf_fws_hanger_poppkt(&fws->hanger, hslot, | ||
1859 | &skb, true); | ||
1860 | ifidx = brcmf_skb_if_flags_get_field(skb, | ||
1861 | INDEX); | ||
1862 | brcmf_proto_hdrpush(drvr, ifidx, 0, skb); | ||
1863 | /* Use bus module to send data frame */ | ||
1864 | brcmf_fws_unlock(fws); | ||
1865 | ret = brcmf_bus_txdata(drvr->bus_if, skb); | ||
1866 | brcmf_fws_lock(fws); | ||
1867 | if (ret < 0) | ||
1868 | brcmf_txfinalize(drvr, skb, false); | ||
1869 | if (fws->bus_flow_blocked) | ||
1870 | break; | ||
1871 | } | ||
1872 | continue; | ||
1873 | } | ||
1846 | while ((fws->fifo_credit[fifo]) || ((!fws->bcmc_credit_check) && | 1874 | while ((fws->fifo_credit[fifo]) || ((!fws->bcmc_credit_check) && |
1847 | (fifo == BRCMF_FWS_FIFO_BCMC))) { | 1875 | (fifo == BRCMF_FWS_FIFO_BCMC))) { |
1848 | skb = brcmf_fws_deq(fws, fifo); | 1876 | skb = brcmf_fws_deq(fws, fifo); |
@@ -1870,42 +1898,43 @@ static void brcmf_fws_dequeue_worker(struct work_struct *worker) | |||
1870 | } | 1898 | } |
1871 | } | 1899 | } |
1872 | } | 1900 | } |
1873 | brcmf_fws_unlock(fws->drvr, flags); | 1901 | brcmf_fws_unlock(fws); |
1874 | } | 1902 | } |
1875 | 1903 | ||
1876 | int brcmf_fws_init(struct brcmf_pub *drvr) | 1904 | int brcmf_fws_init(struct brcmf_pub *drvr) |
1877 | { | 1905 | { |
1906 | struct brcmf_fws_info *fws; | ||
1878 | u32 tlv = BRCMF_FWS_FLAGS_RSSI_SIGNALS; | 1907 | u32 tlv = BRCMF_FWS_FLAGS_RSSI_SIGNALS; |
1879 | int rc; | 1908 | int rc; |
1880 | 1909 | ||
1881 | if (!drvr->fw_signals) | ||
1882 | return 0; | ||
1883 | |||
1884 | spin_lock_init(&drvr->fws_spinlock); | ||
1885 | |||
1886 | drvr->fws = kzalloc(sizeof(*(drvr->fws)), GFP_KERNEL); | 1910 | drvr->fws = kzalloc(sizeof(*(drvr->fws)), GFP_KERNEL); |
1887 | if (!drvr->fws) { | 1911 | if (!drvr->fws) { |
1888 | rc = -ENOMEM; | 1912 | rc = -ENOMEM; |
1889 | goto fail; | 1913 | goto fail; |
1890 | } | 1914 | } |
1891 | 1915 | ||
1916 | fws = drvr->fws; | ||
1917 | |||
1918 | spin_lock_init(&fws->spinlock); | ||
1919 | |||
1892 | /* set linkage back */ | 1920 | /* set linkage back */ |
1893 | drvr->fws->drvr = drvr; | 1921 | fws->drvr = drvr; |
1894 | drvr->fws->fcmode = fcmode; | 1922 | fws->fcmode = fcmode; |
1895 | 1923 | ||
1896 | drvr->fws->fws_wq = create_singlethread_workqueue("brcmf_fws_wq"); | 1924 | fws->fws_wq = create_singlethread_workqueue("brcmf_fws_wq"); |
1897 | if (drvr->fws->fws_wq == NULL) { | 1925 | if (fws->fws_wq == NULL) { |
1898 | brcmf_err("workqueue creation failed\n"); | 1926 | brcmf_err("workqueue creation failed\n"); |
1899 | rc = -EBADF; | 1927 | rc = -EBADF; |
1900 | goto fail; | 1928 | goto fail; |
1901 | } | 1929 | } |
1902 | INIT_WORK(&drvr->fws->fws_dequeue_work, brcmf_fws_dequeue_worker); | 1930 | INIT_WORK(&fws->fws_dequeue_work, brcmf_fws_dequeue_worker); |
1903 | 1931 | ||
1904 | /* enable firmware signalling if fcmode active */ | 1932 | /* enable firmware signalling if fcmode active */ |
1905 | if (drvr->fws->fcmode != BRCMF_FWS_FCMODE_NONE) | 1933 | if (fws->fcmode != BRCMF_FWS_FCMODE_NONE) |
1906 | tlv |= BRCMF_FWS_FLAGS_XONXOFF_SIGNALS | | 1934 | tlv |= BRCMF_FWS_FLAGS_XONXOFF_SIGNALS | |
1907 | BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS | | 1935 | BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS | |
1908 | BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE; | 1936 | BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE | |
1937 | BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE; | ||
1909 | 1938 | ||
1910 | rc = brcmf_fweh_register(drvr, BRCMF_E_FIFO_CREDIT_MAP, | 1939 | rc = brcmf_fweh_register(drvr, BRCMF_E_FIFO_CREDIT_MAP, |
1911 | brcmf_fws_notify_credit_map); | 1940 | brcmf_fws_notify_credit_map); |
@@ -1921,31 +1950,33 @@ int brcmf_fws_init(struct brcmf_pub *drvr) | |||
1921 | goto fail; | 1950 | goto fail; |
1922 | } | 1951 | } |
1923 | 1952 | ||
1924 | /* setting the iovar may fail if feature is unsupported | 1953 | /* Setting the iovar may fail if feature is unsupported |
1925 | * so leave the rc as is so driver initialization can | 1954 | * so leave the rc as is so driver initialization can |
1926 | * continue. | 1955 | * continue. Set mode back to none indicating not enabled. |
1927 | */ | 1956 | */ |
1957 | fws->fw_signals = true; | ||
1928 | if (brcmf_fil_iovar_int_set(drvr->iflist[0], "tlv", tlv)) { | 1958 | if (brcmf_fil_iovar_int_set(drvr->iflist[0], "tlv", tlv)) { |
1929 | brcmf_err("failed to set bdcv2 tlv signaling\n"); | 1959 | brcmf_err("failed to set bdcv2 tlv signaling\n"); |
1930 | goto fail_event; | 1960 | fws->fcmode = BRCMF_FWS_FCMODE_NONE; |
1961 | fws->fw_signals = false; | ||
1931 | } | 1962 | } |
1932 | 1963 | ||
1933 | brcmf_fws_hanger_init(&drvr->fws->hanger); | 1964 | if (brcmf_fil_iovar_int_set(drvr->iflist[0], "ampdu_hostreorder", 1)) |
1934 | brcmf_fws_macdesc_init(&drvr->fws->desc.other, NULL, 0); | 1965 | brcmf_dbg(INFO, "enabling AMPDU host-reorder failed\n"); |
1935 | brcmf_fws_macdesc_set_name(drvr->fws, &drvr->fws->desc.other); | 1966 | |
1936 | brcmu_pktq_init(&drvr->fws->desc.other.psq, BRCMF_FWS_PSQ_PREC_COUNT, | 1967 | brcmf_fws_hanger_init(&fws->hanger); |
1968 | brcmf_fws_macdesc_init(&fws->desc.other, NULL, 0); | ||
1969 | brcmf_fws_macdesc_set_name(fws, &fws->desc.other); | ||
1970 | brcmu_pktq_init(&fws->desc.other.psq, BRCMF_FWS_PSQ_PREC_COUNT, | ||
1937 | BRCMF_FWS_PSQ_LEN); | 1971 | BRCMF_FWS_PSQ_LEN); |
1938 | 1972 | ||
1939 | /* create debugfs file for statistics */ | 1973 | /* create debugfs file for statistics */ |
1940 | brcmf_debugfs_create_fws_stats(drvr, &drvr->fws->stats); | 1974 | brcmf_debugfs_create_fws_stats(drvr, &fws->stats); |
1941 | 1975 | ||
1942 | brcmf_dbg(INFO, "%s bdcv2 tlv signaling [%x]\n", | 1976 | brcmf_dbg(INFO, "%s bdcv2 tlv signaling [%x]\n", |
1943 | drvr->fw_signals ? "enabled" : "disabled", tlv); | 1977 | fws->fw_signals ? "enabled" : "disabled", tlv); |
1944 | return 0; | 1978 | return 0; |
1945 | 1979 | ||
1946 | fail_event: | ||
1947 | brcmf_fweh_unregister(drvr, BRCMF_E_BCMC_CREDIT_SUPPORT); | ||
1948 | brcmf_fweh_unregister(drvr, BRCMF_E_FIFO_CREDIT_MAP); | ||
1949 | fail: | 1980 | fail: |
1950 | brcmf_fws_deinit(drvr); | 1981 | brcmf_fws_deinit(drvr); |
1951 | return rc; | 1982 | return rc; |
@@ -1954,24 +1985,18 @@ fail: | |||
1954 | void brcmf_fws_deinit(struct brcmf_pub *drvr) | 1985 | void brcmf_fws_deinit(struct brcmf_pub *drvr) |
1955 | { | 1986 | { |
1956 | struct brcmf_fws_info *fws = drvr->fws; | 1987 | struct brcmf_fws_info *fws = drvr->fws; |
1957 | ulong flags; | ||
1958 | 1988 | ||
1959 | if (!fws) | 1989 | if (!fws) |
1960 | return; | 1990 | return; |
1961 | 1991 | ||
1962 | /* disable firmware signalling entirely | ||
1963 | * to avoid using the workqueue. | ||
1964 | */ | ||
1965 | drvr->fw_signals = false; | ||
1966 | |||
1967 | if (drvr->fws->fws_wq) | 1992 | if (drvr->fws->fws_wq) |
1968 | destroy_workqueue(drvr->fws->fws_wq); | 1993 | destroy_workqueue(drvr->fws->fws_wq); |
1969 | 1994 | ||
1970 | /* cleanup */ | 1995 | /* cleanup */ |
1971 | brcmf_fws_lock(drvr, flags); | 1996 | brcmf_fws_lock(fws); |
1972 | brcmf_fws_cleanup(fws, -1); | 1997 | brcmf_fws_cleanup(fws, -1); |
1973 | drvr->fws = NULL; | 1998 | drvr->fws = NULL; |
1974 | brcmf_fws_unlock(drvr, flags); | 1999 | brcmf_fws_unlock(fws); |
1975 | 2000 | ||
1976 | /* free top structure */ | 2001 | /* free top structure */ |
1977 | kfree(fws); | 2002 | kfree(fws); |
@@ -1979,7 +2004,7 @@ void brcmf_fws_deinit(struct brcmf_pub *drvr) | |||
1979 | 2004 | ||
1980 | bool brcmf_fws_fc_active(struct brcmf_fws_info *fws) | 2005 | bool brcmf_fws_fc_active(struct brcmf_fws_info *fws) |
1981 | { | 2006 | { |
1982 | if (!fws) | 2007 | if (!fws->creditmap_received) |
1983 | return false; | 2008 | return false; |
1984 | 2009 | ||
1985 | return fws->fcmode != BRCMF_FWS_FCMODE_NONE; | 2010 | return fws->fcmode != BRCMF_FWS_FCMODE_NONE; |
@@ -1987,17 +2012,16 @@ bool brcmf_fws_fc_active(struct brcmf_fws_info *fws) | |||
1987 | 2012 | ||
1988 | void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb) | 2013 | void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb) |
1989 | { | 2014 | { |
1990 | ulong flags; | ||
1991 | u32 hslot; | 2015 | u32 hslot; |
1992 | 2016 | ||
1993 | if (brcmf_skbcb(skb)->state == BRCMF_FWS_SKBSTATE_TIM) { | 2017 | if (brcmf_skbcb(skb)->state == BRCMF_FWS_SKBSTATE_TIM) { |
1994 | brcmu_pkt_buf_free_skb(skb); | 2018 | brcmu_pkt_buf_free_skb(skb); |
1995 | return; | 2019 | return; |
1996 | } | 2020 | } |
1997 | brcmf_fws_lock(fws->drvr, flags); | 2021 | brcmf_fws_lock(fws); |
1998 | hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT); | 2022 | hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT); |
1999 | brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED, hslot, 0); | 2023 | brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED, hslot, 0); |
2000 | brcmf_fws_unlock(fws->drvr, flags); | 2024 | brcmf_fws_unlock(fws); |
2001 | } | 2025 | } |
2002 | 2026 | ||
2003 | void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked) | 2027 | void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked) |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 09786a539950..2b5407f002e5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h | |||
@@ -208,7 +208,7 @@ extern int brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr, | |||
208 | */ | 208 | */ |
209 | extern int | 209 | extern int |
210 | brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | 210 | brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, |
211 | uint flags, struct sk_buff *pkt); | 211 | uint flags, struct sk_buff_head *pktq); |
212 | extern int | 212 | extern int |
213 | brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | 213 | brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, |
214 | uint flags, u8 *buf, uint nbytes); | 214 | uint flags, u8 *buf, uint nbytes); |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 322cadc51ded..39e01a7c8556 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c | |||
@@ -614,7 +614,6 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb) | |||
614 | return 0; | 614 | return 0; |
615 | 615 | ||
616 | fail: | 616 | fail: |
617 | brcmf_txcomplete(dev, skb, false); | ||
618 | return ret; | 617 | return ret; |
619 | } | 618 | } |
620 | 619 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index b7d885020dd7..571f013cebbb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | |||
@@ -1093,8 +1093,11 @@ static void brcmf_link_down(struct brcmf_cfg80211_vif *vif) | |||
1093 | brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n "); | 1093 | brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n "); |
1094 | err = brcmf_fil_cmd_data_set(vif->ifp, | 1094 | err = brcmf_fil_cmd_data_set(vif->ifp, |
1095 | BRCMF_C_DISASSOC, NULL, 0); | 1095 | BRCMF_C_DISASSOC, NULL, 0); |
1096 | if (err) | 1096 | if (err) { |
1097 | brcmf_err("WLC_DISASSOC failed (%d)\n", err); | 1097 | brcmf_err("WLC_DISASSOC failed (%d)\n", err); |
1098 | cfg80211_disconnected(vif->wdev.netdev, 0, | ||
1099 | NULL, 0, GFP_KERNEL); | ||
1100 | } | ||
1098 | clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state); | 1101 | clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state); |
1099 | } | 1102 | } |
1100 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state); | 1103 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state); |
@@ -4125,6 +4128,53 @@ static void brcmf_cfg80211_crit_proto_stop(struct wiphy *wiphy, | |||
4125 | clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); | 4128 | clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); |
4126 | } | 4129 | } |
4127 | 4130 | ||
4131 | static int brcmf_convert_nl80211_tdls_oper(enum nl80211_tdls_operation oper) | ||
4132 | { | ||
4133 | int ret; | ||
4134 | |||
4135 | switch (oper) { | ||
4136 | case NL80211_TDLS_DISCOVERY_REQ: | ||
4137 | ret = BRCMF_TDLS_MANUAL_EP_DISCOVERY; | ||
4138 | break; | ||
4139 | case NL80211_TDLS_SETUP: | ||
4140 | ret = BRCMF_TDLS_MANUAL_EP_CREATE; | ||
4141 | break; | ||
4142 | case NL80211_TDLS_TEARDOWN: | ||
4143 | ret = BRCMF_TDLS_MANUAL_EP_DELETE; | ||
4144 | break; | ||
4145 | default: | ||
4146 | brcmf_err("unsupported operation: %d\n", oper); | ||
4147 | ret = -EOPNOTSUPP; | ||
4148 | } | ||
4149 | return ret; | ||
4150 | } | ||
4151 | |||
4152 | static int brcmf_cfg80211_tdls_oper(struct wiphy *wiphy, | ||
4153 | struct net_device *ndev, u8 *peer, | ||
4154 | enum nl80211_tdls_operation oper) | ||
4155 | { | ||
4156 | struct brcmf_if *ifp; | ||
4157 | struct brcmf_tdls_iovar_le info; | ||
4158 | int ret = 0; | ||
4159 | |||
4160 | ret = brcmf_convert_nl80211_tdls_oper(oper); | ||
4161 | if (ret < 0) | ||
4162 | return ret; | ||
4163 | |||
4164 | ifp = netdev_priv(ndev); | ||
4165 | memset(&info, 0, sizeof(info)); | ||
4166 | info.mode = (u8)ret; | ||
4167 | if (peer) | ||
4168 | memcpy(info.ea, peer, ETH_ALEN); | ||
4169 | |||
4170 | ret = brcmf_fil_iovar_data_set(ifp, "tdls_endpoint", | ||
4171 | &info, sizeof(info)); | ||
4172 | if (ret < 0) | ||
4173 | brcmf_err("tdls_endpoint iovar failed: ret=%d\n", ret); | ||
4174 | |||
4175 | return ret; | ||
4176 | } | ||
4177 | |||
4128 | static struct cfg80211_ops wl_cfg80211_ops = { | 4178 | static struct cfg80211_ops wl_cfg80211_ops = { |
4129 | .add_virtual_intf = brcmf_cfg80211_add_iface, | 4179 | .add_virtual_intf = brcmf_cfg80211_add_iface, |
4130 | .del_virtual_intf = brcmf_cfg80211_del_iface, | 4180 | .del_virtual_intf = brcmf_cfg80211_del_iface, |
@@ -4163,9 +4213,8 @@ static struct cfg80211_ops wl_cfg80211_ops = { | |||
4163 | .stop_p2p_device = brcmf_p2p_stop_device, | 4213 | .stop_p2p_device = brcmf_p2p_stop_device, |
4164 | .crit_proto_start = brcmf_cfg80211_crit_proto_start, | 4214 | .crit_proto_start = brcmf_cfg80211_crit_proto_start, |
4165 | .crit_proto_stop = brcmf_cfg80211_crit_proto_stop, | 4215 | .crit_proto_stop = brcmf_cfg80211_crit_proto_stop, |
4166 | #ifdef CONFIG_NL80211_TESTMODE | 4216 | .tdls_oper = brcmf_cfg80211_tdls_oper, |
4167 | .testmode_cmd = brcmf_cfg80211_testmode | 4217 | CFG80211_TESTMODE_CMD(brcmf_cfg80211_testmode) |
4168 | #endif | ||
4169 | }; | 4218 | }; |
4170 | 4219 | ||
4171 | static s32 brcmf_nl80211_iftype_to_mode(enum nl80211_iftype type) | 4220 | static s32 brcmf_nl80211_iftype_to_mode(enum nl80211_iftype type) |
@@ -4286,7 +4335,8 @@ static struct wiphy *brcmf_setup_wiphy(struct device *phydev) | |||
4286 | wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites); | 4335 | wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites); |
4287 | wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT | | 4336 | wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT | |
4288 | WIPHY_FLAG_OFFCHAN_TX | | 4337 | WIPHY_FLAG_OFFCHAN_TX | |
4289 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; | 4338 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | |
4339 | WIPHY_FLAG_SUPPORTS_TDLS; | ||
4290 | wiphy->mgmt_stypes = brcmf_txrx_stypes; | 4340 | wiphy->mgmt_stypes = brcmf_txrx_stypes; |
4291 | wiphy->max_remain_on_channel_duration = 5000; | 4341 | wiphy->max_remain_on_channel_duration = 5000; |
4292 | brcmf_wiphy_pno_params(wiphy); | 4342 | brcmf_wiphy_pno_params(wiphy); |
@@ -4907,6 +4957,12 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, | |||
4907 | goto cfg80211_p2p_attach_out; | 4957 | goto cfg80211_p2p_attach_out; |
4908 | } | 4958 | } |
4909 | 4959 | ||
4960 | err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1); | ||
4961 | if (err) { | ||
4962 | brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err); | ||
4963 | wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_TDLS; | ||
4964 | } | ||
4965 | |||
4910 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, | 4966 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, |
4911 | &io_type); | 4967 | &io_type); |
4912 | if (err) { | 4968 | if (err) { |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index e4fd1ee3d690..53365977bfd6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | |||
@@ -679,27 +679,6 @@ bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode) | |||
679 | return mode == BCMA_CLKMODE_FAST; | 679 | return mode == BCMA_CLKMODE_FAST; |
680 | } | 680 | } |
681 | 681 | ||
682 | void ai_pci_up(struct si_pub *sih) | ||
683 | { | ||
684 | struct si_info *sii; | ||
685 | |||
686 | sii = container_of(sih, struct si_info, pub); | ||
687 | |||
688 | if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI) | ||
689 | bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true); | ||
690 | } | ||
691 | |||
692 | /* Unconfigure and/or apply various WARs when going down */ | ||
693 | void ai_pci_down(struct si_pub *sih) | ||
694 | { | ||
695 | struct si_info *sii; | ||
696 | |||
697 | sii = container_of(sih, struct si_info, pub); | ||
698 | |||
699 | if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI) | ||
700 | bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false); | ||
701 | } | ||
702 | |||
703 | /* Enable BT-COEX & Ex-PA for 4313 */ | 682 | /* Enable BT-COEX & Ex-PA for 4313 */ |
704 | void ai_epa_4313war(struct si_pub *sih) | 683 | void ai_epa_4313war(struct si_pub *sih) |
705 | { | 684 | { |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 89562c1fbf49..a8a267b5b87a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | |||
@@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih); | |||
183 | extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode); | 183 | extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode); |
184 | extern bool ai_deviceremoved(struct si_pub *sih); | 184 | extern bool ai_deviceremoved(struct si_pub *sih); |
185 | 185 | ||
186 | extern void ai_pci_down(struct si_pub *sih); | ||
187 | extern void ai_pci_up(struct si_pub *sih); | ||
188 | |||
189 | /* Enable Ex-PA for 4313 */ | 186 | /* Enable Ex-PA for 4313 */ |
190 | extern void ai_epa_4313war(struct si_pub *sih); | 187 | extern void ai_epa_4313war(struct si_pub *sih); |
191 | 188 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index bd982856d385..fa391e4eb098 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c | |||
@@ -928,9 +928,9 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, | |||
928 | } | 928 | } |
929 | } else if (txs->phyerr) { | 929 | } else if (txs->phyerr) { |
930 | update_rate = false; | 930 | update_rate = false; |
931 | brcms_err(wlc->hw->d11core, | 931 | brcms_dbg_ht(wlc->hw->d11core, |
932 | "%s: ampdu tx phy error (0x%x)\n", | 932 | "%s: ampdu tx phy error (0x%x)\n", |
933 | __func__, txs->phyerr); | 933 | __func__, txs->phyerr); |
934 | } | 934 | } |
935 | } | 935 | } |
936 | 936 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 1860c572b3c4..4fb9635d3919 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c | |||
@@ -1015,9 +1015,10 @@ static bool dma64_txidle(struct dma_info *di) | |||
1015 | 1015 | ||
1016 | /* | 1016 | /* |
1017 | * post receive buffers | 1017 | * post receive buffers |
1018 | * return false is refill failed completely and ring is empty this will stall | 1018 | * Return false if refill failed completely or dma mapping failed. The ring |
1019 | * the rx dma and user might want to call rxfill again asap. This unlikely | 1019 | * is empty, which will stall the rx dma and user might want to call rxfill |
1020 | * happens on memory-rich NIC, but often on memory-constrained dongle | 1020 | * again asap. This is unlikely to happen on a memory-rich NIC, but often on |
1021 | * memory-constrained dongle. | ||
1021 | */ | 1022 | */ |
1022 | bool dma_rxfill(struct dma_pub *pub) | 1023 | bool dma_rxfill(struct dma_pub *pub) |
1023 | { | 1024 | { |
@@ -1078,6 +1079,8 @@ bool dma_rxfill(struct dma_pub *pub) | |||
1078 | 1079 | ||
1079 | pa = dma_map_single(di->dmadev, p->data, di->rxbufsize, | 1080 | pa = dma_map_single(di->dmadev, p->data, di->rxbufsize, |
1080 | DMA_FROM_DEVICE); | 1081 | DMA_FROM_DEVICE); |
1082 | if (dma_mapping_error(di->dmadev, pa)) | ||
1083 | return false; | ||
1081 | 1084 | ||
1082 | /* save the free packet pointer */ | 1085 | /* save the free packet pointer */ |
1083 | di->rxp[rxout] = p; | 1086 | di->rxp[rxout] = p; |
@@ -1284,7 +1287,11 @@ static void dma_txenq(struct dma_info *di, struct sk_buff *p) | |||
1284 | 1287 | ||
1285 | /* get physical address of buffer start */ | 1288 | /* get physical address of buffer start */ |
1286 | pa = dma_map_single(di->dmadev, data, len, DMA_TO_DEVICE); | 1289 | pa = dma_map_single(di->dmadev, data, len, DMA_TO_DEVICE); |
1287 | 1290 | /* if mapping failed, free skb */ | |
1291 | if (dma_mapping_error(di->dmadev, pa)) { | ||
1292 | brcmu_pkt_buf_free_skb(p); | ||
1293 | return; | ||
1294 | } | ||
1288 | /* With a DMA segment list, Descriptor table is filled | 1295 | /* With a DMA segment list, Descriptor table is filled |
1289 | * using the segment list instead of looping over | 1296 | * using the segment list instead of looping over |
1290 | * buffers in multi-chain DMA. Therefore, EOF for SGLIST | 1297 | * buffers in multi-chain DMA. Therefore, EOF for SGLIST |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 9fd6f2fef11b..4608e0eb1493 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c | |||
@@ -882,8 +882,8 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) | |||
882 | mcl = le16_to_cpu(txh->MacTxControlLow); | 882 | mcl = le16_to_cpu(txh->MacTxControlLow); |
883 | 883 | ||
884 | if (txs->phyerr) | 884 | if (txs->phyerr) |
885 | brcms_err(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", | 885 | brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", |
886 | txs->phyerr, txh->MainRates); | 886 | txs->phyerr, txh->MainRates); |
887 | 887 | ||
888 | if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { | 888 | if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { |
889 | brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); | 889 | brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); |
@@ -4652,7 +4652,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, | |||
4652 | wlc->band->phyrev = wlc_hw->band->phyrev; | 4652 | wlc->band->phyrev = wlc_hw->band->phyrev; |
4653 | wlc->band->radioid = wlc_hw->band->radioid; | 4653 | wlc->band->radioid = wlc_hw->band->radioid; |
4654 | wlc->band->radiorev = wlc_hw->band->radiorev; | 4654 | wlc->band->radiorev = wlc_hw->band->radiorev; |
4655 | 4655 | brcms_dbg_info(core, "wl%d: phy %u/%u radio %x/%u\n", unit, | |
4656 | wlc->band->phytype, wlc->band->phyrev, | ||
4657 | wlc->band->radioid, wlc->band->radiorev); | ||
4656 | /* default contention windows size limits */ | 4658 | /* default contention windows size limits */ |
4657 | wlc_hw->band->CWmin = APHY_CWMIN; | 4659 | wlc_hw->band->CWmin = APHY_CWMIN; |
4658 | wlc_hw->band->CWmax = PHY_CWMAX; | 4660 | wlc_hw->band->CWmax = PHY_CWMAX; |
@@ -4667,7 +4669,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, | |||
4667 | brcms_c_coredisable(wlc_hw); | 4669 | brcms_c_coredisable(wlc_hw); |
4668 | 4670 | ||
4669 | /* Match driver "down" state */ | 4671 | /* Match driver "down" state */ |
4670 | ai_pci_down(wlc_hw->sih); | 4672 | bcma_core_pci_down(wlc_hw->d11core->bus); |
4671 | 4673 | ||
4672 | /* turn off pll and xtal to match driver "down" state */ | 4674 | /* turn off pll and xtal to match driver "down" state */ |
4673 | brcms_b_xtal(wlc_hw, OFF); | 4675 | brcms_b_xtal(wlc_hw, OFF); |
@@ -5010,12 +5012,12 @@ static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) | |||
5010 | */ | 5012 | */ |
5011 | if (brcms_b_radio_read_hwdisabled(wlc_hw)) { | 5013 | if (brcms_b_radio_read_hwdisabled(wlc_hw)) { |
5012 | /* put SB PCI in down state again */ | 5014 | /* put SB PCI in down state again */ |
5013 | ai_pci_down(wlc_hw->sih); | 5015 | bcma_core_pci_down(wlc_hw->d11core->bus); |
5014 | brcms_b_xtal(wlc_hw, OFF); | 5016 | brcms_b_xtal(wlc_hw, OFF); |
5015 | return -ENOMEDIUM; | 5017 | return -ENOMEDIUM; |
5016 | } | 5018 | } |
5017 | 5019 | ||
5018 | ai_pci_up(wlc_hw->sih); | 5020 | bcma_core_pci_up(wlc_hw->d11core->bus); |
5019 | 5021 | ||
5020 | /* reset the d11 core */ | 5022 | /* reset the d11 core */ |
5021 | brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); | 5023 | brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); |
@@ -5212,7 +5214,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) | |||
5212 | 5214 | ||
5213 | /* turn off primary xtal and pll */ | 5215 | /* turn off primary xtal and pll */ |
5214 | if (!wlc_hw->noreset) { | 5216 | if (!wlc_hw->noreset) { |
5215 | ai_pci_down(wlc_hw->sih); | 5217 | bcma_core_pci_down(wlc_hw->d11core->bus); |
5216 | brcms_b_xtal(wlc_hw, OFF); | 5218 | brcms_b_xtal(wlc_hw, OFF); |
5217 | } | 5219 | } |
5218 | } | 5220 | } |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c index 3d6b16ce4687..b2d6d6da3daf 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c | |||
@@ -1137,8 +1137,9 @@ wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, | |||
1137 | gain0_15 = ((biq1 & 0xf) << 12) | | 1137 | gain0_15 = ((biq1 & 0xf) << 12) | |
1138 | ((tia & 0xf) << 8) | | 1138 | ((tia & 0xf) << 8) | |
1139 | ((lna2 & 0x3) << 6) | | 1139 | ((lna2 & 0x3) << 6) | |
1140 | ((lna2 & | 1140 | ((lna2 & 0x3) << 4) | |
1141 | 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); | 1141 | ((lna1 & 0x3) << 2) | |
1142 | ((lna1 & 0x3) << 0); | ||
1142 | 1143 | ||
1143 | mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); | 1144 | mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); |
1144 | mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); | 1145 | mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); |
@@ -1328,6 +1329,43 @@ static u32 wlc_lcnphy_measure_digital_power(struct brcms_phy *pi, u16 nsamples) | |||
1328 | return (iq_est.i_pwr + iq_est.q_pwr) / nsamples; | 1329 | return (iq_est.i_pwr + iq_est.q_pwr) / nsamples; |
1329 | } | 1330 | } |
1330 | 1331 | ||
1332 | static bool wlc_lcnphy_rx_iq_cal_gain(struct brcms_phy *pi, u16 biq1_gain, | ||
1333 | u16 tia_gain, u16 lna2_gain) | ||
1334 | { | ||
1335 | u32 i_thresh_l, q_thresh_l; | ||
1336 | u32 i_thresh_h, q_thresh_h; | ||
1337 | struct lcnphy_iq_est iq_est_h, iq_est_l; | ||
1338 | |||
1339 | wlc_lcnphy_set_rx_gain_by_distribution(pi, 0, 0, 0, biq1_gain, tia_gain, | ||
1340 | lna2_gain, 0); | ||
1341 | |||
1342 | wlc_lcnphy_rx_gain_override_enable(pi, true); | ||
1343 | wlc_lcnphy_start_tx_tone(pi, 2000, (40 >> 1), 0); | ||
1344 | udelay(500); | ||
1345 | write_radio_reg(pi, RADIO_2064_REG112, 0); | ||
1346 | if (!wlc_lcnphy_rx_iq_est(pi, 1024, 32, &iq_est_l)) | ||
1347 | return false; | ||
1348 | |||
1349 | wlc_lcnphy_start_tx_tone(pi, 2000, 40, 0); | ||
1350 | udelay(500); | ||
1351 | write_radio_reg(pi, RADIO_2064_REG112, 0); | ||
1352 | if (!wlc_lcnphy_rx_iq_est(pi, 1024, 32, &iq_est_h)) | ||
1353 | return false; | ||
1354 | |||
1355 | i_thresh_l = (iq_est_l.i_pwr << 1); | ||
1356 | i_thresh_h = (iq_est_l.i_pwr << 2) + iq_est_l.i_pwr; | ||
1357 | |||
1358 | q_thresh_l = (iq_est_l.q_pwr << 1); | ||
1359 | q_thresh_h = (iq_est_l.q_pwr << 2) + iq_est_l.q_pwr; | ||
1360 | if ((iq_est_h.i_pwr > i_thresh_l) && | ||
1361 | (iq_est_h.i_pwr < i_thresh_h) && | ||
1362 | (iq_est_h.q_pwr > q_thresh_l) && | ||
1363 | (iq_est_h.q_pwr < q_thresh_h)) | ||
1364 | return true; | ||
1365 | |||
1366 | return false; | ||
1367 | } | ||
1368 | |||
1331 | static bool | 1369 | static bool |
1332 | wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, | 1370 | wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, |
1333 | const struct lcnphy_rx_iqcomp *iqcomp, | 1371 | const struct lcnphy_rx_iqcomp *iqcomp, |
@@ -1342,8 +1380,8 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, | |||
1342 | RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, | 1380 | RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, |
1343 | rfoverride3_old, rfoverride3val_old, rfoverride4_old, | 1381 | rfoverride3_old, rfoverride3val_old, rfoverride4_old, |
1344 | rfoverride4val_old, afectrlovr_old, afectrlovrval_old; | 1382 | rfoverride4val_old, afectrlovr_old, afectrlovrval_old; |
1345 | int tia_gain; | 1383 | int tia_gain, lna2_gain, biq1_gain; |
1346 | u32 received_power, rx_pwr_threshold; | 1384 | bool set_gain; |
1347 | u16 old_sslpnCalibClkEnCtrl, old_sslpnRxFeClkEnCtrl; | 1385 | u16 old_sslpnCalibClkEnCtrl, old_sslpnRxFeClkEnCtrl; |
1348 | u16 values_to_save[11]; | 1386 | u16 values_to_save[11]; |
1349 | s16 *ptr; | 1387 | s16 *ptr; |
@@ -1368,126 +1406,125 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, | |||
1368 | goto cal_done; | 1406 | goto cal_done; |
1369 | } | 1407 | } |
1370 | 1408 | ||
1371 | if (module == 1) { | 1409 | WARN_ON(module != 1); |
1410 | tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); | ||
1411 | wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); | ||
1372 | 1412 | ||
1373 | tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); | 1413 | for (i = 0; i < 11; i++) |
1374 | wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); | 1414 | values_to_save[i] = |
1415 | read_radio_reg(pi, rxiq_cal_rf_reg[i]); | ||
1416 | Core1TxControl_old = read_phy_reg(pi, 0x631); | ||
1417 | |||
1418 | or_phy_reg(pi, 0x631, 0x0015); | ||
1419 | |||
1420 | RFOverride0_old = read_phy_reg(pi, 0x44c); | ||
1421 | RFOverrideVal0_old = read_phy_reg(pi, 0x44d); | ||
1422 | rfoverride2_old = read_phy_reg(pi, 0x4b0); | ||
1423 | rfoverride2val_old = read_phy_reg(pi, 0x4b1); | ||
1424 | rfoverride3_old = read_phy_reg(pi, 0x4f9); | ||
1425 | rfoverride3val_old = read_phy_reg(pi, 0x4fa); | ||
1426 | rfoverride4_old = read_phy_reg(pi, 0x938); | ||
1427 | rfoverride4val_old = read_phy_reg(pi, 0x939); | ||
1428 | afectrlovr_old = read_phy_reg(pi, 0x43b); | ||
1429 | afectrlovrval_old = read_phy_reg(pi, 0x43c); | ||
1430 | old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); | ||
1431 | old_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); | ||
1375 | 1432 | ||
1376 | for (i = 0; i < 11; i++) | 1433 | tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); |
1377 | values_to_save[i] = | 1434 | if (tx_gain_override_old) { |
1378 | read_radio_reg(pi, rxiq_cal_rf_reg[i]); | 1435 | wlc_lcnphy_get_tx_gain(pi, &old_gains); |
1379 | Core1TxControl_old = read_phy_reg(pi, 0x631); | 1436 | tx_gain_index_old = pi_lcn->lcnphy_current_index; |
1380 | 1437 | } | |
1381 | or_phy_reg(pi, 0x631, 0x0015); | ||
1382 | |||
1383 | RFOverride0_old = read_phy_reg(pi, 0x44c); | ||
1384 | RFOverrideVal0_old = read_phy_reg(pi, 0x44d); | ||
1385 | rfoverride2_old = read_phy_reg(pi, 0x4b0); | ||
1386 | rfoverride2val_old = read_phy_reg(pi, 0x4b1); | ||
1387 | rfoverride3_old = read_phy_reg(pi, 0x4f9); | ||
1388 | rfoverride3val_old = read_phy_reg(pi, 0x4fa); | ||
1389 | rfoverride4_old = read_phy_reg(pi, 0x938); | ||
1390 | rfoverride4val_old = read_phy_reg(pi, 0x939); | ||
1391 | afectrlovr_old = read_phy_reg(pi, 0x43b); | ||
1392 | afectrlovrval_old = read_phy_reg(pi, 0x43c); | ||
1393 | old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); | ||
1394 | old_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); | ||
1395 | |||
1396 | tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); | ||
1397 | if (tx_gain_override_old) { | ||
1398 | wlc_lcnphy_get_tx_gain(pi, &old_gains); | ||
1399 | tx_gain_index_old = pi_lcn->lcnphy_current_index; | ||
1400 | } | ||
1401 | 1438 | ||
1402 | wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_idx); | 1439 | wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_idx); |
1403 | 1440 | ||
1404 | mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); | 1441 | mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); |
1405 | mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); | 1442 | mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); |
1406 | 1443 | ||
1407 | mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); | 1444 | mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); |
1408 | mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); | 1445 | mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); |
1409 | 1446 | ||
1410 | write_radio_reg(pi, RADIO_2064_REG116, 0x06); | 1447 | write_radio_reg(pi, RADIO_2064_REG116, 0x06); |
1411 | write_radio_reg(pi, RADIO_2064_REG12C, 0x07); | 1448 | write_radio_reg(pi, RADIO_2064_REG12C, 0x07); |
1412 | write_radio_reg(pi, RADIO_2064_REG06A, 0xd3); | 1449 | write_radio_reg(pi, RADIO_2064_REG06A, 0xd3); |
1413 | write_radio_reg(pi, RADIO_2064_REG098, 0x03); | 1450 | write_radio_reg(pi, RADIO_2064_REG098, 0x03); |
1414 | write_radio_reg(pi, RADIO_2064_REG00B, 0x7); | 1451 | write_radio_reg(pi, RADIO_2064_REG00B, 0x7); |
1415 | mod_radio_reg(pi, RADIO_2064_REG113, 1 << 4, 1 << 4); | 1452 | mod_radio_reg(pi, RADIO_2064_REG113, 1 << 4, 1 << 4); |
1416 | write_radio_reg(pi, RADIO_2064_REG01D, 0x01); | 1453 | write_radio_reg(pi, RADIO_2064_REG01D, 0x01); |
1417 | write_radio_reg(pi, RADIO_2064_REG114, 0x01); | 1454 | write_radio_reg(pi, RADIO_2064_REG114, 0x01); |
1418 | write_radio_reg(pi, RADIO_2064_REG02E, 0x10); | 1455 | write_radio_reg(pi, RADIO_2064_REG02E, 0x10); |
1419 | write_radio_reg(pi, RADIO_2064_REG12A, 0x08); | 1456 | write_radio_reg(pi, RADIO_2064_REG12A, 0x08); |
1420 | 1457 | ||
1421 | mod_phy_reg(pi, 0x938, (0x1 << 0), 1 << 0); | 1458 | mod_phy_reg(pi, 0x938, (0x1 << 0), 1 << 0); |
1422 | mod_phy_reg(pi, 0x939, (0x1 << 0), 0 << 0); | 1459 | mod_phy_reg(pi, 0x939, (0x1 << 0), 0 << 0); |
1423 | mod_phy_reg(pi, 0x938, (0x1 << 1), 1 << 1); | 1460 | mod_phy_reg(pi, 0x938, (0x1 << 1), 1 << 1); |
1424 | mod_phy_reg(pi, 0x939, (0x1 << 1), 1 << 1); | 1461 | mod_phy_reg(pi, 0x939, (0x1 << 1), 1 << 1); |
1425 | mod_phy_reg(pi, 0x938, (0x1 << 2), 1 << 2); | 1462 | mod_phy_reg(pi, 0x938, (0x1 << 2), 1 << 2); |
1426 | mod_phy_reg(pi, 0x939, (0x1 << 2), 1 << 2); | 1463 | mod_phy_reg(pi, 0x939, (0x1 << 2), 1 << 2); |
1427 | mod_phy_reg(pi, 0x938, (0x1 << 3), 1 << 3); | 1464 | mod_phy_reg(pi, 0x938, (0x1 << 3), 1 << 3); |
1428 | mod_phy_reg(pi, 0x939, (0x1 << 3), 1 << 3); | 1465 | mod_phy_reg(pi, 0x939, (0x1 << 3), 1 << 3); |
1429 | mod_phy_reg(pi, 0x938, (0x1 << 5), 1 << 5); | 1466 | mod_phy_reg(pi, 0x938, (0x1 << 5), 1 << 5); |
1430 | mod_phy_reg(pi, 0x939, (0x1 << 5), 0 << 5); | 1467 | mod_phy_reg(pi, 0x939, (0x1 << 5), 0 << 5); |
1431 | |||
1432 | mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); | ||
1433 | mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); | ||
1434 | |||
1435 | wlc_lcnphy_start_tx_tone(pi, 2000, 120, 0); | ||
1436 | write_phy_reg(pi, 0x6da, 0xffff); | ||
1437 | or_phy_reg(pi, 0x6db, 0x3); | ||
1438 | wlc_lcnphy_set_trsw_override(pi, tx_switch, rx_switch); | ||
1439 | wlc_lcnphy_rx_gain_override_enable(pi, true); | ||
1440 | |||
1441 | tia_gain = 8; | ||
1442 | rx_pwr_threshold = 950; | ||
1443 | while (tia_gain > 0) { | ||
1444 | tia_gain -= 1; | ||
1445 | wlc_lcnphy_set_rx_gain_by_distribution(pi, | ||
1446 | 0, 0, 2, 2, | ||
1447 | (u16) | ||
1448 | tia_gain, 1, 0); | ||
1449 | udelay(500); | ||
1450 | 1468 | ||
1451 | received_power = | 1469 | mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); |
1452 | wlc_lcnphy_measure_digital_power(pi, 2000); | 1470 | mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); |
1453 | if (received_power < rx_pwr_threshold) | ||
1454 | break; | ||
1455 | } | ||
1456 | result = wlc_lcnphy_calc_rx_iq_comp(pi, 0xffff); | ||
1457 | 1471 | ||
1458 | wlc_lcnphy_stop_tx_tone(pi); | 1472 | write_phy_reg(pi, 0x6da, 0xffff); |
1473 | or_phy_reg(pi, 0x6db, 0x3); | ||
1474 | |||
1475 | wlc_lcnphy_set_trsw_override(pi, tx_switch, rx_switch); | ||
1476 | for (lna2_gain = 3; lna2_gain >= 0; lna2_gain--) { | ||
1477 | for (tia_gain = 4; tia_gain >= 0; tia_gain--) { | ||
1478 | for (biq1_gain = 6; biq1_gain >= 0; biq1_gain--) { | ||
1479 | set_gain = wlc_lcnphy_rx_iq_cal_gain(pi, | ||
1480 | (u16) | ||
1481 | biq1_gain, | ||
1482 | (u16) | ||
1483 | tia_gain, | ||
1484 | (u16) | ||
1485 | lna2_gain); | ||
1486 | if (!set_gain) | ||
1487 | continue; | ||
1488 | |||
1489 | result = wlc_lcnphy_calc_rx_iq_comp(pi, 1024); | ||
1490 | goto stop_tone; | ||
1491 | } | ||
1492 | } | ||
1493 | } | ||
1459 | 1494 | ||
1460 | write_phy_reg(pi, 0x631, Core1TxControl_old); | 1495 | stop_tone: |
1496 | wlc_lcnphy_stop_tx_tone(pi); | ||
1461 | 1497 | ||
1462 | write_phy_reg(pi, 0x44c, RFOverrideVal0_old); | 1498 | write_phy_reg(pi, 0x631, Core1TxControl_old); |
1463 | write_phy_reg(pi, 0x44d, RFOverrideVal0_old); | 1499 | |
1464 | write_phy_reg(pi, 0x4b0, rfoverride2_old); | 1500 | write_phy_reg(pi, 0x44c, RFOverrideVal0_old); |
1465 | write_phy_reg(pi, 0x4b1, rfoverride2val_old); | 1501 | write_phy_reg(pi, 0x44d, RFOverrideVal0_old); |
1466 | write_phy_reg(pi, 0x4f9, rfoverride3_old); | 1502 | write_phy_reg(pi, 0x4b0, rfoverride2_old); |
1467 | write_phy_reg(pi, 0x4fa, rfoverride3val_old); | 1503 | write_phy_reg(pi, 0x4b1, rfoverride2val_old); |
1468 | write_phy_reg(pi, 0x938, rfoverride4_old); | 1504 | write_phy_reg(pi, 0x4f9, rfoverride3_old); |
1469 | write_phy_reg(pi, 0x939, rfoverride4val_old); | 1505 | write_phy_reg(pi, 0x4fa, rfoverride3val_old); |
1470 | write_phy_reg(pi, 0x43b, afectrlovr_old); | 1506 | write_phy_reg(pi, 0x938, rfoverride4_old); |
1471 | write_phy_reg(pi, 0x43c, afectrlovrval_old); | 1507 | write_phy_reg(pi, 0x939, rfoverride4val_old); |
1472 | write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); | 1508 | write_phy_reg(pi, 0x43b, afectrlovr_old); |
1473 | write_phy_reg(pi, 0x6db, old_sslpnRxFeClkEnCtrl); | 1509 | write_phy_reg(pi, 0x43c, afectrlovrval_old); |
1510 | write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); | ||
1511 | write_phy_reg(pi, 0x6db, old_sslpnRxFeClkEnCtrl); | ||
1474 | 1512 | ||
1475 | wlc_lcnphy_clear_trsw_override(pi); | 1513 | wlc_lcnphy_clear_trsw_override(pi); |
1476 | 1514 | ||
1477 | mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); | 1515 | mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); |
1478 | 1516 | ||
1479 | for (i = 0; i < 11; i++) | 1517 | for (i = 0; i < 11; i++) |
1480 | write_radio_reg(pi, rxiq_cal_rf_reg[i], | 1518 | write_radio_reg(pi, rxiq_cal_rf_reg[i], |
1481 | values_to_save[i]); | 1519 | values_to_save[i]); |
1482 | 1520 | ||
1483 | if (tx_gain_override_old) | 1521 | if (tx_gain_override_old) |
1484 | wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); | 1522 | wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); |
1485 | else | 1523 | else |
1486 | wlc_lcnphy_disable_tx_gain_override(pi); | 1524 | wlc_lcnphy_disable_tx_gain_override(pi); |
1487 | 1525 | ||
1488 | wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); | 1526 | wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); |
1489 | wlc_lcnphy_rx_gain_override_enable(pi, false); | 1527 | wlc_lcnphy_rx_gain_override_enable(pi, false); |
1490 | } | ||
1491 | 1528 | ||
1492 | cal_done: | 1529 | cal_done: |
1493 | kfree(ptr); | 1530 | kfree(ptr); |
@@ -1789,6 +1826,19 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) | |||
1789 | write_radio_reg(pi, RADIO_2064_REG038, 3); | 1826 | write_radio_reg(pi, RADIO_2064_REG038, 3); |
1790 | write_radio_reg(pi, RADIO_2064_REG091, 7); | 1827 | write_radio_reg(pi, RADIO_2064_REG091, 7); |
1791 | } | 1828 | } |
1829 | |||
1830 | if (!(pi->sh->boardflags & BFL_FEM)) { | ||
1831 | static const u8 reg038[14] = { | ||
1832 | 0xd, 0xe, 0xd, 0xd, 0xd, 0xc, 0xa, | ||
1833 | 0xb, 0xb, 0x3, 0x3, 0x2, 0x0, 0x0 | ||
1834 | }; | ||
1835 | |||
1836 | write_radio_reg(pi, RADIO_2064_REG02A, 0xf); | ||
1837 | write_radio_reg(pi, RADIO_2064_REG091, 0x3); | ||
1838 | write_radio_reg(pi, RADIO_2064_REG038, 0x3); | ||
1839 | |||
1840 | write_radio_reg(pi, RADIO_2064_REG038, reg038[channel - 1]); | ||
1841 | } | ||
1792 | } | 1842 | } |
1793 | 1843 | ||
1794 | static int | 1844 | static int |
@@ -1983,6 +2033,16 @@ wlc_lcnphy_set_tssi_mux(struct brcms_phy *pi, enum lcnphy_tssi_mode pos) | |||
1983 | } else { | 2033 | } else { |
1984 | mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0x1); | 2034 | mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0x1); |
1985 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 0x8); | 2035 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 0x8); |
2036 | mod_radio_reg(pi, RADIO_2064_REG028, 0x1, 0x0); | ||
2037 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x4, 1<<2); | ||
2038 | mod_radio_reg(pi, RADIO_2064_REG036, 0x10, 0x0); | ||
2039 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x10, 1<<4); | ||
2040 | mod_radio_reg(pi, RADIO_2064_REG036, 0x3, 0x0); | ||
2041 | mod_radio_reg(pi, RADIO_2064_REG035, 0xff, 0x77); | ||
2042 | mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0xe<<1); | ||
2043 | mod_radio_reg(pi, RADIO_2064_REG112, 0x80, 1<<7); | ||
2044 | mod_radio_reg(pi, RADIO_2064_REG005, 0x7, 1<<1); | ||
2045 | mod_radio_reg(pi, RADIO_2064_REG029, 0xf0, 0<<4); | ||
1986 | } | 2046 | } |
1987 | } else { | 2047 | } else { |
1988 | mod_phy_reg(pi, 0x4d9, (0x1 << 2), (0x1) << 2); | 2048 | mod_phy_reg(pi, 0x4d9, (0x1 << 2), (0x1) << 2); |
@@ -2069,13 +2129,23 @@ static void wlc_lcnphy_pwrctrl_rssiparams(struct brcms_phy *pi) | |||
2069 | (auxpga_vmid_temp << 0) | (auxpga_gain_temp << 12)); | 2129 | (auxpga_vmid_temp << 0) | (auxpga_gain_temp << 12)); |
2070 | 2130 | ||
2071 | mod_radio_reg(pi, RADIO_2064_REG082, (1 << 5), (1 << 5)); | 2131 | mod_radio_reg(pi, RADIO_2064_REG082, (1 << 5), (1 << 5)); |
2132 | mod_radio_reg(pi, RADIO_2064_REG07C, (1 << 0), (1 << 0)); | ||
2072 | } | 2133 | } |
2073 | 2134 | ||
2074 | static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) | 2135 | static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) |
2075 | { | 2136 | { |
2076 | struct phytbl_info tab; | 2137 | struct phytbl_info tab; |
2077 | u32 rfseq, ind; | 2138 | u32 rfseq, ind; |
2139 | enum lcnphy_tssi_mode mode; | ||
2140 | u8 tssi_sel; | ||
2078 | 2141 | ||
2142 | if (pi->sh->boardflags & BFL_FEM) { | ||
2143 | tssi_sel = 0x1; | ||
2144 | mode = LCNPHY_TSSI_EXT; | ||
2145 | } else { | ||
2146 | tssi_sel = 0xe; | ||
2147 | mode = LCNPHY_TSSI_POST_PA; | ||
2148 | } | ||
2079 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; | 2149 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; |
2080 | tab.tbl_width = 32; | 2150 | tab.tbl_width = 32; |
2081 | tab.tbl_ptr = &ind; | 2151 | tab.tbl_ptr = &ind; |
@@ -2096,7 +2166,7 @@ static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) | |||
2096 | 2166 | ||
2097 | mod_phy_reg(pi, 0x503, (0x1 << 4), (1) << 4); | 2167 | mod_phy_reg(pi, 0x503, (0x1 << 4), (1) << 4); |
2098 | 2168 | ||
2099 | wlc_lcnphy_set_tssi_mux(pi, LCNPHY_TSSI_EXT); | 2169 | wlc_lcnphy_set_tssi_mux(pi, mode); |
2100 | mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0) << 14); | 2170 | mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0) << 14); |
2101 | 2171 | ||
2102 | mod_phy_reg(pi, 0x4a4, (0x1 << 15), (1) << 15); | 2172 | mod_phy_reg(pi, 0x4a4, (0x1 << 15), (1) << 15); |
@@ -2132,9 +2202,10 @@ static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) | |||
2132 | mod_phy_reg(pi, 0x49a, (0x1ff << 0), (0xff) << 0); | 2202 | mod_phy_reg(pi, 0x49a, (0x1ff << 0), (0xff) << 0); |
2133 | 2203 | ||
2134 | if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { | 2204 | if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { |
2135 | mod_radio_reg(pi, RADIO_2064_REG028, 0xf, 0xe); | 2205 | mod_radio_reg(pi, RADIO_2064_REG028, 0xf, tssi_sel); |
2136 | mod_radio_reg(pi, RADIO_2064_REG086, 0x4, 0x4); | 2206 | mod_radio_reg(pi, RADIO_2064_REG086, 0x4, 0x4); |
2137 | } else { | 2207 | } else { |
2208 | mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, tssi_sel << 1); | ||
2138 | mod_radio_reg(pi, RADIO_2064_REG03A, 0x1, 1); | 2209 | mod_radio_reg(pi, RADIO_2064_REG03A, 0x1, 1); |
2139 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 1 << 3); | 2210 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 1 << 3); |
2140 | } | 2211 | } |
@@ -2181,6 +2252,10 @@ static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) | |||
2181 | 2252 | ||
2182 | mod_phy_reg(pi, 0x4d7, (0xf << 8), (0) << 8); | 2253 | mod_phy_reg(pi, 0x4d7, (0xf << 8), (0) << 8); |
2183 | 2254 | ||
2255 | mod_radio_reg(pi, RADIO_2064_REG035, 0xff, 0x0); | ||
2256 | mod_radio_reg(pi, RADIO_2064_REG036, 0x3, 0x0); | ||
2257 | mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 0x8); | ||
2258 | |||
2184 | wlc_lcnphy_pwrctrl_rssiparams(pi); | 2259 | wlc_lcnphy_pwrctrl_rssiparams(pi); |
2185 | } | 2260 | } |
2186 | 2261 | ||
@@ -2799,6 +2874,8 @@ static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) | |||
2799 | read_radio_reg(pi, RADIO_2064_REG007) & 1; | 2874 | read_radio_reg(pi, RADIO_2064_REG007) & 1; |
2800 | u16 SAVE_jtag_auxpga = read_radio_reg(pi, RADIO_2064_REG0FF) & 0x10; | 2875 | u16 SAVE_jtag_auxpga = read_radio_reg(pi, RADIO_2064_REG0FF) & 0x10; |
2801 | u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; | 2876 | u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; |
2877 | u8 SAVE_bbmult = wlc_lcnphy_get_bbmult(pi); | ||
2878 | |||
2802 | idleTssi = read_phy_reg(pi, 0x4ab); | 2879 | idleTssi = read_phy_reg(pi, 0x4ab); |
2803 | suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & | 2880 | suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & |
2804 | MCTL_EN_MAC)); | 2881 | MCTL_EN_MAC)); |
@@ -2816,6 +2893,12 @@ static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) | |||
2816 | mod_radio_reg(pi, RADIO_2064_REG0FF, 0x10, 1 << 4); | 2893 | mod_radio_reg(pi, RADIO_2064_REG0FF, 0x10, 1 << 4); |
2817 | mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 1 << 2); | 2894 | mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 1 << 2); |
2818 | wlc_lcnphy_tssi_setup(pi); | 2895 | wlc_lcnphy_tssi_setup(pi); |
2896 | |||
2897 | mod_phy_reg(pi, 0x4d7, (0x1 << 0), (1 << 0)); | ||
2898 | mod_phy_reg(pi, 0x4d7, (0x1 << 6), (1 << 6)); | ||
2899 | |||
2900 | wlc_lcnphy_set_bbmult(pi, 0x0); | ||
2901 | |||
2819 | wlc_phy_do_dummy_tx(pi, true, OFF); | 2902 | wlc_phy_do_dummy_tx(pi, true, OFF); |
2820 | idleTssi = ((read_phy_reg(pi, 0x4ab) & (0x1ff << 0)) | 2903 | idleTssi = ((read_phy_reg(pi, 0x4ab) & (0x1ff << 0)) |
2821 | >> 0); | 2904 | >> 0); |
@@ -2837,6 +2920,7 @@ static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) | |||
2837 | 2920 | ||
2838 | mod_phy_reg(pi, 0x44c, (0x1 << 12), (0) << 12); | 2921 | mod_phy_reg(pi, 0x44c, (0x1 << 12), (0) << 12); |
2839 | 2922 | ||
2923 | wlc_lcnphy_set_bbmult(pi, SAVE_bbmult); | ||
2840 | wlc_lcnphy_set_tx_gain_override(pi, tx_gain_override_old); | 2924 | wlc_lcnphy_set_tx_gain_override(pi, tx_gain_override_old); |
2841 | wlc_lcnphy_set_tx_gain(pi, &old_gains); | 2925 | wlc_lcnphy_set_tx_gain(pi, &old_gains); |
2842 | wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_txpwrctrl); | 2926 | wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_txpwrctrl); |
@@ -3050,6 +3134,11 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi) | |||
3050 | wlc_lcnphy_write_table(pi, &tab); | 3134 | wlc_lcnphy_write_table(pi, &tab); |
3051 | tab.tbl_offset++; | 3135 | tab.tbl_offset++; |
3052 | } | 3136 | } |
3137 | mod_phy_reg(pi, 0x4d0, (0x1 << 0), (0) << 0); | ||
3138 | mod_phy_reg(pi, 0x4d3, (0xff << 0), (0) << 0); | ||
3139 | mod_phy_reg(pi, 0x4d3, (0xff << 8), (0) << 8); | ||
3140 | mod_phy_reg(pi, 0x4d0, (0x1 << 4), (0) << 4); | ||
3141 | mod_phy_reg(pi, 0x4d0, (0x1 << 2), (0) << 2); | ||
3053 | 3142 | ||
3054 | mod_phy_reg(pi, 0x410, (0x1 << 7), (0) << 7); | 3143 | mod_phy_reg(pi, 0x410, (0x1 << 7), (0) << 7); |
3055 | 3144 | ||
@@ -3851,7 +3940,6 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) | |||
3851 | target_gains.pad_gain = 21; | 3940 | target_gains.pad_gain = 21; |
3852 | target_gains.dac_gain = 0; | 3941 | target_gains.dac_gain = 0; |
3853 | wlc_lcnphy_set_tx_gain(pi, &target_gains); | 3942 | wlc_lcnphy_set_tx_gain(pi, &target_gains); |
3854 | wlc_lcnphy_set_tx_pwr_by_index(pi, 16); | ||
3855 | 3943 | ||
3856 | if (LCNREV_IS(pi->pubpi.phy_rev, 1) || pi_lcn->lcnphy_hw_iqcal_en) { | 3944 | if (LCNREV_IS(pi->pubpi.phy_rev, 1) || pi_lcn->lcnphy_hw_iqcal_en) { |
3857 | 3945 | ||
@@ -3862,6 +3950,7 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) | |||
3862 | lcnphy_recal ? LCNPHY_CAL_RECAL : | 3950 | lcnphy_recal ? LCNPHY_CAL_RECAL : |
3863 | LCNPHY_CAL_FULL), false); | 3951 | LCNPHY_CAL_FULL), false); |
3864 | } else { | 3952 | } else { |
3953 | wlc_lcnphy_set_tx_pwr_by_index(pi, 16); | ||
3865 | wlc_lcnphy_tx_iqlo_soft_cal_full(pi); | 3954 | wlc_lcnphy_tx_iqlo_soft_cal_full(pi); |
3866 | } | 3955 | } |
3867 | 3956 | ||
@@ -4283,20 +4372,20 @@ wlc_lcnphy_load_tx_gain_table(struct brcms_phy *pi, | |||
4283 | u16 pa_gain; | 4372 | u16 pa_gain; |
4284 | u16 gm_gain; | 4373 | u16 gm_gain; |
4285 | 4374 | ||
4286 | if (CHSPEC_IS5G(pi->radio_chanspec)) | ||
4287 | pa_gain = 0x70; | ||
4288 | else | ||
4289 | pa_gain = 0x70; | ||
4290 | |||
4291 | if (pi->sh->boardflags & BFL_FEM) | 4375 | if (pi->sh->boardflags & BFL_FEM) |
4292 | pa_gain = 0x10; | 4376 | pa_gain = 0x10; |
4377 | else | ||
4378 | pa_gain = 0x60; | ||
4293 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; | 4379 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; |
4294 | tab.tbl_width = 32; | 4380 | tab.tbl_width = 32; |
4295 | tab.tbl_len = 1; | 4381 | tab.tbl_len = 1; |
4296 | tab.tbl_ptr = &val; | 4382 | tab.tbl_ptr = &val; |
4297 | 4383 | ||
4384 | /* fixed gm_gain value for iPA */ | ||
4385 | gm_gain = 15; | ||
4298 | for (j = 0; j < 128; j++) { | 4386 | for (j = 0; j < 128; j++) { |
4299 | gm_gain = gain_table[j].gm; | 4387 | if (pi->sh->boardflags & BFL_FEM) |
4388 | gm_gain = gain_table[j].gm; | ||
4300 | val = (((u32) pa_gain << 24) | | 4389 | val = (((u32) pa_gain << 24) | |
4301 | (gain_table[j].pad << 16) | | 4390 | (gain_table[j].pad << 16) | |
4302 | (gain_table[j].pga << 8) | gm_gain); | 4391 | (gain_table[j].pga << 8) | gm_gain); |
@@ -4507,7 +4596,10 @@ static void wlc_radio_2064_init(struct brcms_phy *pi) | |||
4507 | 4596 | ||
4508 | write_phy_reg(pi, 0x4ea, 0x4688); | 4597 | write_phy_reg(pi, 0x4ea, 0x4688); |
4509 | 4598 | ||
4510 | mod_phy_reg(pi, 0x4eb, (0x7 << 0), 2 << 0); | 4599 | if (pi->sh->boardflags & BFL_FEM) |
4600 | mod_phy_reg(pi, 0x4eb, (0x7 << 0), 2 << 0); | ||
4601 | else | ||
4602 | mod_phy_reg(pi, 0x4eb, (0x7 << 0), 3 << 0); | ||
4511 | 4603 | ||
4512 | mod_phy_reg(pi, 0x4eb, (0x7 << 6), 0 << 6); | 4604 | mod_phy_reg(pi, 0x4eb, (0x7 << 6), 0 << 6); |
4513 | 4605 | ||
@@ -4518,6 +4610,13 @@ static void wlc_radio_2064_init(struct brcms_phy *pi) | |||
4518 | wlc_lcnphy_rcal(pi); | 4610 | wlc_lcnphy_rcal(pi); |
4519 | 4611 | ||
4520 | wlc_lcnphy_rc_cal(pi); | 4612 | wlc_lcnphy_rc_cal(pi); |
4613 | |||
4614 | if (!(pi->sh->boardflags & BFL_FEM)) { | ||
4615 | write_radio_reg(pi, RADIO_2064_REG032, 0x6f); | ||
4616 | write_radio_reg(pi, RADIO_2064_REG033, 0x19); | ||
4617 | write_radio_reg(pi, RADIO_2064_REG039, 0xe); | ||
4618 | } | ||
4619 | |||
4521 | } | 4620 | } |
4522 | 4621 | ||
4523 | static void wlc_lcnphy_radio_init(struct brcms_phy *pi) | 4622 | static void wlc_lcnphy_radio_init(struct brcms_phy *pi) |
@@ -4530,6 +4629,7 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) | |||
4530 | uint idx; | 4629 | uint idx; |
4531 | u8 phybw40; | 4630 | u8 phybw40; |
4532 | struct phytbl_info tab; | 4631 | struct phytbl_info tab; |
4632 | const struct phytbl_info *tb; | ||
4533 | u32 val; | 4633 | u32 val; |
4534 | 4634 | ||
4535 | phybw40 = CHSPEC_IS40(pi->radio_chanspec); | 4635 | phybw40 = CHSPEC_IS40(pi->radio_chanspec); |
@@ -4547,22 +4647,20 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) | |||
4547 | wlc_lcnphy_write_table(pi, &tab); | 4647 | wlc_lcnphy_write_table(pi, &tab); |
4548 | } | 4648 | } |
4549 | 4649 | ||
4550 | tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; | 4650 | if (!(pi->sh->boardflags & BFL_FEM)) { |
4551 | tab.tbl_width = 16; | 4651 | tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; |
4552 | tab.tbl_ptr = &val; | 4652 | tab.tbl_width = 16; |
4553 | tab.tbl_len = 1; | 4653 | tab.tbl_ptr = &val; |
4554 | 4654 | tab.tbl_len = 1; | |
4555 | val = 114; | ||
4556 | tab.tbl_offset = 0; | ||
4557 | wlc_lcnphy_write_table(pi, &tab); | ||
4558 | 4655 | ||
4559 | val = 130; | 4656 | val = 150; |
4560 | tab.tbl_offset = 1; | 4657 | tab.tbl_offset = 0; |
4561 | wlc_lcnphy_write_table(pi, &tab); | 4658 | wlc_lcnphy_write_table(pi, &tab); |
4562 | 4659 | ||
4563 | val = 6; | 4660 | val = 220; |
4564 | tab.tbl_offset = 8; | 4661 | tab.tbl_offset = 1; |
4565 | wlc_lcnphy_write_table(pi, &tab); | 4662 | wlc_lcnphy_write_table(pi, &tab); |
4663 | } | ||
4566 | 4664 | ||
4567 | if (CHSPEC_IS2G(pi->radio_chanspec)) { | 4665 | if (CHSPEC_IS2G(pi->radio_chanspec)) { |
4568 | if (pi->sh->boardflags & BFL_FEM) | 4666 | if (pi->sh->boardflags & BFL_FEM) |
@@ -4576,7 +4674,6 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) | |||
4576 | } | 4674 | } |
4577 | 4675 | ||
4578 | if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { | 4676 | if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { |
4579 | const struct phytbl_info *tb; | ||
4580 | int l; | 4677 | int l; |
4581 | 4678 | ||
4582 | if (CHSPEC_IS2G(pi->radio_chanspec)) { | 4679 | if (CHSPEC_IS2G(pi->radio_chanspec)) { |
@@ -4597,21 +4694,22 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) | |||
4597 | wlc_lcnphy_write_table(pi, &tb[idx]); | 4694 | wlc_lcnphy_write_table(pi, &tb[idx]); |
4598 | } | 4695 | } |
4599 | 4696 | ||
4600 | if ((pi->sh->boardflags & BFL_FEM) | 4697 | if (pi->sh->boardflags & BFL_FEM) { |
4601 | && !(pi->sh->boardflags & BFL_FEM_BT)) | 4698 | if (pi->sh->boardflags & BFL_FEM_BT) { |
4602 | wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313_epa); | 4699 | if (pi->sh->boardrev < 0x1250) |
4603 | else if (pi->sh->boardflags & BFL_FEM_BT) { | 4700 | tb = &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa; |
4604 | if (pi->sh->boardrev < 0x1250) | 4701 | else |
4605 | wlc_lcnphy_write_table( | 4702 | tb = &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250; |
4606 | pi, | 4703 | } else { |
4607 | &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa); | 4704 | tb = &dot11lcn_sw_ctrl_tbl_info_4313_epa; |
4705 | } | ||
4706 | } else { | ||
4707 | if (pi->sh->boardflags & BFL_FEM_BT) | ||
4708 | tb = &dot11lcn_sw_ctrl_tbl_info_4313_bt_ipa; | ||
4608 | else | 4709 | else |
4609 | wlc_lcnphy_write_table( | 4710 | tb = &dot11lcn_sw_ctrl_tbl_info_4313; |
4610 | pi, | 4711 | } |
4611 | &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250); | 4712 | wlc_lcnphy_write_table(pi, tb); |
4612 | } else | ||
4613 | wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313); | ||
4614 | |||
4615 | wlc_lcnphy_load_rfpower(pi); | 4713 | wlc_lcnphy_load_rfpower(pi); |
4616 | 4714 | ||
4617 | wlc_lcnphy_clear_papd_comptable(pi); | 4715 | wlc_lcnphy_clear_papd_comptable(pi); |
@@ -4955,6 +5053,8 @@ void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) | |||
4955 | wlc_lcnphy_load_tx_iir_filter(pi, true, 3); | 5053 | wlc_lcnphy_load_tx_iir_filter(pi, true, 3); |
4956 | 5054 | ||
4957 | mod_phy_reg(pi, 0x4eb, (0x7 << 3), (1) << 3); | 5055 | mod_phy_reg(pi, 0x4eb, (0x7 << 3), (1) << 3); |
5056 | if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) | ||
5057 | wlc_lcnphy_tssi_setup(pi); | ||
4958 | } | 5058 | } |
4959 | 5059 | ||
4960 | void wlc_phy_detach_lcnphy(struct brcms_phy *pi) | 5060 | void wlc_phy_detach_lcnphy(struct brcms_phy *pi) |
@@ -4993,8 +5093,7 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) | |||
4993 | if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) | 5093 | if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) |
4994 | return false; | 5094 | return false; |
4995 | 5095 | ||
4996 | if ((pi->sh->boardflags & BFL_FEM) && | 5096 | if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { |
4997 | (LCNREV_IS(pi->pubpi.phy_rev, 1))) { | ||
4998 | if (pi_lcn->lcnphy_tempsense_option == 3) { | 5097 | if (pi_lcn->lcnphy_tempsense_option == 3) { |
4999 | pi->hwpwrctrl = true; | 5098 | pi->hwpwrctrl = true; |
5000 | pi->hwpwrctrl_capable = true; | 5099 | pi->hwpwrctrl_capable = true; |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.c index 622c01ca72c5..d7fa312214f3 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.c | |||
@@ -1507,117 +1507,103 @@ static const u32 dot11lcn_gain_tbl_5G[] = { | |||
1507 | 1507 | ||
1508 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[] = { | 1508 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[] = { |
1509 | {&dot11lcn_gain_tbl_rev0, | 1509 | {&dot11lcn_gain_tbl_rev0, |
1510 | sizeof(dot11lcn_gain_tbl_rev0) / sizeof(dot11lcn_gain_tbl_rev0[0]), 18, | 1510 | ARRAY_SIZE(dot11lcn_gain_tbl_rev0), 18, |
1511 | 0, 32} | 1511 | 0, 32} |
1512 | , | 1512 | , |
1513 | {&dot11lcn_aux_gain_idx_tbl_rev0, | 1513 | {&dot11lcn_aux_gain_idx_tbl_rev0, |
1514 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / | 1514 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_rev0), 14, 0, 16} |
1515 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} | ||
1516 | , | 1515 | , |
1517 | {&dot11lcn_gain_idx_tbl_rev0, | 1516 | {&dot11lcn_gain_idx_tbl_rev0, |
1518 | sizeof(dot11lcn_gain_idx_tbl_rev0) / | 1517 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_rev0), 13, 0, 32} |
1519 | sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} | ||
1520 | , | 1518 | , |
1521 | }; | 1519 | }; |
1522 | 1520 | ||
1523 | static const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev1[] = { | 1521 | static const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev1[] = { |
1524 | {&dot11lcn_gain_tbl_rev1, | 1522 | {&dot11lcn_gain_tbl_rev1, |
1525 | sizeof(dot11lcn_gain_tbl_rev1) / sizeof(dot11lcn_gain_tbl_rev1[0]), 18, | 1523 | ARRAY_SIZE(dot11lcn_gain_tbl_rev1), 18, |
1526 | 0, 32} | 1524 | 0, 32} |
1527 | , | 1525 | , |
1528 | {&dot11lcn_aux_gain_idx_tbl_rev0, | 1526 | {&dot11lcn_aux_gain_idx_tbl_rev0, |
1529 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / | 1527 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_rev0), 14, 0, 16} |
1530 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} | ||
1531 | , | 1528 | , |
1532 | {&dot11lcn_gain_idx_tbl_rev0, | 1529 | {&dot11lcn_gain_idx_tbl_rev0, |
1533 | sizeof(dot11lcn_gain_idx_tbl_rev0) / | 1530 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_rev0), 13, 0, 32} |
1534 | sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} | ||
1535 | , | 1531 | , |
1536 | }; | 1532 | }; |
1537 | 1533 | ||
1538 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_2G_rev2[] = { | 1534 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_2G_rev2[] = { |
1539 | {&dot11lcn_gain_tbl_2G, | 1535 | {&dot11lcn_gain_tbl_2G, |
1540 | sizeof(dot11lcn_gain_tbl_2G) / sizeof(dot11lcn_gain_tbl_2G[0]), 18, 0, | 1536 | ARRAY_SIZE(dot11lcn_gain_tbl_2G), 18, 0, |
1541 | 32} | 1537 | 32} |
1542 | , | 1538 | , |
1543 | {&dot11lcn_aux_gain_idx_tbl_2G, | 1539 | {&dot11lcn_aux_gain_idx_tbl_2G, |
1544 | sizeof(dot11lcn_aux_gain_idx_tbl_2G) / | 1540 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_2G), 14, 0, 16} |
1545 | sizeof(dot11lcn_aux_gain_idx_tbl_2G[0]), 14, 0, 16} | ||
1546 | , | 1541 | , |
1547 | {&dot11lcn_gain_idx_tbl_2G, | 1542 | {&dot11lcn_gain_idx_tbl_2G, |
1548 | sizeof(dot11lcn_gain_idx_tbl_2G) / sizeof(dot11lcn_gain_idx_tbl_2G[0]), | 1543 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_2G), |
1549 | 13, 0, 32} | 1544 | 13, 0, 32} |
1550 | , | 1545 | , |
1551 | {&dot11lcn_gain_val_tbl_2G, | 1546 | {&dot11lcn_gain_val_tbl_2G, |
1552 | sizeof(dot11lcn_gain_val_tbl_2G) / sizeof(dot11lcn_gain_val_tbl_2G[0]), | 1547 | ARRAY_SIZE(dot11lcn_gain_val_tbl_2G), |
1553 | 17, 0, 8} | 1548 | 17, 0, 8} |
1554 | }; | 1549 | }; |
1555 | 1550 | ||
1556 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_5G_rev2[] = { | 1551 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_5G_rev2[] = { |
1557 | {&dot11lcn_gain_tbl_5G, | 1552 | {&dot11lcn_gain_tbl_5G, |
1558 | sizeof(dot11lcn_gain_tbl_5G) / sizeof(dot11lcn_gain_tbl_5G[0]), 18, 0, | 1553 | ARRAY_SIZE(dot11lcn_gain_tbl_5G), 18, 0, |
1559 | 32} | 1554 | 32} |
1560 | , | 1555 | , |
1561 | {&dot11lcn_aux_gain_idx_tbl_5G, | 1556 | {&dot11lcn_aux_gain_idx_tbl_5G, |
1562 | sizeof(dot11lcn_aux_gain_idx_tbl_5G) / | 1557 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_5G), 14, 0, 16} |
1563 | sizeof(dot11lcn_aux_gain_idx_tbl_5G[0]), 14, 0, 16} | ||
1564 | , | 1558 | , |
1565 | {&dot11lcn_gain_idx_tbl_5G, | 1559 | {&dot11lcn_gain_idx_tbl_5G, |
1566 | sizeof(dot11lcn_gain_idx_tbl_5G) / sizeof(dot11lcn_gain_idx_tbl_5G[0]), | 1560 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_5G), |
1567 | 13, 0, 32} | 1561 | 13, 0, 32} |
1568 | , | 1562 | , |
1569 | {&dot11lcn_gain_val_tbl_5G, | 1563 | {&dot11lcn_gain_val_tbl_5G, |
1570 | sizeof(dot11lcn_gain_val_tbl_5G) / sizeof(dot11lcn_gain_val_tbl_5G[0]), | 1564 | ARRAY_SIZE(dot11lcn_gain_val_tbl_5G), |
1571 | 17, 0, 8} | 1565 | 17, 0, 8} |
1572 | }; | 1566 | }; |
1573 | 1567 | ||
1574 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_2G_rev2[] = { | 1568 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_2G_rev2[] = { |
1575 | {&dot11lcn_gain_tbl_extlna_2G, | 1569 | {&dot11lcn_gain_tbl_extlna_2G, |
1576 | sizeof(dot11lcn_gain_tbl_extlna_2G) / | 1570 | ARRAY_SIZE(dot11lcn_gain_tbl_extlna_2G), 18, 0, 32} |
1577 | sizeof(dot11lcn_gain_tbl_extlna_2G[0]), 18, 0, 32} | ||
1578 | , | 1571 | , |
1579 | {&dot11lcn_aux_gain_idx_tbl_extlna_2G, | 1572 | {&dot11lcn_aux_gain_idx_tbl_extlna_2G, |
1580 | sizeof(dot11lcn_aux_gain_idx_tbl_extlna_2G) / | 1573 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_extlna_2G), 14, 0, 16} |
1581 | sizeof(dot11lcn_aux_gain_idx_tbl_extlna_2G[0]), 14, 0, 16} | ||
1582 | , | 1574 | , |
1583 | {&dot11lcn_gain_idx_tbl_extlna_2G, | 1575 | {&dot11lcn_gain_idx_tbl_extlna_2G, |
1584 | sizeof(dot11lcn_gain_idx_tbl_extlna_2G) / | 1576 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_extlna_2G), 13, 0, 32} |
1585 | sizeof(dot11lcn_gain_idx_tbl_extlna_2G[0]), 13, 0, 32} | ||
1586 | , | 1577 | , |
1587 | {&dot11lcn_gain_val_tbl_extlna_2G, | 1578 | {&dot11lcn_gain_val_tbl_extlna_2G, |
1588 | sizeof(dot11lcn_gain_val_tbl_extlna_2G) / | 1579 | ARRAY_SIZE(dot11lcn_gain_val_tbl_extlna_2G), 17, 0, 8} |
1589 | sizeof(dot11lcn_gain_val_tbl_extlna_2G[0]), 17, 0, 8} | ||
1590 | }; | 1580 | }; |
1591 | 1581 | ||
1592 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_5G_rev2[] = { | 1582 | const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_5G_rev2[] = { |
1593 | {&dot11lcn_gain_tbl_5G, | 1583 | {&dot11lcn_gain_tbl_5G, |
1594 | sizeof(dot11lcn_gain_tbl_5G) / sizeof(dot11lcn_gain_tbl_5G[0]), 18, 0, | 1584 | ARRAY_SIZE(dot11lcn_gain_tbl_5G), 18, 0, |
1595 | 32} | 1585 | 32} |
1596 | , | 1586 | , |
1597 | {&dot11lcn_aux_gain_idx_tbl_5G, | 1587 | {&dot11lcn_aux_gain_idx_tbl_5G, |
1598 | sizeof(dot11lcn_aux_gain_idx_tbl_5G) / | 1588 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_5G), 14, 0, 16} |
1599 | sizeof(dot11lcn_aux_gain_idx_tbl_5G[0]), 14, 0, 16} | ||
1600 | , | 1589 | , |
1601 | {&dot11lcn_gain_idx_tbl_5G, | 1590 | {&dot11lcn_gain_idx_tbl_5G, |
1602 | sizeof(dot11lcn_gain_idx_tbl_5G) / sizeof(dot11lcn_gain_idx_tbl_5G[0]), | 1591 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_5G), |
1603 | 13, 0, 32} | 1592 | 13, 0, 32} |
1604 | , | 1593 | , |
1605 | {&dot11lcn_gain_val_tbl_5G, | 1594 | {&dot11lcn_gain_val_tbl_5G, |
1606 | sizeof(dot11lcn_gain_val_tbl_5G) / sizeof(dot11lcn_gain_val_tbl_5G[0]), | 1595 | ARRAY_SIZE(dot11lcn_gain_val_tbl_5G), |
1607 | 17, 0, 8} | 1596 | 17, 0, 8} |
1608 | }; | 1597 | }; |
1609 | 1598 | ||
1610 | const u32 dot11lcnphytbl_rx_gain_info_sz_rev0 = | 1599 | const u32 dot11lcnphytbl_rx_gain_info_sz_rev0 = |
1611 | sizeof(dot11lcnphytbl_rx_gain_info_rev0) / | 1600 | ARRAY_SIZE(dot11lcnphytbl_rx_gain_info_rev0); |
1612 | sizeof(dot11lcnphytbl_rx_gain_info_rev0[0]); | ||
1613 | 1601 | ||
1614 | const u32 dot11lcnphytbl_rx_gain_info_2G_rev2_sz = | 1602 | const u32 dot11lcnphytbl_rx_gain_info_2G_rev2_sz = |
1615 | sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2) / | 1603 | ARRAY_SIZE(dot11lcnphytbl_rx_gain_info_2G_rev2); |
1616 | sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2[0]); | ||
1617 | 1604 | ||
1618 | const u32 dot11lcnphytbl_rx_gain_info_5G_rev2_sz = | 1605 | const u32 dot11lcnphytbl_rx_gain_info_5G_rev2_sz = |
1619 | sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2) / | 1606 | ARRAY_SIZE(dot11lcnphytbl_rx_gain_info_5G_rev2); |
1620 | sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2[0]); | ||
1621 | 1607 | ||
1622 | static const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { | 1608 | static const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { |
1623 | 0x014d, | 1609 | 0x014d, |
@@ -2058,6 +2044,73 @@ static const u16 dot11lcn_sw_ctrl_tbl_4313_rev0[] = { | |||
2058 | 0x0005, | 2044 | 0x0005, |
2059 | }; | 2045 | }; |
2060 | 2046 | ||
2047 | static const u16 dot11lcn_sw_ctrl_tbl_4313_ipa_rev0_combo[] = { | ||
2048 | 0x0005, | ||
2049 | 0x0006, | ||
2050 | 0x0009, | ||
2051 | 0x000a, | ||
2052 | 0x0005, | ||
2053 | 0x0006, | ||
2054 | 0x0009, | ||
2055 | 0x000a, | ||
2056 | 0x0005, | ||
2057 | 0x0006, | ||
2058 | 0x0009, | ||
2059 | 0x000a, | ||
2060 | 0x0005, | ||
2061 | 0x0006, | ||
2062 | 0x0009, | ||
2063 | 0x000a, | ||
2064 | 0x0005, | ||
2065 | 0x0006, | ||
2066 | 0x0009, | ||
2067 | 0x000a, | ||
2068 | 0x0005, | ||
2069 | 0x0006, | ||
2070 | 0x0009, | ||
2071 | 0x000a, | ||
2072 | 0x0005, | ||
2073 | 0x0006, | ||
2074 | 0x0009, | ||
2075 | 0x000a, | ||
2076 | 0x0005, | ||
2077 | 0x0006, | ||
2078 | 0x0009, | ||
2079 | 0x000a, | ||
2080 | 0x0005, | ||
2081 | 0x0006, | ||
2082 | 0x0009, | ||
2083 | 0x000a, | ||
2084 | 0x0005, | ||
2085 | 0x0006, | ||
2086 | 0x0009, | ||
2087 | 0x000a, | ||
2088 | 0x0005, | ||
2089 | 0x0006, | ||
2090 | 0x0009, | ||
2091 | 0x000a, | ||
2092 | 0x0005, | ||
2093 | 0x0006, | ||
2094 | 0x0009, | ||
2095 | 0x000a, | ||
2096 | 0x0005, | ||
2097 | 0x0006, | ||
2098 | 0x0009, | ||
2099 | 0x000a, | ||
2100 | 0x0005, | ||
2101 | 0x0006, | ||
2102 | 0x0009, | ||
2103 | 0x000a, | ||
2104 | 0x0005, | ||
2105 | 0x0006, | ||
2106 | 0x0009, | ||
2107 | 0x000a, | ||
2108 | 0x0005, | ||
2109 | 0x0006, | ||
2110 | 0x0009, | ||
2111 | 0x000a, | ||
2112 | }; | ||
2113 | |||
2061 | static const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { | 2114 | static const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { |
2062 | 0x0004, | 2115 | 0x0004, |
2063 | 0x0004, | 2116 | 0x0004, |
@@ -2771,89 +2824,79 @@ static const u32 dot11lcn_papd_compdelta_tbl_rev0[] = { | |||
2771 | 2824 | ||
2772 | const struct phytbl_info dot11lcnphytbl_info_rev0[] = { | 2825 | const struct phytbl_info dot11lcnphytbl_info_rev0[] = { |
2773 | {&dot11lcn_min_sig_sq_tbl_rev0, | 2826 | {&dot11lcn_min_sig_sq_tbl_rev0, |
2774 | sizeof(dot11lcn_min_sig_sq_tbl_rev0) / | 2827 | ARRAY_SIZE(dot11lcn_min_sig_sq_tbl_rev0), 2, 0, 16} |
2775 | sizeof(dot11lcn_min_sig_sq_tbl_rev0[0]), 2, 0, 16} | ||
2776 | , | 2828 | , |
2777 | {&dot11lcn_noise_scale_tbl_rev0, | 2829 | {&dot11lcn_noise_scale_tbl_rev0, |
2778 | sizeof(dot11lcn_noise_scale_tbl_rev0) / | 2830 | ARRAY_SIZE(dot11lcn_noise_scale_tbl_rev0), 1, 0, 16} |
2779 | sizeof(dot11lcn_noise_scale_tbl_rev0[0]), 1, 0, 16} | ||
2780 | , | 2831 | , |
2781 | {&dot11lcn_fltr_ctrl_tbl_rev0, | 2832 | {&dot11lcn_fltr_ctrl_tbl_rev0, |
2782 | sizeof(dot11lcn_fltr_ctrl_tbl_rev0) / | 2833 | ARRAY_SIZE(dot11lcn_fltr_ctrl_tbl_rev0), 11, 0, 32} |
2783 | sizeof(dot11lcn_fltr_ctrl_tbl_rev0[0]), 11, 0, 32} | ||
2784 | , | 2834 | , |
2785 | {&dot11lcn_ps_ctrl_tbl_rev0, | 2835 | {&dot11lcn_ps_ctrl_tbl_rev0, |
2786 | sizeof(dot11lcn_ps_ctrl_tbl_rev0) / | 2836 | ARRAY_SIZE(dot11lcn_ps_ctrl_tbl_rev0), 12, 0, 32} |
2787 | sizeof(dot11lcn_ps_ctrl_tbl_rev0[0]), 12, 0, 32} | ||
2788 | , | 2837 | , |
2789 | {&dot11lcn_gain_idx_tbl_rev0, | 2838 | {&dot11lcn_gain_idx_tbl_rev0, |
2790 | sizeof(dot11lcn_gain_idx_tbl_rev0) / | 2839 | ARRAY_SIZE(dot11lcn_gain_idx_tbl_rev0), 13, 0, 32} |
2791 | sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} | ||
2792 | , | 2840 | , |
2793 | {&dot11lcn_aux_gain_idx_tbl_rev0, | 2841 | {&dot11lcn_aux_gain_idx_tbl_rev0, |
2794 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / | 2842 | ARRAY_SIZE(dot11lcn_aux_gain_idx_tbl_rev0), 14, 0, 16} |
2795 | sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} | ||
2796 | , | 2843 | , |
2797 | {&dot11lcn_sw_ctrl_tbl_rev0, | 2844 | {&dot11lcn_sw_ctrl_tbl_rev0, |
2798 | sizeof(dot11lcn_sw_ctrl_tbl_rev0) / | 2845 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_rev0), 15, 0, 16} |
2799 | sizeof(dot11lcn_sw_ctrl_tbl_rev0[0]), 15, 0, 16} | ||
2800 | , | 2846 | , |
2801 | {&dot11lcn_nf_table_rev0, | 2847 | {&dot11lcn_nf_table_rev0, |
2802 | sizeof(dot11lcn_nf_table_rev0) / sizeof(dot11lcn_nf_table_rev0[0]), 16, | 2848 | ARRAY_SIZE(dot11lcn_nf_table_rev0), 16, |
2803 | 0, 8} | 2849 | 0, 8} |
2804 | , | 2850 | , |
2805 | {&dot11lcn_gain_val_tbl_rev0, | 2851 | {&dot11lcn_gain_val_tbl_rev0, |
2806 | sizeof(dot11lcn_gain_val_tbl_rev0) / | 2852 | ARRAY_SIZE(dot11lcn_gain_val_tbl_rev0), 17, 0, 8} |
2807 | sizeof(dot11lcn_gain_val_tbl_rev0[0]), 17, 0, 8} | ||
2808 | , | 2853 | , |
2809 | {&dot11lcn_gain_tbl_rev0, | 2854 | {&dot11lcn_gain_tbl_rev0, |
2810 | sizeof(dot11lcn_gain_tbl_rev0) / sizeof(dot11lcn_gain_tbl_rev0[0]), 18, | 2855 | ARRAY_SIZE(dot11lcn_gain_tbl_rev0), 18, |
2811 | 0, 32} | 2856 | 0, 32} |
2812 | , | 2857 | , |
2813 | {&dot11lcn_spur_tbl_rev0, | 2858 | {&dot11lcn_spur_tbl_rev0, |
2814 | sizeof(dot11lcn_spur_tbl_rev0) / sizeof(dot11lcn_spur_tbl_rev0[0]), 20, | 2859 | ARRAY_SIZE(dot11lcn_spur_tbl_rev0), 20, |
2815 | 0, 8} | 2860 | 0, 8} |
2816 | , | 2861 | , |
2817 | {&dot11lcn_unsup_mcs_tbl_rev0, | 2862 | {&dot11lcn_unsup_mcs_tbl_rev0, |
2818 | sizeof(dot11lcn_unsup_mcs_tbl_rev0) / | 2863 | ARRAY_SIZE(dot11lcn_unsup_mcs_tbl_rev0), 23, 0, 16} |
2819 | sizeof(dot11lcn_unsup_mcs_tbl_rev0[0]), 23, 0, 16} | ||
2820 | , | 2864 | , |
2821 | {&dot11lcn_iq_local_tbl_rev0, | 2865 | {&dot11lcn_iq_local_tbl_rev0, |
2822 | sizeof(dot11lcn_iq_local_tbl_rev0) / | 2866 | ARRAY_SIZE(dot11lcn_iq_local_tbl_rev0), 0, 0, 16} |
2823 | sizeof(dot11lcn_iq_local_tbl_rev0[0]), 0, 0, 16} | ||
2824 | , | 2867 | , |
2825 | {&dot11lcn_papd_compdelta_tbl_rev0, | 2868 | {&dot11lcn_papd_compdelta_tbl_rev0, |
2826 | sizeof(dot11lcn_papd_compdelta_tbl_rev0) / | 2869 | ARRAY_SIZE(dot11lcn_papd_compdelta_tbl_rev0), 24, 0, 32} |
2827 | sizeof(dot11lcn_papd_compdelta_tbl_rev0[0]), 24, 0, 32} | ||
2828 | , | 2870 | , |
2829 | }; | 2871 | }; |
2830 | 2872 | ||
2831 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313 = { | 2873 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313 = { |
2832 | &dot11lcn_sw_ctrl_tbl_4313_rev0, | 2874 | &dot11lcn_sw_ctrl_tbl_4313_rev0, |
2833 | sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0) / | 2875 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_4313_rev0), 15, 0, 16 |
2834 | sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0[0]), 15, 0, 16 | 2876 | }; |
2877 | |||
2878 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_ipa = { | ||
2879 | &dot11lcn_sw_ctrl_tbl_4313_ipa_rev0_combo, | ||
2880 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_4313_ipa_rev0_combo), 15, 0, 16 | ||
2835 | }; | 2881 | }; |
2836 | 2882 | ||
2837 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa = { | 2883 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa = { |
2838 | &dot11lcn_sw_ctrl_tbl_4313_epa_rev0, | 2884 | &dot11lcn_sw_ctrl_tbl_4313_epa_rev0, |
2839 | sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0) / | 2885 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_4313_epa_rev0), 15, 0, 16 |
2840 | sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0[0]), 15, 0, 16 | ||
2841 | }; | 2886 | }; |
2842 | 2887 | ||
2843 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa = { | 2888 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa = { |
2844 | &dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo, | 2889 | &dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo, |
2845 | sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo) / | 2890 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo), 15, 0, 16 |
2846 | sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[0]), 15, 0, 16 | ||
2847 | }; | 2891 | }; |
2848 | 2892 | ||
2849 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250 = { | 2893 | const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250 = { |
2850 | &dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0, | 2894 | &dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0, |
2851 | sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0) / | 2895 | ARRAY_SIZE(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0), 15, 0, 16 |
2852 | sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[0]), 15, 0, 16 | ||
2853 | }; | 2896 | }; |
2854 | 2897 | ||
2855 | const u32 dot11lcnphytbl_info_sz_rev0 = | 2898 | const u32 dot11lcnphytbl_info_sz_rev0 = |
2856 | sizeof(dot11lcnphytbl_info_rev0) / sizeof(dot11lcnphytbl_info_rev0[0]); | 2899 | ARRAY_SIZE(dot11lcnphytbl_info_rev0); |
2857 | 2900 | ||
2858 | const struct lcnphy_tx_gain_tbl_entry | 2901 | const struct lcnphy_tx_gain_tbl_entry |
2859 | dot11lcnphy_2GHz_extPA_gaintable_rev0[128] = { | 2902 | dot11lcnphy_2GHz_extPA_gaintable_rev0[128] = { |
@@ -2988,134 +3031,134 @@ dot11lcnphy_2GHz_extPA_gaintable_rev0[128] = { | |||
2988 | }; | 3031 | }; |
2989 | 3032 | ||
2990 | const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_gaintable_rev0[128] = { | 3033 | const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_gaintable_rev0[128] = { |
2991 | {7, 0, 31, 0, 72}, | 3034 | {15, 0, 31, 0, 72}, |
2992 | {7, 0, 31, 0, 70}, | 3035 | {15, 0, 31, 0, 70}, |
2993 | {7, 0, 31, 0, 68}, | 3036 | {15, 0, 31, 0, 68}, |
2994 | {7, 0, 30, 0, 67}, | 3037 | {15, 0, 30, 0, 68}, |
2995 | {7, 0, 29, 0, 68}, | 3038 | {15, 0, 29, 0, 69}, |
2996 | {7, 0, 28, 0, 68}, | 3039 | {15, 0, 28, 0, 69}, |
2997 | {7, 0, 27, 0, 69}, | 3040 | {15, 0, 27, 0, 70}, |
2998 | {7, 0, 26, 0, 70}, | 3041 | {15, 0, 26, 0, 70}, |
2999 | {7, 0, 25, 0, 70}, | 3042 | {15, 0, 25, 0, 71}, |
3000 | {7, 0, 24, 0, 71}, | 3043 | {15, 0, 24, 0, 72}, |
3001 | {7, 0, 23, 0, 72}, | 3044 | {15, 0, 23, 0, 73}, |
3002 | {7, 0, 23, 0, 70}, | 3045 | {15, 0, 23, 0, 71}, |
3003 | {7, 0, 22, 0, 71}, | 3046 | {15, 0, 22, 0, 72}, |
3004 | {7, 0, 21, 0, 72}, | 3047 | {15, 0, 21, 0, 73}, |
3005 | {7, 0, 21, 0, 70}, | 3048 | {15, 0, 21, 0, 71}, |
3006 | {7, 0, 21, 0, 68}, | 3049 | {15, 0, 21, 0, 69}, |
3007 | {7, 0, 21, 0, 66}, | 3050 | {15, 0, 21, 0, 67}, |
3008 | {7, 0, 21, 0, 64}, | 3051 | {15, 0, 21, 0, 65}, |
3009 | {7, 0, 21, 0, 63}, | 3052 | {15, 0, 21, 0, 63}, |
3010 | {7, 0, 20, 0, 64}, | 3053 | {15, 0, 20, 0, 65}, |
3011 | {7, 0, 19, 0, 65}, | 3054 | {15, 0, 19, 0, 66}, |
3012 | {7, 0, 19, 0, 64}, | 3055 | {15, 0, 19, 0, 64}, |
3013 | {7, 0, 18, 0, 65}, | 3056 | {15, 0, 18, 0, 66}, |
3014 | {7, 0, 18, 0, 64}, | 3057 | {15, 0, 18, 0, 64}, |
3015 | {7, 0, 17, 0, 65}, | 3058 | {15, 0, 17, 0, 66}, |
3016 | {7, 0, 17, 0, 64}, | 3059 | {15, 0, 17, 0, 64}, |
3017 | {7, 0, 16, 0, 65}, | 3060 | {15, 0, 16, 0, 66}, |
3018 | {7, 0, 16, 0, 64}, | 3061 | {15, 0, 16, 0, 64}, |
3019 | {7, 0, 16, 0, 62}, | 3062 | {15, 0, 16, 0, 62}, |
3020 | {7, 0, 16, 0, 60}, | 3063 | {15, 0, 16, 0, 61}, |
3021 | {7, 0, 16, 0, 58}, | 3064 | {15, 0, 16, 0, 59}, |
3022 | {7, 0, 15, 0, 61}, | 3065 | {15, 0, 15, 0, 61}, |
3023 | {7, 0, 15, 0, 59}, | 3066 | {15, 0, 15, 0, 59}, |
3024 | {7, 0, 14, 0, 61}, | 3067 | {15, 0, 14, 0, 62}, |
3025 | {7, 0, 14, 0, 60}, | 3068 | {15, 0, 14, 0, 60}, |
3026 | {7, 0, 14, 0, 58}, | 3069 | {15, 0, 14, 0, 58}, |
3027 | {7, 0, 13, 0, 60}, | 3070 | {15, 0, 13, 0, 61}, |
3028 | {7, 0, 13, 0, 59}, | 3071 | {15, 0, 13, 0, 59}, |
3029 | {7, 0, 12, 0, 62}, | 3072 | {15, 0, 12, 0, 62}, |
3030 | {7, 0, 12, 0, 60}, | 3073 | {15, 0, 12, 0, 61}, |
3031 | {7, 0, 12, 0, 58}, | 3074 | {15, 0, 12, 0, 59}, |
3032 | {7, 0, 11, 0, 62}, | 3075 | {15, 0, 11, 0, 62}, |
3033 | {7, 0, 11, 0, 60}, | 3076 | {15, 0, 11, 0, 61}, |
3034 | {7, 0, 11, 0, 59}, | 3077 | {15, 0, 11, 0, 59}, |
3035 | {7, 0, 11, 0, 57}, | 3078 | {15, 0, 11, 0, 57}, |
3036 | {7, 0, 10, 0, 61}, | 3079 | {15, 0, 10, 0, 61}, |
3037 | {7, 0, 10, 0, 59}, | 3080 | {15, 0, 10, 0, 59}, |
3038 | {7, 0, 10, 0, 57}, | 3081 | {15, 0, 10, 0, 58}, |
3039 | {7, 0, 9, 0, 62}, | 3082 | {15, 0, 9, 0, 62}, |
3040 | {7, 0, 9, 0, 60}, | 3083 | {15, 0, 9, 0, 61}, |
3041 | {7, 0, 9, 0, 58}, | 3084 | {15, 0, 9, 0, 59}, |
3042 | {7, 0, 9, 0, 57}, | 3085 | {15, 0, 9, 0, 57}, |
3043 | {7, 0, 8, 0, 62}, | 3086 | {15, 0, 8, 0, 62}, |
3044 | {7, 0, 8, 0, 60}, | 3087 | {15, 0, 8, 0, 61}, |
3045 | {7, 0, 8, 0, 58}, | 3088 | {15, 0, 8, 0, 59}, |
3046 | {7, 0, 8, 0, 57}, | 3089 | {15, 0, 8, 0, 57}, |
3047 | {7, 0, 8, 0, 55}, | 3090 | {15, 0, 8, 0, 56}, |
3048 | {7, 0, 7, 0, 61}, | 3091 | {15, 0, 8, 0, 54}, |
3092 | {15, 0, 8, 0, 53}, | ||
3093 | {15, 0, 8, 0, 51}, | ||
3094 | {15, 0, 8, 0, 50}, | ||
3095 | {7, 0, 7, 0, 69}, | ||
3096 | {7, 0, 7, 0, 67}, | ||
3097 | {7, 0, 7, 0, 65}, | ||
3098 | {7, 0, 7, 0, 64}, | ||
3099 | {7, 0, 7, 0, 62}, | ||
3049 | {7, 0, 7, 0, 60}, | 3100 | {7, 0, 7, 0, 60}, |
3050 | {7, 0, 7, 0, 58}, | 3101 | {7, 0, 7, 0, 58}, |
3051 | {7, 0, 7, 0, 56}, | 3102 | {7, 0, 7, 0, 57}, |
3052 | {7, 0, 7, 0, 55}, | 3103 | {7, 0, 7, 0, 55}, |
3053 | {7, 0, 6, 0, 62}, | 3104 | {7, 0, 6, 0, 62}, |
3054 | {7, 0, 6, 0, 60}, | 3105 | {7, 0, 6, 0, 61}, |
3055 | {7, 0, 6, 0, 58}, | 3106 | {7, 0, 6, 0, 59}, |
3056 | {7, 0, 6, 0, 57}, | 3107 | {7, 0, 6, 0, 57}, |
3057 | {7, 0, 6, 0, 55}, | 3108 | {7, 0, 6, 0, 56}, |
3058 | {7, 0, 6, 0, 54}, | 3109 | {7, 0, 6, 0, 54}, |
3059 | {7, 0, 6, 0, 52}, | 3110 | {7, 0, 6, 0, 53}, |
3060 | {7, 0, 5, 0, 61}, | 3111 | {7, 0, 5, 0, 61}, |
3061 | {7, 0, 5, 0, 59}, | 3112 | {7, 0, 5, 0, 60}, |
3062 | {7, 0, 5, 0, 57}, | 3113 | {7, 0, 5, 0, 58}, |
3063 | {7, 0, 5, 0, 56}, | 3114 | {7, 0, 5, 0, 56}, |
3064 | {7, 0, 5, 0, 54}, | 3115 | {7, 0, 5, 0, 55}, |
3065 | {7, 0, 5, 0, 53}, | 3116 | {7, 0, 5, 0, 53}, |
3066 | {7, 0, 5, 0, 51}, | 3117 | {7, 0, 5, 0, 52}, |
3067 | {7, 0, 4, 0, 62}, | 3118 | {7, 0, 5, 0, 50}, |
3068 | {7, 0, 4, 0, 60}, | 3119 | {7, 0, 5, 0, 49}, |
3069 | {7, 0, 4, 0, 58}, | 3120 | {7, 0, 5, 0, 47}, |
3070 | {7, 0, 4, 0, 57}, | 3121 | {7, 0, 4, 0, 57}, |
3071 | {7, 0, 4, 0, 55}, | 3122 | {7, 0, 4, 0, 56}, |
3072 | {7, 0, 4, 0, 54}, | 3123 | {7, 0, 4, 0, 54}, |
3073 | {7, 0, 4, 0, 52}, | 3124 | {7, 0, 4, 0, 53}, |
3074 | {7, 0, 4, 0, 51}, | 3125 | {7, 0, 4, 0, 51}, |
3075 | {7, 0, 4, 0, 49}, | 3126 | {7, 0, 4, 0, 50}, |
3076 | {7, 0, 4, 0, 48}, | 3127 | {7, 0, 4, 0, 48}, |
3128 | {7, 0, 4, 0, 47}, | ||
3077 | {7, 0, 4, 0, 46}, | 3129 | {7, 0, 4, 0, 46}, |
3078 | {7, 0, 3, 0, 60}, | 3130 | {7, 0, 4, 0, 44}, |
3079 | {7, 0, 3, 0, 58}, | 3131 | {7, 0, 4, 0, 43}, |
3080 | {7, 0, 3, 0, 57}, | 3132 | {7, 0, 4, 0, 42}, |
3081 | {7, 0, 3, 0, 55}, | 3133 | {7, 0, 4, 0, 41}, |
3082 | {7, 0, 3, 0, 54}, | 3134 | {7, 0, 4, 0, 40}, |
3083 | {7, 0, 3, 0, 52}, | ||
3084 | {7, 0, 3, 0, 51}, | 3135 | {7, 0, 3, 0, 51}, |
3085 | {7, 0, 3, 0, 49}, | 3136 | {7, 0, 3, 0, 50}, |
3086 | {7, 0, 3, 0, 48}, | 3137 | {7, 0, 3, 0, 48}, |
3138 | {7, 0, 3, 0, 47}, | ||
3087 | {7, 0, 3, 0, 46}, | 3139 | {7, 0, 3, 0, 46}, |
3088 | {7, 0, 3, 0, 45}, | ||
3089 | {7, 0, 3, 0, 44}, | 3140 | {7, 0, 3, 0, 44}, |
3090 | {7, 0, 3, 0, 43}, | 3141 | {7, 0, 3, 0, 43}, |
3142 | {7, 0, 3, 0, 42}, | ||
3091 | {7, 0, 3, 0, 41}, | 3143 | {7, 0, 3, 0, 41}, |
3092 | {7, 0, 2, 0, 61}, | 3144 | {3, 0, 3, 0, 56}, |
3093 | {7, 0, 2, 0, 59}, | 3145 | {3, 0, 3, 0, 54}, |
3094 | {7, 0, 2, 0, 57}, | 3146 | {3, 0, 3, 0, 53}, |
3095 | {7, 0, 2, 0, 56}, | 3147 | {3, 0, 3, 0, 51}, |
3096 | {7, 0, 2, 0, 54}, | 3148 | {3, 0, 3, 0, 50}, |
3097 | {7, 0, 2, 0, 53}, | 3149 | {3, 0, 3, 0, 48}, |
3098 | {7, 0, 2, 0, 51}, | 3150 | {3, 0, 3, 0, 47}, |
3099 | {7, 0, 2, 0, 50}, | 3151 | {3, 0, 3, 0, 46}, |
3100 | {7, 0, 2, 0, 48}, | 3152 | {3, 0, 3, 0, 44}, |
3101 | {7, 0, 2, 0, 47}, | 3153 | {3, 0, 3, 0, 43}, |
3102 | {7, 0, 2, 0, 46}, | 3154 | {3, 0, 3, 0, 42}, |
3103 | {7, 0, 2, 0, 44}, | 3155 | {3, 0, 3, 0, 41}, |
3104 | {7, 0, 2, 0, 43}, | 3156 | {3, 0, 3, 0, 39}, |
3105 | {7, 0, 2, 0, 42}, | 3157 | {3, 0, 3, 0, 38}, |
3106 | {7, 0, 2, 0, 41}, | 3158 | {3, 0, 3, 0, 37}, |
3107 | {7, 0, 2, 0, 39}, | 3159 | {3, 0, 3, 0, 36}, |
3108 | {7, 0, 2, 0, 38}, | 3160 | {3, 0, 3, 0, 35}, |
3109 | {7, 0, 2, 0, 37}, | 3161 | {3, 0, 3, 0, 34}, |
3110 | {7, 0, 2, 0, 36}, | ||
3111 | {7, 0, 2, 0, 35}, | ||
3112 | {7, 0, 2, 0, 34}, | ||
3113 | {7, 0, 2, 0, 33}, | ||
3114 | {7, 0, 2, 0, 32}, | ||
3115 | {7, 0, 1, 0, 63}, | ||
3116 | {7, 0, 1, 0, 61}, | ||
3117 | {7, 0, 1, 0, 59}, | ||
3118 | {7, 0, 1, 0, 57}, | ||
3119 | }; | 3162 | }; |
3120 | 3163 | ||
3121 | const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_5GHz_gaintable_rev0[128] = { | 3164 | const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_5GHz_gaintable_rev0[128] = { |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.h index 5f75e16bf5a7..489422a36085 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phytbl_lcn.h | |||
@@ -20,6 +20,7 @@ | |||
20 | extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[]; | 20 | extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[]; |
21 | extern const u32 dot11lcnphytbl_rx_gain_info_sz_rev0; | 21 | extern const u32 dot11lcnphytbl_rx_gain_info_sz_rev0; |
22 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313; | 22 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313; |
23 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_ipa; | ||
23 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa; | 24 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa; |
24 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa_combo; | 25 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa_combo; |
25 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa; | 26 | extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa; |
diff --git a/drivers/net/wireless/cw1200/sta.c b/drivers/net/wireless/cw1200/sta.c index 7365674366f4..010b252be584 100644 --- a/drivers/net/wireless/cw1200/sta.c +++ b/drivers/net/wireless/cw1200/sta.c | |||
@@ -1406,11 +1406,8 @@ static void cw1200_do_unjoin(struct cw1200_common *priv) | |||
1406 | if (!priv->join_status) | 1406 | if (!priv->join_status) |
1407 | goto done; | 1407 | goto done; |
1408 | 1408 | ||
1409 | if (priv->join_status > CW1200_JOIN_STATUS_IBSS) { | 1409 | if (priv->join_status == CW1200_JOIN_STATUS_AP) |
1410 | wiphy_err(priv->hw->wiphy, "Unexpected: join status: %d\n", | 1410 | goto done; |
1411 | priv->join_status); | ||
1412 | BUG_ON(1); | ||
1413 | } | ||
1414 | 1411 | ||
1415 | cancel_work_sync(&priv->update_filtering_work); | 1412 | cancel_work_sync(&priv->update_filtering_work); |
1416 | cancel_work_sync(&priv->set_beacon_wakeup_period_work); | 1413 | cancel_work_sync(&priv->set_beacon_wakeup_period_work); |
diff --git a/drivers/net/wireless/cw1200/txrx.c b/drivers/net/wireless/cw1200/txrx.c index 5862c373d714..e824d4d4a18d 100644 --- a/drivers/net/wireless/cw1200/txrx.c +++ b/drivers/net/wireless/cw1200/txrx.c | |||
@@ -1165,7 +1165,7 @@ void cw1200_rx_cb(struct cw1200_common *priv, | |||
1165 | if (cw1200_handle_action_rx(priv, skb)) | 1165 | if (cw1200_handle_action_rx(priv, skb)) |
1166 | return; | 1166 | return; |
1167 | } else if (ieee80211_is_beacon(frame->frame_control) && | 1167 | } else if (ieee80211_is_beacon(frame->frame_control) && |
1168 | !arg->status && | 1168 | !arg->status && priv->vif && |
1169 | !memcmp(ieee80211_get_SA(frame), priv->vif->bss_conf.bssid, | 1169 | !memcmp(ieee80211_get_SA(frame), priv->vif->bss_conf.bssid, |
1170 | ETH_ALEN)) { | 1170 | ETH_ALEN)) { |
1171 | const u8 *tim_ie; | 1171 | const u8 *tim_ie; |
diff --git a/drivers/net/wireless/cw1200/wsm.h b/drivers/net/wireless/cw1200/wsm.h index 7afc613c3706..48086e849515 100644 --- a/drivers/net/wireless/cw1200/wsm.h +++ b/drivers/net/wireless/cw1200/wsm.h | |||
@@ -832,7 +832,7 @@ struct wsm_tx { | |||
832 | /* the MSDU shall be terminated. Overrides the global */ | 832 | /* the MSDU shall be terminated. Overrides the global */ |
833 | /* dot11MaxTransmitMsduLifeTime setting [optional] */ | 833 | /* dot11MaxTransmitMsduLifeTime setting [optional] */ |
834 | /* Device will set the default value if this is 0. */ | 834 | /* Device will set the default value if this is 0. */ |
835 | u32 expire_time; | 835 | __le32 expire_time; |
836 | 836 | ||
837 | /* WSM_HT_TX_... */ | 837 | /* WSM_HT_TX_... */ |
838 | __le32 ht_tx_parameters; | 838 | __le32 ht_tx_parameters; |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index ac074731335a..e5090309824e 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -523,9 +523,9 @@ static int prism2_ioctl_giwaplist(struct net_device *dev, | |||
523 | 523 | ||
524 | data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1); | 524 | data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1); |
525 | 525 | ||
526 | memcpy(extra, &addr, sizeof(struct sockaddr) * data->length); | 526 | memcpy(extra, addr, sizeof(struct sockaddr) * data->length); |
527 | data->flags = 1; /* has quality information */ | 527 | data->flags = 1; /* has quality information */ |
528 | memcpy(extra + sizeof(struct sockaddr) * data->length, &qual, | 528 | memcpy(extra + sizeof(struct sockaddr) * data->length, qual, |
529 | sizeof(struct iw_quality) * data->length); | 529 | sizeof(struct iw_quality) * data->length); |
530 | 530 | ||
531 | kfree(addr); | 531 | kfree(addr); |
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c index 15f0fad39add..e4f56ad26cd8 100644 --- a/drivers/net/wireless/hostap/hostap_main.c +++ b/drivers/net/wireless/hostap/hostap_main.c | |||
@@ -667,7 +667,7 @@ static int prism2_open(struct net_device *dev) | |||
667 | if (local->no_pri) { | 667 | if (local->no_pri) { |
668 | printk(KERN_DEBUG "%s: could not set interface UP - no PRI " | 668 | printk(KERN_DEBUG "%s: could not set interface UP - no PRI " |
669 | "f/w\n", dev->name); | 669 | "f/w\n", dev->name); |
670 | return 1; | 670 | return -ENODEV; |
671 | } | 671 | } |
672 | 672 | ||
673 | if ((local->func->card_present && !local->func->card_present(local)) || | 673 | if ((local->func->card_present && !local->func->card_present(local)) || |
@@ -682,7 +682,7 @@ static int prism2_open(struct net_device *dev) | |||
682 | printk(KERN_WARNING "%s: could not enable MAC port\n", | 682 | printk(KERN_WARNING "%s: could not enable MAC port\n", |
683 | dev->name); | 683 | dev->name); |
684 | prism2_close(dev); | 684 | prism2_close(dev); |
685 | return 1; | 685 | return -ENODEV; |
686 | } | 686 | } |
687 | if (!local->dev_enabled) | 687 | if (!local->dev_enabled) |
688 | prism2_callback(local, PRISM2_CALLBACK_ENABLE); | 688 | prism2_callback(local, PRISM2_CALLBACK_ENABLE); |
diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index c092033945cc..f09e257759d5 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c | |||
@@ -475,6 +475,8 @@ il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) | |||
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | #define SMALL_PACKET_SIZE 256 | ||
479 | |||
478 | static void | 480 | static void |
479 | il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, | 481 | il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, |
480 | struct ieee80211_rx_status *stats) | 482 | struct ieee80211_rx_status *stats) |
@@ -483,14 +485,13 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, | |||
483 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); | 485 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); |
484 | struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); | 486 | struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); |
485 | struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); | 487 | struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); |
486 | u16 len = le16_to_cpu(rx_hdr->len); | 488 | u32 len = le16_to_cpu(rx_hdr->len); |
487 | struct sk_buff *skb; | 489 | struct sk_buff *skb; |
488 | __le16 fc = hdr->frame_control; | 490 | __le16 fc = hdr->frame_control; |
491 | u32 fraglen = PAGE_SIZE << il->hw_params.rx_page_order; | ||
489 | 492 | ||
490 | /* We received data from the HW, so stop the watchdog */ | 493 | /* We received data from the HW, so stop the watchdog */ |
491 | if (unlikely | 494 | if (unlikely(len + IL39_RX_FRAME_SIZE > fraglen)) { |
492 | (len + IL39_RX_FRAME_SIZE > | ||
493 | PAGE_SIZE << il->hw_params.rx_page_order)) { | ||
494 | D_DROP("Corruption detected!\n"); | 495 | D_DROP("Corruption detected!\n"); |
495 | return; | 496 | return; |
496 | } | 497 | } |
@@ -506,26 +507,32 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, | |||
506 | D_INFO("Woke queues - frame received on passive channel\n"); | 507 | D_INFO("Woke queues - frame received on passive channel\n"); |
507 | } | 508 | } |
508 | 509 | ||
509 | skb = dev_alloc_skb(128); | 510 | skb = dev_alloc_skb(SMALL_PACKET_SIZE); |
510 | if (!skb) { | 511 | if (!skb) { |
511 | IL_ERR("dev_alloc_skb failed\n"); | 512 | IL_ERR("dev_alloc_skb failed\n"); |
512 | return; | 513 | return; |
513 | } | 514 | } |
514 | 515 | ||
515 | if (!il3945_mod_params.sw_crypto) | 516 | if (!il3945_mod_params.sw_crypto) |
516 | il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), | 517 | il_set_decrypted_flag(il, (struct ieee80211_hdr *)pkt, |
517 | le32_to_cpu(rx_end->status), stats); | 518 | le32_to_cpu(rx_end->status), stats); |
518 | 519 | ||
519 | skb_add_rx_frag(skb, 0, rxb->page, | 520 | /* If frame is small enough to fit into skb->head, copy it |
520 | (void *)rx_hdr->payload - (void *)pkt, len, | 521 | * and do not consume a full page |
521 | len); | 522 | */ |
522 | 523 | if (len <= SMALL_PACKET_SIZE) { | |
524 | memcpy(skb_put(skb, len), rx_hdr->payload, len); | ||
525 | } else { | ||
526 | skb_add_rx_frag(skb, 0, rxb->page, | ||
527 | (void *)rx_hdr->payload - (void *)pkt, len, | ||
528 | fraglen); | ||
529 | il->alloc_rxb_page--; | ||
530 | rxb->page = NULL; | ||
531 | } | ||
523 | il_update_stats(il, false, fc, len); | 532 | il_update_stats(il, false, fc, len); |
524 | memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); | 533 | memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); |
525 | 534 | ||
526 | ieee80211_rx(il->hw, skb); | 535 | ieee80211_rx(il->hw, skb); |
527 | il->alloc_rxb_page--; | ||
528 | rxb->page = NULL; | ||
529 | } | 536 | } |
530 | 537 | ||
531 | #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) | 538 | #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) |
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index b9b2bb51e605..5ab50a5b48b1 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c | |||
@@ -574,9 +574,11 @@ il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) | |||
574 | return decrypt_out; | 574 | return decrypt_out; |
575 | } | 575 | } |
576 | 576 | ||
577 | #define SMALL_PACKET_SIZE 256 | ||
578 | |||
577 | static void | 579 | static void |
578 | il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, | 580 | il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, |
579 | u16 len, u32 ampdu_status, struct il_rx_buf *rxb, | 581 | u32 len, u32 ampdu_status, struct il_rx_buf *rxb, |
580 | struct ieee80211_rx_status *stats) | 582 | struct ieee80211_rx_status *stats) |
581 | { | 583 | { |
582 | struct sk_buff *skb; | 584 | struct sk_buff *skb; |
@@ -598,21 +600,25 @@ il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, | |||
598 | il_set_decrypted_flag(il, hdr, ampdu_status, stats)) | 600 | il_set_decrypted_flag(il, hdr, ampdu_status, stats)) |
599 | return; | 601 | return; |
600 | 602 | ||
601 | skb = dev_alloc_skb(128); | 603 | skb = dev_alloc_skb(SMALL_PACKET_SIZE); |
602 | if (!skb) { | 604 | if (!skb) { |
603 | IL_ERR("dev_alloc_skb failed\n"); | 605 | IL_ERR("dev_alloc_skb failed\n"); |
604 | return; | 606 | return; |
605 | } | 607 | } |
606 | 608 | ||
607 | skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len, | 609 | if (len <= SMALL_PACKET_SIZE) { |
608 | len); | 610 | memcpy(skb_put(skb, len), hdr, len); |
611 | } else { | ||
612 | skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), | ||
613 | len, PAGE_SIZE << il->hw_params.rx_page_order); | ||
614 | il->alloc_rxb_page--; | ||
615 | rxb->page = NULL; | ||
616 | } | ||
609 | 617 | ||
610 | il_update_stats(il, false, fc, len); | 618 | il_update_stats(il, false, fc, len); |
611 | memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); | 619 | memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); |
612 | 620 | ||
613 | ieee80211_rx(il->hw, skb); | 621 | ieee80211_rx(il->hw, skb); |
614 | il->alloc_rxb_page--; | ||
615 | rxb->page = NULL; | ||
616 | } | 622 | } |
617 | 623 | ||
618 | /* Called for N_RX (legacy ABG frames), or | 624 | /* Called for N_RX (legacy ABG frames), or |
@@ -4460,13 +4466,13 @@ il4965_irq_tasklet(struct il_priv *il) | |||
4460 | * is killed. Hence update the killswitch state here. The | 4466 | * is killed. Hence update the killswitch state here. The |
4461 | * rfkill handler will care about restarting if needed. | 4467 | * rfkill handler will care about restarting if needed. |
4462 | */ | 4468 | */ |
4463 | if (!test_bit(S_ALIVE, &il->status)) { | 4469 | if (hw_rf_kill) { |
4464 | if (hw_rf_kill) | 4470 | set_bit(S_RFKILL, &il->status); |
4465 | set_bit(S_RFKILL, &il->status); | 4471 | } else { |
4466 | else | 4472 | clear_bit(S_RFKILL, &il->status); |
4467 | clear_bit(S_RFKILL, &il->status); | 4473 | il_force_reset(il, true); |
4468 | wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); | ||
4469 | } | 4474 | } |
4475 | wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); | ||
4470 | 4476 | ||
4471 | handled |= CSR_INT_BIT_RF_KILL; | 4477 | handled |= CSR_INT_BIT_RF_KILL; |
4472 | } | 4478 | } |
@@ -5334,6 +5340,9 @@ il4965_alive_start(struct il_priv *il) | |||
5334 | 5340 | ||
5335 | il->active_rate = RATES_MASK; | 5341 | il->active_rate = RATES_MASK; |
5336 | 5342 | ||
5343 | il_power_update_mode(il, true); | ||
5344 | D_INFO("Updated power mode\n"); | ||
5345 | |||
5337 | if (il_is_associated(il)) { | 5346 | if (il_is_associated(il)) { |
5338 | struct il_rxon_cmd *active_rxon = | 5347 | struct il_rxon_cmd *active_rxon = |
5339 | (struct il_rxon_cmd *)&il->active; | 5348 | (struct il_rxon_cmd *)&il->active; |
@@ -5364,9 +5373,6 @@ il4965_alive_start(struct il_priv *il) | |||
5364 | D_INFO("ALIVE processing complete.\n"); | 5373 | D_INFO("ALIVE processing complete.\n"); |
5365 | wake_up(&il->wait_command_queue); | 5374 | wake_up(&il->wait_command_queue); |
5366 | 5375 | ||
5367 | il_power_update_mode(il, true); | ||
5368 | D_INFO("Updated power mode\n"); | ||
5369 | |||
5370 | return; | 5376 | return; |
5371 | 5377 | ||
5372 | restart: | 5378 | restart: |
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 3195aad440dd..b03e22ef5462 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c | |||
@@ -4660,6 +4660,7 @@ il_force_reset(struct il_priv *il, bool external) | |||
4660 | 4660 | ||
4661 | return 0; | 4661 | return 0; |
4662 | } | 4662 | } |
4663 | EXPORT_SYMBOL(il_force_reset); | ||
4663 | 4664 | ||
4664 | int | 4665 | int |
4665 | il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 4666 | il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index cbaa5c2c410f..3eb2102ce236 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig | |||
@@ -22,6 +22,8 @@ config IWLWIFI | |||
22 | Intel Wireless WiFi Link 6150BGN 2 Adapter | 22 | Intel Wireless WiFi Link 6150BGN 2 Adapter |
23 | Intel 100 Series Wi-Fi Adapters (100BGN and 130BGN) | 23 | Intel 100 Series Wi-Fi Adapters (100BGN and 130BGN) |
24 | Intel 2000 Series Wi-Fi Adapters | 24 | Intel 2000 Series Wi-Fi Adapters |
25 | Intel 7260 Wi-Fi Adapter | ||
26 | Intel 3160 Wi-Fi Adapter | ||
25 | 27 | ||
26 | 28 | ||
27 | This driver uses the kernel's mac80211 subsystem. | 29 | This driver uses the kernel's mac80211 subsystem. |
@@ -46,17 +48,16 @@ config IWLDVM | |||
46 | depends on IWLWIFI | 48 | depends on IWLWIFI |
47 | default IWLWIFI | 49 | default IWLWIFI |
48 | help | 50 | help |
49 | This is the driver supporting the DVM firmware which is | 51 | This is the driver that supports the DVM firmware which is |
50 | currently the only firmware available for existing devices. | 52 | used by most existing devices (with the exception of 7260 |
53 | and 3160). | ||
51 | 54 | ||
52 | config IWLMVM | 55 | config IWLMVM |
53 | tristate "Intel Wireless WiFi MVM Firmware support" | 56 | tristate "Intel Wireless WiFi MVM Firmware support" |
54 | depends on IWLWIFI | 57 | depends on IWLWIFI |
55 | help | 58 | help |
56 | This is the driver supporting the MVM firmware which is | 59 | This is the driver that supports the MVM firmware which is |
57 | currently only available for 7000 series devices. | 60 | currently only available for 7260 and 3160 devices. |
58 | |||
59 | Say yes if you have such a device. | ||
60 | 61 | ||
61 | # don't call it _MODULE -- will confuse Kconfig/fixdep/... | 62 | # don't call it _MODULE -- will confuse Kconfig/fixdep/... |
62 | config IWLWIFI_OPMODE_MODULAR | 63 | config IWLWIFI_OPMODE_MODULAR |
@@ -127,20 +128,3 @@ config IWLWIFI_DEVICE_TRACING | |||
127 | If unsure, say Y so we can help you better when problems | 128 | If unsure, say Y so we can help you better when problems |
128 | occur. | 129 | occur. |
129 | endmenu | 130 | endmenu |
130 | |||
131 | config IWLWIFI_P2P | ||
132 | def_bool y | ||
133 | bool "iwlwifi experimental P2P support" | ||
134 | depends on IWLWIFI | ||
135 | help | ||
136 | This option enables experimental P2P support for some devices | ||
137 | based on microcode support. Since P2P support is still under | ||
138 | development, this option may even enable it for some devices | ||
139 | now that turn out to not support it in the future due to | ||
140 | microcode restrictions. | ||
141 | |||
142 | To determine if your microcode supports the experimental P2P | ||
143 | offered by this option, check if the driver advertises AP | ||
144 | support when it is loaded. | ||
145 | |||
146 | Say Y only if you want to experiment with P2P. | ||
diff --git a/drivers/net/wireless/iwlwifi/dvm/agn.h b/drivers/net/wireless/iwlwifi/dvm/agn.h index 18355110deff..f2a86ffc3b4c 100644 --- a/drivers/net/wireless/iwlwifi/dvm/agn.h +++ b/drivers/net/wireless/iwlwifi/dvm/agn.h | |||
@@ -106,7 +106,6 @@ extern const struct iwl_dvm_cfg iwl_dvm_6030_cfg; | |||
106 | #define STATUS_CHANNEL_SWITCH_PENDING 11 | 106 | #define STATUS_CHANNEL_SWITCH_PENDING 11 |
107 | #define STATUS_SCAN_COMPLETE 12 | 107 | #define STATUS_SCAN_COMPLETE 12 |
108 | #define STATUS_POWER_PMI 13 | 108 | #define STATUS_POWER_PMI 13 |
109 | #define STATUS_SCAN_ROC_EXPIRED 14 | ||
110 | 109 | ||
111 | struct iwl_ucode_capabilities; | 110 | struct iwl_ucode_capabilities; |
112 | 111 | ||
@@ -250,7 +249,6 @@ u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); | |||
250 | 249 | ||
251 | /* scan */ | 250 | /* scan */ |
252 | void iwlagn_post_scan(struct iwl_priv *priv); | 251 | void iwlagn_post_scan(struct iwl_priv *priv); |
253 | void iwlagn_disable_roc(struct iwl_priv *priv); | ||
254 | int iwl_force_rf_reset(struct iwl_priv *priv, bool external); | 252 | int iwl_force_rf_reset(struct iwl_priv *priv, bool external); |
255 | void iwl_init_scan_params(struct iwl_priv *priv); | 253 | void iwl_init_scan_params(struct iwl_priv *priv); |
256 | int iwl_scan_cancel(struct iwl_priv *priv); | 254 | int iwl_scan_cancel(struct iwl_priv *priv); |
@@ -265,10 +263,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, | |||
265 | enum iwl_scan_type scan_type, | 263 | enum iwl_scan_type scan_type, |
266 | enum ieee80211_band band); | 264 | enum ieee80211_band band); |
267 | 265 | ||
268 | void iwl_scan_roc_expired(struct iwl_priv *priv); | ||
269 | void iwl_scan_offchannel_skb(struct iwl_priv *priv); | ||
270 | void iwl_scan_offchannel_skb_status(struct iwl_priv *priv); | ||
271 | |||
272 | /* For faster active scanning, scan will move to the next channel if fewer than | 266 | /* For faster active scanning, scan will move to the next channel if fewer than |
273 | * PLCP_QUIET_THRESH packets are heard on this channel within | 267 | * PLCP_QUIET_THRESH packets are heard on this channel within |
274 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | 268 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell |
diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c index d5329489245a..d94f8ab15004 100644 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c | |||
@@ -69,19 +69,7 @@ | |||
69 | } while (0) | 69 | } while (0) |
70 | 70 | ||
71 | /* file operation */ | 71 | /* file operation */ |
72 | #define DEBUGFS_READ_FUNC(name) \ | ||
73 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ | ||
74 | char __user *user_buf, \ | ||
75 | size_t count, loff_t *ppos); | ||
76 | |||
77 | #define DEBUGFS_WRITE_FUNC(name) \ | ||
78 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ | ||
79 | const char __user *user_buf, \ | ||
80 | size_t count, loff_t *ppos); | ||
81 | |||
82 | |||
83 | #define DEBUGFS_READ_FILE_OPS(name) \ | 72 | #define DEBUGFS_READ_FILE_OPS(name) \ |
84 | DEBUGFS_READ_FUNC(name); \ | ||
85 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 73 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
86 | .read = iwl_dbgfs_##name##_read, \ | 74 | .read = iwl_dbgfs_##name##_read, \ |
87 | .open = simple_open, \ | 75 | .open = simple_open, \ |
@@ -89,7 +77,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
89 | }; | 77 | }; |
90 | 78 | ||
91 | #define DEBUGFS_WRITE_FILE_OPS(name) \ | 79 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
92 | DEBUGFS_WRITE_FUNC(name); \ | ||
93 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 80 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
94 | .write = iwl_dbgfs_##name##_write, \ | 81 | .write = iwl_dbgfs_##name##_write, \ |
95 | .open = simple_open, \ | 82 | .open = simple_open, \ |
@@ -98,8 +85,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
98 | 85 | ||
99 | 86 | ||
100 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ | 87 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
101 | DEBUGFS_READ_FUNC(name); \ | ||
102 | DEBUGFS_WRITE_FUNC(name); \ | ||
103 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 88 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
104 | .write = iwl_dbgfs_##name##_write, \ | 89 | .write = iwl_dbgfs_##name##_write, \ |
105 | .read = iwl_dbgfs_##name##_read, \ | 90 | .read = iwl_dbgfs_##name##_read, \ |
diff --git a/drivers/net/wireless/iwlwifi/dvm/dev.h b/drivers/net/wireless/iwlwifi/dvm/dev.h index 60a4e0d15715..a79fdd137f95 100644 --- a/drivers/net/wireless/iwlwifi/dvm/dev.h +++ b/drivers/net/wireless/iwlwifi/dvm/dev.h | |||
@@ -540,7 +540,6 @@ struct iwl_rxon_context { | |||
540 | enum iwl_scan_type { | 540 | enum iwl_scan_type { |
541 | IWL_SCAN_NORMAL, | 541 | IWL_SCAN_NORMAL, |
542 | IWL_SCAN_RADIO_RESET, | 542 | IWL_SCAN_RADIO_RESET, |
543 | IWL_SCAN_ROC, | ||
544 | }; | 543 | }; |
545 | 544 | ||
546 | /** | 545 | /** |
@@ -825,12 +824,6 @@ struct iwl_priv { | |||
825 | struct reply_tx_error_statistics reply_tx_stats; | 824 | struct reply_tx_error_statistics reply_tx_stats; |
826 | struct reply_agg_tx_error_statistics reply_agg_tx_stats; | 825 | struct reply_agg_tx_error_statistics reply_agg_tx_stats; |
827 | 826 | ||
828 | /* remain-on-channel offload support */ | ||
829 | struct ieee80211_channel *hw_roc_channel; | ||
830 | struct delayed_work hw_roc_disable_work; | ||
831 | int hw_roc_duration; | ||
832 | bool hw_roc_setup, hw_roc_start_notified; | ||
833 | |||
834 | /* bt coex */ | 827 | /* bt coex */ |
835 | u8 bt_enable_flag; | 828 | u8 bt_enable_flag; |
836 | u8 bt_status; | 829 | u8 bt_status; |
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c index 822f1a00efbb..cae4d3182e33 100644 --- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c | |||
@@ -76,29 +76,6 @@ static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { | |||
76 | }, | 76 | }, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { | ||
80 | { | ||
81 | .max = 1, | ||
82 | .types = BIT(NL80211_IFTYPE_STATION), | ||
83 | }, | ||
84 | { | ||
85 | .max = 1, | ||
86 | .types = BIT(NL80211_IFTYPE_P2P_GO) | | ||
87 | BIT(NL80211_IFTYPE_AP), | ||
88 | }, | ||
89 | }; | ||
90 | |||
91 | static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { | ||
92 | { | ||
93 | .max = 2, | ||
94 | .types = BIT(NL80211_IFTYPE_STATION), | ||
95 | }, | ||
96 | { | ||
97 | .max = 1, | ||
98 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), | ||
99 | }, | ||
100 | }; | ||
101 | |||
102 | static const struct ieee80211_iface_combination | 79 | static const struct ieee80211_iface_combination |
103 | iwlagn_iface_combinations_dualmode[] = { | 80 | iwlagn_iface_combinations_dualmode[] = { |
104 | { .num_different_channels = 1, | 81 | { .num_different_channels = 1, |
@@ -114,21 +91,6 @@ iwlagn_iface_combinations_dualmode[] = { | |||
114 | }, | 91 | }, |
115 | }; | 92 | }; |
116 | 93 | ||
117 | static const struct ieee80211_iface_combination | ||
118 | iwlagn_iface_combinations_p2p[] = { | ||
119 | { .num_different_channels = 1, | ||
120 | .max_interfaces = 2, | ||
121 | .beacon_int_infra_match = true, | ||
122 | .limits = iwlagn_p2p_sta_go_limits, | ||
123 | .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), | ||
124 | }, | ||
125 | { .num_different_channels = 1, | ||
126 | .max_interfaces = 2, | ||
127 | .limits = iwlagn_p2p_2sta_limits, | ||
128 | .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), | ||
129 | }, | ||
130 | }; | ||
131 | |||
132 | /* | 94 | /* |
133 | * Not a mac80211 entry point function, but it fits in with all the | 95 | * Not a mac80211 entry point function, but it fits in with all the |
134 | * other mac80211 functions grouped here. | 96 | * other mac80211 functions grouped here. |
@@ -186,19 +148,13 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, | |||
186 | 148 | ||
187 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | 149 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); |
188 | 150 | ||
189 | if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { | 151 | if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { |
190 | hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; | ||
191 | hw->wiphy->n_iface_combinations = | ||
192 | ARRAY_SIZE(iwlagn_iface_combinations_p2p); | ||
193 | } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { | ||
194 | hw->wiphy->iface_combinations = | 152 | hw->wiphy->iface_combinations = |
195 | iwlagn_iface_combinations_dualmode; | 153 | iwlagn_iface_combinations_dualmode; |
196 | hw->wiphy->n_iface_combinations = | 154 | hw->wiphy->n_iface_combinations = |
197 | ARRAY_SIZE(iwlagn_iface_combinations_dualmode); | 155 | ARRAY_SIZE(iwlagn_iface_combinations_dualmode); |
198 | } | 156 | } |
199 | 157 | ||
200 | hw->wiphy->max_remain_on_channel_duration = 500; | ||
201 | |||
202 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | | 158 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | |
203 | WIPHY_FLAG_DISABLE_BEACON_HINTS | | 159 | WIPHY_FLAG_DISABLE_BEACON_HINTS | |
204 | WIPHY_FLAG_IBSS_RSN; | 160 | WIPHY_FLAG_IBSS_RSN; |
@@ -1068,7 +1024,10 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success) | |||
1068 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 1024 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
1069 | return; | 1025 | return; |
1070 | 1026 | ||
1071 | if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) | 1027 | if (!test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) |
1028 | return; | ||
1029 | |||
1030 | if (ctx->vif) | ||
1072 | ieee80211_chswitch_done(ctx->vif, is_success); | 1031 | ieee80211_chswitch_done(ctx->vif, is_success); |
1073 | } | 1032 | } |
1074 | 1033 | ||
@@ -1156,126 +1115,6 @@ done: | |||
1156 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 1115 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
1157 | } | 1116 | } |
1158 | 1117 | ||
1159 | static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, | ||
1160 | struct ieee80211_vif *vif, | ||
1161 | struct ieee80211_channel *channel, | ||
1162 | int duration, | ||
1163 | enum ieee80211_roc_type type) | ||
1164 | { | ||
1165 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
1166 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; | ||
1167 | int err = 0; | ||
1168 | |||
1169 | if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
1170 | return -EOPNOTSUPP; | ||
1171 | |||
1172 | if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) | ||
1173 | return -EOPNOTSUPP; | ||
1174 | |||
1175 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1176 | mutex_lock(&priv->mutex); | ||
1177 | |||
1178 | if (test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
1179 | /* mac80211 should not scan while ROC or ROC while scanning */ | ||
1180 | if (WARN_ON_ONCE(priv->scan_type != IWL_SCAN_RADIO_RESET)) { | ||
1181 | err = -EBUSY; | ||
1182 | goto out; | ||
1183 | } | ||
1184 | |||
1185 | iwl_scan_cancel_timeout(priv, 100); | ||
1186 | |||
1187 | if (test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
1188 | err = -EBUSY; | ||
1189 | goto out; | ||
1190 | } | ||
1191 | } | ||
1192 | |||
1193 | priv->hw_roc_channel = channel; | ||
1194 | /* convert from ms to TU */ | ||
1195 | priv->hw_roc_duration = DIV_ROUND_UP(1000 * duration, 1024); | ||
1196 | priv->hw_roc_start_notified = false; | ||
1197 | cancel_delayed_work(&priv->hw_roc_disable_work); | ||
1198 | |||
1199 | if (!ctx->is_active) { | ||
1200 | static const struct iwl_qos_info default_qos_data = { | ||
1201 | .def_qos_parm = { | ||
1202 | .ac[0] = { | ||
1203 | .cw_min = cpu_to_le16(3), | ||
1204 | .cw_max = cpu_to_le16(7), | ||
1205 | .aifsn = 2, | ||
1206 | .edca_txop = cpu_to_le16(1504), | ||
1207 | }, | ||
1208 | .ac[1] = { | ||
1209 | .cw_min = cpu_to_le16(7), | ||
1210 | .cw_max = cpu_to_le16(15), | ||
1211 | .aifsn = 2, | ||
1212 | .edca_txop = cpu_to_le16(3008), | ||
1213 | }, | ||
1214 | .ac[2] = { | ||
1215 | .cw_min = cpu_to_le16(15), | ||
1216 | .cw_max = cpu_to_le16(1023), | ||
1217 | .aifsn = 3, | ||
1218 | }, | ||
1219 | .ac[3] = { | ||
1220 | .cw_min = cpu_to_le16(15), | ||
1221 | .cw_max = cpu_to_le16(1023), | ||
1222 | .aifsn = 7, | ||
1223 | }, | ||
1224 | }, | ||
1225 | }; | ||
1226 | |||
1227 | ctx->is_active = true; | ||
1228 | ctx->qos_data = default_qos_data; | ||
1229 | ctx->staging.dev_type = RXON_DEV_TYPE_P2P; | ||
1230 | memcpy(ctx->staging.node_addr, | ||
1231 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
1232 | ETH_ALEN); | ||
1233 | memcpy(ctx->staging.bssid_addr, | ||
1234 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
1235 | ETH_ALEN); | ||
1236 | err = iwlagn_commit_rxon(priv, ctx); | ||
1237 | if (err) | ||
1238 | goto out; | ||
1239 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | | ||
1240 | RXON_FILTER_PROMISC_MSK | | ||
1241 | RXON_FILTER_CTL2HOST_MSK; | ||
1242 | |||
1243 | err = iwlagn_commit_rxon(priv, ctx); | ||
1244 | if (err) { | ||
1245 | iwlagn_disable_roc(priv); | ||
1246 | goto out; | ||
1247 | } | ||
1248 | priv->hw_roc_setup = true; | ||
1249 | } | ||
1250 | |||
1251 | err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); | ||
1252 | if (err) | ||
1253 | iwlagn_disable_roc(priv); | ||
1254 | |||
1255 | out: | ||
1256 | mutex_unlock(&priv->mutex); | ||
1257 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1258 | |||
1259 | return err; | ||
1260 | } | ||
1261 | |||
1262 | static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) | ||
1263 | { | ||
1264 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
1265 | |||
1266 | if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
1267 | return -EOPNOTSUPP; | ||
1268 | |||
1269 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1270 | mutex_lock(&priv->mutex); | ||
1271 | iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); | ||
1272 | iwlagn_disable_roc(priv); | ||
1273 | mutex_unlock(&priv->mutex); | ||
1274 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1275 | |||
1276 | return 0; | ||
1277 | } | ||
1278 | |||
1279 | static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, | 1118 | static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, |
1280 | struct ieee80211_vif *vif, | 1119 | struct ieee80211_vif *vif, |
1281 | enum ieee80211_rssi_event rssi_event) | 1120 | enum ieee80211_rssi_event rssi_event) |
@@ -1431,12 +1270,8 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, | |||
1431 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", | 1270 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", |
1432 | viftype, vif->addr); | 1271 | viftype, vif->addr); |
1433 | 1272 | ||
1434 | cancel_delayed_work_sync(&priv->hw_roc_disable_work); | ||
1435 | |||
1436 | mutex_lock(&priv->mutex); | 1273 | mutex_lock(&priv->mutex); |
1437 | 1274 | ||
1438 | iwlagn_disable_roc(priv); | ||
1439 | |||
1440 | if (!iwl_is_ready_rf(priv)) { | 1275 | if (!iwl_is_ready_rf(priv)) { |
1441 | IWL_WARN(priv, "Try to add interface when device not ready\n"); | 1276 | IWL_WARN(priv, "Try to add interface when device not ready\n"); |
1442 | err = -EINVAL; | 1277 | err = -EINVAL; |
@@ -1763,8 +1598,6 @@ struct ieee80211_ops iwlagn_hw_ops = { | |||
1763 | .channel_switch = iwlagn_mac_channel_switch, | 1598 | .channel_switch = iwlagn_mac_channel_switch, |
1764 | .flush = iwlagn_mac_flush, | 1599 | .flush = iwlagn_mac_flush, |
1765 | .tx_last_beacon = iwlagn_mac_tx_last_beacon, | 1600 | .tx_last_beacon = iwlagn_mac_tx_last_beacon, |
1766 | .remain_on_channel = iwlagn_mac_remain_on_channel, | ||
1767 | .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, | ||
1768 | .rssi_callback = iwlagn_mac_rssi_callback, | 1601 | .rssi_callback = iwlagn_mac_rssi_callback, |
1769 | .set_tim = iwlagn_mac_set_tim, | 1602 | .set_tim = iwlagn_mac_set_tim, |
1770 | }; | 1603 | }; |
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c index 3952ddf2ddb2..7aad766865cf 100644 --- a/drivers/net/wireless/iwlwifi/dvm/main.c +++ b/drivers/net/wireless/iwlwifi/dvm/main.c | |||
@@ -587,11 +587,6 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) | |||
587 | priv->contexts[IWL_RXON_CTX_PAN].interface_modes = | 587 | priv->contexts[IWL_RXON_CTX_PAN].interface_modes = |
588 | BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP); | 588 | BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP); |
589 | 589 | ||
590 | if (ucode_flags & IWL_UCODE_TLV_FLAGS_P2P) | ||
591 | priv->contexts[IWL_RXON_CTX_PAN].interface_modes |= | ||
592 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
593 | BIT(NL80211_IFTYPE_P2P_GO); | ||
594 | |||
595 | priv->contexts[IWL_RXON_CTX_PAN].ap_devtype = RXON_DEV_TYPE_CP; | 590 | priv->contexts[IWL_RXON_CTX_PAN].ap_devtype = RXON_DEV_TYPE_CP; |
596 | priv->contexts[IWL_RXON_CTX_PAN].station_devtype = RXON_DEV_TYPE_2STA; | 591 | priv->contexts[IWL_RXON_CTX_PAN].station_devtype = RXON_DEV_TYPE_2STA; |
597 | priv->contexts[IWL_RXON_CTX_PAN].unused_devtype = RXON_DEV_TYPE_P2P; | 592 | priv->contexts[IWL_RXON_CTX_PAN].unused_devtype = RXON_DEV_TYPE_P2P; |
@@ -758,7 +753,7 @@ int iwl_alive_start(struct iwl_priv *priv) | |||
758 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | 753 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); |
759 | if (ret) | 754 | if (ret) |
760 | return ret; | 755 | return ret; |
761 | } else { | 756 | } else if (priv->lib->bt_params) { |
762 | /* | 757 | /* |
763 | * default is 2-wire BT coexexistence support | 758 | * default is 2-wire BT coexexistence support |
764 | */ | 759 | */ |
@@ -854,14 +849,6 @@ void iwl_down(struct iwl_priv *priv) | |||
854 | 849 | ||
855 | iwl_scan_cancel_timeout(priv, 200); | 850 | iwl_scan_cancel_timeout(priv, 200); |
856 | 851 | ||
857 | /* | ||
858 | * If active, scanning won't cancel it, so say it expired. | ||
859 | * No race since we hold the mutex here and a new one | ||
860 | * can't come in at this time. | ||
861 | */ | ||
862 | if (priv->ucode_loaded && priv->cur_ucode != IWL_UCODE_INIT) | ||
863 | ieee80211_remain_on_channel_expired(priv->hw); | ||
864 | |||
865 | exit_pending = | 852 | exit_pending = |
866 | test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); | 853 | test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); |
867 | 854 | ||
@@ -1002,41 +989,6 @@ static void iwl_bg_restart(struct work_struct *data) | |||
1002 | } | 989 | } |
1003 | } | 990 | } |
1004 | 991 | ||
1005 | |||
1006 | |||
1007 | |||
1008 | void iwlagn_disable_roc(struct iwl_priv *priv) | ||
1009 | { | ||
1010 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; | ||
1011 | |||
1012 | lockdep_assert_held(&priv->mutex); | ||
1013 | |||
1014 | if (!priv->hw_roc_setup) | ||
1015 | return; | ||
1016 | |||
1017 | ctx->staging.dev_type = RXON_DEV_TYPE_P2P; | ||
1018 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
1019 | |||
1020 | priv->hw_roc_channel = NULL; | ||
1021 | |||
1022 | memset(ctx->staging.node_addr, 0, ETH_ALEN); | ||
1023 | |||
1024 | iwlagn_commit_rxon(priv, ctx); | ||
1025 | |||
1026 | ctx->is_active = false; | ||
1027 | priv->hw_roc_setup = false; | ||
1028 | } | ||
1029 | |||
1030 | static void iwlagn_disable_roc_work(struct work_struct *work) | ||
1031 | { | ||
1032 | struct iwl_priv *priv = container_of(work, struct iwl_priv, | ||
1033 | hw_roc_disable_work.work); | ||
1034 | |||
1035 | mutex_lock(&priv->mutex); | ||
1036 | iwlagn_disable_roc(priv); | ||
1037 | mutex_unlock(&priv->mutex); | ||
1038 | } | ||
1039 | |||
1040 | /***************************************************************************** | 992 | /***************************************************************************** |
1041 | * | 993 | * |
1042 | * driver setup and teardown | 994 | * driver setup and teardown |
@@ -1053,8 +1005,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) | |||
1053 | INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); | 1005 | INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); |
1054 | INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); | 1006 | INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); |
1055 | INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); | 1007 | INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); |
1056 | INIT_DELAYED_WORK(&priv->hw_roc_disable_work, | ||
1057 | iwlagn_disable_roc_work); | ||
1058 | 1008 | ||
1059 | iwl_setup_scan_deferred_work(priv); | 1009 | iwl_setup_scan_deferred_work(priv); |
1060 | 1010 | ||
@@ -1082,7 +1032,6 @@ void iwl_cancel_deferred_work(struct iwl_priv *priv) | |||
1082 | 1032 | ||
1083 | cancel_work_sync(&priv->bt_full_concurrency); | 1033 | cancel_work_sync(&priv->bt_full_concurrency); |
1084 | cancel_work_sync(&priv->bt_runtime_config); | 1034 | cancel_work_sync(&priv->bt_runtime_config); |
1085 | cancel_delayed_work_sync(&priv->hw_roc_disable_work); | ||
1086 | 1035 | ||
1087 | del_timer_sync(&priv->statistics_periodic); | 1036 | del_timer_sync(&priv->statistics_periodic); |
1088 | del_timer_sync(&priv->ucode_trace); | 1037 | del_timer_sync(&priv->ucode_trace); |
@@ -1169,12 +1118,6 @@ static void iwl_option_config(struct iwl_priv *priv) | |||
1169 | #else | 1118 | #else |
1170 | IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TRACING disabled\n"); | 1119 | IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TRACING disabled\n"); |
1171 | #endif | 1120 | #endif |
1172 | |||
1173 | #ifdef CONFIG_IWLWIFI_P2P | ||
1174 | IWL_INFO(priv, "CONFIG_IWLWIFI_P2P enabled\n"); | ||
1175 | #else | ||
1176 | IWL_INFO(priv, "CONFIG_IWLWIFI_P2P disabled\n"); | ||
1177 | #endif | ||
1178 | } | 1121 | } |
1179 | 1122 | ||
1180 | static int iwl_eeprom_init_hw_params(struct iwl_priv *priv) | 1123 | static int iwl_eeprom_init_hw_params(struct iwl_priv *priv) |
@@ -1315,10 +1258,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, | |||
1315 | 1258 | ||
1316 | ucode_flags = fw->ucode_capa.flags; | 1259 | ucode_flags = fw->ucode_capa.flags; |
1317 | 1260 | ||
1318 | #ifndef CONFIG_IWLWIFI_P2P | ||
1319 | ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; | ||
1320 | #endif | ||
1321 | |||
1322 | if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { | 1261 | if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { |
1323 | priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; | 1262 | priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; |
1324 | trans_cfg.cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; | 1263 | trans_cfg.cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; |
@@ -1413,7 +1352,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, | |||
1413 | * if not PAN, then don't support P2P -- might be a uCode | 1352 | * if not PAN, then don't support P2P -- might be a uCode |
1414 | * packaging bug or due to the eeprom check above | 1353 | * packaging bug or due to the eeprom check above |
1415 | */ | 1354 | */ |
1416 | ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; | ||
1417 | priv->sta_key_max_num = STA_KEY_MAX_NUM; | 1355 | priv->sta_key_max_num = STA_KEY_MAX_NUM; |
1418 | trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; | 1356 | trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; |
1419 | 1357 | ||
diff --git a/drivers/net/wireless/iwlwifi/dvm/rs.c b/drivers/net/wireless/iwlwifi/dvm/rs.c index 91eb09b9b56f..b647e506564c 100644 --- a/drivers/net/wireless/iwlwifi/dvm/rs.c +++ b/drivers/net/wireless/iwlwifi/dvm/rs.c | |||
@@ -2826,9 +2826,6 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i | |||
2826 | 2826 | ||
2827 | lq_sta->flush_timer = 0; | 2827 | lq_sta->flush_timer = 0; |
2828 | lq_sta->supp_rates = sta->supp_rates[sband->band]; | 2828 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
2829 | for (j = 0; j < LQ_SIZE; j++) | ||
2830 | for (i = 0; i < IWL_RATE_COUNT; i++) | ||
2831 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); | ||
2832 | 2829 | ||
2833 | IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init for station %d ***\n", | 2830 | IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init for station %d ***\n", |
2834 | sta_id); | 2831 | sta_id); |
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c index cd1ad0019185..d7ce2f12a907 100644 --- a/drivers/net/wireless/iwlwifi/dvm/rxon.c +++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c | |||
@@ -564,11 +564,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) | |||
564 | cmd.slots[0].type = 0; /* BSS */ | 564 | cmd.slots[0].type = 0; /* BSS */ |
565 | cmd.slots[1].type = 1; /* PAN */ | 565 | cmd.slots[1].type = 1; /* PAN */ |
566 | 566 | ||
567 | if (priv->hw_roc_setup) { | 567 | if (ctx_bss->vif && ctx_pan->vif) { |
568 | /* both contexts must be used for this to happen */ | ||
569 | slot1 = IWL_MIN_SLOT_TIME; | ||
570 | slot0 = 3000; | ||
571 | } else if (ctx_bss->vif && ctx_pan->vif) { | ||
572 | int bcnint = ctx_pan->beacon_int; | 568 | int bcnint = ctx_pan->beacon_int; |
573 | int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1; | 569 | int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1; |
574 | 570 | ||
diff --git a/drivers/net/wireless/iwlwifi/dvm/scan.c b/drivers/net/wireless/iwlwifi/dvm/scan.c index 8c686a5b90ac..35e0ee8b4e5b 100644 --- a/drivers/net/wireless/iwlwifi/dvm/scan.c +++ b/drivers/net/wireless/iwlwifi/dvm/scan.c | |||
@@ -100,9 +100,6 @@ static void iwl_complete_scan(struct iwl_priv *priv, bool aborted) | |||
100 | ieee80211_scan_completed(priv->hw, aborted); | 100 | ieee80211_scan_completed(priv->hw, aborted); |
101 | } | 101 | } |
102 | 102 | ||
103 | if (priv->scan_type == IWL_SCAN_ROC) | ||
104 | iwl_scan_roc_expired(priv); | ||
105 | |||
106 | priv->scan_type = IWL_SCAN_NORMAL; | 103 | priv->scan_type = IWL_SCAN_NORMAL; |
107 | priv->scan_vif = NULL; | 104 | priv->scan_vif = NULL; |
108 | priv->scan_request = NULL; | 105 | priv->scan_request = NULL; |
@@ -130,9 +127,6 @@ static void iwl_process_scan_complete(struct iwl_priv *priv) | |||
130 | goto out_settings; | 127 | goto out_settings; |
131 | } | 128 | } |
132 | 129 | ||
133 | if (priv->scan_type == IWL_SCAN_ROC) | ||
134 | iwl_scan_roc_expired(priv); | ||
135 | |||
136 | if (priv->scan_type != IWL_SCAN_NORMAL && !aborted) { | 130 | if (priv->scan_type != IWL_SCAN_NORMAL && !aborted) { |
137 | int err; | 131 | int err; |
138 | 132 | ||
@@ -284,12 +278,6 @@ static int iwl_rx_scan_start_notif(struct iwl_priv *priv, | |||
284 | le32_to_cpu(notif->tsf_low), | 278 | le32_to_cpu(notif->tsf_low), |
285 | notif->status, notif->beacon_timer); | 279 | notif->status, notif->beacon_timer); |
286 | 280 | ||
287 | if (priv->scan_type == IWL_SCAN_ROC && | ||
288 | !priv->hw_roc_start_notified) { | ||
289 | ieee80211_ready_on_channel(priv->hw); | ||
290 | priv->hw_roc_start_notified = true; | ||
291 | } | ||
292 | |||
293 | return 0; | 281 | return 0; |
294 | } | 282 | } |
295 | 283 | ||
@@ -697,8 +685,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
697 | scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; | 685 | scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; |
698 | scan->quiet_time = IWL_ACTIVE_QUIET_TIME; | 686 | scan->quiet_time = IWL_ACTIVE_QUIET_TIME; |
699 | 687 | ||
700 | if (priv->scan_type != IWL_SCAN_ROC && | 688 | if (iwl_is_any_associated(priv)) { |
701 | iwl_is_any_associated(priv)) { | ||
702 | u16 interval = 0; | 689 | u16 interval = 0; |
703 | u32 extra; | 690 | u32 extra; |
704 | u32 suspend_time = 100; | 691 | u32 suspend_time = 100; |
@@ -706,9 +693,6 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
706 | 693 | ||
707 | IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); | 694 | IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); |
708 | switch (priv->scan_type) { | 695 | switch (priv->scan_type) { |
709 | case IWL_SCAN_ROC: | ||
710 | WARN_ON(1); | ||
711 | break; | ||
712 | case IWL_SCAN_RADIO_RESET: | 696 | case IWL_SCAN_RADIO_RESET: |
713 | interval = 0; | 697 | interval = 0; |
714 | break; | 698 | break; |
@@ -728,11 +712,6 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
728 | scan->suspend_time = cpu_to_le32(scan_suspend_time); | 712 | scan->suspend_time = cpu_to_le32(scan_suspend_time); |
729 | IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", | 713 | IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", |
730 | scan_suspend_time, interval); | 714 | scan_suspend_time, interval); |
731 | } else if (priv->scan_type == IWL_SCAN_ROC) { | ||
732 | scan->suspend_time = 0; | ||
733 | scan->max_out_time = 0; | ||
734 | scan->quiet_time = 0; | ||
735 | scan->quiet_plcp_th = 0; | ||
736 | } | 715 | } |
737 | 716 | ||
738 | switch (priv->scan_type) { | 717 | switch (priv->scan_type) { |
@@ -774,9 +753,6 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
774 | } else | 753 | } else |
775 | IWL_DEBUG_SCAN(priv, "Start passive scan.\n"); | 754 | IWL_DEBUG_SCAN(priv, "Start passive scan.\n"); |
776 | break; | 755 | break; |
777 | case IWL_SCAN_ROC: | ||
778 | IWL_DEBUG_SCAN(priv, "Start ROC scan.\n"); | ||
779 | break; | ||
780 | } | 756 | } |
781 | 757 | ||
782 | scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; | 758 | scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; |
@@ -898,7 +874,6 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
898 | scan_cmd_size - sizeof(*scan)); | 874 | scan_cmd_size - sizeof(*scan)); |
899 | break; | 875 | break; |
900 | case IWL_SCAN_RADIO_RESET: | 876 | case IWL_SCAN_RADIO_RESET: |
901 | case IWL_SCAN_ROC: | ||
902 | /* use bcast addr, will not be transmitted but must be valid */ | 877 | /* use bcast addr, will not be transmitted but must be valid */ |
903 | cmd_len = iwl_fill_probe_req( | 878 | cmd_len = iwl_fill_probe_req( |
904 | (struct ieee80211_mgmt *)scan->data, | 879 | (struct ieee80211_mgmt *)scan->data, |
@@ -926,46 +901,6 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
926 | is_active, n_probes, | 901 | is_active, n_probes, |
927 | (void *)&scan->data[cmd_len]); | 902 | (void *)&scan->data[cmd_len]); |
928 | break; | 903 | break; |
929 | case IWL_SCAN_ROC: { | ||
930 | struct iwl_scan_channel *scan_ch; | ||
931 | int n_chan, i; | ||
932 | u16 dwell; | ||
933 | |||
934 | dwell = iwl_limit_dwell(priv, priv->hw_roc_duration); | ||
935 | n_chan = DIV_ROUND_UP(priv->hw_roc_duration, dwell); | ||
936 | |||
937 | scan->channel_count = n_chan; | ||
938 | |||
939 | scan_ch = (void *)&scan->data[cmd_len]; | ||
940 | |||
941 | for (i = 0; i < n_chan; i++) { | ||
942 | scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; | ||
943 | scan_ch->channel = | ||
944 | cpu_to_le16(priv->hw_roc_channel->hw_value); | ||
945 | |||
946 | if (i == n_chan - 1) | ||
947 | dwell = priv->hw_roc_duration - i * dwell; | ||
948 | |||
949 | scan_ch->active_dwell = | ||
950 | scan_ch->passive_dwell = cpu_to_le16(dwell); | ||
951 | |||
952 | /* Set txpower levels to defaults */ | ||
953 | scan_ch->dsp_atten = 110; | ||
954 | |||
955 | /* NOTE: if we were doing 6Mb OFDM for scans we'd use | ||
956 | * power level: | ||
957 | * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; | ||
958 | */ | ||
959 | if (priv->hw_roc_channel->band == IEEE80211_BAND_5GHZ) | ||
960 | scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; | ||
961 | else | ||
962 | scan_ch->tx_gain = ((1 << 5) | (5 << 3)); | ||
963 | |||
964 | scan_ch++; | ||
965 | } | ||
966 | } | ||
967 | |||
968 | break; | ||
969 | } | 904 | } |
970 | 905 | ||
971 | if (scan->channel_count == 0) { | 906 | if (scan->channel_count == 0) { |
@@ -1035,7 +970,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, | |||
1035 | 970 | ||
1036 | IWL_DEBUG_SCAN(priv, "Starting %sscan...\n", | 971 | IWL_DEBUG_SCAN(priv, "Starting %sscan...\n", |
1037 | scan_type == IWL_SCAN_NORMAL ? "" : | 972 | scan_type == IWL_SCAN_NORMAL ? "" : |
1038 | scan_type == IWL_SCAN_ROC ? "remain-on-channel " : | ||
1039 | "internal short "); | 973 | "internal short "); |
1040 | 974 | ||
1041 | set_bit(STATUS_SCANNING, &priv->status); | 975 | set_bit(STATUS_SCANNING, &priv->status); |
@@ -1149,40 +1083,3 @@ void iwl_cancel_scan_deferred_work(struct iwl_priv *priv) | |||
1149 | mutex_unlock(&priv->mutex); | 1083 | mutex_unlock(&priv->mutex); |
1150 | } | 1084 | } |
1151 | } | 1085 | } |
1152 | |||
1153 | void iwl_scan_roc_expired(struct iwl_priv *priv) | ||
1154 | { | ||
1155 | /* | ||
1156 | * The status bit should be set here, to prevent a race | ||
1157 | * where the atomic_read returns 1, but before the execution continues | ||
1158 | * iwl_scan_offchannel_skb_status() checks if the status bit is set | ||
1159 | */ | ||
1160 | set_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status); | ||
1161 | |||
1162 | if (atomic_read(&priv->num_aux_in_flight) == 0) { | ||
1163 | ieee80211_remain_on_channel_expired(priv->hw); | ||
1164 | priv->hw_roc_channel = NULL; | ||
1165 | schedule_delayed_work(&priv->hw_roc_disable_work, | ||
1166 | 10 * HZ); | ||
1167 | |||
1168 | clear_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status); | ||
1169 | } else { | ||
1170 | IWL_DEBUG_SCAN(priv, "ROC done with %d frames in aux\n", | ||
1171 | atomic_read(&priv->num_aux_in_flight)); | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | void iwl_scan_offchannel_skb(struct iwl_priv *priv) | ||
1176 | { | ||
1177 | WARN_ON(!priv->hw_roc_start_notified); | ||
1178 | atomic_inc(&priv->num_aux_in_flight); | ||
1179 | } | ||
1180 | |||
1181 | void iwl_scan_offchannel_skb_status(struct iwl_priv *priv) | ||
1182 | { | ||
1183 | if (atomic_dec_return(&priv->num_aux_in_flight) == 0 && | ||
1184 | test_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status)) { | ||
1185 | IWL_DEBUG_SCAN(priv, "0 aux frames. Calling ROC expired\n"); | ||
1186 | iwl_scan_roc_expired(priv); | ||
1187 | } | ||
1188 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c index f364583b1535..da442b81370a 100644 --- a/drivers/net/wireless/iwlwifi/dvm/tx.c +++ b/drivers/net/wireless/iwlwifi/dvm/tx.c | |||
@@ -478,9 +478,6 @@ int iwlagn_tx_skb(struct iwl_priv *priv, | |||
478 | if (sta_priv && sta_priv->client && !is_agg) | 478 | if (sta_priv && sta_priv->client && !is_agg) |
479 | atomic_inc(&sta_priv->pending_frames); | 479 | atomic_inc(&sta_priv->pending_frames); |
480 | 480 | ||
481 | if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) | ||
482 | iwl_scan_offchannel_skb(priv); | ||
483 | |||
484 | return 0; | 481 | return 0; |
485 | 482 | ||
486 | drop_unlock_sta: | 483 | drop_unlock_sta: |
@@ -1158,7 +1155,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, | |||
1158 | struct sk_buff *skb; | 1155 | struct sk_buff *skb; |
1159 | struct iwl_rxon_context *ctx; | 1156 | struct iwl_rxon_context *ctx; |
1160 | bool is_agg = (txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); | 1157 | bool is_agg = (txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); |
1161 | bool is_offchannel_skb; | ||
1162 | 1158 | ||
1163 | tid = (tx_resp->ra_tid & IWLAGN_TX_RES_TID_MSK) >> | 1159 | tid = (tx_resp->ra_tid & IWLAGN_TX_RES_TID_MSK) >> |
1164 | IWLAGN_TX_RES_TID_POS; | 1160 | IWLAGN_TX_RES_TID_POS; |
@@ -1178,8 +1174,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, | |||
1178 | 1174 | ||
1179 | __skb_queue_head_init(&skbs); | 1175 | __skb_queue_head_init(&skbs); |
1180 | 1176 | ||
1181 | is_offchannel_skb = false; | ||
1182 | |||
1183 | if (tx_resp->frame_count == 1) { | 1177 | if (tx_resp->frame_count == 1) { |
1184 | u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl); | 1178 | u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl); |
1185 | next_reclaimed = IEEE80211_SEQ_TO_SN(next_reclaimed + 0x10); | 1179 | next_reclaimed = IEEE80211_SEQ_TO_SN(next_reclaimed + 0x10); |
@@ -1256,8 +1250,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, | |||
1256 | if (!is_agg) | 1250 | if (!is_agg) |
1257 | iwlagn_non_agg_tx_status(priv, ctx, hdr->addr1); | 1251 | iwlagn_non_agg_tx_status(priv, ctx, hdr->addr1); |
1258 | 1252 | ||
1259 | is_offchannel_skb = | ||
1260 | (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN); | ||
1261 | freed++; | 1253 | freed++; |
1262 | } | 1254 | } |
1263 | 1255 | ||
@@ -1271,14 +1263,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, | |||
1271 | if (!is_agg && freed != 1) | 1263 | if (!is_agg && freed != 1) |
1272 | IWL_ERR(priv, "Q: %d, freed %d\n", txq_id, freed); | 1264 | IWL_ERR(priv, "Q: %d, freed %d\n", txq_id, freed); |
1273 | 1265 | ||
1274 | /* | ||
1275 | * An offchannel frame can be send only on the AUX queue, where | ||
1276 | * there is no aggregation (and reordering) so it only is single | ||
1277 | * skb is expected to be processed. | ||
1278 | */ | ||
1279 | if (is_offchannel_skb && freed != 1) | ||
1280 | IWL_ERR(priv, "OFFCHANNEL SKB freed %d\n", freed); | ||
1281 | |||
1282 | IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x)\n", txq_id, | 1266 | IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x)\n", txq_id, |
1283 | iwl_get_tx_fail_reason(status), status); | 1267 | iwl_get_tx_fail_reason(status), status); |
1284 | 1268 | ||
@@ -1298,9 +1282,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, | |||
1298 | ieee80211_tx_status_ni(priv->hw, skb); | 1282 | ieee80211_tx_status_ni(priv->hw, skb); |
1299 | } | 1283 | } |
1300 | 1284 | ||
1301 | if (is_offchannel_skb) | ||
1302 | iwl_scan_offchannel_skb_status(priv); | ||
1303 | |||
1304 | return 0; | 1285 | return 0; |
1305 | } | 1286 | } |
1306 | 1287 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c index 22b7fa5b971a..76e14c046d94 100644 --- a/drivers/net/wireless/iwlwifi/iwl-7000.c +++ b/drivers/net/wireless/iwlwifi/iwl-7000.c | |||
@@ -99,6 +99,7 @@ static const struct iwl_base_params iwl7000_base_params = { | |||
99 | .wd_timeout = IWL_LONG_WD_TIMEOUT, | 99 | .wd_timeout = IWL_LONG_WD_TIMEOUT, |
100 | .max_event_log_size = 512, | 100 | .max_event_log_size = 512, |
101 | .shadow_reg_enable = true, | 101 | .shadow_reg_enable = true, |
102 | .pcie_l1_allowed = true, | ||
102 | }; | 103 | }; |
103 | 104 | ||
104 | static const struct iwl_ht_params iwl7000_ht_params = { | 105 | static const struct iwl_ht_params iwl7000_ht_params = { |
@@ -126,6 +127,16 @@ const struct iwl_cfg iwl7260_2ac_cfg = { | |||
126 | .nvm_calib_ver = IWL7260_TX_POWER_VERSION, | 127 | .nvm_calib_ver = IWL7260_TX_POWER_VERSION, |
127 | }; | 128 | }; |
128 | 129 | ||
130 | const struct iwl_cfg iwl7260_2ac_cfg_high_temp = { | ||
131 | .name = "Intel(R) Dual Band Wireless AC 7260", | ||
132 | .fw_name_pre = IWL7260_FW_PRE, | ||
133 | IWL_DEVICE_7000, | ||
134 | .ht_params = &iwl7000_ht_params, | ||
135 | .nvm_ver = IWL7260_NVM_VERSION, | ||
136 | .nvm_calib_ver = IWL7260_TX_POWER_VERSION, | ||
137 | .high_temp = true, | ||
138 | }; | ||
139 | |||
129 | const struct iwl_cfg iwl7260_2n_cfg = { | 140 | const struct iwl_cfg iwl7260_2n_cfg = { |
130 | .name = "Intel(R) Dual Band Wireless N 7260", | 141 | .name = "Intel(R) Dual Band Wireless N 7260", |
131 | .fw_name_pre = IWL7260_FW_PRE, | 142 | .fw_name_pre = IWL7260_FW_PRE, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h index 83b9ff6ff3ad..e4d370bff306 100644 --- a/drivers/net/wireless/iwlwifi/iwl-config.h +++ b/drivers/net/wireless/iwlwifi/iwl-config.h | |||
@@ -152,6 +152,7 @@ struct iwl_base_params { | |||
152 | unsigned int wd_timeout; | 152 | unsigned int wd_timeout; |
153 | u32 max_event_log_size; | 153 | u32 max_event_log_size; |
154 | const bool shadow_reg_enable; | 154 | const bool shadow_reg_enable; |
155 | const bool pcie_l1_allowed; | ||
155 | }; | 156 | }; |
156 | 157 | ||
157 | /* | 158 | /* |
@@ -205,6 +206,7 @@ struct iwl_eeprom_params { | |||
205 | * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) | 206 | * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) |
206 | * @rx_with_siso_diversity: 1x1 device with rx antenna diversity | 207 | * @rx_with_siso_diversity: 1x1 device with rx antenna diversity |
207 | * @internal_wimax_coex: internal wifi/wimax combo device | 208 | * @internal_wimax_coex: internal wifi/wimax combo device |
209 | * @high_temp: Is this NIC is designated to be in high temperature. | ||
208 | * | 210 | * |
209 | * We enable the driver to be backward compatible wrt. hardware features. | 211 | * We enable the driver to be backward compatible wrt. hardware features. |
210 | * API differences in uCode shouldn't be handled here but through TLVs | 212 | * API differences in uCode shouldn't be handled here but through TLVs |
@@ -233,6 +235,7 @@ struct iwl_cfg { | |||
233 | enum iwl_led_mode led_mode; | 235 | enum iwl_led_mode led_mode; |
234 | const bool rx_with_siso_diversity; | 236 | const bool rx_with_siso_diversity; |
235 | const bool internal_wimax_coex; | 237 | const bool internal_wimax_coex; |
238 | bool high_temp; | ||
236 | }; | 239 | }; |
237 | 240 | ||
238 | /* | 241 | /* |
@@ -283,6 +286,7 @@ extern const struct iwl_cfg iwl135_bgn_cfg; | |||
283 | #endif /* CONFIG_IWLDVM */ | 286 | #endif /* CONFIG_IWLDVM */ |
284 | #if IS_ENABLED(CONFIG_IWLMVM) | 287 | #if IS_ENABLED(CONFIG_IWLMVM) |
285 | extern const struct iwl_cfg iwl7260_2ac_cfg; | 288 | extern const struct iwl_cfg iwl7260_2ac_cfg; |
289 | extern const struct iwl_cfg iwl7260_2ac_cfg_high_temp; | ||
286 | extern const struct iwl_cfg iwl7260_2n_cfg; | 290 | extern const struct iwl_cfg iwl7260_2n_cfg; |
287 | extern const struct iwl_cfg iwl7260_n_cfg; | 291 | extern const struct iwl_cfg iwl7260_n_cfg; |
288 | extern const struct iwl_cfg iwl3160_2ac_cfg; | 292 | extern const struct iwl_cfg iwl3160_2ac_cfg; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 7edb8519c8a4..b2bb32a781dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h | |||
@@ -145,6 +145,7 @@ do { \ | |||
145 | #define IWL_DL_RX 0x01000000 | 145 | #define IWL_DL_RX 0x01000000 |
146 | #define IWL_DL_ISR 0x02000000 | 146 | #define IWL_DL_ISR 0x02000000 |
147 | #define IWL_DL_HT 0x04000000 | 147 | #define IWL_DL_HT 0x04000000 |
148 | #define IWL_DL_EXTERNAL 0x08000000 | ||
148 | /* 0xF0000000 - 0x10000000 */ | 149 | /* 0xF0000000 - 0x10000000 */ |
149 | #define IWL_DL_11H 0x10000000 | 150 | #define IWL_DL_11H 0x10000000 |
150 | #define IWL_DL_STATS 0x20000000 | 151 | #define IWL_DL_STATS 0x20000000 |
@@ -153,6 +154,7 @@ do { \ | |||
153 | 154 | ||
154 | #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) | 155 | #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) |
155 | #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) | 156 | #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) |
157 | #define IWL_DEBUG_EXTERNAL(p, f, a...) IWL_DEBUG(p, IWL_DL_EXTERNAL, f, ## a) | ||
156 | #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) | 158 | #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) |
157 | #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) | 159 | #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) |
158 | #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) | 160 | #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index d0162d426f88..99e1da3123c9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c | |||
@@ -843,7 +843,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context) | |||
843 | int i; | 843 | int i; |
844 | bool load_module = false; | 844 | bool load_module = false; |
845 | 845 | ||
846 | fw->ucode_capa.max_probe_length = 200; | 846 | fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH; |
847 | fw->ucode_capa.standard_phy_calibration_size = | 847 | fw->ucode_capa.standard_phy_calibration_size = |
848 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; | 848 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
849 | 849 | ||
@@ -1032,8 +1032,10 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, | |||
1032 | int ret; | 1032 | int ret; |
1033 | 1033 | ||
1034 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); | 1034 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); |
1035 | if (!drv) | 1035 | if (!drv) { |
1036 | return NULL; | 1036 | ret = -ENOMEM; |
1037 | goto err; | ||
1038 | } | ||
1037 | 1039 | ||
1038 | drv->trans = trans; | 1040 | drv->trans = trans; |
1039 | drv->dev = trans->dev; | 1041 | drv->dev = trans->dev; |
@@ -1078,7 +1080,7 @@ err_free_dbgfs: | |||
1078 | err_free_drv: | 1080 | err_free_drv: |
1079 | #endif | 1081 | #endif |
1080 | kfree(drv); | 1082 | kfree(drv); |
1081 | 1083 | err: | |
1082 | return ERR_PTR(ret); | 1084 | return ERR_PTR(ret); |
1083 | } | 1085 | } |
1084 | 1086 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index f844d5c748c0..a1223680bc70 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h | |||
@@ -74,13 +74,24 @@ | |||
74 | * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). | 74 | * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). |
75 | * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. | 75 | * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. |
76 | * @IWL_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS | 76 | * @IWL_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS |
77 | * @IWL_UCODE_TLV_FLAGS_UAPSD: This uCode image supports uAPSD | ||
78 | * @IWL_UCODE_TLV_FLAGS_RX_ENERGY_API: supports rx signal strength api | ||
79 | * @IWL_UCODE_TLV_FLAGS_TIME_EVENT_API_V2: using the new time event API. | ||
80 | * @IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS: D3 image supports up to six | ||
81 | * (rather than two) IPv6 addresses | ||
82 | * @IWL_UCODE_TLV_FLAGS_BF_UPDATED: new beacon filtering API | ||
77 | */ | 83 | */ |
78 | enum iwl_ucode_tlv_flag { | 84 | enum iwl_ucode_tlv_flag { |
79 | IWL_UCODE_TLV_FLAGS_PAN = BIT(0), | 85 | IWL_UCODE_TLV_FLAGS_PAN = BIT(0), |
80 | IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), | 86 | IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), |
81 | IWL_UCODE_TLV_FLAGS_MFP = BIT(2), | 87 | IWL_UCODE_TLV_FLAGS_MFP = BIT(2), |
82 | IWL_UCODE_TLV_FLAGS_P2P = BIT(3), | 88 | IWL_UCODE_TLV_FLAGS_P2P = BIT(3), |
83 | IWL_UCODE_TLV_FLAGS_DW_BC_TABLE = BIT(4), | 89 | IWL_UCODE_TLV_FLAGS_DW_BC_TABLE = BIT(4), |
90 | IWL_UCODE_TLV_FLAGS_UAPSD = BIT(6), | ||
91 | IWL_UCODE_TLV_FLAGS_RX_ENERGY_API = BIT(8), | ||
92 | IWL_UCODE_TLV_FLAGS_TIME_EVENT_API_V2 = BIT(9), | ||
93 | IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS = BIT(10), | ||
94 | IWL_UCODE_TLV_FLAGS_BF_UPDATED = BIT(11), | ||
84 | }; | 95 | }; |
85 | 96 | ||
86 | /* The default calibrate table size if not specified by firmware file */ | 97 | /* The default calibrate table size if not specified by firmware file */ |
@@ -88,6 +99,9 @@ enum iwl_ucode_tlv_flag { | |||
88 | #define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE 19 | 99 | #define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE 19 |
89 | #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE 253 | 100 | #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE 253 |
90 | 101 | ||
102 | /* The default max probe length if not specified by the firmware file */ | ||
103 | #define IWL_DEFAULT_MAX_PROBE_LENGTH 200 | ||
104 | |||
91 | /** | 105 | /** |
92 | * enum iwl_ucode_type | 106 | * enum iwl_ucode_type |
93 | * | 107 | * |
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index 305c81f2c2b4..dfa4d2e3aaa2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include "iwl-io.h" | 33 | #include "iwl-io.h" |
34 | #include "iwl-csr.h" | 34 | #include "iwl-csr.h" |
35 | #include "iwl-debug.h" | 35 | #include "iwl-debug.h" |
36 | #include "iwl-fh.h" | ||
37 | #include "iwl-csr.h" | ||
36 | 38 | ||
37 | #define IWL_POLL_INTERVAL 10 /* microseconds */ | 39 | #define IWL_POLL_INTERVAL 10 /* microseconds */ |
38 | 40 | ||
@@ -166,3 +168,68 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask) | |||
166 | } | 168 | } |
167 | } | 169 | } |
168 | IWL_EXPORT_SYMBOL(iwl_clear_bits_prph); | 170 | IWL_EXPORT_SYMBOL(iwl_clear_bits_prph); |
171 | |||
172 | static const char *get_fh_string(int cmd) | ||
173 | { | ||
174 | #define IWL_CMD(x) case x: return #x | ||
175 | switch (cmd) { | ||
176 | IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); | ||
177 | IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); | ||
178 | IWL_CMD(FH_RSCSR_CHNL0_WPTR); | ||
179 | IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); | ||
180 | IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); | ||
181 | IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG); | ||
182 | IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); | ||
183 | IWL_CMD(FH_TSSR_TX_STATUS_REG); | ||
184 | IWL_CMD(FH_TSSR_TX_ERROR_REG); | ||
185 | default: | ||
186 | return "UNKNOWN"; | ||
187 | } | ||
188 | #undef IWL_CMD | ||
189 | } | ||
190 | |||
191 | int iwl_dump_fh(struct iwl_trans *trans, char **buf) | ||
192 | { | ||
193 | int i; | ||
194 | static const u32 fh_tbl[] = { | ||
195 | FH_RSCSR_CHNL0_STTS_WPTR_REG, | ||
196 | FH_RSCSR_CHNL0_RBDCB_BASE_REG, | ||
197 | FH_RSCSR_CHNL0_WPTR, | ||
198 | FH_MEM_RCSR_CHNL0_CONFIG_REG, | ||
199 | FH_MEM_RSSR_SHARED_CTRL_REG, | ||
200 | FH_MEM_RSSR_RX_STATUS_REG, | ||
201 | FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, | ||
202 | FH_TSSR_TX_STATUS_REG, | ||
203 | FH_TSSR_TX_ERROR_REG | ||
204 | }; | ||
205 | |||
206 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
207 | if (buf) { | ||
208 | int pos = 0; | ||
209 | size_t bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; | ||
210 | |||
211 | *buf = kmalloc(bufsz, GFP_KERNEL); | ||
212 | if (!*buf) | ||
213 | return -ENOMEM; | ||
214 | |||
215 | pos += scnprintf(*buf + pos, bufsz - pos, | ||
216 | "FH register values:\n"); | ||
217 | |||
218 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) | ||
219 | pos += scnprintf(*buf + pos, bufsz - pos, | ||
220 | " %34s: 0X%08x\n", | ||
221 | get_fh_string(fh_tbl[i]), | ||
222 | iwl_read_direct32(trans, fh_tbl[i])); | ||
223 | |||
224 | return pos; | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | IWL_ERR(trans, "FH register values:\n"); | ||
229 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) | ||
230 | IWL_ERR(trans, " %34s: 0X%08x\n", | ||
231 | get_fh_string(fh_tbl[i]), | ||
232 | iwl_read_direct32(trans, fh_tbl[i])); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index fd9f5b97fff3..63d10ec08dbc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h | |||
@@ -77,4 +77,7 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs, | |||
77 | u32 bits, u32 mask); | 77 | u32 bits, u32 mask); |
78 | void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); | 78 | void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); |
79 | 79 | ||
80 | /* Error handling */ | ||
81 | int iwl_dump_fh(struct iwl_trans *trans, char **buf); | ||
82 | |||
80 | #endif | 83 | #endif |
diff --git a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c index acd2665afb8c..b76a9a8fc0b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c +++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c | |||
@@ -118,6 +118,7 @@ static const u8 iwl_nvm_channels[] = { | |||
118 | #define LAST_2GHZ_HT_PLUS 9 | 118 | #define LAST_2GHZ_HT_PLUS 9 |
119 | #define LAST_5GHZ_HT 161 | 119 | #define LAST_5GHZ_HT 161 |
120 | 120 | ||
121 | #define DEFAULT_MAX_TX_POWER 16 | ||
121 | 122 | ||
122 | /* rate data (static) */ | 123 | /* rate data (static) */ |
123 | static struct ieee80211_rate iwl_cfg80211_rates[] = { | 124 | static struct ieee80211_rate iwl_cfg80211_rates[] = { |
@@ -232,8 +233,11 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, | |||
232 | 233 | ||
233 | /* Initialize regulatory-based run-time data */ | 234 | /* Initialize regulatory-based run-time data */ |
234 | 235 | ||
235 | /* TODO: read the real value from the NVM */ | 236 | /* |
236 | channel->max_power = 0; | 237 | * Default value - highest tx power value. max_power |
238 | * is not used in mvm, and is used for backwards compatibility | ||
239 | */ | ||
240 | channel->max_power = DEFAULT_MAX_TX_POWER; | ||
237 | is_5ghz = channel->band == IEEE80211_BAND_5GHZ; | 241 | is_5ghz = channel->band == IEEE80211_BAND_5GHZ; |
238 | IWL_DEBUG_EEPROM(dev, | 242 | IWL_DEBUG_EEPROM(dev, |
239 | "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", | 243 | "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", |
diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index 98c7aa7346da..976448a57d02 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h | |||
@@ -93,7 +93,7 @@ struct iwl_cfg; | |||
93 | * 1) The driver layer (iwl-drv.c) chooses the op_mode based on the | 93 | * 1) The driver layer (iwl-drv.c) chooses the op_mode based on the |
94 | * capabilities advertized by the fw file (in TLV format). | 94 | * capabilities advertized by the fw file (in TLV format). |
95 | * 2) The driver layer starts the op_mode (ops->start) | 95 | * 2) The driver layer starts the op_mode (ops->start) |
96 | * 3) The op_mode registers registers mac80211 | 96 | * 3) The op_mode registers mac80211 |
97 | * 4) The op_mode is governed by mac80211 | 97 | * 4) The op_mode is governed by mac80211 |
98 | * 5) The driver layer stops the op_mode | 98 | * 5) The driver layer stops the op_mode |
99 | */ | 99 | */ |
@@ -112,7 +112,7 @@ struct iwl_cfg; | |||
112 | * @stop: stop the op_mode. Must free all the memory allocated. | 112 | * @stop: stop the op_mode. Must free all the memory allocated. |
113 | * May sleep | 113 | * May sleep |
114 | * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the | 114 | * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the |
115 | * HCMD the this Rx responds to. | 115 | * HCMD this Rx responds to. |
116 | * This callback may sleep, it is called from a threaded IRQ handler. | 116 | * This callback may sleep, it is called from a threaded IRQ handler. |
117 | * @queue_full: notifies that a HW queue is full. | 117 | * @queue_full: notifies that a HW queue is full. |
118 | * Must be atomic and called with BH disabled. | 118 | * Must be atomic and called with BH disabled. |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 8d91422c5982..dd57a36ecb10 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h | |||
@@ -180,7 +180,7 @@ struct iwl_rx_packet { | |||
180 | * enum CMD_MODE - how to send the host commands ? | 180 | * enum CMD_MODE - how to send the host commands ? |
181 | * | 181 | * |
182 | * @CMD_SYNC: The caller will be stalled until the fw responds to the command | 182 | * @CMD_SYNC: The caller will be stalled until the fw responds to the command |
183 | * @CMD_ASYNC: Return right away and don't want for the response | 183 | * @CMD_ASYNC: Return right away and don't wait for the response |
184 | * @CMD_WANT_SKB: valid only with CMD_SYNC. The caller needs the buffer of the | 184 | * @CMD_WANT_SKB: valid only with CMD_SYNC. The caller needs the buffer of the |
185 | * response. The caller needs to call iwl_free_resp when done. | 185 | * response. The caller needs to call iwl_free_resp when done. |
186 | */ | 186 | */ |
@@ -218,7 +218,7 @@ struct iwl_device_cmd { | |||
218 | * | 218 | * |
219 | * @IWL_HCMD_DFL_NOCOPY: By default, the command is copied to the host command's | 219 | * @IWL_HCMD_DFL_NOCOPY: By default, the command is copied to the host command's |
220 | * ring. The transport layer doesn't map the command's buffer to DMA, but | 220 | * ring. The transport layer doesn't map the command's buffer to DMA, but |
221 | * rather copies it to an previously allocated DMA buffer. This flag tells | 221 | * rather copies it to a previously allocated DMA buffer. This flag tells |
222 | * the transport layer not to copy the command, but to map the existing | 222 | * the transport layer not to copy the command, but to map the existing |
223 | * buffer (that is passed in) instead. This saves the memcpy and allows | 223 | * buffer (that is passed in) instead. This saves the memcpy and allows |
224 | * commands that are bigger than the fixed buffer to be submitted. | 224 | * commands that are bigger than the fixed buffer to be submitted. |
@@ -243,7 +243,7 @@ enum iwl_hcmd_dataflag { | |||
243 | * @handler_status: return value of the handler of the command | 243 | * @handler_status: return value of the handler of the command |
244 | * (put in setup_rx_handlers) - valid for SYNC mode only | 244 | * (put in setup_rx_handlers) - valid for SYNC mode only |
245 | * @flags: can be CMD_* | 245 | * @flags: can be CMD_* |
246 | * @len: array of the lenths of the chunks in data | 246 | * @len: array of the lengths of the chunks in data |
247 | * @dataflags: IWL_HCMD_DFL_* | 247 | * @dataflags: IWL_HCMD_DFL_* |
248 | * @id: id of the host command | 248 | * @id: id of the host command |
249 | */ | 249 | */ |
@@ -396,8 +396,6 @@ struct iwl_trans; | |||
396 | * May sleep | 396 | * May sleep |
397 | * @dbgfs_register: add the dbgfs files under this directory. Files will be | 397 | * @dbgfs_register: add the dbgfs files under this directory. Files will be |
398 | * automatically deleted. | 398 | * automatically deleted. |
399 | * @suspend: stop the device unless WoWLAN is configured | ||
400 | * @resume: resume activity of the device | ||
401 | * @write8: write a u8 to a register at offset ofs from the BAR | 399 | * @write8: write a u8 to a register at offset ofs from the BAR |
402 | * @write32: write a u32 to a register at offset ofs from the BAR | 400 | * @write32: write a u32 to a register at offset ofs from the BAR |
403 | * @read32: read a u32 register at offset ofs from the BAR | 401 | * @read32: read a u32 register at offset ofs from the BAR |
@@ -443,10 +441,7 @@ struct iwl_trans_ops { | |||
443 | 441 | ||
444 | int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); | 442 | int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); |
445 | int (*wait_tx_queue_empty)(struct iwl_trans *trans); | 443 | int (*wait_tx_queue_empty)(struct iwl_trans *trans); |
446 | #ifdef CONFIG_PM_SLEEP | 444 | |
447 | int (*suspend)(struct iwl_trans *trans); | ||
448 | int (*resume)(struct iwl_trans *trans); | ||
449 | #endif | ||
450 | void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); | 445 | void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); |
451 | void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); | 446 | void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); |
452 | u32 (*read32)(struct iwl_trans *trans, u32 ofs); | 447 | u32 (*read32)(struct iwl_trans *trans, u32 ofs); |
@@ -700,18 +695,6 @@ static inline int iwl_trans_dbgfs_register(struct iwl_trans *trans, | |||
700 | return trans->ops->dbgfs_register(trans, dir); | 695 | return trans->ops->dbgfs_register(trans, dir); |
701 | } | 696 | } |
702 | 697 | ||
703 | #ifdef CONFIG_PM_SLEEP | ||
704 | static inline int iwl_trans_suspend(struct iwl_trans *trans) | ||
705 | { | ||
706 | return trans->ops->suspend(trans); | ||
707 | } | ||
708 | |||
709 | static inline int iwl_trans_resume(struct iwl_trans *trans) | ||
710 | { | ||
711 | return trans->ops->resume(trans); | ||
712 | } | ||
713 | #endif | ||
714 | |||
715 | static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) | 698 | static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) |
716 | { | 699 | { |
717 | trans->ops->write8(trans, ofs, val); | 700 | trans->ops->write8(trans, ofs, val); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/Makefile b/drivers/net/wireless/iwlwifi/mvm/Makefile index ff856e543ae8..6d73817850ce 100644 --- a/drivers/net/wireless/iwlwifi/mvm/Makefile +++ b/drivers/net/wireless/iwlwifi/mvm/Makefile | |||
@@ -2,7 +2,7 @@ obj-$(CONFIG_IWLMVM) += iwlmvm.o | |||
2 | iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o | 2 | iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o |
3 | iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o | 3 | iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o |
4 | iwlmvm-y += scan.o time-event.o rs.o | 4 | iwlmvm-y += scan.o time-event.o rs.o |
5 | iwlmvm-y += power.o bt-coex.o | 5 | iwlmvm-y += power.o power_legacy.o bt-coex.o |
6 | iwlmvm-y += led.o tt.o | 6 | iwlmvm-y += led.o tt.o |
7 | iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o | 7 | iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o |
8 | iwlmvm-$(CONFIG_PM_SLEEP) += d3.o | 8 | iwlmvm-$(CONFIG_PM_SLEEP) += d3.o |
diff --git a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c index dbd622a3929c..0fad98b85f60 100644 --- a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c +++ b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c | |||
@@ -220,66 +220,87 @@ static const __le32 iwl_single_shared_ant_lookup[BT_COEX_LUT_SIZE] = { | |||
220 | 220 | ||
221 | int iwl_send_bt_init_conf(struct iwl_mvm *mvm) | 221 | int iwl_send_bt_init_conf(struct iwl_mvm *mvm) |
222 | { | 222 | { |
223 | struct iwl_bt_coex_cmd cmd = { | 223 | struct iwl_bt_coex_cmd *bt_cmd; |
224 | .max_kill = 5, | 224 | struct iwl_host_cmd cmd = { |
225 | .bt3_time_t7_value = 1, | 225 | .id = BT_CONFIG, |
226 | .bt3_prio_sample_time = 2, | 226 | .len = { sizeof(*bt_cmd), }, |
227 | .bt3_timer_t2_value = 0xc, | 227 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
228 | .flags = CMD_SYNC, | ||
228 | }; | 229 | }; |
229 | int ret; | 230 | int ret; |
230 | 231 | ||
231 | cmd.flags = iwlwifi_mod_params.bt_coex_active ? | 232 | /* go to CALIB state in internal BT-Coex state machine */ |
233 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_OPEN, | ||
234 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
235 | if (ret) | ||
236 | return ret; | ||
237 | |||
238 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_CLOSE, | ||
239 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
240 | if (ret) | ||
241 | return ret; | ||
242 | |||
243 | bt_cmd = kzalloc(sizeof(*bt_cmd), GFP_KERNEL); | ||
244 | if (!bt_cmd) | ||
245 | return -ENOMEM; | ||
246 | cmd.data[0] = bt_cmd; | ||
247 | |||
248 | bt_cmd->max_kill = 5; | ||
249 | bt_cmd->bt3_time_t7_value = 1; | ||
250 | bt_cmd->bt3_prio_sample_time = 2; | ||
251 | bt_cmd->bt3_timer_t2_value = 0xc; | ||
252 | |||
253 | bt_cmd->flags = iwlwifi_mod_params.bt_coex_active ? | ||
232 | BT_COEX_NW : BT_COEX_DISABLE; | 254 | BT_COEX_NW : BT_COEX_DISABLE; |
233 | cmd.flags |= BT_CH_PRIMARY_EN | BT_SYNC_2_BT_DISABLE; | 255 | bt_cmd->flags |= BT_CH_PRIMARY_EN | BT_SYNC_2_BT_DISABLE; |
234 | 256 | ||
235 | cmd.valid_bit_msk = cpu_to_le16(BT_VALID_ENABLE | | 257 | bt_cmd->valid_bit_msk = cpu_to_le16(BT_VALID_ENABLE | |
236 | BT_VALID_BT_PRIO_BOOST | | 258 | BT_VALID_BT_PRIO_BOOST | |
237 | BT_VALID_MAX_KILL | | 259 | BT_VALID_MAX_KILL | |
238 | BT_VALID_3W_TMRS | | 260 | BT_VALID_3W_TMRS | |
239 | BT_VALID_KILL_ACK | | 261 | BT_VALID_KILL_ACK | |
240 | BT_VALID_KILL_CTS | | 262 | BT_VALID_KILL_CTS | |
241 | BT_VALID_REDUCED_TX_POWER | | 263 | BT_VALID_REDUCED_TX_POWER | |
242 | BT_VALID_LUT); | 264 | BT_VALID_LUT); |
243 | 265 | ||
244 | if (mvm->cfg->bt_shared_single_ant) | 266 | if (mvm->cfg->bt_shared_single_ant) |
245 | memcpy(&cmd.decision_lut, iwl_single_shared_ant_lookup, | 267 | memcpy(&bt_cmd->decision_lut, iwl_single_shared_ant_lookup, |
246 | sizeof(iwl_single_shared_ant_lookup)); | 268 | sizeof(iwl_single_shared_ant_lookup)); |
247 | else if (is_loose_coex()) | 269 | else if (is_loose_coex()) |
248 | memcpy(&cmd.decision_lut, iwl_loose_lookup, | 270 | memcpy(&bt_cmd->decision_lut, iwl_loose_lookup, |
249 | sizeof(iwl_tight_lookup)); | 271 | sizeof(iwl_tight_lookup)); |
250 | else | 272 | else |
251 | memcpy(&cmd.decision_lut, iwl_tight_lookup, | 273 | memcpy(&bt_cmd->decision_lut, iwl_tight_lookup, |
252 | sizeof(iwl_tight_lookup)); | 274 | sizeof(iwl_tight_lookup)); |
253 | 275 | ||
254 | cmd.bt_prio_boost = cpu_to_le32(IWL_BT_DEFAULT_BOOST); | 276 | bt_cmd->bt_prio_boost = cpu_to_le32(IWL_BT_DEFAULT_BOOST); |
255 | cmd.kill_ack_msk = | 277 | bt_cmd->kill_ack_msk = |
256 | cpu_to_le32(iwl_bt_ack_kill_msk[BT_KILL_MSK_DEFAULT]); | 278 | cpu_to_le32(iwl_bt_ack_kill_msk[BT_KILL_MSK_DEFAULT]); |
257 | cmd.kill_cts_msk = | 279 | bt_cmd->kill_cts_msk = |
258 | cpu_to_le32(iwl_bt_cts_kill_msk[BT_KILL_MSK_DEFAULT]); | 280 | cpu_to_le32(iwl_bt_cts_kill_msk[BT_KILL_MSK_DEFAULT]); |
259 | 281 | ||
260 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); | 282 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); |
261 | 283 | ||
262 | /* go to CALIB state in internal BT-Coex state machine */ | 284 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
263 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_OPEN, | ||
264 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
265 | if (ret) | ||
266 | return ret; | ||
267 | |||
268 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_CLOSE, | ||
269 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
270 | if (ret) | ||
271 | return ret; | ||
272 | 285 | ||
273 | return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, CMD_SYNC, | 286 | kfree(bt_cmd); |
274 | sizeof(cmd), &cmd); | 287 | return ret; |
275 | } | 288 | } |
276 | 289 | ||
277 | static int iwl_mvm_bt_udpate_ctrl_kill_msk(struct iwl_mvm *mvm, | 290 | static int iwl_mvm_bt_udpate_ctrl_kill_msk(struct iwl_mvm *mvm, |
278 | bool reduced_tx_power) | 291 | bool reduced_tx_power) |
279 | { | 292 | { |
280 | enum iwl_bt_kill_msk bt_kill_msk; | 293 | enum iwl_bt_kill_msk bt_kill_msk; |
281 | struct iwl_bt_coex_cmd cmd = {}; | 294 | struct iwl_bt_coex_cmd *bt_cmd; |
282 | struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif; | 295 | struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif; |
296 | struct iwl_host_cmd cmd = { | ||
297 | .id = BT_CONFIG, | ||
298 | .data[0] = &bt_cmd, | ||
299 | .len = { sizeof(*bt_cmd), }, | ||
300 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, | ||
301 | .flags = CMD_SYNC, | ||
302 | }; | ||
303 | int ret = 0; | ||
283 | 304 | ||
284 | lockdep_assert_held(&mvm->mutex); | 305 | lockdep_assert_held(&mvm->mutex); |
285 | 306 | ||
@@ -308,24 +329,40 @@ static int iwl_mvm_bt_udpate_ctrl_kill_msk(struct iwl_mvm *mvm, | |||
308 | return 0; | 329 | return 0; |
309 | 330 | ||
310 | mvm->bt_kill_msk = bt_kill_msk; | 331 | mvm->bt_kill_msk = bt_kill_msk; |
311 | cmd.kill_ack_msk = cpu_to_le32(iwl_bt_ack_kill_msk[bt_kill_msk]); | 332 | |
312 | cmd.kill_cts_msk = cpu_to_le32(iwl_bt_cts_kill_msk[bt_kill_msk]); | 333 | bt_cmd = kzalloc(sizeof(*bt_cmd), GFP_KERNEL); |
313 | cmd.valid_bit_msk = cpu_to_le16(BT_VALID_KILL_ACK | BT_VALID_KILL_CTS); | 334 | if (!bt_cmd) |
335 | return -ENOMEM; | ||
336 | cmd.data[0] = bt_cmd; | ||
337 | |||
338 | bt_cmd->kill_ack_msk = cpu_to_le32(iwl_bt_ack_kill_msk[bt_kill_msk]); | ||
339 | bt_cmd->kill_cts_msk = cpu_to_le32(iwl_bt_cts_kill_msk[bt_kill_msk]); | ||
340 | bt_cmd->valid_bit_msk = | ||
341 | cpu_to_le16(BT_VALID_KILL_ACK | BT_VALID_KILL_CTS); | ||
314 | 342 | ||
315 | IWL_DEBUG_COEX(mvm, "bt_kill_msk = %d\n", bt_kill_msk); | 343 | IWL_DEBUG_COEX(mvm, "bt_kill_msk = %d\n", bt_kill_msk); |
316 | return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, CMD_SYNC, | 344 | |
317 | sizeof(cmd), &cmd); | 345 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
346 | |||
347 | kfree(bt_cmd); | ||
348 | return ret; | ||
318 | } | 349 | } |
319 | 350 | ||
320 | static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id, | 351 | static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id, |
321 | bool enable) | 352 | bool enable) |
322 | { | 353 | { |
323 | struct iwl_bt_coex_cmd cmd = { | 354 | struct iwl_bt_coex_cmd *bt_cmd; |
324 | .valid_bit_msk = cpu_to_le16(BT_VALID_REDUCED_TX_POWER), | 355 | /* Send ASYNC since this can be sent from an atomic context */ |
325 | .bt_reduced_tx_power = sta_id, | 356 | struct iwl_host_cmd cmd = { |
357 | .id = BT_CONFIG, | ||
358 | .len = { sizeof(*bt_cmd), }, | ||
359 | .dataflags = { IWL_HCMD_DFL_DUP, }, | ||
360 | .flags = CMD_ASYNC, | ||
326 | }; | 361 | }; |
362 | |||
327 | struct ieee80211_sta *sta; | 363 | struct ieee80211_sta *sta; |
328 | struct iwl_mvm_sta *mvmsta; | 364 | struct iwl_mvm_sta *mvmsta; |
365 | int ret; | ||
329 | 366 | ||
330 | /* This can happen if the station has been removed right now */ | 367 | /* This can happen if the station has been removed right now */ |
331 | if (sta_id == IWL_MVM_STATION_COUNT) | 368 | if (sta_id == IWL_MVM_STATION_COUNT) |
@@ -339,17 +376,26 @@ static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id, | |||
339 | if (mvmsta->bt_reduced_txpower == enable) | 376 | if (mvmsta->bt_reduced_txpower == enable) |
340 | return 0; | 377 | return 0; |
341 | 378 | ||
379 | bt_cmd = kzalloc(sizeof(*bt_cmd), GFP_ATOMIC); | ||
380 | if (!bt_cmd) | ||
381 | return -ENOMEM; | ||
382 | cmd.data[0] = bt_cmd; | ||
383 | |||
384 | bt_cmd->valid_bit_msk = cpu_to_le16(BT_VALID_REDUCED_TX_POWER), | ||
385 | bt_cmd->bt_reduced_tx_power = sta_id; | ||
386 | |||
342 | if (enable) | 387 | if (enable) |
343 | cmd.bt_reduced_tx_power |= BT_REDUCED_TX_POWER_BIT; | 388 | bt_cmd->bt_reduced_tx_power |= BT_REDUCED_TX_POWER_BIT; |
344 | 389 | ||
345 | IWL_DEBUG_COEX(mvm, "%sable reduced Tx Power for sta %d\n", | 390 | IWL_DEBUG_COEX(mvm, "%sable reduced Tx Power for sta %d\n", |
346 | enable ? "en" : "dis", sta_id); | 391 | enable ? "en" : "dis", sta_id); |
347 | 392 | ||
348 | mvmsta->bt_reduced_txpower = enable; | 393 | mvmsta->bt_reduced_txpower = enable; |
349 | 394 | ||
350 | /* Send ASYNC since this can be sent from an atomic context */ | 395 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
351 | return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, CMD_ASYNC, | 396 | |
352 | sizeof(cmd), &cmd); | 397 | kfree(bt_cmd); |
398 | return ret; | ||
353 | } | 399 | } |
354 | 400 | ||
355 | struct iwl_bt_iterator_data { | 401 | struct iwl_bt_iterator_data { |
@@ -384,6 +430,10 @@ static void iwl_mvm_bt_notif_iterator(void *_data, u8 *mac, | |||
384 | 430 | ||
385 | smps_mode = IEEE80211_SMPS_AUTOMATIC; | 431 | smps_mode = IEEE80211_SMPS_AUTOMATIC; |
386 | 432 | ||
433 | /* non associated BSSes aren't to be considered */ | ||
434 | if (!vif->bss_conf.assoc) | ||
435 | return; | ||
436 | |||
387 | if (band != IEEE80211_BAND_2GHZ) { | 437 | if (band != IEEE80211_BAND_2GHZ) { |
388 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX, | 438 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX, |
389 | smps_mode); | 439 | smps_mode); |
@@ -523,6 +573,8 @@ static void iwl_mvm_bt_rssi_iterator(void *_data, u8 *mac, | |||
523 | lockdep_is_held(&mvm->mutex)); | 573 | lockdep_is_held(&mvm->mutex)); |
524 | mvmsta = (void *)sta->drv_priv; | 574 | mvmsta = (void *)sta->drv_priv; |
525 | 575 | ||
576 | data->num_bss_ifaces++; | ||
577 | |||
526 | /* | 578 | /* |
527 | * This interface doesn't support reduced Tx power (because of low | 579 | * This interface doesn't support reduced Tx power (because of low |
528 | * RSSI probably), then set bt_kill_msk to default values. | 580 | * RSSI probably), then set bt_kill_msk to default values. |
@@ -588,23 +640,5 @@ void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
588 | 640 | ||
589 | void iwl_mvm_bt_coex_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | 641 | void iwl_mvm_bt_coex_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
590 | { | 642 | { |
591 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
592 | enum ieee80211_band band; | ||
593 | |||
594 | rcu_read_lock(); | ||
595 | chanctx_conf = rcu_dereference(vif->chanctx_conf); | ||
596 | if (chanctx_conf && chanctx_conf->def.chan) | ||
597 | band = chanctx_conf->def.chan->band; | ||
598 | else | ||
599 | band = -1; | ||
600 | rcu_read_unlock(); | ||
601 | |||
602 | /* if we are in 2GHz we will get a notification from the fw */ | ||
603 | if (band == IEEE80211_BAND_2GHZ) | ||
604 | return; | ||
605 | |||
606 | /* else, we can remove all the constraints */ | ||
607 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); | ||
608 | |||
609 | iwl_mvm_bt_coex_notif_handle(mvm); | 643 | iwl_mvm_bt_coex_notif_handle(mvm); |
610 | } | 644 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/constants.h b/drivers/net/wireless/iwlwifi/mvm/constants.h new file mode 100644 index 000000000000..2bf29f7992ee --- /dev/null +++ b/drivers/net/wireless/iwlwifi/mvm/constants.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
4 | * redistributing this file, you may do so under either license. | ||
5 | * | ||
6 | * GPL LICENSE SUMMARY | ||
7 | * | ||
8 | * Copyright(c) 2013 Intel Corporation. All rights reserved. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of version 2 of the GNU General Public License as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | ||
22 | * USA | ||
23 | * | ||
24 | * The full GNU General Public License is included in this distribution | ||
25 | * in the file called COPYING. | ||
26 | * | ||
27 | * Contact Information: | ||
28 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
30 | * | ||
31 | * BSD LICENSE | ||
32 | * | ||
33 | * Copyright(c) 2013 Intel Corporation. All rights reserved. | ||
34 | * All rights reserved. | ||
35 | * | ||
36 | * Redistribution and use in source and binary forms, with or without | ||
37 | * modification, are permitted provided that the following conditions | ||
38 | * are met: | ||
39 | * | ||
40 | * * Redistributions of source code must retain the above copyright | ||
41 | * notice, this list of conditions and the following disclaimer. | ||
42 | * * Redistributions in binary form must reproduce the above copyright | ||
43 | * notice, this list of conditions and the following disclaimer in | ||
44 | * the documentation and/or other materials provided with the | ||
45 | * distribution. | ||
46 | * * Neither the name Intel Corporation nor the names of its | ||
47 | * contributors may be used to endorse or promote products derived | ||
48 | * from this software without specific prior written permission. | ||
49 | * | ||
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
61 | * | ||
62 | *****************************************************************************/ | ||
63 | #ifndef __MVM_CONSTANTS_H | ||
64 | #define __MVM_CONSTANTS_H | ||
65 | |||
66 | #define IWL_MVM_DEFAULT_PS_TX_DATA_TIMEOUT (100 * USEC_PER_MSEC) | ||
67 | #define IWL_MVM_DEFAULT_PS_RX_DATA_TIMEOUT (100 * USEC_PER_MSEC) | ||
68 | #define IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT (10 * USEC_PER_MSEC) | ||
69 | #define IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT (10 * USEC_PER_MSEC) | ||
70 | #define IWL_MVM_UAPSD_RX_DATA_TIMEOUT (50 * USEC_PER_MSEC) | ||
71 | #define IWL_MVM_UAPSD_TX_DATA_TIMEOUT (50 * USEC_PER_MSEC) | ||
72 | #define IWL_MVM_PS_HEAVY_TX_THLD_PACKETS 20 | ||
73 | #define IWL_MVM_PS_HEAVY_RX_THLD_PACKETS 20 | ||
74 | #define IWL_MVM_PS_HEAVY_TX_THLD_PERCENT 50 | ||
75 | #define IWL_MVM_PS_HEAVY_RX_THLD_PERCENT 50 | ||
76 | #define IWL_MVM_PS_SNOOZE_INTERVAL 25 | ||
77 | #define IWL_MVM_PS_SNOOZE_WINDOW 50 | ||
78 | #define IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW 25 | ||
79 | |||
80 | #endif /* __MVM_CONSTANTS_H */ | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c index 7e5e5c2f9f87..417639f77b01 100644 --- a/drivers/net/wireless/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/iwlwifi/mvm/d3.c | |||
@@ -105,7 +105,7 @@ void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw, | |||
105 | list_for_each_entry(ifa, &idev->addr_list, if_list) { | 105 | list_for_each_entry(ifa, &idev->addr_list, if_list) { |
106 | mvmvif->target_ipv6_addrs[idx] = ifa->addr; | 106 | mvmvif->target_ipv6_addrs[idx] = ifa->addr; |
107 | idx++; | 107 | idx++; |
108 | if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS) | 108 | if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX) |
109 | break; | 109 | break; |
110 | } | 110 | } |
111 | read_unlock_bh(&idev->lock); | 111 | read_unlock_bh(&idev->lock); |
@@ -134,7 +134,7 @@ struct wowlan_key_data { | |||
134 | struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc; | 134 | struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc; |
135 | struct iwl_wowlan_tkip_params_cmd *tkip; | 135 | struct iwl_wowlan_tkip_params_cmd *tkip; |
136 | bool error, use_rsc_tsc, use_tkip; | 136 | bool error, use_rsc_tsc, use_tkip; |
137 | int gtk_key_idx; | 137 | int wep_key_idx; |
138 | }; | 138 | }; |
139 | 139 | ||
140 | static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, | 140 | static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, |
@@ -188,8 +188,8 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, | |||
188 | wkc.wep_key.key_offset = 0; | 188 | wkc.wep_key.key_offset = 0; |
189 | } else { | 189 | } else { |
190 | /* others start at 1 */ | 190 | /* others start at 1 */ |
191 | data->gtk_key_idx++; | 191 | data->wep_key_idx++; |
192 | wkc.wep_key.key_offset = data->gtk_key_idx; | 192 | wkc.wep_key.key_offset = data->wep_key_idx; |
193 | } | 193 | } |
194 | 194 | ||
195 | ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, CMD_SYNC, | 195 | ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, CMD_SYNC, |
@@ -316,8 +316,13 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, | |||
316 | mvm->ptk_ivlen = key->iv_len; | 316 | mvm->ptk_ivlen = key->iv_len; |
317 | mvm->ptk_icvlen = key->icv_len; | 317 | mvm->ptk_icvlen = key->icv_len; |
318 | } else { | 318 | } else { |
319 | data->gtk_key_idx++; | 319 | /* |
320 | key->hw_key_idx = data->gtk_key_idx; | 320 | * firmware only supports TSC/RSC for a single key, |
321 | * so if there are multiple keep overwriting them | ||
322 | * with new ones -- this relies on mac80211 doing | ||
323 | * list_add_tail(). | ||
324 | */ | ||
325 | key->hw_key_idx = 1; | ||
321 | mvm->gtk_ivlen = key->iv_len; | 326 | mvm->gtk_ivlen = key->iv_len; |
322 | mvm->gtk_icvlen = key->icv_len; | 327 | mvm->gtk_icvlen = key->icv_len; |
323 | } | 328 | } |
@@ -373,36 +378,68 @@ static int iwl_mvm_send_patterns(struct iwl_mvm *mvm, | |||
373 | static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, | 378 | static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, |
374 | struct ieee80211_vif *vif) | 379 | struct ieee80211_vif *vif) |
375 | { | 380 | { |
376 | struct iwl_proto_offload_cmd cmd = {}; | 381 | union { |
382 | struct iwl_proto_offload_cmd_v1 v1; | ||
383 | struct iwl_proto_offload_cmd_v2 v2; | ||
384 | } cmd = {}; | ||
385 | struct iwl_proto_offload_cmd_common *common; | ||
386 | u32 enabled = 0, size; | ||
377 | #if IS_ENABLED(CONFIG_IPV6) | 387 | #if IS_ENABLED(CONFIG_IPV6) |
378 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 388 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
379 | int i; | 389 | int i; |
380 | 390 | ||
381 | if (mvmvif->num_target_ipv6_addrs) { | 391 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) { |
382 | cmd.enabled |= cpu_to_le32(IWL_D3_PROTO_OFFLOAD_NS); | 392 | if (mvmvif->num_target_ipv6_addrs) { |
383 | memcpy(cmd.ndp_mac_addr, vif->addr, ETH_ALEN); | 393 | enabled |= IWL_D3_PROTO_OFFLOAD_NS; |
384 | } | 394 | memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN); |
395 | } | ||
385 | 396 | ||
386 | BUILD_BUG_ON(sizeof(cmd.target_ipv6_addr[i]) != | 397 | BUILD_BUG_ON(sizeof(cmd.v2.target_ipv6_addr[0]) != |
387 | sizeof(mvmvif->target_ipv6_addrs[i])); | 398 | sizeof(mvmvif->target_ipv6_addrs[0])); |
388 | 399 | ||
389 | for (i = 0; i < mvmvif->num_target_ipv6_addrs; i++) | 400 | for (i = 0; i < min(mvmvif->num_target_ipv6_addrs, |
390 | memcpy(cmd.target_ipv6_addr[i], | 401 | IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++) |
391 | &mvmvif->target_ipv6_addrs[i], | 402 | memcpy(cmd.v2.target_ipv6_addr[i], |
392 | sizeof(cmd.target_ipv6_addr[i])); | 403 | &mvmvif->target_ipv6_addrs[i], |
404 | sizeof(cmd.v2.target_ipv6_addr[i])); | ||
405 | } else { | ||
406 | if (mvmvif->num_target_ipv6_addrs) { | ||
407 | enabled |= IWL_D3_PROTO_OFFLOAD_NS; | ||
408 | memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN); | ||
409 | } | ||
410 | |||
411 | BUILD_BUG_ON(sizeof(cmd.v1.target_ipv6_addr[0]) != | ||
412 | sizeof(mvmvif->target_ipv6_addrs[0])); | ||
413 | |||
414 | for (i = 0; i < min(mvmvif->num_target_ipv6_addrs, | ||
415 | IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++) | ||
416 | memcpy(cmd.v1.target_ipv6_addr[i], | ||
417 | &mvmvif->target_ipv6_addrs[i], | ||
418 | sizeof(cmd.v1.target_ipv6_addr[i])); | ||
419 | } | ||
393 | #endif | 420 | #endif |
394 | 421 | ||
422 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) { | ||
423 | common = &cmd.v2.common; | ||
424 | size = sizeof(cmd.v2); | ||
425 | } else { | ||
426 | common = &cmd.v1.common; | ||
427 | size = sizeof(cmd.v1); | ||
428 | } | ||
429 | |||
395 | if (vif->bss_conf.arp_addr_cnt) { | 430 | if (vif->bss_conf.arp_addr_cnt) { |
396 | cmd.enabled |= cpu_to_le32(IWL_D3_PROTO_OFFLOAD_ARP); | 431 | enabled |= IWL_D3_PROTO_OFFLOAD_ARP; |
397 | cmd.host_ipv4_addr = vif->bss_conf.arp_addr_list[0]; | 432 | common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0]; |
398 | memcpy(cmd.arp_mac_addr, vif->addr, ETH_ALEN); | 433 | memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN); |
399 | } | 434 | } |
400 | 435 | ||
401 | if (!cmd.enabled) | 436 | if (!enabled) |
402 | return 0; | 437 | return 0; |
403 | 438 | ||
439 | common->enabled = cpu_to_le32(enabled); | ||
440 | |||
404 | return iwl_mvm_send_cmd_pdu(mvm, PROT_OFFLOAD_CONFIG_CMD, CMD_SYNC, | 441 | return iwl_mvm_send_cmd_pdu(mvm, PROT_OFFLOAD_CONFIG_CMD, CMD_SYNC, |
405 | sizeof(cmd), &cmd); | 442 | size, &cmd); |
406 | } | 443 | } |
407 | 444 | ||
408 | enum iwl_mvm_tcp_packet_type { | 445 | enum iwl_mvm_tcp_packet_type { |
@@ -1072,73 +1109,16 @@ int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
1072 | return __iwl_mvm_suspend(hw, wowlan, false); | 1109 | return __iwl_mvm_suspend(hw, wowlan, false); |
1073 | } | 1110 | } |
1074 | 1111 | ||
1075 | static void iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm, | 1112 | static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm, |
1076 | struct ieee80211_vif *vif) | 1113 | struct ieee80211_vif *vif, |
1114 | struct iwl_wowlan_status *status) | ||
1077 | { | 1115 | { |
1078 | u32 base = mvm->error_event_table; | 1116 | struct sk_buff *pkt = NULL; |
1079 | struct error_table_start { | ||
1080 | /* cf. struct iwl_error_event_table */ | ||
1081 | u32 valid; | ||
1082 | u32 error_id; | ||
1083 | } err_info; | ||
1084 | struct cfg80211_wowlan_wakeup wakeup = { | 1117 | struct cfg80211_wowlan_wakeup wakeup = { |
1085 | .pattern_idx = -1, | 1118 | .pattern_idx = -1, |
1086 | }; | 1119 | }; |
1087 | struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup; | 1120 | struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup; |
1088 | struct iwl_host_cmd cmd = { | 1121 | u32 reasons = le32_to_cpu(status->wakeup_reasons); |
1089 | .id = WOWLAN_GET_STATUSES, | ||
1090 | .flags = CMD_SYNC | CMD_WANT_SKB, | ||
1091 | }; | ||
1092 | struct iwl_wowlan_status *status; | ||
1093 | u32 reasons; | ||
1094 | int ret, len; | ||
1095 | struct sk_buff *pkt = NULL; | ||
1096 | |||
1097 | iwl_trans_read_mem_bytes(mvm->trans, base, | ||
1098 | &err_info, sizeof(err_info)); | ||
1099 | |||
1100 | if (err_info.valid) { | ||
1101 | IWL_INFO(mvm, "error table is valid (%d)\n", | ||
1102 | err_info.valid); | ||
1103 | if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) { | ||
1104 | wakeup.rfkill_release = true; | ||
1105 | ieee80211_report_wowlan_wakeup(vif, &wakeup, | ||
1106 | GFP_KERNEL); | ||
1107 | } | ||
1108 | return; | ||
1109 | } | ||
1110 | |||
1111 | /* only for tracing for now */ | ||
1112 | ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, CMD_SYNC, 0, NULL); | ||
1113 | if (ret) | ||
1114 | IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret); | ||
1115 | |||
1116 | ret = iwl_mvm_send_cmd(mvm, &cmd); | ||
1117 | if (ret) { | ||
1118 | IWL_ERR(mvm, "failed to query status (%d)\n", ret); | ||
1119 | return; | ||
1120 | } | ||
1121 | |||
1122 | /* RF-kill already asserted again... */ | ||
1123 | if (!cmd.resp_pkt) | ||
1124 | return; | ||
1125 | |||
1126 | len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; | ||
1127 | if (len - sizeof(struct iwl_cmd_header) < sizeof(*status)) { | ||
1128 | IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); | ||
1129 | goto out; | ||
1130 | } | ||
1131 | |||
1132 | status = (void *)cmd.resp_pkt->data; | ||
1133 | |||
1134 | if (len - sizeof(struct iwl_cmd_header) != | ||
1135 | sizeof(*status) + | ||
1136 | ALIGN(le32_to_cpu(status->wake_packet_bufsize), 4)) { | ||
1137 | IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); | ||
1138 | goto out; | ||
1139 | } | ||
1140 | |||
1141 | reasons = le32_to_cpu(status->wakeup_reasons); | ||
1142 | 1122 | ||
1143 | if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) { | 1123 | if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) { |
1144 | wakeup_report = NULL; | 1124 | wakeup_report = NULL; |
@@ -1201,6 +1181,12 @@ static void iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm, | |||
1201 | pktsize -= hdrlen; | 1181 | pktsize -= hdrlen; |
1202 | 1182 | ||
1203 | if (ieee80211_has_protected(hdr->frame_control)) { | 1183 | if (ieee80211_has_protected(hdr->frame_control)) { |
1184 | /* | ||
1185 | * This is unlocked and using gtk_i(c)vlen, | ||
1186 | * but since everything is under RTNL still | ||
1187 | * that's not really a problem - changing | ||
1188 | * it would be difficult. | ||
1189 | */ | ||
1204 | if (is_multicast_ether_addr(hdr->addr1)) { | 1190 | if (is_multicast_ether_addr(hdr->addr1)) { |
1205 | ivlen = mvm->gtk_ivlen; | 1191 | ivlen = mvm->gtk_ivlen; |
1206 | icvlen += mvm->gtk_icvlen; | 1192 | icvlen += mvm->gtk_icvlen; |
@@ -1251,9 +1237,82 @@ static void iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm, | |||
1251 | report: | 1237 | report: |
1252 | ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL); | 1238 | ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL); |
1253 | kfree_skb(pkt); | 1239 | kfree_skb(pkt); |
1240 | } | ||
1254 | 1241 | ||
1255 | out: | 1242 | /* releases the MVM mutex */ |
1243 | static void iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm, | ||
1244 | struct ieee80211_vif *vif) | ||
1245 | { | ||
1246 | u32 base = mvm->error_event_table; | ||
1247 | struct error_table_start { | ||
1248 | /* cf. struct iwl_error_event_table */ | ||
1249 | u32 valid; | ||
1250 | u32 error_id; | ||
1251 | } err_info; | ||
1252 | struct iwl_host_cmd cmd = { | ||
1253 | .id = WOWLAN_GET_STATUSES, | ||
1254 | .flags = CMD_SYNC | CMD_WANT_SKB, | ||
1255 | }; | ||
1256 | struct iwl_wowlan_status *status; | ||
1257 | int ret, len; | ||
1258 | |||
1259 | iwl_trans_read_mem_bytes(mvm->trans, base, | ||
1260 | &err_info, sizeof(err_info)); | ||
1261 | |||
1262 | if (err_info.valid) { | ||
1263 | IWL_INFO(mvm, "error table is valid (%d)\n", | ||
1264 | err_info.valid); | ||
1265 | if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) { | ||
1266 | struct cfg80211_wowlan_wakeup wakeup = { | ||
1267 | .rfkill_release = true, | ||
1268 | }; | ||
1269 | ieee80211_report_wowlan_wakeup(vif, &wakeup, | ||
1270 | GFP_KERNEL); | ||
1271 | } | ||
1272 | goto out_unlock; | ||
1273 | } | ||
1274 | |||
1275 | /* only for tracing for now */ | ||
1276 | ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, CMD_SYNC, 0, NULL); | ||
1277 | if (ret) | ||
1278 | IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret); | ||
1279 | |||
1280 | ret = iwl_mvm_send_cmd(mvm, &cmd); | ||
1281 | if (ret) { | ||
1282 | IWL_ERR(mvm, "failed to query status (%d)\n", ret); | ||
1283 | goto out_unlock; | ||
1284 | } | ||
1285 | |||
1286 | /* RF-kill already asserted again... */ | ||
1287 | if (!cmd.resp_pkt) | ||
1288 | goto out_unlock; | ||
1289 | |||
1290 | len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; | ||
1291 | if (len - sizeof(struct iwl_cmd_header) < sizeof(*status)) { | ||
1292 | IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); | ||
1293 | goto out_free_resp; | ||
1294 | } | ||
1295 | |||
1296 | status = (void *)cmd.resp_pkt->data; | ||
1297 | |||
1298 | if (len - sizeof(struct iwl_cmd_header) != | ||
1299 | sizeof(*status) + | ||
1300 | ALIGN(le32_to_cpu(status->wake_packet_bufsize), 4)) { | ||
1301 | IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); | ||
1302 | goto out_free_resp; | ||
1303 | } | ||
1304 | |||
1305 | /* now we have all the data we need, unlock to avoid mac80211 issues */ | ||
1306 | mutex_unlock(&mvm->mutex); | ||
1307 | |||
1308 | iwl_mvm_report_wakeup_reasons(mvm, vif, status); | ||
1309 | iwl_free_resp(&cmd); | ||
1310 | return; | ||
1311 | |||
1312 | out_free_resp: | ||
1256 | iwl_free_resp(&cmd); | 1313 | iwl_free_resp(&cmd); |
1314 | out_unlock: | ||
1315 | mutex_unlock(&mvm->mutex); | ||
1257 | } | 1316 | } |
1258 | 1317 | ||
1259 | static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm) | 1318 | static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm) |
@@ -1310,10 +1369,13 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) | |||
1310 | iwl_mvm_read_d3_sram(mvm); | 1369 | iwl_mvm_read_d3_sram(mvm); |
1311 | 1370 | ||
1312 | iwl_mvm_query_wakeup_reasons(mvm, vif); | 1371 | iwl_mvm_query_wakeup_reasons(mvm, vif); |
1372 | /* has unlocked the mutex, so skip that */ | ||
1373 | goto out; | ||
1313 | 1374 | ||
1314 | out_unlock: | 1375 | out_unlock: |
1315 | mutex_unlock(&mvm->mutex); | 1376 | mutex_unlock(&mvm->mutex); |
1316 | 1377 | ||
1378 | out: | ||
1317 | if (!test && vif) | 1379 | if (!test && vif) |
1318 | ieee80211_resume_disconnect(vif); | 1380 | ieee80211_resume_disconnect(vif); |
1319 | 1381 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c index e56ed2a84888..aac81b8984b0 100644 --- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c | |||
@@ -352,6 +352,10 @@ static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm, | |||
352 | IWL_DEBUG_POWER(mvm, "lprx_rssi_threshold=%d\n", val); | 352 | IWL_DEBUG_POWER(mvm, "lprx_rssi_threshold=%d\n", val); |
353 | dbgfs_pm->lprx_rssi_threshold = val; | 353 | dbgfs_pm->lprx_rssi_threshold = val; |
354 | break; | 354 | break; |
355 | case MVM_DEBUGFS_PM_SNOOZE_ENABLE: | ||
356 | IWL_DEBUG_POWER(mvm, "snooze_enable=%d\n", val); | ||
357 | dbgfs_pm->snooze_ena = val; | ||
358 | break; | ||
355 | } | 359 | } |
356 | } | 360 | } |
357 | 361 | ||
@@ -405,6 +409,10 @@ static ssize_t iwl_dbgfs_pm_params_write(struct file *file, | |||
405 | POWER_LPRX_RSSI_THRESHOLD_MIN) | 409 | POWER_LPRX_RSSI_THRESHOLD_MIN) |
406 | return -EINVAL; | 410 | return -EINVAL; |
407 | param = MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD; | 411 | param = MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD; |
412 | } else if (!strncmp("snooze_enable=", buf, 14)) { | ||
413 | if (sscanf(buf + 14, "%d", &val) != 1) | ||
414 | return -EINVAL; | ||
415 | param = MVM_DEBUGFS_PM_SNOOZE_ENABLE; | ||
408 | } else { | 416 | } else { |
409 | return -EINVAL; | 417 | return -EINVAL; |
410 | } | 418 | } |
@@ -424,40 +432,11 @@ static ssize_t iwl_dbgfs_pm_params_read(struct file *file, | |||
424 | struct ieee80211_vif *vif = file->private_data; | 432 | struct ieee80211_vif *vif = file->private_data; |
425 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 433 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
426 | struct iwl_mvm *mvm = mvmvif->dbgfs_data; | 434 | struct iwl_mvm *mvm = mvmvif->dbgfs_data; |
427 | struct iwl_powertable_cmd cmd = {}; | 435 | char buf[512]; |
428 | char buf[256]; | ||
429 | int bufsz = sizeof(buf); | 436 | int bufsz = sizeof(buf); |
430 | int pos = 0; | 437 | int pos; |
431 | 438 | ||
432 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | 439 | pos = iwl_mvm_power_dbgfs_read(mvm, vif, buf, bufsz); |
433 | |||
434 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n", | ||
435 | (cmd.flags & | ||
436 | cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ? | ||
437 | 0 : 1); | ||
438 | pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n", | ||
439 | le32_to_cpu(cmd.skip_dtim_periods)); | ||
440 | pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n", | ||
441 | iwlmvm_mod_params.power_scheme); | ||
442 | pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n", | ||
443 | le16_to_cpu(cmd.flags)); | ||
444 | pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n", | ||
445 | cmd.keep_alive_seconds); | ||
446 | |||
447 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | ||
448 | pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n", | ||
449 | (cmd.flags & | ||
450 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? | ||
451 | 1 : 0); | ||
452 | pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n", | ||
453 | le32_to_cpu(cmd.rx_data_timeout)); | ||
454 | pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n", | ||
455 | le32_to_cpu(cmd.tx_data_timeout)); | ||
456 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | ||
457 | pos += scnprintf(buf+pos, bufsz-pos, | ||
458 | "lprx_rssi_threshold = %d\n", | ||
459 | le32_to_cpu(cmd.lprx_rssi_threshold)); | ||
460 | } | ||
461 | 440 | ||
462 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | 441 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
463 | } | 442 | } |
@@ -621,25 +600,160 @@ static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf, | |||
621 | } | 600 | } |
622 | #undef BT_MBOX_PRINT | 601 | #undef BT_MBOX_PRINT |
623 | 602 | ||
603 | #define PRINT_STATS_LE32(_str, _val) \ | ||
604 | pos += scnprintf(buf + pos, bufsz - pos, \ | ||
605 | fmt_table, _str, \ | ||
606 | le32_to_cpu(_val)) | ||
607 | |||
608 | static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file, | ||
609 | char __user *user_buf, size_t count, | ||
610 | loff_t *ppos) | ||
611 | { | ||
612 | struct iwl_mvm *mvm = file->private_data; | ||
613 | static const char *fmt_table = "\t%-30s %10u\n"; | ||
614 | static const char *fmt_header = "%-32s\n"; | ||
615 | int pos = 0; | ||
616 | char *buf; | ||
617 | int ret; | ||
618 | int bufsz = sizeof(struct mvm_statistics_rx_phy) * 20 + | ||
619 | sizeof(struct mvm_statistics_rx_non_phy) * 10 + | ||
620 | sizeof(struct mvm_statistics_rx_ht_phy) * 10 + 200; | ||
621 | struct mvm_statistics_rx_phy *ofdm; | ||
622 | struct mvm_statistics_rx_phy *cck; | ||
623 | struct mvm_statistics_rx_non_phy *general; | ||
624 | struct mvm_statistics_rx_ht_phy *ht; | ||
625 | |||
626 | buf = kzalloc(bufsz, GFP_KERNEL); | ||
627 | if (!buf) | ||
628 | return -ENOMEM; | ||
629 | |||
630 | mutex_lock(&mvm->mutex); | ||
631 | |||
632 | ofdm = &mvm->rx_stats.ofdm; | ||
633 | cck = &mvm->rx_stats.cck; | ||
634 | general = &mvm->rx_stats.general; | ||
635 | ht = &mvm->rx_stats.ofdm_ht; | ||
636 | |||
637 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, | ||
638 | "Statistics_Rx - OFDM"); | ||
639 | PRINT_STATS_LE32("ina_cnt", ofdm->ina_cnt); | ||
640 | PRINT_STATS_LE32("fina_cnt", ofdm->fina_cnt); | ||
641 | PRINT_STATS_LE32("plcp_err", ofdm->plcp_err); | ||
642 | PRINT_STATS_LE32("crc32_err", ofdm->crc32_err); | ||
643 | PRINT_STATS_LE32("overrun_err", ofdm->overrun_err); | ||
644 | PRINT_STATS_LE32("early_overrun_err", ofdm->early_overrun_err); | ||
645 | PRINT_STATS_LE32("crc32_good", ofdm->crc32_good); | ||
646 | PRINT_STATS_LE32("false_alarm_cnt", ofdm->false_alarm_cnt); | ||
647 | PRINT_STATS_LE32("fina_sync_err_cnt", ofdm->fina_sync_err_cnt); | ||
648 | PRINT_STATS_LE32("sfd_timeout", ofdm->sfd_timeout); | ||
649 | PRINT_STATS_LE32("fina_timeout", ofdm->fina_timeout); | ||
650 | PRINT_STATS_LE32("unresponded_rts", ofdm->unresponded_rts); | ||
651 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", | ||
652 | ofdm->rxe_frame_limit_overrun); | ||
653 | PRINT_STATS_LE32("sent_ack_cnt", ofdm->sent_ack_cnt); | ||
654 | PRINT_STATS_LE32("sent_cts_cnt", ofdm->sent_cts_cnt); | ||
655 | PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm->sent_ba_rsp_cnt); | ||
656 | PRINT_STATS_LE32("dsp_self_kill", ofdm->dsp_self_kill); | ||
657 | PRINT_STATS_LE32("mh_format_err", ofdm->mh_format_err); | ||
658 | PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm->re_acq_main_rssi_sum); | ||
659 | PRINT_STATS_LE32("reserved", ofdm->reserved); | ||
660 | |||
661 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, | ||
662 | "Statistics_Rx - CCK"); | ||
663 | PRINT_STATS_LE32("ina_cnt", cck->ina_cnt); | ||
664 | PRINT_STATS_LE32("fina_cnt", cck->fina_cnt); | ||
665 | PRINT_STATS_LE32("plcp_err", cck->plcp_err); | ||
666 | PRINT_STATS_LE32("crc32_err", cck->crc32_err); | ||
667 | PRINT_STATS_LE32("overrun_err", cck->overrun_err); | ||
668 | PRINT_STATS_LE32("early_overrun_err", cck->early_overrun_err); | ||
669 | PRINT_STATS_LE32("crc32_good", cck->crc32_good); | ||
670 | PRINT_STATS_LE32("false_alarm_cnt", cck->false_alarm_cnt); | ||
671 | PRINT_STATS_LE32("fina_sync_err_cnt", cck->fina_sync_err_cnt); | ||
672 | PRINT_STATS_LE32("sfd_timeout", cck->sfd_timeout); | ||
673 | PRINT_STATS_LE32("fina_timeout", cck->fina_timeout); | ||
674 | PRINT_STATS_LE32("unresponded_rts", cck->unresponded_rts); | ||
675 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", | ||
676 | cck->rxe_frame_limit_overrun); | ||
677 | PRINT_STATS_LE32("sent_ack_cnt", cck->sent_ack_cnt); | ||
678 | PRINT_STATS_LE32("sent_cts_cnt", cck->sent_cts_cnt); | ||
679 | PRINT_STATS_LE32("sent_ba_rsp_cnt", cck->sent_ba_rsp_cnt); | ||
680 | PRINT_STATS_LE32("dsp_self_kill", cck->dsp_self_kill); | ||
681 | PRINT_STATS_LE32("mh_format_err", cck->mh_format_err); | ||
682 | PRINT_STATS_LE32("re_acq_main_rssi_sum", cck->re_acq_main_rssi_sum); | ||
683 | PRINT_STATS_LE32("reserved", cck->reserved); | ||
684 | |||
685 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, | ||
686 | "Statistics_Rx - GENERAL"); | ||
687 | PRINT_STATS_LE32("bogus_cts", general->bogus_cts); | ||
688 | PRINT_STATS_LE32("bogus_ack", general->bogus_ack); | ||
689 | PRINT_STATS_LE32("non_bssid_frames", general->non_bssid_frames); | ||
690 | PRINT_STATS_LE32("filtered_frames", general->filtered_frames); | ||
691 | PRINT_STATS_LE32("non_channel_beacons", general->non_channel_beacons); | ||
692 | PRINT_STATS_LE32("channel_beacons", general->channel_beacons); | ||
693 | PRINT_STATS_LE32("num_missed_bcon", general->num_missed_bcon); | ||
694 | PRINT_STATS_LE32("adc_rx_saturation_time", | ||
695 | general->adc_rx_saturation_time); | ||
696 | PRINT_STATS_LE32("ina_detection_search_time", | ||
697 | general->ina_detection_search_time); | ||
698 | PRINT_STATS_LE32("beacon_silence_rssi_a", | ||
699 | general->beacon_silence_rssi_a); | ||
700 | PRINT_STATS_LE32("beacon_silence_rssi_b", | ||
701 | general->beacon_silence_rssi_b); | ||
702 | PRINT_STATS_LE32("beacon_silence_rssi_c", | ||
703 | general->beacon_silence_rssi_c); | ||
704 | PRINT_STATS_LE32("interference_data_flag", | ||
705 | general->interference_data_flag); | ||
706 | PRINT_STATS_LE32("channel_load", general->channel_load); | ||
707 | PRINT_STATS_LE32("dsp_false_alarms", general->dsp_false_alarms); | ||
708 | PRINT_STATS_LE32("beacon_rssi_a", general->beacon_rssi_a); | ||
709 | PRINT_STATS_LE32("beacon_rssi_b", general->beacon_rssi_b); | ||
710 | PRINT_STATS_LE32("beacon_rssi_c", general->beacon_rssi_c); | ||
711 | PRINT_STATS_LE32("beacon_energy_a", general->beacon_energy_a); | ||
712 | PRINT_STATS_LE32("beacon_energy_b", general->beacon_energy_b); | ||
713 | PRINT_STATS_LE32("beacon_energy_c", general->beacon_energy_c); | ||
714 | PRINT_STATS_LE32("num_bt_kills", general->num_bt_kills); | ||
715 | PRINT_STATS_LE32("directed_data_mpdu", general->directed_data_mpdu); | ||
716 | |||
717 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, | ||
718 | "Statistics_Rx - HT"); | ||
719 | PRINT_STATS_LE32("plcp_err", ht->plcp_err); | ||
720 | PRINT_STATS_LE32("overrun_err", ht->overrun_err); | ||
721 | PRINT_STATS_LE32("early_overrun_err", ht->early_overrun_err); | ||
722 | PRINT_STATS_LE32("crc32_good", ht->crc32_good); | ||
723 | PRINT_STATS_LE32("crc32_err", ht->crc32_err); | ||
724 | PRINT_STATS_LE32("mh_format_err", ht->mh_format_err); | ||
725 | PRINT_STATS_LE32("agg_crc32_good", ht->agg_crc32_good); | ||
726 | PRINT_STATS_LE32("agg_mpdu_cnt", ht->agg_mpdu_cnt); | ||
727 | PRINT_STATS_LE32("agg_cnt", ht->agg_cnt); | ||
728 | PRINT_STATS_LE32("unsupport_mcs", ht->unsupport_mcs); | ||
729 | |||
730 | mutex_unlock(&mvm->mutex); | ||
731 | |||
732 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | ||
733 | kfree(buf); | ||
734 | |||
735 | return ret; | ||
736 | } | ||
737 | #undef PRINT_STAT_LE32 | ||
738 | |||
624 | static ssize_t iwl_dbgfs_fw_restart_write(struct file *file, | 739 | static ssize_t iwl_dbgfs_fw_restart_write(struct file *file, |
625 | const char __user *user_buf, | 740 | const char __user *user_buf, |
626 | size_t count, loff_t *ppos) | 741 | size_t count, loff_t *ppos) |
627 | { | 742 | { |
628 | struct iwl_mvm *mvm = file->private_data; | 743 | struct iwl_mvm *mvm = file->private_data; |
629 | bool restart_fw = iwlwifi_mod_params.restart_fw; | ||
630 | int ret; | 744 | int ret; |
631 | 745 | ||
632 | iwlwifi_mod_params.restart_fw = true; | ||
633 | |||
634 | mutex_lock(&mvm->mutex); | 746 | mutex_lock(&mvm->mutex); |
635 | 747 | ||
748 | /* allow one more restart that we're provoking here */ | ||
749 | if (mvm->restart_fw >= 0) | ||
750 | mvm->restart_fw++; | ||
751 | |||
636 | /* take the return value to make compiler happy - it will fail anyway */ | 752 | /* take the return value to make compiler happy - it will fail anyway */ |
637 | ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, CMD_SYNC, 0, NULL); | 753 | ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, CMD_SYNC, 0, NULL); |
638 | 754 | ||
639 | mutex_unlock(&mvm->mutex); | 755 | mutex_unlock(&mvm->mutex); |
640 | 756 | ||
641 | iwlwifi_mod_params.restart_fw = restart_fw; | ||
642 | |||
643 | return count; | 757 | return count; |
644 | } | 758 | } |
645 | 759 | ||
@@ -661,8 +775,14 @@ static void iwl_dbgfs_update_bf(struct ieee80211_vif *vif, | |||
661 | case MVM_DEBUGFS_BF_ROAMING_STATE: | 775 | case MVM_DEBUGFS_BF_ROAMING_STATE: |
662 | dbgfs_bf->bf_roaming_state = value; | 776 | dbgfs_bf->bf_roaming_state = value; |
663 | break; | 777 | break; |
664 | case MVM_DEBUGFS_BF_TEMPERATURE_DELTA: | 778 | case MVM_DEBUGFS_BF_TEMP_THRESHOLD: |
665 | dbgfs_bf->bf_temperature_delta = value; | 779 | dbgfs_bf->bf_temp_threshold = value; |
780 | break; | ||
781 | case MVM_DEBUGFS_BF_TEMP_FAST_FILTER: | ||
782 | dbgfs_bf->bf_temp_fast_filter = value; | ||
783 | break; | ||
784 | case MVM_DEBUGFS_BF_TEMP_SLOW_FILTER: | ||
785 | dbgfs_bf->bf_temp_slow_filter = value; | ||
666 | break; | 786 | break; |
667 | case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER: | 787 | case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER: |
668 | dbgfs_bf->bf_enable_beacon_filter = value; | 788 | dbgfs_bf->bf_enable_beacon_filter = value; |
@@ -721,13 +841,27 @@ static ssize_t iwl_dbgfs_bf_params_write(struct file *file, | |||
721 | value > IWL_BF_ROAMING_STATE_MAX) | 841 | value > IWL_BF_ROAMING_STATE_MAX) |
722 | return -EINVAL; | 842 | return -EINVAL; |
723 | param = MVM_DEBUGFS_BF_ROAMING_STATE; | 843 | param = MVM_DEBUGFS_BF_ROAMING_STATE; |
724 | } else if (!strncmp("bf_temperature_delta=", buf, 21)) { | 844 | } else if (!strncmp("bf_temp_threshold=", buf, 18)) { |
725 | if (sscanf(buf+21, "%d", &value) != 1) | 845 | if (sscanf(buf+18, "%d", &value) != 1) |
846 | return -EINVAL; | ||
847 | if (value < IWL_BF_TEMP_THRESHOLD_MIN || | ||
848 | value > IWL_BF_TEMP_THRESHOLD_MAX) | ||
849 | return -EINVAL; | ||
850 | param = MVM_DEBUGFS_BF_TEMP_THRESHOLD; | ||
851 | } else if (!strncmp("bf_temp_fast_filter=", buf, 20)) { | ||
852 | if (sscanf(buf+20, "%d", &value) != 1) | ||
726 | return -EINVAL; | 853 | return -EINVAL; |
727 | if (value < IWL_BF_TEMPERATURE_DELTA_MIN || | 854 | if (value < IWL_BF_TEMP_FAST_FILTER_MIN || |
728 | value > IWL_BF_TEMPERATURE_DELTA_MAX) | 855 | value > IWL_BF_TEMP_FAST_FILTER_MAX) |
729 | return -EINVAL; | 856 | return -EINVAL; |
730 | param = MVM_DEBUGFS_BF_TEMPERATURE_DELTA; | 857 | param = MVM_DEBUGFS_BF_TEMP_FAST_FILTER; |
858 | } else if (!strncmp("bf_temp_slow_filter=", buf, 20)) { | ||
859 | if (sscanf(buf+20, "%d", &value) != 1) | ||
860 | return -EINVAL; | ||
861 | if (value < IWL_BF_TEMP_SLOW_FILTER_MIN || | ||
862 | value > IWL_BF_TEMP_SLOW_FILTER_MAX) | ||
863 | return -EINVAL; | ||
864 | param = MVM_DEBUGFS_BF_TEMP_SLOW_FILTER; | ||
731 | } else if (!strncmp("bf_enable_beacon_filter=", buf, 24)) { | 865 | } else if (!strncmp("bf_enable_beacon_filter=", buf, 24)) { |
732 | if (sscanf(buf+24, "%d", &value) != 1) | 866 | if (sscanf(buf+24, "%d", &value) != 1) |
733 | return -EINVAL; | 867 | return -EINVAL; |
@@ -769,10 +903,7 @@ static ssize_t iwl_dbgfs_bf_params_write(struct file *file, | |||
769 | if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value) { | 903 | if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value) { |
770 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); | 904 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
771 | } else { | 905 | } else { |
772 | if (mvmvif->bf_enabled) | 906 | ret = iwl_mvm_enable_beacon_filter(mvm, vif); |
773 | ret = iwl_mvm_enable_beacon_filter(mvm, vif); | ||
774 | else | ||
775 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); | ||
776 | } | 907 | } |
777 | mutex_unlock(&mvm->mutex); | 908 | mutex_unlock(&mvm->mutex); |
778 | 909 | ||
@@ -789,41 +920,41 @@ static ssize_t iwl_dbgfs_bf_params_read(struct file *file, | |||
789 | int pos = 0; | 920 | int pos = 0; |
790 | const size_t bufsz = sizeof(buf); | 921 | const size_t bufsz = sizeof(buf); |
791 | struct iwl_beacon_filter_cmd cmd = { | 922 | struct iwl_beacon_filter_cmd cmd = { |
792 | .bf_energy_delta = IWL_BF_ENERGY_DELTA_DEFAULT, | 923 | IWL_BF_CMD_CONFIG_DEFAULTS, |
793 | .bf_roaming_energy_delta = IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT, | 924 | .bf_enable_beacon_filter = |
794 | .bf_roaming_state = IWL_BF_ROAMING_STATE_DEFAULT, | 925 | cpu_to_le32(IWL_BF_ENABLE_BEACON_FILTER_DEFAULT), |
795 | .bf_temperature_delta = IWL_BF_TEMPERATURE_DELTA_DEFAULT, | 926 | .ba_enable_beacon_abort = |
796 | .bf_enable_beacon_filter = IWL_BF_ENABLE_BEACON_FILTER_DEFAULT, | 927 | cpu_to_le32(IWL_BA_ENABLE_BEACON_ABORT_DEFAULT), |
797 | .bf_debug_flag = IWL_BF_DEBUG_FLAG_DEFAULT, | ||
798 | .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT), | ||
799 | .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT), | ||
800 | .ba_enable_beacon_abort = IWL_BA_ENABLE_BEACON_ABORT_DEFAULT, | ||
801 | }; | 928 | }; |
802 | 929 | ||
803 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); | 930 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); |
804 | if (mvmvif->bf_enabled) | 931 | if (mvmvif->bf_data.bf_enabled) |
805 | cmd.bf_enable_beacon_filter = 1; | 932 | cmd.bf_enable_beacon_filter = cpu_to_le32(1); |
806 | else | 933 | else |
807 | cmd.bf_enable_beacon_filter = 0; | 934 | cmd.bf_enable_beacon_filter = 0; |
808 | 935 | ||
809 | pos += scnprintf(buf+pos, bufsz-pos, "bf_energy_delta = %d\n", | 936 | pos += scnprintf(buf+pos, bufsz-pos, "bf_energy_delta = %d\n", |
810 | cmd.bf_energy_delta); | 937 | le32_to_cpu(cmd.bf_energy_delta)); |
811 | pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_energy_delta = %d\n", | 938 | pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_energy_delta = %d\n", |
812 | cmd.bf_roaming_energy_delta); | 939 | le32_to_cpu(cmd.bf_roaming_energy_delta)); |
813 | pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_state = %d\n", | 940 | pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_state = %d\n", |
814 | cmd.bf_roaming_state); | 941 | le32_to_cpu(cmd.bf_roaming_state)); |
815 | pos += scnprintf(buf+pos, bufsz-pos, "bf_temperature_delta = %d\n", | 942 | pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_threshold = %d\n", |
816 | cmd.bf_temperature_delta); | 943 | le32_to_cpu(cmd.bf_temp_threshold)); |
944 | pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_fast_filter = %d\n", | ||
945 | le32_to_cpu(cmd.bf_temp_fast_filter)); | ||
946 | pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_slow_filter = %d\n", | ||
947 | le32_to_cpu(cmd.bf_temp_slow_filter)); | ||
817 | pos += scnprintf(buf+pos, bufsz-pos, "bf_enable_beacon_filter = %d\n", | 948 | pos += scnprintf(buf+pos, bufsz-pos, "bf_enable_beacon_filter = %d\n", |
818 | cmd.bf_enable_beacon_filter); | 949 | le32_to_cpu(cmd.bf_enable_beacon_filter)); |
819 | pos += scnprintf(buf+pos, bufsz-pos, "bf_debug_flag = %d\n", | 950 | pos += scnprintf(buf+pos, bufsz-pos, "bf_debug_flag = %d\n", |
820 | cmd.bf_debug_flag); | 951 | le32_to_cpu(cmd.bf_debug_flag)); |
821 | pos += scnprintf(buf+pos, bufsz-pos, "bf_escape_timer = %d\n", | 952 | pos += scnprintf(buf+pos, bufsz-pos, "bf_escape_timer = %d\n", |
822 | cmd.bf_escape_timer); | 953 | le32_to_cpu(cmd.bf_escape_timer)); |
823 | pos += scnprintf(buf+pos, bufsz-pos, "ba_escape_timer = %d\n", | 954 | pos += scnprintf(buf+pos, bufsz-pos, "ba_escape_timer = %d\n", |
824 | cmd.ba_escape_timer); | 955 | le32_to_cpu(cmd.ba_escape_timer)); |
825 | pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n", | 956 | pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n", |
826 | cmd.ba_enable_beacon_abort); | 957 | le32_to_cpu(cmd.ba_enable_beacon_abort)); |
827 | 958 | ||
828 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | 959 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
829 | } | 960 | } |
@@ -934,6 +1065,7 @@ MVM_DEBUGFS_READ_FILE_OPS(stations); | |||
934 | MVM_DEBUGFS_READ_FILE_OPS(bt_notif); | 1065 | MVM_DEBUGFS_READ_FILE_OPS(bt_notif); |
935 | MVM_DEBUGFS_WRITE_FILE_OPS(power_down_allow); | 1066 | MVM_DEBUGFS_WRITE_FILE_OPS(power_down_allow); |
936 | MVM_DEBUGFS_WRITE_FILE_OPS(power_down_d3_allow); | 1067 | MVM_DEBUGFS_WRITE_FILE_OPS(power_down_d3_allow); |
1068 | MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats); | ||
937 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart); | 1069 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart); |
938 | #ifdef CONFIG_PM_SLEEP | 1070 | #ifdef CONFIG_PM_SLEEP |
939 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram); | 1071 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram); |
@@ -957,6 +1089,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) | |||
957 | MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR); | 1089 | MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR); |
958 | MVM_DEBUGFS_ADD_FILE(power_down_allow, mvm->debugfs_dir, S_IWUSR); | 1090 | MVM_DEBUGFS_ADD_FILE(power_down_allow, mvm->debugfs_dir, S_IWUSR); |
959 | MVM_DEBUGFS_ADD_FILE(power_down_d3_allow, mvm->debugfs_dir, S_IWUSR); | 1091 | MVM_DEBUGFS_ADD_FILE(power_down_d3_allow, mvm->debugfs_dir, S_IWUSR); |
1092 | MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR); | ||
960 | MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR); | 1093 | MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR); |
961 | #ifdef CONFIG_PM_SLEEP | 1094 | #ifdef CONFIG_PM_SLEEP |
962 | MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR); | 1095 | MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR); |
@@ -988,7 +1121,11 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
988 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 1121 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
989 | char buf[100]; | 1122 | char buf[100]; |
990 | 1123 | ||
991 | if (!dbgfs_dir) | 1124 | /* |
1125 | * Check if debugfs directory already exist before creating it. | ||
1126 | * This may happen when, for example, resetting hw or suspend-resume | ||
1127 | */ | ||
1128 | if (!dbgfs_dir || mvmvif->dbgfs_dir) | ||
992 | return; | 1129 | return; |
993 | 1130 | ||
994 | mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir); | 1131 | mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-d3.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-d3.h index 6f8b2c16ae17..df72fcdf8170 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api-d3.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-d3.h | |||
@@ -98,34 +98,63 @@ enum iwl_proto_offloads { | |||
98 | IWL_D3_PROTO_OFFLOAD_NS = BIT(1), | 98 | IWL_D3_PROTO_OFFLOAD_NS = BIT(1), |
99 | }; | 99 | }; |
100 | 100 | ||
101 | #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS 2 | 101 | #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1 2 |
102 | #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2 6 | ||
103 | #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX 6 | ||
102 | 104 | ||
103 | /** | 105 | /** |
104 | * struct iwl_proto_offload_cmd - ARP/NS offload configuration | 106 | * struct iwl_proto_offload_cmd_common - ARP/NS offload common part |
105 | * @enabled: enable flags | 107 | * @enabled: enable flags |
106 | * @remote_ipv4_addr: remote address to answer to (or zero if all) | 108 | * @remote_ipv4_addr: remote address to answer to (or zero if all) |
107 | * @host_ipv4_addr: our IPv4 address to respond to queries for | 109 | * @host_ipv4_addr: our IPv4 address to respond to queries for |
108 | * @arp_mac_addr: our MAC address for ARP responses | 110 | * @arp_mac_addr: our MAC address for ARP responses |
109 | * @remote_ipv6_addr: remote address to answer to (or zero if all) | 111 | * @reserved: unused |
110 | * @solicited_node_ipv6_addr: broken -- solicited node address exists | ||
111 | * for each target address | ||
112 | * @target_ipv6_addr: our target addresses | ||
113 | * @ndp_mac_addr: neighbor soliciation response MAC address | ||
114 | */ | 112 | */ |
115 | struct iwl_proto_offload_cmd { | 113 | struct iwl_proto_offload_cmd_common { |
116 | __le32 enabled; | 114 | __le32 enabled; |
117 | __be32 remote_ipv4_addr; | 115 | __be32 remote_ipv4_addr; |
118 | __be32 host_ipv4_addr; | 116 | __be32 host_ipv4_addr; |
119 | u8 arp_mac_addr[ETH_ALEN]; | 117 | u8 arp_mac_addr[ETH_ALEN]; |
120 | __le16 reserved1; | 118 | __le16 reserved; |
119 | } __packed; | ||
121 | 120 | ||
121 | /** | ||
122 | * struct iwl_proto_offload_cmd_v1 - ARP/NS offload configuration | ||
123 | * @common: common/IPv4 configuration | ||
124 | * @remote_ipv6_addr: remote address to answer to (or zero if all) | ||
125 | * @solicited_node_ipv6_addr: broken -- solicited node address exists | ||
126 | * for each target address | ||
127 | * @target_ipv6_addr: our target addresses | ||
128 | * @ndp_mac_addr: neighbor soliciation response MAC address | ||
129 | */ | ||
130 | struct iwl_proto_offload_cmd_v1 { | ||
131 | struct iwl_proto_offload_cmd_common common; | ||
122 | u8 remote_ipv6_addr[16]; | 132 | u8 remote_ipv6_addr[16]; |
123 | u8 solicited_node_ipv6_addr[16]; | 133 | u8 solicited_node_ipv6_addr[16]; |
124 | u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS][16]; | 134 | u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1][16]; |
125 | u8 ndp_mac_addr[ETH_ALEN]; | 135 | u8 ndp_mac_addr[ETH_ALEN]; |
126 | __le16 reserved2; | 136 | __le16 reserved2; |
127 | } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_1 */ | 137 | } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_1 */ |
128 | 138 | ||
139 | /** | ||
140 | * struct iwl_proto_offload_cmd_v2 - ARP/NS offload configuration | ||
141 | * @common: common/IPv4 configuration | ||
142 | * @remote_ipv6_addr: remote address to answer to (or zero if all) | ||
143 | * @solicited_node_ipv6_addr: broken -- solicited node address exists | ||
144 | * for each target address | ||
145 | * @target_ipv6_addr: our target addresses | ||
146 | * @ndp_mac_addr: neighbor soliciation response MAC address | ||
147 | */ | ||
148 | struct iwl_proto_offload_cmd_v2 { | ||
149 | struct iwl_proto_offload_cmd_common common; | ||
150 | u8 remote_ipv6_addr[16]; | ||
151 | u8 solicited_node_ipv6_addr[16]; | ||
152 | u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2][16]; | ||
153 | u8 ndp_mac_addr[ETH_ALEN]; | ||
154 | u8 numValidIPv6Addresses; | ||
155 | u8 reserved2[3]; | ||
156 | } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_2 */ | ||
157 | |||
129 | 158 | ||
130 | /* | 159 | /* |
131 | * WOWLAN_PATTERNS | 160 | * WOWLAN_PATTERNS |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h index a6da359a80c3..8e7ab41079ca 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h | |||
@@ -79,6 +79,10 @@ | |||
79 | * '1' Driver enables PM (use rest of parameters) | 79 | * '1' Driver enables PM (use rest of parameters) |
80 | * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM, | 80 | * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM, |
81 | * '1' PM could sleep over DTIM till listen Interval. | 81 | * '1' PM could sleep over DTIM till listen Interval. |
82 | * @POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all | ||
83 | * access categories are both delivery and trigger enabled. | ||
84 | * @POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and | ||
85 | * PBW Snoozing enabled | ||
82 | * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask | 86 | * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask |
83 | * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable. | 87 | * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable. |
84 | */ | 88 | */ |
@@ -86,6 +90,8 @@ enum iwl_power_flags { | |||
86 | POWER_FLAGS_POWER_SAVE_ENA_MSK = BIT(0), | 90 | POWER_FLAGS_POWER_SAVE_ENA_MSK = BIT(0), |
87 | POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK = BIT(1), | 91 | POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK = BIT(1), |
88 | POWER_FLAGS_SKIP_OVER_DTIM_MSK = BIT(2), | 92 | POWER_FLAGS_SKIP_OVER_DTIM_MSK = BIT(2), |
93 | POWER_FLAGS_SNOOZE_ENA_MSK = BIT(5), | ||
94 | POWER_FLAGS_BT_SCO_ENA = BIT(8), | ||
89 | POWER_FLAGS_ADVANCE_PM_ENA_MSK = BIT(9), | 95 | POWER_FLAGS_ADVANCE_PM_ENA_MSK = BIT(9), |
90 | POWER_FLAGS_LPRX_ENA_MSK = BIT(11), | 96 | POWER_FLAGS_LPRX_ENA_MSK = BIT(11), |
91 | }; | 97 | }; |
@@ -93,7 +99,8 @@ enum iwl_power_flags { | |||
93 | #define IWL_POWER_VEC_SIZE 5 | 99 | #define IWL_POWER_VEC_SIZE 5 |
94 | 100 | ||
95 | /** | 101 | /** |
96 | * struct iwl_powertable_cmd - Power Table Command | 102 | * struct iwl_powertable_cmd - legacy power command. Beside old API support this |
103 | * is used also with a new power API for device wide power settings. | ||
97 | * POWER_TABLE_CMD = 0x77 (command, has simple generic response) | 104 | * POWER_TABLE_CMD = 0x77 (command, has simple generic response) |
98 | * | 105 | * |
99 | * @flags: Power table command flags from POWER_FLAGS_* | 106 | * @flags: Power table command flags from POWER_FLAGS_* |
@@ -125,6 +132,76 @@ struct iwl_powertable_cmd { | |||
125 | } __packed; | 132 | } __packed; |
126 | 133 | ||
127 | /** | 134 | /** |
135 | * struct iwl_mac_power_cmd - New power command containing uAPSD support | ||
136 | * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response) | ||
137 | * @id_and_color: MAC contex identifier | ||
138 | * @flags: Power table command flags from POWER_FLAGS_* | ||
139 | * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec. | ||
140 | * Minimum allowed:- 3 * DTIM. Keep alive period must be | ||
141 | * set regardless of power scheme or current power state. | ||
142 | * FW use this value also when PM is disabled. | ||
143 | * @rx_data_timeout: Minimum time (usec) from last Rx packet for AM to | ||
144 | * PSM transition - legacy PM | ||
145 | * @tx_data_timeout: Minimum time (usec) from last Tx packet for AM to | ||
146 | * PSM transition - legacy PM | ||
147 | * @sleep_interval: not in use | ||
148 | * @skip_dtim_periods: Number of DTIM periods to skip if Skip over DTIM flag | ||
149 | * is set. For example, if it is required to skip over | ||
150 | * one DTIM, this value need to be set to 2 (DTIM periods). | ||
151 | * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to | ||
152 | * PSM transition - uAPSD | ||
153 | * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to | ||
154 | * PSM transition - uAPSD | ||
155 | * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled. | ||
156 | * Default: 80dbm | ||
157 | * @num_skip_dtim: Number of DTIMs to skip if Skip over DTIM flag is set | ||
158 | * @snooze_interval: Maximum time between attempts to retrieve buffered data | ||
159 | * from the AP [msec] | ||
160 | * @snooze_window: A window of time in which PBW snoozing insures that all | ||
161 | * packets received. It is also the minimum time from last | ||
162 | * received unicast RX packet, before client stops snoozing | ||
163 | * for data. [msec] | ||
164 | * @snooze_step: TBD | ||
165 | * @qndp_tid: TID client shall use for uAPSD QNDP triggers | ||
166 | * @uapsd_ac_flags: Set trigger-enabled and delivery-enabled indication for | ||
167 | * each corresponding AC. | ||
168 | * Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values. | ||
169 | * @uapsd_max_sp: Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct | ||
170 | * values. | ||
171 | * @heavy_tx_thld_packets: TX threshold measured in number of packets | ||
172 | * @heavy_rx_thld_packets: RX threshold measured in number of packets | ||
173 | * @heavy_tx_thld_percentage: TX threshold measured in load's percentage | ||
174 | * @heavy_rx_thld_percentage: RX threshold measured in load's percentage | ||
175 | * @limited_ps_threshold: | ||
176 | */ | ||
177 | struct iwl_mac_power_cmd { | ||
178 | /* CONTEXT_DESC_API_T_VER_1 */ | ||
179 | __le32 id_and_color; | ||
180 | |||
181 | /* CLIENT_PM_POWER_TABLE_S_VER_1 */ | ||
182 | __le16 flags; | ||
183 | __le16 keep_alive_seconds; | ||
184 | __le32 rx_data_timeout; | ||
185 | __le32 tx_data_timeout; | ||
186 | __le32 rx_data_timeout_uapsd; | ||
187 | __le32 tx_data_timeout_uapsd; | ||
188 | u8 lprx_rssi_threshold; | ||
189 | u8 skip_dtim_periods; | ||
190 | __le16 snooze_interval; | ||
191 | __le16 snooze_window; | ||
192 | u8 snooze_step; | ||
193 | u8 qndp_tid; | ||
194 | u8 uapsd_ac_flags; | ||
195 | u8 uapsd_max_sp; | ||
196 | u8 heavy_tx_thld_packets; | ||
197 | u8 heavy_rx_thld_packets; | ||
198 | u8 heavy_tx_thld_percentage; | ||
199 | u8 heavy_rx_thld_percentage; | ||
200 | u8 limited_ps_threshold; | ||
201 | u8 reserved; | ||
202 | } __packed; | ||
203 | |||
204 | /** | ||
128 | * struct iwl_beacon_filter_cmd | 205 | * struct iwl_beacon_filter_cmd |
129 | * REPLY_BEACON_FILTERING_CMD = 0xd2 (command) | 206 | * REPLY_BEACON_FILTERING_CMD = 0xd2 (command) |
130 | * @id_and_color: MAC contex identifier | 207 | * @id_and_color: MAC contex identifier |
@@ -143,11 +220,21 @@ struct iwl_powertable_cmd { | |||
143 | * calculated for current beacon is less than the threshold, use | 220 | * calculated for current beacon is less than the threshold, use |
144 | * Roaming Energy Delta Threshold, otherwise use normal Energy Delta | 221 | * Roaming Energy Delta Threshold, otherwise use normal Energy Delta |
145 | * Threshold. Typical energy threshold is -72dBm. | 222 | * Threshold. Typical energy threshold is -72dBm. |
146 | * @bf_temperature_delta: Send Beacon to driver if delta in temperature values | 223 | * @bf_temp_threshold: This threshold determines the type of temperature |
147 | * calculated for this and the last passed beacon is greater than this | 224 | * filtering (Slow or Fast) that is selected (Units are in Celsuis): |
148 | * threshold. Zero value means that the temperature changeis ignored for | 225 | * If the current temperature is above this threshold - Fast filter |
226 | * will be used, If the current temperature is below this threshold - | ||
227 | * Slow filter will be used. | ||
228 | * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values | ||
229 | * calculated for this and the last passed beacon is greater than this | ||
230 | * threshold. Zero value means that the temperature change is ignored for | ||
149 | * beacon filtering; beacons will not be forced to be sent to driver | 231 | * beacon filtering; beacons will not be forced to be sent to driver |
150 | * regardless of whether its temerature has been changed. | 232 | * regardless of whether its temerature has been changed. |
233 | * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values | ||
234 | * calculated for this and the last passed beacon is greater than this | ||
235 | * threshold. Zero value means that the temperature change is ignored for | ||
236 | * beacon filtering; beacons will not be forced to be sent to driver | ||
237 | * regardless of whether its temerature has been changed. | ||
151 | * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled. | 238 | * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled. |
152 | * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed | 239 | * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed |
153 | * for a specific period of time. Units: Beacons. | 240 | * for a specific period of time. Units: Beacons. |
@@ -156,17 +243,17 @@ struct iwl_powertable_cmd { | |||
156 | * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled. | 243 | * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled. |
157 | */ | 244 | */ |
158 | struct iwl_beacon_filter_cmd { | 245 | struct iwl_beacon_filter_cmd { |
159 | u8 bf_energy_delta; | 246 | __le32 bf_energy_delta; |
160 | u8 bf_roaming_energy_delta; | 247 | __le32 bf_roaming_energy_delta; |
161 | u8 bf_roaming_state; | 248 | __le32 bf_roaming_state; |
162 | u8 bf_temperature_delta; | 249 | __le32 bf_temp_threshold; |
163 | u8 bf_enable_beacon_filter; | 250 | __le32 bf_temp_fast_filter; |
164 | u8 bf_debug_flag; | 251 | __le32 bf_temp_slow_filter; |
165 | __le16 reserved1; | 252 | __le32 bf_enable_beacon_filter; |
253 | __le32 bf_debug_flag; | ||
166 | __le32 bf_escape_timer; | 254 | __le32 bf_escape_timer; |
167 | __le32 ba_escape_timer; | 255 | __le32 ba_escape_timer; |
168 | u8 ba_enable_beacon_abort; | 256 | __le32 ba_enable_beacon_abort; |
169 | u8 reserved2[3]; | ||
170 | } __packed; | 257 | } __packed; |
171 | 258 | ||
172 | /* Beacon filtering and beacon abort */ | 259 | /* Beacon filtering and beacon abort */ |
@@ -182,9 +269,17 @@ struct iwl_beacon_filter_cmd { | |||
182 | #define IWL_BF_ROAMING_STATE_MAX 255 | 269 | #define IWL_BF_ROAMING_STATE_MAX 255 |
183 | #define IWL_BF_ROAMING_STATE_MIN 0 | 270 | #define IWL_BF_ROAMING_STATE_MIN 0 |
184 | 271 | ||
185 | #define IWL_BF_TEMPERATURE_DELTA_DEFAULT 5 | 272 | #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112 |
186 | #define IWL_BF_TEMPERATURE_DELTA_MAX 255 | 273 | #define IWL_BF_TEMP_THRESHOLD_MAX 255 |
187 | #define IWL_BF_TEMPERATURE_DELTA_MIN 0 | 274 | #define IWL_BF_TEMP_THRESHOLD_MIN 0 |
275 | |||
276 | #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1 | ||
277 | #define IWL_BF_TEMP_FAST_FILTER_MAX 255 | ||
278 | #define IWL_BF_TEMP_FAST_FILTER_MIN 0 | ||
279 | |||
280 | #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5 | ||
281 | #define IWL_BF_TEMP_SLOW_FILTER_MAX 255 | ||
282 | #define IWL_BF_TEMP_SLOW_FILTER_MIN 0 | ||
188 | 283 | ||
189 | #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1 | 284 | #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1 |
190 | 285 | ||
@@ -194,19 +289,23 @@ struct iwl_beacon_filter_cmd { | |||
194 | #define IWL_BF_ESCAPE_TIMER_MAX 1024 | 289 | #define IWL_BF_ESCAPE_TIMER_MAX 1024 |
195 | #define IWL_BF_ESCAPE_TIMER_MIN 0 | 290 | #define IWL_BF_ESCAPE_TIMER_MIN 0 |
196 | 291 | ||
197 | #define IWL_BA_ESCAPE_TIMER_DEFAULT 3 | 292 | #define IWL_BA_ESCAPE_TIMER_DEFAULT 6 |
293 | #define IWL_BA_ESCAPE_TIMER_D3 6 | ||
198 | #define IWL_BA_ESCAPE_TIMER_MAX 1024 | 294 | #define IWL_BA_ESCAPE_TIMER_MAX 1024 |
199 | #define IWL_BA_ESCAPE_TIMER_MIN 0 | 295 | #define IWL_BA_ESCAPE_TIMER_MIN 0 |
200 | 296 | ||
201 | #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1 | 297 | #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1 |
202 | 298 | ||
203 | #define IWL_BF_CMD_CONFIG_DEFAULTS \ | 299 | #define IWL_BF_CMD_CONFIG_DEFAULTS \ |
204 | .bf_energy_delta = IWL_BF_ENERGY_DELTA_DEFAULT, \ | 300 | .bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA_DEFAULT), \ |
205 | .bf_roaming_energy_delta = IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT, \ | 301 | .bf_roaming_energy_delta = \ |
206 | .bf_roaming_state = IWL_BF_ROAMING_STATE_DEFAULT, \ | 302 | cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT), \ |
207 | .bf_temperature_delta = IWL_BF_TEMPERATURE_DELTA_DEFAULT, \ | 303 | .bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE_DEFAULT), \ |
208 | .bf_debug_flag = IWL_BF_DEBUG_FLAG_DEFAULT, \ | 304 | .bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD_DEFAULT), \ |
209 | .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT), \ | 305 | .bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER_DEFAULT), \ |
306 | .bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER_DEFAULT), \ | ||
307 | .bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG_DEFAULT), \ | ||
308 | .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT), \ | ||
210 | .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT) | 309 | .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT) |
211 | 310 | ||
212 | #endif | 311 | #endif |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h index b60d14151721..83cb9b992ea4 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h | |||
@@ -69,7 +69,6 @@ | |||
69 | /* Scan Commands, Responses, Notifications */ | 69 | /* Scan Commands, Responses, Notifications */ |
70 | 70 | ||
71 | /* Masks for iwl_scan_channel.type flags */ | 71 | /* Masks for iwl_scan_channel.type flags */ |
72 | #define SCAN_CHANNEL_TYPE_PASSIVE 0 | ||
73 | #define SCAN_CHANNEL_TYPE_ACTIVE BIT(0) | 72 | #define SCAN_CHANNEL_TYPE_ACTIVE BIT(0) |
74 | #define SCAN_CHANNEL_NARROW_BAND BIT(22) | 73 | #define SCAN_CHANNEL_NARROW_BAND BIT(22) |
75 | 74 | ||
@@ -138,6 +137,8 @@ struct iwl_ssid_ie { | |||
138 | *@SCAN_FLAGS_DELAYED_SCAN_LOWBAND: | 137 | *@SCAN_FLAGS_DELAYED_SCAN_LOWBAND: |
139 | *@SCAN_FLAGS_DELAYED_SCAN_HIGHBAND: | 138 | *@SCAN_FLAGS_DELAYED_SCAN_HIGHBAND: |
140 | *@SCAN_FLAGS_FRAGMENTED_SCAN: | 139 | *@SCAN_FLAGS_FRAGMENTED_SCAN: |
140 | *@SCAN_FLAGS_PASSIVE2ACTIVE: use active scan on channels that was active | ||
141 | * in the past hour, even if they are marked as passive. | ||
141 | */ | 142 | */ |
142 | enum iwl_scan_flags { | 143 | enum iwl_scan_flags { |
143 | SCAN_FLAGS_PERIODIC_SCAN = BIT(0), | 144 | SCAN_FLAGS_PERIODIC_SCAN = BIT(0), |
@@ -145,6 +146,7 @@ enum iwl_scan_flags { | |||
145 | SCAN_FLAGS_DELAYED_SCAN_LOWBAND = BIT(2), | 146 | SCAN_FLAGS_DELAYED_SCAN_LOWBAND = BIT(2), |
146 | SCAN_FLAGS_DELAYED_SCAN_HIGHBAND = BIT(3), | 147 | SCAN_FLAGS_DELAYED_SCAN_HIGHBAND = BIT(3), |
147 | SCAN_FLAGS_FRAGMENTED_SCAN = BIT(4), | 148 | SCAN_FLAGS_FRAGMENTED_SCAN = BIT(4), |
149 | SCAN_FLAGS_PASSIVE2ACTIVE = BIT(5), | ||
148 | }; | 150 | }; |
149 | 151 | ||
150 | /** | 152 | /** |
@@ -179,7 +181,7 @@ enum iwl_scan_type { | |||
179 | * @quiet_time: in msecs, dwell this time for active scan on quiet channels | 181 | * @quiet_time: in msecs, dwell this time for active scan on quiet channels |
180 | * @quiet_plcp_th: quiet PLCP threshold (channel is quiet if less than | 182 | * @quiet_plcp_th: quiet PLCP threshold (channel is quiet if less than |
181 | * this number of packets were received (typically 1) | 183 | * this number of packets were received (typically 1) |
182 | * @passive2active: is auto switching from passive to active allowed (0 or 1) | 184 | * @passive2active: is auto switching from passive to active during scan allowed |
183 | * @rxchain_sel_flags: RXON_RX_CHAIN_* | 185 | * @rxchain_sel_flags: RXON_RX_CHAIN_* |
184 | * @max_out_time: in usecs, max out of serving channel time | 186 | * @max_out_time: in usecs, max out of serving channel time |
185 | * @suspend_time: how long to pause scan when returning to service channel: | 187 | * @suspend_time: how long to pause scan when returning to service channel: |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-tx.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-tx.h index 700cce731770..d606197bde8f 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api-tx.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-tx.h | |||
@@ -91,7 +91,6 @@ | |||
91 | * @TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW | 91 | * @TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW |
92 | * @TX_CMD_FLG_CCMP_AGG: this frame uses CCMP for aggregation acceleration | 92 | * @TX_CMD_FLG_CCMP_AGG: this frame uses CCMP for aggregation acceleration |
93 | * @TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation | 93 | * @TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation |
94 | * @TX_CMD_FLG_CTS_ONLY: send CTS only, no data after that | ||
95 | * @TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id | 94 | * @TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id |
96 | * @TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped | 95 | * @TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped |
97 | * @TX_CMD_FLG_EXEC_PAPD: execute PAPD | 96 | * @TX_CMD_FLG_EXEC_PAPD: execute PAPD |
@@ -120,7 +119,6 @@ enum iwl_tx_flags { | |||
120 | TX_CMD_FLG_RESP_TO_DRV = BIT(21), | 119 | TX_CMD_FLG_RESP_TO_DRV = BIT(21), |
121 | TX_CMD_FLG_CCMP_AGG = BIT(22), | 120 | TX_CMD_FLG_CCMP_AGG = BIT(22), |
122 | TX_CMD_FLG_TKIP_MIC_DONE = BIT(23), | 121 | TX_CMD_FLG_TKIP_MIC_DONE = BIT(23), |
123 | TX_CMD_FLG_CTS_ONLY = BIT(24), | ||
124 | TX_CMD_FLG_DUR = BIT(25), | 122 | TX_CMD_FLG_DUR = BIT(25), |
125 | TX_CMD_FLG_FW_DROP = BIT(26), | 123 | TX_CMD_FLG_FW_DROP = BIT(26), |
126 | TX_CMD_FLG_EXEC_PAPD = BIT(27), | 124 | TX_CMD_FLG_EXEC_PAPD = BIT(27), |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h index cbfb3beae783..66264cc5a016 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h | |||
@@ -136,7 +136,7 @@ enum { | |||
136 | CALIB_RES_NOTIF_PHY_DB = 0x6b, | 136 | CALIB_RES_NOTIF_PHY_DB = 0x6b, |
137 | /* PHY_DB_CMD = 0x6c, */ | 137 | /* PHY_DB_CMD = 0x6c, */ |
138 | 138 | ||
139 | /* Power */ | 139 | /* Power - legacy power table command */ |
140 | POWER_TABLE_CMD = 0x77, | 140 | POWER_TABLE_CMD = 0x77, |
141 | 141 | ||
142 | /* Thermal Throttling*/ | 142 | /* Thermal Throttling*/ |
@@ -159,6 +159,7 @@ enum { | |||
159 | TX_ANT_CONFIGURATION_CMD = 0x98, | 159 | TX_ANT_CONFIGURATION_CMD = 0x98, |
160 | BT_CONFIG = 0x9b, | 160 | BT_CONFIG = 0x9b, |
161 | STATISTICS_NOTIFICATION = 0x9d, | 161 | STATISTICS_NOTIFICATION = 0x9d, |
162 | REDUCE_TX_POWER_CMD = 0x9f, | ||
162 | 163 | ||
163 | /* RF-KILL commands and notifications */ | 164 | /* RF-KILL commands and notifications */ |
164 | CARD_STATE_CMD = 0xa0, | 165 | CARD_STATE_CMD = 0xa0, |
@@ -166,6 +167,9 @@ enum { | |||
166 | 167 | ||
167 | MISSED_BEACONS_NOTIFICATION = 0xa2, | 168 | MISSED_BEACONS_NOTIFICATION = 0xa2, |
168 | 169 | ||
170 | /* Power - new power table command */ | ||
171 | MAC_PM_POWER_TABLE = 0xa9, | ||
172 | |||
169 | REPLY_RX_PHY_CMD = 0xc0, | 173 | REPLY_RX_PHY_CMD = 0xc0, |
170 | REPLY_RX_MPDU_CMD = 0xc1, | 174 | REPLY_RX_MPDU_CMD = 0xc1, |
171 | BA_NOTIF = 0xc5, | 175 | BA_NOTIF = 0xc5, |
@@ -223,6 +227,19 @@ struct iwl_tx_ant_cfg_cmd { | |||
223 | __le32 valid; | 227 | __le32 valid; |
224 | } __packed; | 228 | } __packed; |
225 | 229 | ||
230 | /** | ||
231 | * struct iwl_reduce_tx_power_cmd - TX power reduction command | ||
232 | * REDUCE_TX_POWER_CMD = 0x9f | ||
233 | * @flags: (reserved for future implementation) | ||
234 | * @mac_context_id: id of the mac ctx for which we are reducing TX power. | ||
235 | * @pwr_restriction: TX power restriction in dBms. | ||
236 | */ | ||
237 | struct iwl_reduce_tx_power_cmd { | ||
238 | u8 flags; | ||
239 | u8 mac_context_id; | ||
240 | __le16 pwr_restriction; | ||
241 | } __packed; /* TX_REDUCED_POWER_API_S_VER_1 */ | ||
242 | |||
226 | /* | 243 | /* |
227 | * Calibration control struct. | 244 | * Calibration control struct. |
228 | * Sent as part of the phy configuration command. | 245 | * Sent as part of the phy configuration command. |
@@ -482,71 +499,199 @@ enum iwl_time_event_type { | |||
482 | TE_MAX | 499 | TE_MAX |
483 | }; /* MAC_EVENT_TYPE_API_E_VER_1 */ | 500 | }; /* MAC_EVENT_TYPE_API_E_VER_1 */ |
484 | 501 | ||
502 | |||
503 | |||
504 | /* Time event - defines for command API v1 */ | ||
505 | |||
506 | /* | ||
507 | * @TE_V1_FRAG_NONE: fragmentation of the time event is NOT allowed. | ||
508 | * @TE_V1_FRAG_SINGLE: fragmentation of the time event is allowed, but only | ||
509 | * the first fragment is scheduled. | ||
510 | * @TE_V1_FRAG_DUAL: fragmentation of the time event is allowed, but only | ||
511 | * the first 2 fragments are scheduled. | ||
512 | * @TE_V1_FRAG_ENDLESS: fragmentation of the time event is allowed, and any | ||
513 | * number of fragments are valid. | ||
514 | * | ||
515 | * Other than the constant defined above, specifying a fragmentation value 'x' | ||
516 | * means that the event can be fragmented but only the first 'x' will be | ||
517 | * scheduled. | ||
518 | */ | ||
519 | enum { | ||
520 | TE_V1_FRAG_NONE = 0, | ||
521 | TE_V1_FRAG_SINGLE = 1, | ||
522 | TE_V1_FRAG_DUAL = 2, | ||
523 | TE_V1_FRAG_ENDLESS = 0xffffffff | ||
524 | }; | ||
525 | |||
526 | /* If a Time Event can be fragmented, this is the max number of fragments */ | ||
527 | #define TE_V1_FRAG_MAX_MSK 0x0fffffff | ||
528 | /* Repeat the time event endlessly (until removed) */ | ||
529 | #define TE_V1_REPEAT_ENDLESS 0xffffffff | ||
530 | /* If a Time Event has bounded repetitions, this is the maximal value */ | ||
531 | #define TE_V1_REPEAT_MAX_MSK_V1 0x0fffffff | ||
532 | |||
485 | /* Time Event dependencies: none, on another TE, or in a specific time */ | 533 | /* Time Event dependencies: none, on another TE, or in a specific time */ |
486 | enum { | 534 | enum { |
487 | TE_INDEPENDENT = 0, | 535 | TE_V1_INDEPENDENT = 0, |
488 | TE_DEP_OTHER = 1, | 536 | TE_V1_DEP_OTHER = BIT(0), |
489 | TE_DEP_TSF = 2, | 537 | TE_V1_DEP_TSF = BIT(1), |
490 | TE_EVENT_SOCIOPATHIC = 4, | 538 | TE_V1_EVENT_SOCIOPATHIC = BIT(2), |
491 | }; /* MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */ | 539 | }; /* MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */ |
540 | |||
492 | /* | 541 | /* |
542 | * @TE_V1_NOTIF_NONE: no notifications | ||
543 | * @TE_V1_NOTIF_HOST_EVENT_START: request/receive notification on event start | ||
544 | * @TE_V1_NOTIF_HOST_EVENT_END:request/receive notification on event end | ||
545 | * @TE_V1_NOTIF_INTERNAL_EVENT_START: internal FW use | ||
546 | * @TE_V1_NOTIF_INTERNAL_EVENT_END: internal FW use. | ||
547 | * @TE_V1_NOTIF_HOST_FRAG_START: request/receive notification on frag start | ||
548 | * @TE_V1_NOTIF_HOST_FRAG_END:request/receive notification on frag end | ||
549 | * @TE_V1_NOTIF_INTERNAL_FRAG_START: internal FW use. | ||
550 | * @TE_V1_NOTIF_INTERNAL_FRAG_END: internal FW use. | ||
551 | * | ||
493 | * Supported Time event notifications configuration. | 552 | * Supported Time event notifications configuration. |
494 | * A notification (both event and fragment) includes a status indicating weather | 553 | * A notification (both event and fragment) includes a status indicating weather |
495 | * the FW was able to schedule the event or not. For fragment start/end | 554 | * the FW was able to schedule the event or not. For fragment start/end |
496 | * notification the status is always success. There is no start/end fragment | 555 | * notification the status is always success. There is no start/end fragment |
497 | * notification for monolithic events. | 556 | * notification for monolithic events. |
498 | * | ||
499 | * @TE_NOTIF_NONE: no notifications | ||
500 | * @TE_NOTIF_HOST_EVENT_START: request/receive notification on event start | ||
501 | * @TE_NOTIF_HOST_EVENT_END:request/receive notification on event end | ||
502 | * @TE_NOTIF_INTERNAL_EVENT_START: internal FW use | ||
503 | * @TE_NOTIF_INTERNAL_EVENT_END: internal FW use. | ||
504 | * @TE_NOTIF_HOST_FRAG_START: request/receive notification on frag start | ||
505 | * @TE_NOTIF_HOST_FRAG_END:request/receive notification on frag end | ||
506 | * @TE_NOTIF_INTERNAL_FRAG_START: internal FW use. | ||
507 | * @TE_NOTIF_INTERNAL_FRAG_END: internal FW use. | ||
508 | */ | 557 | */ |
509 | enum { | 558 | enum { |
510 | TE_NOTIF_NONE = 0, | 559 | TE_V1_NOTIF_NONE = 0, |
511 | TE_NOTIF_HOST_EVENT_START = 0x1, | 560 | TE_V1_NOTIF_HOST_EVENT_START = BIT(0), |
512 | TE_NOTIF_HOST_EVENT_END = 0x2, | 561 | TE_V1_NOTIF_HOST_EVENT_END = BIT(1), |
513 | TE_NOTIF_INTERNAL_EVENT_START = 0x4, | 562 | TE_V1_NOTIF_INTERNAL_EVENT_START = BIT(2), |
514 | TE_NOTIF_INTERNAL_EVENT_END = 0x8, | 563 | TE_V1_NOTIF_INTERNAL_EVENT_END = BIT(3), |
515 | TE_NOTIF_HOST_FRAG_START = 0x10, | 564 | TE_V1_NOTIF_HOST_FRAG_START = BIT(4), |
516 | TE_NOTIF_HOST_FRAG_END = 0x20, | 565 | TE_V1_NOTIF_HOST_FRAG_END = BIT(5), |
517 | TE_NOTIF_INTERNAL_FRAG_START = 0x40, | 566 | TE_V1_NOTIF_INTERNAL_FRAG_START = BIT(6), |
518 | TE_NOTIF_INTERNAL_FRAG_END = 0x80 | 567 | TE_V1_NOTIF_INTERNAL_FRAG_END = BIT(7), |
519 | }; /* MAC_EVENT_ACTION_API_E_VER_2 */ | 568 | }; /* MAC_EVENT_ACTION_API_E_VER_2 */ |
520 | 569 | ||
570 | |||
571 | /** | ||
572 | * struct iwl_time_event_cmd_api_v1 - configuring Time Events | ||
573 | * with struct MAC_TIME_EVENT_DATA_API_S_VER_1 (see also | ||
574 | * with version 2. determined by IWL_UCODE_TLV_FLAGS) | ||
575 | * ( TIME_EVENT_CMD = 0x29 ) | ||
576 | * @id_and_color: ID and color of the relevant MAC | ||
577 | * @action: action to perform, one of FW_CTXT_ACTION_* | ||
578 | * @id: this field has two meanings, depending on the action: | ||
579 | * If the action is ADD, then it means the type of event to add. | ||
580 | * For all other actions it is the unique event ID assigned when the | ||
581 | * event was added by the FW. | ||
582 | * @apply_time: When to start the Time Event (in GP2) | ||
583 | * @max_delay: maximum delay to event's start (apply time), in TU | ||
584 | * @depends_on: the unique ID of the event we depend on (if any) | ||
585 | * @interval: interval between repetitions, in TU | ||
586 | * @interval_reciprocal: 2^32 / interval | ||
587 | * @duration: duration of event in TU | ||
588 | * @repeat: how many repetitions to do, can be TE_REPEAT_ENDLESS | ||
589 | * @dep_policy: one of TE_V1_INDEPENDENT, TE_V1_DEP_OTHER, TE_V1_DEP_TSF | ||
590 | * and TE_V1_EVENT_SOCIOPATHIC | ||
591 | * @is_present: 0 or 1, are we present or absent during the Time Event | ||
592 | * @max_frags: maximal number of fragments the Time Event can be divided to | ||
593 | * @notify: notifications using TE_V1_NOTIF_* (whom to notify when) | ||
594 | */ | ||
595 | struct iwl_time_event_cmd_v1 { | ||
596 | /* COMMON_INDEX_HDR_API_S_VER_1 */ | ||
597 | __le32 id_and_color; | ||
598 | __le32 action; | ||
599 | __le32 id; | ||
600 | /* MAC_TIME_EVENT_DATA_API_S_VER_1 */ | ||
601 | __le32 apply_time; | ||
602 | __le32 max_delay; | ||
603 | __le32 dep_policy; | ||
604 | __le32 depends_on; | ||
605 | __le32 is_present; | ||
606 | __le32 max_frags; | ||
607 | __le32 interval; | ||
608 | __le32 interval_reciprocal; | ||
609 | __le32 duration; | ||
610 | __le32 repeat; | ||
611 | __le32 notify; | ||
612 | } __packed; /* MAC_TIME_EVENT_CMD_API_S_VER_1 */ | ||
613 | |||
614 | |||
615 | /* Time event - defines for command API v2 */ | ||
616 | |||
521 | /* | 617 | /* |
522 | * @TE_FRAG_NONE: fragmentation of the time event is NOT allowed. | 618 | * @TE_V2_FRAG_NONE: fragmentation of the time event is NOT allowed. |
523 | * @TE_FRAG_SINGLE: fragmentation of the time event is allowed, but only | 619 | * @TE_V2_FRAG_SINGLE: fragmentation of the time event is allowed, but only |
524 | * the first fragment is scheduled. | 620 | * the first fragment is scheduled. |
525 | * @TE_FRAG_DUAL: fragmentation of the time event is allowed, but only | 621 | * @TE_V2_FRAG_DUAL: fragmentation of the time event is allowed, but only |
526 | * the first 2 fragments are scheduled. | 622 | * the first 2 fragments are scheduled. |
527 | * @TE_FRAG_ENDLESS: fragmentation of the time event is allowed, and any number | 623 | * @TE_V2_FRAG_ENDLESS: fragmentation of the time event is allowed, and any |
528 | * of fragments are valid. | 624 | * number of fragments are valid. |
529 | * | 625 | * |
530 | * Other than the constant defined above, specifying a fragmentation value 'x' | 626 | * Other than the constant defined above, specifying a fragmentation value 'x' |
531 | * means that the event can be fragmented but only the first 'x' will be | 627 | * means that the event can be fragmented but only the first 'x' will be |
532 | * scheduled. | 628 | * scheduled. |
533 | */ | 629 | */ |
534 | enum { | 630 | enum { |
535 | TE_FRAG_NONE = 0, | 631 | TE_V2_FRAG_NONE = 0, |
536 | TE_FRAG_SINGLE = 1, | 632 | TE_V2_FRAG_SINGLE = 1, |
537 | TE_FRAG_DUAL = 2, | 633 | TE_V2_FRAG_DUAL = 2, |
538 | TE_FRAG_ENDLESS = 0xffffffff | 634 | TE_V2_FRAG_MAX = 0xfe, |
635 | TE_V2_FRAG_ENDLESS = 0xff | ||
539 | }; | 636 | }; |
540 | 637 | ||
541 | /* Repeat the time event endlessly (until removed) */ | 638 | /* Repeat the time event endlessly (until removed) */ |
542 | #define TE_REPEAT_ENDLESS (0xffffffff) | 639 | #define TE_V2_REPEAT_ENDLESS 0xff |
543 | /* If a Time Event has bounded repetitions, this is the maximal value */ | 640 | /* If a Time Event has bounded repetitions, this is the maximal value */ |
544 | #define TE_REPEAT_MAX_MSK (0x0fffffff) | 641 | #define TE_V2_REPEAT_MAX 0xfe |
545 | /* If a Time Event can be fragmented, this is the max number of fragments */ | 642 | |
546 | #define TE_FRAG_MAX_MSK (0x0fffffff) | 643 | #define TE_V2_PLACEMENT_POS 12 |
644 | #define TE_V2_ABSENCE_POS 15 | ||
645 | |||
646 | /* Time event policy values (for time event cmd api v2) | ||
647 | * A notification (both event and fragment) includes a status indicating weather | ||
648 | * the FW was able to schedule the event or not. For fragment start/end | ||
649 | * notification the status is always success. There is no start/end fragment | ||
650 | * notification for monolithic events. | ||
651 | * | ||
652 | * @TE_V2_DEFAULT_POLICY: independent, social, present, unoticable | ||
653 | * @TE_V2_NOTIF_HOST_EVENT_START: request/receive notification on event start | ||
654 | * @TE_V2_NOTIF_HOST_EVENT_END:request/receive notification on event end | ||
655 | * @TE_V2_NOTIF_INTERNAL_EVENT_START: internal FW use | ||
656 | * @TE_V2_NOTIF_INTERNAL_EVENT_END: internal FW use. | ||
657 | * @TE_V2_NOTIF_HOST_FRAG_START: request/receive notification on frag start | ||
658 | * @TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end | ||
659 | * @TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use. | ||
660 | * @TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use. | ||
661 | * @TE_V2_DEP_OTHER: depends on another time event | ||
662 | * @TE_V2_DEP_TSF: depends on a specific time | ||
663 | * @TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC | ||
664 | * @TE_V2_ABSENCE: are we present or absent during the Time Event. | ||
665 | */ | ||
666 | enum { | ||
667 | TE_V2_DEFAULT_POLICY = 0x0, | ||
668 | |||
669 | /* notifications (event start/stop, fragment start/stop) */ | ||
670 | TE_V2_NOTIF_HOST_EVENT_START = BIT(0), | ||
671 | TE_V2_NOTIF_HOST_EVENT_END = BIT(1), | ||
672 | TE_V2_NOTIF_INTERNAL_EVENT_START = BIT(2), | ||
673 | TE_V2_NOTIF_INTERNAL_EVENT_END = BIT(3), | ||
674 | |||
675 | TE_V2_NOTIF_HOST_FRAG_START = BIT(4), | ||
676 | TE_V2_NOTIF_HOST_FRAG_END = BIT(5), | ||
677 | TE_V2_NOTIF_INTERNAL_FRAG_START = BIT(6), | ||
678 | TE_V2_NOTIF_INTERNAL_FRAG_END = BIT(7), | ||
679 | |||
680 | TE_V2_NOTIF_MSK = 0xff, | ||
681 | |||
682 | /* placement characteristics */ | ||
683 | TE_V2_DEP_OTHER = BIT(TE_V2_PLACEMENT_POS), | ||
684 | TE_V2_DEP_TSF = BIT(TE_V2_PLACEMENT_POS + 1), | ||
685 | TE_V2_EVENT_SOCIOPATHIC = BIT(TE_V2_PLACEMENT_POS + 2), | ||
686 | |||
687 | /* are we present or absent during the Time Event. */ | ||
688 | TE_V2_ABSENCE = BIT(TE_V2_ABSENCE_POS), | ||
689 | }; | ||
547 | 690 | ||
548 | /** | 691 | /** |
549 | * struct iwl_time_event_cmd - configuring Time Events | 692 | * struct iwl_time_event_cmd_api_v2 - configuring Time Events |
693 | * with struct MAC_TIME_EVENT_DATA_API_S_VER_2 (see also | ||
694 | * with version 1. determined by IWL_UCODE_TLV_FLAGS) | ||
550 | * ( TIME_EVENT_CMD = 0x29 ) | 695 | * ( TIME_EVENT_CMD = 0x29 ) |
551 | * @id_and_color: ID and color of the relevant MAC | 696 | * @id_and_color: ID and color of the relevant MAC |
552 | * @action: action to perform, one of FW_CTXT_ACTION_* | 697 | * @action: action to perform, one of FW_CTXT_ACTION_* |
@@ -558,32 +703,30 @@ enum { | |||
558 | * @max_delay: maximum delay to event's start (apply time), in TU | 703 | * @max_delay: maximum delay to event's start (apply time), in TU |
559 | * @depends_on: the unique ID of the event we depend on (if any) | 704 | * @depends_on: the unique ID of the event we depend on (if any) |
560 | * @interval: interval between repetitions, in TU | 705 | * @interval: interval between repetitions, in TU |
561 | * @interval_reciprocal: 2^32 / interval | ||
562 | * @duration: duration of event in TU | 706 | * @duration: duration of event in TU |
563 | * @repeat: how many repetitions to do, can be TE_REPEAT_ENDLESS | 707 | * @repeat: how many repetitions to do, can be TE_REPEAT_ENDLESS |
564 | * @dep_policy: one of TE_INDEPENDENT, TE_DEP_OTHER, TE_DEP_TSF | ||
565 | * @is_present: 0 or 1, are we present or absent during the Time Event | ||
566 | * @max_frags: maximal number of fragments the Time Event can be divided to | 708 | * @max_frags: maximal number of fragments the Time Event can be divided to |
567 | * @notify: notifications using TE_NOTIF_* (whom to notify when) | 709 | * @policy: defines whether uCode shall notify the host or other uCode modules |
710 | * on event and/or fragment start and/or end | ||
711 | * using one of TE_INDEPENDENT, TE_DEP_OTHER, TE_DEP_TSF | ||
712 | * TE_EVENT_SOCIOPATHIC | ||
713 | * using TE_ABSENCE and using TE_NOTIF_* | ||
568 | */ | 714 | */ |
569 | struct iwl_time_event_cmd { | 715 | struct iwl_time_event_cmd_v2 { |
570 | /* COMMON_INDEX_HDR_API_S_VER_1 */ | 716 | /* COMMON_INDEX_HDR_API_S_VER_1 */ |
571 | __le32 id_and_color; | 717 | __le32 id_and_color; |
572 | __le32 action; | 718 | __le32 action; |
573 | __le32 id; | 719 | __le32 id; |
574 | /* MAC_TIME_EVENT_DATA_API_S_VER_1 */ | 720 | /* MAC_TIME_EVENT_DATA_API_S_VER_2 */ |
575 | __le32 apply_time; | 721 | __le32 apply_time; |
576 | __le32 max_delay; | 722 | __le32 max_delay; |
577 | __le32 dep_policy; | ||
578 | __le32 depends_on; | 723 | __le32 depends_on; |
579 | __le32 is_present; | ||
580 | __le32 max_frags; | ||
581 | __le32 interval; | 724 | __le32 interval; |
582 | __le32 interval_reciprocal; | ||
583 | __le32 duration; | 725 | __le32 duration; |
584 | __le32 repeat; | 726 | u8 repeat; |
585 | __le32 notify; | 727 | u8 max_frags; |
586 | } __packed; /* MAC_TIME_EVENT_CMD_API_S_VER_1 */ | 728 | __le16 policy; |
729 | } __packed; /* MAC_TIME_EVENT_CMD_API_S_VER_2 */ | ||
587 | 730 | ||
588 | /** | 731 | /** |
589 | * struct iwl_time_event_resp - response structure to iwl_time_event_cmd | 732 | * struct iwl_time_event_resp - response structure to iwl_time_event_cmd |
@@ -765,6 +908,14 @@ struct iwl_phy_context_cmd { | |||
765 | } __packed; /* PHY_CONTEXT_CMD_API_VER_1 */ | 908 | } __packed; /* PHY_CONTEXT_CMD_API_VER_1 */ |
766 | 909 | ||
767 | #define IWL_RX_INFO_PHY_CNT 8 | 910 | #define IWL_RX_INFO_PHY_CNT 8 |
911 | #define IWL_RX_INFO_ENERGY_ANT_ABC_IDX 1 | ||
912 | #define IWL_RX_INFO_ENERGY_ANT_A_MSK 0x000000ff | ||
913 | #define IWL_RX_INFO_ENERGY_ANT_B_MSK 0x0000ff00 | ||
914 | #define IWL_RX_INFO_ENERGY_ANT_C_MSK 0x00ff0000 | ||
915 | #define IWL_RX_INFO_ENERGY_ANT_A_POS 0 | ||
916 | #define IWL_RX_INFO_ENERGY_ANT_B_POS 8 | ||
917 | #define IWL_RX_INFO_ENERGY_ANT_C_POS 16 | ||
918 | |||
768 | #define IWL_RX_INFO_AGC_IDX 1 | 919 | #define IWL_RX_INFO_AGC_IDX 1 |
769 | #define IWL_RX_INFO_RSSI_AB_IDX 2 | 920 | #define IWL_RX_INFO_RSSI_AB_IDX 2 |
770 | #define IWL_OFDM_AGC_A_MSK 0x0000007f | 921 | #define IWL_OFDM_AGC_A_MSK 0x0000007f |
@@ -1170,7 +1321,7 @@ struct mvm_statistics_general { | |||
1170 | struct mvm_statistics_general_common common; | 1321 | struct mvm_statistics_general_common common; |
1171 | __le32 beacon_filtered; | 1322 | __le32 beacon_filtered; |
1172 | __le32 missed_beacons; | 1323 | __le32 missed_beacons; |
1173 | __s8 beacon_filter_everage_energy; | 1324 | __s8 beacon_filter_average_energy; |
1174 | __s8 beacon_filter_reason; | 1325 | __s8 beacon_filter_reason; |
1175 | __s8 beacon_filter_current_energy; | 1326 | __s8 beacon_filter_current_energy; |
1176 | __s8 beacon_filter_reserved; | 1327 | __s8 beacon_filter_reserved; |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c index cd7c0032cc58..c76299a3a1e0 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/iwlwifi/mvm/fw.c | |||
@@ -78,22 +78,6 @@ | |||
78 | 78 | ||
79 | #define UCODE_VALID_OK cpu_to_le32(0x1) | 79 | #define UCODE_VALID_OK cpu_to_le32(0x1) |
80 | 80 | ||
81 | /* Default calibration values for WkP - set to INIT image w/o running */ | ||
82 | static const u8 wkp_calib_values_rx_iq_skew[] = { 0x00, 0x00, 0x01, 0x00 }; | ||
83 | static const u8 wkp_calib_values_tx_iq_skew[] = { 0x01, 0x00, 0x00, 0x00 }; | ||
84 | |||
85 | struct iwl_calib_default_data { | ||
86 | u16 size; | ||
87 | void *data; | ||
88 | }; | ||
89 | |||
90 | #define CALIB_SIZE_N_DATA(_buf) {.size = sizeof(_buf), .data = &_buf} | ||
91 | |||
92 | static const struct iwl_calib_default_data wkp_calib_default_data[12] = { | ||
93 | [9] = CALIB_SIZE_N_DATA(wkp_calib_values_tx_iq_skew), | ||
94 | [11] = CALIB_SIZE_N_DATA(wkp_calib_values_rx_iq_skew), | ||
95 | }; | ||
96 | |||
97 | struct iwl_mvm_alive_data { | 81 | struct iwl_mvm_alive_data { |
98 | bool valid; | 82 | bool valid; |
99 | u32 scd_base_addr; | 83 | u32 scd_base_addr; |
@@ -248,40 +232,6 @@ static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) | |||
248 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); | 232 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); |
249 | } | 233 | } |
250 | 234 | ||
251 | static int iwl_set_default_calibrations(struct iwl_mvm *mvm) | ||
252 | { | ||
253 | u8 cmd_raw[16]; /* holds the variable size commands */ | ||
254 | struct iwl_set_calib_default_cmd *cmd = | ||
255 | (struct iwl_set_calib_default_cmd *)cmd_raw; | ||
256 | int ret, i; | ||
257 | |||
258 | /* Setting default values for calibrations we don't run */ | ||
259 | for (i = 0; i < ARRAY_SIZE(wkp_calib_default_data); i++) { | ||
260 | u16 cmd_len; | ||
261 | |||
262 | if (wkp_calib_default_data[i].size == 0) | ||
263 | continue; | ||
264 | |||
265 | memset(cmd_raw, 0, sizeof(cmd_raw)); | ||
266 | cmd_len = wkp_calib_default_data[i].size + sizeof(cmd); | ||
267 | cmd->calib_index = cpu_to_le16(i); | ||
268 | cmd->length = cpu_to_le16(wkp_calib_default_data[i].size); | ||
269 | if (WARN_ONCE(cmd_len > sizeof(cmd_raw), | ||
270 | "Need to enlarge cmd_raw to %d\n", cmd_len)) | ||
271 | break; | ||
272 | memcpy(cmd->data, wkp_calib_default_data[i].data, | ||
273 | wkp_calib_default_data[i].size); | ||
274 | ret = iwl_mvm_send_cmd_pdu(mvm, SET_CALIB_DEFAULT_CMD, 0, | ||
275 | sizeof(*cmd) + | ||
276 | wkp_calib_default_data[i].size, | ||
277 | cmd); | ||
278 | if (ret) | ||
279 | return ret; | ||
280 | } | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) | 235 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
286 | { | 236 | { |
287 | struct iwl_notification_wait calib_wait; | 237 | struct iwl_notification_wait calib_wait; |
@@ -342,11 +292,6 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) | |||
342 | if (ret) | 292 | if (ret) |
343 | goto error; | 293 | goto error; |
344 | 294 | ||
345 | /* need to set default values */ | ||
346 | ret = iwl_set_default_calibrations(mvm); | ||
347 | if (ret) | ||
348 | goto error; | ||
349 | |||
350 | /* | 295 | /* |
351 | * Send phy configurations command to init uCode | 296 | * Send phy configurations command to init uCode |
352 | * to start the 16.0 uCode init image internal calibrations. | 297 | * to start the 16.0 uCode init image internal calibrations. |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c index 94aae9c8562c..5fe23a5ea9b6 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c | |||
@@ -264,7 +264,8 @@ static int iwl_mvm_mac_ctxt_allocate_resources(struct iwl_mvm *mvm, | |||
264 | return 0; | 264 | return 0; |
265 | 265 | ||
266 | /* Therefore, in recovery, we can't get here */ | 266 | /* Therefore, in recovery, we can't get here */ |
267 | WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)); | 267 | if (WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))) |
268 | return -EBUSY; | ||
268 | 269 | ||
269 | mvmvif->id = find_first_bit(data.available_mac_ids, | 270 | mvmvif->id = find_first_bit(data.available_mac_ids, |
270 | NUM_MAC_INDEX_DRIVER); | 271 | NUM_MAC_INDEX_DRIVER); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index e08683b20531..9833cdf6177c 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
@@ -153,7 +153,10 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
153 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | | 153 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | |
154 | IEEE80211_HW_AMPDU_AGGREGATION | | 154 | IEEE80211_HW_AMPDU_AGGREGATION | |
155 | IEEE80211_HW_TIMING_BEACON_ONLY | | 155 | IEEE80211_HW_TIMING_BEACON_ONLY | |
156 | IEEE80211_HW_CONNECTION_MONITOR; | 156 | IEEE80211_HW_CONNECTION_MONITOR | |
157 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | ||
158 | IEEE80211_HW_SUPPORTS_STATIC_SMPS | | ||
159 | IEEE80211_HW_SUPPORTS_UAPSD; | ||
157 | 160 | ||
158 | hw->queues = IWL_MVM_FIRST_AGG_QUEUE; | 161 | hw->queues = IWL_MVM_FIRST_AGG_QUEUE; |
159 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; | 162 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
@@ -188,6 +191,8 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
188 | 191 | ||
189 | hw->wiphy->max_remain_on_channel_duration = 10000; | 192 | hw->wiphy->max_remain_on_channel_duration = 10000; |
190 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; | 193 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
194 | hw->uapsd_queues = IWL_UAPSD_AC_INFO; | ||
195 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; | ||
191 | 196 | ||
192 | /* Extract MAC address */ | 197 | /* Extract MAC address */ |
193 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); | 198 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); |
@@ -257,7 +262,11 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
257 | if (ret) | 262 | if (ret) |
258 | return ret; | 263 | return ret; |
259 | 264 | ||
260 | return ieee80211_register_hw(mvm->hw); | 265 | ret = ieee80211_register_hw(mvm->hw); |
266 | if (ret) | ||
267 | iwl_mvm_leds_exit(mvm); | ||
268 | |||
269 | return ret; | ||
261 | } | 270 | } |
262 | 271 | ||
263 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, | 272 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
@@ -385,6 +394,7 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) | |||
385 | ieee80211_wake_queues(mvm->hw); | 394 | ieee80211_wake_queues(mvm->hw); |
386 | 395 | ||
387 | mvm->vif_count = 0; | 396 | mvm->vif_count = 0; |
397 | mvm->rx_ba_sessions = 0; | ||
388 | } | 398 | } |
389 | 399 | ||
390 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) | 400 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
@@ -501,12 +511,33 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, | |||
501 | 511 | ||
502 | mutex_lock(&mvm->mutex); | 512 | mutex_lock(&mvm->mutex); |
503 | 513 | ||
504 | /* Allocate resources for the MAC context, and add it the the fw */ | 514 | /* Allocate resources for the MAC context, and add it to the fw */ |
505 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); | 515 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
506 | if (ret) | 516 | if (ret) |
507 | goto out_unlock; | 517 | goto out_unlock; |
508 | 518 | ||
509 | /* | 519 | /* |
520 | * TODO: remove this temporary code. | ||
521 | * Currently MVM FW supports power management only on single MAC. | ||
522 | * If new interface added, disable PM on existing interface. | ||
523 | * P2P device is a special case, since it is handled by FW similary to | ||
524 | * scan. If P2P deviced is added, PM remains enabled on existing | ||
525 | * interface. | ||
526 | * Note: the method below does not count the new interface being added | ||
527 | * at this moment. | ||
528 | */ | ||
529 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) | ||
530 | mvm->vif_count++; | ||
531 | if (mvm->vif_count > 1) { | ||
532 | IWL_DEBUG_MAC80211(mvm, | ||
533 | "Disable power on existing interfaces\n"); | ||
534 | ieee80211_iterate_active_interfaces_atomic( | ||
535 | mvm->hw, | ||
536 | IEEE80211_IFACE_ITER_NORMAL, | ||
537 | iwl_mvm_pm_disable_iterator, mvm); | ||
538 | } | ||
539 | |||
540 | /* | ||
510 | * The AP binding flow can be done only after the beacon | 541 | * The AP binding flow can be done only after the beacon |
511 | * template is configured (which happens only in the mac80211 | 542 | * template is configured (which happens only in the mac80211 |
512 | * start_ap() flow), and adding the broadcast station can happen | 543 | * start_ap() flow), and adding the broadcast station can happen |
@@ -526,30 +557,10 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, | |||
526 | goto out_release; | 557 | goto out_release; |
527 | } | 558 | } |
528 | 559 | ||
560 | iwl_mvm_vif_dbgfs_register(mvm, vif); | ||
529 | goto out_unlock; | 561 | goto out_unlock; |
530 | } | 562 | } |
531 | 563 | ||
532 | /* | ||
533 | * TODO: remove this temporary code. | ||
534 | * Currently MVM FW supports power management only on single MAC. | ||
535 | * If new interface added, disable PM on existing interface. | ||
536 | * P2P device is a special case, since it is handled by FW similary to | ||
537 | * scan. If P2P deviced is added, PM remains enabled on existing | ||
538 | * interface. | ||
539 | * Note: the method below does not count the new interface being added | ||
540 | * at this moment. | ||
541 | */ | ||
542 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) | ||
543 | mvm->vif_count++; | ||
544 | if (mvm->vif_count > 1) { | ||
545 | IWL_DEBUG_MAC80211(mvm, | ||
546 | "Disable power on existing interfaces\n"); | ||
547 | ieee80211_iterate_active_interfaces_atomic( | ||
548 | mvm->hw, | ||
549 | IEEE80211_IFACE_ITER_NORMAL, | ||
550 | iwl_mvm_pm_disable_iterator, mvm); | ||
551 | } | ||
552 | |||
553 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); | 564 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
554 | if (ret) | 565 | if (ret) |
555 | goto out_release; | 566 | goto out_release; |
@@ -561,16 +572,18 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, | |||
561 | iwl_mvm_power_update_mode(mvm, vif); | 572 | iwl_mvm_power_update_mode(mvm, vif); |
562 | 573 | ||
563 | /* beacon filtering */ | 574 | /* beacon filtering */ |
575 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); | ||
576 | if (ret) | ||
577 | goto out_remove_mac; | ||
578 | |||
564 | if (!mvm->bf_allowed_vif && | 579 | if (!mvm->bf_allowed_vif && |
565 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p){ | 580 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
581 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ | ||
566 | mvm->bf_allowed_vif = mvmvif; | 582 | mvm->bf_allowed_vif = mvmvif; |
567 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; | 583 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
584 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; | ||
568 | } | 585 | } |
569 | 586 | ||
570 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); | ||
571 | if (ret) | ||
572 | goto out_release; | ||
573 | |||
574 | /* | 587 | /* |
575 | * P2P_DEVICE interface does not have a channel context assigned to it, | 588 | * P2P_DEVICE interface does not have a channel context assigned to it, |
576 | * so a dedicated PHY context is allocated to it and the corresponding | 589 | * so a dedicated PHY context is allocated to it and the corresponding |
@@ -581,7 +594,7 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, | |||
581 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); | 594 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
582 | if (!mvmvif->phy_ctxt) { | 595 | if (!mvmvif->phy_ctxt) { |
583 | ret = -ENOSPC; | 596 | ret = -ENOSPC; |
584 | goto out_remove_mac; | 597 | goto out_free_bf; |
585 | } | 598 | } |
586 | 599 | ||
587 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | 600 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
@@ -605,6 +618,12 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, | |||
605 | iwl_mvm_binding_remove_vif(mvm, vif); | 618 | iwl_mvm_binding_remove_vif(mvm, vif); |
606 | out_unref_phy: | 619 | out_unref_phy: |
607 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | 620 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
621 | out_free_bf: | ||
622 | if (mvm->bf_allowed_vif == mvmvif) { | ||
623 | mvm->bf_allowed_vif = NULL; | ||
624 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | | ||
625 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | ||
626 | } | ||
608 | out_remove_mac: | 627 | out_remove_mac: |
609 | mvmvif->phy_ctxt = NULL; | 628 | mvmvif->phy_ctxt = NULL; |
610 | iwl_mvm_mac_ctxt_remove(mvm, vif); | 629 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
@@ -669,7 +688,8 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, | |||
669 | 688 | ||
670 | if (mvm->bf_allowed_vif == mvmvif) { | 689 | if (mvm->bf_allowed_vif == mvmvif) { |
671 | mvm->bf_allowed_vif = NULL; | 690 | mvm->bf_allowed_vif = NULL; |
672 | vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; | 691 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
692 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | ||
673 | } | 693 | } |
674 | 694 | ||
675 | iwl_mvm_vif_dbgfs_clean(mvm, vif); | 695 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
@@ -714,6 +734,20 @@ out_release: | |||
714 | mutex_unlock(&mvm->mutex); | 734 | mutex_unlock(&mvm->mutex); |
715 | } | 735 | } |
716 | 736 | ||
737 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | ||
738 | s8 tx_power) | ||
739 | { | ||
740 | /* FW is in charge of regulatory enforcement */ | ||
741 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { | ||
742 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, | ||
743 | .pwr_restriction = cpu_to_le16(tx_power), | ||
744 | }; | ||
745 | |||
746 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, | ||
747 | sizeof(reduce_txpwr_cmd), | ||
748 | &reduce_txpwr_cmd); | ||
749 | } | ||
750 | |||
717 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) | 751 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
718 | { | 752 | { |
719 | return 0; | 753 | return 0; |
@@ -761,7 +795,6 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, | |||
761 | IWL_ERR(mvm, "failed to update quotas\n"); | 795 | IWL_ERR(mvm, "failed to update quotas\n"); |
762 | return; | 796 | return; |
763 | } | 797 | } |
764 | iwl_mvm_bt_coex_vif_assoc(mvm, vif); | ||
765 | iwl_mvm_configure_mcast_filter(mvm, vif); | 798 | iwl_mvm_configure_mcast_filter(mvm, vif); |
766 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { | 799 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
767 | /* remove AP station now that the MAC is unassoc */ | 800 | /* remove AP station now that the MAC is unassoc */ |
@@ -774,9 +807,19 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, | |||
774 | if (ret) | 807 | if (ret) |
775 | IWL_ERR(mvm, "failed to update quotas\n"); | 808 | IWL_ERR(mvm, "failed to update quotas\n"); |
776 | } | 809 | } |
777 | ret = iwl_mvm_power_update_mode(mvm, vif); | 810 | |
778 | if (ret) | 811 | /* reset rssi values */ |
779 | IWL_ERR(mvm, "failed to update power mode\n"); | 812 | mvmvif->bf_data.ave_beacon_signal = 0; |
813 | |||
814 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD)) { | ||
815 | /* Workaround for FW bug, otherwise FW disables device | ||
816 | * power save upon disassociation | ||
817 | */ | ||
818 | ret = iwl_mvm_power_update_mode(mvm, vif); | ||
819 | if (ret) | ||
820 | IWL_ERR(mvm, "failed to update power mode\n"); | ||
821 | } | ||
822 | iwl_mvm_bt_coex_vif_assoc(mvm, vif); | ||
780 | } else if (changes & BSS_CHANGED_BEACON_INFO) { | 823 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
781 | /* | 824 | /* |
782 | * We received a beacon _after_ association so | 825 | * We received a beacon _after_ association so |
@@ -784,11 +827,25 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, | |||
784 | */ | 827 | */ |
785 | iwl_mvm_remove_time_event(mvm, mvmvif, | 828 | iwl_mvm_remove_time_event(mvm, mvmvif, |
786 | &mvmvif->time_event_data); | 829 | &mvmvif->time_event_data); |
787 | } else if (changes & BSS_CHANGED_PS) { | 830 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_QOS)) { |
788 | ret = iwl_mvm_power_update_mode(mvm, vif); | 831 | ret = iwl_mvm_power_update_mode(mvm, vif); |
789 | if (ret) | 832 | if (ret) |
790 | IWL_ERR(mvm, "failed to update power mode\n"); | 833 | IWL_ERR(mvm, "failed to update power mode\n"); |
791 | } | 834 | } |
835 | if (changes & BSS_CHANGED_TXPOWER) { | ||
836 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | ||
837 | bss_conf->txpower); | ||
838 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | ||
839 | } | ||
840 | |||
841 | if (changes & BSS_CHANGED_CQM) { | ||
842 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed"); | ||
843 | /* reset cqm events tracking */ | ||
844 | mvmvif->bf_data.last_cqm_event = 0; | ||
845 | ret = iwl_mvm_update_beacon_filter(mvm, vif); | ||
846 | if (ret) | ||
847 | IWL_ERR(mvm, "failed to update CQM thresholds\n"); | ||
848 | } | ||
792 | } | 849 | } |
793 | 850 | ||
794 | static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | 851 | static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
@@ -1006,6 +1063,21 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, | |||
1006 | mutex_lock(&mvm->mutex); | 1063 | mutex_lock(&mvm->mutex); |
1007 | if (old_state == IEEE80211_STA_NOTEXIST && | 1064 | if (old_state == IEEE80211_STA_NOTEXIST && |
1008 | new_state == IEEE80211_STA_NONE) { | 1065 | new_state == IEEE80211_STA_NONE) { |
1066 | /* | ||
1067 | * Firmware bug - it'll crash if the beacon interval is less | ||
1068 | * than 16. We can't avoid connecting at all, so refuse the | ||
1069 | * station state change, this will cause mac80211 to abandon | ||
1070 | * attempts to connect to this AP, and eventually wpa_s will | ||
1071 | * blacklist the AP... | ||
1072 | */ | ||
1073 | if (vif->type == NL80211_IFTYPE_STATION && | ||
1074 | vif->bss_conf.beacon_int < 16) { | ||
1075 | IWL_ERR(mvm, | ||
1076 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", | ||
1077 | sta->addr, vif->bss_conf.beacon_int); | ||
1078 | ret = -EINVAL; | ||
1079 | goto out_unlock; | ||
1080 | } | ||
1009 | ret = iwl_mvm_add_sta(mvm, vif, sta); | 1081 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
1010 | } else if (old_state == IEEE80211_STA_NONE && | 1082 | } else if (old_state == IEEE80211_STA_NONE && |
1011 | new_state == IEEE80211_STA_AUTH) { | 1083 | new_state == IEEE80211_STA_AUTH) { |
@@ -1038,6 +1110,7 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, | |||
1038 | } else { | 1110 | } else { |
1039 | ret = -EIO; | 1111 | ret = -EIO; |
1040 | } | 1112 | } |
1113 | out_unlock: | ||
1041 | mutex_unlock(&mvm->mutex); | 1114 | mutex_unlock(&mvm->mutex); |
1042 | 1115 | ||
1043 | return ret; | 1116 | return ret; |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h index d40d7db185d6..b0389279cc1e 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h | |||
@@ -76,6 +76,7 @@ | |||
76 | #include "iwl-trans.h" | 76 | #include "iwl-trans.h" |
77 | #include "sta.h" | 77 | #include "sta.h" |
78 | #include "fw-api.h" | 78 | #include "fw-api.h" |
79 | #include "constants.h" | ||
79 | 80 | ||
80 | #define IWL_INVALID_MAC80211_QUEUE 0xff | 81 | #define IWL_INVALID_MAC80211_QUEUE 0xff |
81 | #define IWL_MVM_MAX_ADDRESSES 5 | 82 | #define IWL_MVM_MAX_ADDRESSES 5 |
@@ -91,6 +92,9 @@ enum iwl_mvm_tx_fifo { | |||
91 | }; | 92 | }; |
92 | 93 | ||
93 | extern struct ieee80211_ops iwl_mvm_hw_ops; | 94 | extern struct ieee80211_ops iwl_mvm_hw_ops; |
95 | extern const struct iwl_mvm_power_ops pm_legacy_ops; | ||
96 | extern const struct iwl_mvm_power_ops pm_mac_ops; | ||
97 | |||
94 | /** | 98 | /** |
95 | * struct iwl_mvm_mod_params - module parameters for iwlmvm | 99 | * struct iwl_mvm_mod_params - module parameters for iwlmvm |
96 | * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted. | 100 | * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted. |
@@ -149,6 +153,22 @@ enum iwl_power_scheme { | |||
149 | }; | 153 | }; |
150 | 154 | ||
151 | #define IWL_CONN_MAX_LISTEN_INTERVAL 70 | 155 | #define IWL_CONN_MAX_LISTEN_INTERVAL 70 |
156 | #define IWL_UAPSD_AC_INFO (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO |\ | ||
157 | IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |\ | ||
158 | IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |\ | ||
159 | IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) | ||
160 | #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_2 | ||
161 | |||
162 | struct iwl_mvm_power_ops { | ||
163 | int (*power_update_mode)(struct iwl_mvm *mvm, | ||
164 | struct ieee80211_vif *vif); | ||
165 | int (*power_disable)(struct iwl_mvm *mvm, struct ieee80211_vif *vif); | ||
166 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
167 | int (*power_dbgfs_read)(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | ||
168 | char *buf, int bufsz); | ||
169 | #endif | ||
170 | }; | ||
171 | |||
152 | 172 | ||
153 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 173 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
154 | enum iwl_dbgfs_pm_mask { | 174 | enum iwl_dbgfs_pm_mask { |
@@ -160,10 +180,11 @@ enum iwl_dbgfs_pm_mask { | |||
160 | MVM_DEBUGFS_PM_DISABLE_POWER_OFF = BIT(5), | 180 | MVM_DEBUGFS_PM_DISABLE_POWER_OFF = BIT(5), |
161 | MVM_DEBUGFS_PM_LPRX_ENA = BIT(6), | 181 | MVM_DEBUGFS_PM_LPRX_ENA = BIT(6), |
162 | MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7), | 182 | MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7), |
183 | MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8), | ||
163 | }; | 184 | }; |
164 | 185 | ||
165 | struct iwl_dbgfs_pm { | 186 | struct iwl_dbgfs_pm { |
166 | u8 keep_alive_seconds; | 187 | u16 keep_alive_seconds; |
167 | u32 rx_data_timeout; | 188 | u32 rx_data_timeout; |
168 | u32 tx_data_timeout; | 189 | u32 tx_data_timeout; |
169 | bool skip_over_dtim; | 190 | bool skip_over_dtim; |
@@ -171,6 +192,7 @@ struct iwl_dbgfs_pm { | |||
171 | bool disable_power_off; | 192 | bool disable_power_off; |
172 | bool lprx_ena; | 193 | bool lprx_ena; |
173 | u32 lprx_rssi_threshold; | 194 | u32 lprx_rssi_threshold; |
195 | bool snooze_ena; | ||
174 | int mask; | 196 | int mask; |
175 | }; | 197 | }; |
176 | 198 | ||
@@ -180,24 +202,28 @@ enum iwl_dbgfs_bf_mask { | |||
180 | MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0), | 202 | MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0), |
181 | MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1), | 203 | MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1), |
182 | MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2), | 204 | MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2), |
183 | MVM_DEBUGFS_BF_TEMPERATURE_DELTA = BIT(3), | 205 | MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3), |
184 | MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(4), | 206 | MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4), |
185 | MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(5), | 207 | MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5), |
186 | MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(6), | 208 | MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6), |
187 | MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(7), | 209 | MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7), |
188 | MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(8), | 210 | MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8), |
211 | MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9), | ||
212 | MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10), | ||
189 | }; | 213 | }; |
190 | 214 | ||
191 | struct iwl_dbgfs_bf { | 215 | struct iwl_dbgfs_bf { |
192 | u8 bf_energy_delta; | 216 | u32 bf_energy_delta; |
193 | u8 bf_roaming_energy_delta; | 217 | u32 bf_roaming_energy_delta; |
194 | u8 bf_roaming_state; | 218 | u32 bf_roaming_state; |
195 | u8 bf_temperature_delta; | 219 | u32 bf_temp_threshold; |
196 | u8 bf_enable_beacon_filter; | 220 | u32 bf_temp_fast_filter; |
197 | u8 bf_debug_flag; | 221 | u32 bf_temp_slow_filter; |
222 | u32 bf_enable_beacon_filter; | ||
223 | u32 bf_debug_flag; | ||
198 | u32 bf_escape_timer; | 224 | u32 bf_escape_timer; |
199 | u32 ba_escape_timer; | 225 | u32 ba_escape_timer; |
200 | u8 ba_enable_beacon_abort; | 226 | u32 ba_enable_beacon_abort; |
201 | int mask; | 227 | int mask; |
202 | }; | 228 | }; |
203 | #endif | 229 | #endif |
@@ -209,6 +235,21 @@ enum iwl_mvm_smps_type_request { | |||
209 | }; | 235 | }; |
210 | 236 | ||
211 | /** | 237 | /** |
238 | * struct iwl_mvm_vif_bf_data - beacon filtering related data | ||
239 | * @bf_enabled: indicates if beacon filtering is enabled | ||
240 | * @ba_enabled: indicated if beacon abort is enabled | ||
241 | * @last_beacon_signal: last beacon rssi signal in dbm | ||
242 | * @ave_beacon_signal: average beacon signal | ||
243 | * @last_cqm_event: rssi of the last cqm event | ||
244 | */ | ||
245 | struct iwl_mvm_vif_bf_data { | ||
246 | bool bf_enabled; | ||
247 | bool ba_enabled; | ||
248 | s8 ave_beacon_signal; | ||
249 | s8 last_cqm_event; | ||
250 | }; | ||
251 | |||
252 | /** | ||
212 | * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context | 253 | * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context |
213 | * @id: between 0 and 3 | 254 | * @id: between 0 and 3 |
214 | * @color: to solve races upon MAC addition and removal | 255 | * @color: to solve races upon MAC addition and removal |
@@ -233,8 +274,7 @@ struct iwl_mvm_vif { | |||
233 | bool uploaded; | 274 | bool uploaded; |
234 | bool ap_active; | 275 | bool ap_active; |
235 | bool monitor_active; | 276 | bool monitor_active; |
236 | /* indicate whether beacon filtering is enabled */ | 277 | struct iwl_mvm_vif_bf_data bf_data; |
237 | bool bf_enabled; | ||
238 | 278 | ||
239 | u32 ap_beacon_time; | 279 | u32 ap_beacon_time; |
240 | 280 | ||
@@ -268,7 +308,7 @@ struct iwl_mvm_vif { | |||
268 | 308 | ||
269 | #if IS_ENABLED(CONFIG_IPV6) | 309 | #if IS_ENABLED(CONFIG_IPV6) |
270 | /* IPv6 addresses for WoWLAN */ | 310 | /* IPv6 addresses for WoWLAN */ |
271 | struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS]; | 311 | struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX]; |
272 | int num_target_ipv6_addrs; | 312 | int num_target_ipv6_addrs; |
273 | #endif | 313 | #endif |
274 | #endif | 314 | #endif |
@@ -402,6 +442,8 @@ struct iwl_mvm { | |||
402 | 442 | ||
403 | struct iwl_notif_wait_data notif_wait; | 443 | struct iwl_notif_wait_data notif_wait; |
404 | 444 | ||
445 | struct mvm_statistics_rx rx_stats; | ||
446 | |||
405 | unsigned long transport_queue_stop; | 447 | unsigned long transport_queue_stop; |
406 | u8 queue_to_mac80211[IWL_MAX_HW_QUEUES]; | 448 | u8 queue_to_mac80211[IWL_MAX_HW_QUEUES]; |
407 | atomic_t queue_stop_count[IWL_MAX_HW_QUEUES]; | 449 | atomic_t queue_stop_count[IWL_MAX_HW_QUEUES]; |
@@ -419,6 +461,7 @@ struct iwl_mvm { | |||
419 | struct work_struct sta_drained_wk; | 461 | struct work_struct sta_drained_wk; |
420 | unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)]; | 462 | unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)]; |
421 | atomic_t pending_frames[IWL_MVM_STATION_COUNT]; | 463 | atomic_t pending_frames[IWL_MVM_STATION_COUNT]; |
464 | u8 rx_ba_sessions; | ||
422 | 465 | ||
423 | /* configured by mac80211 */ | 466 | /* configured by mac80211 */ |
424 | u32 rts_threshold; | 467 | u32 rts_threshold; |
@@ -458,6 +501,9 @@ struct iwl_mvm { | |||
458 | */ | 501 | */ |
459 | u8 vif_count; | 502 | u8 vif_count; |
460 | 503 | ||
504 | /* -1 for always, 0 for never, >0 for that many times */ | ||
505 | s8 restart_fw; | ||
506 | |||
461 | struct led_classdev led; | 507 | struct led_classdev led; |
462 | 508 | ||
463 | struct ieee80211_vif *p2p_device_vif; | 509 | struct ieee80211_vif *p2p_device_vif; |
@@ -481,6 +527,8 @@ struct iwl_mvm { | |||
481 | /* Thermal Throttling and CTkill */ | 527 | /* Thermal Throttling and CTkill */ |
482 | struct iwl_mvm_tt_mgmt thermal_throttle; | 528 | struct iwl_mvm_tt_mgmt thermal_throttle; |
483 | s32 temperature; /* Celsius */ | 529 | s32 temperature; /* Celsius */ |
530 | |||
531 | const struct iwl_mvm_power_ops *pm_ops; | ||
484 | }; | 532 | }; |
485 | 533 | ||
486 | /* Extract MVM priv from op_mode and _hw */ | 534 | /* Extract MVM priv from op_mode and _hw */ |
@@ -524,6 +572,7 @@ int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags, | |||
524 | enum ieee80211_band band); | 572 | enum ieee80211_band band); |
525 | u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx); | 573 | u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx); |
526 | void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm); | 574 | void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm); |
575 | void iwl_mvm_dump_sram(struct iwl_mvm *mvm); | ||
527 | u8 first_antenna(u8 mask); | 576 | u8 first_antenna(u8 mask); |
528 | u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx); | 577 | u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx); |
529 | 578 | ||
@@ -659,10 +708,26 @@ int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, | |||
659 | u8 flags, bool init); | 708 | u8 flags, bool init); |
660 | 709 | ||
661 | /* power managment */ | 710 | /* power managment */ |
662 | int iwl_mvm_power_update_mode(struct iwl_mvm *mvm, struct ieee80211_vif *vif); | 711 | static inline int iwl_mvm_power_update_mode(struct iwl_mvm *mvm, |
663 | int iwl_mvm_power_disable(struct iwl_mvm *mvm, struct ieee80211_vif *vif); | 712 | struct ieee80211_vif *vif) |
664 | void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | 713 | { |
665 | struct iwl_powertable_cmd *cmd); | 714 | return mvm->pm_ops->power_update_mode(mvm, vif); |
715 | } | ||
716 | |||
717 | static inline int iwl_mvm_power_disable(struct iwl_mvm *mvm, | ||
718 | struct ieee80211_vif *vif) | ||
719 | { | ||
720 | return mvm->pm_ops->power_disable(mvm, vif); | ||
721 | } | ||
722 | |||
723 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
724 | static inline int iwl_mvm_power_dbgfs_read(struct iwl_mvm *mvm, | ||
725 | struct ieee80211_vif *vif, | ||
726 | char *buf, int bufsz) | ||
727 | { | ||
728 | return mvm->pm_ops->power_dbgfs_read(mvm, vif, buf, bufsz); | ||
729 | } | ||
730 | #endif | ||
666 | 731 | ||
667 | int iwl_mvm_leds_init(struct iwl_mvm *mvm); | 732 | int iwl_mvm_leds_init(struct iwl_mvm *mvm); |
668 | void iwl_mvm_leds_exit(struct iwl_mvm *mvm); | 733 | void iwl_mvm_leds_exit(struct iwl_mvm *mvm); |
@@ -706,6 +771,12 @@ int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, | |||
706 | struct ieee80211_vif *vif); | 771 | struct ieee80211_vif *vif); |
707 | int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, | 772 | int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, |
708 | struct ieee80211_vif *vif); | 773 | struct ieee80211_vif *vif); |
774 | int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm, | ||
775 | struct iwl_beacon_filter_cmd *cmd); | ||
776 | int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm, | ||
777 | struct ieee80211_vif *vif, bool enable); | ||
778 | int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm, | ||
779 | struct ieee80211_vif *vif); | ||
709 | 780 | ||
710 | /* SMPS */ | 781 | /* SMPS */ |
711 | void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | 782 | void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c index af79a14063a9..2fcc8ef88a68 100644 --- a/drivers/net/wireless/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c | |||
@@ -275,6 +275,7 @@ static const char *iwl_mvm_cmd_strings[REPLY_MAX] = { | |||
275 | CMD(BEACON_NOTIFICATION), | 275 | CMD(BEACON_NOTIFICATION), |
276 | CMD(BEACON_TEMPLATE_CMD), | 276 | CMD(BEACON_TEMPLATE_CMD), |
277 | CMD(STATISTICS_NOTIFICATION), | 277 | CMD(STATISTICS_NOTIFICATION), |
278 | CMD(REDUCE_TX_POWER_CMD), | ||
278 | CMD(TX_ANT_CONFIGURATION_CMD), | 279 | CMD(TX_ANT_CONFIGURATION_CMD), |
279 | CMD(D3_CONFIG_CMD), | 280 | CMD(D3_CONFIG_CMD), |
280 | CMD(PROT_OFFLOAD_CONFIG_CMD), | 281 | CMD(PROT_OFFLOAD_CONFIG_CMD), |
@@ -301,6 +302,7 @@ static const char *iwl_mvm_cmd_strings[REPLY_MAX] = { | |||
301 | CMD(MCAST_FILTER_CMD), | 302 | CMD(MCAST_FILTER_CMD), |
302 | CMD(REPLY_BEACON_FILTERING_CMD), | 303 | CMD(REPLY_BEACON_FILTERING_CMD), |
303 | CMD(REPLY_THERMAL_MNG_BACKOFF), | 304 | CMD(REPLY_THERMAL_MNG_BACKOFF), |
305 | CMD(MAC_PM_POWER_TABLE), | ||
304 | }; | 306 | }; |
305 | #undef CMD | 307 | #undef CMD |
306 | 308 | ||
@@ -340,6 +342,8 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
340 | mvm->fw = fw; | 342 | mvm->fw = fw; |
341 | mvm->hw = hw; | 343 | mvm->hw = hw; |
342 | 344 | ||
345 | mvm->restart_fw = iwlwifi_mod_params.restart_fw ? -1 : 0; | ||
346 | |||
343 | mutex_init(&mvm->mutex); | 347 | mutex_init(&mvm->mutex); |
344 | spin_lock_init(&mvm->async_handlers_lock); | 348 | spin_lock_init(&mvm->async_handlers_lock); |
345 | INIT_LIST_HEAD(&mvm->time_event_list); | 349 | INIT_LIST_HEAD(&mvm->time_event_list); |
@@ -431,6 +435,13 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
431 | if (err) | 435 | if (err) |
432 | goto out_unregister; | 436 | goto out_unregister; |
433 | 437 | ||
438 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD) | ||
439 | mvm->pm_ops = &pm_mac_ops; | ||
440 | else | ||
441 | mvm->pm_ops = &pm_legacy_ops; | ||
442 | |||
443 | memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx)); | ||
444 | |||
434 | return op_mode; | 445 | return op_mode; |
435 | 446 | ||
436 | out_unregister: | 447 | out_unregister: |
@@ -638,6 +649,22 @@ static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) | |||
638 | ieee80211_free_txskb(mvm->hw, skb); | 649 | ieee80211_free_txskb(mvm->hw, skb); |
639 | } | 650 | } |
640 | 651 | ||
652 | struct iwl_mvm_reprobe { | ||
653 | struct device *dev; | ||
654 | struct work_struct work; | ||
655 | }; | ||
656 | |||
657 | static void iwl_mvm_reprobe_wk(struct work_struct *wk) | ||
658 | { | ||
659 | struct iwl_mvm_reprobe *reprobe; | ||
660 | |||
661 | reprobe = container_of(wk, struct iwl_mvm_reprobe, work); | ||
662 | if (device_reprobe(reprobe->dev)) | ||
663 | dev_err(reprobe->dev, "reprobe failed!\n"); | ||
664 | kfree(reprobe); | ||
665 | module_put(THIS_MODULE); | ||
666 | } | ||
667 | |||
641 | static void iwl_mvm_nic_restart(struct iwl_mvm *mvm) | 668 | static void iwl_mvm_nic_restart(struct iwl_mvm *mvm) |
642 | { | 669 | { |
643 | iwl_abort_notification_waits(&mvm->notif_wait); | 670 | iwl_abort_notification_waits(&mvm->notif_wait); |
@@ -649,9 +676,30 @@ static void iwl_mvm_nic_restart(struct iwl_mvm *mvm) | |||
649 | * can't recover this since we're already half suspended. | 676 | * can't recover this since we're already half suspended. |
650 | */ | 677 | */ |
651 | if (test_and_set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { | 678 | if (test_and_set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { |
652 | IWL_ERR(mvm, "Firmware error during reconfiguration! Abort.\n"); | 679 | struct iwl_mvm_reprobe *reprobe; |
653 | } else if (mvm->cur_ucode == IWL_UCODE_REGULAR && | 680 | |
654 | iwlwifi_mod_params.restart_fw) { | 681 | IWL_ERR(mvm, |
682 | "Firmware error during reconfiguration - reprobe!\n"); | ||
683 | |||
684 | /* | ||
685 | * get a module reference to avoid doing this while unloading | ||
686 | * anyway and to avoid scheduling a work with code that's | ||
687 | * being removed. | ||
688 | */ | ||
689 | if (!try_module_get(THIS_MODULE)) { | ||
690 | IWL_ERR(mvm, "Module is being unloaded - abort\n"); | ||
691 | return; | ||
692 | } | ||
693 | |||
694 | reprobe = kzalloc(sizeof(*reprobe), GFP_ATOMIC); | ||
695 | if (!reprobe) { | ||
696 | module_put(THIS_MODULE); | ||
697 | return; | ||
698 | } | ||
699 | reprobe->dev = mvm->trans->dev; | ||
700 | INIT_WORK(&reprobe->work, iwl_mvm_reprobe_wk); | ||
701 | schedule_work(&reprobe->work); | ||
702 | } else if (mvm->cur_ucode == IWL_UCODE_REGULAR && mvm->restart_fw) { | ||
655 | /* | 703 | /* |
656 | * This is a bit racy, but worst case we tell mac80211 about | 704 | * This is a bit racy, but worst case we tell mac80211 about |
657 | * a stopped/aborted (sched) scan when that was already done | 705 | * a stopped/aborted (sched) scan when that was already done |
@@ -669,6 +717,8 @@ static void iwl_mvm_nic_restart(struct iwl_mvm *mvm) | |||
669 | break; | 717 | break; |
670 | } | 718 | } |
671 | 719 | ||
720 | if (mvm->restart_fw > 0) | ||
721 | mvm->restart_fw--; | ||
672 | ieee80211_restart_hw(mvm->hw); | 722 | ieee80211_restart_hw(mvm->hw); |
673 | } | 723 | } |
674 | } | 724 | } |
@@ -678,6 +728,8 @@ static void iwl_mvm_nic_error(struct iwl_op_mode *op_mode) | |||
678 | struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); | 728 | struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); |
679 | 729 | ||
680 | iwl_mvm_dump_nic_error_log(mvm); | 730 | iwl_mvm_dump_nic_error_log(mvm); |
731 | if (!mvm->restart_fw) | ||
732 | iwl_mvm_dump_sram(mvm); | ||
681 | 733 | ||
682 | iwl_mvm_nic_restart(mvm); | 734 | iwl_mvm_nic_restart(mvm); |
683 | } | 735 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/power.c b/drivers/net/wireless/iwlwifi/mvm/power.c index e7ca965a89b8..21407a353a3b 100644 --- a/drivers/net/wireless/iwlwifi/mvm/power.c +++ b/drivers/net/wireless/iwlwifi/mvm/power.c | |||
@@ -75,8 +75,8 @@ | |||
75 | 75 | ||
76 | #define POWER_KEEP_ALIVE_PERIOD_SEC 25 | 76 | #define POWER_KEEP_ALIVE_PERIOD_SEC 25 |
77 | 77 | ||
78 | static int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm, | 78 | int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm, |
79 | struct iwl_beacon_filter_cmd *cmd) | 79 | struct iwl_beacon_filter_cmd *cmd) |
80 | { | 80 | { |
81 | int ret; | 81 | int ret; |
82 | 82 | ||
@@ -85,69 +85,110 @@ static int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm, | |||
85 | 85 | ||
86 | if (!ret) { | 86 | if (!ret) { |
87 | IWL_DEBUG_POWER(mvm, "ba_enable_beacon_abort is: %d\n", | 87 | IWL_DEBUG_POWER(mvm, "ba_enable_beacon_abort is: %d\n", |
88 | cmd->ba_enable_beacon_abort); | 88 | le32_to_cpu(cmd->ba_enable_beacon_abort)); |
89 | IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n", | 89 | IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n", |
90 | cmd->ba_escape_timer); | 90 | le32_to_cpu(cmd->ba_escape_timer)); |
91 | IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n", | 91 | IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n", |
92 | cmd->bf_debug_flag); | 92 | le32_to_cpu(cmd->bf_debug_flag)); |
93 | IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n", | 93 | IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n", |
94 | cmd->bf_enable_beacon_filter); | 94 | le32_to_cpu(cmd->bf_enable_beacon_filter)); |
95 | IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n", | 95 | IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n", |
96 | cmd->bf_energy_delta); | 96 | le32_to_cpu(cmd->bf_energy_delta)); |
97 | IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n", | 97 | IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n", |
98 | cmd->bf_escape_timer); | 98 | le32_to_cpu(cmd->bf_escape_timer)); |
99 | IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n", | 99 | IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n", |
100 | cmd->bf_roaming_energy_delta); | 100 | le32_to_cpu(cmd->bf_roaming_energy_delta)); |
101 | IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n", | 101 | IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n", |
102 | cmd->bf_roaming_state); | 102 | le32_to_cpu(cmd->bf_roaming_state)); |
103 | IWL_DEBUG_POWER(mvm, "bf_temperature_delta is: %d\n", | 103 | IWL_DEBUG_POWER(mvm, "bf_temp_threshold is: %d\n", |
104 | cmd->bf_temperature_delta); | 104 | le32_to_cpu(cmd->bf_temp_threshold)); |
105 | IWL_DEBUG_POWER(mvm, "bf_temp_fast_filter is: %d\n", | ||
106 | le32_to_cpu(cmd->bf_temp_fast_filter)); | ||
107 | IWL_DEBUG_POWER(mvm, "bf_temp_slow_filter is: %d\n", | ||
108 | le32_to_cpu(cmd->bf_temp_slow_filter)); | ||
105 | } | 109 | } |
106 | return ret; | 110 | return ret; |
107 | } | 111 | } |
108 | 112 | ||
109 | static int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm, | 113 | static |
110 | struct ieee80211_vif *vif, bool enable) | 114 | void iwl_mvm_beacon_filter_set_cqm_params(struct iwl_mvm *mvm, |
115 | struct ieee80211_vif *vif, | ||
116 | struct iwl_beacon_filter_cmd *cmd) | ||
117 | { | ||
118 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | ||
119 | |||
120 | if (vif->bss_conf.cqm_rssi_thold) { | ||
121 | cmd->bf_energy_delta = | ||
122 | cpu_to_le32(vif->bss_conf.cqm_rssi_hyst); | ||
123 | /* fw uses an absolute value for this */ | ||
124 | cmd->bf_roaming_state = | ||
125 | cpu_to_le32(-vif->bss_conf.cqm_rssi_thold); | ||
126 | } | ||
127 | cmd->ba_enable_beacon_abort = cpu_to_le32(mvmvif->bf_data.ba_enabled); | ||
128 | } | ||
129 | |||
130 | int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm, | ||
131 | struct ieee80211_vif *vif, bool enable) | ||
111 | { | 132 | { |
112 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 133 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
113 | struct iwl_beacon_filter_cmd cmd = { | 134 | struct iwl_beacon_filter_cmd cmd = { |
114 | IWL_BF_CMD_CONFIG_DEFAULTS, | 135 | IWL_BF_CMD_CONFIG_DEFAULTS, |
115 | .bf_enable_beacon_filter = 1, | 136 | .bf_enable_beacon_filter = cpu_to_le32(1), |
116 | .ba_enable_beacon_abort = enable, | 137 | .ba_enable_beacon_abort = cpu_to_le32(enable), |
117 | }; | 138 | }; |
118 | 139 | ||
119 | if (!mvmvif->bf_enabled) | 140 | if (!mvmvif->bf_data.bf_enabled) |
120 | return 0; | 141 | return 0; |
121 | 142 | ||
143 | if (mvm->cur_ucode == IWL_UCODE_WOWLAN) | ||
144 | cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3); | ||
145 | |||
146 | mvmvif->bf_data.ba_enabled = enable; | ||
147 | iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd); | ||
122 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); | 148 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); |
123 | return iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); | 149 | return iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
124 | } | 150 | } |
125 | 151 | ||
126 | static void iwl_mvm_power_log(struct iwl_mvm *mvm, | 152 | static void iwl_mvm_power_log(struct iwl_mvm *mvm, |
127 | struct iwl_powertable_cmd *cmd) | 153 | struct iwl_mac_power_cmd *cmd) |
128 | { | 154 | { |
129 | IWL_DEBUG_POWER(mvm, | 155 | IWL_DEBUG_POWER(mvm, |
130 | "Sending power table command for power level %d, flags = 0x%X\n", | 156 | "Sending power table command on mac id 0x%X for power level %d, flags = 0x%X\n", |
131 | iwlmvm_mod_params.power_scheme, | 157 | cmd->id_and_color, iwlmvm_mod_params.power_scheme, |
132 | le16_to_cpu(cmd->flags)); | 158 | le16_to_cpu(cmd->flags)); |
133 | IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n", cmd->keep_alive_seconds); | 159 | IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n", |
134 | 160 | le16_to_cpu(cmd->keep_alive_seconds)); | |
135 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | 161 | |
136 | IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n", | 162 | if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK))) { |
137 | le32_to_cpu(cmd->rx_data_timeout)); | 163 | IWL_DEBUG_POWER(mvm, "Disable power management\n"); |
138 | IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n", | 164 | return; |
139 | le32_to_cpu(cmd->tx_data_timeout)); | 165 | } |
140 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) | 166 | |
141 | IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n", | 167 | IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n", |
142 | le32_to_cpu(cmd->skip_dtim_periods)); | 168 | le32_to_cpu(cmd->rx_data_timeout)); |
143 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | 169 | IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n", |
144 | IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n", | 170 | le32_to_cpu(cmd->tx_data_timeout)); |
145 | le32_to_cpu(cmd->lprx_rssi_threshold)); | 171 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) |
172 | IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n", | ||
173 | cmd->skip_dtim_periods); | ||
174 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | ||
175 | IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n", | ||
176 | cmd->lprx_rssi_threshold); | ||
177 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) { | ||
178 | IWL_DEBUG_POWER(mvm, "uAPSD enabled\n"); | ||
179 | IWL_DEBUG_POWER(mvm, "Rx timeout (uAPSD) = %u usec\n", | ||
180 | le32_to_cpu(cmd->rx_data_timeout_uapsd)); | ||
181 | IWL_DEBUG_POWER(mvm, "Tx timeout (uAPSD) = %u usec\n", | ||
182 | le32_to_cpu(cmd->tx_data_timeout_uapsd)); | ||
183 | IWL_DEBUG_POWER(mvm, "QNDP TID = %d\n", cmd->qndp_tid); | ||
184 | IWL_DEBUG_POWER(mvm, "ACs flags = 0x%x\n", cmd->uapsd_ac_flags); | ||
185 | IWL_DEBUG_POWER(mvm, "Max SP = %d\n", cmd->uapsd_max_sp); | ||
146 | } | 186 | } |
147 | } | 187 | } |
148 | 188 | ||
149 | void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | 189 | static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, |
150 | struct iwl_powertable_cmd *cmd) | 190 | struct ieee80211_vif *vif, |
191 | struct iwl_mac_power_cmd *cmd) | ||
151 | { | 192 | { |
152 | struct ieee80211_hw *hw = mvm->hw; | 193 | struct ieee80211_hw *hw = mvm->hw; |
153 | struct ieee80211_chanctx_conf *chanctx_conf; | 194 | struct ieee80211_chanctx_conf *chanctx_conf; |
@@ -157,20 +198,29 @@ void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
157 | bool radar_detect = false; | 198 | bool radar_detect = false; |
158 | struct iwl_mvm_vif *mvmvif __maybe_unused = | 199 | struct iwl_mvm_vif *mvmvif __maybe_unused = |
159 | iwl_mvm_vif_from_mac80211(vif); | 200 | iwl_mvm_vif_from_mac80211(vif); |
201 | enum ieee80211_ac_numbers ac; | ||
202 | bool tid_found = false; | ||
203 | |||
204 | cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, | ||
205 | mvmvif->color)); | ||
206 | dtimper = hw->conf.ps_dtim_period ?: 1; | ||
160 | 207 | ||
161 | /* | 208 | /* |
162 | * Regardless of power management state the driver must set | 209 | * Regardless of power management state the driver must set |
163 | * keep alive period. FW will use it for sending keep alive NDPs | 210 | * keep alive period. FW will use it for sending keep alive NDPs |
164 | * immediately after association. | 211 | * immediately after association. Check that keep alive period |
212 | * is at least 3 * DTIM | ||
165 | */ | 213 | */ |
166 | cmd->keep_alive_seconds = POWER_KEEP_ALIVE_PERIOD_SEC; | 214 | dtimper_msec = dtimper * vif->bss_conf.beacon_int; |
215 | keep_alive = max_t(int, 3 * dtimper_msec, | ||
216 | MSEC_PER_SEC * POWER_KEEP_ALIVE_PERIOD_SEC); | ||
217 | keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC); | ||
218 | cmd->keep_alive_seconds = cpu_to_le16(keep_alive); | ||
167 | 219 | ||
168 | if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM) | 220 | if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM) |
169 | return; | 221 | return; |
170 | 222 | ||
171 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); | 223 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); |
172 | if (!vif->bss_conf.assoc) | ||
173 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK); | ||
174 | 224 | ||
175 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 225 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
176 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && | 226 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && |
@@ -186,12 +236,9 @@ void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
186 | (vif->bss_conf.beacon_rate->bitrate == 10 || | 236 | (vif->bss_conf.beacon_rate->bitrate == 10 || |
187 | vif->bss_conf.beacon_rate->bitrate == 60)) { | 237 | vif->bss_conf.beacon_rate->bitrate == 60)) { |
188 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | 238 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); |
189 | cmd->lprx_rssi_threshold = | 239 | cmd->lprx_rssi_threshold = POWER_LPRX_RSSI_THRESHOLD; |
190 | cpu_to_le32(POWER_LPRX_RSSI_THRESHOLD); | ||
191 | } | 240 | } |
192 | 241 | ||
193 | dtimper = hw->conf.ps_dtim_period ?: 1; | ||
194 | |||
195 | /* Check if radar detection is required on current channel */ | 242 | /* Check if radar detection is required on current channel */ |
196 | rcu_read_lock(); | 243 | rcu_read_lock(); |
197 | chanctx_conf = rcu_dereference(vif->chanctx_conf); | 244 | chanctx_conf = rcu_dereference(vif->chanctx_conf); |
@@ -207,27 +254,82 @@ void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
207 | (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP || | 254 | (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP || |
208 | mvm->cur_ucode == IWL_UCODE_WOWLAN)) { | 255 | mvm->cur_ucode == IWL_UCODE_WOWLAN)) { |
209 | cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); | 256 | cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); |
210 | cmd->skip_dtim_periods = cpu_to_le32(3); | 257 | cmd->skip_dtim_periods = 3; |
211 | } | 258 | } |
212 | 259 | ||
213 | /* Check that keep alive period is at least 3 * DTIM */ | ||
214 | dtimper_msec = dtimper * vif->bss_conf.beacon_int; | ||
215 | keep_alive = max_t(int, 3 * dtimper_msec, | ||
216 | MSEC_PER_SEC * cmd->keep_alive_seconds); | ||
217 | keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC); | ||
218 | cmd->keep_alive_seconds = keep_alive; | ||
219 | |||
220 | if (mvm->cur_ucode != IWL_UCODE_WOWLAN) { | 260 | if (mvm->cur_ucode != IWL_UCODE_WOWLAN) { |
221 | cmd->rx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | 261 | cmd->rx_data_timeout = |
222 | cmd->tx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | 262 | cpu_to_le32(IWL_MVM_DEFAULT_PS_RX_DATA_TIMEOUT); |
263 | cmd->tx_data_timeout = | ||
264 | cpu_to_le32(IWL_MVM_DEFAULT_PS_TX_DATA_TIMEOUT); | ||
223 | } else { | 265 | } else { |
224 | cmd->rx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | 266 | cmd->rx_data_timeout = |
225 | cmd->tx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | 267 | cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT); |
268 | cmd->tx_data_timeout = | ||
269 | cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT); | ||
270 | } | ||
271 | |||
272 | for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_BK; ac++) { | ||
273 | if (!mvmvif->queue_params[ac].uapsd) | ||
274 | continue; | ||
275 | |||
276 | cmd->flags |= cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK); | ||
277 | cmd->uapsd_ac_flags |= BIT(ac); | ||
278 | |||
279 | /* QNDP TID - the highest TID with no admission control */ | ||
280 | if (!tid_found && !mvmvif->queue_params[ac].acm) { | ||
281 | tid_found = true; | ||
282 | switch (ac) { | ||
283 | case IEEE80211_AC_VO: | ||
284 | cmd->qndp_tid = 6; | ||
285 | break; | ||
286 | case IEEE80211_AC_VI: | ||
287 | cmd->qndp_tid = 5; | ||
288 | break; | ||
289 | case IEEE80211_AC_BE: | ||
290 | cmd->qndp_tid = 0; | ||
291 | break; | ||
292 | case IEEE80211_AC_BK: | ||
293 | cmd->qndp_tid = 1; | ||
294 | break; | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | |||
299 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) { | ||
300 | cmd->rx_data_timeout_uapsd = | ||
301 | cpu_to_le32(IWL_MVM_UAPSD_RX_DATA_TIMEOUT); | ||
302 | cmd->tx_data_timeout_uapsd = | ||
303 | cpu_to_le32(IWL_MVM_UAPSD_TX_DATA_TIMEOUT); | ||
304 | |||
305 | if (cmd->uapsd_ac_flags == (BIT(IEEE80211_AC_VO) | | ||
306 | BIT(IEEE80211_AC_VI) | | ||
307 | BIT(IEEE80211_AC_BE) | | ||
308 | BIT(IEEE80211_AC_BK))) { | ||
309 | cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK); | ||
310 | cmd->snooze_interval = | ||
311 | cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL); | ||
312 | cmd->snooze_window = | ||
313 | (mvm->cur_ucode == IWL_UCODE_WOWLAN) ? | ||
314 | cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) : | ||
315 | cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW); | ||
316 | } | ||
317 | |||
318 | cmd->uapsd_max_sp = IWL_UAPSD_MAX_SP; | ||
319 | cmd->heavy_tx_thld_packets = | ||
320 | IWL_MVM_PS_HEAVY_TX_THLD_PACKETS; | ||
321 | cmd->heavy_rx_thld_packets = | ||
322 | IWL_MVM_PS_HEAVY_RX_THLD_PACKETS; | ||
323 | cmd->heavy_tx_thld_percentage = | ||
324 | IWL_MVM_PS_HEAVY_TX_THLD_PERCENT; | ||
325 | cmd->heavy_rx_thld_percentage = | ||
326 | IWL_MVM_PS_HEAVY_RX_THLD_PERCENT; | ||
226 | } | 327 | } |
227 | 328 | ||
228 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 329 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
229 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE) | 330 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE) |
230 | cmd->keep_alive_seconds = mvmvif->dbgfs_pm.keep_alive_seconds; | 331 | cmd->keep_alive_seconds = |
332 | cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds); | ||
231 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) { | 333 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) { |
232 | if (mvmvif->dbgfs_pm.skip_over_dtim) | 334 | if (mvmvif->dbgfs_pm.skip_over_dtim) |
233 | cmd->flags |= | 335 | cmd->flags |= |
@@ -243,8 +345,7 @@ void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
243 | cmd->tx_data_timeout = | 345 | cmd->tx_data_timeout = |
244 | cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout); | 346 | cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout); |
245 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS) | 347 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS) |
246 | cmd->skip_dtim_periods = | 348 | cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods; |
247 | cpu_to_le32(mvmvif->dbgfs_pm.skip_dtim_periods); | ||
248 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) { | 349 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) { |
249 | if (mvmvif->dbgfs_pm.lprx_ena) | 350 | if (mvmvif->dbgfs_pm.lprx_ena) |
250 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | 351 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); |
@@ -252,16 +353,24 @@ void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
252 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK); | 353 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK); |
253 | } | 354 | } |
254 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD) | 355 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD) |
255 | cmd->lprx_rssi_threshold = | 356 | cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold; |
256 | cpu_to_le32(mvmvif->dbgfs_pm.lprx_rssi_threshold); | 357 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SNOOZE_ENABLE) { |
358 | if (mvmvif->dbgfs_pm.snooze_ena) | ||
359 | cmd->flags |= | ||
360 | cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK); | ||
361 | else | ||
362 | cmd->flags &= | ||
363 | cpu_to_le16(~POWER_FLAGS_SNOOZE_ENA_MSK); | ||
364 | } | ||
257 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ | 365 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ |
258 | } | 366 | } |
259 | 367 | ||
260 | int iwl_mvm_power_update_mode(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | 368 | static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm, |
369 | struct ieee80211_vif *vif) | ||
261 | { | 370 | { |
262 | int ret; | 371 | int ret; |
263 | bool ba_enable; | 372 | bool ba_enable; |
264 | struct iwl_powertable_cmd cmd = {}; | 373 | struct iwl_mac_power_cmd cmd = {}; |
265 | 374 | ||
266 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | 375 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) |
267 | return 0; | 376 | return 0; |
@@ -280,7 +389,7 @@ int iwl_mvm_power_update_mode(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
280 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | 389 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); |
281 | iwl_mvm_power_log(mvm, &cmd); | 390 | iwl_mvm_power_log(mvm, &cmd); |
282 | 391 | ||
283 | ret = iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_SYNC, | 392 | ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_SYNC, |
284 | sizeof(cmd), &cmd); | 393 | sizeof(cmd), &cmd); |
285 | if (ret) | 394 | if (ret) |
286 | return ret; | 395 | return ret; |
@@ -291,15 +400,19 @@ int iwl_mvm_power_update_mode(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
291 | return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable); | 400 | return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable); |
292 | } | 401 | } |
293 | 402 | ||
294 | int iwl_mvm_power_disable(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | 403 | static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm, |
404 | struct ieee80211_vif *vif) | ||
295 | { | 405 | { |
296 | struct iwl_powertable_cmd cmd = {}; | 406 | struct iwl_mac_power_cmd cmd = {}; |
297 | struct iwl_mvm_vif *mvmvif __maybe_unused = | 407 | struct iwl_mvm_vif *mvmvif __maybe_unused = |
298 | iwl_mvm_vif_from_mac80211(vif); | 408 | iwl_mvm_vif_from_mac80211(vif); |
299 | 409 | ||
300 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | 410 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) |
301 | return 0; | 411 | return 0; |
302 | 412 | ||
413 | cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, | ||
414 | mvmvif->color)); | ||
415 | |||
303 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) | 416 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
304 | cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); | 417 | cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); |
305 | 418 | ||
@@ -310,11 +423,98 @@ int iwl_mvm_power_disable(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
310 | #endif | 423 | #endif |
311 | iwl_mvm_power_log(mvm, &cmd); | 424 | iwl_mvm_power_log(mvm, &cmd); |
312 | 425 | ||
313 | return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_ASYNC, | 426 | return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_ASYNC, |
314 | sizeof(cmd), &cmd); | 427 | sizeof(cmd), &cmd); |
315 | } | 428 | } |
316 | 429 | ||
317 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 430 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
431 | static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, | ||
432 | struct ieee80211_vif *vif, char *buf, | ||
433 | int bufsz) | ||
434 | { | ||
435 | struct iwl_mac_power_cmd cmd = {}; | ||
436 | int pos = 0; | ||
437 | |||
438 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | ||
439 | |||
440 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n", | ||
441 | (cmd.flags & | ||
442 | cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ? | ||
443 | 0 : 1); | ||
444 | pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n", | ||
445 | iwlmvm_mod_params.power_scheme); | ||
446 | pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n", | ||
447 | le16_to_cpu(cmd.flags)); | ||
448 | pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n", | ||
449 | le16_to_cpu(cmd.keep_alive_seconds)); | ||
450 | |||
451 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | ||
452 | pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n", | ||
453 | (cmd.flags & | ||
454 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? | ||
455 | 1 : 0); | ||
456 | pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n", | ||
457 | cmd.skip_dtim_periods); | ||
458 | if (!(cmd.flags & | ||
459 | cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK))) { | ||
460 | pos += scnprintf(buf+pos, bufsz-pos, | ||
461 | "rx_data_timeout = %d\n", | ||
462 | le32_to_cpu(cmd.rx_data_timeout)); | ||
463 | pos += scnprintf(buf+pos, bufsz-pos, | ||
464 | "tx_data_timeout = %d\n", | ||
465 | le32_to_cpu(cmd.tx_data_timeout)); | ||
466 | } | ||
467 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | ||
468 | pos += scnprintf(buf+pos, bufsz-pos, | ||
469 | "lprx_rssi_threshold = %d\n", | ||
470 | cmd.lprx_rssi_threshold); | ||
471 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) { | ||
472 | pos += | ||
473 | scnprintf(buf+pos, bufsz-pos, | ||
474 | "rx_data_timeout_uapsd = %d\n", | ||
475 | le32_to_cpu(cmd.rx_data_timeout_uapsd)); | ||
476 | pos += | ||
477 | scnprintf(buf+pos, bufsz-pos, | ||
478 | "tx_data_timeout_uapsd = %d\n", | ||
479 | le32_to_cpu(cmd.tx_data_timeout_uapsd)); | ||
480 | pos += scnprintf(buf+pos, bufsz-pos, "qndp_tid = %d\n", | ||
481 | cmd.qndp_tid); | ||
482 | pos += scnprintf(buf+pos, bufsz-pos, | ||
483 | "uapsd_ac_flags = 0x%x\n", | ||
484 | cmd.uapsd_ac_flags); | ||
485 | pos += scnprintf(buf+pos, bufsz-pos, | ||
486 | "uapsd_max_sp = %d\n", | ||
487 | cmd.uapsd_max_sp); | ||
488 | pos += scnprintf(buf+pos, bufsz-pos, | ||
489 | "heavy_tx_thld_packets = %d\n", | ||
490 | cmd.heavy_tx_thld_packets); | ||
491 | pos += scnprintf(buf+pos, bufsz-pos, | ||
492 | "heavy_rx_thld_packets = %d\n", | ||
493 | cmd.heavy_rx_thld_packets); | ||
494 | pos += scnprintf(buf+pos, bufsz-pos, | ||
495 | "heavy_tx_thld_percentage = %d\n", | ||
496 | cmd.heavy_tx_thld_percentage); | ||
497 | pos += scnprintf(buf+pos, bufsz-pos, | ||
498 | "heavy_rx_thld_percentage = %d\n", | ||
499 | cmd.heavy_rx_thld_percentage); | ||
500 | pos += | ||
501 | scnprintf(buf+pos, bufsz-pos, "snooze_enable = %d\n", | ||
502 | (cmd.flags & | ||
503 | cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) ? | ||
504 | 1 : 0); | ||
505 | } | ||
506 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) { | ||
507 | pos += scnprintf(buf+pos, bufsz-pos, | ||
508 | "snooze_interval = %d\n", | ||
509 | cmd.snooze_interval); | ||
510 | pos += scnprintf(buf+pos, bufsz-pos, | ||
511 | "snooze_window = %d\n", | ||
512 | cmd.snooze_window); | ||
513 | } | ||
514 | } | ||
515 | return pos; | ||
516 | } | ||
517 | |||
318 | void | 518 | void |
319 | iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, | 519 | iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, |
320 | struct iwl_beacon_filter_cmd *cmd) | 520 | struct iwl_beacon_filter_cmd *cmd) |
@@ -323,22 +523,30 @@ iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, | |||
323 | struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf; | 523 | struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf; |
324 | 524 | ||
325 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA) | 525 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA) |
326 | cmd->bf_energy_delta = dbgfs_bf->bf_energy_delta; | 526 | cmd->bf_energy_delta = cpu_to_le32(dbgfs_bf->bf_energy_delta); |
327 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA) | 527 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA) |
328 | cmd->bf_roaming_energy_delta = | 528 | cmd->bf_roaming_energy_delta = |
329 | dbgfs_bf->bf_roaming_energy_delta; | 529 | cpu_to_le32(dbgfs_bf->bf_roaming_energy_delta); |
330 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE) | 530 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE) |
331 | cmd->bf_roaming_state = dbgfs_bf->bf_roaming_state; | 531 | cmd->bf_roaming_state = cpu_to_le32(dbgfs_bf->bf_roaming_state); |
332 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMPERATURE_DELTA) | 532 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_THRESHOLD) |
333 | cmd->bf_temperature_delta = dbgfs_bf->bf_temperature_delta; | 533 | cmd->bf_temp_threshold = |
534 | cpu_to_le32(dbgfs_bf->bf_temp_threshold); | ||
535 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_FAST_FILTER) | ||
536 | cmd->bf_temp_fast_filter = | ||
537 | cpu_to_le32(dbgfs_bf->bf_temp_fast_filter); | ||
538 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_SLOW_FILTER) | ||
539 | cmd->bf_temp_slow_filter = | ||
540 | cpu_to_le32(dbgfs_bf->bf_temp_slow_filter); | ||
334 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG) | 541 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG) |
335 | cmd->bf_debug_flag = dbgfs_bf->bf_debug_flag; | 542 | cmd->bf_debug_flag = cpu_to_le32(dbgfs_bf->bf_debug_flag); |
336 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER) | 543 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER) |
337 | cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer); | 544 | cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer); |
338 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER) | 545 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER) |
339 | cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer); | 546 | cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer); |
340 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT) | 547 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT) |
341 | cmd->ba_enable_beacon_abort = dbgfs_bf->ba_enable_beacon_abort; | 548 | cmd->ba_enable_beacon_abort = |
549 | cpu_to_le32(dbgfs_bf->ba_enable_beacon_abort); | ||
342 | } | 550 | } |
343 | #endif | 551 | #endif |
344 | 552 | ||
@@ -348,7 +556,7 @@ int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, | |||
348 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 556 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
349 | struct iwl_beacon_filter_cmd cmd = { | 557 | struct iwl_beacon_filter_cmd cmd = { |
350 | IWL_BF_CMD_CONFIG_DEFAULTS, | 558 | IWL_BF_CMD_CONFIG_DEFAULTS, |
351 | .bf_enable_beacon_filter = 1, | 559 | .bf_enable_beacon_filter = cpu_to_le32(1), |
352 | }; | 560 | }; |
353 | int ret; | 561 | int ret; |
354 | 562 | ||
@@ -356,11 +564,12 @@ int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, | |||
356 | vif->type != NL80211_IFTYPE_STATION || vif->p2p) | 564 | vif->type != NL80211_IFTYPE_STATION || vif->p2p) |
357 | return 0; | 565 | return 0; |
358 | 566 | ||
567 | iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd); | ||
359 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); | 568 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); |
360 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); | 569 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
361 | 570 | ||
362 | if (!ret) | 571 | if (!ret) |
363 | mvmvif->bf_enabled = true; | 572 | mvmvif->bf_data.bf_enabled = true; |
364 | 573 | ||
365 | return ret; | 574 | return ret; |
366 | } | 575 | } |
@@ -372,13 +581,33 @@ int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, | |||
372 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 581 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
373 | int ret; | 582 | int ret; |
374 | 583 | ||
375 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | 584 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED) || |
585 | vif->type != NL80211_IFTYPE_STATION || vif->p2p) | ||
376 | return 0; | 586 | return 0; |
377 | 587 | ||
378 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); | 588 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
379 | 589 | ||
380 | if (!ret) | 590 | if (!ret) |
381 | mvmvif->bf_enabled = false; | 591 | mvmvif->bf_data.bf_enabled = false; |
382 | 592 | ||
383 | return ret; | 593 | return ret; |
384 | } | 594 | } |
595 | |||
596 | int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm, | ||
597 | struct ieee80211_vif *vif) | ||
598 | { | ||
599 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | ||
600 | |||
601 | if (!mvmvif->bf_data.bf_enabled) | ||
602 | return 0; | ||
603 | |||
604 | return iwl_mvm_enable_beacon_filter(mvm, vif); | ||
605 | } | ||
606 | |||
607 | const struct iwl_mvm_power_ops pm_mac_ops = { | ||
608 | .power_update_mode = iwl_mvm_power_mac_update_mode, | ||
609 | .power_disable = iwl_mvm_power_mac_disable, | ||
610 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
611 | .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read, | ||
612 | #endif | ||
613 | }; | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/power_legacy.c b/drivers/net/wireless/iwlwifi/mvm/power_legacy.c new file mode 100644 index 000000000000..2ce79bad5845 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/mvm/power_legacy.c | |||
@@ -0,0 +1,319 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
4 | * redistributing this file, you may do so under either license. | ||
5 | * | ||
6 | * GPL LICENSE SUMMARY | ||
7 | * | ||
8 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of version 2 of the GNU General Public License as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | ||
22 | * USA | ||
23 | * | ||
24 | * The full GNU General Public License is included in this distribution | ||
25 | * in the file called COPYING. | ||
26 | * | ||
27 | * Contact Information: | ||
28 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
30 | * | ||
31 | * BSD LICENSE | ||
32 | * | ||
33 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. | ||
34 | * All rights reserved. | ||
35 | * | ||
36 | * Redistribution and use in source and binary forms, with or without | ||
37 | * modification, are permitted provided that the following conditions | ||
38 | * are met: | ||
39 | * | ||
40 | * * Redistributions of source code must retain the above copyright | ||
41 | * notice, this list of conditions and the following disclaimer. | ||
42 | * * Redistributions in binary form must reproduce the above copyright | ||
43 | * notice, this list of conditions and the following disclaimer in | ||
44 | * the documentation and/or other materials provided with the | ||
45 | * distribution. | ||
46 | * * Neither the name Intel Corporation nor the names of its | ||
47 | * contributors may be used to endorse or promote products derived | ||
48 | * from this software without specific prior written permission. | ||
49 | * | ||
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
61 | * | ||
62 | *****************************************************************************/ | ||
63 | |||
64 | #include <linux/kernel.h> | ||
65 | #include <linux/module.h> | ||
66 | #include <linux/slab.h> | ||
67 | #include <linux/init.h> | ||
68 | |||
69 | #include <net/mac80211.h> | ||
70 | |||
71 | #include "iwl-debug.h" | ||
72 | #include "mvm.h" | ||
73 | #include "iwl-modparams.h" | ||
74 | #include "fw-api-power.h" | ||
75 | |||
76 | #define POWER_KEEP_ALIVE_PERIOD_SEC 25 | ||
77 | |||
78 | static void iwl_mvm_power_log(struct iwl_mvm *mvm, | ||
79 | struct iwl_powertable_cmd *cmd) | ||
80 | { | ||
81 | IWL_DEBUG_POWER(mvm, | ||
82 | "Sending power table command for power level %d, flags = 0x%X\n", | ||
83 | iwlmvm_mod_params.power_scheme, | ||
84 | le16_to_cpu(cmd->flags)); | ||
85 | IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n", cmd->keep_alive_seconds); | ||
86 | |||
87 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | ||
88 | IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n", | ||
89 | le32_to_cpu(cmd->rx_data_timeout)); | ||
90 | IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n", | ||
91 | le32_to_cpu(cmd->tx_data_timeout)); | ||
92 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) | ||
93 | IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n", | ||
94 | le32_to_cpu(cmd->skip_dtim_periods)); | ||
95 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | ||
96 | IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n", | ||
97 | le32_to_cpu(cmd->lprx_rssi_threshold)); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, | ||
102 | struct ieee80211_vif *vif, | ||
103 | struct iwl_powertable_cmd *cmd) | ||
104 | { | ||
105 | struct ieee80211_hw *hw = mvm->hw; | ||
106 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
107 | struct ieee80211_channel *chan; | ||
108 | int dtimper, dtimper_msec; | ||
109 | int keep_alive; | ||
110 | bool radar_detect = false; | ||
111 | struct iwl_mvm_vif *mvmvif __maybe_unused = | ||
112 | iwl_mvm_vif_from_mac80211(vif); | ||
113 | |||
114 | /* | ||
115 | * Regardless of power management state the driver must set | ||
116 | * keep alive period. FW will use it for sending keep alive NDPs | ||
117 | * immediately after association. | ||
118 | */ | ||
119 | cmd->keep_alive_seconds = POWER_KEEP_ALIVE_PERIOD_SEC; | ||
120 | |||
121 | if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM) | ||
122 | return; | ||
123 | |||
124 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); | ||
125 | if (!vif->bss_conf.assoc) | ||
126 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK); | ||
127 | |||
128 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
129 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && | ||
130 | mvmvif->dbgfs_pm.disable_power_off) | ||
131 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK); | ||
132 | #endif | ||
133 | if (!vif->bss_conf.ps) | ||
134 | return; | ||
135 | |||
136 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK); | ||
137 | |||
138 | if (vif->bss_conf.beacon_rate && | ||
139 | (vif->bss_conf.beacon_rate->bitrate == 10 || | ||
140 | vif->bss_conf.beacon_rate->bitrate == 60)) { | ||
141 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | ||
142 | cmd->lprx_rssi_threshold = | ||
143 | cpu_to_le32(POWER_LPRX_RSSI_THRESHOLD); | ||
144 | } | ||
145 | |||
146 | dtimper = hw->conf.ps_dtim_period ?: 1; | ||
147 | |||
148 | /* Check if radar detection is required on current channel */ | ||
149 | rcu_read_lock(); | ||
150 | chanctx_conf = rcu_dereference(vif->chanctx_conf); | ||
151 | WARN_ON(!chanctx_conf); | ||
152 | if (chanctx_conf) { | ||
153 | chan = chanctx_conf->def.chan; | ||
154 | radar_detect = chan->flags & IEEE80211_CHAN_RADAR; | ||
155 | } | ||
156 | rcu_read_unlock(); | ||
157 | |||
158 | /* Check skip over DTIM conditions */ | ||
159 | if (!radar_detect && (dtimper <= 10) && | ||
160 | (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP || | ||
161 | mvm->cur_ucode == IWL_UCODE_WOWLAN)) { | ||
162 | cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); | ||
163 | cmd->skip_dtim_periods = cpu_to_le32(3); | ||
164 | } | ||
165 | |||
166 | /* Check that keep alive period is at least 3 * DTIM */ | ||
167 | dtimper_msec = dtimper * vif->bss_conf.beacon_int; | ||
168 | keep_alive = max_t(int, 3 * dtimper_msec, | ||
169 | MSEC_PER_SEC * cmd->keep_alive_seconds); | ||
170 | keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC); | ||
171 | cmd->keep_alive_seconds = keep_alive; | ||
172 | |||
173 | if (mvm->cur_ucode != IWL_UCODE_WOWLAN) { | ||
174 | cmd->rx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | ||
175 | cmd->tx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | ||
176 | } else { | ||
177 | cmd->rx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | ||
178 | cmd->tx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | ||
179 | } | ||
180 | |||
181 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
182 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE) | ||
183 | cmd->keep_alive_seconds = mvmvif->dbgfs_pm.keep_alive_seconds; | ||
184 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) { | ||
185 | if (mvmvif->dbgfs_pm.skip_over_dtim) | ||
186 | cmd->flags |= | ||
187 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); | ||
188 | else | ||
189 | cmd->flags &= | ||
190 | cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK); | ||
191 | } | ||
192 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT) | ||
193 | cmd->rx_data_timeout = | ||
194 | cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout); | ||
195 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT) | ||
196 | cmd->tx_data_timeout = | ||
197 | cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout); | ||
198 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS) | ||
199 | cmd->skip_dtim_periods = | ||
200 | cpu_to_le32(mvmvif->dbgfs_pm.skip_dtim_periods); | ||
201 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) { | ||
202 | if (mvmvif->dbgfs_pm.lprx_ena) | ||
203 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | ||
204 | else | ||
205 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK); | ||
206 | } | ||
207 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD) | ||
208 | cmd->lprx_rssi_threshold = | ||
209 | cpu_to_le32(mvmvif->dbgfs_pm.lprx_rssi_threshold); | ||
210 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ | ||
211 | } | ||
212 | |||
213 | static int iwl_mvm_power_legacy_update_mode(struct iwl_mvm *mvm, | ||
214 | struct ieee80211_vif *vif) | ||
215 | { | ||
216 | int ret; | ||
217 | bool ba_enable; | ||
218 | struct iwl_powertable_cmd cmd = {}; | ||
219 | |||
220 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | ||
221 | return 0; | ||
222 | |||
223 | /* | ||
224 | * TODO: The following vif_count verification is temporary condition. | ||
225 | * Avoid power mode update if more than one interface is currently | ||
226 | * active. Remove this condition when FW will support power management | ||
227 | * on multiple MACs. | ||
228 | */ | ||
229 | IWL_DEBUG_POWER(mvm, "Currently %d interfaces active\n", | ||
230 | mvm->vif_count); | ||
231 | if (mvm->vif_count > 1) | ||
232 | return 0; | ||
233 | |||
234 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | ||
235 | iwl_mvm_power_log(mvm, &cmd); | ||
236 | |||
237 | ret = iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_SYNC, | ||
238 | sizeof(cmd), &cmd); | ||
239 | if (ret) | ||
240 | return ret; | ||
241 | |||
242 | ba_enable = !!(cmd.flags & | ||
243 | cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)); | ||
244 | |||
245 | return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable); | ||
246 | } | ||
247 | |||
248 | static int iwl_mvm_power_legacy_disable(struct iwl_mvm *mvm, | ||
249 | struct ieee80211_vif *vif) | ||
250 | { | ||
251 | struct iwl_powertable_cmd cmd = {}; | ||
252 | struct iwl_mvm_vif *mvmvif __maybe_unused = | ||
253 | iwl_mvm_vif_from_mac80211(vif); | ||
254 | |||
255 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | ||
256 | return 0; | ||
257 | |||
258 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) | ||
259 | cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); | ||
260 | |||
261 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
262 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && | ||
263 | mvmvif->dbgfs_pm.disable_power_off) | ||
264 | cmd.flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK); | ||
265 | #endif | ||
266 | iwl_mvm_power_log(mvm, &cmd); | ||
267 | |||
268 | return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_ASYNC, | ||
269 | sizeof(cmd), &cmd); | ||
270 | } | ||
271 | |||
272 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
273 | static int iwl_mvm_power_legacy_dbgfs_read(struct iwl_mvm *mvm, | ||
274 | struct ieee80211_vif *vif, char *buf, | ||
275 | int bufsz) | ||
276 | { | ||
277 | struct iwl_powertable_cmd cmd = {}; | ||
278 | int pos = 0; | ||
279 | |||
280 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | ||
281 | |||
282 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n", | ||
283 | (cmd.flags & | ||
284 | cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ? | ||
285 | 0 : 1); | ||
286 | pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n", | ||
287 | le32_to_cpu(cmd.skip_dtim_periods)); | ||
288 | pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n", | ||
289 | iwlmvm_mod_params.power_scheme); | ||
290 | pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n", | ||
291 | le16_to_cpu(cmd.flags)); | ||
292 | pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n", | ||
293 | cmd.keep_alive_seconds); | ||
294 | |||
295 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | ||
296 | pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n", | ||
297 | (cmd.flags & | ||
298 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? | ||
299 | 1 : 0); | ||
300 | pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n", | ||
301 | le32_to_cpu(cmd.rx_data_timeout)); | ||
302 | pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n", | ||
303 | le32_to_cpu(cmd.tx_data_timeout)); | ||
304 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | ||
305 | pos += scnprintf(buf+pos, bufsz-pos, | ||
306 | "lprx_rssi_threshold = %d\n", | ||
307 | le32_to_cpu(cmd.lprx_rssi_threshold)); | ||
308 | } | ||
309 | return pos; | ||
310 | } | ||
311 | #endif | ||
312 | |||
313 | const struct iwl_mvm_power_ops pm_legacy_ops = { | ||
314 | .power_update_mode = iwl_mvm_power_legacy_update_mode, | ||
315 | .power_disable = iwl_mvm_power_legacy_disable, | ||
316 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
317 | .power_dbgfs_read = iwl_mvm_power_legacy_dbgfs_read, | ||
318 | #endif | ||
319 | }; | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/quota.c b/drivers/net/wireless/iwlwifi/mvm/quota.c index 29d49cf0fdb2..5c6ae16ec52b 100644 --- a/drivers/net/wireless/iwlwifi/mvm/quota.c +++ b/drivers/net/wireless/iwlwifi/mvm/quota.c | |||
@@ -131,23 +131,22 @@ static void iwl_mvm_quota_iterator(void *_data, u8 *mac, | |||
131 | 131 | ||
132 | int iwl_mvm_update_quotas(struct iwl_mvm *mvm, struct ieee80211_vif *newvif) | 132 | int iwl_mvm_update_quotas(struct iwl_mvm *mvm, struct ieee80211_vif *newvif) |
133 | { | 133 | { |
134 | struct iwl_time_quota_cmd cmd; | 134 | struct iwl_time_quota_cmd cmd = {}; |
135 | int i, idx, ret, num_active_bindings, quota, quota_rem; | 135 | int i, idx, ret, num_active_macs, quota, quota_rem; |
136 | struct iwl_mvm_quota_iterator_data data = { | 136 | struct iwl_mvm_quota_iterator_data data = { |
137 | .n_interfaces = {}, | 137 | .n_interfaces = {}, |
138 | .colors = { -1, -1, -1, -1 }, | 138 | .colors = { -1, -1, -1, -1 }, |
139 | .new_vif = newvif, | 139 | .new_vif = newvif, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | lockdep_assert_held(&mvm->mutex); | ||
143 | |||
142 | /* update all upon completion */ | 144 | /* update all upon completion */ |
143 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | 145 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
144 | return 0; | 146 | return 0; |
145 | 147 | ||
146 | BUILD_BUG_ON(data.colors[MAX_BINDINGS - 1] != -1); | 148 | /* iterator data above must match */ |
147 | 149 | BUILD_BUG_ON(MAX_BINDINGS != 4); | |
148 | lockdep_assert_held(&mvm->mutex); | ||
149 | |||
150 | memset(&cmd, 0, sizeof(cmd)); | ||
151 | 150 | ||
152 | ieee80211_iterate_active_interfaces_atomic( | 151 | ieee80211_iterate_active_interfaces_atomic( |
153 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | 152 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
@@ -162,18 +161,17 @@ int iwl_mvm_update_quotas(struct iwl_mvm *mvm, struct ieee80211_vif *newvif) | |||
162 | * IWL_MVM_MAX_QUOTA fragments. Divide these fragments | 161 | * IWL_MVM_MAX_QUOTA fragments. Divide these fragments |
163 | * equally between all the bindings that require quota | 162 | * equally between all the bindings that require quota |
164 | */ | 163 | */ |
165 | num_active_bindings = 0; | 164 | num_active_macs = 0; |
166 | for (i = 0; i < MAX_BINDINGS; i++) { | 165 | for (i = 0; i < MAX_BINDINGS; i++) { |
167 | cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID); | 166 | cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID); |
168 | if (data.n_interfaces[i] > 0) | 167 | num_active_macs += data.n_interfaces[i]; |
169 | num_active_bindings++; | ||
170 | } | 168 | } |
171 | 169 | ||
172 | quota = 0; | 170 | quota = 0; |
173 | quota_rem = 0; | 171 | quota_rem = 0; |
174 | if (num_active_bindings) { | 172 | if (num_active_macs) { |
175 | quota = IWL_MVM_MAX_QUOTA / num_active_bindings; | 173 | quota = IWL_MVM_MAX_QUOTA / num_active_macs; |
176 | quota_rem = IWL_MVM_MAX_QUOTA % num_active_bindings; | 174 | quota_rem = IWL_MVM_MAX_QUOTA % num_active_macs; |
177 | } | 175 | } |
178 | 176 | ||
179 | for (idx = 0, i = 0; i < MAX_BINDINGS; i++) { | 177 | for (idx = 0, i = 0; i < MAX_BINDINGS; i++) { |
@@ -187,7 +185,8 @@ int iwl_mvm_update_quotas(struct iwl_mvm *mvm, struct ieee80211_vif *newvif) | |||
187 | cmd.quotas[idx].quota = cpu_to_le32(0); | 185 | cmd.quotas[idx].quota = cpu_to_le32(0); |
188 | cmd.quotas[idx].max_duration = cpu_to_le32(0); | 186 | cmd.quotas[idx].max_duration = cpu_to_le32(0); |
189 | } else { | 187 | } else { |
190 | cmd.quotas[idx].quota = cpu_to_le32(quota); | 188 | cmd.quotas[idx].quota = |
189 | cpu_to_le32(quota * data.n_interfaces[i]); | ||
191 | cmd.quotas[idx].max_duration = | 190 | cmd.quotas[idx].max_duration = |
192 | cpu_to_le32(IWL_MVM_MAX_QUOTA); | 191 | cpu_to_le32(IWL_MVM_MAX_QUOTA); |
193 | } | 192 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c index 376ea2112de2..4ffaa3fa153f 100644 --- a/drivers/net/wireless/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/iwlwifi/mvm/rs.c | |||
@@ -56,61 +56,61 @@ | |||
56 | #define IWL_RATE_SCALE_FLUSH_INTVL (3*HZ) | 56 | #define IWL_RATE_SCALE_FLUSH_INTVL (3*HZ) |
57 | 57 | ||
58 | static u8 rs_ht_to_legacy[] = { | 58 | static u8 rs_ht_to_legacy[] = { |
59 | IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, | 59 | [IWL_RATE_1M_INDEX] = IWL_RATE_6M_INDEX, |
60 | IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, | 60 | [IWL_RATE_2M_INDEX] = IWL_RATE_6M_INDEX, |
61 | IWL_RATE_6M_INDEX, | 61 | [IWL_RATE_5M_INDEX] = IWL_RATE_6M_INDEX, |
62 | IWL_RATE_6M_INDEX, IWL_RATE_9M_INDEX, | 62 | [IWL_RATE_11M_INDEX] = IWL_RATE_6M_INDEX, |
63 | IWL_RATE_12M_INDEX, IWL_RATE_18M_INDEX, | 63 | [IWL_RATE_6M_INDEX] = IWL_RATE_6M_INDEX, |
64 | IWL_RATE_24M_INDEX, IWL_RATE_36M_INDEX, | 64 | [IWL_RATE_9M_INDEX] = IWL_RATE_6M_INDEX, |
65 | IWL_RATE_48M_INDEX, IWL_RATE_54M_INDEX | 65 | [IWL_RATE_12M_INDEX] = IWL_RATE_9M_INDEX, |
66 | [IWL_RATE_18M_INDEX] = IWL_RATE_12M_INDEX, | ||
67 | [IWL_RATE_24M_INDEX] = IWL_RATE_18M_INDEX, | ||
68 | [IWL_RATE_36M_INDEX] = IWL_RATE_24M_INDEX, | ||
69 | [IWL_RATE_48M_INDEX] = IWL_RATE_36M_INDEX, | ||
70 | [IWL_RATE_54M_INDEX] = IWL_RATE_48M_INDEX, | ||
71 | [IWL_RATE_60M_INDEX] = IWL_RATE_54M_INDEX, | ||
66 | }; | 72 | }; |
67 | 73 | ||
68 | static const u8 ant_toggle_lookup[] = { | 74 | static const u8 ant_toggle_lookup[] = { |
69 | /*ANT_NONE -> */ ANT_NONE, | 75 | [ANT_NONE] = ANT_NONE, |
70 | /*ANT_A -> */ ANT_B, | 76 | [ANT_A] = ANT_B, |
71 | /*ANT_B -> */ ANT_C, | 77 | [ANT_B] = ANT_C, |
72 | /*ANT_AB -> */ ANT_BC, | 78 | [ANT_AB] = ANT_BC, |
73 | /*ANT_C -> */ ANT_A, | 79 | [ANT_C] = ANT_A, |
74 | /*ANT_AC -> */ ANT_AB, | 80 | [ANT_AC] = ANT_AB, |
75 | /*ANT_BC -> */ ANT_AC, | 81 | [ANT_BC] = ANT_AC, |
76 | /*ANT_ABC -> */ ANT_ABC, | 82 | [ANT_ABC] = ANT_ABC, |
77 | }; | 83 | }; |
78 | 84 | ||
79 | #define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ | 85 | #define IWL_DECLARE_RATE_INFO(r, s, rp, rn) \ |
80 | [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ | 86 | [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ |
81 | IWL_RATE_SISO_##s##M_PLCP, \ | 87 | IWL_RATE_SISO_##s##M_PLCP, \ |
82 | IWL_RATE_MIMO2_##s##M_PLCP,\ | 88 | IWL_RATE_MIMO2_##s##M_PLCP,\ |
83 | IWL_RATE_MIMO3_##s##M_PLCP,\ | ||
84 | IWL_RATE_##r##M_IEEE, \ | ||
85 | IWL_RATE_##ip##M_INDEX, \ | ||
86 | IWL_RATE_##in##M_INDEX, \ | ||
87 | IWL_RATE_##rp##M_INDEX, \ | 89 | IWL_RATE_##rp##M_INDEX, \ |
88 | IWL_RATE_##rn##M_INDEX, \ | 90 | IWL_RATE_##rn##M_INDEX } |
89 | IWL_RATE_##pp##M_INDEX, \ | ||
90 | IWL_RATE_##np##M_INDEX } | ||
91 | 91 | ||
92 | /* | 92 | /* |
93 | * Parameter order: | 93 | * Parameter order: |
94 | * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate | 94 | * rate, ht rate, prev rate, next rate |
95 | * | 95 | * |
96 | * If there isn't a valid next or previous rate then INV is used which | 96 | * If there isn't a valid next or previous rate then INV is used which |
97 | * maps to IWL_RATE_INVALID | 97 | * maps to IWL_RATE_INVALID |
98 | * | 98 | * |
99 | */ | 99 | */ |
100 | static const struct iwl_rs_rate_info iwl_rates[IWL_RATE_COUNT] = { | 100 | static const struct iwl_rs_rate_info iwl_rates[IWL_RATE_COUNT] = { |
101 | IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ | 101 | IWL_DECLARE_RATE_INFO(1, INV, INV, 2), /* 1mbps */ |
102 | IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ | 102 | IWL_DECLARE_RATE_INFO(2, INV, 1, 5), /* 2mbps */ |
103 | IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ | 103 | IWL_DECLARE_RATE_INFO(5, INV, 2, 11), /*5.5mbps */ |
104 | IWL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ | 104 | IWL_DECLARE_RATE_INFO(11, INV, 9, 12), /* 11mbps */ |
105 | IWL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ | 105 | IWL_DECLARE_RATE_INFO(6, 6, 5, 11), /* 6mbps */ |
106 | IWL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ | 106 | IWL_DECLARE_RATE_INFO(9, 6, 6, 11), /* 9mbps */ |
107 | IWL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ | 107 | IWL_DECLARE_RATE_INFO(12, 12, 11, 18), /* 12mbps */ |
108 | IWL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ | 108 | IWL_DECLARE_RATE_INFO(18, 18, 12, 24), /* 18mbps */ |
109 | IWL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ | 109 | IWL_DECLARE_RATE_INFO(24, 24, 18, 36), /* 24mbps */ |
110 | IWL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ | 110 | IWL_DECLARE_RATE_INFO(36, 36, 24, 48), /* 36mbps */ |
111 | IWL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ | 111 | IWL_DECLARE_RATE_INFO(48, 48, 36, 54), /* 48mbps */ |
112 | IWL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ | 112 | IWL_DECLARE_RATE_INFO(54, 54, 48, INV), /* 54mbps */ |
113 | IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ | 113 | IWL_DECLARE_RATE_INFO(60, 60, 48, INV), /* 60mbps */ |
114 | /* FIXME:RS: ^^ should be INV (legacy) */ | 114 | /* FIXME:RS: ^^ should be INV (legacy) */ |
115 | }; | 115 | }; |
116 | 116 | ||
@@ -128,9 +128,8 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
128 | if (rate_n_flags & RATE_MCS_HT_MSK) { | 128 | if (rate_n_flags & RATE_MCS_HT_MSK) { |
129 | idx = rs_extract_rate(rate_n_flags); | 129 | idx = rs_extract_rate(rate_n_flags); |
130 | 130 | ||
131 | if (idx >= IWL_RATE_MIMO3_6M_PLCP) | 131 | WARN_ON_ONCE(idx >= IWL_RATE_MIMO3_6M_PLCP); |
132 | idx = idx - IWL_RATE_MIMO3_6M_PLCP; | 132 | if (idx >= IWL_RATE_MIMO2_6M_PLCP) |
133 | else if (idx >= IWL_RATE_MIMO2_6M_PLCP) | ||
134 | idx = idx - IWL_RATE_MIMO2_6M_PLCP; | 133 | idx = idx - IWL_RATE_MIMO2_6M_PLCP; |
135 | 134 | ||
136 | idx += IWL_FIRST_OFDM_RATE; | 135 | idx += IWL_FIRST_OFDM_RATE; |
@@ -162,10 +161,10 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search); | |||
162 | 161 | ||
163 | #ifdef CONFIG_MAC80211_DEBUGFS | 162 | #ifdef CONFIG_MAC80211_DEBUGFS |
164 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, | 163 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, |
165 | u32 *rate_n_flags, int index); | 164 | u32 *rate_n_flags); |
166 | #else | 165 | #else |
167 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, | 166 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, |
168 | u32 *rate_n_flags, int index) | 167 | u32 *rate_n_flags) |
169 | {} | 168 | {} |
170 | #endif | 169 | #endif |
171 | 170 | ||
@@ -212,20 +211,6 @@ static s32 expected_tpt_mimo2_40MHz[4][IWL_RATE_COUNT] = { | |||
212 | {0, 0, 0, 0, 186, 0, 329, 439, 527, 667, 764, 803, 838}, /* AGG+SGI */ | 211 | {0, 0, 0, 0, 186, 0, 329, 439, 527, 667, 764, 803, 838}, /* AGG+SGI */ |
213 | }; | 212 | }; |
214 | 213 | ||
215 | static s32 expected_tpt_mimo3_20MHz[4][IWL_RATE_COUNT] = { | ||
216 | {0, 0, 0, 0, 99, 0, 153, 186, 208, 239, 256, 263, 268}, /* Norm */ | ||
217 | {0, 0, 0, 0, 106, 0, 162, 194, 215, 246, 262, 268, 273}, /* SGI */ | ||
218 | {0, 0, 0, 0, 134, 0, 249, 346, 431, 574, 685, 732, 775}, /* AGG */ | ||
219 | {0, 0, 0, 0, 148, 0, 272, 376, 465, 614, 727, 775, 818}, /* AGG+SGI */ | ||
220 | }; | ||
221 | |||
222 | static s32 expected_tpt_mimo3_40MHz[4][IWL_RATE_COUNT] = { | ||
223 | {0, 0, 0, 0, 152, 0, 211, 239, 255, 279, 290, 294, 297}, /* Norm */ | ||
224 | {0, 0, 0, 0, 160, 0, 219, 245, 261, 284, 294, 297, 300}, /* SGI */ | ||
225 | {0, 0, 0, 0, 254, 0, 443, 584, 695, 868, 984, 1030, 1070}, /* AGG */ | ||
226 | {0, 0, 0, 0, 277, 0, 478, 624, 737, 911, 1026, 1070, 1109}, /* AGG+SGI */ | ||
227 | }; | ||
228 | |||
229 | /* mbps, mcs */ | 214 | /* mbps, mcs */ |
230 | static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { | 215 | static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { |
231 | { "1", "BPSK DSSS"}, | 216 | { "1", "BPSK DSSS"}, |
@@ -260,82 +245,6 @@ static inline u8 rs_is_valid_ant(u8 valid_antenna, u8 ant_type) | |||
260 | return (ant_type & valid_antenna) == ant_type; | 245 | return (ant_type & valid_antenna) == ant_type; |
261 | } | 246 | } |
262 | 247 | ||
263 | /* | ||
264 | * removes the old data from the statistics. All data that is older than | ||
265 | * TID_MAX_TIME_DIFF, will be deleted. | ||
266 | */ | ||
267 | static void rs_tl_rm_old_stats(struct iwl_traffic_load *tl, u32 curr_time) | ||
268 | { | ||
269 | /* The oldest age we want to keep */ | ||
270 | u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; | ||
271 | |||
272 | while (tl->queue_count && | ||
273 | (tl->time_stamp < oldest_time)) { | ||
274 | tl->total -= tl->packet_count[tl->head]; | ||
275 | tl->packet_count[tl->head] = 0; | ||
276 | tl->time_stamp += TID_QUEUE_CELL_SPACING; | ||
277 | tl->queue_count--; | ||
278 | tl->head++; | ||
279 | if (tl->head >= TID_QUEUE_MAX_SIZE) | ||
280 | tl->head = 0; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | /* | ||
285 | * increment traffic load value for tid and also remove | ||
286 | * any old values if passed the certain time period | ||
287 | */ | ||
288 | static u8 rs_tl_add_packet(struct iwl_lq_sta *lq_data, | ||
289 | struct ieee80211_hdr *hdr) | ||
290 | { | ||
291 | u32 curr_time = jiffies_to_msecs(jiffies); | ||
292 | u32 time_diff; | ||
293 | s32 index; | ||
294 | struct iwl_traffic_load *tl = NULL; | ||
295 | u8 tid; | ||
296 | |||
297 | if (ieee80211_is_data_qos(hdr->frame_control)) { | ||
298 | u8 *qc = ieee80211_get_qos_ctl(hdr); | ||
299 | tid = qc[0] & 0xf; | ||
300 | } else { | ||
301 | return IWL_MAX_TID_COUNT; | ||
302 | } | ||
303 | |||
304 | if (unlikely(tid >= IWL_MAX_TID_COUNT)) | ||
305 | return IWL_MAX_TID_COUNT; | ||
306 | |||
307 | tl = &lq_data->load[tid]; | ||
308 | |||
309 | curr_time -= curr_time % TID_ROUND_VALUE; | ||
310 | |||
311 | /* Happens only for the first packet. Initialize the data */ | ||
312 | if (!(tl->queue_count)) { | ||
313 | tl->total = 1; | ||
314 | tl->time_stamp = curr_time; | ||
315 | tl->queue_count = 1; | ||
316 | tl->head = 0; | ||
317 | tl->packet_count[0] = 1; | ||
318 | return IWL_MAX_TID_COUNT; | ||
319 | } | ||
320 | |||
321 | time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); | ||
322 | index = time_diff / TID_QUEUE_CELL_SPACING; | ||
323 | |||
324 | /* The history is too long: remove data that is older than */ | ||
325 | /* TID_MAX_TIME_DIFF */ | ||
326 | if (index >= TID_QUEUE_MAX_SIZE) | ||
327 | rs_tl_rm_old_stats(tl, curr_time); | ||
328 | |||
329 | index = (tl->head + index) % TID_QUEUE_MAX_SIZE; | ||
330 | tl->packet_count[index] = tl->packet_count[index] + 1; | ||
331 | tl->total = tl->total + 1; | ||
332 | |||
333 | if ((index + 1) > tl->queue_count) | ||
334 | tl->queue_count = index + 1; | ||
335 | |||
336 | return tid; | ||
337 | } | ||
338 | |||
339 | #ifdef CONFIG_MAC80211_DEBUGFS | 248 | #ifdef CONFIG_MAC80211_DEBUGFS |
340 | /** | 249 | /** |
341 | * Program the device to use fixed rate for frame transmit | 250 | * Program the device to use fixed rate for frame transmit |
@@ -349,7 +258,6 @@ static void rs_program_fix_rate(struct iwl_mvm *mvm, | |||
349 | lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ | 258 | lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ |
350 | lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 259 | lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
351 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 260 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
352 | lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | ||
353 | 261 | ||
354 | IWL_DEBUG_RATE(mvm, "sta_id %d rate 0x%X\n", | 262 | IWL_DEBUG_RATE(mvm, "sta_id %d rate 0x%X\n", |
355 | lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); | 263 | lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); |
@@ -361,45 +269,11 @@ static void rs_program_fix_rate(struct iwl_mvm *mvm, | |||
361 | } | 269 | } |
362 | #endif | 270 | #endif |
363 | 271 | ||
364 | /* | ||
365 | get the traffic load value for tid | ||
366 | */ | ||
367 | static u32 rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) | ||
368 | { | ||
369 | u32 curr_time = jiffies_to_msecs(jiffies); | ||
370 | u32 time_diff; | ||
371 | s32 index; | ||
372 | struct iwl_traffic_load *tl = NULL; | ||
373 | |||
374 | if (tid >= IWL_MAX_TID_COUNT) | ||
375 | return 0; | ||
376 | |||
377 | tl = &(lq_data->load[tid]); | ||
378 | |||
379 | curr_time -= curr_time % TID_ROUND_VALUE; | ||
380 | |||
381 | if (!(tl->queue_count)) | ||
382 | return 0; | ||
383 | |||
384 | time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); | ||
385 | index = time_diff / TID_QUEUE_CELL_SPACING; | ||
386 | |||
387 | /* The history is too long: remove data that is older than */ | ||
388 | /* TID_MAX_TIME_DIFF */ | ||
389 | if (index >= TID_QUEUE_MAX_SIZE) | ||
390 | rs_tl_rm_old_stats(tl, curr_time); | ||
391 | |||
392 | return tl->total; | ||
393 | } | ||
394 | |||
395 | static int rs_tl_turn_on_agg_for_tid(struct iwl_mvm *mvm, | 272 | static int rs_tl_turn_on_agg_for_tid(struct iwl_mvm *mvm, |
396 | struct iwl_lq_sta *lq_data, u8 tid, | 273 | struct iwl_lq_sta *lq_data, u8 tid, |
397 | struct ieee80211_sta *sta) | 274 | struct ieee80211_sta *sta) |
398 | { | 275 | { |
399 | int ret = -EAGAIN; | 276 | int ret = -EAGAIN; |
400 | u32 load; | ||
401 | |||
402 | load = rs_tl_get_load(lq_data, tid); | ||
403 | 277 | ||
404 | /* | 278 | /* |
405 | * Don't create TX aggregation sessions when in high | 279 | * Don't create TX aggregation sessions when in high |
@@ -563,7 +437,7 @@ static u32 rate_n_flags_from_tbl(struct iwl_mvm *mvm, | |||
563 | else if (is_mimo2(tbl->lq_type)) | 437 | else if (is_mimo2(tbl->lq_type)) |
564 | rate_n_flags |= iwl_rates[index].plcp_mimo2; | 438 | rate_n_flags |= iwl_rates[index].plcp_mimo2; |
565 | else | 439 | else |
566 | rate_n_flags |= iwl_rates[index].plcp_mimo3; | 440 | WARN_ON_ONCE(1); |
567 | } else { | 441 | } else { |
568 | IWL_ERR(mvm, "Invalid tbl->lq_type %d\n", tbl->lq_type); | 442 | IWL_ERR(mvm, "Invalid tbl->lq_type %d\n", tbl->lq_type); |
569 | } | 443 | } |
@@ -601,7 +475,7 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | |||
601 | u8 num_of_ant = get_num_of_ant_from_rate(rate_n_flags); | 475 | u8 num_of_ant = get_num_of_ant_from_rate(rate_n_flags); |
602 | u8 mcs; | 476 | u8 mcs; |
603 | 477 | ||
604 | memset(tbl, 0, sizeof(struct iwl_scale_tbl_info)); | 478 | memset(tbl, 0, offsetof(struct iwl_scale_tbl_info, win)); |
605 | *rate_idx = iwl_hwrate_to_plcp_idx(rate_n_flags); | 479 | *rate_idx = iwl_hwrate_to_plcp_idx(rate_n_flags); |
606 | 480 | ||
607 | if (*rate_idx == IWL_RATE_INVALID) { | 481 | if (*rate_idx == IWL_RATE_INVALID) { |
@@ -640,12 +514,8 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | |||
640 | } else if (mcs <= IWL_RATE_MIMO2_60M_PLCP) { | 514 | } else if (mcs <= IWL_RATE_MIMO2_60M_PLCP) { |
641 | if (num_of_ant == 2) | 515 | if (num_of_ant == 2) |
642 | tbl->lq_type = LQ_MIMO2; | 516 | tbl->lq_type = LQ_MIMO2; |
643 | /* MIMO3 */ | ||
644 | } else { | 517 | } else { |
645 | if (num_of_ant == 3) { | 518 | WARN_ON_ONCE(num_of_ant == 3); |
646 | tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH; | ||
647 | tbl->lq_type = LQ_MIMO3; | ||
648 | } | ||
649 | } | 519 | } |
650 | } | 520 | } |
651 | return 0; | 521 | return 0; |
@@ -711,10 +581,10 @@ static u16 rs_get_supported_rates(struct iwl_lq_sta *lq_sta, | |||
711 | } else { | 581 | } else { |
712 | if (is_siso(rate_type)) | 582 | if (is_siso(rate_type)) |
713 | return lq_sta->active_siso_rate; | 583 | return lq_sta->active_siso_rate; |
714 | else if (is_mimo2(rate_type)) | 584 | else { |
585 | WARN_ON_ONCE(!is_mimo2(rate_type)); | ||
715 | return lq_sta->active_mimo2_rate; | 586 | return lq_sta->active_mimo2_rate; |
716 | else | 587 | } |
717 | return lq_sta->active_mimo3_rate; | ||
718 | } | 588 | } |
719 | } | 589 | } |
720 | 590 | ||
@@ -1089,7 +959,7 @@ static void rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, | |||
1089 | } | 959 | } |
1090 | 960 | ||
1091 | /* Choose among many HT tables depending on number of streams | 961 | /* Choose among many HT tables depending on number of streams |
1092 | * (SISO/MIMO2/MIMO3), channel width (20/40), SGI, and aggregation | 962 | * (SISO/MIMO2), channel width (20/40), SGI, and aggregation |
1093 | * status */ | 963 | * status */ |
1094 | if (is_siso(tbl->lq_type) && !tbl->is_ht40) | 964 | if (is_siso(tbl->lq_type) && !tbl->is_ht40) |
1095 | ht_tbl_pointer = expected_tpt_siso20MHz; | 965 | ht_tbl_pointer = expected_tpt_siso20MHz; |
@@ -1097,12 +967,10 @@ static void rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, | |||
1097 | ht_tbl_pointer = expected_tpt_siso40MHz; | 967 | ht_tbl_pointer = expected_tpt_siso40MHz; |
1098 | else if (is_mimo2(tbl->lq_type) && !tbl->is_ht40) | 968 | else if (is_mimo2(tbl->lq_type) && !tbl->is_ht40) |
1099 | ht_tbl_pointer = expected_tpt_mimo2_20MHz; | 969 | ht_tbl_pointer = expected_tpt_mimo2_20MHz; |
1100 | else if (is_mimo2(tbl->lq_type)) | 970 | else { |
971 | WARN_ON_ONCE(!is_mimo2(tbl->lq_type)); | ||
1101 | ht_tbl_pointer = expected_tpt_mimo2_40MHz; | 972 | ht_tbl_pointer = expected_tpt_mimo2_40MHz; |
1102 | else if (is_mimo3(tbl->lq_type) && !tbl->is_ht40) | 973 | } |
1103 | ht_tbl_pointer = expected_tpt_mimo3_20MHz; | ||
1104 | else /* if (is_mimo3(tbl->lq_type)) <-- must be true */ | ||
1105 | ht_tbl_pointer = expected_tpt_mimo3_40MHz; | ||
1106 | 974 | ||
1107 | if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ | 975 | if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ |
1108 | tbl->expected_tpt = ht_tbl_pointer[0]; | 976 | tbl->expected_tpt = ht_tbl_pointer[0]; |
@@ -1274,58 +1142,6 @@ static int rs_switch_to_mimo2(struct iwl_mvm *mvm, | |||
1274 | } | 1142 | } |
1275 | 1143 | ||
1276 | /* | 1144 | /* |
1277 | * Set up search table for MIMO3 | ||
1278 | */ | ||
1279 | static int rs_switch_to_mimo3(struct iwl_mvm *mvm, | ||
1280 | struct iwl_lq_sta *lq_sta, | ||
1281 | struct ieee80211_sta *sta, | ||
1282 | struct iwl_scale_tbl_info *tbl, int index) | ||
1283 | { | ||
1284 | u16 rate_mask; | ||
1285 | s32 rate; | ||
1286 | s8 is_green = lq_sta->is_green; | ||
1287 | |||
1288 | if (!sta->ht_cap.ht_supported) | ||
1289 | return -1; | ||
1290 | |||
1291 | if (sta->smps_mode == IEEE80211_SMPS_STATIC) | ||
1292 | return -1; | ||
1293 | |||
1294 | /* Need both Tx chains/antennas to support MIMO */ | ||
1295 | if (num_of_ant(iwl_fw_valid_tx_ant(mvm->fw)) < 3) | ||
1296 | return -1; | ||
1297 | |||
1298 | IWL_DEBUG_RATE(mvm, "LQ: try to switch to MIMO3\n"); | ||
1299 | |||
1300 | tbl->lq_type = LQ_MIMO3; | ||
1301 | tbl->action = 0; | ||
1302 | tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH; | ||
1303 | rate_mask = lq_sta->active_mimo3_rate; | ||
1304 | |||
1305 | if (iwl_is_ht40_tx_allowed(sta)) | ||
1306 | tbl->is_ht40 = 1; | ||
1307 | else | ||
1308 | tbl->is_ht40 = 0; | ||
1309 | |||
1310 | rs_set_expected_tpt_table(lq_sta, tbl); | ||
1311 | |||
1312 | rate = rs_get_best_rate(mvm, lq_sta, tbl, rate_mask, index); | ||
1313 | |||
1314 | IWL_DEBUG_RATE(mvm, "LQ: MIMO3 best rate %d mask %X\n", | ||
1315 | rate, rate_mask); | ||
1316 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { | ||
1317 | IWL_DEBUG_RATE(mvm, "Can't switch with index %d rate mask %x\n", | ||
1318 | rate, rate_mask); | ||
1319 | return -1; | ||
1320 | } | ||
1321 | tbl->current_rate = rate_n_flags_from_tbl(mvm, tbl, rate, is_green); | ||
1322 | |||
1323 | IWL_DEBUG_RATE(mvm, "LQ: Switch to new mcs %X index is green %X\n", | ||
1324 | tbl->current_rate, is_green); | ||
1325 | return 0; | ||
1326 | } | ||
1327 | |||
1328 | /* | ||
1329 | * Set up search table for SISO | 1145 | * Set up search table for SISO |
1330 | */ | 1146 | */ |
1331 | static int rs_switch_to_siso(struct iwl_mvm *mvm, | 1147 | static int rs_switch_to_siso(struct iwl_mvm *mvm, |
@@ -1434,21 +1250,14 @@ static int rs_move_legacy_other(struct iwl_mvm *mvm, | |||
1434 | } | 1250 | } |
1435 | 1251 | ||
1436 | break; | 1252 | break; |
1437 | case IWL_LEGACY_SWITCH_MIMO2_AB: | 1253 | case IWL_LEGACY_SWITCH_MIMO2: |
1438 | case IWL_LEGACY_SWITCH_MIMO2_AC: | ||
1439 | case IWL_LEGACY_SWITCH_MIMO2_BC: | ||
1440 | IWL_DEBUG_RATE(mvm, "LQ: Legacy switch to MIMO2\n"); | 1254 | IWL_DEBUG_RATE(mvm, "LQ: Legacy switch to MIMO2\n"); |
1441 | 1255 | ||
1442 | /* Set up search table to try MIMO */ | 1256 | /* Set up search table to try MIMO */ |
1443 | memcpy(search_tbl, tbl, sz); | 1257 | memcpy(search_tbl, tbl, sz); |
1444 | search_tbl->is_SGI = 0; | 1258 | search_tbl->is_SGI = 0; |
1445 | 1259 | ||
1446 | if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AB) | 1260 | search_tbl->ant_type = ANT_AB; |
1447 | search_tbl->ant_type = ANT_AB; | ||
1448 | else if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AC) | ||
1449 | search_tbl->ant_type = ANT_AC; | ||
1450 | else | ||
1451 | search_tbl->ant_type = ANT_BC; | ||
1452 | 1261 | ||
1453 | if (!rs_is_valid_ant(valid_tx_ant, | 1262 | if (!rs_is_valid_ant(valid_tx_ant, |
1454 | search_tbl->ant_type)) | 1263 | search_tbl->ant_type)) |
@@ -1461,30 +1270,11 @@ static int rs_move_legacy_other(struct iwl_mvm *mvm, | |||
1461 | goto out; | 1270 | goto out; |
1462 | } | 1271 | } |
1463 | break; | 1272 | break; |
1464 | 1273 | default: | |
1465 | case IWL_LEGACY_SWITCH_MIMO3_ABC: | 1274 | WARN_ON_ONCE(1); |
1466 | IWL_DEBUG_RATE(mvm, "LQ: Legacy switch to MIMO3\n"); | ||
1467 | |||
1468 | /* Set up search table to try MIMO3 */ | ||
1469 | memcpy(search_tbl, tbl, sz); | ||
1470 | search_tbl->is_SGI = 0; | ||
1471 | |||
1472 | search_tbl->ant_type = ANT_ABC; | ||
1473 | |||
1474 | if (!rs_is_valid_ant(valid_tx_ant, | ||
1475 | search_tbl->ant_type)) | ||
1476 | break; | ||
1477 | |||
1478 | ret = rs_switch_to_mimo3(mvm, lq_sta, sta, | ||
1479 | search_tbl, index); | ||
1480 | if (!ret) { | ||
1481 | lq_sta->action_counter = 0; | ||
1482 | goto out; | ||
1483 | } | ||
1484 | break; | ||
1485 | } | 1275 | } |
1486 | tbl->action++; | 1276 | tbl->action++; |
1487 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) | 1277 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO2) |
1488 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; | 1278 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; |
1489 | 1279 | ||
1490 | if (tbl->action == start_action) | 1280 | if (tbl->action == start_action) |
@@ -1496,7 +1286,7 @@ static int rs_move_legacy_other(struct iwl_mvm *mvm, | |||
1496 | out: | 1286 | out: |
1497 | lq_sta->search_better_tbl = 1; | 1287 | lq_sta->search_better_tbl = 1; |
1498 | tbl->action++; | 1288 | tbl->action++; |
1499 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) | 1289 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO2) |
1500 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; | 1290 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; |
1501 | if (update_search_tbl_counter) | 1291 | if (update_search_tbl_counter) |
1502 | search_tbl->action = tbl->action; | 1292 | search_tbl->action = tbl->action; |
@@ -1531,7 +1321,7 @@ static int rs_move_siso_to_other(struct iwl_mvm *mvm, | |||
1531 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | 1321 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
1532 | /* avoid antenna B unless MIMO */ | 1322 | /* avoid antenna B unless MIMO */ |
1533 | if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) | 1323 | if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) |
1534 | tbl->action = IWL_SISO_SWITCH_MIMO2_AB; | 1324 | tbl->action = IWL_SISO_SWITCH_MIMO2; |
1535 | break; | 1325 | break; |
1536 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: | 1326 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
1537 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: | 1327 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
@@ -1573,19 +1363,12 @@ static int rs_move_siso_to_other(struct iwl_mvm *mvm, | |||
1573 | goto out; | 1363 | goto out; |
1574 | } | 1364 | } |
1575 | break; | 1365 | break; |
1576 | case IWL_SISO_SWITCH_MIMO2_AB: | 1366 | case IWL_SISO_SWITCH_MIMO2: |
1577 | case IWL_SISO_SWITCH_MIMO2_AC: | ||
1578 | case IWL_SISO_SWITCH_MIMO2_BC: | ||
1579 | IWL_DEBUG_RATE(mvm, "LQ: SISO switch to MIMO2\n"); | 1367 | IWL_DEBUG_RATE(mvm, "LQ: SISO switch to MIMO2\n"); |
1580 | memcpy(search_tbl, tbl, sz); | 1368 | memcpy(search_tbl, tbl, sz); |
1581 | search_tbl->is_SGI = 0; | 1369 | search_tbl->is_SGI = 0; |
1582 | 1370 | ||
1583 | if (tbl->action == IWL_SISO_SWITCH_MIMO2_AB) | 1371 | search_tbl->ant_type = ANT_AB; |
1584 | search_tbl->ant_type = ANT_AB; | ||
1585 | else if (tbl->action == IWL_SISO_SWITCH_MIMO2_AC) | ||
1586 | search_tbl->ant_type = ANT_AC; | ||
1587 | else | ||
1588 | search_tbl->ant_type = ANT_BC; | ||
1589 | 1372 | ||
1590 | if (!rs_is_valid_ant(valid_tx_ant, | 1373 | if (!rs_is_valid_ant(valid_tx_ant, |
1591 | search_tbl->ant_type)) | 1374 | search_tbl->ant_type)) |
@@ -1626,24 +1409,11 @@ static int rs_move_siso_to_other(struct iwl_mvm *mvm, | |||
1626 | index, is_green); | 1409 | index, is_green); |
1627 | update_search_tbl_counter = 1; | 1410 | update_search_tbl_counter = 1; |
1628 | goto out; | 1411 | goto out; |
1629 | case IWL_SISO_SWITCH_MIMO3_ABC: | 1412 | default: |
1630 | IWL_DEBUG_RATE(mvm, "LQ: SISO switch to MIMO3\n"); | 1413 | WARN_ON_ONCE(1); |
1631 | memcpy(search_tbl, tbl, sz); | ||
1632 | search_tbl->is_SGI = 0; | ||
1633 | search_tbl->ant_type = ANT_ABC; | ||
1634 | |||
1635 | if (!rs_is_valid_ant(valid_tx_ant, | ||
1636 | search_tbl->ant_type)) | ||
1637 | break; | ||
1638 | |||
1639 | ret = rs_switch_to_mimo3(mvm, lq_sta, sta, | ||
1640 | search_tbl, index); | ||
1641 | if (!ret) | ||
1642 | goto out; | ||
1643 | break; | ||
1644 | } | 1414 | } |
1645 | tbl->action++; | 1415 | tbl->action++; |
1646 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) | 1416 | if (tbl->action > IWL_SISO_SWITCH_GI) |
1647 | tbl->action = IWL_SISO_SWITCH_ANTENNA1; | 1417 | tbl->action = IWL_SISO_SWITCH_ANTENNA1; |
1648 | 1418 | ||
1649 | if (tbl->action == start_action) | 1419 | if (tbl->action == start_action) |
@@ -1655,7 +1425,7 @@ static int rs_move_siso_to_other(struct iwl_mvm *mvm, | |||
1655 | out: | 1425 | out: |
1656 | lq_sta->search_better_tbl = 1; | 1426 | lq_sta->search_better_tbl = 1; |
1657 | tbl->action++; | 1427 | tbl->action++; |
1658 | if (tbl->action > IWL_SISO_SWITCH_MIMO3_ABC) | 1428 | if (tbl->action > IWL_SISO_SWITCH_GI) |
1659 | tbl->action = IWL_SISO_SWITCH_ANTENNA1; | 1429 | tbl->action = IWL_SISO_SWITCH_ANTENNA1; |
1660 | if (update_search_tbl_counter) | 1430 | if (update_search_tbl_counter) |
1661 | search_tbl->action = tbl->action; | 1431 | search_tbl->action = tbl->action; |
@@ -1696,8 +1466,7 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1696 | break; | 1466 | break; |
1697 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | 1467 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
1698 | /* avoid antenna B unless MIMO */ | 1468 | /* avoid antenna B unless MIMO */ |
1699 | if (tbl->action == IWL_MIMO2_SWITCH_SISO_B || | 1469 | if (tbl->action == IWL_MIMO2_SWITCH_SISO_B) |
1700 | tbl->action == IWL_MIMO2_SWITCH_SISO_C) | ||
1701 | tbl->action = IWL_MIMO2_SWITCH_SISO_A; | 1470 | tbl->action = IWL_MIMO2_SWITCH_SISO_A; |
1702 | break; | 1471 | break; |
1703 | default: | 1472 | default: |
@@ -1730,7 +1499,6 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1730 | break; | 1499 | break; |
1731 | case IWL_MIMO2_SWITCH_SISO_A: | 1500 | case IWL_MIMO2_SWITCH_SISO_A: |
1732 | case IWL_MIMO2_SWITCH_SISO_B: | 1501 | case IWL_MIMO2_SWITCH_SISO_B: |
1733 | case IWL_MIMO2_SWITCH_SISO_C: | ||
1734 | IWL_DEBUG_RATE(mvm, "LQ: MIMO2 switch to SISO\n"); | 1502 | IWL_DEBUG_RATE(mvm, "LQ: MIMO2 switch to SISO\n"); |
1735 | 1503 | ||
1736 | /* Set up new search table for SISO */ | 1504 | /* Set up new search table for SISO */ |
@@ -1738,10 +1506,8 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1738 | 1506 | ||
1739 | if (tbl->action == IWL_MIMO2_SWITCH_SISO_A) | 1507 | if (tbl->action == IWL_MIMO2_SWITCH_SISO_A) |
1740 | search_tbl->ant_type = ANT_A; | 1508 | search_tbl->ant_type = ANT_A; |
1741 | else if (tbl->action == IWL_MIMO2_SWITCH_SISO_B) | 1509 | else /* tbl->action == IWL_MIMO2_SWITCH_SISO_B */ |
1742 | search_tbl->ant_type = ANT_B; | 1510 | search_tbl->ant_type = ANT_B; |
1743 | else | ||
1744 | search_tbl->ant_type = ANT_C; | ||
1745 | 1511 | ||
1746 | if (!rs_is_valid_ant(valid_tx_ant, | 1512 | if (!rs_is_valid_ant(valid_tx_ant, |
1747 | search_tbl->ant_type)) | 1513 | search_tbl->ant_type)) |
@@ -1784,26 +1550,11 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1784 | index, is_green); | 1550 | index, is_green); |
1785 | update_search_tbl_counter = 1; | 1551 | update_search_tbl_counter = 1; |
1786 | goto out; | 1552 | goto out; |
1787 | 1553 | default: | |
1788 | case IWL_MIMO2_SWITCH_MIMO3_ABC: | 1554 | WARN_ON_ONCE(1); |
1789 | IWL_DEBUG_RATE(mvm, "LQ: MIMO2 switch to MIMO3\n"); | ||
1790 | memcpy(search_tbl, tbl, sz); | ||
1791 | search_tbl->is_SGI = 0; | ||
1792 | search_tbl->ant_type = ANT_ABC; | ||
1793 | |||
1794 | if (!rs_is_valid_ant(valid_tx_ant, | ||
1795 | search_tbl->ant_type)) | ||
1796 | break; | ||
1797 | |||
1798 | ret = rs_switch_to_mimo3(mvm, lq_sta, sta, | ||
1799 | search_tbl, index); | ||
1800 | if (!ret) | ||
1801 | goto out; | ||
1802 | |||
1803 | break; | ||
1804 | } | 1555 | } |
1805 | tbl->action++; | 1556 | tbl->action++; |
1806 | if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC) | 1557 | if (tbl->action > IWL_MIMO2_SWITCH_GI) |
1807 | tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; | 1558 | tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; |
1808 | 1559 | ||
1809 | if (tbl->action == start_action) | 1560 | if (tbl->action == start_action) |
@@ -1814,7 +1565,7 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1814 | out: | 1565 | out: |
1815 | lq_sta->search_better_tbl = 1; | 1566 | lq_sta->search_better_tbl = 1; |
1816 | tbl->action++; | 1567 | tbl->action++; |
1817 | if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC) | 1568 | if (tbl->action > IWL_MIMO2_SWITCH_GI) |
1818 | tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; | 1569 | tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; |
1819 | if (update_search_tbl_counter) | 1570 | if (update_search_tbl_counter) |
1820 | search_tbl->action = tbl->action; | 1571 | search_tbl->action = tbl->action; |
@@ -1823,171 +1574,6 @@ static int rs_move_mimo2_to_other(struct iwl_mvm *mvm, | |||
1823 | } | 1574 | } |
1824 | 1575 | ||
1825 | /* | 1576 | /* |
1826 | * Try to switch to new modulation mode from MIMO3 | ||
1827 | */ | ||
1828 | static int rs_move_mimo3_to_other(struct iwl_mvm *mvm, | ||
1829 | struct iwl_lq_sta *lq_sta, | ||
1830 | struct ieee80211_sta *sta, int index) | ||
1831 | { | ||
1832 | s8 is_green = lq_sta->is_green; | ||
1833 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | ||
1834 | struct iwl_scale_tbl_info *search_tbl = | ||
1835 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); | ||
1836 | struct iwl_rate_scale_data *window = &(tbl->win[index]); | ||
1837 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | ||
1838 | u32 sz = (sizeof(struct iwl_scale_tbl_info) - | ||
1839 | (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); | ||
1840 | u8 start_action; | ||
1841 | u8 valid_tx_ant = iwl_fw_valid_tx_ant(mvm->fw); | ||
1842 | u8 tx_chains_num = num_of_ant(valid_tx_ant); | ||
1843 | int ret; | ||
1844 | u8 update_search_tbl_counter = 0; | ||
1845 | |||
1846 | switch (BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD)) { | ||
1847 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: | ||
1848 | /* nothing */ | ||
1849 | break; | ||
1850 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: | ||
1851 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: | ||
1852 | /* avoid antenna B and MIMO */ | ||
1853 | if (tbl->action != IWL_MIMO3_SWITCH_SISO_A) | ||
1854 | tbl->action = IWL_MIMO3_SWITCH_SISO_A; | ||
1855 | break; | ||
1856 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | ||
1857 | /* avoid antenna B unless MIMO */ | ||
1858 | if (tbl->action == IWL_MIMO3_SWITCH_SISO_B || | ||
1859 | tbl->action == IWL_MIMO3_SWITCH_SISO_C) | ||
1860 | tbl->action = IWL_MIMO3_SWITCH_SISO_A; | ||
1861 | break; | ||
1862 | default: | ||
1863 | IWL_ERR(mvm, "Invalid BT load %d", | ||
1864 | BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD)); | ||
1865 | break; | ||
1866 | } | ||
1867 | |||
1868 | start_action = tbl->action; | ||
1869 | while (1) { | ||
1870 | lq_sta->action_counter++; | ||
1871 | switch (tbl->action) { | ||
1872 | case IWL_MIMO3_SWITCH_ANTENNA1: | ||
1873 | case IWL_MIMO3_SWITCH_ANTENNA2: | ||
1874 | IWL_DEBUG_RATE(mvm, "LQ: MIMO3 toggle Antennas\n"); | ||
1875 | |||
1876 | if (tx_chains_num <= 3) | ||
1877 | break; | ||
1878 | |||
1879 | if (window->success_ratio >= IWL_RS_GOOD_RATIO) | ||
1880 | break; | ||
1881 | |||
1882 | memcpy(search_tbl, tbl, sz); | ||
1883 | if (rs_toggle_antenna(valid_tx_ant, | ||
1884 | &search_tbl->current_rate, | ||
1885 | search_tbl)) | ||
1886 | goto out; | ||
1887 | break; | ||
1888 | case IWL_MIMO3_SWITCH_SISO_A: | ||
1889 | case IWL_MIMO3_SWITCH_SISO_B: | ||
1890 | case IWL_MIMO3_SWITCH_SISO_C: | ||
1891 | IWL_DEBUG_RATE(mvm, "LQ: MIMO3 switch to SISO\n"); | ||
1892 | |||
1893 | /* Set up new search table for SISO */ | ||
1894 | memcpy(search_tbl, tbl, sz); | ||
1895 | |||
1896 | if (tbl->action == IWL_MIMO3_SWITCH_SISO_A) | ||
1897 | search_tbl->ant_type = ANT_A; | ||
1898 | else if (tbl->action == IWL_MIMO3_SWITCH_SISO_B) | ||
1899 | search_tbl->ant_type = ANT_B; | ||
1900 | else | ||
1901 | search_tbl->ant_type = ANT_C; | ||
1902 | |||
1903 | if (!rs_is_valid_ant(valid_tx_ant, | ||
1904 | search_tbl->ant_type)) | ||
1905 | break; | ||
1906 | |||
1907 | ret = rs_switch_to_siso(mvm, lq_sta, sta, | ||
1908 | search_tbl, index); | ||
1909 | if (!ret) | ||
1910 | goto out; | ||
1911 | |||
1912 | break; | ||
1913 | |||
1914 | case IWL_MIMO3_SWITCH_MIMO2_AB: | ||
1915 | case IWL_MIMO3_SWITCH_MIMO2_AC: | ||
1916 | case IWL_MIMO3_SWITCH_MIMO2_BC: | ||
1917 | IWL_DEBUG_RATE(mvm, "LQ: MIMO3 switch to MIMO2\n"); | ||
1918 | |||
1919 | memcpy(search_tbl, tbl, sz); | ||
1920 | search_tbl->is_SGI = 0; | ||
1921 | if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AB) | ||
1922 | search_tbl->ant_type = ANT_AB; | ||
1923 | else if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AC) | ||
1924 | search_tbl->ant_type = ANT_AC; | ||
1925 | else | ||
1926 | search_tbl->ant_type = ANT_BC; | ||
1927 | |||
1928 | if (!rs_is_valid_ant(valid_tx_ant, | ||
1929 | search_tbl->ant_type)) | ||
1930 | break; | ||
1931 | |||
1932 | ret = rs_switch_to_mimo2(mvm, lq_sta, sta, | ||
1933 | search_tbl, index); | ||
1934 | if (!ret) | ||
1935 | goto out; | ||
1936 | |||
1937 | break; | ||
1938 | |||
1939 | case IWL_MIMO3_SWITCH_GI: | ||
1940 | if (!tbl->is_ht40 && !(ht_cap->cap & | ||
1941 | IEEE80211_HT_CAP_SGI_20)) | ||
1942 | break; | ||
1943 | if (tbl->is_ht40 && !(ht_cap->cap & | ||
1944 | IEEE80211_HT_CAP_SGI_40)) | ||
1945 | break; | ||
1946 | |||
1947 | IWL_DEBUG_RATE(mvm, "LQ: MIMO3 toggle SGI/NGI\n"); | ||
1948 | |||
1949 | /* Set up new search table for MIMO */ | ||
1950 | memcpy(search_tbl, tbl, sz); | ||
1951 | search_tbl->is_SGI = !tbl->is_SGI; | ||
1952 | rs_set_expected_tpt_table(lq_sta, search_tbl); | ||
1953 | /* | ||
1954 | * If active table already uses the fastest possible | ||
1955 | * modulation (dual stream with short guard interval), | ||
1956 | * and it's working well, there's no need to look | ||
1957 | * for a better type of modulation! | ||
1958 | */ | ||
1959 | if (tbl->is_SGI) { | ||
1960 | s32 tpt = lq_sta->last_tpt / 100; | ||
1961 | if (tpt >= search_tbl->expected_tpt[index]) | ||
1962 | break; | ||
1963 | } | ||
1964 | search_tbl->current_rate = | ||
1965 | rate_n_flags_from_tbl(mvm, search_tbl, | ||
1966 | index, is_green); | ||
1967 | update_search_tbl_counter = 1; | ||
1968 | goto out; | ||
1969 | } | ||
1970 | tbl->action++; | ||
1971 | if (tbl->action > IWL_MIMO3_SWITCH_GI) | ||
1972 | tbl->action = IWL_MIMO3_SWITCH_ANTENNA1; | ||
1973 | |||
1974 | if (tbl->action == start_action) | ||
1975 | break; | ||
1976 | } | ||
1977 | search_tbl->lq_type = LQ_NONE; | ||
1978 | return 0; | ||
1979 | out: | ||
1980 | lq_sta->search_better_tbl = 1; | ||
1981 | tbl->action++; | ||
1982 | if (tbl->action > IWL_MIMO3_SWITCH_GI) | ||
1983 | tbl->action = IWL_MIMO3_SWITCH_ANTENNA1; | ||
1984 | if (update_search_tbl_counter) | ||
1985 | search_tbl->action = tbl->action; | ||
1986 | |||
1987 | return 0; | ||
1988 | } | ||
1989 | |||
1990 | /* | ||
1991 | * Check whether we should continue using same modulation mode, or | 1577 | * Check whether we should continue using same modulation mode, or |
1992 | * begin search for a new mode, based on: | 1578 | * begin search for a new mode, based on: |
1993 | * 1) # tx successes or failures while using this mode | 1579 | * 1) # tx successes or failures while using this mode |
@@ -2086,6 +1672,22 @@ static void rs_update_rate_tbl(struct iwl_mvm *mvm, | |||
2086 | iwl_mvm_send_lq_cmd(mvm, &lq_sta->lq, CMD_ASYNC, false); | 1672 | iwl_mvm_send_lq_cmd(mvm, &lq_sta->lq, CMD_ASYNC, false); |
2087 | } | 1673 | } |
2088 | 1674 | ||
1675 | static u8 rs_get_tid(struct iwl_lq_sta *lq_data, | ||
1676 | struct ieee80211_hdr *hdr) | ||
1677 | { | ||
1678 | u8 tid = IWL_MAX_TID_COUNT; | ||
1679 | |||
1680 | if (ieee80211_is_data_qos(hdr->frame_control)) { | ||
1681 | u8 *qc = ieee80211_get_qos_ctl(hdr); | ||
1682 | tid = qc[0] & 0xf; | ||
1683 | } | ||
1684 | |||
1685 | if (unlikely(tid > IWL_MAX_TID_COUNT)) | ||
1686 | tid = IWL_MAX_TID_COUNT; | ||
1687 | |||
1688 | return tid; | ||
1689 | } | ||
1690 | |||
2089 | /* | 1691 | /* |
2090 | * Do rate scaling and search for new modulation mode. | 1692 | * Do rate scaling and search for new modulation mode. |
2091 | */ | 1693 | */ |
@@ -2129,7 +1731,7 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm, | |||
2129 | 1731 | ||
2130 | lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; | 1732 | lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; |
2131 | 1733 | ||
2132 | tid = rs_tl_add_packet(lq_sta, hdr); | 1734 | tid = rs_get_tid(lq_sta, hdr); |
2133 | if ((tid != IWL_MAX_TID_COUNT) && | 1735 | if ((tid != IWL_MAX_TID_COUNT) && |
2134 | (lq_sta->tx_agg_tid_en & (1 << tid))) { | 1736 | (lq_sta->tx_agg_tid_en & (1 << tid))) { |
2135 | tid_data = &sta_priv->tid_data[tid]; | 1737 | tid_data = &sta_priv->tid_data[tid]; |
@@ -2377,8 +1979,7 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm, | |||
2377 | scale_action = 0; | 1979 | scale_action = 0; |
2378 | 1980 | ||
2379 | if ((BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD) >= | 1981 | if ((BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD) >= |
2380 | IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && | 1982 | IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && (is_mimo(tbl->lq_type))) { |
2381 | (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) { | ||
2382 | if (lq_sta->last_bt_traffic > | 1983 | if (lq_sta->last_bt_traffic > |
2383 | BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD)) { | 1984 | BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD)) { |
2384 | /* | 1985 | /* |
@@ -2395,8 +1996,7 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm, | |||
2395 | BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD); | 1996 | BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD); |
2396 | 1997 | ||
2397 | if ((BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD) >= | 1998 | if ((BT_MBOX_MSG(&mvm->last_bt_notif, 3, TRAFFIC_LOAD) >= |
2398 | IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && | 1999 | IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && is_mimo(tbl->lq_type)) { |
2399 | (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) { | ||
2400 | /* search for a new modulation */ | 2000 | /* search for a new modulation */ |
2401 | rs_stay_in_table(lq_sta, true); | 2001 | rs_stay_in_table(lq_sta, true); |
2402 | goto lq_update; | 2002 | goto lq_update; |
@@ -2456,7 +2056,7 @@ lq_update: | |||
2456 | else if (is_mimo2(tbl->lq_type)) | 2056 | else if (is_mimo2(tbl->lq_type)) |
2457 | rs_move_mimo2_to_other(mvm, lq_sta, sta, index); | 2057 | rs_move_mimo2_to_other(mvm, lq_sta, sta, index); |
2458 | else | 2058 | else |
2459 | rs_move_mimo3_to_other(mvm, lq_sta, sta, index); | 2059 | WARN_ON_ONCE(1); |
2460 | 2060 | ||
2461 | /* If new "search" mode was selected, set up in uCode table */ | 2061 | /* If new "search" mode was selected, set up in uCode table */ |
2462 | if (lq_sta->search_better_tbl) { | 2062 | if (lq_sta->search_better_tbl) { |
@@ -2621,11 +2221,10 @@ static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta, | |||
2621 | rate_idx -= IWL_FIRST_OFDM_RATE; | 2221 | rate_idx -= IWL_FIRST_OFDM_RATE; |
2622 | /* 6M and 9M shared same MCS index */ | 2222 | /* 6M and 9M shared same MCS index */ |
2623 | rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; | 2223 | rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; |
2224 | WARN_ON_ONCE(rs_extract_rate(lq_sta->last_rate_n_flags) >= | ||
2225 | IWL_RATE_MIMO3_6M_PLCP); | ||
2624 | if (rs_extract_rate(lq_sta->last_rate_n_flags) >= | 2226 | if (rs_extract_rate(lq_sta->last_rate_n_flags) >= |
2625 | IWL_RATE_MIMO3_6M_PLCP) | 2227 | IWL_RATE_MIMO2_6M_PLCP) |
2626 | rate_idx = rate_idx + (2 * MCS_INDEX_PER_STREAM); | ||
2627 | else if (rs_extract_rate(lq_sta->last_rate_n_flags) >= | ||
2628 | IWL_RATE_MIMO2_6M_PLCP) | ||
2629 | rate_idx = rate_idx + MCS_INDEX_PER_STREAM; | 2228 | rate_idx = rate_idx + MCS_INDEX_PER_STREAM; |
2630 | info->control.rates[0].flags = IEEE80211_TX_RC_MCS; | 2229 | info->control.rates[0].flags = IEEE80211_TX_RC_MCS; |
2631 | if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) | 2230 | if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) |
@@ -2688,9 +2287,6 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
2688 | 2287 | ||
2689 | lq_sta->flush_timer = 0; | 2288 | lq_sta->flush_timer = 0; |
2690 | lq_sta->supp_rates = sta->supp_rates[sband->band]; | 2289 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
2691 | for (j = 0; j < LQ_SIZE; j++) | ||
2692 | for (i = 0; i < IWL_RATE_COUNT; i++) | ||
2693 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); | ||
2694 | 2290 | ||
2695 | IWL_DEBUG_RATE(mvm, | 2291 | IWL_DEBUG_RATE(mvm, |
2696 | "LQ: *** rate scale station global init for station %d ***\n", | 2292 | "LQ: *** rate scale station global init for station %d ***\n", |
@@ -2727,16 +2323,10 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
2727 | lq_sta->active_mimo2_rate &= ~((u16)0x2); | 2323 | lq_sta->active_mimo2_rate &= ~((u16)0x2); |
2728 | lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; | 2324 | lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; |
2729 | 2325 | ||
2730 | lq_sta->active_mimo3_rate = ht_cap->mcs.rx_mask[2] << 1; | ||
2731 | lq_sta->active_mimo3_rate |= ht_cap->mcs.rx_mask[2] & 0x1; | ||
2732 | lq_sta->active_mimo3_rate &= ~((u16)0x2); | ||
2733 | lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; | ||
2734 | |||
2735 | IWL_DEBUG_RATE(mvm, | 2326 | IWL_DEBUG_RATE(mvm, |
2736 | "SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n", | 2327 | "SISO-RATE=%X MIMO2-RATE=%X\n", |
2737 | lq_sta->active_siso_rate, | 2328 | lq_sta->active_siso_rate, |
2738 | lq_sta->active_mimo2_rate, | 2329 | lq_sta->active_mimo2_rate); |
2739 | lq_sta->active_mimo3_rate); | ||
2740 | 2330 | ||
2741 | /* These values will be overridden later */ | 2331 | /* These values will be overridden later */ |
2742 | lq_sta->lq.single_stream_ant_msk = | 2332 | lq_sta->lq.single_stream_ant_msk = |
@@ -2780,7 +2370,7 @@ static void rs_fill_link_cmd(struct iwl_mvm *mvm, | |||
2780 | struct iwl_lq_cmd *lq_cmd = &lq_sta->lq; | 2370 | struct iwl_lq_cmd *lq_cmd = &lq_sta->lq; |
2781 | 2371 | ||
2782 | /* Override starting rate (index 0) if needed for debug purposes */ | 2372 | /* Override starting rate (index 0) if needed for debug purposes */ |
2783 | rs_dbgfs_set_mcs(lq_sta, &new_rate, index); | 2373 | rs_dbgfs_set_mcs(lq_sta, &new_rate); |
2784 | 2374 | ||
2785 | /* Interpret new_rate (rate_n_flags) */ | 2375 | /* Interpret new_rate (rate_n_flags) */ |
2786 | rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, | 2376 | rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, |
@@ -2827,7 +2417,7 @@ static void rs_fill_link_cmd(struct iwl_mvm *mvm, | |||
2827 | } | 2417 | } |
2828 | 2418 | ||
2829 | /* Override next rate if needed for debug purposes */ | 2419 | /* Override next rate if needed for debug purposes */ |
2830 | rs_dbgfs_set_mcs(lq_sta, &new_rate, index); | 2420 | rs_dbgfs_set_mcs(lq_sta, &new_rate); |
2831 | 2421 | ||
2832 | /* Fill next table entry */ | 2422 | /* Fill next table entry */ |
2833 | lq_cmd->rs_table[index] = | 2423 | lq_cmd->rs_table[index] = |
@@ -2869,7 +2459,7 @@ static void rs_fill_link_cmd(struct iwl_mvm *mvm, | |||
2869 | use_ht_possible = 0; | 2459 | use_ht_possible = 0; |
2870 | 2460 | ||
2871 | /* Override next rate if needed for debug purposes */ | 2461 | /* Override next rate if needed for debug purposes */ |
2872 | rs_dbgfs_set_mcs(lq_sta, &new_rate, index); | 2462 | rs_dbgfs_set_mcs(lq_sta, &new_rate); |
2873 | 2463 | ||
2874 | /* Fill next table entry */ | 2464 | /* Fill next table entry */ |
2875 | lq_cmd->rs_table[index] = cpu_to_le32(new_rate); | 2465 | lq_cmd->rs_table[index] = cpu_to_le32(new_rate); |
@@ -2914,7 +2504,7 @@ static void rs_free_sta(void *mvm_r, struct ieee80211_sta *sta, | |||
2914 | 2504 | ||
2915 | #ifdef CONFIG_MAC80211_DEBUGFS | 2505 | #ifdef CONFIG_MAC80211_DEBUGFS |
2916 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, | 2506 | static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, |
2917 | u32 *rate_n_flags, int index) | 2507 | u32 *rate_n_flags) |
2918 | { | 2508 | { |
2919 | struct iwl_mvm *mvm; | 2509 | struct iwl_mvm *mvm; |
2920 | u8 valid_tx_ant; | 2510 | u8 valid_tx_ant; |
@@ -2999,8 +2589,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file, | |||
2999 | (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); | 2589 | (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); |
3000 | if (is_Ht(tbl->lq_type)) { | 2590 | if (is_Ht(tbl->lq_type)) { |
3001 | desc += sprintf(buff+desc, " %s", | 2591 | desc += sprintf(buff+desc, " %s", |
3002 | (is_siso(tbl->lq_type)) ? "SISO" : | 2592 | (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); |
3003 | ((is_mimo2(tbl->lq_type)) ? "MIMO2" : "MIMO3")); | ||
3004 | desc += sprintf(buff+desc, " %s", | 2593 | desc += sprintf(buff+desc, " %s", |
3005 | (tbl->is_ht40) ? "40MHz" : "20MHz"); | 2594 | (tbl->is_ht40) ? "40MHz" : "20MHz"); |
3006 | desc += sprintf(buff+desc, " %s %s %s\n", | 2595 | desc += sprintf(buff+desc, " %s %s %s\n", |
@@ -3100,32 +2689,6 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { | |||
3100 | .llseek = default_llseek, | 2689 | .llseek = default_llseek, |
3101 | }; | 2690 | }; |
3102 | 2691 | ||
3103 | static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file, | ||
3104 | char __user *user_buf, size_t count, loff_t *ppos) | ||
3105 | { | ||
3106 | struct iwl_lq_sta *lq_sta = file->private_data; | ||
3107 | struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; | ||
3108 | char buff[120]; | ||
3109 | int desc = 0; | ||
3110 | |||
3111 | if (is_Ht(tbl->lq_type)) | ||
3112 | desc += sprintf(buff+desc, | ||
3113 | "Bit Rate= %d Mb/s\n", | ||
3114 | tbl->expected_tpt[lq_sta->last_txrate_idx]); | ||
3115 | else | ||
3116 | desc += sprintf(buff+desc, | ||
3117 | "Bit Rate= %d Mb/s\n", | ||
3118 | iwl_rates[lq_sta->last_txrate_idx].ieee >> 1); | ||
3119 | |||
3120 | return simple_read_from_buffer(user_buf, count, ppos, buff, desc); | ||
3121 | } | ||
3122 | |||
3123 | static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { | ||
3124 | .read = rs_sta_dbgfs_rate_scale_data_read, | ||
3125 | .open = simple_open, | ||
3126 | .llseek = default_llseek, | ||
3127 | }; | ||
3128 | |||
3129 | static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir) | 2692 | static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir) |
3130 | { | 2693 | { |
3131 | struct iwl_lq_sta *lq_sta = mvm_sta; | 2694 | struct iwl_lq_sta *lq_sta = mvm_sta; |
@@ -3135,9 +2698,6 @@ static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir) | |||
3135 | lq_sta->rs_sta_dbgfs_stats_table_file = | 2698 | lq_sta->rs_sta_dbgfs_stats_table_file = |
3136 | debugfs_create_file("rate_stats_table", S_IRUSR, dir, | 2699 | debugfs_create_file("rate_stats_table", S_IRUSR, dir, |
3137 | lq_sta, &rs_sta_dbgfs_stats_table_ops); | 2700 | lq_sta, &rs_sta_dbgfs_stats_table_ops); |
3138 | lq_sta->rs_sta_dbgfs_rate_scale_data_file = | ||
3139 | debugfs_create_file("rate_scale_data", S_IRUSR, dir, | ||
3140 | lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); | ||
3141 | lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = | 2701 | lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = |
3142 | debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, | 2702 | debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, |
3143 | &lq_sta->tx_agg_tid_en); | 2703 | &lq_sta->tx_agg_tid_en); |
@@ -3148,7 +2708,6 @@ static void rs_remove_debugfs(void *mvm, void *mvm_sta) | |||
3148 | struct iwl_lq_sta *lq_sta = mvm_sta; | 2708 | struct iwl_lq_sta *lq_sta = mvm_sta; |
3149 | debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); | 2709 | debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); |
3150 | debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); | 2710 | debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); |
3151 | debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); | ||
3152 | debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); | 2711 | debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); |
3153 | } | 2712 | } |
3154 | #endif | 2713 | #endif |
@@ -3194,13 +2753,14 @@ void iwl_mvm_rate_control_unregister(void) | |||
3194 | * iwl_mvm_tx_protection - Gets LQ command, change it to enable/disable | 2753 | * iwl_mvm_tx_protection - Gets LQ command, change it to enable/disable |
3195 | * Tx protection, according to this rquest and previous requests, | 2754 | * Tx protection, according to this rquest and previous requests, |
3196 | * and send the LQ command. | 2755 | * and send the LQ command. |
3197 | * @lq: The LQ command | ||
3198 | * @mvmsta: The station | 2756 | * @mvmsta: The station |
3199 | * @enable: Enable Tx protection? | 2757 | * @enable: Enable Tx protection? |
3200 | */ | 2758 | */ |
3201 | int iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, | 2759 | int iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, |
3202 | struct iwl_mvm_sta *mvmsta, bool enable) | 2760 | bool enable) |
3203 | { | 2761 | { |
2762 | struct iwl_lq_cmd *lq = &mvmsta->lq_sta.lq; | ||
2763 | |||
3204 | lockdep_assert_held(&mvm->mutex); | 2764 | lockdep_assert_held(&mvm->mutex); |
3205 | 2765 | ||
3206 | if (enable) { | 2766 | if (enable) { |
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.h b/drivers/net/wireless/iwlwifi/mvm/rs.h index cff4f6da7733..335cf1682902 100644 --- a/drivers/net/wireless/iwlwifi/mvm/rs.h +++ b/drivers/net/wireless/iwlwifi/mvm/rs.h | |||
@@ -38,14 +38,8 @@ struct iwl_rs_rate_info { | |||
38 | u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ | 38 | u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ |
39 | u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ | 39 | u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ |
40 | u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ | 40 | u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ |
41 | u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */ | ||
42 | u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ | ||
43 | u8 prev_ieee; /* previous rate in IEEE speeds */ | ||
44 | u8 next_ieee; /* next rate in IEEE speeds */ | ||
45 | u8 prev_rs; /* previous rate used in rs algo */ | 41 | u8 prev_rs; /* previous rate used in rs algo */ |
46 | u8 next_rs; /* next rate used in rs algo */ | 42 | u8 next_rs; /* next rate used in rs algo */ |
47 | u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ | ||
48 | u8 next_rs_tgg; /* next rate used in TGG rs algo */ | ||
49 | }; | 43 | }; |
50 | 44 | ||
51 | #define IWL_RATE_60M_PLCP 3 | 45 | #define IWL_RATE_60M_PLCP 3 |
@@ -120,23 +114,6 @@ enum { | |||
120 | IWL_RATE_MIMO3_INVM_PLCP = IWL_RATE_SISO_INVM_PLCP, | 114 | IWL_RATE_MIMO3_INVM_PLCP = IWL_RATE_SISO_INVM_PLCP, |
121 | }; | 115 | }; |
122 | 116 | ||
123 | /* MAC header values for bit rates */ | ||
124 | enum { | ||
125 | IWL_RATE_6M_IEEE = 12, | ||
126 | IWL_RATE_9M_IEEE = 18, | ||
127 | IWL_RATE_12M_IEEE = 24, | ||
128 | IWL_RATE_18M_IEEE = 36, | ||
129 | IWL_RATE_24M_IEEE = 48, | ||
130 | IWL_RATE_36M_IEEE = 72, | ||
131 | IWL_RATE_48M_IEEE = 96, | ||
132 | IWL_RATE_54M_IEEE = 108, | ||
133 | IWL_RATE_60M_IEEE = 120, | ||
134 | IWL_RATE_1M_IEEE = 2, | ||
135 | IWL_RATE_2M_IEEE = 4, | ||
136 | IWL_RATE_5M_IEEE = 11, | ||
137 | IWL_RATE_11M_IEEE = 22, | ||
138 | }; | ||
139 | |||
140 | #define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) | 117 | #define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) |
141 | 118 | ||
142 | #define IWL_INVALID_VALUE -1 | 119 | #define IWL_INVALID_VALUE -1 |
@@ -165,47 +142,22 @@ enum { | |||
165 | #define IWL_LEGACY_SWITCH_ANTENNA1 0 | 142 | #define IWL_LEGACY_SWITCH_ANTENNA1 0 |
166 | #define IWL_LEGACY_SWITCH_ANTENNA2 1 | 143 | #define IWL_LEGACY_SWITCH_ANTENNA2 1 |
167 | #define IWL_LEGACY_SWITCH_SISO 2 | 144 | #define IWL_LEGACY_SWITCH_SISO 2 |
168 | #define IWL_LEGACY_SWITCH_MIMO2_AB 3 | 145 | #define IWL_LEGACY_SWITCH_MIMO2 3 |
169 | #define IWL_LEGACY_SWITCH_MIMO2_AC 4 | ||
170 | #define IWL_LEGACY_SWITCH_MIMO2_BC 5 | ||
171 | #define IWL_LEGACY_SWITCH_MIMO3_ABC 6 | ||
172 | 146 | ||
173 | /* possible actions when in siso mode */ | 147 | /* possible actions when in siso mode */ |
174 | #define IWL_SISO_SWITCH_ANTENNA1 0 | 148 | #define IWL_SISO_SWITCH_ANTENNA1 0 |
175 | #define IWL_SISO_SWITCH_ANTENNA2 1 | 149 | #define IWL_SISO_SWITCH_ANTENNA2 1 |
176 | #define IWL_SISO_SWITCH_MIMO2_AB 2 | 150 | #define IWL_SISO_SWITCH_MIMO2 2 |
177 | #define IWL_SISO_SWITCH_MIMO2_AC 3 | 151 | #define IWL_SISO_SWITCH_GI 3 |
178 | #define IWL_SISO_SWITCH_MIMO2_BC 4 | ||
179 | #define IWL_SISO_SWITCH_GI 5 | ||
180 | #define IWL_SISO_SWITCH_MIMO3_ABC 6 | ||
181 | |||
182 | 152 | ||
183 | /* possible actions when in mimo mode */ | 153 | /* possible actions when in mimo mode */ |
184 | #define IWL_MIMO2_SWITCH_ANTENNA1 0 | 154 | #define IWL_MIMO2_SWITCH_ANTENNA1 0 |
185 | #define IWL_MIMO2_SWITCH_ANTENNA2 1 | 155 | #define IWL_MIMO2_SWITCH_ANTENNA2 1 |
186 | #define IWL_MIMO2_SWITCH_SISO_A 2 | 156 | #define IWL_MIMO2_SWITCH_SISO_A 2 |
187 | #define IWL_MIMO2_SWITCH_SISO_B 3 | 157 | #define IWL_MIMO2_SWITCH_SISO_B 3 |
188 | #define IWL_MIMO2_SWITCH_SISO_C 4 | 158 | #define IWL_MIMO2_SWITCH_GI 4 |
189 | #define IWL_MIMO2_SWITCH_GI 5 | ||
190 | #define IWL_MIMO2_SWITCH_MIMO3_ABC 6 | ||
191 | |||
192 | 159 | ||
193 | /* possible actions when in mimo3 mode */ | 160 | #define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_GI |
194 | #define IWL_MIMO3_SWITCH_ANTENNA1 0 | ||
195 | #define IWL_MIMO3_SWITCH_ANTENNA2 1 | ||
196 | #define IWL_MIMO3_SWITCH_SISO_A 2 | ||
197 | #define IWL_MIMO3_SWITCH_SISO_B 3 | ||
198 | #define IWL_MIMO3_SWITCH_SISO_C 4 | ||
199 | #define IWL_MIMO3_SWITCH_MIMO2_AB 5 | ||
200 | #define IWL_MIMO3_SWITCH_MIMO2_AC 6 | ||
201 | #define IWL_MIMO3_SWITCH_MIMO2_BC 7 | ||
202 | #define IWL_MIMO3_SWITCH_GI 8 | ||
203 | |||
204 | |||
205 | #define IWL_MAX_11N_MIMO3_SEARCH IWL_MIMO3_SWITCH_GI | ||
206 | #define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_MIMO3_ABC | ||
207 | |||
208 | /*FIXME:RS:add possible actions for MIMO3*/ | ||
209 | 161 | ||
210 | #define IWL_ACTION_LIMIT 3 /* # possible actions */ | 162 | #define IWL_ACTION_LIMIT 3 /* # possible actions */ |
211 | 163 | ||
@@ -240,15 +192,13 @@ enum iwl_table_type { | |||
240 | LQ_A, | 192 | LQ_A, |
241 | LQ_SISO, /* high-throughput types */ | 193 | LQ_SISO, /* high-throughput types */ |
242 | LQ_MIMO2, | 194 | LQ_MIMO2, |
243 | LQ_MIMO3, | ||
244 | LQ_MAX, | 195 | LQ_MAX, |
245 | }; | 196 | }; |
246 | 197 | ||
247 | #define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A)) | 198 | #define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A)) |
248 | #define is_siso(tbl) ((tbl) == LQ_SISO) | 199 | #define is_siso(tbl) ((tbl) == LQ_SISO) |
249 | #define is_mimo2(tbl) ((tbl) == LQ_MIMO2) | 200 | #define is_mimo2(tbl) ((tbl) == LQ_MIMO2) |
250 | #define is_mimo3(tbl) ((tbl) == LQ_MIMO3) | 201 | #define is_mimo(tbl) is_mimo2(tbl) |
251 | #define is_mimo(tbl) (is_mimo2(tbl) || is_mimo3(tbl)) | ||
252 | #define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) | 202 | #define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) |
253 | #define is_a_band(tbl) ((tbl) == LQ_A) | 203 | #define is_a_band(tbl) ((tbl) == LQ_A) |
254 | #define is_g_and(tbl) ((tbl) == LQ_G) | 204 | #define is_g_and(tbl) ((tbl) == LQ_G) |
@@ -290,17 +240,6 @@ struct iwl_scale_tbl_info { | |||
290 | struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ | 240 | struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ |
291 | }; | 241 | }; |
292 | 242 | ||
293 | struct iwl_traffic_load { | ||
294 | unsigned long time_stamp; /* age of the oldest statistics */ | ||
295 | u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time | ||
296 | * slice */ | ||
297 | u32 total; /* total num of packets during the | ||
298 | * last TID_MAX_TIME_DIFF */ | ||
299 | u8 queue_count; /* number of queues that has | ||
300 | * been used since the last cleanup */ | ||
301 | u8 head; /* start of the circular buffer */ | ||
302 | }; | ||
303 | |||
304 | /** | 243 | /** |
305 | * struct iwl_lq_sta -- driver's rate scaling private structure | 244 | * struct iwl_lq_sta -- driver's rate scaling private structure |
306 | * | 245 | * |
@@ -331,18 +270,15 @@ struct iwl_lq_sta { | |||
331 | u16 active_legacy_rate; | 270 | u16 active_legacy_rate; |
332 | u16 active_siso_rate; | 271 | u16 active_siso_rate; |
333 | u16 active_mimo2_rate; | 272 | u16 active_mimo2_rate; |
334 | u16 active_mimo3_rate; | ||
335 | s8 max_rate_idx; /* Max rate set by user */ | 273 | s8 max_rate_idx; /* Max rate set by user */ |
336 | u8 missed_rate_counter; | 274 | u8 missed_rate_counter; |
337 | 275 | ||
338 | struct iwl_lq_cmd lq; | 276 | struct iwl_lq_cmd lq; |
339 | struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ | 277 | struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ |
340 | struct iwl_traffic_load load[IWL_MAX_TID_COUNT]; | ||
341 | u8 tx_agg_tid_en; | 278 | u8 tx_agg_tid_en; |
342 | #ifdef CONFIG_MAC80211_DEBUGFS | 279 | #ifdef CONFIG_MAC80211_DEBUGFS |
343 | struct dentry *rs_sta_dbgfs_scale_table_file; | 280 | struct dentry *rs_sta_dbgfs_scale_table_file; |
344 | struct dentry *rs_sta_dbgfs_stats_table_file; | 281 | struct dentry *rs_sta_dbgfs_stats_table_file; |
345 | struct dentry *rs_sta_dbgfs_rate_scale_data_file; | ||
346 | struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; | 282 | struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; |
347 | u32 dbg_fixed_rate; | 283 | u32 dbg_fixed_rate; |
348 | #endif | 284 | #endif |
@@ -404,7 +340,7 @@ extern void iwl_mvm_rate_control_unregister(void); | |||
404 | 340 | ||
405 | struct iwl_mvm_sta; | 341 | struct iwl_mvm_sta; |
406 | 342 | ||
407 | int iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, | 343 | int iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, |
408 | struct iwl_mvm_sta *mvmsta, bool enable); | 344 | bool enable); |
409 | 345 | ||
410 | #endif /* __rs__ */ | 346 | #endif /* __rs__ */ |
diff --git a/drivers/net/wireless/iwlwifi/mvm/rx.c b/drivers/net/wireless/iwlwifi/mvm/rx.c index e4930d5027d2..2a8cb5a60535 100644 --- a/drivers/net/wireless/iwlwifi/mvm/rx.c +++ b/drivers/net/wireless/iwlwifi/mvm/rx.c | |||
@@ -124,24 +124,15 @@ static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm, | |||
124 | ieee80211_rx_ni(mvm->hw, skb); | 124 | ieee80211_rx_ni(mvm->hw, skb); |
125 | } | 125 | } |
126 | 126 | ||
127 | /* | 127 | static void iwl_mvm_calc_rssi(struct iwl_mvm *mvm, |
128 | * iwl_mvm_calc_rssi - calculate the rssi in dBm | 128 | struct iwl_rx_phy_info *phy_info, |
129 | * @phy_info: the phy information for the coming packet | 129 | struct ieee80211_rx_status *rx_status) |
130 | */ | ||
131 | static int iwl_mvm_calc_rssi(struct iwl_mvm *mvm, | ||
132 | struct iwl_rx_phy_info *phy_info) | ||
133 | { | 130 | { |
134 | int rssi_a, rssi_b, rssi_a_dbm, rssi_b_dbm, max_rssi_dbm; | 131 | int rssi_a, rssi_b, rssi_a_dbm, rssi_b_dbm, max_rssi_dbm; |
135 | int rssi_all_band_a, rssi_all_band_b; | 132 | int rssi_all_band_a, rssi_all_band_b; |
136 | u32 agc_a, agc_b, max_agc; | 133 | u32 agc_a, agc_b, max_agc; |
137 | u32 val; | 134 | u32 val; |
138 | 135 | ||
139 | /* Find max rssi among 2 possible receivers. | ||
140 | * These values are measured by the Digital Signal Processor (DSP). | ||
141 | * They should stay fairly constant even as the signal strength varies, | ||
142 | * if the radio's Automatic Gain Control (AGC) is working right. | ||
143 | * AGC value (see below) will provide the "interesting" info. | ||
144 | */ | ||
145 | val = le32_to_cpu(phy_info->non_cfg_phy[IWL_RX_INFO_AGC_IDX]); | 136 | val = le32_to_cpu(phy_info->non_cfg_phy[IWL_RX_INFO_AGC_IDX]); |
146 | agc_a = (val & IWL_OFDM_AGC_A_MSK) >> IWL_OFDM_AGC_A_POS; | 137 | agc_a = (val & IWL_OFDM_AGC_A_MSK) >> IWL_OFDM_AGC_A_POS; |
147 | agc_b = (val & IWL_OFDM_AGC_B_MSK) >> IWL_OFDM_AGC_B_POS; | 138 | agc_b = (val & IWL_OFDM_AGC_B_MSK) >> IWL_OFDM_AGC_B_POS; |
@@ -166,7 +157,51 @@ static int iwl_mvm_calc_rssi(struct iwl_mvm *mvm, | |||
166 | IWL_DEBUG_STATS(mvm, "Rssi In A %d B %d Max %d AGCA %d AGCB %d\n", | 157 | IWL_DEBUG_STATS(mvm, "Rssi In A %d B %d Max %d AGCA %d AGCB %d\n", |
167 | rssi_a_dbm, rssi_b_dbm, max_rssi_dbm, agc_a, agc_b); | 158 | rssi_a_dbm, rssi_b_dbm, max_rssi_dbm, agc_a, agc_b); |
168 | 159 | ||
169 | return max_rssi_dbm; | 160 | rx_status->signal = max_rssi_dbm; |
161 | rx_status->chains = (le16_to_cpu(phy_info->phy_flags) & | ||
162 | RX_RES_PHY_FLAGS_ANTENNA) | ||
163 | >> RX_RES_PHY_FLAGS_ANTENNA_POS; | ||
164 | rx_status->chain_signal[0] = rssi_a_dbm; | ||
165 | rx_status->chain_signal[1] = rssi_b_dbm; | ||
166 | } | ||
167 | |||
168 | /* | ||
169 | * iwl_mvm_get_signal_strength - use new rx PHY INFO API | ||
170 | * values are reported by the fw as positive values - need to negate | ||
171 | * to obtain their dBM. Account for missing antennas by replacing 0 | ||
172 | * values by -256dBm: practically 0 power and a non-feasible 8 bit value. | ||
173 | */ | ||
174 | static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm, | ||
175 | struct iwl_rx_phy_info *phy_info, | ||
176 | struct ieee80211_rx_status *rx_status) | ||
177 | { | ||
178 | int energy_a, energy_b, energy_c, max_energy; | ||
179 | u32 val; | ||
180 | |||
181 | val = | ||
182 | le32_to_cpu(phy_info->non_cfg_phy[IWL_RX_INFO_ENERGY_ANT_ABC_IDX]); | ||
183 | energy_a = (val & IWL_RX_INFO_ENERGY_ANT_A_MSK) >> | ||
184 | IWL_RX_INFO_ENERGY_ANT_A_POS; | ||
185 | energy_a = energy_a ? -energy_a : -256; | ||
186 | energy_b = (val & IWL_RX_INFO_ENERGY_ANT_B_MSK) >> | ||
187 | IWL_RX_INFO_ENERGY_ANT_B_POS; | ||
188 | energy_b = energy_b ? -energy_b : -256; | ||
189 | energy_c = (val & IWL_RX_INFO_ENERGY_ANT_C_MSK) >> | ||
190 | IWL_RX_INFO_ENERGY_ANT_C_POS; | ||
191 | energy_c = energy_c ? -energy_c : -256; | ||
192 | max_energy = max(energy_a, energy_b); | ||
193 | max_energy = max(max_energy, energy_c); | ||
194 | |||
195 | IWL_DEBUG_STATS(mvm, "energy In A %d B %d C %d , and max %d\n", | ||
196 | energy_a, energy_b, energy_c, max_energy); | ||
197 | |||
198 | rx_status->signal = max_energy; | ||
199 | rx_status->chains = (le16_to_cpu(phy_info->phy_flags) & | ||
200 | RX_RES_PHY_FLAGS_ANTENNA) | ||
201 | >> RX_RES_PHY_FLAGS_ANTENNA_POS; | ||
202 | rx_status->chain_signal[0] = energy_a; | ||
203 | rx_status->chain_signal[1] = energy_b; | ||
204 | rx_status->chain_signal[2] = energy_c; | ||
170 | } | 205 | } |
171 | 206 | ||
172 | /* | 207 | /* |
@@ -289,29 +324,14 @@ int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, | |||
289 | */ | 324 | */ |
290 | /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ | 325 | /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ |
291 | 326 | ||
292 | /* Find max signal strength (dBm) among 3 antenna/receiver chains */ | 327 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_RX_ENERGY_API) |
293 | rx_status.signal = iwl_mvm_calc_rssi(mvm, phy_info); | 328 | iwl_mvm_get_signal_strength(mvm, phy_info, &rx_status); |
329 | else | ||
330 | iwl_mvm_calc_rssi(mvm, phy_info, &rx_status); | ||
294 | 331 | ||
295 | IWL_DEBUG_STATS_LIMIT(mvm, "Rssi %d, TSF %llu\n", rx_status.signal, | 332 | IWL_DEBUG_STATS_LIMIT(mvm, "Rssi %d, TSF %llu\n", rx_status.signal, |
296 | (unsigned long long)rx_status.mactime); | 333 | (unsigned long long)rx_status.mactime); |
297 | 334 | ||
298 | /* | ||
299 | * "antenna number" | ||
300 | * | ||
301 | * It seems that the antenna field in the phy flags value | ||
302 | * is actually a bit field. This is undefined by radiotap, | ||
303 | * it wants an actual antenna number but I always get "7" | ||
304 | * for most legacy frames I receive indicating that the | ||
305 | * same frame was received on all three RX chains. | ||
306 | * | ||
307 | * I think this field should be removed in favor of a | ||
308 | * new 802.11n radiotap field "RX chains" that is defined | ||
309 | * as a bitmask. | ||
310 | */ | ||
311 | rx_status.antenna = (le16_to_cpu(phy_info->phy_flags) & | ||
312 | RX_RES_PHY_FLAGS_ANTENNA) | ||
313 | >> RX_RES_PHY_FLAGS_ANTENNA_POS; | ||
314 | |||
315 | /* set the preamble flag if appropriate */ | 335 | /* set the preamble flag if appropriate */ |
316 | if (phy_info->phy_flags & cpu_to_le16(RX_RES_PHY_FLAGS_SHORT_PREAMBLE)) | 336 | if (phy_info->phy_flags & cpu_to_le16(RX_RES_PHY_FLAGS_SHORT_PREAMBLE)) |
317 | rx_status.flag |= RX_FLAG_SHORTPRE; | 337 | rx_status.flag |= RX_FLAG_SHORTPRE; |
@@ -364,11 +384,74 @@ int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, | |||
364 | return 0; | 384 | return 0; |
365 | } | 385 | } |
366 | 386 | ||
387 | static void iwl_mvm_update_rx_statistics(struct iwl_mvm *mvm, | ||
388 | struct iwl_notif_statistics *stats) | ||
389 | { | ||
390 | /* | ||
391 | * NOTE FW aggregates the statistics - BUT the statistics are cleared | ||
392 | * when the driver issues REPLY_STATISTICS_CMD 0x9c with CLEAR_STATS | ||
393 | * bit set. | ||
394 | */ | ||
395 | lockdep_assert_held(&mvm->mutex); | ||
396 | memcpy(&mvm->rx_stats, &stats->rx, sizeof(struct mvm_statistics_rx)); | ||
397 | } | ||
398 | |||
399 | struct iwl_mvm_stat_data { | ||
400 | struct iwl_notif_statistics *stats; | ||
401 | struct iwl_mvm *mvm; | ||
402 | }; | ||
403 | |||
404 | static void iwl_mvm_stat_iterator(void *_data, u8 *mac, | ||
405 | struct ieee80211_vif *vif) | ||
406 | { | ||
407 | struct iwl_mvm_stat_data *data = _data; | ||
408 | struct iwl_notif_statistics *stats = data->stats; | ||
409 | struct iwl_mvm *mvm = data->mvm; | ||
410 | int sig = -stats->general.beacon_filter_average_energy; | ||
411 | int last_event; | ||
412 | int thold = vif->bss_conf.cqm_rssi_thold; | ||
413 | int hyst = vif->bss_conf.cqm_rssi_hyst; | ||
414 | u16 id = le32_to_cpu(stats->rx.general.mac_id); | ||
415 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | ||
416 | |||
417 | if (mvmvif->id != id) | ||
418 | return; | ||
419 | |||
420 | if (vif->type != NL80211_IFTYPE_STATION) | ||
421 | return; | ||
422 | |||
423 | mvmvif->bf_data.ave_beacon_signal = sig; | ||
424 | |||
425 | if (!(vif->driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) | ||
426 | return; | ||
427 | |||
428 | /* CQM Notification */ | ||
429 | last_event = mvmvif->bf_data.last_cqm_event; | ||
430 | if (thold && sig < thold && (last_event == 0 || | ||
431 | sig < last_event - hyst)) { | ||
432 | mvmvif->bf_data.last_cqm_event = sig; | ||
433 | IWL_DEBUG_RX(mvm, "cqm_iterator cqm low %d\n", | ||
434 | sig); | ||
435 | ieee80211_cqm_rssi_notify( | ||
436 | vif, | ||
437 | NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW, | ||
438 | GFP_KERNEL); | ||
439 | } else if (sig > thold && | ||
440 | (last_event == 0 || sig > last_event + hyst)) { | ||
441 | mvmvif->bf_data.last_cqm_event = sig; | ||
442 | IWL_DEBUG_RX(mvm, "cqm_iterator cqm high %d\n", | ||
443 | sig); | ||
444 | ieee80211_cqm_rssi_notify( | ||
445 | vif, | ||
446 | NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, | ||
447 | GFP_KERNEL); | ||
448 | } | ||
449 | } | ||
450 | |||
367 | /* | 451 | /* |
368 | * iwl_mvm_rx_statistics - STATISTICS_NOTIFICATION handler | 452 | * iwl_mvm_rx_statistics - STATISTICS_NOTIFICATION handler |
369 | * | 453 | * |
370 | * TODO: This handler is implemented partially. | 454 | * TODO: This handler is implemented partially. |
371 | * It only gets the NIC's temperature. | ||
372 | */ | 455 | */ |
373 | int iwl_mvm_rx_statistics(struct iwl_mvm *mvm, | 456 | int iwl_mvm_rx_statistics(struct iwl_mvm *mvm, |
374 | struct iwl_rx_cmd_buffer *rxb, | 457 | struct iwl_rx_cmd_buffer *rxb, |
@@ -377,11 +460,20 @@ int iwl_mvm_rx_statistics(struct iwl_mvm *mvm, | |||
377 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | 460 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
378 | struct iwl_notif_statistics *stats = (void *)&pkt->data; | 461 | struct iwl_notif_statistics *stats = (void *)&pkt->data; |
379 | struct mvm_statistics_general_common *common = &stats->general.common; | 462 | struct mvm_statistics_general_common *common = &stats->general.common; |
463 | struct iwl_mvm_stat_data data = { | ||
464 | .stats = stats, | ||
465 | .mvm = mvm, | ||
466 | }; | ||
380 | 467 | ||
381 | if (mvm->temperature != le32_to_cpu(common->temperature)) { | 468 | if (mvm->temperature != le32_to_cpu(common->temperature)) { |
382 | mvm->temperature = le32_to_cpu(common->temperature); | 469 | mvm->temperature = le32_to_cpu(common->temperature); |
383 | iwl_mvm_tt_handler(mvm); | 470 | iwl_mvm_tt_handler(mvm); |
384 | } | 471 | } |
472 | iwl_mvm_update_rx_statistics(mvm, stats); | ||
385 | 473 | ||
474 | ieee80211_iterate_active_interfaces(mvm->hw, | ||
475 | IEEE80211_IFACE_ITER_NORMAL, | ||
476 | iwl_mvm_stat_iterator, | ||
477 | &data); | ||
386 | return 0; | 478 | return 0; |
387 | } | 479 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c index 2157b0f8ced5..9a7ab8495300 100644 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c | |||
@@ -137,8 +137,8 @@ static void iwl_mvm_scan_fill_ssids(struct iwl_scan_cmd *cmd, | |||
137 | { | 137 | { |
138 | int fw_idx, req_idx; | 138 | int fw_idx, req_idx; |
139 | 139 | ||
140 | fw_idx = 0; | 140 | for (req_idx = req->n_ssids - 1, fw_idx = 0; req_idx > 0; |
141 | for (req_idx = req->n_ssids - 1; req_idx > 0; req_idx--) { | 141 | req_idx--, fw_idx++) { |
142 | cmd->direct_scan[fw_idx].id = WLAN_EID_SSID; | 142 | cmd->direct_scan[fw_idx].id = WLAN_EID_SSID; |
143 | cmd->direct_scan[fw_idx].len = req->ssids[req_idx].ssid_len; | 143 | cmd->direct_scan[fw_idx].len = req->ssids[req_idx].ssid_len; |
144 | memcpy(cmd->direct_scan[fw_idx].ssid, | 144 | memcpy(cmd->direct_scan[fw_idx].ssid, |
@@ -153,7 +153,9 @@ static void iwl_mvm_scan_fill_ssids(struct iwl_scan_cmd *cmd, | |||
153 | * just to notify that this scan is active and not passive. | 153 | * just to notify that this scan is active and not passive. |
154 | * In order to notify the FW of the number of SSIDs we wish to scan (including | 154 | * In order to notify the FW of the number of SSIDs we wish to scan (including |
155 | * the zero-length one), we need to set the corresponding bits in chan->type, | 155 | * the zero-length one), we need to set the corresponding bits in chan->type, |
156 | * one for each SSID, and set the active bit (first). | 156 | * one for each SSID, and set the active bit (first). The first SSID is already |
157 | * included in the probe template, so we need to set only req->n_ssids - 1 bits | ||
158 | * in addition to the first bit. | ||
157 | */ | 159 | */ |
158 | static u16 iwl_mvm_get_active_dwell(enum ieee80211_band band, int n_ssids) | 160 | static u16 iwl_mvm_get_active_dwell(enum ieee80211_band band, int n_ssids) |
159 | { | 161 | { |
@@ -176,19 +178,12 @@ static void iwl_mvm_scan_fill_channels(struct iwl_scan_cmd *cmd, | |||
176 | struct iwl_scan_channel *chan = (struct iwl_scan_channel *) | 178 | struct iwl_scan_channel *chan = (struct iwl_scan_channel *) |
177 | (cmd->data + le16_to_cpu(cmd->tx_cmd.len)); | 179 | (cmd->data + le16_to_cpu(cmd->tx_cmd.len)); |
178 | int i; | 180 | int i; |
179 | __le32 chan_type_value; | ||
180 | |||
181 | if (req->n_ssids > 0) | ||
182 | chan_type_value = cpu_to_le32(BIT(req->n_ssids + 1) - 1); | ||
183 | else | ||
184 | chan_type_value = SCAN_CHANNEL_TYPE_PASSIVE; | ||
185 | 181 | ||
186 | for (i = 0; i < cmd->channel_count; i++) { | 182 | for (i = 0; i < cmd->channel_count; i++) { |
187 | chan->channel = cpu_to_le16(req->channels[i]->hw_value); | 183 | chan->channel = cpu_to_le16(req->channels[i]->hw_value); |
184 | chan->type = cpu_to_le32(BIT(req->n_ssids) - 1); | ||
188 | if (req->channels[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN) | 185 | if (req->channels[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN) |
189 | chan->type = SCAN_CHANNEL_TYPE_PASSIVE; | 186 | chan->type &= cpu_to_le32(~SCAN_CHANNEL_TYPE_ACTIVE); |
190 | else | ||
191 | chan->type = chan_type_value; | ||
192 | chan->active_dwell = cpu_to_le16(active_dwell); | 187 | chan->active_dwell = cpu_to_le16(active_dwell); |
193 | chan->passive_dwell = cpu_to_le16(passive_dwell); | 188 | chan->passive_dwell = cpu_to_le16(passive_dwell); |
194 | chan->iteration_count = cpu_to_le16(1); | 189 | chan->iteration_count = cpu_to_le16(1); |
@@ -306,10 +301,12 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm, | |||
306 | */ | 301 | */ |
307 | if (req->n_ssids > 0) { | 302 | if (req->n_ssids > 0) { |
308 | cmd->passive2active = cpu_to_le16(1); | 303 | cmd->passive2active = cpu_to_le16(1); |
304 | cmd->scan_flags |= SCAN_FLAGS_PASSIVE2ACTIVE; | ||
309 | ssid = req->ssids[0].ssid; | 305 | ssid = req->ssids[0].ssid; |
310 | ssid_len = req->ssids[0].ssid_len; | 306 | ssid_len = req->ssids[0].ssid_len; |
311 | } else { | 307 | } else { |
312 | cmd->passive2active = 0; | 308 | cmd->passive2active = 0; |
309 | cmd->scan_flags &= ~SCAN_FLAGS_PASSIVE2ACTIVE; | ||
313 | } | 310 | } |
314 | 311 | ||
315 | iwl_mvm_scan_fill_ssids(cmd, req); | 312 | iwl_mvm_scan_fill_ssids(cmd, req); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/sta.c b/drivers/net/wireless/iwlwifi/mvm/sta.c index 62fe5209093b..44add291531b 100644 --- a/drivers/net/wireless/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/iwlwifi/mvm/sta.c | |||
@@ -608,6 +608,8 @@ int iwl_mvm_rm_bcast_sta(struct iwl_mvm *mvm, struct iwl_mvm_int_sta *bsta) | |||
608 | return ret; | 608 | return ret; |
609 | } | 609 | } |
610 | 610 | ||
611 | #define IWL_MAX_RX_BA_SESSIONS 16 | ||
612 | |||
611 | int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | 613 | int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
612 | int tid, u16 ssn, bool start) | 614 | int tid, u16 ssn, bool start) |
613 | { | 615 | { |
@@ -618,11 +620,20 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
618 | 620 | ||
619 | lockdep_assert_held(&mvm->mutex); | 621 | lockdep_assert_held(&mvm->mutex); |
620 | 622 | ||
623 | if (start && mvm->rx_ba_sessions >= IWL_MAX_RX_BA_SESSIONS) { | ||
624 | IWL_WARN(mvm, "Not enough RX BA SESSIONS\n"); | ||
625 | return -ENOSPC; | ||
626 | } | ||
627 | |||
621 | cmd.mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color); | 628 | cmd.mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color); |
622 | cmd.sta_id = mvm_sta->sta_id; | 629 | cmd.sta_id = mvm_sta->sta_id; |
623 | cmd.add_modify = STA_MODE_MODIFY; | 630 | cmd.add_modify = STA_MODE_MODIFY; |
624 | cmd.add_immediate_ba_tid = (u8) tid; | 631 | if (start) { |
625 | cmd.add_immediate_ba_ssn = cpu_to_le16(ssn); | 632 | cmd.add_immediate_ba_tid = (u8) tid; |
633 | cmd.add_immediate_ba_ssn = cpu_to_le16(ssn); | ||
634 | } else { | ||
635 | cmd.remove_immediate_ba_tid = (u8) tid; | ||
636 | } | ||
626 | cmd.modify_mask = start ? STA_MODIFY_ADD_BA_TID : | 637 | cmd.modify_mask = start ? STA_MODIFY_ADD_BA_TID : |
627 | STA_MODIFY_REMOVE_BA_TID; | 638 | STA_MODIFY_REMOVE_BA_TID; |
628 | 639 | ||
@@ -648,6 +659,14 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
648 | break; | 659 | break; |
649 | } | 660 | } |
650 | 661 | ||
662 | if (!ret) { | ||
663 | if (start) | ||
664 | mvm->rx_ba_sessions++; | ||
665 | else if (mvm->rx_ba_sessions > 0) | ||
666 | /* check that restart flow didn't zero the counter */ | ||
667 | mvm->rx_ba_sessions--; | ||
668 | } | ||
669 | |||
651 | return ret; | 670 | return ret; |
652 | } | 671 | } |
653 | 672 | ||
@@ -807,8 +826,7 @@ int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
807 | * method for HT traffic | 826 | * method for HT traffic |
808 | * this function also sends the LQ command | 827 | * this function also sends the LQ command |
809 | */ | 828 | */ |
810 | return iwl_mvm_tx_protection(mvm, &mvmsta->lq_sta.lq, | 829 | return iwl_mvm_tx_protection(mvm, mvmsta, true); |
811 | mvmsta, true); | ||
812 | /* | 830 | /* |
813 | * TODO: remove the TLC_RTS flag when we tear down the last | 831 | * TODO: remove the TLC_RTS flag when we tear down the last |
814 | * AGG session (agg_tids_count in DVM) | 832 | * AGG session (agg_tids_count in DVM) |
@@ -896,6 +914,7 @@ int iwl_mvm_sta_tx_agg_flush(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
896 | struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv; | 914 | struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv; |
897 | struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; | 915 | struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; |
898 | u16 txq_id; | 916 | u16 txq_id; |
917 | enum iwl_mvm_agg_state old_state; | ||
899 | 918 | ||
900 | /* | 919 | /* |
901 | * First set the agg state to OFF to avoid calling | 920 | * First set the agg state to OFF to avoid calling |
@@ -905,13 +924,17 @@ int iwl_mvm_sta_tx_agg_flush(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
905 | txq_id = tid_data->txq_id; | 924 | txq_id = tid_data->txq_id; |
906 | IWL_DEBUG_TX_QUEUES(mvm, "Flush AGG: sta %d tid %d q %d state %d\n", | 925 | IWL_DEBUG_TX_QUEUES(mvm, "Flush AGG: sta %d tid %d q %d state %d\n", |
907 | mvmsta->sta_id, tid, txq_id, tid_data->state); | 926 | mvmsta->sta_id, tid, txq_id, tid_data->state); |
927 | old_state = tid_data->state; | ||
908 | tid_data->state = IWL_AGG_OFF; | 928 | tid_data->state = IWL_AGG_OFF; |
909 | spin_unlock_bh(&mvmsta->lock); | 929 | spin_unlock_bh(&mvmsta->lock); |
910 | 930 | ||
911 | if (iwl_mvm_flush_tx_path(mvm, BIT(txq_id), true)) | 931 | if (old_state >= IWL_AGG_ON) { |
912 | IWL_ERR(mvm, "Couldn't flush the AGG queue\n"); | 932 | if (iwl_mvm_flush_tx_path(mvm, BIT(txq_id), true)) |
933 | IWL_ERR(mvm, "Couldn't flush the AGG queue\n"); | ||
934 | |||
935 | iwl_trans_txq_disable(mvm->trans, tid_data->txq_id); | ||
936 | } | ||
913 | 937 | ||
914 | iwl_trans_txq_disable(mvm->trans, tid_data->txq_id); | ||
915 | mvm->queue_to_mac80211[tid_data->txq_id] = | 938 | mvm->queue_to_mac80211[tid_data->txq_id] = |
916 | IWL_INVALID_MAC80211_QUEUE; | 939 | IWL_INVALID_MAC80211_QUEUE; |
917 | 940 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c index 9f100363b177..c17b74c31398 100644 --- a/drivers/net/wireless/iwlwifi/mvm/time-event.c +++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c | |||
@@ -137,6 +137,20 @@ static void iwl_mvm_roc_finished(struct iwl_mvm *mvm) | |||
137 | schedule_work(&mvm->roc_done_wk); | 137 | schedule_work(&mvm->roc_done_wk); |
138 | } | 138 | } |
139 | 139 | ||
140 | static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm, | ||
141 | struct ieee80211_vif *vif, | ||
142 | const char *errmsg) | ||
143 | { | ||
144 | if (vif->type != NL80211_IFTYPE_STATION) | ||
145 | return false; | ||
146 | if (vif->bss_conf.assoc && vif->bss_conf.dtim_period) | ||
147 | return false; | ||
148 | if (errmsg) | ||
149 | IWL_ERR(mvm, "%s\n", errmsg); | ||
150 | ieee80211_connection_loss(vif); | ||
151 | return true; | ||
152 | } | ||
153 | |||
140 | /* | 154 | /* |
141 | * Handles a FW notification for an event that is known to the driver. | 155 | * Handles a FW notification for an event that is known to the driver. |
142 | * | 156 | * |
@@ -162,10 +176,15 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm, | |||
162 | * P2P Device discoveribility, while there are other higher priority | 176 | * P2P Device discoveribility, while there are other higher priority |
163 | * events in the system). | 177 | * events in the system). |
164 | */ | 178 | */ |
165 | WARN_ONCE(!le32_to_cpu(notif->status), | 179 | if (WARN_ONCE(!le32_to_cpu(notif->status), |
166 | "Failed to schedule time event\n"); | 180 | "Failed to schedule time event\n")) { |
181 | if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, NULL)) { | ||
182 | iwl_mvm_te_clear_data(mvm, te_data); | ||
183 | return; | ||
184 | } | ||
185 | } | ||
167 | 186 | ||
168 | if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_END) { | 187 | if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_END) { |
169 | IWL_DEBUG_TE(mvm, | 188 | IWL_DEBUG_TE(mvm, |
170 | "TE ended - current time %lu, estimated end %lu\n", | 189 | "TE ended - current time %lu, estimated end %lu\n", |
171 | jiffies, te_data->end_jiffies); | 190 | jiffies, te_data->end_jiffies); |
@@ -179,16 +198,10 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm, | |||
179 | * By now, we should have finished association | 198 | * By now, we should have finished association |
180 | * and know the dtim period. | 199 | * and know the dtim period. |
181 | */ | 200 | */ |
182 | if (te_data->vif->type == NL80211_IFTYPE_STATION && | 201 | iwl_mvm_te_check_disconnect(mvm, te_data->vif, |
183 | (!te_data->vif->bss_conf.assoc || | 202 | "No assocation and the time event is over already..."); |
184 | !te_data->vif->bss_conf.dtim_period)) { | ||
185 | IWL_ERR(mvm, | ||
186 | "No assocation and the time event is over already...\n"); | ||
187 | ieee80211_connection_loss(te_data->vif); | ||
188 | } | ||
189 | |||
190 | iwl_mvm_te_clear_data(mvm, te_data); | 203 | iwl_mvm_te_clear_data(mvm, te_data); |
191 | } else if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_START) { | 204 | } else if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_START) { |
192 | te_data->running = true; | 205 | te_data->running = true; |
193 | te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration); | 206 | te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration); |
194 | 207 | ||
@@ -255,10 +268,67 @@ static bool iwl_mvm_time_event_response(struct iwl_notif_wait_data *notif_wait, | |||
255 | return true; | 268 | return true; |
256 | } | 269 | } |
257 | 270 | ||
271 | /* used to convert from time event API v2 to v1 */ | ||
272 | #define TE_V2_DEP_POLICY_MSK (TE_V2_DEP_OTHER | TE_V2_DEP_TSF |\ | ||
273 | TE_V2_EVENT_SOCIOPATHIC) | ||
274 | static inline u16 te_v2_get_notify(__le16 policy) | ||
275 | { | ||
276 | return le16_to_cpu(policy) & TE_V2_NOTIF_MSK; | ||
277 | } | ||
278 | |||
279 | static inline u16 te_v2_get_dep_policy(__le16 policy) | ||
280 | { | ||
281 | return (le16_to_cpu(policy) & TE_V2_DEP_POLICY_MSK) >> | ||
282 | TE_V2_PLACEMENT_POS; | ||
283 | } | ||
284 | |||
285 | static inline u16 te_v2_get_absence(__le16 policy) | ||
286 | { | ||
287 | return (le16_to_cpu(policy) & TE_V2_ABSENCE) >> TE_V2_ABSENCE_POS; | ||
288 | } | ||
289 | |||
290 | static void iwl_mvm_te_v2_to_v1(const struct iwl_time_event_cmd_v2 *cmd_v2, | ||
291 | struct iwl_time_event_cmd_v1 *cmd_v1) | ||
292 | { | ||
293 | cmd_v1->id_and_color = cmd_v2->id_and_color; | ||
294 | cmd_v1->action = cmd_v2->action; | ||
295 | cmd_v1->id = cmd_v2->id; | ||
296 | cmd_v1->apply_time = cmd_v2->apply_time; | ||
297 | cmd_v1->max_delay = cmd_v2->max_delay; | ||
298 | cmd_v1->depends_on = cmd_v2->depends_on; | ||
299 | cmd_v1->interval = cmd_v2->interval; | ||
300 | cmd_v1->duration = cmd_v2->duration; | ||
301 | if (cmd_v2->repeat == TE_V2_REPEAT_ENDLESS) | ||
302 | cmd_v1->repeat = cpu_to_le32(TE_V1_REPEAT_ENDLESS); | ||
303 | else | ||
304 | cmd_v1->repeat = cpu_to_le32(cmd_v2->repeat); | ||
305 | cmd_v1->max_frags = cpu_to_le32(cmd_v2->max_frags); | ||
306 | cmd_v1->interval_reciprocal = 0; /* unused */ | ||
307 | |||
308 | cmd_v1->dep_policy = cpu_to_le32(te_v2_get_dep_policy(cmd_v2->policy)); | ||
309 | cmd_v1->is_present = cpu_to_le32(!te_v2_get_absence(cmd_v2->policy)); | ||
310 | cmd_v1->notify = cpu_to_le32(te_v2_get_notify(cmd_v2->policy)); | ||
311 | } | ||
312 | |||
313 | static int iwl_mvm_send_time_event_cmd(struct iwl_mvm *mvm, | ||
314 | const struct iwl_time_event_cmd_v2 *cmd) | ||
315 | { | ||
316 | struct iwl_time_event_cmd_v1 cmd_v1; | ||
317 | |||
318 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_TIME_EVENT_API_V2) | ||
319 | return iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC, | ||
320 | sizeof(*cmd), cmd); | ||
321 | |||
322 | iwl_mvm_te_v2_to_v1(cmd, &cmd_v1); | ||
323 | return iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC, | ||
324 | sizeof(cmd_v1), &cmd_v1); | ||
325 | } | ||
326 | |||
327 | |||
258 | static int iwl_mvm_time_event_send_add(struct iwl_mvm *mvm, | 328 | static int iwl_mvm_time_event_send_add(struct iwl_mvm *mvm, |
259 | struct ieee80211_vif *vif, | 329 | struct ieee80211_vif *vif, |
260 | struct iwl_mvm_time_event_data *te_data, | 330 | struct iwl_mvm_time_event_data *te_data, |
261 | struct iwl_time_event_cmd *te_cmd) | 331 | struct iwl_time_event_cmd_v2 *te_cmd) |
262 | { | 332 | { |
263 | static const u8 time_event_response[] = { TIME_EVENT_CMD }; | 333 | static const u8 time_event_response[] = { TIME_EVENT_CMD }; |
264 | struct iwl_notification_wait wait_time_event; | 334 | struct iwl_notification_wait wait_time_event; |
@@ -294,8 +364,7 @@ static int iwl_mvm_time_event_send_add(struct iwl_mvm *mvm, | |||
294 | ARRAY_SIZE(time_event_response), | 364 | ARRAY_SIZE(time_event_response), |
295 | iwl_mvm_time_event_response, te_data); | 365 | iwl_mvm_time_event_response, te_data); |
296 | 366 | ||
297 | ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC, | 367 | ret = iwl_mvm_send_time_event_cmd(mvm, te_cmd); |
298 | sizeof(*te_cmd), te_cmd); | ||
299 | if (ret) { | 368 | if (ret) { |
300 | IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret); | 369 | IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret); |
301 | iwl_remove_notification(&mvm->notif_wait, &wait_time_event); | 370 | iwl_remove_notification(&mvm->notif_wait, &wait_time_event); |
@@ -322,7 +391,7 @@ void iwl_mvm_protect_session(struct iwl_mvm *mvm, | |||
322 | { | 391 | { |
323 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 392 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
324 | struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data; | 393 | struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data; |
325 | struct iwl_time_event_cmd time_cmd = {}; | 394 | struct iwl_time_event_cmd_v2 time_cmd = {}; |
326 | 395 | ||
327 | lockdep_assert_held(&mvm->mutex); | 396 | lockdep_assert_held(&mvm->mutex); |
328 | 397 | ||
@@ -356,17 +425,14 @@ void iwl_mvm_protect_session(struct iwl_mvm *mvm, | |||
356 | time_cmd.apply_time = | 425 | time_cmd.apply_time = |
357 | cpu_to_le32(iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG)); | 426 | cpu_to_le32(iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG)); |
358 | 427 | ||
359 | time_cmd.dep_policy = TE_INDEPENDENT; | 428 | time_cmd.max_frags = TE_V2_FRAG_NONE; |
360 | time_cmd.is_present = cpu_to_le32(1); | ||
361 | time_cmd.max_frags = cpu_to_le32(TE_FRAG_NONE); | ||
362 | time_cmd.max_delay = cpu_to_le32(500); | 429 | time_cmd.max_delay = cpu_to_le32(500); |
363 | /* TODO: why do we need to interval = bi if it is not periodic? */ | 430 | /* TODO: why do we need to interval = bi if it is not periodic? */ |
364 | time_cmd.interval = cpu_to_le32(1); | 431 | time_cmd.interval = cpu_to_le32(1); |
365 | time_cmd.interval_reciprocal = cpu_to_le32(iwl_mvm_reciprocal(1)); | ||
366 | time_cmd.duration = cpu_to_le32(duration); | 432 | time_cmd.duration = cpu_to_le32(duration); |
367 | time_cmd.repeat = cpu_to_le32(1); | 433 | time_cmd.repeat = 1; |
368 | time_cmd.notify = cpu_to_le32(TE_NOTIF_HOST_EVENT_START | | 434 | time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START | |
369 | TE_NOTIF_HOST_EVENT_END); | 435 | TE_V2_NOTIF_HOST_EVENT_END); |
370 | 436 | ||
371 | iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); | 437 | iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); |
372 | } | 438 | } |
@@ -380,7 +446,7 @@ void iwl_mvm_remove_time_event(struct iwl_mvm *mvm, | |||
380 | struct iwl_mvm_vif *mvmvif, | 446 | struct iwl_mvm_vif *mvmvif, |
381 | struct iwl_mvm_time_event_data *te_data) | 447 | struct iwl_mvm_time_event_data *te_data) |
382 | { | 448 | { |
383 | struct iwl_time_event_cmd time_cmd = {}; | 449 | struct iwl_time_event_cmd_v2 time_cmd = {}; |
384 | u32 id, uid; | 450 | u32 id, uid; |
385 | int ret; | 451 | int ret; |
386 | 452 | ||
@@ -417,8 +483,7 @@ void iwl_mvm_remove_time_event(struct iwl_mvm *mvm, | |||
417 | cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color)); | 483 | cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color)); |
418 | 484 | ||
419 | IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id)); | 485 | IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id)); |
420 | ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC, | 486 | ret = iwl_mvm_send_time_event_cmd(mvm, &time_cmd); |
421 | sizeof(time_cmd), &time_cmd); | ||
422 | if (WARN_ON(ret)) | 487 | if (WARN_ON(ret)) |
423 | return; | 488 | return; |
424 | } | 489 | } |
@@ -438,7 +503,7 @@ int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
438 | { | 503 | { |
439 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | 504 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
440 | struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data; | 505 | struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data; |
441 | struct iwl_time_event_cmd time_cmd = {}; | 506 | struct iwl_time_event_cmd_v2 time_cmd = {}; |
442 | 507 | ||
443 | lockdep_assert_held(&mvm->mutex); | 508 | lockdep_assert_held(&mvm->mutex); |
444 | if (te_data->running) { | 509 | if (te_data->running) { |
@@ -469,8 +534,6 @@ int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
469 | } | 534 | } |
470 | 535 | ||
471 | time_cmd.apply_time = cpu_to_le32(0); | 536 | time_cmd.apply_time = cpu_to_le32(0); |
472 | time_cmd.dep_policy = cpu_to_le32(TE_INDEPENDENT); | ||
473 | time_cmd.is_present = cpu_to_le32(1); | ||
474 | time_cmd.interval = cpu_to_le32(1); | 537 | time_cmd.interval = cpu_to_le32(1); |
475 | 538 | ||
476 | /* | 539 | /* |
@@ -479,12 +542,12 @@ int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
479 | * scheduled. To improve the chances of it being scheduled, allow them | 542 | * scheduled. To improve the chances of it being scheduled, allow them |
480 | * to be fragmented, and in addition allow them to be delayed. | 543 | * to be fragmented, and in addition allow them to be delayed. |
481 | */ | 544 | */ |
482 | time_cmd.max_frags = cpu_to_le32(MSEC_TO_TU(duration)/20); | 545 | time_cmd.max_frags = min(MSEC_TO_TU(duration)/50, TE_V2_FRAG_ENDLESS); |
483 | time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2)); | 546 | time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2)); |
484 | time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration)); | 547 | time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration)); |
485 | time_cmd.repeat = cpu_to_le32(1); | 548 | time_cmd.repeat = 1; |
486 | time_cmd.notify = cpu_to_le32(TE_NOTIF_HOST_EVENT_START | | 549 | time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START | |
487 | TE_NOTIF_HOST_EVENT_END); | 550 | TE_V2_NOTIF_HOST_EVENT_END); |
488 | 551 | ||
489 | return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); | 552 | return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); |
490 | } | 553 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/tt.c b/drivers/net/wireless/iwlwifi/mvm/tt.c index d6ae7f16ac11..1f3282dff513 100644 --- a/drivers/net/wireless/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/iwlwifi/mvm/tt.c | |||
@@ -391,8 +391,7 @@ static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable) | |||
391 | mvmsta = (void *)sta->drv_priv; | 391 | mvmsta = (void *)sta->drv_priv; |
392 | if (enable == mvmsta->tt_tx_protection) | 392 | if (enable == mvmsta->tt_tx_protection) |
393 | continue; | 393 | continue; |
394 | err = iwl_mvm_tx_protection(mvm, &mvmsta->lq_sta.lq, | 394 | err = iwl_mvm_tx_protection(mvm, mvmsta, enable); |
395 | mvmsta, enable); | ||
396 | if (err) { | 395 | if (err) { |
397 | IWL_ERR(mvm, "Failed to %s Tx protection\n", | 396 | IWL_ERR(mvm, "Failed to %s Tx protection\n", |
398 | enable ? "enable" : "disable"); | 397 | enable ? "enable" : "disable"); |
@@ -513,12 +512,39 @@ static const struct iwl_tt_params iwl7000_tt_params = { | |||
513 | .support_tx_backoff = true, | 512 | .support_tx_backoff = true, |
514 | }; | 513 | }; |
515 | 514 | ||
515 | static const struct iwl_tt_params iwl7000_high_temp_tt_params = { | ||
516 | .ct_kill_entry = 118, | ||
517 | .ct_kill_exit = 96, | ||
518 | .ct_kill_duration = 5, | ||
519 | .dynamic_smps_entry = 114, | ||
520 | .dynamic_smps_exit = 110, | ||
521 | .tx_protection_entry = 114, | ||
522 | .tx_protection_exit = 108, | ||
523 | .tx_backoff = { | ||
524 | {.temperature = 112, .backoff = 300}, | ||
525 | {.temperature = 113, .backoff = 800}, | ||
526 | {.temperature = 114, .backoff = 1500}, | ||
527 | {.temperature = 115, .backoff = 3000}, | ||
528 | {.temperature = 116, .backoff = 5000}, | ||
529 | {.temperature = 117, .backoff = 10000}, | ||
530 | }, | ||
531 | .support_ct_kill = true, | ||
532 | .support_dynamic_smps = true, | ||
533 | .support_tx_protection = true, | ||
534 | .support_tx_backoff = true, | ||
535 | }; | ||
536 | |||
516 | void iwl_mvm_tt_initialize(struct iwl_mvm *mvm) | 537 | void iwl_mvm_tt_initialize(struct iwl_mvm *mvm) |
517 | { | 538 | { |
518 | struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; | 539 | struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; |
519 | 540 | ||
520 | IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n"); | 541 | IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n"); |
521 | tt->params = &iwl7000_tt_params; | 542 | |
543 | if (mvm->cfg->high_temp) | ||
544 | tt->params = &iwl7000_high_temp_tt_params; | ||
545 | else | ||
546 | tt->params = &iwl7000_tt_params; | ||
547 | |||
522 | tt->throttle = false; | 548 | tt->throttle = false; |
523 | INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill); | 549 | INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill); |
524 | } | 550 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c index d62a6d3053ff..e05440d90319 100644 --- a/drivers/net/wireless/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/iwlwifi/mvm/tx.c | |||
@@ -122,6 +122,8 @@ static void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb, | |||
122 | * it | 122 | * it |
123 | */ | 123 | */ |
124 | WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU); | 124 | WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU); |
125 | } else if (skb->protocol == cpu_to_be16(ETH_P_PAE)) { | ||
126 | tx_cmd->pm_frame_timeout = cpu_to_le16(2); | ||
125 | } else { | 127 | } else { |
126 | tx_cmd->pm_frame_timeout = 0; | 128 | tx_cmd->pm_frame_timeout = 0; |
127 | } | 129 | } |
@@ -170,7 +172,7 @@ static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, | |||
170 | } | 172 | } |
171 | 173 | ||
172 | /* | 174 | /* |
173 | * for data packets, rate info comes from the table inside he fw. This | 175 | * for data packets, rate info comes from the table inside the fw. This |
174 | * table is controlled by LINK_QUALITY commands | 176 | * table is controlled by LINK_QUALITY commands |
175 | */ | 177 | */ |
176 | 178 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/utils.c b/drivers/net/wireless/iwlwifi/mvm/utils.c index 1e1332839e4a..a9c357491434 100644 --- a/drivers/net/wireless/iwlwifi/mvm/utils.c +++ b/drivers/net/wireless/iwlwifi/mvm/utils.c | |||
@@ -453,6 +453,29 @@ void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm) | |||
453 | IWL_ERR(mvm, "0x%08X | flow_handler\n", table.flow_handler); | 453 | IWL_ERR(mvm, "0x%08X | flow_handler\n", table.flow_handler); |
454 | } | 454 | } |
455 | 455 | ||
456 | void iwl_mvm_dump_sram(struct iwl_mvm *mvm) | ||
457 | { | ||
458 | const struct fw_img *img; | ||
459 | int ofs, len = 0; | ||
460 | u8 *buf; | ||
461 | |||
462 | if (!mvm->ucode_loaded) | ||
463 | return; | ||
464 | |||
465 | img = &mvm->fw->img[mvm->cur_ucode]; | ||
466 | ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; | ||
467 | len = img->sec[IWL_UCODE_SECTION_DATA].len; | ||
468 | |||
469 | buf = kzalloc(len, GFP_KERNEL); | ||
470 | if (!buf) | ||
471 | return; | ||
472 | |||
473 | iwl_trans_read_mem_bytes(mvm->trans, ofs, buf, len); | ||
474 | iwl_print_hex_error(mvm->trans, buf, len); | ||
475 | |||
476 | kfree(buf); | ||
477 | } | ||
478 | |||
456 | /** | 479 | /** |
457 | * iwl_mvm_send_lq_cmd() - Send link quality command | 480 | * iwl_mvm_send_lq_cmd() - Send link quality command |
458 | * @init: This command is sent as part of station initialization right | 481 | * @init: This command is sent as part of station initialization right |
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c index 81f3ea5b09a4..dc02cb9792af 100644 --- a/drivers/net/wireless/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/iwlwifi/pcie/drv.c | |||
@@ -130,6 +130,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
130 | {IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */ | 130 | {IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */ |
131 | {IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */ | 131 | {IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */ |
132 | {IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */ | 132 | {IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */ |
133 | {IWL_PCI_DEVICE(0x423C, 0x1326, iwl5150_abg_cfg)}, /* Half Mini Card */ | ||
133 | 134 | ||
134 | {IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */ | 135 | {IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */ |
135 | {IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */ | 136 | {IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */ |
@@ -272,9 +273,9 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
272 | {IWL_PCI_DEVICE(0x08B1, 0x4462, iwl7260_n_cfg)}, | 273 | {IWL_PCI_DEVICE(0x08B1, 0x4462, iwl7260_n_cfg)}, |
273 | {IWL_PCI_DEVICE(0x08B1, 0x4870, iwl7260_2ac_cfg)}, | 274 | {IWL_PCI_DEVICE(0x08B1, 0x4870, iwl7260_2ac_cfg)}, |
274 | {IWL_PCI_DEVICE(0x08B1, 0x486E, iwl7260_2ac_cfg)}, | 275 | {IWL_PCI_DEVICE(0x08B1, 0x486E, iwl7260_2ac_cfg)}, |
275 | {IWL_PCI_DEVICE(0x08B1, 0x4A70, iwl7260_2ac_cfg)}, | 276 | {IWL_PCI_DEVICE(0x08B1, 0x4A70, iwl7260_2ac_cfg_high_temp)}, |
276 | {IWL_PCI_DEVICE(0x08B1, 0x4A6E, iwl7260_2ac_cfg)}, | 277 | {IWL_PCI_DEVICE(0x08B1, 0x4A6E, iwl7260_2ac_cfg_high_temp)}, |
277 | {IWL_PCI_DEVICE(0x08B1, 0x4A6C, iwl7260_2ac_cfg)}, | 278 | {IWL_PCI_DEVICE(0x08B1, 0x4A6C, iwl7260_2ac_cfg_high_temp)}, |
278 | {IWL_PCI_DEVICE(0x08B1, 0x4020, iwl7260_2n_cfg)}, | 279 | {IWL_PCI_DEVICE(0x08B1, 0x4020, iwl7260_2n_cfg)}, |
279 | {IWL_PCI_DEVICE(0x08B2, 0x4220, iwl7260_2n_cfg)}, | 280 | {IWL_PCI_DEVICE(0x08B2, 0x4220, iwl7260_2n_cfg)}, |
280 | {IWL_PCI_DEVICE(0x08B1, 0x4420, iwl7260_2n_cfg)}, | 281 | {IWL_PCI_DEVICE(0x08B1, 0x4420, iwl7260_2n_cfg)}, |
@@ -324,15 +325,15 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
324 | int ret; | 325 | int ret; |
325 | 326 | ||
326 | iwl_trans = iwl_trans_pcie_alloc(pdev, ent, cfg); | 327 | iwl_trans = iwl_trans_pcie_alloc(pdev, ent, cfg); |
327 | if (iwl_trans == NULL) | 328 | if (IS_ERR(iwl_trans)) |
328 | return -ENOMEM; | 329 | return PTR_ERR(iwl_trans); |
329 | 330 | ||
330 | pci_set_drvdata(pdev, iwl_trans); | 331 | pci_set_drvdata(pdev, iwl_trans); |
331 | 332 | ||
332 | trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); | 333 | trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); |
333 | trans_pcie->drv = iwl_drv_start(iwl_trans, cfg); | 334 | trans_pcie->drv = iwl_drv_start(iwl_trans, cfg); |
334 | 335 | ||
335 | if (IS_ERR_OR_NULL(trans_pcie->drv)) { | 336 | if (IS_ERR(trans_pcie->drv)) { |
336 | ret = PTR_ERR(trans_pcie->drv); | 337 | ret = PTR_ERR(trans_pcie->drv); |
337 | goto out_free_trans; | 338 | goto out_free_trans; |
338 | } | 339 | } |
@@ -367,21 +368,19 @@ static void iwl_pci_remove(struct pci_dev *pdev) | |||
367 | 368 | ||
368 | static int iwl_pci_suspend(struct device *device) | 369 | static int iwl_pci_suspend(struct device *device) |
369 | { | 370 | { |
370 | struct pci_dev *pdev = to_pci_dev(device); | ||
371 | struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); | ||
372 | |||
373 | /* Before you put code here, think about WoWLAN. You cannot check here | 371 | /* Before you put code here, think about WoWLAN. You cannot check here |
374 | * whether WoWLAN is enabled or not, and your code will run even if | 372 | * whether WoWLAN is enabled or not, and your code will run even if |
375 | * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx. | 373 | * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx. |
376 | */ | 374 | */ |
377 | 375 | ||
378 | return iwl_trans_suspend(iwl_trans); | 376 | return 0; |
379 | } | 377 | } |
380 | 378 | ||
381 | static int iwl_pci_resume(struct device *device) | 379 | static int iwl_pci_resume(struct device *device) |
382 | { | 380 | { |
383 | struct pci_dev *pdev = to_pci_dev(device); | 381 | struct pci_dev *pdev = to_pci_dev(device); |
384 | struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); | 382 | struct iwl_trans *trans = pci_get_drvdata(pdev); |
383 | bool hw_rfkill; | ||
385 | 384 | ||
386 | /* Before you put code here, think about WoWLAN. You cannot check here | 385 | /* Before you put code here, think about WoWLAN. You cannot check here |
387 | * whether WoWLAN is enabled or not, and your code will run even if | 386 | * whether WoWLAN is enabled or not, and your code will run even if |
@@ -394,7 +393,15 @@ static int iwl_pci_resume(struct device *device) | |||
394 | */ | 393 | */ |
395 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); | 394 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); |
396 | 395 | ||
397 | return iwl_trans_resume(iwl_trans); | 396 | if (!trans->op_mode) |
397 | return 0; | ||
398 | |||
399 | iwl_enable_rfkill_int(trans); | ||
400 | |||
401 | hw_rfkill = iwl_is_rfkill_set(trans); | ||
402 | iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); | ||
403 | |||
404 | return 0; | ||
398 | } | 405 | } |
399 | 406 | ||
400 | static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); | 407 | static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); |
diff --git a/drivers/net/wireless/iwlwifi/pcie/internal.h b/drivers/net/wireless/iwlwifi/pcie/internal.h index b654dcdd048a..fa22639b63c9 100644 --- a/drivers/net/wireless/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/iwlwifi/pcie/internal.h | |||
@@ -392,7 +392,6 @@ void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); | |||
392 | /***************************************************** | 392 | /***************************************************** |
393 | * Error handling | 393 | * Error handling |
394 | ******************************************************/ | 394 | ******************************************************/ |
395 | int iwl_pcie_dump_fh(struct iwl_trans *trans, char **buf); | ||
396 | void iwl_pcie_dump_csr(struct iwl_trans *trans); | 395 | void iwl_pcie_dump_csr(struct iwl_trans *trans); |
397 | 396 | ||
398 | /***************************************************** | 397 | /***************************************************** |
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c index fd848cd1583e..3f237b42eb36 100644 --- a/drivers/net/wireless/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/iwlwifi/pcie/rx.c | |||
@@ -112,15 +112,16 @@ | |||
112 | */ | 112 | */ |
113 | static int iwl_rxq_space(const struct iwl_rxq *rxq) | 113 | static int iwl_rxq_space(const struct iwl_rxq *rxq) |
114 | { | 114 | { |
115 | int s = rxq->read - rxq->write; | 115 | /* Make sure RX_QUEUE_SIZE is a power of 2 */ |
116 | 116 | BUILD_BUG_ON(RX_QUEUE_SIZE & (RX_QUEUE_SIZE - 1)); | |
117 | if (s <= 0) | 117 | |
118 | s += RX_QUEUE_SIZE; | 118 | /* |
119 | /* keep some buffer to not confuse full and empty queue */ | 119 | * There can be up to (RX_QUEUE_SIZE - 1) free slots, to avoid ambiguity |
120 | s -= 2; | 120 | * between empty and completely full queues. |
121 | if (s < 0) | 121 | * The following is equivalent to modulo by RX_QUEUE_SIZE and is well |
122 | s = 0; | 122 | * defined for negative dividends. |
123 | return s; | 123 | */ |
124 | return (rxq->read - rxq->write - 1) & (RX_QUEUE_SIZE - 1); | ||
124 | } | 125 | } |
125 | 126 | ||
126 | /* | 127 | /* |
@@ -793,7 +794,7 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans *trans) | |||
793 | } | 794 | } |
794 | 795 | ||
795 | iwl_pcie_dump_csr(trans); | 796 | iwl_pcie_dump_csr(trans); |
796 | iwl_pcie_dump_fh(trans, NULL); | 797 | iwl_dump_fh(trans, NULL); |
797 | 798 | ||
798 | set_bit(STATUS_FW_ERROR, &trans_pcie->status); | 799 | set_bit(STATUS_FW_ERROR, &trans_pcie->status); |
799 | clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); | 800 | clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); |
@@ -1120,6 +1121,7 @@ static irqreturn_t iwl_pcie_isr(int irq, void *data) | |||
1120 | struct iwl_trans *trans = data; | 1121 | struct iwl_trans *trans = data; |
1121 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 1122 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
1122 | u32 inta, inta_mask; | 1123 | u32 inta, inta_mask; |
1124 | irqreturn_t ret = IRQ_NONE; | ||
1123 | 1125 | ||
1124 | lockdep_assert_held(&trans_pcie->irq_lock); | 1126 | lockdep_assert_held(&trans_pcie->irq_lock); |
1125 | 1127 | ||
@@ -1168,10 +1170,8 @@ static irqreturn_t iwl_pcie_isr(int irq, void *data) | |||
1168 | /* the thread will service interrupts and re-enable them */ | 1170 | /* the thread will service interrupts and re-enable them */ |
1169 | if (likely(inta)) | 1171 | if (likely(inta)) |
1170 | return IRQ_WAKE_THREAD; | 1172 | return IRQ_WAKE_THREAD; |
1171 | else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && | 1173 | |
1172 | !trans_pcie->inta) | 1174 | ret = IRQ_HANDLED; |
1173 | iwl_enable_interrupts(trans); | ||
1174 | return IRQ_HANDLED; | ||
1175 | 1175 | ||
1176 | none: | 1176 | none: |
1177 | /* re-enable interrupts here since we don't have anything to service. */ | 1177 | /* re-enable interrupts here since we don't have anything to service. */ |
@@ -1180,7 +1180,7 @@ none: | |||
1180 | !trans_pcie->inta) | 1180 | !trans_pcie->inta) |
1181 | iwl_enable_interrupts(trans); | 1181 | iwl_enable_interrupts(trans); |
1182 | 1182 | ||
1183 | return IRQ_NONE; | 1183 | return ret; |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | /* interrupt handler using ict table, with this interrupt driver will | 1186 | /* interrupt handler using ict table, with this interrupt driver will |
@@ -1199,6 +1199,7 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data) | |||
1199 | u32 val = 0; | 1199 | u32 val = 0; |
1200 | u32 read; | 1200 | u32 read; |
1201 | unsigned long flags; | 1201 | unsigned long flags; |
1202 | irqreturn_t ret = IRQ_NONE; | ||
1202 | 1203 | ||
1203 | if (!trans) | 1204 | if (!trans) |
1204 | return IRQ_NONE; | 1205 | return IRQ_NONE; |
@@ -1211,7 +1212,7 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data) | |||
1211 | * use legacy interrupt. | 1212 | * use legacy interrupt. |
1212 | */ | 1213 | */ |
1213 | if (unlikely(!trans_pcie->use_ict)) { | 1214 | if (unlikely(!trans_pcie->use_ict)) { |
1214 | irqreturn_t ret = iwl_pcie_isr(irq, data); | 1215 | ret = iwl_pcie_isr(irq, data); |
1215 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 1216 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); |
1216 | return ret; | 1217 | return ret; |
1217 | } | 1218 | } |
@@ -1280,17 +1281,9 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data) | |||
1280 | if (likely(inta)) { | 1281 | if (likely(inta)) { |
1281 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 1282 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); |
1282 | return IRQ_WAKE_THREAD; | 1283 | return IRQ_WAKE_THREAD; |
1283 | } else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && | ||
1284 | !trans_pcie->inta) { | ||
1285 | /* Allow interrupt if was disabled by this handler and | ||
1286 | * no tasklet was schedules, We should not enable interrupt, | ||
1287 | * tasklet will enable it. | ||
1288 | */ | ||
1289 | iwl_enable_interrupts(trans); | ||
1290 | } | 1284 | } |
1291 | 1285 | ||
1292 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 1286 | ret = IRQ_HANDLED; |
1293 | return IRQ_HANDLED; | ||
1294 | 1287 | ||
1295 | none: | 1288 | none: |
1296 | /* re-enable interrupts here since we don't have anything to service. | 1289 | /* re-enable interrupts here since we don't have anything to service. |
@@ -1301,5 +1294,5 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data) | |||
1301 | iwl_enable_interrupts(trans); | 1294 | iwl_enable_interrupts(trans); |
1302 | 1295 | ||
1303 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 1296 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); |
1304 | return IRQ_NONE; | 1297 | return ret; |
1305 | } | 1298 | } |
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 826c15602c46..bad95d28d50d 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c | |||
@@ -670,6 +670,11 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) | |||
670 | return err; | 670 | return err; |
671 | } | 671 | } |
672 | 672 | ||
673 | /* Reset the entire device */ | ||
674 | iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | ||
675 | |||
676 | usleep_range(10, 15); | ||
677 | |||
673 | iwl_pcie_apm_init(trans); | 678 | iwl_pcie_apm_init(trans); |
674 | 679 | ||
675 | /* From now on, the op_mode will be kept updated about RF kill state */ | 680 | /* From now on, the op_mode will be kept updated about RF kill state */ |
@@ -815,25 +820,6 @@ static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state) | |||
815 | clear_bit(STATUS_TPOWER_PMI, &trans_pcie->status); | 820 | clear_bit(STATUS_TPOWER_PMI, &trans_pcie->status); |
816 | } | 821 | } |
817 | 822 | ||
818 | #ifdef CONFIG_PM_SLEEP | ||
819 | static int iwl_trans_pcie_suspend(struct iwl_trans *trans) | ||
820 | { | ||
821 | return 0; | ||
822 | } | ||
823 | |||
824 | static int iwl_trans_pcie_resume(struct iwl_trans *trans) | ||
825 | { | ||
826 | bool hw_rfkill; | ||
827 | |||
828 | iwl_enable_rfkill_int(trans); | ||
829 | |||
830 | hw_rfkill = iwl_is_rfkill_set(trans); | ||
831 | iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); | ||
832 | |||
833 | return 0; | ||
834 | } | ||
835 | #endif /* CONFIG_PM_SLEEP */ | ||
836 | |||
837 | static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent, | 823 | static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent, |
838 | unsigned long *flags) | 824 | unsigned long *flags) |
839 | { | 825 | { |
@@ -1033,71 +1019,6 @@ static void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg, | |||
1033 | spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); | 1019 | spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); |
1034 | } | 1020 | } |
1035 | 1021 | ||
1036 | static const char *get_fh_string(int cmd) | ||
1037 | { | ||
1038 | #define IWL_CMD(x) case x: return #x | ||
1039 | switch (cmd) { | ||
1040 | IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); | ||
1041 | IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); | ||
1042 | IWL_CMD(FH_RSCSR_CHNL0_WPTR); | ||
1043 | IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); | ||
1044 | IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); | ||
1045 | IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG); | ||
1046 | IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); | ||
1047 | IWL_CMD(FH_TSSR_TX_STATUS_REG); | ||
1048 | IWL_CMD(FH_TSSR_TX_ERROR_REG); | ||
1049 | default: | ||
1050 | return "UNKNOWN"; | ||
1051 | } | ||
1052 | #undef IWL_CMD | ||
1053 | } | ||
1054 | |||
1055 | int iwl_pcie_dump_fh(struct iwl_trans *trans, char **buf) | ||
1056 | { | ||
1057 | int i; | ||
1058 | static const u32 fh_tbl[] = { | ||
1059 | FH_RSCSR_CHNL0_STTS_WPTR_REG, | ||
1060 | FH_RSCSR_CHNL0_RBDCB_BASE_REG, | ||
1061 | FH_RSCSR_CHNL0_WPTR, | ||
1062 | FH_MEM_RCSR_CHNL0_CONFIG_REG, | ||
1063 | FH_MEM_RSSR_SHARED_CTRL_REG, | ||
1064 | FH_MEM_RSSR_RX_STATUS_REG, | ||
1065 | FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, | ||
1066 | FH_TSSR_TX_STATUS_REG, | ||
1067 | FH_TSSR_TX_ERROR_REG | ||
1068 | }; | ||
1069 | |||
1070 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
1071 | if (buf) { | ||
1072 | int pos = 0; | ||
1073 | size_t bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; | ||
1074 | |||
1075 | *buf = kmalloc(bufsz, GFP_KERNEL); | ||
1076 | if (!*buf) | ||
1077 | return -ENOMEM; | ||
1078 | |||
1079 | pos += scnprintf(*buf + pos, bufsz - pos, | ||
1080 | "FH register values:\n"); | ||
1081 | |||
1082 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) | ||
1083 | pos += scnprintf(*buf + pos, bufsz - pos, | ||
1084 | " %34s: 0X%08x\n", | ||
1085 | get_fh_string(fh_tbl[i]), | ||
1086 | iwl_read_direct32(trans, fh_tbl[i])); | ||
1087 | |||
1088 | return pos; | ||
1089 | } | ||
1090 | #endif | ||
1091 | |||
1092 | IWL_ERR(trans, "FH register values:\n"); | ||
1093 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) | ||
1094 | IWL_ERR(trans, " %34s: 0X%08x\n", | ||
1095 | get_fh_string(fh_tbl[i]), | ||
1096 | iwl_read_direct32(trans, fh_tbl[i])); | ||
1097 | |||
1098 | return 0; | ||
1099 | } | ||
1100 | |||
1101 | static const char *get_csr_string(int cmd) | 1022 | static const char *get_csr_string(int cmd) |
1102 | { | 1023 | { |
1103 | #define IWL_CMD(x) case x: return #x | 1024 | #define IWL_CMD(x) case x: return #x |
@@ -1178,18 +1099,7 @@ void iwl_pcie_dump_csr(struct iwl_trans *trans) | |||
1178 | } while (0) | 1099 | } while (0) |
1179 | 1100 | ||
1180 | /* file operation */ | 1101 | /* file operation */ |
1181 | #define DEBUGFS_READ_FUNC(name) \ | ||
1182 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ | ||
1183 | char __user *user_buf, \ | ||
1184 | size_t count, loff_t *ppos); | ||
1185 | |||
1186 | #define DEBUGFS_WRITE_FUNC(name) \ | ||
1187 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ | ||
1188 | const char __user *user_buf, \ | ||
1189 | size_t count, loff_t *ppos); | ||
1190 | |||
1191 | #define DEBUGFS_READ_FILE_OPS(name) \ | 1102 | #define DEBUGFS_READ_FILE_OPS(name) \ |
1192 | DEBUGFS_READ_FUNC(name); \ | ||
1193 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 1103 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
1194 | .read = iwl_dbgfs_##name##_read, \ | 1104 | .read = iwl_dbgfs_##name##_read, \ |
1195 | .open = simple_open, \ | 1105 | .open = simple_open, \ |
@@ -1197,7 +1107,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
1197 | }; | 1107 | }; |
1198 | 1108 | ||
1199 | #define DEBUGFS_WRITE_FILE_OPS(name) \ | 1109 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
1200 | DEBUGFS_WRITE_FUNC(name); \ | ||
1201 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 1110 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
1202 | .write = iwl_dbgfs_##name##_write, \ | 1111 | .write = iwl_dbgfs_##name##_write, \ |
1203 | .open = simple_open, \ | 1112 | .open = simple_open, \ |
@@ -1205,8 +1114,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
1205 | }; | 1114 | }; |
1206 | 1115 | ||
1207 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ | 1116 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
1208 | DEBUGFS_READ_FUNC(name); \ | ||
1209 | DEBUGFS_WRITE_FUNC(name); \ | ||
1210 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | 1117 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
1211 | .write = iwl_dbgfs_##name##_write, \ | 1118 | .write = iwl_dbgfs_##name##_write, \ |
1212 | .read = iwl_dbgfs_##name##_read, \ | 1119 | .read = iwl_dbgfs_##name##_read, \ |
@@ -1390,7 +1297,7 @@ static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, | |||
1390 | int pos = 0; | 1297 | int pos = 0; |
1391 | ssize_t ret = -EFAULT; | 1298 | ssize_t ret = -EFAULT; |
1392 | 1299 | ||
1393 | ret = pos = iwl_pcie_dump_fh(trans, &buf); | 1300 | ret = pos = iwl_dump_fh(trans, &buf); |
1394 | if (buf) { | 1301 | if (buf) { |
1395 | ret = simple_read_from_buffer(user_buf, | 1302 | ret = simple_read_from_buffer(user_buf, |
1396 | count, ppos, buf, pos); | 1303 | count, ppos, buf, pos); |
@@ -1454,10 +1361,6 @@ static const struct iwl_trans_ops trans_ops_pcie = { | |||
1454 | 1361 | ||
1455 | .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty, | 1362 | .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty, |
1456 | 1363 | ||
1457 | #ifdef CONFIG_PM_SLEEP | ||
1458 | .suspend = iwl_trans_pcie_suspend, | ||
1459 | .resume = iwl_trans_pcie_resume, | ||
1460 | #endif | ||
1461 | .write8 = iwl_trans_pcie_write8, | 1364 | .write8 = iwl_trans_pcie_write8, |
1462 | .write32 = iwl_trans_pcie_write32, | 1365 | .write32 = iwl_trans_pcie_write32, |
1463 | .read32 = iwl_trans_pcie_read32, | 1366 | .read32 = iwl_trans_pcie_read32, |
@@ -1483,9 +1386,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, | |||
1483 | 1386 | ||
1484 | trans = kzalloc(sizeof(struct iwl_trans) + | 1387 | trans = kzalloc(sizeof(struct iwl_trans) + |
1485 | sizeof(struct iwl_trans_pcie), GFP_KERNEL); | 1388 | sizeof(struct iwl_trans_pcie), GFP_KERNEL); |
1486 | 1389 | if (!trans) { | |
1487 | if (!trans) | 1390 | err = -ENOMEM; |
1488 | return NULL; | 1391 | goto out; |
1392 | } | ||
1489 | 1393 | ||
1490 | trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 1394 | trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
1491 | 1395 | ||
@@ -1497,15 +1401,20 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, | |||
1497 | spin_lock_init(&trans_pcie->reg_lock); | 1401 | spin_lock_init(&trans_pcie->reg_lock); |
1498 | init_waitqueue_head(&trans_pcie->ucode_write_waitq); | 1402 | init_waitqueue_head(&trans_pcie->ucode_write_waitq); |
1499 | 1403 | ||
1500 | /* W/A - seems to solve weird behavior. We need to remove this if we | 1404 | if (!cfg->base_params->pcie_l1_allowed) { |
1501 | * don't want to stay in L1 all the time. This wastes a lot of power */ | 1405 | /* |
1502 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | | 1406 | * W/A - seems to solve weird behavior. We need to remove this |
1503 | PCIE_LINK_STATE_CLKPM); | 1407 | * if we don't want to stay in L1 all the time. This wastes a |
1408 | * lot of power. | ||
1409 | */ | ||
1410 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | | ||
1411 | PCIE_LINK_STATE_L1 | | ||
1412 | PCIE_LINK_STATE_CLKPM); | ||
1413 | } | ||
1504 | 1414 | ||
1505 | if (pci_enable_device(pdev)) { | 1415 | err = pci_enable_device(pdev); |
1506 | err = -ENODEV; | 1416 | if (err) |
1507 | goto out_no_pci; | 1417 | goto out_no_pci; |
1508 | } | ||
1509 | 1418 | ||
1510 | pci_set_master(pdev); | 1419 | pci_set_master(pdev); |
1511 | 1420 | ||
@@ -1574,17 +1483,20 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, | |||
1574 | SLAB_HWCACHE_ALIGN, | 1483 | SLAB_HWCACHE_ALIGN, |
1575 | NULL); | 1484 | NULL); |
1576 | 1485 | ||
1577 | if (!trans->dev_cmd_pool) | 1486 | if (!trans->dev_cmd_pool) { |
1487 | err = -ENOMEM; | ||
1578 | goto out_pci_disable_msi; | 1488 | goto out_pci_disable_msi; |
1489 | } | ||
1579 | 1490 | ||
1580 | trans_pcie->inta_mask = CSR_INI_SET_MASK; | 1491 | trans_pcie->inta_mask = CSR_INI_SET_MASK; |
1581 | 1492 | ||
1582 | if (iwl_pcie_alloc_ict(trans)) | 1493 | if (iwl_pcie_alloc_ict(trans)) |
1583 | goto out_free_cmd_pool; | 1494 | goto out_free_cmd_pool; |
1584 | 1495 | ||
1585 | if (request_threaded_irq(pdev->irq, iwl_pcie_isr_ict, | 1496 | err = request_threaded_irq(pdev->irq, iwl_pcie_isr_ict, |
1586 | iwl_pcie_irq_handler, | 1497 | iwl_pcie_irq_handler, |
1587 | IRQF_SHARED, DRV_NAME, trans)) { | 1498 | IRQF_SHARED, DRV_NAME, trans); |
1499 | if (err) { | ||
1588 | IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq); | 1500 | IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq); |
1589 | goto out_free_ict; | 1501 | goto out_free_ict; |
1590 | } | 1502 | } |
@@ -1603,5 +1515,6 @@ out_pci_disable_device: | |||
1603 | pci_disable_device(pdev); | 1515 | pci_disable_device(pdev); |
1604 | out_no_pci: | 1516 | out_no_pci: |
1605 | kfree(trans); | 1517 | kfree(trans); |
1606 | return NULL; | 1518 | out: |
1519 | return ERR_PTR(err); | ||
1607 | } | 1520 | } |
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c index c47c92165aba..f45eb29c2ede 100644 --- a/drivers/net/wireless/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/iwlwifi/pcie/tx.c | |||
@@ -65,18 +65,30 @@ | |||
65 | ***************************************************/ | 65 | ***************************************************/ |
66 | static int iwl_queue_space(const struct iwl_queue *q) | 66 | static int iwl_queue_space(const struct iwl_queue *q) |
67 | { | 67 | { |
68 | int s = q->read_ptr - q->write_ptr; | 68 | unsigned int max; |
69 | 69 | unsigned int used; | |
70 | if (q->read_ptr > q->write_ptr) | 70 | |
71 | s -= q->n_bd; | 71 | /* |
72 | 72 | * To avoid ambiguity between empty and completely full queues, there | |
73 | if (s <= 0) | 73 | * should always be less than q->n_bd elements in the queue. |
74 | s += q->n_window; | 74 | * If q->n_window is smaller than q->n_bd, there is no need to reserve |
75 | /* keep some reserve to not confuse empty and full situations */ | 75 | * any queue entries for this purpose. |
76 | s -= 2; | 76 | */ |
77 | if (s < 0) | 77 | if (q->n_window < q->n_bd) |
78 | s = 0; | 78 | max = q->n_window; |
79 | return s; | 79 | else |
80 | max = q->n_bd - 1; | ||
81 | |||
82 | /* | ||
83 | * q->n_bd is a power of 2, so the following is equivalent to modulo by | ||
84 | * q->n_bd and is well defined for negative dividends. | ||
85 | */ | ||
86 | used = (q->write_ptr - q->read_ptr) & (q->n_bd - 1); | ||
87 | |||
88 | if (WARN_ON(used > max)) | ||
89 | return 0; | ||
90 | |||
91 | return max - used; | ||
80 | } | 92 | } |
81 | 93 | ||
82 | /* | 94 | /* |
@@ -451,13 +463,10 @@ static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq, | |||
451 | return -EINVAL; | 463 | return -EINVAL; |
452 | } | 464 | } |
453 | 465 | ||
454 | if (WARN_ON(addr & ~DMA_BIT_MASK(36))) | 466 | if (WARN(addr & ~IWL_TX_DMA_MASK, |
467 | "Unaligned address = %llx\n", (unsigned long long)addr)) | ||
455 | return -EINVAL; | 468 | return -EINVAL; |
456 | 469 | ||
457 | if (unlikely(addr & ~IWL_TX_DMA_MASK)) | ||
458 | IWL_ERR(trans, "Unaligned address = %llx\n", | ||
459 | (unsigned long long)addr); | ||
460 | |||
461 | iwl_pcie_tfd_set_tb(tfd, num_tbs, addr, len); | 470 | iwl_pcie_tfd_set_tb(tfd, num_tbs, addr, len); |
462 | 471 | ||
463 | return 0; | 472 | return 0; |
@@ -829,7 +838,7 @@ static int iwl_pcie_tx_alloc(struct iwl_trans *trans) | |||
829 | sizeof(struct iwl_txq), GFP_KERNEL); | 838 | sizeof(struct iwl_txq), GFP_KERNEL); |
830 | if (!trans_pcie->txq) { | 839 | if (!trans_pcie->txq) { |
831 | IWL_ERR(trans, "Not enough memory for txq\n"); | 840 | IWL_ERR(trans, "Not enough memory for txq\n"); |
832 | ret = ENOMEM; | 841 | ret = -ENOMEM; |
833 | goto error; | 842 | goto error; |
834 | } | 843 | } |
835 | 844 | ||
@@ -1153,10 +1162,10 @@ void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id) | |||
1153 | /* | 1162 | /* |
1154 | * iwl_pcie_enqueue_hcmd - enqueue a uCode command | 1163 | * iwl_pcie_enqueue_hcmd - enqueue a uCode command |
1155 | * @priv: device private data point | 1164 | * @priv: device private data point |
1156 | * @cmd: a point to the ucode command structure | 1165 | * @cmd: a pointer to the ucode command structure |
1157 | * | 1166 | * |
1158 | * The function returns < 0 values to indicate the operation is | 1167 | * The function returns < 0 values to indicate the operation |
1159 | * failed. On success, it turns the index (> 0) of command in the | 1168 | * failed. On success, it returns the index (>= 0) of command in the |
1160 | * command queue. | 1169 | * command queue. |
1161 | */ | 1170 | */ |
1162 | static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, | 1171 | static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, |
@@ -1619,10 +1628,9 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, | |||
1619 | txq = &trans_pcie->txq[txq_id]; | 1628 | txq = &trans_pcie->txq[txq_id]; |
1620 | q = &txq->q; | 1629 | q = &txq->q; |
1621 | 1630 | ||
1622 | if (unlikely(!test_bit(txq_id, trans_pcie->queue_used))) { | 1631 | if (WARN_ONCE(!test_bit(txq_id, trans_pcie->queue_used), |
1623 | WARN_ON_ONCE(1); | 1632 | "TX on unused queue %d\n", txq_id)) |
1624 | return -EINVAL; | 1633 | return -EINVAL; |
1625 | } | ||
1626 | 1634 | ||
1627 | spin_lock(&txq->lock); | 1635 | spin_lock(&txq->lock); |
1628 | 1636 | ||
@@ -1632,7 +1640,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, | |||
1632 | * Check here that the packets are in the right place on the ring. | 1640 | * Check here that the packets are in the right place on the ring. |
1633 | */ | 1641 | */ |
1634 | wifi_seq = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); | 1642 | wifi_seq = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); |
1635 | WARN_ONCE(trans_pcie->txq[txq_id].ampdu && | 1643 | WARN_ONCE(txq->ampdu && |
1636 | (wifi_seq & 0xff) != q->write_ptr, | 1644 | (wifi_seq & 0xff) != q->write_ptr, |
1637 | "Q: %d WiFi Seq %d tfdNum %d", | 1645 | "Q: %d WiFi Seq %d tfdNum %d", |
1638 | txq_id, wifi_seq, q->write_ptr); | 1646 | txq_id, wifi_seq, q->write_ptr); |
@@ -1664,7 +1672,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, | |||
1664 | */ | 1672 | */ |
1665 | len = sizeof(struct iwl_tx_cmd) + sizeof(struct iwl_cmd_header) + | 1673 | len = sizeof(struct iwl_tx_cmd) + sizeof(struct iwl_cmd_header) + |
1666 | hdr_len - IWL_HCMD_SCRATCHBUF_SIZE; | 1674 | hdr_len - IWL_HCMD_SCRATCHBUF_SIZE; |
1667 | tb1_len = (len + 3) & ~3; | 1675 | tb1_len = ALIGN(len, 4); |
1668 | 1676 | ||
1669 | /* Tell NIC about any 2-byte padding after MAC header */ | 1677 | /* Tell NIC about any 2-byte padding after MAC header */ |
1670 | if (tb1_len != len) | 1678 | if (tb1_len != len) |
diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c index 41e9d25a2d8e..0b803c05cab3 100644 --- a/drivers/net/wireless/mwifiex/11n.c +++ b/drivers/net/wireless/mwifiex/11n.c | |||
@@ -292,6 +292,7 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, | |||
292 | struct mwifiex_ie_types_extcap *ext_cap; | 292 | struct mwifiex_ie_types_extcap *ext_cap; |
293 | int ret_len = 0; | 293 | int ret_len = 0; |
294 | struct ieee80211_supported_band *sband; | 294 | struct ieee80211_supported_band *sband; |
295 | struct ieee_types_header *hdr; | ||
295 | u8 radio_type; | 296 | u8 radio_type; |
296 | 297 | ||
297 | if (!buffer || !*buffer) | 298 | if (!buffer || !*buffer) |
@@ -388,17 +389,24 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, | |||
388 | } | 389 | } |
389 | 390 | ||
390 | if (bss_desc->bcn_ext_cap) { | 391 | if (bss_desc->bcn_ext_cap) { |
392 | hdr = (void *)bss_desc->bcn_ext_cap; | ||
391 | ext_cap = (struct mwifiex_ie_types_extcap *) *buffer; | 393 | ext_cap = (struct mwifiex_ie_types_extcap *) *buffer; |
392 | memset(ext_cap, 0, sizeof(struct mwifiex_ie_types_extcap)); | 394 | memset(ext_cap, 0, sizeof(struct mwifiex_ie_types_extcap)); |
393 | ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY); | 395 | ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY); |
394 | ext_cap->header.len = cpu_to_le16(sizeof(ext_cap->ext_cap)); | 396 | ext_cap->header.len = cpu_to_le16(hdr->len); |
395 | 397 | ||
396 | memcpy((u8 *)ext_cap + sizeof(struct mwifiex_ie_types_header), | 398 | memcpy((u8 *)ext_cap->ext_capab, |
397 | bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header), | 399 | bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header), |
398 | le16_to_cpu(ext_cap->header.len)); | 400 | le16_to_cpu(ext_cap->header.len)); |
399 | 401 | ||
400 | *buffer += sizeof(struct mwifiex_ie_types_extcap); | 402 | if (hdr->len > 3 && |
401 | ret_len += sizeof(struct mwifiex_ie_types_extcap); | 403 | ext_cap->ext_capab[3] & WLAN_EXT_CAPA4_INTERWORKING_ENABLED) |
404 | priv->hs2_enabled = true; | ||
405 | else | ||
406 | priv->hs2_enabled = false; | ||
407 | |||
408 | *buffer += sizeof(struct mwifiex_ie_types_extcap) + hdr->len; | ||
409 | ret_len += sizeof(struct mwifiex_ie_types_extcap) + hdr->len; | ||
402 | } | 410 | } |
403 | 411 | ||
404 | return ret_len; | 412 | return ret_len; |
diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c index a78e0651409c..f69d7e068e75 100644 --- a/drivers/net/wireless/mwifiex/11n_aggr.c +++ b/drivers/net/wireless/mwifiex/11n_aggr.c | |||
@@ -69,7 +69,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr, | |||
69 | memcpy(&tx_header->eth803_hdr, skb_src->data, dt_offset); | 69 | memcpy(&tx_header->eth803_hdr, skb_src->data, dt_offset); |
70 | 70 | ||
71 | /* Copy SNAP header */ | 71 | /* Copy SNAP header */ |
72 | snap.snap_type = *(u16 *) ((u8 *)skb_src->data + dt_offset); | 72 | snap.snap_type = le16_to_cpu(*(__le16 *) ((u8 *)skb_src->data + dt_offset)); |
73 | dt_offset += sizeof(u16); | 73 | dt_offset += sizeof(u16); |
74 | 74 | ||
75 | memcpy(&tx_header->rfc1042_hdr, &snap, sizeof(struct rfc_1042_hdr)); | 75 | memcpy(&tx_header->rfc1042_hdr, &snap, sizeof(struct rfc_1042_hdr)); |
@@ -189,7 +189,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, | |||
189 | 189 | ||
190 | skb_src = skb_dequeue(&pra_list->skb_head); | 190 | skb_src = skb_dequeue(&pra_list->skb_head); |
191 | 191 | ||
192 | pra_list->total_pkts_size -= skb_src->len; | 192 | pra_list->total_pkt_count--; |
193 | 193 | ||
194 | atomic_dec(&priv->wmm.tx_pkts_queued); | 194 | atomic_dec(&priv->wmm.tx_pkts_queued); |
195 | 195 | ||
@@ -268,7 +268,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, | |||
268 | 268 | ||
269 | skb_queue_tail(&pra_list->skb_head, skb_aggr); | 269 | skb_queue_tail(&pra_list->skb_head, skb_aggr); |
270 | 270 | ||
271 | pra_list->total_pkts_size += skb_aggr->len; | 271 | pra_list->total_pkt_count++; |
272 | 272 | ||
273 | atomic_inc(&priv->wmm.tx_pkts_queued); | 273 | atomic_inc(&priv->wmm.tx_pkts_queued); |
274 | 274 | ||
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 0bd631fd556c..fbad00a5abc8 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c | |||
@@ -25,7 +25,9 @@ module_param(reg_alpha2, charp, 0); | |||
25 | 25 | ||
26 | static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = { | 26 | static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = { |
27 | { | 27 | { |
28 | .max = 2, .types = BIT(NL80211_IFTYPE_STATION), | 28 | .max = 2, .types = BIT(NL80211_IFTYPE_STATION) | |
29 | BIT(NL80211_IFTYPE_P2P_GO) | | ||
30 | BIT(NL80211_IFTYPE_P2P_CLIENT), | ||
29 | }, | 31 | }, |
30 | { | 32 | { |
31 | .max = 1, .types = BIT(NL80211_IFTYPE_AP), | 33 | .max = 1, .types = BIT(NL80211_IFTYPE_AP), |
@@ -189,6 +191,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
189 | struct sk_buff *skb; | 191 | struct sk_buff *skb; |
190 | u16 pkt_len; | 192 | u16 pkt_len; |
191 | const struct ieee80211_mgmt *mgmt; | 193 | const struct ieee80211_mgmt *mgmt; |
194 | struct mwifiex_txinfo *tx_info; | ||
192 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); | 195 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); |
193 | 196 | ||
194 | if (!buf || !len) { | 197 | if (!buf || !len) { |
@@ -216,6 +219,10 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
216 | return -ENOMEM; | 219 | return -ENOMEM; |
217 | } | 220 | } |
218 | 221 | ||
222 | tx_info = MWIFIEX_SKB_TXCB(skb); | ||
223 | tx_info->bss_num = priv->bss_num; | ||
224 | tx_info->bss_type = priv->bss_type; | ||
225 | |||
219 | mwifiex_form_mgmt_frame(skb, buf, len); | 226 | mwifiex_form_mgmt_frame(skb, buf, len); |
220 | mwifiex_queue_tx_pkt(priv, skb); | 227 | mwifiex_queue_tx_pkt(priv, skb); |
221 | 228 | ||
@@ -235,16 +242,20 @@ mwifiex_cfg80211_mgmt_frame_register(struct wiphy *wiphy, | |||
235 | u16 frame_type, bool reg) | 242 | u16 frame_type, bool reg) |
236 | { | 243 | { |
237 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); | 244 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); |
245 | u32 mask; | ||
238 | 246 | ||
239 | if (reg) | 247 | if (reg) |
240 | priv->mgmt_frame_mask |= BIT(frame_type >> 4); | 248 | mask = priv->mgmt_frame_mask | BIT(frame_type >> 4); |
241 | else | 249 | else |
242 | priv->mgmt_frame_mask &= ~BIT(frame_type >> 4); | 250 | mask = priv->mgmt_frame_mask & ~BIT(frame_type >> 4); |
243 | |||
244 | mwifiex_send_cmd_async(priv, HostCmd_CMD_MGMT_FRAME_REG, | ||
245 | HostCmd_ACT_GEN_SET, 0, &priv->mgmt_frame_mask); | ||
246 | 251 | ||
247 | wiphy_dbg(wiphy, "info: mgmt frame registered\n"); | 252 | if (mask != priv->mgmt_frame_mask) { |
253 | priv->mgmt_frame_mask = mask; | ||
254 | mwifiex_send_cmd_async(priv, HostCmd_CMD_MGMT_FRAME_REG, | ||
255 | HostCmd_ACT_GEN_SET, 0, | ||
256 | &priv->mgmt_frame_mask); | ||
257 | wiphy_dbg(wiphy, "info: mgmt frame registered\n"); | ||
258 | } | ||
248 | } | 259 | } |
249 | 260 | ||
250 | /* | 261 | /* |
@@ -1497,6 +1508,7 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, | |||
1497 | " reason code %d\n", priv->cfg_bssid, reason_code); | 1508 | " reason code %d\n", priv->cfg_bssid, reason_code); |
1498 | 1509 | ||
1499 | memset(priv->cfg_bssid, 0, ETH_ALEN); | 1510 | memset(priv->cfg_bssid, 0, ETH_ALEN); |
1511 | priv->hs2_enabled = false; | ||
1500 | 1512 | ||
1501 | return 0; | 1513 | return 0; |
1502 | } | 1514 | } |
@@ -1716,9 +1728,9 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, | |||
1716 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); | 1728 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
1717 | int ret; | 1729 | int ret; |
1718 | 1730 | ||
1719 | if (priv->bss_mode != NL80211_IFTYPE_STATION) { | 1731 | if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) { |
1720 | wiphy_err(wiphy, | 1732 | wiphy_err(wiphy, |
1721 | "%s: reject infra assoc request in non-STA mode\n", | 1733 | "%s: reject infra assoc request in non-STA role\n", |
1722 | dev->name); | 1734 | dev->name); |
1723 | return -EINVAL; | 1735 | return -EINVAL; |
1724 | } | 1736 | } |
@@ -2296,9 +2308,9 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
2296 | } | 2308 | } |
2297 | EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf); | 2309 | EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf); |
2298 | 2310 | ||
2299 | #ifdef CONFIG_PM | ||
2300 | static bool | 2311 | static bool |
2301 | mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq) | 2312 | mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq, |
2313 | u8 max_byte_seq) | ||
2302 | { | 2314 | { |
2303 | int j, k, valid_byte_cnt = 0; | 2315 | int j, k, valid_byte_cnt = 0; |
2304 | bool dont_care_byte = false; | 2316 | bool dont_care_byte = false; |
@@ -2316,16 +2328,17 @@ mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq) | |||
2316 | dont_care_byte = true; | 2328 | dont_care_byte = true; |
2317 | } | 2329 | } |
2318 | 2330 | ||
2319 | if (valid_byte_cnt > MAX_BYTESEQ) | 2331 | if (valid_byte_cnt > max_byte_seq) |
2320 | return false; | 2332 | return false; |
2321 | } | 2333 | } |
2322 | } | 2334 | } |
2323 | 2335 | ||
2324 | byte_seq[MAX_BYTESEQ] = valid_byte_cnt; | 2336 | byte_seq[max_byte_seq] = valid_byte_cnt; |
2325 | 2337 | ||
2326 | return true; | 2338 | return true; |
2327 | } | 2339 | } |
2328 | 2340 | ||
2341 | #ifdef CONFIG_PM | ||
2329 | static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, | 2342 | static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, |
2330 | struct cfg80211_wowlan *wowlan) | 2343 | struct cfg80211_wowlan *wowlan) |
2331 | { | 2344 | { |
@@ -2334,7 +2347,7 @@ static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, | |||
2334 | struct mwifiex_mef_entry *mef_entry; | 2347 | struct mwifiex_mef_entry *mef_entry; |
2335 | int i, filt_num = 0, ret; | 2348 | int i, filt_num = 0, ret; |
2336 | bool first_pat = true; | 2349 | bool first_pat = true; |
2337 | u8 byte_seq[MAX_BYTESEQ + 1]; | 2350 | u8 byte_seq[MWIFIEX_MEF_MAX_BYTESEQ + 1]; |
2338 | const u8 ipv4_mc_mac[] = {0x33, 0x33}; | 2351 | const u8 ipv4_mc_mac[] = {0x33, 0x33}; |
2339 | const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e}; | 2352 | const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e}; |
2340 | struct mwifiex_private *priv = | 2353 | struct mwifiex_private *priv = |
@@ -2364,7 +2377,8 @@ static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, | |||
2364 | for (i = 0; i < wowlan->n_patterns; i++) { | 2377 | for (i = 0; i < wowlan->n_patterns; i++) { |
2365 | memset(byte_seq, 0, sizeof(byte_seq)); | 2378 | memset(byte_seq, 0, sizeof(byte_seq)); |
2366 | if (!mwifiex_is_pattern_supported(&wowlan->patterns[i], | 2379 | if (!mwifiex_is_pattern_supported(&wowlan->patterns[i], |
2367 | byte_seq)) { | 2380 | byte_seq, |
2381 | MWIFIEX_MEF_MAX_BYTESEQ)) { | ||
2368 | wiphy_err(wiphy, "Pattern not supported\n"); | 2382 | wiphy_err(wiphy, "Pattern not supported\n"); |
2369 | kfree(mef_entry); | 2383 | kfree(mef_entry); |
2370 | return -EOPNOTSUPP; | 2384 | return -EOPNOTSUPP; |
@@ -2372,16 +2386,16 @@ static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, | |||
2372 | 2386 | ||
2373 | if (!wowlan->patterns[i].pkt_offset) { | 2387 | if (!wowlan->patterns[i].pkt_offset) { |
2374 | if (!(byte_seq[0] & 0x01) && | 2388 | if (!(byte_seq[0] & 0x01) && |
2375 | (byte_seq[MAX_BYTESEQ] == 1)) { | 2389 | (byte_seq[MWIFIEX_MEF_MAX_BYTESEQ] == 1)) { |
2376 | mef_cfg.criteria |= MWIFIEX_CRITERIA_UNICAST; | 2390 | mef_cfg.criteria |= MWIFIEX_CRITERIA_UNICAST; |
2377 | continue; | 2391 | continue; |
2378 | } else if (is_broadcast_ether_addr(byte_seq)) { | 2392 | } else if (is_broadcast_ether_addr(byte_seq)) { |
2379 | mef_cfg.criteria |= MWIFIEX_CRITERIA_BROADCAST; | 2393 | mef_cfg.criteria |= MWIFIEX_CRITERIA_BROADCAST; |
2380 | continue; | 2394 | continue; |
2381 | } else if ((!memcmp(byte_seq, ipv4_mc_mac, 2) && | 2395 | } else if ((!memcmp(byte_seq, ipv4_mc_mac, 2) && |
2382 | (byte_seq[MAX_BYTESEQ] == 2)) || | 2396 | (byte_seq[MWIFIEX_MEF_MAX_BYTESEQ] == 2)) || |
2383 | (!memcmp(byte_seq, ipv6_mc_mac, 3) && | 2397 | (!memcmp(byte_seq, ipv6_mc_mac, 3) && |
2384 | (byte_seq[MAX_BYTESEQ] == 3))) { | 2398 | (byte_seq[MWIFIEX_MEF_MAX_BYTESEQ] == 3))) { |
2385 | mef_cfg.criteria |= MWIFIEX_CRITERIA_MULTICAST; | 2399 | mef_cfg.criteria |= MWIFIEX_CRITERIA_MULTICAST; |
2386 | continue; | 2400 | continue; |
2387 | } | 2401 | } |
@@ -2407,7 +2421,8 @@ static int mwifiex_cfg80211_suspend(struct wiphy *wiphy, | |||
2407 | mef_entry->filter[filt_num].repeat = 16; | 2421 | mef_entry->filter[filt_num].repeat = 16; |
2408 | memcpy(mef_entry->filter[filt_num].byte_seq, priv->curr_addr, | 2422 | memcpy(mef_entry->filter[filt_num].byte_seq, priv->curr_addr, |
2409 | ETH_ALEN); | 2423 | ETH_ALEN); |
2410 | mef_entry->filter[filt_num].byte_seq[MAX_BYTESEQ] = ETH_ALEN; | 2424 | mef_entry->filter[filt_num].byte_seq[MWIFIEX_MEF_MAX_BYTESEQ] = |
2425 | ETH_ALEN; | ||
2411 | mef_entry->filter[filt_num].offset = 14; | 2426 | mef_entry->filter[filt_num].offset = 14; |
2412 | mef_entry->filter[filt_num].filt_type = TYPE_EQ; | 2427 | mef_entry->filter[filt_num].filt_type = TYPE_EQ; |
2413 | if (filt_num) | 2428 | if (filt_num) |
@@ -2441,6 +2456,119 @@ static void mwifiex_cfg80211_set_wakeup(struct wiphy *wiphy, | |||
2441 | } | 2456 | } |
2442 | #endif | 2457 | #endif |
2443 | 2458 | ||
2459 | static int mwifiex_get_coalesce_pkt_type(u8 *byte_seq) | ||
2460 | { | ||
2461 | const u8 ipv4_mc_mac[] = {0x33, 0x33}; | ||
2462 | const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e}; | ||
2463 | const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff}; | ||
2464 | |||
2465 | if ((byte_seq[0] & 0x01) && | ||
2466 | (byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ] == 1)) | ||
2467 | return PACKET_TYPE_UNICAST; | ||
2468 | else if (!memcmp(byte_seq, bc_mac, 4)) | ||
2469 | return PACKET_TYPE_BROADCAST; | ||
2470 | else if ((!memcmp(byte_seq, ipv4_mc_mac, 2) && | ||
2471 | byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ] == 2) || | ||
2472 | (!memcmp(byte_seq, ipv6_mc_mac, 3) && | ||
2473 | byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ] == 3)) | ||
2474 | return PACKET_TYPE_MULTICAST; | ||
2475 | |||
2476 | return 0; | ||
2477 | } | ||
2478 | |||
2479 | static int | ||
2480 | mwifiex_fill_coalesce_rule_info(struct mwifiex_private *priv, | ||
2481 | struct cfg80211_coalesce_rules *crule, | ||
2482 | struct mwifiex_coalesce_rule *mrule) | ||
2483 | { | ||
2484 | u8 byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ + 1]; | ||
2485 | struct filt_field_param *param; | ||
2486 | int i; | ||
2487 | |||
2488 | mrule->max_coalescing_delay = crule->delay; | ||
2489 | |||
2490 | param = mrule->params; | ||
2491 | |||
2492 | for (i = 0; i < crule->n_patterns; i++) { | ||
2493 | memset(byte_seq, 0, sizeof(byte_seq)); | ||
2494 | if (!mwifiex_is_pattern_supported(&crule->patterns[i], | ||
2495 | byte_seq, | ||
2496 | MWIFIEX_COALESCE_MAX_BYTESEQ)) { | ||
2497 | dev_err(priv->adapter->dev, "Pattern not supported\n"); | ||
2498 | return -EOPNOTSUPP; | ||
2499 | } | ||
2500 | |||
2501 | if (!crule->patterns[i].pkt_offset) { | ||
2502 | u8 pkt_type; | ||
2503 | |||
2504 | pkt_type = mwifiex_get_coalesce_pkt_type(byte_seq); | ||
2505 | if (pkt_type && mrule->pkt_type) { | ||
2506 | dev_err(priv->adapter->dev, | ||
2507 | "Multiple packet types not allowed\n"); | ||
2508 | return -EOPNOTSUPP; | ||
2509 | } else if (pkt_type) { | ||
2510 | mrule->pkt_type = pkt_type; | ||
2511 | continue; | ||
2512 | } | ||
2513 | } | ||
2514 | |||
2515 | if (crule->condition == NL80211_COALESCE_CONDITION_MATCH) | ||
2516 | param->operation = RECV_FILTER_MATCH_TYPE_EQ; | ||
2517 | else | ||
2518 | param->operation = RECV_FILTER_MATCH_TYPE_NE; | ||
2519 | |||
2520 | param->operand_len = byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ]; | ||
2521 | memcpy(param->operand_byte_stream, byte_seq, | ||
2522 | param->operand_len); | ||
2523 | param->offset = crule->patterns[i].pkt_offset; | ||
2524 | param++; | ||
2525 | |||
2526 | mrule->num_of_fields++; | ||
2527 | } | ||
2528 | |||
2529 | if (!mrule->pkt_type) { | ||
2530 | dev_err(priv->adapter->dev, | ||
2531 | "Packet type can not be determined\n"); | ||
2532 | return -EOPNOTSUPP; | ||
2533 | } | ||
2534 | |||
2535 | return 0; | ||
2536 | } | ||
2537 | |||
2538 | static int mwifiex_cfg80211_set_coalesce(struct wiphy *wiphy, | ||
2539 | struct cfg80211_coalesce *coalesce) | ||
2540 | { | ||
2541 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); | ||
2542 | int i, ret; | ||
2543 | struct mwifiex_ds_coalesce_cfg coalesce_cfg; | ||
2544 | struct mwifiex_private *priv = | ||
2545 | mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA); | ||
2546 | |||
2547 | memset(&coalesce_cfg, 0, sizeof(coalesce_cfg)); | ||
2548 | if (!coalesce) { | ||
2549 | dev_dbg(adapter->dev, | ||
2550 | "Disable coalesce and reset all previous rules\n"); | ||
2551 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_COALESCE_CFG, | ||
2552 | HostCmd_ACT_GEN_SET, 0, | ||
2553 | &coalesce_cfg); | ||
2554 | } | ||
2555 | |||
2556 | coalesce_cfg.num_of_rules = coalesce->n_rules; | ||
2557 | for (i = 0; i < coalesce->n_rules; i++) { | ||
2558 | ret = mwifiex_fill_coalesce_rule_info(priv, &coalesce->rules[i], | ||
2559 | &coalesce_cfg.rule[i]); | ||
2560 | if (ret) { | ||
2561 | dev_err(priv->adapter->dev, | ||
2562 | "Recheck the patterns provided for rule %d\n", | ||
2563 | i + 1); | ||
2564 | return ret; | ||
2565 | } | ||
2566 | } | ||
2567 | |||
2568 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_COALESCE_CFG, | ||
2569 | HostCmd_ACT_GEN_SET, 0, &coalesce_cfg); | ||
2570 | } | ||
2571 | |||
2444 | /* station cfg80211 operations */ | 2572 | /* station cfg80211 operations */ |
2445 | static struct cfg80211_ops mwifiex_cfg80211_ops = { | 2573 | static struct cfg80211_ops mwifiex_cfg80211_ops = { |
2446 | .add_virtual_intf = mwifiex_add_virtual_intf, | 2574 | .add_virtual_intf = mwifiex_add_virtual_intf, |
@@ -2475,12 +2603,13 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = { | |||
2475 | .resume = mwifiex_cfg80211_resume, | 2603 | .resume = mwifiex_cfg80211_resume, |
2476 | .set_wakeup = mwifiex_cfg80211_set_wakeup, | 2604 | .set_wakeup = mwifiex_cfg80211_set_wakeup, |
2477 | #endif | 2605 | #endif |
2606 | .set_coalesce = mwifiex_cfg80211_set_coalesce, | ||
2478 | }; | 2607 | }; |
2479 | 2608 | ||
2480 | #ifdef CONFIG_PM | 2609 | #ifdef CONFIG_PM |
2481 | static const struct wiphy_wowlan_support mwifiex_wowlan_support = { | 2610 | static const struct wiphy_wowlan_support mwifiex_wowlan_support = { |
2482 | .flags = WIPHY_WOWLAN_MAGIC_PKT, | 2611 | .flags = WIPHY_WOWLAN_MAGIC_PKT, |
2483 | .n_patterns = MWIFIEX_MAX_FILTERS, | 2612 | .n_patterns = MWIFIEX_MEF_MAX_FILTERS, |
2484 | .pattern_min_len = 1, | 2613 | .pattern_min_len = 1, |
2485 | .pattern_max_len = MWIFIEX_MAX_PATTERN_LEN, | 2614 | .pattern_max_len = MWIFIEX_MAX_PATTERN_LEN, |
2486 | .max_pkt_offset = MWIFIEX_MAX_OFFSET_LEN, | 2615 | .max_pkt_offset = MWIFIEX_MAX_OFFSET_LEN, |
@@ -2498,6 +2627,15 @@ static bool mwifiex_is_valid_alpha2(const char *alpha2) | |||
2498 | return false; | 2627 | return false; |
2499 | } | 2628 | } |
2500 | 2629 | ||
2630 | static const struct wiphy_coalesce_support mwifiex_coalesce_support = { | ||
2631 | .n_rules = MWIFIEX_COALESCE_MAX_RULES, | ||
2632 | .max_delay = MWIFIEX_MAX_COALESCING_DELAY, | ||
2633 | .n_patterns = MWIFIEX_COALESCE_MAX_FILTERS, | ||
2634 | .pattern_min_len = 1, | ||
2635 | .pattern_max_len = MWIFIEX_MAX_PATTERN_LEN, | ||
2636 | .max_pkt_offset = MWIFIEX_MAX_OFFSET_LEN, | ||
2637 | }; | ||
2638 | |||
2501 | /* | 2639 | /* |
2502 | * This function registers the device with CFG802.11 subsystem. | 2640 | * This function registers the device with CFG802.11 subsystem. |
2503 | * | 2641 | * |
@@ -2559,6 +2697,8 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter) | |||
2559 | wiphy->wowlan = &mwifiex_wowlan_support; | 2697 | wiphy->wowlan = &mwifiex_wowlan_support; |
2560 | #endif | 2698 | #endif |
2561 | 2699 | ||
2700 | wiphy->coalesce = &mwifiex_coalesce_support; | ||
2701 | |||
2562 | wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | | 2702 | wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | |
2563 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | | 2703 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | |
2564 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P; | 2704 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P; |
diff --git a/drivers/net/wireless/mwifiex/cfp.c b/drivers/net/wireless/mwifiex/cfp.c index 988552dece75..9eefacbc844b 100644 --- a/drivers/net/wireless/mwifiex/cfp.c +++ b/drivers/net/wireless/mwifiex/cfp.c | |||
@@ -404,18 +404,51 @@ mwifiex_is_rate_auto(struct mwifiex_private *priv) | |||
404 | return false; | 404 | return false; |
405 | } | 405 | } |
406 | 406 | ||
407 | /* | 407 | /* This function gets the supported data rates from bitmask inside |
408 | * This function gets the supported data rates. | 408 | * cfg80211_scan_request. |
409 | * | 409 | */ |
410 | * The function works in both Ad-Hoc and infra mode by printing the | 410 | u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv, |
411 | * band and returning the data rates. | 411 | u8 *rates, u8 radio_type) |
412 | { | ||
413 | struct wiphy *wiphy = priv->adapter->wiphy; | ||
414 | struct cfg80211_scan_request *request = priv->scan_request; | ||
415 | u32 num_rates, rate_mask; | ||
416 | struct ieee80211_supported_band *sband; | ||
417 | int i; | ||
418 | |||
419 | if (radio_type) { | ||
420 | sband = wiphy->bands[IEEE80211_BAND_5GHZ]; | ||
421 | if (WARN_ON_ONCE(!sband)) | ||
422 | return 0; | ||
423 | rate_mask = request->rates[IEEE80211_BAND_5GHZ]; | ||
424 | } else { | ||
425 | sband = wiphy->bands[IEEE80211_BAND_2GHZ]; | ||
426 | if (WARN_ON_ONCE(!sband)) | ||
427 | return 0; | ||
428 | rate_mask = request->rates[IEEE80211_BAND_2GHZ]; | ||
429 | } | ||
430 | |||
431 | num_rates = 0; | ||
432 | for (i = 0; i < sband->n_bitrates; i++) { | ||
433 | if ((BIT(i) & rate_mask) == 0) | ||
434 | continue; /* skip rate */ | ||
435 | rates[num_rates++] = (u8)(sband->bitrates[i].bitrate / 5); | ||
436 | } | ||
437 | |||
438 | return num_rates; | ||
439 | } | ||
440 | |||
441 | /* This function gets the supported data rates. The function works in | ||
442 | * both Ad-Hoc and infra mode by printing the band and returning the | ||
443 | * data rates. | ||
412 | */ | 444 | */ |
413 | u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates) | 445 | u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates) |
414 | { | 446 | { |
415 | u32 k = 0; | 447 | u32 k = 0; |
416 | struct mwifiex_adapter *adapter = priv->adapter; | 448 | struct mwifiex_adapter *adapter = priv->adapter; |
417 | 449 | ||
418 | if (priv->bss_mode == NL80211_IFTYPE_STATION) { | 450 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
451 | priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) { | ||
419 | switch (adapter->config_bands) { | 452 | switch (adapter->config_bands) { |
420 | case BAND_B: | 453 | case BAND_B: |
421 | dev_dbg(adapter->dev, "info: infra band=%d " | 454 | dev_dbg(adapter->dev, "info: infra band=%d " |
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h index 94cc09d48444..5c85d7803d00 100644 --- a/drivers/net/wireless/mwifiex/decl.h +++ b/drivers/net/wireless/mwifiex/decl.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/wait.h> | 26 | #include <linux/wait.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
28 | #include <linux/ieee80211.h> | 28 | #include <linux/ieee80211.h> |
29 | #include <uapi/linux/if_arp.h> | ||
29 | #include <net/mac80211.h> | 30 | #include <net/mac80211.h> |
30 | 31 | ||
31 | 32 | ||
@@ -75,7 +76,8 @@ | |||
75 | #define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0) | 76 | #define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0) |
76 | #define MWIFIEX_BUF_FLAG_BRIDGED_PKT BIT(1) | 77 | #define MWIFIEX_BUF_FLAG_BRIDGED_PKT BIT(1) |
77 | 78 | ||
78 | #define MWIFIEX_BRIDGED_PKTS_THRESHOLD 1024 | 79 | #define MWIFIEX_BRIDGED_PKTS_THR_HIGH 1024 |
80 | #define MWIFIEX_BRIDGED_PKTS_THR_LOW 128 | ||
79 | 81 | ||
80 | enum mwifiex_bss_type { | 82 | enum mwifiex_bss_type { |
81 | MWIFIEX_BSS_TYPE_STA = 0, | 83 | MWIFIEX_BSS_TYPE_STA = 0, |
@@ -151,4 +153,12 @@ struct mwifiex_types_wmm_info { | |||
151 | u8 reserved; | 153 | u8 reserved; |
152 | struct ieee_types_wmm_ac_parameters ac_params[IEEE80211_NUM_ACS]; | 154 | struct ieee_types_wmm_ac_parameters ac_params[IEEE80211_NUM_ACS]; |
153 | } __packed; | 155 | } __packed; |
156 | |||
157 | struct mwifiex_arp_eth_header { | ||
158 | struct arphdr hdr; | ||
159 | u8 ar_sha[ETH_ALEN]; | ||
160 | u8 ar_sip[4]; | ||
161 | u8 ar_tha[ETH_ALEN]; | ||
162 | u8 ar_tip[4]; | ||
163 | } __packed; | ||
154 | #endif /* !_MWIFIEX_DECL_H_ */ | 164 | #endif /* !_MWIFIEX_DECL_H_ */ |
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index 1b45aa533300..f80f30b6160e 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h | |||
@@ -85,9 +85,6 @@ enum KEY_TYPE_ID { | |||
85 | #define WAPI_KEY_LEN 50 | 85 | #define WAPI_KEY_LEN 50 |
86 | 86 | ||
87 | #define MAX_POLL_TRIES 100 | 87 | #define MAX_POLL_TRIES 100 |
88 | |||
89 | #define MAX_MULTI_INTERFACE_POLL_TRIES 1000 | ||
90 | |||
91 | #define MAX_FIRMWARE_POLL_TRIES 100 | 88 | #define MAX_FIRMWARE_POLL_TRIES 100 |
92 | 89 | ||
93 | #define FIRMWARE_READY_SDIO 0xfedc | 90 | #define FIRMWARE_READY_SDIO 0xfedc |
@@ -156,6 +153,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { | |||
156 | #define TLV_TYPE_UAP_PS_AO_TIMER (PROPRIETARY_TLV_BASE_ID + 123) | 153 | #define TLV_TYPE_UAP_PS_AO_TIMER (PROPRIETARY_TLV_BASE_ID + 123) |
157 | #define TLV_TYPE_PWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 145) | 154 | #define TLV_TYPE_PWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 145) |
158 | #define TLV_TYPE_GWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 146) | 155 | #define TLV_TYPE_GWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 146) |
156 | #define TLV_TYPE_COALESCE_RULE (PROPRIETARY_TLV_BASE_ID + 154) | ||
159 | 157 | ||
160 | #define MWIFIEX_TX_DATA_BUF_SIZE_2K 2048 | 158 | #define MWIFIEX_TX_DATA_BUF_SIZE_2K 2048 |
161 | 159 | ||
@@ -297,6 +295,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { | |||
297 | #define HostCmd_CMD_CAU_REG_ACCESS 0x00ed | 295 | #define HostCmd_CMD_CAU_REG_ACCESS 0x00ed |
298 | #define HostCmd_CMD_SET_BSS_MODE 0x00f7 | 296 | #define HostCmd_CMD_SET_BSS_MODE 0x00f7 |
299 | #define HostCmd_CMD_PCIE_DESC_DETAILS 0x00fa | 297 | #define HostCmd_CMD_PCIE_DESC_DETAILS 0x00fa |
298 | #define HostCmd_CMD_COALESCE_CFG 0x010a | ||
300 | #define HostCmd_CMD_MGMT_FRAME_REG 0x010c | 299 | #define HostCmd_CMD_MGMT_FRAME_REG 0x010c |
301 | #define HostCmd_CMD_REMAIN_ON_CHAN 0x010d | 300 | #define HostCmd_CMD_REMAIN_ON_CHAN 0x010d |
302 | #define HostCmd_CMD_11AC_CFG 0x0112 | 301 | #define HostCmd_CMD_11AC_CFG 0x0112 |
@@ -453,7 +452,7 @@ enum P2P_MODES { | |||
453 | (((event_cause) >> 24) & 0x00ff) | 452 | (((event_cause) >> 24) & 0x00ff) |
454 | 453 | ||
455 | #define MWIFIEX_MAX_PATTERN_LEN 20 | 454 | #define MWIFIEX_MAX_PATTERN_LEN 20 |
456 | #define MWIFIEX_MAX_OFFSET_LEN 50 | 455 | #define MWIFIEX_MAX_OFFSET_LEN 100 |
457 | #define STACK_NBYTES 100 | 456 | #define STACK_NBYTES 100 |
458 | #define TYPE_DNUM 1 | 457 | #define TYPE_DNUM 1 |
459 | #define TYPE_BYTESEQ 2 | 458 | #define TYPE_BYTESEQ 2 |
@@ -1331,7 +1330,7 @@ struct mwifiex_ie_types_2040bssco { | |||
1331 | 1330 | ||
1332 | struct mwifiex_ie_types_extcap { | 1331 | struct mwifiex_ie_types_extcap { |
1333 | struct mwifiex_ie_types_header header; | 1332 | struct mwifiex_ie_types_header header; |
1334 | u8 ext_cap; | 1333 | u8 ext_capab[0]; |
1335 | } __packed; | 1334 | } __packed; |
1336 | 1335 | ||
1337 | struct host_cmd_ds_mac_reg_access { | 1336 | struct host_cmd_ds_mac_reg_access { |
@@ -1369,11 +1368,6 @@ struct host_cmd_ds_802_11_eeprom_access { | |||
1369 | u8 value; | 1368 | u8 value; |
1370 | } __packed; | 1369 | } __packed; |
1371 | 1370 | ||
1372 | struct host_cmd_tlv { | ||
1373 | __le16 type; | ||
1374 | __le16 len; | ||
1375 | } __packed; | ||
1376 | |||
1377 | struct mwifiex_assoc_event { | 1371 | struct mwifiex_assoc_event { |
1378 | u8 sta_addr[ETH_ALEN]; | 1372 | u8 sta_addr[ETH_ALEN]; |
1379 | __le16 type; | 1373 | __le16 type; |
@@ -1399,99 +1393,99 @@ struct host_cmd_11ac_vht_cfg { | |||
1399 | } __packed; | 1393 | } __packed; |
1400 | 1394 | ||
1401 | struct host_cmd_tlv_akmp { | 1395 | struct host_cmd_tlv_akmp { |
1402 | struct host_cmd_tlv tlv; | 1396 | struct mwifiex_ie_types_header header; |
1403 | __le16 key_mgmt; | 1397 | __le16 key_mgmt; |
1404 | __le16 key_mgmt_operation; | 1398 | __le16 key_mgmt_operation; |
1405 | } __packed; | 1399 | } __packed; |
1406 | 1400 | ||
1407 | struct host_cmd_tlv_pwk_cipher { | 1401 | struct host_cmd_tlv_pwk_cipher { |
1408 | struct host_cmd_tlv tlv; | 1402 | struct mwifiex_ie_types_header header; |
1409 | __le16 proto; | 1403 | __le16 proto; |
1410 | u8 cipher; | 1404 | u8 cipher; |
1411 | u8 reserved; | 1405 | u8 reserved; |
1412 | } __packed; | 1406 | } __packed; |
1413 | 1407 | ||
1414 | struct host_cmd_tlv_gwk_cipher { | 1408 | struct host_cmd_tlv_gwk_cipher { |
1415 | struct host_cmd_tlv tlv; | 1409 | struct mwifiex_ie_types_header header; |
1416 | u8 cipher; | 1410 | u8 cipher; |
1417 | u8 reserved; | 1411 | u8 reserved; |
1418 | } __packed; | 1412 | } __packed; |
1419 | 1413 | ||
1420 | struct host_cmd_tlv_passphrase { | 1414 | struct host_cmd_tlv_passphrase { |
1421 | struct host_cmd_tlv tlv; | 1415 | struct mwifiex_ie_types_header header; |
1422 | u8 passphrase[0]; | 1416 | u8 passphrase[0]; |
1423 | } __packed; | 1417 | } __packed; |
1424 | 1418 | ||
1425 | struct host_cmd_tlv_wep_key { | 1419 | struct host_cmd_tlv_wep_key { |
1426 | struct host_cmd_tlv tlv; | 1420 | struct mwifiex_ie_types_header header; |
1427 | u8 key_index; | 1421 | u8 key_index; |
1428 | u8 is_default; | 1422 | u8 is_default; |
1429 | u8 key[1]; | 1423 | u8 key[1]; |
1430 | }; | 1424 | }; |
1431 | 1425 | ||
1432 | struct host_cmd_tlv_auth_type { | 1426 | struct host_cmd_tlv_auth_type { |
1433 | struct host_cmd_tlv tlv; | 1427 | struct mwifiex_ie_types_header header; |
1434 | u8 auth_type; | 1428 | u8 auth_type; |
1435 | } __packed; | 1429 | } __packed; |
1436 | 1430 | ||
1437 | struct host_cmd_tlv_encrypt_protocol { | 1431 | struct host_cmd_tlv_encrypt_protocol { |
1438 | struct host_cmd_tlv tlv; | 1432 | struct mwifiex_ie_types_header header; |
1439 | __le16 proto; | 1433 | __le16 proto; |
1440 | } __packed; | 1434 | } __packed; |
1441 | 1435 | ||
1442 | struct host_cmd_tlv_ssid { | 1436 | struct host_cmd_tlv_ssid { |
1443 | struct host_cmd_tlv tlv; | 1437 | struct mwifiex_ie_types_header header; |
1444 | u8 ssid[0]; | 1438 | u8 ssid[0]; |
1445 | } __packed; | 1439 | } __packed; |
1446 | 1440 | ||
1447 | struct host_cmd_tlv_rates { | 1441 | struct host_cmd_tlv_rates { |
1448 | struct host_cmd_tlv tlv; | 1442 | struct mwifiex_ie_types_header header; |
1449 | u8 rates[0]; | 1443 | u8 rates[0]; |
1450 | } __packed; | 1444 | } __packed; |
1451 | 1445 | ||
1452 | struct host_cmd_tlv_bcast_ssid { | 1446 | struct host_cmd_tlv_bcast_ssid { |
1453 | struct host_cmd_tlv tlv; | 1447 | struct mwifiex_ie_types_header header; |
1454 | u8 bcast_ctl; | 1448 | u8 bcast_ctl; |
1455 | } __packed; | 1449 | } __packed; |
1456 | 1450 | ||
1457 | struct host_cmd_tlv_beacon_period { | 1451 | struct host_cmd_tlv_beacon_period { |
1458 | struct host_cmd_tlv tlv; | 1452 | struct mwifiex_ie_types_header header; |
1459 | __le16 period; | 1453 | __le16 period; |
1460 | } __packed; | 1454 | } __packed; |
1461 | 1455 | ||
1462 | struct host_cmd_tlv_dtim_period { | 1456 | struct host_cmd_tlv_dtim_period { |
1463 | struct host_cmd_tlv tlv; | 1457 | struct mwifiex_ie_types_header header; |
1464 | u8 period; | 1458 | u8 period; |
1465 | } __packed; | 1459 | } __packed; |
1466 | 1460 | ||
1467 | struct host_cmd_tlv_frag_threshold { | 1461 | struct host_cmd_tlv_frag_threshold { |
1468 | struct host_cmd_tlv tlv; | 1462 | struct mwifiex_ie_types_header header; |
1469 | __le16 frag_thr; | 1463 | __le16 frag_thr; |
1470 | } __packed; | 1464 | } __packed; |
1471 | 1465 | ||
1472 | struct host_cmd_tlv_rts_threshold { | 1466 | struct host_cmd_tlv_rts_threshold { |
1473 | struct host_cmd_tlv tlv; | 1467 | struct mwifiex_ie_types_header header; |
1474 | __le16 rts_thr; | 1468 | __le16 rts_thr; |
1475 | } __packed; | 1469 | } __packed; |
1476 | 1470 | ||
1477 | struct host_cmd_tlv_retry_limit { | 1471 | struct host_cmd_tlv_retry_limit { |
1478 | struct host_cmd_tlv tlv; | 1472 | struct mwifiex_ie_types_header header; |
1479 | u8 limit; | 1473 | u8 limit; |
1480 | } __packed; | 1474 | } __packed; |
1481 | 1475 | ||
1482 | struct host_cmd_tlv_mac_addr { | 1476 | struct host_cmd_tlv_mac_addr { |
1483 | struct host_cmd_tlv tlv; | 1477 | struct mwifiex_ie_types_header header; |
1484 | u8 mac_addr[ETH_ALEN]; | 1478 | u8 mac_addr[ETH_ALEN]; |
1485 | } __packed; | 1479 | } __packed; |
1486 | 1480 | ||
1487 | struct host_cmd_tlv_channel_band { | 1481 | struct host_cmd_tlv_channel_band { |
1488 | struct host_cmd_tlv tlv; | 1482 | struct mwifiex_ie_types_header header; |
1489 | u8 band_config; | 1483 | u8 band_config; |
1490 | u8 channel; | 1484 | u8 channel; |
1491 | } __packed; | 1485 | } __packed; |
1492 | 1486 | ||
1493 | struct host_cmd_tlv_ageout_timer { | 1487 | struct host_cmd_tlv_ageout_timer { |
1494 | struct host_cmd_tlv tlv; | 1488 | struct mwifiex_ie_types_header header; |
1495 | __le32 sta_ao_timer; | 1489 | __le32 sta_ao_timer; |
1496 | } __packed; | 1490 | } __packed; |
1497 | 1491 | ||
@@ -1604,6 +1598,27 @@ struct host_cmd_ds_802_11_cfg_data { | |||
1604 | __le16 data_len; | 1598 | __le16 data_len; |
1605 | } __packed; | 1599 | } __packed; |
1606 | 1600 | ||
1601 | struct coalesce_filt_field_param { | ||
1602 | u8 operation; | ||
1603 | u8 operand_len; | ||
1604 | __le16 offset; | ||
1605 | u8 operand_byte_stream[4]; | ||
1606 | }; | ||
1607 | |||
1608 | struct coalesce_receive_filt_rule { | ||
1609 | struct mwifiex_ie_types_header header; | ||
1610 | u8 num_of_fields; | ||
1611 | u8 pkt_type; | ||
1612 | __le16 max_coalescing_delay; | ||
1613 | struct coalesce_filt_field_param params[0]; | ||
1614 | } __packed; | ||
1615 | |||
1616 | struct host_cmd_ds_coalesce_cfg { | ||
1617 | __le16 action; | ||
1618 | __le16 num_of_rules; | ||
1619 | struct coalesce_receive_filt_rule rule[0]; | ||
1620 | } __packed; | ||
1621 | |||
1607 | struct host_cmd_ds_command { | 1622 | struct host_cmd_ds_command { |
1608 | __le16 command; | 1623 | __le16 command; |
1609 | __le16 size; | 1624 | __le16 size; |
@@ -1664,6 +1679,7 @@ struct host_cmd_ds_command { | |||
1664 | struct host_cmd_ds_sta_deauth sta_deauth; | 1679 | struct host_cmd_ds_sta_deauth sta_deauth; |
1665 | struct host_cmd_11ac_vht_cfg vht_cfg; | 1680 | struct host_cmd_11ac_vht_cfg vht_cfg; |
1666 | struct host_cmd_ds_802_11_cfg_data cfg_data; | 1681 | struct host_cmd_ds_802_11_cfg_data cfg_data; |
1682 | struct host_cmd_ds_coalesce_cfg coalesce_cfg; | ||
1667 | } params; | 1683 | } params; |
1668 | } __packed; | 1684 | } __packed; |
1669 | 1685 | ||
diff --git a/drivers/net/wireless/mwifiex/ie.c b/drivers/net/wireless/mwifiex/ie.c index e38342f86c51..220af4fe0fc6 100644 --- a/drivers/net/wireless/mwifiex/ie.c +++ b/drivers/net/wireless/mwifiex/ie.c | |||
@@ -87,7 +87,7 @@ mwifiex_update_autoindex_ies(struct mwifiex_private *priv, | |||
87 | u8 *tmp; | 87 | u8 *tmp; |
88 | 88 | ||
89 | input_len = le16_to_cpu(ie_list->len); | 89 | input_len = le16_to_cpu(ie_list->len); |
90 | travel_len = sizeof(struct host_cmd_tlv); | 90 | travel_len = sizeof(struct mwifiex_ie_types_header); |
91 | 91 | ||
92 | ie_list->len = 0; | 92 | ie_list->len = 0; |
93 | 93 | ||
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index caaf4bd56b30..6499117fce43 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c | |||
@@ -135,6 +135,8 @@ int mwifiex_init_priv(struct mwifiex_private *priv) | |||
135 | 135 | ||
136 | priv->csa_chan = 0; | 136 | priv->csa_chan = 0; |
137 | priv->csa_expire_time = 0; | 137 | priv->csa_expire_time = 0; |
138 | priv->del_list_idx = 0; | ||
139 | priv->hs2_enabled = false; | ||
138 | 140 | ||
139 | return mwifiex_add_bss_prio_tbl(priv); | 141 | return mwifiex_add_bss_prio_tbl(priv); |
140 | } | 142 | } |
@@ -377,18 +379,11 @@ static void mwifiex_free_lock_list(struct mwifiex_adapter *adapter) | |||
377 | static void | 379 | static void |
378 | mwifiex_adapter_cleanup(struct mwifiex_adapter *adapter) | 380 | mwifiex_adapter_cleanup(struct mwifiex_adapter *adapter) |
379 | { | 381 | { |
380 | int i; | ||
381 | |||
382 | if (!adapter) { | 382 | if (!adapter) { |
383 | pr_err("%s: adapter is NULL\n", __func__); | 383 | pr_err("%s: adapter is NULL\n", __func__); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | 386 | ||
387 | for (i = 0; i < adapter->priv_num; i++) { | ||
388 | if (adapter->priv[i]) | ||
389 | del_timer_sync(&adapter->priv[i]->scan_delay_timer); | ||
390 | } | ||
391 | |||
392 | mwifiex_cancel_all_pending_cmd(adapter); | 387 | mwifiex_cancel_all_pending_cmd(adapter); |
393 | 388 | ||
394 | /* Free lock variables */ | 389 | /* Free lock variables */ |
@@ -398,13 +393,8 @@ mwifiex_adapter_cleanup(struct mwifiex_adapter *adapter) | |||
398 | dev_dbg(adapter->dev, "info: free cmd buffer\n"); | 393 | dev_dbg(adapter->dev, "info: free cmd buffer\n"); |
399 | mwifiex_free_cmd_buffer(adapter); | 394 | mwifiex_free_cmd_buffer(adapter); |
400 | 395 | ||
401 | del_timer(&adapter->cmd_timer); | ||
402 | |||
403 | dev_dbg(adapter->dev, "info: free scan table\n"); | 396 | dev_dbg(adapter->dev, "info: free scan table\n"); |
404 | 397 | ||
405 | if (adapter->if_ops.cleanup_if) | ||
406 | adapter->if_ops.cleanup_if(adapter); | ||
407 | |||
408 | if (adapter->sleep_cfm) | 398 | if (adapter->sleep_cfm) |
409 | dev_kfree_skb_any(adapter->sleep_cfm); | 399 | dev_kfree_skb_any(adapter->sleep_cfm); |
410 | } | 400 | } |
@@ -693,7 +683,7 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, | |||
693 | if (!ret) { | 683 | if (!ret) { |
694 | dev_notice(adapter->dev, | 684 | dev_notice(adapter->dev, |
695 | "WLAN FW already running! Skip FW dnld\n"); | 685 | "WLAN FW already running! Skip FW dnld\n"); |
696 | goto done; | 686 | return 0; |
697 | } | 687 | } |
698 | 688 | ||
699 | poll_num = MAX_FIRMWARE_POLL_TRIES; | 689 | poll_num = MAX_FIRMWARE_POLL_TRIES; |
@@ -702,7 +692,6 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, | |||
702 | if (!adapter->winner) { | 692 | if (!adapter->winner) { |
703 | dev_notice(adapter->dev, | 693 | dev_notice(adapter->dev, |
704 | "FW already running! Skip FW dnld\n"); | 694 | "FW already running! Skip FW dnld\n"); |
705 | poll_num = MAX_MULTI_INTERFACE_POLL_TRIES; | ||
706 | goto poll_fw; | 695 | goto poll_fw; |
707 | } | 696 | } |
708 | } | 697 | } |
@@ -719,14 +708,8 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, | |||
719 | poll_fw: | 708 | poll_fw: |
720 | /* Check if the firmware is downloaded successfully or not */ | 709 | /* Check if the firmware is downloaded successfully or not */ |
721 | ret = adapter->if_ops.check_fw_status(adapter, poll_num); | 710 | ret = adapter->if_ops.check_fw_status(adapter, poll_num); |
722 | if (ret) { | 711 | if (ret) |
723 | dev_err(adapter->dev, "FW failed to be active in time\n"); | 712 | dev_err(adapter->dev, "FW failed to be active in time\n"); |
724 | return -1; | ||
725 | } | ||
726 | done: | ||
727 | /* re-enable host interrupt for mwifiex after fw dnld is successful */ | ||
728 | if (adapter->if_ops.enable_int) | ||
729 | adapter->if_ops.enable_int(adapter); | ||
730 | 713 | ||
731 | return ret; | 714 | return ret; |
732 | } | 715 | } |
diff --git a/drivers/net/wireless/mwifiex/ioctl.h b/drivers/net/wireless/mwifiex/ioctl.h index 7f27e45680b5..00a95f4c6a6c 100644 --- a/drivers/net/wireless/mwifiex/ioctl.h +++ b/drivers/net/wireless/mwifiex/ioctl.h | |||
@@ -362,13 +362,13 @@ struct mwifiex_ds_misc_subsc_evt { | |||
362 | struct subsc_evt_cfg bcn_h_rssi_cfg; | 362 | struct subsc_evt_cfg bcn_h_rssi_cfg; |
363 | }; | 363 | }; |
364 | 364 | ||
365 | #define MAX_BYTESEQ 6 /* non-adjustable */ | 365 | #define MWIFIEX_MEF_MAX_BYTESEQ 6 /* non-adjustable */ |
366 | #define MWIFIEX_MAX_FILTERS 10 | 366 | #define MWIFIEX_MEF_MAX_FILTERS 10 |
367 | 367 | ||
368 | struct mwifiex_mef_filter { | 368 | struct mwifiex_mef_filter { |
369 | u16 repeat; | 369 | u16 repeat; |
370 | u16 offset; | 370 | u16 offset; |
371 | s8 byte_seq[MAX_BYTESEQ + 1]; | 371 | s8 byte_seq[MWIFIEX_MEF_MAX_BYTESEQ + 1]; |
372 | u8 filt_type; | 372 | u8 filt_type; |
373 | u8 filt_action; | 373 | u8 filt_action; |
374 | }; | 374 | }; |
@@ -376,7 +376,7 @@ struct mwifiex_mef_filter { | |||
376 | struct mwifiex_mef_entry { | 376 | struct mwifiex_mef_entry { |
377 | u8 mode; | 377 | u8 mode; |
378 | u8 action; | 378 | u8 action; |
379 | struct mwifiex_mef_filter filter[MWIFIEX_MAX_FILTERS]; | 379 | struct mwifiex_mef_filter filter[MWIFIEX_MEF_MAX_FILTERS]; |
380 | }; | 380 | }; |
381 | 381 | ||
382 | struct mwifiex_ds_mef_cfg { | 382 | struct mwifiex_ds_mef_cfg { |
@@ -397,4 +397,39 @@ enum { | |||
397 | MWIFIEX_FUNC_SHUTDOWN, | 397 | MWIFIEX_FUNC_SHUTDOWN, |
398 | }; | 398 | }; |
399 | 399 | ||
400 | enum COALESCE_OPERATION { | ||
401 | RECV_FILTER_MATCH_TYPE_EQ = 0x80, | ||
402 | RECV_FILTER_MATCH_TYPE_NE, | ||
403 | }; | ||
404 | |||
405 | enum COALESCE_PACKET_TYPE { | ||
406 | PACKET_TYPE_UNICAST = 1, | ||
407 | PACKET_TYPE_MULTICAST = 2, | ||
408 | PACKET_TYPE_BROADCAST = 3 | ||
409 | }; | ||
410 | |||
411 | #define MWIFIEX_COALESCE_MAX_RULES 8 | ||
412 | #define MWIFIEX_COALESCE_MAX_BYTESEQ 4 /* non-adjustable */ | ||
413 | #define MWIFIEX_COALESCE_MAX_FILTERS 4 | ||
414 | #define MWIFIEX_MAX_COALESCING_DELAY 100 /* in msecs */ | ||
415 | |||
416 | struct filt_field_param { | ||
417 | u8 operation; | ||
418 | u8 operand_len; | ||
419 | u16 offset; | ||
420 | u8 operand_byte_stream[MWIFIEX_COALESCE_MAX_BYTESEQ]; | ||
421 | }; | ||
422 | |||
423 | struct mwifiex_coalesce_rule { | ||
424 | u16 max_coalescing_delay; | ||
425 | u8 num_of_fields; | ||
426 | u8 pkt_type; | ||
427 | struct filt_field_param params[MWIFIEX_COALESCE_MAX_FILTERS]; | ||
428 | }; | ||
429 | |||
430 | struct mwifiex_ds_coalesce_cfg { | ||
431 | u16 num_of_rules; | ||
432 | struct mwifiex_coalesce_rule rule[MWIFIEX_COALESCE_MAX_RULES]; | ||
433 | }; | ||
434 | |||
400 | #endif /* !_MWIFIEX_IOCTL_H_ */ | 435 | #endif /* !_MWIFIEX_IOCTL_H_ */ |
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 1c8a771e8e81..9d7c0e6c4fc7 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c | |||
@@ -1291,8 +1291,10 @@ int mwifiex_associate(struct mwifiex_private *priv, | |||
1291 | { | 1291 | { |
1292 | u8 current_bssid[ETH_ALEN]; | 1292 | u8 current_bssid[ETH_ALEN]; |
1293 | 1293 | ||
1294 | /* Return error if the adapter or table entry is not marked as infra */ | 1294 | /* Return error if the adapter is not STA role or table entry |
1295 | if ((priv->bss_mode != NL80211_IFTYPE_STATION) || | 1295 | * is not marked as infra. |
1296 | */ | ||
1297 | if ((GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) || | ||
1296 | (bss_desc->bss_mode != NL80211_IFTYPE_STATION)) | 1298 | (bss_desc->bss_mode != NL80211_IFTYPE_STATION)) |
1297 | return -1; | 1299 | return -1; |
1298 | 1300 | ||
@@ -1425,6 +1427,7 @@ int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac) | |||
1425 | 1427 | ||
1426 | switch (priv->bss_mode) { | 1428 | switch (priv->bss_mode) { |
1427 | case NL80211_IFTYPE_STATION: | 1429 | case NL80211_IFTYPE_STATION: |
1430 | case NL80211_IFTYPE_P2P_CLIENT: | ||
1428 | return mwifiex_deauthenticate_infra(priv, mac); | 1431 | return mwifiex_deauthenticate_infra(priv, mac); |
1429 | case NL80211_IFTYPE_ADHOC: | 1432 | case NL80211_IFTYPE_ADHOC: |
1430 | return mwifiex_send_cmd_sync(priv, | 1433 | return mwifiex_send_cmd_sync(priv, |
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index e15ab72fb03d..fd778337deee 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c | |||
@@ -191,12 +191,16 @@ static int mwifiex_unregister(struct mwifiex_adapter *adapter) | |||
191 | { | 191 | { |
192 | s32 i; | 192 | s32 i; |
193 | 193 | ||
194 | if (adapter->if_ops.cleanup_if) | ||
195 | adapter->if_ops.cleanup_if(adapter); | ||
196 | |||
194 | del_timer(&adapter->cmd_timer); | 197 | del_timer(&adapter->cmd_timer); |
195 | 198 | ||
196 | /* Free private structures */ | 199 | /* Free private structures */ |
197 | for (i = 0; i < adapter->priv_num; i++) { | 200 | for (i = 0; i < adapter->priv_num; i++) { |
198 | if (adapter->priv[i]) { | 201 | if (adapter->priv[i]) { |
199 | mwifiex_free_curr_bcn(adapter->priv[i]); | 202 | mwifiex_free_curr_bcn(adapter->priv[i]); |
203 | del_timer_sync(&adapter->priv[i]->scan_delay_timer); | ||
200 | kfree(adapter->priv[i]); | 204 | kfree(adapter->priv[i]); |
201 | } | 205 | } |
202 | } | 206 | } |
@@ -386,6 +390,17 @@ static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) | |||
386 | } | 390 | } |
387 | 391 | ||
388 | /* | 392 | /* |
393 | * This function cancels all works in the queue and destroys | ||
394 | * the main workqueue. | ||
395 | */ | ||
396 | static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) | ||
397 | { | ||
398 | flush_workqueue(adapter->workqueue); | ||
399 | destroy_workqueue(adapter->workqueue); | ||
400 | adapter->workqueue = NULL; | ||
401 | } | ||
402 | |||
403 | /* | ||
389 | * This function gets firmware and initializes it. | 404 | * This function gets firmware and initializes it. |
390 | * | 405 | * |
391 | * The main initialization steps followed are - | 406 | * The main initialization steps followed are - |
@@ -394,16 +409,18 @@ static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) | |||
394 | */ | 409 | */ |
395 | static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | 410 | static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) |
396 | { | 411 | { |
397 | int ret; | 412 | int ret, i; |
398 | char fmt[64]; | 413 | char fmt[64]; |
399 | struct mwifiex_private *priv; | 414 | struct mwifiex_private *priv; |
400 | struct mwifiex_adapter *adapter = context; | 415 | struct mwifiex_adapter *adapter = context; |
401 | struct mwifiex_fw_image fw; | 416 | struct mwifiex_fw_image fw; |
417 | struct semaphore *sem = adapter->card_sem; | ||
418 | bool init_failed = false; | ||
402 | 419 | ||
403 | if (!firmware) { | 420 | if (!firmware) { |
404 | dev_err(adapter->dev, | 421 | dev_err(adapter->dev, |
405 | "Failed to get firmware %s\n", adapter->fw_name); | 422 | "Failed to get firmware %s\n", adapter->fw_name); |
406 | goto done; | 423 | goto err_dnld_fw; |
407 | } | 424 | } |
408 | 425 | ||
409 | memset(&fw, 0, sizeof(struct mwifiex_fw_image)); | 426 | memset(&fw, 0, sizeof(struct mwifiex_fw_image)); |
@@ -416,7 +433,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | |||
416 | else | 433 | else |
417 | ret = mwifiex_dnld_fw(adapter, &fw); | 434 | ret = mwifiex_dnld_fw(adapter, &fw); |
418 | if (ret == -1) | 435 | if (ret == -1) |
419 | goto done; | 436 | goto err_dnld_fw; |
420 | 437 | ||
421 | dev_notice(adapter->dev, "WLAN FW is active\n"); | 438 | dev_notice(adapter->dev, "WLAN FW is active\n"); |
422 | 439 | ||
@@ -427,10 +444,16 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | |||
427 | "Cal data request_firmware() failed\n"); | 444 | "Cal data request_firmware() failed\n"); |
428 | } | 445 | } |
429 | 446 | ||
447 | /* enable host interrupt after fw dnld is successful */ | ||
448 | if (adapter->if_ops.enable_int) { | ||
449 | if (adapter->if_ops.enable_int(adapter)) | ||
450 | goto err_dnld_fw; | ||
451 | } | ||
452 | |||
430 | adapter->init_wait_q_woken = false; | 453 | adapter->init_wait_q_woken = false; |
431 | ret = mwifiex_init_fw(adapter); | 454 | ret = mwifiex_init_fw(adapter); |
432 | if (ret == -1) { | 455 | if (ret == -1) { |
433 | goto done; | 456 | goto err_init_fw; |
434 | } else if (!ret) { | 457 | } else if (!ret) { |
435 | adapter->hw_status = MWIFIEX_HW_STATUS_READY; | 458 | adapter->hw_status = MWIFIEX_HW_STATUS_READY; |
436 | goto done; | 459 | goto done; |
@@ -439,12 +462,12 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | |||
439 | wait_event_interruptible(adapter->init_wait_q, | 462 | wait_event_interruptible(adapter->init_wait_q, |
440 | adapter->init_wait_q_woken); | 463 | adapter->init_wait_q_woken); |
441 | if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) | 464 | if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) |
442 | goto done; | 465 | goto err_init_fw; |
443 | 466 | ||
444 | priv = adapter->priv[MWIFIEX_BSS_ROLE_STA]; | 467 | priv = adapter->priv[MWIFIEX_BSS_ROLE_STA]; |
445 | if (mwifiex_register_cfg80211(adapter)) { | 468 | if (mwifiex_register_cfg80211(adapter)) { |
446 | dev_err(adapter->dev, "cannot register with cfg80211\n"); | 469 | dev_err(adapter->dev, "cannot register with cfg80211\n"); |
447 | goto err_init_fw; | 470 | goto err_register_cfg80211; |
448 | } | 471 | } |
449 | 472 | ||
450 | rtnl_lock(); | 473 | rtnl_lock(); |
@@ -454,20 +477,6 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | |||
454 | dev_err(adapter->dev, "cannot create default STA interface\n"); | 477 | dev_err(adapter->dev, "cannot create default STA interface\n"); |
455 | goto err_add_intf; | 478 | goto err_add_intf; |
456 | } | 479 | } |
457 | |||
458 | /* Create AP interface by default */ | ||
459 | if (!mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", | ||
460 | NL80211_IFTYPE_AP, NULL, NULL)) { | ||
461 | dev_err(adapter->dev, "cannot create default AP interface\n"); | ||
462 | goto err_add_intf; | ||
463 | } | ||
464 | |||
465 | /* Create P2P interface by default */ | ||
466 | if (!mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", | ||
467 | NL80211_IFTYPE_P2P_CLIENT, NULL, NULL)) { | ||
468 | dev_err(adapter->dev, "cannot create default P2P interface\n"); | ||
469 | goto err_add_intf; | ||
470 | } | ||
471 | rtnl_unlock(); | 480 | rtnl_unlock(); |
472 | 481 | ||
473 | mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); | 482 | mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); |
@@ -475,18 +484,52 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | |||
475 | goto done; | 484 | goto done; |
476 | 485 | ||
477 | err_add_intf: | 486 | err_add_intf: |
478 | mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); | 487 | for (i = 0; i < adapter->priv_num; i++) { |
488 | priv = adapter->priv[i]; | ||
489 | |||
490 | if (!priv) | ||
491 | continue; | ||
492 | |||
493 | if (priv->wdev && priv->netdev) | ||
494 | mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); | ||
495 | } | ||
479 | rtnl_unlock(); | 496 | rtnl_unlock(); |
497 | err_register_cfg80211: | ||
498 | wiphy_unregister(adapter->wiphy); | ||
499 | wiphy_free(adapter->wiphy); | ||
480 | err_init_fw: | 500 | err_init_fw: |
501 | if (adapter->if_ops.disable_int) | ||
502 | adapter->if_ops.disable_int(adapter); | ||
503 | err_dnld_fw: | ||
481 | pr_debug("info: %s: unregister device\n", __func__); | 504 | pr_debug("info: %s: unregister device\n", __func__); |
482 | adapter->if_ops.unregister_dev(adapter); | 505 | if (adapter->if_ops.unregister_dev) |
506 | adapter->if_ops.unregister_dev(adapter); | ||
507 | |||
508 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_FW_READY) || | ||
509 | (adapter->hw_status == MWIFIEX_HW_STATUS_READY)) { | ||
510 | pr_debug("info: %s: shutdown mwifiex\n", __func__); | ||
511 | adapter->init_wait_q_woken = false; | ||
512 | |||
513 | if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS) | ||
514 | wait_event_interruptible(adapter->init_wait_q, | ||
515 | adapter->init_wait_q_woken); | ||
516 | } | ||
517 | adapter->surprise_removed = true; | ||
518 | mwifiex_terminate_workqueue(adapter); | ||
519 | init_failed = true; | ||
483 | done: | 520 | done: |
484 | if (adapter->cal_data) { | 521 | if (adapter->cal_data) { |
485 | release_firmware(adapter->cal_data); | 522 | release_firmware(adapter->cal_data); |
486 | adapter->cal_data = NULL; | 523 | adapter->cal_data = NULL; |
487 | } | 524 | } |
488 | release_firmware(adapter->firmware); | 525 | if (adapter->firmware) { |
526 | release_firmware(adapter->firmware); | ||
527 | adapter->firmware = NULL; | ||
528 | } | ||
489 | complete(&adapter->fw_load); | 529 | complete(&adapter->fw_load); |
530 | if (init_failed) | ||
531 | mwifiex_free_adapter(adapter); | ||
532 | up(sem); | ||
490 | return; | 533 | return; |
491 | } | 534 | } |
492 | 535 | ||
@@ -797,18 +840,6 @@ static void mwifiex_main_work_queue(struct work_struct *work) | |||
797 | } | 840 | } |
798 | 841 | ||
799 | /* | 842 | /* |
800 | * This function cancels all works in the queue and destroys | ||
801 | * the main workqueue. | ||
802 | */ | ||
803 | static void | ||
804 | mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) | ||
805 | { | ||
806 | flush_workqueue(adapter->workqueue); | ||
807 | destroy_workqueue(adapter->workqueue); | ||
808 | adapter->workqueue = NULL; | ||
809 | } | ||
810 | |||
811 | /* | ||
812 | * This function adds the card. | 843 | * This function adds the card. |
813 | * | 844 | * |
814 | * This function follows the following major steps to set up the device - | 845 | * This function follows the following major steps to set up the device - |
@@ -836,6 +867,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, | |||
836 | } | 867 | } |
837 | 868 | ||
838 | adapter->iface_type = iface_type; | 869 | adapter->iface_type = iface_type; |
870 | adapter->card_sem = sem; | ||
839 | 871 | ||
840 | adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; | 872 | adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; |
841 | adapter->surprise_removed = false; | 873 | adapter->surprise_removed = false; |
@@ -855,7 +887,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, | |||
855 | INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); | 887 | INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); |
856 | 888 | ||
857 | /* Register the device. Fill up the private data structure with relevant | 889 | /* Register the device. Fill up the private data structure with relevant |
858 | information from the card and request for the required IRQ. */ | 890 | information from the card. */ |
859 | if (adapter->if_ops.register_dev(adapter)) { | 891 | if (adapter->if_ops.register_dev(adapter)) { |
860 | pr_err("%s: failed to register mwifiex device\n", __func__); | 892 | pr_err("%s: failed to register mwifiex device\n", __func__); |
861 | goto err_registerdev; | 893 | goto err_registerdev; |
@@ -866,17 +898,12 @@ mwifiex_add_card(void *card, struct semaphore *sem, | |||
866 | goto err_init_fw; | 898 | goto err_init_fw; |
867 | } | 899 | } |
868 | 900 | ||
869 | up(sem); | ||
870 | return 0; | 901 | return 0; |
871 | 902 | ||
872 | err_init_fw: | 903 | err_init_fw: |
873 | pr_debug("info: %s: unregister device\n", __func__); | 904 | pr_debug("info: %s: unregister device\n", __func__); |
874 | if (adapter->if_ops.unregister_dev) | 905 | if (adapter->if_ops.unregister_dev) |
875 | adapter->if_ops.unregister_dev(adapter); | 906 | adapter->if_ops.unregister_dev(adapter); |
876 | err_registerdev: | ||
877 | adapter->surprise_removed = true; | ||
878 | mwifiex_terminate_workqueue(adapter); | ||
879 | err_kmalloc: | ||
880 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_FW_READY) || | 907 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_FW_READY) || |
881 | (adapter->hw_status == MWIFIEX_HW_STATUS_READY)) { | 908 | (adapter->hw_status == MWIFIEX_HW_STATUS_READY)) { |
882 | pr_debug("info: %s: shutdown mwifiex\n", __func__); | 909 | pr_debug("info: %s: shutdown mwifiex\n", __func__); |
@@ -886,7 +913,10 @@ err_kmalloc: | |||
886 | wait_event_interruptible(adapter->init_wait_q, | 913 | wait_event_interruptible(adapter->init_wait_q, |
887 | adapter->init_wait_q_woken); | 914 | adapter->init_wait_q_woken); |
888 | } | 915 | } |
889 | 916 | err_registerdev: | |
917 | adapter->surprise_removed = true; | ||
918 | mwifiex_terminate_workqueue(adapter); | ||
919 | err_kmalloc: | ||
890 | mwifiex_free_adapter(adapter); | 920 | mwifiex_free_adapter(adapter); |
891 | 921 | ||
892 | err_init_sw: | 922 | err_init_sw: |
@@ -919,6 +949,11 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) | |||
919 | if (!adapter) | 949 | if (!adapter) |
920 | goto exit_remove; | 950 | goto exit_remove; |
921 | 951 | ||
952 | /* We can no longer handle interrupts once we start doing the teardown | ||
953 | * below. */ | ||
954 | if (adapter->if_ops.disable_int) | ||
955 | adapter->if_ops.disable_int(adapter); | ||
956 | |||
922 | adapter->surprise_removed = true; | 957 | adapter->surprise_removed = true; |
923 | 958 | ||
924 | /* Stop data */ | 959 | /* Stop data */ |
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 3da73d36acdf..1d72f13adb9d 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h | |||
@@ -204,11 +204,11 @@ struct mwifiex_ra_list_tbl { | |||
204 | struct list_head list; | 204 | struct list_head list; |
205 | struct sk_buff_head skb_head; | 205 | struct sk_buff_head skb_head; |
206 | u8 ra[ETH_ALEN]; | 206 | u8 ra[ETH_ALEN]; |
207 | u32 total_pkts_size; | ||
208 | u32 is_11n_enabled; | 207 | u32 is_11n_enabled; |
209 | u16 max_amsdu; | 208 | u16 max_amsdu; |
210 | u16 pkt_count; | 209 | u16 ba_pkt_count; |
211 | u8 ba_packet_thr; | 210 | u8 ba_packet_thr; |
211 | u16 total_pkt_count; | ||
212 | }; | 212 | }; |
213 | 213 | ||
214 | struct mwifiex_tid_tbl { | 214 | struct mwifiex_tid_tbl { |
@@ -515,6 +515,8 @@ struct mwifiex_private { | |||
515 | bool scan_aborting; | 515 | bool scan_aborting; |
516 | u8 csa_chan; | 516 | u8 csa_chan; |
517 | unsigned long csa_expire_time; | 517 | unsigned long csa_expire_time; |
518 | u8 del_list_idx; | ||
519 | bool hs2_enabled; | ||
518 | }; | 520 | }; |
519 | 521 | ||
520 | enum mwifiex_ba_status { | 522 | enum mwifiex_ba_status { |
@@ -601,6 +603,7 @@ struct mwifiex_if_ops { | |||
601 | int (*register_dev) (struct mwifiex_adapter *); | 603 | int (*register_dev) (struct mwifiex_adapter *); |
602 | void (*unregister_dev) (struct mwifiex_adapter *); | 604 | void (*unregister_dev) (struct mwifiex_adapter *); |
603 | int (*enable_int) (struct mwifiex_adapter *); | 605 | int (*enable_int) (struct mwifiex_adapter *); |
606 | void (*disable_int) (struct mwifiex_adapter *); | ||
604 | int (*process_int_status) (struct mwifiex_adapter *); | 607 | int (*process_int_status) (struct mwifiex_adapter *); |
605 | int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *, | 608 | int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *, |
606 | struct mwifiex_tx_param *); | 609 | struct mwifiex_tx_param *); |
@@ -747,6 +750,7 @@ struct mwifiex_adapter { | |||
747 | 750 | ||
748 | atomic_t is_tx_received; | 751 | atomic_t is_tx_received; |
749 | atomic_t pending_bridged_pkts; | 752 | atomic_t pending_bridged_pkts; |
753 | struct semaphore *card_sem; | ||
750 | }; | 754 | }; |
751 | 755 | ||
752 | int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); | 756 | int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); |
@@ -899,6 +903,8 @@ int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask, | |||
899 | u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, | 903 | u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, |
900 | u8 *rates); | 904 | u8 *rates); |
901 | u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates); | 905 | u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates); |
906 | u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv, | ||
907 | u8 *rates, u8 radio_type); | ||
902 | u8 mwifiex_is_rate_auto(struct mwifiex_private *priv); | 908 | u8 mwifiex_is_rate_auto(struct mwifiex_private *priv); |
903 | extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE]; | 909 | extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE]; |
904 | void mwifiex_save_curr_bcn(struct mwifiex_private *priv); | 910 | void mwifiex_save_curr_bcn(struct mwifiex_private *priv); |
@@ -1020,7 +1026,7 @@ mwifiex_netdev_get_priv(struct net_device *dev) | |||
1020 | */ | 1026 | */ |
1021 | static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb) | 1027 | static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb) |
1022 | { | 1028 | { |
1023 | return (*(u32 *)skb->data == PKT_TYPE_MGMT); | 1029 | return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT); |
1024 | } | 1030 | } |
1025 | 1031 | ||
1026 | /* This function retrieves channel closed for operation by Channel | 1032 | /* This function retrieves channel closed for operation by Channel |
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 20c9c4c7b0b2..52da8ee7599a 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c | |||
@@ -76,7 +76,7 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) | |||
76 | return false; | 76 | return false; |
77 | } | 77 | } |
78 | 78 | ||
79 | #ifdef CONFIG_PM | 79 | #ifdef CONFIG_PM_SLEEP |
80 | /* | 80 | /* |
81 | * Kernel needs to suspend all functions separately. Therefore all | 81 | * Kernel needs to suspend all functions separately. Therefore all |
82 | * registered functions must have drivers with suspend and resume | 82 | * registered functions must have drivers with suspend and resume |
@@ -85,11 +85,12 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) | |||
85 | * If already not suspended, this function allocates and sends a host | 85 | * If already not suspended, this function allocates and sends a host |
86 | * sleep activate request to the firmware and turns off the traffic. | 86 | * sleep activate request to the firmware and turns off the traffic. |
87 | */ | 87 | */ |
88 | static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state) | 88 | static int mwifiex_pcie_suspend(struct device *dev) |
89 | { | 89 | { |
90 | struct mwifiex_adapter *adapter; | 90 | struct mwifiex_adapter *adapter; |
91 | struct pcie_service_card *card; | 91 | struct pcie_service_card *card; |
92 | int hs_actived; | 92 | int hs_actived; |
93 | struct pci_dev *pdev = to_pci_dev(dev); | ||
93 | 94 | ||
94 | if (pdev) { | 95 | if (pdev) { |
95 | card = (struct pcie_service_card *) pci_get_drvdata(pdev); | 96 | card = (struct pcie_service_card *) pci_get_drvdata(pdev); |
@@ -120,10 +121,11 @@ static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state) | |||
120 | * If already not resumed, this function turns on the traffic and | 121 | * If already not resumed, this function turns on the traffic and |
121 | * sends a host sleep cancel request to the firmware. | 122 | * sends a host sleep cancel request to the firmware. |
122 | */ | 123 | */ |
123 | static int mwifiex_pcie_resume(struct pci_dev *pdev) | 124 | static int mwifiex_pcie_resume(struct device *dev) |
124 | { | 125 | { |
125 | struct mwifiex_adapter *adapter; | 126 | struct mwifiex_adapter *adapter; |
126 | struct pcie_service_card *card; | 127 | struct pcie_service_card *card; |
128 | struct pci_dev *pdev = to_pci_dev(dev); | ||
127 | 129 | ||
128 | if (pdev) { | 130 | if (pdev) { |
129 | card = (struct pcie_service_card *) pci_get_drvdata(pdev); | 131 | card = (struct pcie_service_card *) pci_get_drvdata(pdev); |
@@ -211,9 +213,9 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) | |||
211 | wait_for_completion(&adapter->fw_load); | 213 | wait_for_completion(&adapter->fw_load); |
212 | 214 | ||
213 | if (user_rmmod) { | 215 | if (user_rmmod) { |
214 | #ifdef CONFIG_PM | 216 | #ifdef CONFIG_PM_SLEEP |
215 | if (adapter->is_suspended) | 217 | if (adapter->is_suspended) |
216 | mwifiex_pcie_resume(pdev); | 218 | mwifiex_pcie_resume(&pdev->dev); |
217 | #endif | 219 | #endif |
218 | 220 | ||
219 | for (i = 0; i < adapter->priv_num; i++) | 221 | for (i = 0; i < adapter->priv_num; i++) |
@@ -233,6 +235,14 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) | |||
233 | kfree(card); | 235 | kfree(card); |
234 | } | 236 | } |
235 | 237 | ||
238 | static void mwifiex_pcie_shutdown(struct pci_dev *pdev) | ||
239 | { | ||
240 | user_rmmod = 1; | ||
241 | mwifiex_pcie_remove(pdev); | ||
242 | |||
243 | return; | ||
244 | } | ||
245 | |||
236 | static DEFINE_PCI_DEVICE_TABLE(mwifiex_ids) = { | 246 | static DEFINE_PCI_DEVICE_TABLE(mwifiex_ids) = { |
237 | { | 247 | { |
238 | PCIE_VENDOR_ID_MARVELL, PCIE_DEVICE_ID_MARVELL_88W8766P, | 248 | PCIE_VENDOR_ID_MARVELL, PCIE_DEVICE_ID_MARVELL_88W8766P, |
@@ -249,17 +259,24 @@ static DEFINE_PCI_DEVICE_TABLE(mwifiex_ids) = { | |||
249 | 259 | ||
250 | MODULE_DEVICE_TABLE(pci, mwifiex_ids); | 260 | MODULE_DEVICE_TABLE(pci, mwifiex_ids); |
251 | 261 | ||
262 | #ifdef CONFIG_PM_SLEEP | ||
263 | /* Power Management Hooks */ | ||
264 | static SIMPLE_DEV_PM_OPS(mwifiex_pcie_pm_ops, mwifiex_pcie_suspend, | ||
265 | mwifiex_pcie_resume); | ||
266 | #endif | ||
267 | |||
252 | /* PCI Device Driver */ | 268 | /* PCI Device Driver */ |
253 | static struct pci_driver __refdata mwifiex_pcie = { | 269 | static struct pci_driver __refdata mwifiex_pcie = { |
254 | .name = "mwifiex_pcie", | 270 | .name = "mwifiex_pcie", |
255 | .id_table = mwifiex_ids, | 271 | .id_table = mwifiex_ids, |
256 | .probe = mwifiex_pcie_probe, | 272 | .probe = mwifiex_pcie_probe, |
257 | .remove = mwifiex_pcie_remove, | 273 | .remove = mwifiex_pcie_remove, |
258 | #ifdef CONFIG_PM | 274 | #ifdef CONFIG_PM_SLEEP |
259 | /* Power Management Hooks */ | 275 | .driver = { |
260 | .suspend = mwifiex_pcie_suspend, | 276 | .pm = &mwifiex_pcie_pm_ops, |
261 | .resume = mwifiex_pcie_resume, | 277 | }, |
262 | #endif | 278 | #endif |
279 | .shutdown = mwifiex_pcie_shutdown, | ||
263 | }; | 280 | }; |
264 | 281 | ||
265 | /* | 282 | /* |
@@ -1925,7 +1942,7 @@ mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) | |||
1925 | ret = 0; | 1942 | ret = 0; |
1926 | break; | 1943 | break; |
1927 | } else { | 1944 | } else { |
1928 | mdelay(100); | 1945 | msleep(100); |
1929 | ret = -1; | 1946 | ret = -1; |
1930 | } | 1947 | } |
1931 | } | 1948 | } |
@@ -1937,12 +1954,10 @@ mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) | |||
1937 | else if (!winner_status) { | 1954 | else if (!winner_status) { |
1938 | dev_err(adapter->dev, "PCI-E is the winner\n"); | 1955 | dev_err(adapter->dev, "PCI-E is the winner\n"); |
1939 | adapter->winner = 1; | 1956 | adapter->winner = 1; |
1940 | ret = -1; | ||
1941 | } else { | 1957 | } else { |
1942 | dev_err(adapter->dev, | 1958 | dev_err(adapter->dev, |
1943 | "PCI-E is not the winner <%#x,%d>, exit dnld\n", | 1959 | "PCI-E is not the winner <%#x,%d>, exit dnld\n", |
1944 | ret, adapter->winner); | 1960 | ret, adapter->winner); |
1945 | ret = 0; | ||
1946 | } | 1961 | } |
1947 | } | 1962 | } |
1948 | 1963 | ||
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index c447d9bd1aa9..8cf7d50a7603 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c | |||
@@ -543,6 +543,37 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv, | |||
543 | return chan_idx; | 543 | return chan_idx; |
544 | } | 544 | } |
545 | 545 | ||
546 | /* This function appends rate TLV to scan config command. */ | ||
547 | static int | ||
548 | mwifiex_append_rate_tlv(struct mwifiex_private *priv, | ||
549 | struct mwifiex_scan_cmd_config *scan_cfg_out, | ||
550 | u8 radio) | ||
551 | { | ||
552 | struct mwifiex_ie_types_rates_param_set *rates_tlv; | ||
553 | u8 rates[MWIFIEX_SUPPORTED_RATES], *tlv_pos; | ||
554 | u32 rates_size; | ||
555 | |||
556 | memset(rates, 0, sizeof(rates)); | ||
557 | |||
558 | tlv_pos = (u8 *)scan_cfg_out->tlv_buf + scan_cfg_out->tlv_buf_len; | ||
559 | |||
560 | if (priv->scan_request) | ||
561 | rates_size = mwifiex_get_rates_from_cfg80211(priv, rates, | ||
562 | radio); | ||
563 | else | ||
564 | rates_size = mwifiex_get_supported_rates(priv, rates); | ||
565 | |||
566 | dev_dbg(priv->adapter->dev, "info: SCAN_CMD: Rates size = %d\n", | ||
567 | rates_size); | ||
568 | rates_tlv = (struct mwifiex_ie_types_rates_param_set *)tlv_pos; | ||
569 | rates_tlv->header.type = cpu_to_le16(WLAN_EID_SUPP_RATES); | ||
570 | rates_tlv->header.len = cpu_to_le16((u16) rates_size); | ||
571 | memcpy(rates_tlv->rates, rates, rates_size); | ||
572 | scan_cfg_out->tlv_buf_len += sizeof(rates_tlv->header) + rates_size; | ||
573 | |||
574 | return rates_size; | ||
575 | } | ||
576 | |||
546 | /* | 577 | /* |
547 | * This function constructs and sends multiple scan config commands to | 578 | * This function constructs and sends multiple scan config commands to |
548 | * the firmware. | 579 | * the firmware. |
@@ -564,9 +595,10 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, | |||
564 | struct mwifiex_chan_scan_param_set *tmp_chan_list; | 595 | struct mwifiex_chan_scan_param_set *tmp_chan_list; |
565 | struct mwifiex_chan_scan_param_set *start_chan; | 596 | struct mwifiex_chan_scan_param_set *start_chan; |
566 | 597 | ||
567 | u32 tlv_idx; | 598 | u32 tlv_idx, rates_size; |
568 | u32 total_scan_time; | 599 | u32 total_scan_time; |
569 | u32 done_early; | 600 | u32 done_early; |
601 | u8 radio_type; | ||
570 | 602 | ||
571 | if (!scan_cfg_out || !chan_tlv_out || !scan_chan_list) { | 603 | if (!scan_cfg_out || !chan_tlv_out || !scan_chan_list) { |
572 | dev_dbg(priv->adapter->dev, | 604 | dev_dbg(priv->adapter->dev, |
@@ -591,6 +623,7 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, | |||
591 | 623 | ||
592 | tlv_idx = 0; | 624 | tlv_idx = 0; |
593 | total_scan_time = 0; | 625 | total_scan_time = 0; |
626 | radio_type = 0; | ||
594 | chan_tlv_out->header.len = 0; | 627 | chan_tlv_out->header.len = 0; |
595 | start_chan = tmp_chan_list; | 628 | start_chan = tmp_chan_list; |
596 | done_early = false; | 629 | done_early = false; |
@@ -612,6 +645,7 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, | |||
612 | continue; | 645 | continue; |
613 | } | 646 | } |
614 | 647 | ||
648 | radio_type = tmp_chan_list->radio_type; | ||
615 | dev_dbg(priv->adapter->dev, | 649 | dev_dbg(priv->adapter->dev, |
616 | "info: Scan: Chan(%3d), Radio(%d)," | 650 | "info: Scan: Chan(%3d), Radio(%d)," |
617 | " Mode(%d, %d), Dur(%d)\n", | 651 | " Mode(%d, %d), Dur(%d)\n", |
@@ -692,6 +726,9 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, | |||
692 | break; | 726 | break; |
693 | } | 727 | } |
694 | 728 | ||
729 | rates_size = mwifiex_append_rate_tlv(priv, scan_cfg_out, | ||
730 | radio_type); | ||
731 | |||
695 | priv->adapter->scan_channels = start_chan; | 732 | priv->adapter->scan_channels = start_chan; |
696 | 733 | ||
697 | /* Send the scan command to the firmware with the specified | 734 | /* Send the scan command to the firmware with the specified |
@@ -699,6 +736,14 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, | |||
699 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SCAN, | 736 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SCAN, |
700 | HostCmd_ACT_GEN_SET, 0, | 737 | HostCmd_ACT_GEN_SET, 0, |
701 | scan_cfg_out); | 738 | scan_cfg_out); |
739 | |||
740 | /* rate IE is updated per scan command but same starting | ||
741 | * pointer is used each time so that rate IE from earlier | ||
742 | * scan_cfg_out->buf is overwritten with new one. | ||
743 | */ | ||
744 | scan_cfg_out->tlv_buf_len -= | ||
745 | sizeof(struct mwifiex_ie_types_header) + rates_size; | ||
746 | |||
702 | if (ret) | 747 | if (ret) |
703 | break; | 748 | break; |
704 | } | 749 | } |
@@ -741,7 +786,6 @@ mwifiex_config_scan(struct mwifiex_private *priv, | |||
741 | struct mwifiex_adapter *adapter = priv->adapter; | 786 | struct mwifiex_adapter *adapter = priv->adapter; |
742 | struct mwifiex_ie_types_num_probes *num_probes_tlv; | 787 | struct mwifiex_ie_types_num_probes *num_probes_tlv; |
743 | struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv; | 788 | struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv; |
744 | struct mwifiex_ie_types_rates_param_set *rates_tlv; | ||
745 | u8 *tlv_pos; | 789 | u8 *tlv_pos; |
746 | u32 num_probes; | 790 | u32 num_probes; |
747 | u32 ssid_len; | 791 | u32 ssid_len; |
@@ -753,8 +797,6 @@ mwifiex_config_scan(struct mwifiex_private *priv, | |||
753 | u8 radio_type; | 797 | u8 radio_type; |
754 | int i; | 798 | int i; |
755 | u8 ssid_filter; | 799 | u8 ssid_filter; |
756 | u8 rates[MWIFIEX_SUPPORTED_RATES]; | ||
757 | u32 rates_size; | ||
758 | struct mwifiex_ie_types_htcap *ht_cap; | 800 | struct mwifiex_ie_types_htcap *ht_cap; |
759 | 801 | ||
760 | /* The tlv_buf_len is calculated for each scan command. The TLVs added | 802 | /* The tlv_buf_len is calculated for each scan command. The TLVs added |
@@ -889,19 +931,6 @@ mwifiex_config_scan(struct mwifiex_private *priv, | |||
889 | 931 | ||
890 | } | 932 | } |
891 | 933 | ||
892 | /* Append rates tlv */ | ||
893 | memset(rates, 0, sizeof(rates)); | ||
894 | |||
895 | rates_size = mwifiex_get_supported_rates(priv, rates); | ||
896 | |||
897 | rates_tlv = (struct mwifiex_ie_types_rates_param_set *) tlv_pos; | ||
898 | rates_tlv->header.type = cpu_to_le16(WLAN_EID_SUPP_RATES); | ||
899 | rates_tlv->header.len = cpu_to_le16((u16) rates_size); | ||
900 | memcpy(rates_tlv->rates, rates, rates_size); | ||
901 | tlv_pos += sizeof(rates_tlv->header) + rates_size; | ||
902 | |||
903 | dev_dbg(adapter->dev, "info: SCAN_CMD: Rates size = %d\n", rates_size); | ||
904 | |||
905 | if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && | 934 | if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && |
906 | (priv->adapter->config_bands & BAND_GN || | 935 | (priv->adapter->config_bands & BAND_GN || |
907 | priv->adapter->config_bands & BAND_AN)) { | 936 | priv->adapter->config_bands & BAND_AN)) { |
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 5ee5ed02eccd..1576104e3d95 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c | |||
@@ -50,8 +50,6 @@ static struct mwifiex_if_ops sdio_ops; | |||
50 | 50 | ||
51 | static struct semaphore add_remove_card_sem; | 51 | static struct semaphore add_remove_card_sem; |
52 | 52 | ||
53 | static int mwifiex_sdio_resume(struct device *dev); | ||
54 | |||
55 | /* | 53 | /* |
56 | * SDIO probe. | 54 | * SDIO probe. |
57 | * | 55 | * |
@@ -112,6 +110,51 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) | |||
112 | } | 110 | } |
113 | 111 | ||
114 | /* | 112 | /* |
113 | * SDIO resume. | ||
114 | * | ||
115 | * Kernel needs to suspend all functions separately. Therefore all | ||
116 | * registered functions must have drivers with suspend and resume | ||
117 | * methods. Failing that the kernel simply removes the whole card. | ||
118 | * | ||
119 | * If already not resumed, this function turns on the traffic and | ||
120 | * sends a host sleep cancel request to the firmware. | ||
121 | */ | ||
122 | static int mwifiex_sdio_resume(struct device *dev) | ||
123 | { | ||
124 | struct sdio_func *func = dev_to_sdio_func(dev); | ||
125 | struct sdio_mmc_card *card; | ||
126 | struct mwifiex_adapter *adapter; | ||
127 | mmc_pm_flag_t pm_flag = 0; | ||
128 | |||
129 | if (func) { | ||
130 | pm_flag = sdio_get_host_pm_caps(func); | ||
131 | card = sdio_get_drvdata(func); | ||
132 | if (!card || !card->adapter) { | ||
133 | pr_err("resume: invalid card or adapter\n"); | ||
134 | return 0; | ||
135 | } | ||
136 | } else { | ||
137 | pr_err("resume: sdio_func is not specified\n"); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | adapter = card->adapter; | ||
142 | |||
143 | if (!adapter->is_suspended) { | ||
144 | dev_warn(adapter->dev, "device already resumed\n"); | ||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | adapter->is_suspended = false; | ||
149 | |||
150 | /* Disable Host Sleep */ | ||
151 | mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), | ||
152 | MWIFIEX_ASYNC_CMD); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | /* | ||
115 | * SDIO remove. | 158 | * SDIO remove. |
116 | * | 159 | * |
117 | * This function removes the interface and frees up the card structure. | 160 | * This function removes the interface and frees up the card structure. |
@@ -211,51 +254,6 @@ static int mwifiex_sdio_suspend(struct device *dev) | |||
211 | return ret; | 254 | return ret; |
212 | } | 255 | } |
213 | 256 | ||
214 | /* | ||
215 | * SDIO resume. | ||
216 | * | ||
217 | * Kernel needs to suspend all functions separately. Therefore all | ||
218 | * registered functions must have drivers with suspend and resume | ||
219 | * methods. Failing that the kernel simply removes the whole card. | ||
220 | * | ||
221 | * If already not resumed, this function turns on the traffic and | ||
222 | * sends a host sleep cancel request to the firmware. | ||
223 | */ | ||
224 | static int mwifiex_sdio_resume(struct device *dev) | ||
225 | { | ||
226 | struct sdio_func *func = dev_to_sdio_func(dev); | ||
227 | struct sdio_mmc_card *card; | ||
228 | struct mwifiex_adapter *adapter; | ||
229 | mmc_pm_flag_t pm_flag = 0; | ||
230 | |||
231 | if (func) { | ||
232 | pm_flag = sdio_get_host_pm_caps(func); | ||
233 | card = sdio_get_drvdata(func); | ||
234 | if (!card || !card->adapter) { | ||
235 | pr_err("resume: invalid card or adapter\n"); | ||
236 | return 0; | ||
237 | } | ||
238 | } else { | ||
239 | pr_err("resume: sdio_func is not specified\n"); | ||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | adapter = card->adapter; | ||
244 | |||
245 | if (!adapter->is_suspended) { | ||
246 | dev_warn(adapter->dev, "device already resumed\n"); | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | adapter->is_suspended = false; | ||
251 | |||
252 | /* Disable Host Sleep */ | ||
253 | mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), | ||
254 | MWIFIEX_ASYNC_CMD); | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | /* Device ID for SD8786 */ | 257 | /* Device ID for SD8786 */ |
260 | #define SDIO_DEVICE_ID_MARVELL_8786 (0x9116) | 258 | #define SDIO_DEVICE_ID_MARVELL_8786 (0x9116) |
261 | /* Device ID for SD8787 */ | 259 | /* Device ID for SD8787 */ |
@@ -296,6 +294,15 @@ static struct sdio_driver mwifiex_sdio = { | |||
296 | } | 294 | } |
297 | }; | 295 | }; |
298 | 296 | ||
297 | /* Write data into SDIO card register. Caller claims SDIO device. */ | ||
298 | static int | ||
299 | mwifiex_write_reg_locked(struct sdio_func *func, u32 reg, u8 data) | ||
300 | { | ||
301 | int ret = -1; | ||
302 | sdio_writeb(func, data, reg, &ret); | ||
303 | return ret; | ||
304 | } | ||
305 | |||
299 | /* | 306 | /* |
300 | * This function writes data into SDIO card register. | 307 | * This function writes data into SDIO card register. |
301 | */ | 308 | */ |
@@ -303,10 +310,10 @@ static int | |||
303 | mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data) | 310 | mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data) |
304 | { | 311 | { |
305 | struct sdio_mmc_card *card = adapter->card; | 312 | struct sdio_mmc_card *card = adapter->card; |
306 | int ret = -1; | 313 | int ret; |
307 | 314 | ||
308 | sdio_claim_host(card->func); | 315 | sdio_claim_host(card->func); |
309 | sdio_writeb(card->func, data, reg, &ret); | 316 | ret = mwifiex_write_reg_locked(card->func, reg, data); |
310 | sdio_release_host(card->func); | 317 | sdio_release_host(card->func); |
311 | 318 | ||
312 | return ret; | 319 | return ret; |
@@ -685,23 +692,74 @@ mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat) | |||
685 | * The host interrupt mask is read, the disable bit is reset and | 692 | * The host interrupt mask is read, the disable bit is reset and |
686 | * written back to the card host interrupt mask register. | 693 | * written back to the card host interrupt mask register. |
687 | */ | 694 | */ |
688 | static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter) | 695 | static void mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter) |
689 | { | 696 | { |
690 | u8 host_int_mask, host_int_disable = HOST_INT_DISABLE; | 697 | struct sdio_mmc_card *card = adapter->card; |
698 | struct sdio_func *func = card->func; | ||
691 | 699 | ||
692 | /* Read back the host_int_mask register */ | 700 | sdio_claim_host(func); |
693 | if (mwifiex_read_reg(adapter, HOST_INT_MASK_REG, &host_int_mask)) | 701 | mwifiex_write_reg_locked(func, HOST_INT_MASK_REG, 0); |
694 | return -1; | 702 | sdio_release_irq(func); |
703 | sdio_release_host(func); | ||
704 | } | ||
695 | 705 | ||
696 | /* Update with the mask and write back to the register */ | 706 | /* |
697 | host_int_mask &= ~host_int_disable; | 707 | * This function reads the interrupt status from card. |
708 | */ | ||
709 | static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter) | ||
710 | { | ||
711 | struct sdio_mmc_card *card = adapter->card; | ||
712 | u8 sdio_ireg; | ||
713 | unsigned long flags; | ||
698 | 714 | ||
699 | if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, host_int_mask)) { | 715 | if (mwifiex_read_data_sync(adapter, card->mp_regs, |
700 | dev_err(adapter->dev, "disable host interrupt failed\n"); | 716 | card->reg->max_mp_regs, |
701 | return -1; | 717 | REG_PORT | MWIFIEX_SDIO_BYTE_MODE_MASK, 0)) { |
718 | dev_err(adapter->dev, "read mp_regs failed\n"); | ||
719 | return; | ||
702 | } | 720 | } |
703 | 721 | ||
704 | return 0; | 722 | sdio_ireg = card->mp_regs[HOST_INTSTATUS_REG]; |
723 | if (sdio_ireg) { | ||
724 | /* | ||
725 | * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS | ||
726 | * For SDIO new mode CMD port interrupts | ||
727 | * DN_LD_CMD_PORT_HOST_INT_STATUS and/or | ||
728 | * UP_LD_CMD_PORT_HOST_INT_STATUS | ||
729 | * Clear the interrupt status register | ||
730 | */ | ||
731 | dev_dbg(adapter->dev, "int: sdio_ireg = %#x\n", sdio_ireg); | ||
732 | spin_lock_irqsave(&adapter->int_lock, flags); | ||
733 | adapter->int_status |= sdio_ireg; | ||
734 | spin_unlock_irqrestore(&adapter->int_lock, flags); | ||
735 | } | ||
736 | } | ||
737 | |||
738 | /* | ||
739 | * SDIO interrupt handler. | ||
740 | * | ||
741 | * This function reads the interrupt status from firmware and handles | ||
742 | * the interrupt in current thread (ksdioirqd) right away. | ||
743 | */ | ||
744 | static void | ||
745 | mwifiex_sdio_interrupt(struct sdio_func *func) | ||
746 | { | ||
747 | struct mwifiex_adapter *adapter; | ||
748 | struct sdio_mmc_card *card; | ||
749 | |||
750 | card = sdio_get_drvdata(func); | ||
751 | if (!card || !card->adapter) { | ||
752 | pr_debug("int: func=%p card=%p adapter=%p\n", | ||
753 | func, card, card ? card->adapter : NULL); | ||
754 | return; | ||
755 | } | ||
756 | adapter = card->adapter; | ||
757 | |||
758 | if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP) | ||
759 | adapter->ps_state = PS_STATE_AWAKE; | ||
760 | |||
761 | mwifiex_interrupt_status(adapter); | ||
762 | mwifiex_main_process(adapter); | ||
705 | } | 763 | } |
706 | 764 | ||
707 | /* | 765 | /* |
@@ -713,14 +771,29 @@ static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter) | |||
713 | static int mwifiex_sdio_enable_host_int(struct mwifiex_adapter *adapter) | 771 | static int mwifiex_sdio_enable_host_int(struct mwifiex_adapter *adapter) |
714 | { | 772 | { |
715 | struct sdio_mmc_card *card = adapter->card; | 773 | struct sdio_mmc_card *card = adapter->card; |
774 | struct sdio_func *func = card->func; | ||
775 | int ret; | ||
776 | |||
777 | sdio_claim_host(func); | ||
778 | |||
779 | /* Request the SDIO IRQ */ | ||
780 | ret = sdio_claim_irq(func, mwifiex_sdio_interrupt); | ||
781 | if (ret) { | ||
782 | dev_err(adapter->dev, "claim irq failed: ret=%d\n", ret); | ||
783 | goto out; | ||
784 | } | ||
716 | 785 | ||
717 | /* Simply write the mask to the register */ | 786 | /* Simply write the mask to the register */ |
718 | if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, | 787 | ret = mwifiex_write_reg_locked(func, HOST_INT_MASK_REG, |
719 | card->reg->host_int_enable)) { | 788 | card->reg->host_int_enable); |
789 | if (ret) { | ||
720 | dev_err(adapter->dev, "enable host interrupt failed\n"); | 790 | dev_err(adapter->dev, "enable host interrupt failed\n"); |
721 | return -1; | 791 | sdio_release_irq(func); |
722 | } | 792 | } |
723 | return 0; | 793 | |
794 | out: | ||
795 | sdio_release_host(func); | ||
796 | return ret; | ||
724 | } | 797 | } |
725 | 798 | ||
726 | /* | 799 | /* |
@@ -927,7 +1000,7 @@ static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter, | |||
927 | ret = 0; | 1000 | ret = 0; |
928 | break; | 1001 | break; |
929 | } else { | 1002 | } else { |
930 | mdelay(100); | 1003 | msleep(100); |
931 | ret = -1; | 1004 | ret = -1; |
932 | } | 1005 | } |
933 | } | 1006 | } |
@@ -946,68 +1019,6 @@ static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter, | |||
946 | } | 1019 | } |
947 | 1020 | ||
948 | /* | 1021 | /* |
949 | * This function reads the interrupt status from card. | ||
950 | */ | ||
951 | static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter) | ||
952 | { | ||
953 | struct sdio_mmc_card *card = adapter->card; | ||
954 | u8 sdio_ireg; | ||
955 | unsigned long flags; | ||
956 | |||
957 | if (mwifiex_read_data_sync(adapter, card->mp_regs, | ||
958 | card->reg->max_mp_regs, | ||
959 | REG_PORT | MWIFIEX_SDIO_BYTE_MODE_MASK, 0)) { | ||
960 | dev_err(adapter->dev, "read mp_regs failed\n"); | ||
961 | return; | ||
962 | } | ||
963 | |||
964 | sdio_ireg = card->mp_regs[HOST_INTSTATUS_REG]; | ||
965 | if (sdio_ireg) { | ||
966 | /* | ||
967 | * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS | ||
968 | * For SDIO new mode CMD port interrupts | ||
969 | * DN_LD_CMD_PORT_HOST_INT_STATUS and/or | ||
970 | * UP_LD_CMD_PORT_HOST_INT_STATUS | ||
971 | * Clear the interrupt status register | ||
972 | */ | ||
973 | dev_dbg(adapter->dev, "int: sdio_ireg = %#x\n", sdio_ireg); | ||
974 | spin_lock_irqsave(&adapter->int_lock, flags); | ||
975 | adapter->int_status |= sdio_ireg; | ||
976 | spin_unlock_irqrestore(&adapter->int_lock, flags); | ||
977 | } | ||
978 | } | ||
979 | |||
980 | /* | ||
981 | * SDIO interrupt handler. | ||
982 | * | ||
983 | * This function reads the interrupt status from firmware and handles | ||
984 | * the interrupt in current thread (ksdioirqd) right away. | ||
985 | */ | ||
986 | static void | ||
987 | mwifiex_sdio_interrupt(struct sdio_func *func) | ||
988 | { | ||
989 | struct mwifiex_adapter *adapter; | ||
990 | struct sdio_mmc_card *card; | ||
991 | |||
992 | card = sdio_get_drvdata(func); | ||
993 | if (!card || !card->adapter) { | ||
994 | pr_debug("int: func=%p card=%p adapter=%p\n", | ||
995 | func, card, card ? card->adapter : NULL); | ||
996 | return; | ||
997 | } | ||
998 | adapter = card->adapter; | ||
999 | |||
1000 | if (adapter->surprise_removed) | ||
1001 | return; | ||
1002 | |||
1003 | if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP) | ||
1004 | adapter->ps_state = PS_STATE_AWAKE; | ||
1005 | |||
1006 | mwifiex_interrupt_status(adapter); | ||
1007 | mwifiex_main_process(adapter); | ||
1008 | } | ||
1009 | |||
1010 | /* | ||
1011 | * This function decodes a received packet. | 1022 | * This function decodes a received packet. |
1012 | * | 1023 | * |
1013 | * Based on the type, the packet is treated as either a data, or | 1024 | * Based on the type, the packet is treated as either a data, or |
@@ -1051,7 +1062,7 @@ static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter, | |||
1051 | 1062 | ||
1052 | case MWIFIEX_TYPE_EVENT: | 1063 | case MWIFIEX_TYPE_EVENT: |
1053 | dev_dbg(adapter->dev, "info: --- Rx: Event ---\n"); | 1064 | dev_dbg(adapter->dev, "info: --- Rx: Event ---\n"); |
1054 | adapter->event_cause = *(u32 *) skb->data; | 1065 | adapter->event_cause = le32_to_cpu(*(__le32 *) skb->data); |
1055 | 1066 | ||
1056 | if ((skb->len > 0) && (skb->len < MAX_EVENT_SIZE)) | 1067 | if ((skb->len > 0) && (skb->len < MAX_EVENT_SIZE)) |
1057 | memcpy(adapter->event_body, | 1068 | memcpy(adapter->event_body, |
@@ -1196,8 +1207,8 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, | |||
1196 | for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) { | 1207 | for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) { |
1197 | 1208 | ||
1198 | /* get curr PKT len & type */ | 1209 | /* get curr PKT len & type */ |
1199 | pkt_len = *(u16 *) &curr_ptr[0]; | 1210 | pkt_len = le16_to_cpu(*(__le16 *) &curr_ptr[0]); |
1200 | pkt_type = *(u16 *) &curr_ptr[2]; | 1211 | pkt_type = le16_to_cpu(*(__le16 *) &curr_ptr[2]); |
1201 | 1212 | ||
1202 | /* copy pkt to deaggr buf */ | 1213 | /* copy pkt to deaggr buf */ |
1203 | skb_deaggr = card->mpa_rx.skb_arr[pind]; | 1214 | skb_deaggr = card->mpa_rx.skb_arr[pind]; |
@@ -1625,8 +1636,8 @@ static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter, | |||
1625 | /* Allocate buffer and copy payload */ | 1636 | /* Allocate buffer and copy payload */ |
1626 | blk_size = MWIFIEX_SDIO_BLOCK_SIZE; | 1637 | blk_size = MWIFIEX_SDIO_BLOCK_SIZE; |
1627 | buf_block_len = (pkt_len + blk_size - 1) / blk_size; | 1638 | buf_block_len = (pkt_len + blk_size - 1) / blk_size; |
1628 | *(u16 *) &payload[0] = (u16) pkt_len; | 1639 | *(__le16 *)&payload[0] = cpu_to_le16((u16)pkt_len); |
1629 | *(u16 *) &payload[2] = type; | 1640 | *(__le16 *)&payload[2] = cpu_to_le16(type); |
1630 | 1641 | ||
1631 | /* | 1642 | /* |
1632 | * This is SDIO specific header | 1643 | * This is SDIO specific header |
@@ -1728,9 +1739,7 @@ mwifiex_unregister_dev(struct mwifiex_adapter *adapter) | |||
1728 | struct sdio_mmc_card *card = adapter->card; | 1739 | struct sdio_mmc_card *card = adapter->card; |
1729 | 1740 | ||
1730 | if (adapter->card) { | 1741 | if (adapter->card) { |
1731 | /* Release the SDIO IRQ */ | ||
1732 | sdio_claim_host(card->func); | 1742 | sdio_claim_host(card->func); |
1733 | sdio_release_irq(card->func); | ||
1734 | sdio_disable_func(card->func); | 1743 | sdio_disable_func(card->func); |
1735 | sdio_release_host(card->func); | 1744 | sdio_release_host(card->func); |
1736 | sdio_set_drvdata(card->func, NULL); | 1745 | sdio_set_drvdata(card->func, NULL); |
@@ -1744,7 +1753,7 @@ mwifiex_unregister_dev(struct mwifiex_adapter *adapter) | |||
1744 | */ | 1753 | */ |
1745 | static int mwifiex_register_dev(struct mwifiex_adapter *adapter) | 1754 | static int mwifiex_register_dev(struct mwifiex_adapter *adapter) |
1746 | { | 1755 | { |
1747 | int ret = 0; | 1756 | int ret; |
1748 | struct sdio_mmc_card *card = adapter->card; | 1757 | struct sdio_mmc_card *card = adapter->card; |
1749 | struct sdio_func *func = card->func; | 1758 | struct sdio_func *func = card->func; |
1750 | 1759 | ||
@@ -1753,22 +1762,14 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) | |||
1753 | 1762 | ||
1754 | sdio_claim_host(func); | 1763 | sdio_claim_host(func); |
1755 | 1764 | ||
1756 | /* Request the SDIO IRQ */ | ||
1757 | ret = sdio_claim_irq(func, mwifiex_sdio_interrupt); | ||
1758 | if (ret) { | ||
1759 | pr_err("claim irq failed: ret=%d\n", ret); | ||
1760 | goto disable_func; | ||
1761 | } | ||
1762 | |||
1763 | /* Set block size */ | 1765 | /* Set block size */ |
1764 | ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE); | 1766 | ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE); |
1767 | sdio_release_host(func); | ||
1765 | if (ret) { | 1768 | if (ret) { |
1766 | pr_err("cannot set SDIO block size\n"); | 1769 | pr_err("cannot set SDIO block size\n"); |
1767 | ret = -1; | 1770 | return ret; |
1768 | goto release_irq; | ||
1769 | } | 1771 | } |
1770 | 1772 | ||
1771 | sdio_release_host(func); | ||
1772 | sdio_set_drvdata(func, card); | 1773 | sdio_set_drvdata(func, card); |
1773 | 1774 | ||
1774 | adapter->dev = &func->dev; | 1775 | adapter->dev = &func->dev; |
@@ -1776,15 +1777,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) | |||
1776 | strcpy(adapter->fw_name, card->firmware); | 1777 | strcpy(adapter->fw_name, card->firmware); |
1777 | 1778 | ||
1778 | return 0; | 1779 | return 0; |
1779 | |||
1780 | release_irq: | ||
1781 | sdio_release_irq(func); | ||
1782 | disable_func: | ||
1783 | sdio_disable_func(func); | ||
1784 | sdio_release_host(func); | ||
1785 | adapter->card = NULL; | ||
1786 | |||
1787 | return -1; | ||
1788 | } | 1780 | } |
1789 | 1781 | ||
1790 | /* | 1782 | /* |
@@ -1813,9 +1805,6 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) | |||
1813 | */ | 1805 | */ |
1814 | mwifiex_read_reg(adapter, HOST_INTSTATUS_REG, &sdio_ireg); | 1806 | mwifiex_read_reg(adapter, HOST_INTSTATUS_REG, &sdio_ireg); |
1815 | 1807 | ||
1816 | /* Disable host interrupt mask register for SDIO */ | ||
1817 | mwifiex_sdio_disable_host_int(adapter); | ||
1818 | |||
1819 | /* Get SDIO ioport */ | 1808 | /* Get SDIO ioport */ |
1820 | mwifiex_init_sdio_ioport(adapter); | 1809 | mwifiex_init_sdio_ioport(adapter); |
1821 | 1810 | ||
@@ -1957,6 +1946,7 @@ static struct mwifiex_if_ops sdio_ops = { | |||
1957 | .register_dev = mwifiex_register_dev, | 1946 | .register_dev = mwifiex_register_dev, |
1958 | .unregister_dev = mwifiex_unregister_dev, | 1947 | .unregister_dev = mwifiex_unregister_dev, |
1959 | .enable_int = mwifiex_sdio_enable_host_int, | 1948 | .enable_int = mwifiex_sdio_enable_host_int, |
1949 | .disable_int = mwifiex_sdio_disable_host_int, | ||
1960 | .process_int_status = mwifiex_process_int_status, | 1950 | .process_int_status = mwifiex_process_int_status, |
1961 | .host_to_card = mwifiex_sdio_host_to_card, | 1951 | .host_to_card = mwifiex_sdio_host_to_card, |
1962 | .wakeup = mwifiex_pm_wakeup_card, | 1952 | .wakeup = mwifiex_pm_wakeup_card, |
diff --git a/drivers/net/wireless/mwifiex/sdio.h b/drivers/net/wireless/mwifiex/sdio.h index 6d51dfdd8251..532ae0ac4dfb 100644 --- a/drivers/net/wireless/mwifiex/sdio.h +++ b/drivers/net/wireless/mwifiex/sdio.h | |||
@@ -92,9 +92,6 @@ | |||
92 | /* Host Control Registers : Download host interrupt mask */ | 92 | /* Host Control Registers : Download host interrupt mask */ |
93 | #define DN_LD_HOST_INT_MASK (0x2U) | 93 | #define DN_LD_HOST_INT_MASK (0x2U) |
94 | 94 | ||
95 | /* Disable Host interrupt mask */ | ||
96 | #define HOST_INT_DISABLE 0xff | ||
97 | |||
98 | /* Host Control Registers : Host interrupt status */ | 95 | /* Host Control Registers : Host interrupt status */ |
99 | #define HOST_INTSTATUS_REG 0x03 | 96 | #define HOST_INTSTATUS_REG 0x03 |
100 | /* Host Control Registers : Upload host interrupt status */ | 97 | /* Host Control Registers : Upload host interrupt status */ |
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c index 8ece48580642..c0268b597748 100644 --- a/drivers/net/wireless/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/mwifiex/sta_cmd.c | |||
@@ -707,8 +707,9 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, | |||
707 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { | 707 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { |
708 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + | 708 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + |
709 | key_param_len); | 709 | key_param_len); |
710 | tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); | 710 | tlv_mac->header.type = |
711 | tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN); | 711 | cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); |
712 | tlv_mac->header.len = cpu_to_le16(ETH_ALEN); | ||
712 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); | 713 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); |
713 | cmd_size = key_param_len + S_DS_GEN + | 714 | cmd_size = key_param_len + S_DS_GEN + |
714 | sizeof(key_material->action) + | 715 | sizeof(key_material->action) + |
@@ -1069,7 +1070,7 @@ mwifiex_cmd_append_rpn_expression(struct mwifiex_private *priv, | |||
1069 | int i, byte_len; | 1070 | int i, byte_len; |
1070 | u8 *stack_ptr = *buffer; | 1071 | u8 *stack_ptr = *buffer; |
1071 | 1072 | ||
1072 | for (i = 0; i < MWIFIEX_MAX_FILTERS; i++) { | 1073 | for (i = 0; i < MWIFIEX_MEF_MAX_FILTERS; i++) { |
1073 | filter = &mef_entry->filter[i]; | 1074 | filter = &mef_entry->filter[i]; |
1074 | if (!filter->filt_type) | 1075 | if (!filter->filt_type) |
1075 | break; | 1076 | break; |
@@ -1078,7 +1079,7 @@ mwifiex_cmd_append_rpn_expression(struct mwifiex_private *priv, | |||
1078 | *stack_ptr = TYPE_DNUM; | 1079 | *stack_ptr = TYPE_DNUM; |
1079 | stack_ptr += 1; | 1080 | stack_ptr += 1; |
1080 | 1081 | ||
1081 | byte_len = filter->byte_seq[MAX_BYTESEQ]; | 1082 | byte_len = filter->byte_seq[MWIFIEX_MEF_MAX_BYTESEQ]; |
1082 | memcpy(stack_ptr, filter->byte_seq, byte_len); | 1083 | memcpy(stack_ptr, filter->byte_seq, byte_len); |
1083 | stack_ptr += byte_len; | 1084 | stack_ptr += byte_len; |
1084 | *stack_ptr = byte_len; | 1085 | *stack_ptr = byte_len; |
@@ -1183,6 +1184,70 @@ static int mwifiex_cmd_cfg_data(struct mwifiex_private *priv, | |||
1183 | return 0; | 1184 | return 0; |
1184 | } | 1185 | } |
1185 | 1186 | ||
1187 | static int | ||
1188 | mwifiex_cmd_coalesce_cfg(struct mwifiex_private *priv, | ||
1189 | struct host_cmd_ds_command *cmd, | ||
1190 | u16 cmd_action, void *data_buf) | ||
1191 | { | ||
1192 | struct host_cmd_ds_coalesce_cfg *coalesce_cfg = | ||
1193 | &cmd->params.coalesce_cfg; | ||
1194 | struct mwifiex_ds_coalesce_cfg *cfg = data_buf; | ||
1195 | struct coalesce_filt_field_param *param; | ||
1196 | u16 cnt, idx, length; | ||
1197 | struct coalesce_receive_filt_rule *rule; | ||
1198 | |||
1199 | cmd->command = cpu_to_le16(HostCmd_CMD_COALESCE_CFG); | ||
1200 | cmd->size = cpu_to_le16(S_DS_GEN); | ||
1201 | |||
1202 | coalesce_cfg->action = cpu_to_le16(cmd_action); | ||
1203 | coalesce_cfg->num_of_rules = cpu_to_le16(cfg->num_of_rules); | ||
1204 | rule = coalesce_cfg->rule; | ||
1205 | |||
1206 | for (cnt = 0; cnt < cfg->num_of_rules; cnt++) { | ||
1207 | rule->header.type = cpu_to_le16(TLV_TYPE_COALESCE_RULE); | ||
1208 | rule->max_coalescing_delay = | ||
1209 | cpu_to_le16(cfg->rule[cnt].max_coalescing_delay); | ||
1210 | rule->pkt_type = cfg->rule[cnt].pkt_type; | ||
1211 | rule->num_of_fields = cfg->rule[cnt].num_of_fields; | ||
1212 | |||
1213 | length = 0; | ||
1214 | |||
1215 | param = rule->params; | ||
1216 | for (idx = 0; idx < cfg->rule[cnt].num_of_fields; idx++) { | ||
1217 | param->operation = cfg->rule[cnt].params[idx].operation; | ||
1218 | param->operand_len = | ||
1219 | cfg->rule[cnt].params[idx].operand_len; | ||
1220 | param->offset = | ||
1221 | cpu_to_le16(cfg->rule[cnt].params[idx].offset); | ||
1222 | memcpy(param->operand_byte_stream, | ||
1223 | cfg->rule[cnt].params[idx].operand_byte_stream, | ||
1224 | param->operand_len); | ||
1225 | |||
1226 | length += sizeof(struct coalesce_filt_field_param); | ||
1227 | |||
1228 | param++; | ||
1229 | } | ||
1230 | |||
1231 | /* Total rule length is sizeof max_coalescing_delay(u16), | ||
1232 | * num_of_fields(u8), pkt_type(u8) and total length of the all | ||
1233 | * params | ||
1234 | */ | ||
1235 | rule->header.len = cpu_to_le16(length + sizeof(u16) + | ||
1236 | sizeof(u8) + sizeof(u8)); | ||
1237 | |||
1238 | /* Add the rule length to the command size*/ | ||
1239 | le16_add_cpu(&cmd->size, le16_to_cpu(rule->header.len) + | ||
1240 | sizeof(struct mwifiex_ie_types_header)); | ||
1241 | |||
1242 | rule = (void *)((u8 *)rule->params + length); | ||
1243 | } | ||
1244 | |||
1245 | /* Add sizeof action, num_of_rules to total command length */ | ||
1246 | le16_add_cpu(&cmd->size, sizeof(u16) + sizeof(u16)); | ||
1247 | |||
1248 | return 0; | ||
1249 | } | ||
1250 | |||
1186 | /* | 1251 | /* |
1187 | * This function prepares the commands before sending them to the firmware. | 1252 | * This function prepares the commands before sending them to the firmware. |
1188 | * | 1253 | * |
@@ -1406,6 +1471,10 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, | |||
1406 | case HostCmd_CMD_MEF_CFG: | 1471 | case HostCmd_CMD_MEF_CFG: |
1407 | ret = mwifiex_cmd_mef_cfg(priv, cmd_ptr, data_buf); | 1472 | ret = mwifiex_cmd_mef_cfg(priv, cmd_ptr, data_buf); |
1408 | break; | 1473 | break; |
1474 | case HostCmd_CMD_COALESCE_CFG: | ||
1475 | ret = mwifiex_cmd_coalesce_cfg(priv, cmd_ptr, cmd_action, | ||
1476 | data_buf); | ||
1477 | break; | ||
1409 | default: | 1478 | default: |
1410 | dev_err(priv->adapter->dev, | 1479 | dev_err(priv->adapter->dev, |
1411 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); | 1480 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); |
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c index d85df158cc6c..58a6013712d2 100644 --- a/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c | |||
@@ -280,7 +280,7 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, | |||
280 | 280 | ||
281 | tlv_buf = ((u8 *)rate_cfg) + | 281 | tlv_buf = ((u8 *)rate_cfg) + |
282 | sizeof(struct host_cmd_ds_tx_rate_cfg); | 282 | sizeof(struct host_cmd_ds_tx_rate_cfg); |
283 | tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16)); | 283 | tlv_buf_len = le16_to_cpu(*(__le16 *) (tlv_buf + sizeof(u16))); |
284 | 284 | ||
285 | while (tlv_buf && tlv_buf_len > 0) { | 285 | while (tlv_buf && tlv_buf_len > 0) { |
286 | tlv = (*tlv_buf); | 286 | tlv = (*tlv_buf); |
@@ -997,6 +997,8 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, | |||
997 | break; | 997 | break; |
998 | case HostCmd_CMD_MEF_CFG: | 998 | case HostCmd_CMD_MEF_CFG: |
999 | break; | 999 | break; |
1000 | case HostCmd_CMD_COALESCE_CFG: | ||
1001 | break; | ||
1000 | default: | 1002 | default: |
1001 | dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n", | 1003 | dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n", |
1002 | resp->command); | 1004 | resp->command); |
diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c index ea265ec0e522..8b057524b252 100644 --- a/drivers/net/wireless/mwifiex/sta_event.c +++ b/drivers/net/wireless/mwifiex/sta_event.c | |||
@@ -201,6 +201,11 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) | |||
201 | 201 | ||
202 | case EVENT_DEAUTHENTICATED: | 202 | case EVENT_DEAUTHENTICATED: |
203 | dev_dbg(adapter->dev, "event: Deauthenticated\n"); | 203 | dev_dbg(adapter->dev, "event: Deauthenticated\n"); |
204 | if (priv->wps.session_enable) { | ||
205 | dev_dbg(adapter->dev, | ||
206 | "info: receive deauth event in wps session\n"); | ||
207 | break; | ||
208 | } | ||
204 | adapter->dbg.num_event_deauth++; | 209 | adapter->dbg.num_event_deauth++; |
205 | if (priv->media_connected) { | 210 | if (priv->media_connected) { |
206 | reason_code = | 211 | reason_code = |
@@ -211,6 +216,11 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) | |||
211 | 216 | ||
212 | case EVENT_DISASSOCIATED: | 217 | case EVENT_DISASSOCIATED: |
213 | dev_dbg(adapter->dev, "event: Disassociated\n"); | 218 | dev_dbg(adapter->dev, "event: Disassociated\n"); |
219 | if (priv->wps.session_enable) { | ||
220 | dev_dbg(adapter->dev, | ||
221 | "info: receive disassoc event in wps session\n"); | ||
222 | break; | ||
223 | } | ||
214 | adapter->dbg.num_event_disassoc++; | 224 | adapter->dbg.num_event_disassoc++; |
215 | if (priv->media_connected) { | 225 | if (priv->media_connected) { |
216 | reason_code = | 226 | reason_code = |
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 206c3e038072..f084412eee0b 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c | |||
@@ -257,10 +257,10 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, | |||
257 | goto done; | 257 | goto done; |
258 | } | 258 | } |
259 | 259 | ||
260 | if (priv->bss_mode == NL80211_IFTYPE_STATION) { | 260 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
261 | priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) { | ||
261 | u8 config_bands; | 262 | u8 config_bands; |
262 | 263 | ||
263 | /* Infra mode */ | ||
264 | ret = mwifiex_deauthenticate(priv, NULL); | 264 | ret = mwifiex_deauthenticate(priv, NULL); |
265 | if (ret) | 265 | if (ret) |
266 | goto done; | 266 | goto done; |
@@ -797,15 +797,16 @@ static int mwifiex_set_wps_ie(struct mwifiex_private *priv, | |||
797 | u8 *ie_data_ptr, u16 ie_len) | 797 | u8 *ie_data_ptr, u16 ie_len) |
798 | { | 798 | { |
799 | if (ie_len) { | 799 | if (ie_len) { |
800 | priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL); | 800 | if (ie_len > MWIFIEX_MAX_VSIE_LEN) { |
801 | if (!priv->wps_ie) | ||
802 | return -ENOMEM; | ||
803 | if (ie_len > sizeof(priv->wps_ie)) { | ||
804 | dev_dbg(priv->adapter->dev, | 801 | dev_dbg(priv->adapter->dev, |
805 | "info: failed to copy WPS IE, too big\n"); | 802 | "info: failed to copy WPS IE, too big\n"); |
806 | kfree(priv->wps_ie); | ||
807 | return -1; | 803 | return -1; |
808 | } | 804 | } |
805 | |||
806 | priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL); | ||
807 | if (!priv->wps_ie) | ||
808 | return -ENOMEM; | ||
809 | |||
809 | memcpy(priv->wps_ie, ie_data_ptr, ie_len); | 810 | memcpy(priv->wps_ie, ie_data_ptr, ie_len); |
810 | priv->wps_ie_len = ie_len; | 811 | priv->wps_ie_len = ie_len; |
811 | dev_dbg(priv->adapter->dev, "cmd: Set wps_ie_len=%d IE=%#x\n", | 812 | dev_dbg(priv->adapter->dev, "cmd: Set wps_ie_len=%d IE=%#x\n", |
diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c index b5c109504393..bb22664923ef 100644 --- a/drivers/net/wireless/mwifiex/sta_rx.c +++ b/drivers/net/wireless/mwifiex/sta_rx.c | |||
@@ -17,6 +17,8 @@ | |||
17 | * this warranty disclaimer. | 17 | * this warranty disclaimer. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <uapi/linux/ipv6.h> | ||
21 | #include <net/ndisc.h> | ||
20 | #include "decl.h" | 22 | #include "decl.h" |
21 | #include "ioctl.h" | 23 | #include "ioctl.h" |
22 | #include "util.h" | 24 | #include "util.h" |
@@ -25,6 +27,46 @@ | |||
25 | #include "11n_aggr.h" | 27 | #include "11n_aggr.h" |
26 | #include "11n_rxreorder.h" | 28 | #include "11n_rxreorder.h" |
27 | 29 | ||
30 | /* This function checks if a frame is IPv4 ARP or IPv6 Neighbour advertisement | ||
31 | * frame. If frame has both source and destination mac address as same, this | ||
32 | * function drops such gratuitous frames. | ||
33 | */ | ||
34 | static bool | ||
35 | mwifiex_discard_gratuitous_arp(struct mwifiex_private *priv, | ||
36 | struct sk_buff *skb) | ||
37 | { | ||
38 | const struct mwifiex_arp_eth_header *arp; | ||
39 | struct ethhdr *eth_hdr; | ||
40 | struct ipv6hdr *ipv6; | ||
41 | struct icmp6hdr *icmpv6; | ||
42 | |||
43 | eth_hdr = (struct ethhdr *)skb->data; | ||
44 | switch (ntohs(eth_hdr->h_proto)) { | ||
45 | case ETH_P_ARP: | ||
46 | arp = (void *)(skb->data + sizeof(struct ethhdr)); | ||
47 | if (arp->hdr.ar_op == htons(ARPOP_REPLY) || | ||
48 | arp->hdr.ar_op == htons(ARPOP_REQUEST)) { | ||
49 | if (!memcmp(arp->ar_sip, arp->ar_tip, 4)) | ||
50 | return true; | ||
51 | } | ||
52 | break; | ||
53 | case ETH_P_IPV6: | ||
54 | ipv6 = (void *)(skb->data + sizeof(struct ethhdr)); | ||
55 | icmpv6 = (void *)(skb->data + sizeof(struct ethhdr) + | ||
56 | sizeof(struct ipv6hdr)); | ||
57 | if (NDISC_NEIGHBOUR_ADVERTISEMENT == icmpv6->icmp6_type) { | ||
58 | if (!memcmp(&ipv6->saddr, &ipv6->daddr, | ||
59 | sizeof(struct in6_addr))) | ||
60 | return true; | ||
61 | } | ||
62 | break; | ||
63 | default: | ||
64 | break; | ||
65 | } | ||
66 | |||
67 | return false; | ||
68 | } | ||
69 | |||
28 | /* | 70 | /* |
29 | * This function processes the received packet and forwards it | 71 | * This function processes the received packet and forwards it |
30 | * to kernel/upper layer. | 72 | * to kernel/upper layer. |
@@ -90,6 +132,13 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv, | |||
90 | either the reconstructed EthII frame or the 802.2/llc/snap frame */ | 132 | either the reconstructed EthII frame or the 802.2/llc/snap frame */ |
91 | skb_pull(skb, hdr_chop); | 133 | skb_pull(skb, hdr_chop); |
92 | 134 | ||
135 | if (priv->hs2_enabled && | ||
136 | mwifiex_discard_gratuitous_arp(priv, skb)) { | ||
137 | dev_dbg(priv->adapter->dev, "Bypassed Gratuitous ARP\n"); | ||
138 | dev_kfree_skb_any(skb); | ||
139 | return 0; | ||
140 | } | ||
141 | |||
93 | priv->rxpd_rate = local_rx_pd->rx_rate; | 142 | priv->rxpd_rate = local_rx_pd->rx_rate; |
94 | 143 | ||
95 | priv->rxpd_htinfo = local_rx_pd->ht_info; | 144 | priv->rxpd_htinfo = local_rx_pd->ht_info; |
diff --git a/drivers/net/wireless/mwifiex/uap_cmd.c b/drivers/net/wireless/mwifiex/uap_cmd.c index 2de882dead0f..64424c81b44f 100644 --- a/drivers/net/wireless/mwifiex/uap_cmd.c +++ b/drivers/net/wireless/mwifiex/uap_cmd.c | |||
@@ -293,9 +293,9 @@ mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
293 | u8 *tlv = *tlv_buf; | 293 | u8 *tlv = *tlv_buf; |
294 | 294 | ||
295 | tlv_akmp = (struct host_cmd_tlv_akmp *)tlv; | 295 | tlv_akmp = (struct host_cmd_tlv_akmp *)tlv; |
296 | tlv_akmp->tlv.type = cpu_to_le16(TLV_TYPE_UAP_AKMP); | 296 | tlv_akmp->header.type = cpu_to_le16(TLV_TYPE_UAP_AKMP); |
297 | tlv_akmp->tlv.len = cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) - | 297 | tlv_akmp->header.len = cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) - |
298 | sizeof(struct host_cmd_tlv)); | 298 | sizeof(struct mwifiex_ie_types_header)); |
299 | tlv_akmp->key_mgmt_operation = cpu_to_le16(bss_cfg->key_mgmt_operation); | 299 | tlv_akmp->key_mgmt_operation = cpu_to_le16(bss_cfg->key_mgmt_operation); |
300 | tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt); | 300 | tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt); |
301 | cmd_size += sizeof(struct host_cmd_tlv_akmp); | 301 | cmd_size += sizeof(struct host_cmd_tlv_akmp); |
@@ -303,10 +303,10 @@ mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
303 | 303 | ||
304 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa & VALID_CIPHER_BITMAP) { | 304 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa & VALID_CIPHER_BITMAP) { |
305 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; | 305 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; |
306 | pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); | 306 | pwk_cipher->header.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); |
307 | pwk_cipher->tlv.len = | 307 | pwk_cipher->header.len = |
308 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - | 308 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - |
309 | sizeof(struct host_cmd_tlv)); | 309 | sizeof(struct mwifiex_ie_types_header)); |
310 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA); | 310 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA); |
311 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa; | 311 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa; |
312 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); | 312 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); |
@@ -315,10 +315,10 @@ mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
315 | 315 | ||
316 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 & VALID_CIPHER_BITMAP) { | 316 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 & VALID_CIPHER_BITMAP) { |
317 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; | 317 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; |
318 | pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); | 318 | pwk_cipher->header.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); |
319 | pwk_cipher->tlv.len = | 319 | pwk_cipher->header.len = |
320 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - | 320 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - |
321 | sizeof(struct host_cmd_tlv)); | 321 | sizeof(struct mwifiex_ie_types_header)); |
322 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2); | 322 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2); |
323 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa2; | 323 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa2; |
324 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); | 324 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); |
@@ -327,10 +327,10 @@ mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
327 | 327 | ||
328 | if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) { | 328 | if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) { |
329 | gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv; | 329 | gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv; |
330 | gwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER); | 330 | gwk_cipher->header.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER); |
331 | gwk_cipher->tlv.len = | 331 | gwk_cipher->header.len = |
332 | cpu_to_le16(sizeof(struct host_cmd_tlv_gwk_cipher) - | 332 | cpu_to_le16(sizeof(struct host_cmd_tlv_gwk_cipher) - |
333 | sizeof(struct host_cmd_tlv)); | 333 | sizeof(struct mwifiex_ie_types_header)); |
334 | gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher; | 334 | gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher; |
335 | cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher); | 335 | cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher); |
336 | tlv += sizeof(struct host_cmd_tlv_gwk_cipher); | 336 | tlv += sizeof(struct host_cmd_tlv_gwk_cipher); |
@@ -338,13 +338,15 @@ mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
338 | 338 | ||
339 | if (bss_cfg->wpa_cfg.length) { | 339 | if (bss_cfg->wpa_cfg.length) { |
340 | passphrase = (struct host_cmd_tlv_passphrase *)tlv; | 340 | passphrase = (struct host_cmd_tlv_passphrase *)tlv; |
341 | passphrase->tlv.type = cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE); | 341 | passphrase->header.type = |
342 | passphrase->tlv.len = cpu_to_le16(bss_cfg->wpa_cfg.length); | 342 | cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE); |
343 | passphrase->header.len = cpu_to_le16(bss_cfg->wpa_cfg.length); | ||
343 | memcpy(passphrase->passphrase, bss_cfg->wpa_cfg.passphrase, | 344 | memcpy(passphrase->passphrase, bss_cfg->wpa_cfg.passphrase, |
344 | bss_cfg->wpa_cfg.length); | 345 | bss_cfg->wpa_cfg.length); |
345 | cmd_size += sizeof(struct host_cmd_tlv) + | 346 | cmd_size += sizeof(struct mwifiex_ie_types_header) + |
346 | bss_cfg->wpa_cfg.length; | 347 | bss_cfg->wpa_cfg.length; |
347 | tlv += sizeof(struct host_cmd_tlv) + bss_cfg->wpa_cfg.length; | 348 | tlv += sizeof(struct mwifiex_ie_types_header) + |
349 | bss_cfg->wpa_cfg.length; | ||
348 | } | 350 | } |
349 | 351 | ||
350 | *param_size = cmd_size; | 352 | *param_size = cmd_size; |
@@ -403,16 +405,17 @@ mwifiex_uap_bss_wep(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |||
403 | (bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP40 || | 405 | (bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP40 || |
404 | bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP104)) { | 406 | bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP104)) { |
405 | wep_key = (struct host_cmd_tlv_wep_key *)tlv; | 407 | wep_key = (struct host_cmd_tlv_wep_key *)tlv; |
406 | wep_key->tlv.type = cpu_to_le16(TLV_TYPE_UAP_WEP_KEY); | 408 | wep_key->header.type = |
407 | wep_key->tlv.len = | 409 | cpu_to_le16(TLV_TYPE_UAP_WEP_KEY); |
410 | wep_key->header.len = | ||
408 | cpu_to_le16(bss_cfg->wep_cfg[i].length + 2); | 411 | cpu_to_le16(bss_cfg->wep_cfg[i].length + 2); |
409 | wep_key->key_index = bss_cfg->wep_cfg[i].key_index; | 412 | wep_key->key_index = bss_cfg->wep_cfg[i].key_index; |
410 | wep_key->is_default = bss_cfg->wep_cfg[i].is_default; | 413 | wep_key->is_default = bss_cfg->wep_cfg[i].is_default; |
411 | memcpy(wep_key->key, bss_cfg->wep_cfg[i].key, | 414 | memcpy(wep_key->key, bss_cfg->wep_cfg[i].key, |
412 | bss_cfg->wep_cfg[i].length); | 415 | bss_cfg->wep_cfg[i].length); |
413 | cmd_size += sizeof(struct host_cmd_tlv) + 2 + | 416 | cmd_size += sizeof(struct mwifiex_ie_types_header) + 2 + |
414 | bss_cfg->wep_cfg[i].length; | 417 | bss_cfg->wep_cfg[i].length; |
415 | tlv += sizeof(struct host_cmd_tlv) + 2 + | 418 | tlv += sizeof(struct mwifiex_ie_types_header) + 2 + |
416 | bss_cfg->wep_cfg[i].length; | 419 | bss_cfg->wep_cfg[i].length; |
417 | } | 420 | } |
418 | } | 421 | } |
@@ -449,16 +452,17 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
449 | 452 | ||
450 | if (bss_cfg->ssid.ssid_len) { | 453 | if (bss_cfg->ssid.ssid_len) { |
451 | ssid = (struct host_cmd_tlv_ssid *)tlv; | 454 | ssid = (struct host_cmd_tlv_ssid *)tlv; |
452 | ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_SSID); | 455 | ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID); |
453 | ssid->tlv.len = cpu_to_le16((u16)bss_cfg->ssid.ssid_len); | 456 | ssid->header.len = cpu_to_le16((u16)bss_cfg->ssid.ssid_len); |
454 | memcpy(ssid->ssid, bss_cfg->ssid.ssid, bss_cfg->ssid.ssid_len); | 457 | memcpy(ssid->ssid, bss_cfg->ssid.ssid, bss_cfg->ssid.ssid_len); |
455 | cmd_size += sizeof(struct host_cmd_tlv) + | 458 | cmd_size += sizeof(struct mwifiex_ie_types_header) + |
456 | bss_cfg->ssid.ssid_len; | 459 | bss_cfg->ssid.ssid_len; |
457 | tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len; | 460 | tlv += sizeof(struct mwifiex_ie_types_header) + |
461 | bss_cfg->ssid.ssid_len; | ||
458 | 462 | ||
459 | bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv; | 463 | bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv; |
460 | bcast_ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID); | 464 | bcast_ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID); |
461 | bcast_ssid->tlv.len = | 465 | bcast_ssid->header.len = |
462 | cpu_to_le16(sizeof(bcast_ssid->bcast_ctl)); | 466 | cpu_to_le16(sizeof(bcast_ssid->bcast_ctl)); |
463 | bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl; | 467 | bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl; |
464 | cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid); | 468 | cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid); |
@@ -466,13 +470,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
466 | } | 470 | } |
467 | if (bss_cfg->rates[0]) { | 471 | if (bss_cfg->rates[0]) { |
468 | tlv_rates = (struct host_cmd_tlv_rates *)tlv; | 472 | tlv_rates = (struct host_cmd_tlv_rates *)tlv; |
469 | tlv_rates->tlv.type = cpu_to_le16(TLV_TYPE_UAP_RATES); | 473 | tlv_rates->header.type = cpu_to_le16(TLV_TYPE_UAP_RATES); |
470 | 474 | ||
471 | for (i = 0; i < MWIFIEX_SUPPORTED_RATES && bss_cfg->rates[i]; | 475 | for (i = 0; i < MWIFIEX_SUPPORTED_RATES && bss_cfg->rates[i]; |
472 | i++) | 476 | i++) |
473 | tlv_rates->rates[i] = bss_cfg->rates[i]; | 477 | tlv_rates->rates[i] = bss_cfg->rates[i]; |
474 | 478 | ||
475 | tlv_rates->tlv.len = cpu_to_le16(i); | 479 | tlv_rates->header.len = cpu_to_le16(i); |
476 | cmd_size += sizeof(struct host_cmd_tlv_rates) + i; | 480 | cmd_size += sizeof(struct host_cmd_tlv_rates) + i; |
477 | tlv += sizeof(struct host_cmd_tlv_rates) + i; | 481 | tlv += sizeof(struct host_cmd_tlv_rates) + i; |
478 | } | 482 | } |
@@ -482,10 +486,10 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
482 | (bss_cfg->band_cfg == BAND_CONFIG_A && | 486 | (bss_cfg->band_cfg == BAND_CONFIG_A && |
483 | bss_cfg->channel <= MAX_CHANNEL_BAND_A))) { | 487 | bss_cfg->channel <= MAX_CHANNEL_BAND_A))) { |
484 | chan_band = (struct host_cmd_tlv_channel_band *)tlv; | 488 | chan_band = (struct host_cmd_tlv_channel_band *)tlv; |
485 | chan_band->tlv.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST); | 489 | chan_band->header.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST); |
486 | chan_band->tlv.len = | 490 | chan_band->header.len = |
487 | cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band) - | 491 | cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band) - |
488 | sizeof(struct host_cmd_tlv)); | 492 | sizeof(struct mwifiex_ie_types_header)); |
489 | chan_band->band_config = bss_cfg->band_cfg; | 493 | chan_band->band_config = bss_cfg->band_cfg; |
490 | chan_band->channel = bss_cfg->channel; | 494 | chan_band->channel = bss_cfg->channel; |
491 | cmd_size += sizeof(struct host_cmd_tlv_channel_band); | 495 | cmd_size += sizeof(struct host_cmd_tlv_channel_band); |
@@ -494,11 +498,11 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
494 | if (bss_cfg->beacon_period >= MIN_BEACON_PERIOD && | 498 | if (bss_cfg->beacon_period >= MIN_BEACON_PERIOD && |
495 | bss_cfg->beacon_period <= MAX_BEACON_PERIOD) { | 499 | bss_cfg->beacon_period <= MAX_BEACON_PERIOD) { |
496 | beacon_period = (struct host_cmd_tlv_beacon_period *)tlv; | 500 | beacon_period = (struct host_cmd_tlv_beacon_period *)tlv; |
497 | beacon_period->tlv.type = | 501 | beacon_period->header.type = |
498 | cpu_to_le16(TLV_TYPE_UAP_BEACON_PERIOD); | 502 | cpu_to_le16(TLV_TYPE_UAP_BEACON_PERIOD); |
499 | beacon_period->tlv.len = | 503 | beacon_period->header.len = |
500 | cpu_to_le16(sizeof(struct host_cmd_tlv_beacon_period) - | 504 | cpu_to_le16(sizeof(struct host_cmd_tlv_beacon_period) - |
501 | sizeof(struct host_cmd_tlv)); | 505 | sizeof(struct mwifiex_ie_types_header)); |
502 | beacon_period->period = cpu_to_le16(bss_cfg->beacon_period); | 506 | beacon_period->period = cpu_to_le16(bss_cfg->beacon_period); |
503 | cmd_size += sizeof(struct host_cmd_tlv_beacon_period); | 507 | cmd_size += sizeof(struct host_cmd_tlv_beacon_period); |
504 | tlv += sizeof(struct host_cmd_tlv_beacon_period); | 508 | tlv += sizeof(struct host_cmd_tlv_beacon_period); |
@@ -506,21 +510,22 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
506 | if (bss_cfg->dtim_period >= MIN_DTIM_PERIOD && | 510 | if (bss_cfg->dtim_period >= MIN_DTIM_PERIOD && |
507 | bss_cfg->dtim_period <= MAX_DTIM_PERIOD) { | 511 | bss_cfg->dtim_period <= MAX_DTIM_PERIOD) { |
508 | dtim_period = (struct host_cmd_tlv_dtim_period *)tlv; | 512 | dtim_period = (struct host_cmd_tlv_dtim_period *)tlv; |
509 | dtim_period->tlv.type = cpu_to_le16(TLV_TYPE_UAP_DTIM_PERIOD); | 513 | dtim_period->header.type = |
510 | dtim_period->tlv.len = | 514 | cpu_to_le16(TLV_TYPE_UAP_DTIM_PERIOD); |
515 | dtim_period->header.len = | ||
511 | cpu_to_le16(sizeof(struct host_cmd_tlv_dtim_period) - | 516 | cpu_to_le16(sizeof(struct host_cmd_tlv_dtim_period) - |
512 | sizeof(struct host_cmd_tlv)); | 517 | sizeof(struct mwifiex_ie_types_header)); |
513 | dtim_period->period = bss_cfg->dtim_period; | 518 | dtim_period->period = bss_cfg->dtim_period; |
514 | cmd_size += sizeof(struct host_cmd_tlv_dtim_period); | 519 | cmd_size += sizeof(struct host_cmd_tlv_dtim_period); |
515 | tlv += sizeof(struct host_cmd_tlv_dtim_period); | 520 | tlv += sizeof(struct host_cmd_tlv_dtim_period); |
516 | } | 521 | } |
517 | if (bss_cfg->rts_threshold <= MWIFIEX_RTS_MAX_VALUE) { | 522 | if (bss_cfg->rts_threshold <= MWIFIEX_RTS_MAX_VALUE) { |
518 | rts_threshold = (struct host_cmd_tlv_rts_threshold *)tlv; | 523 | rts_threshold = (struct host_cmd_tlv_rts_threshold *)tlv; |
519 | rts_threshold->tlv.type = | 524 | rts_threshold->header.type = |
520 | cpu_to_le16(TLV_TYPE_UAP_RTS_THRESHOLD); | 525 | cpu_to_le16(TLV_TYPE_UAP_RTS_THRESHOLD); |
521 | rts_threshold->tlv.len = | 526 | rts_threshold->header.len = |
522 | cpu_to_le16(sizeof(struct host_cmd_tlv_rts_threshold) - | 527 | cpu_to_le16(sizeof(struct host_cmd_tlv_rts_threshold) - |
523 | sizeof(struct host_cmd_tlv)); | 528 | sizeof(struct mwifiex_ie_types_header)); |
524 | rts_threshold->rts_thr = cpu_to_le16(bss_cfg->rts_threshold); | 529 | rts_threshold->rts_thr = cpu_to_le16(bss_cfg->rts_threshold); |
525 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); | 530 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); |
526 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); | 531 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); |
@@ -528,21 +533,22 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
528 | if ((bss_cfg->frag_threshold >= MWIFIEX_FRAG_MIN_VALUE) && | 533 | if ((bss_cfg->frag_threshold >= MWIFIEX_FRAG_MIN_VALUE) && |
529 | (bss_cfg->frag_threshold <= MWIFIEX_FRAG_MAX_VALUE)) { | 534 | (bss_cfg->frag_threshold <= MWIFIEX_FRAG_MAX_VALUE)) { |
530 | frag_threshold = (struct host_cmd_tlv_frag_threshold *)tlv; | 535 | frag_threshold = (struct host_cmd_tlv_frag_threshold *)tlv; |
531 | frag_threshold->tlv.type = | 536 | frag_threshold->header.type = |
532 | cpu_to_le16(TLV_TYPE_UAP_FRAG_THRESHOLD); | 537 | cpu_to_le16(TLV_TYPE_UAP_FRAG_THRESHOLD); |
533 | frag_threshold->tlv.len = | 538 | frag_threshold->header.len = |
534 | cpu_to_le16(sizeof(struct host_cmd_tlv_frag_threshold) - | 539 | cpu_to_le16(sizeof(struct host_cmd_tlv_frag_threshold) - |
535 | sizeof(struct host_cmd_tlv)); | 540 | sizeof(struct mwifiex_ie_types_header)); |
536 | frag_threshold->frag_thr = cpu_to_le16(bss_cfg->frag_threshold); | 541 | frag_threshold->frag_thr = cpu_to_le16(bss_cfg->frag_threshold); |
537 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); | 542 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); |
538 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); | 543 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); |
539 | } | 544 | } |
540 | if (bss_cfg->retry_limit <= MWIFIEX_RETRY_LIMIT) { | 545 | if (bss_cfg->retry_limit <= MWIFIEX_RETRY_LIMIT) { |
541 | retry_limit = (struct host_cmd_tlv_retry_limit *)tlv; | 546 | retry_limit = (struct host_cmd_tlv_retry_limit *)tlv; |
542 | retry_limit->tlv.type = cpu_to_le16(TLV_TYPE_UAP_RETRY_LIMIT); | 547 | retry_limit->header.type = |
543 | retry_limit->tlv.len = | 548 | cpu_to_le16(TLV_TYPE_UAP_RETRY_LIMIT); |
549 | retry_limit->header.len = | ||
544 | cpu_to_le16(sizeof(struct host_cmd_tlv_retry_limit) - | 550 | cpu_to_le16(sizeof(struct host_cmd_tlv_retry_limit) - |
545 | sizeof(struct host_cmd_tlv)); | 551 | sizeof(struct mwifiex_ie_types_header)); |
546 | retry_limit->limit = (u8)bss_cfg->retry_limit; | 552 | retry_limit->limit = (u8)bss_cfg->retry_limit; |
547 | cmd_size += sizeof(struct host_cmd_tlv_retry_limit); | 553 | cmd_size += sizeof(struct host_cmd_tlv_retry_limit); |
548 | tlv += sizeof(struct host_cmd_tlv_retry_limit); | 554 | tlv += sizeof(struct host_cmd_tlv_retry_limit); |
@@ -557,21 +563,21 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
557 | if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) || | 563 | if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) || |
558 | (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) { | 564 | (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) { |
559 | auth_type = (struct host_cmd_tlv_auth_type *)tlv; | 565 | auth_type = (struct host_cmd_tlv_auth_type *)tlv; |
560 | auth_type->tlv.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE); | 566 | auth_type->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE); |
561 | auth_type->tlv.len = | 567 | auth_type->header.len = |
562 | cpu_to_le16(sizeof(struct host_cmd_tlv_auth_type) - | 568 | cpu_to_le16(sizeof(struct host_cmd_tlv_auth_type) - |
563 | sizeof(struct host_cmd_tlv)); | 569 | sizeof(struct mwifiex_ie_types_header)); |
564 | auth_type->auth_type = (u8)bss_cfg->auth_mode; | 570 | auth_type->auth_type = (u8)bss_cfg->auth_mode; |
565 | cmd_size += sizeof(struct host_cmd_tlv_auth_type); | 571 | cmd_size += sizeof(struct host_cmd_tlv_auth_type); |
566 | tlv += sizeof(struct host_cmd_tlv_auth_type); | 572 | tlv += sizeof(struct host_cmd_tlv_auth_type); |
567 | } | 573 | } |
568 | if (bss_cfg->protocol) { | 574 | if (bss_cfg->protocol) { |
569 | encrypt_protocol = (struct host_cmd_tlv_encrypt_protocol *)tlv; | 575 | encrypt_protocol = (struct host_cmd_tlv_encrypt_protocol *)tlv; |
570 | encrypt_protocol->tlv.type = | 576 | encrypt_protocol->header.type = |
571 | cpu_to_le16(TLV_TYPE_UAP_ENCRY_PROTOCOL); | 577 | cpu_to_le16(TLV_TYPE_UAP_ENCRY_PROTOCOL); |
572 | encrypt_protocol->tlv.len = | 578 | encrypt_protocol->header.len = |
573 | cpu_to_le16(sizeof(struct host_cmd_tlv_encrypt_protocol) | 579 | cpu_to_le16(sizeof(struct host_cmd_tlv_encrypt_protocol) |
574 | - sizeof(struct host_cmd_tlv)); | 580 | - sizeof(struct mwifiex_ie_types_header)); |
575 | encrypt_protocol->proto = cpu_to_le16(bss_cfg->protocol); | 581 | encrypt_protocol->proto = cpu_to_le16(bss_cfg->protocol); |
576 | cmd_size += sizeof(struct host_cmd_tlv_encrypt_protocol); | 582 | cmd_size += sizeof(struct host_cmd_tlv_encrypt_protocol); |
577 | tlv += sizeof(struct host_cmd_tlv_encrypt_protocol); | 583 | tlv += sizeof(struct host_cmd_tlv_encrypt_protocol); |
@@ -608,9 +614,9 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
608 | 614 | ||
609 | if (bss_cfg->sta_ao_timer) { | 615 | if (bss_cfg->sta_ao_timer) { |
610 | ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; | 616 | ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; |
611 | ao_timer->tlv.type = cpu_to_le16(TLV_TYPE_UAP_AO_TIMER); | 617 | ao_timer->header.type = cpu_to_le16(TLV_TYPE_UAP_AO_TIMER); |
612 | ao_timer->tlv.len = cpu_to_le16(sizeof(*ao_timer) - | 618 | ao_timer->header.len = cpu_to_le16(sizeof(*ao_timer) - |
613 | sizeof(struct host_cmd_tlv)); | 619 | sizeof(struct mwifiex_ie_types_header)); |
614 | ao_timer->sta_ao_timer = cpu_to_le32(bss_cfg->sta_ao_timer); | 620 | ao_timer->sta_ao_timer = cpu_to_le32(bss_cfg->sta_ao_timer); |
615 | cmd_size += sizeof(*ao_timer); | 621 | cmd_size += sizeof(*ao_timer); |
616 | tlv += sizeof(*ao_timer); | 622 | tlv += sizeof(*ao_timer); |
@@ -618,9 +624,10 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
618 | 624 | ||
619 | if (bss_cfg->ps_sta_ao_timer) { | 625 | if (bss_cfg->ps_sta_ao_timer) { |
620 | ps_ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; | 626 | ps_ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; |
621 | ps_ao_timer->tlv.type = cpu_to_le16(TLV_TYPE_UAP_PS_AO_TIMER); | 627 | ps_ao_timer->header.type = |
622 | ps_ao_timer->tlv.len = cpu_to_le16(sizeof(*ps_ao_timer) - | 628 | cpu_to_le16(TLV_TYPE_UAP_PS_AO_TIMER); |
623 | sizeof(struct host_cmd_tlv)); | 629 | ps_ao_timer->header.len = cpu_to_le16(sizeof(*ps_ao_timer) - |
630 | sizeof(struct mwifiex_ie_types_header)); | ||
624 | ps_ao_timer->sta_ao_timer = | 631 | ps_ao_timer->sta_ao_timer = |
625 | cpu_to_le32(bss_cfg->ps_sta_ao_timer); | 632 | cpu_to_le32(bss_cfg->ps_sta_ao_timer); |
626 | cmd_size += sizeof(*ps_ao_timer); | 633 | cmd_size += sizeof(*ps_ao_timer); |
@@ -636,16 +643,17 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
636 | static int mwifiex_uap_custom_ie_prepare(u8 *tlv, void *cmd_buf, u16 *ie_size) | 643 | static int mwifiex_uap_custom_ie_prepare(u8 *tlv, void *cmd_buf, u16 *ie_size) |
637 | { | 644 | { |
638 | struct mwifiex_ie_list *ap_ie = cmd_buf; | 645 | struct mwifiex_ie_list *ap_ie = cmd_buf; |
639 | struct host_cmd_tlv *tlv_ie = (struct host_cmd_tlv *)tlv; | 646 | struct mwifiex_ie_types_header *tlv_ie = (void *)tlv; |
640 | 647 | ||
641 | if (!ap_ie || !ap_ie->len || !ap_ie->ie_list) | 648 | if (!ap_ie || !ap_ie->len || !ap_ie->ie_list) |
642 | return -1; | 649 | return -1; |
643 | 650 | ||
644 | *ie_size += le16_to_cpu(ap_ie->len) + sizeof(struct host_cmd_tlv); | 651 | *ie_size += le16_to_cpu(ap_ie->len) + |
652 | sizeof(struct mwifiex_ie_types_header); | ||
645 | 653 | ||
646 | tlv_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE); | 654 | tlv_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE); |
647 | tlv_ie->len = ap_ie->len; | 655 | tlv_ie->len = ap_ie->len; |
648 | tlv += sizeof(struct host_cmd_tlv); | 656 | tlv += sizeof(struct mwifiex_ie_types_header); |
649 | 657 | ||
650 | memcpy(tlv, ap_ie->ie_list, le16_to_cpu(ap_ie->len)); | 658 | memcpy(tlv, ap_ie->ie_list, le16_to_cpu(ap_ie->len)); |
651 | 659 | ||
diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c index a018e42d117e..1cfe5a738c47 100644 --- a/drivers/net/wireless/mwifiex/uap_txrx.c +++ b/drivers/net/wireless/mwifiex/uap_txrx.c | |||
@@ -24,6 +24,69 @@ | |||
24 | #include "11n_aggr.h" | 24 | #include "11n_aggr.h" |
25 | #include "11n_rxreorder.h" | 25 | #include "11n_rxreorder.h" |
26 | 26 | ||
27 | /* This function checks if particular RA list has packets more than low bridge | ||
28 | * packet threshold and then deletes packet from this RA list. | ||
29 | * Function deletes packets from such RA list and returns true. If no such list | ||
30 | * is found, false is returned. | ||
31 | */ | ||
32 | static bool | ||
33 | mwifiex_uap_del_tx_pkts_in_ralist(struct mwifiex_private *priv, | ||
34 | struct list_head *ra_list_head) | ||
35 | { | ||
36 | struct mwifiex_ra_list_tbl *ra_list; | ||
37 | struct sk_buff *skb, *tmp; | ||
38 | bool pkt_deleted = false; | ||
39 | struct mwifiex_txinfo *tx_info; | ||
40 | struct mwifiex_adapter *adapter = priv->adapter; | ||
41 | |||
42 | list_for_each_entry(ra_list, ra_list_head, list) { | ||
43 | if (skb_queue_empty(&ra_list->skb_head)) | ||
44 | continue; | ||
45 | |||
46 | skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) { | ||
47 | tx_info = MWIFIEX_SKB_TXCB(skb); | ||
48 | if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) { | ||
49 | __skb_unlink(skb, &ra_list->skb_head); | ||
50 | mwifiex_write_data_complete(adapter, skb, 0, | ||
51 | -1); | ||
52 | atomic_dec(&priv->wmm.tx_pkts_queued); | ||
53 | pkt_deleted = true; | ||
54 | } | ||
55 | if ((atomic_read(&adapter->pending_bridged_pkts) <= | ||
56 | MWIFIEX_BRIDGED_PKTS_THR_LOW)) | ||
57 | break; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | return pkt_deleted; | ||
62 | } | ||
63 | |||
64 | /* This function deletes packets from particular RA List. RA list index | ||
65 | * from which packets are deleted is preserved so that packets from next RA | ||
66 | * list are deleted upon subsequent call thus maintaining fairness. | ||
67 | */ | ||
68 | static void mwifiex_uap_cleanup_tx_queues(struct mwifiex_private *priv) | ||
69 | { | ||
70 | unsigned long flags; | ||
71 | struct list_head *ra_list; | ||
72 | int i; | ||
73 | |||
74 | spin_lock_irqsave(&priv->wmm.ra_list_spinlock, flags); | ||
75 | |||
76 | for (i = 0; i < MAX_NUM_TID; i++, priv->del_list_idx++) { | ||
77 | if (priv->del_list_idx == MAX_NUM_TID) | ||
78 | priv->del_list_idx = 0; | ||
79 | ra_list = &priv->wmm.tid_tbl_ptr[priv->del_list_idx].ra_list; | ||
80 | if (mwifiex_uap_del_tx_pkts_in_ralist(priv, ra_list)) { | ||
81 | priv->del_list_idx++; | ||
82 | break; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); | ||
87 | } | ||
88 | |||
89 | |||
27 | static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | 90 | static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, |
28 | struct sk_buff *skb) | 91 | struct sk_buff *skb) |
29 | { | 92 | { |
@@ -40,10 +103,11 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | |||
40 | rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); | 103 | rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); |
41 | 104 | ||
42 | if ((atomic_read(&adapter->pending_bridged_pkts) >= | 105 | if ((atomic_read(&adapter->pending_bridged_pkts) >= |
43 | MWIFIEX_BRIDGED_PKTS_THRESHOLD)) { | 106 | MWIFIEX_BRIDGED_PKTS_THR_HIGH)) { |
44 | dev_err(priv->adapter->dev, | 107 | dev_err(priv->adapter->dev, |
45 | "Tx: Bridge packet limit reached. Drop packet!\n"); | 108 | "Tx: Bridge packet limit reached. Drop packet!\n"); |
46 | kfree_skb(skb); | 109 | kfree_skb(skb); |
110 | mwifiex_uap_cleanup_tx_queues(priv); | ||
47 | return; | 111 | return; |
48 | } | 112 | } |
49 | 113 | ||
@@ -95,10 +159,6 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | |||
95 | atomic_inc(&adapter->tx_pending); | 159 | atomic_inc(&adapter->tx_pending); |
96 | atomic_inc(&adapter->pending_bridged_pkts); | 160 | atomic_inc(&adapter->pending_bridged_pkts); |
97 | 161 | ||
98 | if ((atomic_read(&adapter->tx_pending) >= MAX_TX_PENDING)) { | ||
99 | mwifiex_set_trans_start(priv->netdev); | ||
100 | mwifiex_stop_net_dev_queue(priv->netdev, priv->adapter); | ||
101 | } | ||
102 | return; | 162 | return; |
103 | } | 163 | } |
104 | 164 | ||
diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c index f90fe21e5bfd..2472d4b7f00e 100644 --- a/drivers/net/wireless/mwifiex/usb.c +++ b/drivers/net/wireless/mwifiex/usb.c | |||
@@ -24,9 +24,9 @@ | |||
24 | 24 | ||
25 | static const char usbdriver_name[] = "usb8797"; | 25 | static const char usbdriver_name[] = "usb8797"; |
26 | 26 | ||
27 | static u8 user_rmmod; | ||
28 | static struct mwifiex_if_ops usb_ops; | 27 | static struct mwifiex_if_ops usb_ops; |
29 | static struct semaphore add_remove_card_sem; | 28 | static struct semaphore add_remove_card_sem; |
29 | static struct usb_card_rec *usb_card; | ||
30 | 30 | ||
31 | static struct usb_device_id mwifiex_usb_table[] = { | 31 | static struct usb_device_id mwifiex_usb_table[] = { |
32 | {USB_DEVICE(USB8797_VID, USB8797_PID_1)}, | 32 | {USB_DEVICE(USB8797_VID, USB8797_PID_1)}, |
@@ -350,6 +350,7 @@ static int mwifiex_usb_probe(struct usb_interface *intf, | |||
350 | 350 | ||
351 | card->udev = udev; | 351 | card->udev = udev; |
352 | card->intf = intf; | 352 | card->intf = intf; |
353 | usb_card = card; | ||
353 | 354 | ||
354 | pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocol=%#x\n", | 355 | pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocol=%#x\n", |
355 | udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass, | 356 | udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass, |
@@ -532,7 +533,6 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf) | |||
532 | { | 533 | { |
533 | struct usb_card_rec *card = usb_get_intfdata(intf); | 534 | struct usb_card_rec *card = usb_get_intfdata(intf); |
534 | struct mwifiex_adapter *adapter; | 535 | struct mwifiex_adapter *adapter; |
535 | int i; | ||
536 | 536 | ||
537 | if (!card || !card->adapter) { | 537 | if (!card || !card->adapter) { |
538 | pr_err("%s: card or card->adapter is NULL\n", __func__); | 538 | pr_err("%s: card or card->adapter is NULL\n", __func__); |
@@ -543,27 +543,6 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf) | |||
543 | if (!adapter->priv_num) | 543 | if (!adapter->priv_num) |
544 | return; | 544 | return; |
545 | 545 | ||
546 | /* In case driver is removed when asynchronous FW downloading is | ||
547 | * in progress | ||
548 | */ | ||
549 | wait_for_completion(&adapter->fw_load); | ||
550 | |||
551 | if (user_rmmod) { | ||
552 | #ifdef CONFIG_PM | ||
553 | if (adapter->is_suspended) | ||
554 | mwifiex_usb_resume(intf); | ||
555 | #endif | ||
556 | for (i = 0; i < adapter->priv_num; i++) | ||
557 | if ((GET_BSS_ROLE(adapter->priv[i]) == | ||
558 | MWIFIEX_BSS_ROLE_STA) && | ||
559 | adapter->priv[i]->media_connected) | ||
560 | mwifiex_deauthenticate(adapter->priv[i], NULL); | ||
561 | |||
562 | mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, | ||
563 | MWIFIEX_BSS_ROLE_ANY), | ||
564 | MWIFIEX_FUNC_SHUTDOWN); | ||
565 | } | ||
566 | |||
567 | mwifiex_usb_free(card); | 546 | mwifiex_usb_free(card); |
568 | 547 | ||
569 | dev_dbg(adapter->dev, "%s: removing card\n", __func__); | 548 | dev_dbg(adapter->dev, "%s: removing card\n", __func__); |
@@ -786,6 +765,13 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) | |||
786 | return 0; | 765 | return 0; |
787 | } | 766 | } |
788 | 767 | ||
768 | static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) | ||
769 | { | ||
770 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; | ||
771 | |||
772 | usb_set_intfdata(card->intf, NULL); | ||
773 | } | ||
774 | |||
789 | static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, | 775 | static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, |
790 | struct mwifiex_fw_image *fw) | 776 | struct mwifiex_fw_image *fw) |
791 | { | 777 | { |
@@ -978,6 +964,7 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) | |||
978 | 964 | ||
979 | static struct mwifiex_if_ops usb_ops = { | 965 | static struct mwifiex_if_ops usb_ops = { |
980 | .register_dev = mwifiex_register_dev, | 966 | .register_dev = mwifiex_register_dev, |
967 | .unregister_dev = mwifiex_unregister_dev, | ||
981 | .wakeup = mwifiex_pm_wakeup_card, | 968 | .wakeup = mwifiex_pm_wakeup_card, |
982 | .wakeup_complete = mwifiex_pm_wakeup_card_complete, | 969 | .wakeup_complete = mwifiex_pm_wakeup_card_complete, |
983 | 970 | ||
@@ -1024,8 +1011,29 @@ static void mwifiex_usb_cleanup_module(void) | |||
1024 | if (!down_interruptible(&add_remove_card_sem)) | 1011 | if (!down_interruptible(&add_remove_card_sem)) |
1025 | up(&add_remove_card_sem); | 1012 | up(&add_remove_card_sem); |
1026 | 1013 | ||
1027 | /* set the flag as user is removing this module */ | 1014 | if (usb_card) { |
1028 | user_rmmod = 1; | 1015 | struct mwifiex_adapter *adapter = usb_card->adapter; |
1016 | int i; | ||
1017 | |||
1018 | /* In case driver is removed when asynchronous FW downloading is | ||
1019 | * in progress | ||
1020 | */ | ||
1021 | wait_for_completion(&adapter->fw_load); | ||
1022 | |||
1023 | #ifdef CONFIG_PM | ||
1024 | if (adapter->is_suspended) | ||
1025 | mwifiex_usb_resume(usb_card->intf); | ||
1026 | #endif | ||
1027 | for (i = 0; i < adapter->priv_num; i++) | ||
1028 | if ((GET_BSS_ROLE(adapter->priv[i]) == | ||
1029 | MWIFIEX_BSS_ROLE_STA) && | ||
1030 | adapter->priv[i]->media_connected) | ||
1031 | mwifiex_deauthenticate(adapter->priv[i], NULL); | ||
1032 | |||
1033 | mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, | ||
1034 | MWIFIEX_BSS_ROLE_ANY), | ||
1035 | MWIFIEX_FUNC_SHUTDOWN); | ||
1036 | } | ||
1029 | 1037 | ||
1030 | usb_deregister(&mwifiex_usb_driver); | 1038 | usb_deregister(&mwifiex_usb_driver); |
1031 | } | 1039 | } |
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index 944e8846f6fc..2e8f9cdea54d 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c | |||
@@ -120,7 +120,7 @@ mwifiex_wmm_allocate_ralist_node(struct mwifiex_adapter *adapter, u8 *ra) | |||
120 | 120 | ||
121 | memcpy(ra_list->ra, ra, ETH_ALEN); | 121 | memcpy(ra_list->ra, ra, ETH_ALEN); |
122 | 122 | ||
123 | ra_list->total_pkts_size = 0; | 123 | ra_list->total_pkt_count = 0; |
124 | 124 | ||
125 | dev_dbg(adapter->dev, "info: allocated ra_list %p\n", ra_list); | 125 | dev_dbg(adapter->dev, "info: allocated ra_list %p\n", ra_list); |
126 | 126 | ||
@@ -188,7 +188,7 @@ mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra) | |||
188 | ra_list, ra_list->is_11n_enabled); | 188 | ra_list, ra_list->is_11n_enabled); |
189 | 189 | ||
190 | if (ra_list->is_11n_enabled) { | 190 | if (ra_list->is_11n_enabled) { |
191 | ra_list->pkt_count = 0; | 191 | ra_list->ba_pkt_count = 0; |
192 | ra_list->ba_packet_thr = | 192 | ra_list->ba_packet_thr = |
193 | mwifiex_get_random_ba_threshold(); | 193 | mwifiex_get_random_ba_threshold(); |
194 | } | 194 | } |
@@ -679,8 +679,8 @@ mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv, | |||
679 | 679 | ||
680 | skb_queue_tail(&ra_list->skb_head, skb); | 680 | skb_queue_tail(&ra_list->skb_head, skb); |
681 | 681 | ||
682 | ra_list->total_pkts_size += skb->len; | 682 | ra_list->ba_pkt_count++; |
683 | ra_list->pkt_count++; | 683 | ra_list->total_pkt_count++; |
684 | 684 | ||
685 | if (atomic_read(&priv->wmm.highest_queued_prio) < | 685 | if (atomic_read(&priv->wmm.highest_queued_prio) < |
686 | tos_to_tid_inv[tid_down]) | 686 | tos_to_tid_inv[tid_down]) |
@@ -1037,7 +1037,7 @@ mwifiex_send_single_packet(struct mwifiex_private *priv, | |||
1037 | tx_info = MWIFIEX_SKB_TXCB(skb); | 1037 | tx_info = MWIFIEX_SKB_TXCB(skb); |
1038 | dev_dbg(adapter->dev, "data: dequeuing the packet %p %p\n", ptr, skb); | 1038 | dev_dbg(adapter->dev, "data: dequeuing the packet %p %p\n", ptr, skb); |
1039 | 1039 | ||
1040 | ptr->total_pkts_size -= skb->len; | 1040 | ptr->total_pkt_count--; |
1041 | 1041 | ||
1042 | if (!skb_queue_empty(&ptr->skb_head)) | 1042 | if (!skb_queue_empty(&ptr->skb_head)) |
1043 | skb_next = skb_peek(&ptr->skb_head); | 1043 | skb_next = skb_peek(&ptr->skb_head); |
@@ -1062,8 +1062,8 @@ mwifiex_send_single_packet(struct mwifiex_private *priv, | |||
1062 | 1062 | ||
1063 | skb_queue_tail(&ptr->skb_head, skb); | 1063 | skb_queue_tail(&ptr->skb_head, skb); |
1064 | 1064 | ||
1065 | ptr->total_pkts_size += skb->len; | 1065 | ptr->total_pkt_count++; |
1066 | ptr->pkt_count++; | 1066 | ptr->ba_pkt_count++; |
1067 | tx_info->flags |= MWIFIEX_BUF_FLAG_REQUEUED_PKT; | 1067 | tx_info->flags |= MWIFIEX_BUF_FLAG_REQUEUED_PKT; |
1068 | spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, | 1068 | spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, |
1069 | ra_list_flags); | 1069 | ra_list_flags); |
@@ -1224,7 +1224,7 @@ mwifiex_dequeue_tx_packet(struct mwifiex_adapter *adapter) | |||
1224 | mwifiex_send_single_packet() */ | 1224 | mwifiex_send_single_packet() */ |
1225 | } else { | 1225 | } else { |
1226 | if (mwifiex_is_ampdu_allowed(priv, tid) && | 1226 | if (mwifiex_is_ampdu_allowed(priv, tid) && |
1227 | ptr->pkt_count > ptr->ba_packet_thr) { | 1227 | ptr->ba_pkt_count > ptr->ba_packet_thr) { |
1228 | if (mwifiex_space_avail_for_new_ba_stream(adapter)) { | 1228 | if (mwifiex_space_avail_for_new_ba_stream(adapter)) { |
1229 | mwifiex_create_ba_tbl(priv, ptr->ra, tid, | 1229 | mwifiex_create_ba_tbl(priv, ptr->ra, tid, |
1230 | BA_SETUP_INPROGRESS); | 1230 | BA_SETUP_INPROGRESS); |
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index 9b915d3a44be..68dbbb9c6d12 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | menuconfig RT2X00 | 1 | menuconfig RT2X00 |
2 | tristate "Ralink driver support" | 2 | tristate "Ralink driver support" |
3 | depends on MAC80211 | 3 | depends on MAC80211 && HAS_DMA |
4 | ---help--- | 4 | ---help--- |
5 | This will enable the support for the Ralink drivers, | 5 | This will enable the support for the Ralink drivers, |
6 | developed in the rt2x00 project <http://rt2x00.serialmonkey.com>. | 6 | developed in the rt2x00 project <http://rt2x00.serialmonkey.com>. |
@@ -166,6 +166,12 @@ config RT2800USB_RT35XX | |||
166 | rt2800usb driver. | 166 | rt2800usb driver. |
167 | Supported chips: RT3572 | 167 | Supported chips: RT3572 |
168 | 168 | ||
169 | config RT2800USB_RT3573 | ||
170 | bool "rt2800usb - Include support for rt3573 devices (EXPERIMENTAL)" | ||
171 | ---help--- | ||
172 | This enables support for RT3573 chipset based wireless USB devices | ||
173 | in the rt2800usb driver. | ||
174 | |||
169 | config RT2800USB_RT53XX | 175 | config RT2800USB_RT53XX |
170 | bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)" | 176 | bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)" |
171 | ---help--- | 177 | ---help--- |
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index d78c495a86a0..fa33b5edf931 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h | |||
@@ -88,6 +88,7 @@ | |||
88 | #define REV_RT3071E 0x0211 | 88 | #define REV_RT3071E 0x0211 |
89 | #define REV_RT3090E 0x0211 | 89 | #define REV_RT3090E 0x0211 |
90 | #define REV_RT3390E 0x0211 | 90 | #define REV_RT3390E 0x0211 |
91 | #define REV_RT3593E 0x0211 | ||
91 | #define REV_RT5390F 0x0502 | 92 | #define REV_RT5390F 0x0502 |
92 | #define REV_RT5390R 0x1502 | 93 | #define REV_RT5390R 0x1502 |
93 | #define REV_RT5592C 0x0221 | 94 | #define REV_RT5592C 0x0221 |
@@ -1082,6 +1083,15 @@ | |||
1082 | #define TX_PWR_CFG_0_9MBS FIELD32(0x00f00000) | 1083 | #define TX_PWR_CFG_0_9MBS FIELD32(0x00f00000) |
1083 | #define TX_PWR_CFG_0_12MBS FIELD32(0x0f000000) | 1084 | #define TX_PWR_CFG_0_12MBS FIELD32(0x0f000000) |
1084 | #define TX_PWR_CFG_0_18MBS FIELD32(0xf0000000) | 1085 | #define TX_PWR_CFG_0_18MBS FIELD32(0xf0000000) |
1086 | /* bits for 3T devices */ | ||
1087 | #define TX_PWR_CFG_0_CCK1_CH0 FIELD32(0x0000000f) | ||
1088 | #define TX_PWR_CFG_0_CCK1_CH1 FIELD32(0x000000f0) | ||
1089 | #define TX_PWR_CFG_0_CCK5_CH0 FIELD32(0x00000f00) | ||
1090 | #define TX_PWR_CFG_0_CCK5_CH1 FIELD32(0x0000f000) | ||
1091 | #define TX_PWR_CFG_0_OFDM6_CH0 FIELD32(0x000f0000) | ||
1092 | #define TX_PWR_CFG_0_OFDM6_CH1 FIELD32(0x00f00000) | ||
1093 | #define TX_PWR_CFG_0_OFDM12_CH0 FIELD32(0x0f000000) | ||
1094 | #define TX_PWR_CFG_0_OFDM12_CH1 FIELD32(0xf0000000) | ||
1085 | 1095 | ||
1086 | /* | 1096 | /* |
1087 | * TX_PWR_CFG_1: | 1097 | * TX_PWR_CFG_1: |
@@ -1095,6 +1105,15 @@ | |||
1095 | #define TX_PWR_CFG_1_MCS1 FIELD32(0x00f00000) | 1105 | #define TX_PWR_CFG_1_MCS1 FIELD32(0x00f00000) |
1096 | #define TX_PWR_CFG_1_MCS2 FIELD32(0x0f000000) | 1106 | #define TX_PWR_CFG_1_MCS2 FIELD32(0x0f000000) |
1097 | #define TX_PWR_CFG_1_MCS3 FIELD32(0xf0000000) | 1107 | #define TX_PWR_CFG_1_MCS3 FIELD32(0xf0000000) |
1108 | /* bits for 3T devices */ | ||
1109 | #define TX_PWR_CFG_1_OFDM24_CH0 FIELD32(0x0000000f) | ||
1110 | #define TX_PWR_CFG_1_OFDM24_CH1 FIELD32(0x000000f0) | ||
1111 | #define TX_PWR_CFG_1_OFDM48_CH0 FIELD32(0x00000f00) | ||
1112 | #define TX_PWR_CFG_1_OFDM48_CH1 FIELD32(0x0000f000) | ||
1113 | #define TX_PWR_CFG_1_MCS0_CH0 FIELD32(0x000f0000) | ||
1114 | #define TX_PWR_CFG_1_MCS0_CH1 FIELD32(0x00f00000) | ||
1115 | #define TX_PWR_CFG_1_MCS2_CH0 FIELD32(0x0f000000) | ||
1116 | #define TX_PWR_CFG_1_MCS2_CH1 FIELD32(0xf0000000) | ||
1098 | 1117 | ||
1099 | /* | 1118 | /* |
1100 | * TX_PWR_CFG_2: | 1119 | * TX_PWR_CFG_2: |
@@ -1108,6 +1127,15 @@ | |||
1108 | #define TX_PWR_CFG_2_MCS9 FIELD32(0x00f00000) | 1127 | #define TX_PWR_CFG_2_MCS9 FIELD32(0x00f00000) |
1109 | #define TX_PWR_CFG_2_MCS10 FIELD32(0x0f000000) | 1128 | #define TX_PWR_CFG_2_MCS10 FIELD32(0x0f000000) |
1110 | #define TX_PWR_CFG_2_MCS11 FIELD32(0xf0000000) | 1129 | #define TX_PWR_CFG_2_MCS11 FIELD32(0xf0000000) |
1130 | /* bits for 3T devices */ | ||
1131 | #define TX_PWR_CFG_2_MCS4_CH0 FIELD32(0x0000000f) | ||
1132 | #define TX_PWR_CFG_2_MCS4_CH1 FIELD32(0x000000f0) | ||
1133 | #define TX_PWR_CFG_2_MCS6_CH0 FIELD32(0x00000f00) | ||
1134 | #define TX_PWR_CFG_2_MCS6_CH1 FIELD32(0x0000f000) | ||
1135 | #define TX_PWR_CFG_2_MCS8_CH0 FIELD32(0x000f0000) | ||
1136 | #define TX_PWR_CFG_2_MCS8_CH1 FIELD32(0x00f00000) | ||
1137 | #define TX_PWR_CFG_2_MCS10_CH0 FIELD32(0x0f000000) | ||
1138 | #define TX_PWR_CFG_2_MCS10_CH1 FIELD32(0xf0000000) | ||
1111 | 1139 | ||
1112 | /* | 1140 | /* |
1113 | * TX_PWR_CFG_3: | 1141 | * TX_PWR_CFG_3: |
@@ -1121,6 +1149,15 @@ | |||
1121 | #define TX_PWR_CFG_3_UKNOWN2 FIELD32(0x00f00000) | 1149 | #define TX_PWR_CFG_3_UKNOWN2 FIELD32(0x00f00000) |
1122 | #define TX_PWR_CFG_3_UKNOWN3 FIELD32(0x0f000000) | 1150 | #define TX_PWR_CFG_3_UKNOWN3 FIELD32(0x0f000000) |
1123 | #define TX_PWR_CFG_3_UKNOWN4 FIELD32(0xf0000000) | 1151 | #define TX_PWR_CFG_3_UKNOWN4 FIELD32(0xf0000000) |
1152 | /* bits for 3T devices */ | ||
1153 | #define TX_PWR_CFG_3_MCS12_CH0 FIELD32(0x0000000f) | ||
1154 | #define TX_PWR_CFG_3_MCS12_CH1 FIELD32(0x000000f0) | ||
1155 | #define TX_PWR_CFG_3_MCS14_CH0 FIELD32(0x00000f00) | ||
1156 | #define TX_PWR_CFG_3_MCS14_CH1 FIELD32(0x0000f000) | ||
1157 | #define TX_PWR_CFG_3_STBC0_CH0 FIELD32(0x000f0000) | ||
1158 | #define TX_PWR_CFG_3_STBC0_CH1 FIELD32(0x00f00000) | ||
1159 | #define TX_PWR_CFG_3_STBC2_CH0 FIELD32(0x0f000000) | ||
1160 | #define TX_PWR_CFG_3_STBC2_CH1 FIELD32(0xf0000000) | ||
1124 | 1161 | ||
1125 | /* | 1162 | /* |
1126 | * TX_PWR_CFG_4: | 1163 | * TX_PWR_CFG_4: |
@@ -1130,6 +1167,11 @@ | |||
1130 | #define TX_PWR_CFG_4_UKNOWN6 FIELD32(0x000000f0) | 1167 | #define TX_PWR_CFG_4_UKNOWN6 FIELD32(0x000000f0) |
1131 | #define TX_PWR_CFG_4_UKNOWN7 FIELD32(0x00000f00) | 1168 | #define TX_PWR_CFG_4_UKNOWN7 FIELD32(0x00000f00) |
1132 | #define TX_PWR_CFG_4_UKNOWN8 FIELD32(0x0000f000) | 1169 | #define TX_PWR_CFG_4_UKNOWN8 FIELD32(0x0000f000) |
1170 | /* bits for 3T devices */ | ||
1171 | #define TX_PWR_CFG_3_STBC4_CH0 FIELD32(0x0000000f) | ||
1172 | #define TX_PWR_CFG_3_STBC4_CH1 FIELD32(0x000000f0) | ||
1173 | #define TX_PWR_CFG_3_STBC6_CH0 FIELD32(0x00000f00) | ||
1174 | #define TX_PWR_CFG_3_STBC6_CH1 FIELD32(0x0000f000) | ||
1133 | 1175 | ||
1134 | /* | 1176 | /* |
1135 | * TX_PIN_CFG: | 1177 | * TX_PIN_CFG: |
@@ -1451,6 +1493,81 @@ | |||
1451 | */ | 1493 | */ |
1452 | #define EXP_ACK_TIME 0x1380 | 1494 | #define EXP_ACK_TIME 0x1380 |
1453 | 1495 | ||
1496 | /* TX_PWR_CFG_5 */ | ||
1497 | #define TX_PWR_CFG_5 0x1384 | ||
1498 | #define TX_PWR_CFG_5_MCS16_CH0 FIELD32(0x0000000f) | ||
1499 | #define TX_PWR_CFG_5_MCS16_CH1 FIELD32(0x000000f0) | ||
1500 | #define TX_PWR_CFG_5_MCS16_CH2 FIELD32(0x00000f00) | ||
1501 | #define TX_PWR_CFG_5_MCS18_CH0 FIELD32(0x000f0000) | ||
1502 | #define TX_PWR_CFG_5_MCS18_CH1 FIELD32(0x00f00000) | ||
1503 | #define TX_PWR_CFG_5_MCS18_CH2 FIELD32(0x0f000000) | ||
1504 | |||
1505 | /* TX_PWR_CFG_6 */ | ||
1506 | #define TX_PWR_CFG_6 0x1388 | ||
1507 | #define TX_PWR_CFG_6_MCS20_CH0 FIELD32(0x0000000f) | ||
1508 | #define TX_PWR_CFG_6_MCS20_CH1 FIELD32(0x000000f0) | ||
1509 | #define TX_PWR_CFG_6_MCS20_CH2 FIELD32(0x00000f00) | ||
1510 | #define TX_PWR_CFG_6_MCS22_CH0 FIELD32(0x000f0000) | ||
1511 | #define TX_PWR_CFG_6_MCS22_CH1 FIELD32(0x00f00000) | ||
1512 | #define TX_PWR_CFG_6_MCS22_CH2 FIELD32(0x0f000000) | ||
1513 | |||
1514 | /* TX_PWR_CFG_0_EXT */ | ||
1515 | #define TX_PWR_CFG_0_EXT 0x1390 | ||
1516 | #define TX_PWR_CFG_0_EXT_CCK1_CH2 FIELD32(0x0000000f) | ||
1517 | #define TX_PWR_CFG_0_EXT_CCK5_CH2 FIELD32(0x00000f00) | ||
1518 | #define TX_PWR_CFG_0_EXT_OFDM6_CH2 FIELD32(0x000f0000) | ||
1519 | #define TX_PWR_CFG_0_EXT_OFDM12_CH2 FIELD32(0x0f000000) | ||
1520 | |||
1521 | /* TX_PWR_CFG_1_EXT */ | ||
1522 | #define TX_PWR_CFG_1_EXT 0x1394 | ||
1523 | #define TX_PWR_CFG_1_EXT_OFDM24_CH2 FIELD32(0x0000000f) | ||
1524 | #define TX_PWR_CFG_1_EXT_OFDM48_CH2 FIELD32(0x00000f00) | ||
1525 | #define TX_PWR_CFG_1_EXT_MCS0_CH2 FIELD32(0x000f0000) | ||
1526 | #define TX_PWR_CFG_1_EXT_MCS2_CH2 FIELD32(0x0f000000) | ||
1527 | |||
1528 | /* TX_PWR_CFG_2_EXT */ | ||
1529 | #define TX_PWR_CFG_2_EXT 0x1398 | ||
1530 | #define TX_PWR_CFG_2_EXT_MCS4_CH2 FIELD32(0x0000000f) | ||
1531 | #define TX_PWR_CFG_2_EXT_MCS6_CH2 FIELD32(0x00000f00) | ||
1532 | #define TX_PWR_CFG_2_EXT_MCS8_CH2 FIELD32(0x000f0000) | ||
1533 | #define TX_PWR_CFG_2_EXT_MCS10_CH2 FIELD32(0x0f000000) | ||
1534 | |||
1535 | /* TX_PWR_CFG_3_EXT */ | ||
1536 | #define TX_PWR_CFG_3_EXT 0x139c | ||
1537 | #define TX_PWR_CFG_3_EXT_MCS12_CH2 FIELD32(0x0000000f) | ||
1538 | #define TX_PWR_CFG_3_EXT_MCS14_CH2 FIELD32(0x00000f00) | ||
1539 | #define TX_PWR_CFG_3_EXT_STBC0_CH2 FIELD32(0x000f0000) | ||
1540 | #define TX_PWR_CFG_3_EXT_STBC2_CH2 FIELD32(0x0f000000) | ||
1541 | |||
1542 | /* TX_PWR_CFG_4_EXT */ | ||
1543 | #define TX_PWR_CFG_4_EXT 0x13a0 | ||
1544 | #define TX_PWR_CFG_4_EXT_STBC4_CH2 FIELD32(0x0000000f) | ||
1545 | #define TX_PWR_CFG_4_EXT_STBC6_CH2 FIELD32(0x00000f00) | ||
1546 | |||
1547 | /* TX_PWR_CFG_7 */ | ||
1548 | #define TX_PWR_CFG_7 0x13d4 | ||
1549 | #define TX_PWR_CFG_7_OFDM54_CH0 FIELD32(0x0000000f) | ||
1550 | #define TX_PWR_CFG_7_OFDM54_CH1 FIELD32(0x000000f0) | ||
1551 | #define TX_PWR_CFG_7_OFDM54_CH2 FIELD32(0x00000f00) | ||
1552 | #define TX_PWR_CFG_7_MCS7_CH0 FIELD32(0x000f0000) | ||
1553 | #define TX_PWR_CFG_7_MCS7_CH1 FIELD32(0x00f00000) | ||
1554 | #define TX_PWR_CFG_7_MCS7_CH2 FIELD32(0x0f000000) | ||
1555 | |||
1556 | /* TX_PWR_CFG_8 */ | ||
1557 | #define TX_PWR_CFG_8 0x13d8 | ||
1558 | #define TX_PWR_CFG_8_MCS15_CH0 FIELD32(0x0000000f) | ||
1559 | #define TX_PWR_CFG_8_MCS15_CH1 FIELD32(0x000000f0) | ||
1560 | #define TX_PWR_CFG_8_MCS15_CH2 FIELD32(0x00000f00) | ||
1561 | #define TX_PWR_CFG_8_MCS23_CH0 FIELD32(0x000f0000) | ||
1562 | #define TX_PWR_CFG_8_MCS23_CH1 FIELD32(0x00f00000) | ||
1563 | #define TX_PWR_CFG_8_MCS23_CH2 FIELD32(0x0f000000) | ||
1564 | |||
1565 | /* TX_PWR_CFG_9 */ | ||
1566 | #define TX_PWR_CFG_9 0x13dc | ||
1567 | #define TX_PWR_CFG_9_STBC7_CH0 FIELD32(0x0000000f) | ||
1568 | #define TX_PWR_CFG_9_STBC7_CH1 FIELD32(0x000000f0) | ||
1569 | #define TX_PWR_CFG_9_STBC7_CH2 FIELD32(0x00000f00) | ||
1570 | |||
1454 | /* | 1571 | /* |
1455 | * RX_FILTER_CFG: RX configuration register. | 1572 | * RX_FILTER_CFG: RX configuration register. |
1456 | */ | 1573 | */ |
@@ -1902,11 +2019,13 @@ struct mac_iveiv_entry { | |||
1902 | #define HW_BEACON_BASE6 0x5dc0 | 2019 | #define HW_BEACON_BASE6 0x5dc0 |
1903 | #define HW_BEACON_BASE7 0x5bc0 | 2020 | #define HW_BEACON_BASE7 0x5bc0 |
1904 | 2021 | ||
1905 | #define HW_BEACON_OFFSET(__index) \ | 2022 | #define HW_BEACON_BASE(__index) \ |
1906 | (((__index) < 4) ? (HW_BEACON_BASE0 + (__index * 0x0200)) : \ | 2023 | (((__index) < 4) ? (HW_BEACON_BASE0 + (__index * 0x0200)) : \ |
1907 | (((__index) < 6) ? (HW_BEACON_BASE4 + ((__index - 4) * 0x0200)) : \ | 2024 | (((__index) < 6) ? (HW_BEACON_BASE4 + ((__index - 4) * 0x0200)) : \ |
1908 | (HW_BEACON_BASE6 - ((__index - 6) * 0x0200)))) | 2025 | (HW_BEACON_BASE6 - ((__index - 6) * 0x0200)))) |
1909 | 2026 | ||
2027 | #define BEACON_BASE_TO_OFFSET(_base) (((_base) - 0x4000) / 64) | ||
2028 | |||
1910 | /* | 2029 | /* |
1911 | * BBP registers. | 2030 | * BBP registers. |
1912 | * The wordsize of the BBP is 8 bits. | 2031 | * The wordsize of the BBP is 8 bits. |
@@ -1975,6 +2094,10 @@ struct mac_iveiv_entry { | |||
1975 | #define BBP109_TX0_POWER FIELD8(0x0f) | 2094 | #define BBP109_TX0_POWER FIELD8(0x0f) |
1976 | #define BBP109_TX1_POWER FIELD8(0xf0) | 2095 | #define BBP109_TX1_POWER FIELD8(0xf0) |
1977 | 2096 | ||
2097 | /* BBP 110 */ | ||
2098 | #define BBP110_TX2_POWER FIELD8(0x0f) | ||
2099 | |||
2100 | |||
1978 | /* | 2101 | /* |
1979 | * BBP 138: Unknown | 2102 | * BBP 138: Unknown |
1980 | */ | 2103 | */ |
@@ -2024,6 +2147,12 @@ struct mac_iveiv_entry { | |||
2024 | #define RFCSR3_PA2_CASCODE_BIAS_CCKK FIELD8(0x80) | 2147 | #define RFCSR3_PA2_CASCODE_BIAS_CCKK FIELD8(0x80) |
2025 | /* Bits for RF3290/RF5360/RF5370/RF5372/RF5390/RF5392 */ | 2148 | /* Bits for RF3290/RF5360/RF5370/RF5372/RF5390/RF5392 */ |
2026 | #define RFCSR3_VCOCAL_EN FIELD8(0x80) | 2149 | #define RFCSR3_VCOCAL_EN FIELD8(0x80) |
2150 | /* Bits for RF3050 */ | ||
2151 | #define RFCSR3_BIT1 FIELD8(0x02) | ||
2152 | #define RFCSR3_BIT2 FIELD8(0x04) | ||
2153 | #define RFCSR3_BIT3 FIELD8(0x08) | ||
2154 | #define RFCSR3_BIT4 FIELD8(0x10) | ||
2155 | #define RFCSR3_BIT5 FIELD8(0x20) | ||
2027 | 2156 | ||
2028 | /* | 2157 | /* |
2029 | * FRCSR 5: | 2158 | * FRCSR 5: |
@@ -2036,6 +2165,8 @@ struct mac_iveiv_entry { | |||
2036 | #define RFCSR6_R1 FIELD8(0x03) | 2165 | #define RFCSR6_R1 FIELD8(0x03) |
2037 | #define RFCSR6_R2 FIELD8(0x40) | 2166 | #define RFCSR6_R2 FIELD8(0x40) |
2038 | #define RFCSR6_TXDIV FIELD8(0x0c) | 2167 | #define RFCSR6_TXDIV FIELD8(0x0c) |
2168 | /* bits for RF3053 */ | ||
2169 | #define RFCSR6_VCO_IC FIELD8(0xc0) | ||
2039 | 2170 | ||
2040 | /* | 2171 | /* |
2041 | * RFCSR 7: | 2172 | * RFCSR 7: |
@@ -2060,7 +2191,12 @@ struct mac_iveiv_entry { | |||
2060 | * RFCSR 11: | 2191 | * RFCSR 11: |
2061 | */ | 2192 | */ |
2062 | #define RFCSR11_R FIELD8(0x03) | 2193 | #define RFCSR11_R FIELD8(0x03) |
2194 | #define RFCSR11_PLL_MOD FIELD8(0x0c) | ||
2063 | #define RFCSR11_MOD FIELD8(0xc0) | 2195 | #define RFCSR11_MOD FIELD8(0xc0) |
2196 | /* bits for RF3053 */ | ||
2197 | /* TODO: verify RFCSR11_MOD usage on other chips */ | ||
2198 | #define RFCSR11_PLL_IDOH FIELD8(0x40) | ||
2199 | |||
2064 | 2200 | ||
2065 | /* | 2201 | /* |
2066 | * RFCSR 12: | 2202 | * RFCSR 12: |
@@ -2092,6 +2228,10 @@ struct mac_iveiv_entry { | |||
2092 | #define RFCSR17_R FIELD8(0x20) | 2228 | #define RFCSR17_R FIELD8(0x20) |
2093 | #define RFCSR17_CODE FIELD8(0x7f) | 2229 | #define RFCSR17_CODE FIELD8(0x7f) |
2094 | 2230 | ||
2231 | /* RFCSR 18 */ | ||
2232 | #define RFCSR18_XO_TUNE_BYPASS FIELD8(0x40) | ||
2233 | |||
2234 | |||
2095 | /* | 2235 | /* |
2096 | * RFCSR 20: | 2236 | * RFCSR 20: |
2097 | */ | 2237 | */ |
@@ -2152,6 +2292,12 @@ struct mac_iveiv_entry { | |||
2152 | #define RFCSR31_RX_H20M FIELD8(0x20) | 2292 | #define RFCSR31_RX_H20M FIELD8(0x20) |
2153 | #define RFCSR31_RX_CALIB FIELD8(0x7f) | 2293 | #define RFCSR31_RX_CALIB FIELD8(0x7f) |
2154 | 2294 | ||
2295 | /* RFCSR 32 bits for RF3053 */ | ||
2296 | #define RFCSR32_TX_AGC_FC FIELD8(0xf8) | ||
2297 | |||
2298 | /* RFCSR 36 bits for RF3053 */ | ||
2299 | #define RFCSR36_RF_BS FIELD8(0x80) | ||
2300 | |||
2155 | /* | 2301 | /* |
2156 | * RFCSR 38: | 2302 | * RFCSR 38: |
2157 | */ | 2303 | */ |
@@ -2160,6 +2306,7 @@ struct mac_iveiv_entry { | |||
2160 | /* | 2306 | /* |
2161 | * RFCSR 39: | 2307 | * RFCSR 39: |
2162 | */ | 2308 | */ |
2309 | #define RFCSR39_RX_DIV FIELD8(0x40) | ||
2163 | #define RFCSR39_RX_LO2_EN FIELD8(0x80) | 2310 | #define RFCSR39_RX_LO2_EN FIELD8(0x80) |
2164 | 2311 | ||
2165 | /* | 2312 | /* |
@@ -2167,12 +2314,36 @@ struct mac_iveiv_entry { | |||
2167 | */ | 2314 | */ |
2168 | #define RFCSR49_TX FIELD8(0x3f) | 2315 | #define RFCSR49_TX FIELD8(0x3f) |
2169 | #define RFCSR49_EP FIELD8(0xc0) | 2316 | #define RFCSR49_EP FIELD8(0xc0) |
2317 | /* bits for RT3593 */ | ||
2318 | #define RFCSR49_TX_LO1_IC FIELD8(0x1c) | ||
2319 | #define RFCSR49_TX_DIV FIELD8(0x20) | ||
2170 | 2320 | ||
2171 | /* | 2321 | /* |
2172 | * RFCSR 50: | 2322 | * RFCSR 50: |
2173 | */ | 2323 | */ |
2174 | #define RFCSR50_TX FIELD8(0x3f) | 2324 | #define RFCSR50_TX FIELD8(0x3f) |
2175 | #define RFCSR50_EP FIELD8(0xc0) | 2325 | #define RFCSR50_EP FIELD8(0xc0) |
2326 | /* bits for RT3593 */ | ||
2327 | #define RFCSR50_TX_LO1_EN FIELD8(0x20) | ||
2328 | #define RFCSR50_TX_LO2_EN FIELD8(0x10) | ||
2329 | |||
2330 | /* RFCSR 51 */ | ||
2331 | /* bits for RT3593 */ | ||
2332 | #define RFCSR51_BITS01 FIELD8(0x03) | ||
2333 | #define RFCSR51_BITS24 FIELD8(0x1c) | ||
2334 | #define RFCSR51_BITS57 FIELD8(0xe0) | ||
2335 | |||
2336 | #define RFCSR53_TX_POWER FIELD8(0x3f) | ||
2337 | #define RFCSR53_UNKNOWN FIELD8(0xc0) | ||
2338 | |||
2339 | #define RFCSR54_TX_POWER FIELD8(0x3f) | ||
2340 | #define RFCSR54_UNKNOWN FIELD8(0xc0) | ||
2341 | |||
2342 | #define RFCSR55_TX_POWER FIELD8(0x3f) | ||
2343 | #define RFCSR55_UNKNOWN FIELD8(0xc0) | ||
2344 | |||
2345 | #define RFCSR57_DRV_CC FIELD8(0xfc) | ||
2346 | |||
2176 | 2347 | ||
2177 | /* | 2348 | /* |
2178 | * RF registers | 2349 | * RF registers |
@@ -2206,28 +2377,67 @@ struct mac_iveiv_entry { | |||
2206 | * The wordsize of the EEPROM is 16 bits. | 2377 | * The wordsize of the EEPROM is 16 bits. |
2207 | */ | 2378 | */ |
2208 | 2379 | ||
2209 | /* | 2380 | enum rt2800_eeprom_word { |
2210 | * Chip ID | 2381 | EEPROM_CHIP_ID = 0, |
2211 | */ | 2382 | EEPROM_VERSION, |
2212 | #define EEPROM_CHIP_ID 0x0000 | 2383 | EEPROM_MAC_ADDR_0, |
2384 | EEPROM_MAC_ADDR_1, | ||
2385 | EEPROM_MAC_ADDR_2, | ||
2386 | EEPROM_NIC_CONF0, | ||
2387 | EEPROM_NIC_CONF1, | ||
2388 | EEPROM_FREQ, | ||
2389 | EEPROM_LED_AG_CONF, | ||
2390 | EEPROM_LED_ACT_CONF, | ||
2391 | EEPROM_LED_POLARITY, | ||
2392 | EEPROM_NIC_CONF2, | ||
2393 | EEPROM_LNA, | ||
2394 | EEPROM_RSSI_BG, | ||
2395 | EEPROM_RSSI_BG2, | ||
2396 | EEPROM_TXMIXER_GAIN_BG, | ||
2397 | EEPROM_RSSI_A, | ||
2398 | EEPROM_RSSI_A2, | ||
2399 | EEPROM_TXMIXER_GAIN_A, | ||
2400 | EEPROM_EIRP_MAX_TX_POWER, | ||
2401 | EEPROM_TXPOWER_DELTA, | ||
2402 | EEPROM_TXPOWER_BG1, | ||
2403 | EEPROM_TXPOWER_BG2, | ||
2404 | EEPROM_TSSI_BOUND_BG1, | ||
2405 | EEPROM_TSSI_BOUND_BG2, | ||
2406 | EEPROM_TSSI_BOUND_BG3, | ||
2407 | EEPROM_TSSI_BOUND_BG4, | ||
2408 | EEPROM_TSSI_BOUND_BG5, | ||
2409 | EEPROM_TXPOWER_A1, | ||
2410 | EEPROM_TXPOWER_A2, | ||
2411 | EEPROM_TSSI_BOUND_A1, | ||
2412 | EEPROM_TSSI_BOUND_A2, | ||
2413 | EEPROM_TSSI_BOUND_A3, | ||
2414 | EEPROM_TSSI_BOUND_A4, | ||
2415 | EEPROM_TSSI_BOUND_A5, | ||
2416 | EEPROM_TXPOWER_BYRATE, | ||
2417 | EEPROM_BBP_START, | ||
2418 | |||
2419 | /* IDs for extended EEPROM format used by three-chain devices */ | ||
2420 | EEPROM_EXT_LNA2, | ||
2421 | EEPROM_EXT_TXPOWER_BG3, | ||
2422 | EEPROM_EXT_TXPOWER_A3, | ||
2423 | |||
2424 | /* New values must be added before this */ | ||
2425 | EEPROM_WORD_COUNT | ||
2426 | }; | ||
2213 | 2427 | ||
2214 | /* | 2428 | /* |
2215 | * EEPROM Version | 2429 | * EEPROM Version |
2216 | */ | 2430 | */ |
2217 | #define EEPROM_VERSION 0x0001 | ||
2218 | #define EEPROM_VERSION_FAE FIELD16(0x00ff) | 2431 | #define EEPROM_VERSION_FAE FIELD16(0x00ff) |
2219 | #define EEPROM_VERSION_VERSION FIELD16(0xff00) | 2432 | #define EEPROM_VERSION_VERSION FIELD16(0xff00) |
2220 | 2433 | ||
2221 | /* | 2434 | /* |
2222 | * HW MAC address. | 2435 | * HW MAC address. |
2223 | */ | 2436 | */ |
2224 | #define EEPROM_MAC_ADDR_0 0x0002 | ||
2225 | #define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff) | 2437 | #define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff) |
2226 | #define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00) | 2438 | #define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00) |
2227 | #define EEPROM_MAC_ADDR_1 0x0003 | ||
2228 | #define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff) | 2439 | #define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff) |
2229 | #define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00) | 2440 | #define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00) |
2230 | #define EEPROM_MAC_ADDR_2 0x0004 | ||
2231 | #define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff) | 2441 | #define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff) |
2232 | #define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00) | 2442 | #define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00) |
2233 | 2443 | ||
@@ -2237,7 +2447,6 @@ struct mac_iveiv_entry { | |||
2237 | * TXPATH: 1: 1T, 2: 2T, 3: 3T | 2447 | * TXPATH: 1: 1T, 2: 2T, 3: 3T |
2238 | * RF_TYPE: RFIC type | 2448 | * RF_TYPE: RFIC type |
2239 | */ | 2449 | */ |
2240 | #define EEPROM_NIC_CONF0 0x001a | ||
2241 | #define EEPROM_NIC_CONF0_RXPATH FIELD16(0x000f) | 2450 | #define EEPROM_NIC_CONF0_RXPATH FIELD16(0x000f) |
2242 | #define EEPROM_NIC_CONF0_TXPATH FIELD16(0x00f0) | 2451 | #define EEPROM_NIC_CONF0_TXPATH FIELD16(0x00f0) |
2243 | #define EEPROM_NIC_CONF0_RF_TYPE FIELD16(0x0f00) | 2452 | #define EEPROM_NIC_CONF0_RF_TYPE FIELD16(0x0f00) |
@@ -2261,7 +2470,6 @@ struct mac_iveiv_entry { | |||
2261 | * BT_COEXIST: 0: disable, 1: enable | 2470 | * BT_COEXIST: 0: disable, 1: enable |
2262 | * DAC_TEST: 0: disable, 1: enable | 2471 | * DAC_TEST: 0: disable, 1: enable |
2263 | */ | 2472 | */ |
2264 | #define EEPROM_NIC_CONF1 0x001b | ||
2265 | #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001) | 2473 | #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001) |
2266 | #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC FIELD16(0x0002) | 2474 | #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC FIELD16(0x0002) |
2267 | #define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G FIELD16(0x0004) | 2475 | #define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G FIELD16(0x0004) |
@@ -2281,7 +2489,6 @@ struct mac_iveiv_entry { | |||
2281 | /* | 2489 | /* |
2282 | * EEPROM frequency | 2490 | * EEPROM frequency |
2283 | */ | 2491 | */ |
2284 | #define EEPROM_FREQ 0x001d | ||
2285 | #define EEPROM_FREQ_OFFSET FIELD16(0x00ff) | 2492 | #define EEPROM_FREQ_OFFSET FIELD16(0x00ff) |
2286 | #define EEPROM_FREQ_LED_MODE FIELD16(0x7f00) | 2493 | #define EEPROM_FREQ_LED_MODE FIELD16(0x7f00) |
2287 | #define EEPROM_FREQ_LED_POLARITY FIELD16(0x1000) | 2494 | #define EEPROM_FREQ_LED_POLARITY FIELD16(0x1000) |
@@ -2298,9 +2505,6 @@ struct mac_iveiv_entry { | |||
2298 | * POLARITY_GPIO_4: Polarity GPIO4 setting. | 2505 | * POLARITY_GPIO_4: Polarity GPIO4 setting. |
2299 | * LED_MODE: Led mode. | 2506 | * LED_MODE: Led mode. |
2300 | */ | 2507 | */ |
2301 | #define EEPROM_LED_AG_CONF 0x001e | ||
2302 | #define EEPROM_LED_ACT_CONF 0x001f | ||
2303 | #define EEPROM_LED_POLARITY 0x0020 | ||
2304 | #define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001) | 2508 | #define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001) |
2305 | #define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002) | 2509 | #define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002) |
2306 | #define EEPROM_LED_POLARITY_ACT FIELD16(0x0004) | 2510 | #define EEPROM_LED_POLARITY_ACT FIELD16(0x0004) |
@@ -2317,7 +2521,6 @@ struct mac_iveiv_entry { | |||
2317 | * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream | 2521 | * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream |
2318 | * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved | 2522 | * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved |
2319 | */ | 2523 | */ |
2320 | #define EEPROM_NIC_CONF2 0x0021 | ||
2321 | #define EEPROM_NIC_CONF2_RX_STREAM FIELD16(0x000f) | 2524 | #define EEPROM_NIC_CONF2_RX_STREAM FIELD16(0x000f) |
2322 | #define EEPROM_NIC_CONF2_TX_STREAM FIELD16(0x00f0) | 2525 | #define EEPROM_NIC_CONF2_TX_STREAM FIELD16(0x00f0) |
2323 | #define EEPROM_NIC_CONF2_CRYSTAL FIELD16(0x0600) | 2526 | #define EEPROM_NIC_CONF2_CRYSTAL FIELD16(0x0600) |
@@ -2325,54 +2528,46 @@ struct mac_iveiv_entry { | |||
2325 | /* | 2528 | /* |
2326 | * EEPROM LNA | 2529 | * EEPROM LNA |
2327 | */ | 2530 | */ |
2328 | #define EEPROM_LNA 0x0022 | ||
2329 | #define EEPROM_LNA_BG FIELD16(0x00ff) | 2531 | #define EEPROM_LNA_BG FIELD16(0x00ff) |
2330 | #define EEPROM_LNA_A0 FIELD16(0xff00) | 2532 | #define EEPROM_LNA_A0 FIELD16(0xff00) |
2331 | 2533 | ||
2332 | /* | 2534 | /* |
2333 | * EEPROM RSSI BG offset | 2535 | * EEPROM RSSI BG offset |
2334 | */ | 2536 | */ |
2335 | #define EEPROM_RSSI_BG 0x0023 | ||
2336 | #define EEPROM_RSSI_BG_OFFSET0 FIELD16(0x00ff) | 2537 | #define EEPROM_RSSI_BG_OFFSET0 FIELD16(0x00ff) |
2337 | #define EEPROM_RSSI_BG_OFFSET1 FIELD16(0xff00) | 2538 | #define EEPROM_RSSI_BG_OFFSET1 FIELD16(0xff00) |
2338 | 2539 | ||
2339 | /* | 2540 | /* |
2340 | * EEPROM RSSI BG2 offset | 2541 | * EEPROM RSSI BG2 offset |
2341 | */ | 2542 | */ |
2342 | #define EEPROM_RSSI_BG2 0x0024 | ||
2343 | #define EEPROM_RSSI_BG2_OFFSET2 FIELD16(0x00ff) | 2543 | #define EEPROM_RSSI_BG2_OFFSET2 FIELD16(0x00ff) |
2344 | #define EEPROM_RSSI_BG2_LNA_A1 FIELD16(0xff00) | 2544 | #define EEPROM_RSSI_BG2_LNA_A1 FIELD16(0xff00) |
2345 | 2545 | ||
2346 | /* | 2546 | /* |
2347 | * EEPROM TXMIXER GAIN BG offset (note overlaps with EEPROM RSSI BG2). | 2547 | * EEPROM TXMIXER GAIN BG offset (note overlaps with EEPROM RSSI BG2). |
2348 | */ | 2548 | */ |
2349 | #define EEPROM_TXMIXER_GAIN_BG 0x0024 | ||
2350 | #define EEPROM_TXMIXER_GAIN_BG_VAL FIELD16(0x0007) | 2549 | #define EEPROM_TXMIXER_GAIN_BG_VAL FIELD16(0x0007) |
2351 | 2550 | ||
2352 | /* | 2551 | /* |
2353 | * EEPROM RSSI A offset | 2552 | * EEPROM RSSI A offset |
2354 | */ | 2553 | */ |
2355 | #define EEPROM_RSSI_A 0x0025 | ||
2356 | #define EEPROM_RSSI_A_OFFSET0 FIELD16(0x00ff) | 2554 | #define EEPROM_RSSI_A_OFFSET0 FIELD16(0x00ff) |
2357 | #define EEPROM_RSSI_A_OFFSET1 FIELD16(0xff00) | 2555 | #define EEPROM_RSSI_A_OFFSET1 FIELD16(0xff00) |
2358 | 2556 | ||
2359 | /* | 2557 | /* |
2360 | * EEPROM RSSI A2 offset | 2558 | * EEPROM RSSI A2 offset |
2361 | */ | 2559 | */ |
2362 | #define EEPROM_RSSI_A2 0x0026 | ||
2363 | #define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff) | 2560 | #define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff) |
2364 | #define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00) | 2561 | #define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00) |
2365 | 2562 | ||
2366 | /* | 2563 | /* |
2367 | * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2). | 2564 | * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2). |
2368 | */ | 2565 | */ |
2369 | #define EEPROM_TXMIXER_GAIN_A 0x0026 | ||
2370 | #define EEPROM_TXMIXER_GAIN_A_VAL FIELD16(0x0007) | 2566 | #define EEPROM_TXMIXER_GAIN_A_VAL FIELD16(0x0007) |
2371 | 2567 | ||
2372 | /* | 2568 | /* |
2373 | * EEPROM EIRP Maximum TX power values(unit: dbm) | 2569 | * EEPROM EIRP Maximum TX power values(unit: dbm) |
2374 | */ | 2570 | */ |
2375 | #define EEPROM_EIRP_MAX_TX_POWER 0x0027 | ||
2376 | #define EEPROM_EIRP_MAX_TX_POWER_2GHZ FIELD16(0x00ff) | 2571 | #define EEPROM_EIRP_MAX_TX_POWER_2GHZ FIELD16(0x00ff) |
2377 | #define EEPROM_EIRP_MAX_TX_POWER_5GHZ FIELD16(0xff00) | 2572 | #define EEPROM_EIRP_MAX_TX_POWER_5GHZ FIELD16(0xff00) |
2378 | 2573 | ||
@@ -2383,7 +2578,6 @@ struct mac_iveiv_entry { | |||
2383 | * TYPE: 1: Plus the delta value, 0: minus the delta value | 2578 | * TYPE: 1: Plus the delta value, 0: minus the delta value |
2384 | * ENABLE: enable tx power compensation for 40BW | 2579 | * ENABLE: enable tx power compensation for 40BW |
2385 | */ | 2580 | */ |
2386 | #define EEPROM_TXPOWER_DELTA 0x0028 | ||
2387 | #define EEPROM_TXPOWER_DELTA_VALUE_2G FIELD16(0x003f) | 2581 | #define EEPROM_TXPOWER_DELTA_VALUE_2G FIELD16(0x003f) |
2388 | #define EEPROM_TXPOWER_DELTA_TYPE_2G FIELD16(0x0040) | 2582 | #define EEPROM_TXPOWER_DELTA_TYPE_2G FIELD16(0x0040) |
2389 | #define EEPROM_TXPOWER_DELTA_ENABLE_2G FIELD16(0x0080) | 2583 | #define EEPROM_TXPOWER_DELTA_ENABLE_2G FIELD16(0x0080) |
@@ -2394,8 +2588,6 @@ struct mac_iveiv_entry { | |||
2394 | /* | 2588 | /* |
2395 | * EEPROM TXPOWER 802.11BG | 2589 | * EEPROM TXPOWER 802.11BG |
2396 | */ | 2590 | */ |
2397 | #define EEPROM_TXPOWER_BG1 0x0029 | ||
2398 | #define EEPROM_TXPOWER_BG2 0x0030 | ||
2399 | #define EEPROM_TXPOWER_BG_SIZE 7 | 2591 | #define EEPROM_TXPOWER_BG_SIZE 7 |
2400 | #define EEPROM_TXPOWER_BG_1 FIELD16(0x00ff) | 2592 | #define EEPROM_TXPOWER_BG_1 FIELD16(0x00ff) |
2401 | #define EEPROM_TXPOWER_BG_2 FIELD16(0xff00) | 2593 | #define EEPROM_TXPOWER_BG_2 FIELD16(0xff00) |
@@ -2407,7 +2599,6 @@ struct mac_iveiv_entry { | |||
2407 | * MINUS3: If the actual TSSI is below this boundary, tx power needs to be | 2599 | * MINUS3: If the actual TSSI is below this boundary, tx power needs to be |
2408 | * reduced by (agc_step * -3) | 2600 | * reduced by (agc_step * -3) |
2409 | */ | 2601 | */ |
2410 | #define EEPROM_TSSI_BOUND_BG1 0x0037 | ||
2411 | #define EEPROM_TSSI_BOUND_BG1_MINUS4 FIELD16(0x00ff) | 2602 | #define EEPROM_TSSI_BOUND_BG1_MINUS4 FIELD16(0x00ff) |
2412 | #define EEPROM_TSSI_BOUND_BG1_MINUS3 FIELD16(0xff00) | 2603 | #define EEPROM_TSSI_BOUND_BG1_MINUS3 FIELD16(0xff00) |
2413 | 2604 | ||
@@ -2418,7 +2609,6 @@ struct mac_iveiv_entry { | |||
2418 | * MINUS1: If the actual TSSI is below this boundary, tx power needs to be | 2609 | * MINUS1: If the actual TSSI is below this boundary, tx power needs to be |
2419 | * reduced by (agc_step * -1) | 2610 | * reduced by (agc_step * -1) |
2420 | */ | 2611 | */ |
2421 | #define EEPROM_TSSI_BOUND_BG2 0x0038 | ||
2422 | #define EEPROM_TSSI_BOUND_BG2_MINUS2 FIELD16(0x00ff) | 2612 | #define EEPROM_TSSI_BOUND_BG2_MINUS2 FIELD16(0x00ff) |
2423 | #define EEPROM_TSSI_BOUND_BG2_MINUS1 FIELD16(0xff00) | 2613 | #define EEPROM_TSSI_BOUND_BG2_MINUS1 FIELD16(0xff00) |
2424 | 2614 | ||
@@ -2428,7 +2618,6 @@ struct mac_iveiv_entry { | |||
2428 | * PLUS1: If the actual TSSI is above this boundary, tx power needs to be | 2618 | * PLUS1: If the actual TSSI is above this boundary, tx power needs to be |
2429 | * increased by (agc_step * 1) | 2619 | * increased by (agc_step * 1) |
2430 | */ | 2620 | */ |
2431 | #define EEPROM_TSSI_BOUND_BG3 0x0039 | ||
2432 | #define EEPROM_TSSI_BOUND_BG3_REF FIELD16(0x00ff) | 2621 | #define EEPROM_TSSI_BOUND_BG3_REF FIELD16(0x00ff) |
2433 | #define EEPROM_TSSI_BOUND_BG3_PLUS1 FIELD16(0xff00) | 2622 | #define EEPROM_TSSI_BOUND_BG3_PLUS1 FIELD16(0xff00) |
2434 | 2623 | ||
@@ -2439,7 +2628,6 @@ struct mac_iveiv_entry { | |||
2439 | * PLUS3: If the actual TSSI is above this boundary, tx power needs to be | 2628 | * PLUS3: If the actual TSSI is above this boundary, tx power needs to be |
2440 | * increased by (agc_step * 3) | 2629 | * increased by (agc_step * 3) |
2441 | */ | 2630 | */ |
2442 | #define EEPROM_TSSI_BOUND_BG4 0x003a | ||
2443 | #define EEPROM_TSSI_BOUND_BG4_PLUS2 FIELD16(0x00ff) | 2631 | #define EEPROM_TSSI_BOUND_BG4_PLUS2 FIELD16(0x00ff) |
2444 | #define EEPROM_TSSI_BOUND_BG4_PLUS3 FIELD16(0xff00) | 2632 | #define EEPROM_TSSI_BOUND_BG4_PLUS3 FIELD16(0xff00) |
2445 | 2633 | ||
@@ -2449,19 +2637,20 @@ struct mac_iveiv_entry { | |||
2449 | * increased by (agc_step * 4) | 2637 | * increased by (agc_step * 4) |
2450 | * AGC_STEP: Temperature compensation step. | 2638 | * AGC_STEP: Temperature compensation step. |
2451 | */ | 2639 | */ |
2452 | #define EEPROM_TSSI_BOUND_BG5 0x003b | ||
2453 | #define EEPROM_TSSI_BOUND_BG5_PLUS4 FIELD16(0x00ff) | 2640 | #define EEPROM_TSSI_BOUND_BG5_PLUS4 FIELD16(0x00ff) |
2454 | #define EEPROM_TSSI_BOUND_BG5_AGC_STEP FIELD16(0xff00) | 2641 | #define EEPROM_TSSI_BOUND_BG5_AGC_STEP FIELD16(0xff00) |
2455 | 2642 | ||
2456 | /* | 2643 | /* |
2457 | * EEPROM TXPOWER 802.11A | 2644 | * EEPROM TXPOWER 802.11A |
2458 | */ | 2645 | */ |
2459 | #define EEPROM_TXPOWER_A1 0x003c | ||
2460 | #define EEPROM_TXPOWER_A2 0x0053 | ||
2461 | #define EEPROM_TXPOWER_A_SIZE 6 | 2646 | #define EEPROM_TXPOWER_A_SIZE 6 |
2462 | #define EEPROM_TXPOWER_A_1 FIELD16(0x00ff) | 2647 | #define EEPROM_TXPOWER_A_1 FIELD16(0x00ff) |
2463 | #define EEPROM_TXPOWER_A_2 FIELD16(0xff00) | 2648 | #define EEPROM_TXPOWER_A_2 FIELD16(0xff00) |
2464 | 2649 | ||
2650 | /* EEPROM_TXPOWER_{A,G} fields for RT3593 */ | ||
2651 | #define EEPROM_TXPOWER_ALC FIELD8(0x1f) | ||
2652 | #define EEPROM_TXPOWER_FINE_CTRL FIELD8(0xe0) | ||
2653 | |||
2465 | /* | 2654 | /* |
2466 | * EEPROM temperature compensation boundaries 802.11A | 2655 | * EEPROM temperature compensation boundaries 802.11A |
2467 | * MINUS4: If the actual TSSI is below this boundary, tx power needs to be | 2656 | * MINUS4: If the actual TSSI is below this boundary, tx power needs to be |
@@ -2469,7 +2658,6 @@ struct mac_iveiv_entry { | |||
2469 | * MINUS3: If the actual TSSI is below this boundary, tx power needs to be | 2658 | * MINUS3: If the actual TSSI is below this boundary, tx power needs to be |
2470 | * reduced by (agc_step * -3) | 2659 | * reduced by (agc_step * -3) |
2471 | */ | 2660 | */ |
2472 | #define EEPROM_TSSI_BOUND_A1 0x006a | ||
2473 | #define EEPROM_TSSI_BOUND_A1_MINUS4 FIELD16(0x00ff) | 2661 | #define EEPROM_TSSI_BOUND_A1_MINUS4 FIELD16(0x00ff) |
2474 | #define EEPROM_TSSI_BOUND_A1_MINUS3 FIELD16(0xff00) | 2662 | #define EEPROM_TSSI_BOUND_A1_MINUS3 FIELD16(0xff00) |
2475 | 2663 | ||
@@ -2480,7 +2668,6 @@ struct mac_iveiv_entry { | |||
2480 | * MINUS1: If the actual TSSI is below this boundary, tx power needs to be | 2668 | * MINUS1: If the actual TSSI is below this boundary, tx power needs to be |
2481 | * reduced by (agc_step * -1) | 2669 | * reduced by (agc_step * -1) |
2482 | */ | 2670 | */ |
2483 | #define EEPROM_TSSI_BOUND_A2 0x006b | ||
2484 | #define EEPROM_TSSI_BOUND_A2_MINUS2 FIELD16(0x00ff) | 2671 | #define EEPROM_TSSI_BOUND_A2_MINUS2 FIELD16(0x00ff) |
2485 | #define EEPROM_TSSI_BOUND_A2_MINUS1 FIELD16(0xff00) | 2672 | #define EEPROM_TSSI_BOUND_A2_MINUS1 FIELD16(0xff00) |
2486 | 2673 | ||
@@ -2490,7 +2677,6 @@ struct mac_iveiv_entry { | |||
2490 | * PLUS1: If the actual TSSI is above this boundary, tx power needs to be | 2677 | * PLUS1: If the actual TSSI is above this boundary, tx power needs to be |
2491 | * increased by (agc_step * 1) | 2678 | * increased by (agc_step * 1) |
2492 | */ | 2679 | */ |
2493 | #define EEPROM_TSSI_BOUND_A3 0x006c | ||
2494 | #define EEPROM_TSSI_BOUND_A3_REF FIELD16(0x00ff) | 2680 | #define EEPROM_TSSI_BOUND_A3_REF FIELD16(0x00ff) |
2495 | #define EEPROM_TSSI_BOUND_A3_PLUS1 FIELD16(0xff00) | 2681 | #define EEPROM_TSSI_BOUND_A3_PLUS1 FIELD16(0xff00) |
2496 | 2682 | ||
@@ -2501,7 +2687,6 @@ struct mac_iveiv_entry { | |||
2501 | * PLUS3: If the actual TSSI is above this boundary, tx power needs to be | 2687 | * PLUS3: If the actual TSSI is above this boundary, tx power needs to be |
2502 | * increased by (agc_step * 3) | 2688 | * increased by (agc_step * 3) |
2503 | */ | 2689 | */ |
2504 | #define EEPROM_TSSI_BOUND_A4 0x006d | ||
2505 | #define EEPROM_TSSI_BOUND_A4_PLUS2 FIELD16(0x00ff) | 2690 | #define EEPROM_TSSI_BOUND_A4_PLUS2 FIELD16(0x00ff) |
2506 | #define EEPROM_TSSI_BOUND_A4_PLUS3 FIELD16(0xff00) | 2691 | #define EEPROM_TSSI_BOUND_A4_PLUS3 FIELD16(0xff00) |
2507 | 2692 | ||
@@ -2511,14 +2696,12 @@ struct mac_iveiv_entry { | |||
2511 | * increased by (agc_step * 4) | 2696 | * increased by (agc_step * 4) |
2512 | * AGC_STEP: Temperature compensation step. | 2697 | * AGC_STEP: Temperature compensation step. |
2513 | */ | 2698 | */ |
2514 | #define EEPROM_TSSI_BOUND_A5 0x006e | ||
2515 | #define EEPROM_TSSI_BOUND_A5_PLUS4 FIELD16(0x00ff) | 2699 | #define EEPROM_TSSI_BOUND_A5_PLUS4 FIELD16(0x00ff) |
2516 | #define EEPROM_TSSI_BOUND_A5_AGC_STEP FIELD16(0xff00) | 2700 | #define EEPROM_TSSI_BOUND_A5_AGC_STEP FIELD16(0xff00) |
2517 | 2701 | ||
2518 | /* | 2702 | /* |
2519 | * EEPROM TXPOWER by rate: tx power per tx rate for HT20 mode | 2703 | * EEPROM TXPOWER by rate: tx power per tx rate for HT20 mode |
2520 | */ | 2704 | */ |
2521 | #define EEPROM_TXPOWER_BYRATE 0x006f | ||
2522 | #define EEPROM_TXPOWER_BYRATE_SIZE 9 | 2705 | #define EEPROM_TXPOWER_BYRATE_SIZE 9 |
2523 | 2706 | ||
2524 | #define EEPROM_TXPOWER_BYRATE_RATE0 FIELD16(0x000f) | 2707 | #define EEPROM_TXPOWER_BYRATE_RATE0 FIELD16(0x000f) |
@@ -2529,11 +2712,14 @@ struct mac_iveiv_entry { | |||
2529 | /* | 2712 | /* |
2530 | * EEPROM BBP. | 2713 | * EEPROM BBP. |
2531 | */ | 2714 | */ |
2532 | #define EEPROM_BBP_START 0x0078 | ||
2533 | #define EEPROM_BBP_SIZE 16 | 2715 | #define EEPROM_BBP_SIZE 16 |
2534 | #define EEPROM_BBP_VALUE FIELD16(0x00ff) | 2716 | #define EEPROM_BBP_VALUE FIELD16(0x00ff) |
2535 | #define EEPROM_BBP_REG_ID FIELD16(0xff00) | 2717 | #define EEPROM_BBP_REG_ID FIELD16(0xff00) |
2536 | 2718 | ||
2719 | /* EEPROM_EXT_LNA2 */ | ||
2720 | #define EEPROM_EXT_LNA2_A1 FIELD16(0x00ff) | ||
2721 | #define EEPROM_EXT_LNA2_A2 FIELD16(0xff00) | ||
2722 | |||
2537 | /* | 2723 | /* |
2538 | * EEPROM IQ Calibration, unlike other entries those are byte addresses. | 2724 | * EEPROM IQ Calibration, unlike other entries those are byte addresses. |
2539 | */ | 2725 | */ |
@@ -2610,6 +2796,7 @@ struct mac_iveiv_entry { | |||
2610 | #define MCU_RADAR 0x60 | 2796 | #define MCU_RADAR 0x60 |
2611 | #define MCU_BOOT_SIGNAL 0x72 | 2797 | #define MCU_BOOT_SIGNAL 0x72 |
2612 | #define MCU_ANT_SELECT 0X73 | 2798 | #define MCU_ANT_SELECT 0X73 |
2799 | #define MCU_FREQ_OFFSET 0x74 | ||
2613 | #define MCU_BBP_SIGNAL 0x80 | 2800 | #define MCU_BBP_SIGNAL 0x80 |
2614 | #define MCU_POWER_SAVE 0x83 | 2801 | #define MCU_POWER_SAVE 0x83 |
2615 | #define MCU_BAND_SELECT 0x91 | 2802 | #define MCU_BAND_SELECT 0x91 |
@@ -2630,6 +2817,7 @@ struct mac_iveiv_entry { | |||
2630 | #define TXWI_DESC_SIZE_5WORDS (5 * sizeof(__le32)) | 2817 | #define TXWI_DESC_SIZE_5WORDS (5 * sizeof(__le32)) |
2631 | 2818 | ||
2632 | #define RXWI_DESC_SIZE_4WORDS (4 * sizeof(__le32)) | 2819 | #define RXWI_DESC_SIZE_4WORDS (4 * sizeof(__le32)) |
2820 | #define RXWI_DESC_SIZE_5WORDS (5 * sizeof(__le32)) | ||
2633 | #define RXWI_DESC_SIZE_6WORDS (6 * sizeof(__le32)) | 2821 | #define RXWI_DESC_SIZE_6WORDS (6 * sizeof(__le32)) |
2634 | 2822 | ||
2635 | /* | 2823 | /* |
@@ -2750,18 +2938,15 @@ struct mac_iveiv_entry { | |||
2750 | #define MAX_A_TXPOWER 15 | 2938 | #define MAX_A_TXPOWER 15 |
2751 | #define DEFAULT_TXPOWER 5 | 2939 | #define DEFAULT_TXPOWER 5 |
2752 | 2940 | ||
2941 | #define MIN_A_TXPOWER_3593 0 | ||
2942 | #define MAX_A_TXPOWER_3593 31 | ||
2943 | |||
2753 | #define TXPOWER_G_FROM_DEV(__txpower) \ | 2944 | #define TXPOWER_G_FROM_DEV(__txpower) \ |
2754 | ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) | 2945 | ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) |
2755 | 2946 | ||
2756 | #define TXPOWER_G_TO_DEV(__txpower) \ | ||
2757 | clamp_t(char, __txpower, MIN_G_TXPOWER, MAX_G_TXPOWER) | ||
2758 | |||
2759 | #define TXPOWER_A_FROM_DEV(__txpower) \ | 2947 | #define TXPOWER_A_FROM_DEV(__txpower) \ |
2760 | ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) | 2948 | ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) |
2761 | 2949 | ||
2762 | #define TXPOWER_A_TO_DEV(__txpower) \ | ||
2763 | clamp_t(char, __txpower, MIN_A_TXPOWER, MAX_A_TXPOWER) | ||
2764 | |||
2765 | /* | 2950 | /* |
2766 | * Board's maximun TX power limitation | 2951 | * Board's maximun TX power limitation |
2767 | */ | 2952 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 1f80ea5e29dd..95e6e61c3de0 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -221,6 +221,157 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev, | |||
221 | mutex_unlock(&rt2x00dev->csr_mutex); | 221 | mutex_unlock(&rt2x00dev->csr_mutex); |
222 | } | 222 | } |
223 | 223 | ||
224 | static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = { | ||
225 | [EEPROM_CHIP_ID] = 0x0000, | ||
226 | [EEPROM_VERSION] = 0x0001, | ||
227 | [EEPROM_MAC_ADDR_0] = 0x0002, | ||
228 | [EEPROM_MAC_ADDR_1] = 0x0003, | ||
229 | [EEPROM_MAC_ADDR_2] = 0x0004, | ||
230 | [EEPROM_NIC_CONF0] = 0x001a, | ||
231 | [EEPROM_NIC_CONF1] = 0x001b, | ||
232 | [EEPROM_FREQ] = 0x001d, | ||
233 | [EEPROM_LED_AG_CONF] = 0x001e, | ||
234 | [EEPROM_LED_ACT_CONF] = 0x001f, | ||
235 | [EEPROM_LED_POLARITY] = 0x0020, | ||
236 | [EEPROM_NIC_CONF2] = 0x0021, | ||
237 | [EEPROM_LNA] = 0x0022, | ||
238 | [EEPROM_RSSI_BG] = 0x0023, | ||
239 | [EEPROM_RSSI_BG2] = 0x0024, | ||
240 | [EEPROM_TXMIXER_GAIN_BG] = 0x0024, /* overlaps with RSSI_BG2 */ | ||
241 | [EEPROM_RSSI_A] = 0x0025, | ||
242 | [EEPROM_RSSI_A2] = 0x0026, | ||
243 | [EEPROM_TXMIXER_GAIN_A] = 0x0026, /* overlaps with RSSI_A2 */ | ||
244 | [EEPROM_EIRP_MAX_TX_POWER] = 0x0027, | ||
245 | [EEPROM_TXPOWER_DELTA] = 0x0028, | ||
246 | [EEPROM_TXPOWER_BG1] = 0x0029, | ||
247 | [EEPROM_TXPOWER_BG2] = 0x0030, | ||
248 | [EEPROM_TSSI_BOUND_BG1] = 0x0037, | ||
249 | [EEPROM_TSSI_BOUND_BG2] = 0x0038, | ||
250 | [EEPROM_TSSI_BOUND_BG3] = 0x0039, | ||
251 | [EEPROM_TSSI_BOUND_BG4] = 0x003a, | ||
252 | [EEPROM_TSSI_BOUND_BG5] = 0x003b, | ||
253 | [EEPROM_TXPOWER_A1] = 0x003c, | ||
254 | [EEPROM_TXPOWER_A2] = 0x0053, | ||
255 | [EEPROM_TSSI_BOUND_A1] = 0x006a, | ||
256 | [EEPROM_TSSI_BOUND_A2] = 0x006b, | ||
257 | [EEPROM_TSSI_BOUND_A3] = 0x006c, | ||
258 | [EEPROM_TSSI_BOUND_A4] = 0x006d, | ||
259 | [EEPROM_TSSI_BOUND_A5] = 0x006e, | ||
260 | [EEPROM_TXPOWER_BYRATE] = 0x006f, | ||
261 | [EEPROM_BBP_START] = 0x0078, | ||
262 | }; | ||
263 | |||
264 | static const unsigned int rt2800_eeprom_map_ext[EEPROM_WORD_COUNT] = { | ||
265 | [EEPROM_CHIP_ID] = 0x0000, | ||
266 | [EEPROM_VERSION] = 0x0001, | ||
267 | [EEPROM_MAC_ADDR_0] = 0x0002, | ||
268 | [EEPROM_MAC_ADDR_1] = 0x0003, | ||
269 | [EEPROM_MAC_ADDR_2] = 0x0004, | ||
270 | [EEPROM_NIC_CONF0] = 0x001a, | ||
271 | [EEPROM_NIC_CONF1] = 0x001b, | ||
272 | [EEPROM_NIC_CONF2] = 0x001c, | ||
273 | [EEPROM_EIRP_MAX_TX_POWER] = 0x0020, | ||
274 | [EEPROM_FREQ] = 0x0022, | ||
275 | [EEPROM_LED_AG_CONF] = 0x0023, | ||
276 | [EEPROM_LED_ACT_CONF] = 0x0024, | ||
277 | [EEPROM_LED_POLARITY] = 0x0025, | ||
278 | [EEPROM_LNA] = 0x0026, | ||
279 | [EEPROM_EXT_LNA2] = 0x0027, | ||
280 | [EEPROM_RSSI_BG] = 0x0028, | ||
281 | [EEPROM_TXPOWER_DELTA] = 0x0028, /* Overlaps with RSSI_BG */ | ||
282 | [EEPROM_RSSI_BG2] = 0x0029, | ||
283 | [EEPROM_TXMIXER_GAIN_BG] = 0x0029, /* Overlaps with RSSI_BG2 */ | ||
284 | [EEPROM_RSSI_A] = 0x002a, | ||
285 | [EEPROM_RSSI_A2] = 0x002b, | ||
286 | [EEPROM_TXMIXER_GAIN_A] = 0x002b, /* Overlaps with RSSI_A2 */ | ||
287 | [EEPROM_TXPOWER_BG1] = 0x0030, | ||
288 | [EEPROM_TXPOWER_BG2] = 0x0037, | ||
289 | [EEPROM_EXT_TXPOWER_BG3] = 0x003e, | ||
290 | [EEPROM_TSSI_BOUND_BG1] = 0x0045, | ||
291 | [EEPROM_TSSI_BOUND_BG2] = 0x0046, | ||
292 | [EEPROM_TSSI_BOUND_BG3] = 0x0047, | ||
293 | [EEPROM_TSSI_BOUND_BG4] = 0x0048, | ||
294 | [EEPROM_TSSI_BOUND_BG5] = 0x0049, | ||
295 | [EEPROM_TXPOWER_A1] = 0x004b, | ||
296 | [EEPROM_TXPOWER_A2] = 0x0065, | ||
297 | [EEPROM_EXT_TXPOWER_A3] = 0x007f, | ||
298 | [EEPROM_TSSI_BOUND_A1] = 0x009a, | ||
299 | [EEPROM_TSSI_BOUND_A2] = 0x009b, | ||
300 | [EEPROM_TSSI_BOUND_A3] = 0x009c, | ||
301 | [EEPROM_TSSI_BOUND_A4] = 0x009d, | ||
302 | [EEPROM_TSSI_BOUND_A5] = 0x009e, | ||
303 | [EEPROM_TXPOWER_BYRATE] = 0x00a0, | ||
304 | }; | ||
305 | |||
306 | static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev, | ||
307 | const enum rt2800_eeprom_word word) | ||
308 | { | ||
309 | const unsigned int *map; | ||
310 | unsigned int index; | ||
311 | |||
312 | if (WARN_ONCE(word >= EEPROM_WORD_COUNT, | ||
313 | "%s: invalid EEPROM word %d\n", | ||
314 | wiphy_name(rt2x00dev->hw->wiphy), word)) | ||
315 | return 0; | ||
316 | |||
317 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
318 | map = rt2800_eeprom_map_ext; | ||
319 | else | ||
320 | map = rt2800_eeprom_map; | ||
321 | |||
322 | index = map[word]; | ||
323 | |||
324 | /* Index 0 is valid only for EEPROM_CHIP_ID. | ||
325 | * Otherwise it means that the offset of the | ||
326 | * given word is not initialized in the map, | ||
327 | * or that the field is not usable on the | ||
328 | * actual chipset. | ||
329 | */ | ||
330 | WARN_ONCE(word != EEPROM_CHIP_ID && index == 0, | ||
331 | "%s: invalid access of EEPROM word %d\n", | ||
332 | wiphy_name(rt2x00dev->hw->wiphy), word); | ||
333 | |||
334 | return index; | ||
335 | } | ||
336 | |||
337 | static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev, | ||
338 | const enum rt2800_eeprom_word word) | ||
339 | { | ||
340 | unsigned int index; | ||
341 | |||
342 | index = rt2800_eeprom_word_index(rt2x00dev, word); | ||
343 | return rt2x00_eeprom_addr(rt2x00dev, index); | ||
344 | } | ||
345 | |||
346 | static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev, | ||
347 | const enum rt2800_eeprom_word word, u16 *data) | ||
348 | { | ||
349 | unsigned int index; | ||
350 | |||
351 | index = rt2800_eeprom_word_index(rt2x00dev, word); | ||
352 | rt2x00_eeprom_read(rt2x00dev, index, data); | ||
353 | } | ||
354 | |||
355 | static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev, | ||
356 | const enum rt2800_eeprom_word word, u16 data) | ||
357 | { | ||
358 | unsigned int index; | ||
359 | |||
360 | index = rt2800_eeprom_word_index(rt2x00dev, word); | ||
361 | rt2x00_eeprom_write(rt2x00dev, index, data); | ||
362 | } | ||
363 | |||
364 | static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev, | ||
365 | const enum rt2800_eeprom_word array, | ||
366 | unsigned int offset, | ||
367 | u16 *data) | ||
368 | { | ||
369 | unsigned int index; | ||
370 | |||
371 | index = rt2800_eeprom_word_index(rt2x00dev, array); | ||
372 | rt2x00_eeprom_read(rt2x00dev, index + offset, data); | ||
373 | } | ||
374 | |||
224 | static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev) | 375 | static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev) |
225 | { | 376 | { |
226 | u32 reg; | 377 | u32 reg; |
@@ -370,6 +521,29 @@ void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev) | |||
370 | } | 521 | } |
371 | EXPORT_SYMBOL_GPL(rt2800_disable_wpdma); | 522 | EXPORT_SYMBOL_GPL(rt2800_disable_wpdma); |
372 | 523 | ||
524 | void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev, | ||
525 | unsigned short *txwi_size, | ||
526 | unsigned short *rxwi_size) | ||
527 | { | ||
528 | switch (rt2x00dev->chip.rt) { | ||
529 | case RT3593: | ||
530 | *txwi_size = TXWI_DESC_SIZE_4WORDS; | ||
531 | *rxwi_size = RXWI_DESC_SIZE_5WORDS; | ||
532 | break; | ||
533 | |||
534 | case RT5592: | ||
535 | *txwi_size = TXWI_DESC_SIZE_5WORDS; | ||
536 | *rxwi_size = RXWI_DESC_SIZE_6WORDS; | ||
537 | break; | ||
538 | |||
539 | default: | ||
540 | *txwi_size = TXWI_DESC_SIZE_4WORDS; | ||
541 | *rxwi_size = RXWI_DESC_SIZE_4WORDS; | ||
542 | break; | ||
543 | } | ||
544 | } | ||
545 | EXPORT_SYMBOL_GPL(rt2800_get_txwi_rxwi_size); | ||
546 | |||
373 | static bool rt2800_check_firmware_crc(const u8 *data, const size_t len) | 547 | static bool rt2800_check_firmware_crc(const u8 *data, const size_t len) |
374 | { | 548 | { |
375 | u16 fw_crc; | 549 | u16 fw_crc; |
@@ -609,16 +783,16 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2) | |||
609 | u8 offset2; | 783 | u8 offset2; |
610 | 784 | ||
611 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { | 785 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { |
612 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom); | 786 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom); |
613 | offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET0); | 787 | offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET0); |
614 | offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET1); | 788 | offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET1); |
615 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom); | 789 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom); |
616 | offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_OFFSET2); | 790 | offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_OFFSET2); |
617 | } else { | 791 | } else { |
618 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom); | 792 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom); |
619 | offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET0); | 793 | offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET0); |
620 | offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET1); | 794 | offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET1); |
621 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom); | 795 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom); |
622 | offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_OFFSET2); | 796 | offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_OFFSET2); |
623 | } | 797 | } |
624 | 798 | ||
@@ -766,6 +940,18 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi) | |||
766 | } | 940 | } |
767 | EXPORT_SYMBOL_GPL(rt2800_txdone_entry); | 941 | EXPORT_SYMBOL_GPL(rt2800_txdone_entry); |
768 | 942 | ||
943 | static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev, | ||
944 | unsigned int index) | ||
945 | { | ||
946 | return HW_BEACON_BASE(index); | ||
947 | } | ||
948 | |||
949 | static inline u8 rt2800_get_beacon_offset(struct rt2x00_dev *rt2x00dev, | ||
950 | unsigned int index) | ||
951 | { | ||
952 | return BEACON_BASE_TO_OFFSET(rt2800_hw_beacon_base(rt2x00dev, index)); | ||
953 | } | ||
954 | |||
769 | void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) | 955 | void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) |
770 | { | 956 | { |
771 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 957 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
@@ -818,7 +1004,8 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) | |||
818 | return; | 1004 | return; |
819 | } | 1005 | } |
820 | 1006 | ||
821 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); | 1007 | beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx); |
1008 | |||
822 | rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, | 1009 | rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, |
823 | entry->skb->len + padding_len); | 1010 | entry->skb->len + padding_len); |
824 | 1011 | ||
@@ -837,10 +1024,13 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) | |||
837 | EXPORT_SYMBOL_GPL(rt2800_write_beacon); | 1024 | EXPORT_SYMBOL_GPL(rt2800_write_beacon); |
838 | 1025 | ||
839 | static inline void rt2800_clear_beacon_register(struct rt2x00_dev *rt2x00dev, | 1026 | static inline void rt2800_clear_beacon_register(struct rt2x00_dev *rt2x00dev, |
840 | unsigned int beacon_base) | 1027 | unsigned int index) |
841 | { | 1028 | { |
842 | int i; | 1029 | int i; |
843 | const int txwi_desc_size = rt2x00dev->bcn->winfo_size; | 1030 | const int txwi_desc_size = rt2x00dev->bcn->winfo_size; |
1031 | unsigned int beacon_base; | ||
1032 | |||
1033 | beacon_base = rt2800_hw_beacon_base(rt2x00dev, index); | ||
844 | 1034 | ||
845 | /* | 1035 | /* |
846 | * For the Beacon base registers we only need to clear | 1036 | * For the Beacon base registers we only need to clear |
@@ -867,8 +1057,7 @@ void rt2800_clear_beacon(struct queue_entry *entry) | |||
867 | /* | 1057 | /* |
868 | * Clear beacon. | 1058 | * Clear beacon. |
869 | */ | 1059 | */ |
870 | rt2800_clear_beacon_register(rt2x00dev, | 1060 | rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx); |
871 | HW_BEACON_OFFSET(entry->entry_idx)); | ||
872 | 1061 | ||
873 | /* | 1062 | /* |
874 | * Enabled beaconing again. | 1063 | * Enabled beaconing again. |
@@ -890,6 +1079,9 @@ const struct rt2x00debug rt2800_rt2x00debug = { | |||
890 | .word_count = CSR_REG_SIZE / sizeof(u32), | 1079 | .word_count = CSR_REG_SIZE / sizeof(u32), |
891 | }, | 1080 | }, |
892 | .eeprom = { | 1081 | .eeprom = { |
1082 | /* NOTE: The local EEPROM access functions can't | ||
1083 | * be used here, use the generic versions instead. | ||
1084 | */ | ||
893 | .read = rt2x00_eeprom_read, | 1085 | .read = rt2x00_eeprom_read, |
894 | .write = rt2x00_eeprom_write, | 1086 | .write = rt2x00_eeprom_write, |
895 | .word_base = EEPROM_BASE, | 1087 | .word_base = EEPROM_BASE, |
@@ -1547,7 +1739,7 @@ static void rt2800_config_3572bt_ant(struct rt2x00_dev *rt2x00dev) | |||
1547 | led_r_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 0 : 3; | 1739 | led_r_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 0 : 3; |
1548 | if (led_g_mode != rt2x00_get_field32(reg, LED_CFG_G_LED_MODE) || | 1740 | if (led_g_mode != rt2x00_get_field32(reg, LED_CFG_G_LED_MODE) || |
1549 | led_r_mode != rt2x00_get_field32(reg, LED_CFG_R_LED_MODE)) { | 1741 | led_r_mode != rt2x00_get_field32(reg, LED_CFG_R_LED_MODE)) { |
1550 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); | 1742 | rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); |
1551 | led_ctrl = rt2x00_get_field16(eeprom, EEPROM_FREQ_LED_MODE); | 1743 | led_ctrl = rt2x00_get_field16(eeprom, EEPROM_FREQ_LED_MODE); |
1552 | if (led_ctrl == 0 || led_ctrl > 0x40) { | 1744 | if (led_ctrl == 0 || led_ctrl > 0x40) { |
1553 | rt2x00_set_field32(®, LED_CFG_G_LED_MODE, led_g_mode); | 1745 | rt2x00_set_field32(®, LED_CFG_G_LED_MODE, led_g_mode); |
@@ -1609,7 +1801,7 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant) | |||
1609 | rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2); | 1801 | rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2); |
1610 | break; | 1802 | break; |
1611 | case 3: | 1803 | case 3: |
1612 | rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 0); | 1804 | rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2); |
1613 | break; | 1805 | break; |
1614 | } | 1806 | } |
1615 | 1807 | ||
@@ -1622,7 +1814,7 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant) | |||
1622 | rt2x00_rt(rt2x00dev, RT3090) || | 1814 | rt2x00_rt(rt2x00dev, RT3090) || |
1623 | rt2x00_rt(rt2x00dev, RT3352) || | 1815 | rt2x00_rt(rt2x00dev, RT3352) || |
1624 | rt2x00_rt(rt2x00dev, RT3390)) { | 1816 | rt2x00_rt(rt2x00dev, RT3390)) { |
1625 | rt2x00_eeprom_read(rt2x00dev, | 1817 | rt2800_eeprom_read(rt2x00dev, |
1626 | EEPROM_NIC_CONF1, &eeprom); | 1818 | EEPROM_NIC_CONF1, &eeprom); |
1627 | if (rt2x00_get_field16(eeprom, | 1819 | if (rt2x00_get_field16(eeprom, |
1628 | EEPROM_NIC_CONF1_ANT_DIVERSITY)) | 1820 | EEPROM_NIC_CONF1_ANT_DIVERSITY)) |
@@ -1649,6 +1841,13 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant) | |||
1649 | 1841 | ||
1650 | rt2800_bbp_write(rt2x00dev, 3, r3); | 1842 | rt2800_bbp_write(rt2x00dev, 3, r3); |
1651 | rt2800_bbp_write(rt2x00dev, 1, r1); | 1843 | rt2800_bbp_write(rt2x00dev, 1, r1); |
1844 | |||
1845 | if (rt2x00_rt(rt2x00dev, RT3593)) { | ||
1846 | if (ant->rx_chain_num == 1) | ||
1847 | rt2800_bbp_write(rt2x00dev, 86, 0x00); | ||
1848 | else | ||
1849 | rt2800_bbp_write(rt2x00dev, 86, 0x46); | ||
1850 | } | ||
1652 | } | 1851 | } |
1653 | EXPORT_SYMBOL_GPL(rt2800_config_ant); | 1852 | EXPORT_SYMBOL_GPL(rt2800_config_ant); |
1654 | 1853 | ||
@@ -1659,22 +1858,73 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev, | |||
1659 | short lna_gain; | 1858 | short lna_gain; |
1660 | 1859 | ||
1661 | if (libconf->rf.channel <= 14) { | 1860 | if (libconf->rf.channel <= 14) { |
1662 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom); | 1861 | rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom); |
1663 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG); | 1862 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG); |
1664 | } else if (libconf->rf.channel <= 64) { | 1863 | } else if (libconf->rf.channel <= 64) { |
1665 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom); | 1864 | rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom); |
1666 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0); | 1865 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0); |
1667 | } else if (libconf->rf.channel <= 128) { | 1866 | } else if (libconf->rf.channel <= 128) { |
1668 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom); | 1867 | if (rt2x00_rt(rt2x00dev, RT3593)) { |
1669 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1); | 1868 | rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom); |
1869 | lna_gain = rt2x00_get_field16(eeprom, | ||
1870 | EEPROM_EXT_LNA2_A1); | ||
1871 | } else { | ||
1872 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom); | ||
1873 | lna_gain = rt2x00_get_field16(eeprom, | ||
1874 | EEPROM_RSSI_BG2_LNA_A1); | ||
1875 | } | ||
1670 | } else { | 1876 | } else { |
1671 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom); | 1877 | if (rt2x00_rt(rt2x00dev, RT3593)) { |
1672 | lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2); | 1878 | rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom); |
1879 | lna_gain = rt2x00_get_field16(eeprom, | ||
1880 | EEPROM_EXT_LNA2_A2); | ||
1881 | } else { | ||
1882 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom); | ||
1883 | lna_gain = rt2x00_get_field16(eeprom, | ||
1884 | EEPROM_RSSI_A2_LNA_A2); | ||
1885 | } | ||
1673 | } | 1886 | } |
1674 | 1887 | ||
1675 | rt2x00dev->lna_gain = lna_gain; | 1888 | rt2x00dev->lna_gain = lna_gain; |
1676 | } | 1889 | } |
1677 | 1890 | ||
1891 | #define FREQ_OFFSET_BOUND 0x5f | ||
1892 | |||
1893 | static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev) | ||
1894 | { | ||
1895 | u8 freq_offset, prev_freq_offset; | ||
1896 | u8 rfcsr, prev_rfcsr; | ||
1897 | |||
1898 | freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE); | ||
1899 | freq_offset = min_t(u8, freq_offset, FREQ_OFFSET_BOUND); | ||
1900 | |||
1901 | rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr); | ||
1902 | prev_rfcsr = rfcsr; | ||
1903 | |||
1904 | rt2x00_set_field8(&rfcsr, RFCSR17_CODE, freq_offset); | ||
1905 | if (rfcsr == prev_rfcsr) | ||
1906 | return; | ||
1907 | |||
1908 | if (rt2x00_is_usb(rt2x00dev)) { | ||
1909 | rt2800_mcu_request(rt2x00dev, MCU_FREQ_OFFSET, 0xff, | ||
1910 | freq_offset, prev_rfcsr); | ||
1911 | return; | ||
1912 | } | ||
1913 | |||
1914 | prev_freq_offset = rt2x00_get_field8(prev_rfcsr, RFCSR17_CODE); | ||
1915 | while (prev_freq_offset != freq_offset) { | ||
1916 | if (prev_freq_offset < freq_offset) | ||
1917 | prev_freq_offset++; | ||
1918 | else | ||
1919 | prev_freq_offset--; | ||
1920 | |||
1921 | rt2x00_set_field8(&rfcsr, RFCSR17_CODE, prev_freq_offset); | ||
1922 | rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); | ||
1923 | |||
1924 | usleep_range(1000, 1500); | ||
1925 | } | ||
1926 | } | ||
1927 | |||
1678 | static void rt2800_config_channel_rf2xxx(struct rt2x00_dev *rt2x00dev, | 1928 | static void rt2800_config_channel_rf2xxx(struct rt2x00_dev *rt2x00dev, |
1679 | struct ieee80211_conf *conf, | 1929 | struct ieee80211_conf *conf, |
1680 | struct rf_channel *rf, | 1930 | struct rf_channel *rf, |
@@ -1993,22 +2243,306 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, | |||
1993 | rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); | 2243 | rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); |
1994 | } | 2244 | } |
1995 | 2245 | ||
1996 | #define POWER_BOUND 0x27 | 2246 | static void rt2800_config_channel_rf3053(struct rt2x00_dev *rt2x00dev, |
1997 | #define POWER_BOUND_5G 0x2b | 2247 | struct ieee80211_conf *conf, |
1998 | #define FREQ_OFFSET_BOUND 0x5f | 2248 | struct rf_channel *rf, |
1999 | 2249 | struct channel_info *info) | |
2000 | static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev) | ||
2001 | { | 2250 | { |
2251 | struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; | ||
2252 | u8 txrx_agc_fc; | ||
2253 | u8 txrx_h20m; | ||
2002 | u8 rfcsr; | 2254 | u8 rfcsr; |
2255 | u8 bbp; | ||
2256 | const bool txbf_enabled = false; /* TODO */ | ||
2003 | 2257 | ||
2004 | rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr); | 2258 | /* TODO: use TX{0,1,2}FinePowerControl values from EEPROM */ |
2005 | if (rt2x00dev->freq_offset > FREQ_OFFSET_BOUND) | 2259 | rt2800_bbp_read(rt2x00dev, 109, &bbp); |
2006 | rt2x00_set_field8(&rfcsr, RFCSR17_CODE, FREQ_OFFSET_BOUND); | 2260 | rt2x00_set_field8(&bbp, BBP109_TX0_POWER, 0); |
2261 | rt2x00_set_field8(&bbp, BBP109_TX1_POWER, 0); | ||
2262 | rt2800_bbp_write(rt2x00dev, 109, bbp); | ||
2263 | |||
2264 | rt2800_bbp_read(rt2x00dev, 110, &bbp); | ||
2265 | rt2x00_set_field8(&bbp, BBP110_TX2_POWER, 0); | ||
2266 | rt2800_bbp_write(rt2x00dev, 110, bbp); | ||
2267 | |||
2268 | if (rf->channel <= 14) { | ||
2269 | /* Restore BBP 25 & 26 for 2.4 GHz */ | ||
2270 | rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); | ||
2271 | rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); | ||
2272 | } else { | ||
2273 | /* Hard code BBP 25 & 26 for 5GHz */ | ||
2274 | |||
2275 | /* Enable IQ Phase correction */ | ||
2276 | rt2800_bbp_write(rt2x00dev, 25, 0x09); | ||
2277 | /* Setup IQ Phase correction value */ | ||
2278 | rt2800_bbp_write(rt2x00dev, 26, 0xff); | ||
2279 | } | ||
2280 | |||
2281 | rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); | ||
2282 | rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3 & 0xf); | ||
2283 | |||
2284 | rt2800_rfcsr_read(rt2x00dev, 11, &rfcsr); | ||
2285 | rt2x00_set_field8(&rfcsr, RFCSR11_R, (rf->rf2 & 0x3)); | ||
2286 | rt2800_rfcsr_write(rt2x00dev, 11, rfcsr); | ||
2287 | |||
2288 | rt2800_rfcsr_read(rt2x00dev, 11, &rfcsr); | ||
2289 | rt2x00_set_field8(&rfcsr, RFCSR11_PLL_IDOH, 1); | ||
2290 | if (rf->channel <= 14) | ||
2291 | rt2x00_set_field8(&rfcsr, RFCSR11_PLL_MOD, 1); | ||
2007 | else | 2292 | else |
2008 | rt2x00_set_field8(&rfcsr, RFCSR17_CODE, rt2x00dev->freq_offset); | 2293 | rt2x00_set_field8(&rfcsr, RFCSR11_PLL_MOD, 2); |
2009 | rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); | 2294 | rt2800_rfcsr_write(rt2x00dev, 11, rfcsr); |
2295 | |||
2296 | rt2800_rfcsr_read(rt2x00dev, 53, &rfcsr); | ||
2297 | if (rf->channel <= 14) { | ||
2298 | rfcsr = 0; | ||
2299 | rt2x00_set_field8(&rfcsr, RFCSR53_TX_POWER, | ||
2300 | info->default_power1 & 0x1f); | ||
2301 | } else { | ||
2302 | if (rt2x00_is_usb(rt2x00dev)) | ||
2303 | rfcsr = 0x40; | ||
2304 | |||
2305 | rt2x00_set_field8(&rfcsr, RFCSR53_TX_POWER, | ||
2306 | ((info->default_power1 & 0x18) << 1) | | ||
2307 | (info->default_power1 & 7)); | ||
2308 | } | ||
2309 | rt2800_rfcsr_write(rt2x00dev, 53, rfcsr); | ||
2310 | |||
2311 | rt2800_rfcsr_read(rt2x00dev, 55, &rfcsr); | ||
2312 | if (rf->channel <= 14) { | ||
2313 | rfcsr = 0; | ||
2314 | rt2x00_set_field8(&rfcsr, RFCSR55_TX_POWER, | ||
2315 | info->default_power2 & 0x1f); | ||
2316 | } else { | ||
2317 | if (rt2x00_is_usb(rt2x00dev)) | ||
2318 | rfcsr = 0x40; | ||
2319 | |||
2320 | rt2x00_set_field8(&rfcsr, RFCSR55_TX_POWER, | ||
2321 | ((info->default_power2 & 0x18) << 1) | | ||
2322 | (info->default_power2 & 7)); | ||
2323 | } | ||
2324 | rt2800_rfcsr_write(rt2x00dev, 55, rfcsr); | ||
2325 | |||
2326 | rt2800_rfcsr_read(rt2x00dev, 54, &rfcsr); | ||
2327 | if (rf->channel <= 14) { | ||
2328 | rfcsr = 0; | ||
2329 | rt2x00_set_field8(&rfcsr, RFCSR54_TX_POWER, | ||
2330 | info->default_power3 & 0x1f); | ||
2331 | } else { | ||
2332 | if (rt2x00_is_usb(rt2x00dev)) | ||
2333 | rfcsr = 0x40; | ||
2334 | |||
2335 | rt2x00_set_field8(&rfcsr, RFCSR54_TX_POWER, | ||
2336 | ((info->default_power3 & 0x18) << 1) | | ||
2337 | (info->default_power3 & 7)); | ||
2338 | } | ||
2339 | rt2800_rfcsr_write(rt2x00dev, 54, rfcsr); | ||
2340 | |||
2341 | rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); | ||
2342 | rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); | ||
2343 | rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); | ||
2344 | rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); | ||
2345 | rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); | ||
2346 | rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); | ||
2347 | rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); | ||
2348 | rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); | ||
2349 | rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1); | ||
2350 | |||
2351 | switch (rt2x00dev->default_ant.tx_chain_num) { | ||
2352 | case 3: | ||
2353 | rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1); | ||
2354 | /* fallthrough */ | ||
2355 | case 2: | ||
2356 | rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); | ||
2357 | /* fallthrough */ | ||
2358 | case 1: | ||
2359 | rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 1); | ||
2360 | break; | ||
2361 | } | ||
2362 | |||
2363 | switch (rt2x00dev->default_ant.rx_chain_num) { | ||
2364 | case 3: | ||
2365 | rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1); | ||
2366 | /* fallthrough */ | ||
2367 | case 2: | ||
2368 | rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); | ||
2369 | /* fallthrough */ | ||
2370 | case 1: | ||
2371 | rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1); | ||
2372 | break; | ||
2373 | } | ||
2374 | rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); | ||
2375 | |||
2376 | rt2800_adjust_freq_offset(rt2x00dev); | ||
2377 | |||
2378 | if (conf_is_ht40(conf)) { | ||
2379 | txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40, | ||
2380 | RFCSR24_TX_AGC_FC); | ||
2381 | txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw40, | ||
2382 | RFCSR24_TX_H20M); | ||
2383 | } else { | ||
2384 | txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20, | ||
2385 | RFCSR24_TX_AGC_FC); | ||
2386 | txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw20, | ||
2387 | RFCSR24_TX_H20M); | ||
2388 | } | ||
2389 | |||
2390 | /* NOTE: the reference driver does not writes the new value | ||
2391 | * back to RFCSR 32 | ||
2392 | */ | ||
2393 | rt2800_rfcsr_read(rt2x00dev, 32, &rfcsr); | ||
2394 | rt2x00_set_field8(&rfcsr, RFCSR32_TX_AGC_FC, txrx_agc_fc); | ||
2395 | |||
2396 | if (rf->channel <= 14) | ||
2397 | rfcsr = 0xa0; | ||
2398 | else | ||
2399 | rfcsr = 0x80; | ||
2400 | rt2800_rfcsr_write(rt2x00dev, 31, rfcsr); | ||
2401 | |||
2402 | rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); | ||
2403 | rt2x00_set_field8(&rfcsr, RFCSR30_TX_H20M, txrx_h20m); | ||
2404 | rt2x00_set_field8(&rfcsr, RFCSR30_RX_H20M, txrx_h20m); | ||
2405 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | ||
2406 | |||
2407 | /* Band selection */ | ||
2408 | rt2800_rfcsr_read(rt2x00dev, 36, &rfcsr); | ||
2409 | if (rf->channel <= 14) | ||
2410 | rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 1); | ||
2411 | else | ||
2412 | rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 0); | ||
2413 | rt2800_rfcsr_write(rt2x00dev, 36, rfcsr); | ||
2414 | |||
2415 | rt2800_rfcsr_read(rt2x00dev, 34, &rfcsr); | ||
2416 | if (rf->channel <= 14) | ||
2417 | rfcsr = 0x3c; | ||
2418 | else | ||
2419 | rfcsr = 0x20; | ||
2420 | rt2800_rfcsr_write(rt2x00dev, 34, rfcsr); | ||
2421 | |||
2422 | rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr); | ||
2423 | if (rf->channel <= 14) | ||
2424 | rfcsr = 0x1a; | ||
2425 | else | ||
2426 | rfcsr = 0x12; | ||
2427 | rt2800_rfcsr_write(rt2x00dev, 12, rfcsr); | ||
2428 | |||
2429 | rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr); | ||
2430 | if (rf->channel >= 1 && rf->channel <= 14) | ||
2431 | rt2x00_set_field8(&rfcsr, RFCSR6_VCO_IC, 1); | ||
2432 | else if (rf->channel >= 36 && rf->channel <= 64) | ||
2433 | rt2x00_set_field8(&rfcsr, RFCSR6_VCO_IC, 2); | ||
2434 | else if (rf->channel >= 100 && rf->channel <= 128) | ||
2435 | rt2x00_set_field8(&rfcsr, RFCSR6_VCO_IC, 2); | ||
2436 | else | ||
2437 | rt2x00_set_field8(&rfcsr, RFCSR6_VCO_IC, 1); | ||
2438 | rt2800_rfcsr_write(rt2x00dev, 6, rfcsr); | ||
2439 | |||
2440 | rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); | ||
2441 | rt2x00_set_field8(&rfcsr, RFCSR30_RX_VCM, 2); | ||
2442 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | ||
2443 | |||
2444 | rt2800_rfcsr_write(rt2x00dev, 46, 0x60); | ||
2445 | |||
2446 | if (rf->channel <= 14) { | ||
2447 | rt2800_rfcsr_write(rt2x00dev, 10, 0xd3); | ||
2448 | rt2800_rfcsr_write(rt2x00dev, 13, 0x12); | ||
2449 | } else { | ||
2450 | rt2800_rfcsr_write(rt2x00dev, 10, 0xd8); | ||
2451 | rt2800_rfcsr_write(rt2x00dev, 13, 0x23); | ||
2452 | } | ||
2453 | |||
2454 | rt2800_rfcsr_read(rt2x00dev, 51, &rfcsr); | ||
2455 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS01, 1); | ||
2456 | rt2800_rfcsr_write(rt2x00dev, 51, rfcsr); | ||
2457 | |||
2458 | rt2800_rfcsr_read(rt2x00dev, 51, &rfcsr); | ||
2459 | if (rf->channel <= 14) { | ||
2460 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS24, 5); | ||
2461 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS57, 3); | ||
2462 | } else { | ||
2463 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS24, 4); | ||
2464 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS57, 2); | ||
2465 | } | ||
2466 | rt2800_rfcsr_write(rt2x00dev, 51, rfcsr); | ||
2467 | |||
2468 | rt2800_rfcsr_read(rt2x00dev, 49, &rfcsr); | ||
2469 | if (rf->channel <= 14) | ||
2470 | rt2x00_set_field8(&rfcsr, RFCSR49_TX_LO1_IC, 3); | ||
2471 | else | ||
2472 | rt2x00_set_field8(&rfcsr, RFCSR49_TX_LO1_IC, 2); | ||
2473 | |||
2474 | if (txbf_enabled) | ||
2475 | rt2x00_set_field8(&rfcsr, RFCSR49_TX_DIV, 1); | ||
2476 | |||
2477 | rt2800_rfcsr_write(rt2x00dev, 49, rfcsr); | ||
2478 | |||
2479 | rt2800_rfcsr_read(rt2x00dev, 50, &rfcsr); | ||
2480 | rt2x00_set_field8(&rfcsr, RFCSR50_TX_LO1_EN, 0); | ||
2481 | rt2800_rfcsr_write(rt2x00dev, 50, rfcsr); | ||
2482 | |||
2483 | rt2800_rfcsr_read(rt2x00dev, 57, &rfcsr); | ||
2484 | if (rf->channel <= 14) | ||
2485 | rt2x00_set_field8(&rfcsr, RFCSR57_DRV_CC, 0x1b); | ||
2486 | else | ||
2487 | rt2x00_set_field8(&rfcsr, RFCSR57_DRV_CC, 0x0f); | ||
2488 | rt2800_rfcsr_write(rt2x00dev, 57, rfcsr); | ||
2489 | |||
2490 | if (rf->channel <= 14) { | ||
2491 | rt2800_rfcsr_write(rt2x00dev, 44, 0x93); | ||
2492 | rt2800_rfcsr_write(rt2x00dev, 52, 0x45); | ||
2493 | } else { | ||
2494 | rt2800_rfcsr_write(rt2x00dev, 44, 0x9b); | ||
2495 | rt2800_rfcsr_write(rt2x00dev, 52, 0x05); | ||
2496 | } | ||
2497 | |||
2498 | /* Initiate VCO calibration */ | ||
2499 | rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr); | ||
2500 | if (rf->channel <= 14) { | ||
2501 | rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1); | ||
2502 | } else { | ||
2503 | rt2x00_set_field8(&rfcsr, RFCSR3_BIT1, 1); | ||
2504 | rt2x00_set_field8(&rfcsr, RFCSR3_BIT2, 1); | ||
2505 | rt2x00_set_field8(&rfcsr, RFCSR3_BIT3, 1); | ||
2506 | rt2x00_set_field8(&rfcsr, RFCSR3_BIT4, 1); | ||
2507 | rt2x00_set_field8(&rfcsr, RFCSR3_BIT5, 1); | ||
2508 | rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1); | ||
2509 | } | ||
2510 | rt2800_rfcsr_write(rt2x00dev, 3, rfcsr); | ||
2511 | |||
2512 | if (rf->channel >= 1 && rf->channel <= 14) { | ||
2513 | rfcsr = 0x23; | ||
2514 | if (txbf_enabled) | ||
2515 | rt2x00_set_field8(&rfcsr, RFCSR39_RX_DIV, 1); | ||
2516 | rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); | ||
2517 | |||
2518 | rt2800_rfcsr_write(rt2x00dev, 45, 0xbb); | ||
2519 | } else if (rf->channel >= 36 && rf->channel <= 64) { | ||
2520 | rfcsr = 0x36; | ||
2521 | if (txbf_enabled) | ||
2522 | rt2x00_set_field8(&rfcsr, RFCSR39_RX_DIV, 1); | ||
2523 | rt2800_rfcsr_write(rt2x00dev, 39, 0x36); | ||
2524 | |||
2525 | rt2800_rfcsr_write(rt2x00dev, 45, 0xeb); | ||
2526 | } else if (rf->channel >= 100 && rf->channel <= 128) { | ||
2527 | rfcsr = 0x32; | ||
2528 | if (txbf_enabled) | ||
2529 | rt2x00_set_field8(&rfcsr, RFCSR39_RX_DIV, 1); | ||
2530 | rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); | ||
2531 | |||
2532 | rt2800_rfcsr_write(rt2x00dev, 45, 0xb3); | ||
2533 | } else { | ||
2534 | rfcsr = 0x30; | ||
2535 | if (txbf_enabled) | ||
2536 | rt2x00_set_field8(&rfcsr, RFCSR39_RX_DIV, 1); | ||
2537 | rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); | ||
2538 | |||
2539 | rt2800_rfcsr_write(rt2x00dev, 45, 0x9b); | ||
2540 | } | ||
2010 | } | 2541 | } |
2011 | 2542 | ||
2543 | #define POWER_BOUND 0x27 | ||
2544 | #define POWER_BOUND_5G 0x2b | ||
2545 | |||
2012 | static void rt2800_config_channel_rf3290(struct rt2x00_dev *rt2x00dev, | 2546 | static void rt2800_config_channel_rf3290(struct rt2x00_dev *rt2x00dev, |
2013 | struct ieee80211_conf *conf, | 2547 | struct ieee80211_conf *conf, |
2014 | struct rf_channel *rf, | 2548 | struct rf_channel *rf, |
@@ -2563,6 +3097,23 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel) | |||
2563 | rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0); | 3097 | rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0); |
2564 | } | 3098 | } |
2565 | 3099 | ||
3100 | static char rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev, | ||
3101 | unsigned int channel, | ||
3102 | char txpower) | ||
3103 | { | ||
3104 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3105 | txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC); | ||
3106 | |||
3107 | if (channel <= 14) | ||
3108 | return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER); | ||
3109 | |||
3110 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3111 | return clamp_t(char, txpower, MIN_A_TXPOWER_3593, | ||
3112 | MAX_A_TXPOWER_3593); | ||
3113 | else | ||
3114 | return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER); | ||
3115 | } | ||
3116 | |||
2566 | static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | 3117 | static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, |
2567 | struct ieee80211_conf *conf, | 3118 | struct ieee80211_conf *conf, |
2568 | struct rf_channel *rf, | 3119 | struct rf_channel *rf, |
@@ -2572,13 +3123,14 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
2572 | unsigned int tx_pin; | 3123 | unsigned int tx_pin; |
2573 | u8 bbp, rfcsr; | 3124 | u8 bbp, rfcsr; |
2574 | 3125 | ||
2575 | if (rf->channel <= 14) { | 3126 | info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, |
2576 | info->default_power1 = TXPOWER_G_TO_DEV(info->default_power1); | 3127 | info->default_power1); |
2577 | info->default_power2 = TXPOWER_G_TO_DEV(info->default_power2); | 3128 | info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, |
2578 | } else { | 3129 | info->default_power2); |
2579 | info->default_power1 = TXPOWER_A_TO_DEV(info->default_power1); | 3130 | if (rt2x00dev->default_ant.tx_chain_num > 2) |
2580 | info->default_power2 = TXPOWER_A_TO_DEV(info->default_power2); | 3131 | info->default_power3 = |
2581 | } | 3132 | rt2800_txpower_to_dev(rt2x00dev, rf->channel, |
3133 | info->default_power3); | ||
2582 | 3134 | ||
2583 | switch (rt2x00dev->chip.rf) { | 3135 | switch (rt2x00dev->chip.rf) { |
2584 | case RF2020: | 3136 | case RF2020: |
@@ -2591,6 +3143,9 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
2591 | case RF3052: | 3143 | case RF3052: |
2592 | rt2800_config_channel_rf3052(rt2x00dev, conf, rf, info); | 3144 | rt2800_config_channel_rf3052(rt2x00dev, conf, rf, info); |
2593 | break; | 3145 | break; |
3146 | case RF3053: | ||
3147 | rt2800_config_channel_rf3053(rt2x00dev, conf, rf, info); | ||
3148 | break; | ||
2594 | case RF3290: | 3149 | case RF3290: |
2595 | rt2800_config_channel_rf3290(rt2x00dev, conf, rf, info); | 3150 | rt2800_config_channel_rf3290(rt2x00dev, conf, rf, info); |
2596 | break; | 3151 | break; |
@@ -2636,6 +3191,23 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
2636 | rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); | 3191 | rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); |
2637 | rt2800_bbp_write(rt2x00dev, 27, 0x20); | 3192 | rt2800_bbp_write(rt2x00dev, 27, 0x20); |
2638 | rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); | 3193 | rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); |
3194 | } else if (rt2x00_rt(rt2x00dev, RT3593)) { | ||
3195 | if (rf->channel > 14) { | ||
3196 | /* Disable CCK Packet detection on 5GHz */ | ||
3197 | rt2800_bbp_write(rt2x00dev, 70, 0x00); | ||
3198 | } else { | ||
3199 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | ||
3200 | } | ||
3201 | |||
3202 | if (conf_is_ht40(conf)) | ||
3203 | rt2800_bbp_write(rt2x00dev, 105, 0x04); | ||
3204 | else | ||
3205 | rt2800_bbp_write(rt2x00dev, 105, 0x34); | ||
3206 | |||
3207 | rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); | ||
3208 | rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); | ||
3209 | rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); | ||
3210 | rt2800_bbp_write(rt2x00dev, 77, 0x98); | ||
2639 | } else { | 3211 | } else { |
2640 | rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); | 3212 | rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); |
2641 | rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); | 3213 | rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); |
@@ -2651,16 +3223,27 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
2651 | rt2800_bbp_write(rt2x00dev, 82, 0x62); | 3223 | rt2800_bbp_write(rt2x00dev, 82, 0x62); |
2652 | rt2800_bbp_write(rt2x00dev, 75, 0x46); | 3224 | rt2800_bbp_write(rt2x00dev, 75, 0x46); |
2653 | } else { | 3225 | } else { |
2654 | rt2800_bbp_write(rt2x00dev, 82, 0x84); | 3226 | if (rt2x00_rt(rt2x00dev, RT3593)) |
3227 | rt2800_bbp_write(rt2x00dev, 82, 0x62); | ||
3228 | else | ||
3229 | rt2800_bbp_write(rt2x00dev, 82, 0x84); | ||
2655 | rt2800_bbp_write(rt2x00dev, 75, 0x50); | 3230 | rt2800_bbp_write(rt2x00dev, 75, 0x50); |
2656 | } | 3231 | } |
3232 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3233 | rt2800_bbp_write(rt2x00dev, 83, 0x8a); | ||
2657 | } | 3234 | } |
3235 | |||
2658 | } else { | 3236 | } else { |
2659 | if (rt2x00_rt(rt2x00dev, RT3572)) | 3237 | if (rt2x00_rt(rt2x00dev, RT3572)) |
2660 | rt2800_bbp_write(rt2x00dev, 82, 0x94); | 3238 | rt2800_bbp_write(rt2x00dev, 82, 0x94); |
3239 | else if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3240 | rt2800_bbp_write(rt2x00dev, 82, 0x82); | ||
2661 | else | 3241 | else |
2662 | rt2800_bbp_write(rt2x00dev, 82, 0xf2); | 3242 | rt2800_bbp_write(rt2x00dev, 82, 0xf2); |
2663 | 3243 | ||
3244 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3245 | rt2800_bbp_write(rt2x00dev, 83, 0x9a); | ||
3246 | |||
2664 | if (test_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags)) | 3247 | if (test_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags)) |
2665 | rt2800_bbp_write(rt2x00dev, 75, 0x46); | 3248 | rt2800_bbp_write(rt2x00dev, 75, 0x46); |
2666 | else | 3249 | else |
@@ -2731,6 +3314,41 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
2731 | if (rt2x00_rt(rt2x00dev, RT3572)) | 3314 | if (rt2x00_rt(rt2x00dev, RT3572)) |
2732 | rt2800_rfcsr_write(rt2x00dev, 8, 0x80); | 3315 | rt2800_rfcsr_write(rt2x00dev, 8, 0x80); |
2733 | 3316 | ||
3317 | if (rt2x00_rt(rt2x00dev, RT3593)) { | ||
3318 | if (rt2x00_is_usb(rt2x00dev)) { | ||
3319 | rt2800_register_read(rt2x00dev, GPIO_CTRL, ®); | ||
3320 | |||
3321 | /* Band selection. GPIO #8 controls all paths */ | ||
3322 | rt2x00_set_field32(®, GPIO_CTRL_DIR8, 0); | ||
3323 | if (rf->channel <= 14) | ||
3324 | rt2x00_set_field32(®, GPIO_CTRL_VAL8, 1); | ||
3325 | else | ||
3326 | rt2x00_set_field32(®, GPIO_CTRL_VAL8, 0); | ||
3327 | |||
3328 | rt2x00_set_field32(®, GPIO_CTRL_DIR4, 0); | ||
3329 | rt2x00_set_field32(®, GPIO_CTRL_DIR7, 0); | ||
3330 | |||
3331 | /* LNA PE control. | ||
3332 | * GPIO #4 controls PE0 and PE1, | ||
3333 | * GPIO #7 controls PE2 | ||
3334 | */ | ||
3335 | rt2x00_set_field32(®, GPIO_CTRL_VAL4, 1); | ||
3336 | rt2x00_set_field32(®, GPIO_CTRL_VAL7, 1); | ||
3337 | |||
3338 | rt2800_register_write(rt2x00dev, GPIO_CTRL, reg); | ||
3339 | } | ||
3340 | |||
3341 | /* AGC init */ | ||
3342 | if (rf->channel <= 14) | ||
3343 | reg = 0x1c + 2 * rt2x00dev->lna_gain; | ||
3344 | else | ||
3345 | reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); | ||
3346 | |||
3347 | rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); | ||
3348 | |||
3349 | usleep_range(1000, 1500); | ||
3350 | } | ||
3351 | |||
2734 | if (rt2x00_rt(rt2x00dev, RT5592)) { | 3352 | if (rt2x00_rt(rt2x00dev, RT5592)) { |
2735 | rt2800_bbp_write(rt2x00dev, 195, 141); | 3353 | rt2800_bbp_write(rt2x00dev, 195, 141); |
2736 | rt2800_bbp_write(rt2x00dev, 196, conf_is_ht40(conf) ? 0x10 : 0x1a); | 3354 | rt2800_bbp_write(rt2x00dev, 196, conf_is_ht40(conf) ? 0x10 : 0x1a); |
@@ -2790,6 +3408,13 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev) | |||
2790 | int i; | 3408 | int i; |
2791 | 3409 | ||
2792 | /* | 3410 | /* |
3411 | * First check if temperature compensation is supported. | ||
3412 | */ | ||
3413 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | ||
3414 | if (!rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC)) | ||
3415 | return 0; | ||
3416 | |||
3417 | /* | ||
2793 | * Read TSSI boundaries for temperature compensation from | 3418 | * Read TSSI boundaries for temperature compensation from |
2794 | * the EEPROM. | 3419 | * the EEPROM. |
2795 | * | 3420 | * |
@@ -2798,62 +3423,62 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev) | |||
2798 | * Example TSSI bounds 0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00 | 3423 | * Example TSSI bounds 0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00 |
2799 | */ | 3424 | */ |
2800 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { | 3425 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { |
2801 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom); | 3426 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom); |
2802 | tssi_bounds[0] = rt2x00_get_field16(eeprom, | 3427 | tssi_bounds[0] = rt2x00_get_field16(eeprom, |
2803 | EEPROM_TSSI_BOUND_BG1_MINUS4); | 3428 | EEPROM_TSSI_BOUND_BG1_MINUS4); |
2804 | tssi_bounds[1] = rt2x00_get_field16(eeprom, | 3429 | tssi_bounds[1] = rt2x00_get_field16(eeprom, |
2805 | EEPROM_TSSI_BOUND_BG1_MINUS3); | 3430 | EEPROM_TSSI_BOUND_BG1_MINUS3); |
2806 | 3431 | ||
2807 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom); | 3432 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom); |
2808 | tssi_bounds[2] = rt2x00_get_field16(eeprom, | 3433 | tssi_bounds[2] = rt2x00_get_field16(eeprom, |
2809 | EEPROM_TSSI_BOUND_BG2_MINUS2); | 3434 | EEPROM_TSSI_BOUND_BG2_MINUS2); |
2810 | tssi_bounds[3] = rt2x00_get_field16(eeprom, | 3435 | tssi_bounds[3] = rt2x00_get_field16(eeprom, |
2811 | EEPROM_TSSI_BOUND_BG2_MINUS1); | 3436 | EEPROM_TSSI_BOUND_BG2_MINUS1); |
2812 | 3437 | ||
2813 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom); | 3438 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom); |
2814 | tssi_bounds[4] = rt2x00_get_field16(eeprom, | 3439 | tssi_bounds[4] = rt2x00_get_field16(eeprom, |
2815 | EEPROM_TSSI_BOUND_BG3_REF); | 3440 | EEPROM_TSSI_BOUND_BG3_REF); |
2816 | tssi_bounds[5] = rt2x00_get_field16(eeprom, | 3441 | tssi_bounds[5] = rt2x00_get_field16(eeprom, |
2817 | EEPROM_TSSI_BOUND_BG3_PLUS1); | 3442 | EEPROM_TSSI_BOUND_BG3_PLUS1); |
2818 | 3443 | ||
2819 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom); | 3444 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom); |
2820 | tssi_bounds[6] = rt2x00_get_field16(eeprom, | 3445 | tssi_bounds[6] = rt2x00_get_field16(eeprom, |
2821 | EEPROM_TSSI_BOUND_BG4_PLUS2); | 3446 | EEPROM_TSSI_BOUND_BG4_PLUS2); |
2822 | tssi_bounds[7] = rt2x00_get_field16(eeprom, | 3447 | tssi_bounds[7] = rt2x00_get_field16(eeprom, |
2823 | EEPROM_TSSI_BOUND_BG4_PLUS3); | 3448 | EEPROM_TSSI_BOUND_BG4_PLUS3); |
2824 | 3449 | ||
2825 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom); | 3450 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom); |
2826 | tssi_bounds[8] = rt2x00_get_field16(eeprom, | 3451 | tssi_bounds[8] = rt2x00_get_field16(eeprom, |
2827 | EEPROM_TSSI_BOUND_BG5_PLUS4); | 3452 | EEPROM_TSSI_BOUND_BG5_PLUS4); |
2828 | 3453 | ||
2829 | step = rt2x00_get_field16(eeprom, | 3454 | step = rt2x00_get_field16(eeprom, |
2830 | EEPROM_TSSI_BOUND_BG5_AGC_STEP); | 3455 | EEPROM_TSSI_BOUND_BG5_AGC_STEP); |
2831 | } else { | 3456 | } else { |
2832 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom); | 3457 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom); |
2833 | tssi_bounds[0] = rt2x00_get_field16(eeprom, | 3458 | tssi_bounds[0] = rt2x00_get_field16(eeprom, |
2834 | EEPROM_TSSI_BOUND_A1_MINUS4); | 3459 | EEPROM_TSSI_BOUND_A1_MINUS4); |
2835 | tssi_bounds[1] = rt2x00_get_field16(eeprom, | 3460 | tssi_bounds[1] = rt2x00_get_field16(eeprom, |
2836 | EEPROM_TSSI_BOUND_A1_MINUS3); | 3461 | EEPROM_TSSI_BOUND_A1_MINUS3); |
2837 | 3462 | ||
2838 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom); | 3463 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom); |
2839 | tssi_bounds[2] = rt2x00_get_field16(eeprom, | 3464 | tssi_bounds[2] = rt2x00_get_field16(eeprom, |
2840 | EEPROM_TSSI_BOUND_A2_MINUS2); | 3465 | EEPROM_TSSI_BOUND_A2_MINUS2); |
2841 | tssi_bounds[3] = rt2x00_get_field16(eeprom, | 3466 | tssi_bounds[3] = rt2x00_get_field16(eeprom, |
2842 | EEPROM_TSSI_BOUND_A2_MINUS1); | 3467 | EEPROM_TSSI_BOUND_A2_MINUS1); |
2843 | 3468 | ||
2844 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom); | 3469 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom); |
2845 | tssi_bounds[4] = rt2x00_get_field16(eeprom, | 3470 | tssi_bounds[4] = rt2x00_get_field16(eeprom, |
2846 | EEPROM_TSSI_BOUND_A3_REF); | 3471 | EEPROM_TSSI_BOUND_A3_REF); |
2847 | tssi_bounds[5] = rt2x00_get_field16(eeprom, | 3472 | tssi_bounds[5] = rt2x00_get_field16(eeprom, |
2848 | EEPROM_TSSI_BOUND_A3_PLUS1); | 3473 | EEPROM_TSSI_BOUND_A3_PLUS1); |
2849 | 3474 | ||
2850 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom); | 3475 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom); |
2851 | tssi_bounds[6] = rt2x00_get_field16(eeprom, | 3476 | tssi_bounds[6] = rt2x00_get_field16(eeprom, |
2852 | EEPROM_TSSI_BOUND_A4_PLUS2); | 3477 | EEPROM_TSSI_BOUND_A4_PLUS2); |
2853 | tssi_bounds[7] = rt2x00_get_field16(eeprom, | 3478 | tssi_bounds[7] = rt2x00_get_field16(eeprom, |
2854 | EEPROM_TSSI_BOUND_A4_PLUS3); | 3479 | EEPROM_TSSI_BOUND_A4_PLUS3); |
2855 | 3480 | ||
2856 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom); | 3481 | rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom); |
2857 | tssi_bounds[8] = rt2x00_get_field16(eeprom, | 3482 | tssi_bounds[8] = rt2x00_get_field16(eeprom, |
2858 | EEPROM_TSSI_BOUND_A5_PLUS4); | 3483 | EEPROM_TSSI_BOUND_A5_PLUS4); |
2859 | 3484 | ||
@@ -2899,7 +3524,7 @@ static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev, | |||
2899 | u8 comp_type; | 3524 | u8 comp_type; |
2900 | int comp_value = 0; | 3525 | int comp_value = 0; |
2901 | 3526 | ||
2902 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom); | 3527 | rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom); |
2903 | 3528 | ||
2904 | /* | 3529 | /* |
2905 | * HT40 compensation not required. | 3530 | * HT40 compensation not required. |
@@ -2966,6 +3591,9 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, | |||
2966 | u8 eirp_txpower_criterion; | 3591 | u8 eirp_txpower_criterion; |
2967 | u8 reg_limit; | 3592 | u8 reg_limit; |
2968 | 3593 | ||
3594 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
3595 | return min_t(u8, txpower, 0xc); | ||
3596 | |||
2969 | if (test_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags)) { | 3597 | if (test_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags)) { |
2970 | /* | 3598 | /* |
2971 | * Check if eirp txpower exceed txpower_limit. | 3599 | * Check if eirp txpower exceed txpower_limit. |
@@ -2974,12 +3602,12 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, | |||
2974 | * .11b data rate need add additional 4dbm | 3602 | * .11b data rate need add additional 4dbm |
2975 | * when calculating eirp txpower. | 3603 | * when calculating eirp txpower. |
2976 | */ | 3604 | */ |
2977 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1, | 3605 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, |
2978 | &eeprom); | 3606 | 1, &eeprom); |
2979 | criterion = rt2x00_get_field16(eeprom, | 3607 | criterion = rt2x00_get_field16(eeprom, |
2980 | EEPROM_TXPOWER_BYRATE_RATE0); | 3608 | EEPROM_TXPOWER_BYRATE_RATE0); |
2981 | 3609 | ||
2982 | rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, | 3610 | rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, |
2983 | &eeprom); | 3611 | &eeprom); |
2984 | 3612 | ||
2985 | if (band == IEEE80211_BAND_2GHZ) | 3613 | if (band == IEEE80211_BAND_2GHZ) |
@@ -3001,6 +3629,412 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, | |||
3001 | return min_t(u8, txpower, 0xc); | 3629 | return min_t(u8, txpower, 0xc); |
3002 | } | 3630 | } |
3003 | 3631 | ||
3632 | |||
3633 | enum { | ||
3634 | TX_PWR_CFG_0_IDX, | ||
3635 | TX_PWR_CFG_1_IDX, | ||
3636 | TX_PWR_CFG_2_IDX, | ||
3637 | TX_PWR_CFG_3_IDX, | ||
3638 | TX_PWR_CFG_4_IDX, | ||
3639 | TX_PWR_CFG_5_IDX, | ||
3640 | TX_PWR_CFG_6_IDX, | ||
3641 | TX_PWR_CFG_7_IDX, | ||
3642 | TX_PWR_CFG_8_IDX, | ||
3643 | TX_PWR_CFG_9_IDX, | ||
3644 | TX_PWR_CFG_0_EXT_IDX, | ||
3645 | TX_PWR_CFG_1_EXT_IDX, | ||
3646 | TX_PWR_CFG_2_EXT_IDX, | ||
3647 | TX_PWR_CFG_3_EXT_IDX, | ||
3648 | TX_PWR_CFG_4_EXT_IDX, | ||
3649 | TX_PWR_CFG_IDX_COUNT, | ||
3650 | }; | ||
3651 | |||
3652 | static void rt2800_config_txpower_rt3593(struct rt2x00_dev *rt2x00dev, | ||
3653 | struct ieee80211_channel *chan, | ||
3654 | int power_level) | ||
3655 | { | ||
3656 | u8 txpower; | ||
3657 | u16 eeprom; | ||
3658 | u32 regs[TX_PWR_CFG_IDX_COUNT]; | ||
3659 | unsigned int offset; | ||
3660 | enum ieee80211_band band = chan->band; | ||
3661 | int delta; | ||
3662 | int i; | ||
3663 | |||
3664 | memset(regs, '\0', sizeof(regs)); | ||
3665 | |||
3666 | /* TODO: adapt TX power reduction from the rt28xx code */ | ||
3667 | |||
3668 | /* calculate temperature compensation delta */ | ||
3669 | delta = rt2800_get_gain_calibration_delta(rt2x00dev); | ||
3670 | |||
3671 | if (band == IEEE80211_BAND_5GHZ) | ||
3672 | offset = 16; | ||
3673 | else | ||
3674 | offset = 0; | ||
3675 | |||
3676 | if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) | ||
3677 | offset += 8; | ||
3678 | |||
3679 | /* read the next four txpower values */ | ||
3680 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3681 | offset, &eeprom); | ||
3682 | |||
3683 | /* CCK 1MBS,2MBS */ | ||
3684 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3685 | txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, | ||
3686 | txpower, delta); | ||
3687 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3688 | TX_PWR_CFG_0_CCK1_CH0, txpower); | ||
3689 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3690 | TX_PWR_CFG_0_CCK1_CH1, txpower); | ||
3691 | rt2x00_set_field32(®s[TX_PWR_CFG_0_EXT_IDX], | ||
3692 | TX_PWR_CFG_0_EXT_CCK1_CH2, txpower); | ||
3693 | |||
3694 | /* CCK 5.5MBS,11MBS */ | ||
3695 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3696 | txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, | ||
3697 | txpower, delta); | ||
3698 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3699 | TX_PWR_CFG_0_CCK5_CH0, txpower); | ||
3700 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3701 | TX_PWR_CFG_0_CCK5_CH1, txpower); | ||
3702 | rt2x00_set_field32(®s[TX_PWR_CFG_0_EXT_IDX], | ||
3703 | TX_PWR_CFG_0_EXT_CCK5_CH2, txpower); | ||
3704 | |||
3705 | /* OFDM 6MBS,9MBS */ | ||
3706 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3707 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3708 | txpower, delta); | ||
3709 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3710 | TX_PWR_CFG_0_OFDM6_CH0, txpower); | ||
3711 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3712 | TX_PWR_CFG_0_OFDM6_CH1, txpower); | ||
3713 | rt2x00_set_field32(®s[TX_PWR_CFG_0_EXT_IDX], | ||
3714 | TX_PWR_CFG_0_EXT_OFDM6_CH2, txpower); | ||
3715 | |||
3716 | /* OFDM 12MBS,18MBS */ | ||
3717 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); | ||
3718 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3719 | txpower, delta); | ||
3720 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3721 | TX_PWR_CFG_0_OFDM12_CH0, txpower); | ||
3722 | rt2x00_set_field32(®s[TX_PWR_CFG_0_IDX], | ||
3723 | TX_PWR_CFG_0_OFDM12_CH1, txpower); | ||
3724 | rt2x00_set_field32(®s[TX_PWR_CFG_0_EXT_IDX], | ||
3725 | TX_PWR_CFG_0_EXT_OFDM12_CH2, txpower); | ||
3726 | |||
3727 | /* read the next four txpower values */ | ||
3728 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3729 | offset + 1, &eeprom); | ||
3730 | |||
3731 | /* OFDM 24MBS,36MBS */ | ||
3732 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3733 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3734 | txpower, delta); | ||
3735 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3736 | TX_PWR_CFG_1_OFDM24_CH0, txpower); | ||
3737 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3738 | TX_PWR_CFG_1_OFDM24_CH1, txpower); | ||
3739 | rt2x00_set_field32(®s[TX_PWR_CFG_1_EXT_IDX], | ||
3740 | TX_PWR_CFG_1_EXT_OFDM24_CH2, txpower); | ||
3741 | |||
3742 | /* OFDM 48MBS */ | ||
3743 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3744 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3745 | txpower, delta); | ||
3746 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3747 | TX_PWR_CFG_1_OFDM48_CH0, txpower); | ||
3748 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3749 | TX_PWR_CFG_1_OFDM48_CH1, txpower); | ||
3750 | rt2x00_set_field32(®s[TX_PWR_CFG_1_EXT_IDX], | ||
3751 | TX_PWR_CFG_1_EXT_OFDM48_CH2, txpower); | ||
3752 | |||
3753 | /* OFDM 54MBS */ | ||
3754 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3755 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3756 | txpower, delta); | ||
3757 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3758 | TX_PWR_CFG_7_OFDM54_CH0, txpower); | ||
3759 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3760 | TX_PWR_CFG_7_OFDM54_CH1, txpower); | ||
3761 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3762 | TX_PWR_CFG_7_OFDM54_CH2, txpower); | ||
3763 | |||
3764 | /* read the next four txpower values */ | ||
3765 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3766 | offset + 2, &eeprom); | ||
3767 | |||
3768 | /* MCS 0,1 */ | ||
3769 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3770 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3771 | txpower, delta); | ||
3772 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3773 | TX_PWR_CFG_1_MCS0_CH0, txpower); | ||
3774 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3775 | TX_PWR_CFG_1_MCS0_CH1, txpower); | ||
3776 | rt2x00_set_field32(®s[TX_PWR_CFG_1_EXT_IDX], | ||
3777 | TX_PWR_CFG_1_EXT_MCS0_CH2, txpower); | ||
3778 | |||
3779 | /* MCS 2,3 */ | ||
3780 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3781 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3782 | txpower, delta); | ||
3783 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3784 | TX_PWR_CFG_1_MCS2_CH0, txpower); | ||
3785 | rt2x00_set_field32(®s[TX_PWR_CFG_1_IDX], | ||
3786 | TX_PWR_CFG_1_MCS2_CH1, txpower); | ||
3787 | rt2x00_set_field32(®s[TX_PWR_CFG_1_EXT_IDX], | ||
3788 | TX_PWR_CFG_1_EXT_MCS2_CH2, txpower); | ||
3789 | |||
3790 | /* MCS 4,5 */ | ||
3791 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3792 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3793 | txpower, delta); | ||
3794 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3795 | TX_PWR_CFG_2_MCS4_CH0, txpower); | ||
3796 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3797 | TX_PWR_CFG_2_MCS4_CH1, txpower); | ||
3798 | rt2x00_set_field32(®s[TX_PWR_CFG_2_EXT_IDX], | ||
3799 | TX_PWR_CFG_2_EXT_MCS4_CH2, txpower); | ||
3800 | |||
3801 | /* MCS 6 */ | ||
3802 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); | ||
3803 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3804 | txpower, delta); | ||
3805 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3806 | TX_PWR_CFG_2_MCS6_CH0, txpower); | ||
3807 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3808 | TX_PWR_CFG_2_MCS6_CH1, txpower); | ||
3809 | rt2x00_set_field32(®s[TX_PWR_CFG_2_EXT_IDX], | ||
3810 | TX_PWR_CFG_2_EXT_MCS6_CH2, txpower); | ||
3811 | |||
3812 | /* read the next four txpower values */ | ||
3813 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3814 | offset + 3, &eeprom); | ||
3815 | |||
3816 | /* MCS 7 */ | ||
3817 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3818 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3819 | txpower, delta); | ||
3820 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3821 | TX_PWR_CFG_7_MCS7_CH0, txpower); | ||
3822 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3823 | TX_PWR_CFG_7_MCS7_CH1, txpower); | ||
3824 | rt2x00_set_field32(®s[TX_PWR_CFG_7_IDX], | ||
3825 | TX_PWR_CFG_7_MCS7_CH2, txpower); | ||
3826 | |||
3827 | /* MCS 8,9 */ | ||
3828 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3829 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3830 | txpower, delta); | ||
3831 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3832 | TX_PWR_CFG_2_MCS8_CH0, txpower); | ||
3833 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3834 | TX_PWR_CFG_2_MCS8_CH1, txpower); | ||
3835 | rt2x00_set_field32(®s[TX_PWR_CFG_2_EXT_IDX], | ||
3836 | TX_PWR_CFG_2_EXT_MCS8_CH2, txpower); | ||
3837 | |||
3838 | /* MCS 10,11 */ | ||
3839 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3840 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3841 | txpower, delta); | ||
3842 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3843 | TX_PWR_CFG_2_MCS10_CH0, txpower); | ||
3844 | rt2x00_set_field32(®s[TX_PWR_CFG_2_IDX], | ||
3845 | TX_PWR_CFG_2_MCS10_CH1, txpower); | ||
3846 | rt2x00_set_field32(®s[TX_PWR_CFG_2_EXT_IDX], | ||
3847 | TX_PWR_CFG_2_EXT_MCS10_CH2, txpower); | ||
3848 | |||
3849 | /* MCS 12,13 */ | ||
3850 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); | ||
3851 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3852 | txpower, delta); | ||
3853 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3854 | TX_PWR_CFG_3_MCS12_CH0, txpower); | ||
3855 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3856 | TX_PWR_CFG_3_MCS12_CH1, txpower); | ||
3857 | rt2x00_set_field32(®s[TX_PWR_CFG_3_EXT_IDX], | ||
3858 | TX_PWR_CFG_3_EXT_MCS12_CH2, txpower); | ||
3859 | |||
3860 | /* read the next four txpower values */ | ||
3861 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3862 | offset + 4, &eeprom); | ||
3863 | |||
3864 | /* MCS 14 */ | ||
3865 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3866 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3867 | txpower, delta); | ||
3868 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3869 | TX_PWR_CFG_3_MCS14_CH0, txpower); | ||
3870 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3871 | TX_PWR_CFG_3_MCS14_CH1, txpower); | ||
3872 | rt2x00_set_field32(®s[TX_PWR_CFG_3_EXT_IDX], | ||
3873 | TX_PWR_CFG_3_EXT_MCS14_CH2, txpower); | ||
3874 | |||
3875 | /* MCS 15 */ | ||
3876 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3877 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3878 | txpower, delta); | ||
3879 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3880 | TX_PWR_CFG_8_MCS15_CH0, txpower); | ||
3881 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3882 | TX_PWR_CFG_8_MCS15_CH1, txpower); | ||
3883 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3884 | TX_PWR_CFG_8_MCS15_CH2, txpower); | ||
3885 | |||
3886 | /* MCS 16,17 */ | ||
3887 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3888 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3889 | txpower, delta); | ||
3890 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3891 | TX_PWR_CFG_5_MCS16_CH0, txpower); | ||
3892 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3893 | TX_PWR_CFG_5_MCS16_CH1, txpower); | ||
3894 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3895 | TX_PWR_CFG_5_MCS16_CH2, txpower); | ||
3896 | |||
3897 | /* MCS 18,19 */ | ||
3898 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); | ||
3899 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3900 | txpower, delta); | ||
3901 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3902 | TX_PWR_CFG_5_MCS18_CH0, txpower); | ||
3903 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3904 | TX_PWR_CFG_5_MCS18_CH1, txpower); | ||
3905 | rt2x00_set_field32(®s[TX_PWR_CFG_5_IDX], | ||
3906 | TX_PWR_CFG_5_MCS18_CH2, txpower); | ||
3907 | |||
3908 | /* read the next four txpower values */ | ||
3909 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3910 | offset + 5, &eeprom); | ||
3911 | |||
3912 | /* MCS 20,21 */ | ||
3913 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3914 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3915 | txpower, delta); | ||
3916 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3917 | TX_PWR_CFG_6_MCS20_CH0, txpower); | ||
3918 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3919 | TX_PWR_CFG_6_MCS20_CH1, txpower); | ||
3920 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3921 | TX_PWR_CFG_6_MCS20_CH2, txpower); | ||
3922 | |||
3923 | /* MCS 22 */ | ||
3924 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3925 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3926 | txpower, delta); | ||
3927 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3928 | TX_PWR_CFG_6_MCS22_CH0, txpower); | ||
3929 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3930 | TX_PWR_CFG_6_MCS22_CH1, txpower); | ||
3931 | rt2x00_set_field32(®s[TX_PWR_CFG_6_IDX], | ||
3932 | TX_PWR_CFG_6_MCS22_CH2, txpower); | ||
3933 | |||
3934 | /* MCS 23 */ | ||
3935 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3936 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3937 | txpower, delta); | ||
3938 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3939 | TX_PWR_CFG_8_MCS23_CH0, txpower); | ||
3940 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3941 | TX_PWR_CFG_8_MCS23_CH1, txpower); | ||
3942 | rt2x00_set_field32(®s[TX_PWR_CFG_8_IDX], | ||
3943 | TX_PWR_CFG_8_MCS23_CH2, txpower); | ||
3944 | |||
3945 | /* read the next four txpower values */ | ||
3946 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3947 | offset + 6, &eeprom); | ||
3948 | |||
3949 | /* STBC, MCS 0,1 */ | ||
3950 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3951 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3952 | txpower, delta); | ||
3953 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3954 | TX_PWR_CFG_3_STBC0_CH0, txpower); | ||
3955 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3956 | TX_PWR_CFG_3_STBC0_CH1, txpower); | ||
3957 | rt2x00_set_field32(®s[TX_PWR_CFG_3_EXT_IDX], | ||
3958 | TX_PWR_CFG_3_EXT_STBC0_CH2, txpower); | ||
3959 | |||
3960 | /* STBC, MCS 2,3 */ | ||
3961 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); | ||
3962 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3963 | txpower, delta); | ||
3964 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3965 | TX_PWR_CFG_3_STBC2_CH0, txpower); | ||
3966 | rt2x00_set_field32(®s[TX_PWR_CFG_3_IDX], | ||
3967 | TX_PWR_CFG_3_STBC2_CH1, txpower); | ||
3968 | rt2x00_set_field32(®s[TX_PWR_CFG_3_EXT_IDX], | ||
3969 | TX_PWR_CFG_3_EXT_STBC2_CH2, txpower); | ||
3970 | |||
3971 | /* STBC, MCS 4,5 */ | ||
3972 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); | ||
3973 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3974 | txpower, delta); | ||
3975 | rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE0, txpower); | ||
3976 | rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE1, txpower); | ||
3977 | rt2x00_set_field32(®s[TX_PWR_CFG_4_EXT_IDX], TX_PWR_CFG_RATE0, | ||
3978 | txpower); | ||
3979 | |||
3980 | /* STBC, MCS 6 */ | ||
3981 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); | ||
3982 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3983 | txpower, delta); | ||
3984 | rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE2, txpower); | ||
3985 | rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE3, txpower); | ||
3986 | rt2x00_set_field32(®s[TX_PWR_CFG_4_EXT_IDX], TX_PWR_CFG_RATE2, | ||
3987 | txpower); | ||
3988 | |||
3989 | /* read the next four txpower values */ | ||
3990 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, | ||
3991 | offset + 7, &eeprom); | ||
3992 | |||
3993 | /* STBC, MCS 7 */ | ||
3994 | txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); | ||
3995 | txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, | ||
3996 | txpower, delta); | ||
3997 | rt2x00_set_field32(®s[TX_PWR_CFG_9_IDX], | ||
3998 | TX_PWR_CFG_9_STBC7_CH0, txpower); | ||
3999 | rt2x00_set_field32(®s[TX_PWR_CFG_9_IDX], | ||
4000 | TX_PWR_CFG_9_STBC7_CH1, txpower); | ||
4001 | rt2x00_set_field32(®s[TX_PWR_CFG_9_IDX], | ||
4002 | TX_PWR_CFG_9_STBC7_CH2, txpower); | ||
4003 | |||
4004 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_0, regs[TX_PWR_CFG_0_IDX]); | ||
4005 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_1, regs[TX_PWR_CFG_1_IDX]); | ||
4006 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_2, regs[TX_PWR_CFG_2_IDX]); | ||
4007 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_3, regs[TX_PWR_CFG_3_IDX]); | ||
4008 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_4, regs[TX_PWR_CFG_4_IDX]); | ||
4009 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_5, regs[TX_PWR_CFG_5_IDX]); | ||
4010 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_6, regs[TX_PWR_CFG_6_IDX]); | ||
4011 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_7, regs[TX_PWR_CFG_7_IDX]); | ||
4012 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_8, regs[TX_PWR_CFG_8_IDX]); | ||
4013 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_9, regs[TX_PWR_CFG_9_IDX]); | ||
4014 | |||
4015 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_0_EXT, | ||
4016 | regs[TX_PWR_CFG_0_EXT_IDX]); | ||
4017 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_1_EXT, | ||
4018 | regs[TX_PWR_CFG_1_EXT_IDX]); | ||
4019 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_2_EXT, | ||
4020 | regs[TX_PWR_CFG_2_EXT_IDX]); | ||
4021 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_3_EXT, | ||
4022 | regs[TX_PWR_CFG_3_EXT_IDX]); | ||
4023 | rt2800_register_write(rt2x00dev, TX_PWR_CFG_4_EXT, | ||
4024 | regs[TX_PWR_CFG_4_EXT_IDX]); | ||
4025 | |||
4026 | for (i = 0; i < TX_PWR_CFG_IDX_COUNT; i++) | ||
4027 | rt2x00_dbg(rt2x00dev, | ||
4028 | "band:%cGHz, BW:%c0MHz, TX_PWR_CFG_%d%s = %08lx\n", | ||
4029 | (band == IEEE80211_BAND_5GHZ) ? '5' : '2', | ||
4030 | (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? | ||
4031 | '4' : '2', | ||
4032 | (i > TX_PWR_CFG_9_IDX) ? | ||
4033 | (i - TX_PWR_CFG_9_IDX - 1) : i, | ||
4034 | (i > TX_PWR_CFG_9_IDX) ? "_EXT" : "", | ||
4035 | (unsigned long) regs[i]); | ||
4036 | } | ||
4037 | |||
3004 | /* | 4038 | /* |
3005 | * We configure transmit power using MAC TX_PWR_CFG_{0,...,N} registers and | 4039 | * We configure transmit power using MAC TX_PWR_CFG_{0,...,N} registers and |
3006 | * BBP R1 register. TX_PWR_CFG_X allow to configure per rate TX power values, | 4040 | * BBP R1 register. TX_PWR_CFG_X allow to configure per rate TX power values, |
@@ -3010,9 +4044,9 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, | |||
3010 | * EEPROM_TXPOWER_BYRATE offset. We adjust them and BBP R1 settings according to | 4044 | * EEPROM_TXPOWER_BYRATE offset. We adjust them and BBP R1 settings according to |
3011 | * current conditions (i.e. band, bandwidth, temperature, user settings). | 4045 | * current conditions (i.e. band, bandwidth, temperature, user settings). |
3012 | */ | 4046 | */ |
3013 | static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | 4047 | static void rt2800_config_txpower_rt28xx(struct rt2x00_dev *rt2x00dev, |
3014 | struct ieee80211_channel *chan, | 4048 | struct ieee80211_channel *chan, |
3015 | int power_level) | 4049 | int power_level) |
3016 | { | 4050 | { |
3017 | u8 txpower, r1; | 4051 | u8 txpower, r1; |
3018 | u16 eeprom; | 4052 | u16 eeprom; |
@@ -3080,8 +4114,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
3080 | rt2800_register_read(rt2x00dev, offset, ®); | 4114 | rt2800_register_read(rt2x00dev, offset, ®); |
3081 | 4115 | ||
3082 | /* read the next four txpower values */ | 4116 | /* read the next four txpower values */ |
3083 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i, | 4117 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, |
3084 | &eeprom); | 4118 | i, &eeprom); |
3085 | 4119 | ||
3086 | is_rate_b = i ? 0 : 1; | 4120 | is_rate_b = i ? 0 : 1; |
3087 | /* | 4121 | /* |
@@ -3129,8 +4163,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
3129 | rt2x00_set_field32(®, TX_PWR_CFG_RATE3, txpower); | 4163 | rt2x00_set_field32(®, TX_PWR_CFG_RATE3, txpower); |
3130 | 4164 | ||
3131 | /* read the next four txpower values */ | 4165 | /* read the next four txpower values */ |
3132 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1, | 4166 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE, |
3133 | &eeprom); | 4167 | i + 1, &eeprom); |
3134 | 4168 | ||
3135 | is_rate_b = 0; | 4169 | is_rate_b = 0; |
3136 | /* | 4170 | /* |
@@ -3184,6 +4218,16 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
3184 | } | 4218 | } |
3185 | } | 4219 | } |
3186 | 4220 | ||
4221 | static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | ||
4222 | struct ieee80211_channel *chan, | ||
4223 | int power_level) | ||
4224 | { | ||
4225 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
4226 | rt2800_config_txpower_rt3593(rt2x00dev, chan, power_level); | ||
4227 | else | ||
4228 | rt2800_config_txpower_rt28xx(rt2x00dev, chan, power_level); | ||
4229 | } | ||
4230 | |||
3187 | void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev) | 4231 | void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev) |
3188 | { | 4232 | { |
3189 | rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, | 4233 | rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, |
@@ -3219,6 +4263,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) | |||
3219 | rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); | 4263 | rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); |
3220 | rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); | 4264 | rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); |
3221 | break; | 4265 | break; |
4266 | case RF3053: | ||
3222 | case RF3290: | 4267 | case RF3290: |
3223 | case RF5360: | 4268 | case RF5360: |
3224 | case RF5370: | 4269 | case RF5370: |
@@ -3442,17 +4487,25 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
3442 | return ret; | 4487 | return ret; |
3443 | 4488 | ||
3444 | rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®); | 4489 | rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®); |
3445 | rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */ | 4490 | rt2x00_set_field32(®, BCN_OFFSET0_BCN0, |
3446 | rt2x00_set_field32(®, BCN_OFFSET0_BCN1, 0xe8); /* 0x3a00 */ | 4491 | rt2800_get_beacon_offset(rt2x00dev, 0)); |
3447 | rt2x00_set_field32(®, BCN_OFFSET0_BCN2, 0xf0); /* 0x3c00 */ | 4492 | rt2x00_set_field32(®, BCN_OFFSET0_BCN1, |
3448 | rt2x00_set_field32(®, BCN_OFFSET0_BCN3, 0xf8); /* 0x3e00 */ | 4493 | rt2800_get_beacon_offset(rt2x00dev, 1)); |
4494 | rt2x00_set_field32(®, BCN_OFFSET0_BCN2, | ||
4495 | rt2800_get_beacon_offset(rt2x00dev, 2)); | ||
4496 | rt2x00_set_field32(®, BCN_OFFSET0_BCN3, | ||
4497 | rt2800_get_beacon_offset(rt2x00dev, 3)); | ||
3449 | rt2800_register_write(rt2x00dev, BCN_OFFSET0, reg); | 4498 | rt2800_register_write(rt2x00dev, BCN_OFFSET0, reg); |
3450 | 4499 | ||
3451 | rt2800_register_read(rt2x00dev, BCN_OFFSET1, ®); | 4500 | rt2800_register_read(rt2x00dev, BCN_OFFSET1, ®); |
3452 | rt2x00_set_field32(®, BCN_OFFSET1_BCN4, 0xc8); /* 0x3200 */ | 4501 | rt2x00_set_field32(®, BCN_OFFSET1_BCN4, |
3453 | rt2x00_set_field32(®, BCN_OFFSET1_BCN5, 0xd0); /* 0x3400 */ | 4502 | rt2800_get_beacon_offset(rt2x00dev, 4)); |
3454 | rt2x00_set_field32(®, BCN_OFFSET1_BCN6, 0x77); /* 0x1dc0 */ | 4503 | rt2x00_set_field32(®, BCN_OFFSET1_BCN5, |
3455 | rt2x00_set_field32(®, BCN_OFFSET1_BCN7, 0x6f); /* 0x1bc0 */ | 4504 | rt2800_get_beacon_offset(rt2x00dev, 5)); |
4505 | rt2x00_set_field32(®, BCN_OFFSET1_BCN6, | ||
4506 | rt2800_get_beacon_offset(rt2x00dev, 6)); | ||
4507 | rt2x00_set_field32(®, BCN_OFFSET1_BCN7, | ||
4508 | rt2800_get_beacon_offset(rt2x00dev, 7)); | ||
3456 | rt2800_register_write(rt2x00dev, BCN_OFFSET1, reg); | 4509 | rt2800_register_write(rt2x00dev, BCN_OFFSET1, reg); |
3457 | 4510 | ||
3458 | rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f); | 4511 | rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f); |
@@ -3528,7 +4581,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
3528 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || | 4581 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || |
3529 | rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) || | 4582 | rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) || |
3530 | rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) { | 4583 | rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) { |
3531 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | 4584 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, |
4585 | &eeprom); | ||
3532 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST)) | 4586 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST)) |
3533 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | 4587 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, |
3534 | 0x0000002c); | 4588 | 0x0000002c); |
@@ -3559,6 +4613,23 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
3559 | } else if (rt2x00_rt(rt2x00dev, RT3572)) { | 4613 | } else if (rt2x00_rt(rt2x00dev, RT3572)) { |
3560 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); | 4614 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); |
3561 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); | 4615 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); |
4616 | } else if (rt2x00_rt(rt2x00dev, RT3593)) { | ||
4617 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000402); | ||
4618 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); | ||
4619 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3593, REV_RT3593E)) { | ||
4620 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, | ||
4621 | &eeprom); | ||
4622 | if (rt2x00_get_field16(eeprom, | ||
4623 | EEPROM_NIC_CONF1_DAC_TEST)) | ||
4624 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | ||
4625 | 0x0000001f); | ||
4626 | else | ||
4627 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | ||
4628 | 0x0000000f); | ||
4629 | } else { | ||
4630 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | ||
4631 | 0x00000000); | ||
4632 | } | ||
3562 | } else if (rt2x00_rt(rt2x00dev, RT5390) || | 4633 | } else if (rt2x00_rt(rt2x00dev, RT5390) || |
3563 | rt2x00_rt(rt2x00dev, RT5392) || | 4634 | rt2x00_rt(rt2x00dev, RT5392) || |
3564 | rt2x00_rt(rt2x00dev, RT5592)) { | 4635 | rt2x00_rt(rt2x00dev, RT5592)) { |
@@ -3786,14 +4857,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
3786 | /* | 4857 | /* |
3787 | * Clear all beacons | 4858 | * Clear all beacons |
3788 | */ | 4859 | */ |
3789 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE0); | 4860 | for (i = 0; i < 8; i++) |
3790 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE1); | 4861 | rt2800_clear_beacon_register(rt2x00dev, i); |
3791 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE2); | ||
3792 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE3); | ||
3793 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE4); | ||
3794 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE5); | ||
3795 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE6); | ||
3796 | rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE7); | ||
3797 | 4862 | ||
3798 | if (rt2x00_is_usb(rt2x00dev)) { | 4863 | if (rt2x00_is_usb(rt2x00dev)) { |
3799 | rt2800_register_read(rt2x00dev, US_CYC_CNT, ®); | 4864 | rt2800_register_read(rt2x00dev, US_CYC_CNT, ®); |
@@ -3989,7 +5054,7 @@ static void rt2800_disable_unused_dac_adc(struct rt2x00_dev *rt2x00dev) | |||
3989 | u8 value; | 5054 | u8 value; |
3990 | 5055 | ||
3991 | rt2800_bbp_read(rt2x00dev, 138, &value); | 5056 | rt2800_bbp_read(rt2x00dev, 138, &value); |
3992 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); | 5057 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); |
3993 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) | 5058 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) |
3994 | value |= 0x20; | 5059 | value |= 0x20; |
3995 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) | 5060 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) |
@@ -4332,6 +5397,22 @@ static void rt2800_init_bbp_3572(struct rt2x00_dev *rt2x00dev) | |||
4332 | rt2800_disable_unused_dac_adc(rt2x00dev); | 5397 | rt2800_disable_unused_dac_adc(rt2x00dev); |
4333 | } | 5398 | } |
4334 | 5399 | ||
5400 | static void rt2800_init_bbp_3593(struct rt2x00_dev *rt2x00dev) | ||
5401 | { | ||
5402 | rt2800_init_bbp_early(rt2x00dev); | ||
5403 | |||
5404 | rt2800_bbp_write(rt2x00dev, 79, 0x13); | ||
5405 | rt2800_bbp_write(rt2x00dev, 80, 0x05); | ||
5406 | rt2800_bbp_write(rt2x00dev, 81, 0x33); | ||
5407 | rt2800_bbp_write(rt2x00dev, 137, 0x0f); | ||
5408 | |||
5409 | rt2800_bbp_write(rt2x00dev, 84, 0x19); | ||
5410 | |||
5411 | /* Enable DC filter */ | ||
5412 | if (rt2x00_rt_rev_gte(rt2x00dev, RT3593, REV_RT3593E)) | ||
5413 | rt2800_bbp_write(rt2x00dev, 103, 0xc0); | ||
5414 | } | ||
5415 | |||
4335 | static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev) | 5416 | static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev) |
4336 | { | 5417 | { |
4337 | int ant, div_mode; | 5418 | int ant, div_mode; |
@@ -4402,7 +5483,7 @@ static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev) | |||
4402 | 5483 | ||
4403 | rt2800_disable_unused_dac_adc(rt2x00dev); | 5484 | rt2800_disable_unused_dac_adc(rt2x00dev); |
4404 | 5485 | ||
4405 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | 5486 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); |
4406 | div_mode = rt2x00_get_field16(eeprom, | 5487 | div_mode = rt2x00_get_field16(eeprom, |
4407 | EEPROM_NIC_CONF1_ANT_DIVERSITY); | 5488 | EEPROM_NIC_CONF1_ANT_DIVERSITY); |
4408 | ant = (div_mode == 3) ? 1 : 0; | 5489 | ant = (div_mode == 3) ? 1 : 0; |
@@ -4488,7 +5569,7 @@ static void rt2800_init_bbp_5592(struct rt2x00_dev *rt2x00dev) | |||
4488 | 5569 | ||
4489 | rt2800_bbp4_mac_if_ctrl(rt2x00dev); | 5570 | rt2800_bbp4_mac_if_ctrl(rt2x00dev); |
4490 | 5571 | ||
4491 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | 5572 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); |
4492 | div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY); | 5573 | div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY); |
4493 | ant = (div_mode == 3) ? 1 : 0; | 5574 | ant = (div_mode == 3) ? 1 : 0; |
4494 | rt2800_bbp_read(rt2x00dev, 152, &value); | 5575 | rt2800_bbp_read(rt2x00dev, 152, &value); |
@@ -4547,6 +5628,9 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
4547 | case RT3572: | 5628 | case RT3572: |
4548 | rt2800_init_bbp_3572(rt2x00dev); | 5629 | rt2800_init_bbp_3572(rt2x00dev); |
4549 | break; | 5630 | break; |
5631 | case RT3593: | ||
5632 | rt2800_init_bbp_3593(rt2x00dev); | ||
5633 | return; | ||
4550 | case RT5390: | 5634 | case RT5390: |
4551 | case RT5392: | 5635 | case RT5392: |
4552 | rt2800_init_bbp_53xx(rt2x00dev); | 5636 | rt2800_init_bbp_53xx(rt2x00dev); |
@@ -4557,7 +5641,8 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
4557 | } | 5641 | } |
4558 | 5642 | ||
4559 | for (i = 0; i < EEPROM_BBP_SIZE; i++) { | 5643 | for (i = 0; i < EEPROM_BBP_SIZE; i++) { |
4560 | rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom); | 5644 | rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_BBP_START, i, |
5645 | &eeprom); | ||
4561 | 5646 | ||
4562 | if (eeprom != 0xffff && eeprom != 0x0000) { | 5647 | if (eeprom != 0xffff && eeprom != 0x0000) { |
4563 | reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID); | 5648 | reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID); |
@@ -4728,7 +5813,7 @@ static void rt2800_normal_mode_setup_3xxx(struct rt2x00_dev *rt2x00dev) | |||
4728 | if (rt2x00_rt(rt2x00dev, RT3090)) { | 5813 | if (rt2x00_rt(rt2x00dev, RT3090)) { |
4729 | /* Turn off unused DAC1 and ADC1 to reduce power consumption */ | 5814 | /* Turn off unused DAC1 and ADC1 to reduce power consumption */ |
4730 | rt2800_bbp_read(rt2x00dev, 138, &bbp); | 5815 | rt2800_bbp_read(rt2x00dev, 138, &bbp); |
4731 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); | 5816 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); |
4732 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) | 5817 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) |
4733 | rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0); | 5818 | rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0); |
4734 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) | 5819 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) |
@@ -4771,6 +5856,42 @@ static void rt2800_normal_mode_setup_3xxx(struct rt2x00_dev *rt2x00dev) | |||
4771 | } | 5856 | } |
4772 | } | 5857 | } |
4773 | 5858 | ||
5859 | static void rt2800_normal_mode_setup_3593(struct rt2x00_dev *rt2x00dev) | ||
5860 | { | ||
5861 | struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; | ||
5862 | u8 rfcsr; | ||
5863 | u8 tx_gain; | ||
5864 | |||
5865 | rt2800_rfcsr_read(rt2x00dev, 50, &rfcsr); | ||
5866 | rt2x00_set_field8(&rfcsr, RFCSR50_TX_LO2_EN, 0); | ||
5867 | rt2800_rfcsr_write(rt2x00dev, 50, rfcsr); | ||
5868 | |||
5869 | rt2800_rfcsr_read(rt2x00dev, 51, &rfcsr); | ||
5870 | tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, | ||
5871 | RFCSR17_TXMIXER_GAIN); | ||
5872 | rt2x00_set_field8(&rfcsr, RFCSR51_BITS24, tx_gain); | ||
5873 | rt2800_rfcsr_write(rt2x00dev, 51, rfcsr); | ||
5874 | |||
5875 | rt2800_rfcsr_read(rt2x00dev, 38, &rfcsr); | ||
5876 | rt2x00_set_field8(&rfcsr, RFCSR38_RX_LO1_EN, 0); | ||
5877 | rt2800_rfcsr_write(rt2x00dev, 38, rfcsr); | ||
5878 | |||
5879 | rt2800_rfcsr_read(rt2x00dev, 39, &rfcsr); | ||
5880 | rt2x00_set_field8(&rfcsr, RFCSR39_RX_LO2_EN, 0); | ||
5881 | rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); | ||
5882 | |||
5883 | rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); | ||
5884 | rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); | ||
5885 | rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1); | ||
5886 | rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); | ||
5887 | |||
5888 | rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); | ||
5889 | rt2x00_set_field8(&rfcsr, RFCSR30_RX_VCM, 2); | ||
5890 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | ||
5891 | |||
5892 | /* TODO: enable stream mode */ | ||
5893 | } | ||
5894 | |||
4774 | static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev) | 5895 | static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev) |
4775 | { | 5896 | { |
4776 | u8 reg; | 5897 | u8 reg; |
@@ -4778,7 +5899,7 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev) | |||
4778 | 5899 | ||
4779 | /* Turn off unused DAC1 and ADC1 to reduce power consumption */ | 5900 | /* Turn off unused DAC1 and ADC1 to reduce power consumption */ |
4780 | rt2800_bbp_read(rt2x00dev, 138, ®); | 5901 | rt2800_bbp_read(rt2x00dev, 138, ®); |
4781 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); | 5902 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); |
4782 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) | 5903 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) |
4783 | rt2x00_set_field8(®, BBP138_RX_ADC1, 0); | 5904 | rt2x00_set_field8(®, BBP138_RX_ADC1, 0); |
4784 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) | 5905 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) |
@@ -4884,7 +6005,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev) | |||
4884 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); | 6005 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); |
4885 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || | 6006 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || |
4886 | rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) { | 6007 | rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) { |
4887 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | 6008 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, |
6009 | &eeprom); | ||
4888 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST)) | 6010 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST)) |
4889 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); | 6011 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); |
4890 | else | 6012 | else |
@@ -5152,6 +6274,136 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev) | |||
5152 | rt2800_normal_mode_setup_3xxx(rt2x00dev); | 6274 | rt2800_normal_mode_setup_3xxx(rt2x00dev); |
5153 | } | 6275 | } |
5154 | 6276 | ||
6277 | static void rt3593_post_bbp_init(struct rt2x00_dev *rt2x00dev) | ||
6278 | { | ||
6279 | u8 bbp; | ||
6280 | bool txbf_enabled = false; /* FIXME */ | ||
6281 | |||
6282 | rt2800_bbp_read(rt2x00dev, 105, &bbp); | ||
6283 | if (rt2x00dev->default_ant.rx_chain_num == 1) | ||
6284 | rt2x00_set_field8(&bbp, BBP105_MLD, 0); | ||
6285 | else | ||
6286 | rt2x00_set_field8(&bbp, BBP105_MLD, 1); | ||
6287 | rt2800_bbp_write(rt2x00dev, 105, bbp); | ||
6288 | |||
6289 | rt2800_bbp4_mac_if_ctrl(rt2x00dev); | ||
6290 | |||
6291 | rt2800_bbp_write(rt2x00dev, 92, 0x02); | ||
6292 | rt2800_bbp_write(rt2x00dev, 82, 0x82); | ||
6293 | rt2800_bbp_write(rt2x00dev, 106, 0x05); | ||
6294 | rt2800_bbp_write(rt2x00dev, 104, 0x92); | ||
6295 | rt2800_bbp_write(rt2x00dev, 88, 0x90); | ||
6296 | rt2800_bbp_write(rt2x00dev, 148, 0xc8); | ||
6297 | rt2800_bbp_write(rt2x00dev, 47, 0x48); | ||
6298 | rt2800_bbp_write(rt2x00dev, 120, 0x50); | ||
6299 | |||
6300 | if (txbf_enabled) | ||
6301 | rt2800_bbp_write(rt2x00dev, 163, 0xbd); | ||
6302 | else | ||
6303 | rt2800_bbp_write(rt2x00dev, 163, 0x9d); | ||
6304 | |||
6305 | /* SNR mapping */ | ||
6306 | rt2800_bbp_write(rt2x00dev, 142, 6); | ||
6307 | rt2800_bbp_write(rt2x00dev, 143, 160); | ||
6308 | rt2800_bbp_write(rt2x00dev, 142, 7); | ||
6309 | rt2800_bbp_write(rt2x00dev, 143, 161); | ||
6310 | rt2800_bbp_write(rt2x00dev, 142, 8); | ||
6311 | rt2800_bbp_write(rt2x00dev, 143, 162); | ||
6312 | |||
6313 | /* ADC/DAC control */ | ||
6314 | rt2800_bbp_write(rt2x00dev, 31, 0x08); | ||
6315 | |||
6316 | /* RX AGC energy lower bound in log2 */ | ||
6317 | rt2800_bbp_write(rt2x00dev, 68, 0x0b); | ||
6318 | |||
6319 | /* FIXME: BBP 105 owerwrite? */ | ||
6320 | rt2800_bbp_write(rt2x00dev, 105, 0x04); | ||
6321 | |||
6322 | } | ||
6323 | |||
6324 | static void rt2800_init_rfcsr_3593(struct rt2x00_dev *rt2x00dev) | ||
6325 | { | ||
6326 | struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; | ||
6327 | u32 reg; | ||
6328 | u8 rfcsr; | ||
6329 | |||
6330 | /* Disable GPIO #4 and #7 function for LAN PE control */ | ||
6331 | rt2800_register_read(rt2x00dev, GPIO_SWITCH, ®); | ||
6332 | rt2x00_set_field32(®, GPIO_SWITCH_4, 0); | ||
6333 | rt2x00_set_field32(®, GPIO_SWITCH_7, 0); | ||
6334 | rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg); | ||
6335 | |||
6336 | /* Initialize default register values */ | ||
6337 | rt2800_rfcsr_write(rt2x00dev, 1, 0x03); | ||
6338 | rt2800_rfcsr_write(rt2x00dev, 3, 0x80); | ||
6339 | rt2800_rfcsr_write(rt2x00dev, 5, 0x00); | ||
6340 | rt2800_rfcsr_write(rt2x00dev, 6, 0x40); | ||
6341 | rt2800_rfcsr_write(rt2x00dev, 8, 0xf1); | ||
6342 | rt2800_rfcsr_write(rt2x00dev, 9, 0x02); | ||
6343 | rt2800_rfcsr_write(rt2x00dev, 10, 0xd3); | ||
6344 | rt2800_rfcsr_write(rt2x00dev, 11, 0x40); | ||
6345 | rt2800_rfcsr_write(rt2x00dev, 12, 0x4e); | ||
6346 | rt2800_rfcsr_write(rt2x00dev, 13, 0x12); | ||
6347 | rt2800_rfcsr_write(rt2x00dev, 18, 0x40); | ||
6348 | rt2800_rfcsr_write(rt2x00dev, 22, 0x20); | ||
6349 | rt2800_rfcsr_write(rt2x00dev, 30, 0x10); | ||
6350 | rt2800_rfcsr_write(rt2x00dev, 31, 0x80); | ||
6351 | rt2800_rfcsr_write(rt2x00dev, 32, 0x78); | ||
6352 | rt2800_rfcsr_write(rt2x00dev, 33, 0x3b); | ||
6353 | rt2800_rfcsr_write(rt2x00dev, 34, 0x3c); | ||
6354 | rt2800_rfcsr_write(rt2x00dev, 35, 0xe0); | ||
6355 | rt2800_rfcsr_write(rt2x00dev, 38, 0x86); | ||
6356 | rt2800_rfcsr_write(rt2x00dev, 39, 0x23); | ||
6357 | rt2800_rfcsr_write(rt2x00dev, 44, 0xd3); | ||
6358 | rt2800_rfcsr_write(rt2x00dev, 45, 0xbb); | ||
6359 | rt2800_rfcsr_write(rt2x00dev, 46, 0x60); | ||
6360 | rt2800_rfcsr_write(rt2x00dev, 49, 0x8e); | ||
6361 | rt2800_rfcsr_write(rt2x00dev, 50, 0x86); | ||
6362 | rt2800_rfcsr_write(rt2x00dev, 51, 0x75); | ||
6363 | rt2800_rfcsr_write(rt2x00dev, 52, 0x45); | ||
6364 | rt2800_rfcsr_write(rt2x00dev, 53, 0x18); | ||
6365 | rt2800_rfcsr_write(rt2x00dev, 54, 0x18); | ||
6366 | rt2800_rfcsr_write(rt2x00dev, 55, 0x18); | ||
6367 | rt2800_rfcsr_write(rt2x00dev, 56, 0xdb); | ||
6368 | rt2800_rfcsr_write(rt2x00dev, 57, 0x6e); | ||
6369 | |||
6370 | /* Initiate calibration */ | ||
6371 | /* TODO: use rt2800_rf_init_calibration ? */ | ||
6372 | rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr); | ||
6373 | rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1); | ||
6374 | rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); | ||
6375 | |||
6376 | rt2800_adjust_freq_offset(rt2x00dev); | ||
6377 | |||
6378 | rt2800_rfcsr_read(rt2x00dev, 18, &rfcsr); | ||
6379 | rt2x00_set_field8(&rfcsr, RFCSR18_XO_TUNE_BYPASS, 1); | ||
6380 | rt2800_rfcsr_write(rt2x00dev, 18, rfcsr); | ||
6381 | |||
6382 | rt2800_register_read(rt2x00dev, LDO_CFG0, ®); | ||
6383 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); | ||
6384 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); | ||
6385 | rt2800_register_write(rt2x00dev, LDO_CFG0, reg); | ||
6386 | usleep_range(1000, 1500); | ||
6387 | rt2800_register_read(rt2x00dev, LDO_CFG0, ®); | ||
6388 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 0); | ||
6389 | rt2800_register_write(rt2x00dev, LDO_CFG0, reg); | ||
6390 | |||
6391 | /* Set initial values for RX filter calibration */ | ||
6392 | drv_data->calibration_bw20 = 0x1f; | ||
6393 | drv_data->calibration_bw40 = 0x2f; | ||
6394 | |||
6395 | /* Save BBP 25 & 26 values for later use in channel switching */ | ||
6396 | rt2800_bbp_read(rt2x00dev, 25, &drv_data->bbp25); | ||
6397 | rt2800_bbp_read(rt2x00dev, 26, &drv_data->bbp26); | ||
6398 | |||
6399 | rt2800_led_open_drain_enable(rt2x00dev); | ||
6400 | rt2800_normal_mode_setup_3593(rt2x00dev); | ||
6401 | |||
6402 | rt3593_post_bbp_init(rt2x00dev); | ||
6403 | |||
6404 | /* TODO: enable stream mode support */ | ||
6405 | } | ||
6406 | |||
5155 | static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev) | 6407 | static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev) |
5156 | { | 6408 | { |
5157 | rt2800_rf_init_calibration(rt2x00dev, 2); | 6409 | rt2800_rf_init_calibration(rt2x00dev, 2); |
@@ -5380,6 +6632,9 @@ static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
5380 | case RT3572: | 6632 | case RT3572: |
5381 | rt2800_init_rfcsr_3572(rt2x00dev); | 6633 | rt2800_init_rfcsr_3572(rt2x00dev); |
5382 | break; | 6634 | break; |
6635 | case RT3593: | ||
6636 | rt2800_init_rfcsr_3593(rt2x00dev); | ||
6637 | break; | ||
5383 | case RT5390: | 6638 | case RT5390: |
5384 | rt2800_init_rfcsr_5390(rt2x00dev); | 6639 | rt2800_init_rfcsr_5390(rt2x00dev); |
5385 | break; | 6640 | break; |
@@ -5456,15 +6711,15 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
5456 | /* | 6711 | /* |
5457 | * Initialize LED control | 6712 | * Initialize LED control |
5458 | */ | 6713 | */ |
5459 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word); | 6714 | rt2800_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word); |
5460 | rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff, | 6715 | rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff, |
5461 | word & 0xff, (word >> 8) & 0xff); | 6716 | word & 0xff, (word >> 8) & 0xff); |
5462 | 6717 | ||
5463 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word); | 6718 | rt2800_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word); |
5464 | rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff, | 6719 | rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff, |
5465 | word & 0xff, (word >> 8) & 0xff); | 6720 | word & 0xff, (word >> 8) & 0xff); |
5466 | 6721 | ||
5467 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word); | 6722 | rt2800_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word); |
5468 | rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff, | 6723 | rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff, |
5469 | word & 0xff, (word >> 8) & 0xff); | 6724 | word & 0xff, (word >> 8) & 0xff); |
5470 | 6725 | ||
@@ -5560,6 +6815,34 @@ int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) | |||
5560 | } | 6815 | } |
5561 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); | 6816 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); |
5562 | 6817 | ||
6818 | static u8 rt2800_get_txmixer_gain_24g(struct rt2x00_dev *rt2x00dev) | ||
6819 | { | ||
6820 | u16 word; | ||
6821 | |||
6822 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
6823 | return 0; | ||
6824 | |||
6825 | rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word); | ||
6826 | if ((word & 0x00ff) != 0x00ff) | ||
6827 | return rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL); | ||
6828 | |||
6829 | return 0; | ||
6830 | } | ||
6831 | |||
6832 | static u8 rt2800_get_txmixer_gain_5g(struct rt2x00_dev *rt2x00dev) | ||
6833 | { | ||
6834 | u16 word; | ||
6835 | |||
6836 | if (rt2x00_rt(rt2x00dev, RT3593)) | ||
6837 | return 0; | ||
6838 | |||
6839 | rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word); | ||
6840 | if ((word & 0x00ff) != 0x00ff) | ||
6841 | return rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL); | ||
6842 | |||
6843 | return 0; | ||
6844 | } | ||
6845 | |||
5563 | static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | 6846 | static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
5564 | { | 6847 | { |
5565 | struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; | 6848 | struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; |
@@ -5578,18 +6861,18 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5578 | /* | 6861 | /* |
5579 | * Start validation of the data that has been read. | 6862 | * Start validation of the data that has been read. |
5580 | */ | 6863 | */ |
5581 | mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); | 6864 | mac = rt2800_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); |
5582 | if (!is_valid_ether_addr(mac)) { | 6865 | if (!is_valid_ether_addr(mac)) { |
5583 | eth_random_addr(mac); | 6866 | eth_random_addr(mac); |
5584 | rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac); | 6867 | rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac); |
5585 | } | 6868 | } |
5586 | 6869 | ||
5587 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word); | 6870 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word); |
5588 | if (word == 0xffff) { | 6871 | if (word == 0xffff) { |
5589 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2); | 6872 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2); |
5590 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1); | 6873 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1); |
5591 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820); | 6874 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820); |
5592 | rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word); | 6875 | rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word); |
5593 | rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word); | 6876 | rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word); |
5594 | } else if (rt2x00_rt(rt2x00dev, RT2860) || | 6877 | } else if (rt2x00_rt(rt2x00dev, RT2860) || |
5595 | rt2x00_rt(rt2x00dev, RT2872)) { | 6878 | rt2x00_rt(rt2x00dev, RT2872)) { |
@@ -5598,10 +6881,10 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5598 | */ | 6881 | */ |
5599 | if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2) | 6882 | if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2) |
5600 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2); | 6883 | rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2); |
5601 | rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word); | 6884 | rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word); |
5602 | } | 6885 | } |
5603 | 6886 | ||
5604 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word); | 6887 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word); |
5605 | if (word == 0xffff) { | 6888 | if (word == 0xffff) { |
5606 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0); | 6889 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0); |
5607 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0); | 6890 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0); |
@@ -5618,24 +6901,24 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5618 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0); | 6901 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0); |
5619 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0); | 6902 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0); |
5620 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0); | 6903 | rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0); |
5621 | rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word); | 6904 | rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word); |
5622 | rt2x00_eeprom_dbg(rt2x00dev, "NIC: 0x%04x\n", word); | 6905 | rt2x00_eeprom_dbg(rt2x00dev, "NIC: 0x%04x\n", word); |
5623 | } | 6906 | } |
5624 | 6907 | ||
5625 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word); | 6908 | rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &word); |
5626 | if ((word & 0x00ff) == 0x00ff) { | 6909 | if ((word & 0x00ff) == 0x00ff) { |
5627 | rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0); | 6910 | rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0); |
5628 | rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word); | 6911 | rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word); |
5629 | rt2x00_eeprom_dbg(rt2x00dev, "Freq: 0x%04x\n", word); | 6912 | rt2x00_eeprom_dbg(rt2x00dev, "Freq: 0x%04x\n", word); |
5630 | } | 6913 | } |
5631 | if ((word & 0xff00) == 0xff00) { | 6914 | if ((word & 0xff00) == 0xff00) { |
5632 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE, | 6915 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE, |
5633 | LED_MODE_TXRX_ACTIVITY); | 6916 | LED_MODE_TXRX_ACTIVITY); |
5634 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0); | 6917 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0); |
5635 | rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word); | 6918 | rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word); |
5636 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555); | 6919 | rt2800_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555); |
5637 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221); | 6920 | rt2800_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221); |
5638 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8); | 6921 | rt2800_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8); |
5639 | rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word); | 6922 | rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word); |
5640 | } | 6923 | } |
5641 | 6924 | ||
@@ -5644,56 +6927,61 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5644 | * lna0 as correct value. Note that EEPROM_LNA | 6927 | * lna0 as correct value. Note that EEPROM_LNA |
5645 | * is never validated. | 6928 | * is never validated. |
5646 | */ | 6929 | */ |
5647 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word); | 6930 | rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &word); |
5648 | default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0); | 6931 | default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0); |
5649 | 6932 | ||
5650 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word); | 6933 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word); |
5651 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10) | 6934 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10) |
5652 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0); | 6935 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0); |
5653 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10) | 6936 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10) |
5654 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); | 6937 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); |
5655 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); | 6938 | rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); |
5656 | 6939 | ||
5657 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word); | 6940 | drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); |
5658 | if ((word & 0x00ff) != 0x00ff) { | ||
5659 | drv_data->txmixer_gain_24g = | ||
5660 | rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL); | ||
5661 | } else { | ||
5662 | drv_data->txmixer_gain_24g = 0; | ||
5663 | } | ||
5664 | 6941 | ||
5665 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); | 6942 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); |
5666 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) | 6943 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) |
5667 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); | 6944 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); |
5668 | if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || | 6945 | if (!rt2x00_rt(rt2x00dev, RT3593)) { |
5669 | rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) | 6946 | if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || |
5670 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, | 6947 | rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) |
5671 | default_lna_gain); | 6948 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, |
5672 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); | 6949 | default_lna_gain); |
5673 | |||
5674 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word); | ||
5675 | if ((word & 0x00ff) != 0x00ff) { | ||
5676 | drv_data->txmixer_gain_5g = | ||
5677 | rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL); | ||
5678 | } else { | ||
5679 | drv_data->txmixer_gain_5g = 0; | ||
5680 | } | 6950 | } |
6951 | rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); | ||
5681 | 6952 | ||
5682 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); | 6953 | drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); |
6954 | |||
6955 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); | ||
5683 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) | 6956 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) |
5684 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); | 6957 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); |
5685 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10) | 6958 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10) |
5686 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0); | 6959 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0); |
5687 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word); | 6960 | rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word); |
5688 | 6961 | ||
5689 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word); | 6962 | rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word); |
5690 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) | 6963 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) |
5691 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); | 6964 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); |
5692 | if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || | 6965 | if (!rt2x00_rt(rt2x00dev, RT3593)) { |
5693 | rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) | 6966 | if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || |
5694 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, | 6967 | rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) |
5695 | default_lna_gain); | 6968 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, |
5696 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); | 6969 | default_lna_gain); |
6970 | } | ||
6971 | rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); | ||
6972 | |||
6973 | if (rt2x00_rt(rt2x00dev, RT3593)) { | ||
6974 | rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &word); | ||
6975 | if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 || | ||
6976 | rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff) | ||
6977 | rt2x00_set_field16(&word, EEPROM_EXT_LNA2_A1, | ||
6978 | default_lna_gain); | ||
6979 | if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A2) == 0x00 || | ||
6980 | rt2x00_get_field16(word, EEPROM_EXT_LNA2_A2) == 0xff) | ||
6981 | rt2x00_set_field16(&word, EEPROM_EXT_LNA2_A1, | ||
6982 | default_lna_gain); | ||
6983 | rt2800_eeprom_write(rt2x00dev, EEPROM_EXT_LNA2, word); | ||
6984 | } | ||
5697 | 6985 | ||
5698 | return 0; | 6986 | return 0; |
5699 | } | 6987 | } |
@@ -5707,7 +6995,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5707 | /* | 6995 | /* |
5708 | * Read EEPROM word for configuration. | 6996 | * Read EEPROM word for configuration. |
5709 | */ | 6997 | */ |
5710 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); | 6998 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); |
5711 | 6999 | ||
5712 | /* | 7000 | /* |
5713 | * Identify RF chipset by EEPROM value | 7001 | * Identify RF chipset by EEPROM value |
@@ -5717,7 +7005,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5717 | if (rt2x00_rt(rt2x00dev, RT3290) || | 7005 | if (rt2x00_rt(rt2x00dev, RT3290) || |
5718 | rt2x00_rt(rt2x00dev, RT5390) || | 7006 | rt2x00_rt(rt2x00dev, RT5390) || |
5719 | rt2x00_rt(rt2x00dev, RT5392)) | 7007 | rt2x00_rt(rt2x00dev, RT5392)) |
5720 | rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf); | 7008 | rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf); |
5721 | else | 7009 | else |
5722 | rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); | 7010 | rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); |
5723 | 7011 | ||
@@ -5731,6 +7019,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5731 | case RF3021: | 7019 | case RF3021: |
5732 | case RF3022: | 7020 | case RF3022: |
5733 | case RF3052: | 7021 | case RF3052: |
7022 | case RF3053: | ||
5734 | case RF3290: | 7023 | case RF3290: |
5735 | case RF3320: | 7024 | case RF3320: |
5736 | case RF3322: | 7025 | case RF3322: |
@@ -5757,7 +7046,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5757 | rt2x00dev->default_ant.rx_chain_num = | 7046 | rt2x00dev->default_ant.rx_chain_num = |
5758 | rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH); | 7047 | rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH); |
5759 | 7048 | ||
5760 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); | 7049 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); |
5761 | 7050 | ||
5762 | if (rt2x00_rt(rt2x00dev, RT3070) || | 7051 | if (rt2x00_rt(rt2x00dev, RT3070) || |
5763 | rt2x00_rt(rt2x00dev, RT3090) || | 7052 | rt2x00_rt(rt2x00dev, RT3090) || |
@@ -5810,7 +7099,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5810 | /* | 7099 | /* |
5811 | * Read frequency offset and RF programming sequence. | 7100 | * Read frequency offset and RF programming sequence. |
5812 | */ | 7101 | */ |
5813 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); | 7102 | rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); |
5814 | rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); | 7103 | rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); |
5815 | 7104 | ||
5816 | /* | 7105 | /* |
@@ -5827,7 +7116,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
5827 | /* | 7116 | /* |
5828 | * Check if support EIRP tx power limit feature. | 7117 | * Check if support EIRP tx power limit feature. |
5829 | */ | 7118 | */ |
5830 | rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom); | 7119 | rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom); |
5831 | 7120 | ||
5832 | if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) < | 7121 | if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) < |
5833 | EIRP_MAX_TX_POWER_LIMIT) | 7122 | EIRP_MAX_TX_POWER_LIMIT) |
@@ -6109,12 +7398,79 @@ static const struct rf_channel rf_vals_5592_xtal40[] = { | |||
6109 | {196, 83, 0, 12, 1}, | 7398 | {196, 83, 0, 12, 1}, |
6110 | }; | 7399 | }; |
6111 | 7400 | ||
7401 | static const struct rf_channel rf_vals_3053[] = { | ||
7402 | /* Channel, N, R, K */ | ||
7403 | {1, 241, 2, 2}, | ||
7404 | {2, 241, 2, 7}, | ||
7405 | {3, 242, 2, 2}, | ||
7406 | {4, 242, 2, 7}, | ||
7407 | {5, 243, 2, 2}, | ||
7408 | {6, 243, 2, 7}, | ||
7409 | {7, 244, 2, 2}, | ||
7410 | {8, 244, 2, 7}, | ||
7411 | {9, 245, 2, 2}, | ||
7412 | {10, 245, 2, 7}, | ||
7413 | {11, 246, 2, 2}, | ||
7414 | {12, 246, 2, 7}, | ||
7415 | {13, 247, 2, 2}, | ||
7416 | {14, 248, 2, 4}, | ||
7417 | |||
7418 | {36, 0x56, 0, 4}, | ||
7419 | {38, 0x56, 0, 6}, | ||
7420 | {40, 0x56, 0, 8}, | ||
7421 | {44, 0x57, 0, 0}, | ||
7422 | {46, 0x57, 0, 2}, | ||
7423 | {48, 0x57, 0, 4}, | ||
7424 | {52, 0x57, 0, 8}, | ||
7425 | {54, 0x57, 0, 10}, | ||
7426 | {56, 0x58, 0, 0}, | ||
7427 | {60, 0x58, 0, 4}, | ||
7428 | {62, 0x58, 0, 6}, | ||
7429 | {64, 0x58, 0, 8}, | ||
7430 | |||
7431 | {100, 0x5B, 0, 8}, | ||
7432 | {102, 0x5B, 0, 10}, | ||
7433 | {104, 0x5C, 0, 0}, | ||
7434 | {108, 0x5C, 0, 4}, | ||
7435 | {110, 0x5C, 0, 6}, | ||
7436 | {112, 0x5C, 0, 8}, | ||
7437 | |||
7438 | /* NOTE: Channel 114 has been removed intentionally. | ||
7439 | * The EEPROM contains no TX power values for that, | ||
7440 | * and it is disabled in the vendor driver as well. | ||
7441 | */ | ||
7442 | |||
7443 | {116, 0x5D, 0, 0}, | ||
7444 | {118, 0x5D, 0, 2}, | ||
7445 | {120, 0x5D, 0, 4}, | ||
7446 | {124, 0x5D, 0, 8}, | ||
7447 | {126, 0x5D, 0, 10}, | ||
7448 | {128, 0x5E, 0, 0}, | ||
7449 | {132, 0x5E, 0, 4}, | ||
7450 | {134, 0x5E, 0, 6}, | ||
7451 | {136, 0x5E, 0, 8}, | ||
7452 | {140, 0x5F, 0, 0}, | ||
7453 | |||
7454 | {149, 0x5F, 0, 9}, | ||
7455 | {151, 0x5F, 0, 11}, | ||
7456 | {153, 0x60, 0, 1}, | ||
7457 | {157, 0x60, 0, 5}, | ||
7458 | {159, 0x60, 0, 7}, | ||
7459 | {161, 0x60, 0, 9}, | ||
7460 | {165, 0x61, 0, 1}, | ||
7461 | {167, 0x61, 0, 3}, | ||
7462 | {169, 0x61, 0, 5}, | ||
7463 | {171, 0x61, 0, 7}, | ||
7464 | {173, 0x61, 0, 9}, | ||
7465 | }; | ||
7466 | |||
6112 | static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | 7467 | static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
6113 | { | 7468 | { |
6114 | struct hw_mode_spec *spec = &rt2x00dev->spec; | 7469 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
6115 | struct channel_info *info; | 7470 | struct channel_info *info; |
6116 | char *default_power1; | 7471 | char *default_power1; |
6117 | char *default_power2; | 7472 | char *default_power2; |
7473 | char *default_power3; | ||
6118 | unsigned int i; | 7474 | unsigned int i; |
6119 | u16 eeprom; | 7475 | u16 eeprom; |
6120 | u32 reg; | 7476 | u32 reg; |
@@ -6133,7 +7489,8 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6133 | IEEE80211_HW_SUPPORTS_PS | | 7489 | IEEE80211_HW_SUPPORTS_PS | |
6134 | IEEE80211_HW_PS_NULLFUNC_STACK | | 7490 | IEEE80211_HW_PS_NULLFUNC_STACK | |
6135 | IEEE80211_HW_AMPDU_AGGREGATION | | 7491 | IEEE80211_HW_AMPDU_AGGREGATION | |
6136 | IEEE80211_HW_REPORTS_TX_ACK_STATUS; | 7492 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
7493 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; | ||
6137 | 7494 | ||
6138 | /* | 7495 | /* |
6139 | * Don't set IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING for USB devices | 7496 | * Don't set IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING for USB devices |
@@ -6148,7 +7505,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6148 | 7505 | ||
6149 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); | 7506 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
6150 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 7507 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
6151 | rt2x00_eeprom_addr(rt2x00dev, | 7508 | rt2800_eeprom_addr(rt2x00dev, |
6152 | EEPROM_MAC_ADDR_0)); | 7509 | EEPROM_MAC_ADDR_0)); |
6153 | 7510 | ||
6154 | /* | 7511 | /* |
@@ -6164,7 +7521,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6164 | rt2x00dev->hw->max_report_rates = 7; | 7521 | rt2x00dev->hw->max_report_rates = 7; |
6165 | rt2x00dev->hw->max_rate_tries = 1; | 7522 | rt2x00dev->hw->max_rate_tries = 1; |
6166 | 7523 | ||
6167 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); | 7524 | rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); |
6168 | 7525 | ||
6169 | /* | 7526 | /* |
6170 | * Initialize hw_mode information. | 7527 | * Initialize hw_mode information. |
@@ -6199,6 +7556,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6199 | spec->supported_bands |= SUPPORT_BAND_5GHZ; | 7556 | spec->supported_bands |= SUPPORT_BAND_5GHZ; |
6200 | spec->num_channels = ARRAY_SIZE(rf_vals_3x); | 7557 | spec->num_channels = ARRAY_SIZE(rf_vals_3x); |
6201 | spec->channels = rf_vals_3x; | 7558 | spec->channels = rf_vals_3x; |
7559 | } else if (rt2x00_rf(rt2x00dev, RF3053)) { | ||
7560 | spec->supported_bands |= SUPPORT_BAND_5GHZ; | ||
7561 | spec->num_channels = ARRAY_SIZE(rf_vals_3053); | ||
7562 | spec->channels = rf_vals_3053; | ||
6202 | } else if (rt2x00_rf(rt2x00dev, RF5592)) { | 7563 | } else if (rt2x00_rf(rt2x00dev, RF5592)) { |
6203 | spec->supported_bands |= SUPPORT_BAND_5GHZ; | 7564 | spec->supported_bands |= SUPPORT_BAND_5GHZ; |
6204 | 7565 | ||
@@ -6264,21 +7625,40 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6264 | 7625 | ||
6265 | spec->channels_info = info; | 7626 | spec->channels_info = info; |
6266 | 7627 | ||
6267 | default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); | 7628 | default_power1 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); |
6268 | default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); | 7629 | default_power2 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); |
7630 | |||
7631 | if (rt2x00dev->default_ant.tx_chain_num > 2) | ||
7632 | default_power3 = rt2800_eeprom_addr(rt2x00dev, | ||
7633 | EEPROM_EXT_TXPOWER_BG3); | ||
7634 | else | ||
7635 | default_power3 = NULL; | ||
6269 | 7636 | ||
6270 | for (i = 0; i < 14; i++) { | 7637 | for (i = 0; i < 14; i++) { |
6271 | info[i].default_power1 = default_power1[i]; | 7638 | info[i].default_power1 = default_power1[i]; |
6272 | info[i].default_power2 = default_power2[i]; | 7639 | info[i].default_power2 = default_power2[i]; |
7640 | if (default_power3) | ||
7641 | info[i].default_power3 = default_power3[i]; | ||
6273 | } | 7642 | } |
6274 | 7643 | ||
6275 | if (spec->num_channels > 14) { | 7644 | if (spec->num_channels > 14) { |
6276 | default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1); | 7645 | default_power1 = rt2800_eeprom_addr(rt2x00dev, |
6277 | default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2); | 7646 | EEPROM_TXPOWER_A1); |
7647 | default_power2 = rt2800_eeprom_addr(rt2x00dev, | ||
7648 | EEPROM_TXPOWER_A2); | ||
7649 | |||
7650 | if (rt2x00dev->default_ant.tx_chain_num > 2) | ||
7651 | default_power3 = | ||
7652 | rt2800_eeprom_addr(rt2x00dev, | ||
7653 | EEPROM_EXT_TXPOWER_A3); | ||
7654 | else | ||
7655 | default_power3 = NULL; | ||
6278 | 7656 | ||
6279 | for (i = 14; i < spec->num_channels; i++) { | 7657 | for (i = 14; i < spec->num_channels; i++) { |
6280 | info[i].default_power1 = default_power1[i - 14]; | 7658 | info[i].default_power1 = default_power1[i - 14]; |
6281 | info[i].default_power2 = default_power2[i - 14]; | 7659 | info[i].default_power2 = default_power2[i - 14]; |
7660 | if (default_power3) | ||
7661 | info[i].default_power3 = default_power3[i - 14]; | ||
6282 | } | 7662 | } |
6283 | } | 7663 | } |
6284 | 7664 | ||
@@ -6289,6 +7669,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
6289 | case RF3022: | 7669 | case RF3022: |
6290 | case RF3320: | 7670 | case RF3320: |
6291 | case RF3052: | 7671 | case RF3052: |
7672 | case RF3053: | ||
6292 | case RF3290: | 7673 | case RF3290: |
6293 | case RF5360: | 7674 | case RF5360: |
6294 | case RF5370: | 7675 | case RF5370: |
@@ -6327,6 +7708,7 @@ static int rt2800_probe_rt(struct rt2x00_dev *rt2x00dev) | |||
6327 | case RT3352: | 7708 | case RT3352: |
6328 | case RT3390: | 7709 | case RT3390: |
6329 | case RT3572: | 7710 | case RT3572: |
7711 | case RT3593: | ||
6330 | case RT5390: | 7712 | case RT5390: |
6331 | case RT5392: | 7713 | case RT5392: |
6332 | case RT5592: | 7714 | case RT5592: |
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h index 6ec739466db4..a94ba447e63c 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/rt2x00/rt2800lib.h | |||
@@ -226,4 +226,8 @@ int rt2800_get_survey(struct ieee80211_hw *hw, int idx, | |||
226 | struct survey_info *survey); | 226 | struct survey_info *survey); |
227 | void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev); | 227 | void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev); |
228 | 228 | ||
229 | void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev, | ||
230 | unsigned short *txwi_size, | ||
231 | unsigned short *rxwi_size); | ||
232 | |||
229 | #endif /* RT2800LIB_H */ | 233 | #endif /* RT2800LIB_H */ |
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 00055627eb8d..f8f2abbfbb65 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -507,9 +507,13 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev) | |||
507 | rt2x00mmio_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); | 507 | rt2x00mmio_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); |
508 | 508 | ||
509 | if (rt2x00_is_pcie(rt2x00dev) && | 509 | if (rt2x00_is_pcie(rt2x00dev) && |
510 | (rt2x00_rt(rt2x00dev, RT3572) || | 510 | (rt2x00_rt(rt2x00dev, RT3090) || |
511 | rt2x00_rt(rt2x00dev, RT3390) || | ||
512 | rt2x00_rt(rt2x00dev, RT3572) || | ||
513 | rt2x00_rt(rt2x00dev, RT3593) || | ||
511 | rt2x00_rt(rt2x00dev, RT5390) || | 514 | rt2x00_rt(rt2x00dev, RT5390) || |
512 | rt2x00_rt(rt2x00dev, RT5392))) { | 515 | rt2x00_rt(rt2x00dev, RT5392) || |
516 | rt2x00_rt(rt2x00dev, RT5592))) { | ||
513 | rt2x00mmio_register_read(rt2x00dev, AUX_CTRL, ®); | 517 | rt2x00mmio_register_read(rt2x00dev, AUX_CTRL, ®); |
514 | rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1); | 518 | rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1); |
515 | rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1); | 519 | rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1); |
@@ -1189,12 +1193,17 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { | |||
1189 | 1193 | ||
1190 | static void rt2800pci_queue_init(struct data_queue *queue) | 1194 | static void rt2800pci_queue_init(struct data_queue *queue) |
1191 | { | 1195 | { |
1196 | struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; | ||
1197 | unsigned short txwi_size, rxwi_size; | ||
1198 | |||
1199 | rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size); | ||
1200 | |||
1192 | switch (queue->qid) { | 1201 | switch (queue->qid) { |
1193 | case QID_RX: | 1202 | case QID_RX: |
1194 | queue->limit = 128; | 1203 | queue->limit = 128; |
1195 | queue->data_size = AGGREGATION_SIZE; | 1204 | queue->data_size = AGGREGATION_SIZE; |
1196 | queue->desc_size = RXD_DESC_SIZE; | 1205 | queue->desc_size = RXD_DESC_SIZE; |
1197 | queue->winfo_size = RXWI_DESC_SIZE_4WORDS; | 1206 | queue->winfo_size = rxwi_size; |
1198 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); | 1207 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); |
1199 | break; | 1208 | break; |
1200 | 1209 | ||
@@ -1205,7 +1214,7 @@ static void rt2800pci_queue_init(struct data_queue *queue) | |||
1205 | queue->limit = 64; | 1214 | queue->limit = 64; |
1206 | queue->data_size = AGGREGATION_SIZE; | 1215 | queue->data_size = AGGREGATION_SIZE; |
1207 | queue->desc_size = TXD_DESC_SIZE; | 1216 | queue->desc_size = TXD_DESC_SIZE; |
1208 | queue->winfo_size = TXWI_DESC_SIZE_4WORDS; | 1217 | queue->winfo_size = txwi_size; |
1209 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); | 1218 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); |
1210 | break; | 1219 | break; |
1211 | 1220 | ||
@@ -1213,7 +1222,7 @@ static void rt2800pci_queue_init(struct data_queue *queue) | |||
1213 | queue->limit = 8; | 1222 | queue->limit = 8; |
1214 | queue->data_size = 0; /* No DMA required for beacons */ | 1223 | queue->data_size = 0; /* No DMA required for beacons */ |
1215 | queue->desc_size = TXD_DESC_SIZE; | 1224 | queue->desc_size = TXD_DESC_SIZE; |
1216 | queue->winfo_size = TXWI_DESC_SIZE_4WORDS; | 1225 | queue->winfo_size = txwi_size; |
1217 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); | 1226 | queue->priv_size = sizeof(struct queue_entry_priv_mmio); |
1218 | break; | 1227 | break; |
1219 | 1228 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 840833b26bfa..338034e18243 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -854,13 +854,7 @@ static void rt2800usb_queue_init(struct data_queue *queue) | |||
854 | struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; | 854 | struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; |
855 | unsigned short txwi_size, rxwi_size; | 855 | unsigned short txwi_size, rxwi_size; |
856 | 856 | ||
857 | if (rt2x00_rt(rt2x00dev, RT5592)) { | 857 | rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size); |
858 | txwi_size = TXWI_DESC_SIZE_5WORDS; | ||
859 | rxwi_size = RXWI_DESC_SIZE_6WORDS; | ||
860 | } else { | ||
861 | txwi_size = TXWI_DESC_SIZE_4WORDS; | ||
862 | rxwi_size = RXWI_DESC_SIZE_4WORDS; | ||
863 | } | ||
864 | 858 | ||
865 | switch (queue->qid) { | 859 | switch (queue->qid) { |
866 | case QID_RX: | 860 | case QID_RX: |
@@ -1194,6 +1188,40 @@ static struct usb_device_id rt2800usb_device_table[] = { | |||
1194 | /* Zinwell */ | 1188 | /* Zinwell */ |
1195 | { USB_DEVICE(0x5a57, 0x0284) }, | 1189 | { USB_DEVICE(0x5a57, 0x0284) }, |
1196 | #endif | 1190 | #endif |
1191 | #ifdef CONFIG_RT2800USB_RT3573 | ||
1192 | /* AirLive */ | ||
1193 | { USB_DEVICE(0x1b75, 0x7733) }, | ||
1194 | /* ASUS */ | ||
1195 | { USB_DEVICE(0x0b05, 0x17bc) }, | ||
1196 | { USB_DEVICE(0x0b05, 0x17ad) }, | ||
1197 | /* Belkin */ | ||
1198 | { USB_DEVICE(0x050d, 0x1103) }, | ||
1199 | /* Cameo */ | ||
1200 | { USB_DEVICE(0x148f, 0xf301) }, | ||
1201 | /* Edimax */ | ||
1202 | { USB_DEVICE(0x7392, 0x7733) }, | ||
1203 | /* Hawking */ | ||
1204 | { USB_DEVICE(0x0e66, 0x0020) }, | ||
1205 | { USB_DEVICE(0x0e66, 0x0021) }, | ||
1206 | /* I-O DATA */ | ||
1207 | { USB_DEVICE(0x04bb, 0x094e) }, | ||
1208 | /* Linksys */ | ||
1209 | { USB_DEVICE(0x13b1, 0x003b) }, | ||
1210 | /* Logitec */ | ||
1211 | { USB_DEVICE(0x0789, 0x016b) }, | ||
1212 | /* NETGEAR */ | ||
1213 | { USB_DEVICE(0x0846, 0x9012) }, | ||
1214 | { USB_DEVICE(0x0846, 0x9019) }, | ||
1215 | /* Planex */ | ||
1216 | { USB_DEVICE(0x2019, 0xed19) }, | ||
1217 | /* Ralink */ | ||
1218 | { USB_DEVICE(0x148f, 0x3573) }, | ||
1219 | /* Sitecom */ | ||
1220 | { USB_DEVICE(0x0df6, 0x0067) }, | ||
1221 | { USB_DEVICE(0x0df6, 0x006a) }, | ||
1222 | /* ZyXEL */ | ||
1223 | { USB_DEVICE(0x0586, 0x3421) }, | ||
1224 | #endif | ||
1197 | #ifdef CONFIG_RT2800USB_RT53XX | 1225 | #ifdef CONFIG_RT2800USB_RT53XX |
1198 | /* Arcadyan */ | 1226 | /* Arcadyan */ |
1199 | { USB_DEVICE(0x043e, 0x7a12) }, | 1227 | { USB_DEVICE(0x043e, 0x7a12) }, |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index ee3fc570b11d..fe4c572db52c 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -211,6 +211,7 @@ struct channel_info { | |||
211 | short max_power; | 211 | short max_power; |
212 | short default_power1; | 212 | short default_power1; |
213 | short default_power2; | 213 | short default_power2; |
214 | short default_power3; | ||
214 | }; | 215 | }; |
215 | 216 | ||
216 | /* | 217 | /* |
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index 6c0a91ff963c..6c8a33b6ee22 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_entry *entry, enum queue_index index) | |||
936 | spin_unlock_irqrestore(&queue->index_lock, irqflags); | 936 | spin_unlock_irqrestore(&queue->index_lock, irqflags); |
937 | } | 937 | } |
938 | 938 | ||
939 | void rt2x00queue_pause_queue(struct data_queue *queue) | 939 | static void rt2x00queue_pause_queue_nocheck(struct data_queue *queue) |
940 | { | 940 | { |
941 | if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) || | ||
942 | !test_bit(QUEUE_STARTED, &queue->flags) || | ||
943 | test_and_set_bit(QUEUE_PAUSED, &queue->flags)) | ||
944 | return; | ||
945 | |||
946 | switch (queue->qid) { | 941 | switch (queue->qid) { |
947 | case QID_AC_VO: | 942 | case QID_AC_VO: |
948 | case QID_AC_VI: | 943 | case QID_AC_VI: |
@@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data_queue *queue) | |||
958 | break; | 953 | break; |
959 | } | 954 | } |
960 | } | 955 | } |
956 | void rt2x00queue_pause_queue(struct data_queue *queue) | ||
957 | { | ||
958 | if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) || | ||
959 | !test_bit(QUEUE_STARTED, &queue->flags) || | ||
960 | test_and_set_bit(QUEUE_PAUSED, &queue->flags)) | ||
961 | return; | ||
962 | |||
963 | rt2x00queue_pause_queue_nocheck(queue); | ||
964 | } | ||
961 | EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue); | 965 | EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue); |
962 | 966 | ||
963 | void rt2x00queue_unpause_queue(struct data_queue *queue) | 967 | void rt2x00queue_unpause_queue(struct data_queue *queue) |
@@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_queue *queue) | |||
1019 | return; | 1023 | return; |
1020 | } | 1024 | } |
1021 | 1025 | ||
1022 | rt2x00queue_pause_queue(queue); | 1026 | rt2x00queue_pause_queue_nocheck(queue); |
1023 | 1027 | ||
1024 | queue->rt2x00dev->ops->lib->stop_queue(queue); | 1028 | queue->rt2x00dev->ops->lib->stop_queue(queue); |
1025 | 1029 | ||
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 91a04e2b8ece..fc207b268e4f 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c | |||
@@ -3,10 +3,10 @@ | |||
3 | * Linux device driver for RTL8180 / RTL8185 | 3 | * Linux device driver for RTL8180 / RTL8185 |
4 | * | 4 | * |
5 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 5 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
6 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 6 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
7 | * | 7 | * |
8 | * Based on the r8180 driver, which is: | 8 | * Based on the r8180 driver, which is: |
9 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 9 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
10 | * | 10 | * |
11 | * Thanks to Realtek for their support! | 11 | * Thanks to Realtek for their support! |
12 | * | 12 | * |
@@ -32,7 +32,7 @@ | |||
32 | #include "grf5101.h" | 32 | #include "grf5101.h" |
33 | 33 | ||
34 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | 34 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); |
35 | MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); | 35 | MODULE_AUTHOR("Andrea Merello <andrea.merello@gmail.com>"); |
36 | MODULE_DESCRIPTION("RTL8180 / RTL8185 PCI wireless driver"); | 36 | MODULE_DESCRIPTION("RTL8180 / RTL8185 PCI wireless driver"); |
37 | MODULE_LICENSE("GPL"); | 37 | MODULE_LICENSE("GPL"); |
38 | 38 | ||
diff --git a/drivers/net/wireless/rtl818x/rtl8180/grf5101.c b/drivers/net/wireless/rtl818x/rtl8180/grf5101.c index 077ff92cc139..dc845693f321 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/grf5101.c +++ b/drivers/net/wireless/rtl818x/rtl8180/grf5101.c | |||
@@ -2,7 +2,7 @@ | |||
2 | /* | 2 | /* |
3 | * Radio tuning for GCT GRF5101 on RTL8180 | 3 | * Radio tuning for GCT GRF5101 on RTL8180 |
4 | * | 4 | * |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Code from the BSD driver and the rtl8181 project have been | 7 | * Code from the BSD driver and the rtl8181 project have been |
8 | * very useful to understand certain things | 8 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/grf5101.h b/drivers/net/wireless/rtl818x/rtl8180/grf5101.h index 76647111bcff..4d80a2785123 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/grf5101.h +++ b/drivers/net/wireless/rtl818x/rtl8180/grf5101.h | |||
@@ -4,7 +4,7 @@ | |||
4 | /* | 4 | /* |
5 | * Radio tuning for GCT GRF5101 on RTL8180 | 5 | * Radio tuning for GCT GRF5101 on RTL8180 |
6 | * | 6 | * |
7 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 7 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
8 | * | 8 | * |
9 | * Code from the BSD driver and the rtl8181 project have been | 9 | * Code from the BSD driver and the rtl8181 project have been |
10 | * very useful to understand certain things | 10 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/max2820.c b/drivers/net/wireless/rtl818x/rtl8180/max2820.c index 4715000c94dd..a63c443c3c6f 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/max2820.c +++ b/drivers/net/wireless/rtl818x/rtl8180/max2820.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Radio tuning for Maxim max2820 on RTL8180 | 2 | * Radio tuning for Maxim max2820 on RTL8180 |
3 | * | 3 | * |
4 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 4 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
5 | * | 5 | * |
6 | * Code from the BSD driver and the rtl8181 project have been | 6 | * Code from the BSD driver and the rtl8181 project have been |
7 | * very useful to understand certain things | 7 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/max2820.h b/drivers/net/wireless/rtl818x/rtl8180/max2820.h index 61cf6d1e7d57..8e982b72b690 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/max2820.h +++ b/drivers/net/wireless/rtl818x/rtl8180/max2820.h | |||
@@ -4,7 +4,7 @@ | |||
4 | /* | 4 | /* |
5 | * Radio tuning for Maxim max2820 on RTL8180 | 5 | * Radio tuning for Maxim max2820 on RTL8180 |
6 | * | 6 | * |
7 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 7 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
8 | * | 8 | * |
9 | * Code from the BSD driver and the rtl8181 project have been | 9 | * Code from the BSD driver and the rtl8181 project have been |
10 | * very useful to understand certain things | 10 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/rtl8225.c b/drivers/net/wireless/rtl818x/rtl8180/rtl8225.c index cc2a5412c1f0..ee638d0749d6 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/rtl8225.c +++ b/drivers/net/wireless/rtl818x/rtl8180/rtl8225.c | |||
@@ -3,10 +3,10 @@ | |||
3 | * Radio tuning for RTL8225 on RTL8180 | 3 | * Radio tuning for RTL8225 on RTL8180 |
4 | * | 4 | * |
5 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 5 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
6 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 6 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
7 | * | 7 | * |
8 | * Based on the r8180 driver, which is: | 8 | * Based on the r8180 driver, which is: |
9 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 9 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
10 | * | 10 | * |
11 | * Thanks to Realtek for their support! | 11 | * Thanks to Realtek for their support! |
12 | * | 12 | * |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/sa2400.c b/drivers/net/wireless/rtl818x/rtl8180/sa2400.c index b3ec40f6bd23..7614d9ccc729 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/sa2400.c +++ b/drivers/net/wireless/rtl818x/rtl8180/sa2400.c | |||
@@ -2,7 +2,7 @@ | |||
2 | /* | 2 | /* |
3 | * Radio tuning for Philips SA2400 on RTL8180 | 3 | * Radio tuning for Philips SA2400 on RTL8180 |
4 | * | 4 | * |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Code from the BSD driver and the rtl8181 project have been | 7 | * Code from the BSD driver and the rtl8181 project have been |
8 | * very useful to understand certain things | 8 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8180/sa2400.h b/drivers/net/wireless/rtl818x/rtl8180/sa2400.h index a4aaa0d413f1..fb0093f35148 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/sa2400.h +++ b/drivers/net/wireless/rtl818x/rtl8180/sa2400.h | |||
@@ -4,7 +4,7 @@ | |||
4 | /* | 4 | /* |
5 | * Radio tuning for Philips SA2400 on RTL8180 | 5 | * Radio tuning for Philips SA2400 on RTL8180 |
6 | * | 6 | * |
7 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 7 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
8 | * | 8 | * |
9 | * Code from the BSD driver and the rtl8181 project have been | 9 | * Code from the BSD driver and the rtl8181 project have been |
10 | * very useful to understand certain things | 10 | * very useful to understand certain things |
diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c index f49220e234b0..841fb9dfc9da 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c | |||
@@ -2,10 +2,10 @@ | |||
2 | * Linux device driver for RTL8187 | 2 | * Linux device driver for RTL8187 |
3 | * | 3 | * |
4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Based on the r8187 driver, which is: | 7 | * Based on the r8187 driver, which is: |
8 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 8 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
9 | * | 9 | * |
10 | * The driver was extended to the RTL8187B in 2008 by: | 10 | * The driver was extended to the RTL8187B in 2008 by: |
11 | * Herton Ronaldo Krzesinski <herton@mandriva.com.br> | 11 | * Herton Ronaldo Krzesinski <herton@mandriva.com.br> |
@@ -37,7 +37,7 @@ | |||
37 | #include "rfkill.h" | 37 | #include "rfkill.h" |
38 | 38 | ||
39 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | 39 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); |
40 | MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); | 40 | MODULE_AUTHOR("Andrea Merello <andrea.merello@gmail.com>"); |
41 | MODULE_AUTHOR("Herton Ronaldo Krzesinski <herton@mandriva.com.br>"); | 41 | MODULE_AUTHOR("Herton Ronaldo Krzesinski <herton@mandriva.com.br>"); |
42 | MODULE_AUTHOR("Hin-Tak Leung <htl10@users.sourceforge.net>"); | 42 | MODULE_AUTHOR("Hin-Tak Leung <htl10@users.sourceforge.net>"); |
43 | MODULE_AUTHOR("Larry Finger <Larry.Finger@lwfinger.net>"); | 43 | MODULE_AUTHOR("Larry Finger <Larry.Finger@lwfinger.net>"); |
diff --git a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h index e19a20a8e955..56aee067f324 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h | |||
@@ -2,10 +2,10 @@ | |||
2 | * Definitions for RTL8187 hardware | 2 | * Definitions for RTL8187 hardware |
3 | * | 3 | * |
4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Based on the r8187 driver, which is: | 7 | * Based on the r8187 driver, which is: |
8 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 8 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/net/wireless/rtl818x/rtl8187/rtl8225.c b/drivers/net/wireless/rtl818x/rtl8187/rtl8225.c index f0bf35fedbaf..a26193a04447 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8225.c +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8225.c | |||
@@ -2,10 +2,10 @@ | |||
2 | * Radio tuning for RTL8225 on RTL8187 | 2 | * Radio tuning for RTL8225 on RTL8187 |
3 | * | 3 | * |
4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Based on the r8187 driver, which is: | 7 | * Based on the r8187 driver, which is: |
8 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 8 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
9 | * | 9 | * |
10 | * Magic delays, register offsets, and phy value tables below are | 10 | * Magic delays, register offsets, and phy value tables below are |
11 | * taken from the original r8187 driver sources. Thanks to Realtek | 11 | * taken from the original r8187 driver sources. Thanks to Realtek |
diff --git a/drivers/net/wireless/rtl818x/rtl8187/rtl8225.h b/drivers/net/wireless/rtl818x/rtl8187/rtl8225.h index 20c5b6ead0f6..141afb09a5b4 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8225.h +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8225.h | |||
@@ -2,10 +2,10 @@ | |||
2 | * Radio tuning definitions for RTL8225 on RTL8187 | 2 | * Radio tuning definitions for RTL8225 on RTL8187 |
3 | * | 3 | * |
4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Based on the r8187 driver, which is: | 7 | * Based on the r8187 driver, which is: |
8 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 8 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/net/wireless/rtl818x/rtl818x.h b/drivers/net/wireless/rtl818x/rtl818x.h index 1615f63b02f6..ce23dfd42381 100644 --- a/drivers/net/wireless/rtl818x/rtl818x.h +++ b/drivers/net/wireless/rtl818x/rtl818x.h | |||
@@ -2,10 +2,10 @@ | |||
2 | * Definitions for RTL818x hardware | 2 | * Definitions for RTL818x hardware |
3 | * | 3 | * |
4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> | 4 | * Copyright 2007 Michael Wu <flamingice@sourmilk.net> |
5 | * Copyright 2007 Andrea Merello <andreamrl@tiscali.it> | 5 | * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> |
6 | * | 6 | * |
7 | * Based on the r8187 driver, which is: | 7 | * Based on the r8187 driver, which is: |
8 | * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 8 | * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig index 7253de3d8c66..c2ffce7a907c 100644 --- a/drivers/net/wireless/rtlwifi/Kconfig +++ b/drivers/net/wireless/rtlwifi/Kconfig | |||
@@ -1,27 +1,20 @@ | |||
1 | config RTLWIFI | 1 | menuconfig RTL_CARDS |
2 | tristate "Realtek wireless card support" | 2 | tristate "Realtek rtlwifi family of devices" |
3 | depends on MAC80211 | 3 | depends on MAC80211 && (PCI || USB) |
4 | select FW_LOADER | ||
5 | ---help--- | ||
6 | This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE | ||
7 | drivers. This module does nothing by itself - the various front-end | ||
8 | drivers need to be enabled to support any desired devices. | ||
9 | |||
10 | If you choose to build as a module, it'll be called rtlwifi. | ||
11 | |||
12 | config RTLWIFI_DEBUG | ||
13 | bool "Debugging output for rtlwifi driver family" | ||
14 | depends on RTLWIFI | ||
15 | default y | 4 | default y |
16 | ---help--- | 5 | ---help--- |
17 | To use the module option that sets the dynamic-debugging level for, | 6 | This option will enable support for the Realtek mac80211-based |
18 | the front-end driver, this parameter must be "Y". For memory-limited | 7 | wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de, |
19 | systems, choose "N". If in doubt, choose "Y". | 8 | rtl8723eu, and rtl8188eu share some common code. |
9 | |||
10 | if RTL_CARDS | ||
20 | 11 | ||
21 | config RTL8192CE | 12 | config RTL8192CE |
22 | tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter" | 13 | tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter" |
23 | depends on RTLWIFI && PCI | 14 | depends on PCI |
24 | select RTL8192C_COMMON | 15 | select RTL8192C_COMMON |
16 | select RTLWIFI | ||
17 | select RTLWIFI_PCI | ||
25 | ---help--- | 18 | ---help--- |
26 | This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe | 19 | This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe |
27 | wireless network adapters. | 20 | wireless network adapters. |
@@ -30,7 +23,9 @@ config RTL8192CE | |||
30 | 23 | ||
31 | config RTL8192SE | 24 | config RTL8192SE |
32 | tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter" | 25 | tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter" |
33 | depends on RTLWIFI && PCI | 26 | depends on PCI |
27 | select RTLWIFI | ||
28 | select RTLWIFI_PCI | ||
34 | ---help--- | 29 | ---help--- |
35 | This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe | 30 | This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe |
36 | wireless network adapters. | 31 | wireless network adapters. |
@@ -39,7 +34,9 @@ config RTL8192SE | |||
39 | 34 | ||
40 | config RTL8192DE | 35 | config RTL8192DE |
41 | tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" | 36 | tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" |
42 | depends on RTLWIFI && PCI | 37 | depends on PCI |
38 | select RTLWIFI | ||
39 | select RTLWIFI_PCI | ||
43 | ---help--- | 40 | ---help--- |
44 | This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe | 41 | This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe |
45 | wireless network adapters. | 42 | wireless network adapters. |
@@ -48,7 +45,9 @@ config RTL8192DE | |||
48 | 45 | ||
49 | config RTL8723AE | 46 | config RTL8723AE |
50 | tristate "Realtek RTL8723AE PCIe Wireless Network Adapter" | 47 | tristate "Realtek RTL8723AE PCIe Wireless Network Adapter" |
51 | depends on RTLWIFI && PCI | 48 | depends on PCI |
49 | select RTLWIFI | ||
50 | select RTLWIFI_PCI | ||
52 | ---help--- | 51 | ---help--- |
53 | This is the driver for Realtek RTL8723AE 802.11n PCIe | 52 | This is the driver for Realtek RTL8723AE 802.11n PCIe |
54 | wireless network adapters. | 53 | wireless network adapters. |
@@ -57,7 +56,9 @@ config RTL8723AE | |||
57 | 56 | ||
58 | config RTL8188EE | 57 | config RTL8188EE |
59 | tristate "Realtek RTL8188EE Wireless Network Adapter" | 58 | tristate "Realtek RTL8188EE Wireless Network Adapter" |
60 | depends on RTLWIFI && PCI | 59 | depends on PCI |
60 | select RTLWIFI | ||
61 | select RTLWIFI_PCI | ||
61 | ---help--- | 62 | ---help--- |
62 | This is the driver for Realtek RTL8188EE 802.11n PCIe | 63 | This is the driver for Realtek RTL8188EE 802.11n PCIe |
63 | wireless network adapters. | 64 | wireless network adapters. |
@@ -66,7 +67,9 @@ config RTL8188EE | |||
66 | 67 | ||
67 | config RTL8192CU | 68 | config RTL8192CU |
68 | tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter" | 69 | tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter" |
69 | depends on RTLWIFI && USB | 70 | depends on USB |
71 | select RTLWIFI | ||
72 | select RTLWIFI_USB | ||
70 | select RTL8192C_COMMON | 73 | select RTL8192C_COMMON |
71 | ---help--- | 74 | ---help--- |
72 | This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB | 75 | This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB |
@@ -74,7 +77,28 @@ config RTL8192CU | |||
74 | 77 | ||
75 | If you choose to build it as a module, it will be called rtl8192cu | 78 | If you choose to build it as a module, it will be called rtl8192cu |
76 | 79 | ||
80 | config RTLWIFI | ||
81 | tristate | ||
82 | select FW_LOADER | ||
83 | |||
84 | config RTLWIFI_PCI | ||
85 | tristate | ||
86 | |||
87 | config RTLWIFI_USB | ||
88 | tristate | ||
89 | |||
90 | config RTLWIFI_DEBUG | ||
91 | bool "Debugging output for rtlwifi driver family" | ||
92 | depends on RTLWIFI | ||
93 | default y | ||
94 | ---help--- | ||
95 | To use the module option that sets the dynamic-debugging level for, | ||
96 | the front-end driver, this parameter must be "Y". For memory-limited | ||
97 | systems, choose "N". If in doubt, choose "Y". | ||
98 | |||
77 | config RTL8192C_COMMON | 99 | config RTL8192C_COMMON |
78 | tristate | 100 | tristate |
79 | depends on RTL8192CE || RTL8192CU | 101 | depends on RTL8192CE || RTL8192CU |
80 | default m | 102 | default y |
103 | |||
104 | endif | ||
diff --git a/drivers/net/wireless/rtlwifi/Makefile b/drivers/net/wireless/rtlwifi/Makefile index ff02b874f8d8..d56f023a4b90 100644 --- a/drivers/net/wireless/rtlwifi/Makefile +++ b/drivers/net/wireless/rtlwifi/Makefile | |||
@@ -12,13 +12,11 @@ rtlwifi-objs := \ | |||
12 | 12 | ||
13 | rtl8192c_common-objs += \ | 13 | rtl8192c_common-objs += \ |
14 | 14 | ||
15 | ifneq ($(CONFIG_PCI),) | 15 | obj-$(CONFIG_RTLWIFI_PCI) += rtl_pci.o |
16 | rtlwifi-objs += pci.o | 16 | rtl_pci-objs := pci.o |
17 | endif | ||
18 | 17 | ||
19 | ifneq ($(CONFIG_USB),) | 18 | obj-$(CONFIG_RTLWIFI_USB) += rtl_usb.o |
20 | rtlwifi-objs += usb.o | 19 | rtl_usb-objs := usb.o |
21 | endif | ||
22 | 20 | ||
23 | obj-$(CONFIG_RTL8192C_COMMON) += rtl8192c/ | 21 | obj-$(CONFIG_RTL8192C_COMMON) += rtl8192c/ |
24 | obj-$(CONFIG_RTL8192CE) += rtl8192ce/ | 22 | obj-$(CONFIG_RTL8192CE) += rtl8192ce/ |
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index 9d558ac77b0c..7651f5acc14b 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c | |||
@@ -172,6 +172,7 @@ u8 rtl_tid_to_ac(u8 tid) | |||
172 | { | 172 | { |
173 | return tid_to_ac[tid]; | 173 | return tid_to_ac[tid]; |
174 | } | 174 | } |
175 | EXPORT_SYMBOL_GPL(rtl_tid_to_ac); | ||
175 | 176 | ||
176 | static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, | 177 | static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, |
177 | struct ieee80211_sta_ht_cap *ht_cap) | 178 | struct ieee80211_sta_ht_cap *ht_cap) |
@@ -406,6 +407,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw) | |||
406 | cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); | 407 | cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); |
407 | cancel_delayed_work(&rtlpriv->works.fwevt_wq); | 408 | cancel_delayed_work(&rtlpriv->works.fwevt_wq); |
408 | } | 409 | } |
410 | EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work); | ||
409 | 411 | ||
410 | void rtl_init_rfkill(struct ieee80211_hw *hw) | 412 | void rtl_init_rfkill(struct ieee80211_hw *hw) |
411 | { | 413 | { |
@@ -439,6 +441,7 @@ void rtl_deinit_rfkill(struct ieee80211_hw *hw) | |||
439 | { | 441 | { |
440 | wiphy_rfkill_stop_polling(hw->wiphy); | 442 | wiphy_rfkill_stop_polling(hw->wiphy); |
441 | } | 443 | } |
444 | EXPORT_SYMBOL_GPL(rtl_deinit_rfkill); | ||
442 | 445 | ||
443 | int rtl_init_core(struct ieee80211_hw *hw) | 446 | int rtl_init_core(struct ieee80211_hw *hw) |
444 | { | 447 | { |
@@ -489,10 +492,12 @@ int rtl_init_core(struct ieee80211_hw *hw) | |||
489 | 492 | ||
490 | return 0; | 493 | return 0; |
491 | } | 494 | } |
495 | EXPORT_SYMBOL_GPL(rtl_init_core); | ||
492 | 496 | ||
493 | void rtl_deinit_core(struct ieee80211_hw *hw) | 497 | void rtl_deinit_core(struct ieee80211_hw *hw) |
494 | { | 498 | { |
495 | } | 499 | } |
500 | EXPORT_SYMBOL_GPL(rtl_deinit_core); | ||
496 | 501 | ||
497 | void rtl_init_rx_config(struct ieee80211_hw *hw) | 502 | void rtl_init_rx_config(struct ieee80211_hw *hw) |
498 | { | 503 | { |
@@ -501,6 +506,7 @@ void rtl_init_rx_config(struct ieee80211_hw *hw) | |||
501 | 506 | ||
502 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf)); | 507 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf)); |
503 | } | 508 | } |
509 | EXPORT_SYMBOL_GPL(rtl_init_rx_config); | ||
504 | 510 | ||
505 | /********************************************************* | 511 | /********************************************************* |
506 | * | 512 | * |
@@ -879,6 +885,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
879 | 885 | ||
880 | return true; | 886 | return true; |
881 | } | 887 | } |
888 | EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc); | ||
882 | 889 | ||
883 | void rtl_get_tcb_desc(struct ieee80211_hw *hw, | 890 | void rtl_get_tcb_desc(struct ieee80211_hw *hw, |
884 | struct ieee80211_tx_info *info, | 891 | struct ieee80211_tx_info *info, |
@@ -1052,6 +1059,7 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) | |||
1052 | 1059 | ||
1053 | return true; | 1060 | return true; |
1054 | } | 1061 | } |
1062 | EXPORT_SYMBOL_GPL(rtl_action_proc); | ||
1055 | 1063 | ||
1056 | /*should call before software enc*/ | 1064 | /*should call before software enc*/ |
1057 | u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) | 1065 | u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) |
@@ -1125,6 +1133,7 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) | |||
1125 | 1133 | ||
1126 | return false; | 1134 | return false; |
1127 | } | 1135 | } |
1136 | EXPORT_SYMBOL_GPL(rtl_is_special_data); | ||
1128 | 1137 | ||
1129 | /********************************************************* | 1138 | /********************************************************* |
1130 | * | 1139 | * |
@@ -1300,6 +1309,7 @@ void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
1300 | 1309 | ||
1301 | rtlpriv->link_info.bcn_rx_inperiod++; | 1310 | rtlpriv->link_info.bcn_rx_inperiod++; |
1302 | } | 1311 | } |
1312 | EXPORT_SYMBOL_GPL(rtl_beacon_statistic); | ||
1303 | 1313 | ||
1304 | void rtl_watchdog_wq_callback(void *data) | 1314 | void rtl_watchdog_wq_callback(void *data) |
1305 | { | 1315 | { |
@@ -1793,6 +1803,7 @@ void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len) | |||
1793 | 1803 | ||
1794 | mac->vendor = vendor; | 1804 | mac->vendor = vendor; |
1795 | } | 1805 | } |
1806 | EXPORT_SYMBOL_GPL(rtl_recognize_peer); | ||
1796 | 1807 | ||
1797 | /********************************************************* | 1808 | /********************************************************* |
1798 | * | 1809 | * |
@@ -1849,6 +1860,7 @@ struct attribute_group rtl_attribute_group = { | |||
1849 | .name = "rtlsysfs", | 1860 | .name = "rtlsysfs", |
1850 | .attrs = rtl_sysfs_entries, | 1861 | .attrs = rtl_sysfs_entries, |
1851 | }; | 1862 | }; |
1863 | EXPORT_SYMBOL_GPL(rtl_attribute_group); | ||
1852 | 1864 | ||
1853 | MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); | 1865 | MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); |
1854 | MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); | 1866 | MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); |
@@ -1856,7 +1868,8 @@ MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); | |||
1856 | MODULE_LICENSE("GPL"); | 1868 | MODULE_LICENSE("GPL"); |
1857 | MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core"); | 1869 | MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core"); |
1858 | 1870 | ||
1859 | struct rtl_global_var global_var = {}; | 1871 | struct rtl_global_var rtl_global_var = {}; |
1872 | EXPORT_SYMBOL_GPL(rtl_global_var); | ||
1860 | 1873 | ||
1861 | static int __init rtl_core_module_init(void) | 1874 | static int __init rtl_core_module_init(void) |
1862 | { | 1875 | { |
@@ -1864,8 +1877,8 @@ static int __init rtl_core_module_init(void) | |||
1864 | pr_err("Unable to register rtl_rc, use default RC !!\n"); | 1877 | pr_err("Unable to register rtl_rc, use default RC !!\n"); |
1865 | 1878 | ||
1866 | /* init some global vars */ | 1879 | /* init some global vars */ |
1867 | INIT_LIST_HEAD(&global_var.glb_priv_list); | 1880 | INIT_LIST_HEAD(&rtl_global_var.glb_priv_list); |
1868 | spin_lock_init(&global_var.glb_list_lock); | 1881 | spin_lock_init(&rtl_global_var.glb_list_lock); |
1869 | 1882 | ||
1870 | return 0; | 1883 | return 0; |
1871 | } | 1884 | } |
diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h index 8576bc34b032..0e5fe0902daf 100644 --- a/drivers/net/wireless/rtlwifi/base.h +++ b/drivers/net/wireless/rtlwifi/base.h | |||
@@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len); | |||
147 | u8 rtl_tid_to_ac(u8 tid); | 147 | u8 rtl_tid_to_ac(u8 tid); |
148 | extern struct attribute_group rtl_attribute_group; | 148 | extern struct attribute_group rtl_attribute_group; |
149 | void rtl_easy_concurrent_retrytimer_callback(unsigned long data); | 149 | void rtl_easy_concurrent_retrytimer_callback(unsigned long data); |
150 | extern struct rtl_global_var global_var; | 150 | extern struct rtl_global_var rtl_global_var; |
151 | int rtlwifi_rate_mapping(struct ieee80211_hw *hw, | 151 | int rtlwifi_rate_mapping(struct ieee80211_hw *hw, |
152 | bool isht, u8 desc_rate, bool first_ampdu); | 152 | bool isht, u8 desc_rate, bool first_ampdu); |
153 | bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb); | 153 | bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb); |
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index ee84844be008..733b7ce7f0e2 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c | |||
@@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = { | |||
1330 | .rfkill_poll = rtl_op_rfkill_poll, | 1330 | .rfkill_poll = rtl_op_rfkill_poll, |
1331 | .flush = rtl_op_flush, | 1331 | .flush = rtl_op_flush, |
1332 | }; | 1332 | }; |
1333 | EXPORT_SYMBOL_GPL(rtl_ops); | ||
diff --git a/drivers/net/wireless/rtlwifi/debug.c b/drivers/net/wireless/rtlwifi/debug.c index 7d52d3d7769f..76e2086e137e 100644 --- a/drivers/net/wireless/rtlwifi/debug.c +++ b/drivers/net/wireless/rtlwifi/debug.c | |||
@@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211_hw *hw) | |||
51 | 51 | ||
52 | /*Init Debug flag enable condition */ | 52 | /*Init Debug flag enable condition */ |
53 | } | 53 | } |
54 | EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init); | ||
diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index 9e3894178e77..838a1ed3f194 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c | |||
@@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) | |||
229 | 229 | ||
230 | *pbuf = (u8) (value32 & 0xff); | 230 | *pbuf = (u8) (value32 & 0xff); |
231 | } | 231 | } |
232 | EXPORT_SYMBOL_GPL(read_efuse_byte); | ||
232 | 233 | ||
233 | void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) | 234 | void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) |
234 | { | 235 | { |
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index c97e9d327331..703f839af6ca 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c | |||
@@ -35,6 +35,13 @@ | |||
35 | #include "efuse.h" | 35 | #include "efuse.h" |
36 | #include <linux/export.h> | 36 | #include <linux/export.h> |
37 | #include <linux/kmemleak.h> | 37 | #include <linux/kmemleak.h> |
38 | #include <linux/module.h> | ||
39 | |||
40 | MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); | ||
41 | MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); | ||
42 | MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); | ||
43 | MODULE_LICENSE("GPL"); | ||
44 | MODULE_DESCRIPTION("PCI basic driver for rtlwifi"); | ||
38 | 45 | ||
39 | static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { | 46 | static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { |
40 | PCI_VENDOR_ID_INTEL, | 47 | PCI_VENDOR_ID_INTEL, |
@@ -1008,19 +1015,6 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) | |||
1008 | return; | 1015 | return; |
1009 | } | 1016 | } |
1010 | 1017 | ||
1011 | static void rtl_lps_change_work_callback(struct work_struct *work) | ||
1012 | { | ||
1013 | struct rtl_works *rtlworks = | ||
1014 | container_of(work, struct rtl_works, lps_change_work); | ||
1015 | struct ieee80211_hw *hw = rtlworks->hw; | ||
1016 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1017 | |||
1018 | if (rtlpriv->enter_ps) | ||
1019 | rtl_lps_enter(hw); | ||
1020 | else | ||
1021 | rtl_lps_leave(hw); | ||
1022 | } | ||
1023 | |||
1024 | static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) | 1018 | static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) |
1025 | { | 1019 | { |
1026 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 1020 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
@@ -1899,7 +1893,7 @@ int rtl_pci_probe(struct pci_dev *pdev, | |||
1899 | rtlpriv->rtlhal.interface = INTF_PCI; | 1893 | rtlpriv->rtlhal.interface = INTF_PCI; |
1900 | rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data); | 1894 | rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data); |
1901 | rtlpriv->intf_ops = &rtl_pci_ops; | 1895 | rtlpriv->intf_ops = &rtl_pci_ops; |
1902 | rtlpriv->glb_var = &global_var; | 1896 | rtlpriv->glb_var = &rtl_global_var; |
1903 | 1897 | ||
1904 | /* | 1898 | /* |
1905 | *init dbgp flags before all | 1899 | *init dbgp flags before all |
diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index 884bceae38a9..f646b7585d9b 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c | |||
@@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw) | |||
269 | 269 | ||
270 | spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags); | 270 | spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags); |
271 | } | 271 | } |
272 | EXPORT_SYMBOL_GPL(rtl_ips_nic_on); | ||
272 | 273 | ||
273 | /*for FW LPS*/ | 274 | /*for FW LPS*/ |
274 | 275 | ||
@@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len) | |||
518 | "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed); | 519 | "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed); |
519 | } | 520 | } |
520 | } | 521 | } |
522 | EXPORT_SYMBOL_GPL(rtl_swlps_beacon); | ||
521 | 523 | ||
522 | void rtl_swlps_rf_awake(struct ieee80211_hw *hw) | 524 | void rtl_swlps_rf_awake(struct ieee80211_hw *hw) |
523 | { | 525 | { |
@@ -611,6 +613,19 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) | |||
611 | MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40)); | 613 | MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40)); |
612 | } | 614 | } |
613 | 615 | ||
616 | void rtl_lps_change_work_callback(struct work_struct *work) | ||
617 | { | ||
618 | struct rtl_works *rtlworks = | ||
619 | container_of(work, struct rtl_works, lps_change_work); | ||
620 | struct ieee80211_hw *hw = rtlworks->hw; | ||
621 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
622 | |||
623 | if (rtlpriv->enter_ps) | ||
624 | rtl_lps_enter(hw); | ||
625 | else | ||
626 | rtl_lps_leave(hw); | ||
627 | } | ||
628 | EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback); | ||
614 | 629 | ||
615 | void rtl_swlps_wq_callback(void *data) | 630 | void rtl_swlps_wq_callback(void *data) |
616 | { | 631 | { |
@@ -673,7 +688,7 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, | |||
673 | find_p2p_ie = true; | 688 | find_p2p_ie = true; |
674 | /*to find noa ie*/ | 689 | /*to find noa ie*/ |
675 | while (ie + 1 < end) { | 690 | while (ie + 1 < end) { |
676 | noa_len = READEF2BYTE(&ie[1]); | 691 | noa_len = READEF2BYTE((__le16 *)&ie[1]); |
677 | if (ie + 3 + ie[1] > end) | 692 | if (ie + 3 + ie[1] > end) |
678 | return; | 693 | return; |
679 | 694 | ||
@@ -702,13 +717,13 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, | |||
702 | READEF1BYTE(ie+index); | 717 | READEF1BYTE(ie+index); |
703 | index += 1; | 718 | index += 1; |
704 | p2pinfo->noa_duration[i] = | 719 | p2pinfo->noa_duration[i] = |
705 | READEF4BYTE(ie+index); | 720 | READEF4BYTE((__le32 *)ie+index); |
706 | index += 4; | 721 | index += 4; |
707 | p2pinfo->noa_interval[i] = | 722 | p2pinfo->noa_interval[i] = |
708 | READEF4BYTE(ie+index); | 723 | READEF4BYTE((__le32 *)ie+index); |
709 | index += 4; | 724 | index += 4; |
710 | p2pinfo->noa_start_time[i] = | 725 | p2pinfo->noa_start_time[i] = |
711 | READEF4BYTE(ie+index); | 726 | READEF4BYTE((__le32 *)ie+index); |
712 | index += 4; | 727 | index += 4; |
713 | } | 728 | } |
714 | 729 | ||
@@ -765,7 +780,7 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, | |||
765 | RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "action frame find P2P IE.\n"); | 780 | RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "action frame find P2P IE.\n"); |
766 | /*to find noa ie*/ | 781 | /*to find noa ie*/ |
767 | while (ie + 1 < end) { | 782 | while (ie + 1 < end) { |
768 | noa_len = READEF2BYTE(&ie[1]); | 783 | noa_len = READEF2BYTE((__le16 *)&ie[1]); |
769 | if (ie + 3 + ie[1] > end) | 784 | if (ie + 3 + ie[1] > end) |
770 | return; | 785 | return; |
771 | 786 | ||
@@ -794,13 +809,13 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, | |||
794 | READEF1BYTE(ie+index); | 809 | READEF1BYTE(ie+index); |
795 | index += 1; | 810 | index += 1; |
796 | p2pinfo->noa_duration[i] = | 811 | p2pinfo->noa_duration[i] = |
797 | READEF4BYTE(ie+index); | 812 | READEF4BYTE((__le32 *)ie+index); |
798 | index += 4; | 813 | index += 4; |
799 | p2pinfo->noa_interval[i] = | 814 | p2pinfo->noa_interval[i] = |
800 | READEF4BYTE(ie+index); | 815 | READEF4BYTE((__le32 *)ie+index); |
801 | index += 4; | 816 | index += 4; |
802 | p2pinfo->noa_start_time[i] = | 817 | p2pinfo->noa_start_time[i] = |
803 | READEF4BYTE(ie+index); | 818 | READEF4BYTE((__le32 *)ie+index); |
804 | index += 4; | 819 | index += 4; |
805 | } | 820 | } |
806 | 821 | ||
@@ -922,3 +937,4 @@ void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len) | |||
922 | else | 937 | else |
923 | rtl_p2p_noa_ie(hw, data, len - FCS_LEN); | 938 | rtl_p2p_noa_ie(hw, data, len - FCS_LEN); |
924 | } | 939 | } |
940 | EXPORT_SYMBOL_GPL(rtl_p2p_info); | ||
diff --git a/drivers/net/wireless/rtlwifi/ps.h b/drivers/net/wireless/rtlwifi/ps.h index 4d682b753f50..88bd76ea88f7 100644 --- a/drivers/net/wireless/rtlwifi/ps.h +++ b/drivers/net/wireless/rtlwifi/ps.h | |||
@@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw); | |||
49 | void rtl_swlps_rf_sleep(struct ieee80211_hw *hw); | 49 | void rtl_swlps_rf_sleep(struct ieee80211_hw *hw); |
50 | void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); | 50 | void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); |
51 | void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len); | 51 | void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len); |
52 | void rtl_lps_change_work_callback(struct work_struct *work); | ||
52 | 53 | ||
53 | #endif | 54 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h index 8e3ec1e25644..0f7812e0c8aa 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h | |||
@@ -109,5 +109,8 @@ void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); | |||
109 | void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, | 109 | void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, |
110 | u8 element_id, u32 cmd_len, u8 *p_cmdbuffer); | 110 | u8 element_id, u32 cmd_len, u8 *p_cmdbuffer); |
111 | bool rtl92cu_phy_mac_config(struct ieee80211_hw *hw); | 111 | bool rtl92cu_phy_mac_config(struct ieee80211_hw *hw); |
112 | void rtl92cu_update_hal_rate_tbl(struct ieee80211_hw *hw, | ||
113 | struct ieee80211_sta *sta, | ||
114 | u8 rssi_level); | ||
112 | 115 | ||
113 | #endif | 116 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h index 262e1e4c6e5b..a1310abd0d54 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h | |||
@@ -49,8 +49,5 @@ bool rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, | |||
49 | u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw, | 49 | u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw, |
50 | enum radio_path rfpath, u32 regaddr, u32 bitmask); | 50 | enum radio_path rfpath, u32 regaddr, u32 bitmask); |
51 | void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw); | 51 | void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw); |
52 | void rtl92cu_update_hal_rate_tbl(struct ieee80211_hw *hw, | ||
53 | struct ieee80211_sta *sta, | ||
54 | u8 rssi_level); | ||
55 | 52 | ||
56 | #endif | 53 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index a3532e077871..e56778cac9bf 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c | |||
@@ -32,6 +32,13 @@ | |||
32 | #include "ps.h" | 32 | #include "ps.h" |
33 | #include "rtl8192c/fw_common.h" | 33 | #include "rtl8192c/fw_common.h" |
34 | #include <linux/export.h> | 34 | #include <linux/export.h> |
35 | #include <linux/module.h> | ||
36 | |||
37 | MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); | ||
38 | MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); | ||
39 | MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); | ||
40 | MODULE_LICENSE("GPL"); | ||
41 | MODULE_DESCRIPTION("USB basic driver for rtlwifi"); | ||
35 | 42 | ||
36 | #define REALTEK_USB_VENQT_READ 0xC0 | 43 | #define REALTEK_USB_VENQT_READ 0xC0 |
37 | #define REALTEK_USB_VENQT_WRITE 0x40 | 44 | #define REALTEK_USB_VENQT_WRITE 0x40 |
@@ -1070,6 +1077,8 @@ int rtl_usb_probe(struct usb_interface *intf, | |||
1070 | spin_lock_init(&rtlpriv->locks.usb_lock); | 1077 | spin_lock_init(&rtlpriv->locks.usb_lock); |
1071 | INIT_WORK(&rtlpriv->works.fill_h2c_cmd, | 1078 | INIT_WORK(&rtlpriv->works.fill_h2c_cmd, |
1072 | rtl_fill_h2c_cmd_work_callback); | 1079 | rtl_fill_h2c_cmd_work_callback); |
1080 | INIT_WORK(&rtlpriv->works.lps_change_work, | ||
1081 | rtl_lps_change_work_callback); | ||
1073 | 1082 | ||
1074 | rtlpriv->usb_data_index = 0; | 1083 | rtlpriv->usb_data_index = 0; |
1075 | init_completion(&rtlpriv->firmware_loading_complete); | 1084 | init_completion(&rtlpriv->firmware_loading_complete); |
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c index 4941f201d6c8..d39c4178c33a 100644 --- a/drivers/net/wireless/zd1201.c +++ b/drivers/net/wireless/zd1201.c | |||
@@ -75,8 +75,10 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw) | |||
75 | len = fw_entry->size; | 75 | len = fw_entry->size; |
76 | 76 | ||
77 | buf = kmalloc(1024, GFP_ATOMIC); | 77 | buf = kmalloc(1024, GFP_ATOMIC); |
78 | if (!buf) | 78 | if (!buf) { |
79 | err = -ENOMEM; | ||
79 | goto exit; | 80 | goto exit; |
81 | } | ||
80 | 82 | ||
81 | while (len > 0) { | 83 | while (len > 0) { |
82 | int translen = (len > 1024) ? 1024 : len; | 84 | int translen = (len > 1024) ? 1024 : len; |
@@ -98,10 +100,12 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw) | |||
98 | goto exit; | 100 | goto exit; |
99 | 101 | ||
100 | err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, | 102 | err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, |
101 | USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT); | 103 | USB_DIR_IN | 0x40, 0, 0, buf, sizeof(ret), ZD1201_FW_TIMEOUT); |
102 | if (err < 0) | 104 | if (err < 0) |
103 | goto exit; | 105 | goto exit; |
104 | 106 | ||
107 | memcpy(&ret, buf, sizeof(ret)); | ||
108 | |||
105 | if (ret & 0x80) { | 109 | if (ret & 0x80) { |
106 | err = -EIO; | 110 | err = -EIO; |
107 | goto exit; | 111 | goto exit; |
@@ -1762,8 +1766,10 @@ static int zd1201_probe(struct usb_interface *interface, | |||
1762 | zd->endp_out2 = 2; | 1766 | zd->endp_out2 = 2; |
1763 | zd->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 1767 | zd->rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
1764 | zd->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 1768 | zd->tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
1765 | if (!zd->rx_urb || !zd->tx_urb) | 1769 | if (!zd->rx_urb || !zd->tx_urb) { |
1770 | err = -ENOMEM; | ||
1766 | goto err_zd; | 1771 | goto err_zd; |
1772 | } | ||
1767 | 1773 | ||
1768 | mdelay(100); | 1774 | mdelay(100); |
1769 | err = zd1201_drvr_start(zd); | 1775 | err = zd1201_drvr_start(zd); |
diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c index c5c30fb1d7bf..9a53f13c88df 100644 --- a/drivers/nfc/nfcsim.c +++ b/drivers/nfc/nfcsim.c | |||
@@ -60,7 +60,7 @@ struct nfcsim { | |||
60 | static struct nfcsim *dev0; | 60 | static struct nfcsim *dev0; |
61 | static struct nfcsim *dev1; | 61 | static struct nfcsim *dev1; |
62 | 62 | ||
63 | struct workqueue_struct *wq; | 63 | static struct workqueue_struct *wq; |
64 | 64 | ||
65 | static void nfcsim_cleanup_dev(struct nfcsim *dev, u8 shutdown) | 65 | static void nfcsim_cleanup_dev(struct nfcsim *dev, u8 shutdown) |
66 | { | 66 | { |
@@ -481,7 +481,7 @@ static void nfcsim_free_device(struct nfcsim *dev) | |||
481 | kfree(dev); | 481 | kfree(dev); |
482 | } | 482 | } |
483 | 483 | ||
484 | int __init nfcsim_init(void) | 484 | static int __init nfcsim_init(void) |
485 | { | 485 | { |
486 | int rc; | 486 | int rc; |
487 | 487 | ||
@@ -522,7 +522,7 @@ exit: | |||
522 | return rc; | 522 | return rc; |
523 | } | 523 | } |
524 | 524 | ||
525 | void __exit nfcsim_exit(void) | 525 | static void __exit nfcsim_exit(void) |
526 | { | 526 | { |
527 | nfcsim_cleanup_dev(dev0, 1); | 527 | nfcsim_cleanup_dev(dev0, 1); |
528 | nfcsim_cleanup_dev(dev1, 1); | 528 | nfcsim_cleanup_dev(dev1, 1); |
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index daf92ac209f8..5df730be88a3 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -83,12 +83,20 @@ MODULE_DEVICE_TABLE(usb, pn533_table); | |||
83 | 83 | ||
84 | /* How much time we spend listening for initiators */ | 84 | /* How much time we spend listening for initiators */ |
85 | #define PN533_LISTEN_TIME 2 | 85 | #define PN533_LISTEN_TIME 2 |
86 | /* Delay between each poll frame (ms) */ | ||
87 | #define PN533_POLL_INTERVAL 10 | ||
86 | 88 | ||
87 | /* Standard pn533 frame definitions */ | 89 | /* Standard pn533 frame definitions (standard and extended)*/ |
88 | #define PN533_STD_FRAME_HEADER_LEN (sizeof(struct pn533_std_frame) \ | 90 | #define PN533_STD_FRAME_HEADER_LEN (sizeof(struct pn533_std_frame) \ |
89 | + 2) /* data[0] TFI, data[1] CC */ | 91 | + 2) /* data[0] TFI, data[1] CC */ |
90 | #define PN533_STD_FRAME_TAIL_LEN 2 /* data[len] DCS, data[len + 1] postamble*/ | 92 | #define PN533_STD_FRAME_TAIL_LEN 2 /* data[len] DCS, data[len + 1] postamble*/ |
91 | 93 | ||
94 | #define PN533_EXT_FRAME_HEADER_LEN (sizeof(struct pn533_ext_frame) \ | ||
95 | + 2) /* data[0] TFI, data[1] CC */ | ||
96 | |||
97 | #define PN533_CMD_DATAEXCH_DATA_MAXLEN 262 | ||
98 | #define PN533_CMD_DATAFRAME_MAXLEN 240 /* max data length (send) */ | ||
99 | |||
92 | /* | 100 | /* |
93 | * Max extended frame payload len, excluding TFI and CC | 101 | * Max extended frame payload len, excluding TFI and CC |
94 | * which are already in PN533_FRAME_HEADER_LEN. | 102 | * which are already in PN533_FRAME_HEADER_LEN. |
@@ -99,6 +107,10 @@ MODULE_DEVICE_TABLE(usb, pn533_table); | |||
99 | Postamble (1) */ | 107 | Postamble (1) */ |
100 | #define PN533_STD_FRAME_CHECKSUM(f) (f->data[f->datalen]) | 108 | #define PN533_STD_FRAME_CHECKSUM(f) (f->data[f->datalen]) |
101 | #define PN533_STD_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1]) | 109 | #define PN533_STD_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1]) |
110 | /* Half start code (3), LEN (4) should be 0xffff for extended frame */ | ||
111 | #define PN533_STD_IS_EXTENDED(hdr) ((hdr)->datalen == 0xFF \ | ||
112 | && (hdr)->datalen_checksum == 0xFF) | ||
113 | #define PN533_EXT_FRAME_CHECKSUM(f) (f->data[be16_to_cpu(f->datalen)]) | ||
102 | 114 | ||
103 | /* start of frame */ | 115 | /* start of frame */ |
104 | #define PN533_STD_FRAME_SOF 0x00FF | 116 | #define PN533_STD_FRAME_SOF 0x00FF |
@@ -124,7 +136,7 @@ MODULE_DEVICE_TABLE(usb, pn533_table); | |||
124 | #define PN533_ACR122_RDR_TO_PC_ESCAPE 0x83 | 136 | #define PN533_ACR122_RDR_TO_PC_ESCAPE 0x83 |
125 | 137 | ||
126 | /* PN533 Commands */ | 138 | /* PN533 Commands */ |
127 | #define PN533_STD_FRAME_CMD(f) (f->data[1]) | 139 | #define PN533_FRAME_CMD(f) (f->data[1]) |
128 | 140 | ||
129 | #define PN533_CMD_GET_FIRMWARE_VERSION 0x02 | 141 | #define PN533_CMD_GET_FIRMWARE_VERSION 0x02 |
130 | #define PN533_CMD_RF_CONFIGURATION 0x32 | 142 | #define PN533_CMD_RF_CONFIGURATION 0x32 |
@@ -168,8 +180,9 @@ struct pn533_fw_version { | |||
168 | #define PN533_CFGITEM_MAX_RETRIES 0x05 | 180 | #define PN533_CFGITEM_MAX_RETRIES 0x05 |
169 | #define PN533_CFGITEM_PASORI 0x82 | 181 | #define PN533_CFGITEM_PASORI 0x82 |
170 | 182 | ||
171 | #define PN533_CFGITEM_RF_FIELD_ON 0x1 | 183 | #define PN533_CFGITEM_RF_FIELD_AUTO_RFCA 0x2 |
172 | #define PN533_CFGITEM_RF_FIELD_OFF 0x0 | 184 | #define PN533_CFGITEM_RF_FIELD_ON 0x1 |
185 | #define PN533_CFGITEM_RF_FIELD_OFF 0x0 | ||
173 | 186 | ||
174 | #define PN533_CONFIG_TIMING_102 0xb | 187 | #define PN533_CONFIG_TIMING_102 0xb |
175 | #define PN533_CONFIG_TIMING_204 0xc | 188 | #define PN533_CONFIG_TIMING_204 0xc |
@@ -257,7 +270,7 @@ static const struct pn533_poll_modulations poll_mod[] = { | |||
257 | .initiator_data.felica = { | 270 | .initiator_data.felica = { |
258 | .opcode = PN533_FELICA_OPC_SENSF_REQ, | 271 | .opcode = PN533_FELICA_OPC_SENSF_REQ, |
259 | .sc = PN533_FELICA_SENSF_SC_ALL, | 272 | .sc = PN533_FELICA_SENSF_SC_ALL, |
260 | .rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE, | 273 | .rc = PN533_FELICA_SENSF_RC_SYSTEM_CODE, |
261 | .tsn = 0x03, | 274 | .tsn = 0x03, |
262 | }, | 275 | }, |
263 | }, | 276 | }, |
@@ -270,7 +283,7 @@ static const struct pn533_poll_modulations poll_mod[] = { | |||
270 | .initiator_data.felica = { | 283 | .initiator_data.felica = { |
271 | .opcode = PN533_FELICA_OPC_SENSF_REQ, | 284 | .opcode = PN533_FELICA_OPC_SENSF_REQ, |
272 | .sc = PN533_FELICA_SENSF_SC_ALL, | 285 | .sc = PN533_FELICA_SENSF_SC_ALL, |
273 | .rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE, | 286 | .rc = PN533_FELICA_SENSF_RC_SYSTEM_CODE, |
274 | .tsn = 0x03, | 287 | .tsn = 0x03, |
275 | }, | 288 | }, |
276 | }, | 289 | }, |
@@ -352,13 +365,16 @@ struct pn533 { | |||
352 | struct urb *in_urb; | 365 | struct urb *in_urb; |
353 | 366 | ||
354 | struct sk_buff_head resp_q; | 367 | struct sk_buff_head resp_q; |
368 | struct sk_buff_head fragment_skb; | ||
355 | 369 | ||
356 | struct workqueue_struct *wq; | 370 | struct workqueue_struct *wq; |
357 | struct work_struct cmd_work; | 371 | struct work_struct cmd_work; |
358 | struct work_struct cmd_complete_work; | 372 | struct work_struct cmd_complete_work; |
359 | struct work_struct poll_work; | 373 | struct delayed_work poll_work; |
360 | struct work_struct mi_work; | 374 | struct work_struct mi_rx_work; |
375 | struct work_struct mi_tx_work; | ||
361 | struct work_struct tg_work; | 376 | struct work_struct tg_work; |
377 | struct work_struct rf_work; | ||
362 | 378 | ||
363 | struct list_head cmd_queue; | 379 | struct list_head cmd_queue; |
364 | struct pn533_cmd *cmd; | 380 | struct pn533_cmd *cmd; |
@@ -366,6 +382,7 @@ struct pn533 { | |||
366 | struct mutex cmd_lock; /* protects cmd queue */ | 382 | struct mutex cmd_lock; /* protects cmd queue */ |
367 | 383 | ||
368 | void *cmd_complete_mi_arg; | 384 | void *cmd_complete_mi_arg; |
385 | void *cmd_complete_dep_arg; | ||
369 | 386 | ||
370 | struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1]; | 387 | struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1]; |
371 | u8 poll_mod_count; | 388 | u8 poll_mod_count; |
@@ -404,6 +421,15 @@ struct pn533_std_frame { | |||
404 | u8 data[]; | 421 | u8 data[]; |
405 | } __packed; | 422 | } __packed; |
406 | 423 | ||
424 | struct pn533_ext_frame { /* Extended Information frame */ | ||
425 | u8 preamble; | ||
426 | __be16 start_frame; | ||
427 | __be16 eif_flag; /* fixed to 0xFFFF */ | ||
428 | __be16 datalen; | ||
429 | u8 datalen_checksum; | ||
430 | u8 data[]; | ||
431 | } __packed; | ||
432 | |||
407 | struct pn533_frame_ops { | 433 | struct pn533_frame_ops { |
408 | void (*tx_frame_init)(void *frame, u8 cmd_code); | 434 | void (*tx_frame_init)(void *frame, u8 cmd_code); |
409 | void (*tx_frame_finish)(void *frame); | 435 | void (*tx_frame_finish)(void *frame); |
@@ -411,7 +437,7 @@ struct pn533_frame_ops { | |||
411 | int tx_header_len; | 437 | int tx_header_len; |
412 | int tx_tail_len; | 438 | int tx_tail_len; |
413 | 439 | ||
414 | bool (*rx_is_frame_valid)(void *frame); | 440 | bool (*rx_is_frame_valid)(void *frame, struct pn533 *dev); |
415 | int (*rx_frame_size)(void *frame); | 441 | int (*rx_frame_size)(void *frame); |
416 | int rx_header_len; | 442 | int rx_header_len; |
417 | int rx_tail_len; | 443 | int rx_tail_len; |
@@ -486,7 +512,7 @@ static void pn533_acr122_tx_update_payload_len(void *_frame, int len) | |||
486 | frame->datalen += len; | 512 | frame->datalen += len; |
487 | } | 513 | } |
488 | 514 | ||
489 | static bool pn533_acr122_is_rx_frame_valid(void *_frame) | 515 | static bool pn533_acr122_is_rx_frame_valid(void *_frame, struct pn533 *dev) |
490 | { | 516 | { |
491 | struct pn533_acr122_rx_frame *frame = _frame; | 517 | struct pn533_acr122_rx_frame *frame = _frame; |
492 | 518 | ||
@@ -511,7 +537,7 @@ static u8 pn533_acr122_get_cmd_code(void *frame) | |||
511 | { | 537 | { |
512 | struct pn533_acr122_rx_frame *f = frame; | 538 | struct pn533_acr122_rx_frame *f = frame; |
513 | 539 | ||
514 | return PN533_STD_FRAME_CMD(f); | 540 | return PN533_FRAME_CMD(f); |
515 | } | 541 | } |
516 | 542 | ||
517 | static struct pn533_frame_ops pn533_acr122_frame_ops = { | 543 | static struct pn533_frame_ops pn533_acr122_frame_ops = { |
@@ -530,6 +556,12 @@ static struct pn533_frame_ops pn533_acr122_frame_ops = { | |||
530 | .get_cmd_code = pn533_acr122_get_cmd_code, | 556 | .get_cmd_code = pn533_acr122_get_cmd_code, |
531 | }; | 557 | }; |
532 | 558 | ||
559 | /* The rule: value(high byte) + value(low byte) + checksum = 0 */ | ||
560 | static inline u8 pn533_ext_checksum(u16 value) | ||
561 | { | ||
562 | return ~(u8)(((value & 0xFF00) >> 8) + (u8)(value & 0xFF)) + 1; | ||
563 | } | ||
564 | |||
533 | /* The rule: value + checksum = 0 */ | 565 | /* The rule: value + checksum = 0 */ |
534 | static inline u8 pn533_std_checksum(u8 value) | 566 | static inline u8 pn533_std_checksum(u8 value) |
535 | { | 567 | { |
@@ -555,7 +587,7 @@ static void pn533_std_tx_frame_init(void *_frame, u8 cmd_code) | |||
555 | frame->preamble = 0; | 587 | frame->preamble = 0; |
556 | frame->start_frame = cpu_to_be16(PN533_STD_FRAME_SOF); | 588 | frame->start_frame = cpu_to_be16(PN533_STD_FRAME_SOF); |
557 | PN533_STD_FRAME_IDENTIFIER(frame) = PN533_STD_FRAME_DIR_OUT; | 589 | PN533_STD_FRAME_IDENTIFIER(frame) = PN533_STD_FRAME_DIR_OUT; |
558 | PN533_STD_FRAME_CMD(frame) = cmd_code; | 590 | PN533_FRAME_CMD(frame) = cmd_code; |
559 | frame->datalen = 2; | 591 | frame->datalen = 2; |
560 | } | 592 | } |
561 | 593 | ||
@@ -578,21 +610,41 @@ static void pn533_std_tx_update_payload_len(void *_frame, int len) | |||
578 | frame->datalen += len; | 610 | frame->datalen += len; |
579 | } | 611 | } |
580 | 612 | ||
581 | static bool pn533_std_rx_frame_is_valid(void *_frame) | 613 | static bool pn533_std_rx_frame_is_valid(void *_frame, struct pn533 *dev) |
582 | { | 614 | { |
583 | u8 checksum; | 615 | u8 checksum; |
584 | struct pn533_std_frame *frame = _frame; | 616 | struct pn533_std_frame *stdf = _frame; |
585 | 617 | ||
586 | if (frame->start_frame != cpu_to_be16(PN533_STD_FRAME_SOF)) | 618 | if (stdf->start_frame != cpu_to_be16(PN533_STD_FRAME_SOF)) |
587 | return false; | 619 | return false; |
588 | 620 | ||
589 | checksum = pn533_std_checksum(frame->datalen); | 621 | if (likely(!PN533_STD_IS_EXTENDED(stdf))) { |
590 | if (checksum != frame->datalen_checksum) | 622 | /* Standard frame code */ |
591 | return false; | 623 | dev->ops->rx_header_len = PN533_STD_FRAME_HEADER_LEN; |
592 | 624 | ||
593 | checksum = pn533_std_data_checksum(frame->data, frame->datalen); | 625 | checksum = pn533_std_checksum(stdf->datalen); |
594 | if (checksum != PN533_STD_FRAME_CHECKSUM(frame)) | 626 | if (checksum != stdf->datalen_checksum) |
595 | return false; | 627 | return false; |
628 | |||
629 | checksum = pn533_std_data_checksum(stdf->data, stdf->datalen); | ||
630 | if (checksum != PN533_STD_FRAME_CHECKSUM(stdf)) | ||
631 | return false; | ||
632 | } else { | ||
633 | /* Extended */ | ||
634 | struct pn533_ext_frame *eif = _frame; | ||
635 | |||
636 | dev->ops->rx_header_len = PN533_EXT_FRAME_HEADER_LEN; | ||
637 | |||
638 | checksum = pn533_ext_checksum(be16_to_cpu(eif->datalen)); | ||
639 | if (checksum != eif->datalen_checksum) | ||
640 | return false; | ||
641 | |||
642 | /* check data checksum */ | ||
643 | checksum = pn533_std_data_checksum(eif->data, | ||
644 | be16_to_cpu(eif->datalen)); | ||
645 | if (checksum != PN533_EXT_FRAME_CHECKSUM(eif)) | ||
646 | return false; | ||
647 | } | ||
596 | 648 | ||
597 | return true; | 649 | return true; |
598 | } | 650 | } |
@@ -612,6 +664,14 @@ static inline int pn533_std_rx_frame_size(void *frame) | |||
612 | { | 664 | { |
613 | struct pn533_std_frame *f = frame; | 665 | struct pn533_std_frame *f = frame; |
614 | 666 | ||
667 | /* check for Extended Information frame */ | ||
668 | if (PN533_STD_IS_EXTENDED(f)) { | ||
669 | struct pn533_ext_frame *eif = frame; | ||
670 | |||
671 | return sizeof(struct pn533_ext_frame) | ||
672 | + be16_to_cpu(eif->datalen) + PN533_STD_FRAME_TAIL_LEN; | ||
673 | } | ||
674 | |||
615 | return sizeof(struct pn533_std_frame) + f->datalen + | 675 | return sizeof(struct pn533_std_frame) + f->datalen + |
616 | PN533_STD_FRAME_TAIL_LEN; | 676 | PN533_STD_FRAME_TAIL_LEN; |
617 | } | 677 | } |
@@ -619,8 +679,12 @@ static inline int pn533_std_rx_frame_size(void *frame) | |||
619 | static u8 pn533_std_get_cmd_code(void *frame) | 679 | static u8 pn533_std_get_cmd_code(void *frame) |
620 | { | 680 | { |
621 | struct pn533_std_frame *f = frame; | 681 | struct pn533_std_frame *f = frame; |
682 | struct pn533_ext_frame *eif = frame; | ||
622 | 683 | ||
623 | return PN533_STD_FRAME_CMD(f); | 684 | if (PN533_STD_IS_EXTENDED(f)) |
685 | return PN533_FRAME_CMD(eif); | ||
686 | else | ||
687 | return PN533_FRAME_CMD(f); | ||
624 | } | 688 | } |
625 | 689 | ||
626 | static struct pn533_frame_ops pn533_std_frame_ops = { | 690 | static struct pn533_frame_ops pn533_std_frame_ops = { |
@@ -675,7 +739,7 @@ static void pn533_recv_response(struct urb *urb) | |||
675 | print_hex_dump_debug("PN533 RX: ", DUMP_PREFIX_NONE, 16, 1, in_frame, | 739 | print_hex_dump_debug("PN533 RX: ", DUMP_PREFIX_NONE, 16, 1, in_frame, |
676 | dev->ops->rx_frame_size(in_frame), false); | 740 | dev->ops->rx_frame_size(in_frame), false); |
677 | 741 | ||
678 | if (!dev->ops->rx_is_frame_valid(in_frame)) { | 742 | if (!dev->ops->rx_is_frame_valid(in_frame, dev)) { |
679 | nfc_dev_err(&dev->interface->dev, "Received an invalid frame"); | 743 | nfc_dev_err(&dev->interface->dev, "Received an invalid frame"); |
680 | cmd->status = -EIO; | 744 | cmd->status = -EIO; |
681 | goto sched_wq; | 745 | goto sched_wq; |
@@ -1657,7 +1721,56 @@ static void pn533_listen_mode_timer(unsigned long data) | |||
1657 | 1721 | ||
1658 | pn533_poll_next_mod(dev); | 1722 | pn533_poll_next_mod(dev); |
1659 | 1723 | ||
1660 | queue_work(dev->wq, &dev->poll_work); | 1724 | queue_delayed_work(dev->wq, &dev->poll_work, |
1725 | msecs_to_jiffies(PN533_POLL_INTERVAL)); | ||
1726 | } | ||
1727 | |||
1728 | static int pn533_rf_complete(struct pn533 *dev, void *arg, | ||
1729 | struct sk_buff *resp) | ||
1730 | { | ||
1731 | int rc = 0; | ||
1732 | |||
1733 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | ||
1734 | |||
1735 | if (IS_ERR(resp)) { | ||
1736 | rc = PTR_ERR(resp); | ||
1737 | |||
1738 | nfc_dev_err(&dev->interface->dev, "%s RF setting error %d", | ||
1739 | __func__, rc); | ||
1740 | |||
1741 | return rc; | ||
1742 | } | ||
1743 | |||
1744 | queue_delayed_work(dev->wq, &dev->poll_work, | ||
1745 | msecs_to_jiffies(PN533_POLL_INTERVAL)); | ||
1746 | |||
1747 | dev_kfree_skb(resp); | ||
1748 | return rc; | ||
1749 | } | ||
1750 | |||
1751 | static void pn533_wq_rf(struct work_struct *work) | ||
1752 | { | ||
1753 | struct pn533 *dev = container_of(work, struct pn533, rf_work); | ||
1754 | struct sk_buff *skb; | ||
1755 | int rc; | ||
1756 | |||
1757 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | ||
1758 | |||
1759 | skb = pn533_alloc_skb(dev, 2); | ||
1760 | if (!skb) | ||
1761 | return; | ||
1762 | |||
1763 | *skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD; | ||
1764 | *skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD_AUTO_RFCA; | ||
1765 | |||
1766 | rc = pn533_send_cmd_async(dev, PN533_CMD_RF_CONFIGURATION, skb, | ||
1767 | pn533_rf_complete, NULL); | ||
1768 | if (rc < 0) { | ||
1769 | dev_kfree_skb(skb); | ||
1770 | nfc_dev_err(&dev->interface->dev, "RF setting error %d", rc); | ||
1771 | } | ||
1772 | |||
1773 | return; | ||
1661 | } | 1774 | } |
1662 | 1775 | ||
1663 | static int pn533_poll_complete(struct pn533 *dev, void *arg, | 1776 | static int pn533_poll_complete(struct pn533 *dev, void *arg, |
@@ -1705,7 +1818,8 @@ static int pn533_poll_complete(struct pn533 *dev, void *arg, | |||
1705 | } | 1818 | } |
1706 | 1819 | ||
1707 | pn533_poll_next_mod(dev); | 1820 | pn533_poll_next_mod(dev); |
1708 | queue_work(dev->wq, &dev->poll_work); | 1821 | /* Not target found, turn radio off */ |
1822 | queue_work(dev->wq, &dev->rf_work); | ||
1709 | 1823 | ||
1710 | done: | 1824 | done: |
1711 | dev_kfree_skb(resp); | 1825 | dev_kfree_skb(resp); |
@@ -1770,7 +1884,7 @@ static int pn533_send_poll_frame(struct pn533 *dev) | |||
1770 | 1884 | ||
1771 | static void pn533_wq_poll(struct work_struct *work) | 1885 | static void pn533_wq_poll(struct work_struct *work) |
1772 | { | 1886 | { |
1773 | struct pn533 *dev = container_of(work, struct pn533, poll_work); | 1887 | struct pn533 *dev = container_of(work, struct pn533, poll_work.work); |
1774 | struct pn533_poll_modulations *cur_mod; | 1888 | struct pn533_poll_modulations *cur_mod; |
1775 | int rc; | 1889 | int rc; |
1776 | 1890 | ||
@@ -1799,6 +1913,7 @@ static int pn533_start_poll(struct nfc_dev *nfc_dev, | |||
1799 | u32 im_protocols, u32 tm_protocols) | 1913 | u32 im_protocols, u32 tm_protocols) |
1800 | { | 1914 | { |
1801 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); | 1915 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); |
1916 | u8 rand_mod; | ||
1802 | 1917 | ||
1803 | nfc_dev_dbg(&dev->interface->dev, | 1918 | nfc_dev_dbg(&dev->interface->dev, |
1804 | "%s: im protocols 0x%x tm protocols 0x%x", | 1919 | "%s: im protocols 0x%x tm protocols 0x%x", |
@@ -1822,11 +1937,15 @@ static int pn533_start_poll(struct nfc_dev *nfc_dev, | |||
1822 | tm_protocols = 0; | 1937 | tm_protocols = 0; |
1823 | } | 1938 | } |
1824 | 1939 | ||
1825 | dev->poll_mod_curr = 0; | ||
1826 | pn533_poll_create_mod_list(dev, im_protocols, tm_protocols); | 1940 | pn533_poll_create_mod_list(dev, im_protocols, tm_protocols); |
1827 | dev->poll_protocols = im_protocols; | 1941 | dev->poll_protocols = im_protocols; |
1828 | dev->listen_protocols = tm_protocols; | 1942 | dev->listen_protocols = tm_protocols; |
1829 | 1943 | ||
1944 | /* Do not always start polling from the same modulation */ | ||
1945 | get_random_bytes(&rand_mod, sizeof(rand_mod)); | ||
1946 | rand_mod %= dev->poll_mod_count; | ||
1947 | dev->poll_mod_curr = rand_mod; | ||
1948 | |||
1830 | return pn533_send_poll_frame(dev); | 1949 | return pn533_send_poll_frame(dev); |
1831 | } | 1950 | } |
1832 | 1951 | ||
@@ -1845,6 +1964,7 @@ static void pn533_stop_poll(struct nfc_dev *nfc_dev) | |||
1845 | } | 1964 | } |
1846 | 1965 | ||
1847 | pn533_abort_cmd(dev, GFP_KERNEL); | 1966 | pn533_abort_cmd(dev, GFP_KERNEL); |
1967 | flush_delayed_work(&dev->poll_work); | ||
1848 | pn533_poll_reset_mod_list(dev); | 1968 | pn533_poll_reset_mod_list(dev); |
1849 | } | 1969 | } |
1850 | 1970 | ||
@@ -2037,28 +2157,15 @@ error: | |||
2037 | return rc; | 2157 | return rc; |
2038 | } | 2158 | } |
2039 | 2159 | ||
2040 | static int pn533_mod_to_baud(struct pn533 *dev) | 2160 | static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf); |
2041 | { | ||
2042 | switch (dev->poll_mod_curr) { | ||
2043 | case PN533_POLL_MOD_106KBPS_A: | ||
2044 | return 0; | ||
2045 | case PN533_POLL_MOD_212KBPS_FELICA: | ||
2046 | return 1; | ||
2047 | case PN533_POLL_MOD_424KBPS_FELICA: | ||
2048 | return 2; | ||
2049 | default: | ||
2050 | return -EINVAL; | ||
2051 | } | ||
2052 | } | ||
2053 | |||
2054 | #define PASSIVE_DATA_LEN 5 | 2161 | #define PASSIVE_DATA_LEN 5 |
2055 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | 2162 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, |
2056 | u8 comm_mode, u8 *gb, size_t gb_len) | 2163 | u8 comm_mode, u8 *gb, size_t gb_len) |
2057 | { | 2164 | { |
2058 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); | 2165 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); |
2059 | struct sk_buff *skb; | 2166 | struct sk_buff *skb; |
2060 | int rc, baud, skb_len; | 2167 | int rc, skb_len; |
2061 | u8 *next, *arg; | 2168 | u8 *next, *arg, nfcid3[NFC_NFCID3_MAXSIZE]; |
2062 | 2169 | ||
2063 | u8 passive_data[PASSIVE_DATA_LEN] = {0x00, 0xff, 0xff, 0x00, 0x3}; | 2170 | u8 passive_data[PASSIVE_DATA_LEN] = {0x00, 0xff, 0xff, 0x00, 0x3}; |
2064 | 2171 | ||
@@ -2076,41 +2183,39 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
2076 | return -EBUSY; | 2183 | return -EBUSY; |
2077 | } | 2184 | } |
2078 | 2185 | ||
2079 | baud = pn533_mod_to_baud(dev); | ||
2080 | if (baud < 0) { | ||
2081 | nfc_dev_err(&dev->interface->dev, | ||
2082 | "Invalid curr modulation %d", dev->poll_mod_curr); | ||
2083 | return baud; | ||
2084 | } | ||
2085 | |||
2086 | skb_len = 3 + gb_len; /* ActPass + BR + Next */ | 2186 | skb_len = 3 + gb_len; /* ActPass + BR + Next */ |
2087 | if (comm_mode == NFC_COMM_PASSIVE) | 2187 | skb_len += PASSIVE_DATA_LEN; |
2088 | skb_len += PASSIVE_DATA_LEN; | ||
2089 | 2188 | ||
2090 | if (target && target->nfcid2_len) | 2189 | /* NFCID3 */ |
2091 | skb_len += NFC_NFCID3_MAXSIZE; | 2190 | skb_len += NFC_NFCID3_MAXSIZE; |
2191 | if (target && !target->nfcid2_len) { | ||
2192 | nfcid3[0] = 0x1; | ||
2193 | nfcid3[1] = 0xfe; | ||
2194 | get_random_bytes(nfcid3 + 2, 6); | ||
2195 | } | ||
2092 | 2196 | ||
2093 | skb = pn533_alloc_skb(dev, skb_len); | 2197 | skb = pn533_alloc_skb(dev, skb_len); |
2094 | if (!skb) | 2198 | if (!skb) |
2095 | return -ENOMEM; | 2199 | return -ENOMEM; |
2096 | 2200 | ||
2097 | *skb_put(skb, 1) = !comm_mode; /* ActPass */ | 2201 | *skb_put(skb, 1) = !comm_mode; /* ActPass */ |
2098 | *skb_put(skb, 1) = baud; /* Baud rate */ | 2202 | *skb_put(skb, 1) = 0x02; /* 424 kbps */ |
2099 | 2203 | ||
2100 | next = skb_put(skb, 1); /* Next */ | 2204 | next = skb_put(skb, 1); /* Next */ |
2101 | *next = 0; | 2205 | *next = 0; |
2102 | 2206 | ||
2103 | if (comm_mode == NFC_COMM_PASSIVE && baud > 0) { | 2207 | /* Copy passive data */ |
2104 | memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, | 2208 | memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, PASSIVE_DATA_LEN); |
2105 | PASSIVE_DATA_LEN); | 2209 | *next |= 1; |
2106 | *next |= 1; | ||
2107 | } | ||
2108 | 2210 | ||
2109 | if (target && target->nfcid2_len) { | 2211 | /* Copy NFCID3 (which is NFCID2 from SENSF_RES) */ |
2212 | if (target && target->nfcid2_len) | ||
2110 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2, | 2213 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2, |
2111 | target->nfcid2_len); | 2214 | target->nfcid2_len); |
2112 | *next |= 2; | 2215 | else |
2113 | } | 2216 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), nfcid3, |
2217 | NFC_NFCID3_MAXSIZE); | ||
2218 | *next |= 2; | ||
2114 | 2219 | ||
2115 | if (gb != NULL && gb_len > 0) { | 2220 | if (gb != NULL && gb_len > 0) { |
2116 | memcpy(skb_put(skb, gb_len), gb, gb_len); | 2221 | memcpy(skb_put(skb, gb_len), gb, gb_len); |
@@ -2127,6 +2232,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
2127 | 2232 | ||
2128 | *arg = !comm_mode; | 2233 | *arg = !comm_mode; |
2129 | 2234 | ||
2235 | pn533_rf_field(dev->nfc_dev, 0); | ||
2236 | |||
2130 | rc = pn533_send_cmd_async(dev, PN533_CMD_IN_JUMP_FOR_DEP, skb, | 2237 | rc = pn533_send_cmd_async(dev, PN533_CMD_IN_JUMP_FOR_DEP, skb, |
2131 | pn533_in_dep_link_up_complete, arg); | 2238 | pn533_in_dep_link_up_complete, arg); |
2132 | 2239 | ||
@@ -2232,7 +2339,15 @@ static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg, | |||
2232 | 2339 | ||
2233 | if (mi) { | 2340 | if (mi) { |
2234 | dev->cmd_complete_mi_arg = arg; | 2341 | dev->cmd_complete_mi_arg = arg; |
2235 | queue_work(dev->wq, &dev->mi_work); | 2342 | queue_work(dev->wq, &dev->mi_rx_work); |
2343 | return -EINPROGRESS; | ||
2344 | } | ||
2345 | |||
2346 | /* Prepare for the next round */ | ||
2347 | if (skb_queue_len(&dev->fragment_skb) > 0) { | ||
2348 | dev->cmd_complete_dep_arg = arg; | ||
2349 | queue_work(dev->wq, &dev->mi_tx_work); | ||
2350 | |||
2236 | return -EINPROGRESS; | 2351 | return -EINPROGRESS; |
2237 | } | 2352 | } |
2238 | 2353 | ||
@@ -2253,6 +2368,50 @@ _error: | |||
2253 | return rc; | 2368 | return rc; |
2254 | } | 2369 | } |
2255 | 2370 | ||
2371 | /* Split the Tx skb into small chunks */ | ||
2372 | static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb) | ||
2373 | { | ||
2374 | struct sk_buff *frag; | ||
2375 | int frag_size; | ||
2376 | |||
2377 | do { | ||
2378 | /* Remaining size */ | ||
2379 | if (skb->len > PN533_CMD_DATAFRAME_MAXLEN) | ||
2380 | frag_size = PN533_CMD_DATAFRAME_MAXLEN; | ||
2381 | else | ||
2382 | frag_size = skb->len; | ||
2383 | |||
2384 | /* Allocate and reserve */ | ||
2385 | frag = pn533_alloc_skb(dev, frag_size); | ||
2386 | if (!frag) { | ||
2387 | skb_queue_purge(&dev->fragment_skb); | ||
2388 | break; | ||
2389 | } | ||
2390 | |||
2391 | /* Reserve the TG/MI byte */ | ||
2392 | skb_reserve(frag, 1); | ||
2393 | |||
2394 | /* MI + TG */ | ||
2395 | if (frag_size == PN533_CMD_DATAFRAME_MAXLEN) | ||
2396 | *skb_push(frag, sizeof(u8)) = (PN533_CMD_MI_MASK | 1); | ||
2397 | else | ||
2398 | *skb_push(frag, sizeof(u8)) = 1; /* TG */ | ||
2399 | |||
2400 | memcpy(skb_put(frag, frag_size), skb->data, frag_size); | ||
2401 | |||
2402 | /* Reduce the size of incoming buffer */ | ||
2403 | skb_pull(skb, frag_size); | ||
2404 | |||
2405 | /* Add this to skb_queue */ | ||
2406 | skb_queue_tail(&dev->fragment_skb, frag); | ||
2407 | |||
2408 | } while (skb->len > 0); | ||
2409 | |||
2410 | dev_kfree_skb(skb); | ||
2411 | |||
2412 | return skb_queue_len(&dev->fragment_skb); | ||
2413 | } | ||
2414 | |||
2256 | static int pn533_transceive(struct nfc_dev *nfc_dev, | 2415 | static int pn533_transceive(struct nfc_dev *nfc_dev, |
2257 | struct nfc_target *target, struct sk_buff *skb, | 2416 | struct nfc_target *target, struct sk_buff *skb, |
2258 | data_exchange_cb_t cb, void *cb_context) | 2417 | data_exchange_cb_t cb, void *cb_context) |
@@ -2263,15 +2422,6 @@ static int pn533_transceive(struct nfc_dev *nfc_dev, | |||
2263 | 2422 | ||
2264 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | 2423 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); |
2265 | 2424 | ||
2266 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { | ||
2267 | /* TODO: Implement support to multi-part data exchange */ | ||
2268 | nfc_dev_err(&dev->interface->dev, | ||
2269 | "Data length greater than the max allowed: %d", | ||
2270 | PN533_CMD_DATAEXCH_DATA_MAXLEN); | ||
2271 | rc = -ENOSYS; | ||
2272 | goto error; | ||
2273 | } | ||
2274 | |||
2275 | if (!dev->tgt_active_prot) { | 2425 | if (!dev->tgt_active_prot) { |
2276 | nfc_dev_err(&dev->interface->dev, | 2426 | nfc_dev_err(&dev->interface->dev, |
2277 | "Can't exchange data if there is no active target"); | 2427 | "Can't exchange data if there is no active target"); |
@@ -2299,7 +2449,20 @@ static int pn533_transceive(struct nfc_dev *nfc_dev, | |||
2299 | break; | 2449 | break; |
2300 | } | 2450 | } |
2301 | default: | 2451 | default: |
2302 | *skb_push(skb, sizeof(u8)) = 1; /*TG*/ | 2452 | /* jumbo frame ? */ |
2453 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { | ||
2454 | rc = pn533_fill_fragment_skbs(dev, skb); | ||
2455 | if (rc <= 0) | ||
2456 | goto error; | ||
2457 | |||
2458 | skb = skb_dequeue(&dev->fragment_skb); | ||
2459 | if (!skb) { | ||
2460 | rc = -EIO; | ||
2461 | goto error; | ||
2462 | } | ||
2463 | } else { | ||
2464 | *skb_push(skb, sizeof(u8)) = 1; /* TG */ | ||
2465 | } | ||
2303 | 2466 | ||
2304 | rc = pn533_send_data_async(dev, PN533_CMD_IN_DATA_EXCHANGE, | 2467 | rc = pn533_send_data_async(dev, PN533_CMD_IN_DATA_EXCHANGE, |
2305 | skb, pn533_data_exchange_complete, | 2468 | skb, pn533_data_exchange_complete, |
@@ -2370,7 +2533,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) | |||
2370 | 2533 | ||
2371 | static void pn533_wq_mi_recv(struct work_struct *work) | 2534 | static void pn533_wq_mi_recv(struct work_struct *work) |
2372 | { | 2535 | { |
2373 | struct pn533 *dev = container_of(work, struct pn533, mi_work); | 2536 | struct pn533 *dev = container_of(work, struct pn533, mi_rx_work); |
2374 | 2537 | ||
2375 | struct sk_buff *skb; | 2538 | struct sk_buff *skb; |
2376 | int rc; | 2539 | int rc; |
@@ -2418,6 +2581,61 @@ error: | |||
2418 | queue_work(dev->wq, &dev->cmd_work); | 2581 | queue_work(dev->wq, &dev->cmd_work); |
2419 | } | 2582 | } |
2420 | 2583 | ||
2584 | static void pn533_wq_mi_send(struct work_struct *work) | ||
2585 | { | ||
2586 | struct pn533 *dev = container_of(work, struct pn533, mi_tx_work); | ||
2587 | struct sk_buff *skb; | ||
2588 | int rc; | ||
2589 | |||
2590 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | ||
2591 | |||
2592 | /* Grab the first skb in the queue */ | ||
2593 | skb = skb_dequeue(&dev->fragment_skb); | ||
2594 | |||
2595 | if (skb == NULL) { /* No more data */ | ||
2596 | /* Reset the queue for future use */ | ||
2597 | skb_queue_head_init(&dev->fragment_skb); | ||
2598 | goto error; | ||
2599 | } | ||
2600 | |||
2601 | switch (dev->device_type) { | ||
2602 | case PN533_DEVICE_PASORI: | ||
2603 | if (dev->tgt_active_prot != NFC_PROTO_FELICA) { | ||
2604 | rc = -EIO; | ||
2605 | break; | ||
2606 | } | ||
2607 | |||
2608 | rc = pn533_send_cmd_direct_async(dev, PN533_CMD_IN_COMM_THRU, | ||
2609 | skb, | ||
2610 | pn533_data_exchange_complete, | ||
2611 | dev->cmd_complete_dep_arg); | ||
2612 | |||
2613 | break; | ||
2614 | |||
2615 | default: | ||
2616 | /* Still some fragments? */ | ||
2617 | rc = pn533_send_cmd_direct_async(dev,PN533_CMD_IN_DATA_EXCHANGE, | ||
2618 | skb, | ||
2619 | pn533_data_exchange_complete, | ||
2620 | dev->cmd_complete_dep_arg); | ||
2621 | |||
2622 | break; | ||
2623 | } | ||
2624 | |||
2625 | if (rc == 0) /* success */ | ||
2626 | return; | ||
2627 | |||
2628 | nfc_dev_err(&dev->interface->dev, | ||
2629 | "Error %d when trying to perform data_exchange", rc); | ||
2630 | |||
2631 | dev_kfree_skb(skb); | ||
2632 | kfree(dev->cmd_complete_dep_arg); | ||
2633 | |||
2634 | error: | ||
2635 | pn533_send_ack(dev, GFP_KERNEL); | ||
2636 | queue_work(dev->wq, &dev->cmd_work); | ||
2637 | } | ||
2638 | |||
2421 | static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata, | 2639 | static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata, |
2422 | u8 cfgdata_len) | 2640 | u8 cfgdata_len) |
2423 | { | 2641 | { |
@@ -2562,6 +2780,8 @@ static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf) | |||
2562 | u8 rf_field = !!rf; | 2780 | u8 rf_field = !!rf; |
2563 | int rc; | 2781 | int rc; |
2564 | 2782 | ||
2783 | rf_field |= PN533_CFGITEM_RF_FIELD_AUTO_RFCA; | ||
2784 | |||
2565 | rc = pn533_set_configuration(dev, PN533_CFGITEM_RF_FIELD, | 2785 | rc = pn533_set_configuration(dev, PN533_CFGITEM_RF_FIELD, |
2566 | (u8 *)&rf_field, 1); | 2786 | (u8 *)&rf_field, 1); |
2567 | if (rc) { | 2787 | if (rc) { |
@@ -2605,17 +2825,6 @@ static int pn533_setup(struct pn533 *dev) | |||
2605 | 2825 | ||
2606 | switch (dev->device_type) { | 2826 | switch (dev->device_type) { |
2607 | case PN533_DEVICE_STD: | 2827 | case PN533_DEVICE_STD: |
2608 | max_retries.mx_rty_atr = PN533_CONFIG_MAX_RETRIES_ENDLESS; | ||
2609 | max_retries.mx_rty_psl = 2; | ||
2610 | max_retries.mx_rty_passive_act = | ||
2611 | PN533_CONFIG_MAX_RETRIES_NO_RETRY; | ||
2612 | |||
2613 | timing.rfu = PN533_CONFIG_TIMING_102; | ||
2614 | timing.atr_res_timeout = PN533_CONFIG_TIMING_204; | ||
2615 | timing.dep_timeout = PN533_CONFIG_TIMING_409; | ||
2616 | |||
2617 | break; | ||
2618 | |||
2619 | case PN533_DEVICE_PASORI: | 2828 | case PN533_DEVICE_PASORI: |
2620 | case PN533_DEVICE_ACR122U: | 2829 | case PN533_DEVICE_ACR122U: |
2621 | max_retries.mx_rty_atr = 0x2; | 2830 | max_retries.mx_rty_atr = 0x2; |
@@ -2729,9 +2938,11 @@ static int pn533_probe(struct usb_interface *interface, | |||
2729 | 2938 | ||
2730 | INIT_WORK(&dev->cmd_work, pn533_wq_cmd); | 2939 | INIT_WORK(&dev->cmd_work, pn533_wq_cmd); |
2731 | INIT_WORK(&dev->cmd_complete_work, pn533_wq_cmd_complete); | 2940 | INIT_WORK(&dev->cmd_complete_work, pn533_wq_cmd_complete); |
2732 | INIT_WORK(&dev->mi_work, pn533_wq_mi_recv); | 2941 | INIT_WORK(&dev->mi_rx_work, pn533_wq_mi_recv); |
2942 | INIT_WORK(&dev->mi_tx_work, pn533_wq_mi_send); | ||
2733 | INIT_WORK(&dev->tg_work, pn533_wq_tg_get_data); | 2943 | INIT_WORK(&dev->tg_work, pn533_wq_tg_get_data); |
2734 | INIT_WORK(&dev->poll_work, pn533_wq_poll); | 2944 | INIT_DELAYED_WORK(&dev->poll_work, pn533_wq_poll); |
2945 | INIT_WORK(&dev->rf_work, pn533_wq_rf); | ||
2735 | dev->wq = alloc_ordered_workqueue("pn533", 0); | 2946 | dev->wq = alloc_ordered_workqueue("pn533", 0); |
2736 | if (dev->wq == NULL) | 2947 | if (dev->wq == NULL) |
2737 | goto error; | 2948 | goto error; |
@@ -2741,6 +2952,7 @@ static int pn533_probe(struct usb_interface *interface, | |||
2741 | dev->listen_timer.function = pn533_listen_mode_timer; | 2952 | dev->listen_timer.function = pn533_listen_mode_timer; |
2742 | 2953 | ||
2743 | skb_queue_head_init(&dev->resp_q); | 2954 | skb_queue_head_init(&dev->resp_q); |
2955 | skb_queue_head_init(&dev->fragment_skb); | ||
2744 | 2956 | ||
2745 | INIT_LIST_HEAD(&dev->cmd_queue); | 2957 | INIT_LIST_HEAD(&dev->cmd_queue); |
2746 | 2958 | ||
@@ -2842,6 +3054,7 @@ static void pn533_disconnect(struct usb_interface *interface) | |||
2842 | usb_kill_urb(dev->in_urb); | 3054 | usb_kill_urb(dev->in_urb); |
2843 | usb_kill_urb(dev->out_urb); | 3055 | usb_kill_urb(dev->out_urb); |
2844 | 3056 | ||
3057 | flush_delayed_work(&dev->poll_work); | ||
2845 | destroy_workqueue(dev->wq); | 3058 | destroy_workqueue(dev->wq); |
2846 | 3059 | ||
2847 | skb_queue_purge(&dev->resp_q); | 3060 | skb_queue_purge(&dev->resp_q); |
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index 8cf64c19f022..01e27d4bdd0d 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c | |||
@@ -25,11 +25,14 @@ | |||
25 | #include <linux/miscdevice.h> | 25 | #include <linux/miscdevice.h> |
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | 28 | #include <linux/nfc.h> | |
29 | #include <linux/firmware.h> | ||
30 | #include <linux/unaligned/access_ok.h> | ||
29 | #include <linux/platform_data/pn544.h> | 31 | #include <linux/platform_data/pn544.h> |
30 | 32 | ||
31 | #include <net/nfc/hci.h> | 33 | #include <net/nfc/hci.h> |
32 | #include <net/nfc/llc.h> | 34 | #include <net/nfc/llc.h> |
35 | #include <net/nfc/nfc.h> | ||
33 | 36 | ||
34 | #include "pn544.h" | 37 | #include "pn544.h" |
35 | 38 | ||
@@ -55,6 +58,58 @@ MODULE_DEVICE_TABLE(i2c, pn544_hci_i2c_id_table); | |||
55 | 58 | ||
56 | #define PN544_HCI_I2C_DRIVER_NAME "pn544_hci_i2c" | 59 | #define PN544_HCI_I2C_DRIVER_NAME "pn544_hci_i2c" |
57 | 60 | ||
61 | #define PN544_FW_CMD_WRITE 0x08 | ||
62 | #define PN544_FW_CMD_CHECK 0x06 | ||
63 | |||
64 | struct pn544_i2c_fw_frame_write { | ||
65 | u8 cmd; | ||
66 | u16 be_length; | ||
67 | u8 be_dest_addr[3]; | ||
68 | u16 be_datalen; | ||
69 | u8 data[]; | ||
70 | } __packed; | ||
71 | |||
72 | struct pn544_i2c_fw_frame_check { | ||
73 | u8 cmd; | ||
74 | u16 be_length; | ||
75 | u8 be_start_addr[3]; | ||
76 | u16 be_datalen; | ||
77 | u16 be_crc; | ||
78 | } __packed; | ||
79 | |||
80 | struct pn544_i2c_fw_frame_response { | ||
81 | u8 status; | ||
82 | u16 be_length; | ||
83 | } __packed; | ||
84 | |||
85 | struct pn544_i2c_fw_blob { | ||
86 | u32 be_size; | ||
87 | u32 be_destaddr; | ||
88 | u8 data[]; | ||
89 | }; | ||
90 | |||
91 | #define PN544_FW_CMD_RESULT_TIMEOUT 0x01 | ||
92 | #define PN544_FW_CMD_RESULT_BAD_CRC 0x02 | ||
93 | #define PN544_FW_CMD_RESULT_ACCESS_DENIED 0x08 | ||
94 | #define PN544_FW_CMD_RESULT_PROTOCOL_ERROR 0x0B | ||
95 | #define PN544_FW_CMD_RESULT_INVALID_PARAMETER 0x11 | ||
96 | #define PN544_FW_CMD_RESULT_INVALID_LENGTH 0x18 | ||
97 | #define PN544_FW_CMD_RESULT_WRITE_FAILED 0x74 | ||
98 | |||
99 | #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) | ||
100 | |||
101 | #define PN544_FW_WRITE_BUFFER_MAX_LEN 0x9f7 | ||
102 | #define PN544_FW_I2C_MAX_PAYLOAD PN544_HCI_I2C_LLC_MAX_SIZE | ||
103 | #define PN544_FW_I2C_WRITE_FRAME_HEADER_LEN 8 | ||
104 | #define PN544_FW_I2C_WRITE_DATA_MAX_LEN MIN((PN544_FW_I2C_MAX_PAYLOAD -\ | ||
105 | PN544_FW_I2C_WRITE_FRAME_HEADER_LEN),\ | ||
106 | PN544_FW_WRITE_BUFFER_MAX_LEN) | ||
107 | |||
108 | #define FW_WORK_STATE_IDLE 1 | ||
109 | #define FW_WORK_STATE_START 2 | ||
110 | #define FW_WORK_STATE_WAIT_WRITE_ANSWER 3 | ||
111 | #define FW_WORK_STATE_WAIT_CHECK_ANSWER 4 | ||
112 | |||
58 | struct pn544_i2c_phy { | 113 | struct pn544_i2c_phy { |
59 | struct i2c_client *i2c_dev; | 114 | struct i2c_client *i2c_dev; |
60 | struct nfc_hci_dev *hdev; | 115 | struct nfc_hci_dev *hdev; |
@@ -64,7 +119,18 @@ struct pn544_i2c_phy { | |||
64 | unsigned int gpio_fw; | 119 | unsigned int gpio_fw; |
65 | unsigned int en_polarity; | 120 | unsigned int en_polarity; |
66 | 121 | ||
122 | struct work_struct fw_work; | ||
123 | int fw_work_state; | ||
124 | char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1]; | ||
125 | const struct firmware *fw; | ||
126 | u32 fw_blob_dest_addr; | ||
127 | size_t fw_blob_size; | ||
128 | const u8 *fw_blob_data; | ||
129 | size_t fw_written; | ||
130 | int fw_cmd_result; | ||
131 | |||
67 | int powered; | 132 | int powered; |
133 | int run_mode; | ||
68 | 134 | ||
69 | int hard_fault; /* | 135 | int hard_fault; /* |
70 | * < 0 if hardware error occured (e.g. i2c err) | 136 | * < 0 if hardware error occured (e.g. i2c err) |
@@ -122,15 +188,22 @@ out: | |||
122 | gpio_set_value(phy->gpio_en, !phy->en_polarity); | 188 | gpio_set_value(phy->gpio_en, !phy->en_polarity); |
123 | } | 189 | } |
124 | 190 | ||
191 | static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode) | ||
192 | { | ||
193 | gpio_set_value(phy->gpio_fw, run_mode == PN544_FW_MODE ? 1 : 0); | ||
194 | gpio_set_value(phy->gpio_en, phy->en_polarity); | ||
195 | usleep_range(10000, 15000); | ||
196 | |||
197 | phy->run_mode = run_mode; | ||
198 | } | ||
199 | |||
125 | static int pn544_hci_i2c_enable(void *phy_id) | 200 | static int pn544_hci_i2c_enable(void *phy_id) |
126 | { | 201 | { |
127 | struct pn544_i2c_phy *phy = phy_id; | 202 | struct pn544_i2c_phy *phy = phy_id; |
128 | 203 | ||
129 | pr_info(DRIVER_DESC ": %s\n", __func__); | 204 | pr_info(DRIVER_DESC ": %s\n", __func__); |
130 | 205 | ||
131 | gpio_set_value(phy->gpio_fw, 0); | 206 | pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE); |
132 | gpio_set_value(phy->gpio_en, phy->en_polarity); | ||
133 | usleep_range(10000, 15000); | ||
134 | 207 | ||
135 | phy->powered = 1; | 208 | phy->powered = 1; |
136 | 209 | ||
@@ -305,6 +378,42 @@ flush: | |||
305 | return r; | 378 | return r; |
306 | } | 379 | } |
307 | 380 | ||
381 | static int pn544_hci_i2c_fw_read_status(struct pn544_i2c_phy *phy) | ||
382 | { | ||
383 | int r; | ||
384 | struct pn544_i2c_fw_frame_response response; | ||
385 | struct i2c_client *client = phy->i2c_dev; | ||
386 | |||
387 | r = i2c_master_recv(client, (char *) &response, sizeof(response)); | ||
388 | if (r != sizeof(response)) { | ||
389 | dev_err(&client->dev, "cannot read fw status\n"); | ||
390 | return -EIO; | ||
391 | } | ||
392 | |||
393 | usleep_range(3000, 6000); | ||
394 | |||
395 | switch (response.status) { | ||
396 | case 0: | ||
397 | return 0; | ||
398 | case PN544_FW_CMD_RESULT_TIMEOUT: | ||
399 | return -ETIMEDOUT; | ||
400 | case PN544_FW_CMD_RESULT_BAD_CRC: | ||
401 | return -ENODATA; | ||
402 | case PN544_FW_CMD_RESULT_ACCESS_DENIED: | ||
403 | return -EACCES; | ||
404 | case PN544_FW_CMD_RESULT_PROTOCOL_ERROR: | ||
405 | return -EPROTO; | ||
406 | case PN544_FW_CMD_RESULT_INVALID_PARAMETER: | ||
407 | return -EINVAL; | ||
408 | case PN544_FW_CMD_RESULT_INVALID_LENGTH: | ||
409 | return -EBADMSG; | ||
410 | case PN544_FW_CMD_RESULT_WRITE_FAILED: | ||
411 | return -EIO; | ||
412 | default: | ||
413 | return -EIO; | ||
414 | } | ||
415 | } | ||
416 | |||
308 | /* | 417 | /* |
309 | * Reads an shdlc frame from the chip. This is not as straightforward as it | 418 | * Reads an shdlc frame from the chip. This is not as straightforward as it |
310 | * seems. There are cases where we could loose the frame start synchronization. | 419 | * seems. There are cases where we could loose the frame start synchronization. |
@@ -339,19 +448,23 @@ static irqreturn_t pn544_hci_i2c_irq_thread_fn(int irq, void *phy_id) | |||
339 | if (phy->hard_fault != 0) | 448 | if (phy->hard_fault != 0) |
340 | return IRQ_HANDLED; | 449 | return IRQ_HANDLED; |
341 | 450 | ||
342 | r = pn544_hci_i2c_read(phy, &skb); | 451 | if (phy->run_mode == PN544_FW_MODE) { |
343 | if (r == -EREMOTEIO) { | 452 | phy->fw_cmd_result = pn544_hci_i2c_fw_read_status(phy); |
344 | phy->hard_fault = r; | 453 | schedule_work(&phy->fw_work); |
454 | } else { | ||
455 | r = pn544_hci_i2c_read(phy, &skb); | ||
456 | if (r == -EREMOTEIO) { | ||
457 | phy->hard_fault = r; | ||
345 | 458 | ||
346 | nfc_hci_recv_frame(phy->hdev, NULL); | 459 | nfc_hci_recv_frame(phy->hdev, NULL); |
347 | 460 | ||
348 | return IRQ_HANDLED; | 461 | return IRQ_HANDLED; |
349 | } else if ((r == -ENOMEM) || (r == -EBADMSG)) { | 462 | } else if ((r == -ENOMEM) || (r == -EBADMSG)) { |
350 | return IRQ_HANDLED; | 463 | return IRQ_HANDLED; |
351 | } | 464 | } |
352 | |||
353 | nfc_hci_recv_frame(phy->hdev, skb); | ||
354 | 465 | ||
466 | nfc_hci_recv_frame(phy->hdev, skb); | ||
467 | } | ||
355 | return IRQ_HANDLED; | 468 | return IRQ_HANDLED; |
356 | } | 469 | } |
357 | 470 | ||
@@ -361,6 +474,215 @@ static struct nfc_phy_ops i2c_phy_ops = { | |||
361 | .disable = pn544_hci_i2c_disable, | 474 | .disable = pn544_hci_i2c_disable, |
362 | }; | 475 | }; |
363 | 476 | ||
477 | static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name) | ||
478 | { | ||
479 | struct pn544_i2c_phy *phy = phy_id; | ||
480 | |||
481 | pr_info(DRIVER_DESC ": Starting Firmware Download (%s)\n", | ||
482 | firmware_name); | ||
483 | |||
484 | strcpy(phy->firmware_name, firmware_name); | ||
485 | |||
486 | phy->fw_work_state = FW_WORK_STATE_START; | ||
487 | |||
488 | schedule_work(&phy->fw_work); | ||
489 | |||
490 | return 0; | ||
491 | } | ||
492 | |||
493 | static void pn544_hci_i2c_fw_work_complete(struct pn544_i2c_phy *phy, | ||
494 | int result) | ||
495 | { | ||
496 | pr_info(DRIVER_DESC ": Firmware Download Complete, result=%d\n", result); | ||
497 | |||
498 | pn544_hci_i2c_disable(phy); | ||
499 | |||
500 | phy->fw_work_state = FW_WORK_STATE_IDLE; | ||
501 | |||
502 | if (phy->fw) { | ||
503 | release_firmware(phy->fw); | ||
504 | phy->fw = NULL; | ||
505 | } | ||
506 | |||
507 | nfc_fw_download_done(phy->hdev->ndev, phy->firmware_name, (u32) -result); | ||
508 | } | ||
509 | |||
510 | static int pn544_hci_i2c_fw_write_cmd(struct i2c_client *client, u32 dest_addr, | ||
511 | const u8 *data, u16 datalen) | ||
512 | { | ||
513 | u8 frame[PN544_FW_I2C_MAX_PAYLOAD]; | ||
514 | struct pn544_i2c_fw_frame_write *framep; | ||
515 | u16 params_len; | ||
516 | int framelen; | ||
517 | int r; | ||
518 | |||
519 | if (datalen > PN544_FW_I2C_WRITE_DATA_MAX_LEN) | ||
520 | datalen = PN544_FW_I2C_WRITE_DATA_MAX_LEN; | ||
521 | |||
522 | framep = (struct pn544_i2c_fw_frame_write *) frame; | ||
523 | |||
524 | params_len = sizeof(framep->be_dest_addr) + | ||
525 | sizeof(framep->be_datalen) + datalen; | ||
526 | framelen = params_len + sizeof(framep->cmd) + | ||
527 | sizeof(framep->be_length); | ||
528 | |||
529 | framep->cmd = PN544_FW_CMD_WRITE; | ||
530 | |||
531 | put_unaligned_be16(params_len, &framep->be_length); | ||
532 | |||
533 | framep->be_dest_addr[0] = (dest_addr & 0xff0000) >> 16; | ||
534 | framep->be_dest_addr[1] = (dest_addr & 0xff00) >> 8; | ||
535 | framep->be_dest_addr[2] = dest_addr & 0xff; | ||
536 | |||
537 | put_unaligned_be16(datalen, &framep->be_datalen); | ||
538 | |||
539 | memcpy(framep->data, data, datalen); | ||
540 | |||
541 | r = i2c_master_send(client, frame, framelen); | ||
542 | |||
543 | if (r == framelen) | ||
544 | return datalen; | ||
545 | else if (r < 0) | ||
546 | return r; | ||
547 | else | ||
548 | return -EIO; | ||
549 | } | ||
550 | |||
551 | static int pn544_hci_i2c_fw_check_cmd(struct i2c_client *client, u32 start_addr, | ||
552 | const u8 *data, u16 datalen) | ||
553 | { | ||
554 | struct pn544_i2c_fw_frame_check frame; | ||
555 | int r; | ||
556 | u16 crc; | ||
557 | |||
558 | /* calculate local crc for the data we want to check */ | ||
559 | crc = crc_ccitt(0xffff, data, datalen); | ||
560 | |||
561 | frame.cmd = PN544_FW_CMD_CHECK; | ||
562 | |||
563 | put_unaligned_be16(sizeof(frame.be_start_addr) + | ||
564 | sizeof(frame.be_datalen) + sizeof(frame.be_crc), | ||
565 | &frame.be_length); | ||
566 | |||
567 | /* tell the chip the memory region to which our crc applies */ | ||
568 | frame.be_start_addr[0] = (start_addr & 0xff0000) >> 16; | ||
569 | frame.be_start_addr[1] = (start_addr & 0xff00) >> 8; | ||
570 | frame.be_start_addr[2] = start_addr & 0xff; | ||
571 | |||
572 | put_unaligned_be16(datalen, &frame.be_datalen); | ||
573 | |||
574 | /* | ||
575 | * and give our local crc. Chip will calculate its own crc for the | ||
576 | * region and compare with ours. | ||
577 | */ | ||
578 | put_unaligned_be16(crc, &frame.be_crc); | ||
579 | |||
580 | r = i2c_master_send(client, (const char *) &frame, sizeof(frame)); | ||
581 | |||
582 | if (r == sizeof(frame)) | ||
583 | return 0; | ||
584 | else if (r < 0) | ||
585 | return r; | ||
586 | else | ||
587 | return -EIO; | ||
588 | } | ||
589 | |||
590 | static int pn544_hci_i2c_fw_write_chunk(struct pn544_i2c_phy *phy) | ||
591 | { | ||
592 | int r; | ||
593 | |||
594 | r = pn544_hci_i2c_fw_write_cmd(phy->i2c_dev, | ||
595 | phy->fw_blob_dest_addr + phy->fw_written, | ||
596 | phy->fw_blob_data + phy->fw_written, | ||
597 | phy->fw_blob_size - phy->fw_written); | ||
598 | if (r < 0) | ||
599 | return r; | ||
600 | |||
601 | phy->fw_written += r; | ||
602 | phy->fw_work_state = FW_WORK_STATE_WAIT_WRITE_ANSWER; | ||
603 | |||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | static void pn544_hci_i2c_fw_work(struct work_struct *work) | ||
608 | { | ||
609 | struct pn544_i2c_phy *phy = container_of(work, struct pn544_i2c_phy, | ||
610 | fw_work); | ||
611 | int r; | ||
612 | struct pn544_i2c_fw_blob *blob; | ||
613 | |||
614 | switch (phy->fw_work_state) { | ||
615 | case FW_WORK_STATE_START: | ||
616 | pn544_hci_i2c_enable_mode(phy, PN544_FW_MODE); | ||
617 | |||
618 | r = request_firmware(&phy->fw, phy->firmware_name, | ||
619 | &phy->i2c_dev->dev); | ||
620 | if (r < 0) | ||
621 | goto exit_state_start; | ||
622 | |||
623 | blob = (struct pn544_i2c_fw_blob *) phy->fw->data; | ||
624 | phy->fw_blob_size = get_unaligned_be32(&blob->be_size); | ||
625 | phy->fw_blob_dest_addr = get_unaligned_be32(&blob->be_destaddr); | ||
626 | phy->fw_blob_data = blob->data; | ||
627 | |||
628 | phy->fw_written = 0; | ||
629 | r = pn544_hci_i2c_fw_write_chunk(phy); | ||
630 | |||
631 | exit_state_start: | ||
632 | if (r < 0) | ||
633 | pn544_hci_i2c_fw_work_complete(phy, r); | ||
634 | break; | ||
635 | |||
636 | case FW_WORK_STATE_WAIT_WRITE_ANSWER: | ||
637 | r = phy->fw_cmd_result; | ||
638 | if (r < 0) | ||
639 | goto exit_state_wait_write_answer; | ||
640 | |||
641 | if (phy->fw_written == phy->fw_blob_size) { | ||
642 | r = pn544_hci_i2c_fw_check_cmd(phy->i2c_dev, | ||
643 | phy->fw_blob_dest_addr, | ||
644 | phy->fw_blob_data, | ||
645 | phy->fw_blob_size); | ||
646 | if (r < 0) | ||
647 | goto exit_state_wait_write_answer; | ||
648 | phy->fw_work_state = FW_WORK_STATE_WAIT_CHECK_ANSWER; | ||
649 | break; | ||
650 | } | ||
651 | |||
652 | r = pn544_hci_i2c_fw_write_chunk(phy); | ||
653 | |||
654 | exit_state_wait_write_answer: | ||
655 | if (r < 0) | ||
656 | pn544_hci_i2c_fw_work_complete(phy, r); | ||
657 | break; | ||
658 | |||
659 | case FW_WORK_STATE_WAIT_CHECK_ANSWER: | ||
660 | r = phy->fw_cmd_result; | ||
661 | if (r < 0) | ||
662 | goto exit_state_wait_check_answer; | ||
663 | |||
664 | blob = (struct pn544_i2c_fw_blob *) (phy->fw_blob_data + | ||
665 | phy->fw_blob_size); | ||
666 | phy->fw_blob_size = get_unaligned_be32(&blob->be_size); | ||
667 | if (phy->fw_blob_size != 0) { | ||
668 | phy->fw_blob_dest_addr = | ||
669 | get_unaligned_be32(&blob->be_destaddr); | ||
670 | phy->fw_blob_data = blob->data; | ||
671 | |||
672 | phy->fw_written = 0; | ||
673 | r = pn544_hci_i2c_fw_write_chunk(phy); | ||
674 | } | ||
675 | |||
676 | exit_state_wait_check_answer: | ||
677 | if (r < 0 || phy->fw_blob_size == 0) | ||
678 | pn544_hci_i2c_fw_work_complete(phy, r); | ||
679 | break; | ||
680 | |||
681 | default: | ||
682 | break; | ||
683 | } | ||
684 | } | ||
685 | |||
364 | static int pn544_hci_i2c_probe(struct i2c_client *client, | 686 | static int pn544_hci_i2c_probe(struct i2c_client *client, |
365 | const struct i2c_device_id *id) | 687 | const struct i2c_device_id *id) |
366 | { | 688 | { |
@@ -384,6 +706,9 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, | |||
384 | return -ENOMEM; | 706 | return -ENOMEM; |
385 | } | 707 | } |
386 | 708 | ||
709 | INIT_WORK(&phy->fw_work, pn544_hci_i2c_fw_work); | ||
710 | phy->fw_work_state = FW_WORK_STATE_IDLE; | ||
711 | |||
387 | phy->i2c_dev = client; | 712 | phy->i2c_dev = client; |
388 | i2c_set_clientdata(client, phy); | 713 | i2c_set_clientdata(client, phy); |
389 | 714 | ||
@@ -420,7 +745,8 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, | |||
420 | 745 | ||
421 | r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME, | 746 | r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME, |
422 | PN544_I2C_FRAME_HEADROOM, PN544_I2C_FRAME_TAILROOM, | 747 | PN544_I2C_FRAME_HEADROOM, PN544_I2C_FRAME_TAILROOM, |
423 | PN544_HCI_I2C_LLC_MAX_PAYLOAD, &phy->hdev); | 748 | PN544_HCI_I2C_LLC_MAX_PAYLOAD, |
749 | pn544_hci_i2c_fw_download, &phy->hdev); | ||
424 | if (r < 0) | 750 | if (r < 0) |
425 | goto err_hci; | 751 | goto err_hci; |
426 | 752 | ||
@@ -443,6 +769,10 @@ static int pn544_hci_i2c_remove(struct i2c_client *client) | |||
443 | 769 | ||
444 | dev_dbg(&client->dev, "%s\n", __func__); | 770 | dev_dbg(&client->dev, "%s\n", __func__); |
445 | 771 | ||
772 | cancel_work_sync(&phy->fw_work); | ||
773 | if (phy->fw_work_state != FW_WORK_STATE_IDLE) | ||
774 | pn544_hci_i2c_fw_work_complete(phy, -ENODEV); | ||
775 | |||
446 | pn544_hci_remove(phy->hdev); | 776 | pn544_hci_remove(phy->hdev); |
447 | 777 | ||
448 | if (phy->powered) | 778 | if (phy->powered) |
diff --git a/drivers/nfc/pn544/mei.c b/drivers/nfc/pn544/mei.c index b5d3d18179eb..ee67de50c36f 100644 --- a/drivers/nfc/pn544/mei.c +++ b/drivers/nfc/pn544/mei.c | |||
@@ -45,7 +45,7 @@ static int pn544_mei_probe(struct mei_cl_device *device, | |||
45 | 45 | ||
46 | r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME, | 46 | r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME, |
47 | MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, | 47 | MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, |
48 | &phy->hdev); | 48 | NULL, &phy->hdev); |
49 | if (r < 0) { | 49 | if (r < 0) { |
50 | nfc_mei_phy_free(phy); | 50 | nfc_mei_phy_free(phy); |
51 | 51 | ||
diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c index 0d17da7675b7..078e62feba17 100644 --- a/drivers/nfc/pn544/pn544.c +++ b/drivers/nfc/pn544/pn544.c | |||
@@ -31,9 +31,6 @@ | |||
31 | /* Timing restrictions (ms) */ | 31 | /* Timing restrictions (ms) */ |
32 | #define PN544_HCI_RESETVEN_TIME 30 | 32 | #define PN544_HCI_RESETVEN_TIME 30 |
33 | 33 | ||
34 | #define HCI_MODE 0 | ||
35 | #define FW_MODE 1 | ||
36 | |||
37 | enum pn544_state { | 34 | enum pn544_state { |
38 | PN544_ST_COLD, | 35 | PN544_ST_COLD, |
39 | PN544_ST_FW_READY, | 36 | PN544_ST_FW_READY, |
@@ -130,6 +127,8 @@ struct pn544_hci_info { | |||
130 | int async_cb_type; | 127 | int async_cb_type; |
131 | data_exchange_cb_t async_cb; | 128 | data_exchange_cb_t async_cb; |
132 | void *async_cb_context; | 129 | void *async_cb_context; |
130 | |||
131 | fw_download_t fw_download; | ||
133 | }; | 132 | }; |
134 | 133 | ||
135 | static int pn544_hci_open(struct nfc_hci_dev *hdev) | 134 | static int pn544_hci_open(struct nfc_hci_dev *hdev) |
@@ -782,6 +781,17 @@ exit: | |||
782 | return r; | 781 | return r; |
783 | } | 782 | } |
784 | 783 | ||
784 | static int pn544_hci_fw_download(struct nfc_hci_dev *hdev, | ||
785 | const char *firmware_name) | ||
786 | { | ||
787 | struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev); | ||
788 | |||
789 | if (info->fw_download == NULL) | ||
790 | return -ENOTSUPP; | ||
791 | |||
792 | return info->fw_download(info->phy_id, firmware_name); | ||
793 | } | ||
794 | |||
785 | static struct nfc_hci_ops pn544_hci_ops = { | 795 | static struct nfc_hci_ops pn544_hci_ops = { |
786 | .open = pn544_hci_open, | 796 | .open = pn544_hci_open, |
787 | .close = pn544_hci_close, | 797 | .close = pn544_hci_close, |
@@ -796,11 +806,12 @@ static struct nfc_hci_ops pn544_hci_ops = { | |||
796 | .tm_send = pn544_hci_tm_send, | 806 | .tm_send = pn544_hci_tm_send, |
797 | .check_presence = pn544_hci_check_presence, | 807 | .check_presence = pn544_hci_check_presence, |
798 | .event_received = pn544_hci_event_received, | 808 | .event_received = pn544_hci_event_received, |
809 | .fw_download = pn544_hci_fw_download, | ||
799 | }; | 810 | }; |
800 | 811 | ||
801 | int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, | 812 | int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, |
802 | int phy_headroom, int phy_tailroom, int phy_payload, | 813 | int phy_headroom, int phy_tailroom, int phy_payload, |
803 | struct nfc_hci_dev **hdev) | 814 | fw_download_t fw_download, struct nfc_hci_dev **hdev) |
804 | { | 815 | { |
805 | struct pn544_hci_info *info; | 816 | struct pn544_hci_info *info; |
806 | u32 protocols; | 817 | u32 protocols; |
@@ -816,6 +827,7 @@ int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, | |||
816 | 827 | ||
817 | info->phy_ops = phy_ops; | 828 | info->phy_ops = phy_ops; |
818 | info->phy_id = phy_id; | 829 | info->phy_id = phy_id; |
830 | info->fw_download = fw_download; | ||
819 | info->state = PN544_ST_COLD; | 831 | info->state = PN544_ST_COLD; |
820 | mutex_init(&info->info_lock); | 832 | mutex_init(&info->info_lock); |
821 | 833 | ||
diff --git a/drivers/nfc/pn544/pn544.h b/drivers/nfc/pn544/pn544.h index f47c6454914b..01020e585443 100644 --- a/drivers/nfc/pn544/pn544.h +++ b/drivers/nfc/pn544/pn544.h | |||
@@ -24,9 +24,14 @@ | |||
24 | 24 | ||
25 | #define DRIVER_DESC "HCI NFC driver for PN544" | 25 | #define DRIVER_DESC "HCI NFC driver for PN544" |
26 | 26 | ||
27 | #define PN544_HCI_MODE 0 | ||
28 | #define PN544_FW_MODE 1 | ||
29 | |||
30 | typedef int (*fw_download_t)(void *context, const char *firmware_name); | ||
31 | |||
27 | int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, | 32 | int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, |
28 | int phy_headroom, int phy_tailroom, int phy_payload, | 33 | int phy_headroom, int phy_tailroom, int phy_payload, |
29 | struct nfc_hci_dev **hdev); | 34 | fw_download_t fw_download, struct nfc_hci_dev **hdev); |
30 | void pn544_hci_remove(struct nfc_hci_dev *hdev); | 35 | void pn544_hci_remove(struct nfc_hci_dev *hdev); |
31 | 36 | ||
32 | #endif /* __LOCAL_PN544_H_ */ | 37 | #endif /* __LOCAL_PN544_H_ */ |
diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig index 36171fd2826b..2cd9b0e44a41 100644 --- a/drivers/ssb/Kconfig +++ b/drivers/ssb/Kconfig | |||
@@ -138,7 +138,7 @@ config SSB_DRIVER_MIPS | |||
138 | 138 | ||
139 | config SSB_SFLASH | 139 | config SSB_SFLASH |
140 | bool "SSB serial flash support" | 140 | bool "SSB serial flash support" |
141 | depends on SSB_DRIVER_MIPS && BROKEN | 141 | depends on SSB_DRIVER_MIPS |
142 | default y | 142 | default y |
143 | 143 | ||
144 | # Assumption: We are on embedded, if we compile the MIPS core. | 144 | # Assumption: We are on embedded, if we compile the MIPS core. |
diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c index e84cf04f4416..50328de712fa 100644 --- a/drivers/ssb/driver_chipcommon_sflash.c +++ b/drivers/ssb/driver_chipcommon_sflash.c | |||
@@ -151,8 +151,8 @@ int ssb_sflash_init(struct ssb_chipcommon *cc) | |||
151 | sflash->size = sflash->blocksize * sflash->numblocks; | 151 | sflash->size = sflash->blocksize * sflash->numblocks; |
152 | sflash->present = true; | 152 | sflash->present = true; |
153 | 153 | ||
154 | pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n", | 154 | pr_info("Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n", |
155 | e->name, e->blocksize, e->numblocks); | 155 | e->name, sflash->size / 1024, e->blocksize, e->numblocks); |
156 | 156 | ||
157 | /* Prepare platform device, but don't register it yet. It's too early, | 157 | /* Prepare platform device, but don't register it yet. It's too early, |
158 | * malloc (required by device_private_init) is not available yet. */ | 158 | * malloc (required by device_private_init) is not available yet. */ |
@@ -160,7 +160,5 @@ int ssb_sflash_init(struct ssb_chipcommon *cc) | |||
160 | sflash->size; | 160 | sflash->size; |
161 | ssb_sflash_dev.dev.platform_data = sflash; | 161 | ssb_sflash_dev.dev.platform_data = sflash; |
162 | 162 | ||
163 | pr_err("Serial flash support is not implemented yet!\n"); | 163 | return 0; |
164 | |||
165 | return -ENOTSUPP; | ||
166 | } | 164 | } |
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index 8fc9f588b056..7f015499cfae 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h | |||
@@ -14,7 +14,7 @@ | |||
14 | * Copyright (c) 2004, Intel Corporation | 14 | * Copyright (c) 2004, Intel Corporation |
15 | * | 15 | * |
16 | * Modified for Realtek's wi-fi cards by Andrea Merello | 16 | * Modified for Realtek's wi-fi cards by Andrea Merello |
17 | * <andreamrl@tiscali.it> | 17 | * <andrea.merello@gmail.com> |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
20 | * it under the terms of the GNU General Public License version 2 as | 20 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c index d5df0d691fcc..10b22100dd3a 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c | |||
@@ -14,7 +14,7 @@ | |||
14 | ****************************************************************************** | 14 | ****************************************************************************** |
15 | 15 | ||
16 | Few modifications for Realtek's Wi-Fi drivers by | 16 | Few modifications for Realtek's Wi-Fi drivers by |
17 | Andrea Merello <andreamrl@tiscali.it> | 17 | Andrea Merello <andrea.merello@gmail.com> |
18 | 18 | ||
19 | A special thanks goes to Realtek for their support ! | 19 | A special thanks goes to Realtek for their support ! |
20 | 20 | ||
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index 00f9af06aca5..b65db542e1ab 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c index d9add5305e29..e5282068e3de 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c index 89ed86ef0d15..b3466530cf94 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c | |||
@@ -25,7 +25,7 @@ | |||
25 | ****************************************************************************** | 25 | ****************************************************************************** |
26 | 26 | ||
27 | Few modifications for Realtek's Wi-Fi drivers by | 27 | Few modifications for Realtek's Wi-Fi drivers by |
28 | Andrea Merello <andreamrl@tiscali.it> | 28 | Andrea Merello <andrea.merello@gmail.com> |
29 | 29 | ||
30 | A special thanks goes to Realtek for their support ! | 30 | A special thanks goes to Realtek for their support ! |
31 | 31 | ||
diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index edacc8001640..d052f4a9a839 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8180 OpenSource driver. | 2 | This is part of rtl8180 OpenSource driver. |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the | 6 | Parts of this driver are based on the GPL part of the |
diff --git a/drivers/staging/rtl8187se/r8180_93cx6.h b/drivers/staging/rtl8187se/r8180_93cx6.h index 79e7391ac881..b52b5b0610ab 100644 --- a/drivers/staging/rtl8187se/r8180_93cx6.h +++ b/drivers/staging/rtl8187se/r8180_93cx6.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8180 OpenSource driver | 2 | This is part of rtl8180 OpenSource driver |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the official realtek driver | 6 | Parts of this driver are based on the GPL part of the official realtek driver |
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index ca691550436a..fd2bfeadd54c 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl818x pci OpenSource driver - v 0.1 | 2 | This is part of rtl818x pci OpenSource driver - v 0.1 |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public License) | 4 | Released under the terms of GPL (General Public License) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the official | 6 | Parts of this driver are based on the GPL part of the official |
@@ -70,7 +70,7 @@ static int hwwep; | |||
70 | 70 | ||
71 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
72 | MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); | 72 | MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); |
73 | MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); | 73 | MODULE_AUTHOR("Andrea Merello <andrea.merello@gmail.com>"); |
74 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8187SE WiFi cards"); | 74 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8187SE WiFi cards"); |
75 | 75 | ||
76 | module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); | 76 | module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); |
diff --git a/drivers/staging/rtl8187se/r8180_hw.h b/drivers/staging/rtl8187se/r8180_hw.h index 533938123a97..92c05af557cf 100644 --- a/drivers/staging/rtl8187se/r8180_hw.h +++ b/drivers/staging/rtl8187se/r8180_hw.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8180 OpenSource driver. | 2 | This is part of rtl8180 OpenSource driver. |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the | 6 | Parts of this driver are based on the GPL part of the |
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225.h b/drivers/staging/rtl8187se/r8180_rtl8225.h index c6f2128e755c..c94ca0794a5d 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225.h +++ b/drivers/staging/rtl8187se/r8180_rtl8225.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This is part of the rtl8180-sa2400 driver | 2 | This is part of the rtl8180-sa2400 driver |
3 | released under the GPL (See file COPYING for details). | 3 | released under the GPL (See file COPYING for details). |
4 | Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 4 | Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
5 | 5 | ||
6 | This files contains programming code for the rtl8225 | 6 | This files contains programming code for the rtl8225 |
7 | radio frontend. | 7 | radio frontend. |
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index c592f7936ddb..9ae96b7852f3 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * This is part of the rtl8180-sa2400 driver | 2 | * This is part of the rtl8180-sa2400 driver |
3 | * released under the GPL (See file COPYING for details). | 3 | * released under the GPL (See file COPYING for details). |
4 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 4 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
5 | * | 5 | * |
6 | * This files contains programming code for the rtl8225 | 6 | * This files contains programming code for the rtl8225 |
7 | * radio frontend. | 7 | * radio frontend. |
diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 156b75882290..dab787542c45 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c | |||
@@ -2,7 +2,7 @@ | |||
2 | This file contains wireless extension handlers. | 2 | This file contains wireless extension handlers. |
3 | 3 | ||
4 | This is part of rtl8180 OpenSource driver. | 4 | This is part of rtl8180 OpenSource driver. |
5 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 5 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
6 | Released under the terms of GPL (General Public Licence) | 6 | Released under the terms of GPL (General Public Licence) |
7 | 7 | ||
8 | Parts of this driver are based on the GPL part | 8 | Parts of this driver are based on the GPL part |
diff --git a/drivers/staging/rtl8187se/r8180_wx.h b/drivers/staging/rtl8187se/r8180_wx.h index 408191403112..d471520ac772 100644 --- a/drivers/staging/rtl8187se/r8180_wx.h +++ b/drivers/staging/rtl8187se/r8180_wx.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8180 OpenSource driver - v 0.3 | 2 | This is part of rtl8180 OpenSource driver - v 0.3 |
3 | Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the official realtek driver | 6 | Parts of this driver are based on the GPL part of the official realtek driver |
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 50c7bb773984..74fbd70d5838 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h index b9b3b52f9120..dbe0e1c87056 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index baf3b6342e44..fa5603a562c3 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h index fa607f98b172..7d075d3cbe62 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 2b6c61c5d3d8..8d45c8dbfa83 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 87d4d349c890..9de1dc3e584b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c index c1ccff4a8321..a6778e0853c7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h index 9452e1683a72..adea2b4c7a44 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c index 0cfb3ecaadee..529ea54d1683 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c index 5abbee37cdca..2ad92eee50c2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h index 28c7da677a80..356aec437963 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index c9a7c563b682..a8c2ade4f435 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h index df79d6c4ca03..962f2e5b8bf8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 3485ef1dfab1..05ef49f24cd9 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h | |||
@@ -14,7 +14,7 @@ | |||
14 | * Copyright (c) 2004, Intel Corporation | 14 | * Copyright (c) 2004, Intel Corporation |
15 | * | 15 | * |
16 | * Modified for Realtek's wi-fi cards by Andrea Merello | 16 | * Modified for Realtek's wi-fi cards by Andrea Merello |
17 | * <andreamrl@tiscali.it> | 17 | * <andrea.merello@gmail.com> |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
20 | * it under the terms of the GNU General Public License version 2 as | 20 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h index 2bfc1155f505..c59f67b26363 100644 --- a/drivers/staging/rtl8192e/rtllib_debug.h +++ b/drivers/staging/rtl8192e/rtllib_debug.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. | 2 | * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * Based on the r8180 driver, which is: | 4 | * Based on the r8180 driver, which is: |
5 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 5 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License as | 7 | * under the terms of version 2 of the GNU General Public License as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index e75364e3eb43..96aa3a2fb7e1 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c | |||
@@ -14,7 +14,7 @@ | |||
14 | ****************************************************************************** | 14 | ****************************************************************************** |
15 | 15 | ||
16 | Few modifications for Realtek's Wi-Fi drivers by | 16 | Few modifications for Realtek's Wi-Fi drivers by |
17 | Andrea Merello <andreamrl@tiscali.it> | 17 | Andrea Merello <andrea.merello@gmail.com> |
18 | 18 | ||
19 | A special thanks goes to Realtek for their support ! | 19 | A special thanks goes to Realtek for their support ! |
20 | 20 | ||
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index aefffac556a6..0cbf6f5593a3 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 740cf85e9d5b..e6af8cfab12b 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 759d7c7d78e5..1cc6a9d5e8a3 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c | |||
@@ -25,7 +25,7 @@ | |||
25 | ****************************************************************************** | 25 | ****************************************************************************** |
26 | 26 | ||
27 | Few modifications for Realtek's Wi-Fi drivers by | 27 | Few modifications for Realtek's Wi-Fi drivers by |
28 | Andrea Merello <andreamrl@tiscali.it> | 28 | Andrea Merello <andrea.merello@gmail.com> |
29 | 29 | ||
30 | A special thanks goes to Realtek for their support ! | 30 | A special thanks goes to Realtek for their support ! |
31 | 31 | ||
diff --git a/drivers/staging/rtl8192u/authors b/drivers/staging/rtl8192u/authors index b08bbae39e72..0fab11228b48 100644 --- a/drivers/staging/rtl8192u/authors +++ b/drivers/staging/rtl8192u/authors | |||
@@ -1 +1 @@ | |||
Andrea Merello <andreamrl@tiscali.it> | Andrea Merello <andrea.merello@gmail.com> | ||
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index c9f3bb363be4..bc64f05a7e6a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h | |||
@@ -14,7 +14,7 @@ | |||
14 | * Copyright (c) 2004, Intel Corporation | 14 | * Copyright (c) 2004, Intel Corporation |
15 | * | 15 | * |
16 | * Modified for Realtek's wi-fi cards by Andrea Merello | 16 | * Modified for Realtek's wi-fi cards by Andrea Merello |
17 | * <andreamrl@tiscali.it> | 17 | * <andrea.merello@gmail.com> |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
20 | * it under the terms of the GNU General Public License version 2 as | 20 | * it under the terms of the GNU General Public License version 2 as |
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index a6b18409103b..59900bfa1c18 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | |||
@@ -14,7 +14,7 @@ | |||
14 | ****************************************************************************** | 14 | ****************************************************************************** |
15 | 15 | ||
16 | Few modifications for Realtek's Wi-Fi drivers by | 16 | Few modifications for Realtek's Wi-Fi drivers by |
17 | Andrea Merello <andreamrl@tiscali.it> | 17 | Andrea Merello <andrea.merello@gmail.com> |
18 | 18 | ||
19 | A special thanks goes to Realtek for their support ! | 19 | A special thanks goes to Realtek for their support ! |
20 | 20 | ||
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 8a0075db9253..5fd696926ee3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 60746b8b1eb0..7b7d929f1536 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* IEEE 802.11 SoftMAC layer | 1 | /* IEEE 802.11 SoftMAC layer |
2 | * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 2 | * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
3 | * | 3 | * |
4 | * Mostly extracted from the rtl8180-sa2400 driver for the | 4 | * Mostly extracted from the rtl8180-sa2400 driver for the |
5 | * in-kernel generic ieee802.11 stack. | 5 | * in-kernel generic ieee802.11 stack. |
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 995504207fc6..a7bcc64ff226 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | |||
@@ -25,7 +25,7 @@ | |||
25 | ****************************************************************************** | 25 | ****************************************************************************** |
26 | 26 | ||
27 | Few modifications for Realtek's Wi-Fi drivers by | 27 | Few modifications for Realtek's Wi-Fi drivers by |
28 | Andrea Merello <andreamrl@tiscali.it> | 28 | Andrea Merello <andrea.merello@gmail.com> |
29 | 29 | ||
30 | A special thanks goes to Realtek for their support ! | 30 | A special thanks goes to Realtek for their support ! |
31 | 31 | ||
diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index d2199986d132..c61729b727ef 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c | |||
@@ -3,7 +3,7 @@ | |||
3 | memory is addressed by 16 bits words. | 3 | memory is addressed by 16 bits words. |
4 | 4 | ||
5 | This is part of rtl8180 OpenSource driver. | 5 | This is part of rtl8180 OpenSource driver. |
6 | Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> | 6 | Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com> |
7 | Released under the terms of GPL (General Public Licence) | 7 | Released under the terms of GPL (General Public Licence) |
8 | 8 | ||
9 | Parts of this driver are based on the GPL part of the | 9 | Parts of this driver are based on the GPL part of the |
diff --git a/drivers/staging/rtl8192u/r8180_93cx6.h b/drivers/staging/rtl8192u/r8180_93cx6.h index 5cea51e1142e..ee55dbffe32c 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.h +++ b/drivers/staging/rtl8192u/r8180_93cx6.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8187 OpenSource driver | 2 | This is part of rtl8187 OpenSource driver |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the official realtek driver | 6 | Parts of this driver are based on the GPL part of the official realtek driver |
diff --git a/drivers/staging/rtl8192u/r8180_pm.c b/drivers/staging/rtl8192u/r8180_pm.c index 0c58d0ed502a..999968d41720 100644 --- a/drivers/staging/rtl8192u/r8180_pm.c +++ b/drivers/staging/rtl8192u/r8180_pm.c | |||
@@ -5,7 +5,7 @@ | |||
5 | does not do anything useful. | 5 | does not do anything useful. |
6 | 6 | ||
7 | This is part of rtl8180 OpenSource driver. | 7 | This is part of rtl8180 OpenSource driver. |
8 | Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> | 8 | Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com> |
9 | Released under the terms of GPL (General Public Licence) | 9 | Released under the terms of GPL (General Public Licence) |
10 | */ | 10 | */ |
11 | 11 | ||
diff --git a/drivers/staging/rtl8192u/r8180_pm.h b/drivers/staging/rtl8192u/r8180_pm.h index 52d6fba99deb..4be63da0b781 100644 --- a/drivers/staging/rtl8192u/r8180_pm.h +++ b/drivers/staging/rtl8192u/r8180_pm.h | |||
@@ -5,7 +5,7 @@ | |||
5 | does not do anything useful. | 5 | does not do anything useful. |
6 | 6 | ||
7 | This is part of rtl8180 OpenSource driver. | 7 | This is part of rtl8180 OpenSource driver. |
8 | Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> | 8 | Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com> |
9 | Released under the terms of GPL (General Public Licence) | 9 | Released under the terms of GPL (General Public Licence) |
10 | 10 | ||
11 | */ | 11 | */ |
diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.h b/drivers/staging/rtl8192u/r8190_rtl8256.h index b64dd662761a..592e7807fa42 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.h +++ b/drivers/staging/rtl8192u/r8190_rtl8256.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This is part of the rtl8180-sa2400 driver | 2 | This is part of the rtl8180-sa2400 driver |
3 | released under the GPL (See file COPYING for details). | 3 | released under the GPL (See file COPYING for details). |
4 | Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> | 4 | Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> |
5 | 5 | ||
6 | This files contains programming code for the rtl8256 | 6 | This files contains programming code for the rtl8256 |
7 | radio frontend. | 7 | radio frontend. |
diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 338e7bc237c3..b484ee128c13 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * This is part of rtl8187 OpenSource driver. | 2 | * This is part of rtl8187 OpenSource driver. |
3 | * Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | * Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | * Released under the terms of GPL (General Public Licence) | 4 | * Released under the terms of GPL (General Public Licence) |
5 | * | 5 | * |
6 | * Parts of this driver are based on the GPL part of the | 6 | * Parts of this driver are based on the GPL part of the |
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 14c14c24ac50..cd0946db025c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Linux device driver for RTL8192U | 3 | * Linux device driver for RTL8192U |
4 | * | 4 | * |
5 | * Based on the r8187 driver, which is: | 5 | * Based on the r8187 driver, which is: |
6 | * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. | 6 | * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al. |
7 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
8 | * under the terms of version 2 of the GNU General Public License as | 8 | * under the terms of version 2 of the GNU General Public License as |
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
diff --git a/drivers/staging/rtl8192u/r8192U_hw.h b/drivers/staging/rtl8192u/r8192U_hw.h index 7e612aa56fa4..dd07a735b537 100644 --- a/drivers/staging/rtl8192u/r8192U_hw.h +++ b/drivers/staging/rtl8192u/r8192U_hw.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8187 OpenSource driver. | 2 | This is part of rtl8187 OpenSource driver. |
3 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the | 6 | Parts of this driver are based on the GPL part of the |
diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 3e2576347d29..61f6620213e2 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c | |||
@@ -2,7 +2,7 @@ | |||
2 | This file contains wireless extension handlers. | 2 | This file contains wireless extension handlers. |
3 | 3 | ||
4 | This is part of rtl8180 OpenSource driver. | 4 | This is part of rtl8180 OpenSource driver. |
5 | Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> | 5 | Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> |
6 | Released under the terms of GPL (General Public Licence) | 6 | Released under the terms of GPL (General Public Licence) |
7 | 7 | ||
8 | Parts of this driver are based on the GPL part | 8 | Parts of this driver are based on the GPL part |
diff --git a/drivers/staging/rtl8192u/r8192U_wx.h b/drivers/staging/rtl8192u/r8192U_wx.h index 9f6b10505426..ae7a617740a3 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.h +++ b/drivers/staging/rtl8192u/r8192U_wx.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This is part of rtl8180 OpenSource driver - v 0.3 | 2 | This is part of rtl8180 OpenSource driver - v 0.3 |
3 | Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> | 3 | Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com> |
4 | Released under the terms of GPL (General Public Licence) | 4 | Released under the terms of GPL (General Public Licence) |
5 | 5 | ||
6 | Parts of this driver are based on the GPL part of the official realtek driver | 6 | Parts of this driver are based on the GPL part of the official realtek driver |
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index 622fc505d3e1..4d043c30216f 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h | |||
@@ -72,7 +72,19 @@ struct bcma_host_ops { | |||
72 | /* Core-ID values. */ | 72 | /* Core-ID values. */ |
73 | #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */ | 73 | #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */ |
74 | #define BCMA_CORE_4706_CHIPCOMMON 0x500 | 74 | #define BCMA_CORE_4706_CHIPCOMMON 0x500 |
75 | #define BCMA_CORE_PCIEG2 0x501 | ||
76 | #define BCMA_CORE_DMA 0x502 | ||
77 | #define BCMA_CORE_SDIO3 0x503 | ||
78 | #define BCMA_CORE_USB20 0x504 | ||
79 | #define BCMA_CORE_USB30 0x505 | ||
80 | #define BCMA_CORE_A9JTAG 0x506 | ||
81 | #define BCMA_CORE_DDR23 0x507 | ||
82 | #define BCMA_CORE_ROM 0x508 | ||
83 | #define BCMA_CORE_NAND 0x509 | ||
84 | #define BCMA_CORE_QSPI 0x50A | ||
85 | #define BCMA_CORE_CHIPCOMMON_B 0x50B | ||
75 | #define BCMA_CORE_4706_SOC_RAM 0x50E | 86 | #define BCMA_CORE_4706_SOC_RAM 0x50E |
87 | #define BCMA_CORE_ARMCA9 0x510 | ||
76 | #define BCMA_CORE_4706_MAC_GBIT 0x52D | 88 | #define BCMA_CORE_4706_MAC_GBIT 0x52D |
77 | #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */ | 89 | #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */ |
78 | #define BCMA_CORE_ALTA 0x534 /* I2S core */ | 90 | #define BCMA_CORE_ALTA 0x534 /* I2S core */ |
@@ -177,6 +189,11 @@ struct bcma_host_ops { | |||
177 | #define BCMA_PKG_ID_BCM5357 11 | 189 | #define BCMA_PKG_ID_BCM5357 11 |
178 | #define BCMA_CHIP_ID_BCM53572 53572 | 190 | #define BCMA_CHIP_ID_BCM53572 53572 |
179 | #define BCMA_PKG_ID_BCM47188 9 | 191 | #define BCMA_PKG_ID_BCM47188 9 |
192 | #define BCMA_CHIP_ID_BCM4707 53010 | ||
193 | #define BCMA_PKG_ID_BCM4707 1 | ||
194 | #define BCMA_PKG_ID_BCM4708 2 | ||
195 | #define BCMA_PKG_ID_BCM4709 0 | ||
196 | #define BCMA_CHIP_ID_BCM53018 53018 | ||
180 | 197 | ||
181 | /* Board types (on PCI usually equals to the subsystem dev id) */ | 198 | /* Board types (on PCI usually equals to the subsystem dev id) */ |
182 | /* BCM4313 */ | 199 | /* BCM4313 */ |
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h index 424760f01b9d..d66033f418c9 100644 --- a/include/linux/bcma/bcma_driver_pci.h +++ b/include/linux/bcma/bcma_driver_pci.h | |||
@@ -181,10 +181,31 @@ struct pci_dev; | |||
181 | 181 | ||
182 | #define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8 | 182 | #define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8 |
183 | 183 | ||
184 | #define BCMA_CORE_PCI_ | ||
185 | |||
186 | /* MDIO devices (SERDES modules) */ | ||
187 | #define BCMA_CORE_PCI_MDIO_IEEE0 0x000 | ||
188 | #define BCMA_CORE_PCI_MDIO_IEEE1 0x001 | ||
189 | #define BCMA_CORE_PCI_MDIO_BLK0 0x800 | ||
190 | #define BCMA_CORE_PCI_MDIO_BLK1 0x801 | ||
191 | #define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16 | ||
192 | #define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17 | ||
193 | #define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18 | ||
194 | #define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19 | ||
195 | #define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A | ||
196 | #define BCMA_CORE_PCI_MDIO_BLK2 0x802 | ||
197 | #define BCMA_CORE_PCI_MDIO_BLK3 0x803 | ||
198 | #define BCMA_CORE_PCI_MDIO_BLK4 0x804 | ||
199 | #define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */ | ||
200 | #define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820 | ||
201 | #define BCMA_CORE_PCI_MDIO_SERDESID 0x831 | ||
202 | #define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840 | ||
203 | |||
184 | /* PCIE Root Capability Register bits (Host mode only) */ | 204 | /* PCIE Root Capability Register bits (Host mode only) */ |
185 | #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001 | 205 | #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001 |
186 | 206 | ||
187 | struct bcma_drv_pci; | 207 | struct bcma_drv_pci; |
208 | struct bcma_bus; | ||
188 | 209 | ||
189 | #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE | 210 | #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE |
190 | struct bcma_drv_pci_host { | 211 | struct bcma_drv_pci_host { |
@@ -219,7 +240,8 @@ struct bcma_drv_pci { | |||
219 | extern void bcma_core_pci_init(struct bcma_drv_pci *pc); | 240 | extern void bcma_core_pci_init(struct bcma_drv_pci *pc); |
220 | extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, | 241 | extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, |
221 | struct bcma_device *core, bool enable); | 242 | struct bcma_device *core, bool enable); |
222 | extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend); | 243 | extern void bcma_core_pci_up(struct bcma_bus *bus); |
244 | extern void bcma_core_pci_down(struct bcma_bus *bus); | ||
223 | 245 | ||
224 | extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev); | 246 | extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev); |
225 | extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev); | 247 | extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev); |
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index b62d4af6c667..45e921401b06 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
@@ -361,7 +361,8 @@ struct ssb_device_id { | |||
361 | __u16 vendor; | 361 | __u16 vendor; |
362 | __u16 coreid; | 362 | __u16 coreid; |
363 | __u8 revision; | 363 | __u8 revision; |
364 | }; | 364 | __u8 __pad; |
365 | } __attribute__((packed, aligned(2))); | ||
365 | #define SSB_DEVICE(_vendor, _coreid, _revision) \ | 366 | #define SSB_DEVICE(_vendor, _coreid, _revision) \ |
366 | { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } | 367 | { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } |
367 | #define SSB_DEVTABLE_END \ | 368 | #define SSB_DEVTABLE_END \ |
@@ -377,7 +378,7 @@ struct bcma_device_id { | |||
377 | __u16 id; | 378 | __u16 id; |
378 | __u8 rev; | 379 | __u8 rev; |
379 | __u8 class; | 380 | __u8 class; |
380 | }; | 381 | } __attribute__((packed,aligned(2))); |
381 | #define BCMA_CORE(_manuf, _id, _rev, _class) \ | 382 | #define BCMA_CORE(_manuf, _id, _rev, _class) \ |
382 | { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, } | 383 | { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, } |
383 | #define BCMA_CORETABLE_END \ | 384 | #define BCMA_CORETABLE_END \ |
diff --git a/include/linux/platform_data/brcmfmac-sdio.h b/include/linux/platform_data/brcmfmac-sdio.h index b7174998c24a..e75dcbf2b230 100644 --- a/include/linux/platform_data/brcmfmac-sdio.h +++ b/include/linux/platform_data/brcmfmac-sdio.h | |||
@@ -94,6 +94,10 @@ void __init brcmfmac_init_pdata(void) | |||
94 | * Set this to true if the SDIO host controller has higher align requirement | 94 | * Set this to true if the SDIO host controller has higher align requirement |
95 | * than 32 bytes for each scatterlist item. | 95 | * than 32 bytes for each scatterlist item. |
96 | * | 96 | * |
97 | * sd_head_align: alignment requirement for start of data buffer | ||
98 | * | ||
99 | * sd_sgentry_align: length alignment requirement for each sg entry | ||
100 | * | ||
97 | * power_on: This function is called by the brcmfmac when the module gets | 101 | * power_on: This function is called by the brcmfmac when the module gets |
98 | * loaded. This can be particularly useful for low power devices. The platform | 102 | * loaded. This can be particularly useful for low power devices. The platform |
99 | * spcific routine may for example decide to power up the complete device. | 103 | * spcific routine may for example decide to power up the complete device. |
@@ -121,6 +125,8 @@ struct brcmfmac_sdio_platform_data { | |||
121 | unsigned int oob_irq_nr; | 125 | unsigned int oob_irq_nr; |
122 | unsigned long oob_irq_flags; | 126 | unsigned long oob_irq_flags; |
123 | bool broken_sg_support; | 127 | bool broken_sg_support; |
128 | unsigned short sd_head_align; | ||
129 | unsigned short sd_sgentry_align; | ||
124 | void (*power_on)(void); | 130 | void (*power_on)(void); |
125 | void (*power_off)(void); | 131 | void (*power_off)(void); |
126 | void (*reset)(void); | 132 | void (*reset)(void); |
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 10eb9b389014..10d43d8c7037 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -107,6 +107,14 @@ struct bt_power { | |||
107 | */ | 107 | */ |
108 | #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 | 108 | #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 |
109 | 109 | ||
110 | #define BT_VOICE 11 | ||
111 | struct bt_voice { | ||
112 | __u16 setting; | ||
113 | }; | ||
114 | |||
115 | #define BT_VOICE_TRANSPARENT 0x0003 | ||
116 | #define BT_VOICE_CVSD_16BIT 0x0060 | ||
117 | |||
110 | __printf(1, 2) | 118 | __printf(1, 2) |
111 | int bt_info(const char *fmt, ...); | 119 | int bt_info(const char *fmt, ...); |
112 | __printf(1, 2) | 120 | __printf(1, 2) |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 3c592cf473da..aaeaf0938ec0 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -238,6 +238,7 @@ enum { | |||
238 | #define LMP_CVSD 0x01 | 238 | #define LMP_CVSD 0x01 |
239 | #define LMP_PSCHEME 0x02 | 239 | #define LMP_PSCHEME 0x02 |
240 | #define LMP_PCONTROL 0x04 | 240 | #define LMP_PCONTROL 0x04 |
241 | #define LMP_TRANSPARENT 0x08 | ||
241 | 242 | ||
242 | #define LMP_RSSI_INQ 0x40 | 243 | #define LMP_RSSI_INQ 0x40 |
243 | #define LMP_ESCO 0x80 | 244 | #define LMP_ESCO 0x80 |
@@ -296,6 +297,12 @@ enum { | |||
296 | #define HCI_AT_GENERAL_BONDING 0x04 | 297 | #define HCI_AT_GENERAL_BONDING 0x04 |
297 | #define HCI_AT_GENERAL_BONDING_MITM 0x05 | 298 | #define HCI_AT_GENERAL_BONDING_MITM 0x05 |
298 | 299 | ||
300 | /* I/O capabilities */ | ||
301 | #define HCI_IO_DISPLAY_ONLY 0x00 | ||
302 | #define HCI_IO_DISPLAY_YESNO 0x01 | ||
303 | #define HCI_IO_KEYBOARD_ONLY 0x02 | ||
304 | #define HCI_IO_NO_INPUT_OUTPUT 0x03 | ||
305 | |||
299 | /* Link Key types */ | 306 | /* Link Key types */ |
300 | #define HCI_LK_COMBINATION 0x00 | 307 | #define HCI_LK_COMBINATION 0x00 |
301 | #define HCI_LK_LOCAL_UNIT 0x01 | 308 | #define HCI_LK_LOCAL_UNIT 0x01 |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f77885ea78c2..3ede820d328f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -320,6 +320,7 @@ struct hci_conn { | |||
320 | __u32 passkey_notify; | 320 | __u32 passkey_notify; |
321 | __u8 passkey_entered; | 321 | __u8 passkey_entered; |
322 | __u16 disc_timeout; | 322 | __u16 disc_timeout; |
323 | __u16 setting; | ||
323 | unsigned long flags; | 324 | unsigned long flags; |
324 | 325 | ||
325 | __u8 remote_cap; | 326 | __u8 remote_cap; |
@@ -569,7 +570,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, | |||
569 | } | 570 | } |
570 | 571 | ||
571 | void hci_disconnect(struct hci_conn *conn, __u8 reason); | 572 | void hci_disconnect(struct hci_conn *conn, __u8 reason); |
572 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); | 573 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle); |
573 | void hci_sco_setup(struct hci_conn *conn, __u8 status); | 574 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
574 | 575 | ||
575 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | 576 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); |
@@ -584,6 +585,8 @@ struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); | |||
584 | 585 | ||
585 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | 586 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, |
586 | __u8 dst_type, __u8 sec_level, __u8 auth_type); | 587 | __u8 dst_type, __u8 sec_level, __u8 auth_type); |
588 | struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, | ||
589 | __u16 setting); | ||
587 | int hci_conn_check_link_mode(struct hci_conn *conn); | 590 | int hci_conn_check_link_mode(struct hci_conn *conn); |
588 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); | 591 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
589 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); | 592 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
@@ -797,6 +800,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn); | |||
797 | #define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO) | 800 | #define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO) |
798 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR) | 801 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR) |
799 | #define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES) | 802 | #define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES) |
803 | #define lmp_transp_capable(dev) ((dev)->features[0][2] & LMP_TRANSPARENT) | ||
800 | 804 | ||
801 | /* ----- Extended LMP capabilities ----- */ | 805 | /* ----- Extended LMP capabilities ----- */ |
802 | #define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP) | 806 | #define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP) |
@@ -1213,4 +1217,8 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], | |||
1213 | 1217 | ||
1214 | u8 bdaddr_to_le(u8 bdaddr_type); | 1218 | u8 bdaddr_to_le(u8 bdaddr_type); |
1215 | 1219 | ||
1220 | #define SCO_AIRMODE_MASK 0x0003 | ||
1221 | #define SCO_AIRMODE_CVSD 0x0000 | ||
1222 | #define SCO_AIRMODE_TRANSP 0x0003 | ||
1223 | |||
1216 | #endif /* __HCI_CORE_H */ | 1224 | #endif /* __HCI_CORE_H */ |
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h index 1e35c43657c8..e252a31ee6b6 100644 --- a/include/net/bluetooth/sco.h +++ b/include/net/bluetooth/sco.h | |||
@@ -73,6 +73,7 @@ struct sco_conn { | |||
73 | struct sco_pinfo { | 73 | struct sco_pinfo { |
74 | struct bt_sock bt; | 74 | struct bt_sock bt; |
75 | __u32 flags; | 75 | __u32 flags; |
76 | __u16 setting; | ||
76 | struct sco_conn *conn; | 77 | struct sco_conn *conn; |
77 | }; | 78 | }; |
78 | 79 | ||
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index e3e303778936..4be8785332b1 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -1521,6 +1521,7 @@ enum ieee80211_hw_flags { | |||
1521 | IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24, | 1521 | IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24, |
1522 | IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25, | 1522 | IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25, |
1523 | IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26, | 1523 | IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26, |
1524 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 1<<27, | ||
1524 | }; | 1525 | }; |
1525 | 1526 | ||
1526 | /** | 1527 | /** |
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h index 0af851c3b038..b64b7bce4b94 100644 --- a/include/net/nfc/hci.h +++ b/include/net/nfc/hci.h | |||
@@ -59,7 +59,7 @@ struct nfc_hci_ops { | |||
59 | struct nfc_target *target); | 59 | struct nfc_target *target); |
60 | int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, | 60 | int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, |
61 | struct sk_buff *skb); | 61 | struct sk_buff *skb); |
62 | int (*fw_upload)(struct nfc_hci_dev *hdev, const char *firmware_name); | 62 | int (*fw_download)(struct nfc_hci_dev *hdev, const char *firmware_name); |
63 | int (*discover_se)(struct nfc_hci_dev *dev); | 63 | int (*discover_se)(struct nfc_hci_dev *dev); |
64 | int (*enable_se)(struct nfc_hci_dev *dev, u32 se_idx); | 64 | int (*enable_se)(struct nfc_hci_dev *dev, u32 se_idx); |
65 | int (*disable_se)(struct nfc_hci_dev *dev, u32 se_idx); | 65 | int (*disable_se)(struct nfc_hci_dev *dev, u32 se_idx); |
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 0e353f1658bb..f68ee68e4e3e 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h | |||
@@ -68,7 +68,7 @@ struct nfc_ops { | |||
68 | void *cb_context); | 68 | void *cb_context); |
69 | int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb); | 69 | int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb); |
70 | int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target); | 70 | int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target); |
71 | int (*fw_upload)(struct nfc_dev *dev, const char *firmware_name); | 71 | int (*fw_download)(struct nfc_dev *dev, const char *firmware_name); |
72 | 72 | ||
73 | /* Secure Element API */ | 73 | /* Secure Element API */ |
74 | int (*discover_se)(struct nfc_dev *dev); | 74 | int (*discover_se)(struct nfc_dev *dev); |
@@ -127,7 +127,7 @@ struct nfc_dev { | |||
127 | int targets_generation; | 127 | int targets_generation; |
128 | struct device dev; | 128 | struct device dev; |
129 | bool dev_up; | 129 | bool dev_up; |
130 | bool fw_upload_in_progress; | 130 | bool fw_download_in_progress; |
131 | u8 rf_mode; | 131 | u8 rf_mode; |
132 | bool polling; | 132 | bool polling; |
133 | struct nfc_target *active_target; | 133 | struct nfc_target *active_target; |
@@ -224,6 +224,9 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, | |||
224 | u8 *gt, u8 gt_len); | 224 | u8 *gt, u8 gt_len); |
225 | u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len); | 225 | u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len); |
226 | 226 | ||
227 | int nfc_fw_download_done(struct nfc_dev *dev, const char *firmware_name, | ||
228 | u32 result); | ||
229 | |||
227 | int nfc_targets_found(struct nfc_dev *dev, | 230 | int nfc_targets_found(struct nfc_dev *dev, |
228 | struct nfc_target *targets, int ntargets); | 231 | struct nfc_target *targets, int ntargets); |
229 | int nfc_target_lost(struct nfc_dev *dev, u32 target_idx); | 232 | int nfc_target_lost(struct nfc_dev *dev, u32 target_idx); |
diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h index caed0f324d5f..29bed72a4ac4 100644 --- a/include/uapi/linux/nfc.h +++ b/include/uapi/linux/nfc.h | |||
@@ -69,8 +69,22 @@ | |||
69 | * starting a poll from a device which has a secure element enabled means | 69 | * starting a poll from a device which has a secure element enabled means |
70 | * we want to do SE based card emulation. | 70 | * we want to do SE based card emulation. |
71 | * @NFC_CMD_DISABLE_SE: Disable the physical link to a specific secure element. | 71 | * @NFC_CMD_DISABLE_SE: Disable the physical link to a specific secure element. |
72 | * @NFC_CMD_FW_UPLOAD: Request to Load/flash firmware, or event to inform that | 72 | * @NFC_CMD_FW_DOWNLOAD: Request to Load/flash firmware, or event to inform |
73 | * some firmware was loaded | 73 | * that some firmware was loaded |
74 | * @NFC_EVENT_SE_ADDED: Event emitted when a new secure element is discovered. | ||
75 | * This typically will be sent whenever a new NFC controller with either | ||
76 | * an embedded SE or an UICC one connected to it through SWP. | ||
77 | * @NFC_EVENT_SE_REMOVED: Event emitted when a secure element is removed from | ||
78 | * the system, as a consequence of e.g. an NFC controller being unplugged. | ||
79 | * @NFC_EVENT_SE_CONNECTIVITY: This event is emitted whenever a secure element | ||
80 | * is requesting connectivity access. For example a UICC SE may need to | ||
81 | * talk with a sleeping modem and will notify this need by sending this | ||
82 | * event. It is then up to userspace to decide if it will wake the modem | ||
83 | * up or not. | ||
84 | * @NFC_EVENT_SE_TRANSACTION: This event is sent when an application running on | ||
85 | * a specific SE notifies us about the end of a transaction. The parameter | ||
86 | * for this event is the application ID (AID). | ||
87 | * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller. | ||
74 | */ | 88 | */ |
75 | enum nfc_commands { | 89 | enum nfc_commands { |
76 | NFC_CMD_UNSPEC, | 90 | NFC_CMD_UNSPEC, |
@@ -94,9 +108,12 @@ enum nfc_commands { | |||
94 | NFC_CMD_DISABLE_SE, | 108 | NFC_CMD_DISABLE_SE, |
95 | NFC_CMD_LLC_SDREQ, | 109 | NFC_CMD_LLC_SDREQ, |
96 | NFC_EVENT_LLC_SDRES, | 110 | NFC_EVENT_LLC_SDRES, |
97 | NFC_CMD_FW_UPLOAD, | 111 | NFC_CMD_FW_DOWNLOAD, |
98 | NFC_EVENT_SE_ADDED, | 112 | NFC_EVENT_SE_ADDED, |
99 | NFC_EVENT_SE_REMOVED, | 113 | NFC_EVENT_SE_REMOVED, |
114 | NFC_EVENT_SE_CONNECTIVITY, | ||
115 | NFC_EVENT_SE_TRANSACTION, | ||
116 | NFC_CMD_GET_SE, | ||
100 | /* private: internal use only */ | 117 | /* private: internal use only */ |
101 | __NFC_CMD_AFTER_LAST | 118 | __NFC_CMD_AFTER_LAST |
102 | }; | 119 | }; |
@@ -129,6 +146,7 @@ enum nfc_commands { | |||
129 | * @NFC_ATTR_FIRMWARE_NAME: Free format firmware version | 146 | * @NFC_ATTR_FIRMWARE_NAME: Free format firmware version |
130 | * @NFC_ATTR_SE_INDEX: Secure element index | 147 | * @NFC_ATTR_SE_INDEX: Secure element index |
131 | * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) | 148 | * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) |
149 | * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status | ||
132 | */ | 150 | */ |
133 | enum nfc_attrs { | 151 | enum nfc_attrs { |
134 | NFC_ATTR_UNSPEC, | 152 | NFC_ATTR_UNSPEC, |
@@ -154,6 +172,8 @@ enum nfc_attrs { | |||
154 | NFC_ATTR_FIRMWARE_NAME, | 172 | NFC_ATTR_FIRMWARE_NAME, |
155 | NFC_ATTR_SE_INDEX, | 173 | NFC_ATTR_SE_INDEX, |
156 | NFC_ATTR_SE_TYPE, | 174 | NFC_ATTR_SE_TYPE, |
175 | NFC_ATTR_SE_AID, | ||
176 | NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, | ||
157 | /* private: internal use only */ | 177 | /* private: internal use only */ |
158 | __NFC_ATTR_AFTER_LAST | 178 | __NFC_ATTR_AFTER_LAST |
159 | }; | 179 | }; |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6c7f36379722..f0817121ec5e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -31,6 +31,24 @@ | |||
31 | #include <net/bluetooth/a2mp.h> | 31 | #include <net/bluetooth/a2mp.h> |
32 | #include <net/bluetooth/smp.h> | 32 | #include <net/bluetooth/smp.h> |
33 | 33 | ||
34 | struct sco_param { | ||
35 | u16 pkt_type; | ||
36 | u16 max_latency; | ||
37 | }; | ||
38 | |||
39 | static const struct sco_param sco_param_cvsd[] = { | ||
40 | { EDR_ESCO_MASK & ~ESCO_2EV3, 0x000a }, /* S3 */ | ||
41 | { EDR_ESCO_MASK & ~ESCO_2EV3, 0x0007 }, /* S2 */ | ||
42 | { EDR_ESCO_MASK | ESCO_EV3, 0x0007 }, /* S1 */ | ||
43 | { EDR_ESCO_MASK | ESCO_HV3, 0xffff }, /* D1 */ | ||
44 | { EDR_ESCO_MASK | ESCO_HV1, 0xffff }, /* D0 */ | ||
45 | }; | ||
46 | |||
47 | static const struct sco_param sco_param_wideband[] = { | ||
48 | { EDR_ESCO_MASK & ~ESCO_2EV3, 0x000d }, /* T2 */ | ||
49 | { EDR_ESCO_MASK | ESCO_EV3, 0x0008 }, /* T1 */ | ||
50 | }; | ||
51 | |||
34 | static void hci_le_create_connection(struct hci_conn *conn) | 52 | static void hci_le_create_connection(struct hci_conn *conn) |
35 | { | 53 | { |
36 | struct hci_dev *hdev = conn->hdev; | 54 | struct hci_dev *hdev = conn->hdev; |
@@ -172,10 +190,11 @@ static void hci_add_sco(struct hci_conn *conn, __u16 handle) | |||
172 | hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp); | 190 | hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp); |
173 | } | 191 | } |
174 | 192 | ||
175 | void hci_setup_sync(struct hci_conn *conn, __u16 handle) | 193 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle) |
176 | { | 194 | { |
177 | struct hci_dev *hdev = conn->hdev; | 195 | struct hci_dev *hdev = conn->hdev; |
178 | struct hci_cp_setup_sync_conn cp; | 196 | struct hci_cp_setup_sync_conn cp; |
197 | const struct sco_param *param; | ||
179 | 198 | ||
180 | BT_DBG("hcon %p", conn); | 199 | BT_DBG("hcon %p", conn); |
181 | 200 | ||
@@ -185,15 +204,35 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle) | |||
185 | conn->attempt++; | 204 | conn->attempt++; |
186 | 205 | ||
187 | cp.handle = cpu_to_le16(handle); | 206 | cp.handle = cpu_to_le16(handle); |
188 | cp.pkt_type = cpu_to_le16(conn->pkt_type); | ||
189 | 207 | ||
190 | cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40); | 208 | cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40); |
191 | cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40); | 209 | cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40); |
192 | cp.max_latency = __constant_cpu_to_le16(0xffff); | 210 | cp.voice_setting = cpu_to_le16(conn->setting); |
193 | cp.voice_setting = cpu_to_le16(hdev->voice_setting); | 211 | |
194 | cp.retrans_effort = 0xff; | 212 | switch (conn->setting & SCO_AIRMODE_MASK) { |
213 | case SCO_AIRMODE_TRANSP: | ||
214 | if (conn->attempt > ARRAY_SIZE(sco_param_wideband)) | ||
215 | return false; | ||
216 | cp.retrans_effort = 0x02; | ||
217 | param = &sco_param_wideband[conn->attempt - 1]; | ||
218 | break; | ||
219 | case SCO_AIRMODE_CVSD: | ||
220 | if (conn->attempt > ARRAY_SIZE(sco_param_cvsd)) | ||
221 | return false; | ||
222 | cp.retrans_effort = 0x01; | ||
223 | param = &sco_param_cvsd[conn->attempt - 1]; | ||
224 | break; | ||
225 | default: | ||
226 | return false; | ||
227 | } | ||
195 | 228 | ||
196 | hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp); | 229 | cp.pkt_type = __cpu_to_le16(param->pkt_type); |
230 | cp.max_latency = __cpu_to_le16(param->max_latency); | ||
231 | |||
232 | if (hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp) < 0) | ||
233 | return false; | ||
234 | |||
235 | return true; | ||
197 | } | 236 | } |
198 | 237 | ||
199 | void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, | 238 | void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, |
@@ -560,13 +599,13 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, | |||
560 | return acl; | 599 | return acl; |
561 | } | 600 | } |
562 | 601 | ||
563 | static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, | 602 | struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, |
564 | bdaddr_t *dst, u8 sec_level, u8 auth_type) | 603 | __u16 setting) |
565 | { | 604 | { |
566 | struct hci_conn *acl; | 605 | struct hci_conn *acl; |
567 | struct hci_conn *sco; | 606 | struct hci_conn *sco; |
568 | 607 | ||
569 | acl = hci_connect_acl(hdev, dst, sec_level, auth_type); | 608 | acl = hci_connect_acl(hdev, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING); |
570 | if (IS_ERR(acl)) | 609 | if (IS_ERR(acl)) |
571 | return acl; | 610 | return acl; |
572 | 611 | ||
@@ -584,6 +623,8 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, | |||
584 | 623 | ||
585 | hci_conn_hold(sco); | 624 | hci_conn_hold(sco); |
586 | 625 | ||
626 | sco->setting = setting; | ||
627 | |||
587 | if (acl->state == BT_CONNECTED && | 628 | if (acl->state == BT_CONNECTED && |
588 | (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { | 629 | (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { |
589 | set_bit(HCI_CONN_POWER_SAVE, &acl->flags); | 630 | set_bit(HCI_CONN_POWER_SAVE, &acl->flags); |
@@ -612,9 +653,6 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | |||
612 | return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type); | 653 | return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type); |
613 | case ACL_LINK: | 654 | case ACL_LINK: |
614 | return hci_connect_acl(hdev, dst, sec_level, auth_type); | 655 | return hci_connect_acl(hdev, dst, sec_level, auth_type); |
615 | case SCO_LINK: | ||
616 | case ESCO_LINK: | ||
617 | return hci_connect_sco(hdev, type, dst, sec_level, auth_type); | ||
618 | } | 656 | } |
619 | 657 | ||
620 | return ERR_PTR(-EINVAL); | 658 | return ERR_PTR(-EINVAL); |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e3a349977595..634debab4d54 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -454,6 +454,18 @@ static void hci_setup_event_mask(struct hci_request *req) | |||
454 | events[4] |= 0x04; /* Read Remote Extended Features Complete */ | 454 | events[4] |= 0x04; /* Read Remote Extended Features Complete */ |
455 | events[5] |= 0x08; /* Synchronous Connection Complete */ | 455 | events[5] |= 0x08; /* Synchronous Connection Complete */ |
456 | events[5] |= 0x10; /* Synchronous Connection Changed */ | 456 | events[5] |= 0x10; /* Synchronous Connection Changed */ |
457 | } else { | ||
458 | /* Use a different default for LE-only devices */ | ||
459 | memset(events, 0, sizeof(events)); | ||
460 | events[0] |= 0x10; /* Disconnection Complete */ | ||
461 | events[0] |= 0x80; /* Encryption Change */ | ||
462 | events[1] |= 0x08; /* Read Remote Version Information Complete */ | ||
463 | events[1] |= 0x20; /* Command Complete */ | ||
464 | events[1] |= 0x40; /* Command Status */ | ||
465 | events[1] |= 0x80; /* Hardware Error */ | ||
466 | events[2] |= 0x04; /* Number of Completed Packets */ | ||
467 | events[3] |= 0x02; /* Data Buffer Overflow */ | ||
468 | events[5] |= 0x80; /* Encryption Key Refresh Complete */ | ||
457 | } | 469 | } |
458 | 470 | ||
459 | if (lmp_inq_rssi_capable(hdev)) | 471 | if (lmp_inq_rssi_capable(hdev)) |
@@ -513,7 +525,10 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt) | |||
513 | 525 | ||
514 | hci_setup_event_mask(req); | 526 | hci_setup_event_mask(req); |
515 | 527 | ||
516 | if (hdev->hci_ver > BLUETOOTH_VER_1_1) | 528 | /* AVM Berlin (31), aka "BlueFRITZ!", doesn't support the read |
529 | * local supported commands HCI command. | ||
530 | */ | ||
531 | if (hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1) | ||
517 | hci_req_add(req, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); | 532 | hci_req_add(req, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); |
518 | 533 | ||
519 | if (lmp_ssp_capable(hdev)) { | 534 | if (lmp_ssp_capable(hdev)) { |
@@ -605,7 +620,7 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt) | |||
605 | * as supported send it. If not supported assume that the controller | 620 | * as supported send it. If not supported assume that the controller |
606 | * does not have actual support for stored link keys which makes this | 621 | * does not have actual support for stored link keys which makes this |
607 | * command redundant anyway. | 622 | * command redundant anyway. |
608 | */ | 623 | */ |
609 | if (hdev->commands[6] & 0x80) { | 624 | if (hdev->commands[6] & 0x80) { |
610 | struct hci_cp_delete_stored_link_key cp; | 625 | struct hci_cp_delete_stored_link_key cp; |
611 | 626 | ||
@@ -2165,10 +2180,6 @@ int hci_register_dev(struct hci_dev *hdev) | |||
2165 | 2180 | ||
2166 | BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); | 2181 | BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); |
2167 | 2182 | ||
2168 | write_lock(&hci_dev_list_lock); | ||
2169 | list_add(&hdev->list, &hci_dev_list); | ||
2170 | write_unlock(&hci_dev_list_lock); | ||
2171 | |||
2172 | hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND | | 2183 | hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND | |
2173 | WQ_MEM_RECLAIM, 1, hdev->name); | 2184 | WQ_MEM_RECLAIM, 1, hdev->name); |
2174 | if (!hdev->workqueue) { | 2185 | if (!hdev->workqueue) { |
@@ -2203,6 +2214,10 @@ int hci_register_dev(struct hci_dev *hdev) | |||
2203 | if (hdev->dev_type != HCI_AMP) | 2214 | if (hdev->dev_type != HCI_AMP) |
2204 | set_bit(HCI_AUTO_OFF, &hdev->dev_flags); | 2215 | set_bit(HCI_AUTO_OFF, &hdev->dev_flags); |
2205 | 2216 | ||
2217 | write_lock(&hci_dev_list_lock); | ||
2218 | list_add(&hdev->list, &hci_dev_list); | ||
2219 | write_unlock(&hci_dev_list_lock); | ||
2220 | |||
2206 | hci_notify(hdev, HCI_DEV_REG); | 2221 | hci_notify(hdev, HCI_DEV_REG); |
2207 | hci_dev_hold(hdev); | 2222 | hci_dev_hold(hdev); |
2208 | 2223 | ||
@@ -2215,9 +2230,6 @@ err_wqueue: | |||
2215 | destroy_workqueue(hdev->req_workqueue); | 2230 | destroy_workqueue(hdev->req_workqueue); |
2216 | err: | 2231 | err: |
2217 | ida_simple_remove(&hci_index_ida, hdev->id); | 2232 | ida_simple_remove(&hci_index_ida, hdev->id); |
2218 | write_lock(&hci_dev_list_lock); | ||
2219 | list_del(&hdev->list); | ||
2220 | write_unlock(&hci_dev_list_lock); | ||
2221 | 2233 | ||
2222 | return error; | 2234 | return error; |
2223 | } | 2235 | } |
@@ -3399,8 +3411,16 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status) | |||
3399 | */ | 3411 | */ |
3400 | if (hdev->sent_cmd) { | 3412 | if (hdev->sent_cmd) { |
3401 | req_complete = bt_cb(hdev->sent_cmd)->req.complete; | 3413 | req_complete = bt_cb(hdev->sent_cmd)->req.complete; |
3402 | if (req_complete) | 3414 | |
3415 | if (req_complete) { | ||
3416 | /* We must set the complete callback to NULL to | ||
3417 | * avoid calling the callback more than once if | ||
3418 | * this function gets called again. | ||
3419 | */ | ||
3420 | bt_cb(hdev->sent_cmd)->req.complete = NULL; | ||
3421 | |||
3403 | goto call_complete; | 3422 | goto call_complete; |
3423 | } | ||
3404 | } | 3424 | } |
3405 | 3425 | ||
3406 | /* Remove all pending commands belonging to this request */ | 3426 | /* Remove all pending commands belonging to this request */ |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0437200d92f4..94aab73f89d4 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -2904,15 +2904,16 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, | |||
2904 | hci_conn_add_sysfs(conn); | 2904 | hci_conn_add_sysfs(conn); |
2905 | break; | 2905 | break; |
2906 | 2906 | ||
2907 | case 0x0d: /* Connection Rejected due to Limited Resources */ | ||
2907 | case 0x11: /* Unsupported Feature or Parameter Value */ | 2908 | case 0x11: /* Unsupported Feature or Parameter Value */ |
2908 | case 0x1c: /* SCO interval rejected */ | 2909 | case 0x1c: /* SCO interval rejected */ |
2909 | case 0x1a: /* Unsupported Remote Feature */ | 2910 | case 0x1a: /* Unsupported Remote Feature */ |
2910 | case 0x1f: /* Unspecified error */ | 2911 | case 0x1f: /* Unspecified error */ |
2911 | if (conn->out && conn->attempt < 2) { | 2912 | if (conn->out) { |
2912 | conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | | 2913 | conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | |
2913 | (hdev->esco_type & EDR_ESCO_MASK); | 2914 | (hdev->esco_type & EDR_ESCO_MASK); |
2914 | hci_setup_sync(conn, conn->link->handle); | 2915 | if (hci_setup_sync(conn, conn->link->handle)) |
2915 | goto unlock; | 2916 | goto unlock; |
2916 | } | 2917 | } |
2917 | /* fall through */ | 2918 | /* fall through */ |
2918 | 2919 | ||
@@ -3024,17 +3025,20 @@ unlock: | |||
3024 | static u8 hci_get_auth_req(struct hci_conn *conn) | 3025 | static u8 hci_get_auth_req(struct hci_conn *conn) |
3025 | { | 3026 | { |
3026 | /* If remote requests dedicated bonding follow that lead */ | 3027 | /* If remote requests dedicated bonding follow that lead */ |
3027 | if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) { | 3028 | if (conn->remote_auth == HCI_AT_DEDICATED_BONDING || |
3029 | conn->remote_auth == HCI_AT_DEDICATED_BONDING_MITM) { | ||
3028 | /* If both remote and local IO capabilities allow MITM | 3030 | /* If both remote and local IO capabilities allow MITM |
3029 | * protection then require it, otherwise don't */ | 3031 | * protection then require it, otherwise don't */ |
3030 | if (conn->remote_cap == 0x03 || conn->io_capability == 0x03) | 3032 | if (conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT || |
3031 | return 0x02; | 3033 | conn->io_capability == HCI_IO_NO_INPUT_OUTPUT) |
3034 | return HCI_AT_DEDICATED_BONDING; | ||
3032 | else | 3035 | else |
3033 | return 0x03; | 3036 | return HCI_AT_DEDICATED_BONDING_MITM; |
3034 | } | 3037 | } |
3035 | 3038 | ||
3036 | /* If remote requests no-bonding follow that lead */ | 3039 | /* If remote requests no-bonding follow that lead */ |
3037 | if (conn->remote_auth == 0x00 || conn->remote_auth == 0x01) | 3040 | if (conn->remote_auth == HCI_AT_NO_BONDING || |
3041 | conn->remote_auth == HCI_AT_NO_BONDING_MITM) | ||
3038 | return conn->remote_auth | (conn->auth_type & 0x01); | 3042 | return conn->remote_auth | (conn->auth_type & 0x01); |
3039 | 3043 | ||
3040 | return conn->auth_type; | 3044 | return conn->auth_type; |
@@ -3066,7 +3070,7 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3066 | /* Change the IO capability from KeyboardDisplay | 3070 | /* Change the IO capability from KeyboardDisplay |
3067 | * to DisplayYesNo as it is not supported by BT spec. */ | 3071 | * to DisplayYesNo as it is not supported by BT spec. */ |
3068 | cp.capability = (conn->io_capability == 0x04) ? | 3072 | cp.capability = (conn->io_capability == 0x04) ? |
3069 | 0x01 : conn->io_capability; | 3073 | HCI_IO_DISPLAY_YESNO : conn->io_capability; |
3070 | conn->auth_type = hci_get_auth_req(conn); | 3074 | conn->auth_type = hci_get_auth_req(conn); |
3071 | cp.authentication = conn->auth_type; | 3075 | cp.authentication = conn->auth_type; |
3072 | 3076 | ||
@@ -3140,7 +3144,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev, | |||
3140 | * request. The only exception is when we're dedicated bonding | 3144 | * request. The only exception is when we're dedicated bonding |
3141 | * initiators (connect_cfm_cb set) since then we always have the MITM | 3145 | * initiators (connect_cfm_cb set) since then we always have the MITM |
3142 | * bit set. */ | 3146 | * bit set. */ |
3143 | if (!conn->connect_cfm_cb && loc_mitm && conn->remote_cap == 0x03) { | 3147 | if (!conn->connect_cfm_cb && loc_mitm && |
3148 | conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { | ||
3144 | BT_DBG("Rejecting request: remote device can't provide MITM"); | 3149 | BT_DBG("Rejecting request: remote device can't provide MITM"); |
3145 | hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, | 3150 | hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, |
3146 | sizeof(ev->bdaddr), &ev->bdaddr); | 3151 | sizeof(ev->bdaddr), &ev->bdaddr); |
@@ -3148,8 +3153,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev, | |||
3148 | } | 3153 | } |
3149 | 3154 | ||
3150 | /* If no side requires MITM protection; auto-accept */ | 3155 | /* If no side requires MITM protection; auto-accept */ |
3151 | if ((!loc_mitm || conn->remote_cap == 0x03) && | 3156 | if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && |
3152 | (!rem_mitm || conn->io_capability == 0x03)) { | 3157 | (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { |
3153 | 3158 | ||
3154 | /* If we're not the initiators request authorization to | 3159 | /* If we're not the initiators request authorization to |
3155 | * proceed from user space (mgmt_user_confirm with | 3160 | * proceed from user space (mgmt_user_confirm with |
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 0c699cdc3696..13863de433a4 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -238,6 +238,31 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep | |||
238 | return hidp_send_intr_message(session, hdr, buf, rsize); | 238 | return hidp_send_intr_message(session, hdr, buf, rsize); |
239 | } | 239 | } |
240 | 240 | ||
241 | static int hidp_hidinput_event(struct input_dev *dev, unsigned int type, | ||
242 | unsigned int code, int value) | ||
243 | { | ||
244 | struct hid_device *hid = input_get_drvdata(dev); | ||
245 | struct hidp_session *session = hid->driver_data; | ||
246 | struct hid_field *field; | ||
247 | int offset; | ||
248 | |||
249 | BT_DBG("session %p type %d code %d value %d", | ||
250 | session, type, code, value); | ||
251 | |||
252 | if (type != EV_LED) | ||
253 | return -1; | ||
254 | |||
255 | offset = hidinput_find_field(hid, type, code, &field); | ||
256 | if (offset == -1) { | ||
257 | hid_warn(dev, "event field not found\n"); | ||
258 | return -1; | ||
259 | } | ||
260 | |||
261 | hid_set_field(field, offset, value); | ||
262 | |||
263 | return hidp_send_report(session, field->report); | ||
264 | } | ||
265 | |||
241 | static int hidp_get_raw_report(struct hid_device *hid, | 266 | static int hidp_get_raw_report(struct hid_device *hid, |
242 | unsigned char report_number, | 267 | unsigned char report_number, |
243 | unsigned char *data, size_t count, | 268 | unsigned char *data, size_t count, |
@@ -678,20 +703,6 @@ static int hidp_parse(struct hid_device *hid) | |||
678 | 703 | ||
679 | static int hidp_start(struct hid_device *hid) | 704 | static int hidp_start(struct hid_device *hid) |
680 | { | 705 | { |
681 | struct hidp_session *session = hid->driver_data; | ||
682 | struct hid_report *report; | ||
683 | |||
684 | if (hid->quirks & HID_QUIRK_NO_INIT_REPORTS) | ||
685 | return 0; | ||
686 | |||
687 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT]. | ||
688 | report_list, list) | ||
689 | hidp_send_report(session, report); | ||
690 | |||
691 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT]. | ||
692 | report_list, list) | ||
693 | hidp_send_report(session, report); | ||
694 | |||
695 | return 0; | 706 | return 0; |
696 | } | 707 | } |
697 | 708 | ||
@@ -711,6 +722,7 @@ static struct hid_ll_driver hidp_hid_driver = { | |||
711 | .stop = hidp_stop, | 722 | .stop = hidp_stop, |
712 | .open = hidp_open, | 723 | .open = hidp_open, |
713 | .close = hidp_close, | 724 | .close = hidp_close, |
725 | .hidinput_input_event = hidp_hidinput_event, | ||
714 | }; | 726 | }; |
715 | 727 | ||
716 | /* This function sets up the hid device. It does not add it | 728 | /* This function sets up the hid device. It does not add it |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8c3499bec893..b3bb7bca8e60 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -1415,8 +1415,9 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) | |||
1415 | sk->sk_state_change(sk); | 1415 | sk->sk_state_change(sk); |
1416 | release_sock(sk); | 1416 | release_sock(sk); |
1417 | 1417 | ||
1418 | } else if (chan->state == BT_CONNECT) | 1418 | } else if (chan->state == BT_CONNECT) { |
1419 | l2cap_do_start(chan); | 1419 | l2cap_do_start(chan); |
1420 | } | ||
1420 | 1421 | ||
1421 | l2cap_chan_unlock(chan); | 1422 | l2cap_chan_unlock(chan); |
1422 | } | 1423 | } |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index b6e44ad6cca6..6d126faf145f 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -58,7 +58,6 @@ struct rfcomm_dev { | |||
58 | uint modem_status; | 58 | uint modem_status; |
59 | 59 | ||
60 | struct rfcomm_dlc *dlc; | 60 | struct rfcomm_dlc *dlc; |
61 | wait_queue_head_t wait; | ||
62 | 61 | ||
63 | struct device *tty_dev; | 62 | struct device *tty_dev; |
64 | 63 | ||
@@ -76,13 +75,6 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig); | |||
76 | 75 | ||
77 | /* ---- Device functions ---- */ | 76 | /* ---- Device functions ---- */ |
78 | 77 | ||
79 | /* | ||
80 | * The reason this isn't actually a race, as you no doubt have a little voice | ||
81 | * screaming at you in your head, is that the refcount should never actually | ||
82 | * reach zero unless the device has already been taken off the list, in | ||
83 | * rfcomm_dev_del(). And if that's not true, we'll hit the BUG() in | ||
84 | * rfcomm_dev_destruct() anyway. | ||
85 | */ | ||
86 | static void rfcomm_dev_destruct(struct tty_port *port) | 78 | static void rfcomm_dev_destruct(struct tty_port *port) |
87 | { | 79 | { |
88 | struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); | 80 | struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); |
@@ -90,10 +82,9 @@ static void rfcomm_dev_destruct(struct tty_port *port) | |||
90 | 82 | ||
91 | BT_DBG("dev %p dlc %p", dev, dlc); | 83 | BT_DBG("dev %p dlc %p", dev, dlc); |
92 | 84 | ||
93 | /* Refcount should only hit zero when called from rfcomm_dev_del() | 85 | spin_lock(&rfcomm_dev_lock); |
94 | which will have taken us off the list. Everything else are | 86 | list_del(&dev->list); |
95 | refcounting bugs. */ | 87 | spin_unlock(&rfcomm_dev_lock); |
96 | BUG_ON(!list_empty(&dev->list)); | ||
97 | 88 | ||
98 | rfcomm_dlc_lock(dlc); | 89 | rfcomm_dlc_lock(dlc); |
99 | /* Detach DLC if it's owned by this dev */ | 90 | /* Detach DLC if it's owned by this dev */ |
@@ -112,8 +103,39 @@ static void rfcomm_dev_destruct(struct tty_port *port) | |||
112 | module_put(THIS_MODULE); | 103 | module_put(THIS_MODULE); |
113 | } | 104 | } |
114 | 105 | ||
106 | /* device-specific initialization: open the dlc */ | ||
107 | static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty) | ||
108 | { | ||
109 | struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); | ||
110 | |||
111 | return rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel); | ||
112 | } | ||
113 | |||
114 | /* we block the open until the dlc->state becomes BT_CONNECTED */ | ||
115 | static int rfcomm_dev_carrier_raised(struct tty_port *port) | ||
116 | { | ||
117 | struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); | ||
118 | |||
119 | return (dev->dlc->state == BT_CONNECTED); | ||
120 | } | ||
121 | |||
122 | /* device-specific cleanup: close the dlc */ | ||
123 | static void rfcomm_dev_shutdown(struct tty_port *port) | ||
124 | { | ||
125 | struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); | ||
126 | |||
127 | if (dev->tty_dev->parent) | ||
128 | device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST); | ||
129 | |||
130 | /* close the dlc */ | ||
131 | rfcomm_dlc_close(dev->dlc, 0); | ||
132 | } | ||
133 | |||
115 | static const struct tty_port_operations rfcomm_port_ops = { | 134 | static const struct tty_port_operations rfcomm_port_ops = { |
116 | .destruct = rfcomm_dev_destruct, | 135 | .destruct = rfcomm_dev_destruct, |
136 | .activate = rfcomm_dev_activate, | ||
137 | .shutdown = rfcomm_dev_shutdown, | ||
138 | .carrier_raised = rfcomm_dev_carrier_raised, | ||
117 | }; | 139 | }; |
118 | 140 | ||
119 | static struct rfcomm_dev *__rfcomm_dev_get(int id) | 141 | static struct rfcomm_dev *__rfcomm_dev_get(int id) |
@@ -236,7 +258,6 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | |||
236 | 258 | ||
237 | tty_port_init(&dev->port); | 259 | tty_port_init(&dev->port); |
238 | dev->port.ops = &rfcomm_port_ops; | 260 | dev->port.ops = &rfcomm_port_ops; |
239 | init_waitqueue_head(&dev->wait); | ||
240 | 261 | ||
241 | skb_queue_head_init(&dev->pending); | 262 | skb_queue_head_init(&dev->pending); |
242 | 263 | ||
@@ -282,7 +303,9 @@ out: | |||
282 | dev->id, NULL); | 303 | dev->id, NULL); |
283 | if (IS_ERR(dev->tty_dev)) { | 304 | if (IS_ERR(dev->tty_dev)) { |
284 | err = PTR_ERR(dev->tty_dev); | 305 | err = PTR_ERR(dev->tty_dev); |
306 | spin_lock(&rfcomm_dev_lock); | ||
285 | list_del(&dev->list); | 307 | list_del(&dev->list); |
308 | spin_unlock(&rfcomm_dev_lock); | ||
286 | goto free; | 309 | goto free; |
287 | } | 310 | } |
288 | 311 | ||
@@ -301,27 +324,6 @@ free: | |||
301 | return err; | 324 | return err; |
302 | } | 325 | } |
303 | 326 | ||
304 | static void rfcomm_dev_del(struct rfcomm_dev *dev) | ||
305 | { | ||
306 | unsigned long flags; | ||
307 | BT_DBG("dev %p", dev); | ||
308 | |||
309 | BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags)); | ||
310 | |||
311 | spin_lock_irqsave(&dev->port.lock, flags); | ||
312 | if (dev->port.count > 0) { | ||
313 | spin_unlock_irqrestore(&dev->port.lock, flags); | ||
314 | return; | ||
315 | } | ||
316 | spin_unlock_irqrestore(&dev->port.lock, flags); | ||
317 | |||
318 | spin_lock(&rfcomm_dev_lock); | ||
319 | list_del_init(&dev->list); | ||
320 | spin_unlock(&rfcomm_dev_lock); | ||
321 | |||
322 | tty_port_put(&dev->port); | ||
323 | } | ||
324 | |||
325 | /* ---- Send buffer ---- */ | 327 | /* ---- Send buffer ---- */ |
326 | static inline unsigned int rfcomm_room(struct rfcomm_dlc *dlc) | 328 | static inline unsigned int rfcomm_room(struct rfcomm_dlc *dlc) |
327 | { | 329 | { |
@@ -333,10 +335,9 @@ static inline unsigned int rfcomm_room(struct rfcomm_dlc *dlc) | |||
333 | static void rfcomm_wfree(struct sk_buff *skb) | 335 | static void rfcomm_wfree(struct sk_buff *skb) |
334 | { | 336 | { |
335 | struct rfcomm_dev *dev = (void *) skb->sk; | 337 | struct rfcomm_dev *dev = (void *) skb->sk; |
336 | struct tty_struct *tty = dev->port.tty; | ||
337 | atomic_sub(skb->truesize, &dev->wmem_alloc); | 338 | atomic_sub(skb->truesize, &dev->wmem_alloc); |
338 | if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags) && tty) | 339 | if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags)) |
339 | tty_wakeup(tty); | 340 | tty_port_tty_wakeup(&dev->port); |
340 | tty_port_put(&dev->port); | 341 | tty_port_put(&dev->port); |
341 | } | 342 | } |
342 | 343 | ||
@@ -410,6 +411,7 @@ static int rfcomm_release_dev(void __user *arg) | |||
410 | { | 411 | { |
411 | struct rfcomm_dev_req req; | 412 | struct rfcomm_dev_req req; |
412 | struct rfcomm_dev *dev; | 413 | struct rfcomm_dev *dev; |
414 | struct tty_struct *tty; | ||
413 | 415 | ||
414 | if (copy_from_user(&req, arg, sizeof(req))) | 416 | if (copy_from_user(&req, arg, sizeof(req))) |
415 | return -EFAULT; | 417 | return -EFAULT; |
@@ -429,11 +431,15 @@ static int rfcomm_release_dev(void __user *arg) | |||
429 | rfcomm_dlc_close(dev->dlc, 0); | 431 | rfcomm_dlc_close(dev->dlc, 0); |
430 | 432 | ||
431 | /* Shut down TTY synchronously before freeing rfcomm_dev */ | 433 | /* Shut down TTY synchronously before freeing rfcomm_dev */ |
432 | if (dev->port.tty) | 434 | tty = tty_port_tty_get(&dev->port); |
433 | tty_vhangup(dev->port.tty); | 435 | if (tty) { |
436 | tty_vhangup(tty); | ||
437 | tty_kref_put(tty); | ||
438 | } | ||
439 | |||
440 | if (!test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags)) | ||
441 | tty_port_put(&dev->port); | ||
434 | 442 | ||
435 | if (!test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) | ||
436 | rfcomm_dev_del(dev); | ||
437 | tty_port_put(&dev->port); | 443 | tty_port_put(&dev->port); |
438 | return 0; | 444 | return 0; |
439 | } | 445 | } |
@@ -563,16 +569,21 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) | |||
563 | static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) | 569 | static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) |
564 | { | 570 | { |
565 | struct rfcomm_dev *dev = dlc->owner; | 571 | struct rfcomm_dev *dev = dlc->owner; |
572 | struct tty_struct *tty; | ||
566 | if (!dev) | 573 | if (!dev) |
567 | return; | 574 | return; |
568 | 575 | ||
569 | BT_DBG("dlc %p dev %p err %d", dlc, dev, err); | 576 | BT_DBG("dlc %p dev %p err %d", dlc, dev, err); |
570 | 577 | ||
571 | dev->err = err; | 578 | dev->err = err; |
572 | wake_up_interruptible(&dev->wait); | 579 | if (dlc->state == BT_CONNECTED) { |
580 | device_move(dev->tty_dev, rfcomm_get_device(dev), | ||
581 | DPM_ORDER_DEV_AFTER_PARENT); | ||
573 | 582 | ||
574 | if (dlc->state == BT_CLOSED) { | 583 | wake_up_interruptible(&dev->port.open_wait); |
575 | if (!dev->port.tty) { | 584 | } else if (dlc->state == BT_CLOSED) { |
585 | tty = tty_port_tty_get(&dev->port); | ||
586 | if (!tty) { | ||
576 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { | 587 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { |
577 | /* Drop DLC lock here to avoid deadlock | 588 | /* Drop DLC lock here to avoid deadlock |
578 | * 1. rfcomm_dev_get will take rfcomm_dev_lock | 589 | * 1. rfcomm_dev_get will take rfcomm_dev_lock |
@@ -580,6 +591,9 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) | |||
580 | * rfcomm_dev_lock -> dlc lock | 591 | * rfcomm_dev_lock -> dlc lock |
581 | * 2. tty_port_put will deadlock if it's | 592 | * 2. tty_port_put will deadlock if it's |
582 | * the last reference | 593 | * the last reference |
594 | * | ||
595 | * FIXME: when we release the lock anything | ||
596 | * could happen to dev, even its destruction | ||
583 | */ | 597 | */ |
584 | rfcomm_dlc_unlock(dlc); | 598 | rfcomm_dlc_unlock(dlc); |
585 | if (rfcomm_dev_get(dev->id) == NULL) { | 599 | if (rfcomm_dev_get(dev->id) == NULL) { |
@@ -587,12 +601,17 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) | |||
587 | return; | 601 | return; |
588 | } | 602 | } |
589 | 603 | ||
590 | rfcomm_dev_del(dev); | 604 | if (!test_and_set_bit(RFCOMM_TTY_RELEASED, |
605 | &dev->flags)) | ||
606 | tty_port_put(&dev->port); | ||
607 | |||
591 | tty_port_put(&dev->port); | 608 | tty_port_put(&dev->port); |
592 | rfcomm_dlc_lock(dlc); | 609 | rfcomm_dlc_lock(dlc); |
593 | } | 610 | } |
594 | } else | 611 | } else { |
595 | tty_hangup(dev->port.tty); | 612 | tty_hangup(tty); |
613 | tty_kref_put(tty); | ||
614 | } | ||
596 | } | 615 | } |
597 | } | 616 | } |
598 | 617 | ||
@@ -604,10 +623,8 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig) | |||
604 | 623 | ||
605 | BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig); | 624 | BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig); |
606 | 625 | ||
607 | if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) { | 626 | if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) |
608 | if (dev->port.tty && !C_CLOCAL(dev->port.tty)) | 627 | tty_port_tty_hangup(&dev->port, true); |
609 | tty_hangup(dev->port.tty); | ||
610 | } | ||
611 | 628 | ||
612 | dev->modem_status = | 629 | dev->modem_status = |
613 | ((v24_sig & RFCOMM_V24_RTC) ? (TIOCM_DSR | TIOCM_DTR) : 0) | | 630 | ((v24_sig & RFCOMM_V24_RTC) ? (TIOCM_DSR | TIOCM_DTR) : 0) | |
@@ -638,124 +655,92 @@ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) | |||
638 | tty_flip_buffer_push(&dev->port); | 655 | tty_flip_buffer_push(&dev->port); |
639 | } | 656 | } |
640 | 657 | ||
641 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | 658 | /* do the reverse of install, clearing the tty fields and releasing the |
659 | * reference to tty_port | ||
660 | */ | ||
661 | static void rfcomm_tty_cleanup(struct tty_struct *tty) | ||
642 | { | 662 | { |
643 | DECLARE_WAITQUEUE(wait, current); | 663 | struct rfcomm_dev *dev = tty->driver_data; |
644 | struct rfcomm_dev *dev; | ||
645 | struct rfcomm_dlc *dlc; | ||
646 | unsigned long flags; | ||
647 | int err, id; | ||
648 | 664 | ||
649 | id = tty->index; | 665 | clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); |
650 | 666 | ||
651 | BT_DBG("tty %p id %d", tty, id); | 667 | rfcomm_dlc_lock(dev->dlc); |
668 | tty->driver_data = NULL; | ||
669 | rfcomm_dlc_unlock(dev->dlc); | ||
652 | 670 | ||
653 | /* We don't leak this refcount. For reasons which are not entirely | 671 | /* |
654 | clear, the TTY layer will call our ->close() method even if the | 672 | * purge the dlc->tx_queue to avoid circular dependencies |
655 | open fails. We decrease the refcount there, and decreasing it | 673 | * between dev and dlc |
656 | here too would cause breakage. */ | 674 | */ |
657 | dev = rfcomm_dev_get(id); | 675 | skb_queue_purge(&dev->dlc->tx_queue); |
658 | if (!dev) | ||
659 | return -ENODEV; | ||
660 | 676 | ||
661 | BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, | 677 | tty_port_put(&dev->port); |
662 | dev->channel, dev->port.count); | 678 | } |
663 | 679 | ||
664 | spin_lock_irqsave(&dev->port.lock, flags); | 680 | /* we acquire the tty_port reference since it's here the tty is first used |
665 | if (++dev->port.count > 1) { | 681 | * by setting the termios. We also populate the driver_data field and install |
666 | spin_unlock_irqrestore(&dev->port.lock, flags); | 682 | * the tty port |
667 | return 0; | 683 | */ |
668 | } | 684 | static int rfcomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) |
669 | spin_unlock_irqrestore(&dev->port.lock, flags); | 685 | { |
686 | struct rfcomm_dev *dev; | ||
687 | struct rfcomm_dlc *dlc; | ||
688 | int err; | ||
689 | |||
690 | dev = rfcomm_dev_get(tty->index); | ||
691 | if (!dev) | ||
692 | return -ENODEV; | ||
670 | 693 | ||
671 | dlc = dev->dlc; | 694 | dlc = dev->dlc; |
672 | 695 | ||
673 | /* Attach TTY and open DLC */ | 696 | /* Attach TTY and open DLC */ |
674 | |||
675 | rfcomm_dlc_lock(dlc); | 697 | rfcomm_dlc_lock(dlc); |
676 | tty->driver_data = dev; | 698 | tty->driver_data = dev; |
677 | dev->port.tty = tty; | ||
678 | rfcomm_dlc_unlock(dlc); | 699 | rfcomm_dlc_unlock(dlc); |
679 | set_bit(RFCOMM_TTY_ATTACHED, &dev->flags); | 700 | set_bit(RFCOMM_TTY_ATTACHED, &dev->flags); |
680 | 701 | ||
681 | err = rfcomm_dlc_open(dlc, &dev->src, &dev->dst, dev->channel); | 702 | /* install the tty_port */ |
682 | if (err < 0) | 703 | err = tty_port_install(&dev->port, driver, tty); |
683 | return err; | 704 | if (err) |
684 | 705 | rfcomm_tty_cleanup(tty); | |
685 | /* Wait for DLC to connect */ | ||
686 | add_wait_queue(&dev->wait, &wait); | ||
687 | while (1) { | ||
688 | set_current_state(TASK_INTERRUPTIBLE); | ||
689 | 706 | ||
690 | if (dlc->state == BT_CLOSED) { | 707 | return err; |
691 | err = -dev->err; | 708 | } |
692 | break; | ||
693 | } | ||
694 | 709 | ||
695 | if (dlc->state == BT_CONNECTED) | 710 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) |
696 | break; | 711 | { |
712 | struct rfcomm_dev *dev = tty->driver_data; | ||
713 | int err; | ||
697 | 714 | ||
698 | if (signal_pending(current)) { | 715 | BT_DBG("tty %p id %d", tty, tty->index); |
699 | err = -EINTR; | ||
700 | break; | ||
701 | } | ||
702 | 716 | ||
703 | tty_unlock(tty); | 717 | BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, |
704 | schedule(); | 718 | dev->channel, dev->port.count); |
705 | tty_lock(tty); | ||
706 | } | ||
707 | set_current_state(TASK_RUNNING); | ||
708 | remove_wait_queue(&dev->wait, &wait); | ||
709 | 719 | ||
710 | if (err == 0) | 720 | err = tty_port_open(&dev->port, tty, filp); |
711 | device_move(dev->tty_dev, rfcomm_get_device(dev), | 721 | if (err) |
712 | DPM_ORDER_DEV_AFTER_PARENT); | 722 | return err; |
713 | 723 | ||
724 | /* | ||
725 | * FIXME: rfcomm should use proper flow control for | ||
726 | * received data. This hack will be unnecessary and can | ||
727 | * be removed when that's implemented | ||
728 | */ | ||
714 | rfcomm_tty_copy_pending(dev); | 729 | rfcomm_tty_copy_pending(dev); |
715 | 730 | ||
716 | rfcomm_dlc_unthrottle(dev->dlc); | 731 | rfcomm_dlc_unthrottle(dev->dlc); |
717 | 732 | ||
718 | return err; | 733 | return 0; |
719 | } | 734 | } |
720 | 735 | ||
721 | static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) | 736 | static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) |
722 | { | 737 | { |
723 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; | 738 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; |
724 | unsigned long flags; | ||
725 | |||
726 | if (!dev) | ||
727 | return; | ||
728 | 739 | ||
729 | BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, | 740 | BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, |
730 | dev->port.count); | 741 | dev->port.count); |
731 | 742 | ||
732 | spin_lock_irqsave(&dev->port.lock, flags); | 743 | tty_port_close(&dev->port, tty, filp); |
733 | if (!--dev->port.count) { | ||
734 | spin_unlock_irqrestore(&dev->port.lock, flags); | ||
735 | if (dev->tty_dev->parent) | ||
736 | device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST); | ||
737 | |||
738 | /* Close DLC and dettach TTY */ | ||
739 | rfcomm_dlc_close(dev->dlc, 0); | ||
740 | |||
741 | clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); | ||
742 | |||
743 | rfcomm_dlc_lock(dev->dlc); | ||
744 | tty->driver_data = NULL; | ||
745 | dev->port.tty = NULL; | ||
746 | rfcomm_dlc_unlock(dev->dlc); | ||
747 | |||
748 | if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) { | ||
749 | spin_lock(&rfcomm_dev_lock); | ||
750 | list_del_init(&dev->list); | ||
751 | spin_unlock(&rfcomm_dev_lock); | ||
752 | |||
753 | tty_port_put(&dev->port); | ||
754 | } | ||
755 | } else | ||
756 | spin_unlock_irqrestore(&dev->port.lock, flags); | ||
757 | |||
758 | tty_port_put(&dev->port); | ||
759 | } | 744 | } |
760 | 745 | ||
761 | static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) | 746 | static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) |
@@ -1055,17 +1040,11 @@ static void rfcomm_tty_hangup(struct tty_struct *tty) | |||
1055 | 1040 | ||
1056 | BT_DBG("tty %p dev %p", tty, dev); | 1041 | BT_DBG("tty %p dev %p", tty, dev); |
1057 | 1042 | ||
1058 | if (!dev) | 1043 | tty_port_hangup(&dev->port); |
1059 | return; | ||
1060 | |||
1061 | rfcomm_tty_flush_buffer(tty); | ||
1062 | 1044 | ||
1063 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { | 1045 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags) && |
1064 | if (rfcomm_dev_get(dev->id) == NULL) | 1046 | !test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags)) |
1065 | return; | ||
1066 | rfcomm_dev_del(dev); | ||
1067 | tty_port_put(&dev->port); | 1047 | tty_port_put(&dev->port); |
1068 | } | ||
1069 | } | 1048 | } |
1070 | 1049 | ||
1071 | static int rfcomm_tty_tiocmget(struct tty_struct *tty) | 1050 | static int rfcomm_tty_tiocmget(struct tty_struct *tty) |
@@ -1128,6 +1107,8 @@ static const struct tty_operations rfcomm_ops = { | |||
1128 | .wait_until_sent = rfcomm_tty_wait_until_sent, | 1107 | .wait_until_sent = rfcomm_tty_wait_until_sent, |
1129 | .tiocmget = rfcomm_tty_tiocmget, | 1108 | .tiocmget = rfcomm_tty_tiocmget, |
1130 | .tiocmset = rfcomm_tty_tiocmset, | 1109 | .tiocmset = rfcomm_tty_tiocmset, |
1110 | .install = rfcomm_tty_install, | ||
1111 | .cleanup = rfcomm_tty_cleanup, | ||
1131 | }; | 1112 | }; |
1132 | 1113 | ||
1133 | int __init rfcomm_init_ttys(void) | 1114 | int __init rfcomm_init_ttys(void) |
@@ -1146,7 +1127,7 @@ int __init rfcomm_init_ttys(void) | |||
1146 | rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; | 1127 | rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; |
1147 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | 1128 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
1148 | rfcomm_tty_driver->init_termios = tty_std_termios; | 1129 | rfcomm_tty_driver->init_termios = tty_std_termios; |
1149 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 1130 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; |
1150 | rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; | 1131 | rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; |
1151 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); | 1132 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); |
1152 | 1133 | ||
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index e7bd4eea575c..96bd388d93a4 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -176,8 +176,13 @@ static int sco_connect(struct sock *sk) | |||
176 | else | 176 | else |
177 | type = SCO_LINK; | 177 | type = SCO_LINK; |
178 | 178 | ||
179 | hcon = hci_connect(hdev, type, dst, BDADDR_BREDR, BT_SECURITY_LOW, | 179 | if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT && |
180 | HCI_AT_NO_BONDING); | 180 | (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) { |
181 | err = -EOPNOTSUPP; | ||
182 | goto done; | ||
183 | } | ||
184 | |||
185 | hcon = hci_connect_sco(hdev, type, dst, sco_pi(sk)->setting); | ||
181 | if (IS_ERR(hcon)) { | 186 | if (IS_ERR(hcon)) { |
182 | err = PTR_ERR(hcon); | 187 | err = PTR_ERR(hcon); |
183 | goto done; | 188 | goto done; |
@@ -417,6 +422,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro | |||
417 | sk->sk_protocol = proto; | 422 | sk->sk_protocol = proto; |
418 | sk->sk_state = BT_OPEN; | 423 | sk->sk_state = BT_OPEN; |
419 | 424 | ||
425 | sco_pi(sk)->setting = BT_VOICE_CVSD_16BIT; | ||
426 | |||
420 | setup_timer(&sk->sk_timer, sco_sock_timeout, (unsigned long)sk); | 427 | setup_timer(&sk->sk_timer, sco_sock_timeout, (unsigned long)sk); |
421 | 428 | ||
422 | bt_sock_link(&sco_sk_list, sk); | 429 | bt_sock_link(&sco_sk_list, sk); |
@@ -652,7 +659,7 @@ static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
652 | return err; | 659 | return err; |
653 | } | 660 | } |
654 | 661 | ||
655 | static void sco_conn_defer_accept(struct hci_conn *conn, int mask) | 662 | static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting) |
656 | { | 663 | { |
657 | struct hci_dev *hdev = conn->hdev; | 664 | struct hci_dev *hdev = conn->hdev; |
658 | 665 | ||
@@ -664,11 +671,7 @@ static void sco_conn_defer_accept(struct hci_conn *conn, int mask) | |||
664 | struct hci_cp_accept_conn_req cp; | 671 | struct hci_cp_accept_conn_req cp; |
665 | 672 | ||
666 | bacpy(&cp.bdaddr, &conn->dst); | 673 | bacpy(&cp.bdaddr, &conn->dst); |
667 | 674 | cp.role = 0x00; /* Ignored */ | |
668 | if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) | ||
669 | cp.role = 0x00; /* Become master */ | ||
670 | else | ||
671 | cp.role = 0x01; /* Remain slave */ | ||
672 | 675 | ||
673 | hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); | 676 | hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); |
674 | } else { | 677 | } else { |
@@ -679,9 +682,21 @@ static void sco_conn_defer_accept(struct hci_conn *conn, int mask) | |||
679 | 682 | ||
680 | cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40); | 683 | cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40); |
681 | cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40); | 684 | cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40); |
682 | cp.max_latency = __constant_cpu_to_le16(0xffff); | 685 | cp.content_format = cpu_to_le16(setting); |
683 | cp.content_format = cpu_to_le16(hdev->voice_setting); | 686 | |
684 | cp.retrans_effort = 0xff; | 687 | switch (setting & SCO_AIRMODE_MASK) { |
688 | case SCO_AIRMODE_TRANSP: | ||
689 | if (conn->pkt_type & ESCO_2EV3) | ||
690 | cp.max_latency = __constant_cpu_to_le16(0x0008); | ||
691 | else | ||
692 | cp.max_latency = __constant_cpu_to_le16(0x000D); | ||
693 | cp.retrans_effort = 0x02; | ||
694 | break; | ||
695 | case SCO_AIRMODE_CVSD: | ||
696 | cp.max_latency = __constant_cpu_to_le16(0xffff); | ||
697 | cp.retrans_effort = 0xff; | ||
698 | break; | ||
699 | } | ||
685 | 700 | ||
686 | hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, | 701 | hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, |
687 | sizeof(cp), &cp); | 702 | sizeof(cp), &cp); |
@@ -698,7 +713,7 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
698 | 713 | ||
699 | if (sk->sk_state == BT_CONNECT2 && | 714 | if (sk->sk_state == BT_CONNECT2 && |
700 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { | 715 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { |
701 | sco_conn_defer_accept(pi->conn->hcon, 0); | 716 | sco_conn_defer_accept(pi->conn->hcon, pi->setting); |
702 | sk->sk_state = BT_CONFIG; | 717 | sk->sk_state = BT_CONFIG; |
703 | msg->msg_namelen = 0; | 718 | msg->msg_namelen = 0; |
704 | 719 | ||
@@ -714,7 +729,8 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
714 | static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) | 729 | static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) |
715 | { | 730 | { |
716 | struct sock *sk = sock->sk; | 731 | struct sock *sk = sock->sk; |
717 | int err = 0; | 732 | int len, err = 0; |
733 | struct bt_voice voice; | ||
718 | u32 opt; | 734 | u32 opt; |
719 | 735 | ||
720 | BT_DBG("sk %p", sk); | 736 | BT_DBG("sk %p", sk); |
@@ -740,6 +756,31 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char | |||
740 | clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); | 756 | clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); |
741 | break; | 757 | break; |
742 | 758 | ||
759 | case BT_VOICE: | ||
760 | if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND && | ||
761 | sk->sk_state != BT_CONNECT2) { | ||
762 | err = -EINVAL; | ||
763 | break; | ||
764 | } | ||
765 | |||
766 | voice.setting = sco_pi(sk)->setting; | ||
767 | |||
768 | len = min_t(unsigned int, sizeof(voice), optlen); | ||
769 | if (copy_from_user((char *) &voice, optval, len)) { | ||
770 | err = -EFAULT; | ||
771 | break; | ||
772 | } | ||
773 | |||
774 | /* Explicitly check for these values */ | ||
775 | if (voice.setting != BT_VOICE_TRANSPARENT && | ||
776 | voice.setting != BT_VOICE_CVSD_16BIT) { | ||
777 | err = -EINVAL; | ||
778 | break; | ||
779 | } | ||
780 | |||
781 | sco_pi(sk)->setting = voice.setting; | ||
782 | break; | ||
783 | |||
743 | default: | 784 | default: |
744 | err = -ENOPROTOOPT; | 785 | err = -ENOPROTOOPT; |
745 | break; | 786 | break; |
@@ -765,7 +806,9 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user | |||
765 | 806 | ||
766 | switch (optname) { | 807 | switch (optname) { |
767 | case SCO_OPTIONS: | 808 | case SCO_OPTIONS: |
768 | if (sk->sk_state != BT_CONNECTED) { | 809 | if (sk->sk_state != BT_CONNECTED && |
810 | !(sk->sk_state == BT_CONNECT2 && | ||
811 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))) { | ||
769 | err = -ENOTCONN; | 812 | err = -ENOTCONN; |
770 | break; | 813 | break; |
771 | } | 814 | } |
@@ -781,7 +824,9 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user | |||
781 | break; | 824 | break; |
782 | 825 | ||
783 | case SCO_CONNINFO: | 826 | case SCO_CONNINFO: |
784 | if (sk->sk_state != BT_CONNECTED) { | 827 | if (sk->sk_state != BT_CONNECTED && |
828 | !(sk->sk_state == BT_CONNECT2 && | ||
829 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))) { | ||
785 | err = -ENOTCONN; | 830 | err = -ENOTCONN; |
786 | break; | 831 | break; |
787 | } | 832 | } |
@@ -809,6 +854,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char | |||
809 | { | 854 | { |
810 | struct sock *sk = sock->sk; | 855 | struct sock *sk = sock->sk; |
811 | int len, err = 0; | 856 | int len, err = 0; |
857 | struct bt_voice voice; | ||
812 | 858 | ||
813 | BT_DBG("sk %p", sk); | 859 | BT_DBG("sk %p", sk); |
814 | 860 | ||
@@ -834,6 +880,15 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char | |||
834 | 880 | ||
835 | break; | 881 | break; |
836 | 882 | ||
883 | case BT_VOICE: | ||
884 | voice.setting = sco_pi(sk)->setting; | ||
885 | |||
886 | len = min_t(unsigned int, len, sizeof(voice)); | ||
887 | if (copy_to_user(optval, (char *)&voice, len)) | ||
888 | err = -EFAULT; | ||
889 | |||
890 | break; | ||
891 | |||
837 | default: | 892 | default: |
838 | err = -ENOPROTOOPT; | 893 | err = -ENOPROTOOPT; |
839 | break; | 894 | break; |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 7aa38ce0b524..2e7855a1b10d 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -672,6 +672,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy, | |||
672 | if (sta->sdata->dev != dev) | 672 | if (sta->sdata->dev != dev) |
673 | continue; | 673 | continue; |
674 | 674 | ||
675 | sinfo.filled = 0; | ||
676 | sta_set_sinfo(sta, &sinfo); | ||
675 | i = 0; | 677 | i = 0; |
676 | ADD_STA_STATS(sta); | 678 | ADD_STA_STATS(sta); |
677 | } | 679 | } |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 74de0f10558a..a12afe77bb26 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -201,7 +201,7 @@ error: | |||
201 | 201 | ||
202 | static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | 202 | static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, |
203 | const u8 *bssid, const int beacon_int, | 203 | const u8 *bssid, const int beacon_int, |
204 | struct ieee80211_channel *chan, | 204 | struct cfg80211_chan_def *req_chandef, |
205 | const u32 basic_rates, | 205 | const u32 basic_rates, |
206 | const u16 capability, u64 tsf, | 206 | const u16 capability, u64 tsf, |
207 | bool creator) | 207 | bool creator) |
@@ -213,6 +213,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
213 | struct cfg80211_bss *bss; | 213 | struct cfg80211_bss *bss; |
214 | u32 bss_change; | 214 | u32 bss_change; |
215 | struct cfg80211_chan_def chandef; | 215 | struct cfg80211_chan_def chandef; |
216 | struct ieee80211_channel *chan; | ||
216 | struct beacon_data *presp; | 217 | struct beacon_data *presp; |
217 | enum nl80211_bss_scan_width scan_width; | 218 | enum nl80211_bss_scan_width scan_width; |
218 | bool have_higher_than_11mbit; | 219 | bool have_higher_than_11mbit; |
@@ -244,7 +245,9 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
244 | 245 | ||
245 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; | 246 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; |
246 | 247 | ||
247 | chandef = ifibss->chandef; | 248 | /* make a copy of the chandef, it could be modified below. */ |
249 | chandef = *req_chandef; | ||
250 | chan = chandef.chan; | ||
248 | if (!cfg80211_reg_can_beacon(local->hw.wiphy, &chandef)) { | 251 | if (!cfg80211_reg_can_beacon(local->hw.wiphy, &chandef)) { |
249 | if (chandef.width == NL80211_CHAN_WIDTH_5 || | 252 | if (chandef.width == NL80211_CHAN_WIDTH_5 || |
250 | chandef.width == NL80211_CHAN_WIDTH_10 || | 253 | chandef.width == NL80211_CHAN_WIDTH_10 || |
@@ -339,10 +342,12 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
339 | struct cfg80211_bss *cbss = | 342 | struct cfg80211_bss *cbss = |
340 | container_of((void *)bss, struct cfg80211_bss, priv); | 343 | container_of((void *)bss, struct cfg80211_bss, priv); |
341 | struct ieee80211_supported_band *sband; | 344 | struct ieee80211_supported_band *sband; |
345 | struct cfg80211_chan_def chandef; | ||
342 | u32 basic_rates; | 346 | u32 basic_rates; |
343 | int i, j; | 347 | int i, j; |
344 | u16 beacon_int = cbss->beacon_interval; | 348 | u16 beacon_int = cbss->beacon_interval; |
345 | const struct cfg80211_bss_ies *ies; | 349 | const struct cfg80211_bss_ies *ies; |
350 | enum nl80211_channel_type chan_type; | ||
346 | u64 tsf; | 351 | u64 tsf; |
347 | u32 rate_flags; | 352 | u32 rate_flags; |
348 | int shift; | 353 | int shift; |
@@ -352,6 +357,26 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
352 | if (beacon_int < 10) | 357 | if (beacon_int < 10) |
353 | beacon_int = 10; | 358 | beacon_int = 10; |
354 | 359 | ||
360 | switch (sdata->u.ibss.chandef.width) { | ||
361 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
362 | case NL80211_CHAN_WIDTH_20: | ||
363 | case NL80211_CHAN_WIDTH_40: | ||
364 | chan_type = cfg80211_get_chandef_type(&sdata->u.ibss.chandef); | ||
365 | cfg80211_chandef_create(&chandef, cbss->channel, chan_type); | ||
366 | break; | ||
367 | case NL80211_CHAN_WIDTH_5: | ||
368 | case NL80211_CHAN_WIDTH_10: | ||
369 | cfg80211_chandef_create(&chandef, cbss->channel, | ||
370 | NL80211_CHAN_WIDTH_20_NOHT); | ||
371 | chandef.width = sdata->u.ibss.chandef.width; | ||
372 | break; | ||
373 | default: | ||
374 | /* fall back to 20 MHz for unsupported modes */ | ||
375 | cfg80211_chandef_create(&chandef, cbss->channel, | ||
376 | NL80211_CHAN_WIDTH_20_NOHT); | ||
377 | break; | ||
378 | } | ||
379 | |||
355 | sband = sdata->local->hw.wiphy->bands[cbss->channel->band]; | 380 | sband = sdata->local->hw.wiphy->bands[cbss->channel->band]; |
356 | rate_flags = ieee80211_chandef_rate_flags(&sdata->u.ibss.chandef); | 381 | rate_flags = ieee80211_chandef_rate_flags(&sdata->u.ibss.chandef); |
357 | shift = ieee80211_vif_get_shift(&sdata->vif); | 382 | shift = ieee80211_vif_get_shift(&sdata->vif); |
@@ -385,7 +410,7 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
385 | 410 | ||
386 | __ieee80211_sta_join_ibss(sdata, cbss->bssid, | 411 | __ieee80211_sta_join_ibss(sdata, cbss->bssid, |
387 | beacon_int, | 412 | beacon_int, |
388 | cbss->channel, | 413 | &chandef, |
389 | basic_rates, | 414 | basic_rates, |
390 | cbss->capability, | 415 | cbss->capability, |
391 | tsf, false); | 416 | tsf, false); |
@@ -867,7 +892,7 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) | |||
867 | sdata->drop_unencrypted = 0; | 892 | sdata->drop_unencrypted = 0; |
868 | 893 | ||
869 | __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, | 894 | __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, |
870 | ifibss->chandef.chan, ifibss->basic_rates, | 895 | &ifibss->chandef, ifibss->basic_rates, |
871 | capability, 0, true); | 896 | capability, 0, true); |
872 | } | 897 | } |
873 | 898 | ||
@@ -1304,6 +1329,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | |||
1304 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); | 1329 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
1305 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | | 1330 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
1306 | BSS_CHANGED_IBSS); | 1331 | BSS_CHANGED_IBSS); |
1332 | ieee80211_vif_release_channel(sdata); | ||
1307 | synchronize_rcu(); | 1333 | synchronize_rcu(); |
1308 | kfree(presp); | 1334 | kfree(presp); |
1309 | 1335 | ||
diff --git a/net/mac80211/mesh_ps.c b/net/mac80211/mesh_ps.c index 3b7bfc01ee36..22290a929b94 100644 --- a/net/mac80211/mesh_ps.c +++ b/net/mac80211/mesh_ps.c | |||
@@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(struct sta_info *sta) | |||
229 | enum nl80211_mesh_power_mode pm; | 229 | enum nl80211_mesh_power_mode pm; |
230 | bool do_buffer; | 230 | bool do_buffer; |
231 | 231 | ||
232 | /* For non-assoc STA, prevent buffering or frame transmission */ | ||
233 | if (sta->sta_state < IEEE80211_STA_ASSOC) | ||
234 | return; | ||
235 | |||
232 | /* | 236 | /* |
233 | * use peer-specific power mode if peering is established and the | 237 | * use peer-specific power mode if peering is established and the |
234 | * peer's power mode is known | 238 | * peer's power mode is known |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 45a87ee3f124..86e4ad56b573 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -31,10 +31,12 @@ | |||
31 | #include "led.h" | 31 | #include "led.h" |
32 | 32 | ||
33 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) | 33 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) |
34 | #define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2) | ||
34 | #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10) | 35 | #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10) |
35 | #define IEEE80211_AUTH_MAX_TRIES 3 | 36 | #define IEEE80211_AUTH_MAX_TRIES 3 |
36 | #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) | 37 | #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) |
37 | #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) | 38 | #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) |
39 | #define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2) | ||
38 | #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) | 40 | #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) |
39 | #define IEEE80211_ASSOC_MAX_TRIES 3 | 41 | #define IEEE80211_ASSOC_MAX_TRIES 3 |
40 | 42 | ||
@@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
209 | struct ieee80211_channel *channel, | 211 | struct ieee80211_channel *channel, |
210 | const struct ieee80211_ht_operation *ht_oper, | 212 | const struct ieee80211_ht_operation *ht_oper, |
211 | const struct ieee80211_vht_operation *vht_oper, | 213 | const struct ieee80211_vht_operation *vht_oper, |
212 | struct cfg80211_chan_def *chandef, bool verbose) | 214 | struct cfg80211_chan_def *chandef, bool tracking) |
213 | { | 215 | { |
216 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
214 | struct cfg80211_chan_def vht_chandef; | 217 | struct cfg80211_chan_def vht_chandef; |
215 | u32 ht_cfreq, ret; | 218 | u32 ht_cfreq, ret; |
216 | 219 | ||
@@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
229 | ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, | 232 | ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, |
230 | channel->band); | 233 | channel->band); |
231 | /* check that channel matches the right operating channel */ | 234 | /* check that channel matches the right operating channel */ |
232 | if (channel->center_freq != ht_cfreq) { | 235 | if (!tracking && channel->center_freq != ht_cfreq) { |
233 | /* | 236 | /* |
234 | * It's possible that some APs are confused here; | 237 | * It's possible that some APs are confused here; |
235 | * Netgear WNDR3700 sometimes reports 4 higher than | 238 | * Netgear WNDR3700 sometimes reports 4 higher than |
@@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
237 | * since we look at probe response/beacon data here | 240 | * since we look at probe response/beacon data here |
238 | * it should be OK. | 241 | * it should be OK. |
239 | */ | 242 | */ |
240 | if (verbose) | 243 | sdata_info(sdata, |
241 | sdata_info(sdata, | 244 | "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n", |
242 | "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n", | 245 | channel->center_freq, ht_cfreq, |
243 | channel->center_freq, ht_cfreq, | 246 | ht_oper->primary_chan, channel->band); |
244 | ht_oper->primary_chan, channel->band); | ||
245 | ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT; | 247 | ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT; |
246 | goto out; | 248 | goto out; |
247 | } | 249 | } |
@@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
295 | channel->band); | 297 | channel->band); |
296 | break; | 298 | break; |
297 | default: | 299 | default: |
298 | if (verbose) | 300 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) |
299 | sdata_info(sdata, | 301 | sdata_info(sdata, |
300 | "AP VHT operation IE has invalid channel width (%d), disable VHT\n", | 302 | "AP VHT operation IE has invalid channel width (%d), disable VHT\n", |
301 | vht_oper->chan_width); | 303 | vht_oper->chan_width); |
@@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
304 | } | 306 | } |
305 | 307 | ||
306 | if (!cfg80211_chandef_valid(&vht_chandef)) { | 308 | if (!cfg80211_chandef_valid(&vht_chandef)) { |
307 | if (verbose) | 309 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) |
308 | sdata_info(sdata, | 310 | sdata_info(sdata, |
309 | "AP VHT information is invalid, disable VHT\n"); | 311 | "AP VHT information is invalid, disable VHT\n"); |
310 | ret = IEEE80211_STA_DISABLE_VHT; | 312 | ret = IEEE80211_STA_DISABLE_VHT; |
@@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
317 | } | 319 | } |
318 | 320 | ||
319 | if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) { | 321 | if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) { |
320 | if (verbose) | 322 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) |
321 | sdata_info(sdata, | 323 | sdata_info(sdata, |
322 | "AP VHT information doesn't match HT, disable VHT\n"); | 324 | "AP VHT information doesn't match HT, disable VHT\n"); |
323 | ret = IEEE80211_STA_DISABLE_VHT; | 325 | ret = IEEE80211_STA_DISABLE_VHT; |
@@ -333,18 +335,27 @@ out: | |||
333 | if (ret & IEEE80211_STA_DISABLE_VHT) | 335 | if (ret & IEEE80211_STA_DISABLE_VHT) |
334 | vht_chandef = *chandef; | 336 | vht_chandef = *chandef; |
335 | 337 | ||
338 | /* | ||
339 | * Ignore the DISABLED flag when we're already connected and only | ||
340 | * tracking the APs beacon for bandwidth changes - otherwise we | ||
341 | * might get disconnected here if we connect to an AP, update our | ||
342 | * regulatory information based on the AP's country IE and the | ||
343 | * information we have is wrong/outdated and disables the channel | ||
344 | * that we're actually using for the connection to the AP. | ||
345 | */ | ||
336 | while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, | 346 | while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, |
337 | IEEE80211_CHAN_DISABLED)) { | 347 | tracking ? 0 : |
348 | IEEE80211_CHAN_DISABLED)) { | ||
338 | if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) { | 349 | if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) { |
339 | ret = IEEE80211_STA_DISABLE_HT | | 350 | ret = IEEE80211_STA_DISABLE_HT | |
340 | IEEE80211_STA_DISABLE_VHT; | 351 | IEEE80211_STA_DISABLE_VHT; |
341 | goto out; | 352 | break; |
342 | } | 353 | } |
343 | 354 | ||
344 | ret |= chandef_downgrade(chandef); | 355 | ret |= chandef_downgrade(chandef); |
345 | } | 356 | } |
346 | 357 | ||
347 | if (chandef->width != vht_chandef.width && verbose) | 358 | if (chandef->width != vht_chandef.width && !tracking) |
348 | sdata_info(sdata, | 359 | sdata_info(sdata, |
349 | "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n"); | 360 | "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n"); |
350 | 361 | ||
@@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ieee80211_sub_if_data *sdata, | |||
384 | 395 | ||
385 | /* calculate new channel (type) based on HT/VHT operation IEs */ | 396 | /* calculate new channel (type) based on HT/VHT operation IEs */ |
386 | flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper, | 397 | flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper, |
387 | vht_oper, &chandef, false); | 398 | vht_oper, &chandef, true); |
388 | 399 | ||
389 | /* | 400 | /* |
390 | * Downgrade the new channel if we associated with restricted | 401 | * Downgrade the new channel if we associated with restricted |
@@ -2850,14 +2861,6 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2850 | ieee80211_rx_bss_put(local, bss); | 2861 | ieee80211_rx_bss_put(local, bss); |
2851 | sdata->vif.bss_conf.beacon_rate = bss->beacon_rate; | 2862 | sdata->vif.bss_conf.beacon_rate = bss->beacon_rate; |
2852 | } | 2863 | } |
2853 | |||
2854 | if (!sdata->u.mgd.associated || | ||
2855 | !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) | ||
2856 | return; | ||
2857 | |||
2858 | ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, | ||
2859 | elems, true); | ||
2860 | |||
2861 | } | 2864 | } |
2862 | 2865 | ||
2863 | 2866 | ||
@@ -3146,6 +3149,9 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
3146 | 3149 | ||
3147 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); | 3150 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); |
3148 | 3151 | ||
3152 | ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, | ||
3153 | &elems, true); | ||
3154 | |||
3149 | if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, | 3155 | if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, |
3150 | elems.wmm_param_len)) | 3156 | elems.wmm_param_len)) |
3151 | changed |= BSS_CHANGED_QOS; | 3157 | changed |= BSS_CHANGED_QOS; |
@@ -3404,10 +3410,13 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) | |||
3404 | 3410 | ||
3405 | if (tx_flags == 0) { | 3411 | if (tx_flags == 0) { |
3406 | auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | 3412 | auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; |
3407 | ifmgd->auth_data->timeout_started = true; | 3413 | auth_data->timeout_started = true; |
3408 | run_again(sdata, auth_data->timeout); | 3414 | run_again(sdata, auth_data->timeout); |
3409 | } else { | 3415 | } else { |
3410 | auth_data->timeout_started = false; | 3416 | auth_data->timeout = |
3417 | round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG); | ||
3418 | auth_data->timeout_started = true; | ||
3419 | run_again(sdata, auth_data->timeout); | ||
3411 | } | 3420 | } |
3412 | 3421 | ||
3413 | return 0; | 3422 | return 0; |
@@ -3444,7 +3453,11 @@ static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata) | |||
3444 | assoc_data->timeout_started = true; | 3453 | assoc_data->timeout_started = true; |
3445 | run_again(sdata, assoc_data->timeout); | 3454 | run_again(sdata, assoc_data->timeout); |
3446 | } else { | 3455 | } else { |
3447 | assoc_data->timeout_started = false; | 3456 | assoc_data->timeout = |
3457 | round_jiffies_up(jiffies + | ||
3458 | IEEE80211_ASSOC_TIMEOUT_LONG); | ||
3459 | assoc_data->timeout_started = true; | ||
3460 | run_again(sdata, assoc_data->timeout); | ||
3448 | } | 3461 | } |
3449 | 3462 | ||
3450 | return 0; | 3463 | return 0; |
@@ -3839,7 +3852,7 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, | |||
3839 | ifmgd->flags |= ieee80211_determine_chantype(sdata, sband, | 3852 | ifmgd->flags |= ieee80211_determine_chantype(sdata, sband, |
3840 | cbss->channel, | 3853 | cbss->channel, |
3841 | ht_oper, vht_oper, | 3854 | ht_oper, vht_oper, |
3842 | &chandef, true); | 3855 | &chandef, false); |
3843 | 3856 | ||
3844 | sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss), | 3857 | sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss), |
3845 | local->rx_chains); | 3858 | local->rx_chains); |
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 7fc5d0d8149a..340126204343 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -99,10 +99,13 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
99 | } | 99 | } |
100 | mutex_unlock(&local->sta_mtx); | 100 | mutex_unlock(&local->sta_mtx); |
101 | 101 | ||
102 | /* remove all interfaces */ | 102 | /* remove all interfaces that were created in the driver */ |
103 | list_for_each_entry(sdata, &local->interfaces, list) { | 103 | list_for_each_entry(sdata, &local->interfaces, list) { |
104 | if (!ieee80211_sdata_running(sdata)) | 104 | if (!ieee80211_sdata_running(sdata) || |
105 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN || | ||
106 | sdata->vif.type == NL80211_IFTYPE_MONITOR) | ||
105 | continue; | 107 | continue; |
108 | |||
106 | drv_remove_interface(local, sdata); | 109 | drv_remove_interface(local, sdata); |
107 | } | 110 | } |
108 | 111 | ||
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index a507376d5316..8b5f7ef7c0c9 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c | |||
@@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, | |||
290 | struct minstrel_rate *msr, *mr; | 290 | struct minstrel_rate *msr, *mr; |
291 | unsigned int ndx; | 291 | unsigned int ndx; |
292 | bool mrr_capable; | 292 | bool mrr_capable; |
293 | bool prev_sample = mi->prev_sample; | 293 | bool prev_sample; |
294 | int delta; | 294 | int delta; |
295 | int sampling_ratio; | 295 | int sampling_ratio; |
296 | 296 | ||
@@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, | |||
314 | (mi->sample_count + mi->sample_deferred / 2); | 314 | (mi->sample_count + mi->sample_deferred / 2); |
315 | 315 | ||
316 | /* delta < 0: no sampling required */ | 316 | /* delta < 0: no sampling required */ |
317 | prev_sample = mi->prev_sample; | ||
317 | mi->prev_sample = false; | 318 | mi->prev_sample = false; |
318 | if (delta < 0 || (!mrr_capable && prev_sample)) | 319 | if (delta < 0 || (!mrr_capable && prev_sample)) |
319 | return; | 320 | return; |
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index c397ff54fe71..7c323f27ba23 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c | |||
@@ -804,10 +804,18 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, | |||
804 | 804 | ||
805 | sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES]; | 805 | sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES]; |
806 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | 806 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; |
807 | rate->count = 1; | ||
808 | |||
809 | if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { | ||
810 | int idx = sample_idx % ARRAY_SIZE(mp->cck_rates); | ||
811 | rate->idx = mp->cck_rates[idx]; | ||
812 | rate->flags = 0; | ||
813 | return; | ||
814 | } | ||
815 | |||
807 | rate->idx = sample_idx % MCS_GROUP_RATES + | 816 | rate->idx = sample_idx % MCS_GROUP_RATES + |
808 | (sample_group->streams - 1) * MCS_GROUP_RATES; | 817 | (sample_group->streams - 1) * MCS_GROUP_RATES; |
809 | rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags; | 818 | rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags; |
810 | rate->count = 1; | ||
811 | } | 819 | } |
812 | 820 | ||
813 | static void | 821 | static void |
@@ -820,6 +828,9 @@ minstrel_ht_update_cck(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, | |||
820 | if (sband->band != IEEE80211_BAND_2GHZ) | 828 | if (sband->band != IEEE80211_BAND_2GHZ) |
821 | return; | 829 | return; |
822 | 830 | ||
831 | if (!(mp->hw->flags & IEEE80211_HW_SUPPORTS_HT_CCK_RATES)) | ||
832 | return; | ||
833 | |||
823 | mi->cck_supported = 0; | 834 | mi->cck_supported = 0; |
824 | mi->cck_supported_short = 0; | 835 | mi->cck_supported_short = 0; |
825 | for (i = 0; i < 4; i++) { | 836 | for (i = 0; i < 4; i++) { |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 07901050812f..54395d7583ba 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -979,8 +979,14 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
979 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 979 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
980 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); | 980 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); |
981 | 981 | ||
982 | /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */ | 982 | /* |
983 | if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) { | 983 | * Drop duplicate 802.11 retransmissions |
984 | * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery") | ||
985 | */ | ||
986 | if (rx->skb->len >= 24 && rx->sta && | ||
987 | !ieee80211_is_ctl(hdr->frame_control) && | ||
988 | !ieee80211_is_qos_nullfunc(hdr->frame_control) && | ||
989 | !is_multicast_ether_addr(hdr->addr1)) { | ||
984 | if (unlikely(ieee80211_has_retry(hdr->frame_control) && | 990 | if (unlikely(ieee80211_has_retry(hdr->frame_control) && |
985 | rx->sta->last_seq_ctrl[rx->seqno_idx] == | 991 | rx->sta->last_seq_ctrl[rx->seqno_idx] == |
986 | hdr->seq_ctrl)) { | 992 | hdr->seq_ctrl)) { |
diff --git a/net/nfc/core.c b/net/nfc/core.c index dc96a83aa6ab..e92923cf3e03 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -44,7 +44,7 @@ DEFINE_MUTEX(nfc_devlist_mutex); | |||
44 | /* NFC device ID bitmap */ | 44 | /* NFC device ID bitmap */ |
45 | static DEFINE_IDA(nfc_index_ida); | 45 | static DEFINE_IDA(nfc_index_ida); |
46 | 46 | ||
47 | int nfc_fw_upload(struct nfc_dev *dev, const char *firmware_name) | 47 | int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name) |
48 | { | 48 | { |
49 | int rc = 0; | 49 | int rc = 0; |
50 | 50 | ||
@@ -62,28 +62,36 @@ int nfc_fw_upload(struct nfc_dev *dev, const char *firmware_name) | |||
62 | goto error; | 62 | goto error; |
63 | } | 63 | } |
64 | 64 | ||
65 | if (!dev->ops->fw_upload) { | 65 | if (!dev->ops->fw_download) { |
66 | rc = -EOPNOTSUPP; | 66 | rc = -EOPNOTSUPP; |
67 | goto error; | 67 | goto error; |
68 | } | 68 | } |
69 | 69 | ||
70 | dev->fw_upload_in_progress = true; | 70 | dev->fw_download_in_progress = true; |
71 | rc = dev->ops->fw_upload(dev, firmware_name); | 71 | rc = dev->ops->fw_download(dev, firmware_name); |
72 | if (rc) | 72 | if (rc) |
73 | dev->fw_upload_in_progress = false; | 73 | dev->fw_download_in_progress = false; |
74 | 74 | ||
75 | error: | 75 | error: |
76 | device_unlock(&dev->dev); | 76 | device_unlock(&dev->dev); |
77 | return rc; | 77 | return rc; |
78 | } | 78 | } |
79 | 79 | ||
80 | int nfc_fw_upload_done(struct nfc_dev *dev, const char *firmware_name) | 80 | /** |
81 | * nfc_fw_download_done - inform that a firmware download was completed | ||
82 | * | ||
83 | * @dev: The nfc device to which firmware was downloaded | ||
84 | * @firmware_name: The firmware filename | ||
85 | * @result: The positive value of a standard errno value | ||
86 | */ | ||
87 | int nfc_fw_download_done(struct nfc_dev *dev, const char *firmware_name, | ||
88 | u32 result) | ||
81 | { | 89 | { |
82 | dev->fw_upload_in_progress = false; | 90 | dev->fw_download_in_progress = false; |
83 | 91 | ||
84 | return nfc_genl_fw_upload_done(dev, firmware_name); | 92 | return nfc_genl_fw_download_done(dev, firmware_name, result); |
85 | } | 93 | } |
86 | EXPORT_SYMBOL(nfc_fw_upload_done); | 94 | EXPORT_SYMBOL(nfc_fw_download_done); |
87 | 95 | ||
88 | /** | 96 | /** |
89 | * nfc_dev_up - turn on the NFC device | 97 | * nfc_dev_up - turn on the NFC device |
@@ -110,7 +118,7 @@ int nfc_dev_up(struct nfc_dev *dev) | |||
110 | goto error; | 118 | goto error; |
111 | } | 119 | } |
112 | 120 | ||
113 | if (dev->fw_upload_in_progress) { | 121 | if (dev->fw_download_in_progress) { |
114 | rc = -EBUSY; | 122 | rc = -EBUSY; |
115 | goto error; | 123 | goto error; |
116 | } | 124 | } |
@@ -129,7 +137,7 @@ int nfc_dev_up(struct nfc_dev *dev) | |||
129 | /* We have to enable the device before discovering SEs */ | 137 | /* We have to enable the device before discovering SEs */ |
130 | if (dev->ops->discover_se) { | 138 | if (dev->ops->discover_se) { |
131 | rc = dev->ops->discover_se(dev); | 139 | rc = dev->ops->discover_se(dev); |
132 | if (!rc) | 140 | if (rc) |
133 | pr_warn("SE discovery failed\n"); | 141 | pr_warn("SE discovery failed\n"); |
134 | } | 142 | } |
135 | 143 | ||
@@ -575,12 +583,14 @@ int nfc_enable_se(struct nfc_dev *dev, u32 se_idx) | |||
575 | goto error; | 583 | goto error; |
576 | } | 584 | } |
577 | 585 | ||
578 | if (se->type == NFC_SE_ENABLED) { | 586 | if (se->state == NFC_SE_ENABLED) { |
579 | rc = -EALREADY; | 587 | rc = -EALREADY; |
580 | goto error; | 588 | goto error; |
581 | } | 589 | } |
582 | 590 | ||
583 | rc = dev->ops->enable_se(dev, se_idx); | 591 | rc = dev->ops->enable_se(dev, se_idx); |
592 | if (rc >= 0) | ||
593 | se->state = NFC_SE_ENABLED; | ||
584 | 594 | ||
585 | error: | 595 | error: |
586 | device_unlock(&dev->dev); | 596 | device_unlock(&dev->dev); |
@@ -618,12 +628,14 @@ int nfc_disable_se(struct nfc_dev *dev, u32 se_idx) | |||
618 | goto error; | 628 | goto error; |
619 | } | 629 | } |
620 | 630 | ||
621 | if (se->type == NFC_SE_DISABLED) { | 631 | if (se->state == NFC_SE_DISABLED) { |
622 | rc = -EALREADY; | 632 | rc = -EALREADY; |
623 | goto error; | 633 | goto error; |
624 | } | 634 | } |
625 | 635 | ||
626 | rc = dev->ops->disable_se(dev, se_idx); | 636 | rc = dev->ops->disable_se(dev, se_idx); |
637 | if (rc >= 0) | ||
638 | se->state = NFC_SE_DISABLED; | ||
627 | 639 | ||
628 | error: | 640 | error: |
629 | device_unlock(&dev->dev); | 641 | device_unlock(&dev->dev); |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 7b1c186736eb..d07ca4c5cf8c 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -717,7 +717,7 @@ static int hci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx) | |||
717 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | 717 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
718 | 718 | ||
719 | if (hdev->ops->disable_se) | 719 | if (hdev->ops->disable_se) |
720 | return hdev->ops->enable_se(hdev, se_idx); | 720 | return hdev->ops->disable_se(hdev, se_idx); |
721 | 721 | ||
722 | return 0; | 722 | return 0; |
723 | } | 723 | } |
@@ -809,14 +809,14 @@ static void nfc_hci_recv_from_llc(struct nfc_hci_dev *hdev, struct sk_buff *skb) | |||
809 | } | 809 | } |
810 | } | 810 | } |
811 | 811 | ||
812 | static int hci_fw_upload(struct nfc_dev *nfc_dev, const char *firmware_name) | 812 | static int hci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name) |
813 | { | 813 | { |
814 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | 814 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
815 | 815 | ||
816 | if (!hdev->ops->fw_upload) | 816 | if (!hdev->ops->fw_download) |
817 | return -ENOTSUPP; | 817 | return -ENOTSUPP; |
818 | 818 | ||
819 | return hdev->ops->fw_upload(hdev, firmware_name); | 819 | return hdev->ops->fw_download(hdev, firmware_name); |
820 | } | 820 | } |
821 | 821 | ||
822 | static struct nfc_ops hci_nfc_ops = { | 822 | static struct nfc_ops hci_nfc_ops = { |
@@ -831,7 +831,7 @@ static struct nfc_ops hci_nfc_ops = { | |||
831 | .im_transceive = hci_transceive, | 831 | .im_transceive = hci_transceive, |
832 | .tm_send = hci_tm_send, | 832 | .tm_send = hci_tm_send, |
833 | .check_presence = hci_check_presence, | 833 | .check_presence = hci_check_presence, |
834 | .fw_upload = hci_fw_upload, | 834 | .fw_download = hci_fw_download, |
835 | .discover_se = hci_discover_se, | 835 | .discover_se = hci_discover_se, |
836 | .enable_se = hci_enable_se, | 836 | .enable_se = hci_enable_se, |
837 | .disable_se = hci_disable_se, | 837 | .disable_se = hci_disable_se, |
diff --git a/net/nfc/nci/Kconfig b/net/nfc/nci/Kconfig index 2a2416080b4f..a4f1e42e3481 100644 --- a/net/nfc/nci/Kconfig +++ b/net/nfc/nci/Kconfig | |||
@@ -11,6 +11,7 @@ config NFC_NCI | |||
11 | 11 | ||
12 | config NFC_NCI_SPI | 12 | config NFC_NCI_SPI |
13 | depends on NFC_NCI && SPI | 13 | depends on NFC_NCI && SPI |
14 | select CRC_CCITT | ||
14 | bool "NCI over SPI protocol support" | 15 | bool "NCI over SPI protocol support" |
15 | default n | 16 | default n |
16 | help | 17 | help |
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index b05ad909778f..68063b2025da 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -1089,7 +1089,7 @@ exit: | |||
1089 | return rc; | 1089 | return rc; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | static int nfc_genl_fw_upload(struct sk_buff *skb, struct genl_info *info) | 1092 | static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info) |
1093 | { | 1093 | { |
1094 | struct nfc_dev *dev; | 1094 | struct nfc_dev *dev; |
1095 | int rc; | 1095 | int rc; |
@@ -1108,13 +1108,14 @@ static int nfc_genl_fw_upload(struct sk_buff *skb, struct genl_info *info) | |||
1108 | nla_strlcpy(firmware_name, info->attrs[NFC_ATTR_FIRMWARE_NAME], | 1108 | nla_strlcpy(firmware_name, info->attrs[NFC_ATTR_FIRMWARE_NAME], |
1109 | sizeof(firmware_name)); | 1109 | sizeof(firmware_name)); |
1110 | 1110 | ||
1111 | rc = nfc_fw_upload(dev, firmware_name); | 1111 | rc = nfc_fw_download(dev, firmware_name); |
1112 | 1112 | ||
1113 | nfc_put_device(dev); | 1113 | nfc_put_device(dev); |
1114 | return rc; | 1114 | return rc; |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | int nfc_genl_fw_upload_done(struct nfc_dev *dev, const char *firmware_name) | 1117 | int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, |
1118 | u32 result) | ||
1118 | { | 1119 | { |
1119 | struct sk_buff *msg; | 1120 | struct sk_buff *msg; |
1120 | void *hdr; | 1121 | void *hdr; |
@@ -1124,11 +1125,12 @@ int nfc_genl_fw_upload_done(struct nfc_dev *dev, const char *firmware_name) | |||
1124 | return -ENOMEM; | 1125 | return -ENOMEM; |
1125 | 1126 | ||
1126 | hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, | 1127 | hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, |
1127 | NFC_CMD_FW_UPLOAD); | 1128 | NFC_CMD_FW_DOWNLOAD); |
1128 | if (!hdr) | 1129 | if (!hdr) |
1129 | goto free_msg; | 1130 | goto free_msg; |
1130 | 1131 | ||
1131 | if (nla_put_string(msg, NFC_ATTR_FIRMWARE_NAME, firmware_name) || | 1132 | if (nla_put_string(msg, NFC_ATTR_FIRMWARE_NAME, firmware_name) || |
1133 | nla_put_u32(msg, NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, result) || | ||
1132 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) | 1134 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) |
1133 | goto nla_put_failure; | 1135 | goto nla_put_failure; |
1134 | 1136 | ||
@@ -1191,6 +1193,91 @@ static int nfc_genl_disable_se(struct sk_buff *skb, struct genl_info *info) | |||
1191 | return rc; | 1193 | return rc; |
1192 | } | 1194 | } |
1193 | 1195 | ||
1196 | static int nfc_genl_send_se(struct sk_buff *msg, struct nfc_dev *dev, | ||
1197 | u32 portid, u32 seq, | ||
1198 | struct netlink_callback *cb, | ||
1199 | int flags) | ||
1200 | { | ||
1201 | void *hdr; | ||
1202 | struct nfc_se *se, *n; | ||
1203 | |||
1204 | list_for_each_entry_safe(se, n, &dev->secure_elements, list) { | ||
1205 | hdr = genlmsg_put(msg, portid, seq, &nfc_genl_family, flags, | ||
1206 | NFC_CMD_GET_SE); | ||
1207 | if (!hdr) | ||
1208 | goto nla_put_failure; | ||
1209 | |||
1210 | if (cb) | ||
1211 | genl_dump_check_consistent(cb, hdr, &nfc_genl_family); | ||
1212 | |||
1213 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) || | ||
1214 | nla_put_u32(msg, NFC_ATTR_SE_INDEX, se->idx) || | ||
1215 | nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type)) | ||
1216 | goto nla_put_failure; | ||
1217 | |||
1218 | if (genlmsg_end(msg, hdr) < 0) | ||
1219 | goto nla_put_failure; | ||
1220 | } | ||
1221 | |||
1222 | return 0; | ||
1223 | |||
1224 | nla_put_failure: | ||
1225 | genlmsg_cancel(msg, hdr); | ||
1226 | return -EMSGSIZE; | ||
1227 | } | ||
1228 | |||
1229 | static int nfc_genl_dump_ses(struct sk_buff *skb, | ||
1230 | struct netlink_callback *cb) | ||
1231 | { | ||
1232 | struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0]; | ||
1233 | struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; | ||
1234 | bool first_call = false; | ||
1235 | |||
1236 | if (!iter) { | ||
1237 | first_call = true; | ||
1238 | iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL); | ||
1239 | if (!iter) | ||
1240 | return -ENOMEM; | ||
1241 | cb->args[0] = (long) iter; | ||
1242 | } | ||
1243 | |||
1244 | mutex_lock(&nfc_devlist_mutex); | ||
1245 | |||
1246 | cb->seq = nfc_devlist_generation; | ||
1247 | |||
1248 | if (first_call) { | ||
1249 | nfc_device_iter_init(iter); | ||
1250 | dev = nfc_device_iter_next(iter); | ||
1251 | } | ||
1252 | |||
1253 | while (dev) { | ||
1254 | int rc; | ||
1255 | |||
1256 | rc = nfc_genl_send_se(skb, dev, NETLINK_CB(cb->skb).portid, | ||
1257 | cb->nlh->nlmsg_seq, cb, NLM_F_MULTI); | ||
1258 | if (rc < 0) | ||
1259 | break; | ||
1260 | |||
1261 | dev = nfc_device_iter_next(iter); | ||
1262 | } | ||
1263 | |||
1264 | mutex_unlock(&nfc_devlist_mutex); | ||
1265 | |||
1266 | cb->args[1] = (long) dev; | ||
1267 | |||
1268 | return skb->len; | ||
1269 | } | ||
1270 | |||
1271 | static int nfc_genl_dump_ses_done(struct netlink_callback *cb) | ||
1272 | { | ||
1273 | struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0]; | ||
1274 | |||
1275 | nfc_device_iter_exit(iter); | ||
1276 | kfree(iter); | ||
1277 | |||
1278 | return 0; | ||
1279 | } | ||
1280 | |||
1194 | static struct genl_ops nfc_genl_ops[] = { | 1281 | static struct genl_ops nfc_genl_ops[] = { |
1195 | { | 1282 | { |
1196 | .cmd = NFC_CMD_GET_DEVICE, | 1283 | .cmd = NFC_CMD_GET_DEVICE, |
@@ -1251,8 +1338,8 @@ static struct genl_ops nfc_genl_ops[] = { | |||
1251 | .policy = nfc_genl_policy, | 1338 | .policy = nfc_genl_policy, |
1252 | }, | 1339 | }, |
1253 | { | 1340 | { |
1254 | .cmd = NFC_CMD_FW_UPLOAD, | 1341 | .cmd = NFC_CMD_FW_DOWNLOAD, |
1255 | .doit = nfc_genl_fw_upload, | 1342 | .doit = nfc_genl_fw_download, |
1256 | .policy = nfc_genl_policy, | 1343 | .policy = nfc_genl_policy, |
1257 | }, | 1344 | }, |
1258 | { | 1345 | { |
@@ -1265,6 +1352,12 @@ static struct genl_ops nfc_genl_ops[] = { | |||
1265 | .doit = nfc_genl_disable_se, | 1352 | .doit = nfc_genl_disable_se, |
1266 | .policy = nfc_genl_policy, | 1353 | .policy = nfc_genl_policy, |
1267 | }, | 1354 | }, |
1355 | { | ||
1356 | .cmd = NFC_CMD_GET_SE, | ||
1357 | .dumpit = nfc_genl_dump_ses, | ||
1358 | .done = nfc_genl_dump_ses_done, | ||
1359 | .policy = nfc_genl_policy, | ||
1360 | }, | ||
1268 | }; | 1361 | }; |
1269 | 1362 | ||
1270 | 1363 | ||
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index ee85a1fc1b24..aaf606fc1faa 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -123,10 +123,9 @@ static inline void nfc_device_iter_exit(struct class_dev_iter *iter) | |||
123 | class_dev_iter_exit(iter); | 123 | class_dev_iter_exit(iter); |
124 | } | 124 | } |
125 | 125 | ||
126 | int nfc_fw_upload(struct nfc_dev *dev, const char *firmware_name); | 126 | int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name); |
127 | int nfc_genl_fw_upload_done(struct nfc_dev *dev, const char *firmware_name); | 127 | int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, |
128 | 128 | u32 result); | |
129 | int nfc_fw_upload_done(struct nfc_dev *dev, const char *firmware_name); | ||
130 | 129 | ||
131 | int nfc_dev_up(struct nfc_dev *dev); | 130 | int nfc_dev_up(struct nfc_dev *dev); |
132 | 131 | ||
diff --git a/net/wireless/core.c b/net/wireless/core.c index 389a3f2ee464..67153964aad2 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -774,6 +774,7 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev, | |||
774 | cfg80211_leave_mesh(rdev, dev); | 774 | cfg80211_leave_mesh(rdev, dev); |
775 | break; | 775 | break; |
776 | case NL80211_IFTYPE_AP: | 776 | case NL80211_IFTYPE_AP: |
777 | case NL80211_IFTYPE_P2P_GO: | ||
777 | cfg80211_stop_ap(rdev, dev); | 778 | cfg80211_stop_ap(rdev, dev); |
778 | break; | 779 | break; |
779 | default: | 780 | default: |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a51269d2d488..af8d84a4a5b2 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -454,10 +454,12 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb, | |||
454 | goto out_unlock; | 454 | goto out_unlock; |
455 | } | 455 | } |
456 | *rdev = wiphy_to_dev((*wdev)->wiphy); | 456 | *rdev = wiphy_to_dev((*wdev)->wiphy); |
457 | cb->args[0] = (*rdev)->wiphy_idx; | 457 | /* 0 is the first index - add 1 to parse only once */ |
458 | cb->args[0] = (*rdev)->wiphy_idx + 1; | ||
458 | cb->args[1] = (*wdev)->identifier; | 459 | cb->args[1] = (*wdev)->identifier; |
459 | } else { | 460 | } else { |
460 | struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]); | 461 | /* subtract the 1 again here */ |
462 | struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1); | ||
461 | struct wireless_dev *tmp; | 463 | struct wireless_dev *tmp; |
462 | 464 | ||
463 | if (!wiphy) { | 465 | if (!wiphy) { |
@@ -2662,8 +2664,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
2662 | 2664 | ||
2663 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 2665 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, |
2664 | NL80211_CMD_NEW_KEY); | 2666 | NL80211_CMD_NEW_KEY); |
2665 | if (IS_ERR(hdr)) | 2667 | if (!hdr) |
2666 | return PTR_ERR(hdr); | 2668 | return -ENOBUFS; |
2667 | 2669 | ||
2668 | cookie.msg = msg; | 2670 | cookie.msg = msg; |
2669 | cookie.idx = key_idx; | 2671 | cookie.idx = key_idx; |
@@ -4812,9 +4814,9 @@ do { \ | |||
4812 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1, | 4814 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1, |
4813 | mask, NL80211_MESHCONF_FORWARDING, | 4815 | mask, NL80211_MESHCONF_FORWARDING, |
4814 | nla_get_u8); | 4816 | nla_get_u8); |
4815 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255, | 4817 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0, |
4816 | mask, NL80211_MESHCONF_RSSI_THRESHOLD, | 4818 | mask, NL80211_MESHCONF_RSSI_THRESHOLD, |
4817 | nla_get_u32); | 4819 | nla_get_s32); |
4818 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16, | 4820 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16, |
4819 | mask, NL80211_MESHCONF_HT_OPMODE, | 4821 | mask, NL80211_MESHCONF_HT_OPMODE, |
4820 | nla_get_u16); | 4822 | nla_get_u16); |
@@ -6679,6 +6681,9 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
6679 | NL80211_CMD_TESTMODE); | 6681 | NL80211_CMD_TESTMODE); |
6680 | struct nlattr *tmdata; | 6682 | struct nlattr *tmdata; |
6681 | 6683 | ||
6684 | if (!hdr) | ||
6685 | break; | ||
6686 | |||
6682 | if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) { | 6687 | if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) { |
6683 | genlmsg_cancel(skb, hdr); | 6688 | genlmsg_cancel(skb, hdr); |
6684 | break; | 6689 | break; |
@@ -6787,12 +6792,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_event_skb); | |||
6787 | 6792 | ||
6788 | void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp) | 6793 | void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp) |
6789 | { | 6794 | { |
6795 | struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; | ||
6790 | void *hdr = ((void **)skb->cb)[1]; | 6796 | void *hdr = ((void **)skb->cb)[1]; |
6791 | struct nlattr *data = ((void **)skb->cb)[2]; | 6797 | struct nlattr *data = ((void **)skb->cb)[2]; |
6792 | 6798 | ||
6793 | nla_nest_end(skb, data); | 6799 | nla_nest_end(skb, data); |
6794 | genlmsg_end(skb, hdr); | 6800 | genlmsg_end(skb, hdr); |
6795 | genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp); | 6801 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0, |
6802 | nl80211_testmode_mcgrp.id, gfp); | ||
6796 | } | 6803 | } |
6797 | EXPORT_SYMBOL(cfg80211_testmode_event); | 6804 | EXPORT_SYMBOL(cfg80211_testmode_event); |
6798 | #endif | 6805 | #endif |
@@ -7121,9 +7128,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, | |||
7121 | 7128 | ||
7122 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 7129 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, |
7123 | NL80211_CMD_REMAIN_ON_CHANNEL); | 7130 | NL80211_CMD_REMAIN_ON_CHANNEL); |
7124 | 7131 | if (!hdr) { | |
7125 | if (IS_ERR(hdr)) { | 7132 | err = -ENOBUFS; |
7126 | err = PTR_ERR(hdr); | ||
7127 | goto free_msg; | 7133 | goto free_msg; |
7128 | } | 7134 | } |
7129 | 7135 | ||
@@ -7421,9 +7427,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
7421 | 7427 | ||
7422 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 7428 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, |
7423 | NL80211_CMD_FRAME); | 7429 | NL80211_CMD_FRAME); |
7424 | 7430 | if (!hdr) { | |
7425 | if (IS_ERR(hdr)) { | 7431 | err = -ENOBUFS; |
7426 | err = PTR_ERR(hdr); | ||
7427 | goto free_msg; | 7432 | goto free_msg; |
7428 | } | 7433 | } |
7429 | } | 7434 | } |
@@ -8555,9 +8560,8 @@ static int nl80211_probe_client(struct sk_buff *skb, | |||
8555 | 8560 | ||
8556 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 8561 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, |
8557 | NL80211_CMD_PROBE_CLIENT); | 8562 | NL80211_CMD_PROBE_CLIENT); |
8558 | 8563 | if (!hdr) { | |
8559 | if (IS_ERR(hdr)) { | 8564 | err = -ENOBUFS; |
8560 | err = PTR_ERR(hdr); | ||
8561 | goto free_msg; | 8565 | goto free_msg; |
8562 | } | 8566 | } |
8563 | 8567 | ||
@@ -10516,7 +10520,8 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, | |||
10516 | 10520 | ||
10517 | genlmsg_end(msg, hdr); | 10521 | genlmsg_end(msg, hdr); |
10518 | 10522 | ||
10519 | genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp); | 10523 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
10524 | nl80211_mlme_mcgrp.id, gfp); | ||
10520 | return; | 10525 | return; |
10521 | 10526 | ||
10522 | nla_put_failure: | 10527 | nla_put_failure: |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5a24c986f34b..de06d5d1287f 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
2247 | 2247 | ||
2248 | void wiphy_regulatory_register(struct wiphy *wiphy) | 2248 | void wiphy_regulatory_register(struct wiphy *wiphy) |
2249 | { | 2249 | { |
2250 | struct regulatory_request *lr; | ||
2251 | |||
2250 | if (!reg_dev_ignore_cell_hint(wiphy)) | 2252 | if (!reg_dev_ignore_cell_hint(wiphy)) |
2251 | reg_num_devs_support_basehint++; | 2253 | reg_num_devs_support_basehint++; |
2252 | 2254 | ||
2253 | wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); | 2255 | lr = get_last_request(); |
2256 | wiphy_update_regulatory(wiphy, lr->initiator); | ||
2254 | } | 2257 | } |
2255 | 2258 | ||
2256 | void wiphy_regulatory_deregister(struct wiphy *wiphy) | 2259 | void wiphy_regulatory_deregister(struct wiphy *wiphy) |
@@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct wiphy *wiphy) | |||
2279 | static void reg_timeout_work(struct work_struct *work) | 2282 | static void reg_timeout_work(struct work_struct *work) |
2280 | { | 2283 | { |
2281 | REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n"); | 2284 | REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n"); |
2285 | rtnl_lock(); | ||
2282 | restore_regulatory_settings(true); | 2286 | restore_regulatory_settings(true); |
2287 | rtnl_unlock(); | ||
2283 | } | 2288 | } |
2284 | 2289 | ||
2285 | int __init regulatory_init(void) | 2290 | int __init regulatory_init(void) |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 1d3cfb1a3f28..20e86a95dc4e 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -34,8 +34,10 @@ struct cfg80211_conn { | |||
34 | CFG80211_CONN_SCAN_AGAIN, | 34 | CFG80211_CONN_SCAN_AGAIN, |
35 | CFG80211_CONN_AUTHENTICATE_NEXT, | 35 | CFG80211_CONN_AUTHENTICATE_NEXT, |
36 | CFG80211_CONN_AUTHENTICATING, | 36 | CFG80211_CONN_AUTHENTICATING, |
37 | CFG80211_CONN_AUTH_FAILED, | ||
37 | CFG80211_CONN_ASSOCIATE_NEXT, | 38 | CFG80211_CONN_ASSOCIATE_NEXT, |
38 | CFG80211_CONN_ASSOCIATING, | 39 | CFG80211_CONN_ASSOCIATING, |
40 | CFG80211_CONN_ASSOC_FAILED, | ||
39 | CFG80211_CONN_DEAUTH, | 41 | CFG80211_CONN_DEAUTH, |
40 | CFG80211_CONN_CONNECTED, | 42 | CFG80211_CONN_CONNECTED, |
41 | } state; | 43 | } state; |
@@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
164 | NULL, 0, | 166 | NULL, 0, |
165 | params->key, params->key_len, | 167 | params->key, params->key_len, |
166 | params->key_idx, NULL, 0); | 168 | params->key_idx, NULL, 0); |
169 | case CFG80211_CONN_AUTH_FAILED: | ||
170 | return -ENOTCONN; | ||
167 | case CFG80211_CONN_ASSOCIATE_NEXT: | 171 | case CFG80211_CONN_ASSOCIATE_NEXT: |
168 | BUG_ON(!rdev->ops->assoc); | 172 | BUG_ON(!rdev->ops->assoc); |
169 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; | 173 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; |
@@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
188 | WLAN_REASON_DEAUTH_LEAVING, | 192 | WLAN_REASON_DEAUTH_LEAVING, |
189 | false); | 193 | false); |
190 | return err; | 194 | return err; |
195 | case CFG80211_CONN_ASSOC_FAILED: | ||
196 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, | ||
197 | NULL, 0, | ||
198 | WLAN_REASON_DEAUTH_LEAVING, false); | ||
199 | return -ENOTCONN; | ||
191 | case CFG80211_CONN_DEAUTH: | 200 | case CFG80211_CONN_DEAUTH: |
192 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, | 201 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, |
193 | NULL, 0, | 202 | NULL, 0, |
194 | WLAN_REASON_DEAUTH_LEAVING, false); | 203 | WLAN_REASON_DEAUTH_LEAVING, false); |
204 | /* free directly, disconnected event already sent */ | ||
205 | cfg80211_sme_free(wdev); | ||
195 | return 0; | 206 | return 0; |
196 | default: | 207 | default: |
197 | return 0; | 208 | return 0; |
@@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct wireless_dev *wdev, u16 status) | |||
371 | return true; | 382 | return true; |
372 | } | 383 | } |
373 | 384 | ||
374 | wdev->conn->state = CFG80211_CONN_DEAUTH; | 385 | wdev->conn->state = CFG80211_CONN_ASSOC_FAILED; |
375 | schedule_work(&rdev->conn_work); | 386 | schedule_work(&rdev->conn_work); |
376 | return false; | 387 | return false; |
377 | } | 388 | } |
@@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless_dev *wdev) | |||
383 | 394 | ||
384 | void cfg80211_sme_auth_timeout(struct wireless_dev *wdev) | 395 | void cfg80211_sme_auth_timeout(struct wireless_dev *wdev) |
385 | { | 396 | { |
386 | cfg80211_sme_free(wdev); | 397 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
398 | |||
399 | if (!wdev->conn) | ||
400 | return; | ||
401 | |||
402 | wdev->conn->state = CFG80211_CONN_AUTH_FAILED; | ||
403 | schedule_work(&rdev->conn_work); | ||
387 | } | 404 | } |
388 | 405 | ||
389 | void cfg80211_sme_disassoc(struct wireless_dev *wdev) | 406 | void cfg80211_sme_disassoc(struct wireless_dev *wdev) |
@@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wireless_dev *wdev) | |||
399 | 416 | ||
400 | void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev) | 417 | void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev) |
401 | { | 418 | { |
402 | cfg80211_sme_disassoc(wdev); | 419 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
420 | |||
421 | if (!wdev->conn) | ||
422 | return; | ||
423 | |||
424 | wdev->conn->state = CFG80211_CONN_ASSOC_FAILED; | ||
425 | schedule_work(&rdev->conn_work); | ||
403 | } | 426 | } |
404 | 427 | ||
405 | static int cfg80211_sme_connect(struct wireless_dev *wdev, | 428 | static int cfg80211_sme_connect(struct wireless_dev *wdev, |
@@ -953,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
953 | struct net_device *dev, u16 reason, bool wextev) | 976 | struct net_device *dev, u16 reason, bool wextev) |
954 | { | 977 | { |
955 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 978 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
956 | int err; | 979 | int err = 0; |
957 | 980 | ||
958 | ASSERT_WDEV_LOCK(wdev); | 981 | ASSERT_WDEV_LOCK(wdev); |
959 | 982 | ||
960 | kfree(wdev->connect_keys); | 983 | kfree(wdev->connect_keys); |
961 | wdev->connect_keys = NULL; | 984 | wdev->connect_keys = NULL; |
962 | 985 | ||
963 | if (wdev->conn) { | 986 | if (wdev->conn) |
964 | err = cfg80211_sme_disconnect(wdev, reason); | 987 | err = cfg80211_sme_disconnect(wdev, reason); |
965 | } else if (!rdev->ops->disconnect) { | 988 | else if (!rdev->ops->disconnect) |
966 | cfg80211_mlme_down(rdev, dev); | 989 | cfg80211_mlme_down(rdev, dev); |
967 | err = 0; | 990 | else if (wdev->current_bss) |
968 | } else { | ||
969 | err = rdev_disconnect(rdev, dev, reason); | 991 | err = rdev_disconnect(rdev, dev, reason); |
970 | } | ||
971 | 992 | ||
972 | return err; | 993 | return err; |
973 | } | 994 | } |