aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJeremy Erickson <jerickso@cs.unc.edu>2014-04-18 17:06:00 -0400
committerJeremy Erickson <jerickso@cs.unc.edu>2014-04-18 17:06:00 -0400
commita215aa7b9ab3759c047201199fba64d3042d7f13 (patch)
treebca37493d9b2233450e6d3ffced1261d0e4f71fe /drivers/net
parentd31199a77ef606f1d06894385f1852181ba6136b (diff)
Update 2.6.36 to 2.6.36.4wip-dissipation2-jerickso
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/8139cp.c10
-rw-r--r--drivers/net/atlx/atl1.c10
-rw-r--r--drivers/net/benet/be_cmds.c2
-rw-r--r--drivers/net/bonding/bonding.h4
-rw-r--r--drivers/net/e1000/e1000_main.c12
-rw-r--r--drivers/net/fec.c4
-rw-r--r--drivers/net/ifb.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c11
-rw-r--r--drivers/net/jme.c22
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/phy/marvell.c31
-rw-r--r--drivers/net/pppoe.c2
-rw-r--r--drivers/net/r6040.c22
-rw-r--r--drivers/net/r8169.c23
-rw-r--r--drivers/net/tehuti.c4
-rw-r--r--drivers/net/usb/usbnet.c11
-rw-r--r--drivers/net/virtio_net.c27
-rw-r--r--drivers/net/wireless/ath/ath.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_hw.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h191
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c87
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.h9
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mac.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_paprd.c14
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h12
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.h13
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_9287.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_def.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c60
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c41
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c96
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c49
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h15
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c116
-rw-r--r--drivers/net/wireless/b43/sdio.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h6
-rw-r--r--drivers/net/wireless/orinoco/main.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c14
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c14
-rw-r--r--drivers/net/wireless/orinoco/wext.c4
-rw-r--r--drivers/net/wireless/p54/eeprom.c4
-rw-r--r--drivers/net/wireless/p54/p54usb.c21
-rw-r--r--drivers/net/wireless/p54/txrx.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h7
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c59
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h5
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c13
-rw-r--r--drivers/net/xen-netfront.c4
66 files changed, 795 insertions, 410 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 4a4f6b81e32d..70609eefc2de 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -490,13 +490,11 @@ static inline unsigned int cp_rx_csum_ok (u32 status)
490{ 490{
491 unsigned int protocol = (status >> 16) & 0x3; 491 unsigned int protocol = (status >> 16) & 0x3;
492 492
493 if (likely((protocol == RxProtoTCP) && (!(status & TCPFail)))) 493 if (((protocol == RxProtoTCP) && !(status & TCPFail)) ||
494 ((protocol == RxProtoUDP) && !(status & UDPFail)))
494 return 1; 495 return 1;
495 else if ((protocol == RxProtoUDP) && (!(status & UDPFail))) 496 else
496 return 1; 497 return 0;
497 else if ((protocol == RxProtoIP) && (!(status & IPFail)))
498 return 1;
499 return 0;
500} 498}
501 499
502static int cp_rx_poll(struct napi_struct *napi, int budget) 500static int cp_rx_poll(struct napi_struct *napi, int budget)
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index c73be2848319..67f75c17919c 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -3503,6 +3503,8 @@ static int atl1_set_ringparam(struct net_device *netdev,
3503 struct atl1_rfd_ring rfd_old, rfd_new; 3503 struct atl1_rfd_ring rfd_old, rfd_new;
3504 struct atl1_rrd_ring rrd_old, rrd_new; 3504 struct atl1_rrd_ring rrd_old, rrd_new;
3505 struct atl1_ring_header rhdr_old, rhdr_new; 3505 struct atl1_ring_header rhdr_old, rhdr_new;
3506 struct atl1_smb smb;
3507 struct atl1_cmb cmb;
3506 int err; 3508 int err;
3507 3509
3508 tpd_old = adapter->tpd_ring; 3510 tpd_old = adapter->tpd_ring;
@@ -3543,11 +3545,19 @@ static int atl1_set_ringparam(struct net_device *netdev,
3543 adapter->rrd_ring = rrd_old; 3545 adapter->rrd_ring = rrd_old;
3544 adapter->tpd_ring = tpd_old; 3546 adapter->tpd_ring = tpd_old;
3545 adapter->ring_header = rhdr_old; 3547 adapter->ring_header = rhdr_old;
3548 /*
3549 * Save SMB and CMB, since atl1_free_ring_resources
3550 * will clear them.
3551 */
3552 smb = adapter->smb;
3553 cmb = adapter->cmb;
3546 atl1_free_ring_resources(adapter); 3554 atl1_free_ring_resources(adapter);
3547 adapter->rfd_ring = rfd_new; 3555 adapter->rfd_ring = rfd_new;
3548 adapter->rrd_ring = rrd_new; 3556 adapter->rrd_ring = rrd_new;
3549 adapter->tpd_ring = tpd_new; 3557 adapter->tpd_ring = tpd_new;
3550 adapter->ring_header = rhdr_new; 3558 adapter->ring_header = rhdr_new;
3559 adapter->smb = smb;
3560 adapter->cmb = cmb;
3551 3561
3552 err = atl1_up(adapter); 3562 err = atl1_up(adapter);
3553 if (err) 3563 if (err)
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 34abcc9403d6..dc913b986795 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -1179,7 +1179,7 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
1179 1179
1180 i = 0; 1180 i = 0;
1181 netdev_for_each_mc_addr(ha, netdev) 1181 netdev_for_each_mc_addr(ha, netdev)
1182 memcpy(req->mac[i].byte, ha->addr, ETH_ALEN); 1182 memcpy(req->mac[i++].byte, ha->addr, ETH_ALEN);
1183 } else { 1183 } else {
1184 req->promiscuous = 1; 1184 req->promiscuous = 1;
1185 } 1185 }
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index c6fdd851579a..c867cf901f9f 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -240,11 +240,11 @@ static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct n
240 240
241 bond_for_each_slave(bond, slave, i) { 241 bond_for_each_slave(bond, slave, i) {
242 if (slave->dev == slave_dev) { 242 if (slave->dev == slave_dev) {
243 break; 243 return slave;
244 } 244 }
245 } 245 }
246 246
247 return slave; 247 return 0;
248} 248}
249 249
250static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) 250static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 5cc39ed289c6..71324286b1e7 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -31,7 +31,7 @@
31 31
32char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
34#define DRV_VERSION "7.3.21-k6-NAPI" 34#define DRV_VERSION "7.3.21-k8-NAPI"
35const char e1000_driver_version[] = DRV_VERSION; 35const char e1000_driver_version[] = DRV_VERSION;
36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
37 37
@@ -483,9 +483,6 @@ void e1000_down(struct e1000_adapter *adapter)
483 struct net_device *netdev = adapter->netdev; 483 struct net_device *netdev = adapter->netdev;
484 u32 rctl, tctl; 484 u32 rctl, tctl;
485 485
486 /* signal that we're down so the interrupt handler does not
487 * reschedule our watchdog timer */
488 set_bit(__E1000_DOWN, &adapter->flags);
489 486
490 /* disable receives in the hardware */ 487 /* disable receives in the hardware */
491 rctl = er32(RCTL); 488 rctl = er32(RCTL);
@@ -506,6 +503,13 @@ void e1000_down(struct e1000_adapter *adapter)
506 503
507 e1000_irq_disable(adapter); 504 e1000_irq_disable(adapter);
508 505
506 /*
507 * Setting DOWN must be after irq_disable to prevent
508 * a screaming interrupt. Setting DOWN also prevents
509 * timers and tasks from rescheduling.
510 */
511 set_bit(__E1000_DOWN, &adapter->flags);
512
509 del_timer_sync(&adapter->tx_fifo_stall_timer); 513 del_timer_sync(&adapter->tx_fifo_stall_timer);
510 del_timer_sync(&adapter->watchdog_timer); 514 del_timer_sync(&adapter->watchdog_timer);
511 del_timer_sync(&adapter->phy_info_timer); 515 del_timer_sync(&adapter->phy_info_timer);
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index cce32d43175f..52e9ca8de4b2 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -651,8 +651,8 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
651 fep->mii_timeout = 0; 651 fep->mii_timeout = 0;
652 init_completion(&fep->mdio_done); 652 init_completion(&fep->mdio_done);
653 653
654 /* start a read op */ 654 /* start a write op */
655 writel(FEC_MMFR_ST | FEC_MMFR_OP_READ | 655 writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE |
656 FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | 656 FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
657 FEC_MMFR_TA | FEC_MMFR_DATA(value), 657 FEC_MMFR_TA | FEC_MMFR_DATA(value),
658 fep->hwp + FEC_MII_DATA); 658 fep->hwp + FEC_MII_DATA);
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ab9f675c5b8b..fe337bd121aa 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -104,6 +104,8 @@ static void ri_tasklet(unsigned long dev)
104 rcu_read_unlock(); 104 rcu_read_unlock();
105 dev_kfree_skb(skb); 105 dev_kfree_skb(skb);
106 stats->tx_dropped++; 106 stats->tx_dropped++;
107 if (skb_queue_len(&dp->tq) != 0)
108 goto resched;
107 break; 109 break;
108 } 110 }
109 rcu_read_unlock(); 111 rcu_read_unlock();
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index e32af434cc9d..0e7f086d28db 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2651,9 +2651,16 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2651 int rx_buf_len; 2651 int rx_buf_len;
2652 2652
2653 /* Decide whether to use packet split mode or not */ 2653 /* Decide whether to use packet split mode or not */
2654 /* On by default */
2655 adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED;
2656
2654 /* Do not use packet split if we're in SR-IOV Mode */ 2657 /* Do not use packet split if we're in SR-IOV Mode */
2655 if (!adapter->num_vfs) 2658 if (adapter->num_vfs)
2656 adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED; 2659 adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED;
2660
2661 /* Disable packet split due to 82599 erratum #45 */
2662 if (hw->mac.type == ixgbe_mac_82599EB)
2663 adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED;
2657 2664
2658 /* Set the RX buffer length according to the mode */ 2665 /* Set the RX buffer length according to the mode */
2659 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 2666 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 99f24f5cac53..f0643ac4aff1 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -1575,6 +1575,16 @@ jme_free_irq(struct jme_adapter *jme)
1575 } 1575 }
1576} 1576}
1577 1577
1578static inline void
1579jme_phy_on(struct jme_adapter *jme)
1580{
1581 u32 bmcr;
1582
1583 bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
1584 bmcr &= ~BMCR_PDOWN;
1585 jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, bmcr);
1586}
1587
1578static int 1588static int
1579jme_open(struct net_device *netdev) 1589jme_open(struct net_device *netdev)
1580{ 1590{
@@ -1595,10 +1605,12 @@ jme_open(struct net_device *netdev)
1595 1605
1596 jme_start_irq(jme); 1606 jme_start_irq(jme);
1597 1607
1598 if (test_bit(JME_FLAG_SSET, &jme->flags)) 1608 if (test_bit(JME_FLAG_SSET, &jme->flags)) {
1609 jme_phy_on(jme);
1599 jme_set_settings(netdev, &jme->old_ecmd); 1610 jme_set_settings(netdev, &jme->old_ecmd);
1600 else 1611 } else {
1601 jme_reset_phy_processor(jme); 1612 jme_reset_phy_processor(jme);
1613 }
1602 1614
1603 jme_reset_link(jme); 1615 jme_reset_link(jme);
1604 1616
@@ -3006,10 +3018,12 @@ jme_resume(struct pci_dev *pdev)
3006 jme_clear_pm(jme); 3018 jme_clear_pm(jme);
3007 pci_restore_state(pdev); 3019 pci_restore_state(pdev);
3008 3020
3009 if (test_bit(JME_FLAG_SSET, &jme->flags)) 3021 if (test_bit(JME_FLAG_SSET, &jme->flags)) {
3022 jme_phy_on(jme);
3010 jme_set_settings(netdev, &jme->old_ecmd); 3023 jme_set_settings(netdev, &jme->old_ecmd);
3011 else 3024 } else {
3012 jme_reset_phy_processor(jme); 3025 jme_reset_phy_processor(jme);
3026 }
3013 3027
3014 jme_start_irq(jme); 3028 jme_start_irq(jme);
3015 netif_device_attach(netdev); 3029 netif_device_attach(netdev);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index f9b509a6b09a..b12553bb5ecc 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1622,6 +1622,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1622 PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "FASTline PCMCIA 10/100 Fast-Ethernet", 0xfa2e424d, 0x3953d9b9), 1622 PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "FASTline PCMCIA 10/100 Fast-Ethernet", 0xfa2e424d, 0x3953d9b9),
1623 PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722), 1623 PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722),
1624 PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2), 1624 PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2),
1625 PCMCIA_DEVICE_PROD_ID12("corega", "Ether CF-TD", 0x0a21501a, 0x6589340a),
1625 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd), 1626 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd),
1626 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-TD", 0x5261440f, 0xc49bd73d), 1627 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-TD", 0x5261440f, 0xc49bd73d),
1627 PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), 1628 PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d),
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 0101f2bdf400..c1ba49b772ff 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -196,20 +196,27 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
196 MII_88E1121_PHY_MSCR_PAGE); 196 MII_88E1121_PHY_MSCR_PAGE);
197 if (err < 0) 197 if (err < 0)
198 return err; 198 return err;
199 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
200 MII_88E1121_PHY_MSCR_DELAY_MASK;
201 199
202 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) 200 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
203 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY | 201 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
204 MII_88E1121_PHY_MSCR_TX_DELAY); 202 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
205 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) 203 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
206 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
207 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
208 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
209 204
210 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr); 205 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
211 if (err < 0) 206 MII_88E1121_PHY_MSCR_DELAY_MASK;
212 return err; 207
208 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
209 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
210 MII_88E1121_PHY_MSCR_TX_DELAY);
211 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
212 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
213 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
214 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
215
216 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
217 if (err < 0)
218 return err;
219 }
213 220
214 phy_write(phydev, MII_88E1121_PHY_PAGE, oldpage); 221 phy_write(phydev, MII_88E1121_PHY_PAGE, oldpage);
215 222
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index c07de359dc07..6a3eae2407c1 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -948,7 +948,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
948 948
949abort: 949abort:
950 kfree_skb(skb); 950 kfree_skb(skb);
951 return 0; 951 return 1;
952} 952}
953 953
954/************************************************************************ 954/************************************************************************
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 142c381e1d73..80666f097ce6 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -893,16 +893,18 @@ static void r6040_multicast_list(struct net_device *dev)
893 /* Multicast Address 1~4 case */ 893 /* Multicast Address 1~4 case */
894 i = 0; 894 i = 0;
895 netdev_for_each_mc_addr(ha, dev) { 895 netdev_for_each_mc_addr(ha, dev) {
896 if (i < MCAST_MAX) { 896 if (i >= MCAST_MAX)
897 adrp = (u16 *) ha->addr; 897 break;
898 iowrite16(adrp[0], ioaddr + MID_1L + 8 * i); 898 adrp = (u16 *) ha->addr;
899 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i); 899 iowrite16(adrp[0], ioaddr + MID_1L + 8 * i);
900 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i); 900 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i);
901 } else { 901 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i);
902 iowrite16(0xffff, ioaddr + MID_1L + 8 * i); 902 i++;
903 iowrite16(0xffff, ioaddr + MID_1M + 8 * i); 903 }
904 iowrite16(0xffff, ioaddr + MID_1H + 8 * i); 904 while (i < MCAST_MAX) {
905 } 905 iowrite16(0xffff, ioaddr + MID_1L + 8 * i);
906 iowrite16(0xffff, ioaddr + MID_1M + 8 * i);
907 iowrite16(0xffff, ioaddr + MID_1H + 8 * i);
906 i++; 908 i++;
907 } 909 }
908} 910}
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 992db2fa136e..ed65e4a473ec 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -855,10 +855,10 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
855 else 855 else
856 tp->features &= ~RTL_FEATURE_WOL; 856 tp->features &= ~RTL_FEATURE_WOL;
857 __rtl8169_set_wol(tp, wol->wolopts); 857 __rtl8169_set_wol(tp, wol->wolopts);
858 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);
859
860 spin_unlock_irq(&tp->lock); 858 spin_unlock_irq(&tp->lock);
861 859
860 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);
861
862 return 0; 862 return 0;
863} 863}
864 864
@@ -2936,7 +2936,7 @@ static const struct rtl_cfg_info {
2936 .hw_start = rtl_hw_start_8168, 2936 .hw_start = rtl_hw_start_8168,
2937 .region = 2, 2937 .region = 2,
2938 .align = 8, 2938 .align = 8,
2939 .intr_event = SYSErr | RxFIFOOver | LinkChg | RxOverflow | 2939 .intr_event = SYSErr | LinkChg | RxOverflow |
2940 TxErr | TxOK | RxOK | RxErr, 2940 TxErr | TxOK | RxOK | RxErr,
2941 .napi_event = TxErr | TxOK | RxOK | RxOverflow, 2941 .napi_event = TxErr | TxOK | RxOK | RxOverflow,
2942 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, 2942 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI,
@@ -4455,14 +4455,12 @@ static inline int rtl8169_fragmented_frame(u32 status)
4455 return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag); 4455 return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
4456} 4456}
4457 4457
4458static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) 4458static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
4459{ 4459{
4460 u32 opts1 = le32_to_cpu(desc->opts1);
4461 u32 status = opts1 & RxProtoMask; 4460 u32 status = opts1 & RxProtoMask;
4462 4461
4463 if (((status == RxProtoTCP) && !(opts1 & TCPFail)) || 4462 if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
4464 ((status == RxProtoUDP) && !(opts1 & UDPFail)) || 4463 ((status == RxProtoUDP) && !(opts1 & UDPFail)))
4465 ((status == RxProtoIP) && !(opts1 & IPFail)))
4466 skb->ip_summed = CHECKSUM_UNNECESSARY; 4464 skb->ip_summed = CHECKSUM_UNNECESSARY;
4467 else 4465 else
4468 skb->ip_summed = CHECKSUM_NONE; 4466 skb->ip_summed = CHECKSUM_NONE;
@@ -4551,8 +4549,6 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
4551 continue; 4549 continue;
4552 } 4550 }
4553 4551
4554 rtl8169_rx_csum(skb, desc);
4555
4556 if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) { 4552 if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) {
4557 dma_sync_single_for_device(&pdev->dev, addr, 4553 dma_sync_single_for_device(&pdev->dev, addr,
4558 pkt_size, PCI_DMA_FROMDEVICE); 4554 pkt_size, PCI_DMA_FROMDEVICE);
@@ -4563,6 +4559,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
4563 tp->Rx_skbuff[entry] = NULL; 4559 tp->Rx_skbuff[entry] = NULL;
4564 } 4560 }
4565 4561
4562 rtl8169_rx_csum(skb, status);
4566 skb_put(skb, pkt_size); 4563 skb_put(skb, pkt_size);
4567 skb->protocol = eth_type_trans(skb, dev); 4564 skb->protocol = eth_type_trans(skb, dev);
4568 4565
@@ -4630,7 +4627,8 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
4630 } 4627 }
4631 4628
4632 /* Work around for rx fifo overflow */ 4629 /* Work around for rx fifo overflow */
4633 if (unlikely(status & RxFIFOOver)) { 4630 if (unlikely(status & RxFIFOOver) &&
4631 (tp->mac_version == RTL_GIGA_MAC_VER_11)) {
4634 netif_stop_queue(dev); 4632 netif_stop_queue(dev);
4635 rtl8169_tx_timeout(dev); 4633 rtl8169_tx_timeout(dev);
4636 break; 4634 break;
@@ -4891,6 +4889,9 @@ static int rtl8169_resume(struct device *device)
4891{ 4889{
4892 struct pci_dev *pdev = to_pci_dev(device); 4890 struct pci_dev *pdev = to_pci_dev(device);
4893 struct net_device *dev = pci_get_drvdata(pdev); 4891 struct net_device *dev = pci_get_drvdata(pdev);
4892 struct rtl8169_private *tp = netdev_priv(dev);
4893
4894 rtl8169_init_phy(dev, tp);
4894 4895
4895 if (netif_running(dev)) 4896 if (netif_running(dev))
4896 __rtl8169_resume(dev); 4897 __rtl8169_resume(dev);
@@ -4931,6 +4932,8 @@ static int rtl8169_runtime_resume(struct device *device)
4931 tp->saved_wolopts = 0; 4932 tp->saved_wolopts = 0;
4932 spin_unlock_irq(&tp->lock); 4933 spin_unlock_irq(&tp->lock);
4933 4934
4935 rtl8169_init_phy(dev, tp);
4936
4934 __rtl8169_resume(dev); 4937 __rtl8169_resume(dev);
4935 4938
4936 return 0; 4939 return 0;
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index 737df6032bbc..2ce585a511d9 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -324,7 +324,7 @@ static int bdx_fw_load(struct bdx_priv *priv)
324 ENTER; 324 ENTER;
325 master = READ_REG(priv, regINIT_SEMAPHORE); 325 master = READ_REG(priv, regINIT_SEMAPHORE);
326 if (!READ_REG(priv, regINIT_STATUS) && master) { 326 if (!READ_REG(priv, regINIT_STATUS) && master) {
327 rc = request_firmware(&fw, "tehuti/firmware.bin", &priv->pdev->dev); 327 rc = request_firmware(&fw, "tehuti/bdx.bin", &priv->pdev->dev);
328 if (rc) 328 if (rc)
329 goto out; 329 goto out;
330 bdx_tx_push_desc_safe(priv, (char *)fw->data, fw->size); 330 bdx_tx_push_desc_safe(priv, (char *)fw->data, fw->size);
@@ -2516,4 +2516,4 @@ module_exit(bdx_module_exit);
2516MODULE_LICENSE("GPL"); 2516MODULE_LICENSE("GPL");
2517MODULE_AUTHOR(DRIVER_AUTHOR); 2517MODULE_AUTHOR(DRIVER_AUTHOR);
2518MODULE_DESCRIPTION(BDX_DRV_DESC); 2518MODULE_DESCRIPTION(BDX_DRV_DESC);
2519MODULE_FIRMWARE("tehuti/firmware.bin"); 2519MODULE_FIRMWARE("tehuti/bdx.bin");
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ca7fc9df1ccf..c04d49e31f81 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -45,6 +45,7 @@
45#include <linux/usb/usbnet.h> 45#include <linux/usb/usbnet.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/kernel.h> 47#include <linux/kernel.h>
48#include <linux/pm_runtime.h>
48 49
49#define DRIVER_VERSION "22-Aug-2005" 50#define DRIVER_VERSION "22-Aug-2005"
50 51
@@ -1273,6 +1274,16 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1273 struct usb_device *xdev; 1274 struct usb_device *xdev;
1274 int status; 1275 int status;
1275 const char *name; 1276 const char *name;
1277 struct usb_driver *driver = to_usb_driver(udev->dev.driver);
1278
1279 /* usbnet already took usb runtime pm, so have to enable the feature
1280 * for usb interface, otherwise usb_autopm_get_interface may return
1281 * failure if USB_SUSPEND(RUNTIME_PM) is enabled.
1282 */
1283 if (!driver->supports_autosuspend) {
1284 driver->supports_autosuspend = 1;
1285 pm_runtime_enable(&udev->dev);
1286 }
1276 1287
1277 name = udev->dev.driver->name; 1288 name = udev->dev.driver->name;
1278 info = (struct driver_info *) prod->driver_info; 1289 info = (struct driver_info *) prod->driver_info;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4598e9d2608f..65d3d801a258 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -446,6 +446,20 @@ static void skb_recv_done(struct virtqueue *rvq)
446 } 446 }
447} 447}
448 448
449static void virtnet_napi_enable(struct virtnet_info *vi)
450{
451 napi_enable(&vi->napi);
452
453 /* If all buffers were filled by other side before we napi_enabled, we
454 * won't get another interrupt, so process any outstanding packets
455 * now. virtnet_poll wants re-enable the queue, so we disable here.
456 * We synchronize against interrupts via NAPI_STATE_SCHED */
457 if (napi_schedule_prep(&vi->napi)) {
458 virtqueue_disable_cb(vi->rvq);
459 __napi_schedule(&vi->napi);
460 }
461}
462
449static void refill_work(struct work_struct *work) 463static void refill_work(struct work_struct *work)
450{ 464{
451 struct virtnet_info *vi; 465 struct virtnet_info *vi;
@@ -454,7 +468,7 @@ static void refill_work(struct work_struct *work)
454 vi = container_of(work, struct virtnet_info, refill.work); 468 vi = container_of(work, struct virtnet_info, refill.work);
455 napi_disable(&vi->napi); 469 napi_disable(&vi->napi);
456 still_empty = !try_fill_recv(vi, GFP_KERNEL); 470 still_empty = !try_fill_recv(vi, GFP_KERNEL);
457 napi_enable(&vi->napi); 471 virtnet_napi_enable(vi);
458 472
459 /* In theory, this can happen: if we don't get any buffers in 473 /* In theory, this can happen: if we don't get any buffers in
460 * we will *never* try to fill again. */ 474 * we will *never* try to fill again. */
@@ -638,16 +652,7 @@ static int virtnet_open(struct net_device *dev)
638{ 652{
639 struct virtnet_info *vi = netdev_priv(dev); 653 struct virtnet_info *vi = netdev_priv(dev);
640 654
641 napi_enable(&vi->napi); 655 virtnet_napi_enable(vi);
642
643 /* If all buffers were filled by other side before we napi_enabled, we
644 * won't get another interrupt, so process any outstanding packets
645 * now. virtnet_poll wants re-enable the queue, so we disable here.
646 * We synchronize against interrupts via NAPI_STATE_SCHED */
647 if (napi_schedule_prep(&vi->napi)) {
648 virtqueue_disable_cb(vi->rvq);
649 __napi_schedule(&vi->napi);
650 }
651 return 0; 656 return 0;
652} 657}
653 658
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index d32f2828b098..a706202fa67c 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -119,6 +119,7 @@ struct ath_common {
119 119
120 u32 keymax; 120 u32 keymax;
121 DECLARE_BITMAP(keymap, ATH_KEYMAX); 121 DECLARE_BITMAP(keymap, ATH_KEYMAX);
122 DECLARE_BITMAP(tkip_keymap, ATH_KEYMAX);
122 u8 splitmic; 123 u8 splitmic;
123 124
124 struct ath_regulatory regulatory; 125 struct ath_regulatory regulatory;
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index fe7418aefc4a..d4ee07084c4d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -710,10 +710,6 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
710 710
711 /* Do NF cal only at longer intervals */ 711 /* Do NF cal only at longer intervals */
712 if (longcal || nfcal_pending) { 712 if (longcal || nfcal_pending) {
713 /* Do periodic PAOffset Cal */
714 ar9002_hw_pa_cal(ah, false);
715 ar9002_hw_olc_temp_compensation(ah);
716
717 /* 713 /*
718 * Get the value from the previous NF cal and update 714 * Get the value from the previous NF cal and update
719 * history buffer. 715 * history buffer.
@@ -728,8 +724,12 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
728 ath9k_hw_loadnf(ah, ah->curchan); 724 ath9k_hw_loadnf(ah, ah->curchan);
729 } 725 }
730 726
731 if (longcal) 727 if (longcal) {
732 ath9k_hw_start_nfcal(ah, false); 728 ath9k_hw_start_nfcal(ah, false);
729 /* Do periodic PAOffset Cal */
730 ar9002_hw_pa_cal(ah, false);
731 ar9002_hw_olc_temp_compensation(ah);
732 }
733 } 733 }
734 734
735 return iscaldone; 735 return iscaldone;
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
index 303c63da5ea3..ab1c50b8326d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
@@ -411,6 +411,9 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
411 val &= ~(AR_WA_BIT6 | AR_WA_BIT7); 411 val &= ~(AR_WA_BIT6 | AR_WA_BIT7);
412 } 412 }
413 413
414 if (AR_SREV_9280(ah))
415 val |= AR_WA_BIT22;
416
414 if (AR_SREV_9285E_20(ah)) 417 if (AR_SREV_9285E_20(ah))
415 val |= AR_WA_BIT23; 418 val |= AR_WA_BIT23;
416 419
@@ -442,9 +445,8 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
442 } 445 }
443 446
444 /* WAR for ASPM system hang */ 447 /* WAR for ASPM system hang */
445 if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) { 448 if (AR_SREV_9285(ah) || AR_SREV_9287(ah))
446 val |= (AR_WA_BIT6 | AR_WA_BIT7); 449 val |= (AR_WA_BIT6 | AR_WA_BIT7);
447 }
448 450
449 if (AR_SREV_9285E_20(ah)) 451 if (AR_SREV_9285E_20(ah))
450 val |= AR_WA_BIT23; 452 val |= AR_WA_BIT23;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
index ec98ab50748a..a14a5e43cf56 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
@@ -34,6 +34,10 @@ static const u32 ar9300_2p2_radio_postamble[][5] = {
34 34
35static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p2[][5] = { 35static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p2[][5] = {
36 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 36 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
37 {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
38 {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
39 {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
40 {0x0000a2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
37 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, 41 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
38 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 42 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
39 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002}, 43 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
@@ -99,6 +103,30 @@ static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p2[][5] = {
99 {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 103 {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
100 {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 104 {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
101 {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 105 {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
106 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
107 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
108 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
109 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
110 {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
111 {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000},
112 {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501},
113 {0x0000a61c, 0x02008802, 0x02008802, 0x02008501, 0x02008501},
114 {0x0000a620, 0x0300cc03, 0x0300cc03, 0x0280ca03, 0x0280ca03},
115 {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
116 {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04014c04, 0x04014c04},
117 {0x0000a62c, 0x03810c03, 0x03810c03, 0x04015005, 0x04015005},
118 {0x0000a630, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
119 {0x0000a634, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
120 {0x0000a638, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
121 {0x0000a63c, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
122 {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
123 {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
124 {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
125 {0x0000b2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
126 {0x0000c2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
127 {0x0000c2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
128 {0x0000c2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
129 {0x0000c2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
102 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 130 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
103 {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001}, 131 {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
104 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 132 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
@@ -118,7 +146,7 @@ static const u32 ar9300Modes_fast_clock_2p2[][3] = {
118 {0x00008014, 0x044c044c, 0x08980898}, 146 {0x00008014, 0x044c044c, 0x08980898},
119 {0x0000801c, 0x148ec02b, 0x148ec057}, 147 {0x0000801c, 0x148ec02b, 0x148ec057},
120 {0x00008318, 0x000044c0, 0x00008980}, 148 {0x00008318, 0x000044c0, 0x00008980},
121 {0x00009e00, 0x03721821, 0x03721821}, 149 {0x00009e00, 0x0372131c, 0x0372131c},
122 {0x0000a230, 0x0000000b, 0x00000016}, 150 {0x0000a230, 0x0000000b, 0x00000016},
123 {0x0000a254, 0x00000898, 0x00001130}, 151 {0x0000a254, 0x00000898, 0x00001130},
124}; 152};
@@ -595,15 +623,16 @@ static const u32 ar9300_2p2_baseband_postamble[][5] = {
595 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, 623 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
596 {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, 624 {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
597 {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, 625 {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4},
598 {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0}, 626 {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0},
599 {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, 627 {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020},
600 {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, 628 {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2},
601 {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, 629 {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e},
602 {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e}, 630 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e},
603 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 631 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
604 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 632 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
605 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, 633 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
606 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, 634 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
635 {0x00009e3c, 0xcf946220, 0xcf946220, 0xcf946222, 0xcf946222},
607 {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27}, 636 {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
608 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012}, 637 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
609 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, 638 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
@@ -624,16 +653,16 @@ static const u32 ar9300_2p2_baseband_postamble[][5] = {
624 {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222}, 653 {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
625 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18}, 654 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
626 {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982}, 655 {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982},
627 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a}, 656 {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a},
628 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 657 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
629 {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 658 {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
630 {0x0000ae04, 0x00800000, 0x00800000, 0x00800000, 0x00800000}, 659 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x001c0000},
631 {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 660 {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
632 {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 661 {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
633 {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce}, 662 {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
634 {0x0000b284, 0x00000000, 0x00000000, 0x00000150, 0x00000150}, 663 {0x0000b284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
635 {0x0000b830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 664 {0x0000b830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
636 {0x0000be04, 0x00800000, 0x00800000, 0x00800000, 0x00800000}, 665 {0x0000be04, 0x001c0000, 0x001c0000, 0x001c0000, 0x001c0000},
637 {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 666 {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
638 {0x0000be1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 667 {0x0000be1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
639 {0x0000be20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce}, 668 {0x0000be20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
@@ -649,13 +678,13 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
649 {0x00009814, 0x9280c00a}, 678 {0x00009814, 0x9280c00a},
650 {0x00009818, 0x00000000}, 679 {0x00009818, 0x00000000},
651 {0x0000981c, 0x00020028}, 680 {0x0000981c, 0x00020028},
652 {0x00009834, 0x5f3ca3de}, 681 {0x00009834, 0x6400a290},
653 {0x00009838, 0x0108ecff}, 682 {0x00009838, 0x0108ecff},
654 {0x0000983c, 0x14750600}, 683 {0x0000983c, 0x14750600},
655 {0x00009880, 0x201fff00}, 684 {0x00009880, 0x201fff00},
656 {0x00009884, 0x00001042}, 685 {0x00009884, 0x00001042},
657 {0x000098a4, 0x00200400}, 686 {0x000098a4, 0x00200400},
658 {0x000098b0, 0x52440bbe}, 687 {0x000098b0, 0x32840bbe},
659 {0x000098d0, 0x004b6a8e}, 688 {0x000098d0, 0x004b6a8e},
660 {0x000098d4, 0x00000820}, 689 {0x000098d4, 0x00000820},
661 {0x000098dc, 0x00000000}, 690 {0x000098dc, 0x00000000},
@@ -681,7 +710,6 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
681 {0x00009e30, 0x06336f77}, 710 {0x00009e30, 0x06336f77},
682 {0x00009e34, 0x6af6532f}, 711 {0x00009e34, 0x6af6532f},
683 {0x00009e38, 0x0cc80c00}, 712 {0x00009e38, 0x0cc80c00},
684 {0x00009e3c, 0xcf946222},
685 {0x00009e40, 0x0d261820}, 713 {0x00009e40, 0x0d261820},
686 {0x00009e4c, 0x00001004}, 714 {0x00009e4c, 0x00001004},
687 {0x00009e50, 0x00ff03f1}, 715 {0x00009e50, 0x00ff03f1},
@@ -694,7 +722,7 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
694 {0x0000a220, 0x00000000}, 722 {0x0000a220, 0x00000000},
695 {0x0000a224, 0x00000000}, 723 {0x0000a224, 0x00000000},
696 {0x0000a228, 0x10002310}, 724 {0x0000a228, 0x10002310},
697 {0x0000a22c, 0x01036a1e}, 725 {0x0000a22c, 0x01036a27},
698 {0x0000a23c, 0x00000000}, 726 {0x0000a23c, 0x00000000},
699 {0x0000a244, 0x0c000000}, 727 {0x0000a244, 0x0c000000},
700 {0x0000a2a0, 0x00000001}, 728 {0x0000a2a0, 0x00000001},
@@ -702,10 +730,6 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
702 {0x0000a2c8, 0x00000000}, 730 {0x0000a2c8, 0x00000000},
703 {0x0000a2cc, 0x18c43433}, 731 {0x0000a2cc, 0x18c43433},
704 {0x0000a2d4, 0x00000000}, 732 {0x0000a2d4, 0x00000000},
705 {0x0000a2dc, 0x00000000},
706 {0x0000a2e0, 0x00000000},
707 {0x0000a2e4, 0x00000000},
708 {0x0000a2e8, 0x00000000},
709 {0x0000a2ec, 0x00000000}, 733 {0x0000a2ec, 0x00000000},
710 {0x0000a2f0, 0x00000000}, 734 {0x0000a2f0, 0x00000000},
711 {0x0000a2f4, 0x00000000}, 735 {0x0000a2f4, 0x00000000},
@@ -753,33 +777,17 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
753 {0x0000a430, 0x1ce739ce}, 777 {0x0000a430, 0x1ce739ce},
754 {0x0000a434, 0x00000000}, 778 {0x0000a434, 0x00000000},
755 {0x0000a438, 0x00001801}, 779 {0x0000a438, 0x00001801},
756 {0x0000a43c, 0x00000000}, 780 {0x0000a43c, 0x00100000},
757 {0x0000a440, 0x00000000}, 781 {0x0000a440, 0x00000000},
758 {0x0000a444, 0x00000000}, 782 {0x0000a444, 0x00000000},
759 {0x0000a448, 0x06000080}, 783 {0x0000a448, 0x06000080},
760 {0x0000a44c, 0x00000001}, 784 {0x0000a44c, 0x00000001},
761 {0x0000a450, 0x00010000}, 785 {0x0000a450, 0x00010000},
762 {0x0000a458, 0x00000000}, 786 {0x0000a458, 0x00000000},
763 {0x0000a600, 0x00000000},
764 {0x0000a604, 0x00000000},
765 {0x0000a608, 0x00000000},
766 {0x0000a60c, 0x00000000},
767 {0x0000a610, 0x00000000},
768 {0x0000a614, 0x00000000},
769 {0x0000a618, 0x00000000},
770 {0x0000a61c, 0x00000000},
771 {0x0000a620, 0x00000000},
772 {0x0000a624, 0x00000000},
773 {0x0000a628, 0x00000000},
774 {0x0000a62c, 0x00000000},
775 {0x0000a630, 0x00000000},
776 {0x0000a634, 0x00000000},
777 {0x0000a638, 0x00000000},
778 {0x0000a63c, 0x00000000},
779 {0x0000a640, 0x00000000}, 787 {0x0000a640, 0x00000000},
780 {0x0000a644, 0x3fad9d74}, 788 {0x0000a644, 0x3fad9d74},
781 {0x0000a648, 0x0048060a}, 789 {0x0000a648, 0x0048060a},
782 {0x0000a64c, 0x00000637}, 790 {0x0000a64c, 0x00003c37},
783 {0x0000a670, 0x03020100}, 791 {0x0000a670, 0x03020100},
784 {0x0000a674, 0x09080504}, 792 {0x0000a674, 0x09080504},
785 {0x0000a678, 0x0d0c0b0a}, 793 {0x0000a678, 0x0d0c0b0a},
@@ -802,10 +810,6 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
802 {0x0000a8f4, 0x00000000}, 810 {0x0000a8f4, 0x00000000},
803 {0x0000b2d0, 0x00000080}, 811 {0x0000b2d0, 0x00000080},
804 {0x0000b2d4, 0x00000000}, 812 {0x0000b2d4, 0x00000000},
805 {0x0000b2dc, 0x00000000},
806 {0x0000b2e0, 0x00000000},
807 {0x0000b2e4, 0x00000000},
808 {0x0000b2e8, 0x00000000},
809 {0x0000b2ec, 0x00000000}, 813 {0x0000b2ec, 0x00000000},
810 {0x0000b2f0, 0x00000000}, 814 {0x0000b2f0, 0x00000000},
811 {0x0000b2f4, 0x00000000}, 815 {0x0000b2f4, 0x00000000},
@@ -820,10 +824,6 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
820 {0x0000b8f4, 0x00000000}, 824 {0x0000b8f4, 0x00000000},
821 {0x0000c2d0, 0x00000080}, 825 {0x0000c2d0, 0x00000080},
822 {0x0000c2d4, 0x00000000}, 826 {0x0000c2d4, 0x00000000},
823 {0x0000c2dc, 0x00000000},
824 {0x0000c2e0, 0x00000000},
825 {0x0000c2e4, 0x00000000},
826 {0x0000c2e8, 0x00000000},
827 {0x0000c2ec, 0x00000000}, 827 {0x0000c2ec, 0x00000000},
828 {0x0000c2f0, 0x00000000}, 828 {0x0000c2f0, 0x00000000},
829 {0x0000c2f4, 0x00000000}, 829 {0x0000c2f4, 0x00000000},
@@ -835,6 +835,10 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
835 835
836static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = { 836static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
837 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 837 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
838 {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
839 {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
840 {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
841 {0x0000a2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
838 {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9}, 842 {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9},
839 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, 843 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
840 {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002}, 844 {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002},
@@ -855,7 +859,7 @@ static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
855 {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660}, 859 {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660},
856 {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861}, 860 {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861},
857 {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81}, 861 {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81},
858 {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83}, 862 {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83},
859 {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84}, 863 {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84},
860 {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3}, 864 {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3},
861 {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5}, 865 {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5},
@@ -900,6 +904,30 @@ static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
900 {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 904 {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
901 {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 905 {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
902 {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 906 {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
907 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
908 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
909 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
910 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
911 {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000},
912 {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000},
913 {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501},
914 {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501},
915 {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03},
916 {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04},
917 {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04},
918 {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
919 {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
920 {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
921 {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
922 {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
923 {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
924 {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
925 {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
926 {0x0000b2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
927 {0x0000c2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
928 {0x0000c2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
929 {0x0000c2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
930 {0x0000c2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
903 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 931 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
904 {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001}, 932 {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
905 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 933 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
@@ -913,6 +941,10 @@ static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
913 941
914static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5] = { 942static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5] = {
915 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 943 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
944 {0x0000a2dc, 0x01feee00, 0x01feee00, 0x00637800, 0x00637800},
945 {0x0000a2e0, 0x0000f000, 0x0000f000, 0x03838000, 0x03838000},
946 {0x0000a2e4, 0x01ff0000, 0x01ff0000, 0x03fc0000, 0x03fc0000},
947 {0x0000a2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
916 {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9}, 948 {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9},
917 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, 949 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
918 {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002}, 950 {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002},
@@ -933,7 +965,7 @@ static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5] = {
933 {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660}, 965 {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660},
934 {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861}, 966 {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861},
935 {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81}, 967 {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81},
936 {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83}, 968 {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83},
937 {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84}, 969 {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84},
938 {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3}, 970 {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3},
939 {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5}, 971 {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5},
@@ -978,6 +1010,30 @@ static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5] = {
978 {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 1010 {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
979 {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 1011 {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
980 {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, 1012 {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
1013 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1014 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1015 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1016 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1017 {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000},
1018 {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000},
1019 {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501},
1020 {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501},
1021 {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03},
1022 {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04},
1023 {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04},
1024 {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
1025 {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
1026 {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
1027 {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
1028 {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
1029 {0x0000b2dc, 0x01feee00, 0x01feee00, 0x00637800, 0x00637800},
1030 {0x0000b2e0, 0x0000f000, 0x0000f000, 0x03838000, 0x03838000},
1031 {0x0000b2e4, 0x01ff0000, 0x01ff0000, 0x03fc0000, 0x03fc0000},
1032 {0x0000b2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1033 {0x0000c2dc, 0x01feee00, 0x01feee00, 0x00637800, 0x00637800},
1034 {0x0000c2e0, 0x0000f000, 0x0000f000, 0x03838000, 0x03838000},
1035 {0x0000c2e4, 0x01ff0000, 0x01ff0000, 0x03fc0000, 0x03fc0000},
1036 {0x0000c2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
981 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 1037 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
982 {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001}, 1038 {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
983 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1039 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
@@ -1151,14 +1207,14 @@ static const u32 ar9300Common_rx_gain_table_2p2[][2] = {
1151 {0x0000b074, 0x00000000}, 1207 {0x0000b074, 0x00000000},
1152 {0x0000b078, 0x00000000}, 1208 {0x0000b078, 0x00000000},
1153 {0x0000b07c, 0x00000000}, 1209 {0x0000b07c, 0x00000000},
1154 {0x0000b080, 0x32323232}, 1210 {0x0000b080, 0x2a2d2f32},
1155 {0x0000b084, 0x2f2f3232}, 1211 {0x0000b084, 0x21232328},
1156 {0x0000b088, 0x23282a2d}, 1212 {0x0000b088, 0x19191c1e},
1157 {0x0000b08c, 0x1c1e2123}, 1213 {0x0000b08c, 0x12141417},
1158 {0x0000b090, 0x14171919}, 1214 {0x0000b090, 0x07070e0e},
1159 {0x0000b094, 0x0e0e1214}, 1215 {0x0000b094, 0x03030305},
1160 {0x0000b098, 0x03050707}, 1216 {0x0000b098, 0x00000003},
1161 {0x0000b09c, 0x00030303}, 1217 {0x0000b09c, 0x00000000},
1162 {0x0000b0a0, 0x00000000}, 1218 {0x0000b0a0, 0x00000000},
1163 {0x0000b0a4, 0x00000000}, 1219 {0x0000b0a4, 0x00000000},
1164 {0x0000b0a8, 0x00000000}, 1220 {0x0000b0a8, 0x00000000},
@@ -1251,6 +1307,10 @@ static const u32 ar9300Common_rx_gain_table_2p2[][2] = {
1251 1307
1252static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p2[][5] = { 1308static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p2[][5] = {
1253 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 1309 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
1310 {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
1311 {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
1312 {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
1313 {0x0000a2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1254 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, 1314 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1255 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1315 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1256 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002}, 1316 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
@@ -1316,6 +1376,30 @@ static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p2[][5] = {
1316 {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 1376 {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1317 {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 1377 {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1318 {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec}, 1378 {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1379 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1380 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1381 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1382 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1383 {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1384 {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000},
1385 {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501},
1386 {0x0000a61c, 0x02008802, 0x02008802, 0x02008501, 0x02008501},
1387 {0x0000a620, 0x0300cc03, 0x0300cc03, 0x0280ca03, 0x0280ca03},
1388 {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
1389 {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04014c04, 0x04014c04},
1390 {0x0000a62c, 0x03810c03, 0x03810c03, 0x04015005, 0x04015005},
1391 {0x0000a630, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
1392 {0x0000a634, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
1393 {0x0000a638, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
1394 {0x0000a63c, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
1395 {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
1396 {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
1397 {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
1398 {0x0000b2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1399 {0x0000c2dc, 0x0380c7fc, 0x0380c7fc, 0x00637800, 0x00637800},
1400 {0x0000c2e0, 0x0000f800, 0x0000f800, 0x03838000, 0x03838000},
1401 {0x0000c2e4, 0x03ff0000, 0x03ff0000, 0x03fc0000, 0x03fc0000},
1402 {0x0000c2e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1319 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1403 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1320 {0x00016048, 0x66480001, 0x66480001, 0x66480001, 0x66480001}, 1404 {0x00016048, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
1321 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1405 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
@@ -1414,15 +1498,10 @@ static const u32 ar9300_2p2_mac_core[][2] = {
1414 {0x00008144, 0xffffffff}, 1498 {0x00008144, 0xffffffff},
1415 {0x00008168, 0x00000000}, 1499 {0x00008168, 0x00000000},
1416 {0x0000816c, 0x00000000}, 1500 {0x0000816c, 0x00000000},
1417 {0x00008170, 0x18486200},
1418 {0x00008174, 0x33332210},
1419 {0x00008178, 0x00000000},
1420 {0x0000817c, 0x00020000},
1421 {0x000081c0, 0x00000000}, 1501 {0x000081c0, 0x00000000},
1422 {0x000081c4, 0x33332210}, 1502 {0x000081c4, 0x33332210},
1423 {0x000081c8, 0x00000000}, 1503 {0x000081c8, 0x00000000},
1424 {0x000081cc, 0x00000000}, 1504 {0x000081cc, 0x00000000},
1425 {0x000081d4, 0x00000000},
1426 {0x000081ec, 0x00000000}, 1505 {0x000081ec, 0x00000000},
1427 {0x000081f0, 0x00000000}, 1506 {0x000081f0, 0x00000000},
1428 {0x000081f4, 0x00000000}, 1507 {0x000081f4, 0x00000000},
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 057fb69ddf7f..5f03c534af6e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -22,12 +22,14 @@
22#define COMP_CKSUM_LEN 2 22#define COMP_CKSUM_LEN 2
23 23
24#define AR_CH0_TOP (0x00016288) 24#define AR_CH0_TOP (0x00016288)
25#define AR_CH0_TOP_XPABIASLVL (0x3) 25#define AR_CH0_TOP_XPABIASLVL (0x300)
26#define AR_CH0_TOP_XPABIASLVL_S (8) 26#define AR_CH0_TOP_XPABIASLVL_S (8)
27 27
28#define AR_CH0_THERM (0x00016290) 28#define AR_CH0_THERM (0x00016290)
29#define AR_CH0_THERM_SPARE (0x3f) 29#define AR_CH0_THERM_XPABIASLVL_MSB 0x3
30#define AR_CH0_THERM_SPARE_S (0) 30#define AR_CH0_THERM_XPABIASLVL_MSB_S 0
31#define AR_CH0_THERM_XPASHORT2GND 0x4
32#define AR_CH0_THERM_XPASHORT2GND_S 2
31 33
32#define AR_SWITCH_TABLE_COM_ALL (0xffff) 34#define AR_SWITCH_TABLE_COM_ALL (0xffff)
33#define AR_SWITCH_TABLE_COM_ALL_S (0) 35#define AR_SWITCH_TABLE_COM_ALL_S (0)
@@ -55,6 +57,8 @@
55#define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */ 57#define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
56#define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */ 58#define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
57 59
60#define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
61
58static const struct ar9300_eeprom ar9300_default = { 62static const struct ar9300_eeprom ar9300_default = {
59 .eepromVersion = 2, 63 .eepromVersion = 2,
60 .templateVersion = 2, 64 .templateVersion = 2,
@@ -290,20 +294,21 @@ static const struct ar9300_eeprom ar9300_default = {
290 } 294 }
291 }, 295 },
292 .ctlPowerData_2G = { 296 .ctlPowerData_2G = {
293 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 297 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
294 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 298 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
295 { { {60, 1}, {60, 0}, {60, 0}, {60, 1} } }, 299 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
296 300
297 { { {60, 1}, {60, 0}, {0, 0}, {0, 0} } }, 301 { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
298 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 302 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
299 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 303 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
300 304
301 { { {60, 0}, {60, 1}, {60, 1}, {60, 0} } }, 305 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
302 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 306 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
303 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 307 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
304 308
305 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 309 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
306 { { {60, 0}, {60, 1}, {60, 1}, {60, 1} } }, 310 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
311 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
307 }, 312 },
308 .modalHeader5G = { 313 .modalHeader5G = {
309 /* 4 idle,t1,t2,b (4 bits per setting) */ 314 /* 4 idle,t1,t2,b (4 bits per setting) */
@@ -568,56 +573,56 @@ static const struct ar9300_eeprom ar9300_default = {
568 .ctlPowerData_5G = { 573 .ctlPowerData_5G = {
569 { 574 {
570 { 575 {
571 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 576 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
572 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 577 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
573 } 578 }
574 }, 579 },
575 { 580 {
576 { 581 {
577 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 582 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
578 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 583 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
579 } 584 }
580 }, 585 },
581 { 586 {
582 { 587 {
583 {60, 0}, {60, 1}, {60, 0}, {60, 1}, 588 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
584 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 589 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
585 } 590 }
586 }, 591 },
587 { 592 {
588 { 593 {
589 {60, 0}, {60, 1}, {60, 1}, {60, 0}, 594 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
590 {60, 1}, {60, 0}, {60, 0}, {60, 0}, 595 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
591 } 596 }
592 }, 597 },
593 { 598 {
594 { 599 {
595 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 600 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
596 {60, 0}, {60, 0}, {60, 0}, {60, 0}, 601 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
597 } 602 }
598 }, 603 },
599 { 604 {
600 { 605 {
601 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 606 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
602 {60, 1}, {60, 0}, {60, 0}, {60, 0}, 607 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
603 } 608 }
604 }, 609 },
605 { 610 {
606 { 611 {
607 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 612 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
608 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 613 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
609 } 614 }
610 }, 615 },
611 { 616 {
612 { 617 {
613 {60, 1}, {60, 1}, {60, 0}, {60, 1}, 618 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
614 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 619 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
615 } 620 }
616 }, 621 },
617 { 622 {
618 { 623 {
619 {60, 1}, {60, 0}, {60, 1}, {60, 1}, 624 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
620 {60, 1}, {60, 1}, {60, 0}, {60, 1}, 625 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
621 } 626 }
622 }, 627 },
623 } 628 }
@@ -992,9 +997,9 @@ static s32 ar9003_hw_xpa_bias_level_get(struct ath_hw *ah, bool is2ghz)
992static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz) 997static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
993{ 998{
994 int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz); 999 int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz);
995 REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, (bias & 0x3)); 1000 REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
996 REG_RMW_FIELD(ah, AR_CH0_THERM, AR_CH0_THERM_SPARE, 1001 REG_RMW_FIELD(ah, AR_CH0_THERM, AR_CH0_THERM_XPABIASLVL_MSB, bias >> 2);
997 ((bias >> 2) & 0x3)); 1002 REG_RMW_FIELD(ah, AR_CH0_THERM, AR_CH0_THERM_XPASHORT2GND, 1);
998} 1003}
999 1004
1000static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) 1005static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
@@ -1827,9 +1832,9 @@ static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
1827 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G; 1832 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
1828 1833
1829 if (is2GHz) 1834 if (is2GHz)
1830 return ctl_2g[idx].ctlEdges[edge].tPower; 1835 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
1831 else 1836 else
1832 return ctl_5g[idx].ctlEdges[edge].tPower; 1837 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
1833} 1838}
1834 1839
1835static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep, 1840static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
@@ -1847,12 +1852,12 @@ static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
1847 1852
1848 if (is2GHz) { 1853 if (is2GHz) {
1849 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq && 1854 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
1850 ctl_2g[idx].ctlEdges[edge - 1].flag) 1855 CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
1851 return ctl_2g[idx].ctlEdges[edge - 1].tPower; 1856 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
1852 } else { 1857 } else {
1853 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq && 1858 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
1854 ctl_5g[idx].ctlEdges[edge - 1].flag) 1859 CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
1855 return ctl_5g[idx].ctlEdges[edge - 1].tPower; 1860 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
1856 } 1861 }
1857 1862
1858 return AR9300_MAX_RATE_POWER; 1863 return AR9300_MAX_RATE_POWER;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index 3c533bb983c7..655b3033396c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -261,17 +261,12 @@ struct cal_tgt_pow_ht {
261 u8 tPow2x[14]; 261 u8 tPow2x[14];
262} __packed; 262} __packed;
263 263
264struct cal_ctl_edge_pwr {
265 u8 tPower:6,
266 flag:2;
267} __packed;
268
269struct cal_ctl_data_2g { 264struct cal_ctl_data_2g {
270 struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_2G]; 265 u8 ctlEdges[AR9300_NUM_BAND_EDGES_2G];
271} __packed; 266} __packed;
272 267
273struct cal_ctl_data_5g { 268struct cal_ctl_data_5g {
274 struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_5G]; 269 u8 ctlEdges[AR9300_NUM_BAND_EDGES_5G];
275} __packed; 270} __packed;
276 271
277struct ar9300_eeprom { 272struct ar9300_eeprom {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 5b995bee70ae..1a0ab706a18f 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -616,7 +616,8 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
616 rxs->rs_status |= ATH9K_RXERR_DECRYPT; 616 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
617 } else if (rxsp->status11 & AR_MichaelErr) { 617 } else if (rxsp->status11 & AR_MichaelErr) {
618 rxs->rs_status |= ATH9K_RXERR_MIC; 618 rxs->rs_status |= ATH9K_RXERR_MIC;
619 } 619 } else if (rxsp->status11 & AR_KeyMiss)
620 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
620 } 621 }
621 622
622 return 0; 623 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 7c38229ba670..716db414c258 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -347,6 +347,10 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
347 (((Y[6] - Y[3]) * 1 << scale_factor) + 347 (((Y[6] - Y[3]) * 1 << scale_factor) +
348 (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]); 348 (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]);
349 349
350 /* prevent division by zero */
351 if (G_fxp == 0)
352 return false;
353
350 Y_intercept = 354 Y_intercept =
351 (G_fxp * (x_est[0] - x_est[3]) + 355 (G_fxp * (x_est[0] - x_est[3]) +
352 (1 << scale_factor)) / (1 << scale_factor) + Y[3]; 356 (1 << scale_factor)) / (1 << scale_factor) + Y[3];
@@ -356,14 +360,12 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
356 360
357 for (i = 0; i <= 3; i++) { 361 for (i = 0; i <= 3; i++) {
358 y_est[i] = i * 32; 362 y_est[i] = i * 32;
359
360 /* prevent division by zero */
361 if (G_fxp == 0)
362 return false;
363
364 x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp; 363 x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp;
365 } 364 }
366 365
366 if (y_est[max_index] == 0)
367 return false;
368
367 x_est_fxp1_nonlin = 369 x_est_fxp1_nonlin =
368 x_est[max_index] - ((1 << scale_factor) * y_est[max_index] + 370 x_est[max_index] - ((1 << scale_factor) * y_est[max_index] +
369 G_fxp) / G_fxp; 371 G_fxp) / G_fxp;
@@ -457,6 +459,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
457 459
458 Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10); 460 Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10);
459 scale_B = scale_B / (1 << Q_scale_B); 461 scale_B = scale_B / (1 << Q_scale_B);
462 if (scale_B == 0)
463 return false;
460 Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10); 464 Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10);
461 Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10); 465 Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10);
462 beta_raw = beta_raw / (1 << Q_beta); 466 beta_raw = beta_raw / (1 << Q_beta);
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 07f26ee7a723..852745c2b752 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -177,8 +177,8 @@ void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
177 177
178/* returns delimiter padding required given the packet length */ 178/* returns delimiter padding required given the packet length */
179#define ATH_AGGR_GET_NDELIM(_len) \ 179#define ATH_AGGR_GET_NDELIM(_len) \
180 (((((_len) + ATH_AGGR_DELIM_SZ) < ATH_AGGR_MINPLEN) ? \ 180 (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \
181 (ATH_AGGR_MINPLEN - (_len) - ATH_AGGR_DELIM_SZ) : 0) >> 2) 181 DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ))
182 182
183#define BAW_WITHIN(_start, _bawsz, _seqno) \ 183#define BAW_WITHIN(_start, _bawsz, _seqno) \
184 ((((_seqno) - (_start)) & 4095) < (_bawsz)) 184 ((((_seqno) - (_start)) & 4095) < (_bawsz))
@@ -312,7 +312,6 @@ struct ath_rx {
312 u8 rxotherant; 312 u8 rxotherant;
313 u32 *rxlink; 313 u32 *rxlink;
314 unsigned int rxfilter; 314 unsigned int rxfilter;
315 spinlock_t rxflushlock;
316 spinlock_t rxbuflock; 315 spinlock_t rxbuflock;
317 struct list_head rxbuf; 316 struct list_head rxbuf;
318 struct ath_descdma rxdma; 317 struct ath_descdma rxdma;
@@ -346,8 +345,8 @@ void ath_tx_tasklet(struct ath_softc *sc);
346void ath_tx_edma_tasklet(struct ath_softc *sc); 345void ath_tx_edma_tasklet(struct ath_softc *sc);
347void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb); 346void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb);
348bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno); 347bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno);
349void ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, 348int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
350 u16 tid, u16 *ssn); 349 u16 tid, u16 *ssn);
351void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); 350void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
352void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); 351void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
353void ath9k_enable_ps(struct ath_softc *sc); 352void ath9k_enable_ps(struct ath_softc *sc);
@@ -516,7 +515,6 @@ void ath_deinit_leds(struct ath_softc *sc);
516#define SC_OP_RXFLUSH BIT(7) 515#define SC_OP_RXFLUSH BIT(7)
517#define SC_OP_LED_ASSOCIATED BIT(8) 516#define SC_OP_LED_ASSOCIATED BIT(8)
518#define SC_OP_LED_ON BIT(9) 517#define SC_OP_LED_ON BIT(9)
519#define SC_OP_SCANNING BIT(10)
520#define SC_OP_TSF_RESET BIT(11) 518#define SC_OP_TSF_RESET BIT(11)
521#define SC_OP_BT_PRIORITY_DETECTED BIT(12) 519#define SC_OP_BT_PRIORITY_DETECTED BIT(12)
522#define SC_OP_BT_SCAN BIT(13) 520#define SC_OP_BT_SCAN BIT(13)
@@ -558,9 +556,9 @@ struct ath_softc {
558 struct ath_hw *sc_ah; 556 struct ath_hw *sc_ah;
559 void __iomem *mem; 557 void __iomem *mem;
560 int irq; 558 int irq;
561 spinlock_t sc_resetlock;
562 spinlock_t sc_serial_rw; 559 spinlock_t sc_serial_rw;
563 spinlock_t sc_pm_lock; 560 spinlock_t sc_pm_lock;
561 spinlock_t sc_pcu_lock;
564 struct mutex mutex; 562 struct mutex mutex;
565 struct work_struct paprd_work; 563 struct work_struct paprd_work;
566 struct work_struct hw_check_work; 564 struct work_struct hw_check_work;
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 4d4b22d52dfd..20cf2d4e58b9 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -366,7 +366,7 @@ void ath_beacon_tasklet(unsigned long data)
366 ath_print(common, ATH_DBG_BEACON, 366 ath_print(common, ATH_DBG_BEACON,
367 "beacon is officially stuck\n"); 367 "beacon is officially stuck\n");
368 sc->sc_flags |= SC_OP_TSF_RESET; 368 sc->sc_flags |= SC_OP_TSF_RESET;
369 ath_reset(sc, false); 369 ath_reset(sc, true);
370 } 370 }
371 371
372 return; 372 return;
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index c86f7d3593ab..108b43369f7c 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -366,9 +366,13 @@ int ath9k_cmn_key_config(struct ath_common *common,
366 set_bit(idx, common->keymap); 366 set_bit(idx, common->keymap);
367 if (key->alg == ALG_TKIP) { 367 if (key->alg == ALG_TKIP) {
368 set_bit(idx + 64, common->keymap); 368 set_bit(idx + 64, common->keymap);
369 set_bit(idx, common->tkip_keymap);
370 set_bit(idx + 64, common->tkip_keymap);
369 if (common->splitmic) { 371 if (common->splitmic) {
370 set_bit(idx + 32, common->keymap); 372 set_bit(idx + 32, common->keymap);
371 set_bit(idx + 64 + 32, common->keymap); 373 set_bit(idx + 64 + 32, common->keymap);
374 set_bit(idx + 32, common->tkip_keymap);
375 set_bit(idx + 64 + 32, common->tkip_keymap);
372 } 376 }
373 } 377 }
374 378
@@ -393,10 +397,17 @@ void ath9k_cmn_key_delete(struct ath_common *common,
393 return; 397 return;
394 398
395 clear_bit(key->hw_key_idx + 64, common->keymap); 399 clear_bit(key->hw_key_idx + 64, common->keymap);
400
401 clear_bit(key->hw_key_idx, common->tkip_keymap);
402 clear_bit(key->hw_key_idx + 64, common->tkip_keymap);
403
396 if (common->splitmic) { 404 if (common->splitmic) {
397 ath9k_hw_keyreset(ah, key->hw_key_idx + 32); 405 ath9k_hw_keyreset(ah, key->hw_key_idx + 32);
398 clear_bit(key->hw_key_idx + 32, common->keymap); 406 clear_bit(key->hw_key_idx + 32, common->keymap);
399 clear_bit(key->hw_key_idx + 64 + 32, common->keymap); 407 clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
408
409 clear_bit(key->hw_key_idx + 32, common->tkip_keymap);
410 clear_bit(key->hw_key_idx + 64 + 32, common->tkip_keymap);
400 } 411 }
401} 412}
402EXPORT_SYMBOL(ath9k_cmn_key_delete); 413EXPORT_SYMBOL(ath9k_cmn_key_delete);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index 1266333f586d..2bbf94d0191e 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -240,16 +240,16 @@ u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
240 for (i = 0; (i < num_band_edges) && 240 for (i = 0; (i < num_band_edges) &&
241 (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) { 241 (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
242 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) { 242 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
243 twiceMaxEdgePower = pRdEdgesPower[i].tPower; 243 twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i].ctl);
244 break; 244 break;
245 } else if ((i > 0) && 245 } else if ((i > 0) &&
246 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, 246 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
247 is2GHz))) { 247 is2GHz))) {
248 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel, 248 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
249 is2GHz) < freq && 249 is2GHz) < freq &&
250 pRdEdgesPower[i - 1].flag) { 250 CTL_EDGE_FLAGS(pRdEdgesPower[i - 1].ctl)) {
251 twiceMaxEdgePower = 251 twiceMaxEdgePower =
252 pRdEdgesPower[i - 1].tPower; 252 CTL_EDGE_TPOWER(pRdEdgesPower[i - 1].ctl);
253 } 253 }
254 break; 254 break;
255 } 255 }
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index 0b09db0f8e7d..17068f9c026e 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -233,6 +233,9 @@
233 233
234#define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1) 234#define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
235 235
236#define CTL_EDGE_TPOWER(_ctl) ((_ctl) & 0x3f)
237#define CTL_EDGE_FLAGS(_ctl) (((_ctl) >> 6) & 0x03)
238
236enum eeprom_param { 239enum eeprom_param {
237 EEP_NFTHRESH_5, 240 EEP_NFTHRESH_5,
238 EEP_NFTHRESH_2, 241 EEP_NFTHRESH_2,
@@ -533,18 +536,10 @@ struct cal_target_power_ht {
533 u8 tPow2x[8]; 536 u8 tPow2x[8];
534} __packed; 537} __packed;
535 538
536
537#ifdef __BIG_ENDIAN_BITFIELD
538struct cal_ctl_edges {
539 u8 bChannel;
540 u8 flag:2, tPower:6;
541} __packed;
542#else
543struct cal_ctl_edges { 539struct cal_ctl_edges {
544 u8 bChannel; 540 u8 bChannel;
545 u8 tPower:6, flag:2; 541 u8 ctl;
546} __packed; 542} __packed;
547#endif
548 543
549struct cal_data_op_loop_ar9287 { 544struct cal_data_op_loop_ar9287 {
550 u8 pwrPdg[2][5]; 545 u8 pwrPdg[2][5];
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index dff2da777312..7cb356e8a531 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -37,7 +37,7 @@ static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
37 int addr, eep_start_loc; 37 int addr, eep_start_loc;
38 eep_data = (u16 *)eep; 38 eep_data = (u16 *)eep;
39 39
40 if (ah->hw_version.devid == 0x7015) 40 if (AR9287_HTC_DEVID(ah))
41 eep_start_loc = AR9287_HTC_EEP_START_LOC; 41 eep_start_loc = AR9287_HTC_EEP_START_LOC;
42 else 42 else
43 eep_start_loc = AR9287_EEP_START_LOC; 43 eep_start_loc = AR9287_EEP_START_LOC;
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index afa2b73ddbdd..a48eb570a47c 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -1062,15 +1062,19 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
1062 case 1: 1062 case 1:
1063 break; 1063 break;
1064 case 2: 1064 case 2:
1065 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 1065 if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
1066 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
1067 else
1068 scaledPower = 0;
1066 break; 1069 break;
1067 case 3: 1070 case 3:
1068 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 1071 if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
1072 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
1073 else
1074 scaledPower = 0;
1069 break; 1075 break;
1070 } 1076 }
1071 1077
1072 scaledPower = max((u16)0, scaledPower);
1073
1074 if (IS_CHAN_2GHZ(chan)) { 1078 if (IS_CHAN_2GHZ(chan)) {
1075 numCtlModes = ARRAY_SIZE(ctlModesFor11g) - 1079 numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
1076 SUB_NUM_CTL_MODES_AT_2G_40; 1080 SUB_NUM_CTL_MODES_AT_2G_40;
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 17e7a9a367e7..0e9bbb13ba66 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -35,8 +35,14 @@ static struct usb_device_id ath9k_hif_usb_ids[] = {
35 { USB_DEVICE(0x07D1, 0x3A10) }, /* Dlink Wireless 150 */ 35 { USB_DEVICE(0x07D1, 0x3A10) }, /* Dlink Wireless 150 */
36 { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */ 36 { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */
37 { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */ 37 { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */
38 { USB_DEVICE(0x13D3, 0x3346) }, /* IMC Networks */
39 { USB_DEVICE(0x13D3, 0x3348) }, /* Azurewave */
40 { USB_DEVICE(0x13D3, 0x3349) }, /* Azurewave */
41 { USB_DEVICE(0x13D3, 0x3350) }, /* Azurewave */
38 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */ 42 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */
39 { USB_DEVICE(0x083A, 0xA704) }, /* SMC Networks */ 43 { USB_DEVICE(0x083A, 0xA704) }, /* SMC Networks */
44 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */
45 { USB_DEVICE(0x1668, 0x1200) }, /* Verizon */
40 { }, 46 { },
41}; 47};
42 48
@@ -138,16 +144,36 @@ static void hif_usb_tx_cb(struct urb *urb)
138 case -ENODEV: 144 case -ENODEV:
139 case -ESHUTDOWN: 145 case -ESHUTDOWN:
140 /* 146 /*
141 * The URB has been killed, free the SKBs 147 * The URB has been killed, free the SKBs.
142 * and return.
143 */ 148 */
144 ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue); 149 ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue);
145 return; 150
151 /*
152 * If the URBs are being flushed, no need to add this
153 * URB to the free list.
154 */
155 spin_lock(&hif_dev->tx.tx_lock);
156 if (hif_dev->tx.flags & HIF_USB_TX_FLUSH) {
157 spin_unlock(&hif_dev->tx.tx_lock);
158 return;
159 }
160 spin_unlock(&hif_dev->tx.tx_lock);
161
162 /*
163 * In the stop() case, this URB has to be added to
164 * the free list.
165 */
166 goto add_free;
146 default: 167 default:
147 break; 168 break;
148 } 169 }
149 170
150 /* Check if TX has been stopped */ 171 /*
172 * Check if TX has been stopped, this is needed because
173 * this CB could have been invoked just after the TX lock
174 * was released in hif_stop() and kill_urb() hasn't been
175 * called yet.
176 */
151 spin_lock(&hif_dev->tx.tx_lock); 177 spin_lock(&hif_dev->tx.tx_lock);
152 if (hif_dev->tx.flags & HIF_USB_TX_STOP) { 178 if (hif_dev->tx.flags & HIF_USB_TX_STOP) {
153 spin_unlock(&hif_dev->tx.tx_lock); 179 spin_unlock(&hif_dev->tx.tx_lock);
@@ -299,6 +325,7 @@ static void hif_usb_start(void *hif_handle, u8 pipe_id)
299static void hif_usb_stop(void *hif_handle, u8 pipe_id) 325static void hif_usb_stop(void *hif_handle, u8 pipe_id)
300{ 326{
301 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; 327 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
328 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
302 unsigned long flags; 329 unsigned long flags;
303 330
304 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); 331 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
@@ -306,6 +333,12 @@ static void hif_usb_stop(void *hif_handle, u8 pipe_id)
306 hif_dev->tx.tx_skb_cnt = 0; 333 hif_dev->tx.tx_skb_cnt = 0;
307 hif_dev->tx.flags |= HIF_USB_TX_STOP; 334 hif_dev->tx.flags |= HIF_USB_TX_STOP;
308 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); 335 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
336
337 /* The pending URBs have to be canceled. */
338 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
339 &hif_dev->tx.tx_pending, list) {
340 usb_kill_urb(tx_buf->urb);
341 }
309} 342}
310 343
311static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb, 344static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb,
@@ -571,6 +604,7 @@ free:
571static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev) 604static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
572{ 605{
573 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL; 606 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
607 unsigned long flags;
574 608
575 list_for_each_entry_safe(tx_buf, tx_buf_tmp, 609 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
576 &hif_dev->tx.tx_buf, list) { 610 &hif_dev->tx.tx_buf, list) {
@@ -581,6 +615,10 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
581 kfree(tx_buf); 615 kfree(tx_buf);
582 } 616 }
583 617
618 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
619 hif_dev->tx.flags |= HIF_USB_TX_FLUSH;
620 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
621
584 list_for_each_entry_safe(tx_buf, tx_buf_tmp, 622 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
585 &hif_dev->tx.tx_pending, list) { 623 &hif_dev->tx.tx_pending, list) {
586 usb_kill_urb(tx_buf->urb); 624 usb_kill_urb(tx_buf->urb);
@@ -799,10 +837,18 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
799 } 837 }
800 kfree(buf); 838 kfree(buf);
801 839
802 if ((hif_dev->device_id == 0x7010) || (hif_dev->device_id == 0x7015)) 840 switch (hif_dev->device_id) {
841 case 0x7010:
842 case 0x7015:
843 case 0x9018:
844 case 0xA704:
845 case 0x1200:
803 firm_offset = AR7010_FIRMWARE_TEXT; 846 firm_offset = AR7010_FIRMWARE_TEXT;
804 else 847 break;
848 default:
805 firm_offset = AR9271_FIRMWARE_TEXT; 849 firm_offset = AR9271_FIRMWARE_TEXT;
850 break;
851 }
806 852
807 /* 853 /*
808 * Issue FW download complete command to firmware. 854 * Issue FW download complete command to firmware.
@@ -903,6 +949,8 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
903 case 0x7010: 949 case 0x7010:
904 case 0x7015: 950 case 0x7015:
905 case 0x9018: 951 case 0x9018:
952 case 0xA704:
953 case 0x1200:
906 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202) 954 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202)
907 hif_dev->fw_name = FIRMWARE_AR7010_1_1; 955 hif_dev->fw_name = FIRMWARE_AR7010_1_1;
908 else 956 else
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 2daf97b11c08..30d09389d437 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -62,6 +62,7 @@ struct tx_buf {
62}; 62};
63 63
64#define HIF_USB_TX_STOP BIT(0) 64#define HIF_USB_TX_STOP BIT(0)
65#define HIF_USB_TX_FLUSH BIT(1)
65 66
66struct hif_usb_tx { 67struct hif_usb_tx {
67 u8 flags; 68 u8 flags;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 2d4279191d7a..e5a0122fc341 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -247,6 +247,8 @@ static int ath9k_init_htc_services(struct ath9k_htc_priv *priv, u16 devid)
247 case 0x7010: 247 case 0x7010:
248 case 0x7015: 248 case 0x7015:
249 case 0x9018: 249 case 0x9018:
250 case 0xA704:
251 case 0x1200:
250 priv->htc->credits = 45; 252 priv->htc->credits = 45;
251 break; 253 break;
252 default: 254 default:
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 2a6e45a293a9..f06eeab2a572 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -121,7 +121,7 @@ int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
121 tx_hdr.data_type = ATH9K_HTC_NORMAL; 121 tx_hdr.data_type = ATH9K_HTC_NORMAL;
122 } 122 }
123 123
124 if (ieee80211_is_data(fc)) { 124 if (ieee80211_is_data_qos(fc)) {
125 qc = ieee80211_get_qos_ctl(hdr); 125 qc = ieee80211_get_qos_ctl(hdr);
126 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 126 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
127 } 127 }
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 3384ca164562..5250c8dc83e1 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -387,6 +387,9 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
387 else 387 else
388 ah->config.ht_enable = 0; 388 ah->config.ht_enable = 0;
389 389
390 /* PAPRD needs some more work to be enabled */
391 ah->config.paprd_disable = 1;
392
390 ah->config.rx_intr_mitigation = true; 393 ah->config.rx_intr_mitigation = true;
391 ah->config.pcieSerDesWrite = true; 394 ah->config.pcieSerDesWrite = true;
392 395
@@ -486,6 +489,7 @@ static int ath9k_hw_post_init(struct ath_hw *ah)
486 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, 489 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
487 "Failed allocating banks for " 490 "Failed allocating banks for "
488 "external radio\n"); 491 "external radio\n");
492 ath9k_hw_rf_free_ext_banks(ah);
489 return ecode; 493 return ecode;
490 } 494 }
491 495
@@ -2263,7 +2267,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2263 pCap->rx_status_len = sizeof(struct ar9003_rxs); 2267 pCap->rx_status_len = sizeof(struct ar9003_rxs);
2264 pCap->tx_desc_len = sizeof(struct ar9003_txc); 2268 pCap->tx_desc_len = sizeof(struct ar9003_txc);
2265 pCap->txs_len = sizeof(struct ar9003_txs); 2269 pCap->txs_len = sizeof(struct ar9003_txs);
2266 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) 2270 if (!ah->config.paprd_disable &&
2271 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
2267 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD; 2272 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
2268 } else { 2273 } else {
2269 pCap->tx_desc_len = sizeof(struct ath_desc); 2274 pCap->tx_desc_len = sizeof(struct ath_desc);
@@ -2350,7 +2355,8 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
2350 val = REG_READ(ah, AR7010_GPIO_IN); 2355 val = REG_READ(ah, AR7010_GPIO_IN);
2351 return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0; 2356 return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0;
2352 } else if (AR_SREV_9300_20_OR_LATER(ah)) 2357 } else if (AR_SREV_9300_20_OR_LATER(ah))
2353 return MS_REG_READ(AR9300, gpio) != 0; 2358 return (MS(REG_READ(ah, AR_GPIO_IN), AR9300_GPIO_IN_VAL) &
2359 AR_GPIO_BIT(gpio)) != 0;
2354 else if (AR_SREV_9271(ah)) 2360 else if (AR_SREV_9271(ah))
2355 return MS_REG_READ(AR9271, gpio) != 0; 2361 return MS_REG_READ(AR9271, gpio) != 0;
2356 else if (AR_SREV_9287_10_OR_LATER(ah)) 2362 else if (AR_SREV_9287_10_OR_LATER(ah))
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 399f7c1283cd..e58ff11cb85c 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -240,6 +240,7 @@ struct ath9k_ops_config {
240 u32 pcie_waen; 240 u32 pcie_waen;
241 u8 analog_shiftreg; 241 u8 analog_shiftreg;
242 u8 ht_enable; 242 u8 ht_enable;
243 u8 paprd_disable;
243 u32 ofdm_trig_low; 244 u32 ofdm_trig_low;
244 u32 ofdm_trig_high; 245 u32 ofdm_trig_high;
245 u32 cck_trig_high; 246 u32 cck_trig_high;
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 243c1775f343..2e4724f1c662 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -56,7 +56,7 @@ MODULE_PARM_DESC(blink, "Enable LED blink on activity");
56 * on 5 MHz steps, we support the channels which we know 56 * on 5 MHz steps, we support the channels which we know
57 * we have calibration data for all cards though to make 57 * we have calibration data for all cards though to make
58 * this static */ 58 * this static */
59static struct ieee80211_channel ath9k_2ghz_chantable[] = { 59static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
60 CHAN2G(2412, 0), /* Channel 1 */ 60 CHAN2G(2412, 0), /* Channel 1 */
61 CHAN2G(2417, 1), /* Channel 2 */ 61 CHAN2G(2417, 1), /* Channel 2 */
62 CHAN2G(2422, 2), /* Channel 3 */ 62 CHAN2G(2422, 2), /* Channel 3 */
@@ -77,7 +77,7 @@ static struct ieee80211_channel ath9k_2ghz_chantable[] = {
77 * on 5 MHz steps, we support the channels which we know 77 * on 5 MHz steps, we support the channels which we know
78 * we have calibration data for all cards though to make 78 * we have calibration data for all cards though to make
79 * this static */ 79 * this static */
80static struct ieee80211_channel ath9k_5ghz_chantable[] = { 80static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
81 /* _We_ call this UNII 1 */ 81 /* _We_ call this UNII 1 */
82 CHAN5G(5180, 14), /* Channel 36 */ 82 CHAN5G(5180, 14), /* Channel 36 */
83 CHAN5G(5200, 15), /* Channel 40 */ 83 CHAN5G(5200, 15), /* Channel 40 */
@@ -477,10 +477,17 @@ err:
477 return -EIO; 477 return -EIO;
478} 478}
479 479
480static void ath9k_init_channels_rates(struct ath_softc *sc) 480static int ath9k_init_channels_rates(struct ath_softc *sc)
481{ 481{
482 void *channels;
483
482 if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) { 484 if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
483 sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable; 485 channels = kmemdup(ath9k_2ghz_chantable,
486 sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
487 if (!channels)
488 return -ENOMEM;
489
490 sc->sbands[IEEE80211_BAND_2GHZ].channels = channels;
484 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; 491 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
485 sc->sbands[IEEE80211_BAND_2GHZ].n_channels = 492 sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
486 ARRAY_SIZE(ath9k_2ghz_chantable); 493 ARRAY_SIZE(ath9k_2ghz_chantable);
@@ -490,7 +497,15 @@ static void ath9k_init_channels_rates(struct ath_softc *sc)
490 } 497 }
491 498
492 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) { 499 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
493 sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable; 500 channels = kmemdup(ath9k_5ghz_chantable,
501 sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
502 if (!channels) {
503 if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
504 kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
505 return -ENOMEM;
506 }
507
508 sc->sbands[IEEE80211_BAND_5GHZ].channels = channels;
494 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; 509 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
495 sc->sbands[IEEE80211_BAND_5GHZ].n_channels = 510 sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
496 ARRAY_SIZE(ath9k_5ghz_chantable); 511 ARRAY_SIZE(ath9k_5ghz_chantable);
@@ -499,6 +514,7 @@ static void ath9k_init_channels_rates(struct ath_softc *sc)
499 sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates = 514 sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
500 ARRAY_SIZE(ath9k_legacy_rates) - 4; 515 ARRAY_SIZE(ath9k_legacy_rates) - 4;
501 } 516 }
517 return 0;
502} 518}
503 519
504static void ath9k_init_misc(struct ath_softc *sc) 520static void ath9k_init_misc(struct ath_softc *sc)
@@ -558,7 +574,6 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
558 common->debug_mask = ath9k_debug; 574 common->debug_mask = ath9k_debug;
559 575
560 spin_lock_init(&sc->wiphy_lock); 576 spin_lock_init(&sc->wiphy_lock);
561 spin_lock_init(&sc->sc_resetlock);
562 spin_lock_init(&sc->sc_serial_rw); 577 spin_lock_init(&sc->sc_serial_rw);
563 spin_lock_init(&sc->sc_pm_lock); 578 spin_lock_init(&sc->sc_pm_lock);
564 mutex_init(&sc->mutex); 579 mutex_init(&sc->mutex);
@@ -593,8 +608,11 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
593 if (ret) 608 if (ret)
594 goto err_btcoex; 609 goto err_btcoex;
595 610
611 ret = ath9k_init_channels_rates(sc);
612 if (ret)
613 goto err_btcoex;
614
596 ath9k_init_crypto(sc); 615 ath9k_init_crypto(sc);
597 ath9k_init_channels_rates(sc);
598 ath9k_init_misc(sc); 616 ath9k_init_misc(sc);
599 617
600 return 0; 618 return 0;
@@ -641,7 +659,8 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
641 BIT(NL80211_IFTYPE_ADHOC) | 659 BIT(NL80211_IFTYPE_ADHOC) |
642 BIT(NL80211_IFTYPE_MESH_POINT); 660 BIT(NL80211_IFTYPE_MESH_POINT);
643 661
644 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 662 if (AR_SREV_5416(sc->sc_ah))
663 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
645 664
646 hw->queues = 4; 665 hw->queues = 4;
647 hw->max_rates = 4; 666 hw->max_rates = 4;
@@ -751,6 +770,12 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
751{ 770{
752 int i = 0; 771 int i = 0;
753 772
773 if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
774 kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
775
776 if (sc->sbands[IEEE80211_BAND_5GHZ].channels)
777 kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
778
754 if ((sc->btcoex.no_stomp_timer) && 779 if ((sc->btcoex.no_stomp_timer) &&
755 sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 780 sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
756 ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); 781 ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index e955bb9d98cb..79302b1e0910 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -713,6 +713,8 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
713 rs->rs_status |= ATH9K_RXERR_DECRYPT; 713 rs->rs_status |= ATH9K_RXERR_DECRYPT;
714 else if (ads.ds_rxstatus8 & AR_MichaelErr) 714 else if (ads.ds_rxstatus8 & AR_MichaelErr)
715 rs->rs_status |= ATH9K_RXERR_MIC; 715 rs->rs_status |= ATH9K_RXERR_MIC;
716 else if (ads.ds_rxstatus8 & AR_KeyMiss)
717 rs->rs_status |= ATH9K_RXERR_DECRYPT;
716 } 718 }
717 719
718 return 0; 720 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 3caa32316e7b..9790d3a86535 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -213,6 +213,9 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
213 */ 213 */
214 ath9k_hw_set_interrupts(ah, 0); 214 ath9k_hw_set_interrupts(ah, 0);
215 ath_drain_all_txq(sc, false); 215 ath_drain_all_txq(sc, false);
216
217 spin_lock_bh(&sc->sc_pcu_lock);
218
216 stopped = ath_stoprecv(sc); 219 stopped = ath_stoprecv(sc);
217 220
218 /* XXX: do not flush receive queue here. We don't want 221 /* XXX: do not flush receive queue here. We don't want
@@ -230,34 +233,35 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
230 sc->sc_ah->curchan->channel, 233 sc->sc_ah->curchan->channel,
231 channel->center_freq, conf_is_ht40(conf)); 234 channel->center_freq, conf_is_ht40(conf));
232 235
233 spin_lock_bh(&sc->sc_resetlock);
234
235 r = ath9k_hw_reset(ah, hchan, caldata, fastcc); 236 r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
236 if (r) { 237 if (r) {
237 ath_print(common, ATH_DBG_FATAL, 238 ath_print(common, ATH_DBG_FATAL,
238 "Unable to reset channel (%u MHz), " 239 "Unable to reset channel (%u MHz), "
239 "reset status %d\n", 240 "reset status %d\n",
240 channel->center_freq, r); 241 channel->center_freq, r);
241 spin_unlock_bh(&sc->sc_resetlock); 242 spin_unlock_bh(&sc->sc_pcu_lock);
242 goto ps_restore; 243 goto ps_restore;
243 } 244 }
244 spin_unlock_bh(&sc->sc_resetlock);
245 245
246 if (ath_startrecv(sc) != 0) { 246 if (ath_startrecv(sc) != 0) {
247 ath_print(common, ATH_DBG_FATAL, 247 ath_print(common, ATH_DBG_FATAL,
248 "Unable to restart recv logic\n"); 248 "Unable to restart recv logic\n");
249 r = -EIO; 249 r = -EIO;
250 spin_unlock_bh(&sc->sc_pcu_lock);
250 goto ps_restore; 251 goto ps_restore;
251 } 252 }
252 253
254 spin_unlock_bh(&sc->sc_pcu_lock);
255
253 ath_cache_conf_rate(sc, &hw->conf); 256 ath_cache_conf_rate(sc, &hw->conf);
254 ath_update_txpow(sc); 257 ath_update_txpow(sc);
255 ath9k_hw_set_interrupts(ah, ah->imask); 258 ath9k_hw_set_interrupts(ah, ah->imask);
256 259
257 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL | SC_OP_SCANNING))) { 260 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) {
258 ath_start_ani(common); 261 if (sc->sc_flags & SC_OP_BEACONS)
262 ath_beacon_config(sc, NULL);
259 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); 263 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
260 ath_beacon_config(sc, NULL); 264 ath_start_ani(common);
261 } 265 }
262 266
263 ps_restore: 267 ps_restore:
@@ -269,6 +273,7 @@ static void ath_paprd_activate(struct ath_softc *sc)
269{ 273{
270 struct ath_hw *ah = sc->sc_ah; 274 struct ath_hw *ah = sc->sc_ah;
271 struct ath9k_hw_cal_data *caldata = ah->caldata; 275 struct ath9k_hw_cal_data *caldata = ah->caldata;
276 struct ath_common *common = ath9k_hw_common(ah);
272 int chain; 277 int chain;
273 278
274 if (!caldata || !caldata->paprd_done) 279 if (!caldata || !caldata->paprd_done)
@@ -277,7 +282,7 @@ static void ath_paprd_activate(struct ath_softc *sc)
277 ath9k_ps_wakeup(sc); 282 ath9k_ps_wakeup(sc);
278 ar9003_paprd_enable(ah, false); 283 ar9003_paprd_enable(ah, false);
279 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) { 284 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
280 if (!(ah->caps.tx_chainmask & BIT(chain))) 285 if (!(common->tx_chainmask & BIT(chain)))
281 continue; 286 continue;
282 287
283 ar9003_paprd_populate_single_table(ah, caldata, chain); 288 ar9003_paprd_populate_single_table(ah, caldata, chain);
@@ -299,6 +304,7 @@ void ath_paprd_calibrate(struct work_struct *work)
299 struct ieee80211_supported_band *sband = &sc->sbands[band]; 304 struct ieee80211_supported_band *sband = &sc->sbands[band];
300 struct ath_tx_control txctl; 305 struct ath_tx_control txctl;
301 struct ath9k_hw_cal_data *caldata = ah->caldata; 306 struct ath9k_hw_cal_data *caldata = ah->caldata;
307 struct ath_common *common = ath9k_hw_common(ah);
302 int qnum, ftype; 308 int qnum, ftype;
303 int chain_ok = 0; 309 int chain_ok = 0;
304 int chain; 310 int chain;
@@ -332,7 +338,7 @@ void ath_paprd_calibrate(struct work_struct *work)
332 ath9k_ps_wakeup(sc); 338 ath9k_ps_wakeup(sc);
333 ar9003_paprd_init_table(ah); 339 ar9003_paprd_init_table(ah);
334 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) { 340 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
335 if (!(ah->caps.tx_chainmask & BIT(chain))) 341 if (!(common->tx_chainmask & BIT(chain)))
336 continue; 342 continue;
337 343
338 chain_ok = 0; 344 chain_ok = 0;
@@ -550,7 +556,7 @@ void ath_hw_check(struct work_struct *work)
550 556
551 msleep(1); 557 msleep(1);
552 } 558 }
553 ath_reset(sc, false); 559 ath_reset(sc, true);
554 560
555out: 561out:
556 ath9k_ps_restore(sc); 562 ath9k_ps_restore(sc);
@@ -568,7 +574,7 @@ void ath9k_tasklet(unsigned long data)
568 ath9k_ps_wakeup(sc); 574 ath9k_ps_wakeup(sc);
569 575
570 if (status & ATH9K_INT_FATAL) { 576 if (status & ATH9K_INT_FATAL) {
571 ath_reset(sc, false); 577 ath_reset(sc, true);
572 ath9k_ps_restore(sc); 578 ath9k_ps_restore(sc);
573 return; 579 return;
574 } 580 }
@@ -583,7 +589,7 @@ void ath9k_tasklet(unsigned long data)
583 rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN); 589 rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
584 590
585 if (status & rxmask) { 591 if (status & rxmask) {
586 spin_lock_bh(&sc->rx.rxflushlock); 592 spin_lock_bh(&sc->sc_pcu_lock);
587 593
588 /* Check for high priority Rx first */ 594 /* Check for high priority Rx first */
589 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) && 595 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
@@ -591,7 +597,7 @@ void ath9k_tasklet(unsigned long data)
591 ath_rx_tasklet(sc, 0, true); 597 ath_rx_tasklet(sc, 0, true);
592 598
593 ath_rx_tasklet(sc, 0, false); 599 ath_rx_tasklet(sc, 0, false);
594 spin_unlock_bh(&sc->rx.rxflushlock); 600 spin_unlock_bh(&sc->sc_pcu_lock);
595 } 601 }
596 602
597 if (status & ATH9K_INT_TX) { 603 if (status & ATH9K_INT_TX) {
@@ -838,7 +844,7 @@ void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
838 if (!ah->curchan) 844 if (!ah->curchan)
839 ah->curchan = ath_get_curchannel(sc, sc->hw); 845 ah->curchan = ath_get_curchannel(sc, sc->hw);
840 846
841 spin_lock_bh(&sc->sc_resetlock); 847 spin_lock_bh(&sc->sc_pcu_lock);
842 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); 848 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
843 if (r) { 849 if (r) {
844 ath_print(common, ATH_DBG_FATAL, 850 ath_print(common, ATH_DBG_FATAL,
@@ -846,14 +852,15 @@ void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
846 "reset status %d\n", 852 "reset status %d\n",
847 channel->center_freq, r); 853 channel->center_freq, r);
848 } 854 }
849 spin_unlock_bh(&sc->sc_resetlock);
850 855
851 ath_update_txpow(sc); 856 ath_update_txpow(sc);
852 if (ath_startrecv(sc) != 0) { 857 if (ath_startrecv(sc) != 0) {
853 ath_print(common, ATH_DBG_FATAL, 858 ath_print(common, ATH_DBG_FATAL,
854 "Unable to restart recv logic\n"); 859 "Unable to restart recv logic\n");
860 spin_unlock_bh(&sc->sc_pcu_lock);
855 return; 861 return;
856 } 862 }
863 spin_unlock_bh(&sc->sc_pcu_lock);
857 864
858 if (sc->sc_flags & SC_OP_BEACONS) 865 if (sc->sc_flags & SC_OP_BEACONS)
859 ath_beacon_config(sc, NULL); /* restart beacons */ 866 ath_beacon_config(sc, NULL); /* restart beacons */
@@ -892,13 +899,15 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
892 ath9k_hw_set_interrupts(ah, 0); 899 ath9k_hw_set_interrupts(ah, 0);
893 900
894 ath_drain_all_txq(sc, false); /* clear pending tx frames */ 901 ath_drain_all_txq(sc, false); /* clear pending tx frames */
902
903 spin_lock_bh(&sc->sc_pcu_lock);
904
895 ath_stoprecv(sc); /* turn off frame recv */ 905 ath_stoprecv(sc); /* turn off frame recv */
896 ath_flushrecv(sc); /* flush recv queue */ 906 ath_flushrecv(sc); /* flush recv queue */
897 907
898 if (!ah->curchan) 908 if (!ah->curchan)
899 ah->curchan = ath_get_curchannel(sc, hw); 909 ah->curchan = ath_get_curchannel(sc, hw);
900 910
901 spin_lock_bh(&sc->sc_resetlock);
902 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); 911 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
903 if (r) { 912 if (r) {
904 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, 913 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
@@ -906,9 +915,11 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
906 "reset status %d\n", 915 "reset status %d\n",
907 channel->center_freq, r); 916 channel->center_freq, r);
908 } 917 }
909 spin_unlock_bh(&sc->sc_resetlock);
910 918
911 ath9k_hw_phy_disable(ah); 919 ath9k_hw_phy_disable(ah);
920
921 spin_unlock_bh(&sc->sc_pcu_lock);
922
912 ath9k_hw_configpcipowersave(ah, 1, 1); 923 ath9k_hw_configpcipowersave(ah, 1, 1);
913 ath9k_ps_restore(sc); 924 ath9k_ps_restore(sc);
914 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP); 925 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
@@ -928,20 +939,23 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
928 939
929 ath9k_hw_set_interrupts(ah, 0); 940 ath9k_hw_set_interrupts(ah, 0);
930 ath_drain_all_txq(sc, retry_tx); 941 ath_drain_all_txq(sc, retry_tx);
942
943 spin_lock_bh(&sc->sc_pcu_lock);
944
931 ath_stoprecv(sc); 945 ath_stoprecv(sc);
932 ath_flushrecv(sc); 946 ath_flushrecv(sc);
933 947
934 spin_lock_bh(&sc->sc_resetlock);
935 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false); 948 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
936 if (r) 949 if (r)
937 ath_print(common, ATH_DBG_FATAL, 950 ath_print(common, ATH_DBG_FATAL,
938 "Unable to reset hardware; reset status %d\n", r); 951 "Unable to reset hardware; reset status %d\n", r);
939 spin_unlock_bh(&sc->sc_resetlock);
940 952
941 if (ath_startrecv(sc) != 0) 953 if (ath_startrecv(sc) != 0)
942 ath_print(common, ATH_DBG_FATAL, 954 ath_print(common, ATH_DBG_FATAL,
943 "Unable to start recv logic\n"); 955 "Unable to start recv logic\n");
944 956
957 spin_unlock_bh(&sc->sc_pcu_lock);
958
945 /* 959 /*
946 * We may be doing a reset in response to a request 960 * We may be doing a reset in response to a request
947 * that changes the channel so update any state that 961 * that changes the channel so update any state that
@@ -951,7 +965,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
951 965
952 ath_update_txpow(sc); 966 ath_update_txpow(sc);
953 967
954 if (sc->sc_flags & SC_OP_BEACONS) 968 if ((sc->sc_flags & SC_OP_BEACONS) || !(sc->sc_flags & (SC_OP_OFFCHANNEL)))
955 ath_beacon_config(sc, NULL); /* restart beacons */ 969 ath_beacon_config(sc, NULL); /* restart beacons */
956 970
957 ath9k_hw_set_interrupts(ah, ah->imask); 971 ath9k_hw_set_interrupts(ah, ah->imask);
@@ -1106,17 +1120,16 @@ static int ath9k_start(struct ieee80211_hw *hw)
1106 * be followed by initialization of the appropriate bits 1120 * be followed by initialization of the appropriate bits
1107 * and then setup of the interrupt mask. 1121 * and then setup of the interrupt mask.
1108 */ 1122 */
1109 spin_lock_bh(&sc->sc_resetlock); 1123 spin_lock_bh(&sc->sc_pcu_lock);
1110 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false); 1124 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
1111 if (r) { 1125 if (r) {
1112 ath_print(common, ATH_DBG_FATAL, 1126 ath_print(common, ATH_DBG_FATAL,
1113 "Unable to reset hardware; reset status %d " 1127 "Unable to reset hardware; reset status %d "
1114 "(freq %u MHz)\n", r, 1128 "(freq %u MHz)\n", r,
1115 curchan->center_freq); 1129 curchan->center_freq);
1116 spin_unlock_bh(&sc->sc_resetlock); 1130 spin_unlock_bh(&sc->sc_pcu_lock);
1117 goto mutex_unlock; 1131 goto mutex_unlock;
1118 } 1132 }
1119 spin_unlock_bh(&sc->sc_resetlock);
1120 1133
1121 /* 1134 /*
1122 * This is needed only to setup initial state 1135 * This is needed only to setup initial state
@@ -1135,8 +1148,10 @@ static int ath9k_start(struct ieee80211_hw *hw)
1135 ath_print(common, ATH_DBG_FATAL, 1148 ath_print(common, ATH_DBG_FATAL,
1136 "Unable to start recv logic\n"); 1149 "Unable to start recv logic\n");
1137 r = -EIO; 1150 r = -EIO;
1151 spin_unlock_bh(&sc->sc_pcu_lock);
1138 goto mutex_unlock; 1152 goto mutex_unlock;
1139 } 1153 }
1154 spin_unlock_bh(&sc->sc_pcu_lock);
1140 1155
1141 /* Setup our intr mask. */ 1156 /* Setup our intr mask. */
1142 ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL | 1157 ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
@@ -1340,18 +1355,24 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1340 1355
1341 if (!(sc->sc_flags & SC_OP_INVALID)) { 1356 if (!(sc->sc_flags & SC_OP_INVALID)) {
1342 ath_drain_all_txq(sc, false); 1357 ath_drain_all_txq(sc, false);
1358 spin_lock_bh(&sc->sc_pcu_lock);
1343 ath_stoprecv(sc); 1359 ath_stoprecv(sc);
1344 ath9k_hw_phy_disable(ah); 1360 ath9k_hw_phy_disable(ah);
1345 } else 1361 spin_unlock_bh(&sc->sc_pcu_lock);
1362 } else {
1363 spin_lock_bh(&sc->sc_pcu_lock);
1346 sc->rx.rxlink = NULL; 1364 sc->rx.rxlink = NULL;
1365 spin_unlock_bh(&sc->sc_pcu_lock);
1366 }
1347 1367
1348 /* disable HAL and put h/w to sleep */ 1368 /* disable HAL and put h/w to sleep */
1349 ath9k_hw_disable(ah); 1369 ath9k_hw_disable(ah);
1350 ath9k_hw_configpcipowersave(ah, 1, 1); 1370 ath9k_hw_configpcipowersave(ah, 1, 1);
1351 ath9k_ps_restore(sc); 1371 ath9k_ps_restore(sc);
1352 1372
1353 /* Finally, put the chip in FULL SLEEP mode */ 1373 sc->ps_idle = true;
1354 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP); 1374 ath9k_set_wiphy_idle(aphy, true);
1375 ath_radio_disable(sc, hw);
1355 1376
1356 sc->sc_flags |= SC_OP_INVALID; 1377 sc->sc_flags |= SC_OP_INVALID;
1357 1378
@@ -1455,6 +1476,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1455 struct ath_softc *sc = aphy->sc; 1476 struct ath_softc *sc = aphy->sc;
1456 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1477 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1457 struct ath_vif *avp = (void *)vif->drv_priv; 1478 struct ath_vif *avp = (void *)vif->drv_priv;
1479 bool bs_valid = false;
1458 int i; 1480 int i;
1459 1481
1460 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n"); 1482 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n");
@@ -1483,7 +1505,15 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1483 "slot\n", __func__); 1505 "slot\n", __func__);
1484 sc->beacon.bslot[i] = NULL; 1506 sc->beacon.bslot[i] = NULL;
1485 sc->beacon.bslot_aphy[i] = NULL; 1507 sc->beacon.bslot_aphy[i] = NULL;
1486 } 1508 } else if (sc->beacon.bslot[i])
1509 bs_valid = true;
1510 }
1511 if (!bs_valid && (sc->sc_ah->imask & ATH9K_INT_SWBA)) {
1512 /* Disable SWBA interrupt */
1513 sc->sc_ah->imask &= ~ATH9K_INT_SWBA;
1514 ath9k_ps_wakeup(sc);
1515 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_ah->imask);
1516 ath9k_ps_restore(sc);
1487 } 1517 }
1488 1518
1489 sc->nvifs--; 1519 sc->nvifs--;
@@ -1556,6 +1586,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1556 * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode. 1586 * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode.
1557 */ 1587 */
1558 if (changed & IEEE80211_CONF_CHANGE_PS) { 1588 if (changed & IEEE80211_CONF_CHANGE_PS) {
1589 unsigned long flags;
1590 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1559 if (conf->flags & IEEE80211_CONF_PS) { 1591 if (conf->flags & IEEE80211_CONF_PS) {
1560 sc->ps_flags |= PS_ENABLED; 1592 sc->ps_flags |= PS_ENABLED;
1561 /* 1593 /*
@@ -1570,7 +1602,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1570 sc->ps_enabled = false; 1602 sc->ps_enabled = false;
1571 sc->ps_flags &= ~(PS_ENABLED | 1603 sc->ps_flags &= ~(PS_ENABLED |
1572 PS_NULLFUNC_COMPLETED); 1604 PS_NULLFUNC_COMPLETED);
1573 ath9k_setpower(sc, ATH9K_PM_AWAKE); 1605 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
1574 if (!(ah->caps.hw_caps & 1606 if (!(ah->caps.hw_caps &
1575 ATH9K_HW_CAP_AUTOSLEEP)) { 1607 ATH9K_HW_CAP_AUTOSLEEP)) {
1576 ath9k_hw_setrxabort(sc->sc_ah, 0); 1608 ath9k_hw_setrxabort(sc->sc_ah, 0);
@@ -1585,6 +1617,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1585 } 1617 }
1586 } 1618 }
1587 } 1619 }
1620 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1588 } 1621 }
1589 1622
1590 if (changed & IEEE80211_CONF_CHANGE_MONITOR) { 1623 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
@@ -1968,8 +2001,9 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1968 break; 2001 break;
1969 case IEEE80211_AMPDU_TX_START: 2002 case IEEE80211_AMPDU_TX_START:
1970 ath9k_ps_wakeup(sc); 2003 ath9k_ps_wakeup(sc);
1971 ath_tx_aggr_start(sc, sta, tid, ssn); 2004 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
1972 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); 2005 if (!ret)
2006 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1973 ath9k_ps_restore(sc); 2007 ath9k_ps_restore(sc);
1974 break; 2008 break;
1975 case IEEE80211_AMPDU_TX_STOP: 2009 case IEEE80211_AMPDU_TX_STOP:
@@ -2032,7 +2066,6 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2032 2066
2033 aphy->state = ATH_WIPHY_SCAN; 2067 aphy->state = ATH_WIPHY_SCAN;
2034 ath9k_wiphy_pause_all_forced(sc, aphy); 2068 ath9k_wiphy_pause_all_forced(sc, aphy);
2035 sc->sc_flags |= SC_OP_SCANNING;
2036 mutex_unlock(&sc->mutex); 2069 mutex_unlock(&sc->mutex);
2037} 2070}
2038 2071
@@ -2047,7 +2080,6 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2047 2080
2048 mutex_lock(&sc->mutex); 2081 mutex_lock(&sc->mutex);
2049 aphy->state = ATH_WIPHY_ACTIVE; 2082 aphy->state = ATH_WIPHY_ACTIVE;
2050 sc->sc_flags &= ~SC_OP_SCANNING;
2051 mutex_unlock(&sc->mutex); 2083 mutex_unlock(&sc->mutex);
2052} 2084}
2053 2085
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index b5b651413e77..894ebadbb1d3 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -290,6 +290,10 @@ static int ath_pci_resume(struct pci_dev *pdev)
290 AR_GPIO_OUTPUT_MUX_AS_OUTPUT); 290 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
291 ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); 291 ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
292 292
293 sc->ps_idle = true;
294 ath9k_set_wiphy_idle(aphy, true);
295 ath_radio_disable(sc, hw);
296
293 return 0; 297 return 0;
294} 298}
295 299
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index e49be733d546..5f825cec5b4d 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -538,7 +538,7 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
538 for (i = 0; i < rateset->rs_nrates; i++) { 538 for (i = 0; i < rateset->rs_nrates; i++) {
539 for (j = 0; j < rate_table->rate_cnt; j++) { 539 for (j = 0; j < rate_table->rate_cnt; j++) {
540 u32 phy = rate_table->info[j].phy; 540 u32 phy = rate_table->info[j].phy;
541 u16 rate_flags = rate_table->info[i].rate_flags; 541 u16 rate_flags = rate_table->info[j].rate_flags;
542 u8 rate = rateset->rs_rates[i]; 542 u8 rate = rateset->rs_rates[i];
543 u8 dot11rate = rate_table->info[j].dot11rate; 543 u8 dot11rate = rate_table->info[j].dot11rate;
544 544
@@ -1359,6 +1359,12 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1359 if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) 1359 if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED)
1360 return; 1360 return;
1361 1361
1362 if (!(tx_info->flags & IEEE80211_TX_STAT_AMPDU)) {
1363 tx_info->status.ampdu_ack_len =
1364 (tx_info->flags & IEEE80211_TX_STAT_ACK ? 1 : 0);
1365 tx_info->status.ampdu_len = 1;
1366 }
1367
1362 /* 1368 /*
1363 * If an underrun error is seen assume it as an excessive retry only 1369 * If an underrun error is seen assume it as an excessive retry only
1364 * if max frame trigger level has been reached (2 KB for singel stream, 1370 * if max frame trigger level has been reached (2 KB for singel stream,
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index a3fc987ebab0..912f747593cd 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -288,19 +288,17 @@ static void ath_edma_start_recv(struct ath_softc *sc)
288 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP, 288 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP,
289 sc->rx.rx_edma[ATH9K_RX_QUEUE_LP].rx_fifo_hwsize); 289 sc->rx.rx_edma[ATH9K_RX_QUEUE_LP].rx_fifo_hwsize);
290 290
291 spin_unlock_bh(&sc->rx.rxbuflock);
292
293 ath_opmode_init(sc); 291 ath_opmode_init(sc);
294 292
295 ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_SCANNING)); 293 ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
294
295 spin_unlock_bh(&sc->rx.rxbuflock);
296} 296}
297 297
298static void ath_edma_stop_recv(struct ath_softc *sc) 298static void ath_edma_stop_recv(struct ath_softc *sc)
299{ 299{
300 spin_lock_bh(&sc->rx.rxbuflock);
301 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP); 300 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP);
302 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP); 301 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP);
303 spin_unlock_bh(&sc->rx.rxbuflock);
304} 302}
305 303
306int ath_rx_init(struct ath_softc *sc, int nbufs) 304int ath_rx_init(struct ath_softc *sc, int nbufs)
@@ -310,7 +308,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
310 struct ath_buf *bf; 308 struct ath_buf *bf;
311 int error = 0; 309 int error = 0;
312 310
313 spin_lock_init(&sc->rx.rxflushlock); 311 spin_lock_init(&sc->sc_pcu_lock);
314 sc->sc_flags &= ~SC_OP_RXFLUSH; 312 sc->sc_flags &= ~SC_OP_RXFLUSH;
315 spin_lock_init(&sc->rx.rxbuflock); 313 spin_lock_init(&sc->rx.rxbuflock);
316 314
@@ -496,9 +494,10 @@ int ath_startrecv(struct ath_softc *sc)
496 ath9k_hw_rxena(ah); 494 ath9k_hw_rxena(ah);
497 495
498start_recv: 496start_recv:
499 spin_unlock_bh(&sc->rx.rxbuflock);
500 ath_opmode_init(sc); 497 ath_opmode_init(sc);
501 ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_SCANNING)); 498 ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
499
500 spin_unlock_bh(&sc->rx.rxbuflock);
502 501
503 return 0; 502 return 0;
504} 503}
@@ -508,7 +507,8 @@ bool ath_stoprecv(struct ath_softc *sc)
508 struct ath_hw *ah = sc->sc_ah; 507 struct ath_hw *ah = sc->sc_ah;
509 bool stopped; 508 bool stopped;
510 509
511 ath9k_hw_stoppcurecv(ah); 510 spin_lock_bh(&sc->rx.rxbuflock);
511 ath9k_hw_abortpcurecv(ah);
512 ath9k_hw_setrxfilter(ah, 0); 512 ath9k_hw_setrxfilter(ah, 0);
513 stopped = ath9k_hw_stopdmarecv(ah); 513 stopped = ath9k_hw_stopdmarecv(ah);
514 514
@@ -516,19 +516,18 @@ bool ath_stoprecv(struct ath_softc *sc)
516 ath_edma_stop_recv(sc); 516 ath_edma_stop_recv(sc);
517 else 517 else
518 sc->rx.rxlink = NULL; 518 sc->rx.rxlink = NULL;
519 spin_unlock_bh(&sc->rx.rxbuflock);
519 520
520 return stopped; 521 return stopped;
521} 522}
522 523
523void ath_flushrecv(struct ath_softc *sc) 524void ath_flushrecv(struct ath_softc *sc)
524{ 525{
525 spin_lock_bh(&sc->rx.rxflushlock);
526 sc->sc_flags |= SC_OP_RXFLUSH; 526 sc->sc_flags |= SC_OP_RXFLUSH;
527 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) 527 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
528 ath_rx_tasklet(sc, 1, true); 528 ath_rx_tasklet(sc, 1, true);
529 ath_rx_tasklet(sc, 1, false); 529 ath_rx_tasklet(sc, 1, false);
530 sc->sc_flags &= ~SC_OP_RXFLUSH; 530 sc->sc_flags &= ~SC_OP_RXFLUSH;
531 spin_unlock_bh(&sc->rx.rxflushlock);
532} 531}
533 532
534static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb) 533static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
@@ -631,7 +630,7 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb)
631 * No more broadcast/multicast frames to be received at this 630 * No more broadcast/multicast frames to be received at this
632 * point. 631 * point.
633 */ 632 */
634 sc->ps_flags &= ~PS_WAIT_FOR_CAB; 633 sc->ps_flags &= ~(PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON);
635 ath_print(common, ATH_DBG_PS, 634 ath_print(common, ATH_DBG_PS,
636 "All PS CAB frames received, back to sleep\n"); 635 "All PS CAB frames received, back to sleep\n");
637 } else if ((sc->ps_flags & PS_WAIT_FOR_PSPOLL_DATA) && 636 } else if ((sc->ps_flags & PS_WAIT_FOR_PSPOLL_DATA) &&
@@ -870,15 +869,18 @@ static bool ath9k_rx_accept(struct ath_common *common,
870 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) { 869 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
871 *decrypt_error = true; 870 *decrypt_error = true;
872 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) { 871 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
873 if (ieee80211_is_ctl(fc)) 872 /*
874 /* 873 * The MIC error bit is only valid if the frame
875 * Sometimes, we get invalid 874 * is not a control frame or fragment, and it was
876 * MIC failures on valid control frames. 875 * decrypted using a valid TKIP key.
877 * Remove these mic errors. 876 */
878 */ 877 if (!ieee80211_is_ctl(fc) &&
879 rx_stats->rs_status &= ~ATH9K_RXERR_MIC; 878 !ieee80211_has_morefrags(fc) &&
880 else 879 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
880 test_bit(rx_stats->rs_keyix, common->tkip_keymap))
881 rxs->flag |= RX_FLAG_MMIC_ERROR; 881 rxs->flag |= RX_FLAG_MMIC_ERROR;
882 else
883 rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
882 } 884 }
883 /* 885 /*
884 * Reject error frames with the exception of 886 * Reject error frames with the exception of
@@ -1033,9 +1035,11 @@ static void ath9k_rx_skb_postprocess(struct ath_common *common,
1033 int hdrlen, padpos, padsize; 1035 int hdrlen, padpos, padsize;
1034 u8 keyix; 1036 u8 keyix;
1035 __le16 fc; 1037 __le16 fc;
1038 bool is_mc;
1036 1039
1037 /* see if any padding is done by the hw and remove it */ 1040 /* see if any padding is done by the hw and remove it */
1038 hdr = (struct ieee80211_hdr *) skb->data; 1041 hdr = (struct ieee80211_hdr *) skb->data;
1042 is_mc = !!is_multicast_ether_addr(hdr->addr1);
1039 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 1043 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1040 fc = hdr->frame_control; 1044 fc = hdr->frame_control;
1041 padpos = ath9k_cmn_padpos(hdr->frame_control); 1045 padpos = ath9k_cmn_padpos(hdr->frame_control);
@@ -1056,7 +1060,7 @@ static void ath9k_rx_skb_postprocess(struct ath_common *common,
1056 1060
1057 keyix = rx_stats->rs_keyix; 1061 keyix = rx_stats->rs_keyix;
1058 1062
1059 if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error && 1063 if ((is_mc || !(keyix == ATH9K_RXKEYIX_INVALID)) && !decrypt_error &&
1060 ieee80211_has_protected(fc)) { 1064 ieee80211_has_protected(fc)) {
1061 rxs->flag |= RX_FLAG_DECRYPTED; 1065 rxs->flag |= RX_FLAG_DECRYPTED;
1062 } else if (ieee80211_has_protected(fc) 1066 } else if (ieee80211_has_protected(fc)
@@ -1096,6 +1100,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1096 u8 rx_status_len = ah->caps.rx_status_len; 1100 u8 rx_status_len = ah->caps.rx_status_len;
1097 u64 tsf = 0; 1101 u64 tsf = 0;
1098 u32 tsf_lower = 0; 1102 u32 tsf_lower = 0;
1103 unsigned long flags;
1099 1104
1100 if (edma) 1105 if (edma)
1101 dma_type = DMA_BIDIRECTIONAL; 1106 dma_type = DMA_BIDIRECTIONAL;
@@ -1204,11 +1209,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1204 sc->rx.rxotherant = 0; 1209 sc->rx.rxotherant = 0;
1205 } 1210 }
1206 1211
1212 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1207 if (unlikely(ath9k_check_auto_sleep(sc) || 1213 if (unlikely(ath9k_check_auto_sleep(sc) ||
1208 (sc->ps_flags & (PS_WAIT_FOR_BEACON | 1214 (sc->ps_flags & (PS_WAIT_FOR_BEACON |
1209 PS_WAIT_FOR_CAB | 1215 PS_WAIT_FOR_CAB |
1210 PS_WAIT_FOR_PSPOLL_DATA)))) 1216 PS_WAIT_FOR_PSPOLL_DATA))))
1211 ath_rx_ps(sc, skb); 1217 ath_rx_ps(sc, skb);
1218 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1212 1219
1213 ath_rx_send_to_mac80211(hw, sc, skb, rxs); 1220 ath_rx_send_to_mac80211(hw, sc, skb, rxs);
1214 1221
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index d01c4adab8d6..86b0a4b1a72f 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -709,6 +709,7 @@
709#define AR_WA_RESET_EN (1 << 18) /* Sw Control to enable PCI-Reset to POR (bit 15) */ 709#define AR_WA_RESET_EN (1 << 18) /* Sw Control to enable PCI-Reset to POR (bit 15) */
710#define AR_WA_ANALOG_SHIFT (1 << 20) 710#define AR_WA_ANALOG_SHIFT (1 << 20)
711#define AR_WA_POR_SHORT (1 << 21) /* PCI-E Phy reset control */ 711#define AR_WA_POR_SHORT (1 << 21) /* PCI-E Phy reset control */
712#define AR_WA_BIT22 (1 << 22)
712#define AR9285_WA_DEFAULT 0x004a050b 713#define AR9285_WA_DEFAULT 0x004a050b
713#define AR9280_WA_DEFAULT 0x0040073b 714#define AR9280_WA_DEFAULT 0x0040073b
714#define AR_WA_DEFAULT 0x0000073f 715#define AR_WA_DEFAULT 0x0000073f
@@ -900,7 +901,13 @@
900#define AR_DEVID_7010(_ah) \ 901#define AR_DEVID_7010(_ah) \
901 (((_ah)->hw_version.devid == 0x7010) || \ 902 (((_ah)->hw_version.devid == 0x7010) || \
902 ((_ah)->hw_version.devid == 0x7015) || \ 903 ((_ah)->hw_version.devid == 0x7015) || \
903 ((_ah)->hw_version.devid == 0x9018)) 904 ((_ah)->hw_version.devid == 0x9018) || \
905 ((_ah)->hw_version.devid == 0xA704) || \
906 ((_ah)->hw_version.devid == 0x1200))
907
908#define AR9287_HTC_DEVID(_ah) \
909 (((_ah)->hw_version.devid == 0x7015) || \
910 ((_ah)->hw_version.devid == 0x1200))
904 911
905#define AR_RADIO_SREV_MAJOR 0xf0 912#define AR_RADIO_SREV_MAJOR 0xf0
906#define AR_RAD5133_SREV_MAJOR 0xc0 913#define AR_RAD5133_SREV_MAJOR 0xc0
@@ -1012,11 +1019,13 @@ enum {
1012#define AR9287_GPIO_IN_VAL_S 11 1019#define AR9287_GPIO_IN_VAL_S 11
1013#define AR9271_GPIO_IN_VAL 0xFFFF0000 1020#define AR9271_GPIO_IN_VAL 0xFFFF0000
1014#define AR9271_GPIO_IN_VAL_S 16 1021#define AR9271_GPIO_IN_VAL_S 16
1015#define AR9300_GPIO_IN_VAL 0x0001FFFF
1016#define AR9300_GPIO_IN_VAL_S 0
1017#define AR7010_GPIO_IN_VAL 0x0000FFFF 1022#define AR7010_GPIO_IN_VAL 0x0000FFFF
1018#define AR7010_GPIO_IN_VAL_S 0 1023#define AR7010_GPIO_IN_VAL_S 0
1019 1024
1025#define AR_GPIO_IN 0x404c
1026#define AR9300_GPIO_IN_VAL 0x0001FFFF
1027#define AR9300_GPIO_IN_VAL_S 0
1028
1020#define AR_GPIO_OE_OUT (AR_SREV_9300_20_OR_LATER(ah) ? 0x4050 : 0x404c) 1029#define AR_GPIO_OE_OUT (AR_SREV_9300_20_OR_LATER(ah) ? 0x4050 : 0x404c)
1021#define AR_GPIO_OE_OUT_DRV 0x3 1030#define AR_GPIO_OE_OUT_DRV 0x3
1022#define AR_GPIO_OE_OUT_DRV_NO 0x0 1031#define AR_GPIO_OE_OUT_DRV_NO 0x0
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 4dda14e36227..8f00c6c13979 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -61,6 +61,8 @@ static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf,
61 struct ath_tx_status *ts, int txok); 61 struct ath_tx_status *ts, int txok);
62static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts, 62static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts,
63 int nbad, int txok, bool update_rc); 63 int nbad, int txok, bool update_rc);
64static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
65 int seqno);
64 66
65enum { 67enum {
66 MCS_HT20, 68 MCS_HT20,
@@ -143,18 +145,23 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
143 struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum]; 145 struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
144 struct ath_buf *bf; 146 struct ath_buf *bf;
145 struct list_head bf_head; 147 struct list_head bf_head;
146 INIT_LIST_HEAD(&bf_head); 148 struct ath_tx_status ts;
147 149
148 WARN_ON(!tid->paused); 150 INIT_LIST_HEAD(&bf_head);
149 151
152 memset(&ts, 0, sizeof(ts));
150 spin_lock_bh(&txq->axq_lock); 153 spin_lock_bh(&txq->axq_lock);
151 tid->paused = false;
152 154
153 while (!list_empty(&tid->buf_q)) { 155 while (!list_empty(&tid->buf_q)) {
154 bf = list_first_entry(&tid->buf_q, struct ath_buf, list); 156 bf = list_first_entry(&tid->buf_q, struct ath_buf, list);
155 BUG_ON(bf_isretried(bf));
156 list_move_tail(&bf->list, &bf_head); 157 list_move_tail(&bf->list, &bf_head);
157 ath_tx_send_ht_normal(sc, txq, tid, &bf_head); 158
159 if (bf_isretried(bf)) {
160 ath_tx_update_baw(sc, tid, bf->bf_seqno);
161 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
162 } else {
163 ath_tx_send_ht_normal(sc, txq, tid, &bf_head);
164 }
158 } 165 }
159 166
160 spin_unlock_bh(&txq->axq_lock); 167 spin_unlock_bh(&txq->axq_lock);
@@ -312,6 +319,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
312 int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0; 319 int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
313 bool rc_update = true; 320 bool rc_update = true;
314 struct ieee80211_tx_rate rates[4]; 321 struct ieee80211_tx_rate rates[4];
322 int nframes;
315 323
316 skb = bf->bf_mpdu; 324 skb = bf->bf_mpdu;
317 hdr = (struct ieee80211_hdr *)skb->data; 325 hdr = (struct ieee80211_hdr *)skb->data;
@@ -320,6 +328,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
320 hw = bf->aphy->hw; 328 hw = bf->aphy->hw;
321 329
322 memcpy(rates, tx_info->control.rates, sizeof(rates)); 330 memcpy(rates, tx_info->control.rates, sizeof(rates));
331 nframes = bf->bf_nframes;
323 332
324 rcu_read_lock(); 333 rcu_read_lock();
325 334
@@ -337,7 +346,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
337 !bf->bf_stale || bf_next != NULL) 346 !bf->bf_stale || bf_next != NULL)
338 list_move_tail(&bf->list, &bf_head); 347 list_move_tail(&bf->list, &bf_head);
339 348
340 ath_tx_rc_status(bf, ts, 0, 0, false); 349 ath_tx_rc_status(bf, ts, 1, 0, false);
341 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 350 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
342 0, 0); 351 0, 0);
343 352
@@ -431,7 +440,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
431 list_move_tail(&bf->list, &bf_head); 440 list_move_tail(&bf->list, &bf_head);
432 } 441 }
433 442
434 if (!txpending) { 443 if (!txpending || (tid->state & AGGR_CLEANUP)) {
435 /* 444 /*
436 * complete the acked-ones/xretried ones; update 445 * complete the acked-ones/xretried ones; update
437 * block-ack window 446 * block-ack window
@@ -442,6 +451,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
442 451
443 if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) { 452 if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
444 memcpy(tx_info->control.rates, rates, sizeof(rates)); 453 memcpy(tx_info->control.rates, rates, sizeof(rates));
454 bf->bf_nframes = nframes;
445 ath_tx_rc_status(bf, ts, nbad, txok, true); 455 ath_tx_rc_status(bf, ts, nbad, txok, true);
446 rc_update = false; 456 rc_update = false;
447 } else { 457 } else {
@@ -510,15 +520,12 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
510 } 520 }
511 521
512 if (tid->state & AGGR_CLEANUP) { 522 if (tid->state & AGGR_CLEANUP) {
523 ath_tx_flush_tid(sc, tid);
524
513 if (tid->baw_head == tid->baw_tail) { 525 if (tid->baw_head == tid->baw_tail) {
514 tid->state &= ~AGGR_ADDBA_COMPLETE; 526 tid->state &= ~AGGR_ADDBA_COMPLETE;
515 tid->state &= ~AGGR_CLEANUP; 527 tid->state &= ~AGGR_CLEANUP;
516
517 /* send buffered frames as singles */
518 ath_tx_flush_tid(sc, tid);
519 } 528 }
520 rcu_read_unlock();
521 return;
522 } 529 }
523 530
524 rcu_read_unlock(); 531 rcu_read_unlock();
@@ -785,17 +792,23 @@ static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
785 status != ATH_AGGR_BAW_CLOSED); 792 status != ATH_AGGR_BAW_CLOSED);
786} 793}
787 794
788void ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, 795int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
789 u16 tid, u16 *ssn) 796 u16 tid, u16 *ssn)
790{ 797{
791 struct ath_atx_tid *txtid; 798 struct ath_atx_tid *txtid;
792 struct ath_node *an; 799 struct ath_node *an;
793 800
794 an = (struct ath_node *)sta->drv_priv; 801 an = (struct ath_node *)sta->drv_priv;
795 txtid = ATH_AN_2_TID(an, tid); 802 txtid = ATH_AN_2_TID(an, tid);
803
804 if (txtid->state & (AGGR_CLEANUP | AGGR_ADDBA_COMPLETE))
805 return -EAGAIN;
806
796 txtid->state |= AGGR_ADDBA_PROGRESS; 807 txtid->state |= AGGR_ADDBA_PROGRESS;
797 txtid->paused = true; 808 txtid->paused = true;
798 *ssn = txtid->seq_start; 809 *ssn = txtid->seq_start;
810
811 return 0;
799} 812}
800 813
801void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) 814void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
@@ -803,12 +816,6 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
803 struct ath_node *an = (struct ath_node *)sta->drv_priv; 816 struct ath_node *an = (struct ath_node *)sta->drv_priv;
804 struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid); 817 struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
805 struct ath_txq *txq = &sc->tx.txq[txtid->ac->qnum]; 818 struct ath_txq *txq = &sc->tx.txq[txtid->ac->qnum];
806 struct ath_tx_status ts;
807 struct ath_buf *bf;
808 struct list_head bf_head;
809
810 memset(&ts, 0, sizeof(ts));
811 INIT_LIST_HEAD(&bf_head);
812 819
813 if (txtid->state & AGGR_CLEANUP) 820 if (txtid->state & AGGR_CLEANUP)
814 return; 821 return;
@@ -818,31 +825,22 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
818 return; 825 return;
819 } 826 }
820 827
821 /* drop all software retried frames and mark this TID */
822 spin_lock_bh(&txq->axq_lock); 828 spin_lock_bh(&txq->axq_lock);
823 txtid->paused = true; 829 txtid->paused = true;
824 while (!list_empty(&txtid->buf_q)) {
825 bf = list_first_entry(&txtid->buf_q, struct ath_buf, list);
826 if (!bf_isretried(bf)) {
827 /*
828 * NB: it's based on the assumption that
829 * software retried frame will always stay
830 * at the head of software queue.
831 */
832 break;
833 }
834 list_move_tail(&bf->list, &bf_head);
835 ath_tx_update_baw(sc, txtid, bf->bf_seqno);
836 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
837 }
838 spin_unlock_bh(&txq->axq_lock);
839 830
840 if (txtid->baw_head != txtid->baw_tail) { 831 /*
832 * If frames are still being transmitted for this TID, they will be
833 * cleaned up during tx completion. To prevent race conditions, this
834 * TID can only be reused after all in-progress subframes have been
835 * completed.
836 */
837 if (txtid->baw_head != txtid->baw_tail)
841 txtid->state |= AGGR_CLEANUP; 838 txtid->state |= AGGR_CLEANUP;
842 } else { 839 else
843 txtid->state &= ~AGGR_ADDBA_COMPLETE; 840 txtid->state &= ~AGGR_ADDBA_COMPLETE;
844 ath_tx_flush_tid(sc, txtid); 841 spin_unlock_bh(&txq->axq_lock);
845 } 842
843 ath_tx_flush_tid(sc, txtid);
846} 844}
847 845
848void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) 846void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
@@ -1103,15 +1101,6 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
1103 txq->axq_tx_inprogress = false; 1101 txq->axq_tx_inprogress = false;
1104 spin_unlock_bh(&txq->axq_lock); 1102 spin_unlock_bh(&txq->axq_lock);
1105 1103
1106 /* flush any pending frames if aggregation is enabled */
1107 if (sc->sc_flags & SC_OP_TXAGGR) {
1108 if (!retry_tx) {
1109 spin_lock_bh(&txq->axq_lock);
1110 ath_txq_drain_pending_buffers(sc, txq);
1111 spin_unlock_bh(&txq->axq_lock);
1112 }
1113 }
1114
1115 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 1104 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
1116 spin_lock_bh(&txq->axq_lock); 1105 spin_lock_bh(&txq->axq_lock);
1117 while (!list_empty(&txq->txq_fifo_pending)) { 1106 while (!list_empty(&txq->txq_fifo_pending)) {
@@ -1132,6 +1121,15 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
1132 } 1121 }
1133 spin_unlock_bh(&txq->axq_lock); 1122 spin_unlock_bh(&txq->axq_lock);
1134 } 1123 }
1124
1125 /* flush any pending frames if aggregation is enabled */
1126 if (sc->sc_flags & SC_OP_TXAGGR) {
1127 if (!retry_tx) {
1128 spin_lock_bh(&txq->axq_lock);
1129 ath_txq_drain_pending_buffers(sc, txq);
1130 spin_unlock_bh(&txq->axq_lock);
1131 }
1132 }
1135} 1133}
1136 1134
1137void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx) 1135void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
@@ -1162,13 +1160,13 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1162 ath_print(common, ATH_DBG_FATAL, 1160 ath_print(common, ATH_DBG_FATAL,
1163 "Failed to stop TX DMA. Resetting hardware!\n"); 1161 "Failed to stop TX DMA. Resetting hardware!\n");
1164 1162
1165 spin_lock_bh(&sc->sc_resetlock); 1163 spin_lock_bh(&sc->sc_pcu_lock);
1166 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false); 1164 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
1167 if (r) 1165 if (r)
1168 ath_print(common, ATH_DBG_FATAL, 1166 ath_print(common, ATH_DBG_FATAL,
1169 "Unable to reset hardware; reset status %d\n", 1167 "Unable to reset hardware; reset status %d\n",
1170 r); 1168 r);
1171 spin_unlock_bh(&sc->sc_resetlock); 1169 spin_unlock_bh(&sc->sc_pcu_lock);
1172 } 1170 }
1173 1171
1174 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { 1172 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
@@ -2024,9 +2022,15 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts,
2024 2022
2025 if (ts->ts_status & ATH9K_TXERR_FILT) 2023 if (ts->ts_status & ATH9K_TXERR_FILT)
2026 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 2024 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
2027 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && update_rc) 2025 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && update_rc) {
2028 tx_info->flags |= IEEE80211_TX_STAT_AMPDU; 2026 tx_info->flags |= IEEE80211_TX_STAT_AMPDU;
2029 2027
2028 BUG_ON(nbad > bf->bf_nframes);
2029
2030 tx_info->status.ampdu_len = bf->bf_nframes;
2031 tx_info->status.ampdu_ack_len = bf->bf_nframes - nbad;
2032 }
2033
2030 if ((ts->ts_status & ATH9K_TXERR_FILT) == 0 && 2034 if ((ts->ts_status & ATH9K_TXERR_FILT) == 0 &&
2031 (bf->bf_flags & ATH9K_TXDESC_NOACK) == 0 && update_rc) { 2035 (bf->bf_flags & ATH9K_TXDESC_NOACK) == 0 && update_rc) {
2032 if (ieee80211_is_data(hdr->frame_control)) { 2036 if (ieee80211_is_data(hdr->frame_control)) {
@@ -2036,8 +2040,6 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts,
2036 if ((ts->ts_status & ATH9K_TXERR_XRETRY) || 2040 if ((ts->ts_status & ATH9K_TXERR_XRETRY) ||
2037 (ts->ts_status & ATH9K_TXERR_FIFO)) 2041 (ts->ts_status & ATH9K_TXERR_FIFO))
2038 tx_info->pad[0] |= ATH_TX_INFO_XRETRY; 2042 tx_info->pad[0] |= ATH_TX_INFO_XRETRY;
2039 tx_info->status.ampdu_len = bf->bf_nframes;
2040 tx_info->status.ampdu_ack_len = bf->bf_nframes - nbad;
2041 } 2043 }
2042 } 2044 }
2043 2045
@@ -2159,7 +2161,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2159 */ 2161 */
2160 if (ts.ts_status & ATH9K_TXERR_XRETRY) 2162 if (ts.ts_status & ATH9K_TXERR_XRETRY)
2161 bf->bf_state.bf_type |= BUF_XRETRY; 2163 bf->bf_state.bf_type |= BUF_XRETRY;
2162 ath_tx_rc_status(bf, &ts, 0, txok, true); 2164 ath_tx_rc_status(bf, &ts, txok ? 0 : 1, txok, true);
2163 } 2165 }
2164 2166
2165 if (bf_isampdu(bf)) 2167 if (bf_isampdu(bf))
@@ -2204,7 +2206,7 @@ static void ath_tx_complete_poll_work(struct work_struct *work)
2204 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET, 2206 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
2205 "tx hung, resetting the chip\n"); 2207 "tx hung, resetting the chip\n");
2206 ath9k_ps_wakeup(sc); 2208 ath9k_ps_wakeup(sc);
2207 ath_reset(sc, false); 2209 ath_reset(sc, true);
2208 ath9k_ps_restore(sc); 2210 ath9k_ps_restore(sc);
2209 } 2211 }
2210 2212
@@ -2288,7 +2290,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
2288 if (!bf_isampdu(bf)) { 2290 if (!bf_isampdu(bf)) {
2289 if (txs.ts_status & ATH9K_TXERR_XRETRY) 2291 if (txs.ts_status & ATH9K_TXERR_XRETRY)
2290 bf->bf_state.bf_type |= BUF_XRETRY; 2292 bf->bf_state.bf_type |= BUF_XRETRY;
2291 ath_tx_rc_status(bf, &txs, 0, txok, true); 2293 ath_tx_rc_status(bf, &txs, txok ? 0 : 1, txok, true);
2292 } 2294 }
2293 2295
2294 if (bf_isampdu(bf)) 2296 if (bf_isampdu(bf))
diff --git a/drivers/net/wireless/b43/sdio.c b/drivers/net/wireless/b43/sdio.c
index 45933cf8e8c2..09e2dfd7b175 100644
--- a/drivers/net/wireless/b43/sdio.c
+++ b/drivers/net/wireless/b43/sdio.c
@@ -163,6 +163,7 @@ static int b43_sdio_probe(struct sdio_func *func,
163err_free_ssb: 163err_free_ssb:
164 kfree(sdio); 164 kfree(sdio);
165err_disable_func: 165err_disable_func:
166 sdio_claim_host(func);
166 sdio_disable_func(func); 167 sdio_disable_func(func);
167err_release_host: 168err_release_host:
168 sdio_release_host(func); 169 sdio_release_host(func);
@@ -175,7 +176,9 @@ static void b43_sdio_remove(struct sdio_func *func)
175 struct b43_sdio *sdio = sdio_get_drvdata(func); 176 struct b43_sdio *sdio = sdio_get_drvdata(func);
176 177
177 ssb_bus_unregister(&sdio->ssb); 178 ssb_bus_unregister(&sdio->ssb);
179 sdio_claim_host(func);
178 sdio_disable_func(func); 180 sdio_disable_func(func);
181 sdio_release_host(func);
179 kfree(sdio); 182 kfree(sdio);
180 sdio_set_drvdata(func, NULL); 183 sdio_set_drvdata(func, NULL);
181} 184}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 10d7b9b7f064..f735117d8fc2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1234,6 +1234,9 @@ static void iwl_irq_tasklet_legacy(struct iwl_priv *priv)
1234 /* only Re-enable if diabled by irq */ 1234 /* only Re-enable if diabled by irq */
1235 if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1235 if (test_bit(STATUS_INT_ENABLED, &priv->status))
1236 iwl_enable_interrupts(priv); 1236 iwl_enable_interrupts(priv);
1237 /* Re-enable RF_KILL if it occurred */
1238 else if (handled & CSR_INT_BIT_RF_KILL)
1239 iwl_enable_rfkill_int(priv);
1237 1240
1238#ifdef CONFIG_IWLWIFI_DEBUG 1241#ifdef CONFIG_IWLWIFI_DEBUG
1239 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) { 1242 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
@@ -1449,6 +1452,9 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1449 /* only Re-enable if diabled by irq */ 1452 /* only Re-enable if diabled by irq */
1450 if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1453 if (test_bit(STATUS_INT_ENABLED, &priv->status))
1451 iwl_enable_interrupts(priv); 1454 iwl_enable_interrupts(priv);
1455 /* Re-enable RF_KILL if it occurred */
1456 else if (handled & CSR_INT_BIT_RF_KILL)
1457 iwl_enable_rfkill_int(priv);
1452} 1458}
1453 1459
1454/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */ 1460/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
@@ -3260,9 +3266,10 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
3260 3266
3261 flush_workqueue(priv->workqueue); 3267 flush_workqueue(priv->workqueue);
3262 3268
3263 /* enable interrupts again in order to receive rfkill changes */ 3269 /* User space software may expect getting rfkill changes
3270 * even if interface is down */
3264 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 3271 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
3265 iwl_enable_interrupts(priv); 3272 iwl_enable_rfkill_int(priv);
3266 3273
3267 IWL_DEBUG_MAC80211(priv, "leave\n"); 3274 IWL_DEBUG_MAC80211(priv, "leave\n");
3268} 3275}
@@ -4103,14 +4110,14 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4103 * 8. Enable interrupts and read RFKILL state 4110 * 8. Enable interrupts and read RFKILL state
4104 *********************************************/ 4111 *********************************************/
4105 4112
4106 /* enable interrupts if needed: hw bug w/a */ 4113 /* enable rfkill interrupt: hw bug w/a */
4107 pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); 4114 pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd);
4108 if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { 4115 if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
4109 pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; 4116 pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
4110 pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); 4117 pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd);
4111 } 4118 }
4112 4119
4113 iwl_enable_interrupts(priv); 4120 iwl_enable_rfkill_int(priv);
4114 4121
4115 /* If platform's RF_KILL switch is NOT set to KILL */ 4122 /* If platform's RF_KILL switch is NOT set to KILL */
4116 if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) 4123 if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 621abe3c5afc..1c6add90b5b4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -168,6 +168,12 @@ static inline void iwl_disable_interrupts(struct iwl_priv *priv)
168 IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); 168 IWL_DEBUG_ISR(priv, "Disabled interrupts\n");
169} 169}
170 170
171static inline void iwl_enable_rfkill_int(struct iwl_priv *priv)
172{
173 IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n");
174 iwl_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL);
175}
176
171static inline void iwl_enable_interrupts(struct iwl_priv *priv) 177static inline void iwl_enable_interrupts(struct iwl_priv *priv)
172{ 178{
173 IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); 179 IWL_DEBUG_ISR(priv, "Enabling interrupts\n");
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index e8e2d0f4763d..f800ef4e6554 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -1813,6 +1813,12 @@ static int __orinoco_commit(struct orinoco_private *priv)
1813 struct net_device *dev = priv->ndev; 1813 struct net_device *dev = priv->ndev;
1814 int err = 0; 1814 int err = 0;
1815 1815
1816 /* If we've called commit, we are reconfiguring or bringing the
1817 * interface up. Maintaining countermeasures across this would
1818 * be confusing, so note that we've disabled them. The port will
1819 * be enabled later in orinoco_commit or __orinoco_up. */
1820 priv->tkip_cm_active = 0;
1821
1816 err = orinoco_hw_program_rids(priv); 1822 err = orinoco_hw_program_rids(priv);
1817 1823
1818 /* FIXME: what about netif_tx_lock */ 1824 /* FIXME: what about netif_tx_lock */
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index ef46a2d88539..083999faaa98 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -248,20 +248,20 @@ orinoco_cs_config(struct pcmcia_device *link)
248 goto failed; 248 goto failed;
249 } 249 }
250 250
251 ret = pcmcia_request_irq(link, orinoco_interrupt);
252 if (ret)
253 goto failed;
254
255 /* We initialize the hermes structure before completing PCMCIA
256 * configuration just in case the interrupt handler gets
257 * called. */
258 mem = ioport_map(link->resource[0]->start, 251 mem = ioport_map(link->resource[0]->start,
259 resource_size(link->resource[0])); 252 resource_size(link->resource[0]));
260 if (!mem) 253 if (!mem)
261 goto failed; 254 goto failed;
262 255
256 /* We initialize the hermes structure before completing PCMCIA
257 * configuration just in case the interrupt handler gets
258 * called. */
263 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 259 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
264 260
261 ret = pcmcia_request_irq(link, orinoco_interrupt);
262 if (ret)
263 goto failed;
264
265 /* 265 /*
266 * This actually configures the PCMCIA socket -- setting up 266 * This actually configures the PCMCIA socket -- setting up
267 * the I/O windows and the interrupt mapping, and putting the 267 * the I/O windows and the interrupt mapping, and putting the
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 873877e17e1b..93070a3a5233 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -310,21 +310,21 @@ spectrum_cs_config(struct pcmcia_device *link)
310 goto failed; 310 goto failed;
311 } 311 }
312 312
313 ret = pcmcia_request_irq(link, orinoco_interrupt);
314 if (ret)
315 goto failed;
316
317 /* We initialize the hermes structure before completing PCMCIA
318 * configuration just in case the interrupt handler gets
319 * called. */
320 mem = ioport_map(link->resource[0]->start, 313 mem = ioport_map(link->resource[0]->start,
321 resource_size(link->resource[0])); 314 resource_size(link->resource[0]));
322 if (!mem) 315 if (!mem)
323 goto failed; 316 goto failed;
324 317
318 /* We initialize the hermes structure before completing PCMCIA
319 * configuration just in case the interrupt handler gets
320 * called. */
325 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 321 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
326 hw->eeprom_pda = true; 322 hw->eeprom_pda = true;
327 323
324 ret = pcmcia_request_irq(link, orinoco_interrupt);
325 if (ret)
326 goto failed;
327
328 /* 328 /*
329 * This actually configures the PCMCIA socket -- setting up 329 * This actually configures the PCMCIA socket -- setting up
330 * the I/O windows and the interrupt mapping, and putting the 330 * the I/O windows and the interrupt mapping, and putting the
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index cf7be1eb6124..56aab61fd4cb 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -904,10 +904,10 @@ static int orinoco_ioctl_set_auth(struct net_device *dev,
904 */ 904 */
905 if (param->value) { 905 if (param->value) {
906 priv->tkip_cm_active = 1; 906 priv->tkip_cm_active = 1;
907 ret = hermes_enable_port(hw, 0); 907 ret = hermes_disable_port(hw, 0);
908 } else { 908 } else {
909 priv->tkip_cm_active = 0; 909 priv->tkip_cm_active = 0;
910 ret = hermes_disable_port(hw, 0); 910 ret = hermes_enable_port(hw, 0);
911 } 911 }
912 break; 912 break;
913 913
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c
index 78347041ec40..0a7ce37aa628 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -260,8 +260,10 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
260 list->max_entries = max_channel_num; 260 list->max_entries = max_channel_num;
261 list->channels = kzalloc(sizeof(struct p54_channel_entry) * 261 list->channels = kzalloc(sizeof(struct p54_channel_entry) *
262 max_channel_num, GFP_KERNEL); 262 max_channel_num, GFP_KERNEL);
263 if (!list->channels) 263 if (!list->channels) {
264 ret = -ENOMEM;
264 goto free; 265 goto free;
266 }
265 267
266 for (i = 0; i < max_channel_num; i++) { 268 for (i = 0; i < max_channel_num; i++) {
267 if (i < priv->iq_autocal_len) { 269 if (i < priv->iq_autocal_len) {
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index ad595958b7df..2325e56a9b0b 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -33,8 +33,18 @@ MODULE_ALIAS("prism54usb");
33MODULE_FIRMWARE("isl3886usb"); 33MODULE_FIRMWARE("isl3886usb");
34MODULE_FIRMWARE("isl3887usb"); 34MODULE_FIRMWARE("isl3887usb");
35 35
36/*
37 * Note:
38 *
39 * Always update our wiki's device list (located at:
40 * http://wireless.kernel.org/en/users/Drivers/p54/devices ),
41 * whenever you add a new device.
42 */
43
36static struct usb_device_id p54u_table[] __devinitdata = { 44static struct usb_device_id p54u_table[] __devinitdata = {
37 /* Version 1 devices (pci chip + net2280) */ 45 /* Version 1 devices (pci chip + net2280) */
46 {USB_DEVICE(0x0411, 0x0050)}, /* Buffalo WLI2-USB2-G54 */
47 {USB_DEVICE(0x045e, 0x00c2)}, /* Microsoft MN-710 */
38 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */ 48 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
39 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */ 49 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
40 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */ 50 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
@@ -47,7 +57,13 @@ static struct usb_device_id p54u_table[] __devinitdata = {
47 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */ 57 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */
48 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */ 58 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
49 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion 40900, Roper Europe */ 59 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion 40900, Roper Europe */
60 {USB_DEVICE(0x0db0, 0x6826)}, /* MSI UB54G (MS-6826) */
61 {USB_DEVICE(0x107b, 0x55f2)}, /* Gateway WGU-210 (Gemtek) */
50 {USB_DEVICE(0x124a, 0x4023)}, /* Shuttle PN15, Airvast WM168g, IOGear GWU513 */ 62 {USB_DEVICE(0x124a, 0x4023)}, /* Shuttle PN15, Airvast WM168g, IOGear GWU513 */
63 {USB_DEVICE(0x1435, 0x0210)}, /* Inventel UR054G */
64 {USB_DEVICE(0x15a9, 0x0002)}, /* Gemtek WUBI-100GW 802.11g */
65 {USB_DEVICE(0x1630, 0x0005)}, /* 2Wire 802.11g USB (v1) / Z-Com */
66 {USB_DEVICE(0x182d, 0x096b)}, /* Sitecom WL-107 */
51 {USB_DEVICE(0x1915, 0x2234)}, /* Linksys WUSB54G OEM */ 67 {USB_DEVICE(0x1915, 0x2234)}, /* Linksys WUSB54G OEM */
52 {USB_DEVICE(0x1915, 0x2235)}, /* Linksys WUSB54G Portable OEM */ 68 {USB_DEVICE(0x1915, 0x2235)}, /* Linksys WUSB54G Portable OEM */
53 {USB_DEVICE(0x2001, 0x3701)}, /* DLink DWL-G120 Spinnaker */ 69 {USB_DEVICE(0x2001, 0x3701)}, /* DLink DWL-G120 Spinnaker */
@@ -60,6 +76,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
60 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */ 76 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */
61 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */ 77 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */
62 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */ 78 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */
79 {USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
63 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */ 80 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
64 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */ 81 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
65 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */ 82 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
@@ -80,7 +97,9 @@ static struct usb_device_id p54u_table[] __devinitdata = {
80 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */ 97 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
81 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */ 98 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */
82 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */ 99 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
100 {USB_DEVICE(0x1668, 0x1050)}, /* Actiontec 802UIG-1 */
83 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */ 101 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
102 {USB_DEVICE(0x2001, 0x3705)}, /* D-Link DWL-G120 rev C1 */
84 {USB_DEVICE(0x413c, 0x5513)}, /* Dell WLA3310 USB Wireless Adapter */ 103 {USB_DEVICE(0x413c, 0x5513)}, /* Dell WLA3310 USB Wireless Adapter */
85 {USB_DEVICE(0x413c, 0x8102)}, /* Spinnaker DUT */ 104 {USB_DEVICE(0x413c, 0x8102)}, /* Spinnaker DUT */
86 {USB_DEVICE(0x413c, 0x8104)}, /* Cohiba Proto board */ 105 {USB_DEVICE(0x413c, 0x8104)}, /* Cohiba Proto board */
@@ -930,8 +949,8 @@ static int __devinit p54u_probe(struct usb_interface *intf,
930#ifdef CONFIG_PM 949#ifdef CONFIG_PM
931 /* ISL3887 needs a full reset on resume */ 950 /* ISL3887 needs a full reset on resume */
932 udev->reset_resume = 1; 951 udev->reset_resume = 1;
952#endif /* CONFIG_PM */
933 err = p54u_device_reset(dev); 953 err = p54u_device_reset(dev);
934#endif
935 954
936 priv->hw_type = P54U_3887; 955 priv->hw_type = P54U_3887;
937 dev->extra_tx_headroom += sizeof(struct lm87_tx_hdr); 956 dev->extra_tx_headroom += sizeof(struct lm87_tx_hdr);
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 0e937dc0c9c4..3d5311330b4a 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -618,7 +618,7 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
618 else 618 else
619 *burst_possible = false; 619 *burst_possible = false;
620 620
621 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) 621 if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
622 *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR; 622 *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
623 623
624 if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE) 624 if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 5063e01410e5..6a6cd7142e31 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1488,8 +1488,10 @@ static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1488 spec->channels_info = info; 1488 spec->channels_info = info;
1489 1489
1490 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START); 1490 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1491 for (i = 0; i < 14; i++) 1491 for (i = 0; i < 14; i++) {
1492 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 1492 info[i].max_power = TXPOWER_FROM_DEV(MAX_TXPOWER);
1493 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
1494 }
1493 1495
1494 return 0; 1496 return 0;
1495} 1497}
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index c2a555d5376b..ec3e8b329a67 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1802,12 +1802,16 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1802 spec->channels_info = info; 1802 spec->channels_info = info;
1803 1803
1804 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START); 1804 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1805 for (i = 0; i < 14; i++) 1805 for (i = 0; i < 14; i++) {
1806 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 1806 info[i].max_power = MAX_TXPOWER;
1807 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
1808 }
1807 1809
1808 if (spec->num_channels > 14) { 1810 if (spec->num_channels > 14) {
1809 for (i = 14; i < spec->num_channels; i++) 1811 for (i = 14; i < spec->num_channels; i++) {
1810 info[i].tx_power1 = DEFAULT_TXPOWER; 1812 info[i].max_power = MAX_TXPOWER;
1813 info[i].default_power1 = DEFAULT_TXPOWER;
1814 }
1811 } 1815 }
1812 1816
1813 return 0; 1817 return 0;
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index cdaf93f48263..ed4de3f02d40 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1705,12 +1705,16 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1705 spec->channels_info = info; 1705 spec->channels_info = info;
1706 1706
1707 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START); 1707 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1708 for (i = 0; i < 14; i++) 1708 for (i = 0; i < 14; i++) {
1709 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 1709 info[i].max_power = MAX_TXPOWER;
1710 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
1711 }
1710 1712
1711 if (spec->num_channels > 14) { 1713 if (spec->num_channels > 14) {
1712 for (i = 14; i < spec->num_channels; i++) 1714 for (i = 14; i < spec->num_channels; i++) {
1713 info[i].tx_power1 = DEFAULT_TXPOWER; 1715 info[i].max_power = MAX_TXPOWER;
1716 info[i].default_power1 = DEFAULT_TXPOWER;
1717 }
1714 } 1718 }
1715 1719
1716 return 0; 1720 return 0;
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index ed4ebcdde7c9..616b71a4ad1f 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -1841,6 +1841,13 @@ struct mac_iveiv_entry {
1841#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00) 1841#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00)
1842 1842
1843/* 1843/*
1844 * EEPROM Maximum TX power values
1845 */
1846#define EEPROM_MAX_TX_POWER 0x0027
1847#define EEPROM_MAX_TX_POWER_24GHZ FIELD16(0x00ff)
1848#define EEPROM_MAX_TX_POWER_5GHZ FIELD16(0xff00)
1849
1850/*
1844 * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power. 1851 * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power.
1845 * This is delta in 40MHZ. 1852 * This is delta in 40MHZ.
1846 * VALUE: Tx Power dalta value (MAX=4) 1853 * VALUE: Tx Power dalta value (MAX=4)
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index b66e0fd8f0fa..60039d3fe0a0 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1120,27 +1120,27 @@ static void rt2800_config_channel_rf2xxx(struct rt2x00_dev *rt2x00dev,
1120 * double meaning, and we should set a 7DBm boost flag. 1120 * double meaning, and we should set a 7DBm boost flag.
1121 */ 1121 */
1122 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST, 1122 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST,
1123 (info->tx_power1 >= 0)); 1123 (info->default_power1 >= 0));
1124 1124
1125 if (info->tx_power1 < 0) 1125 if (info->default_power1 < 0)
1126 info->tx_power1 += 7; 1126 info->default_power1 += 7;
1127 1127
1128 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A, 1128 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A,
1129 TXPOWER_A_TO_DEV(info->tx_power1)); 1129 TXPOWER_A_TO_DEV(info->default_power1));
1130 1130
1131 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST, 1131 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST,
1132 (info->tx_power2 >= 0)); 1132 (info->default_power2 >= 0));
1133 1133
1134 if (info->tx_power2 < 0) 1134 if (info->default_power2 < 0)
1135 info->tx_power2 += 7; 1135 info->default_power2 += 7;
1136 1136
1137 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A, 1137 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
1138 TXPOWER_A_TO_DEV(info->tx_power2)); 1138 TXPOWER_A_TO_DEV(info->default_power2));
1139 } else { 1139 } else {
1140 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G, 1140 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
1141 TXPOWER_G_TO_DEV(info->tx_power1)); 1141 TXPOWER_G_TO_DEV(info->default_power1));
1142 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G, 1142 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
1143 TXPOWER_G_TO_DEV(info->tx_power2)); 1143 TXPOWER_G_TO_DEV(info->default_power2));
1144 } 1144 }
1145 1145
1146 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf)); 1146 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
@@ -1180,13 +1180,11 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev,
1180 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr); 1180 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
1181 1181
1182 rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr); 1182 rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr);
1183 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, 1183 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, info->default_power1);
1184 TXPOWER_G_TO_DEV(info->tx_power1));
1185 rt2800_rfcsr_write(rt2x00dev, 12, rfcsr); 1184 rt2800_rfcsr_write(rt2x00dev, 12, rfcsr);
1186 1185
1187 rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr); 1186 rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr);
1188 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, 1187 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2);
1189 TXPOWER_G_TO_DEV(info->tx_power2));
1190 rt2800_rfcsr_write(rt2x00dev, 13, rfcsr); 1188 rt2800_rfcsr_write(rt2x00dev, 13, rfcsr);
1191 1189
1192 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); 1190 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
@@ -2516,6 +2514,13 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2516 default_lna_gain); 2514 default_lna_gain);
2517 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); 2515 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
2518 2516
2517 rt2x00_eeprom_read(rt2x00dev, EEPROM_MAX_TX_POWER, &word);
2518 if (rt2x00_get_field16(word, EEPROM_MAX_TX_POWER_24GHZ) == 0xff)
2519 rt2x00_set_field16(&word, EEPROM_MAX_TX_POWER_24GHZ, MAX_G_TXPOWER);
2520 if (rt2x00_get_field16(word, EEPROM_MAX_TX_POWER_5GHZ) == 0xff)
2521 rt2x00_set_field16(&word, EEPROM_MAX_TX_POWER_5GHZ, MAX_A_TXPOWER);
2522 rt2x00_eeprom_write(rt2x00dev, EEPROM_MAX_TX_POWER, word);
2523
2519 return 0; 2524 return 0;
2520} 2525}
2521EXPORT_SYMBOL_GPL(rt2800_validate_eeprom); 2526EXPORT_SYMBOL_GPL(rt2800_validate_eeprom);
@@ -2755,9 +2760,10 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2755{ 2760{
2756 struct hw_mode_spec *spec = &rt2x00dev->spec; 2761 struct hw_mode_spec *spec = &rt2x00dev->spec;
2757 struct channel_info *info; 2762 struct channel_info *info;
2758 char *tx_power1; 2763 char *default_power1;
2759 char *tx_power2; 2764 char *default_power2;
2760 unsigned int i; 2765 unsigned int i;
2766 unsigned short max_power;
2761 u16 eeprom; 2767 u16 eeprom;
2762 2768
2763 /* 2769 /*
@@ -2871,21 +2877,26 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2871 2877
2872 spec->channels_info = info; 2878 spec->channels_info = info;
2873 2879
2874 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); 2880 rt2x00_eeprom_read(rt2x00dev, EEPROM_MAX_TX_POWER, &eeprom);
2875 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); 2881 max_power = rt2x00_get_field16(eeprom, EEPROM_MAX_TX_POWER_24GHZ);
2882 default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
2883 default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
2876 2884
2877 for (i = 0; i < 14; i++) { 2885 for (i = 0; i < 14; i++) {
2878 info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]); 2886 info[i].max_power = max_power;
2879 info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]); 2887 info[i].default_power1 = TXPOWER_G_FROM_DEV(default_power1[i]);
2888 info[i].default_power2 = TXPOWER_G_FROM_DEV(default_power2[i]);
2880 } 2889 }
2881 2890
2882 if (spec->num_channels > 14) { 2891 if (spec->num_channels > 14) {
2883 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1); 2892 max_power = rt2x00_get_field16(eeprom, EEPROM_MAX_TX_POWER_5GHZ);
2884 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2); 2893 default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
2894 default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
2885 2895
2886 for (i = 14; i < spec->num_channels; i++) { 2896 for (i = 14; i < spec->num_channels; i++) {
2887 info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]); 2897 info[i].max_power = max_power;
2888 info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]); 2898 info[i].default_power1 = TXPOWER_A_FROM_DEV(default_power1[i]);
2899 info[i].default_power2 = TXPOWER_A_FROM_DEV(default_power2[i]);
2889 } 2900 }
2890 } 2901 }
2891 2902
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c21af38cc5af..6b2b92bfbc6b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -212,8 +212,9 @@ struct channel_info {
212 unsigned int flags; 212 unsigned int flags;
213#define GEOGRAPHY_ALLOWED 0x00000001 213#define GEOGRAPHY_ALLOWED 0x00000001
214 214
215 short tx_power1; 215 short max_power;
216 short tx_power2; 216 short default_power1;
217 short default_power2;
217}; 218};
218 219
219/* 220/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 585e8166f22a..19f86ce13df5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -710,7 +710,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
710 for (i = 0; i < spec->num_channels; i++) { 710 for (i = 0; i < spec->num_channels; i++) {
711 rt2x00lib_channel(&channels[i], 711 rt2x00lib_channel(&channels[i],
712 spec->channels[i].channel, 712 spec->channels[i].channel,
713 spec->channels_info[i].tx_power1, i); 713 spec->channels_info[i].max_power, i);
714 } 714 }
715 715
716 /* 716 /*
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index e539c6cb636f..73d6382663b4 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2661,13 +2661,17 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2661 spec->channels_info = info; 2661 spec->channels_info = info;
2662 2662
2663 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START); 2663 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START);
2664 for (i = 0; i < 14; i++) 2664 for (i = 0; i < 14; i++) {
2665 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 2665 info[i].max_power = MAX_TXPOWER;
2666 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2667 }
2666 2668
2667 if (spec->num_channels > 14) { 2669 if (spec->num_channels > 14) {
2668 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START); 2670 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START);
2669 for (i = 14; i < spec->num_channels; i++) 2671 for (i = 14; i < spec->num_channels; i++) {
2670 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 2672 info[i].max_power = MAX_TXPOWER;
2673 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2674 }
2671 } 2675 }
2672 2676
2673 return 0; 2677 return 0;
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index aa9de18fd410..c457d65f81a7 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2091,13 +2091,17 @@ static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2091 spec->channels_info = info; 2091 spec->channels_info = info;
2092 2092
2093 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START); 2093 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START);
2094 for (i = 0; i < 14; i++) 2094 for (i = 0; i < 14; i++) {
2095 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 2095 info[i].max_power = MAX_TXPOWER;
2096 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2097 }
2096 2098
2097 if (spec->num_channels > 14) { 2099 if (spec->num_channels > 14) {
2098 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START); 2100 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START);
2099 for (i = 14; i < spec->num_channels; i++) 2101 for (i = 14; i < spec->num_channels; i++) {
2100 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); 2102 info[i].max_power = MAX_TXPOWER;
2103 info[i].default_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2104 }
2101 } 2105 }
2102 2106
2103 return 0; 2107 return 0;
@@ -2391,6 +2395,7 @@ static struct usb_device_id rt73usb_device_table[] = {
2391 { USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) }, 2395 { USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) },
2392 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) }, 2396 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) },
2393 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) }, 2397 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) },
2398 { USB_DEVICE(0x0812, 0x3101), USB_DEVICE_DATA(&rt73usb_ops) },
2394 /* Qcom */ 2399 /* Qcom */
2395 { USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) }, 2400 { USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) },
2396 { USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) }, 2401 { USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index b50fedcef8ac..42dad59cadb0 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -66,8 +66,8 @@ struct netfront_cb {
66 66
67#define GRANT_INVALID_REF 0 67#define GRANT_INVALID_REF 0
68 68
69#define NET_TX_RING_SIZE __RING_SIZE((struct xen_netif_tx_sring *)0, PAGE_SIZE) 69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
70#define NET_RX_RING_SIZE __RING_SIZE((struct xen_netif_rx_sring *)0, PAGE_SIZE) 70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256) 71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
72 72
73struct netfront_info { 73struct netfront_info {