Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem

+5139 -2915
-1
Documentation/DocBook/80211.tmpl
··· 404 404 !Finclude/net/mac80211.h ieee80211_get_tkip_p1k 405 405 !Finclude/net/mac80211.h ieee80211_get_tkip_p1k_iv 406 406 !Finclude/net/mac80211.h ieee80211_get_tkip_p2k 407 - !Finclude/net/mac80211.h ieee80211_key_removed 408 407 </chapter> 409 408 410 409 <chapter id="powersave">
+19
drivers/bcma/Kconfig
··· 46 46 47 47 If unsure, say N 48 48 49 + config BCMA_SFLASH 50 + bool 51 + depends on BCMA_DRIVER_MIPS && BROKEN 52 + default y 53 + 54 + config BCMA_NFLASH 55 + bool 56 + depends on BCMA_DRIVER_MIPS && BROKEN 57 + default y 58 + 59 + config BCMA_DRIVER_GMAC_CMN 60 + bool "BCMA Broadcom GBIT MAC COMMON core driver" 61 + depends on BCMA 62 + help 63 + Driver for the Broadcom GBIT MAC COMMON core attached to Broadcom 64 + specific Advanced Microcontroller Bus. 65 + 66 + If unsure, say N 67 + 49 68 config BCMA_DEBUG 50 69 bool "BCMA debugging" 51 70 depends on BCMA
+3
drivers/bcma/Makefile
··· 1 1 bcma-y += main.o scan.o core.o sprom.o 2 2 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 3 + bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 4 + bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 3 5 bcma-y += driver_pci.o 4 6 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o 5 7 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o 8 + bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o 6 9 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o 7 10 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o 8 11 obj-$(CONFIG_BCMA) += bcma.o
+22
drivers/bcma/bcma_private.h
··· 51 51 u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc); 52 52 u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc); 53 53 54 + #ifdef CONFIG_BCMA_SFLASH 55 + /* driver_chipcommon_sflash.c */ 56 + int bcma_sflash_init(struct bcma_drv_cc *cc); 57 + #else 58 + static inline int bcma_sflash_init(struct bcma_drv_cc *cc) 59 + { 60 + bcma_err(cc->core->bus, "Serial flash not supported\n"); 61 + return 0; 62 + } 63 + #endif /* CONFIG_BCMA_SFLASH */ 64 + 65 + #ifdef CONFIG_BCMA_NFLASH 66 + /* driver_chipcommon_nflash.c */ 67 + int bcma_nflash_init(struct bcma_drv_cc *cc); 68 + #else 69 + static inline int bcma_nflash_init(struct bcma_drv_cc *cc) 70 + { 71 + bcma_err(cc->core->bus, "NAND flash not supported\n"); 72 + return 0; 73 + } 74 + #endif /* CONFIG_BCMA_NFLASH */ 75 + 54 76 #ifdef CONFIG_BCMA_HOST_PCI 55 77 /* host_pci.c */ 56 78 extern int __init bcma_host_pci_init(void);
+19
drivers/bcma/driver_chipcommon_nflash.c
··· 1 + /* 2 + * Broadcom specific AMBA 3 + * ChipCommon NAND flash interface 4 + * 5 + * Licensed under the GNU/GPL. See COPYING for details. 6 + */ 7 + 8 + #include <linux/bcma/bcma.h> 9 + #include <linux/bcma/bcma_driver_chipcommon.h> 10 + #include <linux/delay.h> 11 + 12 + #include "bcma_private.h" 13 + 14 + /* Initialize NAND flash access */ 15 + int bcma_nflash_init(struct bcma_drv_cc *cc) 16 + { 17 + bcma_err(cc->core->bus, "NAND flash support is broken\n"); 18 + return 0; 19 + }
+19
drivers/bcma/driver_chipcommon_sflash.c
··· 1 + /* 2 + * Broadcom specific AMBA 3 + * ChipCommon serial flash interface 4 + * 5 + * Licensed under the GNU/GPL. See COPYING for details. 6 + */ 7 + 8 + #include <linux/bcma/bcma.h> 9 + #include <linux/bcma/bcma_driver_chipcommon.h> 10 + #include <linux/delay.h> 11 + 12 + #include "bcma_private.h" 13 + 14 + /* Initialize serial flash access */ 15 + int bcma_sflash_init(struct bcma_drv_cc *cc) 16 + { 17 + bcma_err(cc->core->bus, "Serial flash support is broken\n"); 18 + return 0; 19 + }
+14
drivers/bcma/driver_gmac_cmn.c
··· 1 + /* 2 + * Broadcom specific AMBA 3 + * GBIT MAC COMMON Core 4 + * 5 + * Licensed under the GNU/GPL. See COPYING for details. 6 + */ 7 + 8 + #include "bcma_private.h" 9 + #include <linux/bcma/bcma.h> 10 + 11 + void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) 12 + { 13 + mutex_init(&gc->phy_mutex); 14 + }
+12 -3
drivers/bcma/driver_mips.c
··· 185 185 switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) { 186 186 case BCMA_CC_FLASHT_STSER: 187 187 case BCMA_CC_FLASHT_ATSER: 188 - bcma_err(bus, "Serial flash not supported.\n"); 188 + bcma_debug(bus, "Found serial flash\n"); 189 + bcma_sflash_init(&bus->drv_cc); 189 190 break; 190 191 case BCMA_CC_FLASHT_PARA: 191 - bcma_info(bus, "found parallel flash.\n"); 192 + bcma_debug(bus, "Found parallel flash\n"); 192 193 bus->drv_cc.pflash.window = 0x1c000000; 193 194 bus->drv_cc.pflash.window_size = 0x02000000; 194 195 ··· 200 199 bus->drv_cc.pflash.buswidth = 2; 201 200 break; 202 201 default: 203 - bcma_err(bus, "flash not supported.\n"); 202 + bcma_err(bus, "Flash type not supported\n"); 203 + } 204 + 205 + if (bus->drv_cc.core->id.rev == 38 || 206 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) { 207 + if (bus->drv_cc.capabilities & BCMA_CC_CAP_NFLASH) { 208 + bcma_debug(bus, "Found NAND flash\n"); 209 + bcma_nflash_init(&bus->drv_cc); 210 + } 204 211 } 205 212 } 206 213
+20 -5
drivers/bcma/main.c
··· 61 61 .dev_attrs = bcma_device_attrs, 62 62 }; 63 63 64 + static u16 bcma_cc_core_id(struct bcma_bus *bus) 65 + { 66 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) 67 + return BCMA_CORE_4706_CHIPCOMMON; 68 + return BCMA_CORE_CHIPCOMMON; 69 + } 70 + 64 71 struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid) 65 72 { 66 73 struct bcma_device *core; ··· 98 91 list_for_each_entry(core, &bus->cores, list) { 99 92 /* We support that cores ourself */ 100 93 switch (core->id.id) { 94 + case BCMA_CORE_4706_CHIPCOMMON: 101 95 case BCMA_CORE_CHIPCOMMON: 102 96 case BCMA_CORE_PCI: 103 97 case BCMA_CORE_PCIE: 104 98 case BCMA_CORE_MIPS_74K: 99 + case BCMA_CORE_4706_MAC_GBIT_COMMON: 105 100 continue; 106 101 } 107 102 ··· 166 157 } 167 158 168 159 /* Init CC core */ 169 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON); 160 + core = bcma_find_core(bus, bcma_cc_core_id(bus)); 170 161 if (core) { 171 162 bus->drv_cc.core = core; 172 163 bcma_core_chipcommon_init(&bus->drv_cc); ··· 184 175 if (core) { 185 176 bus->drv_pci.core = core; 186 177 bcma_core_pci_init(&bus->drv_pci); 178 + } 179 + 180 + /* Init GBIT MAC COMMON core */ 181 + core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); 182 + if (core) { 183 + bus->drv_gmac_cmn.core = core; 184 + bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn); 187 185 } 188 186 189 187 /* Try to get SPROM */ ··· 224 208 bcma_init_bus(bus); 225 209 226 210 match.manuf = BCMA_MANUF_BCM; 227 - match.id = BCMA_CORE_CHIPCOMMON; 211 + match.id = bcma_cc_core_id(bus); 228 212 match.class = BCMA_CL_SIM; 229 213 match.rev = BCMA_ANY_REV; 230 214 ··· 248 232 } 249 233 250 234 /* Init CC core */ 251 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON); 235 + core = bcma_find_core(bus, bcma_cc_core_id(bus)); 252 236 if (core) { 253 237 bus->drv_cc.core = core; 254 238 bcma_core_chipcommon_init(&bus->drv_cc); ··· 287 271 struct bcma_device *core; 288 272 289 273 /* Init CC core */ 290 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON); 291 - if (core) { 274 + if (bus->drv_cc.core) { 292 275 bus->drv_cc.setup_done = false; 293 276 bcma_core_chipcommon_init(&bus->drv_cc); 294 277 }
+12 -8
drivers/bcma/scan.c
··· 21 21 }; 22 22 23 23 static const struct bcma_device_id_name bcma_arm_device_names[] = { 24 + { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" }, 24 25 { BCMA_CORE_ARM_1176, "ARM 1176" }, 25 26 { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" }, 26 27 { BCMA_CORE_ARM_CM3, "ARM CM3" }, ··· 34 33 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" }, 35 34 { BCMA_CORE_AMEMC, "AMEMC (DDR)" }, 36 35 { BCMA_CORE_ALTA, "ALTA (I2S)" }, 37 - { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" }, 38 36 { BCMA_CORE_INVALID, "Invalid" }, 39 37 { BCMA_CORE_CHIPCOMMON, "ChipCommon" }, 40 38 { BCMA_CORE_ILINE20, "ILine 20" }, ··· 295 295 296 296 /* check if component is a core at all */ 297 297 if (wrappers[0] + wrappers[1] == 0) { 298 - /* we could save addrl of the router 299 - if (cid == BCMA_CORE_OOB_ROUTER) 300 - */ 301 - bcma_erom_skip_component(bus, eromptr); 302 - return -ENXIO; 298 + /* Some specific cores don't need wrappers */ 299 + switch (core->id.id) { 300 + case BCMA_CORE_4706_MAC_GBIT_COMMON: 301 + /* Not used yet: case BCMA_CORE_OOB_ROUTER: */ 302 + break; 303 + default: 304 + bcma_erom_skip_component(bus, eromptr); 305 + return -ENXIO; 306 + } 303 307 } 304 308 305 309 if (bcma_erom_is_bridge(bus, eromptr)) { ··· 491 487 core->id.manuf, core->id.id, core->id.rev, 492 488 core->id.class); 493 489 494 - list_add(&core->list, &bus->cores); 490 + list_add_tail(&core->list, &bus->cores); 495 491 } 496 492 497 493 if (bus->hosttype == BCMA_HOSTTYPE_SOC) ··· 546 542 core->id.manuf, core->id.id, core->id.rev, 547 543 core->id.class); 548 544 549 - list_add(&core->list, &bus->cores); 545 + list_add_tail(&core->list, &bus->cores); 550 546 err = 0; 551 547 break; 552 548 }
+1 -1
drivers/bcma/scan.h
··· 27 27 #define SCAN_CIB_NMW 0x0007C000 28 28 #define SCAN_CIB_NMW_SHIFT 14 29 29 #define SCAN_CIB_NSW 0x00F80000 30 - #define SCAN_CIB_NSW_SHIFT 17 30 + #define SCAN_CIB_NSW_SHIFT 19 31 31 #define SCAN_CIB_REV 0xFF000000 32 32 #define SCAN_CIB_REV_SHIFT 24 33 33
+12
drivers/bluetooth/Kconfig
··· 81 81 82 82 Say Y here to compile support for HCILL protocol. 83 83 84 + config BT_HCIUART_3WIRE 85 + bool "Three-wire UART (H5) protocol support" 86 + depends on BT_HCIUART 87 + help 88 + The HCI Three-wire UART Transport Layer makes it possible to 89 + user the Bluetooth HCI over a serial port interface. The HCI 90 + Three-wire UART Transport Layer assumes that the UART 91 + communication may have bit errors, overrun errors or burst 92 + errors and thereby making CTS/RTS lines unnecessary. 93 + 94 + Say Y here to compile support for Three-wire UART protocol. 95 + 84 96 config BT_HCIBCM203X 85 97 tristate "HCI BCM203x USB driver" 86 98 depends on USB
+1
drivers/bluetooth/Makefile
··· 28 28 hci_uart-$(CONFIG_BT_HCIUART_BCSP) += hci_bcsp.o 29 29 hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o 30 30 hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o 31 + hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o 31 32 hci_uart-objs := $(hci_uart-y)
+4 -2
drivers/bluetooth/bluecard_cs.c
··· 621 621 static int bluecard_hci_open(struct hci_dev *hdev) 622 622 { 623 623 bluecard_info_t *info = hci_get_drvdata(hdev); 624 - unsigned int iobase = info->p_dev->resource[0]->start; 625 624 626 625 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 627 626 bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); ··· 629 630 return 0; 630 631 631 632 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { 633 + unsigned int iobase = info->p_dev->resource[0]->start; 634 + 632 635 /* Enable LED */ 633 636 outb(0x08 | 0x20, iobase + 0x30); 634 637 } ··· 642 641 static int bluecard_hci_close(struct hci_dev *hdev) 643 642 { 644 643 bluecard_info_t *info = hci_get_drvdata(hdev); 645 - unsigned int iobase = info->p_dev->resource[0]->start; 646 644 647 645 if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) 648 646 return 0; ··· 649 649 bluecard_hci_flush(hdev); 650 650 651 651 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { 652 + unsigned int iobase = info->p_dev->resource[0]->start; 653 + 652 654 /* Disable LED */ 653 655 outb(0x00, iobase + 0x30); 654 656 }
+1 -1
drivers/bluetooth/bt3c_cs.c
··· 664 664 { 665 665 int *try = priv_data; 666 666 667 - if (try == 0) 667 + if (!try) 668 668 p_dev->io_lines = 16; 669 669 670 670 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
+5 -3
drivers/bluetooth/btmrvl_main.c
··· 47 47 bool btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb) 48 48 { 49 49 struct hci_event_hdr *hdr = (void *) skb->data; 50 - struct hci_ev_cmd_complete *ec; 51 - u16 opcode, ocf, ogf; 52 50 53 51 if (hdr->evt == HCI_EV_CMD_COMPLETE) { 52 + struct hci_ev_cmd_complete *ec; 53 + u16 opcode, ocf, ogf; 54 + 54 55 ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE); 55 56 opcode = __le16_to_cpu(ec->opcode); 56 57 ocf = hci_opcode_ocf(opcode); ··· 65 64 } 66 65 67 66 if (ogf == OGF) { 68 - BT_DBG("vendor event skipped: ogf 0x%4.4x", ogf); 67 + BT_DBG("vendor event skipped: ogf 0x%4.4x ocf 0x%4.4x", 68 + ogf, ocf); 69 69 kfree_skb(skb); 70 70 return false; 71 71 }
+2 -1
drivers/bluetooth/btmrvl_sdio.c
··· 568 568 if (type == HCI_EVENT_PKT) { 569 569 if (btmrvl_check_evtpkt(priv, skb)) 570 570 hci_recv_frame(skb); 571 - } else 571 + } else { 572 572 hci_recv_frame(skb); 573 + } 573 574 574 575 hdev->stat.byte_rx += buf_len; 575 576 break;
+1 -1
drivers/bluetooth/btuart_cs.c
··· 593 593 { 594 594 int *try = priv_data; 595 595 596 - if (try == 0) 596 + if (!try) 597 597 p_dev->io_lines = 16; 598 598 599 599 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
+10 -8
drivers/bluetooth/dtl1_cs.c
··· 586 586 static int dtl1_config(struct pcmcia_device *link) 587 587 { 588 588 dtl1_info_t *info = link->priv; 589 - int i; 589 + int ret; 590 590 591 591 /* Look for a generic full-sized window */ 592 592 link->resource[0]->end = 8; 593 - if (pcmcia_loop_config(link, dtl1_confcheck, NULL) < 0) 593 + ret = pcmcia_loop_config(link, dtl1_confcheck, NULL); 594 + if (ret) 594 595 goto failed; 595 596 596 - i = pcmcia_request_irq(link, dtl1_interrupt); 597 - if (i != 0) 597 + ret = pcmcia_request_irq(link, dtl1_interrupt); 598 + if (ret) 598 599 goto failed; 599 600 600 - i = pcmcia_enable_device(link); 601 - if (i != 0) 601 + ret = pcmcia_enable_device(link); 602 + if (ret) 602 603 goto failed; 603 604 604 - if (dtl1_open(info) != 0) 605 + ret = dtl1_open(info); 606 + if (ret) 605 607 goto failed; 606 608 607 609 return 0; 608 610 609 611 failed: 610 612 dtl1_detach(link); 611 - return -ENODEV; 613 + return ret; 612 614 } 613 615 614 616 static const struct pcmcia_device_id dtl1_ids[] = {
+747
drivers/bluetooth/hci_h5.c
··· 1 + /* 2 + * 3 + * Bluetooth HCI Three-wire UART driver 4 + * 5 + * Copyright (C) 2012 Intel Corporation 6 + * 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; either version 2 of the License, or 11 + * (at your option) any later version. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + * You should have received a copy of the GNU General Public License 19 + * along with this program; if not, write to the Free Software 20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 + * 22 + */ 23 + 24 + #include <linux/kernel.h> 25 + #include <linux/errno.h> 26 + #include <linux/skbuff.h> 27 + 28 + #include <net/bluetooth/bluetooth.h> 29 + #include <net/bluetooth/hci_core.h> 30 + 31 + #include "hci_uart.h" 32 + 33 + #define HCI_3WIRE_ACK_PKT 0 34 + #define HCI_3WIRE_LINK_PKT 15 35 + 36 + /* Sliding window size */ 37 + #define H5_TX_WIN_MAX 4 38 + 39 + #define H5_ACK_TIMEOUT msecs_to_jiffies(250) 40 + #define H5_SYNC_TIMEOUT msecs_to_jiffies(100) 41 + 42 + /* 43 + * Maximum Three-wire packet: 44 + * 4 byte header + max value for 12-bit length + 2 bytes for CRC 45 + */ 46 + #define H5_MAX_LEN (4 + 0xfff + 2) 47 + 48 + /* Convenience macros for reading Three-wire header values */ 49 + #define H5_HDR_SEQ(hdr) ((hdr)[0] & 0x07) 50 + #define H5_HDR_ACK(hdr) (((hdr)[0] >> 3) & 0x07) 51 + #define H5_HDR_CRC(hdr) (((hdr)[0] >> 6) & 0x01) 52 + #define H5_HDR_RELIABLE(hdr) (((hdr)[0] >> 7) & 0x01) 53 + #define H5_HDR_PKT_TYPE(hdr) ((hdr)[1] & 0x0f) 54 + #define H5_HDR_LEN(hdr) ((((hdr)[1] >> 4) & 0xff) + ((hdr)[2] << 4)) 55 + 56 + #define SLIP_DELIMITER 0xc0 57 + #define SLIP_ESC 0xdb 58 + #define SLIP_ESC_DELIM 0xdc 59 + #define SLIP_ESC_ESC 0xdd 60 + 61 + /* H5 state flags */ 62 + enum { 63 + H5_RX_ESC, /* SLIP escape mode */ 64 + H5_TX_ACK_REQ, /* Pending ack to send */ 65 + }; 66 + 67 + struct h5 { 68 + struct sk_buff_head unack; /* Unack'ed packets queue */ 69 + struct sk_buff_head rel; /* Reliable packets queue */ 70 + struct sk_buff_head unrel; /* Unreliable packets queue */ 71 + 72 + unsigned long flags; 73 + 74 + struct sk_buff *rx_skb; /* Receive buffer */ 75 + size_t rx_pending; /* Expecting more bytes */ 76 + u8 rx_ack; /* Last ack number received */ 77 + 78 + int (*rx_func) (struct hci_uart *hu, u8 c); 79 + 80 + struct timer_list timer; /* Retransmission timer */ 81 + 82 + u8 tx_seq; /* Next seq number to send */ 83 + u8 tx_ack; /* Next ack number to send */ 84 + u8 tx_win; /* Sliding window size */ 85 + 86 + enum { 87 + H5_UNINITIALIZED, 88 + H5_INITIALIZED, 89 + H5_ACTIVE, 90 + } state; 91 + 92 + enum { 93 + H5_AWAKE, 94 + H5_SLEEPING, 95 + H5_WAKING_UP, 96 + } sleep; 97 + }; 98 + 99 + static void h5_reset_rx(struct h5 *h5); 100 + 101 + static void h5_link_control(struct hci_uart *hu, const void *data, size_t len) 102 + { 103 + struct h5 *h5 = hu->priv; 104 + struct sk_buff *nskb; 105 + 106 + nskb = alloc_skb(3, GFP_ATOMIC); 107 + if (!nskb) 108 + return; 109 + 110 + bt_cb(nskb)->pkt_type = HCI_3WIRE_LINK_PKT; 111 + 112 + memcpy(skb_put(nskb, len), data, len); 113 + 114 + skb_queue_tail(&h5->unrel, nskb); 115 + } 116 + 117 + static u8 h5_cfg_field(struct h5 *h5) 118 + { 119 + u8 field = 0; 120 + 121 + /* Sliding window size (first 3 bits) */ 122 + field |= (h5->tx_win & 7); 123 + 124 + return field; 125 + } 126 + 127 + static void h5_timed_event(unsigned long arg) 128 + { 129 + const unsigned char sync_req[] = { 0x01, 0x7e }; 130 + unsigned char conf_req[] = { 0x03, 0xfc, 0x01 }; 131 + struct hci_uart *hu = (struct hci_uart *) arg; 132 + struct h5 *h5 = hu->priv; 133 + struct sk_buff *skb; 134 + unsigned long flags; 135 + 136 + BT_DBG("%s", hu->hdev->name); 137 + 138 + if (h5->state == H5_UNINITIALIZED) 139 + h5_link_control(hu, sync_req, sizeof(sync_req)); 140 + 141 + if (h5->state == H5_INITIALIZED) { 142 + conf_req[2] = h5_cfg_field(h5); 143 + h5_link_control(hu, conf_req, sizeof(conf_req)); 144 + } 145 + 146 + if (h5->state != H5_ACTIVE) { 147 + mod_timer(&h5->timer, jiffies + H5_SYNC_TIMEOUT); 148 + goto wakeup; 149 + } 150 + 151 + if (h5->sleep != H5_AWAKE) { 152 + h5->sleep = H5_SLEEPING; 153 + goto wakeup; 154 + } 155 + 156 + BT_DBG("hu %p retransmitting %u pkts", hu, h5->unack.qlen); 157 + 158 + spin_lock_irqsave_nested(&h5->unack.lock, flags, SINGLE_DEPTH_NESTING); 159 + 160 + while ((skb = __skb_dequeue_tail(&h5->unack)) != NULL) { 161 + h5->tx_seq = (h5->tx_seq - 1) & 0x07; 162 + skb_queue_head(&h5->rel, skb); 163 + } 164 + 165 + spin_unlock_irqrestore(&h5->unack.lock, flags); 166 + 167 + wakeup: 168 + hci_uart_tx_wakeup(hu); 169 + } 170 + 171 + static int h5_open(struct hci_uart *hu) 172 + { 173 + struct h5 *h5; 174 + const unsigned char sync[] = { 0x01, 0x7e }; 175 + 176 + BT_DBG("hu %p", hu); 177 + 178 + h5 = kzalloc(sizeof(*h5), GFP_KERNEL); 179 + if (!h5) 180 + return -ENOMEM; 181 + 182 + hu->priv = h5; 183 + 184 + skb_queue_head_init(&h5->unack); 185 + skb_queue_head_init(&h5->rel); 186 + skb_queue_head_init(&h5->unrel); 187 + 188 + h5_reset_rx(h5); 189 + 190 + init_timer(&h5->timer); 191 + h5->timer.function = h5_timed_event; 192 + h5->timer.data = (unsigned long) hu; 193 + 194 + h5->tx_win = H5_TX_WIN_MAX; 195 + 196 + set_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags); 197 + 198 + /* Send initial sync request */ 199 + h5_link_control(hu, sync, sizeof(sync)); 200 + mod_timer(&h5->timer, jiffies + H5_SYNC_TIMEOUT); 201 + 202 + return 0; 203 + } 204 + 205 + static int h5_close(struct hci_uart *hu) 206 + { 207 + struct h5 *h5 = hu->priv; 208 + 209 + skb_queue_purge(&h5->unack); 210 + skb_queue_purge(&h5->rel); 211 + skb_queue_purge(&h5->unrel); 212 + 213 + del_timer(&h5->timer); 214 + 215 + kfree(h5); 216 + 217 + return 0; 218 + } 219 + 220 + static void h5_pkt_cull(struct h5 *h5) 221 + { 222 + struct sk_buff *skb, *tmp; 223 + unsigned long flags; 224 + int i, to_remove; 225 + u8 seq; 226 + 227 + spin_lock_irqsave(&h5->unack.lock, flags); 228 + 229 + to_remove = skb_queue_len(&h5->unack); 230 + if (to_remove == 0) 231 + goto unlock; 232 + 233 + seq = h5->tx_seq; 234 + 235 + while (to_remove > 0) { 236 + if (h5->rx_ack == seq) 237 + break; 238 + 239 + to_remove--; 240 + seq = (seq - 1) % 8; 241 + } 242 + 243 + if (seq != h5->rx_ack) 244 + BT_ERR("Controller acked invalid packet"); 245 + 246 + i = 0; 247 + skb_queue_walk_safe(&h5->unack, skb, tmp) { 248 + if (i++ >= to_remove) 249 + break; 250 + 251 + __skb_unlink(skb, &h5->unack); 252 + kfree_skb(skb); 253 + } 254 + 255 + if (skb_queue_empty(&h5->unack)) 256 + del_timer(&h5->timer); 257 + 258 + unlock: 259 + spin_unlock_irqrestore(&h5->unack.lock, flags); 260 + } 261 + 262 + static void h5_handle_internal_rx(struct hci_uart *hu) 263 + { 264 + struct h5 *h5 = hu->priv; 265 + const unsigned char sync_req[] = { 0x01, 0x7e }; 266 + const unsigned char sync_rsp[] = { 0x02, 0x7d }; 267 + unsigned char conf_req[] = { 0x03, 0xfc, 0x01 }; 268 + const unsigned char conf_rsp[] = { 0x04, 0x7b }; 269 + const unsigned char wakeup_req[] = { 0x05, 0xfa }; 270 + const unsigned char woken_req[] = { 0x06, 0xf9 }; 271 + const unsigned char sleep_req[] = { 0x07, 0x78 }; 272 + const unsigned char *hdr = h5->rx_skb->data; 273 + const unsigned char *data = &h5->rx_skb->data[4]; 274 + 275 + BT_DBG("%s", hu->hdev->name); 276 + 277 + if (H5_HDR_PKT_TYPE(hdr) != HCI_3WIRE_LINK_PKT) 278 + return; 279 + 280 + if (H5_HDR_LEN(hdr) < 2) 281 + return; 282 + 283 + conf_req[2] = h5_cfg_field(h5); 284 + 285 + if (memcmp(data, sync_req, 2) == 0) { 286 + h5_link_control(hu, sync_rsp, 2); 287 + } else if (memcmp(data, sync_rsp, 2) == 0) { 288 + h5->state = H5_INITIALIZED; 289 + h5_link_control(hu, conf_req, 3); 290 + } else if (memcmp(data, conf_req, 2) == 0) { 291 + h5_link_control(hu, conf_rsp, 2); 292 + h5_link_control(hu, conf_req, 3); 293 + } else if (memcmp(data, conf_rsp, 2) == 0) { 294 + if (H5_HDR_LEN(hdr) > 2) 295 + h5->tx_win = (data[2] & 7); 296 + BT_DBG("Three-wire init complete. tx_win %u", h5->tx_win); 297 + h5->state = H5_ACTIVE; 298 + hci_uart_init_ready(hu); 299 + return; 300 + } else if (memcmp(data, sleep_req, 2) == 0) { 301 + BT_DBG("Peer went to sleep"); 302 + h5->sleep = H5_SLEEPING; 303 + return; 304 + } else if (memcmp(data, woken_req, 2) == 0) { 305 + BT_DBG("Peer woke up"); 306 + h5->sleep = H5_AWAKE; 307 + } else if (memcmp(data, wakeup_req, 2) == 0) { 308 + BT_DBG("Peer requested wakeup"); 309 + h5_link_control(hu, woken_req, 2); 310 + h5->sleep = H5_AWAKE; 311 + } else { 312 + BT_DBG("Link Control: 0x%02hhx 0x%02hhx", data[0], data[1]); 313 + return; 314 + } 315 + 316 + hci_uart_tx_wakeup(hu); 317 + } 318 + 319 + static void h5_complete_rx_pkt(struct hci_uart *hu) 320 + { 321 + struct h5 *h5 = hu->priv; 322 + const unsigned char *hdr = h5->rx_skb->data; 323 + 324 + if (H5_HDR_RELIABLE(hdr)) { 325 + h5->tx_ack = (h5->tx_ack + 1) % 8; 326 + set_bit(H5_TX_ACK_REQ, &h5->flags); 327 + hci_uart_tx_wakeup(hu); 328 + } 329 + 330 + h5->rx_ack = H5_HDR_ACK(hdr); 331 + 332 + h5_pkt_cull(h5); 333 + 334 + switch (H5_HDR_PKT_TYPE(hdr)) { 335 + case HCI_EVENT_PKT: 336 + case HCI_ACLDATA_PKT: 337 + case HCI_SCODATA_PKT: 338 + bt_cb(h5->rx_skb)->pkt_type = H5_HDR_PKT_TYPE(hdr); 339 + 340 + /* Remove Three-wire header */ 341 + skb_pull(h5->rx_skb, 4); 342 + 343 + hci_recv_frame(h5->rx_skb); 344 + h5->rx_skb = NULL; 345 + 346 + break; 347 + 348 + default: 349 + h5_handle_internal_rx(hu); 350 + break; 351 + } 352 + 353 + h5_reset_rx(h5); 354 + } 355 + 356 + static int h5_rx_crc(struct hci_uart *hu, unsigned char c) 357 + { 358 + struct h5 *h5 = hu->priv; 359 + 360 + h5_complete_rx_pkt(hu); 361 + h5_reset_rx(h5); 362 + 363 + return 0; 364 + } 365 + 366 + static int h5_rx_payload(struct hci_uart *hu, unsigned char c) 367 + { 368 + struct h5 *h5 = hu->priv; 369 + const unsigned char *hdr = h5->rx_skb->data; 370 + 371 + if (H5_HDR_CRC(hdr)) { 372 + h5->rx_func = h5_rx_crc; 373 + h5->rx_pending = 2; 374 + } else { 375 + h5_complete_rx_pkt(hu); 376 + h5_reset_rx(h5); 377 + } 378 + 379 + return 0; 380 + } 381 + 382 + static int h5_rx_3wire_hdr(struct hci_uart *hu, unsigned char c) 383 + { 384 + struct h5 *h5 = hu->priv; 385 + const unsigned char *hdr = h5->rx_skb->data; 386 + 387 + BT_DBG("%s rx: seq %u ack %u crc %u rel %u type %u len %u", 388 + hu->hdev->name, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), 389 + H5_HDR_CRC(hdr), H5_HDR_RELIABLE(hdr), H5_HDR_PKT_TYPE(hdr), 390 + H5_HDR_LEN(hdr)); 391 + 392 + if (((hdr[0] + hdr[1] + hdr[2] + hdr[3]) & 0xff) != 0xff) { 393 + BT_ERR("Invalid header checksum"); 394 + h5_reset_rx(h5); 395 + return 0; 396 + } 397 + 398 + if (H5_HDR_RELIABLE(hdr) && H5_HDR_SEQ(hdr) != h5->tx_ack) { 399 + BT_ERR("Out-of-order packet arrived (%u != %u)", 400 + H5_HDR_SEQ(hdr), h5->tx_ack); 401 + h5_reset_rx(h5); 402 + return 0; 403 + } 404 + 405 + if (h5->state != H5_ACTIVE && 406 + H5_HDR_PKT_TYPE(hdr) != HCI_3WIRE_LINK_PKT) { 407 + BT_ERR("Non-link packet received in non-active state"); 408 + h5_reset_rx(h5); 409 + } 410 + 411 + h5->rx_func = h5_rx_payload; 412 + h5->rx_pending = H5_HDR_LEN(hdr); 413 + 414 + return 0; 415 + } 416 + 417 + static int h5_rx_pkt_start(struct hci_uart *hu, unsigned char c) 418 + { 419 + struct h5 *h5 = hu->priv; 420 + 421 + if (c == SLIP_DELIMITER) 422 + return 1; 423 + 424 + h5->rx_func = h5_rx_3wire_hdr; 425 + h5->rx_pending = 4; 426 + 427 + h5->rx_skb = bt_skb_alloc(H5_MAX_LEN, GFP_ATOMIC); 428 + if (!h5->rx_skb) { 429 + BT_ERR("Can't allocate mem for new packet"); 430 + h5_reset_rx(h5); 431 + return -ENOMEM; 432 + } 433 + 434 + h5->rx_skb->dev = (void *) hu->hdev; 435 + 436 + return 0; 437 + } 438 + 439 + static int h5_rx_delimiter(struct hci_uart *hu, unsigned char c) 440 + { 441 + struct h5 *h5 = hu->priv; 442 + 443 + if (c == SLIP_DELIMITER) 444 + h5->rx_func = h5_rx_pkt_start; 445 + 446 + return 1; 447 + } 448 + 449 + static void h5_unslip_one_byte(struct h5 *h5, unsigned char c) 450 + { 451 + const u8 delim = SLIP_DELIMITER, esc = SLIP_ESC; 452 + const u8 *byte = &c; 453 + 454 + if (!test_bit(H5_RX_ESC, &h5->flags) && c == SLIP_ESC) { 455 + set_bit(H5_RX_ESC, &h5->flags); 456 + return; 457 + } 458 + 459 + if (test_and_clear_bit(H5_RX_ESC, &h5->flags)) { 460 + switch (c) { 461 + case SLIP_ESC_DELIM: 462 + byte = &delim; 463 + break; 464 + case SLIP_ESC_ESC: 465 + byte = &esc; 466 + break; 467 + default: 468 + BT_ERR("Invalid esc byte 0x%02hhx", c); 469 + h5_reset_rx(h5); 470 + return; 471 + } 472 + } 473 + 474 + memcpy(skb_put(h5->rx_skb, 1), byte, 1); 475 + h5->rx_pending--; 476 + 477 + BT_DBG("unsliped 0x%02hhx, rx_pending %zu", *byte, h5->rx_pending); 478 + } 479 + 480 + static void h5_reset_rx(struct h5 *h5) 481 + { 482 + if (h5->rx_skb) { 483 + kfree_skb(h5->rx_skb); 484 + h5->rx_skb = NULL; 485 + } 486 + 487 + h5->rx_func = h5_rx_delimiter; 488 + h5->rx_pending = 0; 489 + clear_bit(H5_RX_ESC, &h5->flags); 490 + } 491 + 492 + static int h5_recv(struct hci_uart *hu, void *data, int count) 493 + { 494 + struct h5 *h5 = hu->priv; 495 + unsigned char *ptr = data; 496 + 497 + BT_DBG("%s pending %zu count %d", hu->hdev->name, h5->rx_pending, 498 + count); 499 + 500 + while (count > 0) { 501 + int processed; 502 + 503 + if (h5->rx_pending > 0) { 504 + if (*ptr == SLIP_DELIMITER) { 505 + BT_ERR("Too short H5 packet"); 506 + h5_reset_rx(h5); 507 + continue; 508 + } 509 + 510 + h5_unslip_one_byte(h5, *ptr); 511 + 512 + ptr++; count--; 513 + continue; 514 + } 515 + 516 + processed = h5->rx_func(hu, *ptr); 517 + if (processed < 0) 518 + return processed; 519 + 520 + ptr += processed; 521 + count -= processed; 522 + } 523 + 524 + return 0; 525 + } 526 + 527 + static int h5_enqueue(struct hci_uart *hu, struct sk_buff *skb) 528 + { 529 + struct h5 *h5 = hu->priv; 530 + 531 + if (skb->len > 0xfff) { 532 + BT_ERR("Packet too long (%u bytes)", skb->len); 533 + kfree_skb(skb); 534 + return 0; 535 + } 536 + 537 + if (h5->state != H5_ACTIVE) { 538 + BT_ERR("Ignoring HCI data in non-active state"); 539 + kfree_skb(skb); 540 + return 0; 541 + } 542 + 543 + switch (bt_cb(skb)->pkt_type) { 544 + case HCI_ACLDATA_PKT: 545 + case HCI_COMMAND_PKT: 546 + skb_queue_tail(&h5->rel, skb); 547 + break; 548 + 549 + case HCI_SCODATA_PKT: 550 + skb_queue_tail(&h5->unrel, skb); 551 + break; 552 + 553 + default: 554 + BT_ERR("Unknown packet type %u", bt_cb(skb)->pkt_type); 555 + kfree_skb(skb); 556 + break; 557 + } 558 + 559 + return 0; 560 + } 561 + 562 + static void h5_slip_delim(struct sk_buff *skb) 563 + { 564 + const char delim = SLIP_DELIMITER; 565 + 566 + memcpy(skb_put(skb, 1), &delim, 1); 567 + } 568 + 569 + static void h5_slip_one_byte(struct sk_buff *skb, u8 c) 570 + { 571 + const char esc_delim[2] = { SLIP_ESC, SLIP_ESC_DELIM }; 572 + const char esc_esc[2] = { SLIP_ESC, SLIP_ESC_ESC }; 573 + 574 + switch (c) { 575 + case SLIP_DELIMITER: 576 + memcpy(skb_put(skb, 2), &esc_delim, 2); 577 + break; 578 + case SLIP_ESC: 579 + memcpy(skb_put(skb, 2), &esc_esc, 2); 580 + break; 581 + default: 582 + memcpy(skb_put(skb, 1), &c, 1); 583 + } 584 + } 585 + 586 + static bool valid_packet_type(u8 type) 587 + { 588 + switch (type) { 589 + case HCI_ACLDATA_PKT: 590 + case HCI_COMMAND_PKT: 591 + case HCI_SCODATA_PKT: 592 + case HCI_3WIRE_LINK_PKT: 593 + case HCI_3WIRE_ACK_PKT: 594 + return true; 595 + default: 596 + return false; 597 + } 598 + } 599 + 600 + static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type, 601 + const u8 *data, size_t len) 602 + { 603 + struct h5 *h5 = hu->priv; 604 + struct sk_buff *nskb; 605 + u8 hdr[4]; 606 + int i; 607 + 608 + if (!valid_packet_type(pkt_type)) { 609 + BT_ERR("Unknown packet type %u", pkt_type); 610 + return NULL; 611 + } 612 + 613 + /* 614 + * Max len of packet: (original len + 4 (H5 hdr) + 2 (crc)) * 2 615 + * (because bytes 0xc0 and 0xdb are escaped, worst case is when 616 + * the packet is all made of 0xc0 and 0xdb) + 2 (0xc0 617 + * delimiters at start and end). 618 + */ 619 + nskb = alloc_skb((len + 6) * 2 + 2, GFP_ATOMIC); 620 + if (!nskb) 621 + return NULL; 622 + 623 + bt_cb(nskb)->pkt_type = pkt_type; 624 + 625 + h5_slip_delim(nskb); 626 + 627 + hdr[0] = h5->tx_ack << 3; 628 + clear_bit(H5_TX_ACK_REQ, &h5->flags); 629 + 630 + /* Reliable packet? */ 631 + if (pkt_type == HCI_ACLDATA_PKT || pkt_type == HCI_COMMAND_PKT) { 632 + hdr[0] |= 1 << 7; 633 + hdr[0] |= h5->tx_seq; 634 + h5->tx_seq = (h5->tx_seq + 1) % 8; 635 + } 636 + 637 + hdr[1] = pkt_type | ((len & 0x0f) << 4); 638 + hdr[2] = len >> 4; 639 + hdr[3] = ~((hdr[0] + hdr[1] + hdr[2]) & 0xff); 640 + 641 + BT_DBG("%s tx: seq %u ack %u crc %u rel %u type %u len %u", 642 + hu->hdev->name, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), 643 + H5_HDR_CRC(hdr), H5_HDR_RELIABLE(hdr), H5_HDR_PKT_TYPE(hdr), 644 + H5_HDR_LEN(hdr)); 645 + 646 + for (i = 0; i < 4; i++) 647 + h5_slip_one_byte(nskb, hdr[i]); 648 + 649 + for (i = 0; i < len; i++) 650 + h5_slip_one_byte(nskb, data[i]); 651 + 652 + h5_slip_delim(nskb); 653 + 654 + return nskb; 655 + } 656 + 657 + static struct sk_buff *h5_dequeue(struct hci_uart *hu) 658 + { 659 + struct h5 *h5 = hu->priv; 660 + unsigned long flags; 661 + struct sk_buff *skb, *nskb; 662 + 663 + if (h5->sleep != H5_AWAKE) { 664 + const unsigned char wakeup_req[] = { 0x05, 0xfa }; 665 + 666 + if (h5->sleep == H5_WAKING_UP) 667 + return NULL; 668 + 669 + h5->sleep = H5_WAKING_UP; 670 + BT_DBG("Sending wakeup request"); 671 + 672 + mod_timer(&h5->timer, jiffies + HZ / 100); 673 + return h5_prepare_pkt(hu, HCI_3WIRE_LINK_PKT, wakeup_req, 2); 674 + } 675 + 676 + if ((skb = skb_dequeue(&h5->unrel)) != NULL) { 677 + nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type, 678 + skb->data, skb->len); 679 + if (nskb) { 680 + kfree_skb(skb); 681 + return nskb; 682 + } 683 + 684 + skb_queue_head(&h5->unrel, skb); 685 + BT_ERR("Could not dequeue pkt because alloc_skb failed"); 686 + } 687 + 688 + spin_lock_irqsave_nested(&h5->unack.lock, flags, SINGLE_DEPTH_NESTING); 689 + 690 + if (h5->unack.qlen >= h5->tx_win) 691 + goto unlock; 692 + 693 + if ((skb = skb_dequeue(&h5->rel)) != NULL) { 694 + nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type, 695 + skb->data, skb->len); 696 + if (nskb) { 697 + __skb_queue_tail(&h5->unack, skb); 698 + mod_timer(&h5->timer, jiffies + H5_ACK_TIMEOUT); 699 + spin_unlock_irqrestore(&h5->unack.lock, flags); 700 + return nskb; 701 + } 702 + 703 + skb_queue_head(&h5->rel, skb); 704 + BT_ERR("Could not dequeue pkt because alloc_skb failed"); 705 + } 706 + 707 + unlock: 708 + spin_unlock_irqrestore(&h5->unack.lock, flags); 709 + 710 + if (test_bit(H5_TX_ACK_REQ, &h5->flags)) 711 + return h5_prepare_pkt(hu, HCI_3WIRE_ACK_PKT, NULL, 0); 712 + 713 + return NULL; 714 + } 715 + 716 + static int h5_flush(struct hci_uart *hu) 717 + { 718 + BT_DBG("hu %p", hu); 719 + return 0; 720 + } 721 + 722 + static struct hci_uart_proto h5p = { 723 + .id = HCI_UART_3WIRE, 724 + .open = h5_open, 725 + .close = h5_close, 726 + .recv = h5_recv, 727 + .enqueue = h5_enqueue, 728 + .dequeue = h5_dequeue, 729 + .flush = h5_flush, 730 + }; 731 + 732 + int __init h5_init(void) 733 + { 734 + int err = hci_uart_register_proto(&h5p); 735 + 736 + if (!err) 737 + BT_INFO("HCI Three-wire UART (H5) protocol initialized"); 738 + else 739 + BT_ERR("HCI Three-wire UART (H5) protocol init failed"); 740 + 741 + return err; 742 + } 743 + 744 + int __exit h5_deinit(void) 745 + { 746 + return hci_uart_unregister_proto(&h5p); 747 + }
+55 -11
drivers/bluetooth/hci_ldisc.c
··· 156 156 return 0; 157 157 } 158 158 159 + static void hci_uart_init_work(struct work_struct *work) 160 + { 161 + struct hci_uart *hu = container_of(work, struct hci_uart, init_ready); 162 + int err; 163 + 164 + if (!test_and_clear_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) 165 + return; 166 + 167 + err = hci_register_dev(hu->hdev); 168 + if (err < 0) { 169 + BT_ERR("Can't register HCI device"); 170 + hci_free_dev(hu->hdev); 171 + hu->hdev = NULL; 172 + hu->proto->close(hu); 173 + } 174 + 175 + set_bit(HCI_UART_REGISTERED, &hu->flags); 176 + } 177 + 178 + int hci_uart_init_ready(struct hci_uart *hu) 179 + { 180 + if (!test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) 181 + return -EALREADY; 182 + 183 + schedule_work(&hu->init_ready); 184 + 185 + return 0; 186 + } 187 + 159 188 /* ------- Interface to HCI layer ------ */ 160 189 /* Initialize device */ 161 190 static int hci_uart_open(struct hci_dev *hdev) ··· 293 264 hu->tty = tty; 294 265 tty->receive_room = 65536; 295 266 267 + INIT_WORK(&hu->init_ready, hci_uart_init_work); 268 + 296 269 spin_lock_init(&hu->rx_lock); 297 270 298 271 /* Flush any pending characters in the driver and line discipline. */ ··· 317 286 static void hci_uart_tty_close(struct tty_struct *tty) 318 287 { 319 288 struct hci_uart *hu = (void *)tty->disc_data; 289 + struct hci_dev *hdev; 320 290 321 291 BT_DBG("tty %p", tty); 322 292 323 293 /* Detach from the tty */ 324 294 tty->disc_data = NULL; 325 295 326 - if (hu) { 327 - struct hci_dev *hdev = hu->hdev; 296 + if (!hu) 297 + return; 328 298 329 - if (hdev) 330 - hci_uart_close(hdev); 299 + hdev = hu->hdev; 300 + if (hdev) 301 + hci_uart_close(hdev); 331 302 332 - if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { 333 - if (hdev) { 303 + if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { 304 + if (hdev) { 305 + if (test_bit(HCI_UART_REGISTERED, &hu->flags)) 334 306 hci_unregister_dev(hdev); 335 - hci_free_dev(hdev); 336 - } 337 - hu->proto->close(hu); 307 + hci_free_dev(hdev); 338 308 } 339 - 340 - kfree(hu); 309 + hu->proto->close(hu); 341 310 } 311 + 312 + kfree(hu); 342 313 } 343 314 344 315 /* hci_uart_tty_wakeup() ··· 434 401 else 435 402 hdev->dev_type = HCI_BREDR; 436 403 404 + if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) 405 + return 0; 406 + 437 407 if (hci_register_dev(hdev) < 0) { 438 408 BT_ERR("Can't register HCI device"); 439 409 hci_free_dev(hdev); 440 410 return -ENODEV; 441 411 } 412 + 413 + set_bit(HCI_UART_REGISTERED, &hu->flags); 442 414 443 415 return 0; 444 416 } ··· 596 558 #ifdef CONFIG_BT_HCIUART_ATH3K 597 559 ath_init(); 598 560 #endif 561 + #ifdef CONFIG_BT_HCIUART_3WIRE 562 + h5_init(); 563 + #endif 599 564 600 565 return 0; 601 566 } ··· 618 577 #endif 619 578 #ifdef CONFIG_BT_HCIUART_ATH3K 620 579 ath_deinit(); 580 + #endif 581 + #ifdef CONFIG_BT_HCIUART_3WIRE 582 + h5_deinit(); 621 583 #endif 622 584 623 585 /* Release tty registration of line discipline */
+10
drivers/bluetooth/hci_uart.h
··· 47 47 #define HCI_UART_RAW_DEVICE 0 48 48 #define HCI_UART_RESET_ON_INIT 1 49 49 #define HCI_UART_CREATE_AMP 2 50 + #define HCI_UART_INIT_PENDING 3 50 51 51 52 struct hci_uart; 52 53 ··· 67 66 unsigned long flags; 68 67 unsigned long hdev_flags; 69 68 69 + struct work_struct init_ready; 70 + 70 71 struct hci_uart_proto *proto; 71 72 void *priv; 72 73 ··· 79 76 80 77 /* HCI_UART proto flag bits */ 81 78 #define HCI_UART_PROTO_SET 0 79 + #define HCI_UART_REGISTERED 1 82 80 83 81 /* TX states */ 84 82 #define HCI_UART_SENDING 1 ··· 88 84 int hci_uart_register_proto(struct hci_uart_proto *p); 89 85 int hci_uart_unregister_proto(struct hci_uart_proto *p); 90 86 int hci_uart_tx_wakeup(struct hci_uart *hu); 87 + int hci_uart_init_ready(struct hci_uart *hu); 91 88 92 89 #ifdef CONFIG_BT_HCIUART_H4 93 90 int h4_init(void); ··· 108 103 #ifdef CONFIG_BT_HCIUART_ATH3K 109 104 int ath_init(void); 110 105 int ath_deinit(void); 106 + #endif 107 + 108 + #ifdef CONFIG_BT_HCIUART_3WIRE 109 + int h5_init(void); 110 + int h5_deinit(void); 111 111 #endif
+2
drivers/net/wireless/ath/ath.h
··· 216 216 * used exclusively for WLAN-BT coexistence starting from 217 217 * AR9462. 218 218 * @ATH_DBG_DFS: radar datection 219 + * @ATH_DBG_WOW: Wake on Wireless 219 220 * @ATH_DBG_ANY: enable all debugging 220 221 * 221 222 * The debug level is used to control the amount and type of debugging output ··· 244 243 ATH_DBG_BSTUCK = 0x00008000, 245 244 ATH_DBG_MCI = 0x00010000, 246 245 ATH_DBG_DFS = 0x00020000, 246 + ATH_DBG_WOW = 0x00040000, 247 247 ATH_DBG_ANY = 0xffffffff 248 248 }; 249 249
+1 -1
drivers/net/wireless/ath/ath5k/mac80211-ops.c
··· 594 594 qi.tqi_aifs = params->aifs; 595 595 qi.tqi_cw_min = params->cw_min; 596 596 qi.tqi_cw_max = params->cw_max; 597 - qi.tqi_burst_time = params->txop; 597 + qi.tqi_burst_time = params->txop * 32; 598 598 599 599 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, 600 600 "Configure tx [queue %d], "
+29 -29
drivers/net/wireless/ath/ath6kl/cfg80211.c
··· 966 966 return 0; 967 967 } 968 968 969 - static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, 969 + static int ath6kl_cfg80211_scan(struct wiphy *wiphy, 970 970 struct cfg80211_scan_request *request) 971 971 { 972 - struct ath6kl *ar = ath6kl_priv(ndev); 973 - struct ath6kl_vif *vif = netdev_priv(ndev); 972 + struct ath6kl_vif *vif = ath6kl_vif_from_wdev(request->wdev); 973 + struct ath6kl *ar = ath6kl_priv(vif->ndev); 974 974 s8 n_channels = 0; 975 975 u16 *channels = NULL; 976 976 int ret = 0; ··· 1487 1487 return 0; 1488 1488 } 1489 1489 1490 - static struct net_device *ath6kl_cfg80211_add_iface(struct wiphy *wiphy, 1491 - char *name, 1492 - enum nl80211_iftype type, 1493 - u32 *flags, 1494 - struct vif_params *params) 1490 + static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy, 1491 + char *name, 1492 + enum nl80211_iftype type, 1493 + u32 *flags, 1494 + struct vif_params *params) 1495 1495 { 1496 1496 struct ath6kl *ar = wiphy_priv(wiphy); 1497 - struct net_device *ndev; 1497 + struct wireless_dev *wdev; 1498 1498 u8 if_idx, nw_type; 1499 1499 1500 1500 if (ar->num_vif == ar->vif_max) { ··· 1507 1507 return ERR_PTR(-EINVAL); 1508 1508 } 1509 1509 1510 - ndev = ath6kl_interface_add(ar, name, type, if_idx, nw_type); 1511 - if (!ndev) 1510 + wdev = ath6kl_interface_add(ar, name, type, if_idx, nw_type); 1511 + if (!wdev) 1512 1512 return ERR_PTR(-ENOMEM); 1513 1513 1514 1514 ar->num_vif++; 1515 1515 1516 - return ndev; 1516 + return wdev; 1517 1517 } 1518 1518 1519 1519 static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy, 1520 - struct net_device *ndev) 1520 + struct wireless_dev *wdev) 1521 1521 { 1522 1522 struct ath6kl *ar = wiphy_priv(wiphy); 1523 - struct ath6kl_vif *vif = netdev_priv(ndev); 1523 + struct ath6kl_vif *vif = netdev_priv(wdev->netdev); 1524 1524 1525 1525 spin_lock_bh(&ar->list_lock); 1526 1526 list_del(&vif->list); ··· 2975 2975 } 2976 2976 2977 2977 static int ath6kl_remain_on_channel(struct wiphy *wiphy, 2978 - struct net_device *dev, 2978 + struct wireless_dev *wdev, 2979 2979 struct ieee80211_channel *chan, 2980 2980 enum nl80211_channel_type channel_type, 2981 2981 unsigned int duration, 2982 2982 u64 *cookie) 2983 2983 { 2984 - struct ath6kl *ar = ath6kl_priv(dev); 2985 - struct ath6kl_vif *vif = netdev_priv(dev); 2984 + struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev); 2985 + struct ath6kl *ar = ath6kl_priv(vif->ndev); 2986 2986 u32 id; 2987 2987 2988 2988 /* TODO: if already pending or ongoing remain-on-channel, ··· 2999 2999 } 3000 3000 3001 3001 static int ath6kl_cancel_remain_on_channel(struct wiphy *wiphy, 3002 - struct net_device *dev, 3002 + struct wireless_dev *wdev, 3003 3003 u64 cookie) 3004 3004 { 3005 - struct ath6kl *ar = ath6kl_priv(dev); 3006 - struct ath6kl_vif *vif = netdev_priv(dev); 3005 + struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev); 3006 + struct ath6kl *ar = ath6kl_priv(vif->ndev); 3007 3007 3008 3008 if (cookie != vif->last_roc_id) 3009 3009 return -ENOENT; ··· 3134 3134 return false; 3135 3135 } 3136 3136 3137 - static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, 3137 + static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 3138 3138 struct ieee80211_channel *chan, bool offchan, 3139 3139 enum nl80211_channel_type channel_type, 3140 3140 bool channel_type_valid, unsigned int wait, 3141 3141 const u8 *buf, size_t len, bool no_cck, 3142 3142 bool dont_wait_for_ack, u64 *cookie) 3143 3143 { 3144 - struct ath6kl *ar = ath6kl_priv(dev); 3145 - struct ath6kl_vif *vif = netdev_priv(dev); 3144 + struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev); 3145 + struct ath6kl *ar = ath6kl_priv(vif->ndev); 3146 3146 u32 id; 3147 3147 const struct ieee80211_mgmt *mgmt; 3148 3148 bool more_data, queued; ··· 3187 3187 } 3188 3188 3189 3189 static void ath6kl_mgmt_frame_register(struct wiphy *wiphy, 3190 - struct net_device *dev, 3190 + struct wireless_dev *wdev, 3191 3191 u16 frame_type, bool reg) 3192 3192 { 3193 - struct ath6kl_vif *vif = netdev_priv(dev); 3193 + struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev); 3194 3194 3195 3195 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: frame_type=0x%x reg=%d\n", 3196 3196 __func__, frame_type, reg); ··· 3477 3477 ar->num_vif--; 3478 3478 } 3479 3479 3480 - struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, 3481 - enum nl80211_iftype type, u8 fw_vif_idx, 3482 - u8 nw_type) 3480 + struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, char *name, 3481 + enum nl80211_iftype type, 3482 + u8 fw_vif_idx, u8 nw_type) 3483 3483 { 3484 3484 struct net_device *ndev; 3485 3485 struct ath6kl_vif *vif; ··· 3533 3533 list_add_tail(&vif->list, &ar->vif_list); 3534 3534 spin_unlock_bh(&ar->list_lock); 3535 3535 3536 - return ndev; 3536 + return &vif->wdev; 3537 3537 3538 3538 err: 3539 3539 aggr_module_destroy(vif->aggr_cntxt);
+3 -3
drivers/net/wireless/ath/ath6kl/cfg80211.h
··· 25 25 ATH6KL_CFG_SUSPEND_SCHED_SCAN, 26 26 }; 27 27 28 - struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, 29 - enum nl80211_iftype type, 30 - u8 fw_vif_idx, u8 nw_type); 28 + struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, char *name, 29 + enum nl80211_iftype type, 30 + u8 fw_vif_idx, u8 nw_type); 31 31 void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq, 32 32 enum wmi_phy_mode mode); 33 33 void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted);
+4 -4
drivers/net/wireless/ath/ath6kl/core.c
··· 56 56 int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type) 57 57 { 58 58 struct ath6kl_bmi_target_info targ_info; 59 - struct net_device *ndev; 59 + struct wireless_dev *wdev; 60 60 int ret = 0, i; 61 61 62 62 switch (htc_type) { ··· 187 187 rtnl_lock(); 188 188 189 189 /* Add an initial station interface */ 190 - ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, 190 + wdev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, 191 191 INFRA_NETWORK); 192 192 193 193 rtnl_unlock(); 194 194 195 - if (!ndev) { 195 + if (!wdev) { 196 196 ath6kl_err("Failed to instantiate a network device\n"); 197 197 ret = -ENOMEM; 198 198 wiphy_unregister(ar->wiphy); ··· 200 200 } 201 201 202 202 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", 203 - __func__, ndev->name, ndev, ar); 203 + __func__, wdev->netdev->name, wdev->netdev, ar); 204 204 205 205 return ret; 206 206
+5
drivers/net/wireless/ath/ath6kl/core.h
··· 589 589 struct list_head mc_filter; 590 590 }; 591 591 592 + static inline struct ath6kl_vif *ath6kl_vif_from_wdev(struct wireless_dev *wdev) 593 + { 594 + return container_of(wdev, struct ath6kl_vif, wdev); 595 + } 596 + 592 597 #define WOW_LIST_ID 0 593 598 #define WOW_HOST_REQ_DELAY 500 /* ms */ 594 599
+5 -5
drivers/net/wireless/ath/ath6kl/wmi.c
··· 474 474 return -EINVAL; 475 475 } 476 476 id = vif->last_roc_id; 477 - cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT, 477 + cfg80211_ready_on_channel(&vif->wdev, id, chan, NL80211_CHAN_NO_HT, 478 478 dur, GFP_ATOMIC); 479 479 480 480 return 0; ··· 513 513 else 514 514 id = vif->last_roc_id; /* timeout on uncanceled r-o-c */ 515 515 vif->last_cancel_roc_id = 0; 516 - cfg80211_remain_on_channel_expired(vif->ndev, id, chan, 516 + cfg80211_remain_on_channel_expired(&vif->wdev, id, chan, 517 517 NL80211_CHAN_NO_HT, GFP_ATOMIC); 518 518 519 519 return 0; ··· 533 533 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 534 534 id, ev->ack_status); 535 535 if (wmi->last_mgmt_tx_frame) { 536 - cfg80211_mgmt_tx_status(vif->ndev, id, 536 + cfg80211_mgmt_tx_status(&vif->wdev, id, 537 537 wmi->last_mgmt_tx_frame, 538 538 wmi->last_mgmt_tx_frame_len, 539 539 !!ev->ack_status, GFP_ATOMIC); ··· 568 568 dlen, freq, vif->probe_req_report); 569 569 570 570 if (vif->probe_req_report || vif->nw_type == AP_NETWORK) 571 - cfg80211_rx_mgmt(vif->ndev, freq, 0, 571 + cfg80211_rx_mgmt(&vif->wdev, freq, 0, 572 572 ev->data, dlen, GFP_ATOMIC); 573 573 574 574 return 0; ··· 608 608 return -EINVAL; 609 609 } 610 610 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 611 - cfg80211_rx_mgmt(vif->ndev, freq, 0, 611 + cfg80211_rx_mgmt(&vif->wdev, freq, 0, 612 612 ev->data, dlen, GFP_ATOMIC); 613 613 614 614 return 0;
+1 -1
drivers/net/wireless/ath/ath9k/Kconfig
··· 64 64 65 65 config ATH9K_DFS_CERTIFIED 66 66 bool "Atheros DFS support for certified platforms" 67 - depends on ATH9K && EXPERT 67 + depends on ATH9K && CFG80211_CERTIFICATION_ONUS 68 68 default n 69 69 ---help--- 70 70 This option enables DFS support for initiating radiation on
+1
drivers/net/wireless/ath/ath9k/Makefile
··· 17 17 dfs.o \ 18 18 dfs_pattern_detector.o \ 19 19 dfs_pri_detector.o 20 + ath9k-$(CONFIG_PM_SLEEP) += wow.o 20 21 21 22 obj-$(CONFIG_ATH9K) += ath9k.o 22 23
+54 -104
drivers/net/wireless/ath/ath9k/ar9002_hw.c
··· 26 26 static void ar9002_hw_init_mode_regs(struct ath_hw *ah) 27 27 { 28 28 if (AR_SREV_9271(ah)) { 29 - INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271, 30 - ARRAY_SIZE(ar9271Modes_9271), 5); 31 - INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, 32 - ARRAY_SIZE(ar9271Common_9271), 2); 33 - INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg, 34 - ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 5); 29 + INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271); 30 + INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271); 31 + INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg); 35 32 return; 36 33 } 37 34 38 35 if (ah->config.pcie_clock_req) 39 36 INIT_INI_ARRAY(&ah->iniPcieSerdes, 40 - ar9280PciePhy_clkreq_off_L1_9280, 41 - ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2); 37 + ar9280PciePhy_clkreq_off_L1_9280); 42 38 else 43 39 INIT_INI_ARRAY(&ah->iniPcieSerdes, 44 - ar9280PciePhy_clkreq_always_on_L1_9280, 45 - ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); 40 + ar9280PciePhy_clkreq_always_on_L1_9280); 41 + #ifdef CONFIG_PM_SLEEP 42 + INIT_INI_ARRAY(&ah->iniPcieSerdesWow, 43 + ar9280PciePhy_awow); 44 + #endif 46 45 47 46 if (AR_SREV_9287_11_OR_LATER(ah)) { 48 - INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, 49 - ARRAY_SIZE(ar9287Modes_9287_1_1), 5); 50 - INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1, 51 - ARRAY_SIZE(ar9287Common_9287_1_1), 2); 47 + INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1); 48 + INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1); 52 49 } else if (AR_SREV_9285_12_OR_LATER(ah)) { 53 - INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2, 54 - ARRAY_SIZE(ar9285Modes_9285_1_2), 5); 55 - INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2, 56 - ARRAY_SIZE(ar9285Common_9285_1_2), 2); 50 + INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2); 51 + INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2); 57 52 } else if (AR_SREV_9280_20_OR_LATER(ah)) { 58 - INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2, 59 - ARRAY_SIZE(ar9280Modes_9280_2), 5); 60 - INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, 61 - ARRAY_SIZE(ar9280Common_9280_2), 2); 53 + INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2); 54 + INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2); 62 55 63 56 INIT_INI_ARRAY(&ah->iniModesFastClock, 64 - ar9280Modes_fast_clock_9280_2, 65 - ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); 57 + ar9280Modes_fast_clock_9280_2); 66 58 } else if (AR_SREV_9160_10_OR_LATER(ah)) { 67 - INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160, 68 - ARRAY_SIZE(ar5416Modes_9160), 5); 69 - INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160, 70 - ARRAY_SIZE(ar5416Common_9160), 2); 59 + INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160); 60 + INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160); 71 61 if (AR_SREV_9160_11(ah)) { 72 62 INIT_INI_ARRAY(&ah->iniAddac, 73 - ar5416Addac_9160_1_1, 74 - ARRAY_SIZE(ar5416Addac_9160_1_1), 2); 63 + ar5416Addac_9160_1_1); 75 64 } else { 76 - INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160, 77 - ARRAY_SIZE(ar5416Addac_9160), 2); 65 + INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160); 78 66 } 79 67 } else if (AR_SREV_9100_OR_LATER(ah)) { 80 - INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100, 81 - ARRAY_SIZE(ar5416Modes_9100), 5); 82 - INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100, 83 - ARRAY_SIZE(ar5416Common_9100), 2); 84 - INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100, 85 - ARRAY_SIZE(ar5416Bank6_9100), 3); 86 - INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100, 87 - ARRAY_SIZE(ar5416Addac_9100), 2); 68 + INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100); 69 + INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100); 70 + INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100); 71 + INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100); 88 72 } else { 89 - INIT_INI_ARRAY(&ah->iniModes, ar5416Modes, 90 - ARRAY_SIZE(ar5416Modes), 5); 91 - INIT_INI_ARRAY(&ah->iniCommon, ar5416Common, 92 - ARRAY_SIZE(ar5416Common), 2); 93 - INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, 94 - ARRAY_SIZE(ar5416Bank6TPC), 3); 95 - INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, 96 - ARRAY_SIZE(ar5416Addac), 2); 73 + INIT_INI_ARRAY(&ah->iniModes, ar5416Modes); 74 + INIT_INI_ARRAY(&ah->iniCommon, ar5416Common); 75 + INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC); 76 + INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac); 97 77 } 98 78 99 79 if (!AR_SREV_9280_20_OR_LATER(ah)) { 100 80 /* Common for AR5416, AR913x, AR9160 */ 101 - INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain, 102 - ARRAY_SIZE(ar5416BB_RfGain), 3); 81 + INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain); 103 82 104 - INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, 105 - ARRAY_SIZE(ar5416Bank0), 2); 106 - INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1, 107 - ARRAY_SIZE(ar5416Bank1), 2); 108 - INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2, 109 - ARRAY_SIZE(ar5416Bank2), 2); 110 - INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3, 111 - ARRAY_SIZE(ar5416Bank3), 3); 112 - INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7, 113 - ARRAY_SIZE(ar5416Bank7), 2); 83 + INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0); 84 + INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1); 85 + INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2); 86 + INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3); 87 + INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7); 114 88 115 89 /* Common for AR5416, AR9160 */ 116 90 if (!AR_SREV_9100(ah)) 117 - INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, 118 - ARRAY_SIZE(ar5416Bank6), 3); 91 + INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6); 119 92 120 93 /* Common for AR913x, AR9160 */ 121 94 if (!AR_SREV_5416(ah)) 122 - INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, 123 - ARRAY_SIZE(ar5416Bank6TPC_9100), 3); 95 + INIT_INI_ARRAY(&ah->iniBank6TPC, 96 + ar5416Bank6TPC_9100); 124 97 } 125 98 126 99 /* iniAddac needs to be modified for these chips */ ··· 116 143 } 117 144 if (AR_SREV_9287_11_OR_LATER(ah)) { 118 145 INIT_INI_ARRAY(&ah->iniCckfirNormal, 119 - ar9287Common_normal_cck_fir_coeff_9287_1_1, 120 - ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_9287_1_1), 121 - 2); 146 + ar9287Common_normal_cck_fir_coeff_9287_1_1); 122 147 INIT_INI_ARRAY(&ah->iniCckfirJapan2484, 123 - ar9287Common_japan_2484_cck_fir_coeff_9287_1_1, 124 - ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_9287_1_1), 125 - 2); 148 + ar9287Common_japan_2484_cck_fir_coeff_9287_1_1); 126 149 } 127 150 } 128 151 ··· 132 163 133 164 if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF) 134 165 INIT_INI_ARRAY(&ah->iniModesRxGain, 135 - ar9280Modes_backoff_13db_rxgain_9280_2, 136 - ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 5); 166 + ar9280Modes_backoff_13db_rxgain_9280_2); 137 167 else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF) 138 168 INIT_INI_ARRAY(&ah->iniModesRxGain, 139 - ar9280Modes_backoff_23db_rxgain_9280_2, 140 - ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 5); 169 + ar9280Modes_backoff_23db_rxgain_9280_2); 141 170 else 142 171 INIT_INI_ARRAY(&ah->iniModesRxGain, 143 - ar9280Modes_original_rxgain_9280_2, 144 - ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 5); 172 + ar9280Modes_original_rxgain_9280_2); 145 173 } else { 146 174 INIT_INI_ARRAY(&ah->iniModesRxGain, 147 - ar9280Modes_original_rxgain_9280_2, 148 - ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 5); 175 + ar9280Modes_original_rxgain_9280_2); 149 176 } 150 177 } 151 178 ··· 151 186 AR5416_EEP_MINOR_VER_19) { 152 187 if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) 153 188 INIT_INI_ARRAY(&ah->iniModesTxGain, 154 - ar9280Modes_high_power_tx_gain_9280_2, 155 - ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 5); 189 + ar9280Modes_high_power_tx_gain_9280_2); 156 190 else 157 191 INIT_INI_ARRAY(&ah->iniModesTxGain, 158 - ar9280Modes_original_tx_gain_9280_2, 159 - ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 5); 192 + ar9280Modes_original_tx_gain_9280_2); 160 193 } else { 161 194 INIT_INI_ARRAY(&ah->iniModesTxGain, 162 - ar9280Modes_original_tx_gain_9280_2, 163 - ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 5); 195 + ar9280Modes_original_tx_gain_9280_2); 164 196 } 165 197 } 166 198 ··· 165 203 { 166 204 if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) 167 205 INIT_INI_ARRAY(&ah->iniModesTxGain, 168 - ar9271Modes_high_power_tx_gain_9271, 169 - ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 5); 206 + ar9271Modes_high_power_tx_gain_9271); 170 207 else 171 208 INIT_INI_ARRAY(&ah->iniModesTxGain, 172 - ar9271Modes_normal_power_tx_gain_9271, 173 - ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 5); 209 + ar9271Modes_normal_power_tx_gain_9271); 174 210 } 175 211 176 212 static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah) ··· 177 217 178 218 if (AR_SREV_9287_11_OR_LATER(ah)) 179 219 INIT_INI_ARRAY(&ah->iniModesRxGain, 180 - ar9287Modes_rx_gain_9287_1_1, 181 - ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 5); 220 + ar9287Modes_rx_gain_9287_1_1); 182 221 else if (AR_SREV_9280_20(ah)) 183 222 ar9280_20_hw_init_rxgain_ini(ah); 184 223 ··· 185 226 ar9271_hw_init_txgain_ini(ah, txgain_type); 186 227 } else if (AR_SREV_9287_11_OR_LATER(ah)) { 187 228 INIT_INI_ARRAY(&ah->iniModesTxGain, 188 - ar9287Modes_tx_gain_9287_1_1, 189 - ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 5); 229 + ar9287Modes_tx_gain_9287_1_1); 190 230 } else if (AR_SREV_9280_20(ah)) { 191 231 ar9280_20_hw_init_txgain_ini(ah, txgain_type); 192 232 } else if (AR_SREV_9285_12_OR_LATER(ah)) { ··· 193 235 if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) { 194 236 if (AR_SREV_9285E_20(ah)) { 195 237 INIT_INI_ARRAY(&ah->iniModesTxGain, 196 - ar9285Modes_XE2_0_high_power, 197 - ARRAY_SIZE( 198 - ar9285Modes_XE2_0_high_power), 5); 238 + ar9285Modes_XE2_0_high_power); 199 239 } else { 200 240 INIT_INI_ARRAY(&ah->iniModesTxGain, 201 - ar9285Modes_high_power_tx_gain_9285_1_2, 202 - ARRAY_SIZE( 203 - ar9285Modes_high_power_tx_gain_9285_1_2), 5); 241 + ar9285Modes_high_power_tx_gain_9285_1_2); 204 242 } 205 243 } else { 206 244 if (AR_SREV_9285E_20(ah)) { 207 245 INIT_INI_ARRAY(&ah->iniModesTxGain, 208 - ar9285Modes_XE2_0_normal_power, 209 - ARRAY_SIZE( 210 - ar9285Modes_XE2_0_normal_power), 5); 246 + ar9285Modes_XE2_0_normal_power); 211 247 } else { 212 248 INIT_INI_ARRAY(&ah->iniModesTxGain, 213 - ar9285Modes_original_tx_gain_9285_1_2, 214 - ARRAY_SIZE( 215 - ar9285Modes_original_tx_gain_9285_1_2), 5); 249 + ar9285Modes_original_tx_gain_9285_1_2); 216 250 } 217 251 } 218 252 }
+14
drivers/net/wireless/ath/ath9k/ar9002_initvals.h
··· 925 925 {0x00004044, 0x00000000}, 926 926 }; 927 927 928 + static const u32 ar9280PciePhy_awow[][2] = { 929 + /* Addr allmodes */ 930 + {0x00004040, 0x9248fd00}, 931 + {0x00004040, 0x24924924}, 932 + {0x00004040, 0xa8000019}, 933 + {0x00004040, 0x13160820}, 934 + {0x00004040, 0xe5980560}, 935 + {0x00004040, 0xc01dcffd}, 936 + {0x00004040, 0x1aaabe41}, 937 + {0x00004040, 0xbe105554}, 938 + {0x00004040, 0x00043007}, 939 + {0x00004044, 0x00000000}, 940 + }; 941 + 928 942 static const u32 ar9285Modes_9285_1_2[][5] = { 929 943 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 930 944 {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160},
+110 -88
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
··· 131 131 .thresh62 = 28, 132 132 .papdRateMaskHt20 = LE32(0x0cf0e0e0), 133 133 .papdRateMaskHt40 = LE32(0x6cf0e0e0), 134 + .xlna_bias_strength = 0, 134 135 .futureModal = { 135 - 0, 0, 0, 0, 0, 0, 0, 0, 136 + 0, 0, 0, 0, 0, 0, 0, 136 137 }, 137 138 }, 138 139 .base_ext1 = { ··· 332 331 .thresh62 = 28, 333 332 .papdRateMaskHt20 = LE32(0x0c80c080), 334 333 .papdRateMaskHt40 = LE32(0x0080c080), 334 + .xlna_bias_strength = 0, 335 335 .futureModal = { 336 - 0, 0, 0, 0, 0, 0, 0, 0, 336 + 0, 0, 0, 0, 0, 0, 0, 337 337 }, 338 338 }, 339 339 .base_ext2 = { ··· 706 704 .thresh62 = 28, 707 705 .papdRateMaskHt20 = LE32(0x0c80c080), 708 706 .papdRateMaskHt40 = LE32(0x0080c080), 707 + .xlna_bias_strength = 0, 709 708 .futureModal = { 710 - 0, 0, 0, 0, 0, 0, 0, 0, 709 + 0, 0, 0, 0, 0, 0, 0, 711 710 }, 712 711 }, 713 712 .base_ext1 = { ··· 907 904 .thresh62 = 28, 908 905 .papdRateMaskHt20 = LE32(0x0cf0e0e0), 909 906 .papdRateMaskHt40 = LE32(0x6cf0e0e0), 907 + .xlna_bias_strength = 0, 910 908 .futureModal = { 911 - 0, 0, 0, 0, 0, 0, 0, 0, 909 + 0, 0, 0, 0, 0, 0, 0, 912 910 }, 913 911 }, 914 912 .base_ext2 = { ··· 1282 1278 .thresh62 = 28, 1283 1279 .papdRateMaskHt20 = LE32(0x0c80c080), 1284 1280 .papdRateMaskHt40 = LE32(0x0080c080), 1281 + .xlna_bias_strength = 0, 1285 1282 .futureModal = { 1286 - 0, 0, 0, 0, 0, 0, 0, 0, 1283 + 0, 0, 0, 0, 0, 0, 0, 1287 1284 }, 1288 1285 }, 1289 1286 .base_ext1 = { ··· 1483 1478 .thresh62 = 28, 1484 1479 .papdRateMaskHt20 = LE32(0x0cf0e0e0), 1485 1480 .papdRateMaskHt40 = LE32(0x6cf0e0e0), 1481 + .xlna_bias_strength = 0, 1486 1482 .futureModal = { 1487 - 0, 0, 0, 0, 0, 0, 0, 0, 1483 + 0, 0, 0, 0, 0, 0, 0, 1488 1484 }, 1489 1485 }, 1490 1486 .base_ext2 = { ··· 1858 1852 .thresh62 = 28, 1859 1853 .papdRateMaskHt20 = LE32(0x0c80c080), 1860 1854 .papdRateMaskHt40 = LE32(0x0080c080), 1855 + .xlna_bias_strength = 0, 1861 1856 .futureModal = { 1862 - 0, 0, 0, 0, 0, 0, 0, 0, 1857 + 0, 0, 0, 0, 0, 0, 0, 1863 1858 }, 1864 1859 }, 1865 1860 .base_ext1 = { ··· 2059 2052 .thresh62 = 28, 2060 2053 .papdRateMaskHt20 = LE32(0x0cf0e0e0), 2061 2054 .papdRateMaskHt40 = LE32(0x6cf0e0e0), 2055 + .xlna_bias_strength = 0, 2062 2056 .futureModal = { 2063 - 0, 0, 0, 0, 0, 0, 0, 0, 2057 + 0, 0, 0, 0, 0, 0, 0, 2064 2058 }, 2065 2059 }, 2066 2060 .base_ext2 = { ··· 2433 2425 .thresh62 = 28, 2434 2426 .papdRateMaskHt20 = LE32(0x0c80C080), 2435 2427 .papdRateMaskHt40 = LE32(0x0080C080), 2428 + .xlna_bias_strength = 0, 2436 2429 .futureModal = { 2437 - 0, 0, 0, 0, 0, 0, 0, 0, 2430 + 0, 0, 0, 0, 0, 0, 0, 2438 2431 }, 2439 2432 }, 2440 2433 .base_ext1 = { ··· 2634 2625 .thresh62 = 28, 2635 2626 .papdRateMaskHt20 = LE32(0x0cf0e0e0), 2636 2627 .papdRateMaskHt40 = LE32(0x6cf0e0e0), 2628 + .xlna_bias_strength = 0, 2637 2629 .futureModal = { 2638 - 0, 0, 0, 0, 0, 0, 0, 0, 2630 + 0, 0, 0, 0, 0, 0, 0, 2639 2631 }, 2640 2632 }, 2641 2633 .base_ext2 = { ··· 2981 2971 return (pBase->txrxMask >> 4) & 0xf; 2982 2972 case EEP_RX_MASK: 2983 2973 return pBase->txrxMask & 0xf; 2984 - case EEP_DRIVE_STRENGTH: 2985 - #define AR9300_EEP_BASE_DRIV_STRENGTH 0x1 2986 - return pBase->miscConfiguration & AR9300_EEP_BASE_DRIV_STRENGTH; 2987 - case EEP_INTERNAL_REGULATOR: 2988 - /* Bit 4 is internal regulator flag */ 2989 - return (pBase->featureEnable & 0x10) >> 4; 2990 - case EEP_SWREG: 2991 - return le32_to_cpu(pBase->swreg); 2992 2974 case EEP_PAPRD: 2993 2975 return !!(pBase->featureEnable & BIT(5)); 2994 2976 case EEP_CHAIN_MASK_REDUCE: ··· 2991 2989 return eep->modalHeader5G.antennaGain; 2992 2990 case EEP_ANTENNA_GAIN_2G: 2993 2991 return eep->modalHeader2G.antennaGain; 2994 - case EEP_QUICK_DROP: 2995 - return pBase->miscConfiguration & BIT(1); 2996 2992 default: 2997 2993 return 0; 2998 2994 } ··· 3260 3260 int it; 3261 3261 u16 checksum, mchecksum; 3262 3262 struct ath_common *common = ath9k_hw_common(ah); 3263 + struct ar9300_eeprom *eep; 3263 3264 eeprom_read_op read; 3264 3265 3265 - if (ath9k_hw_use_flash(ah)) 3266 - return ar9300_eeprom_restore_flash(ah, mptr, mdata_size); 3266 + if (ath9k_hw_use_flash(ah)) { 3267 + u8 txrx; 3268 + 3269 + ar9300_eeprom_restore_flash(ah, mptr, mdata_size); 3270 + 3271 + /* check if eeprom contains valid data */ 3272 + eep = (struct ar9300_eeprom *) mptr; 3273 + txrx = eep->baseEepHeader.txrxMask; 3274 + if (txrx != 0 && txrx != 0xff) 3275 + return 0; 3276 + } 3267 3277 3268 3278 word = kzalloc(2048, GFP_KERNEL); 3269 3279 if (!word) ··· 3503 3493 return 0; 3504 3494 } 3505 3495 3506 - static s32 ar9003_hw_xpa_bias_level_get(struct ath_hw *ah, bool is2ghz) 3496 + static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah, 3497 + bool is2ghz) 3507 3498 { 3508 3499 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3509 3500 3510 3501 if (is2ghz) 3511 - return eep->modalHeader2G.xpaBiasLvl; 3502 + return &eep->modalHeader2G; 3512 3503 else 3513 - return eep->modalHeader5G.xpaBiasLvl; 3504 + return &eep->modalHeader5G; 3514 3505 } 3515 3506 3516 3507 static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz) 3517 3508 { 3518 - int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz); 3509 + int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl; 3519 3510 3520 3511 if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) 3521 3512 REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias); ··· 3532 3521 } 3533 3522 } 3534 3523 3535 - static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is_2ghz) 3524 + static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz) 3536 3525 { 3537 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3538 - __le16 val; 3539 - 3540 - if (is_2ghz) 3541 - val = eep->modalHeader2G.switchcomspdt; 3542 - else 3543 - val = eep->modalHeader5G.switchcomspdt; 3544 - return le16_to_cpu(val); 3526 + return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt); 3545 3527 } 3546 3528 3547 3529 3548 3530 static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) 3549 3531 { 3550 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3551 - __le32 val; 3552 - 3553 - if (is2ghz) 3554 - val = eep->modalHeader2G.antCtrlCommon; 3555 - else 3556 - val = eep->modalHeader5G.antCtrlCommon; 3557 - return le32_to_cpu(val); 3532 + return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon); 3558 3533 } 3559 3534 3560 3535 static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) 3561 3536 { 3562 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3563 - __le32 val; 3564 - 3565 - if (is2ghz) 3566 - val = eep->modalHeader2G.antCtrlCommon2; 3567 - else 3568 - val = eep->modalHeader5G.antCtrlCommon2; 3569 - return le32_to_cpu(val); 3537 + return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2); 3570 3538 } 3571 3539 3572 - static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, 3573 - int chain, 3540 + static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain, 3574 3541 bool is2ghz) 3575 3542 { 3576 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3577 - __le16 val = 0; 3578 - 3579 - if (chain >= 0 && chain < AR9300_MAX_CHAINS) { 3580 - if (is2ghz) 3581 - val = eep->modalHeader2G.antCtrlChain[chain]; 3582 - else 3583 - val = eep->modalHeader5G.antCtrlChain[chain]; 3584 - } 3585 - 3543 + __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain]; 3586 3544 return le16_to_cpu(val); 3587 3545 } 3588 3546 ··· 3661 3681 3662 3682 static void ar9003_hw_drive_strength_apply(struct ath_hw *ah) 3663 3683 { 3684 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3685 + struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader; 3664 3686 int drive_strength; 3665 3687 unsigned long reg; 3666 3688 3667 - drive_strength = ath9k_hw_ar9300_get_eeprom(ah, EEP_DRIVE_STRENGTH); 3668 - 3689 + drive_strength = pBase->miscConfiguration & BIT(0); 3669 3690 if (!drive_strength) 3670 3691 return; 3671 3692 ··· 3796 3815 3797 3816 void ar9003_hw_internal_regulator_apply(struct ath_hw *ah) 3798 3817 { 3799 - int internal_regulator = 3800 - ath9k_hw_ar9300_get_eeprom(ah, EEP_INTERNAL_REGULATOR); 3818 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3819 + struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader; 3801 3820 u32 reg_val; 3802 3821 3803 - if (internal_regulator) { 3822 + if (pBase->featureEnable & BIT(4)) { 3804 3823 if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { 3805 3824 int reg_pmu_set; 3806 3825 ··· 3844 3863 if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set)) 3845 3864 return; 3846 3865 } else if (AR_SREV_9462(ah)) { 3847 - reg_val = ath9k_hw_ar9300_get_eeprom(ah, EEP_SWREG); 3866 + reg_val = le32_to_cpu(pBase->swreg); 3848 3867 REG_WRITE(ah, AR_PHY_PMU1, reg_val); 3849 3868 } else { 3850 3869 /* Internal regulator is ON. Write swreg register. */ 3851 - reg_val = ath9k_hw_ar9300_get_eeprom(ah, EEP_SWREG); 3870 + reg_val = le32_to_cpu(pBase->swreg); 3852 3871 REG_WRITE(ah, AR_RTC_REG_CONTROL1, 3853 3872 REG_READ(ah, AR_RTC_REG_CONTROL1) & 3854 3873 (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM)); ··· 3890 3909 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3891 3910 u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0]; 3892 3911 3912 + if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) 3913 + return; 3914 + 3893 3915 if (eep->baseEepHeader.featureEnable & 0x40) { 3894 3916 tuning_caps_param &= 0x7f; 3895 3917 REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC, ··· 3905 3921 static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq) 3906 3922 { 3907 3923 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3908 - int quick_drop = ath9k_hw_ar9300_get_eeprom(ah, EEP_QUICK_DROP); 3924 + struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader; 3925 + int quick_drop; 3909 3926 s32 t[3], f[3] = {5180, 5500, 5785}; 3910 3927 3911 - if (!quick_drop) 3928 + if (!(pBase->miscConfiguration & BIT(1))) 3912 3929 return; 3913 3930 3914 3931 if (freq < 4000) ··· 3923 3938 REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop); 3924 3939 } 3925 3940 3926 - static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, u16 freq) 3941 + static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz) 3927 3942 { 3928 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3929 3943 u32 value; 3930 3944 3931 - value = (freq < 4000) ? eep->modalHeader2G.txEndToXpaOff : 3932 - eep->modalHeader5G.txEndToXpaOff; 3945 + value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff; 3933 3946 3934 3947 REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, 3935 3948 AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value); ··· 3935 3952 AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value); 3936 3953 } 3937 3954 3955 + static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz) 3956 + { 3957 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3958 + u8 xpa_ctl; 3959 + 3960 + if (!(eep->baseEepHeader.featureEnable & 0x80)) 3961 + return; 3962 + 3963 + if (!AR_SREV_9300(ah) && !AR_SREV_9340(ah) && !AR_SREV_9580(ah)) 3964 + return; 3965 + 3966 + xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn; 3967 + if (is2ghz) 3968 + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, 3969 + AR_PHY_XPA_TIMING_CTL_FRAME_XPAB_ON, xpa_ctl); 3970 + else 3971 + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, 3972 + AR_PHY_XPA_TIMING_CTL_FRAME_XPAA_ON, xpa_ctl); 3973 + } 3974 + 3975 + static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz) 3976 + { 3977 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3978 + u8 bias; 3979 + 3980 + if (!(eep->baseEepHeader.featureEnable & 0x40)) 3981 + return; 3982 + 3983 + if (!AR_SREV_9300(ah)) 3984 + return; 3985 + 3986 + bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength; 3987 + REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS, 3988 + bias & 0x3); 3989 + bias >>= 2; 3990 + REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS, 3991 + bias & 0x3); 3992 + bias >>= 2; 3993 + REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS, 3994 + bias & 0x3); 3995 + } 3996 + 3938 3997 static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, 3939 3998 struct ath9k_channel *chan) 3940 3999 { 3941 - ar9003_hw_xpa_bias_level_apply(ah, IS_CHAN_2GHZ(chan)); 3942 - ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); 4000 + bool is2ghz = IS_CHAN_2GHZ(chan); 4001 + ar9003_hw_xpa_timing_control_apply(ah, is2ghz); 4002 + ar9003_hw_xpa_bias_level_apply(ah, is2ghz); 4003 + ar9003_hw_ant_ctrl_apply(ah, is2ghz); 3943 4004 ar9003_hw_drive_strength_apply(ah); 4005 + ar9003_hw_xlna_bias_strength_apply(ah, is2ghz); 3944 4006 ar9003_hw_atten_apply(ah, chan); 3945 4007 ar9003_hw_quick_drop_apply(ah, chan->channel); 3946 4008 if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && !AR_SREV_9550(ah)) 3947 4009 ar9003_hw_internal_regulator_apply(ah); 3948 - if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) 3949 - ar9003_hw_apply_tuning_caps(ah); 3950 - ar9003_hw_txend_to_xpa_off_apply(ah, chan->channel); 4010 + ar9003_hw_apply_tuning_caps(ah); 4011 + ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz); 3951 4012 } 3952 4013 3953 4014 static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, ··· 5127 5100 return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */ 5128 5101 } 5129 5102 5130 - u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz) 5103 + u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz) 5131 5104 { 5132 - struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 5133 - 5134 - if (is_2ghz) 5135 - return eep->modalHeader2G.spurChans; 5136 - else 5137 - return eep->modalHeader5G.spurChans; 5105 + return ar9003_modal_header(ah, is2ghz)->spurChans; 5138 5106 } 5139 5107 5140 5108 unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
+2 -1
drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
··· 231 231 __le32 papdRateMaskHt20; 232 232 __le32 papdRateMaskHt40; 233 233 __le16 switchcomspdt; 234 - u8 futureModal[8]; 234 + u8 xlna_bias_strength; 235 + u8 futureModal[7]; 235 236 } __packed; 236 237 237 238 struct ar9300_cal_data_per_freq_op_loop {
+157 -389
drivers/net/wireless/ath/ath9k/ar9003_hw.c
··· 44 44 ar9462_2p0_baseband_core_txfir_coeff_japan_2484 45 45 if (AR_SREV_9330_11(ah)) { 46 46 /* mac */ 47 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 48 47 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 49 - ar9331_1p1_mac_core, 50 - ARRAY_SIZE(ar9331_1p1_mac_core), 2); 48 + ar9331_1p1_mac_core); 51 49 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 52 - ar9331_1p1_mac_postamble, 53 - ARRAY_SIZE(ar9331_1p1_mac_postamble), 5); 50 + ar9331_1p1_mac_postamble); 54 51 55 52 /* bb */ 56 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 57 53 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 58 - ar9331_1p1_baseband_core, 59 - ARRAY_SIZE(ar9331_1p1_baseband_core), 2); 54 + ar9331_1p1_baseband_core); 60 55 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 61 - ar9331_1p1_baseband_postamble, 62 - ARRAY_SIZE(ar9331_1p1_baseband_postamble), 5); 56 + ar9331_1p1_baseband_postamble); 63 57 64 58 /* radio */ 65 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 66 59 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 67 - ar9331_1p1_radio_core, 68 - ARRAY_SIZE(ar9331_1p1_radio_core), 2); 69 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0); 60 + ar9331_1p1_radio_core); 70 61 71 62 /* soc */ 72 63 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 73 - ar9331_1p1_soc_preamble, 74 - ARRAY_SIZE(ar9331_1p1_soc_preamble), 2); 75 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 64 + ar9331_1p1_soc_preamble); 76 65 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 77 - ar9331_1p1_soc_postamble, 78 - ARRAY_SIZE(ar9331_1p1_soc_postamble), 2); 66 + ar9331_1p1_soc_postamble); 79 67 80 68 /* rx/tx gain */ 81 69 INIT_INI_ARRAY(&ah->iniModesRxGain, 82 - ar9331_common_rx_gain_1p1, 83 - ARRAY_SIZE(ar9331_common_rx_gain_1p1), 2); 70 + ar9331_common_rx_gain_1p1); 84 71 INIT_INI_ARRAY(&ah->iniModesTxGain, 85 - ar9331_modes_lowest_ob_db_tx_gain_1p1, 86 - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1), 87 - 5); 72 + ar9331_modes_lowest_ob_db_tx_gain_1p1); 88 73 89 74 /* additional clock settings */ 90 75 if (ah->is_clk_25mhz) 91 76 INIT_INI_ARRAY(&ah->iniAdditional, 92 - ar9331_1p1_xtal_25M, 93 - ARRAY_SIZE(ar9331_1p1_xtal_25M), 2); 77 + ar9331_1p1_xtal_25M); 94 78 else 95 79 INIT_INI_ARRAY(&ah->iniAdditional, 96 - ar9331_1p1_xtal_40M, 97 - ARRAY_SIZE(ar9331_1p1_xtal_40M), 2); 80 + ar9331_1p1_xtal_40M); 98 81 } else if (AR_SREV_9330_12(ah)) { 99 82 /* mac */ 100 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 101 83 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 102 - ar9331_1p2_mac_core, 103 - ARRAY_SIZE(ar9331_1p2_mac_core), 2); 84 + ar9331_1p2_mac_core); 104 85 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 105 - ar9331_1p2_mac_postamble, 106 - ARRAY_SIZE(ar9331_1p2_mac_postamble), 5); 86 + ar9331_1p2_mac_postamble); 107 87 108 88 /* bb */ 109 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 110 89 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 111 - ar9331_1p2_baseband_core, 112 - ARRAY_SIZE(ar9331_1p2_baseband_core), 2); 90 + ar9331_1p2_baseband_core); 113 91 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 114 - ar9331_1p2_baseband_postamble, 115 - ARRAY_SIZE(ar9331_1p2_baseband_postamble), 5); 92 + ar9331_1p2_baseband_postamble); 116 93 117 94 /* radio */ 118 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 119 95 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 120 - ar9331_1p2_radio_core, 121 - ARRAY_SIZE(ar9331_1p2_radio_core), 2); 122 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0); 96 + ar9331_1p2_radio_core); 123 97 124 98 /* soc */ 125 99 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 126 - ar9331_1p2_soc_preamble, 127 - ARRAY_SIZE(ar9331_1p2_soc_preamble), 2); 128 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 100 + ar9331_1p2_soc_preamble); 129 101 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 130 - ar9331_1p2_soc_postamble, 131 - ARRAY_SIZE(ar9331_1p2_soc_postamble), 2); 102 + ar9331_1p2_soc_postamble); 132 103 133 104 /* rx/tx gain */ 134 105 INIT_INI_ARRAY(&ah->iniModesRxGain, 135 - ar9331_common_rx_gain_1p2, 136 - ARRAY_SIZE(ar9331_common_rx_gain_1p2), 2); 106 + ar9331_common_rx_gain_1p2); 137 107 INIT_INI_ARRAY(&ah->iniModesTxGain, 138 - ar9331_modes_lowest_ob_db_tx_gain_1p2, 139 - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2), 140 - 5); 108 + ar9331_modes_lowest_ob_db_tx_gain_1p2); 141 109 142 110 /* additional clock settings */ 143 111 if (ah->is_clk_25mhz) 144 112 INIT_INI_ARRAY(&ah->iniAdditional, 145 - ar9331_1p2_xtal_25M, 146 - ARRAY_SIZE(ar9331_1p2_xtal_25M), 2); 113 + ar9331_1p2_xtal_25M); 147 114 else 148 115 INIT_INI_ARRAY(&ah->iniAdditional, 149 - ar9331_1p2_xtal_40M, 150 - ARRAY_SIZE(ar9331_1p2_xtal_40M), 2); 116 + ar9331_1p2_xtal_40M); 151 117 } else if (AR_SREV_9340(ah)) { 152 118 /* mac */ 153 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 154 119 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 155 - ar9340_1p0_mac_core, 156 - ARRAY_SIZE(ar9340_1p0_mac_core), 2); 120 + ar9340_1p0_mac_core); 157 121 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 158 - ar9340_1p0_mac_postamble, 159 - ARRAY_SIZE(ar9340_1p0_mac_postamble), 5); 122 + ar9340_1p0_mac_postamble); 160 123 161 124 /* bb */ 162 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 163 125 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 164 - ar9340_1p0_baseband_core, 165 - ARRAY_SIZE(ar9340_1p0_baseband_core), 2); 126 + ar9340_1p0_baseband_core); 166 127 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 167 - ar9340_1p0_baseband_postamble, 168 - ARRAY_SIZE(ar9340_1p0_baseband_postamble), 5); 128 + ar9340_1p0_baseband_postamble); 169 129 170 130 /* radio */ 171 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 172 131 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 173 - ar9340_1p0_radio_core, 174 - ARRAY_SIZE(ar9340_1p0_radio_core), 2); 132 + ar9340_1p0_radio_core); 175 133 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 176 - ar9340_1p0_radio_postamble, 177 - ARRAY_SIZE(ar9340_1p0_radio_postamble), 5); 134 + ar9340_1p0_radio_postamble); 178 135 179 136 /* soc */ 180 137 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 181 - ar9340_1p0_soc_preamble, 182 - ARRAY_SIZE(ar9340_1p0_soc_preamble), 2); 183 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 138 + ar9340_1p0_soc_preamble); 184 139 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 185 - ar9340_1p0_soc_postamble, 186 - ARRAY_SIZE(ar9340_1p0_soc_postamble), 5); 140 + ar9340_1p0_soc_postamble); 187 141 188 142 /* rx/tx gain */ 189 143 INIT_INI_ARRAY(&ah->iniModesRxGain, 190 - ar9340Common_wo_xlna_rx_gain_table_1p0, 191 - ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0), 192 - 5); 144 + ar9340Common_wo_xlna_rx_gain_table_1p0); 193 145 INIT_INI_ARRAY(&ah->iniModesTxGain, 194 - ar9340Modes_high_ob_db_tx_gain_table_1p0, 195 - ARRAY_SIZE(ar9340Modes_high_ob_db_tx_gain_table_1p0), 196 - 5); 146 + ar9340Modes_high_ob_db_tx_gain_table_1p0); 197 147 198 148 INIT_INI_ARRAY(&ah->iniModesFastClock, 199 - ar9340Modes_fast_clock_1p0, 200 - ARRAY_SIZE(ar9340Modes_fast_clock_1p0), 201 - 3); 149 + ar9340Modes_fast_clock_1p0); 202 150 203 151 if (!ah->is_clk_25mhz) 204 152 INIT_INI_ARRAY(&ah->iniAdditional, 205 - ar9340_1p0_radio_core_40M, 206 - ARRAY_SIZE(ar9340_1p0_radio_core_40M), 207 - 2); 153 + ar9340_1p0_radio_core_40M); 208 154 } else if (AR_SREV_9485_11(ah)) { 209 155 /* mac */ 210 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 211 156 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 212 - ar9485_1_1_mac_core, 213 - ARRAY_SIZE(ar9485_1_1_mac_core), 2); 157 + ar9485_1_1_mac_core); 214 158 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 215 - ar9485_1_1_mac_postamble, 216 - ARRAY_SIZE(ar9485_1_1_mac_postamble), 5); 159 + ar9485_1_1_mac_postamble); 217 160 218 161 /* bb */ 219 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1, 220 - ARRAY_SIZE(ar9485_1_1), 2); 162 + INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1); 221 163 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 222 - ar9485_1_1_baseband_core, 223 - ARRAY_SIZE(ar9485_1_1_baseband_core), 2); 164 + ar9485_1_1_baseband_core); 224 165 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 225 - ar9485_1_1_baseband_postamble, 226 - ARRAY_SIZE(ar9485_1_1_baseband_postamble), 5); 166 + ar9485_1_1_baseband_postamble); 227 167 228 168 /* radio */ 229 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 230 169 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 231 - ar9485_1_1_radio_core, 232 - ARRAY_SIZE(ar9485_1_1_radio_core), 2); 170 + ar9485_1_1_radio_core); 233 171 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 234 - ar9485_1_1_radio_postamble, 235 - ARRAY_SIZE(ar9485_1_1_radio_postamble), 2); 172 + ar9485_1_1_radio_postamble); 236 173 237 174 /* soc */ 238 175 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 239 - ar9485_1_1_soc_preamble, 240 - ARRAY_SIZE(ar9485_1_1_soc_preamble), 2); 241 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 242 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0); 176 + ar9485_1_1_soc_preamble); 243 177 244 178 /* rx/tx gain */ 245 179 INIT_INI_ARRAY(&ah->iniModesRxGain, 246 - ar9485Common_wo_xlna_rx_gain_1_1, 247 - ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 2); 180 + ar9485Common_wo_xlna_rx_gain_1_1); 248 181 INIT_INI_ARRAY(&ah->iniModesTxGain, 249 - ar9485_modes_lowest_ob_db_tx_gain_1_1, 250 - ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1), 251 - 5); 182 + ar9485_modes_lowest_ob_db_tx_gain_1_1); 252 183 253 184 /* Load PCIE SERDES settings from INI */ 254 185 255 186 /* Awake Setting */ 256 187 257 188 INIT_INI_ARRAY(&ah->iniPcieSerdes, 258 - ar9485_1_1_pcie_phy_clkreq_disable_L1, 259 - ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1), 260 - 2); 189 + ar9485_1_1_pcie_phy_clkreq_disable_L1); 261 190 262 191 /* Sleep Setting */ 263 192 264 193 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, 265 - ar9485_1_1_pcie_phy_clkreq_disable_L1, 266 - ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1), 267 - 2); 194 + ar9485_1_1_pcie_phy_clkreq_disable_L1); 268 195 } else if (AR_SREV_9462_20(ah)) { 269 196 270 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 271 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core, 272 - ARRAY_SIZE(ar9462_2p0_mac_core), 2); 197 + INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core); 273 198 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 274 - ar9462_2p0_mac_postamble, 275 - ARRAY_SIZE(ar9462_2p0_mac_postamble), 5); 199 + ar9462_2p0_mac_postamble); 276 200 277 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 278 201 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 279 - ar9462_2p0_baseband_core, 280 - ARRAY_SIZE(ar9462_2p0_baseband_core), 2); 202 + ar9462_2p0_baseband_core); 281 203 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 282 - ar9462_2p0_baseband_postamble, 283 - ARRAY_SIZE(ar9462_2p0_baseband_postamble), 5); 204 + ar9462_2p0_baseband_postamble); 284 205 285 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 286 206 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 287 - ar9462_2p0_radio_core, 288 - ARRAY_SIZE(ar9462_2p0_radio_core), 2); 207 + ar9462_2p0_radio_core); 289 208 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 290 - ar9462_2p0_radio_postamble, 291 - ARRAY_SIZE(ar9462_2p0_radio_postamble), 5); 209 + ar9462_2p0_radio_postamble); 292 210 INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant, 293 - ar9462_2p0_radio_postamble_sys2ant, 294 - ARRAY_SIZE(ar9462_2p0_radio_postamble_sys2ant), 295 - 5); 211 + ar9462_2p0_radio_postamble_sys2ant); 296 212 297 213 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 298 - ar9462_2p0_soc_preamble, 299 - ARRAY_SIZE(ar9462_2p0_soc_preamble), 2); 300 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 214 + ar9462_2p0_soc_preamble); 301 215 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 302 - ar9462_2p0_soc_postamble, 303 - ARRAY_SIZE(ar9462_2p0_soc_postamble), 5); 216 + ar9462_2p0_soc_postamble); 304 217 305 218 INIT_INI_ARRAY(&ah->iniModesRxGain, 306 - ar9462_common_rx_gain_table_2p0, 307 - ARRAY_SIZE(ar9462_common_rx_gain_table_2p0), 2); 219 + ar9462_common_rx_gain_table_2p0); 308 220 309 221 /* Awake -> Sleep Setting */ 310 222 INIT_INI_ARRAY(&ah->iniPcieSerdes, 311 - PCIE_PLL_ON_CREQ_DIS_L1_2P0, 312 - ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0), 313 - 2); 223 + PCIE_PLL_ON_CREQ_DIS_L1_2P0); 314 224 /* Sleep -> Awake Setting */ 315 225 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, 316 - PCIE_PLL_ON_CREQ_DIS_L1_2P0, 317 - ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0), 318 - 2); 226 + PCIE_PLL_ON_CREQ_DIS_L1_2P0); 319 227 320 228 /* Fast clock modal settings */ 321 229 INIT_INI_ARRAY(&ah->iniModesFastClock, 322 - ar9462_modes_fast_clock_2p0, 323 - ARRAY_SIZE(ar9462_modes_fast_clock_2p0), 3); 230 + ar9462_modes_fast_clock_2p0); 324 231 325 232 INIT_INI_ARRAY(&ah->iniCckfirJapan2484, 326 - AR9462_BB_CTX_COEFJ(2p0), 327 - ARRAY_SIZE(AR9462_BB_CTX_COEFJ(2p0)), 2); 233 + AR9462_BB_CTX_COEFJ(2p0)); 328 234 329 - INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ, 330 - ARRAY_SIZE(AR9462_BBC_TXIFR_COEFFJ), 2); 235 + INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ); 331 236 } else if (AR_SREV_9550(ah)) { 332 237 /* mac */ 333 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 334 238 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 335 - ar955x_1p0_mac_core, 336 - ARRAY_SIZE(ar955x_1p0_mac_core), 2); 239 + ar955x_1p0_mac_core); 337 240 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 338 - ar955x_1p0_mac_postamble, 339 - ARRAY_SIZE(ar955x_1p0_mac_postamble), 5); 241 + ar955x_1p0_mac_postamble); 340 242 341 243 /* bb */ 342 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 343 244 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 344 - ar955x_1p0_baseband_core, 345 - ARRAY_SIZE(ar955x_1p0_baseband_core), 2); 245 + ar955x_1p0_baseband_core); 346 246 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 347 - ar955x_1p0_baseband_postamble, 348 - ARRAY_SIZE(ar955x_1p0_baseband_postamble), 5); 247 + ar955x_1p0_baseband_postamble); 349 248 350 249 /* radio */ 351 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 352 250 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 353 - ar955x_1p0_radio_core, 354 - ARRAY_SIZE(ar955x_1p0_radio_core), 2); 251 + ar955x_1p0_radio_core); 355 252 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 356 - ar955x_1p0_radio_postamble, 357 - ARRAY_SIZE(ar955x_1p0_radio_postamble), 5); 253 + ar955x_1p0_radio_postamble); 358 254 359 255 /* soc */ 360 256 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 361 - ar955x_1p0_soc_preamble, 362 - ARRAY_SIZE(ar955x_1p0_soc_preamble), 2); 363 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 257 + ar955x_1p0_soc_preamble); 364 258 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 365 - ar955x_1p0_soc_postamble, 366 - ARRAY_SIZE(ar955x_1p0_soc_postamble), 5); 259 + ar955x_1p0_soc_postamble); 367 260 368 261 /* rx/tx gain */ 369 262 INIT_INI_ARRAY(&ah->iniModesRxGain, 370 - ar955x_1p0_common_wo_xlna_rx_gain_table, 371 - ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_table), 372 - 2); 263 + ar955x_1p0_common_wo_xlna_rx_gain_table); 373 264 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 374 - ar955x_1p0_common_wo_xlna_rx_gain_bounds, 375 - ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_bounds), 376 - 5); 265 + ar955x_1p0_common_wo_xlna_rx_gain_bounds); 377 266 INIT_INI_ARRAY(&ah->iniModesTxGain, 378 - ar955x_1p0_modes_xpa_tx_gain_table, 379 - ARRAY_SIZE(ar955x_1p0_modes_xpa_tx_gain_table), 380 - 9); 267 + ar955x_1p0_modes_xpa_tx_gain_table); 381 268 382 269 /* Fast clock modal settings */ 383 270 INIT_INI_ARRAY(&ah->iniModesFastClock, 384 - ar955x_1p0_modes_fast_clock, 385 - ARRAY_SIZE(ar955x_1p0_modes_fast_clock), 3); 271 + ar955x_1p0_modes_fast_clock); 386 272 } else if (AR_SREV_9580(ah)) { 387 273 /* mac */ 388 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 389 274 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 390 - ar9580_1p0_mac_core, 391 - ARRAY_SIZE(ar9580_1p0_mac_core), 2); 275 + ar9580_1p0_mac_core); 392 276 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 393 - ar9580_1p0_mac_postamble, 394 - ARRAY_SIZE(ar9580_1p0_mac_postamble), 5); 277 + ar9580_1p0_mac_postamble); 395 278 396 279 /* bb */ 397 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 398 280 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 399 - ar9580_1p0_baseband_core, 400 - ARRAY_SIZE(ar9580_1p0_baseband_core), 2); 281 + ar9580_1p0_baseband_core); 401 282 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 402 - ar9580_1p0_baseband_postamble, 403 - ARRAY_SIZE(ar9580_1p0_baseband_postamble), 5); 283 + ar9580_1p0_baseband_postamble); 404 284 405 285 /* radio */ 406 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 407 286 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 408 - ar9580_1p0_radio_core, 409 - ARRAY_SIZE(ar9580_1p0_radio_core), 2); 287 + ar9580_1p0_radio_core); 410 288 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 411 - ar9580_1p0_radio_postamble, 412 - ARRAY_SIZE(ar9580_1p0_radio_postamble), 5); 289 + ar9580_1p0_radio_postamble); 413 290 414 291 /* soc */ 415 292 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 416 - ar9580_1p0_soc_preamble, 417 - ARRAY_SIZE(ar9580_1p0_soc_preamble), 2); 418 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 293 + ar9580_1p0_soc_preamble); 419 294 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 420 - ar9580_1p0_soc_postamble, 421 - ARRAY_SIZE(ar9580_1p0_soc_postamble), 5); 295 + ar9580_1p0_soc_postamble); 422 296 423 297 /* rx/tx gain */ 424 298 INIT_INI_ARRAY(&ah->iniModesRxGain, 425 - ar9580_1p0_rx_gain_table, 426 - ARRAY_SIZE(ar9580_1p0_rx_gain_table), 2); 299 + ar9580_1p0_rx_gain_table); 427 300 INIT_INI_ARRAY(&ah->iniModesTxGain, 428 - ar9580_1p0_low_ob_db_tx_gain_table, 429 - ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table), 430 - 5); 301 + ar9580_1p0_low_ob_db_tx_gain_table); 431 302 432 303 INIT_INI_ARRAY(&ah->iniModesFastClock, 433 - ar9580_1p0_modes_fast_clock, 434 - ARRAY_SIZE(ar9580_1p0_modes_fast_clock), 435 - 3); 304 + ar9580_1p0_modes_fast_clock); 436 305 } else { 437 306 /* mac */ 438 - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); 439 307 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 440 - ar9300_2p2_mac_core, 441 - ARRAY_SIZE(ar9300_2p2_mac_core), 2); 308 + ar9300_2p2_mac_core); 442 309 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], 443 - ar9300_2p2_mac_postamble, 444 - ARRAY_SIZE(ar9300_2p2_mac_postamble), 5); 310 + ar9300_2p2_mac_postamble); 445 311 446 312 /* bb */ 447 - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); 448 313 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], 449 - ar9300_2p2_baseband_core, 450 - ARRAY_SIZE(ar9300_2p2_baseband_core), 2); 314 + ar9300_2p2_baseband_core); 451 315 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], 452 - ar9300_2p2_baseband_postamble, 453 - ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5); 316 + ar9300_2p2_baseband_postamble); 454 317 455 318 /* radio */ 456 - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); 457 319 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], 458 - ar9300_2p2_radio_core, 459 - ARRAY_SIZE(ar9300_2p2_radio_core), 2); 320 + ar9300_2p2_radio_core); 460 321 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], 461 - ar9300_2p2_radio_postamble, 462 - ARRAY_SIZE(ar9300_2p2_radio_postamble), 5); 322 + ar9300_2p2_radio_postamble); 463 323 464 324 /* soc */ 465 325 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], 466 - ar9300_2p2_soc_preamble, 467 - ARRAY_SIZE(ar9300_2p2_soc_preamble), 2); 468 - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); 326 + ar9300_2p2_soc_preamble); 469 327 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], 470 - ar9300_2p2_soc_postamble, 471 - ARRAY_SIZE(ar9300_2p2_soc_postamble), 5); 328 + ar9300_2p2_soc_postamble); 472 329 473 330 /* rx/tx gain */ 474 331 INIT_INI_ARRAY(&ah->iniModesRxGain, 475 - ar9300Common_rx_gain_table_2p2, 476 - ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2); 332 + ar9300Common_rx_gain_table_2p2); 477 333 INIT_INI_ARRAY(&ah->iniModesTxGain, 478 - ar9300Modes_lowest_ob_db_tx_gain_table_2p2, 479 - ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2), 480 - 5); 334 + ar9300Modes_lowest_ob_db_tx_gain_table_2p2); 481 335 482 336 /* Load PCIE SERDES settings from INI */ 483 337 484 338 /* Awake Setting */ 485 339 486 340 INIT_INI_ARRAY(&ah->iniPcieSerdes, 487 - ar9300PciePhy_pll_on_clkreq_disable_L1_2p2, 488 - ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2), 489 - 2); 341 + ar9300PciePhy_pll_on_clkreq_disable_L1_2p2); 490 342 491 343 /* Sleep Setting */ 492 344 493 345 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, 494 - ar9300PciePhy_pll_on_clkreq_disable_L1_2p2, 495 - ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2), 496 - 2); 346 + ar9300PciePhy_pll_on_clkreq_disable_L1_2p2); 497 347 498 348 /* Fast clock modal settings */ 499 349 INIT_INI_ARRAY(&ah->iniModesFastClock, 500 - ar9300Modes_fast_clock_2p2, 501 - ARRAY_SIZE(ar9300Modes_fast_clock_2p2), 502 - 3); 350 + ar9300Modes_fast_clock_2p2); 503 351 } 504 352 } 505 353 ··· 355 507 { 356 508 if (AR_SREV_9330_12(ah)) 357 509 INIT_INI_ARRAY(&ah->iniModesTxGain, 358 - ar9331_modes_lowest_ob_db_tx_gain_1p2, 359 - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2), 360 - 5); 510 + ar9331_modes_lowest_ob_db_tx_gain_1p2); 361 511 else if (AR_SREV_9330_11(ah)) 362 512 INIT_INI_ARRAY(&ah->iniModesTxGain, 363 - ar9331_modes_lowest_ob_db_tx_gain_1p1, 364 - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1), 365 - 5); 513 + ar9331_modes_lowest_ob_db_tx_gain_1p1); 366 514 else if (AR_SREV_9340(ah)) 367 515 INIT_INI_ARRAY(&ah->iniModesTxGain, 368 - ar9340Modes_lowest_ob_db_tx_gain_table_1p0, 369 - ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), 370 - 5); 516 + ar9340Modes_lowest_ob_db_tx_gain_table_1p0); 371 517 else if (AR_SREV_9485_11(ah)) 372 518 INIT_INI_ARRAY(&ah->iniModesTxGain, 373 - ar9485_modes_lowest_ob_db_tx_gain_1_1, 374 - ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1), 375 - 5); 519 + ar9485_modes_lowest_ob_db_tx_gain_1_1); 376 520 else if (AR_SREV_9550(ah)) 377 521 INIT_INI_ARRAY(&ah->iniModesTxGain, 378 - ar955x_1p0_modes_xpa_tx_gain_table, 379 - ARRAY_SIZE(ar955x_1p0_modes_xpa_tx_gain_table), 380 - 9); 522 + ar955x_1p0_modes_xpa_tx_gain_table); 381 523 else if (AR_SREV_9580(ah)) 382 524 INIT_INI_ARRAY(&ah->iniModesTxGain, 383 - ar9580_1p0_lowest_ob_db_tx_gain_table, 384 - ARRAY_SIZE(ar9580_1p0_lowest_ob_db_tx_gain_table), 385 - 5); 525 + ar9580_1p0_lowest_ob_db_tx_gain_table); 386 526 else if (AR_SREV_9462_20(ah)) 387 527 INIT_INI_ARRAY(&ah->iniModesTxGain, 388 - ar9462_modes_low_ob_db_tx_gain_table_2p0, 389 - ARRAY_SIZE(ar9462_modes_low_ob_db_tx_gain_table_2p0), 390 - 5); 528 + ar9462_modes_low_ob_db_tx_gain_table_2p0); 391 529 else 392 530 INIT_INI_ARRAY(&ah->iniModesTxGain, 393 - ar9300Modes_lowest_ob_db_tx_gain_table_2p2, 394 - ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2), 395 - 5); 531 + ar9300Modes_lowest_ob_db_tx_gain_table_2p2); 396 532 } 397 533 398 534 static void ar9003_tx_gain_table_mode1(struct ath_hw *ah) 399 535 { 400 536 if (AR_SREV_9330_12(ah)) 401 537 INIT_INI_ARRAY(&ah->iniModesTxGain, 402 - ar9331_modes_high_ob_db_tx_gain_1p2, 403 - ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p2), 404 - 5); 538 + ar9331_modes_high_ob_db_tx_gain_1p2); 405 539 else if (AR_SREV_9330_11(ah)) 406 540 INIT_INI_ARRAY(&ah->iniModesTxGain, 407 - ar9331_modes_high_ob_db_tx_gain_1p1, 408 - ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p1), 409 - 5); 541 + ar9331_modes_high_ob_db_tx_gain_1p1); 410 542 else if (AR_SREV_9340(ah)) 411 543 INIT_INI_ARRAY(&ah->iniModesTxGain, 412 - ar9340Modes_lowest_ob_db_tx_gain_table_1p0, 413 - ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), 414 - 5); 544 + ar9340Modes_high_ob_db_tx_gain_table_1p0); 415 545 else if (AR_SREV_9485_11(ah)) 416 546 INIT_INI_ARRAY(&ah->iniModesTxGain, 417 - ar9485Modes_high_ob_db_tx_gain_1_1, 418 - ARRAY_SIZE(ar9485Modes_high_ob_db_tx_gain_1_1), 419 - 5); 547 + ar9485Modes_high_ob_db_tx_gain_1_1); 420 548 else if (AR_SREV_9580(ah)) 421 549 INIT_INI_ARRAY(&ah->iniModesTxGain, 422 - ar9580_1p0_high_ob_db_tx_gain_table, 423 - ARRAY_SIZE(ar9580_1p0_high_ob_db_tx_gain_table), 424 - 5); 550 + ar9580_1p0_high_ob_db_tx_gain_table); 425 551 else if (AR_SREV_9550(ah)) 426 552 INIT_INI_ARRAY(&ah->iniModesTxGain, 427 - ar955x_1p0_modes_no_xpa_tx_gain_table, 428 - ARRAY_SIZE(ar955x_1p0_modes_no_xpa_tx_gain_table), 429 - 9); 553 + ar955x_1p0_modes_no_xpa_tx_gain_table); 430 554 else if (AR_SREV_9462_20(ah)) 431 555 INIT_INI_ARRAY(&ah->iniModesTxGain, 432 - ar9462_modes_high_ob_db_tx_gain_table_2p0, 433 - ARRAY_SIZE(ar9462_modes_high_ob_db_tx_gain_table_2p0), 434 - 5); 556 + ar9462_modes_high_ob_db_tx_gain_table_2p0); 435 557 else 436 558 INIT_INI_ARRAY(&ah->iniModesTxGain, 437 - ar9300Modes_high_ob_db_tx_gain_table_2p2, 438 - ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2), 439 - 5); 559 + ar9300Modes_high_ob_db_tx_gain_table_2p2); 440 560 } 441 561 442 562 static void ar9003_tx_gain_table_mode2(struct ath_hw *ah) 443 563 { 444 564 if (AR_SREV_9330_12(ah)) 445 565 INIT_INI_ARRAY(&ah->iniModesTxGain, 446 - ar9331_modes_low_ob_db_tx_gain_1p2, 447 - ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p2), 448 - 5); 566 + ar9331_modes_low_ob_db_tx_gain_1p2); 449 567 else if (AR_SREV_9330_11(ah)) 450 568 INIT_INI_ARRAY(&ah->iniModesTxGain, 451 - ar9331_modes_low_ob_db_tx_gain_1p1, 452 - ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p1), 453 - 5); 569 + ar9331_modes_low_ob_db_tx_gain_1p1); 454 570 else if (AR_SREV_9340(ah)) 455 571 INIT_INI_ARRAY(&ah->iniModesTxGain, 456 - ar9340Modes_lowest_ob_db_tx_gain_table_1p0, 457 - ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), 458 - 5); 572 + ar9340Modes_low_ob_db_tx_gain_table_1p0); 459 573 else if (AR_SREV_9485_11(ah)) 460 574 INIT_INI_ARRAY(&ah->iniModesTxGain, 461 - ar9485Modes_low_ob_db_tx_gain_1_1, 462 - ARRAY_SIZE(ar9485Modes_low_ob_db_tx_gain_1_1), 463 - 5); 575 + ar9485Modes_low_ob_db_tx_gain_1_1); 464 576 else if (AR_SREV_9580(ah)) 465 577 INIT_INI_ARRAY(&ah->iniModesTxGain, 466 - ar9580_1p0_low_ob_db_tx_gain_table, 467 - ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table), 468 - 5); 578 + ar9580_1p0_low_ob_db_tx_gain_table); 469 579 else 470 580 INIT_INI_ARRAY(&ah->iniModesTxGain, 471 - ar9300Modes_low_ob_db_tx_gain_table_2p2, 472 - ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2), 473 - 5); 581 + ar9300Modes_low_ob_db_tx_gain_table_2p2); 474 582 } 475 583 476 584 static void ar9003_tx_gain_table_mode3(struct ath_hw *ah) 477 585 { 478 586 if (AR_SREV_9330_12(ah)) 479 587 INIT_INI_ARRAY(&ah->iniModesTxGain, 480 - ar9331_modes_high_power_tx_gain_1p2, 481 - ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p2), 482 - 5); 588 + ar9331_modes_high_power_tx_gain_1p2); 483 589 else if (AR_SREV_9330_11(ah)) 484 590 INIT_INI_ARRAY(&ah->iniModesTxGain, 485 - ar9331_modes_high_power_tx_gain_1p1, 486 - ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p1), 487 - 5); 591 + ar9331_modes_high_power_tx_gain_1p1); 488 592 else if (AR_SREV_9340(ah)) 489 593 INIT_INI_ARRAY(&ah->iniModesTxGain, 490 - ar9340Modes_lowest_ob_db_tx_gain_table_1p0, 491 - ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), 492 - 5); 594 + ar9340Modes_high_power_tx_gain_table_1p0); 493 595 else if (AR_SREV_9485_11(ah)) 494 596 INIT_INI_ARRAY(&ah->iniModesTxGain, 495 - ar9485Modes_high_power_tx_gain_1_1, 496 - ARRAY_SIZE(ar9485Modes_high_power_tx_gain_1_1), 497 - 5); 597 + ar9485Modes_high_power_tx_gain_1_1); 498 598 else if (AR_SREV_9580(ah)) 499 599 INIT_INI_ARRAY(&ah->iniModesTxGain, 500 - ar9580_1p0_high_power_tx_gain_table, 501 - ARRAY_SIZE(ar9580_1p0_high_power_tx_gain_table), 502 - 5); 600 + ar9580_1p0_high_power_tx_gain_table); 503 601 else 504 602 INIT_INI_ARRAY(&ah->iniModesTxGain, 505 - ar9300Modes_high_power_tx_gain_table_2p2, 506 - ARRAY_SIZE(ar9300Modes_high_power_tx_gain_table_2p2), 507 - 5); 603 + ar9300Modes_high_power_tx_gain_table_2p2); 604 + } 605 + 606 + static void ar9003_tx_gain_table_mode4(struct ath_hw *ah) 607 + { 608 + if (AR_SREV_9340(ah)) 609 + INIT_INI_ARRAY(&ah->iniModesTxGain, 610 + ar9340Modes_mixed_ob_db_tx_gain_table_1p0); 611 + else if (AR_SREV_9580(ah)) 612 + INIT_INI_ARRAY(&ah->iniModesTxGain, 613 + ar9580_1p0_mixed_ob_db_tx_gain_table); 508 614 } 509 615 510 616 static void ar9003_tx_gain_table_apply(struct ath_hw *ah) ··· 477 675 case 3: 478 676 ar9003_tx_gain_table_mode3(ah); 479 677 break; 678 + case 4: 679 + ar9003_tx_gain_table_mode4(ah); 680 + break; 480 681 } 481 682 } 482 683 ··· 487 682 { 488 683 if (AR_SREV_9330_12(ah)) 489 684 INIT_INI_ARRAY(&ah->iniModesRxGain, 490 - ar9331_common_rx_gain_1p2, 491 - ARRAY_SIZE(ar9331_common_rx_gain_1p2), 492 - 2); 685 + ar9331_common_rx_gain_1p2); 493 686 else if (AR_SREV_9330_11(ah)) 494 687 INIT_INI_ARRAY(&ah->iniModesRxGain, 495 - ar9331_common_rx_gain_1p1, 496 - ARRAY_SIZE(ar9331_common_rx_gain_1p1), 497 - 2); 688 + ar9331_common_rx_gain_1p1); 498 689 else if (AR_SREV_9340(ah)) 499 690 INIT_INI_ARRAY(&ah->iniModesRxGain, 500 - ar9340Common_rx_gain_table_1p0, 501 - ARRAY_SIZE(ar9340Common_rx_gain_table_1p0), 502 - 2); 691 + ar9340Common_rx_gain_table_1p0); 503 692 else if (AR_SREV_9485_11(ah)) 504 693 INIT_INI_ARRAY(&ah->iniModesRxGain, 505 - ar9485Common_wo_xlna_rx_gain_1_1, 506 - ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 507 - 2); 694 + ar9485Common_wo_xlna_rx_gain_1_1); 508 695 else if (AR_SREV_9550(ah)) { 509 696 INIT_INI_ARRAY(&ah->iniModesRxGain, 510 - ar955x_1p0_common_rx_gain_table, 511 - ARRAY_SIZE(ar955x_1p0_common_rx_gain_table), 512 - 2); 697 + ar955x_1p0_common_rx_gain_table); 513 698 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 514 - ar955x_1p0_common_rx_gain_bounds, 515 - ARRAY_SIZE(ar955x_1p0_common_rx_gain_bounds), 516 - 5); 699 + ar955x_1p0_common_rx_gain_bounds); 517 700 } else if (AR_SREV_9580(ah)) 518 701 INIT_INI_ARRAY(&ah->iniModesRxGain, 519 - ar9580_1p0_rx_gain_table, 520 - ARRAY_SIZE(ar9580_1p0_rx_gain_table), 521 - 2); 702 + ar9580_1p0_rx_gain_table); 522 703 else if (AR_SREV_9462_20(ah)) 523 704 INIT_INI_ARRAY(&ah->iniModesRxGain, 524 - ar9462_common_rx_gain_table_2p0, 525 - ARRAY_SIZE(ar9462_common_rx_gain_table_2p0), 526 - 2); 705 + ar9462_common_rx_gain_table_2p0); 527 706 else 528 707 INIT_INI_ARRAY(&ah->iniModesRxGain, 529 - ar9300Common_rx_gain_table_2p2, 530 - ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 531 - 2); 708 + ar9300Common_rx_gain_table_2p2); 532 709 } 533 710 534 711 static void ar9003_rx_gain_table_mode1(struct ath_hw *ah) 535 712 { 536 713 if (AR_SREV_9330_12(ah)) 537 714 INIT_INI_ARRAY(&ah->iniModesRxGain, 538 - ar9331_common_wo_xlna_rx_gain_1p2, 539 - ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p2), 540 - 2); 715 + ar9331_common_wo_xlna_rx_gain_1p2); 541 716 else if (AR_SREV_9330_11(ah)) 542 717 INIT_INI_ARRAY(&ah->iniModesRxGain, 543 - ar9331_common_wo_xlna_rx_gain_1p1, 544 - ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p1), 545 - 2); 718 + ar9331_common_wo_xlna_rx_gain_1p1); 546 719 else if (AR_SREV_9340(ah)) 547 720 INIT_INI_ARRAY(&ah->iniModesRxGain, 548 - ar9340Common_wo_xlna_rx_gain_table_1p0, 549 - ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0), 550 - 2); 721 + ar9340Common_wo_xlna_rx_gain_table_1p0); 551 722 else if (AR_SREV_9485_11(ah)) 552 723 INIT_INI_ARRAY(&ah->iniModesRxGain, 553 - ar9485Common_wo_xlna_rx_gain_1_1, 554 - ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 555 - 2); 724 + ar9485Common_wo_xlna_rx_gain_1_1); 556 725 else if (AR_SREV_9462_20(ah)) 557 726 INIT_INI_ARRAY(&ah->iniModesRxGain, 558 - ar9462_common_wo_xlna_rx_gain_table_2p0, 559 - ARRAY_SIZE(ar9462_common_wo_xlna_rx_gain_table_2p0), 560 - 2); 727 + ar9462_common_wo_xlna_rx_gain_table_2p0); 561 728 else if (AR_SREV_9550(ah)) { 562 729 INIT_INI_ARRAY(&ah->iniModesRxGain, 563 - ar955x_1p0_common_wo_xlna_rx_gain_table, 564 - ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_table), 565 - 2); 730 + ar955x_1p0_common_wo_xlna_rx_gain_table); 566 731 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds, 567 - ar955x_1p0_common_wo_xlna_rx_gain_bounds, 568 - ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_bounds), 569 - 5); 732 + ar955x_1p0_common_wo_xlna_rx_gain_bounds); 570 733 } else if (AR_SREV_9580(ah)) 571 734 INIT_INI_ARRAY(&ah->iniModesRxGain, 572 - ar9580_1p0_wo_xlna_rx_gain_table, 573 - ARRAY_SIZE(ar9580_1p0_wo_xlna_rx_gain_table), 574 - 2); 735 + ar9580_1p0_wo_xlna_rx_gain_table); 575 736 else 576 737 INIT_INI_ARRAY(&ah->iniModesRxGain, 577 - ar9300Common_wo_xlna_rx_gain_table_2p2, 578 - ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2), 579 - 2); 738 + ar9300Common_wo_xlna_rx_gain_table_2p2); 580 739 } 581 740 582 741 static void ar9003_rx_gain_table_mode2(struct ath_hw *ah) 583 742 { 584 743 if (AR_SREV_9462_20(ah)) 585 744 INIT_INI_ARRAY(&ah->iniModesRxGain, 586 - ar9462_common_mixed_rx_gain_table_2p0, 587 - ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2); 745 + ar9462_common_mixed_rx_gain_table_2p0); 588 746 } 589 747 590 748 static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
+2 -2
drivers/net/wireless/ath/ath9k/ar9003_phy.c
··· 117 117 ah->is_clk_25mhz) { 118 118 u32 chan_frac; 119 119 120 - channelSel = (freq * 2) / 75; 121 - chan_frac = (((freq * 2) % 75) * 0x20000) / 75; 120 + channelSel = freq / 75; 121 + chan_frac = ((freq % 75) * 0x20000) / 75; 122 122 channelSel = (channelSel << 17) | chan_frac; 123 123 } else { 124 124 channelSel = CHANSEL_5G(freq);
+5
drivers/net/wireless/ath/ath9k/ar9003_phy.h
··· 633 633 #define AR_PHY_65NM_CH0_BIAS2 0x160c4 634 634 #define AR_PHY_65NM_CH0_BIAS4 0x160cc 635 635 #define AR_PHY_65NM_CH0_RXTX4 0x1610c 636 + #define AR_PHY_65NM_CH1_RXTX4 0x1650c 637 + #define AR_PHY_65NM_CH2_RXTX4 0x1690c 636 638 637 639 #define AR_CH0_TOP (AR_SREV_9300(ah) ? 0x16288 : \ 638 640 ((AR_SREV_9462(ah) ? 0x1628c : 0x16280))) ··· 877 875 878 876 #define AR_PHY_65NM_CH0_RXTX4_THERM_ON 0x10000000 879 877 #define AR_PHY_65NM_CH0_RXTX4_THERM_ON_S 28 878 + 879 + #define AR_PHY_65NM_RXTX4_XLNA_BIAS 0xC0000000 880 + #define AR_PHY_65NM_RXTX4_XLNA_BIAS_S 30 880 881 881 882 /* 882 883 * Channel 1 Register Map
+30 -10
drivers/net/wireless/ath/ath9k/ath9k.h
··· 297 297 struct ath_txq txq[ATH9K_NUM_TX_QUEUES]; 298 298 struct ath_descdma txdma; 299 299 struct ath_txq *txq_map[WME_NUM_AC]; 300 + u32 txq_max_pending[WME_NUM_AC]; 301 + u16 max_aggr_framelen[WME_NUM_AC][4][32]; 300 302 }; 301 303 302 304 struct ath_rx_edma { ··· 343 341 void ath_tx_cleanup(struct ath_softc *sc); 344 342 int ath_txq_update(struct ath_softc *sc, int qnum, 345 343 struct ath9k_tx_queue_info *q); 344 + void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop); 346 345 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, 347 346 struct ath_tx_control *txctl); 348 347 void ath_tx_tasklet(struct ath_softc *sc); ··· 363 360 364 361 struct ath_vif { 365 362 int av_bslot; 366 - bool is_bslot_active, primary_sta_vif; 363 + bool primary_sta_vif; 367 364 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */ 368 365 struct ath_buf *av_bcbuf; 369 366 }; ··· 389 386 u16 dtim_period; 390 387 u16 bmiss_timeout; 391 388 u8 dtim_count; 389 + bool enable_beacon; 392 390 }; 393 391 394 392 struct ath_beacon { ··· 401 397 402 398 u32 beaconq; 403 399 u32 bmisscnt; 404 - u32 ast_be_xmit; 405 400 u32 bc_tstamp; 406 401 struct ieee80211_vif *bslot[ATH_BCBUF]; 407 402 int slottime; ··· 414 411 bool tx_last; 415 412 }; 416 413 417 - void ath_beacon_tasklet(unsigned long data); 418 - void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif); 419 - int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif); 420 - void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp); 421 - int ath_beaconq_config(struct ath_softc *sc); 422 - void ath_set_beacon(struct ath_softc *sc); 414 + void ath9k_beacon_tasklet(unsigned long data); 415 + bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif); 416 + void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif, 417 + u32 changed); 418 + void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 419 + void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 420 + void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif); 421 + void ath9k_set_beacon(struct ath_softc *sc); 423 422 void ath9k_set_beaconing_status(struct ath_softc *sc, bool status); 424 423 425 424 /*******************/ ··· 447 442 void ath_start_rx_poll(struct ath_softc *sc, u8 nbeacon); 448 443 void ath_paprd_calibrate(struct work_struct *work); 449 444 void ath_ani_calibrate(unsigned long data); 450 - void ath_start_ani(struct ath_common *common); 445 + void ath_start_ani(struct ath_softc *sc); 446 + void ath_stop_ani(struct ath_softc *sc); 447 + void ath_check_ani(struct ath_softc *sc); 451 448 int ath_update_survey_stats(struct ath_softc *sc); 452 449 void ath_update_survey_nf(struct ath_softc *sc, int channel); 450 + void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type); 453 451 454 452 /**********/ 455 453 /* BTCOEX */ ··· 517 509 { 518 510 } 519 511 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ 512 + 513 + struct ath9k_wow_pattern { 514 + u8 pattern_bytes[MAX_PATTERN_SIZE]; 515 + u8 mask_bytes[MAX_PATTERN_SIZE]; 516 + u32 pattern_len; 517 + }; 520 518 521 519 /********************/ 522 520 /* LED Control */ ··· 627 613 SC_OP_INVALID, 628 614 SC_OP_BEACONS, 629 615 SC_OP_RXFLUSH, 630 - SC_OP_TSF_RESET, 631 616 SC_OP_ANI_RUN, 632 617 SC_OP_PRIM_STA_VIF, 633 618 SC_OP_HW_RESET, ··· 724 711 struct ath_ant_comb ant_comb; 725 712 u8 ant_tx, ant_rx; 726 713 struct dfs_pattern_detector *dfs_detector; 714 + u32 wow_enabled; 715 + 716 + #ifdef CONFIG_PM_SLEEP 717 + atomic_t wow_got_bmiss_intr; 718 + atomic_t wow_sleep_proc_intr; /* in the middle of WoW sleep ? */ 719 + u32 wow_intr_before_sleep; 720 + #endif 727 721 }; 728 722 729 723 void ath9k_tasklet(unsigned long data);
+204 -325
drivers/net/wireless/ath/ath9k/beacon.c
··· 30 30 * the operating mode of the station (AP or AdHoc). Parameters are AIFS 31 31 * settings and channel width min/max 32 32 */ 33 - int ath_beaconq_config(struct ath_softc *sc) 33 + static void ath9k_beaconq_config(struct ath_softc *sc) 34 34 { 35 35 struct ath_hw *ah = sc->sc_ah; 36 36 struct ath_common *common = ath9k_hw_common(ah); ··· 38 38 struct ath_txq *txq; 39 39 40 40 ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi); 41 + 41 42 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) { 42 43 /* Always burst out beacon and CAB traffic. */ 43 44 qi.tqi_aifs = 1; ··· 57 56 } 58 57 59 58 if (!ath9k_hw_set_txq_props(ah, sc->beacon.beaconq, &qi)) { 60 - ath_err(common, 61 - "Unable to update h/w beacon queue parameters\n"); 62 - return 0; 59 + ath_err(common, "Unable to update h/w beacon queue parameters\n"); 63 60 } else { 64 61 ath9k_hw_resettxqueue(ah, sc->beacon.beaconq); 65 - return 1; 66 62 } 67 63 } 68 64 ··· 68 70 * up rate codes, and channel flags. Beacons are always sent out at the 69 71 * lowest rate, and are not retried. 70 72 */ 71 - static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif, 73 + static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif, 72 74 struct ath_buf *bf, int rateidx) 73 75 { 74 76 struct sk_buff *skb = bf->bf_mpdu; ··· 78 80 struct ieee80211_supported_band *sband; 79 81 u8 chainmask = ah->txchainmask; 80 82 u8 rate = 0; 81 - 82 - ath9k_reset_beacon_status(sc); 83 83 84 84 sband = &sc->sbands[common->hw->conf.channel->band]; 85 85 rate = sband->bitrates[rateidx].hw_value; ··· 107 111 ath9k_hw_set_txdesc(ah, bf->bf_desc, &info); 108 112 } 109 113 110 - static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb) 114 + static void ath9k_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb) 111 115 { 112 116 struct ath_softc *sc = hw->priv; 113 117 struct ath_common *common = ath9k_hw_common(sc->sc_ah); ··· 124 128 } 125 129 } 126 130 127 - static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw, 128 - struct ieee80211_vif *vif) 131 + static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, 132 + struct ieee80211_vif *vif) 129 133 { 130 134 struct ath_softc *sc = hw->priv; 131 135 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 132 136 struct ath_buf *bf; 133 - struct ath_vif *avp; 137 + struct ath_vif *avp = (void *)vif->drv_priv; 134 138 struct sk_buff *skb; 135 - struct ath_txq *cabq; 139 + struct ath_txq *cabq = sc->beacon.cabq; 136 140 struct ieee80211_tx_info *info; 141 + struct ieee80211_mgmt *mgmt_hdr; 137 142 int cabq_depth; 138 143 139 - ath9k_reset_beacon_status(sc); 140 - 141 - avp = (void *)vif->drv_priv; 142 - cabq = sc->beacon.cabq; 143 - 144 - if ((avp->av_bcbuf == NULL) || !avp->is_bslot_active) 144 + if (avp->av_bcbuf == NULL) 145 145 return NULL; 146 - 147 - /* Release the old beacon first */ 148 146 149 147 bf = avp->av_bcbuf; 150 148 skb = bf->bf_mpdu; ··· 149 159 bf->bf_buf_addr = 0; 150 160 } 151 161 152 - /* Get a new beacon from mac80211 */ 153 - 154 162 skb = ieee80211_beacon_get(hw, vif); 155 - bf->bf_mpdu = skb; 156 163 if (skb == NULL) 157 164 return NULL; 158 - ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp = 159 - avp->tsf_adjust; 165 + 166 + bf->bf_mpdu = skb; 167 + 168 + mgmt_hdr = (struct ieee80211_mgmt *)skb->data; 169 + mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust; 160 170 161 171 info = IEEE80211_SKB_CB(skb); 162 172 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { ··· 202 212 } 203 213 } 204 214 205 - ath_beacon_setup(sc, vif, bf, info->control.rates[0].idx); 215 + ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx); 206 216 207 217 while (skb) { 208 - ath_tx_cabq(hw, skb); 218 + ath9k_tx_cabq(hw, skb); 209 219 skb = ieee80211_get_buffered_bc(hw, vif); 210 220 } 211 221 212 222 return bf; 213 223 } 214 224 215 - int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif) 225 + void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif) 216 226 { 217 227 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 218 - struct ath_vif *avp; 219 - struct ath_buf *bf; 220 - struct sk_buff *skb; 221 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 222 - __le64 tstamp; 228 + struct ath_vif *avp = (void *)vif->drv_priv; 229 + int slot; 223 230 224 - avp = (void *)vif->drv_priv; 231 + avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf, struct ath_buf, list); 232 + list_del(&avp->av_bcbuf->list); 225 233 226 - /* Allocate a beacon descriptor if we haven't done so. */ 227 - if (!avp->av_bcbuf) { 228 - /* Allocate beacon state for hostap/ibss. We know 229 - * a buffer is available. */ 230 - avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf, 231 - struct ath_buf, list); 232 - list_del(&avp->av_bcbuf->list); 233 - 234 - if (ath9k_uses_beacons(vif->type)) { 235 - int slot; 236 - /* 237 - * Assign the vif to a beacon xmit slot. As 238 - * above, this cannot fail to find one. 239 - */ 240 - avp->av_bslot = 0; 241 - for (slot = 0; slot < ATH_BCBUF; slot++) 242 - if (sc->beacon.bslot[slot] == NULL) { 243 - avp->av_bslot = slot; 244 - avp->is_bslot_active = false; 245 - 246 - /* NB: keep looking for a double slot */ 247 - if (slot == 0 || !sc->beacon.bslot[slot-1]) 248 - break; 249 - } 250 - BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL); 251 - sc->beacon.bslot[avp->av_bslot] = vif; 252 - sc->nbcnvifs++; 234 + for (slot = 0; slot < ATH_BCBUF; slot++) { 235 + if (sc->beacon.bslot[slot] == NULL) { 236 + avp->av_bslot = slot; 237 + break; 253 238 } 254 239 } 255 240 256 - /* release the previous beacon frame, if it already exists. */ 257 - bf = avp->av_bcbuf; 258 - if (bf->bf_mpdu != NULL) { 259 - skb = bf->bf_mpdu; 241 + sc->beacon.bslot[avp->av_bslot] = vif; 242 + sc->nbcnvifs++; 243 + 244 + ath_dbg(common, CONFIG, "Added interface at beacon slot: %d\n", 245 + avp->av_bslot); 246 + } 247 + 248 + void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif) 249 + { 250 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 251 + struct ath_vif *avp = (void *)vif->drv_priv; 252 + struct ath_buf *bf = avp->av_bcbuf; 253 + 254 + ath_dbg(common, CONFIG, "Removing interface at beacon slot: %d\n", 255 + avp->av_bslot); 256 + 257 + tasklet_disable(&sc->bcon_tasklet); 258 + 259 + if (bf && bf->bf_mpdu) { 260 + struct sk_buff *skb = bf->bf_mpdu; 260 261 dma_unmap_single(sc->dev, bf->bf_buf_addr, 261 262 skb->len, DMA_TO_DEVICE); 262 263 dev_kfree_skb_any(skb); ··· 255 274 bf->bf_buf_addr = 0; 256 275 } 257 276 258 - /* NB: the beacon data buffer must be 32-bit aligned. */ 259 - skb = ieee80211_beacon_get(sc->hw, vif); 260 - if (skb == NULL) 261 - return -ENOMEM; 277 + avp->av_bcbuf = NULL; 278 + sc->beacon.bslot[avp->av_bslot] = NULL; 279 + sc->nbcnvifs--; 280 + list_add_tail(&bf->list, &sc->beacon.bbuf); 262 281 263 - tstamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; 264 - sc->beacon.bc_tstamp = (u32) le64_to_cpu(tstamp); 265 - /* Calculate a TSF adjustment factor required for staggered beacons. */ 266 - if (avp->av_bslot > 0) { 267 - u64 tsfadjust; 268 - int intval; 269 - 270 - intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL; 271 - 272 - /* 273 - * Calculate the TSF offset for this beacon slot, i.e., the 274 - * number of usecs that need to be added to the timestamp field 275 - * in Beacon and Probe Response frames. Beacon slot 0 is 276 - * processed at the correct offset, so it does not require TSF 277 - * adjustment. Other slots are adjusted to get the timestamp 278 - * close to the TBTT for the BSS. 279 - */ 280 - tsfadjust = TU_TO_USEC(intval * avp->av_bslot) / ATH_BCBUF; 281 - avp->tsf_adjust = cpu_to_le64(tsfadjust); 282 - 283 - ath_dbg(common, BEACON, 284 - "stagger beacons, bslot %d intval %u tsfadjust %llu\n", 285 - avp->av_bslot, intval, (unsigned long long)tsfadjust); 286 - 287 - ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp = 288 - avp->tsf_adjust; 289 - } else 290 - avp->tsf_adjust = cpu_to_le64(0); 291 - 292 - bf->bf_mpdu = skb; 293 - bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, 294 - skb->len, DMA_TO_DEVICE); 295 - if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { 296 - dev_kfree_skb_any(skb); 297 - bf->bf_mpdu = NULL; 298 - bf->bf_buf_addr = 0; 299 - ath_err(common, "dma_mapping_error on beacon alloc\n"); 300 - return -ENOMEM; 301 - } 302 - avp->is_bslot_active = true; 303 - 304 - return 0; 282 + tasklet_enable(&sc->bcon_tasklet); 305 283 } 306 284 307 - void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp) 285 + static int ath9k_beacon_choose_slot(struct ath_softc *sc) 308 286 { 309 - if (avp->av_bcbuf != NULL) { 310 - struct ath_buf *bf; 287 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 288 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 289 + u16 intval; 290 + u32 tsftu; 291 + u64 tsf; 292 + int slot; 311 293 312 - avp->is_bslot_active = false; 313 - if (avp->av_bslot != -1) { 314 - sc->beacon.bslot[avp->av_bslot] = NULL; 315 - sc->nbcnvifs--; 316 - avp->av_bslot = -1; 317 - } 318 - 319 - bf = avp->av_bcbuf; 320 - if (bf->bf_mpdu != NULL) { 321 - struct sk_buff *skb = bf->bf_mpdu; 322 - dma_unmap_single(sc->dev, bf->bf_buf_addr, 323 - skb->len, DMA_TO_DEVICE); 324 - dev_kfree_skb_any(skb); 325 - bf->bf_mpdu = NULL; 326 - bf->bf_buf_addr = 0; 327 - } 328 - list_add_tail(&bf->list, &sc->beacon.bbuf); 329 - 330 - avp->av_bcbuf = NULL; 294 + if (sc->sc_ah->opmode != NL80211_IFTYPE_AP) { 295 + ath_dbg(common, BEACON, "slot 0, tsf: %llu\n", 296 + ath9k_hw_gettsf64(sc->sc_ah)); 297 + return 0; 331 298 } 299 + 300 + intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL; 301 + tsf = ath9k_hw_gettsf64(sc->sc_ah); 302 + tsf += TU_TO_USEC(sc->sc_ah->config.sw_beacon_response_time); 303 + tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF); 304 + slot = (tsftu % (intval * ATH_BCBUF)) / intval; 305 + 306 + ath_dbg(common, BEACON, "slot: %d tsf: %llu tsftu: %u\n", 307 + slot, tsf, tsftu / ATH_BCBUF); 308 + 309 + return slot; 332 310 } 333 311 334 - void ath_beacon_tasklet(unsigned long data) 312 + void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif) 313 + { 314 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 315 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 316 + struct ath_vif *avp = (void *)vif->drv_priv; 317 + u64 tsfadjust; 318 + 319 + if (avp->av_bslot == 0) 320 + return; 321 + 322 + tsfadjust = cur_conf->beacon_interval * avp->av_bslot / ATH_BCBUF; 323 + avp->tsf_adjust = cpu_to_le64(TU_TO_USEC(tsfadjust)); 324 + 325 + ath_dbg(common, CONFIG, "tsfadjust is: %llu for bslot: %d\n", 326 + (unsigned long long)tsfadjust, avp->av_bslot); 327 + } 328 + 329 + void ath9k_beacon_tasklet(unsigned long data) 335 330 { 336 331 struct ath_softc *sc = (struct ath_softc *)data; 337 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 338 332 struct ath_hw *ah = sc->sc_ah; 339 333 struct ath_common *common = ath9k_hw_common(ah); 340 334 struct ath_buf *bf = NULL; 341 335 struct ieee80211_vif *vif; 342 336 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); 343 337 int slot; 344 - u32 bfaddr, bc = 0; 345 338 346 - if (work_pending(&sc->hw_reset_work)) { 339 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) { 347 340 ath_dbg(common, RESET, 348 341 "reset work is pending, skip beaconing now\n"); 349 342 return; 350 343 } 344 + 351 345 /* 352 346 * Check if the previous beacon has gone out. If 353 347 * not don't try to post another, skip this period ··· 346 390 } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) { 347 391 ath_dbg(common, BSTUCK, "beacon is officially stuck\n"); 348 392 sc->beacon.bmisscnt = 0; 349 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags); 350 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 393 + ath9k_queue_reset(sc, RESET_TYPE_BEACON_STUCK); 351 394 } 352 395 353 396 return; 354 397 } 355 398 356 - /* 357 - * Generate beacon frames. we are sending frames 358 - * staggered so calculate the slot for this frame based 359 - * on the tsf to safeguard against missing an swba. 360 - */ 399 + slot = ath9k_beacon_choose_slot(sc); 400 + vif = sc->beacon.bslot[slot]; 361 401 402 + if (!vif || !vif->bss_conf.enable_beacon) 403 + return; 362 404 363 - if (ah->opmode == NL80211_IFTYPE_AP) { 364 - u16 intval; 365 - u32 tsftu; 366 - u64 tsf; 405 + bf = ath9k_beacon_generate(sc->hw, vif); 406 + WARN_ON(!bf); 367 407 368 - intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL; 369 - tsf = ath9k_hw_gettsf64(ah); 370 - tsf += TU_TO_USEC(ah->config.sw_beacon_response_time); 371 - tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF); 372 - slot = (tsftu % (intval * ATH_BCBUF)) / intval; 373 - vif = sc->beacon.bslot[slot]; 374 - 375 - ath_dbg(common, BEACON, 376 - "slot %d [tsf %llu tsftu %u intval %u] vif %p\n", 377 - slot, tsf, tsftu / ATH_BCBUF, intval, vif); 378 - } else { 379 - slot = 0; 380 - vif = sc->beacon.bslot[slot]; 381 - } 382 - 383 - 384 - bfaddr = 0; 385 - if (vif) { 386 - bf = ath_beacon_generate(sc->hw, vif); 387 - if (bf != NULL) { 388 - bfaddr = bf->bf_daddr; 389 - bc = 1; 390 - } 391 - 392 - if (sc->beacon.bmisscnt != 0) { 393 - ath_dbg(common, BSTUCK, 394 - "resume beacon xmit after %u misses\n", 395 - sc->beacon.bmisscnt); 396 - sc->beacon.bmisscnt = 0; 397 - } 408 + if (sc->beacon.bmisscnt != 0) { 409 + ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n", 410 + sc->beacon.bmisscnt); 411 + sc->beacon.bmisscnt = 0; 398 412 } 399 413 400 414 /* ··· 384 458 * set to ATH_BCBUF so this check is a noop. 385 459 */ 386 460 if (sc->beacon.updateslot == UPDATE) { 387 - sc->beacon.updateslot = COMMIT; /* commit next beacon */ 461 + sc->beacon.updateslot = COMMIT; 388 462 sc->beacon.slotupdate = slot; 389 - } else if (sc->beacon.updateslot == COMMIT && sc->beacon.slotupdate == slot) { 463 + } else if (sc->beacon.updateslot == COMMIT && 464 + sc->beacon.slotupdate == slot) { 390 465 ah->slottime = sc->beacon.slottime; 391 466 ath9k_hw_init_global_settings(ah); 392 467 sc->beacon.updateslot = OK; 393 468 } 394 - if (bfaddr != 0) { 469 + 470 + if (bf) { 471 + ath9k_reset_beacon_status(sc); 472 + 473 + ath_dbg(common, BEACON, 474 + "Transmitting beacon for slot: %d\n", slot); 475 + 395 476 /* NB: cabq traffic should already be queued and primed */ 396 - ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr); 477 + ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr); 397 478 398 479 if (!edma) 399 480 ath9k_hw_txstart(ah, sc->beacon.beaconq); 400 - 401 - sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */ 402 481 } 403 482 } 404 483 405 - static void ath9k_beacon_init(struct ath_softc *sc, 406 - u32 next_beacon, 407 - u32 beacon_period) 484 + static void ath9k_beacon_init(struct ath_softc *sc, u32 nexttbtt, u32 intval) 408 485 { 409 - if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) { 410 - ath9k_ps_wakeup(sc); 411 - ath9k_hw_reset_tsf(sc->sc_ah); 412 - } 486 + struct ath_hw *ah = sc->sc_ah; 413 487 414 - ath9k_hw_beaconinit(sc->sc_ah, next_beacon, beacon_period); 415 - 416 - if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) { 417 - ath9k_ps_restore(sc); 418 - clear_bit(SC_OP_TSF_RESET, &sc->sc_flags); 419 - } 488 + ath9k_hw_disable_interrupts(ah); 489 + ath9k_hw_reset_tsf(ah); 490 + ath9k_beaconq_config(sc); 491 + ath9k_hw_beaconinit(ah, nexttbtt, intval); 492 + sc->beacon.bmisscnt = 0; 493 + ath9k_hw_set_interrupts(ah); 494 + ath9k_hw_enable_interrupts(ah); 420 495 } 421 496 422 497 /* ··· 425 498 * burst together. For the former arrange for the SWBA to be delivered for each 426 499 * slot. Slots that are not occupied will generate nothing. 427 500 */ 428 - static void ath_beacon_config_ap(struct ath_softc *sc, 429 - struct ath_beacon_config *conf) 501 + static void ath9k_beacon_config_ap(struct ath_softc *sc, 502 + struct ath_beacon_config *conf) 430 503 { 431 504 struct ath_hw *ah = sc->sc_ah; 505 + struct ath_common *common = ath9k_hw_common(ah); 432 506 u32 nexttbtt, intval; 433 507 434 508 /* NB: the beacon interval is kept internally in TU's */ 435 509 intval = TU_TO_USEC(conf->beacon_interval); 436 - intval /= ATH_BCBUF; /* for staggered beacons */ 510 + intval /= ATH_BCBUF; 437 511 nexttbtt = intval; 438 512 439 - /* 440 - * In AP mode we enable the beacon timers and SWBA interrupts to 441 - * prepare beacon frames. 442 - */ 443 - ah->imask |= ATH9K_INT_SWBA; 444 - ath_beaconq_config(sc); 513 + if (conf->enable_beacon) 514 + ah->imask |= ATH9K_INT_SWBA; 515 + else 516 + ah->imask &= ~ATH9K_INT_SWBA; 445 517 446 - /* Set the computed AP beacon timers */ 518 + ath_dbg(common, BEACON, "AP nexttbtt: %u intval: %u conf_intval: %u\n", 519 + nexttbtt, intval, conf->beacon_interval); 447 520 448 - ath9k_hw_disable_interrupts(ah); 449 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags); 450 521 ath9k_beacon_init(sc, nexttbtt, intval); 451 - sc->beacon.bmisscnt = 0; 452 - ath9k_hw_set_interrupts(ah); 453 - ath9k_hw_enable_interrupts(ah); 454 522 } 455 523 456 524 /* ··· 456 534 * we'll receive a BMISS interrupt when we stop seeing beacons from the AP 457 535 * we've associated with. 458 536 */ 459 - static void ath_beacon_config_sta(struct ath_softc *sc, 460 - struct ath_beacon_config *conf) 537 + static void ath9k_beacon_config_sta(struct ath_softc *sc, 538 + struct ath_beacon_config *conf) 461 539 { 462 540 struct ath_hw *ah = sc->sc_ah; 463 541 struct ath_common *common = ath9k_hw_common(ah); ··· 469 547 int num_beacons, offset, dtim_dec_count, cfp_dec_count; 470 548 471 549 /* No need to configure beacon if we are not associated */ 472 - if (!common->curaid) { 550 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { 473 551 ath_dbg(common, BEACON, 474 552 "STA is not yet associated..skipping beacon config\n"); 475 553 return; ··· 576 654 ath9k_hw_enable_interrupts(ah); 577 655 } 578 656 579 - static void ath_beacon_config_adhoc(struct ath_softc *sc, 580 - struct ath_beacon_config *conf) 657 + static void ath9k_beacon_config_adhoc(struct ath_softc *sc, 658 + struct ath_beacon_config *conf) 581 659 { 582 660 struct ath_hw *ah = sc->sc_ah; 583 661 struct ath_common *common = ath9k_hw_common(ah); 584 - u32 tsf, intval, nexttbtt; 662 + u32 intval, nexttbtt; 585 663 586 664 ath9k_reset_beacon_status(sc); 587 - if (!test_bit(SC_OP_BEACONS, &sc->sc_flags)) 588 - ath9k_hw_settsf64(ah, sc->beacon.bc_tstamp); 589 665 590 666 intval = TU_TO_USEC(conf->beacon_interval); 591 - tsf = roundup(ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE), intval); 592 - nexttbtt = tsf + intval; 667 + nexttbtt = intval; 593 668 594 - ath_dbg(common, BEACON, "IBSS nexttbtt %u intval %u (%u)\n", 669 + if (conf->enable_beacon) 670 + ah->imask |= ATH9K_INT_SWBA; 671 + else 672 + ah->imask &= ~ATH9K_INT_SWBA; 673 + 674 + ath_dbg(common, BEACON, "IBSS nexttbtt: %u intval: %u conf_intval: %u\n", 595 675 nexttbtt, intval, conf->beacon_interval); 596 676 597 - /* 598 - * In IBSS mode enable the beacon timers but only enable SWBA interrupts 599 - * if we need to manually prepare beacon frames. Otherwise we use a 600 - * self-linked tx descriptor and let the hardware deal with things. 601 - */ 602 - ah->imask |= ATH9K_INT_SWBA; 603 - 604 - ath_beaconq_config(sc); 605 - 606 - /* Set the computed ADHOC beacon timers */ 607 - 608 - ath9k_hw_disable_interrupts(ah); 609 677 ath9k_beacon_init(sc, nexttbtt, intval); 610 - sc->beacon.bmisscnt = 0; 611 - 612 - ath9k_hw_set_interrupts(ah); 613 - ath9k_hw_enable_interrupts(ah); 614 678 } 615 679 616 - static bool ath9k_allow_beacon_config(struct ath_softc *sc, 617 - struct ieee80211_vif *vif) 680 + bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif) 618 681 { 619 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 620 682 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 621 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 622 683 struct ath_vif *avp = (void *)vif->drv_priv; 623 684 624 - /* 625 - * Can not have different beacon interval on multiple 626 - * AP interface case 627 - */ 628 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) && 629 - (sc->nbcnvifs > 1) && 630 - (vif->type == NL80211_IFTYPE_AP) && 631 - (cur_conf->beacon_interval != bss_conf->beacon_int)) { 632 - ath_dbg(common, CONFIG, 633 - "Changing beacon interval of multiple AP interfaces !\n"); 634 - return false; 685 + if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) { 686 + if ((vif->type != NL80211_IFTYPE_AP) || 687 + (sc->nbcnvifs > 1)) { 688 + ath_dbg(common, CONFIG, 689 + "An AP interface is already present !\n"); 690 + return false; 691 + } 635 692 } 636 - /* 637 - * Can not configure station vif's beacon config 638 - * while on AP opmode 639 - */ 640 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) && 641 - (vif->type != NL80211_IFTYPE_AP)) { 642 - ath_dbg(common, CONFIG, 643 - "STA vif's beacon not allowed on AP mode\n"); 644 - return false; 693 + 694 + if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) { 695 + if ((vif->type == NL80211_IFTYPE_STATION) && 696 + test_bit(SC_OP_BEACONS, &sc->sc_flags) && 697 + !avp->primary_sta_vif) { 698 + ath_dbg(common, CONFIG, 699 + "Beacon already configured for a station interface\n"); 700 + return false; 701 + } 645 702 } 646 - /* 647 - * Do not allow beacon config if HW was already configured 648 - * with another STA vif 649 - */ 650 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) && 651 - (vif->type == NL80211_IFTYPE_STATION) && 652 - test_bit(SC_OP_BEACONS, &sc->sc_flags) && 653 - !avp->primary_sta_vif) { 654 - ath_dbg(common, CONFIG, 655 - "Beacon already configured for a station interface\n"); 656 - return false; 657 - } 703 + 658 704 return true; 659 705 } 660 706 661 - void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif) 707 + static void ath9k_cache_beacon_config(struct ath_softc *sc, 708 + struct ieee80211_bss_conf *bss_conf) 662 709 { 710 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 663 711 struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 664 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 665 712 666 - if (!ath9k_allow_beacon_config(sc, vif)) 667 - return; 713 + ath_dbg(common, BEACON, 714 + "Caching beacon data for BSS: %pM\n", bss_conf->bssid); 668 715 669 - /* Setup the beacon configuration parameters */ 670 716 cur_conf->beacon_interval = bss_conf->beacon_int; 671 717 cur_conf->dtim_period = bss_conf->dtim_period; 672 718 cur_conf->listen_interval = 1; ··· 659 769 if (cur_conf->dtim_period == 0) 660 770 cur_conf->dtim_period = 1; 661 771 662 - ath_set_beacon(sc); 663 772 } 664 773 665 - static bool ath_has_valid_bslot(struct ath_softc *sc) 774 + void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif, 775 + u32 changed) 666 776 { 667 - struct ath_vif *avp; 668 - int slot; 669 - bool found = false; 777 + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 778 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 670 779 671 - for (slot = 0; slot < ATH_BCBUF; slot++) { 672 - if (sc->beacon.bslot[slot]) { 673 - avp = (void *)sc->beacon.bslot[slot]->drv_priv; 674 - if (avp->is_bslot_active) { 675 - found = true; 676 - break; 780 + if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) { 781 + ath9k_cache_beacon_config(sc, bss_conf); 782 + ath9k_set_beacon(sc); 783 + set_bit(SC_OP_BEACONS, &sc->sc_flags); 784 + } else { 785 + /* 786 + * Take care of multiple interfaces when 787 + * enabling/disabling SWBA. 788 + */ 789 + if (changed & BSS_CHANGED_BEACON_ENABLED) { 790 + if (!bss_conf->enable_beacon && 791 + (sc->nbcnvifs <= 1)) { 792 + cur_conf->enable_beacon = false; 793 + } else if (bss_conf->enable_beacon) { 794 + cur_conf->enable_beacon = true; 795 + ath9k_cache_beacon_config(sc, bss_conf); 677 796 } 678 797 } 798 + 799 + if (cur_conf->beacon_interval) { 800 + ath9k_set_beacon(sc); 801 + 802 + if (cur_conf->enable_beacon) 803 + set_bit(SC_OP_BEACONS, &sc->sc_flags); 804 + else 805 + clear_bit(SC_OP_BEACONS, &sc->sc_flags); 806 + } 679 807 } 680 - return found; 681 808 } 682 809 683 - 684 - void ath_set_beacon(struct ath_softc *sc) 810 + void ath9k_set_beacon(struct ath_softc *sc) 685 811 { 686 812 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 687 813 struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 688 814 689 815 switch (sc->sc_ah->opmode) { 690 816 case NL80211_IFTYPE_AP: 691 - if (ath_has_valid_bslot(sc)) 692 - ath_beacon_config_ap(sc, cur_conf); 817 + ath9k_beacon_config_ap(sc, cur_conf); 693 818 break; 694 819 case NL80211_IFTYPE_ADHOC: 695 820 case NL80211_IFTYPE_MESH_POINT: 696 - ath_beacon_config_adhoc(sc, cur_conf); 821 + ath9k_beacon_config_adhoc(sc, cur_conf); 697 822 break; 698 823 case NL80211_IFTYPE_STATION: 699 - ath_beacon_config_sta(sc, cur_conf); 824 + ath9k_beacon_config_sta(sc, cur_conf); 700 825 break; 701 826 default: 702 827 ath_dbg(common, CONFIG, "Unsupported beaconing mode\n"); 703 828 return; 704 829 } 705 - 706 - set_bit(SC_OP_BEACONS, &sc->sc_flags); 707 - } 708 - 709 - void ath9k_set_beaconing_status(struct ath_softc *sc, bool status) 710 - { 711 - struct ath_hw *ah = sc->sc_ah; 712 - 713 - if (!ath_has_valid_bslot(sc)) { 714 - clear_bit(SC_OP_BEACONS, &sc->sc_flags); 715 - return; 716 - } 717 - 718 - ath9k_ps_wakeup(sc); 719 - if (status) { 720 - /* Re-enable beaconing */ 721 - ah->imask |= ATH9K_INT_SWBA; 722 - ath9k_hw_set_interrupts(ah); 723 - } else { 724 - /* Disable SWBA interrupt */ 725 - ah->imask &= ~ATH9K_INT_SWBA; 726 - ath9k_hw_set_interrupts(ah); 727 - tasklet_kill(&sc->bcon_tasklet); 728 - ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq); 729 - } 730 - ath9k_ps_restore(sc); 731 830 }
+3 -3
drivers/net/wireless/ath/ath9k/calib.h
··· 30 30 u32 ia_columns; 31 31 }; 32 32 33 - #define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \ 33 + #define INIT_INI_ARRAY(iniarray, array) do { \ 34 34 (iniarray)->ia_array = (u32 *)(array); \ 35 - (iniarray)->ia_rows = (rows); \ 36 - (iniarray)->ia_columns = (columns); \ 35 + (iniarray)->ia_rows = ARRAY_SIZE(array); \ 36 + (iniarray)->ia_columns = ARRAY_SIZE(array[0]); \ 37 37 } while (0) 38 38 39 39 #define INI_RA(iniarray, row, column) \
+10 -3
drivers/net/wireless/ath/ath9k/debug.c
··· 206 206 207 207 if (disable_ani) { 208 208 clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 209 - del_timer_sync(&common->ani.timer); 209 + ath_stop_ani(sc); 210 210 } else { 211 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags); 212 - ath_start_ani(common); 211 + ath_check_ani(sc); 213 212 } 214 213 215 214 return count; ··· 1555 1556 &fops_interrupt); 1556 1557 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1557 1558 &fops_xmit); 1559 + debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1560 + &sc->tx.txq_max_pending[WME_AC_BK]); 1561 + debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1562 + &sc->tx.txq_max_pending[WME_AC_BE]); 1563 + debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1564 + &sc->tx.txq_max_pending[WME_AC_VI]); 1565 + debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1566 + &sc->tx.txq_max_pending[WME_AC_VO]); 1558 1567 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, 1559 1568 &fops_stations); 1560 1569 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
+13 -11
drivers/net/wireless/ath/ath9k/debug.h
··· 32 32 #define RESET_STAT_INC(sc, type) do { } while (0) 33 33 #endif 34 34 35 + enum ath_reset_type { 36 + RESET_TYPE_BB_HANG, 37 + RESET_TYPE_BB_WATCHDOG, 38 + RESET_TYPE_FATAL_INT, 39 + RESET_TYPE_TX_ERROR, 40 + RESET_TYPE_TX_HANG, 41 + RESET_TYPE_PLL_HANG, 42 + RESET_TYPE_MAC_HANG, 43 + RESET_TYPE_BEACON_STUCK, 44 + RESET_TYPE_MCI, 45 + __RESET_TYPE_MAX 46 + }; 47 + 35 48 #ifdef CONFIG_ATH9K_DEBUGFS 36 49 37 50 /** ··· 220 207 u32 rx_drop_rxflush; 221 208 u32 rx_beacons; 222 209 u32 rx_frags; 223 - }; 224 - 225 - enum ath_reset_type { 226 - RESET_TYPE_BB_HANG, 227 - RESET_TYPE_BB_WATCHDOG, 228 - RESET_TYPE_FATAL_INT, 229 - RESET_TYPE_TX_ERROR, 230 - RESET_TYPE_TX_HANG, 231 - RESET_TYPE_PLL_HANG, 232 - RESET_TYPE_MAC_HANG, 233 - __RESET_TYPE_MAX 234 210 }; 235 211 236 212 struct ath_stats {
-4
drivers/net/wireless/ath/ath9k/eeprom.h
··· 241 241 EEP_TEMPSENSE_SLOPE, 242 242 EEP_TEMPSENSE_SLOPE_PAL_ON, 243 243 EEP_PWR_TABLE_OFFSET, 244 - EEP_DRIVE_STRENGTH, 245 - EEP_INTERNAL_REGULATOR, 246 - EEP_SWREG, 247 244 EEP_PAPRD, 248 245 EEP_MODAL_VER, 249 246 EEP_ANT_DIV_CTL1, 250 247 EEP_CHAIN_MASK_REDUCE, 251 248 EEP_ANTENNA_GAIN_2G, 252 249 EEP_ANTENNA_GAIN_5G, 253 - EEP_QUICK_DROP 254 250 }; 255 251 256 252 enum ar5416_rates {
+2 -2
drivers/net/wireless/ath/ath9k/htc_drv_main.c
··· 1111 1111 1112 1112 if ((priv->ah->opmode == NL80211_IFTYPE_AP) && 1113 1113 !test_bit(OP_ANI_RUNNING, &priv->op_flags)) { 1114 - ath9k_hw_set_tsfadjust(priv->ah, 1); 1114 + ath9k_hw_set_tsfadjust(priv->ah, true); 1115 1115 ath9k_htc_start_ani(priv); 1116 1116 } 1117 1117 ··· 1351 1351 qi.tqi_aifs = params->aifs; 1352 1352 qi.tqi_cwmin = params->cw_min; 1353 1353 qi.tqi_cwmax = params->cw_max; 1354 - qi.tqi_burstTime = params->txop; 1354 + qi.tqi_burstTime = params->txop * 32; 1355 1355 1356 1356 qnum = get_hw_qnum(queue, priv->hwq_map); 1357 1357
+10 -6
drivers/net/wireless/ath/ath9k/hw.c
··· 671 671 if (!AR_SREV_9300_20_OR_LATER(ah)) 672 672 ah->ani_function &= ~ATH9K_ANI_MRC_CCK; 673 673 674 - /* disable ANI for 9340 */ 675 - if (AR_SREV_9340(ah)) 676 - ah->config.enable_ani = false; 677 - 678 674 ath9k_hw_init_mode_regs(ah); 679 675 680 676 if (!ah->is_pciexpress) ··· 2585 2589 } 2586 2590 2587 2591 2592 + if (AR_SREV_9280_20_OR_LATER(ah)) { 2593 + pCap->hw_caps |= ATH9K_HW_WOW_DEVICE_CAPABLE | 2594 + ATH9K_HW_WOW_PATTERN_MATCH_EXACT; 2595 + 2596 + if (AR_SREV_9280(ah)) 2597 + pCap->hw_caps |= ATH9K_HW_WOW_PATTERN_MATCH_DWORD; 2598 + } 2599 + 2588 2600 return 0; 2589 2601 } 2590 2602 ··· 2912 2908 } 2913 2909 EXPORT_SYMBOL(ath9k_hw_reset_tsf); 2914 2910 2915 - void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting) 2911 + void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set) 2916 2912 { 2917 - if (setting) 2913 + if (set) 2918 2914 ah->misc_mode |= AR_PCU_TX_ADD_TSF; 2919 2915 else 2920 2916 ah->misc_mode &= ~AR_PCU_TX_ADD_TSF;
+83 -1
drivers/net/wireless/ath/ath9k/hw.h
··· 180 180 #define PAPRD_TABLE_SZ 24 181 181 #define PAPRD_IDEAL_AGC2_PWR_RANGE 0xe0 182 182 183 + /* 184 + * Wake on Wireless 185 + */ 186 + 187 + /* Keep Alive Frame */ 188 + #define KAL_FRAME_LEN 28 189 + #define KAL_FRAME_TYPE 0x2 /* data frame */ 190 + #define KAL_FRAME_SUB_TYPE 0x4 /* null data frame */ 191 + #define KAL_DURATION_ID 0x3d 192 + #define KAL_NUM_DATA_WORDS 6 193 + #define KAL_NUM_DESC_WORDS 12 194 + #define KAL_ANTENNA_MODE 1 195 + #define KAL_TO_DS 1 196 + #define KAL_DELAY 4 /*delay of 4ms between 2 KAL frames */ 197 + #define KAL_TIMEOUT 900 198 + 199 + #define MAX_PATTERN_SIZE 256 200 + #define MAX_PATTERN_MASK_SIZE 32 201 + #define MAX_NUM_PATTERN 8 202 + #define MAX_NUM_USER_PATTERN 6 /* deducting the disassociate and 203 + deauthenticate packets */ 204 + 205 + /* 206 + * WoW trigger mapping to hardware code 207 + */ 208 + 209 + #define AH_WOW_USER_PATTERN_EN BIT(0) 210 + #define AH_WOW_MAGIC_PATTERN_EN BIT(1) 211 + #define AH_WOW_LINK_CHANGE BIT(2) 212 + #define AH_WOW_BEACON_MISS BIT(3) 213 + 183 214 enum ath_hw_txq_subtype { 184 215 ATH_TXQ_AC_BE = 0, 185 216 ATH_TXQ_AC_BK = 1, ··· 243 212 ATH9K_HW_CAP_RTT = BIT(14), 244 213 ATH9K_HW_CAP_MCI = BIT(15), 245 214 ATH9K_HW_CAP_DFS = BIT(16), 215 + ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(17), 216 + ATH9K_HW_WOW_PATTERN_MATCH_EXACT = BIT(18), 217 + ATH9K_HW_WOW_PATTERN_MATCH_DWORD = BIT(19), 246 218 }; 219 + 220 + /* 221 + * WoW device capabilities 222 + * @ATH9K_HW_WOW_DEVICE_CAPABLE: device revision is capable of WoW. 223 + * @ATH9K_HW_WOW_PATTERN_MATCH_EXACT: device is capable of matching 224 + * an exact user defined pattern or de-authentication/disassoc pattern. 225 + * @ATH9K_HW_WOW_PATTERN_MATCH_DWORD: device requires the first four 226 + * bytes of the pattern for user defined pattern, de-authentication and 227 + * disassociation patterns for all types of possible frames recieved 228 + * of those types. 229 + */ 247 230 248 231 struct ath9k_hw_capabilities { 249 232 u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ ··· 860 815 struct ar5416IniArray iniBank7; 861 816 struct ar5416IniArray iniAddac; 862 817 struct ar5416IniArray iniPcieSerdes; 818 + #ifdef CONFIG_PM_SLEEP 819 + struct ar5416IniArray iniPcieSerdesWow; 820 + #endif 863 821 struct ar5416IniArray iniPcieSerdesLowPower; 864 822 struct ar5416IniArray iniModesFastClock; 865 823 struct ar5416IniArray iniAdditional; ··· 911 863 /* Enterprise mode cap */ 912 864 u32 ent_mode; 913 865 866 + #ifdef CONFIG_PM_SLEEP 867 + u32 wow_event_mask; 868 + #endif 914 869 bool is_clk_25mhz; 915 870 int (*get_mac_revision)(void); 916 871 int (*external_reset)(void); ··· 994 943 u64 ath9k_hw_gettsf64(struct ath_hw *ah); 995 944 void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64); 996 945 void ath9k_hw_reset_tsf(struct ath_hw *ah); 997 - void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); 946 + void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set); 998 947 void ath9k_hw_init_global_settings(struct ath_hw *ah); 999 948 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah); 1000 949 void ath9k_hw_set11nmac2040(struct ath_hw *ah); ··· 1111 1060 return ATH_BTCOEX_CFG_NONE; 1112 1061 } 1113 1062 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ 1063 + 1064 + 1065 + #ifdef CONFIG_PM_SLEEP 1066 + const char *ath9k_hw_wow_event_to_string(u32 wow_event); 1067 + void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern, 1068 + u8 *user_mask, int pattern_count, 1069 + int pattern_len); 1070 + u32 ath9k_hw_wow_wakeup(struct ath_hw *ah); 1071 + void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable); 1072 + #else 1073 + static inline const char *ath9k_hw_wow_event_to_string(u32 wow_event) 1074 + { 1075 + return NULL; 1076 + } 1077 + static inline void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, 1078 + u8 *user_pattern, 1079 + u8 *user_mask, 1080 + int pattern_count, 1081 + int pattern_len) 1082 + { 1083 + } 1084 + static inline u32 ath9k_hw_wow_wakeup(struct ath_hw *ah) 1085 + { 1086 + return 0; 1087 + } 1088 + static inline void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable) 1089 + { 1090 + } 1091 + #endif 1092 + 1093 + 1114 1094 1115 1095 #define ATH9K_CLOCK_RATE_CCK 22 1116 1096 #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
+20 -1
drivers/net/wireless/ath/ath9k/init.c
··· 434 434 for (i = 0; i < WME_NUM_AC; i++) { 435 435 sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i); 436 436 sc->tx.txq_map[i]->mac80211_qnum = i; 437 + sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH; 437 438 } 438 439 return 0; 439 440 } ··· 559 558 spin_lock_init(&sc->debug.samp_lock); 560 559 #endif 561 560 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); 562 - tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet, 561 + tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet, 563 562 (unsigned long)sc); 564 563 565 564 INIT_WORK(&sc->hw_reset_work, ath_reset_work); ··· 713 712 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 714 713 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; 715 714 hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; 715 + 716 + #ifdef CONFIG_PM_SLEEP 717 + 718 + if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) && 719 + device_can_wakeup(sc->dev)) { 720 + 721 + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | 722 + WIPHY_WOWLAN_DISCONNECT; 723 + hw->wiphy->wowlan.n_patterns = MAX_NUM_USER_PATTERN; 724 + hw->wiphy->wowlan.pattern_min_len = 1; 725 + hw->wiphy->wowlan.pattern_max_len = MAX_PATTERN_SIZE; 726 + 727 + } 728 + 729 + atomic_set(&sc->wow_sleep_proc_intr, -1); 730 + atomic_set(&sc->wow_got_bmiss_intr, -1); 731 + 732 + #endif 716 733 717 734 hw->queues = 4; 718 735 hw->max_rates = 4;
+59 -14
drivers/net/wireless/ath/ath9k/link.c
··· 50 50 if (needreset) { 51 51 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET, 52 52 "tx hung, resetting the chip\n"); 53 - RESET_STAT_INC(sc, RESET_TYPE_TX_HANG); 54 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 53 + ath9k_queue_reset(sc, RESET_TYPE_TX_HANG); 55 54 return; 56 55 } 57 56 ··· 68 69 unsigned long flags; 69 70 int busy; 70 71 u8 is_alive, nbeacon = 1; 72 + enum ath_reset_type type; 71 73 72 74 ath9k_ps_wakeup(sc); 73 75 is_alive = ath9k_hw_check_alive(sc->sc_ah); ··· 78 78 else if (!is_alive && AR_SREV_9300(sc->sc_ah)) { 79 79 ath_dbg(common, RESET, 80 80 "DCU stuck is detected. Schedule chip reset\n"); 81 - RESET_STAT_INC(sc, RESET_TYPE_MAC_HANG); 81 + type = RESET_TYPE_MAC_HANG; 82 82 goto sched_reset; 83 83 } 84 84 ··· 90 90 busy, sc->hw_busy_count + 1); 91 91 if (busy >= 99) { 92 92 if (++sc->hw_busy_count >= 3) { 93 - RESET_STAT_INC(sc, RESET_TYPE_BB_HANG); 93 + type = RESET_TYPE_BB_HANG; 94 94 goto sched_reset; 95 95 } 96 96 } else if (busy >= 0) { ··· 102 102 goto out; 103 103 104 104 sched_reset: 105 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 105 + ath9k_queue_reset(sc, type); 106 106 out: 107 107 ath9k_ps_restore(sc); 108 108 } ··· 119 119 count++; 120 120 if (count == 3) { 121 121 ath_dbg(common, RESET, "PLL WAR, resetting the chip\n"); 122 - RESET_STAT_INC(sc, RESET_TYPE_PLL_HANG); 123 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 122 + ath9k_queue_reset(sc, RESET_TYPE_PLL_HANG); 124 123 count = 0; 125 124 return true; 126 125 } ··· 431 432 } 432 433 } 433 434 434 - void ath_start_ani(struct ath_common *common) 435 + void ath_start_ani(struct ath_softc *sc) 435 436 { 436 - struct ath_hw *ah = common->ah; 437 + struct ath_hw *ah = sc->sc_ah; 438 + struct ath_common *common = ath9k_hw_common(ah); 437 439 unsigned long timestamp = jiffies_to_msecs(jiffies); 438 - struct ath_softc *sc = (struct ath_softc *) common->priv; 439 440 440 - if (!test_bit(SC_OP_ANI_RUN, &sc->sc_flags)) 441 - return; 442 - 443 - if (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) 441 + if (common->disable_ani || 442 + !test_bit(SC_OP_ANI_RUN, &sc->sc_flags) || 443 + (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) 444 444 return; 445 445 446 446 common->ani.longcal_timer = timestamp; 447 447 common->ani.shortcal_timer = timestamp; 448 448 common->ani.checkani_timer = timestamp; 449 449 450 + ath_dbg(common, ANI, "Starting ANI\n"); 450 451 mod_timer(&common->ani.timer, 451 452 jiffies + msecs_to_jiffies((u32)ah->config.ani_poll_interval)); 453 + } 454 + 455 + void ath_stop_ani(struct ath_softc *sc) 456 + { 457 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 458 + 459 + ath_dbg(common, ANI, "Stopping ANI\n"); 460 + del_timer_sync(&common->ani.timer); 461 + } 462 + 463 + void ath_check_ani(struct ath_softc *sc) 464 + { 465 + struct ath_hw *ah = sc->sc_ah; 466 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf; 467 + 468 + /* 469 + * Check for the various conditions in which ANI has to 470 + * be stopped. 471 + */ 472 + if (ah->opmode == NL80211_IFTYPE_ADHOC) { 473 + if (!cur_conf->enable_beacon) 474 + goto stop_ani; 475 + } else if (ah->opmode == NL80211_IFTYPE_AP) { 476 + if (!cur_conf->enable_beacon) { 477 + /* 478 + * Disable ANI only when there are no 479 + * associated stations. 480 + */ 481 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) 482 + goto stop_ani; 483 + } 484 + } else if (ah->opmode == NL80211_IFTYPE_STATION) { 485 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) 486 + goto stop_ani; 487 + } 488 + 489 + if (!test_bit(SC_OP_ANI_RUN, &sc->sc_flags)) { 490 + set_bit(SC_OP_ANI_RUN, &sc->sc_flags); 491 + ath_start_ani(sc); 492 + } 493 + 494 + return; 495 + 496 + stop_ani: 497 + clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 498 + ath_stop_ani(sc); 452 499 } 453 500 454 501 void ath_update_survey_nf(struct ath_softc *sc, int channel)
+523 -184
drivers/net/wireless/ath/ath9k/main.c
··· 19 19 #include "ath9k.h" 20 20 #include "btcoex.h" 21 21 22 + static void ath9k_set_assoc_state(struct ath_softc *sc, 23 + struct ieee80211_vif *vif); 24 + 22 25 u8 ath9k_parse_mpdudensity(u8 mpdudensity) 23 26 { 24 27 /* ··· 170 167 171 168 static void ath_restart_work(struct ath_softc *sc) 172 169 { 173 - struct ath_common *common = ath9k_hw_common(sc->sc_ah); 174 - 175 170 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); 176 171 177 172 if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) || ··· 178 177 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); 179 178 180 179 ath_start_rx_poll(sc, 3); 181 - 182 - if (!common->disable_ani) 183 - ath_start_ani(common); 180 + ath_start_ani(sc); 184 181 } 185 182 186 183 static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush) 187 184 { 188 185 struct ath_hw *ah = sc->sc_ah; 189 - struct ath_common *common = ath9k_hw_common(ah); 190 186 bool ret = true; 191 187 192 188 ieee80211_stop_queues(sc->hw); 193 189 194 190 sc->hw_busy_count = 0; 195 - del_timer_sync(&common->ani.timer); 191 + ath_stop_ani(sc); 196 192 del_timer_sync(&sc->rx_poll_timer); 197 193 198 194 ath9k_debug_samp_bb_mac(sc); ··· 234 236 if (!test_bit(SC_OP_BEACONS, &sc->sc_flags)) 235 237 goto work; 236 238 237 - ath_set_beacon(sc); 239 + ath9k_set_beacon(sc); 238 240 239 241 if (ah->opmode == NL80211_IFTYPE_STATION && 240 242 test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { ··· 363 365 struct ath_softc *sc = (struct ath_softc *)data; 364 366 struct ath_hw *ah = sc->sc_ah; 365 367 struct ath_common *common = ath9k_hw_common(ah); 368 + enum ath_reset_type type; 366 369 unsigned long flags; 367 370 u32 status = sc->intrstatus; 368 371 u32 rxmask; ··· 373 374 374 375 if ((status & ATH9K_INT_FATAL) || 375 376 (status & ATH9K_INT_BB_WATCHDOG)) { 376 - #ifdef CONFIG_ATH9K_DEBUGFS 377 - enum ath_reset_type type; 378 377 379 378 if (status & ATH9K_INT_FATAL) 380 379 type = RESET_TYPE_FATAL_INT; 381 380 else 382 381 type = RESET_TYPE_BB_WATCHDOG; 383 382 384 - RESET_STAT_INC(sc, type); 385 - #endif 386 - set_bit(SC_OP_HW_RESET, &sc->sc_flags); 387 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 383 + ath9k_queue_reset(sc, type); 388 384 goto out; 389 385 } 390 386 ··· 487 493 if (status & SCHED_INTR) 488 494 sched = true; 489 495 496 + #ifdef CONFIG_PM_SLEEP 497 + if (status & ATH9K_INT_BMISS) { 498 + if (atomic_read(&sc->wow_sleep_proc_intr) == 0) { 499 + ath_dbg(common, ANY, "during WoW we got a BMISS\n"); 500 + atomic_inc(&sc->wow_got_bmiss_intr); 501 + atomic_dec(&sc->wow_sleep_proc_intr); 502 + } 503 + ath_dbg(common, INTERRUPT, "beacon miss interrupt\n"); 504 + } 505 + #endif 506 + 490 507 /* 491 508 * If a FATAL or RXORN interrupt is received, we have to reset the 492 509 * chip immediately. ··· 578 573 ath9k_ps_restore(sc); 579 574 580 575 return r; 576 + } 577 + 578 + void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type) 579 + { 580 + #ifdef CONFIG_ATH9K_DEBUGFS 581 + RESET_STAT_INC(sc, type); 582 + #endif 583 + set_bit(SC_OP_HW_RESET, &sc->sc_flags); 584 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 581 585 } 582 586 583 587 void ath_reset_work(struct work_struct *work) ··· 855 841 } 856 842 } 857 843 858 - static void ath9k_reclaim_beacon(struct ath_softc *sc, 859 - struct ieee80211_vif *vif) 860 - { 861 - struct ath_vif *avp = (void *)vif->drv_priv; 862 - 863 - ath9k_set_beaconing_status(sc, false); 864 - ath_beacon_return(sc, avp); 865 - ath9k_set_beaconing_status(sc, true); 866 - } 867 - 868 844 static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) 869 845 { 870 846 struct ath9k_vif_iter_data *iter_data = data; ··· 884 880 default: 885 881 break; 886 882 } 883 + } 884 + 885 + static void ath9k_sta_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) 886 + { 887 + struct ath_softc *sc = data; 888 + struct ath_vif *avp = (void *)vif->drv_priv; 889 + 890 + if (vif->type != NL80211_IFTYPE_STATION) 891 + return; 892 + 893 + if (avp->primary_sta_vif) 894 + ath9k_set_assoc_state(sc, vif); 887 895 } 888 896 889 897 /* Called with sc->mutex held. */ ··· 931 915 struct ath_hw *ah = sc->sc_ah; 932 916 struct ath_common *common = ath9k_hw_common(ah); 933 917 struct ath9k_vif_iter_data iter_data; 918 + enum nl80211_iftype old_opmode = ah->opmode; 934 919 935 920 ath9k_calculate_iter_data(hw, vif, &iter_data); 936 921 937 - /* Set BSSID mask. */ 938 922 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN); 939 923 ath_hw_setbssidmask(common); 940 924 941 - /* Set op-mode & TSF */ 942 925 if (iter_data.naps > 0) { 943 - ath9k_hw_set_tsfadjust(ah, 1); 944 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags); 926 + ath9k_hw_set_tsfadjust(ah, true); 945 927 ah->opmode = NL80211_IFTYPE_AP; 946 928 } else { 947 - ath9k_hw_set_tsfadjust(ah, 0); 948 - clear_bit(SC_OP_TSF_RESET, &sc->sc_flags); 929 + ath9k_hw_set_tsfadjust(ah, false); 949 930 950 931 if (iter_data.nmeshes) 951 932 ah->opmode = NL80211_IFTYPE_MESH_POINT; ··· 954 941 ah->opmode = NL80211_IFTYPE_STATION; 955 942 } 956 943 957 - /* 958 - * Enable MIB interrupts when there are hardware phy counters. 959 - */ 944 + ath9k_hw_setopmode(ah); 945 + 960 946 if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0) 961 947 ah->imask |= ATH9K_INT_TSFOOR; 962 948 else ··· 963 951 964 952 ath9k_hw_set_interrupts(ah); 965 953 966 - /* Set up ANI */ 967 - if (iter_data.naps > 0) { 968 - sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 969 - 970 - if (!common->disable_ani) { 971 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags); 972 - ath_start_ani(common); 973 - } 974 - 975 - } else { 976 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 977 - del_timer_sync(&common->ani.timer); 978 - } 979 - } 980 - 981 - /* Called with sc->mutex held, vif counts set up properly. */ 982 - static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw, 983 - struct ieee80211_vif *vif) 984 - { 985 - struct ath_softc *sc = hw->priv; 986 - 987 - ath9k_calculate_summary_state(hw, vif); 988 - 989 - if (ath9k_uses_beacons(vif->type)) { 990 - /* Reserve a beacon slot for the vif */ 991 - ath9k_set_beaconing_status(sc, false); 992 - ath_beacon_alloc(sc, vif); 993 - ath9k_set_beaconing_status(sc, true); 954 + /* 955 + * If we are changing the opmode to STATION, 956 + * a beacon sync needs to be done. 957 + */ 958 + if (ah->opmode == NL80211_IFTYPE_STATION && 959 + old_opmode == NL80211_IFTYPE_AP && 960 + test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { 961 + ieee80211_iterate_active_interfaces_atomic(sc->hw, 962 + ath9k_sta_vif_iter, sc); 994 963 } 995 964 } 996 965 ··· 1014 1021 1015 1022 sc->nvifs++; 1016 1023 1017 - ath9k_do_vif_add_setup(hw, vif); 1024 + ath9k_calculate_summary_state(hw, vif); 1025 + if (ath9k_uses_beacons(vif->type)) 1026 + ath9k_beacon_assign_slot(sc, vif); 1027 + 1018 1028 out: 1019 1029 mutex_unlock(&sc->mutex); 1020 1030 ath9k_ps_restore(sc); ··· 1034 1038 int ret = 0; 1035 1039 1036 1040 ath_dbg(common, CONFIG, "Change Interface\n"); 1041 + 1037 1042 mutex_lock(&sc->mutex); 1038 1043 ath9k_ps_wakeup(sc); 1039 1044 ··· 1047 1050 } 1048 1051 } 1049 1052 1050 - /* Clean up old vif stuff */ 1051 1053 if (ath9k_uses_beacons(vif->type)) 1052 - ath9k_reclaim_beacon(sc, vif); 1054 + ath9k_beacon_remove_slot(sc, vif); 1053 1055 1054 - /* Add new settings */ 1055 1056 vif->type = new_type; 1056 1057 vif->p2p = p2p; 1057 1058 1058 - ath9k_do_vif_add_setup(hw, vif); 1059 + ath9k_calculate_summary_state(hw, vif); 1060 + if (ath9k_uses_beacons(vif->type)) 1061 + ath9k_beacon_assign_slot(sc, vif); 1062 + 1059 1063 out: 1060 1064 ath9k_ps_restore(sc); 1061 1065 mutex_unlock(&sc->mutex); ··· 1076 1078 1077 1079 sc->nvifs--; 1078 1080 1079 - /* Reclaim beacon resources */ 1080 1081 if (ath9k_uses_beacons(vif->type)) 1081 - ath9k_reclaim_beacon(sc, vif); 1082 + ath9k_beacon_remove_slot(sc, vif); 1082 1083 1083 1084 ath9k_calculate_summary_state(hw, NULL); 1084 1085 ··· 1374 1377 qi.tqi_aifs = params->aifs; 1375 1378 qi.tqi_cwmin = params->cw_min; 1376 1379 qi.tqi_cwmax = params->cw_max; 1377 - qi.tqi_burstTime = params->txop; 1380 + qi.tqi_burstTime = params->txop * 32; 1378 1381 1379 1382 ath_dbg(common, CONFIG, 1380 1383 "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n", 1381 1384 queue, txq->axq_qnum, params->aifs, params->cw_min, 1382 1385 params->cw_max, params->txop); 1383 1386 1387 + ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime); 1384 1388 ret = ath_txq_update(sc, txq->axq_qnum, &qi); 1385 1389 if (ret) 1386 1390 ath_err(common, "TXQ Update failed\n"); 1387 - 1388 - if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) 1389 - if (queue == WME_AC_BE && !ret) 1390 - ath_beaconq_config(sc); 1391 1391 1392 1392 mutex_unlock(&sc->mutex); 1393 1393 ath9k_ps_restore(sc); ··· 1454 1460 1455 1461 return ret; 1456 1462 } 1457 - static void ath9k_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif) 1463 + 1464 + static void ath9k_set_assoc_state(struct ath_softc *sc, 1465 + struct ieee80211_vif *vif) 1458 1466 { 1459 - struct ath_softc *sc = data; 1460 1467 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1461 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1462 1468 struct ath_vif *avp = (void *)vif->drv_priv; 1469 + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1463 1470 unsigned long flags; 1471 + 1472 + set_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags); 1473 + avp->primary_sta_vif = true; 1474 + 1464 1475 /* 1465 - * Skip iteration if primary station vif's bss info 1466 - * was not changed 1476 + * Set the AID, BSSID and do beacon-sync only when 1477 + * the HW opmode is STATION. 1478 + * 1479 + * But the primary bit is set above in any case. 1467 1480 */ 1468 - if (test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) 1469 - return; 1470 - 1471 - if (bss_conf->assoc) { 1472 - set_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags); 1473 - avp->primary_sta_vif = true; 1474 - memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); 1475 - common->curaid = bss_conf->aid; 1476 - ath9k_hw_write_associd(sc->sc_ah); 1477 - ath_dbg(common, CONFIG, "Bss Info ASSOC %d, bssid: %pM\n", 1478 - bss_conf->aid, common->curbssid); 1479 - ath_beacon_config(sc, vif); 1480 - /* 1481 - * Request a re-configuration of Beacon related timers 1482 - * on the receipt of the first Beacon frame (i.e., 1483 - * after time sync with the AP). 1484 - */ 1485 - spin_lock_irqsave(&sc->sc_pm_lock, flags); 1486 - sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; 1487 - spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 1488 - 1489 - /* Reset rssi stats */ 1490 - sc->last_rssi = ATH_RSSI_DUMMY_MARKER; 1491 - sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 1492 - 1493 - ath_start_rx_poll(sc, 3); 1494 - 1495 - if (!common->disable_ani) { 1496 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags); 1497 - ath_start_ani(common); 1498 - } 1499 - 1500 - } 1501 - } 1502 - 1503 - static void ath9k_config_bss(struct ath_softc *sc, struct ieee80211_vif *vif) 1504 - { 1505 - struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1506 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1507 - struct ath_vif *avp = (void *)vif->drv_priv; 1508 - 1509 1481 if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION) 1510 1482 return; 1511 1483 1512 - /* Reconfigure bss info */ 1513 - if (avp->primary_sta_vif && !bss_conf->assoc) { 1514 - ath_dbg(common, CONFIG, "Bss Info DISASSOC %d, bssid %pM\n", 1515 - common->curaid, common->curbssid); 1516 - clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags); 1517 - clear_bit(SC_OP_BEACONS, &sc->sc_flags); 1518 - avp->primary_sta_vif = false; 1519 - memset(common->curbssid, 0, ETH_ALEN); 1520 - common->curaid = 0; 1521 - } 1484 + memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); 1485 + common->curaid = bss_conf->aid; 1486 + ath9k_hw_write_associd(sc->sc_ah); 1522 1487 1523 - ieee80211_iterate_active_interfaces_atomic( 1524 - sc->hw, ath9k_bss_iter, sc); 1488 + sc->last_rssi = ATH_RSSI_DUMMY_MARKER; 1489 + sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 1525 1490 1526 - /* 1527 - * None of station vifs are associated. 1528 - * Clear bssid & aid 1529 - */ 1530 - if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { 1531 - ath9k_hw_write_associd(sc->sc_ah); 1532 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 1533 - del_timer_sync(&common->ani.timer); 1534 - del_timer_sync(&sc->rx_poll_timer); 1535 - memset(&sc->caldata, 0, sizeof(sc->caldata)); 1536 - } 1491 + spin_lock_irqsave(&sc->sc_pm_lock, flags); 1492 + sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; 1493 + spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 1494 + 1495 + ath_dbg(common, CONFIG, 1496 + "Primary Station interface: %pM, BSSID: %pM\n", 1497 + vif->addr, common->curbssid); 1498 + } 1499 + 1500 + static void ath9k_bss_assoc_iter(void *data, u8 *mac, struct ieee80211_vif *vif) 1501 + { 1502 + struct ath_softc *sc = data; 1503 + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1504 + 1505 + if (test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) 1506 + return; 1507 + 1508 + if (bss_conf->assoc) 1509 + ath9k_set_assoc_state(sc, vif); 1537 1510 } 1538 1511 1539 1512 static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ··· 1508 1547 struct ieee80211_bss_conf *bss_conf, 1509 1548 u32 changed) 1510 1549 { 1550 + #define CHECK_ANI \ 1551 + (BSS_CHANGED_ASSOC | \ 1552 + BSS_CHANGED_IBSS | \ 1553 + BSS_CHANGED_BEACON_ENABLED) 1554 + 1511 1555 struct ath_softc *sc = hw->priv; 1512 1556 struct ath_hw *ah = sc->sc_ah; 1513 1557 struct ath_common *common = ath9k_hw_common(ah); ··· 1523 1557 mutex_lock(&sc->mutex); 1524 1558 1525 1559 if (changed & BSS_CHANGED_ASSOC) { 1526 - ath9k_config_bss(sc, vif); 1560 + ath_dbg(common, CONFIG, "BSSID %pM Changed ASSOC %d\n", 1561 + bss_conf->bssid, bss_conf->assoc); 1527 1562 1528 - ath_dbg(common, CONFIG, "BSSID: %pM aid: 0x%x\n", 1529 - common->curbssid, common->curaid); 1530 - } 1563 + if (avp->primary_sta_vif && !bss_conf->assoc) { 1564 + clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags); 1565 + avp->primary_sta_vif = false; 1531 1566 1532 - if (changed & BSS_CHANGED_IBSS) { 1533 - /* There can be only one vif available */ 1534 - memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); 1535 - common->curaid = bss_conf->aid; 1536 - ath9k_hw_write_associd(sc->sc_ah); 1567 + if (ah->opmode == NL80211_IFTYPE_STATION) 1568 + clear_bit(SC_OP_BEACONS, &sc->sc_flags); 1569 + } 1537 1570 1538 - if (bss_conf->ibss_joined) { 1539 - sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 1571 + ieee80211_iterate_active_interfaces_atomic(sc->hw, 1572 + ath9k_bss_assoc_iter, sc); 1540 1573 1541 - if (!common->disable_ani) { 1542 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags); 1543 - ath_start_ani(common); 1544 - } 1545 - 1546 - } else { 1547 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 1548 - del_timer_sync(&common->ani.timer); 1549 - del_timer_sync(&sc->rx_poll_timer); 1574 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags) && 1575 + ah->opmode == NL80211_IFTYPE_STATION) { 1576 + memset(common->curbssid, 0, ETH_ALEN); 1577 + common->curaid = 0; 1578 + ath9k_hw_write_associd(sc->sc_ah); 1550 1579 } 1551 1580 } 1552 1581 1553 - /* 1554 - * In case of AP mode, the HW TSF has to be reset 1555 - * when the beacon interval changes. 1556 - */ 1557 - if ((changed & BSS_CHANGED_BEACON_INT) && 1558 - (vif->type == NL80211_IFTYPE_AP)) 1559 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags); 1582 + if (changed & BSS_CHANGED_IBSS) { 1583 + memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); 1584 + common->curaid = bss_conf->aid; 1585 + ath9k_hw_write_associd(sc->sc_ah); 1586 + } 1560 1587 1561 - /* Configure beaconing (AP, IBSS, MESH) */ 1562 - if (ath9k_uses_beacons(vif->type) && 1563 - ((changed & BSS_CHANGED_BEACON) || 1564 - (changed & BSS_CHANGED_BEACON_ENABLED) || 1565 - (changed & BSS_CHANGED_BEACON_INT))) { 1566 - ath9k_set_beaconing_status(sc, false); 1567 - if (bss_conf->enable_beacon) 1568 - ath_beacon_alloc(sc, vif); 1569 - else 1570 - avp->is_bslot_active = false; 1571 - ath_beacon_config(sc, vif); 1572 - ath9k_set_beaconing_status(sc, true); 1588 + if ((changed & BSS_CHANGED_BEACON_ENABLED) || 1589 + (changed & BSS_CHANGED_BEACON_INT)) { 1590 + if (ah->opmode == NL80211_IFTYPE_AP && 1591 + bss_conf->enable_beacon) 1592 + ath9k_set_tsfadjust(sc, vif); 1593 + if (ath9k_allow_beacon_config(sc, vif)) 1594 + ath9k_beacon_config(sc, vif, changed); 1573 1595 } 1574 1596 1575 1597 if (changed & BSS_CHANGED_ERP_SLOT) { ··· 1579 1625 } 1580 1626 } 1581 1627 1628 + if (changed & CHECK_ANI) 1629 + ath_check_ani(sc); 1630 + 1582 1631 mutex_unlock(&sc->mutex); 1583 1632 ath9k_ps_restore(sc); 1633 + 1634 + #undef CHECK_ANI 1584 1635 } 1585 1636 1586 1637 static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ··· 1814 1855 if (!vif) 1815 1856 return 0; 1816 1857 1817 - avp = (void *)vif->drv_priv; 1818 - if (!avp->is_bslot_active) 1858 + if (!vif->bss_conf.enable_beacon) 1819 1859 return 0; 1860 + 1861 + avp = (void *)vif->drv_priv; 1820 1862 1821 1863 if (!sc->beacon.tx_processed && !edma) { 1822 1864 tasklet_disable(&sc->bcon_tasklet); ··· 1872 1912 return filled; 1873 1913 } 1874 1914 1915 + static bool validate_antenna_mask(struct ath_hw *ah, u32 val) 1916 + { 1917 + switch (val & 0x7) { 1918 + case 0x1: 1919 + case 0x3: 1920 + case 0x7: 1921 + return true; 1922 + case 0x2: 1923 + return (ah->caps.rx_chainmask == 1); 1924 + default: 1925 + return false; 1926 + } 1927 + } 1928 + 1875 1929 static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) 1876 1930 { 1877 1931 struct ath_softc *sc = hw->priv; 1878 1932 struct ath_hw *ah = sc->sc_ah; 1879 1933 1880 - if (!rx_ant || !tx_ant) 1934 + if (ah->caps.rx_chainmask != 1) 1935 + rx_ant |= tx_ant; 1936 + 1937 + if (!validate_antenna_mask(ah, rx_ant) || !tx_ant) 1881 1938 return -EINVAL; 1882 1939 1883 1940 sc->ant_rx = rx_ant; ··· 2052 2075 #endif 2053 2076 2054 2077 2078 + #ifdef CONFIG_PM_SLEEP 2079 + 2080 + static void ath9k_wow_map_triggers(struct ath_softc *sc, 2081 + struct cfg80211_wowlan *wowlan, 2082 + u32 *wow_triggers) 2083 + { 2084 + if (wowlan->disconnect) 2085 + *wow_triggers |= AH_WOW_LINK_CHANGE | 2086 + AH_WOW_BEACON_MISS; 2087 + if (wowlan->magic_pkt) 2088 + *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN; 2089 + 2090 + if (wowlan->n_patterns) 2091 + *wow_triggers |= AH_WOW_USER_PATTERN_EN; 2092 + 2093 + sc->wow_enabled = *wow_triggers; 2094 + 2095 + } 2096 + 2097 + static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc) 2098 + { 2099 + struct ath_hw *ah = sc->sc_ah; 2100 + struct ath_common *common = ath9k_hw_common(ah); 2101 + struct ath9k_hw_capabilities *pcaps = &ah->caps; 2102 + int pattern_count = 0; 2103 + int i, byte_cnt; 2104 + u8 dis_deauth_pattern[MAX_PATTERN_SIZE]; 2105 + u8 dis_deauth_mask[MAX_PATTERN_SIZE]; 2106 + 2107 + memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE); 2108 + memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE); 2109 + 2110 + /* 2111 + * Create Dissassociate / Deauthenticate packet filter 2112 + * 2113 + * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes 2114 + * +--------------+----------+---------+--------+--------+---- 2115 + * + Frame Control+ Duration + DA + SA + BSSID + 2116 + * +--------------+----------+---------+--------+--------+---- 2117 + * 2118 + * The above is the management frame format for disassociate/ 2119 + * deauthenticate pattern, from this we need to match the first byte 2120 + * of 'Frame Control' and DA, SA, and BSSID fields 2121 + * (skipping 2nd byte of FC and Duration feild. 2122 + * 2123 + * Disassociate pattern 2124 + * -------------------- 2125 + * Frame control = 00 00 1010 2126 + * DA, SA, BSSID = x:x:x:x:x:x 2127 + * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x 2128 + * | x:x:x:x:x:x -- 22 bytes 2129 + * 2130 + * Deauthenticate pattern 2131 + * ---------------------- 2132 + * Frame control = 00 00 1100 2133 + * DA, SA, BSSID = x:x:x:x:x:x 2134 + * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x 2135 + * | x:x:x:x:x:x -- 22 bytes 2136 + */ 2137 + 2138 + /* Create Disassociate Pattern first */ 2139 + 2140 + byte_cnt = 0; 2141 + 2142 + /* Fill out the mask with all FF's */ 2143 + 2144 + for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++) 2145 + dis_deauth_mask[i] = 0xff; 2146 + 2147 + /* copy the first byte of frame control field */ 2148 + dis_deauth_pattern[byte_cnt] = 0xa0; 2149 + byte_cnt++; 2150 + 2151 + /* skip 2nd byte of frame control and Duration field */ 2152 + byte_cnt += 3; 2153 + 2154 + /* 2155 + * need not match the destination mac address, it can be a broadcast 2156 + * mac address or an unicast to this station 2157 + */ 2158 + byte_cnt += 6; 2159 + 2160 + /* copy the source mac address */ 2161 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN); 2162 + 2163 + byte_cnt += 6; 2164 + 2165 + /* copy the bssid, its same as the source mac address */ 2166 + 2167 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN); 2168 + 2169 + /* Create Disassociate pattern mask */ 2170 + 2171 + if (pcaps->hw_caps & ATH9K_HW_WOW_PATTERN_MATCH_EXACT) { 2172 + 2173 + if (pcaps->hw_caps & ATH9K_HW_WOW_PATTERN_MATCH_DWORD) { 2174 + /* 2175 + * for AR9280, because of hardware limitation, the 2176 + * first 4 bytes have to be matched for all patterns. 2177 + * the mask for disassociation and de-auth pattern 2178 + * matching need to enable the first 4 bytes. 2179 + * also the duration field needs to be filled. 2180 + */ 2181 + dis_deauth_mask[0] = 0xf0; 2182 + 2183 + /* 2184 + * fill in duration field 2185 + FIXME: what is the exact value ? 2186 + */ 2187 + dis_deauth_pattern[2] = 0xff; 2188 + dis_deauth_pattern[3] = 0xff; 2189 + } else { 2190 + dis_deauth_mask[0] = 0xfe; 2191 + } 2192 + 2193 + dis_deauth_mask[1] = 0x03; 2194 + dis_deauth_mask[2] = 0xc0; 2195 + } else { 2196 + dis_deauth_mask[0] = 0xef; 2197 + dis_deauth_mask[1] = 0x3f; 2198 + dis_deauth_mask[2] = 0x00; 2199 + dis_deauth_mask[3] = 0xfc; 2200 + } 2201 + 2202 + ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n"); 2203 + 2204 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask, 2205 + pattern_count, byte_cnt); 2206 + 2207 + pattern_count++; 2208 + /* 2209 + * for de-authenticate pattern, only the first byte of the frame 2210 + * control field gets changed from 0xA0 to 0xC0 2211 + */ 2212 + dis_deauth_pattern[0] = 0xC0; 2213 + 2214 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask, 2215 + pattern_count, byte_cnt); 2216 + 2217 + } 2218 + 2219 + static void ath9k_wow_add_pattern(struct ath_softc *sc, 2220 + struct cfg80211_wowlan *wowlan) 2221 + { 2222 + struct ath_hw *ah = sc->sc_ah; 2223 + struct ath9k_wow_pattern *wow_pattern = NULL; 2224 + struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns; 2225 + int mask_len; 2226 + s8 i = 0; 2227 + 2228 + if (!wowlan->n_patterns) 2229 + return; 2230 + 2231 + /* 2232 + * Add the new user configured patterns 2233 + */ 2234 + for (i = 0; i < wowlan->n_patterns; i++) { 2235 + 2236 + wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL); 2237 + 2238 + if (!wow_pattern) 2239 + return; 2240 + 2241 + /* 2242 + * TODO: convert the generic user space pattern to 2243 + * appropriate chip specific/802.11 pattern. 2244 + */ 2245 + 2246 + mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); 2247 + memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE); 2248 + memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE); 2249 + memcpy(wow_pattern->pattern_bytes, patterns[i].pattern, 2250 + patterns[i].pattern_len); 2251 + memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len); 2252 + wow_pattern->pattern_len = patterns[i].pattern_len; 2253 + 2254 + /* 2255 + * just need to take care of deauth and disssoc pattern, 2256 + * make sure we don't overwrite them. 2257 + */ 2258 + 2259 + ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes, 2260 + wow_pattern->mask_bytes, 2261 + i + 2, 2262 + wow_pattern->pattern_len); 2263 + kfree(wow_pattern); 2264 + 2265 + } 2266 + 2267 + } 2268 + 2269 + static int ath9k_suspend(struct ieee80211_hw *hw, 2270 + struct cfg80211_wowlan *wowlan) 2271 + { 2272 + struct ath_softc *sc = hw->priv; 2273 + struct ath_hw *ah = sc->sc_ah; 2274 + struct ath_common *common = ath9k_hw_common(ah); 2275 + u32 wow_triggers_enabled = 0; 2276 + int ret = 0; 2277 + 2278 + mutex_lock(&sc->mutex); 2279 + 2280 + ath_cancel_work(sc); 2281 + del_timer_sync(&common->ani.timer); 2282 + del_timer_sync(&sc->rx_poll_timer); 2283 + 2284 + if (test_bit(SC_OP_INVALID, &sc->sc_flags)) { 2285 + ath_dbg(common, ANY, "Device not present\n"); 2286 + ret = -EINVAL; 2287 + goto fail_wow; 2288 + } 2289 + 2290 + if (WARN_ON(!wowlan)) { 2291 + ath_dbg(common, WOW, "None of the WoW triggers enabled\n"); 2292 + ret = -EINVAL; 2293 + goto fail_wow; 2294 + } 2295 + 2296 + if (!device_can_wakeup(sc->dev)) { 2297 + ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n"); 2298 + ret = 1; 2299 + goto fail_wow; 2300 + } 2301 + 2302 + /* 2303 + * none of the sta vifs are associated 2304 + * and we are not currently handling multivif 2305 + * cases, for instance we have to seperately 2306 + * configure 'keep alive frame' for each 2307 + * STA. 2308 + */ 2309 + 2310 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { 2311 + ath_dbg(common, WOW, "None of the STA vifs are associated\n"); 2312 + ret = 1; 2313 + goto fail_wow; 2314 + } 2315 + 2316 + if (sc->nvifs > 1) { 2317 + ath_dbg(common, WOW, "WoW for multivif is not yet supported\n"); 2318 + ret = 1; 2319 + goto fail_wow; 2320 + } 2321 + 2322 + ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled); 2323 + 2324 + ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n", 2325 + wow_triggers_enabled); 2326 + 2327 + ath9k_ps_wakeup(sc); 2328 + 2329 + ath9k_stop_btcoex(sc); 2330 + 2331 + /* 2332 + * Enable wake up on recieving disassoc/deauth 2333 + * frame by default. 2334 + */ 2335 + ath9k_wow_add_disassoc_deauth_pattern(sc); 2336 + 2337 + if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN) 2338 + ath9k_wow_add_pattern(sc, wowlan); 2339 + 2340 + spin_lock_bh(&sc->sc_pcu_lock); 2341 + /* 2342 + * To avoid false wake, we enable beacon miss interrupt only 2343 + * when we go to sleep. We save the current interrupt mask 2344 + * so we can restore it after the system wakes up 2345 + */ 2346 + sc->wow_intr_before_sleep = ah->imask; 2347 + ah->imask &= ~ATH9K_INT_GLOBAL; 2348 + ath9k_hw_disable_interrupts(ah); 2349 + ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL; 2350 + ath9k_hw_set_interrupts(ah); 2351 + ath9k_hw_enable_interrupts(ah); 2352 + 2353 + spin_unlock_bh(&sc->sc_pcu_lock); 2354 + 2355 + /* 2356 + * we can now sync irq and kill any running tasklets, since we already 2357 + * disabled interrupts and not holding a spin lock 2358 + */ 2359 + synchronize_irq(sc->irq); 2360 + tasklet_kill(&sc->intr_tq); 2361 + 2362 + ath9k_hw_wow_enable(ah, wow_triggers_enabled); 2363 + 2364 + ath9k_ps_restore(sc); 2365 + ath_dbg(common, ANY, "WoW enabled in ath9k\n"); 2366 + atomic_inc(&sc->wow_sleep_proc_intr); 2367 + 2368 + fail_wow: 2369 + mutex_unlock(&sc->mutex); 2370 + return ret; 2371 + } 2372 + 2373 + static int ath9k_resume(struct ieee80211_hw *hw) 2374 + { 2375 + struct ath_softc *sc = hw->priv; 2376 + struct ath_hw *ah = sc->sc_ah; 2377 + struct ath_common *common = ath9k_hw_common(ah); 2378 + u32 wow_status; 2379 + 2380 + mutex_lock(&sc->mutex); 2381 + 2382 + ath9k_ps_wakeup(sc); 2383 + 2384 + spin_lock_bh(&sc->sc_pcu_lock); 2385 + 2386 + ath9k_hw_disable_interrupts(ah); 2387 + ah->imask = sc->wow_intr_before_sleep; 2388 + ath9k_hw_set_interrupts(ah); 2389 + ath9k_hw_enable_interrupts(ah); 2390 + 2391 + spin_unlock_bh(&sc->sc_pcu_lock); 2392 + 2393 + wow_status = ath9k_hw_wow_wakeup(ah); 2394 + 2395 + if (atomic_read(&sc->wow_got_bmiss_intr) == 0) { 2396 + /* 2397 + * some devices may not pick beacon miss 2398 + * as the reason they woke up so we add 2399 + * that here for that shortcoming. 2400 + */ 2401 + wow_status |= AH_WOW_BEACON_MISS; 2402 + atomic_dec(&sc->wow_got_bmiss_intr); 2403 + ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n"); 2404 + } 2405 + 2406 + atomic_dec(&sc->wow_sleep_proc_intr); 2407 + 2408 + if (wow_status) { 2409 + ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n", 2410 + ath9k_hw_wow_event_to_string(wow_status), wow_status); 2411 + } 2412 + 2413 + ath_restart_work(sc); 2414 + ath9k_start_btcoex(sc); 2415 + 2416 + ath9k_ps_restore(sc); 2417 + mutex_unlock(&sc->mutex); 2418 + 2419 + return 0; 2420 + } 2421 + 2422 + static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled) 2423 + { 2424 + struct ath_softc *sc = hw->priv; 2425 + 2426 + mutex_lock(&sc->mutex); 2427 + device_init_wakeup(sc->dev, 1); 2428 + device_set_wakeup_enable(sc->dev, enabled); 2429 + mutex_unlock(&sc->mutex); 2430 + } 2431 + 2432 + #endif 2433 + 2055 2434 struct ieee80211_ops ath9k_ops = { 2056 2435 .tx = ath9k_tx, 2057 2436 .start = ath9k_start, ··· 2436 2103 .get_stats = ath9k_get_stats, 2437 2104 .set_antenna = ath9k_set_antenna, 2438 2105 .get_antenna = ath9k_get_antenna, 2106 + 2107 + #ifdef CONFIG_PM_SLEEP 2108 + .suspend = ath9k_suspend, 2109 + .resume = ath9k_resume, 2110 + .set_wakeup = ath9k_set_wakeup, 2111 + #endif 2439 2112 2440 2113 #ifdef CONFIG_ATH9K_DEBUGFS 2441 2114 .get_et_sset_count = ath9k_get_et_sset_count,
+1 -1
drivers/net/wireless/ath/ath9k/mci.c
··· 202 202 case MCI_GPM_BT_CAL_REQ: 203 203 if (mci_hw->bt_state == MCI_BT_AWAKE) { 204 204 ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START); 205 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 205 + ath9k_queue_reset(sc, RESET_TYPE_MCI); 206 206 } 207 207 ath_dbg(common, MCI, "MCI State : %d\n", mci_hw->bt_state); 208 208 break;
+3
drivers/net/wireless/ath/ath9k/pci.c
··· 313 313 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 314 314 struct ath_softc *sc = hw->priv; 315 315 316 + if (sc->wow_enabled) 317 + return 0; 318 + 316 319 /* The device has to be moved to FULLSLEEP forcibly. 317 320 * Otherwise the chip never moved to full sleep, 318 321 * when no interface is up.
+1 -1
drivers/net/wireless/ath/ath9k/recv.c
··· 553 553 sc->ps_flags &= ~PS_BEACON_SYNC; 554 554 ath_dbg(common, PS, 555 555 "Reconfigure Beacon timers based on timestamp from the AP\n"); 556 - ath_set_beacon(sc); 556 + ath9k_set_beacon(sc); 557 557 } 558 558 559 559 if (ath_beacon_dtim_pending_cab(skb)) {
+144 -1
drivers/net/wireless/ath/ath9k/reg.h
··· 696 696 #define AR_WA_BIT7 (1 << 7) 697 697 #define AR_WA_BIT23 (1 << 23) 698 698 #define AR_WA_D3_L1_DISABLE (1 << 14) 699 + #define AR_WA_UNTIE_RESET_EN (1 << 15) /* Enable PCI Reset 700 + to POR (power-on-reset) */ 699 701 #define AR_WA_D3_TO_L1_DISABLE_REAL (1 << 16) 700 702 #define AR_WA_ASPM_TIMER_BASED_DISABLE (1 << 17) 701 - #define AR_WA_RESET_EN (1 << 18) /* Sw Control to enable PCI-Reset to POR (bit 15) */ 703 + #define AR_WA_RESET_EN (1 << 18) /* Enable PCI-Reset to 704 + POR (bit 15) */ 702 705 #define AR_WA_ANALOG_SHIFT (1 << 20) 703 706 #define AR_WA_POR_SHORT (1 << 21) /* PCI-E Phy reset control */ 704 707 #define AR_WA_BIT22 (1 << 22) ··· 1035 1032 #define AR_PCIE_PM_CTRL (AR_SREV_9340(ah) ? 0x4004 : 0x4014) 1036 1033 #define AR_PCIE_PM_CTRL_ENA 0x00080000 1037 1034 1035 + #define AR_PCIE_PHY_REG3 0x18c08 1036 + 1038 1037 #define AR_NUM_GPIO 14 1039 1038 #define AR928X_NUM_GPIO 10 1040 1039 #define AR9285_NUM_GPIO 12 ··· 1240 1235 #define AR_RTC_PLL_CLKSEL 0x00000300 1241 1236 #define AR_RTC_PLL_CLKSEL_S 8 1242 1237 #define AR_RTC_PLL_BYPASS 0x00010000 1238 + #define AR_RTC_PLL_NOPWD 0x00040000 1239 + #define AR_RTC_PLL_NOPWD_S 18 1243 1240 1244 1241 #define PLL3 0x16188 1245 1242 #define PLL3_DO_MEAS_MASK 0x40000000 ··· 1894 1887 #define AR_PCU_MISC_MODE2_HWWAR2 0x02000000 1895 1888 #define AR_PCU_MISC_MODE2_RESERVED2 0xFFFE0000 1896 1889 1890 + #define AR_PCU_MISC_MODE3 0x83d0 1891 + 1897 1892 #define AR_MAC_PCU_ASYNC_FIFO_REG3 0x8358 1898 1893 #define AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL 0x00000400 1899 1894 #define AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET 0x80000000 ··· 1918 1909 #define AR_RATE_DURATION_32 0x8780 1919 1910 #define AR_RATE_DURATION(_n) (AR_RATE_DURATION_0 + ((_n)<<2)) 1920 1911 1912 + /* WoW - Wake On Wireless */ 1913 + 1914 + #define AR_PMCTRL_AUX_PWR_DET 0x10000000 /* Puts Chip in L2 state */ 1915 + #define AR_PMCTRL_D3COLD_VAUX 0x00800000 1916 + #define AR_PMCTRL_HOST_PME_EN 0x00400000 /* Send OOB WAKE_L on WoW 1917 + event */ 1918 + #define AR_PMCTRL_WOW_PME_CLR 0x00200000 /* Clear WoW event */ 1919 + #define AR_PMCTRL_PWR_STATE_MASK 0x0f000000 /* Power State Mask */ 1920 + #define AR_PMCTRL_PWR_STATE_D1D3 0x0f000000 /* Activate D1 and D3 */ 1921 + #define AR_PMCTRL_PWR_STATE_D1D3_REAL 0x0f000000 /* Activate D1 and D3 */ 1922 + #define AR_PMCTRL_PWR_STATE_D0 0x08000000 /* Activate D0 */ 1923 + #define AR_PMCTRL_PWR_PM_CTRL_ENA 0x00008000 /* Enable power mgmt */ 1924 + 1925 + #define AR_WOW_BEACON_TIMO_MAX 0xffffffff 1926 + 1927 + /* 1928 + * MAC WoW Registers 1929 + */ 1930 + 1931 + #define AR_WOW_PATTERN 0x825C 1932 + #define AR_WOW_COUNT 0x8260 1933 + #define AR_WOW_BCN_EN 0x8270 1934 + #define AR_WOW_BCN_TIMO 0x8274 1935 + #define AR_WOW_KEEP_ALIVE_TIMO 0x8278 1936 + #define AR_WOW_KEEP_ALIVE 0x827c 1937 + #define AR_WOW_US_SCALAR 0x8284 1938 + #define AR_WOW_KEEP_ALIVE_DELAY 0x8288 1939 + #define AR_WOW_PATTERN_MATCH 0x828c 1940 + #define AR_WOW_PATTERN_OFF1 0x8290 /* pattern bytes 0 -> 3 */ 1941 + #define AR_WOW_PATTERN_OFF2 0x8294 /* pattern bytes 4 -> 7 */ 1942 + 1943 + /* for AR9285 or later version of chips */ 1944 + #define AR_WOW_EXACT 0x829c 1945 + #define AR_WOW_LENGTH1 0x8360 1946 + #define AR_WOW_LENGTH2 0X8364 1947 + /* register to enable match for less than 256 bytes packets */ 1948 + #define AR_WOW_PATTERN_MATCH_LT_256B 0x8368 1949 + 1950 + #define AR_SW_WOW_CONTROL 0x20018 1951 + #define AR_SW_WOW_ENABLE 0x1 1952 + #define AR_SWITCH_TO_REFCLK 0x2 1953 + #define AR_RESET_CONTROL 0x4 1954 + #define AR_RESET_VALUE_MASK 0x8 1955 + #define AR_HW_WOW_DISABLE 0x10 1956 + #define AR_CLR_MAC_INTERRUPT 0x20 1957 + #define AR_CLR_KA_INTERRUPT 0x40 1958 + 1959 + /* AR_WOW_PATTERN register values */ 1960 + #define AR_WOW_BACK_OFF_SHIFT(x) ((x & 0xf) << 28) /* in usecs */ 1961 + #define AR_WOW_MAC_INTR_EN 0x00040000 1962 + #define AR_WOW_MAGIC_EN 0x00010000 1963 + #define AR_WOW_PATTERN_EN(x) (x & 0xff) 1964 + #define AR_WOW_PAT_FOUND_SHIFT 8 1965 + #define AR_WOW_PATTERN_FOUND(x) (x & (0xff << AR_WOW_PAT_FOUND_SHIFT)) 1966 + #define AR_WOW_PATTERN_FOUND_MASK ((0xff) << AR_WOW_PAT_FOUND_SHIFT) 1967 + #define AR_WOW_MAGIC_PAT_FOUND 0x00020000 1968 + #define AR_WOW_MAC_INTR 0x00080000 1969 + #define AR_WOW_KEEP_ALIVE_FAIL 0x00100000 1970 + #define AR_WOW_BEACON_FAIL 0x00200000 1971 + 1972 + #define AR_WOW_STATUS(x) (x & (AR_WOW_PATTERN_FOUND_MASK | \ 1973 + AR_WOW_MAGIC_PAT_FOUND | \ 1974 + AR_WOW_KEEP_ALIVE_FAIL | \ 1975 + AR_WOW_BEACON_FAIL)) 1976 + #define AR_WOW_CLEAR_EVENTS(x) (x & ~(AR_WOW_PATTERN_EN(0xff) | \ 1977 + AR_WOW_MAGIC_EN | \ 1978 + AR_WOW_MAC_INTR_EN | \ 1979 + AR_WOW_BEACON_FAIL | \ 1980 + AR_WOW_KEEP_ALIVE_FAIL)) 1981 + 1982 + /* AR_WOW_COUNT register values */ 1983 + #define AR_WOW_AIFS_CNT(x) (x & 0xff) 1984 + #define AR_WOW_SLOT_CNT(x) ((x & 0xff) << 8) 1985 + #define AR_WOW_KEEP_ALIVE_CNT(x) ((x & 0xff) << 16) 1986 + 1987 + /* AR_WOW_BCN_EN register */ 1988 + #define AR_WOW_BEACON_FAIL_EN 0x00000001 1989 + 1990 + /* AR_WOW_BCN_TIMO rgister */ 1991 + #define AR_WOW_BEACON_TIMO 0x40000000 /* valid if BCN_EN is set */ 1992 + 1993 + /* AR_WOW_KEEP_ALIVE_TIMO register */ 1994 + #define AR_WOW_KEEP_ALIVE_TIMO_VALUE 1995 + #define AR_WOW_KEEP_ALIVE_NEVER 0xffffffff 1996 + 1997 + /* AR_WOW_KEEP_ALIVE register */ 1998 + #define AR_WOW_KEEP_ALIVE_AUTO_DIS 0x00000001 1999 + #define AR_WOW_KEEP_ALIVE_FAIL_DIS 0x00000002 2000 + 2001 + /* AR_WOW_KEEP_ALIVE_DELAY register */ 2002 + #define AR_WOW_KEEP_ALIVE_DELAY_VALUE 0x000003e8 /* 1 msec */ 2003 + 2004 + 2005 + /* 2006 + * keep it long for beacon workaround - ensure no false alarm 2007 + */ 2008 + #define AR_WOW_BMISSTHRESHOLD 0x20 2009 + 2010 + /* AR_WOW_PATTERN_MATCH register */ 2011 + #define AR_WOW_PAT_END_OF_PKT(x) (x & 0xf) 2012 + #define AR_WOW_PAT_OFF_MATCH(x) ((x & 0xf) << 8) 2013 + 2014 + /* 2015 + * default values for Wow Configuration for backoff, aifs, slot, keep-alive 2016 + * to be programmed into various registers. 2017 + */ 2018 + #define AR_WOW_PAT_BACKOFF 0x00000004 /* AR_WOW_PATTERN_REG */ 2019 + #define AR_WOW_CNT_AIFS_CNT 0x00000022 /* AR_WOW_COUNT_REG */ 2020 + #define AR_WOW_CNT_SLOT_CNT 0x00000009 /* AR_WOW_COUNT_REG */ 2021 + /* 2022 + * Keepalive count applicable for AR9280 2.0 and above. 2023 + */ 2024 + #define AR_WOW_CNT_KA_CNT 0x00000008 /* AR_WOW_COUNT register */ 2025 + 2026 + /* WoW - Transmit buffer for keep alive frames */ 2027 + #define AR_WOW_TRANSMIT_BUFFER 0xe000 /* E000 - EFFC */ 2028 + 2029 + #define AR_WOW_TXBUF(i) (AR_WOW_TRANSMIT_BUFFER + ((i) << 2)) 2030 + 2031 + #define AR_WOW_KA_DESC_WORD2 0xe000 2032 + 2033 + #define AR_WOW_KA_DATA_WORD0 0xe030 2034 + 2035 + /* WoW Transmit Buffer for patterns */ 2036 + #define AR_WOW_TB_PATTERN(i) (0xe100 + (i << 8)) 2037 + #define AR_WOW_TB_MASK(i) (0xec00 + (i << 5)) 2038 + 2039 + /* Currently Pattern 0-7 are supported - so bit 0-7 are set */ 2040 + #define AR_WOW_PATTERN_SUPPORTED 0xff 2041 + #define AR_WOW_LENGTH_MAX 0xff 2042 + #define AR_WOW_LEN1_SHIFT(_i) ((0x3 - ((_i) & 0x3)) << 0x3) 2043 + #define AR_WOW_LENGTH1_MASK(_i) (AR_WOW_LENGTH_MAX << AR_WOW_LEN1_SHIFT(_i)) 2044 + #define AR_WOW_LEN2_SHIFT(_i) ((0x7 - ((_i) & 0x7)) << 0x3) 2045 + #define AR_WOW_LENGTH2_MASK(_i) (AR_WOW_LENGTH_MAX << AR_WOW_LEN2_SHIFT(_i)) 1921 2046 1922 2047 #define AR9271_CORE_CLOCK 117 /* clock to 117Mhz */ 1923 2048 #define AR9271_TARGET_BAUD_RATE 19200 /* 115200 */
+532
drivers/net/wireless/ath/ath9k/wow.c
··· 1 + /* 2 + * Copyright (c) 2012 Qualcomm Atheros, Inc. 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #include <linux/export.h> 18 + #include "ath9k.h" 19 + #include "reg.h" 20 + #include "hw-ops.h" 21 + 22 + const char *ath9k_hw_wow_event_to_string(u32 wow_event) 23 + { 24 + if (wow_event & AH_WOW_MAGIC_PATTERN_EN) 25 + return "Magic pattern"; 26 + if (wow_event & AH_WOW_USER_PATTERN_EN) 27 + return "User pattern"; 28 + if (wow_event & AH_WOW_LINK_CHANGE) 29 + return "Link change"; 30 + if (wow_event & AH_WOW_BEACON_MISS) 31 + return "Beacon miss"; 32 + 33 + return "unknown reason"; 34 + } 35 + EXPORT_SYMBOL(ath9k_hw_wow_event_to_string); 36 + 37 + static void ath9k_hw_config_serdes_wow_sleep(struct ath_hw *ah) 38 + { 39 + int i; 40 + 41 + for (i = 0; i < ah->iniPcieSerdesWow.ia_rows; i++) 42 + REG_WRITE(ah, INI_RA(&ah->iniPcieSerdesWow, i, 0), 43 + INI_RA(&ah->iniPcieSerdesWow, i, 1)); 44 + 45 + usleep_range(1000, 1500); 46 + } 47 + 48 + static void ath9k_hw_set_powermode_wow_sleep(struct ath_hw *ah) 49 + { 50 + struct ath_common *common = ath9k_hw_common(ah); 51 + 52 + REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); 53 + 54 + /* set rx disable bit */ 55 + REG_WRITE(ah, AR_CR, AR_CR_RXD); 56 + 57 + if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0, AH_WAIT_TIMEOUT)) { 58 + ath_err(common, "Failed to stop Rx DMA in 10ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n", 59 + REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW)); 60 + return; 61 + } else { 62 + if (!AR_SREV_9300_20_OR_LATER(ah)) 63 + REG_WRITE(ah, AR_RXDP, 0x0); 64 + } 65 + 66 + /* AR9280 WoW has sleep issue, do not set it to sleep */ 67 + if (AR_SREV_9280_20(ah)) 68 + return; 69 + 70 + REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_ON_INT); 71 + } 72 + 73 + static void ath9k_wow_create_keep_alive_pattern(struct ath_hw *ah) 74 + { 75 + struct ath_common *common = ath9k_hw_common(ah); 76 + u8 sta_mac_addr[ETH_ALEN], ap_mac_addr[ETH_ALEN]; 77 + u32 ctl[13] = {0}; 78 + u32 data_word[KAL_NUM_DATA_WORDS]; 79 + u8 i; 80 + u32 wow_ka_data_word0; 81 + 82 + memcpy(sta_mac_addr, common->macaddr, ETH_ALEN); 83 + memcpy(ap_mac_addr, common->curbssid, ETH_ALEN); 84 + 85 + /* set the transmit buffer */ 86 + ctl[0] = (KAL_FRAME_LEN | (MAX_RATE_POWER << 16)); 87 + 88 + if (!(AR_SREV_9300_20_OR_LATER(ah))) 89 + ctl[0] += (KAL_ANTENNA_MODE << 25); 90 + 91 + ctl[1] = 0; 92 + ctl[3] = 0xb; /* OFDM_6M hardware value for this rate */ 93 + ctl[4] = 0; 94 + ctl[7] = (ah->txchainmask) << 2; 95 + 96 + if (AR_SREV_9300_20_OR_LATER(ah)) 97 + ctl[2] = 0xf << 16; /* tx_tries 0 */ 98 + else 99 + ctl[2] = 0x7 << 16; /* tx_tries 0 */ 100 + 101 + 102 + for (i = 0; i < KAL_NUM_DESC_WORDS; i++) 103 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]); 104 + 105 + /* for AR9300 family 13 descriptor words */ 106 + if (AR_SREV_9300_20_OR_LATER(ah)) 107 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]); 108 + 109 + data_word[0] = (KAL_FRAME_TYPE << 2) | (KAL_FRAME_SUB_TYPE << 4) | 110 + (KAL_TO_DS << 8) | (KAL_DURATION_ID << 16); 111 + data_word[1] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) | 112 + (ap_mac_addr[1] << 8) | (ap_mac_addr[0]); 113 + data_word[2] = (sta_mac_addr[1] << 24) | (sta_mac_addr[0] << 16) | 114 + (ap_mac_addr[5] << 8) | (ap_mac_addr[4]); 115 + data_word[3] = (sta_mac_addr[5] << 24) | (sta_mac_addr[4] << 16) | 116 + (sta_mac_addr[3] << 8) | (sta_mac_addr[2]); 117 + data_word[4] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) | 118 + (ap_mac_addr[1] << 8) | (ap_mac_addr[0]); 119 + data_word[5] = (ap_mac_addr[5] << 8) | (ap_mac_addr[4]); 120 + 121 + if (AR_SREV_9462_20_OR_LATER(ah)) { 122 + /* AR9462 2.0 has an extra descriptor word (time based 123 + * discard) compared to other chips */ 124 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0); 125 + wow_ka_data_word0 = AR_WOW_TXBUF(13); 126 + } else { 127 + wow_ka_data_word0 = AR_WOW_TXBUF(12); 128 + } 129 + 130 + for (i = 0; i < KAL_NUM_DATA_WORDS; i++) 131 + REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]); 132 + 133 + } 134 + 135 + void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern, 136 + u8 *user_mask, int pattern_count, 137 + int pattern_len) 138 + { 139 + int i; 140 + u32 pattern_val, mask_val; 141 + u32 set, clr; 142 + 143 + /* FIXME: should check count by querying the hardware capability */ 144 + if (pattern_count >= MAX_NUM_PATTERN) 145 + return; 146 + 147 + REG_SET_BIT(ah, AR_WOW_PATTERN, BIT(pattern_count)); 148 + 149 + /* set the registers for pattern */ 150 + for (i = 0; i < MAX_PATTERN_SIZE; i += 4) { 151 + memcpy(&pattern_val, user_pattern, 4); 152 + REG_WRITE(ah, (AR_WOW_TB_PATTERN(pattern_count) + i), 153 + pattern_val); 154 + user_pattern += 4; 155 + } 156 + 157 + /* set the registers for mask */ 158 + for (i = 0; i < MAX_PATTERN_MASK_SIZE; i += 4) { 159 + memcpy(&mask_val, user_mask, 4); 160 + REG_WRITE(ah, (AR_WOW_TB_MASK(pattern_count) + i), mask_val); 161 + user_mask += 4; 162 + } 163 + 164 + /* set the pattern length to be matched 165 + * 166 + * AR_WOW_LENGTH1_REG1 167 + * bit 31:24 pattern 0 length 168 + * bit 23:16 pattern 1 length 169 + * bit 15:8 pattern 2 length 170 + * bit 7:0 pattern 3 length 171 + * 172 + * AR_WOW_LENGTH1_REG2 173 + * bit 31:24 pattern 4 length 174 + * bit 23:16 pattern 5 length 175 + * bit 15:8 pattern 6 length 176 + * bit 7:0 pattern 7 length 177 + * 178 + * the below logic writes out the new 179 + * pattern length for the corresponding 180 + * pattern_count, while masking out the 181 + * other fields 182 + */ 183 + 184 + ah->wow_event_mask |= BIT(pattern_count + AR_WOW_PAT_FOUND_SHIFT); 185 + 186 + if (!AR_SREV_9285_12_OR_LATER(ah)) 187 + return; 188 + 189 + if (pattern_count < 4) { 190 + /* Pattern 0-3 uses AR_WOW_LENGTH1 register */ 191 + set = (pattern_len & AR_WOW_LENGTH_MAX) << 192 + AR_WOW_LEN1_SHIFT(pattern_count); 193 + clr = AR_WOW_LENGTH1_MASK(pattern_count); 194 + REG_RMW(ah, AR_WOW_LENGTH1, set, clr); 195 + } else { 196 + /* Pattern 4-7 uses AR_WOW_LENGTH2 register */ 197 + set = (pattern_len & AR_WOW_LENGTH_MAX) << 198 + AR_WOW_LEN2_SHIFT(pattern_count); 199 + clr = AR_WOW_LENGTH2_MASK(pattern_count); 200 + REG_RMW(ah, AR_WOW_LENGTH2, set, clr); 201 + } 202 + 203 + } 204 + EXPORT_SYMBOL(ath9k_hw_wow_apply_pattern); 205 + 206 + u32 ath9k_hw_wow_wakeup(struct ath_hw *ah) 207 + { 208 + u32 wow_status = 0; 209 + u32 val = 0, rval; 210 + /* 211 + * read the WoW status register to know 212 + * the wakeup reason 213 + */ 214 + rval = REG_READ(ah, AR_WOW_PATTERN); 215 + val = AR_WOW_STATUS(rval); 216 + 217 + /* 218 + * mask only the WoW events that we have enabled. Sometimes 219 + * we have spurious WoW events from the AR_WOW_PATTERN 220 + * register. This mask will clean it up. 221 + */ 222 + 223 + val &= ah->wow_event_mask; 224 + 225 + if (val) { 226 + 227 + if (val & AR_WOW_MAGIC_PAT_FOUND) 228 + wow_status |= AH_WOW_MAGIC_PATTERN_EN; 229 + 230 + if (AR_WOW_PATTERN_FOUND(val)) 231 + wow_status |= AH_WOW_USER_PATTERN_EN; 232 + 233 + if (val & AR_WOW_KEEP_ALIVE_FAIL) 234 + wow_status |= AH_WOW_LINK_CHANGE; 235 + 236 + if (val & AR_WOW_BEACON_FAIL) 237 + wow_status |= AH_WOW_BEACON_MISS; 238 + 239 + } 240 + 241 + /* 242 + * set and clear WOW_PME_CLEAR registers for the chip to 243 + * generate next wow signal. 244 + * disable D3 before accessing other registers ? 245 + */ 246 + 247 + /* do we need to check the bit value 0x01000000 (7-10) ?? */ 248 + REG_RMW(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR, 249 + AR_PMCTRL_PWR_STATE_D1D3); 250 + 251 + /* 252 + * clear all events 253 + */ 254 + REG_WRITE(ah, AR_WOW_PATTERN, 255 + AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN))); 256 + 257 + /* 258 + * tie reset register for AR9002 family of chipsets 259 + * NB: not tieing it back might have some repurcussions. 260 + */ 261 + 262 + if (!AR_SREV_9300_20_OR_LATER(ah)) { 263 + REG_SET_BIT(ah, AR_WA, AR_WA_UNTIE_RESET_EN | 264 + AR_WA_POR_SHORT | AR_WA_RESET_EN); 265 + } 266 + 267 + 268 + /* 269 + * restore the beacon threshold to init value 270 + */ 271 + REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); 272 + 273 + /* 274 + * Restore the way the PCI-E reset, Power-On-Reset, external 275 + * PCIE_POR_SHORT pins are tied to its original value. 276 + * Previously just before WoW sleep, we untie the PCI-E 277 + * reset to our Chip's Power On Reset so that any PCI-E 278 + * reset from the bus will not reset our chip 279 + */ 280 + 281 + if (AR_SREV_9280_20_OR_LATER(ah) && ah->is_pciexpress) 282 + ath9k_hw_configpcipowersave(ah, false); 283 + 284 + ah->wow_event_mask = 0; 285 + 286 + return wow_status; 287 + } 288 + EXPORT_SYMBOL(ath9k_hw_wow_wakeup); 289 + 290 + void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable) 291 + { 292 + u32 wow_event_mask; 293 + u32 set, clr; 294 + 295 + /* 296 + * wow_event_mask is a mask to the AR_WOW_PATTERN register to 297 + * indicate which WoW events we have enabled. The WoW events 298 + * are from the 'pattern_enable' in this function and 299 + * 'pattern_count' of ath9k_hw_wow_apply_pattern() 300 + */ 301 + 302 + wow_event_mask = ah->wow_event_mask; 303 + 304 + /* 305 + * Untie Power-on-Reset from the PCI-E-Reset. When we are in 306 + * WOW sleep, we do want the Reset from the PCI-E to disturb 307 + * our hw state 308 + */ 309 + 310 + if (ah->is_pciexpress) { 311 + 312 + /* 313 + * we need to untie the internal POR (power-on-reset) 314 + * to the external PCI-E reset. We also need to tie 315 + * the PCI-E Phy reset to the PCI-E reset. 316 + */ 317 + 318 + if (AR_SREV_9300_20_OR_LATER(ah)) { 319 + set = AR_WA_RESET_EN | AR_WA_POR_SHORT; 320 + clr = AR_WA_UNTIE_RESET_EN | AR_WA_D3_L1_DISABLE; 321 + REG_RMW(ah, AR_WA, set, clr); 322 + } else { 323 + if (AR_SREV_9285(ah) || AR_SREV_9287(ah)) 324 + set = AR9285_WA_DEFAULT; 325 + else 326 + set = AR9280_WA_DEFAULT; 327 + 328 + /* 329 + * In AR9280 and AR9285, bit 14 in WA register 330 + * (disable L1) should only be set when device 331 + * enters D3 state and be cleared when device 332 + * comes back to D0 333 + */ 334 + 335 + if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) 336 + set |= AR_WA_D3_L1_DISABLE; 337 + 338 + clr = AR_WA_UNTIE_RESET_EN; 339 + set |= AR_WA_RESET_EN | AR_WA_POR_SHORT; 340 + REG_RMW(ah, AR_WA, set, clr); 341 + 342 + /* 343 + * for WoW sleep, we reprogram the SerDes so that the 344 + * PLL and CLK REQ are both enabled. This uses more 345 + * power but otherwise WoW sleep is unstable and the 346 + * chip may disappear. 347 + */ 348 + 349 + if (AR_SREV_9285_12_OR_LATER(ah)) 350 + ath9k_hw_config_serdes_wow_sleep(ah); 351 + 352 + } 353 + } 354 + 355 + /* 356 + * set the power states appropriately and enable PME 357 + */ 358 + set = AR_PMCTRL_HOST_PME_EN | AR_PMCTRL_PWR_PM_CTRL_ENA | 359 + AR_PMCTRL_AUX_PWR_DET | AR_PMCTRL_WOW_PME_CLR; 360 + 361 + /* 362 + * set and clear WOW_PME_CLEAR registers for the chip 363 + * to generate next wow signal. 364 + */ 365 + REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set); 366 + clr = AR_PMCTRL_WOW_PME_CLR; 367 + REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr); 368 + 369 + /* 370 + * Setup for: 371 + * - beacon misses 372 + * - magic pattern 373 + * - keep alive timeout 374 + * - pattern matching 375 + */ 376 + 377 + /* 378 + * Program default values for pattern backoff, aifs/slot/KAL count, 379 + * beacon miss timeout, KAL timeout, etc. 380 + */ 381 + 382 + set = AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF); 383 + REG_SET_BIT(ah, AR_WOW_PATTERN, set); 384 + 385 + set = AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) | 386 + AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) | 387 + AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT); 388 + REG_SET_BIT(ah, AR_WOW_COUNT, set); 389 + 390 + if (pattern_enable & AH_WOW_BEACON_MISS) 391 + set = AR_WOW_BEACON_TIMO; 392 + /* We are not using beacon miss, program a large value */ 393 + else 394 + set = AR_WOW_BEACON_TIMO_MAX; 395 + 396 + REG_WRITE(ah, AR_WOW_BCN_TIMO, set); 397 + 398 + /* 399 + * Keep alive timo in ms except AR9280 400 + */ 401 + if (!pattern_enable || AR_SREV_9280(ah)) 402 + set = AR_WOW_KEEP_ALIVE_NEVER; 403 + else 404 + set = KAL_TIMEOUT * 32; 405 + 406 + REG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, set); 407 + 408 + /* 409 + * Keep alive delay in us. based on 'power on clock', 410 + * therefore in usec 411 + */ 412 + set = KAL_DELAY * 1000; 413 + REG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, set); 414 + 415 + /* 416 + * Create keep alive pattern to respond to beacons 417 + */ 418 + ath9k_wow_create_keep_alive_pattern(ah); 419 + 420 + /* 421 + * Configure MAC WoW Registers 422 + */ 423 + 424 + set = 0; 425 + /* Send keep alive timeouts anyway */ 426 + clr = AR_WOW_KEEP_ALIVE_AUTO_DIS; 427 + 428 + if (pattern_enable & AH_WOW_LINK_CHANGE) 429 + wow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL; 430 + else 431 + set = AR_WOW_KEEP_ALIVE_FAIL_DIS; 432 + 433 + /* 434 + * FIXME: For now disable keep alive frame 435 + * failure. This seems to sometimes trigger 436 + * unnecessary wake up with AR9485 chipsets. 437 + */ 438 + set = AR_WOW_KEEP_ALIVE_FAIL_DIS; 439 + 440 + REG_RMW(ah, AR_WOW_KEEP_ALIVE, set, clr); 441 + 442 + 443 + /* 444 + * we are relying on a bmiss failure. ensure we have 445 + * enough threshold to prevent false positives 446 + */ 447 + REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR, 448 + AR_WOW_BMISSTHRESHOLD); 449 + 450 + set = 0; 451 + clr = 0; 452 + 453 + if (pattern_enable & AH_WOW_BEACON_MISS) { 454 + set = AR_WOW_BEACON_FAIL_EN; 455 + wow_event_mask |= AR_WOW_BEACON_FAIL; 456 + } else { 457 + clr = AR_WOW_BEACON_FAIL_EN; 458 + } 459 + 460 + REG_RMW(ah, AR_WOW_BCN_EN, set, clr); 461 + 462 + set = 0; 463 + clr = 0; 464 + /* 465 + * Enable the magic packet registers 466 + */ 467 + if (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) { 468 + set = AR_WOW_MAGIC_EN; 469 + wow_event_mask |= AR_WOW_MAGIC_PAT_FOUND; 470 + } else { 471 + clr = AR_WOW_MAGIC_EN; 472 + } 473 + set |= AR_WOW_MAC_INTR_EN; 474 + REG_RMW(ah, AR_WOW_PATTERN, set, clr); 475 + 476 + /* 477 + * For AR9285 and later version of chipsets 478 + * enable WoW pattern match for packets less 479 + * than 256 bytes for all patterns 480 + */ 481 + if (AR_SREV_9285_12_OR_LATER(ah)) 482 + REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B, 483 + AR_WOW_PATTERN_SUPPORTED); 484 + 485 + /* 486 + * Set the power states appropriately and enable PME 487 + */ 488 + clr = 0; 489 + set = AR_PMCTRL_PWR_STATE_D1D3 | AR_PMCTRL_HOST_PME_EN | 490 + AR_PMCTRL_PWR_PM_CTRL_ENA; 491 + /* 492 + * This is needed for AR9300 chipsets to wake-up 493 + * the host. 494 + */ 495 + if (AR_SREV_9300_20_OR_LATER(ah)) 496 + clr = AR_PCIE_PM_CTRL_ENA; 497 + 498 + REG_RMW(ah, AR_PCIE_PM_CTRL, set, clr); 499 + 500 + if (AR_SREV_9462(ah)) { 501 + /* 502 + * this is needed to prevent the chip waking up 503 + * the host within 3-4 seconds with certain 504 + * platform/BIOS. The fix is to enable 505 + * D1 & D3 to match original definition and 506 + * also match the OTP value. Anyway this 507 + * is more related to SW WOW. 508 + */ 509 + clr = AR_PMCTRL_PWR_STATE_D1D3; 510 + REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr); 511 + 512 + set = AR_PMCTRL_PWR_STATE_D1D3_REAL; 513 + REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set); 514 + } 515 + 516 + 517 + 518 + REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM); 519 + 520 + if (AR_SREV_9300_20_OR_LATER(ah)) { 521 + /* to bring down WOW power low margin */ 522 + set = BIT(13); 523 + REG_SET_BIT(ah, AR_PCIE_PHY_REG3, set); 524 + /* HW WoW */ 525 + clr = BIT(5); 526 + REG_CLR_BIT(ah, AR_PCU_MISC_MODE3, clr); 527 + } 528 + 529 + ath9k_hw_set_powermode_wow_sleep(ah); 530 + ah->wow_event_mask = wow_event_mask; 531 + } 532 + EXPORT_SYMBOL(ath9k_hw_wow_enable);
+53 -49
drivers/net/wireless/ath/ath9k/xmit.c
··· 29 29 #define HT_LTF(_ns) (4 * (_ns)) 30 30 #define SYMBOL_TIME(_ns) ((_ns) << 2) /* ns * 4 us */ 31 31 #define SYMBOL_TIME_HALFGI(_ns) (((_ns) * 18 + 4) / 5) /* ns * 3.6 us */ 32 + #define TIME_SYMBOLS(t) ((t) >> 2) 33 + #define TIME_SYMBOLS_HALFGI(t) (((t) * 5 - 4) / 18) 32 34 #define NUM_SYMBOLS_PER_USEC(_usec) (_usec >> 2) 33 35 #define NUM_SYMBOLS_PER_USEC_HALFGI(_usec) (((_usec*5)-4)/18) 34 36 ··· 74 72 MCS_HT20_SGI, 75 73 MCS_HT40, 76 74 MCS_HT40_SGI, 77 - }; 78 - 79 - static int ath_max_4ms_framelen[4][32] = { 80 - [MCS_HT20] = { 81 - 3212, 6432, 9648, 12864, 19300, 25736, 28952, 32172, 82 - 6424, 12852, 19280, 25708, 38568, 51424, 57852, 64280, 83 - 9628, 19260, 28896, 38528, 57792, 65532, 65532, 65532, 84 - 12828, 25656, 38488, 51320, 65532, 65532, 65532, 65532, 85 - }, 86 - [MCS_HT20_SGI] = { 87 - 3572, 7144, 10720, 14296, 21444, 28596, 32172, 35744, 88 - 7140, 14284, 21428, 28568, 42856, 57144, 64288, 65532, 89 - 10700, 21408, 32112, 42816, 64228, 65532, 65532, 65532, 90 - 14256, 28516, 42780, 57040, 65532, 65532, 65532, 65532, 91 - }, 92 - [MCS_HT40] = { 93 - 6680, 13360, 20044, 26724, 40092, 53456, 60140, 65532, 94 - 13348, 26700, 40052, 53400, 65532, 65532, 65532, 65532, 95 - 20004, 40008, 60016, 65532, 65532, 65532, 65532, 65532, 96 - 26644, 53292, 65532, 65532, 65532, 65532, 65532, 65532, 97 - }, 98 - [MCS_HT40_SGI] = { 99 - 7420, 14844, 22272, 29696, 44544, 59396, 65532, 65532, 100 - 14832, 29668, 44504, 59340, 65532, 65532, 65532, 65532, 101 - 22232, 44464, 65532, 65532, 65532, 65532, 65532, 65532, 102 - 29616, 59232, 65532, 65532, 65532, 65532, 65532, 65532, 103 - } 104 75 }; 105 76 106 77 /*********************/ ··· 589 614 590 615 rcu_read_unlock(); 591 616 592 - if (needreset) { 593 - RESET_STAT_INC(sc, RESET_TYPE_TX_ERROR); 594 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work); 595 - } 617 + if (needreset) 618 + ath9k_queue_reset(sc, RESET_TYPE_TX_ERROR); 596 619 } 597 620 598 621 static bool ath_lookup_legacy(struct ath_buf *bf) ··· 623 650 struct ieee80211_tx_rate *rates; 624 651 u32 max_4ms_framelen, frmlen; 625 652 u16 aggr_limit, bt_aggr_limit, legacy = 0; 653 + int q = tid->ac->txq->mac80211_qnum; 626 654 int i; 627 655 628 656 skb = bf->bf_mpdu; ··· 632 658 633 659 /* 634 660 * Find the lowest frame length among the rate series that will have a 635 - * 4ms transmit duration. 636 - * TODO - TXOP limit needs to be considered. 661 + * 4ms (or TXOP limited) transmit duration. 637 662 */ 638 663 max_4ms_framelen = ATH_AMPDU_LIMIT_MAX; 639 664 ··· 655 682 if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI) 656 683 modeidx++; 657 684 658 - frmlen = ath_max_4ms_framelen[modeidx][rates[i].idx]; 685 + frmlen = sc->tx.max_aggr_framelen[q][modeidx][rates[i].idx]; 659 686 max_4ms_framelen = min(max_4ms_framelen, frmlen); 660 687 } 661 688 ··· 900 927 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); 901 928 902 929 return duration; 930 + } 931 + 932 + static int ath_max_framelen(int usec, int mcs, bool ht40, bool sgi) 933 + { 934 + int streams = HT_RC_2_STREAMS(mcs); 935 + int symbols, bits; 936 + int bytes = 0; 937 + 938 + symbols = sgi ? TIME_SYMBOLS_HALFGI(usec) : TIME_SYMBOLS(usec); 939 + bits = symbols * bits_per_symbol[mcs % 8][ht40] * streams; 940 + bits -= OFDM_PLCP_BITS; 941 + bytes = bits / 8; 942 + bytes -= L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); 943 + if (bytes > 65532) 944 + bytes = 65532; 945 + 946 + return bytes; 947 + } 948 + 949 + void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop) 950 + { 951 + u16 *cur_ht20, *cur_ht20_sgi, *cur_ht40, *cur_ht40_sgi; 952 + int mcs; 953 + 954 + /* 4ms is the default (and maximum) duration */ 955 + if (!txop || txop > 4096) 956 + txop = 4096; 957 + 958 + cur_ht20 = sc->tx.max_aggr_framelen[queue][MCS_HT20]; 959 + cur_ht20_sgi = sc->tx.max_aggr_framelen[queue][MCS_HT20_SGI]; 960 + cur_ht40 = sc->tx.max_aggr_framelen[queue][MCS_HT40]; 961 + cur_ht40_sgi = sc->tx.max_aggr_framelen[queue][MCS_HT40_SGI]; 962 + for (mcs = 0; mcs < 32; mcs++) { 963 + cur_ht20[mcs] = ath_max_framelen(txop, mcs, false, false); 964 + cur_ht20_sgi[mcs] = ath_max_framelen(txop, mcs, false, true); 965 + cur_ht40[mcs] = ath_max_framelen(txop, mcs, true, false); 966 + cur_ht40_sgi[mcs] = ath_max_framelen(txop, mcs, true, true); 967 + } 903 968 } 904 969 905 970 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, ··· 1414 1403 int error = 0; 1415 1404 struct ath9k_tx_queue_info qi; 1416 1405 1417 - if (qnum == sc->beacon.beaconq) { 1418 - /* 1419 - * XXX: for beacon queue, we just save the parameter. 1420 - * It will be picked up by ath_beaconq_config when 1421 - * it's necessary. 1422 - */ 1423 - sc->beacon.beacon_qi = *qinfo; 1424 - return 0; 1425 - } 1426 - 1427 1406 BUG_ON(sc->tx.txq[qnum].axq_qnum != qnum); 1428 1407 1429 1408 ath9k_hw_get_txq_props(ah, qnum, &qi); ··· 1587 1586 struct ath_atx_ac *ac, *ac_tmp, *last_ac; 1588 1587 struct ath_atx_tid *tid, *last_tid; 1589 1588 1590 - if (work_pending(&sc->hw_reset_work) || list_empty(&txq->axq_acq) || 1589 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) || 1590 + list_empty(&txq->axq_acq) || 1591 1591 txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) 1592 1592 return; 1593 1593 ··· 1990 1988 1991 1989 ath_txq_lock(sc, txq); 1992 1990 if (txq == sc->tx.txq_map[q] && 1993 - ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) { 1991 + ++txq->pending_frames > sc->tx.txq_max_pending[q] && 1992 + !txq->stopped) { 1994 1993 ieee80211_stop_queue(sc->hw, q); 1995 1994 txq->stopped = true; 1996 1995 } ··· 2050 2047 if (WARN_ON(--txq->pending_frames < 0)) 2051 2048 txq->pending_frames = 0; 2052 2049 2053 - if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) { 2050 + if (txq->stopped && 2051 + txq->pending_frames < sc->tx.txq_max_pending[q]) { 2054 2052 ieee80211_wake_queue(sc->hw, q); 2055 2053 txq->stopped = false; 2056 2054 } ··· 2195 2191 2196 2192 ath_txq_lock(sc, txq); 2197 2193 for (;;) { 2198 - if (work_pending(&sc->hw_reset_work)) 2194 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) 2199 2195 break; 2200 2196 2201 2197 if (list_empty(&txq->axq_q)) { ··· 2278 2274 int status; 2279 2275 2280 2276 for (;;) { 2281 - if (work_pending(&sc->hw_reset_work)) 2277 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) 2282 2278 break; 2283 2279 2284 2280 status = ath9k_hw_txprocdesc(ah, NULL, (void *)&ts);
-7
drivers/net/wireless/b43/b43.h
··· 870 870 * handler, only. This basically is just the IRQ mask register. */ 871 871 spinlock_t hardirq_lock; 872 872 873 - /* The number of queues that were registered with the mac80211 subsystem 874 - * initially. This is a backup copy of hw->queues in case hw->queues has 875 - * to be dynamically lowered at runtime (Firmware does not support QoS). 876 - * hw->queues has to be restored to the original value before unregistering 877 - * from the mac80211 subsystem. */ 878 - u16 mac80211_initially_registered_queues; 879 - 880 873 /* Set this if we call ieee80211_register_hw() and check if we call 881 874 * ieee80211_unregister_hw(). */ 882 875 bool hw_registred;
+10 -22
drivers/net/wireless/b43/main.c
··· 2359 2359 if (err) 2360 2360 goto err_load; 2361 2361 2362 + fw->opensource = (ctx->req_type == B43_FWTYPE_OPENSOURCE); 2363 + 2362 2364 return 0; 2363 2365 2364 2366 err_no_ucode: ··· 2436 2434 goto out; 2437 2435 2438 2436 start_ieee80211: 2437 + wl->hw->queues = B43_QOS_QUEUE_NUM; 2438 + if (!modparam_qos || dev->fw.opensource) 2439 + wl->hw->queues = 1; 2440 + 2439 2441 err = ieee80211_register_hw(wl->hw); 2440 2442 if (err) 2441 2443 goto err_one_core_detach; ··· 2543 2537 dev->fw.hdr_format = B43_FW_HDR_410; 2544 2538 else 2545 2539 dev->fw.hdr_format = B43_FW_HDR_351; 2546 - dev->fw.opensource = (fwdate == 0xFFFF); 2540 + WARN_ON(dev->fw.opensource != (fwdate == 0xFFFF)); 2547 2541 2548 - /* Default to use-all-queues. */ 2549 - dev->wl->hw->queues = dev->wl->mac80211_initially_registered_queues; 2550 - dev->qos_enabled = !!modparam_qos; 2542 + dev->qos_enabled = dev->wl->hw->queues > 1; 2551 2543 /* Default to firmware/hardware crypto acceleration. */ 2552 2544 dev->hwcrypto_enabled = true; 2553 2545 ··· 2563 2559 /* Disable hardware crypto and fall back to software crypto. */ 2564 2560 dev->hwcrypto_enabled = false; 2565 2561 } 2566 - if (!(fwcapa & B43_FWCAPA_QOS)) { 2567 - b43info(dev->wl, "QoS not supported by firmware\n"); 2568 - /* Disable QoS. Tweak hw->queues to 1. It will be restored before 2569 - * ieee80211_unregister to make sure the networking core can 2570 - * properly free possible resources. */ 2571 - dev->wl->hw->queues = 1; 2572 - dev->qos_enabled = false; 2573 - } 2562 + /* adding QoS support should use an offline discovery mechanism */ 2563 + WARN(fwcapa & B43_FWCAPA_QOS, "QoS in OpenFW not supported\n"); 2574 2564 } else { 2575 2565 b43info(dev->wl, "Loading firmware version %u.%u " 2576 2566 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", ··· 5296 5298 5297 5299 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 5298 5300 5299 - hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1; 5300 - wl->mac80211_initially_registered_queues = hw->queues; 5301 5301 wl->hw_registred = false; 5302 5302 hw->max_rates = 2; 5303 5303 SET_IEEE80211_DEV(hw, dev->dev); ··· 5370 5374 5371 5375 B43_WARN_ON(!wl); 5372 5376 if (wl->current_dev == wldev && wl->hw_registred) { 5373 - /* Restore the queues count before unregistering, because firmware detect 5374 - * might have modified it. Restoring is important, so the networking 5375 - * stack can properly free resources. */ 5376 - wl->hw->queues = wl->mac80211_initially_registered_queues; 5377 5377 b43_leds_stop(wldev); 5378 5378 ieee80211_unregister_hw(wl->hw); 5379 5379 } ··· 5444 5452 5445 5453 B43_WARN_ON(!wl); 5446 5454 if (wl->current_dev == wldev && wl->hw_registred) { 5447 - /* Restore the queues count before unregistering, because firmware detect 5448 - * might have modified it. Restoring is important, so the networking 5449 - * stack can properly free resources. */ 5450 - wl->hw->queues = wl->mac80211_initially_registered_queues; 5451 5455 b43_leds_stop(wldev); 5452 5456 ieee80211_unregister_hw(wl->hw); 5453 5457 }
+5 -4
drivers/net/wireless/b43/xmit.c
··· 663 663 u32 uninitialized_var(macstat); 664 664 u16 chanid; 665 665 u16 phytype; 666 - int padding; 666 + int padding, rate_idx; 667 667 668 668 memset(&status, 0, sizeof(status)); 669 669 ··· 766 766 } 767 767 768 768 if (phystat0 & B43_RX_PHYST0_OFDM) 769 - status.rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, 769 + rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, 770 770 phytype == B43_PHYTYPE_A); 771 771 else 772 - status.rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); 773 - if (unlikely(status.rate_idx == -1)) { 772 + rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); 773 + if (unlikely(rate_idx == -1)) { 774 774 /* PLCP seems to be corrupted. 775 775 * Drop the frame, if we are not interested in corrupted frames. */ 776 776 if (!(dev->wl->filter_flags & FIF_PLCPFAIL)) 777 777 goto drop; 778 778 } 779 + status.rate_idx = rate_idx; 779 780 status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); 780 781 781 782 /*
+3 -4
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
··· 691 691 } 692 692 693 693 static s32 694 - brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, 694 + brcmf_cfg80211_scan(struct wiphy *wiphy, 695 695 struct cfg80211_scan_request *request) 696 696 { 697 + struct net_device *ndev = request->wdev->netdev; 697 698 s32 err = 0; 698 699 699 700 WL_TRACE("Enter\n"); ··· 920 919 set_bit(WL_STATUS_CONNECTING, &cfg_priv->status); 921 920 922 921 if (params->bssid) 923 - WL_CONN("BSSID: %02X %02X %02X %02X %02X %02X\n", 924 - params->bssid[0], params->bssid[1], params->bssid[2], 925 - params->bssid[3], params->bssid[4], params->bssid[5]); 922 + WL_CONN("BSSID: %pM\n", params->bssid); 926 923 else 927 924 WL_CONN("No BSSID specified\n"); 928 925
+4 -7
drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
··· 663 663 /* patch the first MPDU */ 664 664 if (count == 1) { 665 665 u8 plcp0, plcp3, is40, sgi; 666 - struct ieee80211_sta *sta; 667 - 668 - sta = tx_info->control.sta; 669 666 670 667 if (rr) { 671 668 plcp0 = plcp[0]; ··· 1192 1195 bool rc; 1193 1196 1194 1197 rc = tx_info->flags & IEEE80211_TX_CTL_AMPDU ? true : false; 1195 - rc = rc && (tx_info->control.sta == NULL || ampdu_pars->sta == NULL || 1196 - tx_info->control.sta == ampdu_pars->sta); 1198 + rc = rc && (tx_info->rate_driver_data[0] == NULL || ampdu_pars->sta == NULL || 1199 + tx_info->rate_driver_data[0] == ampdu_pars->sta); 1197 1200 rc = rc && ((u8)(mpdu->priority) == ampdu_pars->tid); 1198 1201 return rc; 1199 1202 } ··· 1207 1210 struct ieee80211_tx_info *tx_info = (struct ieee80211_tx_info *)txi; 1208 1211 1209 1212 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && 1210 - (tx_info->control.sta == sta || sta == NULL)) 1211 - tx_info->control.sta = NULL; 1213 + (tx_info->rate_driver_data[0] == sta || sta == NULL)) 1214 + tx_info->rate_driver_data[0] = NULL; 1212 1215 } 1213 1216 1214 1217 /*
+2
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
··· 267 267 static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 268 268 { 269 269 struct brcms_info *wl = hw->priv; 270 + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 270 271 271 272 spin_lock_bh(&wl->lock); 272 273 if (!wl->pub->up) { ··· 276 275 goto done; 277 276 } 278 277 brcms_c_sendpkt_mac80211(wl->wlc, skb, hw); 278 + tx_info->rate_driver_data[0] = tx_info->control.sta; 279 279 done: 280 280 spin_unlock_bh(&wl->lock); 281 281 }
+1 -1
drivers/net/wireless/brcm80211/brcmsmac/main.c
··· 893 893 tx_info = IEEE80211_SKB_CB(p); 894 894 h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); 895 895 896 - if (tx_info->control.sta) 896 + if (tx_info->rate_driver_data[0]) 897 897 scb = &wlc->pri_scb; 898 898 899 899 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
+1 -1
drivers/net/wireless/iwlegacy/common.c
··· 5359 5359 if (changes & BSS_CHANGED_ASSOC) { 5360 5360 D_MAC80211("ASSOC %d\n", bss_conf->assoc); 5361 5361 if (bss_conf->assoc) { 5362 - il->timestamp = bss_conf->last_tsf; 5362 + il->timestamp = bss_conf->sync_tsf; 5363 5363 5364 5364 if (!il_is_rfkill(il)) 5365 5365 il->ops->post_associate(il);
+1
drivers/net/wireless/iwlwifi/dvm/commands.h
··· 1905 1905 #define IWLAGN_BT_PRIO_BOOST_MAX 0xFF 1906 1906 #define IWLAGN_BT_PRIO_BOOST_MIN 0x00 1907 1907 #define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0 1908 + #define IWLAGN_BT_PRIO_BOOST_DEFAULT32 0xF0F0F0F0 1908 1909 1909 1910 #define IWLAGN_BT_MAX_KILL_DEFAULT 5 1910 1911
+2
drivers/net/wireless/iwlwifi/dvm/lib.c
··· 265 265 bt_cmd_v2.tx_prio_boost = 0; 266 266 bt_cmd_v2.rx_prio_boost = 0; 267 267 } else { 268 + /* older version only has 8 bits */ 269 + WARN_ON(priv->cfg->bt_params->bt_prio_boost & ~0xFF); 268 270 bt_cmd_v1.prio_boost = 269 271 priv->cfg->bt_params->bt_prio_boost; 270 272 bt_cmd_v1.tx_prio_boost = 0;
-1
drivers/net/wireless/iwlwifi/dvm/main.c
··· 1232 1232 struct iwl_trans_config trans_cfg; 1233 1233 static const u8 no_reclaim_cmds[] = { 1234 1234 REPLY_RX_PHY_CMD, 1235 - REPLY_RX, 1236 1235 REPLY_RX_MPDU_CMD, 1237 1236 REPLY_COMPRESSED_BA, 1238 1237 STATISTICS_NOTIFICATION,
+11 -33
drivers/net/wireless/iwlwifi/dvm/rx.c
··· 88 88 IWL_CMD_ENTRY(REPLY_PHY_CALIBRATION_CMD), 89 89 IWL_CMD_ENTRY(REPLY_RX_PHY_CMD), 90 90 IWL_CMD_ENTRY(REPLY_RX_MPDU_CMD), 91 - IWL_CMD_ENTRY(REPLY_RX), 92 91 IWL_CMD_ENTRY(REPLY_COMPRESSED_BA), 93 92 IWL_CMD_ENTRY(CALIBRATION_CFG_CMD), 94 93 IWL_CMD_ENTRY(CALIBRATION_RES_NOTIFICATION), ··· 894 895 return max_rssi - agc - IWLAGN_RSSI_OFFSET; 895 896 } 896 897 897 - /* Called for REPLY_RX (legacy ABG frames), or 898 - * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ 898 + /* Called for REPLY_RX_MPDU_CMD */ 899 899 static int iwlagn_rx_reply_rx(struct iwl_priv *priv, 900 900 struct iwl_rx_cmd_buffer *rxb, 901 901 struct iwl_device_cmd *cmd) ··· 909 911 u32 ampdu_status; 910 912 u32 rate_n_flags; 911 913 912 - /** 913 - * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. 914 - * REPLY_RX: physical layer info is in this buffer 915 - * REPLY_RX_MPDU_CMD: physical layer info was sent in separate 916 - * command and cached in priv->last_phy_res 917 - * 918 - * Here we set up local variables depending on which command is 919 - * received. 920 - */ 921 - if (pkt->hdr.cmd == REPLY_RX) { 922 - phy_res = (struct iwl_rx_phy_res *)pkt->data; 923 - header = (struct ieee80211_hdr *)(pkt->data + sizeof(*phy_res) 924 - + phy_res->cfg_phy_cnt); 925 - 926 - len = le16_to_cpu(phy_res->byte_count); 927 - rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*phy_res) + 928 - phy_res->cfg_phy_cnt + len); 929 - ampdu_status = le32_to_cpu(rx_pkt_status); 930 - } else { 931 - if (!priv->last_phy_res_valid) { 932 - IWL_ERR(priv, "MPDU frame without cached PHY data\n"); 933 - return 0; 934 - } 935 - phy_res = &priv->last_phy_res; 936 - amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data; 937 - header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu)); 938 - len = le16_to_cpu(amsdu->byte_count); 939 - rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len); 940 - ampdu_status = iwlagn_translate_rx_status(priv, 941 - le32_to_cpu(rx_pkt_status)); 914 + if (!priv->last_phy_res_valid) { 915 + IWL_ERR(priv, "MPDU frame without cached PHY data\n"); 916 + return 0; 942 917 } 918 + phy_res = &priv->last_phy_res; 919 + amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data; 920 + header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu)); 921 + len = le16_to_cpu(amsdu->byte_count); 922 + rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len); 923 + ampdu_status = iwlagn_translate_rx_status(priv, 924 + le32_to_cpu(rx_pkt_status)); 943 925 944 926 if ((unlikely(phy_res->cfg_phy_cnt > 20))) { 945 927 IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d\n",
+1 -1
drivers/net/wireless/iwlwifi/dvm/rxon.c
··· 1447 1447 1448 1448 if (changes & BSS_CHANGED_ASSOC) { 1449 1449 if (bss_conf->assoc) { 1450 - priv->timestamp = bss_conf->last_tsf; 1450 + priv->timestamp = bss_conf->sync_tsf; 1451 1451 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; 1452 1452 } else { 1453 1453 /*
+1 -1
drivers/net/wireless/iwlwifi/iwl-config.h
··· 177 177 struct iwl_bt_params { 178 178 bool advanced_bt_coexist; 179 179 u8 bt_init_traffic_load; 180 - u8 bt_prio_boost; 180 + u32 bt_prio_boost; 181 181 u16 agg_time_limit; 182 182 bool bt_sco_disable; 183 183 bool bt_session_2;
+1
drivers/net/wireless/iwlwifi/iwl-trans.h
··· 458 458 /* The following fields are internal only */ 459 459 struct kmem_cache *dev_cmd_pool; 460 460 size_t dev_cmd_headroom; 461 + char dev_cmd_pool_name[50]; 461 462 462 463 /* pointer to trans specific struct */ 463 464 /*Ensure that this pointer will always be aligned to sizeof pointer */
+1 -1
drivers/net/wireless/iwlwifi/pcie/2000.c
··· 112 112 .advanced_bt_coexist = true, 113 113 .agg_time_limit = BT_AGG_THRESHOLD_DEF, 114 114 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE, 115 - .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT, 115 + .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT32, 116 116 .bt_sco_disable = true, 117 117 .bt_session_2 = true, 118 118 };
+3 -4
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 2080 2080 { 2081 2081 struct iwl_trans_pcie *trans_pcie; 2082 2082 struct iwl_trans *trans; 2083 - char cmd_pool_name[100]; 2084 2083 u16 pci_cmd; 2085 2084 int err; 2086 2085 ··· 2177 2178 init_waitqueue_head(&trans->wait_command_queue); 2178 2179 spin_lock_init(&trans->reg_lock); 2179 2180 2180 - snprintf(cmd_pool_name, sizeof(cmd_pool_name), "iwl_cmd_pool:%s", 2181 - dev_name(trans->dev)); 2181 + snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name), 2182 + "iwl_cmd_pool:%s", dev_name(trans->dev)); 2182 2183 2183 2184 trans->dev_cmd_headroom = 0; 2184 2185 trans->dev_cmd_pool = 2185 - kmem_cache_create(cmd_pool_name, 2186 + kmem_cache_create(trans->dev_cmd_pool_name, 2186 2187 sizeof(struct iwl_device_cmd) 2187 2188 + trans->dev_cmd_headroom, 2188 2189 sizeof(void *),
+4 -3
drivers/net/wireless/libertas/cfg.c
··· 805 805 } 806 806 807 807 static int lbs_cfg_scan(struct wiphy *wiphy, 808 - struct net_device *dev, 809 808 struct cfg80211_scan_request *request) 810 809 { 811 810 struct lbs_private *priv = wiphy_priv(wiphy); ··· 2180 2181 struct regulatory_request *request) 2181 2182 { 2182 2183 struct lbs_private *priv = wiphy_priv(wiphy); 2183 - int ret; 2184 + int ret = 0; 2184 2185 2185 2186 lbs_deb_enter_args(LBS_DEB_CFG80211, "cfg80211 regulatory domain " 2186 2187 "callback for domain %c%c\n", request->alpha2[0], 2187 2188 request->alpha2[1]); 2188 2189 2189 - ret = lbs_set_11d_domain_info(priv, request, wiphy->bands); 2190 + memcpy(priv->country_code, request->alpha2, sizeof(request->alpha2)); 2191 + if (lbs_iface_active(priv)) 2192 + ret = lbs_set_11d_domain_info(priv); 2190 2193 2191 2194 lbs_deb_leave(LBS_DEB_CFG80211); 2192 2195 return ret;
+13 -12
drivers/net/wireless/libertas/cmd.c
··· 733 733 * to the firmware 734 734 * 735 735 * @priv: pointer to &struct lbs_private 736 - * @request: cfg80211 regulatory request structure 737 - * @bands: the device's supported bands and channels 738 736 * 739 737 * returns: 0 on success, error code on failure 740 738 */ 741 - int lbs_set_11d_domain_info(struct lbs_private *priv, 742 - struct regulatory_request *request, 743 - struct ieee80211_supported_band **bands) 739 + int lbs_set_11d_domain_info(struct lbs_private *priv) 744 740 { 741 + struct wiphy *wiphy = priv->wdev->wiphy; 742 + struct ieee80211_supported_band **bands = wiphy->bands; 745 743 struct cmd_ds_802_11d_domain_info cmd; 746 744 struct mrvl_ie_domain_param_set *domain = &cmd.domain; 747 745 struct ieee80211_country_ie_triplet *t; ··· 750 752 u8 first_channel = 0, next_chan = 0, max_pwr = 0; 751 753 u8 i, flag = 0; 752 754 size_t triplet_size; 753 - int ret; 755 + int ret = 0; 754 756 755 757 lbs_deb_enter(LBS_DEB_11D); 758 + if (!priv->country_code[0]) 759 + goto out; 756 760 757 761 memset(&cmd, 0, sizeof(cmd)); 758 762 cmd.action = cpu_to_le16(CMD_ACT_SET); 759 763 760 764 lbs_deb_11d("Setting country code '%c%c'\n", 761 - request->alpha2[0], request->alpha2[1]); 765 + priv->country_code[0], priv->country_code[1]); 762 766 763 767 domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN); 764 768 765 769 /* Set country code */ 766 - domain->country_code[0] = request->alpha2[0]; 767 - domain->country_code[1] = request->alpha2[1]; 770 + domain->country_code[0] = priv->country_code[0]; 771 + domain->country_code[1] = priv->country_code[1]; 768 772 domain->country_code[2] = ' '; 769 773 770 774 /* Now set up the channel triplets; firmware is somewhat picky here ··· 848 848 849 849 ret = lbs_cmd_with_response(priv, CMD_802_11D_DOMAIN_INFO, &cmd); 850 850 851 + out: 851 852 lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret); 852 853 return ret; 853 854 } ··· 1020 1019 if (ret) { 1021 1020 netdev_info(priv->dev, "DNLD_CMD: hw_host_to_card failed: %d\n", 1022 1021 ret); 1023 - /* Let the timer kick in and retry, and potentially reset 1024 - the whole thing if the condition persists */ 1025 - timeo = HZ/4; 1022 + /* Reset dnld state machine, report failure */ 1023 + priv->dnld_sent = DNLD_RES_RECEIVED; 1024 + lbs_complete_command(priv, cmdnode, ret); 1026 1025 } 1027 1026 1028 1027 if (command == CMD_802_11_DEEP_SLEEP) {
+1 -3
drivers/net/wireless/libertas/cmd.h
··· 128 128 129 129 int lbs_get_rssi(struct lbs_private *priv, s8 *snr, s8 *nf); 130 130 131 - int lbs_set_11d_domain_info(struct lbs_private *priv, 132 - struct regulatory_request *request, 133 - struct ieee80211_supported_band **bands); 131 + int lbs_set_11d_domain_info(struct lbs_private *priv); 134 132 135 133 int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value); 136 134
+1
drivers/net/wireless/libertas/dev.h
··· 49 49 bool wiphy_registered; 50 50 struct cfg80211_scan_request *scan_req; 51 51 u8 assoc_bss[ETH_ALEN]; 52 + u8 country_code[IEEE80211_COUNTRY_STRING_LEN]; 52 53 u8 disassoc_reason; 53 54 54 55 /* Mesh */
-2
drivers/net/wireless/libertas/firmware.c
··· 4 4 5 5 #include <linux/sched.h> 6 6 #include <linux/firmware.h> 7 - #include <linux/firmware.h> 8 7 #include <linux/module.h> 9 - #include <linux/sched.h> 10 8 11 9 #include "dev.h" 12 10 #include "decl.h"
-1
drivers/net/wireless/libertas/if_usb.c
··· 309 309 cardp->surprise_removed = 1; 310 310 311 311 if (priv) { 312 - priv->surpriseremoved = 1; 313 312 lbs_stop_card(priv); 314 313 lbs_remove_card(priv); 315 314 }
+6
drivers/net/wireless/libertas/main.c
··· 152 152 goto err; 153 153 } 154 154 155 + ret = lbs_set_11d_domain_info(priv); 156 + if (ret) { 157 + lbs_deb_net("set 11d domain info failed\n"); 158 + goto err; 159 + } 160 + 155 161 lbs_update_channel(priv); 156 162 157 163 priv->iface_running = true;
-5
drivers/net/wireless/mac80211_hwsim.c
··· 1540 1540 /* now send back TX status */ 1541 1541 txi = IEEE80211_SKB_CB(skb); 1542 1542 1543 - if (txi->control.vif) 1544 - hwsim_check_magic(txi->control.vif); 1545 - if (txi->control.sta) 1546 - hwsim_check_sta_magic(txi->control.sta); 1547 - 1548 1543 ieee80211_tx_info_clear_status(txi); 1549 1544 1550 1545 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
+152 -135
drivers/net/wireless/mwifiex/cfg80211.c
··· 48 48 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE 49 49 */ 50 50 static u8 51 - mwifiex_cfg80211_channel_type_to_sec_chan_offset(enum nl80211_channel_type 52 - channel_type) 51 + mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type) 53 52 { 54 - switch (channel_type) { 53 + switch (chan_type) { 55 54 case NL80211_CHAN_NO_HT: 56 55 case NL80211_CHAN_HT20: 57 56 return IEEE80211_HT_PARAM_CHA_SEC_NONE; ··· 338 339 } 339 340 340 341 /* 341 - * This function sets the RF channel. 342 - * 343 - * This function creates multiple IOCTL requests, populates them accordingly 344 - * and issues them to set the band/channel and frequency. 345 - */ 346 - static int 347 - mwifiex_set_rf_channel(struct mwifiex_private *priv, 348 - struct ieee80211_channel *chan, 349 - enum nl80211_channel_type channel_type) 350 - { 351 - struct mwifiex_chan_freq_power cfp; 352 - u32 config_bands = 0; 353 - struct wiphy *wiphy = priv->wdev->wiphy; 354 - struct mwifiex_adapter *adapter = priv->adapter; 355 - 356 - if (chan) { 357 - /* Set appropriate bands */ 358 - if (chan->band == IEEE80211_BAND_2GHZ) { 359 - if (channel_type == NL80211_CHAN_NO_HT) 360 - if (priv->adapter->config_bands == BAND_B || 361 - priv->adapter->config_bands == BAND_G) 362 - config_bands = 363 - priv->adapter->config_bands; 364 - else 365 - config_bands = BAND_B | BAND_G; 366 - else 367 - config_bands = BAND_B | BAND_G | BAND_GN; 368 - } else { 369 - if (channel_type == NL80211_CHAN_NO_HT) 370 - config_bands = BAND_A; 371 - else 372 - config_bands = BAND_AN | BAND_A; 373 - } 374 - 375 - if (!((config_bands | adapter->fw_bands) & 376 - ~adapter->fw_bands)) { 377 - adapter->config_bands = config_bands; 378 - if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { 379 - adapter->adhoc_start_band = config_bands; 380 - if ((config_bands & BAND_GN) || 381 - (config_bands & BAND_AN)) 382 - adapter->adhoc_11n_enabled = true; 383 - else 384 - adapter->adhoc_11n_enabled = false; 385 - } 386 - } 387 - adapter->sec_chan_offset = 388 - mwifiex_cfg80211_channel_type_to_sec_chan_offset 389 - (channel_type); 390 - adapter->channel_type = channel_type; 391 - 392 - mwifiex_send_domain_info_cmd_fw(wiphy); 393 - } 394 - 395 - wiphy_dbg(wiphy, "info: setting band %d, chan offset %d, mode %d\n", 396 - config_bands, adapter->sec_chan_offset, priv->bss_mode); 397 - if (!chan) 398 - return 0; 399 - 400 - memset(&cfp, 0, sizeof(cfp)); 401 - cfp.freq = chan->center_freq; 402 - cfp.channel = ieee80211_frequency_to_channel(chan->center_freq); 403 - 404 - if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) { 405 - if (mwifiex_bss_set_channel(priv, &cfp)) 406 - return -EFAULT; 407 - return mwifiex_drv_change_adhoc_chan(priv, cfp.channel); 408 - } 409 - 410 - return 0; 411 - } 412 - 413 - /* 414 342 * This function sets the fragmentation threshold. 415 343 * 416 344 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE ··· 552 626 mwifiex_dump_station_info(struct mwifiex_private *priv, 553 627 struct station_info *sinfo) 554 628 { 555 - struct mwifiex_rate_cfg rate; 629 + u32 rate; 556 630 557 631 sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES | 558 632 STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS | ··· 578 652 579 653 /* 580 654 * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid 581 - * MCS index values for us are 0 to 7. 655 + * MCS index values for us are 0 to 15. 582 656 */ 583 - if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 8)) { 657 + if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) { 584 658 sinfo->txrate.mcs = priv->tx_rate; 585 659 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; 586 660 /* 40MHz rate */ ··· 598 672 sinfo->tx_packets = priv->stats.tx_packets; 599 673 sinfo->signal = priv->bcn_rssi_avg; 600 674 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ 601 - sinfo->txrate.legacy = rate.rate * 5; 675 + sinfo->txrate.legacy = rate * 5; 602 676 603 677 if (priv->bss_mode == NL80211_IFTYPE_STATION) { 604 678 sinfo->filled |= STATION_INFO_BSS_PARAM; ··· 753 827 /* 754 828 * CFG802.11 operation handler for setting bit rates. 755 829 * 756 - * Function selects legacy bang B/G/BG from corresponding bitrates selection. 757 - * Currently only 2.4GHz band is supported. 830 + * Function configures data rates to firmware using bitrate mask 831 + * provided by cfg80211. 758 832 */ 759 833 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy *wiphy, 760 834 struct net_device *dev, ··· 762 836 const struct cfg80211_bitrate_mask *mask) 763 837 { 764 838 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 765 - int index = 0, mode = 0, i; 766 - struct mwifiex_adapter *adapter = priv->adapter; 839 + u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; 840 + enum ieee80211_band band; 767 841 768 - /* Currently only 2.4GHz is supported */ 769 - for (i = 0; i < mwifiex_band_2ghz.n_bitrates; i++) { 770 - /* 771 - * Rates below 6 Mbps in the table are CCK rates; 802.11b 772 - * and from 6 they are OFDM; 802.11G 773 - */ 774 - if (mwifiex_rates[i].bitrate == 60) { 775 - index = 1 << i; 776 - break; 777 - } 842 + if (!priv->media_connected) { 843 + dev_err(priv->adapter->dev, 844 + "Can not set Tx data rate in disconnected state\n"); 845 + return -EINVAL; 778 846 } 779 847 780 - if (mask->control[IEEE80211_BAND_2GHZ].legacy < index) { 781 - mode = BAND_B; 782 - } else { 783 - mode = BAND_G; 784 - if (mask->control[IEEE80211_BAND_2GHZ].legacy % index) 785 - mode |= BAND_B; 786 - } 848 + band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); 787 849 788 - if (!((mode | adapter->fw_bands) & ~adapter->fw_bands)) { 789 - adapter->config_bands = mode; 790 - if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { 791 - adapter->adhoc_start_band = mode; 792 - adapter->adhoc_11n_enabled = false; 793 - } 794 - } 795 - adapter->sec_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; 796 - adapter->channel_type = NL80211_CHAN_NO_HT; 850 + memset(bitmap_rates, 0, sizeof(bitmap_rates)); 797 851 798 - wiphy_debug(wiphy, "info: device configured in 802.11%s%s mode\n", 799 - (mode & BAND_B) ? "b" : "", (mode & BAND_G) ? "g" : ""); 852 + /* Fill HR/DSSS rates. */ 853 + if (band == IEEE80211_BAND_2GHZ) 854 + bitmap_rates[0] = mask->control[band].legacy & 0x000f; 800 855 801 - return 0; 856 + /* Fill OFDM rates */ 857 + if (band == IEEE80211_BAND_2GHZ) 858 + bitmap_rates[1] = (mask->control[band].legacy & 0x0ff0) >> 4; 859 + else 860 + bitmap_rates[1] = mask->control[band].legacy; 861 + 862 + /* Fill MCS rates */ 863 + bitmap_rates[2] = mask->control[band].mcs[0]; 864 + if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) 865 + bitmap_rates[2] |= mask->control[band].mcs[1] << 8; 866 + 867 + return mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG, 868 + HostCmd_ACT_GEN_SET, 0, bitmap_rates); 802 869 } 803 870 804 871 /* ··· 926 1007 { 927 1008 struct mwifiex_uap_bss_param *bss_cfg; 928 1009 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 1010 + u8 config_bands = 0; 929 1011 930 1012 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) 931 1013 return -1; ··· 967 1047 (u8)ieee80211_frequency_to_channel(params->channel->center_freq); 968 1048 bss_cfg->band_cfg = BAND_CONFIG_MANUAL; 969 1049 970 - if (mwifiex_set_rf_channel(priv, params->channel, 971 - params->channel_type)) { 972 - kfree(bss_cfg); 973 - wiphy_err(wiphy, "Failed to set band config information!\n"); 974 - return -1; 1050 + /* Set appropriate bands */ 1051 + if (params->channel->band == IEEE80211_BAND_2GHZ) { 1052 + if (params->channel_type == NL80211_CHAN_NO_HT) 1053 + config_bands = BAND_B | BAND_G; 1054 + else 1055 + config_bands = BAND_B | BAND_G | BAND_GN; 1056 + } else { 1057 + if (params->channel_type == NL80211_CHAN_NO_HT) 1058 + config_bands = BAND_A; 1059 + else 1060 + config_bands = BAND_AN | BAND_A; 975 1061 } 1062 + 1063 + if (!((config_bands | priv->adapter->fw_bands) & 1064 + ~priv->adapter->fw_bands)) 1065 + priv->adapter->config_bands = config_bands; 1066 + 1067 + mwifiex_send_domain_info_cmd_fw(wiphy); 976 1068 977 1069 if (mwifiex_set_secure_params(priv, bss_cfg, params)) { 978 1070 kfree(bss_cfg); ··· 1119 1187 struct cfg80211_ssid req_ssid; 1120 1188 int ret, auth_type = 0; 1121 1189 struct cfg80211_bss *bss = NULL; 1122 - u8 is_scanning_required = 0; 1190 + u8 is_scanning_required = 0, config_bands = 0; 1123 1191 1124 1192 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid)); 1125 1193 ··· 1138 1206 /* disconnect before try to associate */ 1139 1207 mwifiex_deauthenticate(priv, NULL); 1140 1208 1141 - if (channel) 1142 - ret = mwifiex_set_rf_channel(priv, channel, 1143 - priv->adapter->channel_type); 1209 + if (channel) { 1210 + if (mode == NL80211_IFTYPE_STATION) { 1211 + if (channel->band == IEEE80211_BAND_2GHZ) 1212 + config_bands = BAND_B | BAND_G | BAND_GN; 1213 + else 1214 + config_bands = BAND_A | BAND_AN; 1215 + 1216 + if (!((config_bands | priv->adapter->fw_bands) & 1217 + ~priv->adapter->fw_bands)) 1218 + priv->adapter->config_bands = config_bands; 1219 + } 1220 + mwifiex_send_domain_info_cmd_fw(priv->wdev->wiphy); 1221 + } 1144 1222 1145 1223 /* As this is new association, clear locally stored 1146 1224 * keys and security related flags */ ··· 1315 1373 } 1316 1374 1317 1375 /* 1376 + * This function sets following parameters for ibss network. 1377 + * - channel 1378 + * - start band 1379 + * - 11n flag 1380 + * - secondary channel offset 1381 + */ 1382 + static int mwifiex_set_ibss_params(struct mwifiex_private *priv, 1383 + struct cfg80211_ibss_params *params) 1384 + { 1385 + struct wiphy *wiphy = priv->wdev->wiphy; 1386 + struct mwifiex_adapter *adapter = priv->adapter; 1387 + int index = 0, i; 1388 + u8 config_bands = 0; 1389 + 1390 + if (params->channel->band == IEEE80211_BAND_2GHZ) { 1391 + if (!params->basic_rates) { 1392 + config_bands = BAND_B | BAND_G; 1393 + } else { 1394 + for (i = 0; i < mwifiex_band_2ghz.n_bitrates; i++) { 1395 + /* 1396 + * Rates below 6 Mbps in the table are CCK 1397 + * rates; 802.11b and from 6 they are OFDM; 1398 + * 802.11G 1399 + */ 1400 + if (mwifiex_rates[i].bitrate == 60) { 1401 + index = 1 << i; 1402 + break; 1403 + } 1404 + } 1405 + 1406 + if (params->basic_rates < index) { 1407 + config_bands = BAND_B; 1408 + } else { 1409 + config_bands = BAND_G; 1410 + if (params->basic_rates % index) 1411 + config_bands |= BAND_B; 1412 + } 1413 + } 1414 + 1415 + if (params->channel_type != NL80211_CHAN_NO_HT) 1416 + config_bands |= BAND_GN; 1417 + } else { 1418 + if (params->channel_type == NL80211_CHAN_NO_HT) 1419 + config_bands = BAND_A; 1420 + else 1421 + config_bands = BAND_AN | BAND_A; 1422 + } 1423 + 1424 + if (!((config_bands | adapter->fw_bands) & ~adapter->fw_bands)) { 1425 + adapter->config_bands = config_bands; 1426 + adapter->adhoc_start_band = config_bands; 1427 + 1428 + if ((config_bands & BAND_GN) || (config_bands & BAND_AN)) 1429 + adapter->adhoc_11n_enabled = true; 1430 + else 1431 + adapter->adhoc_11n_enabled = false; 1432 + } 1433 + 1434 + adapter->sec_chan_offset = 1435 + mwifiex_chan_type_to_sec_chan_offset(params->channel_type); 1436 + priv->adhoc_channel = 1437 + ieee80211_frequency_to_channel(params->channel->center_freq); 1438 + 1439 + wiphy_dbg(wiphy, "info: set ibss band %d, chan %d, chan offset %d\n", 1440 + config_bands, priv->adhoc_channel, adapter->sec_chan_offset); 1441 + 1442 + return 0; 1443 + } 1444 + 1445 + /* 1318 1446 * CFG802.11 operation handler to join an IBSS. 1319 1447 * 1320 1448 * This function does not work in any mode other than Ad-Hoc, or if ··· 1405 1393 1406 1394 wiphy_dbg(wiphy, "info: trying to join to %s and bssid %pM\n", 1407 1395 (char *) params->ssid, params->bssid); 1396 + 1397 + mwifiex_set_ibss_params(priv, params); 1408 1398 1409 1399 ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid, 1410 1400 params->bssid, priv->bss_mode, ··· 1454 1440 * it also informs the results. 1455 1441 */ 1456 1442 static int 1457 - mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, 1443 + mwifiex_cfg80211_scan(struct wiphy *wiphy, 1458 1444 struct cfg80211_scan_request *request) 1459 1445 { 1446 + struct net_device *dev = request->wdev->netdev; 1460 1447 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 1461 1448 int i; 1462 1449 struct ieee80211_channel *chan; ··· 1591 1576 /* 1592 1577 * create a new virtual interface with the given name 1593 1578 */ 1594 - struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, 1595 - char *name, 1596 - enum nl80211_iftype type, 1597 - u32 *flags, 1598 - struct vif_params *params) 1579 + struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy, 1580 + char *name, 1581 + enum nl80211_iftype type, 1582 + u32 *flags, 1583 + struct vif_params *params) 1599 1584 { 1600 1585 struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); 1601 1586 struct mwifiex_private *priv; ··· 1716 1701 #ifdef CONFIG_DEBUG_FS 1717 1702 mwifiex_dev_debugfs_init(priv); 1718 1703 #endif 1719 - return dev; 1704 + return wdev; 1720 1705 } 1721 1706 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); 1722 1707 1723 1708 /* 1724 1709 * del_virtual_intf: remove the virtual interface determined by dev 1725 1710 */ 1726 - int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev) 1711 + int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) 1727 1712 { 1728 - struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 1713 + struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); 1729 1714 1730 1715 #ifdef CONFIG_DEBUG_FS 1731 1716 mwifiex_dev_debugfs_remove(priv); ··· 1737 1722 if (netif_carrier_ok(priv->netdev)) 1738 1723 netif_carrier_off(priv->netdev); 1739 1724 1740 - if (dev->reg_state == NETREG_REGISTERED) 1741 - unregister_netdevice(dev); 1725 + if (wdev->netdev->reg_state == NETREG_REGISTERED) 1726 + unregister_netdevice(wdev->netdev); 1742 1727 1743 - if (dev->reg_state == NETREG_UNREGISTERED) 1744 - free_netdev(dev); 1728 + if (wdev->netdev->reg_state == NETREG_UNREGISTERED) 1729 + free_netdev(wdev->netdev); 1745 1730 1746 1731 /* Clear the priv in adapter */ 1747 1732 priv->netdev = NULL; ··· 1832 1817 1833 1818 wiphy->available_antennas_tx = BIT(adapter->number_of_antenna) - 1; 1834 1819 wiphy->available_antennas_rx = BIT(adapter->number_of_antenna) - 1; 1820 + 1821 + wiphy->features = NL80211_FEATURE_HT_IBSS; 1835 1822 1836 1823 /* Reserve space for mwifiex specific private data for BSS */ 1837 1824 wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv);
-31
drivers/net/wireless/mwifiex/cfp.c
··· 167 167 } 168 168 169 169 /* 170 - * This function maps a data rate value into corresponding index in supported 171 - * rates table. 172 - */ 173 - u8 mwifiex_data_rate_to_index(u32 rate) 174 - { 175 - u16 *ptr; 176 - 177 - if (rate) { 178 - ptr = memchr(mwifiex_data_rates, rate, 179 - sizeof(mwifiex_data_rates)); 180 - if (ptr) 181 - return (u8) (ptr - mwifiex_data_rates); 182 - } 183 - return 0; 184 - } 185 - 186 - /* 187 170 * This function returns the current active data rates. 188 171 * 189 172 * The result may vary depending upon connection status. ··· 257 274 return true; 258 275 else 259 276 return false; 260 - } 261 - 262 - /* 263 - * This function converts rate bitmap into rate index. 264 - */ 265 - int mwifiex_get_rate_index(u16 *rate_bitmap, int size) 266 - { 267 - int i; 268 - 269 - for (i = 0; i < size * 8; i++) 270 - if (rate_bitmap[i / 16] & (1 << (i % 16))) 271 - return i; 272 - 273 - return 0; 274 277 } 275 278 276 279 /*
-9
drivers/net/wireless/mwifiex/decl.h
··· 41 41 #define MWIFIEX_AMPDU_DEF_RXWINSIZE 16 42 42 #define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff 43 43 44 - #define MWIFIEX_RATE_INDEX_HRDSSS0 0 45 - #define MWIFIEX_RATE_INDEX_HRDSSS3 3 46 - #define MWIFIEX_RATE_INDEX_OFDM0 4 47 - #define MWIFIEX_RATE_INDEX_OFDM7 11 48 - #define MWIFIEX_RATE_INDEX_MCS0 12 49 - 50 - #define MWIFIEX_RATE_BITMAP_OFDM0 16 51 - #define MWIFIEX_RATE_BITMAP_OFDM7 23 52 44 #define MWIFIEX_RATE_BITMAP_MCS0 32 53 - #define MWIFIEX_RATE_BITMAP_MCS127 159 54 45 55 46 #define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024) 56 47 #define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024)
-10
drivers/net/wireless/mwifiex/fw.h
··· 225 225 #define HostCmd_CMD_BBP_REG_ACCESS 0x001a 226 226 #define HostCmd_CMD_RF_REG_ACCESS 0x001b 227 227 #define HostCmd_CMD_PMIC_REG_ACCESS 0x00ad 228 - #define HostCmd_CMD_802_11_RF_CHANNEL 0x001d 229 228 #define HostCmd_CMD_RF_TX_PWR 0x001e 230 229 #define HostCmd_CMD_RF_ANTENNA 0x0020 231 230 #define HostCmd_CMD_802_11_DEAUTHENTICATE 0x0024 ··· 1291 1292 u8 channel; 1292 1293 } __packed; 1293 1294 1294 - struct host_cmd_ds_802_11_rf_channel { 1295 - __le16 action; 1296 - __le16 current_channel; 1297 - __le16 rf_type; 1298 - __le16 reserved; 1299 - u8 reserved_1[32]; 1300 - } __packed; 1301 - 1302 1295 struct host_cmd_ds_version_ext { 1303 1296 u8 version_str_sel; 1304 1297 char version_str[128]; ··· 1375 1384 struct host_cmd_ds_802_11_rssi_info rssi_info; 1376 1385 struct host_cmd_ds_802_11_rssi_info_rsp rssi_info_rsp; 1377 1386 struct host_cmd_ds_802_11_snmp_mib smib; 1378 - struct host_cmd_ds_802_11_rf_channel rf_channel; 1379 1387 struct host_cmd_ds_tx_rate_query tx_rate; 1380 1388 struct host_cmd_ds_tx_rate_cfg tx_rate_cfg; 1381 1389 struct host_cmd_ds_txpwr_cfg txp_cfg;
-1
drivers/net/wireless/mwifiex/init.c
··· 344 344 adapter->adhoc_awake_period = 0; 345 345 memset(&adapter->arp_filter, 0, sizeof(adapter->arp_filter)); 346 346 adapter->arp_filter_size = 0; 347 - adapter->channel_type = NL80211_CHAN_HT20; 348 347 adapter->max_mgmt_ie_index = MAX_MGMT_IE_INDEX; 349 348 } 350 349
-6
drivers/net/wireless/mwifiex/ioctl.h
··· 225 225 u8 wapi_rxpn[WAPI_RXPN_LEN]; 226 226 }; 227 227 228 - struct mwifiex_rate_cfg { 229 - u32 action; 230 - u32 is_rate_auto; 231 - u32 rate; 232 - }; 233 - 234 228 struct mwifiex_power_cfg { 235 229 u32 is_power_auto; 236 230 u32 power_level;
+2 -2
drivers/net/wireless/mwifiex/main.c
··· 377 377 goto done; 378 378 379 379 err_add_intf: 380 - mwifiex_del_virtual_intf(adapter->wiphy, priv->netdev); 380 + mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); 381 381 rtnl_unlock(); 382 382 err_init_fw: 383 383 pr_debug("info: %s: unregister device\n", __func__); ··· 844 844 845 845 rtnl_lock(); 846 846 if (priv->wdev && priv->netdev) 847 - mwifiex_del_virtual_intf(adapter->wiphy, priv->netdev); 847 + mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); 848 848 rtnl_unlock(); 849 849 } 850 850
+7 -13
drivers/net/wireless/mwifiex/main.h
··· 678 678 u8 hw_dev_mcs_support; 679 679 u8 adhoc_11n_enabled; 680 680 u8 sec_chan_offset; 681 - enum nl80211_channel_type channel_type; 682 681 struct mwifiex_dbg dbg; 683 682 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE]; 684 683 u32 arp_filter_size; ··· 823 824 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, 824 825 u8 *rates); 825 826 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates); 826 - u8 mwifiex_data_rate_to_index(u32 rate); 827 827 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv); 828 - int mwifiex_get_rate_index(u16 *rateBitmap, int size); 829 828 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE]; 830 829 void mwifiex_save_curr_bcn(struct mwifiex_private *priv); 831 830 void mwifiex_free_curr_bcn(struct mwifiex_private *priv); ··· 942 945 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type); 943 946 int mwifiex_enable_hs(struct mwifiex_adapter *adapter); 944 947 int mwifiex_disable_auto_ds(struct mwifiex_private *priv); 945 - int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 946 - struct mwifiex_rate_cfg *rate); 948 + int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate); 947 949 int mwifiex_request_scan(struct mwifiex_private *priv, 948 950 struct cfg80211_ssid *req_ssid); 949 951 int mwifiex_scan_networks(struct mwifiex_private *priv, 950 952 const struct mwifiex_user_scan_cfg *user_scan_in); 951 953 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option); 952 - 953 - int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel); 954 954 955 955 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, 956 956 int key_len, u8 key_index, const u8 *mac_addr, ··· 987 993 988 994 int mwifiex_main_process(struct mwifiex_adapter *); 989 995 990 - int mwifiex_bss_set_channel(struct mwifiex_private *, 991 - struct mwifiex_chan_freq_power *cfp); 992 996 int mwifiex_get_bss_info(struct mwifiex_private *, 993 997 struct mwifiex_bss_info *); 994 998 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, ··· 997 1005 int mwifiex_check_network_compatibility(struct mwifiex_private *priv, 998 1006 struct mwifiex_bssdescriptor *bss_desc); 999 1007 1000 - struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, 1001 - char *name, enum nl80211_iftype type, 1002 - u32 *flags, struct vif_params *params); 1003 - int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev); 1008 + struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy, 1009 + char *name, 1010 + enum nl80211_iftype type, 1011 + u32 *flags, 1012 + struct vif_params *params); 1013 + int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev); 1004 1014 1005 1015 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config); 1006 1016
-38
drivers/net/wireless/mwifiex/sta_cmd.c
··· 745 745 } 746 746 747 747 /* 748 - * This function prepares command to set/get RF channel. 749 - * 750 - * Preparation includes - 751 - * - Setting command ID, action and proper size 752 - * - Setting RF type and current RF channel (for SET only) 753 - * - Ensuring correct endian-ness 754 - */ 755 - static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, 756 - struct host_cmd_ds_command *cmd, 757 - u16 cmd_action, u16 *channel) 758 - { 759 - struct host_cmd_ds_802_11_rf_channel *rf_chan = 760 - &cmd->params.rf_channel; 761 - uint16_t rf_type = le16_to_cpu(rf_chan->rf_type); 762 - 763 - cmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_CHANNEL); 764 - cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rf_channel) 765 - + S_DS_GEN); 766 - 767 - if (cmd_action == HostCmd_ACT_GEN_SET) { 768 - if ((priv->adapter->adhoc_start_band & BAND_A) || 769 - (priv->adapter->adhoc_start_band & BAND_AN)) 770 - rf_chan->rf_type = 771 - cpu_to_le16(HostCmd_SCAN_RADIO_TYPE_A); 772 - 773 - rf_type = le16_to_cpu(rf_chan->rf_type); 774 - SET_SECONDARYCHAN(rf_type, priv->adapter->sec_chan_offset); 775 - rf_chan->current_channel = cpu_to_le16(*channel); 776 - } 777 - rf_chan->action = cpu_to_le16(cmd_action); 778 - return 0; 779 - } 780 - 781 - /* 782 748 * This function prepares command to set/get IBSS coalescing status. 783 749 * 784 750 * Preparation includes - ··· 1134 1168 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) + 1135 1169 S_DS_GEN); 1136 1170 ret = 0; 1137 - break; 1138 - case HostCmd_CMD_802_11_RF_CHANNEL: 1139 - ret = mwifiex_cmd_802_11_rf_channel(priv, cmd_ptr, cmd_action, 1140 - data_buf); 1141 1171 break; 1142 1172 case HostCmd_CMD_FUNC_INIT: 1143 1173 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
+7 -63
drivers/net/wireless/mwifiex/sta_cmdresp.c
··· 267 267 * 268 268 * Based on the new rate bitmaps, the function re-evaluates if 269 269 * auto data rate has been activated. If not, it sends another 270 - * query to the firmware to get the current Tx data rate and updates 271 - * the driver value. 270 + * query to the firmware to get the current Tx data rate. 272 271 */ 273 272 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, 274 - struct host_cmd_ds_command *resp, 275 - struct mwifiex_rate_cfg *ds_rate) 273 + struct host_cmd_ds_command *resp) 276 274 { 277 275 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; 278 276 struct mwifiex_rate_scope *rate_scope; ··· 278 280 u16 tlv, tlv_buf_len; 279 281 u8 *tlv_buf; 280 282 u32 i; 281 - int ret = 0; 282 283 283 284 tlv_buf = ((u8 *)rate_cfg) + 284 285 sizeof(struct host_cmd_ds_tx_rate_cfg); ··· 315 318 if (priv->is_data_rate_auto) 316 319 priv->data_rate = 0; 317 320 else 318 - ret = mwifiex_send_cmd_async(priv, 319 - HostCmd_CMD_802_11_TX_RATE_QUERY, 320 - HostCmd_ACT_GEN_GET, 0, NULL); 321 + return mwifiex_send_cmd_async(priv, 322 + HostCmd_CMD_802_11_TX_RATE_QUERY, 323 + HostCmd_ACT_GEN_GET, 0, NULL); 321 324 322 - if (!ds_rate) 323 - return ret; 324 - 325 - if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) { 326 - if (priv->is_data_rate_auto) { 327 - ds_rate->is_rate_auto = 1; 328 - return ret; 329 - } 330 - ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates, 331 - sizeof(priv->bitmap_rates)); 332 - 333 - if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 && 334 - ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7) 335 - ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 - 336 - MWIFIEX_RATE_INDEX_OFDM0); 337 - 338 - if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 && 339 - ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127) 340 - ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 - 341 - MWIFIEX_RATE_INDEX_MCS0); 342 - } 343 - 344 - return ret; 325 + return 0; 345 326 } 346 327 347 328 /* ··· 631 656 } 632 657 633 658 /* 634 - * This function handles the command response of get RF channel. 635 - * 636 - * Handling includes changing the header fields into CPU format 637 - * and saving the new channel in driver. 638 - */ 639 - static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, 640 - struct host_cmd_ds_command *resp, 641 - u16 *data_buf) 642 - { 643 - struct host_cmd_ds_802_11_rf_channel *rf_channel = 644 - &resp->params.rf_channel; 645 - u16 new_channel = le16_to_cpu(rf_channel->current_channel); 646 - 647 - if (priv->curr_bss_params.bss_descriptor.channel != new_channel) { 648 - dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n", 649 - priv->curr_bss_params.bss_descriptor.channel, 650 - new_channel); 651 - /* Update the channel again */ 652 - priv->curr_bss_params.bss_descriptor.channel = new_channel; 653 - } 654 - 655 - if (data_buf) 656 - *data_buf = new_channel; 657 - 658 - return 0; 659 - } 660 - 661 - /* 662 659 * This function handles the command response of get extended version. 663 660 * 664 661 * Handling includes forming the extended version string and sending it ··· 825 878 ret = mwifiex_ret_mac_multicast_adr(priv, resp); 826 879 break; 827 880 case HostCmd_CMD_TX_RATE_CFG: 828 - ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf); 881 + ret = mwifiex_ret_tx_rate_cfg(priv, resp); 829 882 break; 830 883 case HostCmd_CMD_802_11_SCAN: 831 884 ret = mwifiex_ret_802_11_scan(priv, resp); ··· 875 928 break; 876 929 case HostCmd_CMD_802_11_TX_RATE_QUERY: 877 930 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp); 878 - break; 879 - case HostCmd_CMD_802_11_RF_CHANNEL: 880 - ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf); 881 931 break; 882 932 case HostCmd_CMD_VERSION_EXT: 883 933 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
+7 -280
drivers/net/wireless/mwifiex/sta_ioctl.c
··· 497 497 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); 498 498 499 499 /* 500 - * IOCTL request handler to set/get active channel. 501 - * 502 - * This function performs validity checking on channel/frequency 503 - * compatibility and returns failure if not valid. 504 - */ 505 - int mwifiex_bss_set_channel(struct mwifiex_private *priv, 506 - struct mwifiex_chan_freq_power *chan) 507 - { 508 - struct mwifiex_adapter *adapter = priv->adapter; 509 - struct mwifiex_chan_freq_power *cfp = NULL; 510 - 511 - if (!chan) 512 - return -1; 513 - 514 - if (!chan->channel && !chan->freq) 515 - return -1; 516 - if (adapter->adhoc_start_band & BAND_AN) 517 - adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN; 518 - else if (adapter->adhoc_start_band & BAND_A) 519 - adapter->adhoc_start_band = BAND_G | BAND_B; 520 - if (chan->channel) { 521 - if (chan->channel <= MAX_CHANNEL_BAND_BG) 522 - cfp = mwifiex_get_cfp(priv, 0, (u16) chan->channel, 0); 523 - if (!cfp) { 524 - cfp = mwifiex_get_cfp(priv, BAND_A, 525 - (u16) chan->channel, 0); 526 - if (cfp) { 527 - if (adapter->adhoc_11n_enabled) 528 - adapter->adhoc_start_band = BAND_A 529 - | BAND_AN; 530 - else 531 - adapter->adhoc_start_band = BAND_A; 532 - } 533 - } 534 - } else { 535 - if (chan->freq <= MAX_FREQUENCY_BAND_BG) 536 - cfp = mwifiex_get_cfp(priv, 0, 0, chan->freq); 537 - if (!cfp) { 538 - cfp = mwifiex_get_cfp(priv, BAND_A, 0, chan->freq); 539 - if (cfp) { 540 - if (adapter->adhoc_11n_enabled) 541 - adapter->adhoc_start_band = BAND_A 542 - | BAND_AN; 543 - else 544 - adapter->adhoc_start_band = BAND_A; 545 - } 546 - } 547 - } 548 - if (!cfp || !cfp->channel) { 549 - dev_err(adapter->dev, "invalid channel/freq\n"); 550 - return -1; 551 - } 552 - priv->adhoc_channel = (u8) cfp->channel; 553 - chan->channel = cfp->channel; 554 - chan->freq = cfp->freq; 555 - 556 - return 0; 557 - } 558 - 559 - /* 560 - * IOCTL request handler to set/get Ad-Hoc channel. 561 - * 562 - * This function prepares the correct firmware command and 563 - * issues it to set or get the ad-hoc channel. 564 - */ 565 - static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv, 566 - u16 action, u16 *channel) 567 - { 568 - if (action == HostCmd_ACT_GEN_GET) { 569 - if (!priv->media_connected) { 570 - *channel = priv->adhoc_channel; 571 - return 0; 572 - } 573 - } else { 574 - priv->adhoc_channel = (u8) *channel; 575 - } 576 - 577 - return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL, 578 - action, 0, channel); 579 - } 580 - 581 - /* 582 - * IOCTL request handler to change Ad-Hoc channel. 583 - * 584 - * This function allocates the IOCTL request buffer, fills it 585 - * with requisite parameters and calls the IOCTL handler. 586 - * 587 - * The function follows the following steps to perform the change - 588 - * - Get current IBSS information 589 - * - Get current channel 590 - * - If no change is required, return 591 - * - If not connected, change channel and return 592 - * - If connected, 593 - * - Disconnect 594 - * - Change channel 595 - * - Perform specific SSID scan with same SSID 596 - * - Start/Join the IBSS 597 - */ 598 - int 599 - mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel) 600 - { 601 - int ret; 602 - struct mwifiex_bss_info bss_info; 603 - struct mwifiex_ssid_bssid ssid_bssid; 604 - u16 curr_chan = 0; 605 - struct cfg80211_bss *bss = NULL; 606 - struct ieee80211_channel *chan; 607 - enum ieee80211_band band; 608 - 609 - memset(&bss_info, 0, sizeof(bss_info)); 610 - 611 - /* Get BSS information */ 612 - if (mwifiex_get_bss_info(priv, &bss_info)) 613 - return -1; 614 - 615 - /* Get current channel */ 616 - ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET, 617 - &curr_chan); 618 - 619 - if (curr_chan == channel) { 620 - ret = 0; 621 - goto done; 622 - } 623 - dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n", 624 - curr_chan, channel); 625 - 626 - if (!bss_info.media_connected) { 627 - ret = 0; 628 - goto done; 629 - } 630 - 631 - /* Do disonnect */ 632 - memset(&ssid_bssid, 0, ETH_ALEN); 633 - ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid); 634 - 635 - ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET, 636 - &channel); 637 - 638 - /* Do specific SSID scanning */ 639 - if (mwifiex_request_scan(priv, &bss_info.ssid)) { 640 - ret = -1; 641 - goto done; 642 - } 643 - 644 - band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); 645 - chan = __ieee80211_get_channel(priv->wdev->wiphy, 646 - ieee80211_channel_to_frequency(channel, 647 - band)); 648 - 649 - /* Find the BSS we want using available scan results */ 650 - bss = cfg80211_get_bss(priv->wdev->wiphy, chan, bss_info.bssid, 651 - bss_info.ssid.ssid, bss_info.ssid.ssid_len, 652 - WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); 653 - if (!bss) 654 - wiphy_warn(priv->wdev->wiphy, "assoc: bss %pM not in scan results\n", 655 - bss_info.bssid); 656 - 657 - ret = mwifiex_bss_start(priv, bss, &bss_info.ssid); 658 - done: 659 - return ret; 660 - } 661 - 662 - /* 663 - * IOCTL request handler to get rate. 664 - * 665 - * This function prepares the correct firmware command and 666 - * issues it to get the current rate if it is connected, 667 - * otherwise, the function returns the lowest supported rate 668 - * for the band. 669 - */ 670 - static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv, 671 - struct mwifiex_rate_cfg *rate_cfg) 672 - { 673 - rate_cfg->is_rate_auto = priv->is_data_rate_auto; 674 - return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, 675 - HostCmd_ACT_GEN_GET, 0, NULL); 676 - } 677 - 678 - /* 679 - * IOCTL request handler to set rate. 680 - * 681 - * This function prepares the correct firmware command and 682 - * issues it to set the current rate. 683 - * 684 - * The function also performs validation checking on the supplied value. 685 - */ 686 - static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv, 687 - struct mwifiex_rate_cfg *rate_cfg) 688 - { 689 - u8 rates[MWIFIEX_SUPPORTED_RATES]; 690 - u8 *rate; 691 - int rate_index, ret; 692 - u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; 693 - u32 i; 694 - struct mwifiex_adapter *adapter = priv->adapter; 695 - 696 - if (rate_cfg->is_rate_auto) { 697 - memset(bitmap_rates, 0, sizeof(bitmap_rates)); 698 - /* Support all HR/DSSS rates */ 699 - bitmap_rates[0] = 0x000F; 700 - /* Support all OFDM rates */ 701 - bitmap_rates[1] = 0x00FF; 702 - /* Support all HT-MCSs rate */ 703 - for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++) 704 - bitmap_rates[i + 2] = 0xFFFF; 705 - bitmap_rates[9] = 0x3FFF; 706 - } else { 707 - memset(rates, 0, sizeof(rates)); 708 - mwifiex_get_active_data_rates(priv, rates); 709 - rate = rates; 710 - for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) { 711 - dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n", 712 - rate[i], rate_cfg->rate); 713 - if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f)) 714 - break; 715 - } 716 - if ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) { 717 - dev_err(adapter->dev, "fixed data rate %#x is out " 718 - "of range\n", rate_cfg->rate); 719 - return -1; 720 - } 721 - memset(bitmap_rates, 0, sizeof(bitmap_rates)); 722 - 723 - rate_index = mwifiex_data_rate_to_index(rate_cfg->rate); 724 - 725 - /* Only allow b/g rates to be set */ 726 - if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 && 727 - rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) { 728 - bitmap_rates[0] = 1 << rate_index; 729 - } else { 730 - rate_index -= 1; /* There is a 0x00 in the table */ 731 - if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 && 732 - rate_index <= MWIFIEX_RATE_INDEX_OFDM7) 733 - bitmap_rates[1] = 1 << (rate_index - 734 - MWIFIEX_RATE_INDEX_OFDM0); 735 - } 736 - } 737 - 738 - ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG, 739 - HostCmd_ACT_GEN_SET, 0, bitmap_rates); 740 - 741 - return ret; 742 - } 743 - 744 - /* 745 - * IOCTL request handler to set/get rate. 746 - * 747 - * This function can be used to set/get either the rate value or the 748 - * rate index. 749 - */ 750 - static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv, 751 - struct mwifiex_rate_cfg *rate_cfg) 752 - { 753 - int status; 754 - 755 - if (!rate_cfg) 756 - return -1; 757 - 758 - if (rate_cfg->action == HostCmd_ACT_GEN_GET) 759 - status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg); 760 - else 761 - status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg); 762 - 763 - return status; 764 - } 765 - 766 - /* 767 500 * Sends IOCTL request to get the data rate. 768 501 * 769 502 * This function allocates the IOCTL request buffer, fills it 770 503 * with requisite parameters and calls the IOCTL handler. 771 504 */ 772 - int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 773 - struct mwifiex_rate_cfg *rate) 505 + int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate) 774 506 { 775 507 int ret; 776 508 777 - memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); 778 - rate->action = HostCmd_ACT_GEN_GET; 779 - ret = mwifiex_rate_ioctl_cfg(priv, rate); 509 + ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, 510 + HostCmd_ACT_GEN_GET, 0, NULL); 780 511 781 512 if (!ret) { 782 - if (rate->is_rate_auto) 783 - rate->rate = mwifiex_index_to_data_rate(priv, 784 - priv->tx_rate, 785 - priv->tx_htinfo 786 - ); 513 + if (priv->is_data_rate_auto) 514 + *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate, 515 + priv->tx_htinfo); 787 516 else 788 - rate->rate = priv->data_rate; 789 - } else { 790 - ret = -1; 517 + *rate = priv->data_rate; 791 518 } 792 519 793 520 return ret;
+4 -1
drivers/net/wireless/mwl8k.c
··· 1665 1665 1666 1666 info = IEEE80211_SKB_CB(skb); 1667 1667 if (ieee80211_is_data(wh->frame_control)) { 1668 - sta = info->control.sta; 1668 + rcu_read_lock(); 1669 + sta = ieee80211_find_sta_by_ifaddr(hw, wh->addr1, 1670 + wh->addr2); 1669 1671 if (sta) { 1670 1672 sta_info = MWL8K_STA(sta); 1671 1673 BUG_ON(sta_info == NULL); ··· 1684 1682 sta_info->is_ampdu_allowed = true; 1685 1683 } 1686 1684 } 1685 + rcu_read_unlock(); 1687 1686 } 1688 1687 1689 1688 ieee80211_tx_info_clear_status(info);
+1 -1
drivers/net/wireless/orinoco/cfg.c
··· 138 138 return err; 139 139 } 140 140 141 - static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev, 141 + static int orinoco_scan(struct wiphy *wiphy, 142 142 struct cfg80211_scan_request *request) 143 143 { 144 144 struct orinoco_private *priv = wiphy_priv(wiphy);
+3 -2
drivers/net/wireless/rndis_wlan.c
··· 484 484 enum nl80211_iftype type, u32 *flags, 485 485 struct vif_params *params); 486 486 487 - static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, 487 + static int rndis_scan(struct wiphy *wiphy, 488 488 struct cfg80211_scan_request *request); 489 489 490 490 static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed); ··· 1941 1941 } 1942 1942 1943 1943 #define SCAN_DELAY_JIFFIES (6 * HZ) 1944 - static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, 1944 + static int rndis_scan(struct wiphy *wiphy, 1945 1945 struct cfg80211_scan_request *request) 1946 1946 { 1947 + struct net_device *dev = request->wdev->netdev; 1947 1948 struct usbnet *usbdev = netdev_priv(dev); 1948 1949 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1949 1950 int ret;
+1 -1
drivers/net/wireless/rt2x00/rt2x00config.c
··· 102 102 103 103 /* Update the AID, this is needed for dynamic PS support */ 104 104 rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0; 105 - rt2x00dev->last_beacon = bss_conf->last_tsf; 105 + rt2x00dev->last_beacon = bss_conf->sync_tsf; 106 106 107 107 /* Update global beacon interval time, this is needed for PS support */ 108 108 rt2x00dev->beacon_int = bss_conf->beacon_int;
+1 -1
drivers/net/wireless/rtlwifi/base.c
··· 167 167 0, /* IEEE80211_AC_VO */ 168 168 }; 169 169 170 - u8 rtl_tid_to_ac(struct ieee80211_hw *hw, u8 tid) 170 + u8 rtl_tid_to_ac(u8 tid) 171 171 { 172 172 return tid_to_ac[tid]; 173 173 }
+1 -1
drivers/net/wireless/rtlwifi/base.h
··· 138 138 enum ieee80211_smps_mode smps); 139 139 u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie); 140 140 void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len); 141 - u8 rtl_tid_to_ac(struct ieee80211_hw *hw, u8 tid); 141 + u8 rtl_tid_to_ac(u8 tid); 142 142 extern struct attribute_group rtl_attribute_group; 143 143 int rtlwifi_rate_mapping(struct ieee80211_hw *hw, 144 144 bool isht, u8 desc_rate, bool first_ampdu);
+1 -1
drivers/net/wireless/rtlwifi/pci.c
··· 480 480 481 481 /* we juse use em for BE/BK/VI/VO */ 482 482 for (tid = 7; tid >= 0; tid--) { 483 - u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(hw, tid)]; 483 + u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(tid)]; 484 484 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; 485 485 while (!mac->act_scanning && 486 486 rtlpriv->psc.rfpwr_state == ERFON) {
+3 -3
drivers/net/wireless/rtlwifi/rtl8192de/phy.c
··· 3345 3345 switch (rtlhal->macphymode) { 3346 3346 case DUALMAC_SINGLEPHY: 3347 3347 rtlphy->rf_type = RF_2T2R; 3348 - rtlhal->version |= CHIP_92D_SINGLEPHY; 3348 + rtlhal->version |= RF_TYPE_2T2R; 3349 3349 rtlhal->bandset = BAND_ON_BOTH; 3350 3350 rtlhal->current_bandtype = BAND_ON_2_4G; 3351 3351 break; 3352 3352 3353 3353 case SINGLEMAC_SINGLEPHY: 3354 3354 rtlphy->rf_type = RF_2T2R; 3355 - rtlhal->version |= CHIP_92D_SINGLEPHY; 3355 + rtlhal->version |= RF_TYPE_2T2R; 3356 3356 rtlhal->bandset = BAND_ON_BOTH; 3357 3357 rtlhal->current_bandtype = BAND_ON_2_4G; 3358 3358 break; 3359 3359 3360 3360 case DUALMAC_DUALPHY: 3361 3361 rtlphy->rf_type = RF_1T1R; 3362 - rtlhal->version &= (~CHIP_92D_SINGLEPHY); 3362 + rtlhal->version &= RF_TYPE_1T1R; 3363 3363 /* Now we let MAC0 run on 5G band. */ 3364 3364 if (rtlhal->interfaceindex == 0) { 3365 3365 rtlhal->bandset = BAND_ON_5G;
+11 -3
drivers/net/wireless/rtlwifi/usb.c
··· 131 131 u8 request; 132 132 u16 wvalue; 133 133 u16 index; 134 - __le32 *data = &rtlpriv->usb_data[rtlpriv->usb_data_index]; 134 + __le32 *data; 135 + unsigned long flags; 135 136 137 + spin_lock_irqsave(&rtlpriv->locks.usb_lock, flags); 138 + if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT) 139 + rtlpriv->usb_data_index = 0; 140 + data = &rtlpriv->usb_data[rtlpriv->usb_data_index]; 141 + spin_unlock_irqrestore(&rtlpriv->locks.usb_lock, flags); 136 142 request = REALTEK_USB_VENQT_CMD_REQ; 137 143 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */ 138 144 139 145 wvalue = (u16)addr; 140 146 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len); 141 - if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT) 142 - rtlpriv->usb_data_index = 0; 143 147 return le32_to_cpu(*data); 144 148 } 145 149 ··· 955 951 GFP_KERNEL); 956 952 if (!rtlpriv->usb_data) 957 953 return -ENOMEM; 954 + 955 + /* this spin lock must be initialized early */ 956 + spin_lock_init(&rtlpriv->locks.usb_lock); 957 + 958 958 rtlpriv->usb_data_index = 0; 959 959 init_completion(&rtlpriv->firmware_loading_complete); 960 960 SET_IEEE80211_DEV(hw, &intf->dev);
+1
drivers/net/wireless/rtlwifi/wifi.h
··· 1555 1555 spinlock_t rf_ps_lock; 1556 1556 spinlock_t rf_lock; 1557 1557 spinlock_t waitq_lock; 1558 + spinlock_t usb_lock; 1558 1559 1559 1560 /*Dual mac*/ 1560 1561 spinlock_t cck_and_rw_pagea_lock;
+30 -4
drivers/net/wireless/ti/wl12xx/cmd.c
··· 85 85 86 86 memcpy(&gen_parms->general_params, gp, sizeof(*gp)); 87 87 88 - if (gp->tx_bip_fem_auto_detect) 88 + /* If we started in PLT FEM_DETECT mode, force auto detect */ 89 + if (wl->plt_mode == PLT_FEM_DETECT) 90 + gen_parms->general_params.tx_bip_fem_auto_detect = true; 91 + 92 + if (gen_parms->general_params.tx_bip_fem_auto_detect) 89 93 answer = true; 90 94 91 95 /* Override the REF CLK from the NVS with the one from platform data */ ··· 110 106 goto out; 111 107 } 112 108 109 + /* If we are in calibrator based fem auto detect - save fem nr */ 110 + if (wl->plt_mode == PLT_FEM_DETECT) 111 + wl->fem_manuf = gp->tx_bip_fem_manufacturer; 112 + 113 113 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n", 114 - answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer); 114 + answer == false ? 115 + "manual" : 116 + wl->plt_mode == PLT_FEM_DETECT ? 117 + "calibrator_fem_detect" : 118 + "auto", 119 + gp->tx_bip_fem_manufacturer); 115 120 116 121 out: 117 122 kfree(gen_parms); ··· 152 139 153 140 memcpy(&gen_parms->general_params, gp, sizeof(*gp)); 154 141 155 - if (gp->tx_bip_fem_auto_detect) 142 + /* If we started in PLT FEM_DETECT mode, force auto detect */ 143 + if (wl->plt_mode == PLT_FEM_DETECT) 144 + gen_parms->general_params.tx_bip_fem_auto_detect = true; 145 + 146 + if (gen_parms->general_params.tx_bip_fem_auto_detect) 156 147 answer = true; 157 148 158 149 /* Replace REF and TCXO CLKs with the ones from platform data */ ··· 178 161 goto out; 179 162 } 180 163 164 + /* If we are in calibrator based fem auto detect - save fem nr */ 165 + if (wl->plt_mode == PLT_FEM_DETECT) 166 + wl->fem_manuf = gp->tx_bip_fem_manufacturer; 167 + 181 168 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n", 182 - answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer); 169 + answer == false ? 170 + "manual" : 171 + wl->plt_mode == PLT_FEM_DETECT ? 172 + "calibrator_fem_detect" : 173 + "auto", 174 + gp->tx_bip_fem_manufacturer); 183 175 184 176 out: 185 177 kfree(gen_parms);
+23
drivers/net/wireless/ti/wl12xx/main.c
··· 1339 1339 ret = wl128x_cmd_general_parms(wl); 1340 1340 if (ret < 0) 1341 1341 goto out; 1342 + 1343 + /* 1344 + * If we are in calibrator based auto detect then we got the FEM nr 1345 + * in wl->fem_manuf. No need to continue further 1346 + */ 1347 + if (wl->plt_mode == PLT_FEM_DETECT) 1348 + goto out; 1349 + 1342 1350 ret = wl128x_cmd_radio_parms(wl); 1343 1351 if (ret < 0) 1344 1352 goto out; ··· 1363 1355 ret = wl1271_cmd_general_parms(wl); 1364 1356 if (ret < 0) 1365 1357 goto out; 1358 + 1359 + /* 1360 + * If we are in calibrator based auto detect then we got the FEM nr 1361 + * in wl->fem_manuf. No need to continue further 1362 + */ 1363 + if (wl->plt_mode == PLT_FEM_DETECT) 1364 + goto out; 1365 + 1366 1366 ret = wl1271_cmd_radio_parms(wl); 1367 1367 if (ret < 0) 1368 1368 goto out; ··· 1515 1499 ret = wl->ops->hw_init(wl); 1516 1500 if (ret < 0) 1517 1501 goto out_irq_disable; 1502 + 1503 + /* 1504 + * If we are in calibrator based auto detect then we got the FEM nr 1505 + * in wl->fem_manuf. No need to continue further 1506 + */ 1507 + if (wl->plt_mode == PLT_FEM_DETECT) 1508 + goto out; 1518 1509 1519 1510 ret = wl1271_acx_init_mem_config(wl); 1520 1511 if (ret < 0)
+20 -1
drivers/net/wireless/ti/wl18xx/conf.h
··· 23 23 #define __WL18XX_CONF_H__ 24 24 25 25 #define WL18XX_CONF_MAGIC 0x10e100ca 26 - #define WL18XX_CONF_VERSION (WLCORE_CONF_VERSION | 0x0002) 26 + #define WL18XX_CONF_VERSION (WLCORE_CONF_VERSION | 0x0003) 27 27 #define WL18XX_CONF_MASK 0x0000ffff 28 28 #define WL18XX_CONF_SIZE (WLCORE_CONF_SIZE + \ 29 29 sizeof(struct wl18xx_priv_conf)) ··· 84 84 u8 padding[1]; 85 85 } __packed; 86 86 87 + enum wl18xx_ht_mode { 88 + /* Default - use MIMO, fallback to SISO20 */ 89 + HT_MODE_DEFAULT = 0, 90 + 91 + /* Wide - use SISO40 */ 92 + HT_MODE_WIDE = 1, 93 + 94 + /* Use SISO20 */ 95 + HT_MODE_SISO20 = 2, 96 + }; 97 + 98 + struct wl18xx_ht_settings { 99 + /* DEFAULT / WIDE / SISO20 */ 100 + u8 mode; 101 + } __packed; 102 + 87 103 struct wl18xx_priv_conf { 104 + /* Module params structures */ 105 + struct wl18xx_ht_settings ht; 106 + 88 107 /* this structure is copied wholesale to FW */ 89 108 struct wl18xx_mac_and_phy_params phy; 90 109 } __packed;
+1 -1
drivers/net/wireless/ti/wl18xx/io.c
··· 54 54 55 55 int wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out) 56 56 { 57 - u32 val; 57 + u32 val = 0; 58 58 int ret; 59 59 60 60 if (WARN_ON(addr % 2))
+85 -32
drivers/net/wireless/ti/wl18xx/main.c
··· 43 43 44 44 #define WL18XX_RX_CHECKSUM_MASK 0x40 45 45 46 - static char *ht_mode_param = "default"; 47 - static char *board_type_param = "hdk"; 46 + static char *ht_mode_param = NULL; 47 + static char *board_type_param = NULL; 48 48 static bool checksum_param = false; 49 49 static bool enable_11a_param = true; 50 50 static int num_rx_desc_param = -1; ··· 494 494 }; 495 495 496 496 static struct wl18xx_priv_conf wl18xx_default_priv_conf = { 497 + .ht = { 498 + .mode = HT_MODE_DEFAULT, 499 + }, 497 500 .phy = { 498 501 .phy_standalone = 0x00, 499 502 .primary_clock_setting_time = 0x05, 500 503 .clock_valid_on_wake_up = 0x00, 501 504 .secondary_clock_setting_time = 0x05, 505 + .board_type = BOARD_TYPE_HDK_18XX, 502 506 .rdl = 0x01, 503 507 .auto_detect = 0x00, 504 508 .dedicated_fem = FEM_NONE, 505 509 .low_band_component = COMPONENT_2_WAY_SWITCH, 506 - .low_band_component_type = 0x05, 510 + .low_band_component_type = 0x06, 507 511 .high_band_component = COMPONENT_2_WAY_SWITCH, 508 512 .high_band_component_type = 0x09, 509 513 .tcxo_ldo_voltage = 0x00, ··· 776 772 static int wl18xx_set_mac_and_phy(struct wl1271 *wl) 777 773 { 778 774 struct wl18xx_priv *priv = wl->priv; 775 + struct wl18xx_mac_and_phy_params *params; 779 776 int ret; 777 + 778 + params = kmemdup(&priv->conf.phy, sizeof(*params), GFP_KERNEL); 779 + if (!params) { 780 + ret = -ENOMEM; 781 + goto out; 782 + } 780 783 781 784 ret = wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]); 782 785 if (ret < 0) 783 786 goto out; 784 787 785 - ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)&priv->conf.phy, 786 - sizeof(struct wl18xx_mac_and_phy_params), false); 788 + ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, params, 789 + sizeof(*params), false); 787 790 788 791 out: 792 + kfree(params); 789 793 return ret; 790 794 } 791 795 ··· 1013 1001 skb->ip_summed = CHECKSUM_UNNECESSARY; 1014 1002 } 1015 1003 1004 + static bool wl18xx_is_mimo_supported(struct wl1271 *wl) 1005 + { 1006 + struct wl18xx_priv *priv = wl->priv; 1007 + 1008 + return priv->conf.phy.number_of_assembled_ant2_4 >= 2; 1009 + } 1010 + 1016 1011 /* 1017 1012 * TODO: instead of having these two functions to get the rate mask, 1018 1013 * we should modify the wlvif->rate_set instead ··· 1036 1017 1037 1018 /* we don't support MIMO in wide-channel mode */ 1038 1019 hw_rate_set &= ~CONF_TX_MIMO_RATES; 1020 + } else if (wl18xx_is_mimo_supported(wl)) { 1021 + wl1271_debug(DEBUG_ACX, "using MIMO channel rate mask"); 1022 + hw_rate_set |= CONF_TX_MIMO_RATES; 1039 1023 } 1040 1024 1041 1025 return hw_rate_set; ··· 1047 1025 static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl, 1048 1026 struct wl12xx_vif *wlvif) 1049 1027 { 1050 - struct wl18xx_priv *priv = wl->priv; 1051 - 1052 1028 if (wlvif->channel_type == NL80211_CHAN_HT40MINUS || 1053 1029 wlvif->channel_type == NL80211_CHAN_HT40PLUS) { 1054 1030 wl1271_debug(DEBUG_ACX, "using wide channel rate mask"); ··· 1056 1036 return 0; 1057 1037 1058 1038 return CONF_TX_RATE_USE_WIDE_CHAN; 1059 - } else if (priv->conf.phy.number_of_assembled_ant2_4 >= 2 && 1039 + } else if (wl18xx_is_mimo_supported(wl) && 1060 1040 wlvif->band == IEEE80211_BAND_2GHZ) { 1061 1041 wl1271_debug(DEBUG_ACX, "using MIMO rate mask"); 1062 1042 /* ··· 1155 1135 static int wl18xx_plt_init(struct wl1271 *wl) 1156 1136 { 1157 1137 int ret; 1138 + 1139 + /* calibrator based auto/fem detect not supported for 18xx */ 1140 + if (wl->plt_mode == PLT_FEM_DETECT) { 1141 + wl1271_error("wl18xx_plt_init: PLT FEM_DETECT not supported"); 1142 + return -EINVAL; 1143 + } 1158 1144 1159 1145 ret = wlcore_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT); 1160 1146 if (ret < 0) ··· 1409 1383 if (ret < 0) 1410 1384 goto out_free; 1411 1385 1412 - if (!strcmp(board_type_param, "fpga")) { 1413 - priv->conf.phy.board_type = BOARD_TYPE_FPGA_18XX; 1414 - } else if (!strcmp(board_type_param, "hdk")) { 1415 - priv->conf.phy.board_type = BOARD_TYPE_HDK_18XX; 1416 - /* HACK! Just for now we hardcode HDK to 0x06 */ 1386 + /* If the module param is set, update it in conf */ 1387 + if (board_type_param) { 1388 + if (!strcmp(board_type_param, "fpga")) { 1389 + priv->conf.phy.board_type = BOARD_TYPE_FPGA_18XX; 1390 + } else if (!strcmp(board_type_param, "hdk")) { 1391 + priv->conf.phy.board_type = BOARD_TYPE_HDK_18XX; 1392 + } else if (!strcmp(board_type_param, "dvp")) { 1393 + priv->conf.phy.board_type = BOARD_TYPE_DVP_18XX; 1394 + } else if (!strcmp(board_type_param, "evb")) { 1395 + priv->conf.phy.board_type = BOARD_TYPE_EVB_18XX; 1396 + } else if (!strcmp(board_type_param, "com8")) { 1397 + priv->conf.phy.board_type = BOARD_TYPE_COM8_18XX; 1398 + } else { 1399 + wl1271_error("invalid board type '%s'", 1400 + board_type_param); 1401 + ret = -EINVAL; 1402 + goto out_free; 1403 + } 1404 + } 1405 + 1406 + /* HACK! Just for now we hardcode COM8 and HDK to 0x06 */ 1407 + switch (priv->conf.phy.board_type) { 1408 + case BOARD_TYPE_HDK_18XX: 1409 + case BOARD_TYPE_COM8_18XX: 1417 1410 priv->conf.phy.low_band_component_type = 0x06; 1418 - } else if (!strcmp(board_type_param, "dvp")) { 1419 - priv->conf.phy.board_type = BOARD_TYPE_DVP_18XX; 1420 - } else if (!strcmp(board_type_param, "evb")) { 1421 - priv->conf.phy.board_type = BOARD_TYPE_EVB_18XX; 1422 - } else if (!strcmp(board_type_param, "com8")) { 1423 - priv->conf.phy.board_type = BOARD_TYPE_COM8_18XX; 1424 - /* HACK! Just for now we hardcode COM8 to 0x06 */ 1425 - priv->conf.phy.low_band_component_type = 0x06; 1426 - } else { 1427 - wl1271_error("invalid board type '%s'", board_type_param); 1411 + break; 1412 + case BOARD_TYPE_FPGA_18XX: 1413 + case BOARD_TYPE_DVP_18XX: 1414 + case BOARD_TYPE_EVB_18XX: 1415 + priv->conf.phy.low_band_component_type = 0x05; 1416 + break; 1417 + default: 1418 + wl1271_error("invalid board type '%d'", 1419 + priv->conf.phy.board_type); 1428 1420 ret = -EINVAL; 1429 1421 goto out_free; 1430 1422 } 1431 1423 1432 - /* If the module param is set, update it in conf */ 1433 1424 if (low_band_component_param != -1) 1434 1425 priv->conf.phy.low_band_component = low_band_component_param; 1435 1426 if (low_band_component_type_param != -1) ··· 1467 1424 if (dc2dc_param != -1) 1468 1425 priv->conf.phy.external_pa_dc2dc = dc2dc_param; 1469 1426 1470 - if (!strcmp(ht_mode_param, "default")) { 1427 + if (ht_mode_param) { 1428 + if (!strcmp(ht_mode_param, "default")) 1429 + priv->conf.ht.mode = HT_MODE_DEFAULT; 1430 + else if (!strcmp(ht_mode_param, "wide")) 1431 + priv->conf.ht.mode = HT_MODE_WIDE; 1432 + else if (!strcmp(ht_mode_param, "siso20")) 1433 + priv->conf.ht.mode = HT_MODE_SISO20; 1434 + else { 1435 + wl1271_error("invalid ht_mode '%s'", ht_mode_param); 1436 + ret = -EINVAL; 1437 + goto out_free; 1438 + } 1439 + } 1440 + 1441 + if (priv->conf.ht.mode == HT_MODE_DEFAULT) { 1471 1442 /* 1472 1443 * Only support mimo with multiple antennas. Fall back to 1473 1444 * siso20. 1474 1445 */ 1475 - if (priv->conf.phy.number_of_assembled_ant2_4 >= 2) 1446 + if (wl18xx_is_mimo_supported(wl)) 1476 1447 wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ, 1477 1448 &wl18xx_mimo_ht_cap_2ghz); 1478 1449 else ··· 1496 1439 /* 5Ghz is always wide */ 1497 1440 wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, 1498 1441 &wl18xx_siso40_ht_cap_5ghz); 1499 - } else if (!strcmp(ht_mode_param, "wide")) { 1442 + } else if (priv->conf.ht.mode == HT_MODE_WIDE) { 1500 1443 wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ, 1501 1444 &wl18xx_siso40_ht_cap_2ghz); 1502 1445 wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, 1503 1446 &wl18xx_siso40_ht_cap_5ghz); 1504 - } else if (!strcmp(ht_mode_param, "siso20")) { 1447 + } else if (priv->conf.ht.mode == HT_MODE_SISO20) { 1505 1448 wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ, 1506 1449 &wl18xx_siso20_ht_cap); 1507 1450 wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, 1508 1451 &wl18xx_siso20_ht_cap); 1509 - } else { 1510 - wl1271_error("invalid ht_mode '%s'", ht_mode_param); 1511 - ret = -EINVAL; 1512 - goto out_free; 1513 1452 } 1514 1453 1515 1454 if (!checksum_param) {
+12
drivers/net/wireless/ti/wlcore/cmd.c
··· 497 497 { 498 498 struct wl12xx_cmd_role_stop *cmd; 499 499 int ret; 500 + bool timeout = false; 500 501 501 502 if (WARN_ON(wlvif->sta.hlid == WL12XX_INVALID_LINK_ID)) 502 503 return -EINVAL; ··· 519 518 wl1271_error("failed to initiate cmd role stop sta"); 520 519 goto out_free; 521 520 } 521 + 522 + /* 523 + * Sometimes the firmware doesn't send this event, so we just 524 + * time out without failing. Queue recovery for other 525 + * failures. 526 + */ 527 + ret = wl1271_cmd_wait_for_event_or_timeout(wl, 528 + ROLE_STOP_COMPLETE_EVENT_ID, 529 + &timeout); 530 + if (ret) 531 + wl12xx_queue_recovery_work(wl); 522 532 523 533 wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); 524 534
+1 -1
drivers/net/wireless/ti/wlcore/cmd.h
··· 192 192 #define WL1271_COMMAND_TIMEOUT 2000 193 193 #define WL1271_CMD_TEMPL_DFLT_SIZE 252 194 194 #define WL1271_CMD_TEMPL_MAX_SIZE 512 195 - #define WL1271_EVENT_TIMEOUT 1000 195 + #define WL1271_EVENT_TIMEOUT 1500 196 196 197 197 struct wl1271_cmd_header { 198 198 __le16 id;
+40 -4
drivers/net/wireless/ti/wlcore/main.c
··· 1064 1064 return ret; 1065 1065 } 1066 1066 1067 - int wl1271_plt_start(struct wl1271 *wl) 1067 + int wl1271_plt_start(struct wl1271 *wl, const enum plt_mode plt_mode) 1068 1068 { 1069 1069 int retries = WL1271_BOOT_RETRIES; 1070 1070 struct wiphy *wiphy = wl->hw->wiphy; 1071 + 1072 + static const char* const PLT_MODE[] = { 1073 + "PLT_OFF", 1074 + "PLT_ON", 1075 + "PLT_FEM_DETECT" 1076 + }; 1077 + 1071 1078 int ret; 1072 1079 1073 1080 mutex_lock(&wl->mutex); ··· 1088 1081 goto out; 1089 1082 } 1090 1083 1084 + /* Indicate to lower levels that we are now in PLT mode */ 1085 + wl->plt = true; 1086 + wl->plt_mode = plt_mode; 1087 + 1091 1088 while (retries) { 1092 1089 retries--; 1093 1090 ret = wl12xx_chip_wakeup(wl, true); ··· 1102 1091 if (ret < 0) 1103 1092 goto power_off; 1104 1093 1105 - wl->plt = true; 1106 1094 wl->state = WL1271_STATE_ON; 1107 - wl1271_notice("firmware booted in PLT mode (%s)", 1095 + wl1271_notice("firmware booted in PLT mode %s (%s)", 1096 + PLT_MODE[plt_mode], 1108 1097 wl->chip.fw_ver_str); 1109 1098 1110 1099 /* update hw/fw version info in wiphy struct */ ··· 1117 1106 power_off: 1118 1107 wl1271_power_off(wl); 1119 1108 } 1109 + 1110 + wl->plt = false; 1111 + wl->plt_mode = PLT_OFF; 1120 1112 1121 1113 wl1271_error("firmware boot in PLT mode failed despite %d retries", 1122 1114 WL1271_BOOT_RETRIES); ··· 1173 1159 wl->sleep_auth = WL1271_PSM_ILLEGAL; 1174 1160 wl->state = WL1271_STATE_OFF; 1175 1161 wl->plt = false; 1162 + wl->plt_mode = PLT_OFF; 1176 1163 wl->rx_counter = 0; 1177 1164 mutex_unlock(&wl->mutex); 1178 1165 ··· 1600 1585 if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) 1601 1586 goto out; 1602 1587 1588 + if ((wl->conf.conn.suspend_wake_up_event == 1589 + wl->conf.conn.wake_up_event) && 1590 + (wl->conf.conn.suspend_listen_interval == 1591 + wl->conf.conn.listen_interval)) 1592 + goto out; 1593 + 1603 1594 ret = wl1271_ps_elp_wakeup(wl); 1604 1595 if (ret < 0) 1605 1596 goto out; ··· 1667 1646 bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; 1668 1647 1669 1648 if ((!is_ap) && (!is_sta)) 1649 + return; 1650 + 1651 + if (is_sta && 1652 + ((wl->conf.conn.suspend_wake_up_event == 1653 + wl->conf.conn.wake_up_event) && 1654 + (wl->conf.conn.suspend_listen_interval == 1655 + wl->conf.conn.listen_interval))) 1670 1656 return; 1671 1657 1672 1658 ret = wl1271_ps_elp_wakeup(wl); ··· 2392 2364 else 2393 2365 wl->sta_count--; 2394 2366 2395 - /* Last AP, have more stations. Configure according to STA. */ 2367 + /* 2368 + * Last AP, have more stations. Configure sleep auth according to STA. 2369 + * Don't do thin on unintended recovery. 2370 + */ 2371 + if (test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags) && 2372 + !test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)) 2373 + goto unlock; 2374 + 2396 2375 if (wl->ap_count == 0 && is_ap && wl->sta_count) { 2397 2376 u8 sta_auth = wl->conf.conn.sta_sleep_auth; 2398 2377 /* Configure for power according to debugfs */ ··· 2413 2378 wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); 2414 2379 } 2415 2380 2381 + unlock: 2416 2382 mutex_unlock(&wl->mutex); 2417 2383 2418 2384 del_timer_sync(&wlvif->rx_streaming_timer);
+61 -24
drivers/net/wireless/ti/wlcore/testmode.c
··· 129 129 goto out_sleep; 130 130 } 131 131 132 - if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) 133 - goto nla_put_failure; 132 + if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) { 133 + kfree_skb(skb); 134 + ret = -EMSGSIZE; 135 + goto out_sleep; 136 + } 137 + 134 138 ret = cfg80211_testmode_reply(skb); 135 139 if (ret < 0) 136 140 goto out_sleep; ··· 146 142 mutex_unlock(&wl->mutex); 147 143 148 144 return ret; 149 - 150 - nla_put_failure: 151 - kfree_skb(skb); 152 - ret = -EMSGSIZE; 153 - goto out_sleep; 154 145 } 155 146 156 147 static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) ··· 191 192 goto out_free; 192 193 } 193 194 194 - if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) 195 - goto nla_put_failure; 195 + if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) { 196 + kfree_skb(skb); 197 + ret = -EMSGSIZE; 198 + goto out_free; 199 + } 200 + 196 201 ret = cfg80211_testmode_reply(skb); 197 202 if (ret < 0) 198 203 goto out_free; ··· 209 206 mutex_unlock(&wl->mutex); 210 207 211 208 return ret; 212 - 213 - nla_put_failure: 214 - kfree_skb(skb); 215 - ret = -EMSGSIZE; 216 - goto out_free; 217 209 } 218 210 219 211 static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) ··· 243 245 return 0; 244 246 } 245 247 248 + static int wl1271_tm_detect_fem(struct wl1271 *wl, struct nlattr *tb[]) 249 + { 250 + /* return FEM type */ 251 + int ret, len; 252 + struct sk_buff *skb; 253 + 254 + ret = wl1271_plt_start(wl, PLT_FEM_DETECT); 255 + if (ret < 0) 256 + goto out; 257 + 258 + mutex_lock(&wl->mutex); 259 + 260 + len = nla_total_size(sizeof(wl->fem_manuf)); 261 + skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, len); 262 + if (!skb) { 263 + ret = -ENOMEM; 264 + goto out_mutex; 265 + } 266 + 267 + if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(wl->fem_manuf), 268 + &wl->fem_manuf)) { 269 + kfree_skb(skb); 270 + ret = -EMSGSIZE; 271 + goto out_mutex; 272 + } 273 + 274 + ret = cfg80211_testmode_reply(skb); 275 + 276 + out_mutex: 277 + mutex_unlock(&wl->mutex); 278 + 279 + /* We always stop plt after DETECT mode */ 280 + wl1271_plt_stop(wl); 281 + out: 282 + return ret; 283 + } 284 + 246 285 static int wl1271_tm_cmd_set_plt_mode(struct wl1271 *wl, struct nlattr *tb[]) 247 286 { 248 287 u32 val; ··· 293 258 val = nla_get_u32(tb[WL1271_TM_ATTR_PLT_MODE]); 294 259 295 260 switch (val) { 296 - case 0: 261 + case PLT_OFF: 297 262 ret = wl1271_plt_stop(wl); 298 263 break; 299 - case 1: 300 - ret = wl1271_plt_start(wl); 264 + case PLT_ON: 265 + ret = wl1271_plt_start(wl, PLT_ON); 266 + break; 267 + case PLT_FEM_DETECT: 268 + ret = wl1271_tm_detect_fem(wl, tb); 301 269 break; 302 270 default: 303 271 ret = -EINVAL; ··· 341 303 goto out; 342 304 } 343 305 344 - if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) 345 - goto nla_put_failure; 306 + if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) { 307 + kfree_skb(skb); 308 + ret = -EMSGSIZE; 309 + goto out; 310 + } 311 + 346 312 ret = cfg80211_testmode_reply(skb); 347 313 if (ret < 0) 348 314 goto out; ··· 354 312 out: 355 313 mutex_unlock(&wl->mutex); 356 314 return ret; 357 - 358 - nla_put_failure: 359 - kfree_skb(skb); 360 - ret = -EMSGSIZE; 361 - goto out; 362 315 } 363 316 364 317 int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)
+8 -6
drivers/net/wireless/ti/wlcore/tx.c
··· 306 306 rate_idx = 0; 307 307 else if (wlvif->bss_type != BSS_TYPE_AP_BSS) { 308 308 /* 309 - * if the packets are destined for AP (have a STA entry) 309 + * if the packets are data packets 310 310 * send them with AP rate policies (EAPOLs are an exception), 311 311 * otherwise use default basic rates 312 312 */ 313 - if (control->flags & IEEE80211_TX_CTL_NO_CCK_RATE) 314 - rate_idx = wlvif->sta.p2p_rate_idx; 315 - else if (skb->protocol == cpu_to_be16(ETH_P_PAE)) 313 + if (skb->protocol == cpu_to_be16(ETH_P_PAE)) 316 314 rate_idx = wlvif->sta.basic_rate_idx; 317 - else if (control->control.sta) 315 + else if (control->flags & IEEE80211_TX_CTL_NO_CCK_RATE) 316 + rate_idx = wlvif->sta.p2p_rate_idx; 317 + else if (ieee80211_is_data(frame_control)) 318 318 rate_idx = wlvif->sta.ap_rate_idx; 319 319 else 320 320 rate_idx = wlvif->sta.basic_rate_idx; 321 321 } else { 322 322 if (hlid == wlvif->ap.global_hlid) 323 323 rate_idx = wlvif->ap.mgmt_rate_idx; 324 - else if (hlid == wlvif->ap.bcast_hlid) 324 + else if (hlid == wlvif->ap.bcast_hlid || 325 + skb->protocol == cpu_to_be16(ETH_P_PAE)) 326 + /* send AP bcast and EAPOLs using the min basic rate */ 325 327 rate_idx = wlvif->ap.bcast_rate_idx; 326 328 else 327 329 rate_idx = wlvif->ap.ucast_rate_idx[ac];
+2
drivers/net/wireless/ti/wlcore/wlcore.h
··· 156 156 enum wl1271_state state; 157 157 enum wl12xx_fw_type fw_type; 158 158 bool plt; 159 + enum plt_mode plt_mode; 160 + u8 fem_manuf; 159 161 u8 last_vif_count; 160 162 struct mutex mutex; 161 163
+7 -1
drivers/net/wireless/ti/wlcore/wlcore_i.h
··· 293 293 FILTER_FW_HANDLE = 2 294 294 }; 295 295 296 + enum plt_mode { 297 + PLT_OFF = 0, 298 + PLT_ON = 1, 299 + PLT_FEM_DETECT = 2, 300 + }; 301 + 296 302 struct wl12xx_rx_filter_field { 297 303 __le16 offset; 298 304 u8 len; ··· 465 459 #define wl12xx_for_each_wlvif_ap(wl, wlvif) \ 466 460 wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_AP_BSS) 467 461 468 - int wl1271_plt_start(struct wl1271 *wl); 462 + int wl1271_plt_start(struct wl1271 *wl, const enum plt_mode plt_mode); 469 463 int wl1271_plt_stop(struct wl1271 *wl); 470 464 int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif); 471 465 void wl12xx_queue_recovery_work(struct wl1271 *wl);
+2
include/linux/bcma/bcma.h
··· 7 7 #include <linux/bcma/bcma_driver_chipcommon.h> 8 8 #include <linux/bcma/bcma_driver_pci.h> 9 9 #include <linux/bcma/bcma_driver_mips.h> 10 + #include <linux/bcma/bcma_driver_gmac_cmn.h> 10 11 #include <linux/ssb/ssb.h> /* SPROM sharing */ 11 12 12 13 #include "bcma_regs.h" ··· 253 252 struct bcma_drv_cc drv_cc; 254 253 struct bcma_drv_pci drv_pci; 255 254 struct bcma_drv_mips drv_mips; 255 + struct bcma_drv_gmac_cmn drv_gmac_cmn; 256 256 257 257 /* We decided to share SPROM struct with SSB as long as we do not need 258 258 * any hacks for BCMA. This simplifies drivers code. */
+50 -1
include/linux/bcma/bcma_driver_chipcommon.h
··· 24 24 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */ 25 25 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */ 26 26 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */ 27 - #define BCMA_CC_FLASHT_NFLASH 0x00000200 27 + #define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */ 28 28 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */ 29 29 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */ 30 30 #define BCMA_PLLTYPE_NONE 0x00000000 ··· 45 45 #define BCMA_CC_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */ 46 46 #define BCMA_CC_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */ 47 47 #define BCMA_CC_CAP_SPROM 0x40000000 /* SPROM present */ 48 + #define BCMA_CC_CAP_NFLASH 0x80000000 /* NAND flash present (rev >= 35 or BCM4706?) */ 48 49 #define BCMA_CC_CORECTL 0x0008 49 50 #define BCMA_CC_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */ 50 51 #define BCMA_CC_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */ ··· 123 122 #define BCMA_CC_JCTL_EXT_EN 2 /* Enable external targets */ 124 123 #define BCMA_CC_JCTL_EN 1 /* Enable Jtag master */ 125 124 #define BCMA_CC_FLASHCTL 0x0040 125 + /* Start/busy bit in flashcontrol */ 126 + #define BCMA_CC_FLASHCTL_OPCODE 0x000000ff 127 + #define BCMA_CC_FLASHCTL_ACTION 0x00000700 128 + #define BCMA_CC_FLASHCTL_CS_ACTIVE 0x00001000 /* Chip Select Active, rev >= 20 */ 126 129 #define BCMA_CC_FLASHCTL_START 0x80000000 127 130 #define BCMA_CC_FLASHCTL_BUSY BCMA_CC_FLASHCTL_START 131 + /* Flashcontrol action + opcodes for ST flashes */ 132 + #define BCMA_CC_FLASHCTL_ST_WREN 0x0006 /* Write Enable */ 133 + #define BCMA_CC_FLASHCTL_ST_WRDIS 0x0004 /* Write Disable */ 134 + #define BCMA_CC_FLASHCTL_ST_RDSR 0x0105 /* Read Status Register */ 135 + #define BCMA_CC_FLASHCTL_ST_WRSR 0x0101 /* Write Status Register */ 136 + #define BCMA_CC_FLASHCTL_ST_READ 0x0303 /* Read Data Bytes */ 137 + #define BCMA_CC_FLASHCTL_ST_PP 0x0302 /* Page Program */ 138 + #define BCMA_CC_FLASHCTL_ST_SE 0x02d8 /* Sector Erase */ 139 + #define BCMA_CC_FLASHCTL_ST_BE 0x00c7 /* Bulk Erase */ 140 + #define BCMA_CC_FLASHCTL_ST_DP 0x00b9 /* Deep Power-down */ 141 + #define BCMA_CC_FLASHCTL_ST_RES 0x03ab /* Read Electronic Signature */ 142 + #define BCMA_CC_FLASHCTL_ST_CSA 0x1000 /* Keep chip select asserted */ 143 + #define BCMA_CC_FLASHCTL_ST_SSE 0x0220 /* Sub-sector Erase */ 144 + /* Flashcontrol action + opcodes for Atmel flashes */ 145 + #define BCMA_CC_FLASHCTL_AT_READ 0x07e8 146 + #define BCMA_CC_FLASHCTL_AT_PAGE_READ 0x07d2 147 + #define BCMA_CC_FLASHCTL_AT_STATUS 0x01d7 148 + #define BCMA_CC_FLASHCTL_AT_BUF1_WRITE 0x0384 149 + #define BCMA_CC_FLASHCTL_AT_BUF2_WRITE 0x0387 150 + #define BCMA_CC_FLASHCTL_AT_BUF1_ERASE_PROGRAM 0x0283 151 + #define BCMA_CC_FLASHCTL_AT_BUF2_ERASE_PROGRAM 0x0286 152 + #define BCMA_CC_FLASHCTL_AT_BUF1_PROGRAM 0x0288 153 + #define BCMA_CC_FLASHCTL_AT_BUF2_PROGRAM 0x0289 154 + #define BCMA_CC_FLASHCTL_AT_PAGE_ERASE 0x0281 155 + #define BCMA_CC_FLASHCTL_AT_BLOCK_ERASE 0x0250 156 + #define BCMA_CC_FLASHCTL_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382 157 + #define BCMA_CC_FLASHCTL_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385 158 + #define BCMA_CC_FLASHCTL_AT_BUF1_LOAD 0x0253 159 + #define BCMA_CC_FLASHCTL_AT_BUF2_LOAD 0x0255 160 + #define BCMA_CC_FLASHCTL_AT_BUF1_COMPARE 0x0260 161 + #define BCMA_CC_FLASHCTL_AT_BUF2_COMPARE 0x0261 162 + #define BCMA_CC_FLASHCTL_AT_BUF1_REPROGRAM 0x0258 163 + #define BCMA_CC_FLASHCTL_AT_BUF2_REPROGRAM 0x0259 128 164 #define BCMA_CC_FLASHADDR 0x0044 129 165 #define BCMA_CC_FLASHDATA 0x0048 166 + /* Status register bits for ST flashes */ 167 + #define BCMA_CC_FLASHDATA_ST_WIP 0x01 /* Write In Progress */ 168 + #define BCMA_CC_FLASHDATA_ST_WEL 0x02 /* Write Enable Latch */ 169 + #define BCMA_CC_FLASHDATA_ST_BP_MASK 0x1c /* Block Protect */ 170 + #define BCMA_CC_FLASHDATA_ST_BP_SHIFT 2 171 + #define BCMA_CC_FLASHDATA_ST_SRWD 0x80 /* Status Register Write Disable */ 172 + /* Status register bits for Atmel flashes */ 173 + #define BCMA_CC_FLASHDATA_AT_READY 0x80 174 + #define BCMA_CC_FLASHDATA_AT_MISMATCH 0x40 175 + #define BCMA_CC_FLASHDATA_AT_ID_MASK 0x38 176 + #define BCMA_CC_FLASHDATA_AT_ID_SHIFT 3 130 177 #define BCMA_CC_BCAST_ADDR 0x0050 131 178 #define BCMA_CC_BCAST_DATA 0x0054 132 179 #define BCMA_CC_GPIOPULLUP 0x0058 /* Rev >= 20 only */
+100
include/linux/bcma/bcma_driver_gmac_cmn.h
··· 1 + #ifndef LINUX_BCMA_DRIVER_GMAC_CMN_H_ 2 + #define LINUX_BCMA_DRIVER_GMAC_CMN_H_ 3 + 4 + #include <linux/types.h> 5 + 6 + #define BCMA_GMAC_CMN_STAG0 0x000 7 + #define BCMA_GMAC_CMN_STAG1 0x004 8 + #define BCMA_GMAC_CMN_STAG2 0x008 9 + #define BCMA_GMAC_CMN_STAG3 0x00C 10 + #define BCMA_GMAC_CMN_PARSER_CTL 0x020 11 + #define BCMA_GMAC_CMN_MIB_MAX_LEN 0x024 12 + #define BCMA_GMAC_CMN_PHY_ACCESS 0x100 13 + #define BCMA_GMAC_CMN_PA_DATA_MASK 0x0000ffff 14 + #define BCMA_GMAC_CMN_PA_ADDR_MASK 0x001f0000 15 + #define BCMA_GMAC_CMN_PA_ADDR_SHIFT 16 16 + #define BCMA_GMAC_CMN_PA_REG_MASK 0x1f000000 17 + #define BCMA_GMAC_CMN_PA_REG_SHIFT 24 18 + #define BCMA_GMAC_CMN_PA_WRITE 0x20000000 19 + #define BCMA_GMAC_CMN_PA_START 0x40000000 20 + #define BCMA_GMAC_CMN_PHY_CTL 0x104 21 + #define BCMA_GMAC_CMN_PC_EPA_MASK 0x0000001f 22 + #define BCMA_GMAC_CMN_PC_MCT_MASK 0x007f0000 23 + #define BCMA_GMAC_CMN_PC_MCT_SHIFT 16 24 + #define BCMA_GMAC_CMN_PC_MTE 0x00800000 25 + #define BCMA_GMAC_CMN_GMAC0_RGMII_CTL 0x110 26 + #define BCMA_GMAC_CMN_CFP_ACCESS 0x200 27 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA0 0x210 28 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA1 0x214 29 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA2 0x218 30 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA3 0x21C 31 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA4 0x220 32 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA5 0x224 33 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA6 0x228 34 + #define BCMA_GMAC_CMN_CFP_TCAM_DATA7 0x22C 35 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK0 0x230 36 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK1 0x234 37 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK2 0x238 38 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK3 0x23C 39 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK4 0x240 40 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK5 0x244 41 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK6 0x248 42 + #define BCMA_GMAC_CMN_CFP_TCAM_MASK7 0x24C 43 + #define BCMA_GMAC_CMN_CFP_ACTION_DATA 0x250 44 + #define BCMA_GMAC_CMN_TCAM_BIST_CTL 0x2A0 45 + #define BCMA_GMAC_CMN_TCAM_BIST_STATUS 0x2A4 46 + #define BCMA_GMAC_CMN_TCAM_CMP_STATUS 0x2A8 47 + #define BCMA_GMAC_CMN_TCAM_DISABLE 0x2AC 48 + #define BCMA_GMAC_CMN_TCAM_TEST_CTL 0x2F0 49 + #define BCMA_GMAC_CMN_UDF_0_A3_A0 0x300 50 + #define BCMA_GMAC_CMN_UDF_0_A7_A4 0x304 51 + #define BCMA_GMAC_CMN_UDF_0_A8 0x308 52 + #define BCMA_GMAC_CMN_UDF_1_A3_A0 0x310 53 + #define BCMA_GMAC_CMN_UDF_1_A7_A4 0x314 54 + #define BCMA_GMAC_CMN_UDF_1_A8 0x318 55 + #define BCMA_GMAC_CMN_UDF_2_A3_A0 0x320 56 + #define BCMA_GMAC_CMN_UDF_2_A7_A4 0x324 57 + #define BCMA_GMAC_CMN_UDF_2_A8 0x328 58 + #define BCMA_GMAC_CMN_UDF_0_B3_B0 0x330 59 + #define BCMA_GMAC_CMN_UDF_0_B7_B4 0x334 60 + #define BCMA_GMAC_CMN_UDF_0_B8 0x338 61 + #define BCMA_GMAC_CMN_UDF_1_B3_B0 0x340 62 + #define BCMA_GMAC_CMN_UDF_1_B7_B4 0x344 63 + #define BCMA_GMAC_CMN_UDF_1_B8 0x348 64 + #define BCMA_GMAC_CMN_UDF_2_B3_B0 0x350 65 + #define BCMA_GMAC_CMN_UDF_2_B7_B4 0x354 66 + #define BCMA_GMAC_CMN_UDF_2_B8 0x358 67 + #define BCMA_GMAC_CMN_UDF_0_C3_C0 0x360 68 + #define BCMA_GMAC_CMN_UDF_0_C7_C4 0x364 69 + #define BCMA_GMAC_CMN_UDF_0_C8 0x368 70 + #define BCMA_GMAC_CMN_UDF_1_C3_C0 0x370 71 + #define BCMA_GMAC_CMN_UDF_1_C7_C4 0x374 72 + #define BCMA_GMAC_CMN_UDF_1_C8 0x378 73 + #define BCMA_GMAC_CMN_UDF_2_C3_C0 0x380 74 + #define BCMA_GMAC_CMN_UDF_2_C7_C4 0x384 75 + #define BCMA_GMAC_CMN_UDF_2_C8 0x388 76 + #define BCMA_GMAC_CMN_UDF_0_D3_D0 0x390 77 + #define BCMA_GMAC_CMN_UDF_0_D7_D4 0x394 78 + #define BCMA_GMAC_CMN_UDF_0_D11_D8 0x394 79 + 80 + struct bcma_drv_gmac_cmn { 81 + struct bcma_device *core; 82 + 83 + /* Drivers accessing BCMA_GMAC_CMN_PHY_ACCESS and 84 + * BCMA_GMAC_CMN_PHY_CTL need to take that mutex first. */ 85 + struct mutex phy_mutex; 86 + }; 87 + 88 + /* Register access */ 89 + #define gmac_cmn_read16(gc, offset) bcma_read16((gc)->core, offset) 90 + #define gmac_cmn_read32(gc, offset) bcma_read32((gc)->core, offset) 91 + #define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val) 92 + #define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val) 93 + 94 + #ifdef CONFIG_BCMA_DRIVER_GMAC_CMN 95 + extern void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc); 96 + #else 97 + static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { } 98 + #endif 99 + 100 + #endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */
+53
include/linux/nl80211.h
··· 771 771 * @NL80211_ATTR_IFNAME: network interface name 772 772 * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype 773 773 * 774 + * @NL80211_ATTR_WDEV: wireless device identifier, used for pseudo-devices 775 + * that don't have a netdev (u64) 776 + * 774 777 * @NL80211_ATTR_MAC: MAC address (various uses) 775 778 * 776 779 * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of ··· 1245 1242 * @NL80211_ATTR_BG_SCAN_PERIOD: Background scan period in seconds 1246 1243 * or 0 to disable background scan. 1247 1244 * 1245 + * @NL80211_ATTR_USER_REG_HINT_TYPE: type of regulatory hint passed from 1246 + * userspace. If unset it is assumed the hint comes directly from 1247 + * a user. If set code could specify exactly what type of source 1248 + * was used to provide the hint. For the different types of 1249 + * allowed user regulatory hints see nl80211_user_reg_hint_type. 1250 + * 1248 1251 * @NL80211_ATTR_MAX: highest attribute number currently defined 1249 1252 * @__NL80211_ATTR_AFTER_LAST: internal use 1250 1253 */ ··· 1502 1493 1503 1494 NL80211_ATTR_BG_SCAN_PERIOD, 1504 1495 1496 + NL80211_ATTR_WDEV, 1497 + 1498 + NL80211_ATTR_USER_REG_HINT_TYPE, 1499 + 1505 1500 /* add attributes here, update the policy in nl80211.c */ 1506 1501 1507 1502 __NL80211_ATTR_AFTER_LAST, ··· 1557 1544 1558 1545 /* default RSSI threshold for scan results if none specified. */ 1559 1546 #define NL80211_SCAN_RSSI_THOLD_OFF -300 1547 + 1548 + #define NL80211_CQM_TXE_MAX_INTVL 1800 1560 1549 1561 1550 /** 1562 1551 * enum nl80211_iftype - (virtual) interface types ··· 2066 2051 NL80211_DFS_FCC = 1, 2067 2052 NL80211_DFS_ETSI = 2, 2068 2053 NL80211_DFS_JP = 3, 2054 + }; 2055 + 2056 + /** 2057 + * enum nl80211_user_reg_hint_type - type of user regulatory hint 2058 + * 2059 + * @NL80211_USER_REG_HINT_USER: a user sent the hint. This is always 2060 + * assumed if the attribute is not set. 2061 + * @NL80211_USER_REG_HINT_CELL_BASE: the hint comes from a cellular 2062 + * base station. Device drivers that have been tested to work 2063 + * properly to support this type of hint can enable these hints 2064 + * by setting the NL80211_FEATURE_CELL_BASE_REG_HINTS feature 2065 + * capability on the struct wiphy. The wireless core will 2066 + * ignore all cell base station hints until at least one device 2067 + * present has been registered with the wireless core that 2068 + * has listed NL80211_FEATURE_CELL_BASE_REG_HINTS as a 2069 + * supported feature. 2070 + */ 2071 + enum nl80211_user_reg_hint_type { 2072 + NL80211_USER_REG_HINT_USER = 0, 2073 + NL80211_USER_REG_HINT_CELL_BASE = 1, 2069 2074 }; 2070 2075 2071 2076 /** ··· 2619 2584 * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event 2620 2585 * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many 2621 2586 * consecutive packets were not acknowledged by the peer 2587 + * @NL80211_ATTR_CQM_TXE_RATE: TX error rate in %. Minimum % of TX failures 2588 + * during the given %NL80211_ATTR_CQM_TXE_INTVL before an 2589 + * %NL80211_CMD_NOTIFY_CQM with reported %NL80211_ATTR_CQM_TXE_RATE and 2590 + * %NL80211_ATTR_CQM_TXE_PKTS is generated. 2591 + * @NL80211_ATTR_CQM_TXE_PKTS: number of attempted packets in a given 2592 + * %NL80211_ATTR_CQM_TXE_INTVL before %NL80211_ATTR_CQM_TXE_RATE is 2593 + * checked. 2594 + * @NL80211_ATTR_CQM_TXE_INTVL: interval in seconds. Specifies the periodic 2595 + * interval in which %NL80211_ATTR_CQM_TXE_PKTS and 2596 + * %NL80211_ATTR_CQM_TXE_RATE must be satisfied before generating an 2597 + * %NL80211_CMD_NOTIFY_CQM. Set to 0 to turn off TX error reporting. 2622 2598 * @__NL80211_ATTR_CQM_AFTER_LAST: internal 2623 2599 * @NL80211_ATTR_CQM_MAX: highest key attribute 2624 2600 */ ··· 2639 2593 NL80211_ATTR_CQM_RSSI_HYST, 2640 2594 NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, 2641 2595 NL80211_ATTR_CQM_PKT_LOSS_EVENT, 2596 + NL80211_ATTR_CQM_TXE_RATE, 2597 + NL80211_ATTR_CQM_TXE_PKTS, 2598 + NL80211_ATTR_CQM_TXE_INTVL, 2642 2599 2643 2600 /* keep last */ 2644 2601 __NL80211_ATTR_CQM_AFTER_LAST, ··· 2991 2942 * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates. 2992 2943 * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up 2993 2944 * the connected inactive stations in AP mode. 2945 + * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested 2946 + * to work properly to suppport receiving regulatory hints from 2947 + * cellular base stations. 2994 2948 */ 2995 2949 enum nl80211_feature_flags { 2996 2950 NL80211_FEATURE_SK_TX_STATUS = 1 << 0, 2997 2951 NL80211_FEATURE_HT_IBSS = 1 << 1, 2998 2952 NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2, 2953 + NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3, 2999 2954 }; 3000 2955 3001 2956 /**
+6 -5
include/net/bluetooth/hci.h
··· 139 139 #define HCIINQUIRY _IOR('H', 240, int) 140 140 141 141 /* HCI timeouts */ 142 - #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ 143 - #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ 144 - #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 145 - #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ 146 - #define HCI_ACL_TX_TIMEOUT (45000) /* 45 seconds */ 142 + #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ 143 + #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */ 144 + #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */ 145 + #define HCI_CMD_TIMEOUT msecs_to_jiffies(1000) /* 1 second */ 146 + #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */ 147 + #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ 147 148 148 149 /* HCI data types */ 149 150 #define HCI_COMMAND_PKT 0x01
+7 -1
include/net/bluetooth/hci_core.h
··· 587 587 588 588 static inline void hci_conn_hold(struct hci_conn *conn) 589 589 { 590 + BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt), 591 + atomic_read(&conn->refcnt) + 1); 592 + 590 593 atomic_inc(&conn->refcnt); 591 594 cancel_delayed_work(&conn->disc_work); 592 595 } 593 596 594 597 static inline void hci_conn_put(struct hci_conn *conn) 595 598 { 599 + BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt), 600 + atomic_read(&conn->refcnt) - 1); 601 + 596 602 if (atomic_dec_and_test(&conn->refcnt)) { 597 603 unsigned long timeo; 598 604 if (conn->type == ACL_LINK || conn->type == LE_LINK) { 599 605 del_timer(&conn->idle_timer); 600 606 if (conn->state == BT_CONNECTED) { 601 - timeo = msecs_to_jiffies(conn->disc_timeout); 607 + timeo = conn->disc_timeout; 602 608 if (!conn->out) 603 609 timeo *= 2; 604 610 } else {
+5
include/net/bluetooth/l2cap.h
··· 464 464 465 465 __u16 tx_win; 466 466 __u16 tx_win_max; 467 + __u16 ack_win; 467 468 __u8 max_tx; 468 469 __u16 retrans_timeout; 469 470 __u16 monitor_timeout; ··· 673 672 674 673 static inline void l2cap_chan_hold(struct l2cap_chan *c) 675 674 { 675 + BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt)); 676 + 676 677 atomic_inc(&c->refcnt); 677 678 } 678 679 679 680 static inline void l2cap_chan_put(struct l2cap_chan *c) 680 681 { 682 + BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt)); 683 + 681 684 if (atomic_dec_and_test(&c->refcnt)) 682 685 kfree(c); 683 686 }
+1 -1
include/net/bluetooth/mgmt.h
··· 444 444 struct mgmt_ev_device_found { 445 445 struct mgmt_addr_info addr; 446 446 __s8 rssi; 447 - __u8 flags[4]; 447 + __le32 flags; 448 448 __le16 eir_len; 449 449 __u8 eir[0]; 450 450 } __packed;
+72 -35
include/net/cfg80211.h
··· 999 999 * @ie_len: length of ie in octets 1000 1000 * @rates: bitmap of rates to advertise for each band 1001 1001 * @wiphy: the wiphy this was for 1002 - * @dev: the interface 1002 + * @wdev: the wireless device to scan for 1003 1003 * @aborted: (internal) scan request was notified as aborted 1004 1004 * @no_cck: used to send probe requests at non CCK rate in 2GHz band 1005 1005 */ ··· 1012 1012 1013 1013 u32 rates[IEEE80211_NUM_BANDS]; 1014 1014 1015 + struct wireless_dev *wdev; 1016 + 1015 1017 /* internal */ 1016 1018 struct wiphy *wiphy; 1017 - struct net_device *dev; 1018 1019 bool aborted; 1019 1020 bool no_cck; 1020 1021 ··· 1436 1435 * 1437 1436 * @add_virtual_intf: create a new virtual interface with the given name, 1438 1437 * must set the struct wireless_dev's iftype. Beware: You must create 1439 - * the new netdev in the wiphy's network namespace! Returns the netdev, 1440 - * or an ERR_PTR. 1438 + * the new netdev in the wiphy's network namespace! Returns the struct 1439 + * wireless_dev, or an ERR_PTR. 1441 1440 * 1442 - * @del_virtual_intf: remove the virtual interface determined by ifindex. 1441 + * @del_virtual_intf: remove the virtual interface 1443 1442 * 1444 1443 * @change_virtual_intf: change type/configuration of virtual interface, 1445 1444 * keep the struct wireless_dev's iftype updated. ··· 1504 1503 * interfaces are active this callback should reject the configuration. 1505 1504 * If no interfaces are active or the device is down, the channel should 1506 1505 * be stored for when a monitor interface becomes active. 1507 - * @set_monitor_enabled: Notify driver that there are only monitor 1508 - * interfaces running. 1509 1506 * 1510 1507 * @scan: Request to do a scan. If returning zero, the scan request is given 1511 1508 * the driver, and will be valid until passed to cfg80211_scan_done(). ··· 1573 1574 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 1574 1575 * allows the driver to adjust the dynamic ps timeout value. 1575 1576 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. 1577 + * @set_cqm_txe_config: Configure connection quality monitor TX error 1578 + * thresholds. 1576 1579 * @sched_scan_start: Tell the driver to start a scheduled scan. 1577 1580 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled 1578 1581 * scan. The driver_initiated flag specifies whether the driver ··· 1612 1611 * @get_et_strings: Ethtool API to get a set of strings to describe stats 1613 1612 * and perhaps other supported types of ethtool data-sets. 1614 1613 * See @ethtool_ops.get_strings 1614 + * 1615 + * @get_channel: Get the current operating channel for the virtual interface. 1616 + * For monitor interfaces, it should return %NULL unless there's a single 1617 + * current monitoring channel. 1615 1618 */ 1616 1619 struct cfg80211_ops { 1617 1620 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); 1618 1621 int (*resume)(struct wiphy *wiphy); 1619 1622 void (*set_wakeup)(struct wiphy *wiphy, bool enabled); 1620 1623 1621 - struct net_device * (*add_virtual_intf)(struct wiphy *wiphy, 1622 - char *name, 1623 - enum nl80211_iftype type, 1624 - u32 *flags, 1625 - struct vif_params *params); 1626 - int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); 1624 + struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy, 1625 + char *name, 1626 + enum nl80211_iftype type, 1627 + u32 *flags, 1628 + struct vif_params *params); 1629 + int (*del_virtual_intf)(struct wiphy *wiphy, 1630 + struct wireless_dev *wdev); 1627 1631 int (*change_virtual_intf)(struct wiphy *wiphy, 1628 1632 struct net_device *dev, 1629 1633 enum nl80211_iftype type, u32 *flags, ··· 1705 1699 struct ieee80211_channel *chan, 1706 1700 enum nl80211_channel_type channel_type); 1707 1701 1708 - int (*scan)(struct wiphy *wiphy, struct net_device *dev, 1702 + int (*scan)(struct wiphy *wiphy, 1709 1703 struct cfg80211_scan_request *request); 1710 1704 1711 1705 int (*auth)(struct wiphy *wiphy, struct net_device *dev, ··· 1759 1753 int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev); 1760 1754 1761 1755 int (*remain_on_channel)(struct wiphy *wiphy, 1762 - struct net_device *dev, 1756 + struct wireless_dev *wdev, 1763 1757 struct ieee80211_channel *chan, 1764 1758 enum nl80211_channel_type channel_type, 1765 1759 unsigned int duration, 1766 1760 u64 *cookie); 1767 1761 int (*cancel_remain_on_channel)(struct wiphy *wiphy, 1768 - struct net_device *dev, 1762 + struct wireless_dev *wdev, 1769 1763 u64 cookie); 1770 1764 1771 - int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev, 1765 + int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev, 1772 1766 struct ieee80211_channel *chan, bool offchan, 1773 1767 enum nl80211_channel_type channel_type, 1774 1768 bool channel_type_valid, unsigned int wait, 1775 1769 const u8 *buf, size_t len, bool no_cck, 1776 1770 bool dont_wait_for_ack, u64 *cookie); 1777 1771 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, 1778 - struct net_device *dev, 1772 + struct wireless_dev *wdev, 1779 1773 u64 cookie); 1780 1774 1781 1775 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, ··· 1785 1779 struct net_device *dev, 1786 1780 s32 rssi_thold, u32 rssi_hyst); 1787 1781 1782 + int (*set_cqm_txe_config)(struct wiphy *wiphy, 1783 + struct net_device *dev, 1784 + u32 rate, u32 pkts, u32 intvl); 1785 + 1788 1786 void (*mgmt_frame_register)(struct wiphy *wiphy, 1789 - struct net_device *dev, 1787 + struct wireless_dev *wdev, 1790 1788 u16 frame_type, bool reg); 1791 1789 1792 1790 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); ··· 1828 1818 void (*get_et_strings)(struct wiphy *wiphy, struct net_device *dev, 1829 1819 u32 sset, u8 *data); 1830 1820 1831 - void (*set_monitor_enabled)(struct wiphy *wiphy, bool enabled); 1821 + struct ieee80211_channel * 1822 + (*get_channel)(struct wiphy *wiphy, 1823 + struct wireless_dev *wdev, 1824 + enum nl80211_channel_type *type); 1832 1825 }; 1833 1826 1834 1827 /* ··· 2354 2341 struct cfg80211_cached_keys; 2355 2342 2356 2343 /** 2357 - * struct wireless_dev - wireless per-netdev state 2344 + * struct wireless_dev - wireless device state 2358 2345 * 2359 - * This structure must be allocated by the driver/stack 2360 - * that uses the ieee80211_ptr field in struct net_device 2361 - * (this is intentional so it can be allocated along with 2362 - * the netdev.) 2346 + * For netdevs, this structure must be allocated by the driver 2347 + * that uses the ieee80211_ptr field in struct net_device (this 2348 + * is intentional so it can be allocated along with the netdev.) 2349 + * It need not be registered then as netdev registration will 2350 + * be intercepted by cfg80211 to see the new wireless device. 2351 + * 2352 + * For non-netdev uses, it must also be allocated by the driver 2353 + * in response to the cfg80211 callbacks that require it, as 2354 + * there's no netdev registration in that case it may not be 2355 + * allocated outside of callback operations that return it. 2363 2356 * 2364 2357 * @wiphy: pointer to hardware description 2365 2358 * @iftype: interface type 2366 2359 * @list: (private) Used to collect the interfaces 2367 - * @netdev: (private) Used to reference back to the netdev 2360 + * @netdev: (private) Used to reference back to the netdev, may be %NULL 2361 + * @identifier: (private) Identifier used in nl80211 to identify this 2362 + * wireless device if it has no netdev 2368 2363 * @current_bss: (private) Used by the internal configuration code 2369 2364 * @channel: (private) Used by the internal configuration code to track 2370 2365 * the user-set AP, monitor and WDS channel ··· 2403 2382 /* the remainder of this struct should be private to cfg80211 */ 2404 2383 struct list_head list; 2405 2384 struct net_device *netdev; 2385 + 2386 + u32 identifier; 2406 2387 2407 2388 struct list_head mgmt_registrations; 2408 2389 spinlock_t mgmt_registrations_lock; ··· 3292 3269 3293 3270 /** 3294 3271 * cfg80211_ready_on_channel - notification of remain_on_channel start 3295 - * @dev: network device 3272 + * @wdev: wireless device 3296 3273 * @cookie: the request cookie 3297 3274 * @chan: The current channel (from remain_on_channel request) 3298 3275 * @channel_type: Channel type ··· 3300 3277 * channel 3301 3278 * @gfp: allocation flags 3302 3279 */ 3303 - void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, 3280 + void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, 3304 3281 struct ieee80211_channel *chan, 3305 3282 enum nl80211_channel_type channel_type, 3306 3283 unsigned int duration, gfp_t gfp); 3307 3284 3308 3285 /** 3309 3286 * cfg80211_remain_on_channel_expired - remain_on_channel duration expired 3310 - * @dev: network device 3287 + * @wdev: wireless device 3311 3288 * @cookie: the request cookie 3312 3289 * @chan: The current channel (from remain_on_channel request) 3313 3290 * @channel_type: Channel type 3314 3291 * @gfp: allocation flags 3315 3292 */ 3316 - void cfg80211_remain_on_channel_expired(struct net_device *dev, 3317 - u64 cookie, 3293 + void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, 3318 3294 struct ieee80211_channel *chan, 3319 3295 enum nl80211_channel_type channel_type, 3320 3296 gfp_t gfp); ··· 3341 3319 3342 3320 /** 3343 3321 * cfg80211_rx_mgmt - notification of received, unprocessed management frame 3344 - * @dev: network device 3322 + * @wdev: wireless device receiving the frame 3345 3323 * @freq: Frequency on which the frame was received in MHz 3346 3324 * @sig_dbm: signal strength in mBm, or 0 if unknown 3347 3325 * @buf: Management frame (header + body) ··· 3356 3334 * This function is called whenever an Action frame is received for a station 3357 3335 * mode interface, but is not processed in kernel. 3358 3336 */ 3359 - bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_dbm, 3337 + bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, 3360 3338 const u8 *buf, size_t len, gfp_t gfp); 3361 3339 3362 3340 /** 3363 3341 * cfg80211_mgmt_tx_status - notification of TX status for management frame 3364 - * @dev: network device 3342 + * @wdev: wireless device receiving the frame 3365 3343 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx() 3366 3344 * @buf: Management frame (header + body) 3367 3345 * @len: length of the frame data ··· 3372 3350 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the 3373 3351 * transmission attempt. 3374 3352 */ 3375 - void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, 3353 + void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, 3376 3354 const u8 *buf, size_t len, bool ack, gfp_t gfp); 3377 3355 3378 3356 ··· 3400 3378 */ 3401 3379 void cfg80211_cqm_pktloss_notify(struct net_device *dev, 3402 3380 const u8 *peer, u32 num_packets, gfp_t gfp); 3381 + 3382 + /** 3383 + * cfg80211_cqm_txe_notify - TX error rate event 3384 + * @dev: network device 3385 + * @peer: peer's MAC address 3386 + * @num_packets: how many packets were lost 3387 + * @rate: % of packets which failed transmission 3388 + * @intvl: interval (in s) over which the TX failure threshold was breached. 3389 + * @gfp: context flags 3390 + * 3391 + * Notify userspace when configured % TX failures over number of packets in a 3392 + * given interval is exceeded. 3393 + */ 3394 + void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer, 3395 + u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); 3403 3396 3404 3397 /** 3405 3398 * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
+15 -25
include/net/mac80211.h
··· 233 233 * valid in station mode only while @assoc is true and if also 234 234 * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf 235 235 * @ps_dtim_period) 236 - * @last_tsf: last beacon's/probe response's TSF timestamp (could be old 236 + * @sync_tsf: last beacon's/probe response's TSF timestamp (could be old 237 237 * as it may have been received during scanning long ago) 238 + * @sync_device_ts: the device timestamp corresponding to the sync_tsf, 239 + * the driver/device can use this to calculate synchronisation 238 240 * @beacon_int: beacon interval 239 241 * @assoc_capability: capabilities taken from assoc resp 240 242 * @basic_rates: bitmap of basic rates, each bit stands for an ··· 283 281 u8 dtim_period; 284 282 u16 beacon_int; 285 283 u16 assoc_capability; 286 - u64 last_tsf; 284 + u64 sync_tsf; 285 + u32 sync_device_ts; 287 286 u32 basic_rates; 288 287 int mcast_rate[IEEE80211_NUM_BANDS]; 289 288 u16 ht_operation_mode; ··· 699 696 * 700 697 * @mactime: value in microseconds of the 64-bit Time Synchronization Function 701 698 * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. 699 + * @device_timestamp: arbitrary timestamp for the device, mac80211 doesn't use 700 + * it but can store it and pass it back to the driver for synchronisation 702 701 * @band: the active band when this frame was received 703 702 * @freq: frequency the radio was tuned to when receiving this frame, in MHz 704 703 * @signal: signal strength when receiving this frame, either in dBm, in dB or ··· 714 709 */ 715 710 struct ieee80211_rx_status { 716 711 u64 mactime; 717 - enum ieee80211_band band; 718 - int freq; 719 - int signal; 720 - int antenna; 721 - int rate_idx; 722 - int flag; 723 - unsigned int rx_flags; 712 + u32 device_timestamp; 713 + u16 flag; 714 + u16 freq; 715 + u8 rate_idx; 716 + u8 rx_flags; 717 + u8 band; 718 + u8 antenna; 719 + s8 signal; 724 720 }; 725 721 726 722 /** ··· 3596 3590 */ 3597 3591 void ieee80211_request_smps(struct ieee80211_vif *vif, 3598 3592 enum ieee80211_smps_mode smps_mode); 3599 - 3600 - /** 3601 - * ieee80211_key_removed - disable hw acceleration for key 3602 - * @key_conf: The key hw acceleration should be disabled for 3603 - * 3604 - * This allows drivers to indicate that the given key has been 3605 - * removed from hardware acceleration, due to a new key that 3606 - * was added. Don't use this if the key can continue to be used 3607 - * for TX, if the key restriction is on RX only it is permitted 3608 - * to keep the key for TX only and not call this function. 3609 - * 3610 - * Due to locking constraints, it may only be called during 3611 - * @set_key. This function must be allowed to sleep, and the 3612 - * key it tries to disable may still be used until it returns. 3613 - */ 3614 - void ieee80211_key_removed(struct ieee80211_key_conf *key_conf); 3615 3593 3616 3594 /** 3617 3595 * ieee80211_ready_on_channel - notification of remain-on-channel start
+5
include/net/regulatory.h
··· 52 52 * DFS master operation on a known DFS region (NL80211_DFS_*), 53 53 * dfs_region represents that region. Drivers can use this and the 54 54 * @alpha2 to adjust their device's DFS parameters as required. 55 + * @user_reg_hint_type: if the @initiator was of type 56 + * %NL80211_REGDOM_SET_BY_USER, this classifies the type 57 + * of hint passed. This could be any of the %NL80211_USER_REG_HINT_* 58 + * types. 55 59 * @intersect: indicates whether the wireless core should intersect 56 60 * the requested regulatory domain with the presently set regulatory 57 61 * domain. ··· 74 70 struct regulatory_request { 75 71 int wiphy_idx; 76 72 enum nl80211_reg_initiator initiator; 73 + enum nl80211_user_reg_hint_type user_reg_hint_type; 77 74 char alpha2[2]; 78 75 u8 dfs_region; 79 76 bool intersect;
+2 -2
net/bluetooth/a2mp.c
··· 501 501 /* AMP Manager functions */ 502 502 void amp_mgr_get(struct amp_mgr *mgr) 503 503 { 504 - BT_DBG("mgr %p", mgr); 504 + BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); 505 505 506 506 kref_get(&mgr->kref); 507 507 } ··· 517 517 518 518 int amp_mgr_put(struct amp_mgr *mgr) 519 519 { 520 - BT_DBG("mgr %p", mgr); 520 + BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); 521 521 522 522 return kref_put(&mgr->kref, &amp_mgr_destroy); 523 523 }
+24 -23
net/bluetooth/hci_conn.c
··· 107 107 { 108 108 struct hci_cp_create_conn_cancel cp; 109 109 110 - BT_DBG("%p", conn); 110 + BT_DBG("hcon %p", conn); 111 111 112 112 if (conn->hdev->hci_ver < BLUETOOTH_VER_1_2) 113 113 return; ··· 120 120 { 121 121 struct hci_cp_disconnect cp; 122 122 123 - BT_DBG("%p", conn); 123 + BT_DBG("hcon %p", conn); 124 124 125 125 conn->state = BT_DISCONN; 126 126 ··· 134 134 struct hci_dev *hdev = conn->hdev; 135 135 struct hci_cp_add_sco cp; 136 136 137 - BT_DBG("%p", conn); 137 + BT_DBG("hcon %p", conn); 138 138 139 139 conn->state = BT_CONNECT; 140 140 conn->out = true; ··· 152 152 struct hci_dev *hdev = conn->hdev; 153 153 struct hci_cp_setup_sync_conn cp; 154 154 155 - BT_DBG("%p", conn); 155 + BT_DBG("hcon %p", conn); 156 156 157 157 conn->state = BT_CONNECT; 158 158 conn->out = true; ··· 196 196 struct hci_dev *hdev = conn->hdev; 197 197 struct hci_cp_le_start_enc cp; 198 198 199 - BT_DBG("%p", conn); 199 + BT_DBG("hcon %p", conn); 200 200 201 201 memset(&cp, 0, sizeof(cp)); 202 202 ··· 213 213 { 214 214 struct hci_conn *sco = conn->link; 215 215 216 - BT_DBG("%p", conn); 217 - 218 216 if (!sco) 219 217 return; 218 + 219 + BT_DBG("hcon %p", conn); 220 220 221 221 if (!status) { 222 222 if (lmp_esco_capable(conn->hdev)) ··· 235 235 disc_work.work); 236 236 __u8 reason; 237 237 238 - BT_DBG("conn %p state %s", conn, state_to_string(conn->state)); 238 + BT_DBG("hcon %p state %s", conn, state_to_string(conn->state)); 239 239 240 240 if (atomic_read(&conn->refcnt)) 241 241 return; ··· 266 266 { 267 267 struct hci_dev *hdev = conn->hdev; 268 268 269 - BT_DBG("conn %p mode %d", conn, conn->mode); 269 + BT_DBG("hcon %p mode %d", conn, conn->mode); 270 270 271 271 if (test_bit(HCI_RAW, &hdev->flags)) 272 272 return; ··· 301 301 { 302 302 struct hci_conn *conn = (void *) arg; 303 303 304 - BT_DBG("conn %p mode %d", conn, conn->mode); 304 + BT_DBG("hcon %p mode %d", conn, conn->mode); 305 305 306 306 hci_conn_enter_sniff_mode(conn); 307 307 } ··· 382 382 { 383 383 struct hci_dev *hdev = conn->hdev; 384 384 385 - BT_DBG("%s conn %p handle %d", hdev->name, conn, conn->handle); 385 + BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle); 386 386 387 387 del_timer(&conn->idle_timer); 388 388 ··· 442 442 443 443 list_for_each_entry(d, &hci_dev_list, list) { 444 444 if (!test_bit(HCI_UP, &d->flags) || 445 - test_bit(HCI_RAW, &d->flags)) 445 + test_bit(HCI_RAW, &d->flags) || 446 + d->dev_type != HCI_BREDR) 446 447 continue; 447 448 448 449 /* Simple routing: ··· 558 557 /* Check link security requirement */ 559 558 int hci_conn_check_link_mode(struct hci_conn *conn) 560 559 { 561 - BT_DBG("conn %p", conn); 560 + BT_DBG("hcon %p", conn); 562 561 563 562 if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT)) 564 563 return 0; ··· 569 568 /* Authenticate remote device */ 570 569 static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) 571 570 { 572 - BT_DBG("conn %p", conn); 571 + BT_DBG("hcon %p", conn); 573 572 574 573 if (conn->pending_sec_level > sec_level) 575 574 sec_level = conn->pending_sec_level; ··· 603 602 /* Encrypt the the link */ 604 603 static void hci_conn_encrypt(struct hci_conn *conn) 605 604 { 606 - BT_DBG("conn %p", conn); 605 + BT_DBG("hcon %p", conn); 607 606 608 607 if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { 609 608 struct hci_cp_set_conn_encrypt cp; ··· 617 616 /* Enable security */ 618 617 int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) 619 618 { 620 - BT_DBG("conn %p", conn); 619 + BT_DBG("hcon %p", conn); 621 620 622 621 /* For sdp we don't need the link key. */ 623 622 if (sec_level == BT_SECURITY_SDP) ··· 670 669 /* Check secure link requirement */ 671 670 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level) 672 671 { 673 - BT_DBG("conn %p", conn); 672 + BT_DBG("hcon %p", conn); 674 673 675 674 if (sec_level != BT_SECURITY_HIGH) 676 675 return 1; /* Accept if non-secure is required */ ··· 685 684 /* Change link key */ 686 685 int hci_conn_change_link_key(struct hci_conn *conn) 687 686 { 688 - BT_DBG("conn %p", conn); 687 + BT_DBG("hcon %p", conn); 689 688 690 689 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { 691 690 struct hci_cp_change_conn_link_key cp; ··· 700 699 /* Switch role */ 701 700 int hci_conn_switch_role(struct hci_conn *conn, __u8 role) 702 701 { 703 - BT_DBG("conn %p", conn); 702 + BT_DBG("hcon %p", conn); 704 703 705 704 if (!role && conn->link_mode & HCI_LM_MASTER) 706 705 return 1; ··· 721 720 { 722 721 struct hci_dev *hdev = conn->hdev; 723 722 724 - BT_DBG("conn %p mode %d", conn, conn->mode); 723 + BT_DBG("hcon %p mode %d", conn, conn->mode); 725 724 726 725 if (test_bit(HCI_RAW, &hdev->flags)) 727 726 return; ··· 895 894 struct hci_dev *hdev = conn->hdev; 896 895 struct hci_chan *chan; 897 896 898 - BT_DBG("%s conn %p", hdev->name, conn); 897 + BT_DBG("%s hcon %p", hdev->name, conn); 899 898 900 899 chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL); 901 900 if (!chan) ··· 914 913 struct hci_conn *conn = chan->conn; 915 914 struct hci_dev *hdev = conn->hdev; 916 915 917 - BT_DBG("%s conn %p chan %p", hdev->name, conn, chan); 916 + BT_DBG("%s hcon %p chan %p", hdev->name, conn, chan); 918 917 919 918 list_del_rcu(&chan->list); 920 919 ··· 930 929 { 931 930 struct hci_chan *chan, *n; 932 931 933 - BT_DBG("conn %p", conn); 932 + BT_DBG("hcon %p", conn); 934 933 935 934 list_for_each_entry_safe(chan, n, &conn->chan_list, list) 936 935 hci_chan_del(chan);
+39 -38
net/bluetooth/hci_core.c
··· 33 33 #include <net/bluetooth/bluetooth.h> 34 34 #include <net/bluetooth/hci_core.h> 35 35 36 - #define AUTO_OFF_TIMEOUT 2000 37 - 38 36 static void hci_rx_work(struct work_struct *work); 39 37 static void hci_cmd_work(struct work_struct *work); 40 38 static void hci_tx_work(struct work_struct *work); ··· 59 61 60 62 void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result) 61 63 { 62 - BT_DBG("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result); 64 + BT_DBG("%s command 0x%4.4x result 0x%2.2x", hdev->name, cmd, result); 63 65 64 66 /* If this is the init phase check if the completed command matches 65 67 * the last init command, and if not just return. ··· 186 188 187 189 /* Mandatory initialization */ 188 190 189 - /* Reset */ 190 - if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { 191 - set_bit(HCI_RESET, &hdev->flags); 192 - hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); 193 - } 194 - 195 191 /* Read Local Supported Features */ 196 192 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL); 197 193 ··· 226 234 { 227 235 hdev->flow_ctl_mode = HCI_FLOW_CTL_MODE_BLOCK_BASED; 228 236 229 - /* Reset */ 230 - hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); 231 - 232 237 /* Read Local Version */ 233 238 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL); 234 239 ··· 250 261 queue_work(hdev->workqueue, &hdev->cmd_work); 251 262 } 252 263 skb_queue_purge(&hdev->driver_init); 264 + 265 + /* Reset */ 266 + if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) 267 + hci_reset_req(hdev, 0); 253 268 254 269 switch (hdev->dev_type) { 255 270 case HCI_BREDR: ··· 683 690 set_bit(HCI_INIT, &hdev->flags); 684 691 hdev->init_last_cmd = 0; 685 692 686 - ret = __hci_request(hdev, hci_init_req, 0, 687 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 693 + ret = __hci_request(hdev, hci_init_req, 0, HCI_INIT_TIMEOUT); 688 694 689 695 if (lmp_host_le_capable(hdev)) 690 696 ret = __hci_request(hdev, hci_le_init_req, 0, 691 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 697 + HCI_INIT_TIMEOUT); 692 698 693 699 clear_bit(HCI_INIT, &hdev->flags); 694 700 } ··· 774 782 if (!test_bit(HCI_RAW, &hdev->flags) && 775 783 test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { 776 784 set_bit(HCI_INIT, &hdev->flags); 777 - __hci_request(hdev, hci_reset_req, 0, 778 - msecs_to_jiffies(250)); 785 + __hci_request(hdev, hci_reset_req, 0, HCI_CMD_TIMEOUT); 779 786 clear_bit(HCI_INIT, &hdev->flags); 780 787 } 781 788 ··· 863 872 hdev->acl_cnt = 0; hdev->sco_cnt = 0; hdev->le_cnt = 0; 864 873 865 874 if (!test_bit(HCI_RAW, &hdev->flags)) 866 - ret = __hci_request(hdev, hci_reset_req, 0, 867 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 875 + ret = __hci_request(hdev, hci_reset_req, 0, HCI_INIT_TIMEOUT); 868 876 869 877 done: 870 878 hci_req_unlock(hdev); ··· 903 913 switch (cmd) { 904 914 case HCISETAUTH: 905 915 err = hci_request(hdev, hci_auth_req, dr.dev_opt, 906 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 916 + HCI_INIT_TIMEOUT); 907 917 break; 908 918 909 919 case HCISETENCRYPT: ··· 915 925 if (!test_bit(HCI_AUTH, &hdev->flags)) { 916 926 /* Auth must be enabled first */ 917 927 err = hci_request(hdev, hci_auth_req, dr.dev_opt, 918 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 928 + HCI_INIT_TIMEOUT); 919 929 if (err) 920 930 break; 921 931 } 922 932 923 933 err = hci_request(hdev, hci_encrypt_req, dr.dev_opt, 924 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 934 + HCI_INIT_TIMEOUT); 925 935 break; 926 936 927 937 case HCISETSCAN: 928 938 err = hci_request(hdev, hci_scan_req, dr.dev_opt, 929 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 939 + HCI_INIT_TIMEOUT); 930 940 break; 931 941 932 942 case HCISETLINKPOL: 933 943 err = hci_request(hdev, hci_linkpol_req, dr.dev_opt, 934 - msecs_to_jiffies(HCI_INIT_TIMEOUT)); 944 + HCI_INIT_TIMEOUT); 935 945 break; 936 946 937 947 case HCISETLINKMODE: ··· 1081 1091 return; 1082 1092 1083 1093 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1084 - schedule_delayed_work(&hdev->power_off, 1085 - msecs_to_jiffies(AUTO_OFF_TIMEOUT)); 1094 + schedule_delayed_work(&hdev->power_off, HCI_AUTO_OFF_TIMEOUT); 1086 1095 1087 1096 if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) 1088 1097 mgmt_index_added(hdev); ··· 1358 1369 } 1359 1370 1360 1371 /* HCI command timer function */ 1361 - static void hci_cmd_timer(unsigned long arg) 1372 + static void hci_cmd_timeout(unsigned long arg) 1362 1373 { 1363 1374 struct hci_dev *hdev = (void *) arg; 1364 1375 1365 - BT_ERR("%s command tx timeout", hdev->name); 1376 + if (hdev->sent_cmd) { 1377 + struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; 1378 + u16 opcode = __le16_to_cpu(sent->opcode); 1379 + 1380 + BT_ERR("%s command 0x%4.4x tx timeout", hdev->name, opcode); 1381 + } else { 1382 + BT_ERR("%s command tx timeout", hdev->name); 1383 + } 1384 + 1366 1385 atomic_set(&hdev->cmd_cnt, 1); 1367 1386 queue_work(hdev->workqueue, &hdev->cmd_work); 1368 1387 } ··· 1668 1671 1669 1672 init_waitqueue_head(&hdev->req_wait_q); 1670 1673 1671 - setup_timer(&hdev->cmd_timer, hci_cmd_timer, (unsigned long) hdev); 1674 + setup_timer(&hdev->cmd_timer, hci_cmd_timeout, (unsigned long) hdev); 1672 1675 1673 1676 hci_init_sysfs(hdev); 1674 1677 discovery_init(hdev); ··· 1743 1746 } 1744 1747 } 1745 1748 1746 - set_bit(HCI_AUTO_OFF, &hdev->dev_flags); 1747 1749 set_bit(HCI_SETUP, &hdev->dev_flags); 1750 + 1751 + if (hdev->dev_type != HCI_AMP) 1752 + set_bit(HCI_AUTO_OFF, &hdev->dev_flags); 1753 + 1748 1754 schedule_work(&hdev->power_on); 1749 1755 1750 1756 hci_notify(hdev, HCI_DEV_REG); ··· 2087 2087 struct hci_command_hdr *hdr; 2088 2088 struct sk_buff *skb; 2089 2089 2090 - BT_DBG("%s opcode 0x%x plen %d", hdev->name, opcode, plen); 2090 + BT_DBG("%s opcode 0x%4.4x plen %d", hdev->name, opcode, plen); 2091 2091 2092 2092 skb = bt_skb_alloc(len, GFP_ATOMIC); 2093 2093 if (!skb) { ··· 2129 2129 if (hdr->opcode != cpu_to_le16(opcode)) 2130 2130 return NULL; 2131 2131 2132 - BT_DBG("%s opcode 0x%x", hdev->name, opcode); 2132 + BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); 2133 2133 2134 2134 return hdev->sent_cmd->data + HCI_COMMAND_HDR_SIZE; 2135 2135 } ··· 2199 2199 struct hci_conn *conn = chan->conn; 2200 2200 struct hci_dev *hdev = conn->hdev; 2201 2201 2202 - BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags); 2202 + BT_DBG("%s chan %p flags 0x%4.4x", hdev->name, chan, flags); 2203 2203 2204 2204 skb->dev = (void *) hdev; 2205 2205 ··· 2455 2455 /* ACL tx timeout must be longer than maximum 2456 2456 * link supervision timeout (40.9 seconds) */ 2457 2457 if (!cnt && time_after(jiffies, hdev->acl_last_tx + 2458 - msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) 2458 + HCI_ACL_TX_TIMEOUT)) 2459 2459 hci_link_tx_to(hdev, ACL_LINK); 2460 2460 } 2461 2461 } ··· 2699 2699 flags = hci_flags(handle); 2700 2700 handle = hci_handle(handle); 2701 2701 2702 - BT_DBG("%s len %d handle 0x%x flags 0x%x", hdev->name, skb->len, 2702 + BT_DBG("%s len %d handle 0x%4.4x flags 0x%4.4x", hdev->name, skb->len, 2703 2703 handle, flags); 2704 2704 2705 2705 hdev->stat.acl_rx++; ··· 2741 2741 2742 2742 handle = __le16_to_cpu(hdr->handle); 2743 2743 2744 - BT_DBG("%s len %d handle 0x%x", hdev->name, skb->len, handle); 2744 + BT_DBG("%s len %d handle 0x%4.4x", hdev->name, skb->len, handle); 2745 2745 2746 2746 hdev->stat.sco_rx++; 2747 2747 ··· 2821 2821 struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work); 2822 2822 struct sk_buff *skb; 2823 2823 2824 - BT_DBG("%s cmd %d", hdev->name, atomic_read(&hdev->cmd_cnt)); 2824 + BT_DBG("%s cmd_cnt %d cmd queued %d", hdev->name, 2825 + atomic_read(&hdev->cmd_cnt), skb_queue_len(&hdev->cmd_q)); 2825 2826 2826 2827 /* Send queued commands */ 2827 2828 if (atomic_read(&hdev->cmd_cnt)) { ··· 2840 2839 del_timer(&hdev->cmd_timer); 2841 2840 else 2842 2841 mod_timer(&hdev->cmd_timer, 2843 - jiffies + msecs_to_jiffies(HCI_CMD_TIMEOUT)); 2842 + jiffies + HCI_CMD_TIMEOUT); 2844 2843 } else { 2845 2844 skb_queue_head(&hdev->cmd_q, skb); 2846 2845 queue_work(hdev->workqueue, &hdev->cmd_work);
+85 -85
net/bluetooth/hci_event.c
··· 36 36 { 37 37 __u8 status = *((__u8 *) skb->data); 38 38 39 - BT_DBG("%s status 0x%x", hdev->name, status); 39 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 40 40 41 41 if (status) { 42 42 hci_dev_lock(hdev); ··· 60 60 { 61 61 __u8 status = *((__u8 *) skb->data); 62 62 63 - BT_DBG("%s status 0x%x", hdev->name, status); 63 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 64 64 65 65 if (status) 66 66 return; ··· 72 72 { 73 73 __u8 status = *((__u8 *) skb->data); 74 74 75 - BT_DBG("%s status 0x%x", hdev->name, status); 75 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 76 76 77 77 if (status) 78 78 return; ··· 93 93 struct hci_rp_role_discovery *rp = (void *) skb->data; 94 94 struct hci_conn *conn; 95 95 96 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 96 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 97 97 98 98 if (rp->status) 99 99 return; ··· 116 116 struct hci_rp_read_link_policy *rp = (void *) skb->data; 117 117 struct hci_conn *conn; 118 118 119 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 119 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 120 120 121 121 if (rp->status) 122 122 return; ··· 136 136 struct hci_conn *conn; 137 137 void *sent; 138 138 139 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 139 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 140 140 141 141 if (rp->status) 142 142 return; ··· 159 159 { 160 160 struct hci_rp_read_def_link_policy *rp = (void *) skb->data; 161 161 162 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 162 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 163 163 164 164 if (rp->status) 165 165 return; ··· 173 173 __u8 status = *((__u8 *) skb->data); 174 174 void *sent; 175 175 176 - BT_DBG("%s status 0x%x", hdev->name, status); 176 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 177 177 178 178 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY); 179 179 if (!sent) ··· 189 189 { 190 190 __u8 status = *((__u8 *) skb->data); 191 191 192 - BT_DBG("%s status 0x%x", hdev->name, status); 192 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 193 193 194 194 clear_bit(HCI_RESET, &hdev->flags); 195 195 ··· 207 207 __u8 status = *((__u8 *) skb->data); 208 208 void *sent; 209 209 210 - BT_DBG("%s status 0x%x", hdev->name, status); 210 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 211 211 212 212 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); 213 213 if (!sent) ··· 229 229 { 230 230 struct hci_rp_read_local_name *rp = (void *) skb->data; 231 231 232 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 232 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 233 233 234 234 if (rp->status) 235 235 return; ··· 243 243 __u8 status = *((__u8 *) skb->data); 244 244 void *sent; 245 245 246 - BT_DBG("%s status 0x%x", hdev->name, status); 246 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 247 247 248 248 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); 249 249 if (!sent) ··· 269 269 __u8 status = *((__u8 *) skb->data); 270 270 void *sent; 271 271 272 - BT_DBG("%s status 0x%x", hdev->name, status); 272 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 273 273 274 274 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); 275 275 if (!sent) ··· 293 293 int old_pscan, old_iscan; 294 294 void *sent; 295 295 296 - BT_DBG("%s status 0x%x", hdev->name, status); 296 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 297 297 298 298 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); 299 299 if (!sent) ··· 340 340 { 341 341 struct hci_rp_read_class_of_dev *rp = (void *) skb->data; 342 342 343 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 343 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 344 344 345 345 if (rp->status) 346 346 return; ··· 356 356 __u8 status = *((__u8 *) skb->data); 357 357 void *sent; 358 358 359 - BT_DBG("%s status 0x%x", hdev->name, status); 359 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 360 360 361 361 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); 362 362 if (!sent) ··· 378 378 struct hci_rp_read_voice_setting *rp = (void *) skb->data; 379 379 __u16 setting; 380 380 381 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 381 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 382 382 383 383 if (rp->status) 384 384 return; ··· 390 390 391 391 hdev->voice_setting = setting; 392 392 393 - BT_DBG("%s voice setting 0x%04x", hdev->name, setting); 393 + BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting); 394 394 395 395 if (hdev->notify) 396 396 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); ··· 403 403 __u16 setting; 404 404 void *sent; 405 405 406 - BT_DBG("%s status 0x%x", hdev->name, status); 406 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 407 407 408 408 if (status) 409 409 return; ··· 419 419 420 420 hdev->voice_setting = setting; 421 421 422 - BT_DBG("%s voice setting 0x%04x", hdev->name, setting); 422 + BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting); 423 423 424 424 if (hdev->notify) 425 425 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); ··· 429 429 { 430 430 __u8 status = *((__u8 *) skb->data); 431 431 432 - BT_DBG("%s status 0x%x", hdev->name, status); 432 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 433 433 434 434 hci_req_complete(hdev, HCI_OP_HOST_BUFFER_SIZE, status); 435 435 } ··· 439 439 __u8 status = *((__u8 *) skb->data); 440 440 void *sent; 441 441 442 - BT_DBG("%s status 0x%x", hdev->name, status); 442 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 443 443 444 444 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); 445 445 if (!sent) ··· 597 597 { 598 598 struct hci_rp_read_local_version *rp = (void *) skb->data; 599 599 600 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 600 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 601 601 602 602 if (rp->status) 603 603 goto done; ··· 608 608 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); 609 609 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); 610 610 611 - BT_DBG("%s manufacturer %d hci ver %d:%d", hdev->name, 611 + BT_DBG("%s manufacturer 0x%4.4x hci ver %d:%d", hdev->name, 612 612 hdev->manufacturer, hdev->hci_ver, hdev->hci_rev); 613 613 614 614 if (test_bit(HCI_INIT, &hdev->flags)) ··· 641 641 { 642 642 struct hci_rp_read_local_commands *rp = (void *) skb->data; 643 643 644 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 644 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 645 645 646 646 if (rp->status) 647 647 goto done; ··· 660 660 { 661 661 struct hci_rp_read_local_features *rp = (void *) skb->data; 662 662 663 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 663 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 664 664 665 665 if (rp->status) 666 666 return; ··· 732 732 { 733 733 struct hci_rp_read_local_ext_features *rp = (void *) skb->data; 734 734 735 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 735 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 736 736 737 737 if (rp->status) 738 738 goto done; ··· 758 758 { 759 759 struct hci_rp_read_flow_control_mode *rp = (void *) skb->data; 760 760 761 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 761 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 762 762 763 763 if (rp->status) 764 764 return; ··· 772 772 { 773 773 struct hci_rp_read_buffer_size *rp = (void *) skb->data; 774 774 775 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 775 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 776 776 777 777 if (rp->status) 778 778 return; ··· 798 798 { 799 799 struct hci_rp_read_bd_addr *rp = (void *) skb->data; 800 800 801 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 801 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 802 802 803 803 if (!rp->status) 804 804 bacpy(&hdev->bdaddr, &rp->bdaddr); ··· 811 811 { 812 812 struct hci_rp_read_data_block_size *rp = (void *) skb->data; 813 813 814 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 814 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 815 815 816 816 if (rp->status) 817 817 return; ··· 832 832 { 833 833 __u8 status = *((__u8 *) skb->data); 834 834 835 - BT_DBG("%s status 0x%x", hdev->name, status); 835 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 836 836 837 837 hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status); 838 838 } ··· 842 842 { 843 843 struct hci_rp_read_local_amp_info *rp = (void *) skb->data; 844 844 845 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 845 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 846 846 847 847 if (rp->status) 848 848 return; ··· 866 866 { 867 867 __u8 status = *((__u8 *) skb->data); 868 868 869 - BT_DBG("%s status 0x%x", hdev->name, status); 869 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 870 870 871 871 hci_req_complete(hdev, HCI_OP_DELETE_STORED_LINK_KEY, status); 872 872 } ··· 875 875 { 876 876 __u8 status = *((__u8 *) skb->data); 877 877 878 - BT_DBG("%s status 0x%x", hdev->name, status); 878 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 879 879 880 880 hci_req_complete(hdev, HCI_OP_SET_EVENT_MASK, status); 881 881 } ··· 885 885 { 886 886 __u8 status = *((__u8 *) skb->data); 887 887 888 - BT_DBG("%s status 0x%x", hdev->name, status); 888 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 889 889 890 890 hci_req_complete(hdev, HCI_OP_WRITE_INQUIRY_MODE, status); 891 891 } ··· 895 895 { 896 896 struct hci_rp_read_inq_rsp_tx_power *rp = (void *) skb->data; 897 897 898 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 898 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 899 899 900 900 if (!rp->status) 901 901 hdev->inq_tx_power = rp->tx_power; ··· 907 907 { 908 908 __u8 status = *((__u8 *) skb->data); 909 909 910 - BT_DBG("%s status 0x%x", hdev->name, status); 910 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 911 911 912 912 hci_req_complete(hdev, HCI_OP_SET_EVENT_FLT, status); 913 913 } ··· 918 918 struct hci_cp_pin_code_reply *cp; 919 919 struct hci_conn *conn; 920 920 921 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 921 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 922 922 923 923 hci_dev_lock(hdev); 924 924 ··· 944 944 { 945 945 struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data; 946 946 947 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 947 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 948 948 949 949 hci_dev_lock(hdev); 950 950 ··· 960 960 { 961 961 struct hci_rp_le_read_buffer_size *rp = (void *) skb->data; 962 962 963 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 963 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 964 964 965 965 if (rp->status) 966 966 return; ··· 979 979 { 980 980 struct hci_rp_user_confirm_reply *rp = (void *) skb->data; 981 981 982 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 982 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 983 983 984 984 hci_dev_lock(hdev); 985 985 ··· 995 995 { 996 996 struct hci_rp_user_confirm_reply *rp = (void *) skb->data; 997 997 998 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 998 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 999 999 1000 1000 hci_dev_lock(hdev); 1001 1001 ··· 1010 1010 { 1011 1011 struct hci_rp_user_confirm_reply *rp = (void *) skb->data; 1012 1012 1013 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 1013 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 1014 1014 1015 1015 hci_dev_lock(hdev); 1016 1016 ··· 1026 1026 { 1027 1027 struct hci_rp_user_confirm_reply *rp = (void *) skb->data; 1028 1028 1029 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 1029 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 1030 1030 1031 1031 hci_dev_lock(hdev); 1032 1032 ··· 1042 1042 { 1043 1043 struct hci_rp_read_local_oob_data *rp = (void *) skb->data; 1044 1044 1045 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 1045 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 1046 1046 1047 1047 hci_dev_lock(hdev); 1048 1048 mgmt_read_local_oob_data_reply_complete(hdev, rp->hash, ··· 1054 1054 { 1055 1055 __u8 status = *((__u8 *) skb->data); 1056 1056 1057 - BT_DBG("%s status 0x%x", hdev->name, status); 1057 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1058 1058 1059 1059 hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); 1060 1060 ··· 1072 1072 struct hci_cp_le_set_scan_enable *cp; 1073 1073 __u8 status = *((__u8 *) skb->data); 1074 1074 1075 - BT_DBG("%s status 0x%x", hdev->name, status); 1075 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1076 1076 1077 1077 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); 1078 1078 if (!cp) ··· 1127 1127 { 1128 1128 struct hci_rp_le_ltk_reply *rp = (void *) skb->data; 1129 1129 1130 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 1130 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 1131 1131 1132 1132 if (rp->status) 1133 1133 return; ··· 1139 1139 { 1140 1140 struct hci_rp_le_ltk_neg_reply *rp = (void *) skb->data; 1141 1141 1142 - BT_DBG("%s status 0x%x", hdev->name, rp->status); 1142 + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 1143 1143 1144 1144 if (rp->status) 1145 1145 return; ··· 1153 1153 struct hci_cp_write_le_host_supported *sent; 1154 1154 __u8 status = *((__u8 *) skb->data); 1155 1155 1156 - BT_DBG("%s status 0x%x", hdev->name, status); 1156 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1157 1157 1158 1158 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); 1159 1159 if (!sent) ··· 1175 1175 1176 1176 static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) 1177 1177 { 1178 - BT_DBG("%s status 0x%x", hdev->name, status); 1178 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1179 1179 1180 1180 if (status) { 1181 1181 hci_req_complete(hdev, HCI_OP_INQUIRY, status); ··· 1199 1199 struct hci_cp_create_conn *cp; 1200 1200 struct hci_conn *conn; 1201 1201 1202 - BT_DBG("%s status 0x%x", hdev->name, status); 1202 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1203 1203 1204 1204 cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); 1205 1205 if (!cp) ··· 1209 1209 1210 1210 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); 1211 1211 1212 - BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->bdaddr), conn); 1212 + BT_DBG("%s bdaddr %s hcon %p", hdev->name, batostr(&cp->bdaddr), conn); 1213 1213 1214 1214 if (status) { 1215 1215 if (conn && conn->state == BT_CONNECT) { ··· 1240 1240 struct hci_conn *acl, *sco; 1241 1241 __u16 handle; 1242 1242 1243 - BT_DBG("%s status 0x%x", hdev->name, status); 1243 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1244 1244 1245 1245 if (!status) 1246 1246 return; ··· 1251 1251 1252 1252 handle = __le16_to_cpu(cp->handle); 1253 1253 1254 - BT_DBG("%s handle %d", hdev->name, handle); 1254 + BT_DBG("%s handle 0x%4.4x", hdev->name, handle); 1255 1255 1256 1256 hci_dev_lock(hdev); 1257 1257 ··· 1274 1274 struct hci_cp_auth_requested *cp; 1275 1275 struct hci_conn *conn; 1276 1276 1277 - BT_DBG("%s status 0x%x", hdev->name, status); 1277 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1278 1278 1279 1279 if (!status) 1280 1280 return; ··· 1301 1301 struct hci_cp_set_conn_encrypt *cp; 1302 1302 struct hci_conn *conn; 1303 1303 1304 - BT_DBG("%s status 0x%x", hdev->name, status); 1304 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1305 1305 1306 1306 if (!status) 1307 1307 return; ··· 1413 1413 struct hci_cp_remote_name_req *cp; 1414 1414 struct hci_conn *conn; 1415 1415 1416 - BT_DBG("%s status 0x%x", hdev->name, status); 1416 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1417 1417 1418 1418 /* If successful wait for the name req complete event before 1419 1419 * checking for the need to do authentication */ ··· 1452 1452 struct hci_cp_read_remote_features *cp; 1453 1453 struct hci_conn *conn; 1454 1454 1455 - BT_DBG("%s status 0x%x", hdev->name, status); 1455 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1456 1456 1457 1457 if (!status) 1458 1458 return; ··· 1479 1479 struct hci_cp_read_remote_ext_features *cp; 1480 1480 struct hci_conn *conn; 1481 1481 1482 - BT_DBG("%s status 0x%x", hdev->name, status); 1482 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1483 1483 1484 1484 if (!status) 1485 1485 return; ··· 1507 1507 struct hci_conn *acl, *sco; 1508 1508 __u16 handle; 1509 1509 1510 - BT_DBG("%s status 0x%x", hdev->name, status); 1510 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1511 1511 1512 1512 if (!status) 1513 1513 return; ··· 1518 1518 1519 1519 handle = __le16_to_cpu(cp->handle); 1520 1520 1521 - BT_DBG("%s handle %d", hdev->name, handle); 1521 + BT_DBG("%s handle 0x%4.4x", hdev->name, handle); 1522 1522 1523 1523 hci_dev_lock(hdev); 1524 1524 ··· 1541 1541 struct hci_cp_sniff_mode *cp; 1542 1542 struct hci_conn *conn; 1543 1543 1544 - BT_DBG("%s status 0x%x", hdev->name, status); 1544 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1545 1545 1546 1546 if (!status) 1547 1547 return; ··· 1568 1568 struct hci_cp_exit_sniff_mode *cp; 1569 1569 struct hci_conn *conn; 1570 1570 1571 - BT_DBG("%s status 0x%x", hdev->name, status); 1571 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1572 1572 1573 1573 if (!status) 1574 1574 return; ··· 1617 1617 struct hci_cp_le_create_conn *cp; 1618 1618 struct hci_conn *conn; 1619 1619 1620 - BT_DBG("%s status 0x%x", hdev->name, status); 1620 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1621 1621 1622 1622 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); 1623 1623 if (!cp) ··· 1655 1655 1656 1656 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) 1657 1657 { 1658 - BT_DBG("%s status 0x%x", hdev->name, status); 1658 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1659 1659 } 1660 1660 1661 1661 static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) ··· 1664 1664 struct discovery_state *discov = &hdev->discovery; 1665 1665 struct inquiry_entry *e; 1666 1666 1667 - BT_DBG("%s status %d", hdev->name, status); 1667 + BT_DBG("%s status 0x%2.2x", hdev->name, status); 1668 1668 1669 1669 hci_req_complete(hdev, HCI_OP_INQUIRY, status); 1670 1670 ··· 1893 1893 struct hci_ev_disconn_complete *ev = (void *) skb->data; 1894 1894 struct hci_conn *conn; 1895 1895 1896 - BT_DBG("%s status %d", hdev->name, ev->status); 1896 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 1897 1897 1898 1898 hci_dev_lock(hdev); 1899 1899 ··· 1930 1930 struct hci_ev_auth_complete *ev = (void *) skb->data; 1931 1931 struct hci_conn *conn; 1932 1932 1933 - BT_DBG("%s status %d", hdev->name, ev->status); 1933 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 1934 1934 1935 1935 hci_dev_lock(hdev); 1936 1936 ··· 2035 2035 struct hci_ev_encrypt_change *ev = (void *) skb->data; 2036 2036 struct hci_conn *conn; 2037 2037 2038 - BT_DBG("%s status %d", hdev->name, ev->status); 2038 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2039 2039 2040 2040 hci_dev_lock(hdev); 2041 2041 ··· 2079 2079 struct hci_ev_change_link_key_complete *ev = (void *) skb->data; 2080 2080 struct hci_conn *conn; 2081 2081 2082 - BT_DBG("%s status %d", hdev->name, ev->status); 2082 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2083 2083 2084 2084 hci_dev_lock(hdev); 2085 2085 ··· 2102 2102 struct hci_ev_remote_features *ev = (void *) skb->data; 2103 2103 struct hci_conn *conn; 2104 2104 2105 - BT_DBG("%s status %d", hdev->name, ev->status); 2105 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2106 2106 2107 2107 hci_dev_lock(hdev); 2108 2108 ··· 2364 2364 break; 2365 2365 2366 2366 default: 2367 - BT_DBG("%s opcode 0x%x", hdev->name, opcode); 2367 + BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); 2368 2368 break; 2369 2369 } 2370 2370 ··· 2445 2445 break; 2446 2446 2447 2447 default: 2448 - BT_DBG("%s opcode 0x%x", hdev->name, opcode); 2448 + BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); 2449 2449 break; 2450 2450 } 2451 2451 ··· 2464 2464 struct hci_ev_role_change *ev = (void *) skb->data; 2465 2465 struct hci_conn *conn; 2466 2466 2467 - BT_DBG("%s status %d", hdev->name, ev->status); 2467 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2468 2468 2469 2469 hci_dev_lock(hdev); 2470 2470 ··· 2605 2605 struct hci_ev_mode_change *ev = (void *) skb->data; 2606 2606 struct hci_conn *conn; 2607 2607 2608 - BT_DBG("%s status %d", hdev->name, ev->status); 2608 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2609 2609 2610 2610 hci_dev_lock(hdev); 2611 2611 ··· 2763 2763 struct hci_ev_clock_offset *ev = (void *) skb->data; 2764 2764 struct hci_conn *conn; 2765 2765 2766 - BT_DBG("%s status %d", hdev->name, ev->status); 2766 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2767 2767 2768 2768 hci_dev_lock(hdev); 2769 2769 ··· 2786 2786 struct hci_ev_pkt_type_change *ev = (void *) skb->data; 2787 2787 struct hci_conn *conn; 2788 2788 2789 - BT_DBG("%s status %d", hdev->name, ev->status); 2789 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2790 2790 2791 2791 hci_dev_lock(hdev); 2792 2792 ··· 2930 2930 struct hci_ev_sync_conn_complete *ev = (void *) skb->data; 2931 2931 struct hci_conn *conn; 2932 2932 2933 - BT_DBG("%s status %d", hdev->name, ev->status); 2933 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2934 2934 2935 2935 hci_dev_lock(hdev); 2936 2936 ··· 2989 2989 { 2990 2990 struct hci_ev_sniff_subrate *ev = (void *) skb->data; 2991 2991 2992 - BT_DBG("%s status %d", hdev->name, ev->status); 2992 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 2993 2993 } 2994 2994 2995 2995 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, ··· 3046 3046 struct hci_ev_key_refresh_complete *ev = (void *) skb->data; 3047 3047 struct hci_conn *conn; 3048 3048 3049 - BT_DBG("%s status %u handle %u", hdev->name, ev->status, 3049 + BT_DBG("%s status 0x%2.2x handle 0x%4.4x", hdev->name, ev->status, 3050 3050 __le16_to_cpu(ev->handle)); 3051 3051 3052 3052 hci_dev_lock(hdev); ··· 3346 3346 struct hci_ev_le_conn_complete *ev = (void *) skb->data; 3347 3347 struct hci_conn *conn; 3348 3348 3349 - BT_DBG("%s status %d", hdev->name, ev->status); 3349 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 3350 3350 3351 3351 hci_dev_lock(hdev); 3352 3352 ··· 3421 3421 struct hci_conn *conn; 3422 3422 struct smp_ltk *ltk; 3423 3423 3424 - BT_DBG("%s handle %d", hdev->name, __le16_to_cpu(ev->handle)); 3424 + BT_DBG("%s handle 0x%4.4x", hdev->name, __le16_to_cpu(ev->handle)); 3425 3425 3426 3426 hci_dev_lock(hdev); 3427 3427 ··· 3645 3645 break; 3646 3646 3647 3647 default: 3648 - BT_DBG("%s event 0x%x", hdev->name, event); 3648 + BT_DBG("%s event 0x%2.2x", hdev->name, event); 3649 3649 break; 3650 3650 } 3651 3651
+83 -68
net/bluetooth/l2cap_core.c
··· 431 431 chan->max_tx = L2CAP_DEFAULT_MAX_TX; 432 432 chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; 433 433 chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; 434 + chan->ack_win = L2CAP_DEFAULT_TX_WINDOW; 434 435 chan->sec_level = BT_SECURITY_LOW; 435 436 436 437 set_bit(FLAG_FORCE_ACTIVE, &chan->flags); ··· 1658 1657 1659 1658 l2cap_do_send(chan, skb); 1660 1659 1661 - BT_DBG("Sent txseq %d", (int)control->txseq); 1660 + BT_DBG("Sent txseq %u", control->txseq); 1662 1661 1663 1662 chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); 1664 1663 chan->frames_sent++; ··· 1723 1722 chan->tx_send_head = skb_queue_next(&chan->tx_q, skb); 1724 1723 1725 1724 l2cap_do_send(chan, tx_skb); 1726 - BT_DBG("Sent txseq %d", (int)control->txseq); 1725 + BT_DBG("Sent txseq %u", control->txseq); 1727 1726 } 1728 1727 1729 - BT_DBG("Sent %d, %d unacked, %d in ERTM queue", sent, 1730 - (int) chan->unacked_frames, skb_queue_len(&chan->tx_q)); 1728 + BT_DBG("Sent %d, %u unacked, %u in ERTM queue", sent, 1729 + chan->unacked_frames, skb_queue_len(&chan->tx_q)); 1731 1730 1732 1731 return sent; 1733 1732 } ··· 1878 1877 frames_to_ack = 0; 1879 1878 } 1880 1879 1881 - /* Ack now if the tx window is 3/4ths full. 1880 + /* Ack now if the window is 3/4ths full. 1882 1881 * Calculate without mul or div 1883 1882 */ 1884 - threshold = chan->tx_win; 1883 + threshold = chan->ack_win; 1885 1884 threshold += threshold << 1; 1886 1885 threshold >>= 2; 1887 1886 1888 - BT_DBG("frames_to_ack %d, threshold %d", (int)frames_to_ack, 1887 + BT_DBG("frames_to_ack %u, threshold %d", frames_to_ack, 1889 1888 threshold); 1890 1889 1891 1890 if (frames_to_ack >= threshold) { ··· 1947 1946 } 1948 1947 1949 1948 static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, 1950 - struct msghdr *msg, size_t len, 1951 - u32 priority) 1949 + struct msghdr *msg, size_t len, 1950 + u32 priority) 1952 1951 { 1953 1952 struct l2cap_conn *conn = chan->conn; 1954 1953 struct sk_buff *skb; 1955 1954 int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; 1956 1955 struct l2cap_hdr *lh; 1957 1956 1958 - BT_DBG("chan %p len %d priority %u", chan, (int)len, priority); 1957 + BT_DBG("chan %p len %zu priority %u", chan, len, priority); 1959 1958 1960 1959 count = min_t(unsigned int, (conn->mtu - hlen), len); 1961 1960 ··· 1981 1980 } 1982 1981 1983 1982 static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, 1984 - struct msghdr *msg, size_t len, 1985 - u32 priority) 1983 + struct msghdr *msg, size_t len, 1984 + u32 priority) 1986 1985 { 1987 1986 struct l2cap_conn *conn = chan->conn; 1988 1987 struct sk_buff *skb; 1989 1988 int err, count; 1990 1989 struct l2cap_hdr *lh; 1991 1990 1992 - BT_DBG("chan %p len %d", chan, (int)len); 1991 + BT_DBG("chan %p len %zu", chan, len); 1993 1992 1994 1993 count = min_t(unsigned int, (conn->mtu - L2CAP_HDR_SIZE), len); 1995 1994 ··· 2014 2013 } 2015 2014 2016 2015 static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, 2017 - struct msghdr *msg, size_t len, 2018 - u16 sdulen) 2016 + struct msghdr *msg, size_t len, 2017 + u16 sdulen) 2019 2018 { 2020 2019 struct l2cap_conn *conn = chan->conn; 2021 2020 struct sk_buff *skb; 2022 2021 int err, count, hlen; 2023 2022 struct l2cap_hdr *lh; 2024 2023 2025 - BT_DBG("chan %p len %d", chan, (int)len); 2024 + BT_DBG("chan %p len %zu", chan, len); 2026 2025 2027 2026 if (!conn) 2028 2027 return ERR_PTR(-ENOTCONN); ··· 2076 2075 size_t pdu_len; 2077 2076 u8 sar; 2078 2077 2079 - BT_DBG("chan %p, msg %p, len %d", chan, msg, (int)len); 2078 + BT_DBG("chan %p, msg %p, len %zu", chan, msg, len); 2080 2079 2081 2080 /* It is critical that ERTM PDUs fit in a single HCI fragment, 2082 2081 * so fragmented skbs are not used. The HCI layer's handling ··· 2220 2219 struct l2cap_ctrl control; 2221 2220 u16 seq; 2222 2221 2223 - BT_DBG("chan %p, txseq %d", chan, txseq); 2222 + BT_DBG("chan %p, txseq %u", chan, txseq); 2224 2223 2225 2224 memset(&control, 0, sizeof(control)); 2226 2225 control.sframe = 1; ··· 2260 2259 u16 initial_head; 2261 2260 u16 seq; 2262 2261 2263 - BT_DBG("chan %p, txseq %d", chan, txseq); 2262 + BT_DBG("chan %p, txseq %u", chan, txseq); 2264 2263 2265 2264 memset(&control, 0, sizeof(control)); 2266 2265 control.sframe = 1; ··· 2285 2284 struct sk_buff *acked_skb; 2286 2285 u16 ackseq; 2287 2286 2288 - BT_DBG("chan %p, reqseq %d", chan, reqseq); 2287 + BT_DBG("chan %p, reqseq %u", chan, reqseq); 2289 2288 2290 2289 if (chan->unacked_frames == 0 || reqseq == chan->expected_ack_seq) 2291 2290 return; 2292 2291 2293 - BT_DBG("expected_ack_seq %d, unacked_frames %d", 2292 + BT_DBG("expected_ack_seq %u, unacked_frames %u", 2294 2293 chan->expected_ack_seq, chan->unacked_frames); 2295 2294 2296 2295 for (ackseq = chan->expected_ack_seq; ackseq != reqseq; ··· 2309 2308 if (chan->unacked_frames == 0) 2310 2309 __clear_retrans_timer(chan); 2311 2310 2312 - BT_DBG("unacked_frames %d", (int) chan->unacked_frames); 2311 + BT_DBG("unacked_frames %u", chan->unacked_frames); 2313 2312 } 2314 2313 2315 2314 static void l2cap_abort_rx_srej_sent(struct l2cap_chan *chan) ··· 2535 2534 } 2536 2535 2537 2536 /* ---- L2CAP signalling commands ---- */ 2538 - static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, 2539 - u8 code, u8 ident, u16 dlen, void *data) 2537 + static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code, 2538 + u8 ident, u16 dlen, void *data) 2540 2539 { 2541 2540 struct sk_buff *skb, **frag; 2542 2541 struct l2cap_cmd_hdr *cmd; 2543 2542 struct l2cap_hdr *lh; 2544 2543 int len, count; 2545 2544 2546 - BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", 2547 - conn, code, ident, dlen); 2545 + BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %u", 2546 + conn, code, ident, dlen); 2548 2547 2549 2548 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; 2550 2549 count = min_t(unsigned int, conn->mtu, len); ··· 2627 2626 break; 2628 2627 } 2629 2628 2630 - BT_DBG("type 0x%2.2x len %d val 0x%lx", *type, opt->len, *val); 2629 + BT_DBG("type 0x%2.2x len %u val 0x%lx", *type, opt->len, *val); 2631 2630 return len; 2632 2631 } 2633 2632 ··· 2635 2634 { 2636 2635 struct l2cap_conf_opt *opt = *ptr; 2637 2636 2638 - BT_DBG("type 0x%2.2x len %d val 0x%lx", type, len, val); 2637 + BT_DBG("type 0x%2.2x len %u val 0x%lx", type, len, val); 2639 2638 2640 2639 opt->type = type; 2641 2640 opt->len = len; ··· 2787 2786 L2CAP_DEFAULT_TX_WINDOW); 2788 2787 chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; 2789 2788 } 2789 + chan->ack_win = chan->tx_win; 2790 2790 } 2791 2791 2792 2792 static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ··· 3177 3175 break; 3178 3176 3179 3177 case L2CAP_CONF_EWS: 3180 - chan->tx_win = min_t(u16, val, 3181 - L2CAP_DEFAULT_EXT_WINDOW); 3178 + chan->ack_win = min_t(u16, val, chan->ack_win); 3182 3179 l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, 3183 - chan->tx_win); 3180 + chan->tx_win); 3184 3181 break; 3185 3182 3186 3183 case L2CAP_CONF_EFS: ··· 3208 3207 chan->retrans_timeout = le16_to_cpu(rfc.retrans_timeout); 3209 3208 chan->monitor_timeout = le16_to_cpu(rfc.monitor_timeout); 3210 3209 chan->mps = le16_to_cpu(rfc.max_pdu_size); 3210 + if (!test_bit(FLAG_EXT_CTRL, &chan->flags)) 3211 + chan->ack_win = min_t(u16, chan->ack_win, 3212 + rfc.txwin_size); 3211 3213 3212 3214 if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { 3213 3215 chan->local_msdu = le16_to_cpu(efs.msdu); ··· 3272 3268 { 3273 3269 int type, olen; 3274 3270 unsigned long val; 3275 - struct l2cap_conf_rfc rfc; 3271 + /* Use sane default values in case a misbehaving remote device 3272 + * did not send an RFC or extended window size option. 3273 + */ 3274 + u16 txwin_ext = chan->ack_win; 3275 + struct l2cap_conf_rfc rfc = { 3276 + .mode = chan->mode, 3277 + .retrans_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO), 3278 + .monitor_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO), 3279 + .max_pdu_size = cpu_to_le16(chan->imtu), 3280 + .txwin_size = min_t(u16, chan->ack_win, L2CAP_DEFAULT_TX_WINDOW), 3281 + }; 3276 3282 3277 3283 BT_DBG("chan %p, rsp %p, len %d", chan, rsp, len); 3278 3284 ··· 3292 3278 while (len >= L2CAP_CONF_OPT_SIZE) { 3293 3279 len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val); 3294 3280 3295 - if (type != L2CAP_CONF_RFC) 3296 - continue; 3297 - 3298 - if (olen != sizeof(rfc)) 3281 + switch (type) { 3282 + case L2CAP_CONF_RFC: 3283 + if (olen == sizeof(rfc)) 3284 + memcpy(&rfc, (void *)val, olen); 3299 3285 break; 3300 - 3301 - memcpy(&rfc, (void *)val, olen); 3302 - goto done; 3286 + case L2CAP_CONF_EWS: 3287 + txwin_ext = val; 3288 + break; 3289 + } 3303 3290 } 3304 3291 3305 - /* Use sane default values in case a misbehaving remote device 3306 - * did not send an RFC option. 3307 - */ 3308 - rfc.mode = chan->mode; 3309 - rfc.retrans_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO); 3310 - rfc.monitor_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO); 3311 - rfc.max_pdu_size = cpu_to_le16(chan->imtu); 3312 - 3313 - BT_ERR("Expected RFC option was not found, using defaults"); 3314 - 3315 - done: 3316 3292 switch (rfc.mode) { 3317 3293 case L2CAP_MODE_ERTM: 3318 3294 chan->retrans_timeout = le16_to_cpu(rfc.retrans_timeout); 3319 3295 chan->monitor_timeout = le16_to_cpu(rfc.monitor_timeout); 3320 - chan->mps = le16_to_cpu(rfc.max_pdu_size); 3296 + chan->mps = le16_to_cpu(rfc.max_pdu_size); 3297 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 3298 + chan->ack_win = min_t(u16, chan->ack_win, txwin_ext); 3299 + else 3300 + chan->ack_win = min_t(u16, chan->ack_win, 3301 + rfc.txwin_size); 3321 3302 break; 3322 3303 case L2CAP_MODE_STREAMING: 3323 3304 chan->mps = le16_to_cpu(rfc.max_pdu_size); ··· 3958 3949 psm = le16_to_cpu(req->psm); 3959 3950 scid = le16_to_cpu(req->scid); 3960 3951 3961 - BT_DBG("psm %d, scid %d, amp_id %d", psm, scid, req->amp_id); 3952 + BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id); 3962 3953 3963 3954 /* Placeholder: Always reject */ 3964 3955 rsp.dcid = 0; ··· 3981 3972 } 3982 3973 3983 3974 static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, 3984 - u16 icid, u16 result) 3975 + u16 icid, u16 result) 3985 3976 { 3986 3977 struct l2cap_move_chan_rsp rsp; 3987 3978 3988 - BT_DBG("icid %d, result %d", icid, result); 3979 + BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); 3989 3980 3990 3981 rsp.icid = cpu_to_le16(icid); 3991 3982 rsp.result = cpu_to_le16(result); ··· 3994 3985 } 3995 3986 3996 3987 static void l2cap_send_move_chan_cfm(struct l2cap_conn *conn, 3997 - struct l2cap_chan *chan, u16 icid, u16 result) 3988 + struct l2cap_chan *chan, 3989 + u16 icid, u16 result) 3998 3990 { 3999 3991 struct l2cap_move_chan_cfm cfm; 4000 3992 u8 ident; 4001 3993 4002 - BT_DBG("icid %d, result %d", icid, result); 3994 + BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); 4003 3995 4004 3996 ident = l2cap_get_ident(conn); 4005 3997 if (chan) ··· 4013 4003 } 4014 4004 4015 4005 static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, 4016 - u16 icid) 4006 + u16 icid) 4017 4007 { 4018 4008 struct l2cap_move_chan_cfm_rsp rsp; 4019 4009 4020 - BT_DBG("icid %d", icid); 4010 + BT_DBG("icid 0x%4.4x", icid); 4021 4011 4022 4012 rsp.icid = cpu_to_le16(icid); 4023 4013 l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM_RSP, sizeof(rsp), &rsp); 4024 4014 } 4025 4015 4026 4016 static inline int l2cap_move_channel_req(struct l2cap_conn *conn, 4027 - struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 4017 + struct l2cap_cmd_hdr *cmd, 4018 + u16 cmd_len, void *data) 4028 4019 { 4029 4020 struct l2cap_move_chan_req *req = data; 4030 4021 u16 icid = 0; ··· 4036 4025 4037 4026 icid = le16_to_cpu(req->icid); 4038 4027 4039 - BT_DBG("icid %d, dest_amp_id %d", icid, req->dest_amp_id); 4028 + BT_DBG("icid 0x%4.4x, dest_amp_id %d", icid, req->dest_amp_id); 4040 4029 4041 4030 if (!enable_hs) 4042 4031 return -EINVAL; ··· 4048 4037 } 4049 4038 4050 4039 static inline int l2cap_move_channel_rsp(struct l2cap_conn *conn, 4051 - struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 4040 + struct l2cap_cmd_hdr *cmd, 4041 + u16 cmd_len, void *data) 4052 4042 { 4053 4043 struct l2cap_move_chan_rsp *rsp = data; 4054 4044 u16 icid, result; ··· 4060 4048 icid = le16_to_cpu(rsp->icid); 4061 4049 result = le16_to_cpu(rsp->result); 4062 4050 4063 - BT_DBG("icid %d, result %d", icid, result); 4051 + BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); 4064 4052 4065 4053 /* Placeholder: Always unconfirmed */ 4066 4054 l2cap_send_move_chan_cfm(conn, NULL, icid, L2CAP_MC_UNCONFIRMED); ··· 4069 4057 } 4070 4058 4071 4059 static inline int l2cap_move_channel_confirm(struct l2cap_conn *conn, 4072 - struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 4060 + struct l2cap_cmd_hdr *cmd, 4061 + u16 cmd_len, void *data) 4073 4062 { 4074 4063 struct l2cap_move_chan_cfm *cfm = data; 4075 4064 u16 icid, result; ··· 4081 4068 icid = le16_to_cpu(cfm->icid); 4082 4069 result = le16_to_cpu(cfm->result); 4083 4070 4084 - BT_DBG("icid %d, result %d", icid, result); 4071 + BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); 4085 4072 4086 4073 l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); 4087 4074 ··· 4089 4076 } 4090 4077 4091 4078 static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, 4092 - struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 4079 + struct l2cap_cmd_hdr *cmd, 4080 + u16 cmd_len, void *data) 4093 4081 { 4094 4082 struct l2cap_move_chan_cfm_rsp *rsp = data; 4095 4083 u16 icid; ··· 4100 4086 4101 4087 icid = le16_to_cpu(rsp->icid); 4102 4088 4103 - BT_DBG("icid %d", icid); 4089 + BT_DBG("icid 0x%4.4x", icid); 4104 4090 4105 4091 return 0; 4106 4092 } ··· 5388 5374 if (!conn) 5389 5375 return 0; 5390 5376 5391 - BT_DBG("conn %p", conn); 5377 + BT_DBG("conn %p status 0x%2.2x encrypt %u", conn, status, encrypt); 5392 5378 5393 5379 if (hcon->type == LE_LINK) { 5394 5380 if (!status && encrypt) ··· 5401 5387 list_for_each_entry(chan, &conn->chan_l, list) { 5402 5388 l2cap_chan_lock(chan); 5403 5389 5404 - BT_DBG("chan->scid %d", chan->scid); 5390 + BT_DBG("chan %p scid 0x%4.4x state %s", chan, chan->scid, 5391 + state_to_string(chan->state)); 5405 5392 5406 5393 if (chan->scid == L2CAP_CID_LE_DATA) { 5407 5394 if (!status && encrypt) {
+24 -36
net/bluetooth/mgmt.c
··· 210 210 211 211 BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); 212 212 213 - skb = alloc_skb(sizeof(*hdr) + sizeof(*ev), GFP_ATOMIC); 213 + skb = alloc_skb(sizeof(*hdr) + sizeof(*ev), GFP_KERNEL); 214 214 if (!skb) 215 215 return -ENOMEM; 216 216 ··· 241 241 242 242 BT_DBG("sock %p", sk); 243 243 244 - skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + rp_len, GFP_ATOMIC); 244 + skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + rp_len, GFP_KERNEL); 245 245 if (!skb) 246 246 return -ENOMEM; 247 247 ··· 687 687 { 688 688 struct pending_cmd *cmd; 689 689 690 - cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC); 690 + cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); 691 691 if (!cmd) 692 692 return NULL; 693 693 694 694 cmd->opcode = opcode; 695 695 cmd->index = hdev->id; 696 696 697 - cmd->param = kmalloc(len, GFP_ATOMIC); 697 + cmd->param = kmalloc(len, GFP_KERNEL); 698 698 if (!cmd->param) { 699 699 kfree(cmd); 700 700 return NULL; ··· 812 812 struct sk_buff *skb; 813 813 struct mgmt_hdr *hdr; 814 814 815 - skb = alloc_skb(sizeof(*hdr) + data_len, GFP_ATOMIC); 815 + skb = alloc_skb(sizeof(*hdr) + data_len, GFP_KERNEL); 816 816 if (!skb) 817 817 return -ENOMEM; 818 818 ··· 1268 1268 goto failed; 1269 1269 } 1270 1270 1271 - uuid = kmalloc(sizeof(*uuid), GFP_ATOMIC); 1271 + uuid = kmalloc(sizeof(*uuid), GFP_KERNEL); 1272 1272 if (!uuid) { 1273 1273 err = -ENOMEM; 1274 1274 goto failed; ··· 1611 1611 } 1612 1612 1613 1613 dc.handle = cpu_to_le16(conn->handle); 1614 - dc.reason = 0x13; /* Remote User Terminated Connection */ 1614 + dc.reason = HCI_ERROR_REMOTE_USER_TERM; 1615 1615 1616 1616 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); 1617 1617 if (err < 0) ··· 1667 1667 } 1668 1668 1669 1669 rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); 1670 - rp = kmalloc(rp_len, GFP_ATOMIC); 1670 + rp = kmalloc(rp_len, GFP_KERNEL); 1671 1671 if (!rp) { 1672 1672 err = -ENOMEM; 1673 1673 goto unlock; ··· 1772 1772 err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_REPLY, sizeof(reply), &reply); 1773 1773 if (err < 0) 1774 1774 mgmt_pending_remove(cmd); 1775 - 1776 - failed: 1777 - hci_dev_unlock(hdev); 1778 - return err; 1779 - } 1780 - 1781 - static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, 1782 - void *data, u16 len) 1783 - { 1784 - struct mgmt_cp_pin_code_neg_reply *cp = data; 1785 - int err; 1786 - 1787 - BT_DBG(""); 1788 - 1789 - hci_dev_lock(hdev); 1790 - 1791 - if (!hdev_is_powered(hdev)) { 1792 - err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, 1793 - MGMT_STATUS_NOT_POWERED); 1794 - goto failed; 1795 - } 1796 - 1797 - err = send_pin_code_neg_reply(sk, hdev, cp); 1798 1775 1799 1776 failed: 1800 1777 hci_dev_unlock(hdev); ··· 2058 2081 done: 2059 2082 hci_dev_unlock(hdev); 2060 2083 return err; 2084 + } 2085 + 2086 + static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, 2087 + void *data, u16 len) 2088 + { 2089 + struct mgmt_cp_pin_code_neg_reply *cp = data; 2090 + 2091 + BT_DBG(""); 2092 + 2093 + return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, 2094 + MGMT_OP_PIN_CODE_NEG_REPLY, 2095 + HCI_OP_PIN_CODE_NEG_REPLY, 0); 2061 2096 } 2062 2097 2063 2098 static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, void *data, ··· 2596 2607 if (cp->val) { 2597 2608 type = PAGE_SCAN_TYPE_INTERLACED; 2598 2609 2599 - /* 22.5 msec page scan interval */ 2600 - acp.interval = __constant_cpu_to_le16(0x0024); 2610 + /* 160 msec page scan interval */ 2611 + acp.interval = __constant_cpu_to_le16(0x0100); 2601 2612 } else { 2602 2613 type = PAGE_SCAN_TYPE_STANDARD; /* default */ 2603 2614 ··· 3535 3546 ev->addr.type = link_to_bdaddr(link_type, addr_type); 3536 3547 ev->rssi = rssi; 3537 3548 if (cfm_name) 3538 - ev->flags[0] |= MGMT_DEV_FOUND_CONFIRM_NAME; 3549 + ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME); 3539 3550 if (!ssp) 3540 - ev->flags[0] |= MGMT_DEV_FOUND_LEGACY_PAIRING; 3551 + ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING); 3541 3552 3542 3553 if (eir_len > 0) 3543 3554 memcpy(ev->eir, eir, eir_len); ··· 3547 3558 dev_class, 3); 3548 3559 3549 3560 ev->eir_len = cpu_to_le16(eir_len); 3550 - 3551 3561 ev_size = sizeof(*ev) + eir_len; 3552 3562 3553 3563 return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
+2 -1
net/mac80211/agg-tx.c
··· 135 135 bar->control = cpu_to_le16(bar_control); 136 136 bar->start_seq_num = cpu_to_le16(ssn); 137 137 138 - IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; 138 + IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | 139 + IEEE80211_TX_CTL_REQ_TX_STATUS; 139 140 ieee80211_tx_skb_tid(sdata, skb, tid); 140 141 } 141 142 EXPORT_SYMBOL(ieee80211_send_bar);
+33 -29
net/mac80211/cfg.c
··· 20 20 #include "rate.h" 21 21 #include "mesh.h" 22 22 23 - static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name, 24 - enum nl80211_iftype type, 25 - u32 *flags, 26 - struct vif_params *params) 23 + static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, char *name, 24 + enum nl80211_iftype type, 25 + u32 *flags, 26 + struct vif_params *params) 27 27 { 28 28 struct ieee80211_local *local = wiphy_priv(wiphy); 29 - struct net_device *dev; 29 + struct wireless_dev *wdev; 30 30 struct ieee80211_sub_if_data *sdata; 31 31 int err; 32 32 33 - err = ieee80211_if_add(local, name, &dev, type, params); 33 + err = ieee80211_if_add(local, name, &wdev, type, params); 34 34 if (err) 35 35 return ERR_PTR(err); 36 36 37 37 if (type == NL80211_IFTYPE_MONITOR && flags) { 38 - sdata = IEEE80211_DEV_TO_SUB_IF(dev); 38 + sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 39 39 sdata->u.mntr_flags = *flags; 40 40 } 41 41 42 - return dev; 42 + return wdev; 43 43 } 44 44 45 - static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) 45 + static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) 46 46 { 47 - ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev)); 47 + ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); 48 48 49 49 return 0; 50 50 } ··· 917 917 918 918 kfree_rcu(old, rcu_head); 919 919 920 + sta_info_flush(sdata->local, sdata); 920 921 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); 921 922 922 923 return 0; ··· 1742 1741 return -EINVAL; 1743 1742 } 1744 1743 1744 + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); 1745 + 1745 1746 return 0; 1746 1747 } 1747 1748 ··· 1764 1761 #endif 1765 1762 1766 1763 static int ieee80211_scan(struct wiphy *wiphy, 1767 - struct net_device *dev, 1768 1764 struct cfg80211_scan_request *req) 1769 1765 { 1770 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1766 + struct ieee80211_sub_if_data *sdata; 1767 + 1768 + sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); 1771 1769 1772 1770 switch (ieee80211_vif_type_p2p(&sdata->vif)) { 1773 1771 case NL80211_IFTYPE_STATION: ··· 2301 2297 } 2302 2298 2303 2299 static int ieee80211_remain_on_channel(struct wiphy *wiphy, 2304 - struct net_device *dev, 2300 + struct wireless_dev *wdev, 2305 2301 struct ieee80211_channel *chan, 2306 2302 enum nl80211_channel_type channel_type, 2307 2303 unsigned int duration, 2308 2304 u64 *cookie) 2309 2305 { 2310 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2306 + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2311 2307 struct ieee80211_local *local = sdata->local; 2312 2308 int ret; 2313 2309 ··· 2394 2390 } 2395 2391 2396 2392 static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, 2397 - struct net_device *dev, 2393 + struct wireless_dev *wdev, 2398 2394 u64 cookie) 2399 2395 { 2400 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2396 + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2401 2397 struct ieee80211_local *local = sdata->local; 2402 2398 2403 2399 return ieee80211_cancel_roc(local, cookie, false); 2404 2400 } 2405 2401 2406 - static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, 2402 + static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 2407 2403 struct ieee80211_channel *chan, bool offchan, 2408 2404 enum nl80211_channel_type channel_type, 2409 2405 bool channel_type_valid, unsigned int wait, 2410 2406 const u8 *buf, size_t len, bool no_cck, 2411 2407 bool dont_wait_for_ack, u64 *cookie) 2412 2408 { 2413 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2409 + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2414 2410 struct ieee80211_local *local = sdata->local; 2415 2411 struct sk_buff *skb; 2416 2412 struct sta_info *sta; ··· 2494 2490 skb->dev = sdata->dev; 2495 2491 2496 2492 if (!need_offchan) { 2493 + *cookie = (unsigned long) skb; 2497 2494 ieee80211_tx_skb(sdata, skb); 2498 2495 ret = 0; 2499 2496 goto out_unlock; ··· 2516 2511 } 2517 2512 2518 2513 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, 2519 - struct net_device *dev, 2514 + struct wireless_dev *wdev, 2520 2515 u64 cookie) 2521 2516 { 2522 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2523 - struct ieee80211_local *local = sdata->local; 2517 + struct ieee80211_local *local = wiphy_priv(wiphy); 2524 2518 2525 2519 return ieee80211_cancel_roc(local, cookie, true); 2526 2520 } 2527 2521 2528 2522 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, 2529 - struct net_device *dev, 2523 + struct wireless_dev *wdev, 2530 2524 u16 frame_type, bool reg) 2531 2525 { 2532 2526 struct ieee80211_local *local = wiphy_priv(wiphy); 2533 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2527 + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2534 2528 2535 2529 switch (frame_type) { 2536 2530 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH: ··· 2984 2980 return 0; 2985 2981 } 2986 2982 2987 - static void ieee80211_set_monitor_enabled(struct wiphy *wiphy, bool enabled) 2983 + static struct ieee80211_channel * 2984 + ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 2985 + enum nl80211_channel_type *type) 2988 2986 { 2989 2987 struct ieee80211_local *local = wiphy_priv(wiphy); 2990 2988 2991 - if (enabled) 2992 - WARN_ON(ieee80211_add_virtual_monitor(local)); 2993 - else 2994 - ieee80211_del_virtual_monitor(local); 2989 + *type = local->_oper_channel_type; 2990 + return local->oper_channel; 2995 2991 } 2996 2992 2997 2993 #ifdef CONFIG_PM ··· 3068 3064 .tdls_mgmt = ieee80211_tdls_mgmt, 3069 3065 .probe_client = ieee80211_probe_client, 3070 3066 .set_noack_map = ieee80211_set_noack_map, 3071 - .set_monitor_enabled = ieee80211_set_monitor_enabled, 3072 3067 #ifdef CONFIG_PM 3073 3068 .set_wakeup = ieee80211_set_wakeup, 3074 3069 #endif 3075 3070 .get_et_sset_count = ieee80211_get_et_sset_count, 3076 3071 .get_et_stats = ieee80211_get_et_stats, 3077 3072 .get_et_strings = ieee80211_get_et_strings, 3073 + .get_channel = ieee80211_cfg_get_channel, 3078 3074 };
-2
net/mac80211/debugfs.c
··· 325 325 local->rx_handlers_drop_defrag); 326 326 DEBUGFS_STATS_ADD(rx_handlers_drop_short, 327 327 local->rx_handlers_drop_short); 328 - DEBUGFS_STATS_ADD(rx_handlers_drop_passive_scan, 329 - local->rx_handlers_drop_passive_scan); 330 328 DEBUGFS_STATS_ADD(tx_expand_skb_head, 331 329 local->tx_expand_skb_head); 332 330 DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned,
+12 -12
net/mac80211/ieee80211_i.h
··· 85 85 size_t ssid_len; 86 86 u8 ssid[IEEE80211_MAX_SSID_LEN]; 87 87 88 + u32 device_ts; 89 + 88 90 u8 dtim_period; 89 91 90 92 bool wmm_used; ··· 209 207 * enum ieee80211_packet_rx_flags - packet RX flags 210 208 * @IEEE80211_RX_RA_MATCH: frame is destined to interface currently processed 211 209 * (incl. multicast frames) 212 - * @IEEE80211_RX_IN_SCAN: received while scanning 213 210 * @IEEE80211_RX_FRAGMENTED: fragmented frame 214 211 * @IEEE80211_RX_AMSDU: a-MSDU packet 215 212 * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed ··· 218 217 * @rx_flags field of &struct ieee80211_rx_status. 219 218 */ 220 219 enum ieee80211_packet_rx_flags { 221 - IEEE80211_RX_IN_SCAN = BIT(0), 222 220 IEEE80211_RX_RA_MATCH = BIT(1), 223 221 IEEE80211_RX_FRAGMENTED = BIT(2), 224 222 IEEE80211_RX_AMSDU = BIT(3), ··· 965 965 int scan_channel_idx; 966 966 int scan_ies_len; 967 967 968 - bool sched_scanning; 969 968 struct ieee80211_sched_scan_ies sched_scan_ies; 970 969 struct work_struct sched_scan_stopped_work; 970 + struct ieee80211_sub_if_data __rcu *sched_scan_sdata; 971 971 972 972 unsigned long leave_oper_channel_time; 973 973 enum mac80211_scan_state next_scan_state; 974 974 struct delayed_work scan_work; 975 - struct ieee80211_sub_if_data *scan_sdata; 975 + struct ieee80211_sub_if_data __rcu *scan_sdata; 976 976 enum nl80211_channel_type _oper_channel_type; 977 977 struct ieee80211_channel *oper_channel, *csa_channel; 978 978 ··· 1014 1014 unsigned int rx_handlers_drop_nullfunc; 1015 1015 unsigned int rx_handlers_drop_defrag; 1016 1016 unsigned int rx_handlers_drop_short; 1017 - unsigned int rx_handlers_drop_passive_scan; 1018 1017 unsigned int tx_expand_skb_head; 1019 1018 unsigned int tx_expand_skb_head_cloned; 1020 1019 unsigned int rx_expand_skb_head; ··· 1088 1089 IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) 1089 1090 { 1090 1091 return netdev_priv(dev); 1092 + } 1093 + 1094 + static inline struct ieee80211_sub_if_data * 1095 + IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev) 1096 + { 1097 + return container_of(wdev, struct ieee80211_sub_if_data, wdev); 1091 1098 } 1092 1099 1093 1100 /* this struct represents 802.11n's RA/TID combination */ ··· 1246 1241 struct cfg80211_scan_request *req); 1247 1242 void ieee80211_scan_cancel(struct ieee80211_local *local); 1248 1243 void ieee80211_run_deferred_scan(struct ieee80211_local *local); 1249 - ieee80211_rx_result 1250 - ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); 1244 + void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb); 1251 1245 1252 1246 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); 1253 1247 struct ieee80211_bss * ··· 1282 1278 int ieee80211_iface_init(void); 1283 1279 void ieee80211_iface_exit(void); 1284 1280 int ieee80211_if_add(struct ieee80211_local *local, const char *name, 1285 - struct net_device **new_dev, enum nl80211_iftype type, 1281 + struct wireless_dev **new_wdev, enum nl80211_iftype type, 1286 1282 struct vif_params *params); 1287 1283 int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, 1288 1284 enum nl80211_iftype type); ··· 1490 1486 struct sk_buff *skb, bool need_basic); 1491 1487 int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata, 1492 1488 struct sk_buff *skb, bool need_basic); 1493 - 1494 - /* virtual monitor */ 1495 - int ieee80211_add_virtual_monitor(struct ieee80211_local *local); 1496 - void ieee80211_del_virtual_monitor(struct ieee80211_local *local); 1497 1489 1498 1490 /* channel management */ 1499 1491 enum ieee80211_chan_mode {
+41 -19
net/mac80211/iface.c
··· 112 112 } 113 113 } 114 114 115 - if (local->scan_sdata && 116 - !(local->hw.flags & IEEE80211_HW_SCAN_WHILE_IDLE)) { 115 + sdata = rcu_dereference_protected(local->scan_sdata, 116 + lockdep_is_held(&local->mtx)); 117 + if (sdata && !(local->hw.flags & IEEE80211_HW_SCAN_WHILE_IDLE)) { 117 118 scanning = true; 118 - local->scan_sdata->vif.bss_conf.idle = false; 119 + sdata->vif.bss_conf.idle = false; 119 120 } 120 121 121 122 list_for_each_entry(sdata, &local->interfaces, list) { ··· 331 330 sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE; 332 331 } 333 332 334 - int ieee80211_add_virtual_monitor(struct ieee80211_local *local) 333 + static int ieee80211_add_virtual_monitor(struct ieee80211_local *local) 335 334 { 336 335 struct ieee80211_sub_if_data *sdata; 337 - int ret; 336 + int ret = 0; 338 337 339 338 if (!(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF)) 340 339 return 0; 341 340 341 + mutex_lock(&local->iflist_mtx); 342 + 342 343 if (local->monitor_sdata) 343 - return 0; 344 + goto out_unlock; 344 345 345 346 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size, GFP_KERNEL); 346 - if (!sdata) 347 - return -ENOMEM; 347 + if (!sdata) { 348 + ret = -ENOMEM; 349 + goto out_unlock; 350 + } 348 351 349 352 /* set up data */ 350 353 sdata->local = local; ··· 362 357 if (WARN_ON(ret)) { 363 358 /* ok .. stupid driver, it asked for this! */ 364 359 kfree(sdata); 365 - return ret; 360 + goto out_unlock; 366 361 } 367 362 368 363 ret = ieee80211_check_queues(sdata); 369 364 if (ret) { 370 365 kfree(sdata); 371 - return ret; 366 + goto out_unlock; 372 367 } 373 368 374 369 rcu_assign_pointer(local->monitor_sdata, sdata); 375 - 376 - return 0; 370 + out_unlock: 371 + mutex_unlock(&local->iflist_mtx); 372 + return ret; 377 373 } 378 374 379 - void ieee80211_del_virtual_monitor(struct ieee80211_local *local) 375 + static void ieee80211_del_virtual_monitor(struct ieee80211_local *local) 380 376 { 381 377 struct ieee80211_sub_if_data *sdata; 382 378 383 379 if (!(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF)) 384 380 return; 385 381 386 - sdata = rtnl_dereference(local->monitor_sdata); 382 + mutex_lock(&local->iflist_mtx); 387 383 384 + sdata = rcu_dereference_protected(local->monitor_sdata, 385 + lockdep_is_held(&local->iflist_mtx)); 388 386 if (!sdata) 389 - return; 387 + goto out_unlock; 390 388 391 389 rcu_assign_pointer(local->monitor_sdata, NULL); 392 390 synchronize_net(); ··· 397 389 drv_remove_interface(local, sdata); 398 390 399 391 kfree(sdata); 392 + out_unlock: 393 + mutex_unlock(&local->iflist_mtx); 400 394 } 401 395 402 396 /* ··· 497 487 break; 498 488 } 499 489 490 + if (local->monitors == 0 && local->open_count == 0) { 491 + res = ieee80211_add_virtual_monitor(local); 492 + if (res) 493 + goto err_stop; 494 + } 495 + 500 496 /* must be before the call to ieee80211_configure_filter */ 501 497 local->monitors++; 502 498 if (local->monitors == 1) { ··· 517 501 break; 518 502 default: 519 503 if (coming_up) { 504 + ieee80211_del_virtual_monitor(local); 505 + 520 506 res = drv_add_interface(local, sdata); 521 507 if (res) 522 508 goto err_stop; ··· 646 628 647 629 clear_bit(SDATA_STATE_RUNNING, &sdata->state); 648 630 649 - if (local->scan_sdata == sdata) 631 + if (rcu_access_pointer(local->scan_sdata) == sdata) 650 632 ieee80211_scan_cancel(local); 651 633 652 634 /* ··· 753 735 if (local->monitors == 0) { 754 736 local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; 755 737 hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR; 738 + ieee80211_del_virtual_monitor(local); 756 739 } 757 740 758 741 ieee80211_adjust_monitor_flags(sdata, -1); ··· 827 808 } 828 809 } 829 810 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 811 + 812 + if (local->monitors == local->open_count && local->monitors > 0) 813 + ieee80211_add_virtual_monitor(local); 830 814 } 831 815 832 816 static int ieee80211_stop(struct net_device *dev) ··· 1395 1373 } 1396 1374 1397 1375 int ieee80211_if_add(struct ieee80211_local *local, const char *name, 1398 - struct net_device **new_dev, enum nl80211_iftype type, 1376 + struct wireless_dev **new_wdev, enum nl80211_iftype type, 1399 1377 struct vif_params *params) 1400 1378 { 1401 1379 struct net_device *ndev; ··· 1485 1463 list_add_tail_rcu(&sdata->list, &local->interfaces); 1486 1464 mutex_unlock(&local->iflist_mtx); 1487 1465 1488 - if (new_dev) 1489 - *new_dev = ndev; 1466 + if (new_wdev) 1467 + *new_wdev = &sdata->wdev; 1490 1468 1491 1469 return 0; 1492 1470
-20
net/mac80211/key.c
··· 194 194 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 195 195 } 196 196 197 - void ieee80211_key_removed(struct ieee80211_key_conf *key_conf) 198 - { 199 - struct ieee80211_key *key; 200 - 201 - key = container_of(key_conf, struct ieee80211_key, conf); 202 - 203 - might_sleep(); 204 - assert_key_lock(key->local); 205 - 206 - key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 207 - 208 - /* 209 - * Flush TX path to avoid attempts to use this key 210 - * after this function returns. Until then, drivers 211 - * must be prepared to handle the key. 212 - */ 213 - synchronize_rcu(); 214 - } 215 - EXPORT_SYMBOL_GPL(ieee80211_key_removed); 216 - 217 197 static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, 218 198 int idx, bool uni, bool multi) 219 199 {
+2 -1
net/mac80211/main.c
··· 322 322 323 323 mutex_lock(&local->mtx); 324 324 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) || 325 - local->sched_scanning, 325 + rcu_dereference_protected(local->sched_scan_sdata, 326 + lockdep_is_held(&local->mtx)), 326 327 "%s called with hardware scan in progress\n", __func__); 327 328 mutex_unlock(&local->mtx); 328 329
+34 -28
net/mac80211/mlme.c
··· 1108 1108 } 1109 1109 1110 1110 /* MLME */ 1111 - static void ieee80211_sta_wmm_params(struct ieee80211_local *local, 1111 + static bool ieee80211_sta_wmm_params(struct ieee80211_local *local, 1112 1112 struct ieee80211_sub_if_data *sdata, 1113 1113 u8 *wmm_param, size_t wmm_param_len) 1114 1114 { ··· 1119 1119 u8 *pos, uapsd_queues = 0; 1120 1120 1121 1121 if (!local->ops->conf_tx) 1122 - return; 1122 + return false; 1123 1123 1124 1124 if (local->hw.queues < IEEE80211_NUM_ACS) 1125 - return; 1125 + return false; 1126 1126 1127 1127 if (!wmm_param) 1128 - return; 1128 + return false; 1129 1129 1130 1130 if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) 1131 - return; 1131 + return false; 1132 1132 1133 1133 if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) 1134 1134 uapsd_queues = ifmgd->uapsd_queues; 1135 1135 1136 1136 count = wmm_param[6] & 0x0f; 1137 1137 if (count == ifmgd->wmm_last_param_set) 1138 - return; 1138 + return false; 1139 1139 ifmgd->wmm_last_param_set = count; 1140 1140 1141 1141 pos = wmm_param + 8; ··· 1202 1202 1203 1203 /* enable WMM or activate new settings */ 1204 1204 sdata->vif.bss_conf.qos = true; 1205 + return true; 1205 1206 } 1206 1207 1207 1208 static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata) ··· 1269 1268 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 1270 1269 1271 1270 bss_info_changed |= BSS_CHANGED_ASSOC; 1272 - /* set timing information */ 1273 - bss_conf->beacon_int = cbss->beacon_interval; 1274 - bss_conf->last_tsf = cbss->tsf; 1275 - 1276 - bss_info_changed |= BSS_CHANGED_BEACON_INT; 1277 1271 bss_info_changed |= ieee80211_handle_bss_capability(sdata, 1278 1272 bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); 1279 1273 ··· 1360 1364 } 1361 1365 mutex_unlock(&local->sta_mtx); 1362 1366 1367 + /* 1368 + * if we want to get out of ps before disassoc (why?) we have 1369 + * to do it before sending disassoc, as otherwise the null-packet 1370 + * won't be valid. 1371 + */ 1372 + if (local->hw.conf.flags & IEEE80211_CONF_PS) { 1373 + local->hw.conf.flags &= ~IEEE80211_CONF_PS; 1374 + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 1375 + } 1376 + local->ps_sdata = NULL; 1377 + 1363 1378 /* flush out any pending frame (e.g. DELBA) before deauth/disassoc */ 1364 1379 if (tx) 1365 1380 drv_flush(local, false); ··· 1405 1398 1406 1399 del_timer_sync(&local->dynamic_ps_timer); 1407 1400 cancel_work_sync(&local->dynamic_ps_enable_work); 1408 - 1409 - if (local->hw.conf.flags & IEEE80211_CONF_PS) { 1410 - local->hw.conf.flags &= ~IEEE80211_CONF_PS; 1411 - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 1412 - } 1413 - local->ps_sdata = NULL; 1414 1401 1415 1402 /* Disable ARP filtering */ 1416 1403 if (sdata->vif.bss_conf.arp_filter_enabled) { ··· 2436 2435 directed_tim = ieee80211_check_tim(elems.tim, elems.tim_len, 2437 2436 ifmgd->aid); 2438 2437 2439 - if (ncrc != ifmgd->beacon_crc || !ifmgd->beacon_crc_valid) { 2440 - ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, 2441 - true); 2442 - 2443 - ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, 2444 - elems.wmm_param_len); 2445 - } 2446 - 2447 2438 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { 2448 2439 if (directed_tim) { 2449 2440 if (local->hw.conf.dynamic_ps_timeout > 0) { ··· 2465 2472 return; 2466 2473 ifmgd->beacon_crc = ncrc; 2467 2474 ifmgd->beacon_crc_valid = true; 2475 + 2476 + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, 2477 + true); 2478 + 2479 + if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, 2480 + elems.wmm_param_len)) 2481 + changed |= BSS_CHANGED_QOS; 2468 2482 2469 2483 if (elems.erp_info && elems.erp_info_len >= 1) { 2470 2484 erp_valid = true; ··· 2974 2974 /* scan finished notification */ 2975 2975 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) 2976 2976 { 2977 - struct ieee80211_sub_if_data *sdata = local->scan_sdata; 2977 + struct ieee80211_sub_if_data *sdata; 2978 2978 2979 2979 /* Restart STA timers */ 2980 2980 rcu_read_lock(); ··· 3132 3132 3133 3133 memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN); 3134 3134 3135 - /* tell driver about BSSID and basic rates */ 3135 + /* set timing information */ 3136 + sdata->vif.bss_conf.beacon_int = cbss->beacon_interval; 3137 + sdata->vif.bss_conf.sync_tsf = cbss->tsf; 3138 + sdata->vif.bss_conf.sync_device_ts = bss->device_ts; 3139 + 3140 + /* tell driver about BSSID, basic rates and timing */ 3136 3141 ieee80211_bss_info_change_notify(sdata, 3137 - BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES); 3142 + BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES | 3143 + BSS_CHANGED_BEACON_INT); 3138 3144 3139 3145 if (assoc) 3140 3146 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
+7 -5
net/mac80211/offchannel.c
··· 191 191 roc->frame = NULL; 192 192 } 193 193 } else { 194 - cfg80211_ready_on_channel(roc->sdata->dev, (unsigned long)roc, 194 + cfg80211_ready_on_channel(&roc->sdata->wdev, (unsigned long)roc, 195 195 roc->chan, roc->chan_type, 196 196 roc->req_duration, GFP_KERNEL); 197 197 } ··· 299 299 300 300 /* was never transmitted */ 301 301 if (roc->frame) { 302 - cfg80211_mgmt_tx_status(roc->sdata->dev, 302 + cfg80211_mgmt_tx_status(&roc->sdata->wdev, 303 303 (unsigned long)roc->frame, 304 304 roc->frame->data, roc->frame->len, 305 305 false, GFP_KERNEL); ··· 307 307 } 308 308 309 309 if (!roc->mgmt_tx_cookie) 310 - cfg80211_remain_on_channel_expired(roc->sdata->dev, 310 + cfg80211_remain_on_channel_expired(&roc->sdata->wdev, 311 311 (unsigned long)roc, 312 312 roc->chan, roc->chan_type, 313 313 GFP_KERNEL); ··· 324 324 container_of(work, struct ieee80211_roc_work, work.work); 325 325 struct ieee80211_sub_if_data *sdata = roc->sdata; 326 326 struct ieee80211_local *local = sdata->local; 327 + bool started; 327 328 328 329 mutex_lock(&local->mtx); 329 330 ··· 367 366 /* finish this ROC */ 368 367 finish: 369 368 list_del(&roc->list); 369 + started = roc->started; 370 370 ieee80211_roc_notify_destroy(roc); 371 371 372 - if (roc->started) { 372 + if (started) { 373 373 drv_flush(local, false); 374 374 375 375 local->tmp_channel = NULL; ··· 381 379 382 380 ieee80211_recalc_idle(local); 383 381 384 - if (roc->started) 382 + if (started) 385 383 ieee80211_start_next_roc(local); 386 384 } 387 385
+6 -2
net/mac80211/rc80211_minstrel_ht.c
··· 626 626 627 627 #ifdef CONFIG_MAC80211_DEBUGFS 628 628 /* use fixed index if set */ 629 - if (mp->fixed_rate_idx != -1) 630 - sample_idx = mp->fixed_rate_idx; 629 + if (mp->fixed_rate_idx != -1) { 630 + mi->max_tp_rate = mp->fixed_rate_idx; 631 + mi->max_tp_rate2 = mp->fixed_rate_idx; 632 + mi->max_prob_rate = mp->fixed_rate_idx; 633 + sample_idx = -1; 634 + } 631 635 #endif 632 636 633 637 if (sample_idx >= 0) {
+9 -40
net/mac80211/rx.c
··· 413 413 414 414 /* rx handlers */ 415 415 416 - static ieee80211_rx_result debug_noinline 417 - ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) 418 - { 419 - struct ieee80211_local *local = rx->local; 420 - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); 421 - struct sk_buff *skb = rx->skb; 422 - 423 - if (likely(!(status->rx_flags & IEEE80211_RX_IN_SCAN) && 424 - !local->sched_scanning)) 425 - return RX_CONTINUE; 426 - 427 - if (test_bit(SCAN_HW_SCANNING, &local->scanning) || 428 - test_bit(SCAN_SW_SCANNING, &local->scanning) || 429 - test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) || 430 - local->sched_scanning) 431 - return ieee80211_scan_rx(rx->sdata, skb); 432 - 433 - /* scanning finished during invoking of handlers */ 434 - I802_DEBUG_INC(local->rx_handlers_drop_passive_scan); 435 - return RX_DROP_UNUSABLE; 436 - } 437 - 438 - 439 416 static int ieee80211_is_unicast_robust_mgmt_frame(struct sk_buff *skb) 440 417 { 441 418 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; ··· 2381 2404 if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 2382 2405 sig = status->signal; 2383 2406 2384 - if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, sig, 2407 + if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig, 2385 2408 rx->skb->data, rx->skb->len, 2386 2409 GFP_ATOMIC)) { 2387 2410 if (rx->sta) ··· 2672 2695 goto rxh_next; \ 2673 2696 } while (0); 2674 2697 2675 - CALL_RXH(ieee80211_rx_h_passive_scan) 2676 2698 CALL_RXH(ieee80211_rx_h_check) 2677 2699 2678 2700 ieee80211_rx_reorder_ampdu(rx); ··· 2741 2765 return 0; 2742 2766 if (ieee80211_is_beacon(hdr->frame_control)) { 2743 2767 return 1; 2744 - } 2745 - else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { 2746 - if (!(status->rx_flags & IEEE80211_RX_IN_SCAN)) 2747 - return 0; 2748 - status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 2768 + } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { 2769 + return 0; 2749 2770 } else if (!multicast && 2750 2771 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 2751 2772 if (!(sdata->dev->flags & IFF_PROMISC)) ··· 2780 2807 * and location updates. Note that mac80211 2781 2808 * itself never looks at these frames. 2782 2809 */ 2783 - if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) && 2784 - ieee80211_is_public_action(hdr, skb->len)) 2810 + if (ieee80211_is_public_action(hdr, skb->len)) 2785 2811 return 1; 2786 - if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) && 2787 - !ieee80211_is_beacon(hdr->frame_control)) 2812 + if (!ieee80211_is_beacon(hdr->frame_control)) 2788 2813 return 0; 2789 2814 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 2790 2815 } ··· 2848 2877 static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, 2849 2878 struct sk_buff *skb) 2850 2879 { 2851 - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 2852 2880 struct ieee80211_local *local = hw_to_local(hw); 2853 2881 struct ieee80211_sub_if_data *sdata; 2854 2882 struct ieee80211_hdr *hdr; ··· 2865 2895 if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) 2866 2896 local->dot11ReceivedFragmentCount++; 2867 2897 2868 - if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) || 2869 - test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) || 2870 - test_bit(SCAN_SW_SCANNING, &local->scanning))) 2871 - status->rx_flags |= IEEE80211_RX_IN_SCAN; 2872 - 2873 2898 if (ieee80211_is_mgmt(fc)) 2874 2899 err = skb_linearize(skb); 2875 2900 else ··· 2878 2913 hdr = (struct ieee80211_hdr *)skb->data; 2879 2914 ieee80211_parse_qos(&rx); 2880 2915 ieee80211_verify_alignment(&rx); 2916 + 2917 + if (unlikely(ieee80211_is_probe_resp(hdr->frame_control) || 2918 + ieee80211_is_beacon(hdr->frame_control))) 2919 + ieee80211_scan_rx(local, skb); 2881 2920 2882 2921 if (ieee80211_is_data(fc)) { 2883 2922 prev_sta = NULL;
+62 -54
net/mac80211/scan.c
··· 83 83 84 84 cbss = cfg80211_inform_bss_frame(local->hw.wiphy, channel, 85 85 mgmt, len, signal, GFP_ATOMIC); 86 - 87 86 if (!cbss) 88 87 return NULL; 89 88 90 89 cbss->free_priv = ieee80211_rx_bss_free; 91 90 bss = (void *)cbss->priv; 91 + 92 + bss->device_ts = rx_status->device_timestamp; 92 93 93 94 if (elems->parse_error) { 94 95 if (beacon) ··· 165 164 return bss; 166 165 } 167 166 168 - ieee80211_rx_result 169 - ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) 167 + void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) 170 168 { 171 169 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); 172 - struct ieee80211_mgmt *mgmt; 170 + struct ieee80211_sub_if_data *sdata1, *sdata2; 171 + struct ieee80211_mgmt *mgmt = (void *)skb->data; 173 172 struct ieee80211_bss *bss; 174 173 u8 *elements; 175 174 struct ieee80211_channel *channel; 176 175 size_t baselen; 177 176 int freq; 178 - __le16 fc; 179 - bool presp, beacon = false; 177 + bool beacon; 180 178 struct ieee802_11_elems elems; 181 179 182 - if (skb->len < 2) 183 - return RX_DROP_UNUSABLE; 180 + if (skb->len < 24 || 181 + (!ieee80211_is_probe_resp(mgmt->frame_control) && 182 + !ieee80211_is_beacon(mgmt->frame_control))) 183 + return; 184 184 185 - mgmt = (struct ieee80211_mgmt *) skb->data; 186 - fc = mgmt->frame_control; 185 + sdata1 = rcu_dereference(local->scan_sdata); 186 + sdata2 = rcu_dereference(local->sched_scan_sdata); 187 187 188 - if (ieee80211_is_ctl(fc)) 189 - return RX_CONTINUE; 188 + if (likely(!sdata1 && !sdata2)) 189 + return; 190 190 191 - if (skb->len < 24) 192 - return RX_CONTINUE; 193 - 194 - presp = ieee80211_is_probe_resp(fc); 195 - if (presp) { 191 + if (ieee80211_is_probe_resp(mgmt->frame_control)) { 196 192 /* ignore ProbeResp to foreign address */ 197 - if (!ether_addr_equal(mgmt->da, sdata->vif.addr)) 198 - return RX_DROP_MONITOR; 193 + if ((!sdata1 || !ether_addr_equal(mgmt->da, sdata1->vif.addr)) && 194 + (!sdata2 || !ether_addr_equal(mgmt->da, sdata2->vif.addr))) 195 + return; 199 196 200 - presp = true; 201 197 elements = mgmt->u.probe_resp.variable; 202 198 baselen = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); 199 + beacon = false; 203 200 } else { 204 - beacon = ieee80211_is_beacon(fc); 205 201 baselen = offsetof(struct ieee80211_mgmt, u.beacon.variable); 206 202 elements = mgmt->u.beacon.variable; 203 + beacon = true; 207 204 } 208 205 209 - if (!presp && !beacon) 210 - return RX_CONTINUE; 211 - 212 206 if (baselen > skb->len) 213 - return RX_DROP_MONITOR; 207 + return; 214 208 215 209 ieee802_11_parse_elems(elements, skb->len - baselen, &elems); 216 210 ··· 215 219 else 216 220 freq = rx_status->freq; 217 221 218 - channel = ieee80211_get_channel(sdata->local->hw.wiphy, freq); 222 + channel = ieee80211_get_channel(local->hw.wiphy, freq); 219 223 220 224 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) 221 - return RX_DROP_MONITOR; 225 + return; 222 226 223 - bss = ieee80211_bss_info_update(sdata->local, rx_status, 227 + bss = ieee80211_bss_info_update(local, rx_status, 224 228 mgmt, skb->len, &elems, 225 229 channel, beacon); 226 230 if (bss) 227 - ieee80211_rx_bss_put(sdata->local, bss); 228 - 229 - if (channel == sdata->local->oper_channel) 230 - return RX_CONTINUE; 231 - 232 - dev_kfree_skb(skb); 233 - return RX_QUEUED; 231 + ieee80211_rx_bss_put(local, bss); 234 232 } 235 233 236 234 /* return false if no more work */ ··· 282 292 return; 283 293 284 294 if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) { 285 - int rc = drv_hw_scan(local, local->scan_sdata, local->hw_scan_req); 295 + int rc; 296 + 297 + rc = drv_hw_scan(local, 298 + rcu_dereference_protected(local->scan_sdata, 299 + lockdep_is_held(&local->mtx)), 300 + local->hw_scan_req); 301 + 286 302 if (rc == 0) 287 303 return; 288 304 } ··· 389 393 if (!local->scan_req || local->scanning) 390 394 return; 391 395 392 - if (!ieee80211_can_scan(local, local->scan_sdata)) 396 + if (!ieee80211_can_scan(local, 397 + rcu_dereference_protected( 398 + local->scan_sdata, 399 + lockdep_is_held(&local->mtx)))) 393 400 return; 394 401 395 402 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, ··· 403 404 unsigned long *next_delay) 404 405 { 405 406 int i; 406 - struct ieee80211_sub_if_data *sdata = local->scan_sdata; 407 + struct ieee80211_sub_if_data *sdata; 407 408 enum ieee80211_band band = local->hw.conf.channel->band; 409 + 410 + sdata = rcu_dereference_protected(local->scan_sdata, 411 + lockdep_is_held(&local->mtx));; 408 412 409 413 for (i = 0; i < local->scan_req->n_ssids; i++) 410 414 ieee80211_send_probe_req( ··· 440 438 if (!ieee80211_can_scan(local, sdata)) { 441 439 /* wait for the work to finish/time out */ 442 440 local->scan_req = req; 443 - local->scan_sdata = sdata; 441 + rcu_assign_pointer(local->scan_sdata, sdata); 444 442 return 0; 445 443 } 446 444 ··· 474 472 } 475 473 476 474 local->scan_req = req; 477 - local->scan_sdata = sdata; 475 + rcu_assign_pointer(local->scan_sdata, sdata); 478 476 479 477 if (local->ops->hw_scan) { 480 478 __set_bit(SCAN_HW_SCANNING, &local->scanning); ··· 534 532 ieee80211_recalc_idle(local); 535 533 536 534 local->scan_req = NULL; 537 - local->scan_sdata = NULL; 535 + rcu_assign_pointer(local->scan_sdata, NULL); 538 536 } 539 537 540 538 return rc; ··· 721 719 722 720 mutex_lock(&local->mtx); 723 721 724 - sdata = local->scan_sdata; 722 + sdata = rcu_dereference_protected(local->scan_sdata, 723 + lockdep_is_held(&local->mtx)); 725 724 726 725 /* When scanning on-channel, the first-callback means completed. */ 727 726 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) { ··· 743 740 int rc; 744 741 745 742 local->scan_req = NULL; 746 - local->scan_sdata = NULL; 743 + rcu_assign_pointer(local->scan_sdata, NULL); 747 744 748 745 rc = __ieee80211_start_scan(sdata, req); 749 746 if (rc) { ··· 895 892 896 893 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) { 897 894 if (local->ops->cancel_hw_scan) 898 - drv_cancel_hw_scan(local, local->scan_sdata); 895 + drv_cancel_hw_scan(local, 896 + rcu_dereference_protected(local->scan_sdata, 897 + lockdep_is_held(&local->mtx))); 899 898 goto out; 900 899 } 901 900 ··· 919 914 struct ieee80211_local *local = sdata->local; 920 915 int ret, i; 921 916 922 - mutex_lock(&sdata->local->mtx); 917 + mutex_lock(&local->mtx); 923 918 924 - if (local->sched_scanning) { 919 + if (rcu_access_pointer(local->sched_scan_sdata)) { 925 920 ret = -EBUSY; 926 921 goto out; 927 922 } ··· 932 927 } 933 928 934 929 for (i = 0; i < IEEE80211_NUM_BANDS; i++) { 930 + if (!local->hw.wiphy->bands[i]) 931 + continue; 932 + 935 933 local->sched_scan_ies.ie[i] = kzalloc(2 + 936 934 IEEE80211_MAX_SSID_LEN + 937 935 local->scan_ies_len + ··· 955 947 ret = drv_sched_scan_start(local, sdata, req, 956 948 &local->sched_scan_ies); 957 949 if (ret == 0) { 958 - local->sched_scanning = true; 950 + rcu_assign_pointer(local->sched_scan_sdata, sdata); 959 951 goto out; 960 952 } 961 953 ··· 963 955 while (i > 0) 964 956 kfree(local->sched_scan_ies.ie[--i]); 965 957 out: 966 - mutex_unlock(&sdata->local->mtx); 958 + mutex_unlock(&local->mtx); 967 959 return ret; 968 960 } 969 961 ··· 972 964 struct ieee80211_local *local = sdata->local; 973 965 int ret = 0, i; 974 966 975 - mutex_lock(&sdata->local->mtx); 967 + mutex_lock(&local->mtx); 976 968 977 969 if (!local->ops->sched_scan_stop) { 978 970 ret = -ENOTSUPP; 979 971 goto out; 980 972 } 981 973 982 - if (local->sched_scanning) { 974 + if (rcu_access_pointer(local->sched_scan_sdata)) { 983 975 for (i = 0; i < IEEE80211_NUM_BANDS; i++) 984 976 kfree(local->sched_scan_ies.ie[i]); 985 977 986 978 drv_sched_scan_stop(local, sdata); 987 - local->sched_scanning = false; 979 + rcu_assign_pointer(local->sched_scan_sdata, NULL); 988 980 } 989 981 out: 990 - mutex_unlock(&sdata->local->mtx); 982 + mutex_unlock(&local->mtx); 991 983 992 984 return ret; 993 985 } ··· 1011 1003 1012 1004 mutex_lock(&local->mtx); 1013 1005 1014 - if (!local->sched_scanning) { 1006 + if (!rcu_access_pointer(local->sched_scan_sdata)) { 1015 1007 mutex_unlock(&local->mtx); 1016 1008 return; 1017 1009 } ··· 1019 1011 for (i = 0; i < IEEE80211_NUM_BANDS; i++) 1020 1012 kfree(local->sched_scan_ies.ie[i]); 1021 1013 1022 - local->sched_scanning = false; 1014 + rcu_assign_pointer(local->sched_scan_sdata, NULL); 1023 1015 1024 1016 mutex_unlock(&local->mtx); 1025 1017
+7 -2
net/mac80211/status.c
··· 519 519 u64 cookie = (unsigned long)skb; 520 520 acked = info->flags & IEEE80211_TX_STAT_ACK; 521 521 522 + /* 523 + * TODO: When we have non-netdev frame TX, 524 + * we cannot use skb->dev->ieee80211_ptr 525 + */ 526 + 522 527 if (ieee80211_is_nullfunc(hdr->frame_control) || 523 528 ieee80211_is_qos_nullfunc(hdr->frame_control)) 524 529 cfg80211_probe_status(skb->dev, hdr->addr1, 525 530 cookie, acked, GFP_ATOMIC); 526 531 else 527 532 cfg80211_mgmt_tx_status( 528 - skb->dev, cookie, skb->data, skb->len, 529 - acked, GFP_ATOMIC); 533 + skb->dev->ieee80211_ptr, cookie, skb->data, 534 + skb->len, acked, GFP_ATOMIC); 530 535 } 531 536 532 537 if (unlikely(info->ack_frame_id)) {
+4 -2
net/mac80211/trace.h
··· 306 306 __field(u8, dtimper) 307 307 __field(u16, bcnint) 308 308 __field(u16, assoc_cap) 309 - __field(u64, timestamp) 309 + __field(u64, sync_tsf) 310 + __field(u32, sync_device_ts) 310 311 __field(u32, basic_rates) 311 312 __field(u32, changed) 312 313 __field(bool, enable_beacon) ··· 326 325 __entry->dtimper = info->dtim_period; 327 326 __entry->bcnint = info->beacon_int; 328 327 __entry->assoc_cap = info->assoc_capability; 329 - __entry->timestamp = info->last_tsf; 328 + __entry->sync_tsf = info->sync_tsf; 329 + __entry->sync_device_ts = info->sync_device_ts; 330 330 __entry->basic_rates = info->basic_rates; 331 331 __entry->enable_beacon = info->enable_beacon; 332 332 __entry->ht_operation_mode = info->ht_operation_mode;
+20 -10
net/mac80211/tx.c
··· 523 523 static ieee80211_tx_result debug_noinline 524 524 ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) 525 525 { 526 - struct ieee80211_key *key = NULL; 526 + struct ieee80211_key *key; 527 527 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 528 528 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 529 529 ··· 542 542 else if (!is_multicast_ether_addr(hdr->addr1) && 543 543 (key = rcu_dereference(tx->sdata->default_unicast_key))) 544 544 tx->key = key; 545 - else if (tx->sdata->drop_unencrypted && 546 - (tx->skb->protocol != tx->sdata->control_port_protocol) && 547 - !(info->flags & IEEE80211_TX_CTL_INJECTED) && 548 - (!ieee80211_is_robust_mgmt_frame(hdr) || 549 - (ieee80211_is_action(hdr->frame_control) && 550 - tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))) { 545 + else if (info->flags & IEEE80211_TX_CTL_INJECTED) 546 + tx->key = NULL; 547 + else if (!tx->sdata->drop_unencrypted) 548 + tx->key = NULL; 549 + else if (tx->skb->protocol == tx->sdata->control_port_protocol) 550 + tx->key = NULL; 551 + else if (ieee80211_is_robust_mgmt_frame(hdr) && 552 + !(ieee80211_is_action(hdr->frame_control) && 553 + tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP))) 554 + tx->key = NULL; 555 + else if (ieee80211_is_mgmt(hdr->frame_control) && 556 + !ieee80211_is_robust_mgmt_frame(hdr)) 557 + tx->key = NULL; 558 + else { 551 559 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); 552 560 return TX_DROP; 553 - } else 554 - tx->key = NULL; 561 + } 555 562 556 563 if (tx->key) { 557 564 bool skip_hw = false; ··· 1824 1817 /* RA TA mDA mSA AE:DA SA */ 1825 1818 mesh_da = mppath->mpp; 1826 1819 is_mesh_mcast = 0; 1820 + } else if (mpath) { 1821 + mesh_da = mpath->dst; 1822 + is_mesh_mcast = 0; 1827 1823 } else { 1828 1824 /* DA TA mSA AE:SA */ 1829 1825 mesh_da = bcast; ··· 2724 2714 void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, 2725 2715 struct sk_buff *skb, int tid) 2726 2716 { 2727 - int ac = ieee802_1d_to_ac[tid]; 2717 + int ac = ieee802_1d_to_ac[tid & 7]; 2728 2718 2729 2719 skb_set_mac_header(skb, 0); 2730 2720 skb_set_network_header(skb, 0);
+11
net/mac80211/util.c
··· 529 529 &sdata->vif); 530 530 } 531 531 532 + sdata = rcu_dereference_protected(local->monitor_sdata, 533 + lockdep_is_held(&local->iflist_mtx)); 534 + if (sdata) 535 + iterator(data, sdata->vif.addr, &sdata->vif); 536 + 532 537 mutex_unlock(&local->iflist_mtx); 533 538 } 534 539 EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces); ··· 561 556 iterator(data, sdata->vif.addr, 562 557 &sdata->vif); 563 558 } 559 + 560 + sdata = rcu_dereference(local->monitor_sdata); 561 + if (sdata) 562 + iterator(data, sdata->vif.addr, &sdata->vif); 564 563 565 564 rcu_read_unlock(); 566 565 } ··· 1008 999 int ext_rates_len; 1009 1000 1010 1001 sband = local->hw.wiphy->bands[band]; 1002 + if (WARN_ON_ONCE(!sband)) 1003 + return 0; 1011 1004 1012 1005 pos = buffer; 1013 1006
+17 -3
net/nfc/hci/core.c
··· 187 187 struct nfc_target *targets; 188 188 struct sk_buff *atqa_skb = NULL; 189 189 struct sk_buff *sak_skb = NULL; 190 + struct sk_buff *uid_skb = NULL; 190 191 int r; 191 192 192 193 pr_debug("from gate %d\n", gate); ··· 222 221 223 222 targets->sens_res = be16_to_cpu(*(u16 *)atqa_skb->data); 224 223 targets->sel_res = sak_skb->data[0]; 224 + 225 + r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, 226 + NFC_HCI_RF_READER_A_UID, &uid_skb); 227 + if (r < 0) 228 + goto exit; 229 + 230 + if (uid_skb->len == 0 || uid_skb->len > NFC_NFCID1_MAXSIZE) { 231 + r = -EPROTO; 232 + goto exit; 233 + } 234 + 235 + memcpy(targets->nfcid1, uid_skb->data, uid_skb->len); 236 + targets->nfcid1_len = uid_skb->len; 225 237 226 238 if (hdev->ops->complete_target_discovered) { 227 239 r = hdev->ops->complete_target_discovered(hdev, gate, ··· 271 257 kfree(targets); 272 258 kfree_skb(atqa_skb); 273 259 kfree_skb(sak_skb); 260 + kfree_skb(uid_skb); 274 261 275 262 return r; 276 263 } ··· 710 695 711 696 void nfc_hci_unregister_device(struct nfc_hci_dev *hdev) 712 697 { 713 - struct hci_msg *msg; 698 + struct hci_msg *msg, *n; 714 699 715 700 skb_queue_purge(&hdev->rx_hcp_frags); 716 701 skb_queue_purge(&hdev->msg_rx_queue); 717 702 718 - while ((msg = list_first_entry(&hdev->msg_tx_queue, struct hci_msg, 719 - msg_l)) != NULL) { 703 + list_for_each_entry_safe(msg, n, &hdev->msg_tx_queue, msg_l) { 720 704 list_del(&msg->msg_l); 721 705 skb_queue_purge(&msg->msg_frags); 722 706 kfree(msg);
+1 -1
net/nfc/hci/hcp.c
··· 105 105 } 106 106 107 107 mutex_lock(&hdev->msg_tx_mutex); 108 - list_add_tail(&hdev->msg_tx_queue, &cmd->msg_l); 108 + list_add_tail(&cmd->msg_l, &hdev->msg_tx_queue); 109 109 mutex_unlock(&hdev->msg_tx_mutex); 110 110 111 111 queue_work(hdev->msg_tx_wq, &hdev->msg_tx_work);
+3
net/nfc/nci/core.c
··· 27 27 28 28 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ 29 29 30 + #include <linux/module.h> 30 31 #include <linux/types.h> 31 32 #include <linux/workqueue.h> 32 33 #include <linux/completion.h> ··· 881 880 jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT)); 882 881 } 883 882 } 883 + 884 + MODULE_LICENSE("GPL");
+21
net/wireless/Kconfig
··· 74 74 75 75 If unsure, say N. 76 76 77 + config CFG80211_CERTIFICATION_ONUS 78 + bool "cfg80211 certification onus" 79 + depends on CFG80211 && EXPERT 80 + default n 81 + ---help--- 82 + You should disable this option unless you are both capable 83 + and willing to ensure your system will remain regulatory 84 + compliant with the features available under this option. 85 + Some options may still be under heavy development and 86 + for whatever reason regulatory compliance has not or 87 + cannot yet be verified. Regulatory verification may at 88 + times only be possible until you have the final system 89 + in place. 90 + 91 + This option should only be enabled by system integrators 92 + or distributions that have done work necessary to ensure 93 + regulatory certification on the system with the enabled 94 + features. Alternatively you can enable this option if 95 + you are a wireless researcher and are working in a controlled 96 + and approved environment by your local regulatory agency. 97 + 77 98 config CFG80211_DEFAULT_PS 78 99 bool "enable powersave by default" 79 100 depends on CFG80211
+11 -13
net/wireless/chan.c
··· 82 82 int freq, enum nl80211_channel_type chantype) 83 83 { 84 84 struct ieee80211_channel *chan; 85 - int err; 86 85 87 86 if (!rdev->ops->set_monitor_channel) 88 87 return -EOPNOTSUPP; ··· 92 93 if (!chan) 93 94 return -EINVAL; 94 95 95 - err = rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype); 96 - if (!err) { 97 - rdev->monitor_channel = chan; 98 - rdev->monitor_channel_type = chantype; 99 - } 100 - 101 - return err; 96 + return rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype); 102 97 } 103 98 104 99 void 105 - cfg80211_get_chan_state(struct cfg80211_registered_device *rdev, 106 - struct wireless_dev *wdev, 100 + cfg80211_get_chan_state(struct wireless_dev *wdev, 107 101 struct ieee80211_channel **chan, 108 102 enum cfg80211_chan_mode *chanmode) 109 103 { 110 104 *chan = NULL; 111 105 *chanmode = CHAN_MODE_UNDEFINED; 112 106 113 - ASSERT_RDEV_LOCK(rdev); 114 107 ASSERT_WDEV_LOCK(wdev); 115 108 116 109 if (!netif_running(wdev->netdev)) ··· 127 136 break; 128 137 case NL80211_IFTYPE_AP: 129 138 case NL80211_IFTYPE_P2P_GO: 139 + if (wdev->beacon_interval) { 140 + *chan = wdev->channel; 141 + *chanmode = CHAN_MODE_SHARED; 142 + } 143 + return; 130 144 case NL80211_IFTYPE_MESH_POINT: 131 - *chan = wdev->channel; 132 - *chanmode = CHAN_MODE_SHARED; 145 + if (wdev->mesh_id_len) { 146 + *chan = wdev->channel; 147 + *chanmode = CHAN_MODE_SHARED; 148 + } 133 149 return; 134 150 case NL80211_IFTYPE_MONITOR: 135 151 case NL80211_IFTYPE_AP_VLAN:
+21 -58
net/wireless/core.c
··· 176 176 if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK)) 177 177 return -EOPNOTSUPP; 178 178 179 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 179 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 180 + if (!wdev->netdev) 181 + continue; 180 182 wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; 181 183 err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); 182 184 if (err) ··· 190 188 /* failed -- clean up to old netns */ 191 189 net = wiphy_net(&rdev->wiphy); 192 190 193 - list_for_each_entry_continue_reverse(wdev, &rdev->netdev_list, 191 + list_for_each_entry_continue_reverse(wdev, &rdev->wdev_list, 194 192 list) { 193 + if (!wdev->netdev) 194 + continue; 195 195 wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; 196 196 err = dev_change_net_namespace(wdev->netdev, net, 197 197 "wlan%d"); ··· 230 226 rtnl_lock(); 231 227 mutex_lock(&rdev->devlist_mtx); 232 228 233 - list_for_each_entry(wdev, &rdev->netdev_list, list) 234 - dev_close(wdev->netdev); 229 + list_for_each_entry(wdev, &rdev->wdev_list, list) 230 + if (wdev->netdev) 231 + dev_close(wdev->netdev); 235 232 236 233 mutex_unlock(&rdev->devlist_mtx); 237 234 rtnl_unlock(); ··· 309 304 mutex_init(&rdev->mtx); 310 305 mutex_init(&rdev->devlist_mtx); 311 306 mutex_init(&rdev->sched_scan_mtx); 312 - INIT_LIST_HEAD(&rdev->netdev_list); 307 + INIT_LIST_HEAD(&rdev->wdev_list); 313 308 spin_lock_init(&rdev->bss_lock); 314 309 INIT_LIST_HEAD(&rdev->bss_list); 315 310 INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done); ··· 542 537 } 543 538 544 539 /* set up regulatory info */ 545 - regulatory_update(wiphy, NL80211_REGDOM_SET_BY_CORE); 540 + wiphy_regulatory_register(wiphy); 546 541 547 542 list_add_rcu(&rdev->list, &cfg80211_rdev_list); 548 543 cfg80211_rdev_list_generation++; ··· 627 622 __count == 0; })); 628 623 629 624 mutex_lock(&rdev->devlist_mtx); 630 - BUG_ON(!list_empty(&rdev->netdev_list)); 625 + BUG_ON(!list_empty(&rdev->wdev_list)); 631 626 mutex_unlock(&rdev->devlist_mtx); 632 627 633 628 /* ··· 652 647 /* nothing */ 653 648 cfg80211_unlock_rdev(rdev); 654 649 655 - /* If this device got a regulatory hint tell core its 656 - * free to listen now to a new shiny device regulatory hint */ 657 - reg_device_remove(wiphy); 650 + /* 651 + * If this device got a regulatory hint tell core its 652 + * free to listen now to a new shiny device regulatory hint 653 + */ 654 + wiphy_regulatory_deregister(wiphy); 658 655 659 656 cfg80211_rdev_list_generation++; 660 657 device_del(&rdev->wiphy.dev); ··· 710 703 711 704 cfg80211_lock_rdev(rdev); 712 705 713 - if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) { 706 + if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) { 714 707 rdev->scan_req->aborted = true; 715 708 ___cfg80211_scan_done(rdev, true); 716 709 } ··· 738 731 .name = "wlan", 739 732 }; 740 733 741 - static struct ieee80211_channel * 742 - cfg80211_get_any_chan(struct cfg80211_registered_device *rdev) 743 - { 744 - struct ieee80211_supported_band *sband; 745 - int i; 746 - 747 - for (i = 0; i < IEEE80211_NUM_BANDS; i++) { 748 - sband = rdev->wiphy.bands[i]; 749 - if (sband && sband->n_channels > 0) 750 - return &sband->channels[0]; 751 - } 752 - 753 - return NULL; 754 - } 755 - 756 - static void cfg80211_init_mon_chan(struct cfg80211_registered_device *rdev) 757 - { 758 - struct ieee80211_channel *chan; 759 - 760 - chan = cfg80211_get_any_chan(rdev); 761 - if (WARN_ON(!chan)) 762 - return; 763 - 764 - mutex_lock(&rdev->devlist_mtx); 765 - WARN_ON(cfg80211_set_monitor_channel(rdev, chan->center_freq, 766 - NL80211_CHAN_NO_HT)); 767 - mutex_unlock(&rdev->devlist_mtx); 768 - } 769 - 770 734 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, 771 735 enum nl80211_iftype iftype, int num) 772 736 { 773 - bool has_monitors_only_old = cfg80211_has_monitors_only(rdev); 774 - bool has_monitors_only_new; 775 - 776 737 ASSERT_RTNL(); 777 738 778 739 rdev->num_running_ifaces += num; 779 740 if (iftype == NL80211_IFTYPE_MONITOR) 780 741 rdev->num_running_monitor_ifaces += num; 781 - 782 - has_monitors_only_new = cfg80211_has_monitors_only(rdev); 783 - if (has_monitors_only_new != has_monitors_only_old) { 784 - rdev->ops->set_monitor_enabled(&rdev->wiphy, 785 - has_monitors_only_new); 786 - 787 - if (!has_monitors_only_new) { 788 - rdev->monitor_channel = NULL; 789 - rdev->monitor_channel_type = NL80211_CHAN_NO_HT; 790 - } else { 791 - cfg80211_init_mon_chan(rdev); 792 - } 793 - } 794 742 } 795 743 796 744 static int cfg80211_netdev_notifier_call(struct notifier_block *nb, ··· 782 820 spin_lock_init(&wdev->mgmt_registrations_lock); 783 821 784 822 mutex_lock(&rdev->devlist_mtx); 785 - list_add_rcu(&wdev->list, &rdev->netdev_list); 823 + wdev->identifier = ++rdev->wdev_id; 824 + list_add_rcu(&wdev->list, &rdev->wdev_list); 786 825 rdev->devlist_generation++; 787 826 /* can only change netns with wiphy */ 788 827 dev->features |= NETIF_F_NETNS_LOCAL; ··· 868 905 mutex_unlock(&rdev->devlist_mtx); 869 906 dev_put(dev); 870 907 } 908 + cfg80211_update_iface_num(rdev, wdev->iftype, 1); 871 909 cfg80211_lock_rdev(rdev); 872 910 mutex_lock(&rdev->devlist_mtx); 873 911 wdev_lock(wdev); ··· 963 999 mutex_unlock(&rdev->devlist_mtx); 964 1000 if (ret) 965 1001 return notifier_from_errno(ret); 966 - cfg80211_update_iface_num(rdev, wdev->iftype, 1); 967 1002 break; 968 1003 } 969 1004
+5 -9
net/wireless/core.h
··· 47 47 /* wiphy index, internal only */ 48 48 int wiphy_idx; 49 49 50 - /* associate netdev list */ 50 + /* associated wireless interfaces */ 51 51 struct mutex devlist_mtx; 52 52 /* protected by devlist_mtx or RCU */ 53 - struct list_head netdev_list; 54 - int devlist_generation; 53 + struct list_head wdev_list; 54 + int devlist_generation, wdev_id; 55 55 int opencount; /* also protected by devlist_mtx */ 56 56 wait_queue_head_t dev_wait; 57 57 ··· 60 60 /* protected by RTNL only */ 61 61 int num_running_ifaces; 62 62 int num_running_monitor_ifaces; 63 - 64 - struct ieee80211_channel *monitor_channel; 65 - enum nl80211_channel_type monitor_channel_type; 66 63 67 64 /* BSSes/scanning */ 68 65 spinlock_t bss_lock; ··· 369 372 void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid); 370 373 void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev); 371 374 int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, 372 - struct net_device *dev, 375 + struct wireless_dev *wdev, 373 376 struct ieee80211_channel *chan, bool offchan, 374 377 enum nl80211_channel_type channel_type, 375 378 bool channel_type_valid, unsigned int wait, ··· 460 463 } 461 464 462 465 void 463 - cfg80211_get_chan_state(struct cfg80211_registered_device *rdev, 464 - struct wireless_dev *wdev, 466 + cfg80211_get_chan_state(struct wireless_dev *wdev, 465 467 struct ieee80211_channel **chan, 466 468 enum cfg80211_chan_mode *chanmode); 467 469
+28 -19
net/wireless/mlme.c
··· 567 567 } 568 568 } 569 569 570 - void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, 570 + void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, 571 571 struct ieee80211_channel *chan, 572 572 enum nl80211_channel_type channel_type, 573 573 unsigned int duration, gfp_t gfp) 574 574 { 575 - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 575 + struct wiphy *wiphy = wdev->wiphy; 576 576 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 577 577 578 - nl80211_send_remain_on_channel(rdev, dev, cookie, chan, channel_type, 578 + nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, channel_type, 579 579 duration, gfp); 580 580 } 581 581 EXPORT_SYMBOL(cfg80211_ready_on_channel); 582 582 583 - void cfg80211_remain_on_channel_expired(struct net_device *dev, 584 - u64 cookie, 583 + void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, 585 584 struct ieee80211_channel *chan, 586 585 enum nl80211_channel_type channel_type, 587 586 gfp_t gfp) 588 587 { 589 - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 588 + struct wiphy *wiphy = wdev->wiphy; 590 589 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 591 590 592 - nl80211_send_remain_on_channel_cancel(rdev, dev, cookie, chan, 591 + nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, 593 592 channel_type, gfp); 594 593 } 595 594 EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); ··· 677 678 list_add(&nreg->list, &wdev->mgmt_registrations); 678 679 679 680 if (rdev->ops->mgmt_frame_register) 680 - rdev->ops->mgmt_frame_register(wiphy, wdev->netdev, 681 - frame_type, true); 681 + rdev->ops->mgmt_frame_register(wiphy, wdev, frame_type, true); 682 682 683 683 out: 684 684 spin_unlock_bh(&wdev->mgmt_registrations_lock); ··· 700 702 if (rdev->ops->mgmt_frame_register) { 701 703 u16 frame_type = le16_to_cpu(reg->frame_type); 702 704 703 - rdev->ops->mgmt_frame_register(wiphy, wdev->netdev, 705 + rdev->ops->mgmt_frame_register(wiphy, wdev, 704 706 frame_type, false); 705 707 } 706 708 ··· 729 731 } 730 732 731 733 int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, 732 - struct net_device *dev, 734 + struct wireless_dev *wdev, 733 735 struct ieee80211_channel *chan, bool offchan, 734 736 enum nl80211_channel_type channel_type, 735 737 bool channel_type_valid, unsigned int wait, 736 738 const u8 *buf, size_t len, bool no_cck, 737 739 bool dont_wait_for_ack, u64 *cookie) 738 740 { 739 - struct wireless_dev *wdev = dev->ieee80211_ptr; 741 + struct net_device *dev = wdev->netdev; 740 742 const struct ieee80211_mgmt *mgmt; 741 743 u16 stype; 742 744 ··· 823 825 return -EINVAL; 824 826 825 827 /* Transmit the Action frame as requested by user space */ 826 - return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan, 828 + return rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan, 827 829 channel_type, channel_type_valid, 828 830 wait, buf, len, no_cck, dont_wait_for_ack, 829 831 cookie); 830 832 } 831 833 832 - bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_mbm, 834 + bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, 833 835 const u8 *buf, size_t len, gfp_t gfp) 834 836 { 835 - struct wireless_dev *wdev = dev->ieee80211_ptr; 836 837 struct wiphy *wiphy = wdev->wiphy; 837 838 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 838 839 struct cfg80211_mgmt_registration *reg; ··· 868 871 /* found match! */ 869 872 870 873 /* Indicate the received Action frame to user space */ 871 - if (nl80211_send_mgmt(rdev, dev, reg->nlpid, 874 + if (nl80211_send_mgmt(rdev, wdev, reg->nlpid, 872 875 freq, sig_mbm, 873 876 buf, len, gfp)) 874 877 continue; ··· 883 886 } 884 887 EXPORT_SYMBOL(cfg80211_rx_mgmt); 885 888 886 - void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, 889 + void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, 887 890 const u8 *buf, size_t len, bool ack, gfp_t gfp) 888 891 { 889 - struct wireless_dev *wdev = dev->ieee80211_ptr; 890 892 struct wiphy *wiphy = wdev->wiphy; 891 893 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 892 894 893 895 /* Indicate TX status of the Action frame to user space */ 894 - nl80211_send_mgmt_tx_status(rdev, dev, cookie, buf, len, ack, gfp); 896 + nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); 895 897 } 896 898 EXPORT_SYMBOL(cfg80211_mgmt_tx_status); 897 899 ··· 918 922 nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); 919 923 } 920 924 EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); 925 + 926 + void cfg80211_cqm_txe_notify(struct net_device *dev, 927 + const u8 *peer, u32 num_packets, 928 + u32 rate, u32 intvl, gfp_t gfp) 929 + { 930 + struct wireless_dev *wdev = dev->ieee80211_ptr; 931 + struct wiphy *wiphy = wdev->wiphy; 932 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 933 + 934 + nl80211_send_cqm_txe_notify(rdev, dev, peer, num_packets, 935 + rate, intvl, gfp); 936 + } 937 + EXPORT_SYMBOL(cfg80211_cqm_txe_notify); 921 938 922 939 void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, 923 940 const u8 *replay_ctr, gfp_t gfp)
+398 -139
net/wireless/nl80211.c
··· 46 46 .post_doit = nl80211_post_doit, 47 47 }; 48 48 49 - /* internal helper: get rdev and dev */ 50 - static int get_rdev_dev_by_ifindex(struct net *netns, struct nlattr **attrs, 51 - struct cfg80211_registered_device **rdev, 52 - struct net_device **dev) 49 + /* returns ERR_PTR values */ 50 + static struct wireless_dev * 51 + __cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs) 53 52 { 54 - int ifindex; 53 + struct cfg80211_registered_device *rdev; 54 + struct wireless_dev *result = NULL; 55 + bool have_ifidx = attrs[NL80211_ATTR_IFINDEX]; 56 + bool have_wdev_id = attrs[NL80211_ATTR_WDEV]; 57 + u64 wdev_id; 58 + int wiphy_idx = -1; 59 + int ifidx = -1; 55 60 56 - if (!attrs[NL80211_ATTR_IFINDEX]) 57 - return -EINVAL; 61 + assert_cfg80211_lock(); 58 62 59 - ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); 60 - *dev = dev_get_by_index(netns, ifindex); 61 - if (!*dev) 62 - return -ENODEV; 63 + if (!have_ifidx && !have_wdev_id) 64 + return ERR_PTR(-EINVAL); 63 65 64 - *rdev = cfg80211_get_dev_from_ifindex(netns, ifindex); 65 - if (IS_ERR(*rdev)) { 66 - dev_put(*dev); 67 - return PTR_ERR(*rdev); 66 + if (have_ifidx) 67 + ifidx = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); 68 + if (have_wdev_id) { 69 + wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]); 70 + wiphy_idx = wdev_id >> 32; 68 71 } 69 72 70 - return 0; 73 + list_for_each_entry(rdev, &cfg80211_rdev_list, list) { 74 + struct wireless_dev *wdev; 75 + 76 + if (wiphy_net(&rdev->wiphy) != netns) 77 + continue; 78 + 79 + if (have_wdev_id && rdev->wiphy_idx != wiphy_idx) 80 + continue; 81 + 82 + mutex_lock(&rdev->devlist_mtx); 83 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 84 + if (have_ifidx && wdev->netdev && 85 + wdev->netdev->ifindex == ifidx) { 86 + result = wdev; 87 + break; 88 + } 89 + if (have_wdev_id && wdev->identifier == (u32)wdev_id) { 90 + result = wdev; 91 + break; 92 + } 93 + } 94 + mutex_unlock(&rdev->devlist_mtx); 95 + 96 + if (result) 97 + break; 98 + } 99 + 100 + if (result) 101 + return result; 102 + return ERR_PTR(-ENODEV); 71 103 } 72 104 73 105 static struct cfg80211_registered_device * ··· 111 79 assert_cfg80211_lock(); 112 80 113 81 if (!attrs[NL80211_ATTR_WIPHY] && 114 - !attrs[NL80211_ATTR_IFINDEX]) 82 + !attrs[NL80211_ATTR_IFINDEX] && 83 + !attrs[NL80211_ATTR_WDEV]) 115 84 return ERR_PTR(-EINVAL); 116 85 117 86 if (attrs[NL80211_ATTR_WIPHY]) 118 87 rdev = cfg80211_rdev_by_wiphy_idx( 119 88 nla_get_u32(attrs[NL80211_ATTR_WIPHY])); 89 + 90 + if (attrs[NL80211_ATTR_WDEV]) { 91 + u64 wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]); 92 + struct wireless_dev *wdev; 93 + bool found = false; 94 + 95 + tmp = cfg80211_rdev_by_wiphy_idx(wdev_id >> 32); 96 + if (tmp) { 97 + /* make sure wdev exists */ 98 + mutex_lock(&tmp->devlist_mtx); 99 + list_for_each_entry(wdev, &tmp->wdev_list, list) { 100 + if (wdev->identifier != (u32)wdev_id) 101 + continue; 102 + found = true; 103 + break; 104 + } 105 + mutex_unlock(&tmp->devlist_mtx); 106 + 107 + if (!found) 108 + tmp = NULL; 109 + 110 + if (rdev && tmp != rdev) 111 + return ERR_PTR(-EINVAL); 112 + rdev = tmp; 113 + } 114 + } 120 115 121 116 if (attrs[NL80211_ATTR_IFINDEX]) { 122 117 int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); ··· 353 294 [NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 }, 354 295 [NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 }, 355 296 [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, 297 + [NL80211_ATTR_WDEV] = { .type = NLA_U64 }, 298 + [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 }, 356 299 }; 357 300 358 301 /* policy for the key attributes */ ··· 1729 1668 return result; 1730 1669 } 1731 1670 1671 + static inline u64 wdev_id(struct wireless_dev *wdev) 1672 + { 1673 + return (u64)wdev->identifier | 1674 + ((u64)wiphy_to_dev(wdev->wiphy)->wiphy_idx << 32); 1675 + } 1732 1676 1733 1677 static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, 1734 1678 struct cfg80211_registered_device *rdev, 1735 - struct net_device *dev) 1679 + struct wireless_dev *wdev) 1736 1680 { 1681 + struct net_device *dev = wdev->netdev; 1737 1682 void *hdr; 1738 1683 1739 1684 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE); 1740 1685 if (!hdr) 1741 1686 return -1; 1742 1687 1743 - if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 1744 - nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 1745 - nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) || 1746 - nla_put_u32(msg, NL80211_ATTR_IFTYPE, 1747 - dev->ieee80211_ptr->iftype) || 1688 + if (dev && 1689 + (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 1690 + nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) || 1691 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dev->dev_addr))) 1692 + goto nla_put_failure; 1693 + 1694 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 1695 + nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) || 1696 + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) || 1748 1697 nla_put_u32(msg, NL80211_ATTR_GENERATION, 1749 1698 rdev->devlist_generation ^ 1750 1699 (cfg80211_rdev_list_generation << 2))) 1751 1700 goto nla_put_failure; 1752 1701 1753 - if (rdev->monitor_channel) { 1754 - if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, 1755 - rdev->monitor_channel->center_freq) || 1756 - nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, 1757 - rdev->monitor_channel_type)) 1702 + if (rdev->ops->get_channel) { 1703 + struct ieee80211_channel *chan; 1704 + enum nl80211_channel_type channel_type; 1705 + 1706 + chan = rdev->ops->get_channel(&rdev->wiphy, wdev, 1707 + &channel_type); 1708 + if (chan && 1709 + (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, 1710 + chan->center_freq) || 1711 + nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, 1712 + channel_type))) 1758 1713 goto nla_put_failure; 1759 1714 } 1760 1715 ··· 1801 1724 if_idx = 0; 1802 1725 1803 1726 mutex_lock(&rdev->devlist_mtx); 1804 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 1727 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 1805 1728 if (if_idx < if_start) { 1806 1729 if_idx++; 1807 1730 continue; 1808 1731 } 1809 1732 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, 1810 1733 cb->nlh->nlmsg_seq, NLM_F_MULTI, 1811 - rdev, wdev->netdev) < 0) { 1734 + rdev, wdev) < 0) { 1812 1735 mutex_unlock(&rdev->devlist_mtx); 1813 1736 goto out; 1814 1737 } ··· 1831 1754 { 1832 1755 struct sk_buff *msg; 1833 1756 struct cfg80211_registered_device *dev = info->user_ptr[0]; 1834 - struct net_device *netdev = info->user_ptr[1]; 1757 + struct wireless_dev *wdev = info->user_ptr[1]; 1835 1758 1836 1759 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1837 1760 if (!msg) 1838 1761 return -ENOMEM; 1839 1762 1840 1763 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, 1841 - dev, netdev) < 0) { 1764 + dev, wdev) < 0) { 1842 1765 nlmsg_free(msg); 1843 1766 return -ENOBUFS; 1844 1767 } ··· 1978 1901 { 1979 1902 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 1980 1903 struct vif_params params; 1981 - struct net_device *dev; 1904 + struct wireless_dev *wdev; 1905 + struct sk_buff *msg; 1982 1906 int err; 1983 1907 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; 1984 1908 u32 flags; ··· 2006 1928 return err; 2007 1929 } 2008 1930 1931 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1932 + if (!msg) 1933 + return -ENOMEM; 1934 + 2009 1935 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? 2010 1936 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, 2011 1937 &flags); 2012 - dev = rdev->ops->add_virtual_intf(&rdev->wiphy, 1938 + wdev = rdev->ops->add_virtual_intf(&rdev->wiphy, 2013 1939 nla_data(info->attrs[NL80211_ATTR_IFNAME]), 2014 1940 type, err ? NULL : &flags, &params); 2015 - if (IS_ERR(dev)) 2016 - return PTR_ERR(dev); 1941 + if (IS_ERR(wdev)) { 1942 + nlmsg_free(msg); 1943 + return PTR_ERR(wdev); 1944 + } 2017 1945 2018 1946 if (type == NL80211_IFTYPE_MESH_POINT && 2019 1947 info->attrs[NL80211_ATTR_MESH_ID]) { 2020 - struct wireless_dev *wdev = dev->ieee80211_ptr; 2021 - 2022 1948 wdev_lock(wdev); 2023 1949 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != 2024 1950 IEEE80211_MAX_MESH_ID_LEN); ··· 2033 1951 wdev_unlock(wdev); 2034 1952 } 2035 1953 2036 - return 0; 1954 + if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, 1955 + rdev, wdev) < 0) { 1956 + nlmsg_free(msg); 1957 + return -ENOBUFS; 1958 + } 1959 + 1960 + return genlmsg_reply(msg, info); 2037 1961 } 2038 1962 2039 1963 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) 2040 1964 { 2041 1965 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 2042 - struct net_device *dev = info->user_ptr[1]; 1966 + struct wireless_dev *wdev = info->user_ptr[1]; 2043 1967 2044 1968 if (!rdev->ops->del_virtual_intf) 2045 1969 return -EOPNOTSUPP; 2046 1970 2047 - return rdev->ops->del_virtual_intf(&rdev->wiphy, dev); 1971 + /* 1972 + * If we remove a wireless device without a netdev then clear 1973 + * user_ptr[1] so that nl80211_post_doit won't dereference it 1974 + * to check if it needs to do dev_put(). Otherwise it crashes 1975 + * since the wdev has been freed, unlike with a netdev where 1976 + * we need the dev_put() for the netdev to really be freed. 1977 + */ 1978 + if (!wdev->netdev) 1979 + info->user_ptr[1] = NULL; 1980 + 1981 + return rdev->ops->del_virtual_intf(&rdev->wiphy, wdev); 2048 1982 } 2049 1983 2050 1984 static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) ··· 2448 2350 2449 2351 mutex_lock(&rdev->devlist_mtx); 2450 2352 2451 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 2353 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 2452 2354 if (wdev->iftype != NL80211_IFTYPE_AP && 2453 2355 wdev->iftype != NL80211_IFTYPE_P2P_GO) 2454 2356 continue; ··· 3583 3485 { 3584 3486 int r; 3585 3487 char *data = NULL; 3488 + enum nl80211_user_reg_hint_type user_reg_hint_type; 3586 3489 3587 3490 /* 3588 3491 * You should only get this when cfg80211 hasn't yet initialized ··· 3603 3504 3604 3505 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); 3605 3506 3606 - r = regulatory_hint_user(data); 3507 + if (info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]) 3508 + user_reg_hint_type = 3509 + nla_get_u32(info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]); 3510 + else 3511 + user_reg_hint_type = NL80211_USER_REG_HINT_USER; 3512 + 3513 + switch (user_reg_hint_type) { 3514 + case NL80211_USER_REG_HINT_USER: 3515 + case NL80211_USER_REG_HINT_CELL_BASE: 3516 + break; 3517 + default: 3518 + return -EINVAL; 3519 + } 3520 + 3521 + r = regulatory_hint_user(data, user_reg_hint_type); 3607 3522 3608 3523 return r; 3609 3524 } ··· 3987 3874 cfg80211_regdomain->dfs_region))) 3988 3875 goto nla_put_failure; 3989 3876 3877 + if (reg_last_request_cell_base() && 3878 + nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE, 3879 + NL80211_USER_REG_HINT_CELL_BASE)) 3880 + goto nla_put_failure; 3881 + 3990 3882 nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES); 3991 3883 if (!nl_reg_rules) 3992 3884 goto nla_put_failure; ··· 4157 4039 static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) 4158 4040 { 4159 4041 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 4160 - struct net_device *dev = info->user_ptr[1]; 4042 + struct wireless_dev *wdev = info->user_ptr[1]; 4161 4043 struct cfg80211_scan_request *request; 4162 4044 struct nlattr *attr; 4163 4045 struct wiphy *wiphy; ··· 4317 4199 request->no_cck = 4318 4200 nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); 4319 4201 4320 - request->dev = dev; 4202 + request->wdev = wdev; 4321 4203 request->wiphy = &rdev->wiphy; 4322 4204 4323 4205 rdev->scan_req = request; 4324 - err = rdev->ops->scan(&rdev->wiphy, dev, request); 4206 + err = rdev->ops->scan(&rdev->wiphy, request); 4325 4207 4326 4208 if (!err) { 4327 - nl80211_send_scan_start(rdev, dev); 4328 - dev_hold(dev); 4209 + nl80211_send_scan_start(rdev, wdev); 4210 + if (wdev->netdev) 4211 + dev_hold(wdev->netdev); 4329 4212 } else { 4330 4213 out_free: 4331 4214 rdev->scan_req = NULL; ··· 5804 5685 struct genl_info *info) 5805 5686 { 5806 5687 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5807 - struct net_device *dev = info->user_ptr[1]; 5688 + struct wireless_dev *wdev = info->user_ptr[1]; 5808 5689 struct ieee80211_channel *chan; 5809 5690 struct sk_buff *msg; 5810 5691 void *hdr; ··· 5852 5733 goto free_msg; 5853 5734 } 5854 5735 5855 - err = rdev->ops->remain_on_channel(&rdev->wiphy, dev, chan, 5736 + err = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan, 5856 5737 channel_type, duration, &cookie); 5857 5738 5858 5739 if (err) ··· 5876 5757 struct genl_info *info) 5877 5758 { 5878 5759 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5879 - struct net_device *dev = info->user_ptr[1]; 5760 + struct wireless_dev *wdev = info->user_ptr[1]; 5880 5761 u64 cookie; 5881 5762 5882 5763 if (!info->attrs[NL80211_ATTR_COOKIE]) ··· 5887 5768 5888 5769 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); 5889 5770 5890 - return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, dev, cookie); 5771 + return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); 5891 5772 } 5892 5773 5893 5774 static u32 rateset_to_mask(struct ieee80211_supported_band *sband, ··· 6036 5917 static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) 6037 5918 { 6038 5919 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6039 - struct net_device *dev = info->user_ptr[1]; 5920 + struct wireless_dev *wdev = info->user_ptr[1]; 6040 5921 u16 frame_type = IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION; 6041 5922 6042 5923 if (!info->attrs[NL80211_ATTR_FRAME_MATCH]) ··· 6045 5926 if (info->attrs[NL80211_ATTR_FRAME_TYPE]) 6046 5927 frame_type = nla_get_u16(info->attrs[NL80211_ATTR_FRAME_TYPE]); 6047 5928 6048 - if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && 6049 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && 6050 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && 6051 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 6052 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && 6053 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && 6054 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 5929 + switch (wdev->iftype) { 5930 + case NL80211_IFTYPE_STATION: 5931 + case NL80211_IFTYPE_ADHOC: 5932 + case NL80211_IFTYPE_P2P_CLIENT: 5933 + case NL80211_IFTYPE_AP: 5934 + case NL80211_IFTYPE_AP_VLAN: 5935 + case NL80211_IFTYPE_MESH_POINT: 5936 + case NL80211_IFTYPE_P2P_GO: 5937 + break; 5938 + default: 6055 5939 return -EOPNOTSUPP; 5940 + } 6056 5941 6057 5942 /* not much point in registering if we can't reply */ 6058 5943 if (!rdev->ops->mgmt_tx) 6059 5944 return -EOPNOTSUPP; 6060 5945 6061 - return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_pid, 6062 - frame_type, 5946 + return cfg80211_mlme_register_mgmt(wdev, info->snd_pid, frame_type, 6063 5947 nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]), 6064 5948 nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH])); 6065 5949 } ··· 6070 5948 static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) 6071 5949 { 6072 5950 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6073 - struct net_device *dev = info->user_ptr[1]; 5951 + struct wireless_dev *wdev = info->user_ptr[1]; 6074 5952 struct ieee80211_channel *chan; 6075 5953 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; 6076 5954 bool channel_type_valid = false; ··· 6091 5969 if (!rdev->ops->mgmt_tx) 6092 5970 return -EOPNOTSUPP; 6093 5971 6094 - if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && 6095 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && 6096 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && 6097 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 6098 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && 6099 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && 6100 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 5972 + switch (wdev->iftype) { 5973 + case NL80211_IFTYPE_STATION: 5974 + case NL80211_IFTYPE_ADHOC: 5975 + case NL80211_IFTYPE_P2P_CLIENT: 5976 + case NL80211_IFTYPE_AP: 5977 + case NL80211_IFTYPE_AP_VLAN: 5978 + case NL80211_IFTYPE_MESH_POINT: 5979 + case NL80211_IFTYPE_P2P_GO: 5980 + break; 5981 + default: 6101 5982 return -EOPNOTSUPP; 5983 + } 6102 5984 6103 5985 if (info->attrs[NL80211_ATTR_DURATION]) { 6104 5986 if (!(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) ··· 6151 6025 } 6152 6026 } 6153 6027 6154 - err = cfg80211_mlme_mgmt_tx(rdev, dev, chan, offchan, channel_type, 6028 + err = cfg80211_mlme_mgmt_tx(rdev, wdev, chan, offchan, channel_type, 6155 6029 channel_type_valid, wait, 6156 6030 nla_data(info->attrs[NL80211_ATTR_FRAME]), 6157 6031 nla_len(info->attrs[NL80211_ATTR_FRAME]), ··· 6179 6053 static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *info) 6180 6054 { 6181 6055 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6182 - struct net_device *dev = info->user_ptr[1]; 6056 + struct wireless_dev *wdev = info->user_ptr[1]; 6183 6057 u64 cookie; 6184 6058 6185 6059 if (!info->attrs[NL80211_ATTR_COOKIE]) ··· 6188 6062 if (!rdev->ops->mgmt_tx_cancel_wait) 6189 6063 return -EOPNOTSUPP; 6190 6064 6191 - if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && 6192 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && 6193 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && 6194 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 6195 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && 6196 - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 6065 + switch (wdev->iftype) { 6066 + case NL80211_IFTYPE_STATION: 6067 + case NL80211_IFTYPE_ADHOC: 6068 + case NL80211_IFTYPE_P2P_CLIENT: 6069 + case NL80211_IFTYPE_AP: 6070 + case NL80211_IFTYPE_AP_VLAN: 6071 + case NL80211_IFTYPE_P2P_GO: 6072 + break; 6073 + default: 6197 6074 return -EOPNOTSUPP; 6075 + } 6198 6076 6199 6077 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); 6200 6078 6201 - return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, dev, cookie); 6079 + return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); 6202 6080 } 6203 6081 6204 6082 static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) ··· 6288 6158 [NL80211_ATTR_CQM_RSSI_THOLD] = { .type = NLA_U32 }, 6289 6159 [NL80211_ATTR_CQM_RSSI_HYST] = { .type = NLA_U32 }, 6290 6160 [NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 }, 6161 + [NL80211_ATTR_CQM_TXE_RATE] = { .type = NLA_U32 }, 6162 + [NL80211_ATTR_CQM_TXE_PKTS] = { .type = NLA_U32 }, 6163 + [NL80211_ATTR_CQM_TXE_INTVL] = { .type = NLA_U32 }, 6291 6164 }; 6165 + 6166 + static int nl80211_set_cqm_txe(struct genl_info *info, 6167 + u32 rate, u32 pkts, u32 intvl) 6168 + { 6169 + struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6170 + struct wireless_dev *wdev; 6171 + struct net_device *dev = info->user_ptr[1]; 6172 + 6173 + if ((rate < 0 || rate > 100) || 6174 + (intvl < 0 || intvl > NL80211_CQM_TXE_MAX_INTVL)) 6175 + return -EINVAL; 6176 + 6177 + wdev = dev->ieee80211_ptr; 6178 + 6179 + if (!rdev->ops->set_cqm_txe_config) 6180 + return -EOPNOTSUPP; 6181 + 6182 + if (wdev->iftype != NL80211_IFTYPE_STATION && 6183 + wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) 6184 + return -EOPNOTSUPP; 6185 + 6186 + return rdev->ops->set_cqm_txe_config(wdev->wiphy, dev, 6187 + rate, pkts, intvl); 6188 + } 6292 6189 6293 6190 static int nl80211_set_cqm_rssi(struct genl_info *info, 6294 6191 s32 threshold, u32 hysteresis) ··· 6364 6207 threshold = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_THOLD]); 6365 6208 hysteresis = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_HYST]); 6366 6209 err = nl80211_set_cqm_rssi(info, threshold, hysteresis); 6210 + } else if (attrs[NL80211_ATTR_CQM_TXE_RATE] && 6211 + attrs[NL80211_ATTR_CQM_TXE_PKTS] && 6212 + attrs[NL80211_ATTR_CQM_TXE_INTVL]) { 6213 + u32 rate, pkts, intvl; 6214 + rate = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_RATE]); 6215 + pkts = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_PKTS]); 6216 + intvl = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_INTVL]); 6217 + err = nl80211_set_cqm_txe(info, rate, pkts, intvl); 6367 6218 } else 6368 6219 err = -EINVAL; 6369 6220 ··· 6528 6363 { 6529 6364 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6530 6365 struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG]; 6531 - struct cfg80211_wowlan no_triggers = {}; 6532 6366 struct cfg80211_wowlan new_triggers = {}; 6367 + struct cfg80211_wowlan *ntrig; 6533 6368 struct wiphy_wowlan_support *wowlan = &rdev->wiphy.wowlan; 6534 6369 int err, i; 6535 6370 bool prev_enabled = rdev->wowlan; ··· 6537 6372 if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns) 6538 6373 return -EOPNOTSUPP; 6539 6374 6540 - if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) 6541 - goto no_triggers; 6375 + if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) { 6376 + cfg80211_rdev_free_wowlan(rdev); 6377 + rdev->wowlan = NULL; 6378 + goto set_wakeup; 6379 + } 6542 6380 6543 6381 err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG, 6544 6382 nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), ··· 6652 6484 } 6653 6485 } 6654 6486 6655 - if (memcmp(&new_triggers, &no_triggers, sizeof(new_triggers))) { 6656 - struct cfg80211_wowlan *ntrig; 6657 - ntrig = kmemdup(&new_triggers, sizeof(new_triggers), 6658 - GFP_KERNEL); 6659 - if (!ntrig) { 6660 - err = -ENOMEM; 6661 - goto error; 6662 - } 6663 - cfg80211_rdev_free_wowlan(rdev); 6664 - rdev->wowlan = ntrig; 6665 - } else { 6666 - no_triggers: 6667 - cfg80211_rdev_free_wowlan(rdev); 6668 - rdev->wowlan = NULL; 6487 + ntrig = kmemdup(&new_triggers, sizeof(new_triggers), GFP_KERNEL); 6488 + if (!ntrig) { 6489 + err = -ENOMEM; 6490 + goto error; 6669 6491 } 6492 + cfg80211_rdev_free_wowlan(rdev); 6493 + rdev->wowlan = ntrig; 6670 6494 6495 + set_wakeup: 6671 6496 if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan) 6672 6497 rdev->ops->set_wakeup(&rdev->wiphy, rdev->wowlan); 6673 6498 ··· 6816 6655 #define NL80211_FLAG_CHECK_NETDEV_UP 0x08 6817 6656 #define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\ 6818 6657 NL80211_FLAG_CHECK_NETDEV_UP) 6658 + #define NL80211_FLAG_NEED_WDEV 0x10 6659 + /* If a netdev is associated, it must be UP */ 6660 + #define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ 6661 + NL80211_FLAG_CHECK_NETDEV_UP) 6819 6662 6820 6663 static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, 6821 6664 struct genl_info *info) 6822 6665 { 6823 6666 struct cfg80211_registered_device *rdev; 6667 + struct wireless_dev *wdev; 6824 6668 struct net_device *dev; 6825 - int err; 6826 6669 bool rtnl = ops->internal_flags & NL80211_FLAG_NEED_RTNL; 6827 6670 6828 6671 if (rtnl) ··· 6840 6675 return PTR_ERR(rdev); 6841 6676 } 6842 6677 info->user_ptr[0] = rdev; 6843 - } else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) { 6844 - err = get_rdev_dev_by_ifindex(genl_info_net(info), info->attrs, 6845 - &rdev, &dev); 6846 - if (err) { 6678 + } else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV || 6679 + ops->internal_flags & NL80211_FLAG_NEED_WDEV) { 6680 + mutex_lock(&cfg80211_mutex); 6681 + wdev = __cfg80211_wdev_from_attrs(genl_info_net(info), 6682 + info->attrs); 6683 + if (IS_ERR(wdev)) { 6684 + mutex_unlock(&cfg80211_mutex); 6847 6685 if (rtnl) 6848 6686 rtnl_unlock(); 6849 - return err; 6687 + return PTR_ERR(wdev); 6850 6688 } 6851 - if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP && 6852 - !netif_running(dev)) { 6853 - cfg80211_unlock_rdev(rdev); 6854 - dev_put(dev); 6855 - if (rtnl) 6856 - rtnl_unlock(); 6857 - return -ENETDOWN; 6689 + 6690 + dev = wdev->netdev; 6691 + rdev = wiphy_to_dev(wdev->wiphy); 6692 + 6693 + if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) { 6694 + if (!dev) { 6695 + mutex_unlock(&cfg80211_mutex); 6696 + if (rtnl) 6697 + rtnl_unlock(); 6698 + return -EINVAL; 6699 + } 6700 + 6701 + info->user_ptr[1] = dev; 6702 + } else { 6703 + info->user_ptr[1] = wdev; 6858 6704 } 6705 + 6706 + if (dev) { 6707 + if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP && 6708 + !netif_running(dev)) { 6709 + mutex_unlock(&cfg80211_mutex); 6710 + if (rtnl) 6711 + rtnl_unlock(); 6712 + return -ENETDOWN; 6713 + } 6714 + 6715 + dev_hold(dev); 6716 + } 6717 + 6718 + cfg80211_lock_rdev(rdev); 6719 + 6720 + mutex_unlock(&cfg80211_mutex); 6721 + 6859 6722 info->user_ptr[0] = rdev; 6860 - info->user_ptr[1] = dev; 6861 6723 } 6862 6724 6863 6725 return 0; ··· 6895 6703 { 6896 6704 if (info->user_ptr[0]) 6897 6705 cfg80211_unlock_rdev(info->user_ptr[0]); 6898 - if (info->user_ptr[1]) 6899 - dev_put(info->user_ptr[1]); 6706 + if (info->user_ptr[1]) { 6707 + if (ops->internal_flags & NL80211_FLAG_NEED_WDEV) { 6708 + struct wireless_dev *wdev = info->user_ptr[1]; 6709 + 6710 + if (wdev->netdev) 6711 + dev_put(wdev->netdev); 6712 + } else { 6713 + dev_put(info->user_ptr[1]); 6714 + } 6715 + } 6900 6716 if (ops->internal_flags & NL80211_FLAG_NEED_RTNL) 6901 6717 rtnl_unlock(); 6902 6718 } ··· 6931 6731 .dumpit = nl80211_dump_interface, 6932 6732 .policy = nl80211_policy, 6933 6733 /* can be retrieved by unprivileged users */ 6934 - .internal_flags = NL80211_FLAG_NEED_NETDEV, 6734 + .internal_flags = NL80211_FLAG_NEED_WDEV, 6935 6735 }, 6936 6736 { 6937 6737 .cmd = NL80211_CMD_SET_INTERFACE, ··· 6954 6754 .doit = nl80211_del_interface, 6955 6755 .policy = nl80211_policy, 6956 6756 .flags = GENL_ADMIN_PERM, 6957 - .internal_flags = NL80211_FLAG_NEED_NETDEV | 6757 + .internal_flags = NL80211_FLAG_NEED_WDEV | 6958 6758 NL80211_FLAG_NEED_RTNL, 6959 6759 }, 6960 6760 { ··· 7125 6925 .doit = nl80211_trigger_scan, 7126 6926 .policy = nl80211_policy, 7127 6927 .flags = GENL_ADMIN_PERM, 7128 - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 6928 + .internal_flags = NL80211_FLAG_NEED_WDEV_UP | 7129 6929 NL80211_FLAG_NEED_RTNL, 7130 6930 }, 7131 6931 { ··· 7266 7066 .doit = nl80211_remain_on_channel, 7267 7067 .policy = nl80211_policy, 7268 7068 .flags = GENL_ADMIN_PERM, 7269 - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 7069 + .internal_flags = NL80211_FLAG_NEED_WDEV_UP | 7270 7070 NL80211_FLAG_NEED_RTNL, 7271 7071 }, 7272 7072 { ··· 7274 7074 .doit = nl80211_cancel_remain_on_channel, 7275 7075 .policy = nl80211_policy, 7276 7076 .flags = GENL_ADMIN_PERM, 7277 - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 7077 + .internal_flags = NL80211_FLAG_NEED_WDEV_UP | 7278 7078 NL80211_FLAG_NEED_RTNL, 7279 7079 }, 7280 7080 { ··· 7290 7090 .doit = nl80211_register_mgmt, 7291 7091 .policy = nl80211_policy, 7292 7092 .flags = GENL_ADMIN_PERM, 7293 - .internal_flags = NL80211_FLAG_NEED_NETDEV | 7093 + .internal_flags = NL80211_FLAG_NEED_WDEV | 7294 7094 NL80211_FLAG_NEED_RTNL, 7295 7095 }, 7296 7096 { ··· 7298 7098 .doit = nl80211_tx_mgmt, 7299 7099 .policy = nl80211_policy, 7300 7100 .flags = GENL_ADMIN_PERM, 7301 - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 7101 + .internal_flags = NL80211_FLAG_NEED_WDEV_UP | 7302 7102 NL80211_FLAG_NEED_RTNL, 7303 7103 }, 7304 7104 { ··· 7306 7106 .doit = nl80211_tx_mgmt_cancel_wait, 7307 7107 .policy = nl80211_policy, 7308 7108 .flags = GENL_ADMIN_PERM, 7309 - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 7109 + .internal_flags = NL80211_FLAG_NEED_WDEV_UP | 7310 7110 NL80211_FLAG_NEED_RTNL, 7311 7111 }, 7312 7112 { ··· 7517 7317 7518 7318 static int nl80211_send_scan_msg(struct sk_buff *msg, 7519 7319 struct cfg80211_registered_device *rdev, 7520 - struct net_device *netdev, 7320 + struct wireless_dev *wdev, 7521 7321 u32 pid, u32 seq, int flags, 7522 7322 u32 cmd) 7523 7323 { ··· 7528 7328 return -1; 7529 7329 7530 7330 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 7531 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) 7331 + (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, 7332 + wdev->netdev->ifindex)) || 7333 + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev))) 7532 7334 goto nla_put_failure; 7533 7335 7534 7336 /* ignore errors and send incomplete event anyway */ ··· 7567 7365 } 7568 7366 7569 7367 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, 7570 - struct net_device *netdev) 7368 + struct wireless_dev *wdev) 7571 7369 { 7572 7370 struct sk_buff *msg; 7573 7371 ··· 7575 7373 if (!msg) 7576 7374 return; 7577 7375 7578 - if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, 7376 + if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, 7579 7377 NL80211_CMD_TRIGGER_SCAN) < 0) { 7580 7378 nlmsg_free(msg); 7581 7379 return; ··· 7586 7384 } 7587 7385 7588 7386 void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, 7589 - struct net_device *netdev) 7387 + struct wireless_dev *wdev) 7590 7388 { 7591 7389 struct sk_buff *msg; 7592 7390 ··· 7594 7392 if (!msg) 7595 7393 return; 7596 7394 7597 - if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, 7395 + if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, 7598 7396 NL80211_CMD_NEW_SCAN_RESULTS) < 0) { 7599 7397 nlmsg_free(msg); 7600 7398 return; ··· 7605 7403 } 7606 7404 7607 7405 void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, 7608 - struct net_device *netdev) 7406 + struct wireless_dev *wdev) 7609 7407 { 7610 7408 struct sk_buff *msg; 7611 7409 ··· 7613 7411 if (!msg) 7614 7412 return; 7615 7413 7616 - if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, 7414 + if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, 7617 7415 NL80211_CMD_SCAN_ABORTED) < 0) { 7618 7416 nlmsg_free(msg); 7619 7417 return; ··· 8136 7934 8137 7935 static void nl80211_send_remain_on_chan_event( 8138 7936 int cmd, struct cfg80211_registered_device *rdev, 8139 - struct net_device *netdev, u64 cookie, 7937 + struct wireless_dev *wdev, u64 cookie, 8140 7938 struct ieee80211_channel *chan, 8141 7939 enum nl80211_channel_type channel_type, 8142 7940 unsigned int duration, gfp_t gfp) ··· 8155 7953 } 8156 7954 8157 7955 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 8158 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 7956 + (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, 7957 + wdev->netdev->ifindex)) || 7958 + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) || 8159 7959 nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq) || 8160 7960 nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type) || 8161 7961 nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) ··· 8179 7975 } 8180 7976 8181 7977 void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, 8182 - struct net_device *netdev, u64 cookie, 7978 + struct wireless_dev *wdev, u64 cookie, 8183 7979 struct ieee80211_channel *chan, 8184 7980 enum nl80211_channel_type channel_type, 8185 7981 unsigned int duration, gfp_t gfp) 8186 7982 { 8187 7983 nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL, 8188 - rdev, netdev, cookie, chan, 7984 + rdev, wdev, cookie, chan, 8189 7985 channel_type, duration, gfp); 8190 7986 } 8191 7987 8192 7988 void nl80211_send_remain_on_channel_cancel( 8193 - struct cfg80211_registered_device *rdev, struct net_device *netdev, 7989 + struct cfg80211_registered_device *rdev, 7990 + struct wireless_dev *wdev, 8194 7991 u64 cookie, struct ieee80211_channel *chan, 8195 7992 enum nl80211_channel_type channel_type, gfp_t gfp) 8196 7993 { 8197 7994 nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, 8198 - rdev, netdev, cookie, chan, 7995 + rdev, wdev, cookie, chan, 8199 7996 channel_type, 0, gfp); 8200 7997 } 8201 7998 ··· 8310 8105 } 8311 8106 8312 8107 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 8313 - struct net_device *netdev, u32 nlpid, 8108 + struct wireless_dev *wdev, u32 nlpid, 8314 8109 int freq, int sig_dbm, 8315 8110 const u8 *buf, size_t len, gfp_t gfp) 8316 8111 { 8112 + struct net_device *netdev = wdev->netdev; 8317 8113 struct sk_buff *msg; 8318 8114 void *hdr; 8319 8115 ··· 8329 8123 } 8330 8124 8331 8125 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 8332 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 8126 + (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, 8127 + netdev->ifindex)) || 8333 8128 nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) || 8334 8129 (sig_dbm && 8335 8130 nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || ··· 8348 8141 } 8349 8142 8350 8143 void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, 8351 - struct net_device *netdev, u64 cookie, 8144 + struct wireless_dev *wdev, u64 cookie, 8352 8145 const u8 *buf, size_t len, bool ack, 8353 8146 gfp_t gfp) 8354 8147 { 8148 + struct net_device *netdev = wdev->netdev; 8355 8149 struct sk_buff *msg; 8356 8150 void *hdr; 8357 8151 ··· 8367 8159 } 8368 8160 8369 8161 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 8370 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 8162 + (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, 8163 + netdev->ifindex)) || 8371 8164 nla_put(msg, NL80211_ATTR_FRAME, len, buf) || 8372 8165 nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) || 8373 8166 (ack && nla_put_flag(msg, NL80211_ATTR_ACK))) ··· 8552 8343 } 8553 8344 8554 8345 void 8346 + nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, 8347 + struct net_device *netdev, const u8 *peer, 8348 + u32 num_packets, u32 rate, u32 intvl, gfp_t gfp) 8349 + { 8350 + struct sk_buff *msg; 8351 + struct nlattr *pinfoattr; 8352 + void *hdr; 8353 + 8354 + msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8355 + if (!msg) 8356 + return; 8357 + 8358 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_CQM); 8359 + if (!hdr) { 8360 + nlmsg_free(msg); 8361 + return; 8362 + } 8363 + 8364 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 8365 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 8366 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) 8367 + goto nla_put_failure; 8368 + 8369 + pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); 8370 + if (!pinfoattr) 8371 + goto nla_put_failure; 8372 + 8373 + if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_PKTS, num_packets)) 8374 + goto nla_put_failure; 8375 + 8376 + if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_RATE, rate)) 8377 + goto nla_put_failure; 8378 + 8379 + if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_INTVL, intvl)) 8380 + goto nla_put_failure; 8381 + 8382 + nla_nest_end(msg, pinfoattr); 8383 + 8384 + genlmsg_end(msg, hdr); 8385 + 8386 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 8387 + nl80211_mlme_mcgrp.id, gfp); 8388 + return; 8389 + 8390 + nla_put_failure: 8391 + genlmsg_cancel(msg, hdr); 8392 + nlmsg_free(msg); 8393 + } 8394 + 8395 + void 8555 8396 nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, 8556 8397 struct net_device *netdev, const u8 *peer, 8557 8398 u32 num_packets, gfp_t gfp) ··· 8742 8483 rcu_read_lock(); 8743 8484 8744 8485 list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { 8745 - list_for_each_entry_rcu(wdev, &rdev->netdev_list, list) 8486 + list_for_each_entry_rcu(wdev, &rdev->wdev_list, list) 8746 8487 cfg80211_mlme_unregister_socket(wdev, notify->pid); 8747 8488 if (rdev->ap_beacons_nlpid == notify->pid) 8748 8489 rdev->ap_beacons_nlpid = 0;
+13 -8
net/wireless/nl80211.h
··· 7 7 void nl80211_exit(void); 8 8 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev); 9 9 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, 10 - struct net_device *netdev); 10 + struct wireless_dev *wdev); 11 11 void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, 12 - struct net_device *netdev); 12 + struct wireless_dev *wdev); 13 13 void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, 14 - struct net_device *netdev); 14 + struct wireless_dev *wdev); 15 15 void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, 16 16 struct net_device *netdev, u32 cmd); 17 17 void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev, ··· 74 74 gfp_t gfp); 75 75 76 76 void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, 77 - struct net_device *netdev, 78 - u64 cookie, 77 + struct wireless_dev *wdev, u64 cookie, 79 78 struct ieee80211_channel *chan, 80 79 enum nl80211_channel_type channel_type, 81 80 unsigned int duration, gfp_t gfp); 82 81 void nl80211_send_remain_on_channel_cancel( 83 - struct cfg80211_registered_device *rdev, struct net_device *netdev, 82 + struct cfg80211_registered_device *rdev, 83 + struct wireless_dev *wdev, 84 84 u64 cookie, struct ieee80211_channel *chan, 85 85 enum nl80211_channel_type channel_type, gfp_t gfp); 86 86 ··· 92 92 gfp_t gfp); 93 93 94 94 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 95 - struct net_device *netdev, u32 nlpid, 95 + struct wireless_dev *wdev, u32 nlpid, 96 96 int freq, int sig_dbm, 97 97 const u8 *buf, size_t len, gfp_t gfp); 98 98 void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, 99 - struct net_device *netdev, u64 cookie, 99 + struct wireless_dev *wdev, u64 cookie, 100 100 const u8 *buf, size_t len, bool ack, 101 101 gfp_t gfp); 102 102 ··· 109 109 nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, 110 110 struct net_device *netdev, const u8 *peer, 111 111 u32 num_packets, gfp_t gfp); 112 + 113 + void 114 + nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, 115 + struct net_device *netdev, const u8 *peer, 116 + u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); 112 117 113 118 void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, 114 119 struct net_device *netdev, const u8 *bssid,
+116 -16
net/wireless/reg.c
··· 97 97 * - cfg80211_world_regdom 98 98 * - cfg80211_regdom 99 99 * - last_request 100 + * - reg_num_devs_support_basehint 100 101 */ 101 102 static DEFINE_MUTEX(reg_mutex); 103 + 104 + /* 105 + * Number of devices that registered to the core 106 + * that support cellular base station regulatory hints 107 + */ 108 + static int reg_num_devs_support_basehint; 102 109 103 110 static inline void assert_reg_lock(void) 104 111 { ··· 918 911 handle_channel(wiphy, initiator, band, i); 919 912 } 920 913 914 + static bool reg_request_cell_base(struct regulatory_request *request) 915 + { 916 + if (request->initiator != NL80211_REGDOM_SET_BY_USER) 917 + return false; 918 + if (request->user_reg_hint_type != NL80211_USER_REG_HINT_CELL_BASE) 919 + return false; 920 + return true; 921 + } 922 + 923 + bool reg_last_request_cell_base(void) 924 + { 925 + bool val; 926 + assert_cfg80211_lock(); 927 + 928 + mutex_lock(&reg_mutex); 929 + val = reg_request_cell_base(last_request); 930 + mutex_unlock(&reg_mutex); 931 + return val; 932 + } 933 + 934 + #ifdef CONFIG_CFG80211_CERTIFICATION_ONUS 935 + 936 + /* Core specific check */ 937 + static int reg_ignore_cell_hint(struct regulatory_request *pending_request) 938 + { 939 + if (!reg_num_devs_support_basehint) 940 + return -EOPNOTSUPP; 941 + 942 + if (reg_request_cell_base(last_request)) { 943 + if (!regdom_changes(pending_request->alpha2)) 944 + return -EALREADY; 945 + return 0; 946 + } 947 + return 0; 948 + } 949 + 950 + /* Device specific check */ 951 + static bool reg_dev_ignore_cell_hint(struct wiphy *wiphy) 952 + { 953 + if (!(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS)) 954 + return true; 955 + return false; 956 + } 957 + #else 958 + static int reg_ignore_cell_hint(struct regulatory_request *pending_request) 959 + { 960 + return -EOPNOTSUPP; 961 + } 962 + static int reg_dev_ignore_cell_hint(struct wiphy *wiphy) 963 + { 964 + return true; 965 + } 966 + #endif 967 + 968 + 921 969 static bool ignore_reg_update(struct wiphy *wiphy, 922 970 enum nl80211_reg_initiator initiator) 923 971 { ··· 1005 943 reg_initiator_name(initiator)); 1006 944 return true; 1007 945 } 946 + 947 + if (reg_request_cell_base(last_request)) 948 + return reg_dev_ignore_cell_hint(wiphy); 1008 949 1009 950 return false; 1010 951 } ··· 1234 1169 wiphy->reg_notifier(wiphy, last_request); 1235 1170 } 1236 1171 1237 - void regulatory_update(struct wiphy *wiphy, 1238 - enum nl80211_reg_initiator setby) 1239 - { 1240 - mutex_lock(&reg_mutex); 1241 - wiphy_update_regulatory(wiphy, setby); 1242 - mutex_unlock(&reg_mutex); 1243 - } 1244 - 1245 1172 static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator) 1246 1173 { 1247 1174 struct cfg80211_registered_device *rdev; ··· 1364 1307 return 0; 1365 1308 case NL80211_REGDOM_SET_BY_COUNTRY_IE: 1366 1309 1310 + if (reg_request_cell_base(last_request)) { 1311 + /* Trust a Cell base station over the AP's country IE */ 1312 + if (regdom_changes(pending_request->alpha2)) 1313 + return -EOPNOTSUPP; 1314 + return -EALREADY; 1315 + } 1316 + 1367 1317 last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1368 1318 1369 1319 if (unlikely(!is_an_alpha2(pending_request->alpha2))) ··· 1415 1351 1416 1352 return REG_INTERSECT; 1417 1353 case NL80211_REGDOM_SET_BY_USER: 1354 + if (reg_request_cell_base(pending_request)) 1355 + return reg_ignore_cell_hint(pending_request); 1356 + 1357 + if (reg_request_cell_base(last_request)) 1358 + return -EOPNOTSUPP; 1359 + 1418 1360 if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) 1419 1361 return REG_INTERSECT; 1420 1362 /* ··· 1710 1640 } 1711 1641 1712 1642 /* User hints */ 1713 - int regulatory_hint_user(const char *alpha2) 1643 + int regulatory_hint_user(const char *alpha2, 1644 + enum nl80211_user_reg_hint_type user_reg_hint_type) 1714 1645 { 1715 1646 struct regulatory_request *request; 1716 1647 ··· 1725 1654 request->alpha2[0] = alpha2[0]; 1726 1655 request->alpha2[1] = alpha2[1]; 1727 1656 request->initiator = NL80211_REGDOM_SET_BY_USER; 1657 + request->user_reg_hint_type = user_reg_hint_type; 1728 1658 1729 1659 queue_regulatory_request(request); 1730 1660 ··· 1978 1906 * settings, user regulatory settings takes precedence. 1979 1907 */ 1980 1908 if (is_an_alpha2(alpha2)) 1981 - regulatory_hint_user(user_alpha2); 1909 + regulatory_hint_user(user_alpha2, NL80211_USER_REG_HINT_USER); 1982 1910 1983 1911 if (list_empty(&tmp_reg_req_list)) 1984 1912 return; ··· 2153 2081 else { 2154 2082 if (is_unknown_alpha2(rd->alpha2)) 2155 2083 pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); 2156 - else 2157 - pr_info("Regulatory domain changed to country: %c%c\n", 2158 - rd->alpha2[0], rd->alpha2[1]); 2084 + else { 2085 + if (reg_request_cell_base(last_request)) 2086 + pr_info("Regulatory domain changed " 2087 + "to country: %c%c by Cell Station\n", 2088 + rd->alpha2[0], rd->alpha2[1]); 2089 + else 2090 + pr_info("Regulatory domain changed " 2091 + "to country: %c%c\n", 2092 + rd->alpha2[0], rd->alpha2[1]); 2093 + } 2159 2094 } 2160 2095 print_dfs_region(rd->dfs_region); 2161 2096 print_rd_rules(rd); ··· 2207 2128 * checking if the alpha2 changes if CRDA was already called 2208 2129 */ 2209 2130 if (!regdom_changes(rd->alpha2)) 2210 - return -EINVAL; 2131 + return -EALREADY; 2211 2132 } 2212 2133 2213 2134 /* ··· 2327 2248 /* Note that this doesn't update the wiphys, this is done below */ 2328 2249 r = __set_regdom(rd); 2329 2250 if (r) { 2251 + if (r == -EALREADY) 2252 + reg_set_request_processed(); 2253 + 2330 2254 kfree(rd); 2331 2255 mutex_unlock(&reg_mutex); 2332 2256 return r; ··· 2372 2290 } 2373 2291 #endif /* CONFIG_HOTPLUG */ 2374 2292 2293 + void wiphy_regulatory_register(struct wiphy *wiphy) 2294 + { 2295 + assert_cfg80211_lock(); 2296 + 2297 + mutex_lock(&reg_mutex); 2298 + 2299 + if (!reg_dev_ignore_cell_hint(wiphy)) 2300 + reg_num_devs_support_basehint++; 2301 + 2302 + wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); 2303 + 2304 + mutex_unlock(&reg_mutex); 2305 + } 2306 + 2375 2307 /* Caller must hold cfg80211_mutex */ 2376 - void reg_device_remove(struct wiphy *wiphy) 2308 + void wiphy_regulatory_deregister(struct wiphy *wiphy) 2377 2309 { 2378 2310 struct wiphy *request_wiphy = NULL; 2379 2311 2380 2312 assert_cfg80211_lock(); 2381 2313 2382 2314 mutex_lock(&reg_mutex); 2315 + 2316 + if (!reg_dev_ignore_cell_hint(wiphy)) 2317 + reg_num_devs_support_basehint--; 2383 2318 2384 2319 kfree(wiphy->regd); 2385 2320 ··· 2463 2364 * as a user hint. 2464 2365 */ 2465 2366 if (!is_world_regdom(ieee80211_regdom)) 2466 - regulatory_hint_user(ieee80211_regdom); 2367 + regulatory_hint_user(ieee80211_regdom, 2368 + NL80211_USER_REG_HINT_USER); 2467 2369 2468 2370 return 0; 2469 2371 }
+5 -3
net/wireless/reg.h
··· 22 22 bool reg_is_valid_request(const char *alpha2); 23 23 bool reg_supported_dfs_region(u8 dfs_region); 24 24 25 - int regulatory_hint_user(const char *alpha2); 25 + int regulatory_hint_user(const char *alpha2, 26 + enum nl80211_user_reg_hint_type user_reg_hint_type); 26 27 27 28 int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env); 28 - void reg_device_remove(struct wiphy *wiphy); 29 + void wiphy_regulatory_register(struct wiphy *wiphy); 30 + void wiphy_regulatory_deregister(struct wiphy *wiphy); 29 31 30 32 int __init regulatory_init(void); 31 33 void regulatory_exit(void); 32 34 33 35 int set_regdom(const struct ieee80211_regdomain *rd); 34 36 35 - void regulatory_update(struct wiphy *wiphy, enum nl80211_reg_initiator setby); 37 + bool reg_last_request_cell_base(void); 36 38 37 39 /** 38 40 * regulatory_hint_found_beacon - hints a beacon was found on a channel
+13 -11
net/wireless/scan.c
··· 23 23 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) 24 24 { 25 25 struct cfg80211_scan_request *request; 26 - struct net_device *dev; 26 + struct wireless_dev *wdev; 27 27 #ifdef CONFIG_CFG80211_WEXT 28 28 union iwreq_data wrqu; 29 29 #endif ··· 35 35 if (!request) 36 36 return; 37 37 38 - dev = request->dev; 38 + wdev = request->wdev; 39 39 40 40 /* 41 41 * This must be before sending the other events! 42 42 * Otherwise, wpa_supplicant gets completely confused with 43 43 * wext events. 44 44 */ 45 - cfg80211_sme_scan_done(dev); 45 + if (wdev->netdev) 46 + cfg80211_sme_scan_done(wdev->netdev); 46 47 47 48 if (request->aborted) 48 - nl80211_send_scan_aborted(rdev, dev); 49 + nl80211_send_scan_aborted(rdev, wdev); 49 50 else 50 - nl80211_send_scan_done(rdev, dev); 51 + nl80211_send_scan_done(rdev, wdev); 51 52 52 53 #ifdef CONFIG_CFG80211_WEXT 53 - if (!request->aborted) { 54 + if (wdev->netdev && !request->aborted) { 54 55 memset(&wrqu, 0, sizeof(wrqu)); 55 56 56 - wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); 57 + wireless_send_event(wdev->netdev, SIOCGIWSCAN, &wrqu, NULL); 57 58 } 58 59 #endif 59 60 60 - dev_put(dev); 61 + if (wdev->netdev) 62 + dev_put(wdev->netdev); 61 63 62 64 rdev->scan_req = NULL; 63 65 ··· 957 955 } 958 956 959 957 creq->wiphy = wiphy; 960 - creq->dev = dev; 958 + creq->wdev = dev->ieee80211_ptr; 961 959 /* SSIDs come after channels */ 962 960 creq->ssids = (void *)&creq->channels[n_channels]; 963 961 creq->n_channels = n_channels; ··· 1026 1024 creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; 1027 1025 1028 1026 rdev->scan_req = creq; 1029 - err = rdev->ops->scan(wiphy, dev, creq); 1027 + err = rdev->ops->scan(wiphy, creq); 1030 1028 if (err) { 1031 1029 rdev->scan_req = NULL; 1032 1030 /* creq will be freed below */ 1033 1031 } else { 1034 - nl80211_send_scan_start(rdev, dev); 1032 + nl80211_send_scan_start(rdev, dev->ieee80211_ptr); 1035 1033 /* creq now owned by driver */ 1036 1034 creq = NULL; 1037 1035 dev_hold(dev);
+5 -5
net/wireless/sme.c
··· 51 51 */ 52 52 list_for_each_entry(rdev, &cfg80211_rdev_list, list) { 53 53 cfg80211_lock_rdev(rdev); 54 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 54 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 55 55 wdev_lock(wdev); 56 56 if (wdev->sme_state != CFG80211_SME_IDLE) 57 57 is_all_idle = false; ··· 136 136 wdev->conn->params.ssid_len); 137 137 request->ssids[0].ssid_len = wdev->conn->params.ssid_len; 138 138 139 - request->dev = wdev->netdev; 139 + request->wdev = wdev; 140 140 request->wiphy = &rdev->wiphy; 141 141 142 142 rdev->scan_req = request; 143 143 144 - err = rdev->ops->scan(wdev->wiphy, wdev->netdev, request); 144 + err = rdev->ops->scan(wdev->wiphy, request); 145 145 if (!err) { 146 146 wdev->conn->state = CFG80211_CONN_SCANNING; 147 - nl80211_send_scan_start(rdev, wdev->netdev); 147 + nl80211_send_scan_start(rdev, wdev); 148 148 dev_hold(wdev->netdev); 149 149 } else { 150 150 rdev->scan_req = NULL; ··· 221 221 cfg80211_lock_rdev(rdev); 222 222 mutex_lock(&rdev->devlist_mtx); 223 223 224 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 224 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 225 225 wdev_lock(wdev); 226 226 if (!netif_running(wdev->netdev)) { 227 227 wdev_unlock(wdev);
+13 -4
net/wireless/util.c
··· 793 793 794 794 mutex_lock(&rdev->devlist_mtx); 795 795 796 - list_for_each_entry(wdev, &rdev->netdev_list, list) 796 + list_for_each_entry(wdev, &rdev->wdev_list, list) 797 797 cfg80211_process_wdev_events(wdev); 798 798 799 799 mutex_unlock(&rdev->devlist_mtx); ··· 994 994 995 995 mutex_lock(&rdev->devlist_mtx); 996 996 997 - list_for_each_entry(wdev, &rdev->netdev_list, list) { 997 + list_for_each_entry(wdev, &rdev->wdev_list, list) { 998 998 if (!wdev->beacon_interval) 999 999 continue; 1000 1000 if (wdev->beacon_interval != beacon_int) { ··· 1050 1050 break; 1051 1051 } 1052 1052 1053 - list_for_each_entry(wdev_iter, &rdev->netdev_list, list) { 1053 + list_for_each_entry(wdev_iter, &rdev->wdev_list, list) { 1054 1054 if (wdev_iter == wdev) 1055 1055 continue; 1056 1056 if (!netif_running(wdev_iter->netdev)) ··· 1059 1059 if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype)) 1060 1060 continue; 1061 1061 1062 - cfg80211_get_chan_state(rdev, wdev_iter, &ch, &chmode); 1062 + /* 1063 + * We may be holding the "wdev" mutex, but now need to lock 1064 + * wdev_iter. This is OK because once we get here wdev_iter 1065 + * is not wdev (tested above), but we need to use the nested 1066 + * locking for lockdep. 1067 + */ 1068 + mutex_lock_nested(&wdev_iter->mtx, 1); 1069 + __acquire(wdev_iter->mtx); 1070 + cfg80211_get_chan_state(wdev_iter, &ch, &chmode); 1071 + wdev_unlock(wdev_iter); 1063 1072 1064 1073 switch (chmode) { 1065 1074 case CHAN_MODE_UNDEFINED:
+7 -2
net/wireless/wext-compat.c
··· 827 827 { 828 828 struct wireless_dev *wdev = dev->ieee80211_ptr; 829 829 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 830 + struct ieee80211_channel *chan; 831 + enum nl80211_channel_type channel_type; 830 832 831 833 switch (wdev->iftype) { 832 834 case NL80211_IFTYPE_STATION: ··· 836 834 case NL80211_IFTYPE_ADHOC: 837 835 return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); 838 836 case NL80211_IFTYPE_MONITOR: 839 - if (!rdev->monitor_channel) 837 + if (!rdev->ops->get_channel) 840 838 return -EINVAL; 841 839 842 - freq->m = rdev->monitor_channel->center_freq; 840 + chan = rdev->ops->get_channel(wdev->wiphy, wdev, &channel_type); 841 + if (!chan) 842 + return -EINVAL; 843 + freq->m = chan->center_freq; 843 844 freq->e = 6; 844 845 return 0; 845 846 default: