aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2011-07-15 10:05:24 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-07-15 10:05:24 -0400
commit95a943c162d74b20d869917bdf5df11293c35b63 (patch)
treec69d5cb97a4d97b6062a276ecdfa8582535193af /drivers
parentecae42d37045ec71831d0e0e493e00b0e0732edd (diff)
parent95acac61ba66c4abd40e038dae8c1ed2e176c7b1 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Conflicts: net/bluetooth/l2cap_core.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bcma/main.c4
-rw-r--r--drivers/bcma/sprom.c3
-rw-r--r--drivers/bluetooth/ath3k.c5
-rw-r--r--drivers/bluetooth/btusb.c12
-rw-r--r--drivers/net/wireless/ath/ath5k/ahb.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/ani.c9
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h167
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c24
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c71
-rw-r--r--drivers/net/wireless/ath/ath5k/base.h11
-rw-r--r--drivers/net/wireless/ath/ath5k/caps.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c207
-rw-r--r--drivers/net/wireless/ath/ath5k/desc.h4
-rw-r--r--drivers/net/wireless/ath/ath5k/dma.c8
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c46
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.h12
-rw-r--r--drivers/net/wireless/ath/ath5k/initvals.c14
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c8
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/pci.c14
-rw-r--r--drivers/net/wireless/ath/ath5k/pcu.c16
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c100
-rw-r--r--drivers/net/wireless/ath/ath5k/reg.h89
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c45
-rw-r--r--drivers/net/wireless/ath/ath5k/rfbuffer.h4
-rw-r--r--drivers/net/wireless/ath/ath5k/rfgain.h8
-rw-r--r--drivers/net/wireless/ath/ath5k/sysfs.c10
-rw-r--r--drivers/net/wireless/ath/ath5k/trace.h15
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_hw.c39
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_phy.c34
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mac.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_paprd.c30
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c94
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c50
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h5
-rw-r--r--drivers/net/wireless/ath/carl9170/main.c8
-rw-r--r--drivers/net/wireless/b43/Kconfig14
-rw-r--r--drivers/net/wireless/b43/Makefile1
-rw-r--r--drivers/net/wireless/b43/b43.h1
-rw-r--r--drivers/net/wireless/b43/bus.c129
-rw-r--r--drivers/net/wireless/b43/bus.h8
-rw-r--r--drivers/net/wireless/b43/dma.c9
-rw-r--r--drivers/net/wireless/b43/main.c361
-rw-r--r--drivers/net/wireless/b43/phy_common.c6
-rw-r--r--drivers/net/wireless/b43/phy_common.h3
-rw-r--r--drivers/net/wireless/b43/phy_ht.c12
-rw-r--r--drivers/net/wireless/b43/phy_lcn.c52
-rw-r--r--drivers/net/wireless/b43/phy_lcn.h14
-rw-r--r--drivers/net/wireless/b43/phy_n.c62
-rw-r--r--drivers/net/wireless/b43/tables_phy_lcn.c34
-rw-r--r--drivers/net/wireless/b43/tables_phy_lcn.h6
-rw-r--r--drivers/net/wireless/b43/xmit.c3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-tx.c3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl4965-base.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c41
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c30
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c115
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c162
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-sta.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c109
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c23
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h50
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h49
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c32
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c47
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sv-open.c51
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.c154
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h41
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c139
-rw-r--r--drivers/net/wireless/libertas/cmd.c46
-rw-r--r--drivers/net/wireless/libertas/cmd.h2
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c6
-rw-r--r--drivers/net/wireless/libertas/main.c12
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c56
-rw-r--r--drivers/net/wireless/mwifiex/debugfs.c2
-rw-r--r--drivers/net/wireless/mwifiex/decl.h4
-rw-r--r--drivers/net/wireless/mwifiex/fw.h11
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c10
-rw-r--r--drivers/net/wireless/mwifiex/sta_tx.c13
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/rf.c2
-rw-r--r--drivers/net/wireless/wl12xx/acx.c12
-rw-r--r--drivers/net/wireless/wl12xx/acx.h4
-rw-r--r--drivers/net/wireless/wl12xx/boot.c4
-rw-r--r--drivers/net/wireless/wl12xx/cmd.c6
-rw-r--r--drivers/net/wireless/wl12xx/conf.h10
-rw-r--r--drivers/net/wireless/wl12xx/debugfs.c15
-rw-r--r--drivers/net/wireless/wl12xx/event.c42
-rw-r--r--drivers/net/wireless/wl12xx/event.h12
-rw-r--r--drivers/net/wireless/wl12xx/init.c7
-rw-r--r--drivers/net/wireless/wl12xx/main.c202
-rw-r--r--drivers/net/wireless/wl12xx/ps.c9
-rw-r--r--drivers/net/wireless/wl12xx/scan.c27
-rw-r--r--drivers/net/wireless/wl12xx/scan.h1
-rw-r--r--drivers/net/wireless/wl12xx/sdio.c12
-rw-r--r--drivers/net/wireless/wl12xx/tx.c143
-rw-r--r--drivers/net/wireless/wl12xx/tx.h28
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h24
123 files changed, 2589 insertions, 1431 deletions
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 08a14a3d667e..873e2e4ac55f 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -149,7 +149,9 @@ int bcma_bus_register(struct bcma_bus *bus)
149 149
150 /* Try to get SPROM */ 150 /* Try to get SPROM */
151 err = bcma_sprom_get(bus); 151 err = bcma_sprom_get(bus);
152 if (err) { 152 if (err == -ENOENT) {
153 pr_err("No SPROM available\n");
154 } else if (err) {
153 pr_err("Failed to get SPROM: %d\n", err); 155 pr_err("Failed to get SPROM: %d\n", err);
154 return -ENOENT; 156 return -ENOENT;
155 } 157 }
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index ffbb0e32e921..8e8d5cf32e12 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -143,6 +143,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
143 if (!bus->drv_cc.core) 143 if (!bus->drv_cc.core)
144 return -EOPNOTSUPP; 144 return -EOPNOTSUPP;
145 145
146 if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
147 return -ENOENT;
148
146 sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), 149 sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
147 GFP_KERNEL); 150 GFP_KERNEL);
148 if (!sprom) 151 if (!sprom)
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6bacef368fab..a5854735bb2e 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -375,6 +375,11 @@ static int ath3k_probe(struct usb_interface *intf,
375 375
376 /* load patch and sysconfig files for AR3012 */ 376 /* load patch and sysconfig files for AR3012 */
377 if (id->driver_info & BTUSB_ATH3012) { 377 if (id->driver_info & BTUSB_ATH3012) {
378
379 /* New firmware with patch and sysconfig files already loaded */
380 if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
381 return -ENODEV;
382
378 ret = ath3k_load_patch(udev); 383 ret = ath3k_load_patch(udev);
379 if (ret < 0) { 384 if (ret < 0) {
380 BT_ERR("Loading patch file failed"); 385 BT_ERR("Loading patch file failed");
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c2de8951e3fb..91d13a9e8c65 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -54,6 +54,7 @@ static struct usb_driver btusb_driver;
54#define BTUSB_BCM92035 0x10 54#define BTUSB_BCM92035 0x10
55#define BTUSB_BROKEN_ISOC 0x20 55#define BTUSB_BROKEN_ISOC 0x20
56#define BTUSB_WRONG_SCO_MTU 0x40 56#define BTUSB_WRONG_SCO_MTU 0x40
57#define BTUSB_ATH3012 0x80
57 58
58static struct usb_device_id btusb_table[] = { 59static struct usb_device_id btusb_table[] = {
59 /* Generic Bluetooth USB device */ 60 /* Generic Bluetooth USB device */
@@ -110,7 +111,7 @@ static struct usb_device_id blacklist_table[] = {
110 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, 111 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
111 112
112 /* Atheros 3012 with sflash firmware */ 113 /* Atheros 3012 with sflash firmware */
113 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_IGNORE }, 114 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
114 115
115 /* Atheros AR5BBU12 with sflash firmware */ 116 /* Atheros AR5BBU12 with sflash firmware */
116 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 117 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
@@ -914,6 +915,15 @@ static int btusb_probe(struct usb_interface *intf,
914 if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) 915 if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
915 return -ENODEV; 916 return -ENODEV;
916 917
918 if (id->driver_info & BTUSB_ATH3012) {
919 struct usb_device *udev = interface_to_usbdev(intf);
920
921 /* Old firmware would otherwise let ath3k driver load
922 * patch and sysconfig files */
923 if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
924 return -ENODEV;
925 }
926
917 data = kzalloc(sizeof(*data), GFP_KERNEL); 927 data = kzalloc(sizeof(*data), GFP_KERNEL);
918 if (!data) 928 if (!data)
919 return -ENOMEM; 929 return -ENOMEM;
diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c
index c38e9e848995..ba682a0b2dd8 100644
--- a/drivers/net/wireless/ath/ath5k/ahb.c
+++ b/drivers/net/wireless/ath/ath5k/ahb.c
@@ -167,8 +167,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
167 * driver for it 167 * driver for it
168 */ 168 */
169 if (to_platform_device(sc->dev)->id == 0 && 169 if (to_platform_device(sc->dev)->id == 0 &&
170 (bcfg->config->flags & (BD_WLAN0|BD_WLAN1)) == 170 (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) ==
171 (BD_WLAN1|BD_WLAN0)) 171 (BD_WLAN1 | BD_WLAN0))
172 __set_bit(ATH_STAT_2G_DISABLED, sc->status); 172 __set_bit(ATH_STAT_2G_DISABLED, sc->status);
173 } 173 }
174 174
diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c
index f915f404302d..2f0b967a6d8e 100644
--- a/drivers/net/wireless/ath/ath5k/ani.c
+++ b/drivers/net/wireless/ath/ath5k/ani.c
@@ -74,7 +74,7 @@ ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level)
74 static const s8 fr[] = { -78, -80 }; 74 static const s8 fr[] = { -78, -80 };
75#endif 75#endif
76 if (level < 0 || level >= ARRAY_SIZE(sz)) { 76 if (level < 0 || level >= ARRAY_SIZE(sz)) {
77 ATH5K_ERR(ah->ah_sc, "noise immuniy level %d out of range", 77 ATH5K_ERR(ah->ah_sc, "noise immunity level %d out of range",
78 level); 78 level);
79 return; 79 return;
80 } 80 }
@@ -630,6 +630,11 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
630 if (ah->ah_version < AR5K_AR5212) 630 if (ah->ah_version < AR5K_AR5212)
631 return; 631 return;
632 632
633 if (mode < ATH5K_ANI_MODE_OFF || mode > ATH5K_ANI_MODE_AUTO) {
634 ATH5K_ERR(ah->ah_sc, "ANI mode %d out of range", mode);
635 return;
636 }
637
633 /* clear old state information */ 638 /* clear old state information */
634 memset(&ah->ah_sc->ani_state, 0, sizeof(ah->ah_sc->ani_state)); 639 memset(&ah->ah_sc->ani_state, 0, sizeof(ah->ah_sc->ani_state));
635 640
@@ -642,7 +647,7 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
642 /* initial values for our ani parameters */ 647 /* initial values for our ani parameters */
643 if (mode == ATH5K_ANI_MODE_OFF) { 648 if (mode == ATH5K_ANI_MODE_OFF) {
644 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "ANI off\n"); 649 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "ANI off\n");
645 } else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) { 650 } else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) {
646 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 651 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI,
647 "ANI manual low -> high sensitivity\n"); 652 "ANI manual low -> high sensitivity\n");
648 ath5k_ani_set_noise_immunity_level(ah, 0); 653 ath5k_ani_set_noise_immunity_level(ah, 0);
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index c4c02d5145c2..8ff17941bb28 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -18,9 +18,9 @@
18#ifndef _ATH5K_H 18#ifndef _ATH5K_H
19#define _ATH5K_H 19#define _ATH5K_H
20 20
21/* TODO: Clean up channel debuging -doesn't work anyway- and start 21/* TODO: Clean up channel debugging (doesn't work anyway) and start
22 * working on reg. control code using all available eeprom information 22 * working on reg. control code using all available eeprom information
23 * -rev. engineering needed- */ 23 * (rev. engineering needed) */
24#define CHAN_DEBUG 0 24#define CHAN_DEBUG 0
25 25
26#include <linux/io.h> 26#include <linux/io.h>
@@ -39,40 +39,41 @@
39#include "../ath.h" 39#include "../ath.h"
40 40
41/* PCI IDs */ 41/* PCI IDs */
42#define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */ 42#define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */
43#define PCI_DEVICE_ID_ATHEROS_AR5311 0x0011 /* AR5311 */ 43#define PCI_DEVICE_ID_ATHEROS_AR5311 0x0011 /* AR5311 */
44#define PCI_DEVICE_ID_ATHEROS_AR5211 0x0012 /* AR5211 */ 44#define PCI_DEVICE_ID_ATHEROS_AR5211 0x0012 /* AR5211 */
45#define PCI_DEVICE_ID_ATHEROS_AR5212 0x0013 /* AR5212 */ 45#define PCI_DEVICE_ID_ATHEROS_AR5212 0x0013 /* AR5212 */
46#define PCI_DEVICE_ID_3COM_3CRDAG675 0x0013 /* 3CRDAG675 (Atheros AR5212) */ 46#define PCI_DEVICE_ID_3COM_3CRDAG675 0x0013 /* 3CRDAG675 (Atheros AR5212) */
47#define PCI_DEVICE_ID_3COM_2_3CRPAG175 0x0013 /* 3CRPAG175 (Atheros AR5212) */ 47#define PCI_DEVICE_ID_3COM_2_3CRPAG175 0x0013 /* 3CRPAG175 (Atheros AR5212) */
48#define PCI_DEVICE_ID_ATHEROS_AR5210_AP 0x0207 /* AR5210 (Early) */ 48#define PCI_DEVICE_ID_ATHEROS_AR5210_AP 0x0207 /* AR5210 (Early) */
49#define PCI_DEVICE_ID_ATHEROS_AR5212_IBM 0x1014 /* AR5212 (IBM MiniPCI) */ 49#define PCI_DEVICE_ID_ATHEROS_AR5212_IBM 0x1014 /* AR5212 (IBM MiniPCI) */
50#define PCI_DEVICE_ID_ATHEROS_AR5210_DEFAULT 0x1107 /* AR5210 (no eeprom) */ 50#define PCI_DEVICE_ID_ATHEROS_AR5210_DEFAULT 0x1107 /* AR5210 (no eeprom) */
51#define PCI_DEVICE_ID_ATHEROS_AR5212_DEFAULT 0x1113 /* AR5212 (no eeprom) */ 51#define PCI_DEVICE_ID_ATHEROS_AR5212_DEFAULT 0x1113 /* AR5212 (no eeprom) */
52#define PCI_DEVICE_ID_ATHEROS_AR5211_DEFAULT 0x1112 /* AR5211 (no eeprom) */ 52#define PCI_DEVICE_ID_ATHEROS_AR5211_DEFAULT 0x1112 /* AR5211 (no eeprom) */
53#define PCI_DEVICE_ID_ATHEROS_AR5212_FPGA 0xf013 /* AR5212 (emulation board) */ 53#define PCI_DEVICE_ID_ATHEROS_AR5212_FPGA 0xf013 /* AR5212 (emulation board) */
54#define PCI_DEVICE_ID_ATHEROS_AR5211_LEGACY 0xff12 /* AR5211 (emulation board) */ 54#define PCI_DEVICE_ID_ATHEROS_AR5211_LEGACY 0xff12 /* AR5211 (emulation board) */
55#define PCI_DEVICE_ID_ATHEROS_AR5211_FPGA11B 0xf11b /* AR5211 (emulation board) */ 55#define PCI_DEVICE_ID_ATHEROS_AR5211_FPGA11B 0xf11b /* AR5211 (emulation board) */
56#define PCI_DEVICE_ID_ATHEROS_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */ 56#define PCI_DEVICE_ID_ATHEROS_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
57#define PCI_DEVICE_ID_ATHEROS_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */ 57#define PCI_DEVICE_ID_ATHEROS_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
58#define PCI_DEVICE_ID_ATHEROS_AR5312_REV8 0x0058 /* AR5312 WMAC (AP43-030) */ 58#define PCI_DEVICE_ID_ATHEROS_AR5312_REV8 0x0058 /* AR5312 WMAC (AP43-030) */
59#define PCI_DEVICE_ID_ATHEROS_AR5212_0014 0x0014 /* AR5212 compatible */ 59#define PCI_DEVICE_ID_ATHEROS_AR5212_0014 0x0014 /* AR5212 compatible */
60#define PCI_DEVICE_ID_ATHEROS_AR5212_0015 0x0015 /* AR5212 compatible */ 60#define PCI_DEVICE_ID_ATHEROS_AR5212_0015 0x0015 /* AR5212 compatible */
61#define PCI_DEVICE_ID_ATHEROS_AR5212_0016 0x0016 /* AR5212 compatible */ 61#define PCI_DEVICE_ID_ATHEROS_AR5212_0016 0x0016 /* AR5212 compatible */
62#define PCI_DEVICE_ID_ATHEROS_AR5212_0017 0x0017 /* AR5212 compatible */ 62#define PCI_DEVICE_ID_ATHEROS_AR5212_0017 0x0017 /* AR5212 compatible */
63#define PCI_DEVICE_ID_ATHEROS_AR5212_0018 0x0018 /* AR5212 compatible */ 63#define PCI_DEVICE_ID_ATHEROS_AR5212_0018 0x0018 /* AR5212 compatible */
64#define PCI_DEVICE_ID_ATHEROS_AR5212_0019 0x0019 /* AR5212 compatible */ 64#define PCI_DEVICE_ID_ATHEROS_AR5212_0019 0x0019 /* AR5212 compatible */
65#define PCI_DEVICE_ID_ATHEROS_AR2413 0x001a /* AR2413 (Griffin-lite) */ 65#define PCI_DEVICE_ID_ATHEROS_AR2413 0x001a /* AR2413 (Griffin-lite) */
66#define PCI_DEVICE_ID_ATHEROS_AR5413 0x001b /* AR5413 (Eagle) */ 66#define PCI_DEVICE_ID_ATHEROS_AR5413 0x001b /* AR5413 (Eagle) */
67#define PCI_DEVICE_ID_ATHEROS_AR5424 0x001c /* AR5424 (Condor PCI-E) */ 67#define PCI_DEVICE_ID_ATHEROS_AR5424 0x001c /* AR5424 (Condor PCI-E) */
68#define PCI_DEVICE_ID_ATHEROS_AR5416 0x0023 /* AR5416 */ 68#define PCI_DEVICE_ID_ATHEROS_AR5416 0x0023 /* AR5416 */
69#define PCI_DEVICE_ID_ATHEROS_AR5418 0x0024 /* AR5418 */ 69#define PCI_DEVICE_ID_ATHEROS_AR5418 0x0024 /* AR5418 */
70 70
71/****************************\ 71/****************************\
72 GENERIC DRIVER DEFINITIONS 72 GENERIC DRIVER DEFINITIONS
73\****************************/ 73\****************************/
74 74
75#define ATH5K_PRINTF(fmt, ...) printk("%s: " fmt, __func__, ##__VA_ARGS__) 75#define ATH5K_PRINTF(fmt, ...) \
76 printk(KERN_WARNING "%s: " fmt, __func__, ##__VA_ARGS__)
76 77
77#define ATH5K_PRINTK(_sc, _level, _fmt, ...) \ 78#define ATH5K_PRINTK(_sc, _level, _fmt, ...) \
78 printk(_level "ath5k %s: " _fmt, \ 79 printk(_level "ath5k %s: " _fmt, \
@@ -155,7 +156,7 @@
155} while (0) 156} while (0)
156 157
157/* 158/*
158 * Some tuneable values (these should be changeable by the user) 159 * Some tunable values (these should be changeable by the user)
159 * TODO: Make use of them and add more options OR use debug/configfs 160 * TODO: Make use of them and add more options OR use debug/configfs
160 */ 161 */
161#define AR5K_TUNE_DMA_BEACON_RESP 2 162#define AR5K_TUNE_DMA_BEACON_RESP 2
@@ -170,8 +171,8 @@
170#define AR5K_TUNE_RSSI_THRES 129 171#define AR5K_TUNE_RSSI_THRES 129
171/* This must be set when setting the RSSI threshold otherwise it can 172/* This must be set when setting the RSSI threshold otherwise it can
172 * prevent a reset. If AR5K_RSSI_THR is read after writing to it 173 * prevent a reset. If AR5K_RSSI_THR is read after writing to it
173 * the BMISS_THRES will be seen as 0, seems harware doesn't keep 174 * the BMISS_THRES will be seen as 0, seems hardware doesn't keep
174 * track of it. Max value depends on harware. For AR5210 this is just 7. 175 * track of it. Max value depends on hardware. For AR5210 this is just 7.
175 * For AR5211+ this seems to be up to 255. */ 176 * For AR5211+ this seems to be up to 255. */
176#define AR5K_TUNE_BMISS_THRES 7 177#define AR5K_TUNE_BMISS_THRES 7
177#define AR5K_TUNE_REGISTER_DWELL_TIME 20000 178#define AR5K_TUNE_REGISTER_DWELL_TIME 20000
@@ -361,7 +362,7 @@ struct ath5k_srev_name {
361/* 362/*
362 * Some of this information is based on Documentation from: 363 * Some of this information is based on Documentation from:
363 * 364 *
364 * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG 365 * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG
365 * 366 *
366 * Modulation for Atheros' eXtended Range - range enhancing extension that is 367 * Modulation for Atheros' eXtended Range - range enhancing extension that is
367 * supposed to double the distance an Atheros client device can keep a 368 * supposed to double the distance an Atheros client device can keep a
@@ -374,12 +375,12 @@ struct ath5k_srev_name {
374 * they are exclusive. 375 * they are exclusive.
375 * 376 *
376 */ 377 */
377#define MODULATION_XR 0x00000200 378#define MODULATION_XR 0x00000200
378/* 379/*
379 * Modulation for Atheros' Turbo G and Turbo A, its supposed to provide a 380 * Modulation for Atheros' Turbo G and Turbo A, its supposed to provide a
380 * throughput transmission speed up to 40Mbit/s-60Mbit/s at a 108Mbit/s 381 * throughput transmission speed up to 40Mbit/s-60Mbit/s at a 108Mbit/s
381 * signaling rate achieved through the bonding of two 54Mbit/s 802.11g 382 * signaling rate achieved through the bonding of two 54Mbit/s 802.11g
382 * channels. To use this feature your Access Point must also suport it. 383 * channels. To use this feature your Access Point must also support it.
383 * There is also a distinction between "static" and "dynamic" turbo modes: 384 * There is also a distinction between "static" and "dynamic" turbo modes:
384 * 385 *
385 * - Static: is the dumb version: devices set to this mode stick to it until 386 * - Static: is the dumb version: devices set to this mode stick to it until
@@ -495,9 +496,9 @@ enum ath5k_tx_queue {
495 */ 496 */
496enum ath5k_tx_queue_subtype { 497enum ath5k_tx_queue_subtype {
497 AR5K_WME_AC_BK = 0, /*Background traffic*/ 498 AR5K_WME_AC_BK = 0, /*Background traffic*/
498 AR5K_WME_AC_BE, /*Best-effort (normal) traffic)*/ 499 AR5K_WME_AC_BE, /*Best-effort (normal) traffic*/
499 AR5K_WME_AC_VI, /*Video traffic*/ 500 AR5K_WME_AC_VI, /*Video traffic*/
500 AR5K_WME_AC_VO, /*Voice traffic*/ 501 AR5K_WME_AC_VO, /*Voice traffic*/
501}; 502};
502 503
503/* 504/*
@@ -616,8 +617,8 @@ struct ath5k_rx_status {
616#define AR5K_RXERR_FIFO 0x04 617#define AR5K_RXERR_FIFO 0x04
617#define AR5K_RXERR_DECRYPT 0x08 618#define AR5K_RXERR_DECRYPT 0x08
618#define AR5K_RXERR_MIC 0x10 619#define AR5K_RXERR_MIC 0x10
619#define AR5K_RXKEYIX_INVALID ((u8) - 1) 620#define AR5K_RXKEYIX_INVALID ((u8) -1)
620#define AR5K_TXKEYIX_INVALID ((u32) - 1) 621#define AR5K_TXKEYIX_INVALID ((u32) -1)
621 622
622 623
623/**************************\ 624/**************************\
@@ -678,17 +679,18 @@ struct ath5k_gain {
678#define CHANNEL_DYN 0x0400 /* Dynamic CCK-OFDM channel (for g operation) */ 679#define CHANNEL_DYN 0x0400 /* Dynamic CCK-OFDM channel (for g operation) */
679#define CHANNEL_XR 0x0800 /* XR channel */ 680#define CHANNEL_XR 0x0800 /* XR channel */
680 681
681#define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM) 682#define CHANNEL_A (CHANNEL_5GHZ | CHANNEL_OFDM)
682#define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK) 683#define CHANNEL_B (CHANNEL_2GHZ | CHANNEL_CCK)
683#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM) 684#define CHANNEL_G (CHANNEL_2GHZ | CHANNEL_OFDM)
684#define CHANNEL_X (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_XR) 685#define CHANNEL_X (CHANNEL_5GHZ | CHANNEL_OFDM | CHANNEL_XR)
685 686
686#define CHANNEL_ALL (CHANNEL_OFDM|CHANNEL_CCK|CHANNEL_2GHZ|CHANNEL_5GHZ) 687#define CHANNEL_ALL (CHANNEL_OFDM | CHANNEL_CCK | \
688 CHANNEL_2GHZ | CHANNEL_5GHZ)
687 689
688#define CHANNEL_MODES CHANNEL_ALL 690#define CHANNEL_MODES CHANNEL_ALL
689 691
690/* 692/*
691 * Used internaly for reset_tx_queue). 693 * Used internally for ath5k_hw_reset_tx_queue().
692 * Also see struct struct ieee80211_channel. 694 * Also see struct struct ieee80211_channel.
693 */ 695 */
694#define IS_CHAN_XR(_c) ((_c->hw_value & CHANNEL_XR) != 0) 696#define IS_CHAN_XR(_c) ((_c->hw_value & CHANNEL_XR) != 0)
@@ -710,7 +712,7 @@ struct ath5k_athchan_2ghz {
710\******************/ 712\******************/
711 713
712/** 714/**
713 * Seems the ar5xxx harware supports up to 32 rates, indexed by 1-32. 715 * Seems the ar5xxx hardware supports up to 32 rates, indexed by 1-32.
714 * 716 *
715 * The rate code is used to get the RX rate or set the TX rate on the 717 * The rate code is used to get the RX rate or set the TX rate on the
716 * hardware descriptors. It is also used for internal modulation control 718 * hardware descriptors. It is also used for internal modulation control
@@ -776,11 +778,11 @@ extern int ath5k_modparam_nohwcrypt;
776/* 778/*
777 * Misc definitions 779 * Misc definitions
778 */ 780 */
779#define AR5K_RSSI_EP_MULTIPLIER (1<<7) 781#define AR5K_RSSI_EP_MULTIPLIER (1 << 7)
780 782
781#define AR5K_ASSERT_ENTRY(_e, _s) do { \ 783#define AR5K_ASSERT_ENTRY(_e, _s) do { \
782 if (_e >= _s) \ 784 if (_e >= _s) \
783 return (false); \ 785 return false; \
784} while (0) 786} while (0)
785 787
786/* 788/*
@@ -791,52 +793,52 @@ extern int ath5k_modparam_nohwcrypt;
791 * enum ath5k_int - Hardware interrupt masks helpers 793 * enum ath5k_int - Hardware interrupt masks helpers
792 * 794 *
793 * @AR5K_INT_RX: mask to identify received frame interrupts, of type 795 * @AR5K_INT_RX: mask to identify received frame interrupts, of type
794 * AR5K_ISR_RXOK or AR5K_ISR_RXERR 796 * AR5K_ISR_RXOK or AR5K_ISR_RXERR
795 * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor (?) 797 * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor (?)
796 * @AR5K_INT_RXNOFRM: No frame received (?) 798 * @AR5K_INT_RXNOFRM: No frame received (?)
797 * @AR5K_INT_RXEOL: received End Of List for VEOL (Virtual End Of List). The 799 * @AR5K_INT_RXEOL: received End Of List for VEOL (Virtual End Of List). The
798 * Queue Control Unit (QCU) signals an EOL interrupt only if a descriptor's 800 * Queue Control Unit (QCU) signals an EOL interrupt only if a descriptor's
799 * LinkPtr is NULL. For more details, refer to: 801 * LinkPtr is NULL. For more details, refer to:
800 * http://www.freepatentsonline.com/20030225739.html 802 * http://www.freepatentsonline.com/20030225739.html
801 * @AR5K_INT_RXORN: Indicates we got RX overrun (eg. no more descriptors). 803 * @AR5K_INT_RXORN: Indicates we got RX overrun (eg. no more descriptors).
802 * Note that Rx overrun is not always fatal, on some chips we can continue 804 * Note that Rx overrun is not always fatal, on some chips we can continue
803 * operation without reseting the card, that's why int_fatal is not 805 * operation without resetting the card, that's why int_fatal is not
804 * common for all chips. 806 * common for all chips.
805 * @AR5K_INT_TX: mask to identify received frame interrupts, of type 807 * @AR5K_INT_TX: mask to identify received frame interrupts, of type
806 * AR5K_ISR_TXOK or AR5K_ISR_TXERR 808 * AR5K_ISR_TXOK or AR5K_ISR_TXERR
807 * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor (?) 809 * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor (?)
808 * @AR5K_INT_TXURN: received when we should increase the TX trigger threshold 810 * @AR5K_INT_TXURN: received when we should increase the TX trigger threshold
809 * We currently do increments on interrupt by 811 * We currently do increments on interrupt by
810 * (AR5K_TUNE_MAX_TX_FIFO_THRES - current_trigger_level) / 2 812 * (AR5K_TUNE_MAX_TX_FIFO_THRES - current_trigger_level) / 2
811 * @AR5K_INT_MIB: Indicates the either Management Information Base counters or 813 * @AR5K_INT_MIB: Indicates the either Management Information Base counters or
812 * one of the PHY error counters reached the maximum value and should be 814 * one of the PHY error counters reached the maximum value and should be
813 * read and cleared. 815 * read and cleared.
814 * @AR5K_INT_RXPHY: RX PHY Error 816 * @AR5K_INT_RXPHY: RX PHY Error
815 * @AR5K_INT_RXKCM: RX Key cache miss 817 * @AR5K_INT_RXKCM: RX Key cache miss
816 * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a 818 * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a
817 * beacon that must be handled in software. The alternative is if you 819 * beacon that must be handled in software. The alternative is if you
818 * have VEOL support, in that case you let the hardware deal with things. 820 * have VEOL support, in that case you let the hardware deal with things.
819 * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing 821 * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing
820 * beacons from the AP have associated with, we should probably try to 822 * beacons from the AP have associated with, we should probably try to
821 * reassociate. When in IBSS mode this might mean we have not received 823 * reassociate. When in IBSS mode this might mean we have not received
822 * any beacons from any local stations. Note that every station in an 824 * any beacons from any local stations. Note that every station in an
823 * IBSS schedules to send beacons at the Target Beacon Transmission Time 825 * IBSS schedules to send beacons at the Target Beacon Transmission Time
824 * (TBTT) with a random backoff. 826 * (TBTT) with a random backoff.
825 * @AR5K_INT_BNR: Beacon Not Ready interrupt - ?? 827 * @AR5K_INT_BNR: Beacon Not Ready interrupt - ??
826 * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill, disabled for now 828 * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill, disabled for now
827 * until properly handled 829 * until properly handled
828 * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA 830 * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA
829 * errors. These types of errors we can enable seem to be of type 831 * errors. These types of errors we can enable seem to be of type
830 * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR. 832 * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR.
831 * @AR5K_INT_GLOBAL: Used to clear and set the IER 833 * @AR5K_INT_GLOBAL: Used to clear and set the IER
832 * @AR5K_INT_NOCARD: signals the card has been removed 834 * @AR5K_INT_NOCARD: signals the card has been removed
833 * @AR5K_INT_COMMON: common interrupts shared amogst MACs with the same 835 * @AR5K_INT_COMMON: common interrupts shared among MACs with the same
834 * bit value 836 * bit value
835 * 837 *
836 * These are mapped to take advantage of some common bits 838 * These are mapped to take advantage of some common bits
837 * between the MACs, to be able to set intr properties 839 * between the MACs, to be able to set intr properties
838 * easier. Some of them are not used yet inside hw.c. Most map 840 * easier. Some of them are not used yet inside hw.c. Most map
839 * to the respective hw interrupt value as they are common amogst different 841 * to the respective hw interrupt value as they are common among different
840 * MACs. 842 * MACs.
841 */ 843 */
842enum ath5k_int { 844enum ath5k_int {
@@ -968,9 +970,9 @@ enum ath5k_capability_type {
968 AR5K_CAP_MCAST_KEYSRCH = 14, /* Supports multicast key search */ 970 AR5K_CAP_MCAST_KEYSRCH = 14, /* Supports multicast key search */
969 AR5K_CAP_TSF_ADJUST = 15, /* Supports beacon tsf adjust */ 971 AR5K_CAP_TSF_ADJUST = 15, /* Supports beacon tsf adjust */
970 AR5K_CAP_XR = 16, /* Supports XR mode */ 972 AR5K_CAP_XR = 16, /* Supports XR mode */
971 AR5K_CAP_WME_TKIPMIC = 17, /* Supports TKIP MIC when using WMM */ 973 AR5K_CAP_WME_TKIPMIC = 17, /* Supports TKIP MIC when using WMM */
972 AR5K_CAP_CHAN_HALFRATE = 18, /* Supports half rate channels */ 974 AR5K_CAP_CHAN_HALFRATE = 18, /* Supports half rate channels */
973 AR5K_CAP_CHAN_QUARTERRATE = 19, /* Supports quarter rate channels */ 975 AR5K_CAP_CHAN_QUARTERRATE = 19, /* Supports quarter rate channels */
974 AR5K_CAP_RFSILENT = 20, /* Supports RFsilent */ 976 AR5K_CAP_RFSILENT = 20, /* Supports RFsilent */
975}; 977};
976 978
@@ -1010,8 +1012,7 @@ struct ath5k_capabilities {
1010 1012
1011/* size of noise floor history (keep it a power of two) */ 1013/* size of noise floor history (keep it a power of two) */
1012#define ATH5K_NF_CAL_HIST_MAX 8 1014#define ATH5K_NF_CAL_HIST_MAX 8
1013struct ath5k_nfcal_hist 1015struct ath5k_nfcal_hist {
1014{
1015 s16 index; /* current index into nfval */ 1016 s16 index; /* current index into nfval */
1016 s16 nfval[ATH5K_NF_CAL_HIST_MAX]; /* last few noise floors */ 1017 s16 nfval[ATH5K_NF_CAL_HIST_MAX]; /* last few noise floors */
1017}; 1018};
@@ -1066,6 +1067,8 @@ struct ath5k_hw {
1066 u8 ah_retry_long; 1067 u8 ah_retry_long;
1067 u8 ah_retry_short; 1068 u8 ah_retry_short;
1068 1069
1070 u32 ah_use_32khz_clock;
1071
1069 u8 ah_coverage_class; 1072 u8 ah_coverage_class;
1070 bool ah_ack_bitrate_high; 1073 bool ah_ack_bitrate_high;
1071 u8 ah_bwmode; 1074 u8 ah_bwmode;
@@ -1357,17 +1360,17 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
1357 u8 mode, bool fast); 1360 u8 mode, bool fast);
1358 1361
1359/* 1362/*
1360 * Functions used internaly 1363 * Functions used internally
1361 */ 1364 */
1362 1365
1363static inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah) 1366static inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah)
1364{ 1367{
1365 return &ah->common; 1368 return &ah->common;
1366} 1369}
1367 1370
1368static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah) 1371static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)
1369{ 1372{
1370 return &(ath5k_hw_common(ah)->regulatory); 1373 return &(ath5k_hw_common(ah)->regulatory);
1371} 1374}
1372 1375
1373#ifdef CONFIG_ATHEROS_AR231X 1376#ifdef CONFIG_ATHEROS_AR231X
@@ -1378,7 +1381,7 @@ static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
1378 /* On AR2315 and AR2317 the PCI clock domain registers 1381 /* On AR2315 and AR2317 the PCI clock domain registers
1379 * are outside of the WMAC register space */ 1382 * are outside of the WMAC register space */
1380 if (unlikely((reg >= 0x4000) && (reg < 0x5000) && 1383 if (unlikely((reg >= 0x4000) && (reg < 0x5000) &&
1381 (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6))) 1384 (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
1382 return AR5K_AR2315_PCI_BASE + reg; 1385 return AR5K_AR2315_PCI_BASE + reg;
1383 1386
1384 return ah->ah_iobase + reg; 1387 return ah->ah_iobase + reg;
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 1588401de3c4..14dc52e4b50a 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -104,6 +104,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah)
104 */ 104 */
105int ath5k_hw_init(struct ath5k_softc *sc) 105int ath5k_hw_init(struct ath5k_softc *sc)
106{ 106{
107 static const u8 zero_mac[ETH_ALEN] = { };
107 struct ath5k_hw *ah = sc->ah; 108 struct ath5k_hw *ah = sc->ah;
108 struct ath_common *common = ath5k_hw_common(ah); 109 struct ath_common *common = ath5k_hw_common(ah);
109 struct pci_dev *pdev = sc->pdev; 110 struct pci_dev *pdev = sc->pdev;
@@ -191,7 +192,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
191 break; 192 break;
192 case AR5K_SREV_RAD_5424: 193 case AR5K_SREV_RAD_5424:
193 if (ah->ah_mac_version == AR5K_SREV_AR2425 || 194 if (ah->ah_mac_version == AR5K_SREV_AR2425 ||
194 ah->ah_mac_version == AR5K_SREV_AR2417){ 195 ah->ah_mac_version == AR5K_SREV_AR2417) {
195 ah->ah_radio = AR5K_RF2425; 196 ah->ah_radio = AR5K_RF2425;
196 ah->ah_single_chip = true; 197 ah->ah_single_chip = true;
197 } else { 198 } else {
@@ -210,28 +211,28 @@ int ath5k_hw_init(struct ath5k_softc *sc)
210 ah->ah_radio_2ghz_revision = ath5k_hw_radio_revision(ah, 211 ah->ah_radio_2ghz_revision = ath5k_hw_radio_revision(ah,
211 CHANNEL_2GHZ); 212 CHANNEL_2GHZ);
212 } else if (ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4) || 213 } else if (ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4) ||
213 ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4) || 214 ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4) ||
214 ah->ah_phy_revision == AR5K_SREV_PHY_2425) { 215 ah->ah_phy_revision == AR5K_SREV_PHY_2425) {
215 ah->ah_radio = AR5K_RF2425; 216 ah->ah_radio = AR5K_RF2425;
216 ah->ah_single_chip = true; 217 ah->ah_single_chip = true;
217 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2425; 218 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2425;
218 } else if (srev == AR5K_SREV_AR5213A && 219 } else if (srev == AR5K_SREV_AR5213A &&
219 ah->ah_phy_revision == AR5K_SREV_PHY_5212B) { 220 ah->ah_phy_revision == AR5K_SREV_PHY_5212B) {
220 ah->ah_radio = AR5K_RF5112; 221 ah->ah_radio = AR5K_RF5112;
221 ah->ah_single_chip = false; 222 ah->ah_single_chip = false;
222 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5112B; 223 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5112B;
223 } else if (ah->ah_mac_version == (AR5K_SREV_AR2415 >> 4) || 224 } else if (ah->ah_mac_version == (AR5K_SREV_AR2415 >> 4) ||
224 ah->ah_mac_version == (AR5K_SREV_AR2315_R6 >> 4)) { 225 ah->ah_mac_version == (AR5K_SREV_AR2315_R6 >> 4)) {
225 ah->ah_radio = AR5K_RF2316; 226 ah->ah_radio = AR5K_RF2316;
226 ah->ah_single_chip = true; 227 ah->ah_single_chip = true;
227 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2316; 228 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2316;
228 } else if (ah->ah_mac_version == (AR5K_SREV_AR5414 >> 4) || 229 } else if (ah->ah_mac_version == (AR5K_SREV_AR5414 >> 4) ||
229 ah->ah_phy_revision == AR5K_SREV_PHY_5413) { 230 ah->ah_phy_revision == AR5K_SREV_PHY_5413) {
230 ah->ah_radio = AR5K_RF5413; 231 ah->ah_radio = AR5K_RF5413;
231 ah->ah_single_chip = true; 232 ah->ah_single_chip = true;
232 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5413; 233 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5413;
233 } else if (ah->ah_mac_version == (AR5K_SREV_AR2414 >> 4) || 234 } else if (ah->ah_mac_version == (AR5K_SREV_AR2414 >> 4) ||
234 ah->ah_phy_revision == AR5K_SREV_PHY_2413) { 235 ah->ah_phy_revision == AR5K_SREV_PHY_2413) {
235 ah->ah_radio = AR5K_RF2413; 236 ah->ah_radio = AR5K_RF2413;
236 ah->ah_single_chip = true; 237 ah->ah_single_chip = true;
237 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2413; 238 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2413;
@@ -243,9 +244,8 @@ int ath5k_hw_init(struct ath5k_softc *sc)
243 } 244 }
244 245
245 246
246 /* Return on unsuported chips (unsupported eeprom etc) */ 247 /* Return on unsupported chips (unsupported eeprom etc) */
247 if ((srev >= AR5K_SREV_AR5416) && 248 if ((srev >= AR5K_SREV_AR5416) && (srev < AR5K_SREV_AR2425)) {
248 (srev < AR5K_SREV_AR2425)) {
249 ATH5K_ERR(sc, "Device not yet supported.\n"); 249 ATH5K_ERR(sc, "Device not yet supported.\n");
250 ret = -ENODEV; 250 ret = -ENODEV;
251 goto err; 251 goto err;
@@ -285,7 +285,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
285 ath5k_hw_reg_write(ah, 0x28000039, AR5K_PCIE_SERDES); 285 ath5k_hw_reg_write(ah, 0x28000039, AR5K_PCIE_SERDES);
286 ath5k_hw_reg_write(ah, 0x53160824, AR5K_PCIE_SERDES); 286 ath5k_hw_reg_write(ah, 0x53160824, AR5K_PCIE_SERDES);
287 287
288 /* If serdes programing is enabled, increase PCI-E 288 /* If serdes programming is enabled, increase PCI-E
289 * tx power for systems with long trace from host 289 * tx power for systems with long trace from host
290 * to minicard connector. */ 290 * to minicard connector. */
291 if (ee->ee_serdes) 291 if (ee->ee_serdes)
@@ -334,7 +334,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
334 } 334 }
335 335
336 /* MAC address is cleared until add_interface */ 336 /* MAC address is cleared until add_interface */
337 ath5k_hw_set_lladdr(ah, (u8[ETH_ALEN]){}); 337 ath5k_hw_set_lladdr(ah, zero_mac);
338 338
339 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */ 339 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
340 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN); 340 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN);
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index fb05bf89b8e3..dce848f76d7c 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -532,7 +532,7 @@ ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc,
532 if (iter_data.n_stas > 1) { 532 if (iter_data.n_stas > 1) {
533 /* If you have multiple STA interfaces connected to 533 /* If you have multiple STA interfaces connected to
534 * different APs, ARPs are not received (most of the time?) 534 * different APs, ARPs are not received (most of the time?)
535 * Enabling PROMISC appears to fix that probem. 535 * Enabling PROMISC appears to fix that problem.
536 */ 536 */
537 sc->filter_flags |= AR5K_RX_FILTER_PROM; 537 sc->filter_flags |= AR5K_RX_FILTER_PROM;
538 } 538 }
@@ -815,8 +815,7 @@ ath5k_desc_alloc(struct ath5k_softc *sc)
815 815
816 INIT_LIST_HEAD(&sc->txbuf); 816 INIT_LIST_HEAD(&sc->txbuf);
817 sc->txbuf_len = ATH_TXBUF; 817 sc->txbuf_len = ATH_TXBUF;
818 for (i = 0; i < ATH_TXBUF; i++, bf++, ds++, 818 for (i = 0; i < ATH_TXBUF; i++, bf++, ds++, da += sizeof(*ds)) {
819 da += sizeof(*ds)) {
820 bf->desc = ds; 819 bf->desc = ds;
821 bf->daddr = da; 820 bf->daddr = da;
822 list_add_tail(&bf->list, &sc->txbuf); 821 list_add_tail(&bf->list, &sc->txbuf);
@@ -982,7 +981,7 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
982 goto err; 981 goto err;
983 982
984 if (sc->opmode == NL80211_IFTYPE_AP || 983 if (sc->opmode == NL80211_IFTYPE_AP ||
985 sc->opmode == NL80211_IFTYPE_MESH_POINT) { 984 sc->opmode == NL80211_IFTYPE_MESH_POINT) {
986 /* 985 /*
987 * Always burst out beacon and CAB traffic 986 * Always burst out beacon and CAB traffic
988 * (aifs = cwmin = cwmax = 0) 987 * (aifs = cwmin = cwmax = 0)
@@ -1262,16 +1261,15 @@ ath5k_update_beacon_rssi(struct ath5k_softc *sc, struct sk_buff *skb, int rssi)
1262 */ 1261 */
1263static int ath5k_common_padpos(struct sk_buff *skb) 1262static int ath5k_common_padpos(struct sk_buff *skb)
1264{ 1263{
1265 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data; 1264 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1266 __le16 frame_control = hdr->frame_control; 1265 __le16 frame_control = hdr->frame_control;
1267 int padpos = 24; 1266 int padpos = 24;
1268 1267
1269 if (ieee80211_has_a4(frame_control)) { 1268 if (ieee80211_has_a4(frame_control))
1270 padpos += ETH_ALEN; 1269 padpos += ETH_ALEN;
1271 } 1270
1272 if (ieee80211_is_data_qos(frame_control)) { 1271 if (ieee80211_is_data_qos(frame_control))
1273 padpos += IEEE80211_QOS_CTL_LEN; 1272 padpos += IEEE80211_QOS_CTL_LEN;
1274 }
1275 1273
1276 return padpos; 1274 return padpos;
1277} 1275}
@@ -1285,13 +1283,13 @@ static int ath5k_add_padding(struct sk_buff *skb)
1285 int padpos = ath5k_common_padpos(skb); 1283 int padpos = ath5k_common_padpos(skb);
1286 int padsize = padpos & 3; 1284 int padsize = padpos & 3;
1287 1285
1288 if (padsize && skb->len>padpos) { 1286 if (padsize && skb->len > padpos) {
1289 1287
1290 if (skb_headroom(skb) < padsize) 1288 if (skb_headroom(skb) < padsize)
1291 return -1; 1289 return -1;
1292 1290
1293 skb_push(skb, padsize); 1291 skb_push(skb, padsize);
1294 memmove(skb->data, skb->data+padsize, padpos); 1292 memmove(skb->data, skb->data + padsize, padpos);
1295 return padsize; 1293 return padsize;
1296 } 1294 }
1297 1295
@@ -1316,7 +1314,7 @@ static int ath5k_remove_padding(struct sk_buff *skb)
1316 int padpos = ath5k_common_padpos(skb); 1314 int padpos = ath5k_common_padpos(skb);
1317 int padsize = padpos & 3; 1315 int padsize = padpos & 3;
1318 1316
1319 if (padsize && skb->len>=padpos+padsize) { 1317 if (padsize && skb->len >= padpos + padsize) {
1320 memmove(skb->data + padsize, skb->data, padpos); 1318 memmove(skb->data + padsize, skb->data, padpos);
1321 skb_pull(skb, padsize); 1319 skb_pull(skb, padsize);
1322 return padsize; 1320 return padsize;
@@ -1352,7 +1350,7 @@ ath5k_receive_frame(struct ath5k_softc *sc, struct sk_buff *skb,
1352 * timestamp (beginning of phy frame, data frame, end of rx?). 1350 * timestamp (beginning of phy frame, data frame, end of rx?).
1353 * The only thing we know is that it is hardware specific... 1351 * The only thing we know is that it is hardware specific...
1354 * On AR5213 it seems the rx timestamp is at the end of the 1352 * On AR5213 it seems the rx timestamp is at the end of the
1355 * frame, but i'm not sure. 1353 * frame, but I'm not sure.
1356 * 1354 *
1357 * NOTE: mac80211 defines mactime at the beginning of the first 1355 * NOTE: mac80211 defines mactime at the beginning of the first
1358 * data symbol. Since we don't have any time references it's 1356 * data symbol. Since we don't have any time references it's
@@ -1450,10 +1448,11 @@ ath5k_receive_frame_ok(struct ath5k_softc *sc, struct ath5k_rx_status *rs)
1450static void 1448static void
1451ath5k_set_current_imask(struct ath5k_softc *sc) 1449ath5k_set_current_imask(struct ath5k_softc *sc)
1452{ 1450{
1453 enum ath5k_int imask = sc->imask; 1451 enum ath5k_int imask;
1454 unsigned long flags; 1452 unsigned long flags;
1455 1453
1456 spin_lock_irqsave(&sc->irqlock, flags); 1454 spin_lock_irqsave(&sc->irqlock, flags);
1455 imask = sc->imask;
1457 if (sc->rx_pending) 1456 if (sc->rx_pending)
1458 imask &= ~AR5K_INT_RX_ALL; 1457 imask &= ~AR5K_INT_RX_ALL;
1459 if (sc->tx_pending) 1458 if (sc->tx_pending)
@@ -1556,7 +1555,8 @@ ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
1556 goto drop_packet; 1555 goto drop_packet;
1557 } 1556 }
1558 1557
1559 if (txq->txq_len >= txq->txq_max) 1558 if (txq->txq_len >= txq->txq_max &&
1559 txq->qnum <= AR5K_TX_QUEUE_ID_DATA_MAX)
1560 ieee80211_stop_queue(hw, txq->qnum); 1560 ieee80211_stop_queue(hw, txq->qnum);
1561 1561
1562 spin_lock_irqsave(&sc->txbuflock, flags); 1562 spin_lock_irqsave(&sc->txbuflock, flags);
@@ -1711,7 +1711,7 @@ ath5k_tasklet_tx(unsigned long data)
1711 int i; 1711 int i;
1712 struct ath5k_softc *sc = (void *)data; 1712 struct ath5k_softc *sc = (void *)data;
1713 1713
1714 for (i=0; i < AR5K_NUM_TX_QUEUES; i++) 1714 for (i = 0; i < AR5K_NUM_TX_QUEUES; i++)
1715 if (sc->txqs[i].setup && (sc->ah->ah_txq_isr & BIT(i))) 1715 if (sc->txqs[i].setup && (sc->ah->ah_txq_isr & BIT(i)))
1716 ath5k_tx_processq(sc, &sc->txqs[i]); 1716 ath5k_tx_processq(sc, &sc->txqs[i]);
1717 1717
@@ -1766,7 +1766,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1766 * 4 beacons to make sure everybody hears our AP. 1766 * 4 beacons to make sure everybody hears our AP.
1767 * When a client tries to associate, hw will keep 1767 * When a client tries to associate, hw will keep
1768 * track of the tx antenna to be used for this client 1768 * track of the tx antenna to be used for this client
1769 * automaticaly, based on ACKed packets. 1769 * automatically, based on ACKed packets.
1770 * 1770 *
1771 * Note: AP still listens and transmits RTS on the 1771 * Note: AP still listens and transmits RTS on the
1772 * default antenna which is supposed to be an omni. 1772 * default antenna which is supposed to be an omni.
@@ -1902,7 +1902,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1902 avf = (void *)vif->drv_priv; 1902 avf = (void *)vif->drv_priv;
1903 bf = avf->bbuf; 1903 bf = avf->bbuf;
1904 if (unlikely(bf->skb == NULL || sc->opmode == NL80211_IFTYPE_STATION || 1904 if (unlikely(bf->skb == NULL || sc->opmode == NL80211_IFTYPE_STATION ||
1905 sc->opmode == NL80211_IFTYPE_MONITOR)) { 1905 sc->opmode == NL80211_IFTYPE_MONITOR)) {
1906 ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL); 1906 ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL);
1907 return; 1907 return;
1908 } 1908 }
@@ -1919,7 +1919,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1919 1919
1920 /* refresh the beacon for AP or MESH mode */ 1920 /* refresh the beacon for AP or MESH mode */
1921 if (sc->opmode == NL80211_IFTYPE_AP || 1921 if (sc->opmode == NL80211_IFTYPE_AP ||
1922 sc->opmode == NL80211_IFTYPE_MESH_POINT) 1922 sc->opmode == NL80211_IFTYPE_MESH_POINT)
1923 ath5k_beacon_update(sc->hw, vif); 1923 ath5k_beacon_update(sc->hw, vif);
1924 1924
1925 trace_ath5k_tx(sc, bf->skb, &sc->txqs[sc->bhalq]); 1925 trace_ath5k_tx(sc, bf->skb, &sc->txqs[sc->bhalq]);
@@ -1932,6 +1932,10 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1932 skb = ieee80211_get_buffered_bc(sc->hw, vif); 1932 skb = ieee80211_get_buffered_bc(sc->hw, vif);
1933 while (skb) { 1933 while (skb) {
1934 ath5k_tx_queue(sc->hw, skb, sc->cabq); 1934 ath5k_tx_queue(sc->hw, skb, sc->cabq);
1935
1936 if (sc->cabq->txq_len >= sc->cabq->txq_max)
1937 break;
1938
1935 skb = ieee80211_get_buffered_bc(sc->hw, vif); 1939 skb = ieee80211_get_buffered_bc(sc->hw, vif);
1936 } 1940 }
1937 1941
@@ -1978,7 +1982,7 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
1978 hw_tsf = ath5k_hw_get_tsf64(ah); 1982 hw_tsf = ath5k_hw_get_tsf64(ah);
1979 hw_tu = TSF_TO_TU(hw_tsf); 1983 hw_tu = TSF_TO_TU(hw_tsf);
1980 1984
1981#define FUDGE AR5K_TUNE_SW_BEACON_RESP + 3 1985#define FUDGE (AR5K_TUNE_SW_BEACON_RESP + 3)
1982 /* We use FUDGE to make sure the next TBTT is ahead of the current TU. 1986 /* We use FUDGE to make sure the next TBTT is ahead of the current TU.
1983 * Since we later subtract AR5K_TUNE_SW_BEACON_RESP (10) in the timer 1987 * Since we later subtract AR5K_TUNE_SW_BEACON_RESP (10) in the timer
1984 * configuration we need to make sure it is bigger than that. */ 1988 * configuration we need to make sure it is bigger than that. */
@@ -2101,11 +2105,11 @@ static void ath5k_tasklet_beacon(unsigned long data)
2101 * 2105 *
2102 * In IBSS mode we use this interrupt just to 2106 * In IBSS mode we use this interrupt just to
2103 * keep track of the next TBTT (target beacon 2107 * keep track of the next TBTT (target beacon
2104 * transmission time) in order to detect wether 2108 * transmission time) in order to detect whether
2105 * automatic TSF updates happened. 2109 * automatic TSF updates happened.
2106 */ 2110 */
2107 if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2111 if (sc->opmode == NL80211_IFTYPE_ADHOC) {
2108 /* XXX: only if VEOL suppported */ 2112 /* XXX: only if VEOL supported */
2109 u64 tsf = ath5k_hw_get_tsf64(sc->ah); 2113 u64 tsf = ath5k_hw_get_tsf64(sc->ah);
2110 sc->nexttbtt += sc->bintval; 2114 sc->nexttbtt += sc->bintval;
2111 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 2115 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
@@ -2200,13 +2204,12 @@ ath5k_intr(int irq, void *dev_id)
2200 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 2204 ATH5K_DBG(sc, ATH5K_DEBUG_RESET,
2201 "rx overrun, resetting\n"); 2205 "rx overrun, resetting\n");
2202 ieee80211_queue_work(sc->hw, &sc->reset_work); 2206 ieee80211_queue_work(sc->hw, &sc->reset_work);
2203 } 2207 } else
2204 else
2205 ath5k_schedule_rx(sc); 2208 ath5k_schedule_rx(sc);
2206 } else { 2209 } else {
2207 if (status & AR5K_INT_SWBA) { 2210 if (status & AR5K_INT_SWBA)
2208 tasklet_hi_schedule(&sc->beacontq); 2211 tasklet_hi_schedule(&sc->beacontq);
2209 } 2212
2210 if (status & AR5K_INT_RXEOL) { 2213 if (status & AR5K_INT_RXEOL) {
2211 /* 2214 /*
2212 * NB: the hardware should re-read the link when 2215 * NB: the hardware should re-read the link when
@@ -2358,7 +2361,7 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
2358* Initialization routines * 2361* Initialization routines *
2359\*************************/ 2362\*************************/
2360 2363
2361int 2364int __devinit
2362ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops) 2365ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2363{ 2366{
2364 struct ieee80211_hw *hw = sc->hw; 2367 struct ieee80211_hw *hw = sc->hw;
@@ -2423,6 +2426,7 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2423 common->ah = sc->ah; 2426 common->ah = sc->ah;
2424 common->hw = hw; 2427 common->hw = hw;
2425 common->priv = sc; 2428 common->priv = sc;
2429 common->clockrate = 40;
2426 2430
2427 /* 2431 /*
2428 * Cache line size is used to size and align various 2432 * Cache line size is used to size and align various
@@ -2469,7 +2473,7 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2469 sc->ah->ah_radio_5ghz_revision), 2473 sc->ah->ah_radio_5ghz_revision),
2470 sc->ah->ah_radio_5ghz_revision); 2474 sc->ah->ah_radio_5ghz_revision);
2471 /* No 2GHz support (5110 and some 2475 /* No 2GHz support (5110 and some
2472 * 5Ghz only cards) -> report 5Ghz radio */ 2476 * 5GHz only cards) -> report 5GHz radio */
2473 } else if (!test_bit(AR5K_MODE_11B, 2477 } else if (!test_bit(AR5K_MODE_11B,
2474 sc->ah->ah_capabilities.cap_mode)) { 2478 sc->ah->ah_capabilities.cap_mode)) {
2475 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n", 2479 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n",
@@ -2488,7 +2492,7 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2488 /* Multi chip radio (RF5111 - RF2111) -> 2492 /* Multi chip radio (RF5111 - RF2111) ->
2489 * report both 2GHz/5GHz radios */ 2493 * report both 2GHz/5GHz radios */
2490 else if (sc->ah->ah_radio_5ghz_revision && 2494 else if (sc->ah->ah_radio_5ghz_revision &&
2491 sc->ah->ah_radio_2ghz_revision){ 2495 sc->ah->ah_radio_2ghz_revision) {
2492 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n", 2496 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n",
2493 ath5k_chip_name(AR5K_VERSION_RAD, 2497 ath5k_chip_name(AR5K_VERSION_RAD,
2494 sc->ah->ah_radio_5ghz_revision), 2498 sc->ah->ah_radio_5ghz_revision),
@@ -2713,8 +2717,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan,
2713 2717
2714 fast = ((chan != NULL) && modparam_fastchanswitch) ? 1 : 0; 2718 fast = ((chan != NULL) && modparam_fastchanswitch) ? 1 : 0;
2715 2719
2716 ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, fast, 2720 ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, fast, skip_pcu);
2717 skip_pcu);
2718 if (ret) { 2721 if (ret) {
2719 ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret); 2722 ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret);
2720 goto err; 2723 goto err;
@@ -2728,7 +2731,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan,
2728 2731
2729 ath5k_ani_init(ah, ani_mode); 2732 ath5k_ani_init(ah, ani_mode);
2730 2733
2731 ah->ah_cal_next_full = jiffies; 2734 ah->ah_cal_next_full = jiffies + msecs_to_jiffies(100);
2732 ah->ah_cal_next_ani = jiffies; 2735 ah->ah_cal_next_ani = jiffies;
2733 ah->ah_cal_next_nf = jiffies; 2736 ah->ah_cal_next_nf = jiffies;
2734 ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8); 2737 ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8);
@@ -2772,7 +2775,7 @@ static void ath5k_reset_work(struct work_struct *work)
2772 mutex_unlock(&sc->lock); 2775 mutex_unlock(&sc->lock);
2773} 2776}
2774 2777
2775static int 2778static int __devinit
2776ath5k_init(struct ieee80211_hw *hw) 2779ath5k_init(struct ieee80211_hw *hw)
2777{ 2780{
2778 2781
@@ -2800,7 +2803,7 @@ ath5k_init(struct ieee80211_hw *hw)
2800 2803
2801 /* 2804 /*
2802 * Collect the channel list. The 802.11 layer 2805 * Collect the channel list. The 802.11 layer
2803 * is resposible for filtering this list based 2806 * is responsible for filtering this list based
2804 * on settings like the phy mode and regulatory 2807 * on settings like the phy mode and regulatory
2805 * domain restrictions. 2808 * domain restrictions.
2806 */ 2809 */
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index b294f3305011..0a98777b9373 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -96,8 +96,7 @@ struct ath5k_txq {
96/* 96/*
97 * State for LED triggers 97 * State for LED triggers
98 */ 98 */
99struct ath5k_led 99struct ath5k_led {
100{
101 char name[ATH5K_LED_MAX_NAME_LEN + 1]; /* name of the LED in sysfs */ 100 char name[ATH5K_LED_MAX_NAME_LEN + 1]; /* name of the LED in sysfs */
102 struct ath5k_softc *sc; /* driver state */ 101 struct ath5k_softc *sc; /* driver state */
103 struct led_classdev led_dev; /* led classdev */ 102 struct led_classdev led_dev; /* led classdev */
@@ -122,7 +121,7 @@ struct ath5k_statistics {
122 /* frame errors */ 121 /* frame errors */
123 unsigned int rx_all_count; /* all RX frames, including errors */ 122 unsigned int rx_all_count; /* all RX frames, including errors */
124 unsigned int tx_all_count; /* all TX frames, including errors */ 123 unsigned int tx_all_count; /* all TX frames, including errors */
125 unsigned int rx_bytes_count; /* all RX bytes, including errored pks 124 unsigned int rx_bytes_count; /* all RX bytes, including errored pkts
126 * and the MAC headers for each packet 125 * and the MAC headers for each packet
127 */ 126 */
128 unsigned int tx_bytes_count; /* all TX bytes, including errored pkts 127 unsigned int tx_bytes_count; /* all TX bytes, including errored pkts
@@ -154,9 +153,9 @@ struct ath5k_statistics {
154}; 153};
155 154
156#if CHAN_DEBUG 155#if CHAN_DEBUG
157#define ATH_CHAN_MAX (26+26+26+200+200) 156#define ATH_CHAN_MAX (26 + 26 + 26 + 200 + 200)
158#else 157#else
159#define ATH_CHAN_MAX (14+14+14+252+20) 158#define ATH_CHAN_MAX (14 + 14 + 14 + 252 + 20)
160#endif 159#endif
161 160
162struct ath5k_vif { 161struct ath5k_vif {
@@ -251,7 +250,7 @@ struct ath5k_softc {
251 unsigned int nexttbtt; /* next beacon time in TU */ 250 unsigned int nexttbtt; /* next beacon time in TU */
252 struct ath5k_txq *cabq; /* content after beacon */ 251 struct ath5k_txq *cabq; /* content after beacon */
253 252
254 int power_level; /* Requested tx power in dbm */ 253 int power_level; /* Requested tx power in dBm */
255 bool assoc; /* associate state */ 254 bool assoc; /* associate state */
256 bool enable_beacon; /* true if beacons are on */ 255 bool enable_beacon; /* true if beacons are on */
257 256
diff --git a/drivers/net/wireless/ath/ath5k/caps.c b/drivers/net/wireless/ath/ath5k/caps.c
index 7dd88e1c3ff8..c752982aec05 100644
--- a/drivers/net/wireless/ath/ath5k/caps.c
+++ b/drivers/net/wireless/ath/ath5k/caps.c
@@ -52,8 +52,8 @@ int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
52 __set_bit(AR5K_MODE_11A, caps->cap_mode); 52 __set_bit(AR5K_MODE_11A, caps->cap_mode);
53 } else { 53 } else {
54 /* 54 /*
55 * XXX The tranceiver supports frequencies from 4920 to 6100GHz 55 * XXX The transceiver supports frequencies from 4920 to 6100MHz
56 * XXX and from 2312 to 2732GHz. There are problems with the 56 * XXX and from 2312 to 2732MHz. There are problems with the
57 * XXX current ieee80211 implementation because the IEEE 57 * XXX current ieee80211 implementation because the IEEE
58 * XXX channel mapping does not support negative channel 58 * XXX channel mapping does not support negative channel
59 * XXX numbers (2312MHz is channel -19). Of course, this 59 * XXX numbers (2312MHz is channel -19). Of course, this
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 0bf7313b8a17..4edca7072d53 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -205,35 +205,35 @@ static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
205 u64 tsf; 205 u64 tsf;
206 206
207 v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON); 207 v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON);
208 len += snprintf(buf+len, sizeof(buf)-len, 208 len += snprintf(buf + len, sizeof(buf) - len,
209 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n", 209 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
210 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD, 210 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
211 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S); 211 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
212 212
213 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n", 213 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n",
214 "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP)); 214 "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
215 215
216 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n", 216 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n\n",
217 "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT)); 217 "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
218 218
219 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0); 219 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0);
220 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", 220 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
221 "AR5K_TIMER0 (TBTT)", v, v); 221 "AR5K_TIMER0 (TBTT)", v, v);
222 222
223 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1); 223 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1);
224 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", 224 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
225 "AR5K_TIMER1 (DMA)", v, v >> 3); 225 "AR5K_TIMER1 (DMA)", v, v >> 3);
226 226
227 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2); 227 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2);
228 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", 228 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
229 "AR5K_TIMER2 (SWBA)", v, v >> 3); 229 "AR5K_TIMER2 (SWBA)", v, v >> 3);
230 230
231 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3); 231 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3);
232 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", 232 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
233 "AR5K_TIMER3 (ATIM)", v, v); 233 "AR5K_TIMER3 (ATIM)", v, v);
234 234
235 tsf = ath5k_hw_get_tsf64(sc->ah); 235 tsf = ath5k_hw_get_tsf64(sc->ah);
236 len += snprintf(buf+len, sizeof(buf)-len, 236 len += snprintf(buf + len, sizeof(buf) - len,
237 "TSF\t\t0x%016llx\tTU: %08x\n", 237 "TSF\t\t0x%016llx\tTU: %08x\n",
238 (unsigned long long)tsf, TSF_TO_TU(tsf)); 238 (unsigned long long)tsf, TSF_TO_TU(tsf));
239 239
@@ -323,16 +323,16 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf,
323 unsigned int len = 0; 323 unsigned int len = 0;
324 unsigned int i; 324 unsigned int i;
325 325
326 len += snprintf(buf+len, sizeof(buf)-len, 326 len += snprintf(buf + len, sizeof(buf) - len,
327 "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level); 327 "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level);
328 328
329 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) { 329 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
330 len += snprintf(buf+len, sizeof(buf)-len, 330 len += snprintf(buf + len, sizeof(buf) - len,
331 "%10s %c 0x%08x - %s\n", dbg_info[i].name, 331 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
332 sc->debug.level & dbg_info[i].level ? '+' : ' ', 332 sc->debug.level & dbg_info[i].level ? '+' : ' ',
333 dbg_info[i].level, dbg_info[i].desc); 333 dbg_info[i].level, dbg_info[i].desc);
334 } 334 }
335 len += snprintf(buf+len, sizeof(buf)-len, 335 len += snprintf(buf + len, sizeof(buf) - len,
336 "%10s %c 0x%08x - %s\n", dbg_info[i].name, 336 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
337 sc->debug.level == dbg_info[i].level ? '+' : ' ', 337 sc->debug.level == dbg_info[i].level ? '+' : ' ',
338 dbg_info[i].level, dbg_info[i].desc); 338 dbg_info[i].level, dbg_info[i].desc);
@@ -384,60 +384,60 @@ static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
384 unsigned int i; 384 unsigned int i;
385 unsigned int v; 385 unsigned int v;
386 386
387 len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n", 387 len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n",
388 sc->ah->ah_ant_mode); 388 sc->ah->ah_ant_mode);
389 len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n", 389 len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n",
390 sc->ah->ah_def_ant); 390 sc->ah->ah_def_ant);
391 len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n", 391 len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n",
392 sc->ah->ah_tx_ant); 392 sc->ah->ah_tx_ant);
393 393
394 len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n"); 394 len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n");
395 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) { 395 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
396 len += snprintf(buf+len, sizeof(buf)-len, 396 len += snprintf(buf + len, sizeof(buf) - len,
397 "[antenna %d]\t%d\t%d\n", 397 "[antenna %d]\t%d\t%d\n",
398 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]); 398 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
399 } 399 }
400 len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n", 400 len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n",
401 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]); 401 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
402 402
403 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA); 403 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
404 len += snprintf(buf+len, sizeof(buf)-len, 404 len += snprintf(buf + len, sizeof(buf) - len,
405 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v); 405 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
406 406
407 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1); 407 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
408 len += snprintf(buf+len, sizeof(buf)-len, 408 len += snprintf(buf + len, sizeof(buf) - len,
409 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n", 409 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
410 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0); 410 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
411 len += snprintf(buf+len, sizeof(buf)-len, 411 len += snprintf(buf + len, sizeof(buf) - len,
412 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n", 412 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
413 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0); 413 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
414 len += snprintf(buf+len, sizeof(buf)-len, 414 len += snprintf(buf + len, sizeof(buf) - len,
415 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n", 415 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
416 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0); 416 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
417 len += snprintf(buf+len, sizeof(buf)-len, 417 len += snprintf(buf + len, sizeof(buf) - len,
418 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n", 418 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
419 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0); 419 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
420 420
421 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL); 421 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
422 len += snprintf(buf+len, sizeof(buf)-len, 422 len += snprintf(buf + len, sizeof(buf) - len,
423 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n", 423 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
424 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0); 424 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
425 425
426 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART); 426 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
427 len += snprintf(buf+len, sizeof(buf)-len, 427 len += snprintf(buf + len, sizeof(buf) - len,
428 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n", 428 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
429 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S); 429 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
430 430
431 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV); 431 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
432 len += snprintf(buf+len, sizeof(buf)-len, 432 len += snprintf(buf + len, sizeof(buf) - len,
433 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n", 433 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
434 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0); 434 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
435 435
436 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0); 436 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
437 len += snprintf(buf+len, sizeof(buf)-len, 437 len += snprintf(buf + len, sizeof(buf) - len,
438 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v); 438 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
439 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1); 439 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
440 len += snprintf(buf+len, sizeof(buf)-len, 440 len += snprintf(buf + len, sizeof(buf) - len,
441 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v); 441 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
442 442
443 if (len > sizeof(buf)) 443 if (len > sizeof(buf))
@@ -494,36 +494,36 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
494 unsigned int len = 0; 494 unsigned int len = 0;
495 u32 filt = ath5k_hw_get_rx_filter(sc->ah); 495 u32 filt = ath5k_hw_get_rx_filter(sc->ah);
496 496
497 len += snprintf(buf+len, sizeof(buf)-len, "bssid-mask: %pM\n", 497 len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n",
498 sc->bssidmask); 498 sc->bssidmask);
499 len += snprintf(buf+len, sizeof(buf)-len, "filter-flags: 0x%x ", 499 len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ",
500 filt); 500 filt);
501 if (filt & AR5K_RX_FILTER_UCAST) 501 if (filt & AR5K_RX_FILTER_UCAST)
502 len += snprintf(buf+len, sizeof(buf)-len, " UCAST"); 502 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
503 if (filt & AR5K_RX_FILTER_MCAST) 503 if (filt & AR5K_RX_FILTER_MCAST)
504 len += snprintf(buf+len, sizeof(buf)-len, " MCAST"); 504 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
505 if (filt & AR5K_RX_FILTER_BCAST) 505 if (filt & AR5K_RX_FILTER_BCAST)
506 len += snprintf(buf+len, sizeof(buf)-len, " BCAST"); 506 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
507 if (filt & AR5K_RX_FILTER_CONTROL) 507 if (filt & AR5K_RX_FILTER_CONTROL)
508 len += snprintf(buf+len, sizeof(buf)-len, " CONTROL"); 508 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
509 if (filt & AR5K_RX_FILTER_BEACON) 509 if (filt & AR5K_RX_FILTER_BEACON)
510 len += snprintf(buf+len, sizeof(buf)-len, " BEACON"); 510 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
511 if (filt & AR5K_RX_FILTER_PROM) 511 if (filt & AR5K_RX_FILTER_PROM)
512 len += snprintf(buf+len, sizeof(buf)-len, " PROM"); 512 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
513 if (filt & AR5K_RX_FILTER_XRPOLL) 513 if (filt & AR5K_RX_FILTER_XRPOLL)
514 len += snprintf(buf+len, sizeof(buf)-len, " XRPOLL"); 514 len += snprintf(buf + len, sizeof(buf) - len, " XRPOLL");
515 if (filt & AR5K_RX_FILTER_PROBEREQ) 515 if (filt & AR5K_RX_FILTER_PROBEREQ)
516 len += snprintf(buf+len, sizeof(buf)-len, " PROBEREQ"); 516 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
517 if (filt & AR5K_RX_FILTER_PHYERR_5212) 517 if (filt & AR5K_RX_FILTER_PHYERR_5212)
518 len += snprintf(buf+len, sizeof(buf)-len, " PHYERR-5212"); 518 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR-5212");
519 if (filt & AR5K_RX_FILTER_RADARERR_5212) 519 if (filt & AR5K_RX_FILTER_RADARERR_5212)
520 len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5212"); 520 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5212");
521 if (filt & AR5K_RX_FILTER_PHYERR_5211) 521 if (filt & AR5K_RX_FILTER_PHYERR_5211)
522 snprintf(buf+len, sizeof(buf)-len, " PHYERR-5211"); 522 snprintf(buf + len, sizeof(buf) - len, " PHYERR-5211");
523 if (filt & AR5K_RX_FILTER_RADARERR_5211) 523 if (filt & AR5K_RX_FILTER_RADARERR_5211)
524 len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5211"); 524 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211");
525 525
526 len += snprintf(buf+len, sizeof(buf)-len, "\nopmode: %s (%d)\n", 526 len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n",
527 ath_opmode_to_string(sc->opmode), sc->opmode); 527 ath_opmode_to_string(sc->opmode), sc->opmode);
528 528
529 if (len > sizeof(buf)) 529 if (len > sizeof(buf))
@@ -550,65 +550,65 @@ static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
550 unsigned int len = 0; 550 unsigned int len = 0;
551 int i; 551 int i;
552 552
553 len += snprintf(buf+len, sizeof(buf)-len, 553 len += snprintf(buf + len, sizeof(buf) - len,
554 "RX\n---------------------\n"); 554 "RX\n---------------------\n");
555 len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%u\t(%u%%)\n", 555 len += snprintf(buf + len, sizeof(buf) - len, "CRC\t%u\t(%u%%)\n",
556 st->rxerr_crc, 556 st->rxerr_crc,
557 st->rx_all_count > 0 ? 557 st->rx_all_count > 0 ?
558 st->rxerr_crc*100/st->rx_all_count : 0); 558 st->rxerr_crc * 100 / st->rx_all_count : 0);
559 len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%u\t(%u%%)\n", 559 len += snprintf(buf + len, sizeof(buf) - len, "PHY\t%u\t(%u%%)\n",
560 st->rxerr_phy, 560 st->rxerr_phy,
561 st->rx_all_count > 0 ? 561 st->rx_all_count > 0 ?
562 st->rxerr_phy*100/st->rx_all_count : 0); 562 st->rxerr_phy * 100 / st->rx_all_count : 0);
563 for (i = 0; i < 32; i++) { 563 for (i = 0; i < 32; i++) {
564 if (st->rxerr_phy_code[i]) 564 if (st->rxerr_phy_code[i])
565 len += snprintf(buf+len, sizeof(buf)-len, 565 len += snprintf(buf + len, sizeof(buf) - len,
566 " phy_err[%u]\t%u\n", 566 " phy_err[%u]\t%u\n",
567 i, st->rxerr_phy_code[i]); 567 i, st->rxerr_phy_code[i]);
568 } 568 }
569 569
570 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n", 570 len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
571 st->rxerr_fifo, 571 st->rxerr_fifo,
572 st->rx_all_count > 0 ? 572 st->rx_all_count > 0 ?
573 st->rxerr_fifo*100/st->rx_all_count : 0); 573 st->rxerr_fifo * 100 / st->rx_all_count : 0);
574 len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%u\t(%u%%)\n", 574 len += snprintf(buf + len, sizeof(buf) - len, "decrypt\t%u\t(%u%%)\n",
575 st->rxerr_decrypt, 575 st->rxerr_decrypt,
576 st->rx_all_count > 0 ? 576 st->rx_all_count > 0 ?
577 st->rxerr_decrypt*100/st->rx_all_count : 0); 577 st->rxerr_decrypt * 100 / st->rx_all_count : 0);
578 len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%u\t(%u%%)\n", 578 len += snprintf(buf + len, sizeof(buf) - len, "MIC\t%u\t(%u%%)\n",
579 st->rxerr_mic, 579 st->rxerr_mic,
580 st->rx_all_count > 0 ? 580 st->rx_all_count > 0 ?
581 st->rxerr_mic*100/st->rx_all_count : 0); 581 st->rxerr_mic * 100 / st->rx_all_count : 0);
582 len += snprintf(buf+len, sizeof(buf)-len, "process\t%u\t(%u%%)\n", 582 len += snprintf(buf + len, sizeof(buf) - len, "process\t%u\t(%u%%)\n",
583 st->rxerr_proc, 583 st->rxerr_proc,
584 st->rx_all_count > 0 ? 584 st->rx_all_count > 0 ?
585 st->rxerr_proc*100/st->rx_all_count : 0); 585 st->rxerr_proc * 100 / st->rx_all_count : 0);
586 len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%u\t(%u%%)\n", 586 len += snprintf(buf + len, sizeof(buf) - len, "jumbo\t%u\t(%u%%)\n",
587 st->rxerr_jumbo, 587 st->rxerr_jumbo,
588 st->rx_all_count > 0 ? 588 st->rx_all_count > 0 ?
589 st->rxerr_jumbo*100/st->rx_all_count : 0); 589 st->rxerr_jumbo * 100 / st->rx_all_count : 0);
590 len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%u]\n", 590 len += snprintf(buf + len, sizeof(buf) - len, "[RX all\t%u]\n",
591 st->rx_all_count); 591 st->rx_all_count);
592 len += snprintf(buf+len, sizeof(buf)-len, "RX-all-bytes\t%u\n", 592 len += snprintf(buf + len, sizeof(buf) - len, "RX-all-bytes\t%u\n",
593 st->rx_bytes_count); 593 st->rx_bytes_count);
594 594
595 len += snprintf(buf+len, sizeof(buf)-len, 595 len += snprintf(buf + len, sizeof(buf) - len,
596 "\nTX\n---------------------\n"); 596 "\nTX\n---------------------\n");
597 len += snprintf(buf+len, sizeof(buf)-len, "retry\t%u\t(%u%%)\n", 597 len += snprintf(buf + len, sizeof(buf) - len, "retry\t%u\t(%u%%)\n",
598 st->txerr_retry, 598 st->txerr_retry,
599 st->tx_all_count > 0 ? 599 st->tx_all_count > 0 ?
600 st->txerr_retry*100/st->tx_all_count : 0); 600 st->txerr_retry * 100 / st->tx_all_count : 0);
601 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n", 601 len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
602 st->txerr_fifo, 602 st->txerr_fifo,
603 st->tx_all_count > 0 ? 603 st->tx_all_count > 0 ?
604 st->txerr_fifo*100/st->tx_all_count : 0); 604 st->txerr_fifo * 100 / st->tx_all_count : 0);
605 len += snprintf(buf+len, sizeof(buf)-len, "filter\t%u\t(%u%%)\n", 605 len += snprintf(buf + len, sizeof(buf) - len, "filter\t%u\t(%u%%)\n",
606 st->txerr_filt, 606 st->txerr_filt,
607 st->tx_all_count > 0 ? 607 st->tx_all_count > 0 ?
608 st->txerr_filt*100/st->tx_all_count : 0); 608 st->txerr_filt * 100 / st->tx_all_count : 0);
609 len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%u]\n", 609 len += snprintf(buf + len, sizeof(buf) - len, "[TX all\t%u]\n",
610 st->tx_all_count); 610 st->tx_all_count);
611 len += snprintf(buf+len, sizeof(buf)-len, "TX-all-bytes\t%u\n", 611 len += snprintf(buf + len, sizeof(buf) - len, "TX-all-bytes\t%u\n",
612 st->tx_bytes_count); 612 st->tx_bytes_count);
613 613
614 if (len > sizeof(buf)) 614 if (len > sizeof(buf))
@@ -667,89 +667,93 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
667 char buf[700]; 667 char buf[700];
668 unsigned int len = 0; 668 unsigned int len = 0;
669 669
670 len += snprintf(buf+len, sizeof(buf)-len, 670 len += snprintf(buf + len, sizeof(buf) - len,
671 "HW has PHY error counters:\t%s\n", 671 "HW has PHY error counters:\t%s\n",
672 sc->ah->ah_capabilities.cap_has_phyerr_counters ? 672 sc->ah->ah_capabilities.cap_has_phyerr_counters ?
673 "yes" : "no"); 673 "yes" : "no");
674 len += snprintf(buf+len, sizeof(buf)-len, 674 len += snprintf(buf + len, sizeof(buf) - len,
675 "HW max spur immunity level:\t%d\n", 675 "HW max spur immunity level:\t%d\n",
676 as->max_spur_level); 676 as->max_spur_level);
677 len += snprintf(buf+len, sizeof(buf)-len, 677 len += snprintf(buf + len, sizeof(buf) - len,
678 "\nANI state\n--------------------------------------------\n"); 678 "\nANI state\n--------------------------------------------\n");
679 len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t"); 679 len += snprintf(buf + len, sizeof(buf) - len, "operating mode:\t\t\t");
680 switch (as->ani_mode) { 680 switch (as->ani_mode) {
681 case ATH5K_ANI_MODE_OFF: 681 case ATH5K_ANI_MODE_OFF:
682 len += snprintf(buf+len, sizeof(buf)-len, "OFF\n"); 682 len += snprintf(buf + len, sizeof(buf) - len, "OFF\n");
683 break; 683 break;
684 case ATH5K_ANI_MODE_MANUAL_LOW: 684 case ATH5K_ANI_MODE_MANUAL_LOW:
685 len += snprintf(buf+len, sizeof(buf)-len, 685 len += snprintf(buf + len, sizeof(buf) - len,
686 "MANUAL LOW\n"); 686 "MANUAL LOW\n");
687 break; 687 break;
688 case ATH5K_ANI_MODE_MANUAL_HIGH: 688 case ATH5K_ANI_MODE_MANUAL_HIGH:
689 len += snprintf(buf+len, sizeof(buf)-len, 689 len += snprintf(buf + len, sizeof(buf) - len,
690 "MANUAL HIGH\n"); 690 "MANUAL HIGH\n");
691 break; 691 break;
692 case ATH5K_ANI_MODE_AUTO: 692 case ATH5K_ANI_MODE_AUTO:
693 len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n"); 693 len += snprintf(buf + len, sizeof(buf) - len, "AUTO\n");
694 break; 694 break;
695 default: 695 default:
696 len += snprintf(buf+len, sizeof(buf)-len, 696 len += snprintf(buf + len, sizeof(buf) - len,
697 "??? (not good)\n"); 697 "??? (not good)\n");
698 break; 698 break;
699 } 699 }
700 len += snprintf(buf+len, sizeof(buf)-len, 700 len += snprintf(buf + len, sizeof(buf) - len,
701 "noise immunity level:\t\t%d\n", 701 "noise immunity level:\t\t%d\n",
702 as->noise_imm_level); 702 as->noise_imm_level);
703 len += snprintf(buf+len, sizeof(buf)-len, 703 len += snprintf(buf + len, sizeof(buf) - len,
704 "spur immunity level:\t\t%d\n", 704 "spur immunity level:\t\t%d\n",
705 as->spur_level); 705 as->spur_level);
706 len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n", 706 len += snprintf(buf + len, sizeof(buf) - len,
707 "firstep level:\t\t\t%d\n",
707 as->firstep_level); 708 as->firstep_level);
708 len += snprintf(buf+len, sizeof(buf)-len, 709 len += snprintf(buf + len, sizeof(buf) - len,
709 "OFDM weak signal detection:\t%s\n", 710 "OFDM weak signal detection:\t%s\n",
710 as->ofdm_weak_sig ? "on" : "off"); 711 as->ofdm_weak_sig ? "on" : "off");
711 len += snprintf(buf+len, sizeof(buf)-len, 712 len += snprintf(buf + len, sizeof(buf) - len,
712 "CCK weak signal detection:\t%s\n", 713 "CCK weak signal detection:\t%s\n",
713 as->cck_weak_sig ? "on" : "off"); 714 as->cck_weak_sig ? "on" : "off");
714 715
715 len += snprintf(buf+len, sizeof(buf)-len, 716 len += snprintf(buf + len, sizeof(buf) - len,
716 "\nMIB INTERRUPTS:\t\t%u\n", 717 "\nMIB INTERRUPTS:\t\t%u\n",
717 st->mib_intr); 718 st->mib_intr);
718 len += snprintf(buf+len, sizeof(buf)-len, 719 len += snprintf(buf + len, sizeof(buf) - len,
719 "beacon RSSI average:\t%d\n", 720 "beacon RSSI average:\t%d\n",
720 (int)ewma_read(&sc->ah->ah_beacon_rssi_avg)); 721 (int)ewma_read(&sc->ah->ah_beacon_rssi_avg));
721 722
722#define CC_PRINT(_struct, _field) \ 723#define CC_PRINT(_struct, _field) \
723 _struct._field, \ 724 _struct._field, \
724 _struct.cycles > 0 ? \ 725 _struct.cycles > 0 ? \
725 _struct._field*100/_struct.cycles : 0 726 _struct._field * 100 / _struct.cycles : 0
726 727
727 len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n", 728 len += snprintf(buf + len, sizeof(buf) - len,
729 "profcnt tx\t\t%u\t(%d%%)\n",
728 CC_PRINT(as->last_cc, tx_frame)); 730 CC_PRINT(as->last_cc, tx_frame));
729 len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n", 731 len += snprintf(buf + len, sizeof(buf) - len,
732 "profcnt rx\t\t%u\t(%d%%)\n",
730 CC_PRINT(as->last_cc, rx_frame)); 733 CC_PRINT(as->last_cc, rx_frame));
731 len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n", 734 len += snprintf(buf + len, sizeof(buf) - len,
735 "profcnt busy\t\t%u\t(%d%%)\n",
732 CC_PRINT(as->last_cc, rx_busy)); 736 CC_PRINT(as->last_cc, rx_busy));
733#undef CC_PRINT 737#undef CC_PRINT
734 len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n", 738 len += snprintf(buf + len, sizeof(buf) - len, "profcnt cycles\t\t%u\n",
735 as->last_cc.cycles); 739 as->last_cc.cycles);
736 len += snprintf(buf+len, sizeof(buf)-len, 740 len += snprintf(buf + len, sizeof(buf) - len,
737 "listen time\t\t%d\tlast: %d\n", 741 "listen time\t\t%d\tlast: %d\n",
738 as->listen_time, as->last_listen); 742 as->listen_time, as->last_listen);
739 len += snprintf(buf+len, sizeof(buf)-len, 743 len += snprintf(buf + len, sizeof(buf) - len,
740 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n", 744 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
741 as->ofdm_errors, as->last_ofdm_errors, 745 as->ofdm_errors, as->last_ofdm_errors,
742 as->sum_ofdm_errors); 746 as->sum_ofdm_errors);
743 len += snprintf(buf+len, sizeof(buf)-len, 747 len += snprintf(buf + len, sizeof(buf) - len,
744 "CCK errors\t\t%u\tlast: %u\tsum: %u\n", 748 "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
745 as->cck_errors, as->last_cck_errors, 749 as->cck_errors, as->last_cck_errors,
746 as->sum_cck_errors); 750 as->sum_cck_errors);
747 len += snprintf(buf+len, sizeof(buf)-len, 751 len += snprintf(buf + len, sizeof(buf) - len,
748 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n", 752 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
749 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1), 753 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1),
750 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 754 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
751 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1))); 755 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1)));
752 len += snprintf(buf+len, sizeof(buf)-len, 756 len += snprintf(buf + len, sizeof(buf) - len,
753 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n", 757 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
754 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2), 758 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2),
755 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 759 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
@@ -827,13 +831,13 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
827 struct ath5k_buf *bf, *bf0; 831 struct ath5k_buf *bf, *bf0;
828 int i, n; 832 int i, n;
829 833
830 len += snprintf(buf+len, sizeof(buf)-len, 834 len += snprintf(buf + len, sizeof(buf) - len,
831 "available txbuffers: %d\n", sc->txbuf_len); 835 "available txbuffers: %d\n", sc->txbuf_len);
832 836
833 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { 837 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) {
834 txq = &sc->txqs[i]; 838 txq = &sc->txqs[i];
835 839
836 len += snprintf(buf+len, sizeof(buf)-len, 840 len += snprintf(buf + len, sizeof(buf) - len,
837 "%02d: %ssetup\n", i, txq->setup ? "" : "not "); 841 "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
838 842
839 if (!txq->setup) 843 if (!txq->setup)
@@ -845,9 +849,9 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
845 n++; 849 n++;
846 spin_unlock_bh(&txq->lock); 850 spin_unlock_bh(&txq->lock);
847 851
848 len += snprintf(buf+len, sizeof(buf)-len, 852 len += snprintf(buf + len, sizeof(buf) - len,
849 " len: %d bufs: %d\n", txq->txq_len, n); 853 " len: %d bufs: %d\n", txq->txq_len, n);
850 len += snprintf(buf+len, sizeof(buf)-len, 854 len += snprintf(buf + len, sizeof(buf) - len,
851 " stuck: %d\n", txq->txq_stuck); 855 " stuck: %d\n", txq->txq_stuck);
852 } 856 }
853 857
@@ -894,7 +898,7 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
894 898
895 phydir = debugfs_create_dir("ath5k", sc->hw->wiphy->debugfsdir); 899 phydir = debugfs_create_dir("ath5k", sc->hw->wiphy->debugfsdir);
896 if (!phydir) 900 if (!phydir)
897 return; 901 return;
898 902
899 debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, sc, 903 debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, sc,
900 &fops_debug); 904 &fops_debug);
@@ -918,6 +922,9 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
918 922
919 debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, sc, 923 debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, sc,
920 &fops_queue); 924 &fops_queue);
925
926 debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir,
927 &sc->ah->ah_use_32khz_clock);
921} 928}
922 929
923/* functions used in other places */ 930/* functions used in other places */
diff --git a/drivers/net/wireless/ath/ath5k/desc.h b/drivers/net/wireless/ath/ath5k/desc.h
index 2509d0bf037d..cfd529b548f3 100644
--- a/drivers/net/wireless/ath/ath5k/desc.h
+++ b/drivers/net/wireless/ath/ath5k/desc.h
@@ -58,11 +58,11 @@ struct ath5k_hw_rx_status {
58#define AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002 /* reception success */ 58#define AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002 /* reception success */
59#define AR5K_5210_RX_DESC_STATUS1_CRC_ERROR 0x00000004 /* CRC error */ 59#define AR5K_5210_RX_DESC_STATUS1_CRC_ERROR 0x00000004 /* CRC error */
60#define AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN_5210 0x00000008 /* [5210] FIFO overrun */ 60#define AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN_5210 0x00000008 /* [5210] FIFO overrun */
61#define AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000010 /* decyption CRC failure */ 61#define AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000010 /* decryption CRC failure */
62#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR 0x000000e0 /* PHY error */ 62#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR 0x000000e0 /* PHY error */
63#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR_S 5 63#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR_S 5
64#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100 /* key index valid */ 64#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100 /* key index valid */
65#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX 0x00007e00 /* decyption key index */ 65#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX 0x00007e00 /* decryption key index */
66#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_S 9 66#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_S 9
67#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x0fff8000 /* 13 bit of TSF */ 67#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x0fff8000 /* 13 bit of TSF */
68#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 15 68#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 15
diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c
index 21091c26a9a5..b788ecfbdaf6 100644
--- a/drivers/net/wireless/ath/ath5k/dma.c
+++ b/drivers/net/wireless/ath/ath5k/dma.c
@@ -25,7 +25,7 @@
25 * 25 *
26 * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and 26 * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and
27 * handle queue setup for 5210 chipset (rest are handled on qcu.c). 27 * handle queue setup for 5210 chipset (rest are handled on qcu.c).
28 * Also we setup interrupt mask register (IMR) and read the various iterrupt 28 * Also we setup interrupt mask register (IMR) and read the various interrupt
29 * status registers (ISR). 29 * status registers (ISR).
30 * 30 *
31 * TODO: Handle SISR on 5211+ and introduce a function to return the queue 31 * TODO: Handle SISR on 5211+ and introduce a function to return the queue
@@ -258,7 +258,7 @@ static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue)
258 /* For 2413+ order PCU to drop packets using 258 /* For 2413+ order PCU to drop packets using
259 * QUIET mechanism */ 259 * QUIET mechanism */
260 if (ah->ah_mac_version >= (AR5K_SREV_AR2414 >> 4) && 260 if (ah->ah_mac_version >= (AR5K_SREV_AR2414 >> 4) &&
261 pending){ 261 pending) {
262 /* Set periodicity and duration */ 262 /* Set periodicity and duration */
263 ath5k_hw_reg_write(ah, 263 ath5k_hw_reg_write(ah,
264 AR5K_REG_SM(100, AR5K_QUIET_CTL2_QT_PER)| 264 AR5K_REG_SM(100, AR5K_QUIET_CTL2_QT_PER)|
@@ -726,7 +726,7 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask)
726 int_mask |= AR5K_IMR_RXDOPPLER; 726 int_mask |= AR5K_IMR_RXDOPPLER;
727 727
728 /* Note: Per queue interrupt masks 728 /* Note: Per queue interrupt masks
729 * are set via reset_tx_queue (qcu.c) */ 729 * are set via ath5k_hw_reset_tx_queue() (qcu.c) */
730 ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR); 730 ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR);
731 ath5k_hw_reg_write(ah, simr2, AR5K_SIMR2); 731 ath5k_hw_reg_write(ah, simr2, AR5K_SIMR2);
732 732
@@ -783,7 +783,7 @@ void ath5k_hw_dma_init(struct ath5k_hw *ah)
783 * for all PCI-E cards to be safe). 783 * for all PCI-E cards to be safe).
784 * 784 *
785 * XXX: need to check 5210 for this 785 * XXX: need to check 5210 for this
786 * TODO: Check out tx triger level, it's always 64 on dumps but I 786 * TODO: Check out tx trigger level, it's always 64 on dumps but I
787 * guess we can tweak it and see how it goes ;-) 787 * guess we can tweak it and see how it goes ;-)
788 */ 788 */
789 if (ah->ah_version != AR5K_AR5210) { 789 if (ah->ah_version != AR5K_AR5210) {
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 392771f93759..d9e605e37007 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -223,14 +223,14 @@ static int ath5k_eeprom_read_ants(struct ath5k_hw *ah, u32 *offset,
223 ah->ah_ant_ctl[mode][AR5K_ANT_CTL] = 223 ah->ah_ant_ctl[mode][AR5K_ANT_CTL] =
224 (ee->ee_ant_control[mode][0] << 4); 224 (ee->ee_ant_control[mode][0] << 4);
225 ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_A] = 225 ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_A] =
226 ee->ee_ant_control[mode][1] | 226 ee->ee_ant_control[mode][1] |
227 (ee->ee_ant_control[mode][2] << 6) | 227 (ee->ee_ant_control[mode][2] << 6) |
228 (ee->ee_ant_control[mode][3] << 12) | 228 (ee->ee_ant_control[mode][3] << 12) |
229 (ee->ee_ant_control[mode][4] << 18) | 229 (ee->ee_ant_control[mode][4] << 18) |
230 (ee->ee_ant_control[mode][5] << 24); 230 (ee->ee_ant_control[mode][5] << 24);
231 ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_B] = 231 ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_B] =
232 ee->ee_ant_control[mode][6] | 232 ee->ee_ant_control[mode][6] |
233 (ee->ee_ant_control[mode][7] << 6) | 233 (ee->ee_ant_control[mode][7] << 6) |
234 (ee->ee_ant_control[mode][8] << 12) | 234 (ee->ee_ant_control[mode][8] << 12) |
235 (ee->ee_ant_control[mode][9] << 18) | 235 (ee->ee_ant_control[mode][9] << 18) |
236 (ee->ee_ant_control[mode][10] << 24); 236 (ee->ee_ant_control[mode][10] << 24);
@@ -255,7 +255,7 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
255 ee->ee_n_piers[mode] = 0; 255 ee->ee_n_piers[mode] = 0;
256 AR5K_EEPROM_READ(o++, val); 256 AR5K_EEPROM_READ(o++, val);
257 ee->ee_adc_desired_size[mode] = (s8)((val >> 8) & 0xff); 257 ee->ee_adc_desired_size[mode] = (s8)((val >> 8) & 0xff);
258 switch(mode) { 258 switch (mode) {
259 case AR5K_EEPROM_MODE_11A: 259 case AR5K_EEPROM_MODE_11A:
260 ee->ee_ob[mode][3] = (val >> 5) & 0x7; 260 ee->ee_ob[mode][3] = (val >> 5) & 0x7;
261 ee->ee_db[mode][3] = (val >> 2) & 0x7; 261 ee->ee_db[mode][3] = (val >> 2) & 0x7;
@@ -349,7 +349,7 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
349 /* Note: >= v5 have bg freq piers on another location 349 /* Note: >= v5 have bg freq piers on another location
350 * so these freq piers are ignored for >= v5 (should be 0xff 350 * so these freq piers are ignored for >= v5 (should be 0xff
351 * anyway) */ 351 * anyway) */
352 switch(mode) { 352 switch (mode) {
353 case AR5K_EEPROM_MODE_11A: 353 case AR5K_EEPROM_MODE_11A:
354 if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_1) 354 if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_1)
355 break; 355 break;
@@ -422,7 +422,7 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
422 if (ee->ee_version < AR5K_EEPROM_VERSION_5_0) 422 if (ee->ee_version < AR5K_EEPROM_VERSION_5_0)
423 goto done; 423 goto done;
424 424
425 switch (mode){ 425 switch (mode) {
426 case AR5K_EEPROM_MODE_11A: 426 case AR5K_EEPROM_MODE_11A:
427 ee->ee_switch_settling_turbo[mode] = (val >> 6) & 0x7f; 427 ee->ee_switch_settling_turbo[mode] = (val >> 6) & 0x7f;
428 428
@@ -436,7 +436,7 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
436 ee->ee_adc_desired_size_turbo[mode] |= (val & 0x1) << 7; 436 ee->ee_adc_desired_size_turbo[mode] |= (val & 0x1) << 7;
437 ee->ee_pga_desired_size_turbo[mode] = (val >> 1) & 0xff; 437 ee->ee_pga_desired_size_turbo[mode] = (val >> 1) & 0xff;
438 438
439 if (AR5K_EEPROM_EEMAP(ee->ee_misc0) >=2) 439 if (AR5K_EEPROM_EEMAP(ee->ee_misc0) >= 2)
440 ee->ee_pd_gain_overlap = (val >> 9) & 0xf; 440 ee->ee_pd_gain_overlap = (val >> 9) & 0xf;
441 break; 441 break;
442 case AR5K_EEPROM_MODE_11G: 442 case AR5K_EEPROM_MODE_11G:
@@ -516,7 +516,7 @@ ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max,
516 u16 val; 516 u16 val;
517 517
518 ee->ee_n_piers[mode] = 0; 518 ee->ee_n_piers[mode] = 0;
519 while(i < max) { 519 while (i < max) {
520 AR5K_EEPROM_READ(o++, val); 520 AR5K_EEPROM_READ(o++, val);
521 521
522 freq1 = val & 0xff; 522 freq1 = val & 0xff;
@@ -602,7 +602,7 @@ ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
602 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 602 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
603 struct ath5k_chan_pcal_info *pcal; 603 struct ath5k_chan_pcal_info *pcal;
604 604
605 switch(mode) { 605 switch (mode) {
606 case AR5K_EEPROM_MODE_11B: 606 case AR5K_EEPROM_MODE_11B:
607 pcal = ee->ee_pwr_cal_b; 607 pcal = ee->ee_pwr_cal_b;
608 break; 608 break;
@@ -634,7 +634,7 @@ ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
634/* Used to match PCDAC steps with power values on RF5111 chips 634/* Used to match PCDAC steps with power values on RF5111 chips
635 * (eeprom versions < 4). For RF5111 we have 11 pre-defined PCDAC 635 * (eeprom versions < 4). For RF5111 we have 11 pre-defined PCDAC
636 * steps that match with the power values we read from eeprom. On 636 * steps that match with the power values we read from eeprom. On
637 * older eeprom versions (< 3.2) these steps are equaly spaced at 637 * older eeprom versions (< 3.2) these steps are equally spaced at
638 * 10% of the pcdac curve -until the curve reaches its maximum- 638 * 10% of the pcdac curve -until the curve reaches its maximum-
639 * (11 steps from 0 to 100%) but on newer eeprom versions (>= 3.2) 639 * (11 steps from 0 to 100%) but on newer eeprom versions (>= 3.2)
640 * these 11 steps are spaced in a different way. This function returns 640 * these 11 steps are spaced in a different way. This function returns
@@ -644,10 +644,12 @@ ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
644static inline void 644static inline void
645ath5k_get_pcdac_intercepts(struct ath5k_hw *ah, u8 min, u8 max, u8 *vp) 645ath5k_get_pcdac_intercepts(struct ath5k_hw *ah, u8 min, u8 max, u8 *vp)
646{ 646{
647 static const u16 intercepts3[] = 647 static const u16 intercepts3[] = {
648 { 0, 5, 10, 20, 30, 50, 70, 85, 90, 95, 100 }; 648 0, 5, 10, 20, 30, 50, 70, 85, 90, 95, 100
649 static const u16 intercepts3_2[] = 649 };
650 { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; 650 static const u16 intercepts3_2[] = {
651 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
652 };
651 const u16 *ip; 653 const u16 *ip;
652 int i; 654 int i;
653 655
@@ -762,7 +764,7 @@ ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode,
762 764
763 /* Fill raw dataset 765 /* Fill raw dataset
764 * (convert power to 0.25dB units 766 * (convert power to 0.25dB units
765 * for RF5112 combatibility) */ 767 * for RF5112 compatibility) */
766 for (point = 0; point < pd->pd_points; point++) { 768 for (point = 0; point < pd->pd_points; point++) {
767 769
768 /* Absolute values */ 770 /* Absolute values */
@@ -796,7 +798,7 @@ ath5k_eeprom_read_pcal_info_5111(struct ath5k_hw *ah, int mode)
796 u16 val; 798 u16 val;
797 799
798 offset = AR5K_EEPROM_GROUPS_START(ee->ee_version); 800 offset = AR5K_EEPROM_GROUPS_START(ee->ee_version);
799 switch(mode) { 801 switch (mode) {
800 case AR5K_EEPROM_MODE_11A: 802 case AR5K_EEPROM_MODE_11A:
801 if (!AR5K_EEPROM_HDR_11A(ee->ee_header)) 803 if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
802 return 0; 804 return 0;
@@ -882,7 +884,7 @@ ath5k_eeprom_read_pcal_info_5111(struct ath5k_hw *ah, int mode)
882 * Read power calibration for RF5112 chips 884 * Read power calibration for RF5112 chips
883 * 885 *
884 * For RF5112 we have 4 XPD -eXternal Power Detector- curves 886 * For RF5112 we have 4 XPD -eXternal Power Detector- curves
885 * for each calibrated channel on 0, -6, -12 and -18dbm but we only 887 * for each calibrated channel on 0, -6, -12 and -18dBm but we only
886 * use the higher (3) and the lower (0) curves. Each curve has 0.5dB 888 * use the higher (3) and the lower (0) curves. Each curve has 0.5dB
887 * power steps on x axis and PCDAC steps on y axis and looks like a 889 * power steps on x axis and PCDAC steps on y axis and looks like a
888 * linear function. To recreate the curve and pass the power values 890 * linear function. To recreate the curve and pass the power values
@@ -1163,7 +1165,7 @@ ath5k_cal_data_offset_2413(struct ath5k_eeprom_info *ee, int mode)
1163{ 1165{
1164 u32 offset = AR5K_EEPROM_CAL_DATA_START(ee->ee_misc4); 1166 u32 offset = AR5K_EEPROM_CAL_DATA_START(ee->ee_misc4);
1165 1167
1166 switch(mode) { 1168 switch (mode) {
1167 case AR5K_EEPROM_MODE_11G: 1169 case AR5K_EEPROM_MODE_11G:
1168 if (AR5K_EEPROM_HDR_11B(ee->ee_header)) 1170 if (AR5K_EEPROM_HDR_11B(ee->ee_header))
1169 offset += ath5k_pdgains_size_2413(ee, 1171 offset += ath5k_pdgains_size_2413(ee,
@@ -1239,7 +1241,7 @@ ath5k_eeprom_convert_pcal_info_2413(struct ath5k_hw *ah, int mode,
1239 1241
1240 /* Fill raw dataset 1242 /* Fill raw dataset
1241 * convert all pwr levels to 1243 * convert all pwr levels to
1242 * quarter dB for RF5112 combatibility */ 1244 * quarter dB for RF5112 compatibility */
1243 pd->pd_step[0] = pcinfo->pddac_i[pdg]; 1245 pd->pd_step[0] = pcinfo->pddac_i[pdg];
1244 pd->pd_pwr[0] = 4 * pcinfo->pwr_i[pdg]; 1246 pd->pd_pwr[0] = 4 * pcinfo->pwr_i[pdg];
1245 1247
@@ -1620,8 +1622,8 @@ ath5k_eeprom_read_ctl_info(struct ath5k_hw *ah)
1620 offset += AR5K_EEPROM_GROUPS_START(ee->ee_version); 1622 offset += AR5K_EEPROM_GROUPS_START(ee->ee_version);
1621 1623
1622 rep = ee->ee_ctl_pwr; 1624 rep = ee->ee_ctl_pwr;
1623 for(i = 0; i < ee->ee_ctls; i++) { 1625 for (i = 0; i < ee->ee_ctls; i++) {
1624 switch(ee->ee_ctl[i] & AR5K_CTL_MODE_M) { 1626 switch (ee->ee_ctl[i] & AR5K_CTL_MODE_M) {
1625 case AR5K_CTL_11A: 1627 case AR5K_CTL_11A:
1626 case AR5K_CTL_TURBO: 1628 case AR5K_CTL_TURBO:
1627 ctl_mode = AR5K_EEPROM_MODE_11A; 1629 ctl_mode = AR5K_EEPROM_MODE_11A;
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
index 6511c27d938e..dc2bcfeadeb4 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.h
+++ b/drivers/net/wireless/ath/ath5k/eeprom.h
@@ -50,7 +50,7 @@
50 50
51#define AR5K_EEPROM_VERSION AR5K_EEPROM_INFO(1) /* EEPROM Version */ 51#define AR5K_EEPROM_VERSION AR5K_EEPROM_INFO(1) /* EEPROM Version */
52#define AR5K_EEPROM_VERSION_3_0 0x3000 /* No idea what's going on before this version */ 52#define AR5K_EEPROM_VERSION_3_0 0x3000 /* No idea what's going on before this version */
53#define AR5K_EEPROM_VERSION_3_1 0x3001 /* ob/db values for 2Ghz (ar5211_rfregs) */ 53#define AR5K_EEPROM_VERSION_3_1 0x3001 /* ob/db values for 2GHz (ar5211_rfregs) */
54#define AR5K_EEPROM_VERSION_3_2 0x3002 /* different frequency representation (eeprom_bin2freq) */ 54#define AR5K_EEPROM_VERSION_3_2 0x3002 /* different frequency representation (eeprom_bin2freq) */
55#define AR5K_EEPROM_VERSION_3_3 0x3003 /* offsets changed, has 32 CTLs (see below) and ee_false_detect (eeprom_read_modes) */ 55#define AR5K_EEPROM_VERSION_3_3 0x3003 /* offsets changed, has 32 CTLs (see below) and ee_false_detect (eeprom_read_modes) */
56#define AR5K_EEPROM_VERSION_3_4 0x3004 /* has ee_i_gain, ee_cck_ofdm_power_delta (eeprom_read_modes) */ 56#define AR5K_EEPROM_VERSION_3_4 0x3004 /* has ee_i_gain, ee_cck_ofdm_power_delta (eeprom_read_modes) */
@@ -75,11 +75,11 @@
75#define AR5K_EEPROM_HDR_11A(_v) (((_v) >> AR5K_EEPROM_MODE_11A) & 0x1) 75#define AR5K_EEPROM_HDR_11A(_v) (((_v) >> AR5K_EEPROM_MODE_11A) & 0x1)
76#define AR5K_EEPROM_HDR_11B(_v) (((_v) >> AR5K_EEPROM_MODE_11B) & 0x1) 76#define AR5K_EEPROM_HDR_11B(_v) (((_v) >> AR5K_EEPROM_MODE_11B) & 0x1)
77#define AR5K_EEPROM_HDR_11G(_v) (((_v) >> AR5K_EEPROM_MODE_11G) & 0x1) 77#define AR5K_EEPROM_HDR_11G(_v) (((_v) >> AR5K_EEPROM_MODE_11G) & 0x1)
78#define AR5K_EEPROM_HDR_T_2GHZ_DIS(_v) (((_v) >> 3) & 0x1) /* Disable turbo for 2Ghz */ 78#define AR5K_EEPROM_HDR_T_2GHZ_DIS(_v) (((_v) >> 3) & 0x1) /* Disable turbo for 2GHz */
79#define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v) (((_v) >> 4) & 0x7f) /* Max turbo power for < 2W power consumption */ 79#define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v) (((_v) >> 4) & 0x7f) /* Max turbo power for < 2W power consumption */
80#define AR5K_EEPROM_HDR_DEVICE(_v) (((_v) >> 11) & 0x7) /* Device type (1 Cardbus, 2 PCI, 3 MiniPCI, 4 AP) */ 80#define AR5K_EEPROM_HDR_DEVICE(_v) (((_v) >> 11) & 0x7) /* Device type (1 Cardbus, 2 PCI, 3 MiniPCI, 4 AP) */
81#define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */ 81#define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */
82#define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5Ghz */ 82#define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5GHz */
83 83
84/* Newer EEPROMs are using a different offset */ 84/* Newer EEPROMs are using a different offset */
85#define AR5K_EEPROM_OFF(_v, _v3_0, _v3_3) \ 85#define AR5K_EEPROM_OFF(_v, _v3_0, _v3_3) \
@@ -120,7 +120,7 @@
120#define AR5K_EEPROM_FF_DIS(_v) (((_v) >> 2) & 0x1) /* disable fast frames */ 120#define AR5K_EEPROM_FF_DIS(_v) (((_v) >> 2) & 0x1) /* disable fast frames */
121#define AR5K_EEPROM_BURST_DIS(_v) (((_v) >> 3) & 0x1) /* disable bursting */ 121#define AR5K_EEPROM_BURST_DIS(_v) (((_v) >> 3) & 0x1) /* disable bursting */
122#define AR5K_EEPROM_MAX_QCU(_v) (((_v) >> 4) & 0xf) /* max number of QCUs. defaults to 10 */ 122#define AR5K_EEPROM_MAX_QCU(_v) (((_v) >> 4) & 0xf) /* max number of QCUs. defaults to 10 */
123#define AR5K_EEPROM_HEAVY_CLIP_EN(_v) (((_v) >> 8) & 0x1) /* enable heayy clipping */ 123#define AR5K_EEPROM_HEAVY_CLIP_EN(_v) (((_v) >> 8) & 0x1) /* enable heavy clipping */
124#define AR5K_EEPROM_KEY_CACHE_SIZE(_v) (((_v) >> 12) & 0xf) /* key cache size. defaults to 128 */ 124#define AR5K_EEPROM_KEY_CACHE_SIZE(_v) (((_v) >> 12) & 0xf) /* key cache size. defaults to 128 */
125 125
126#define AR5K_EEPROM_MISC6 AR5K_EEPROM_INFO(10) 126#define AR5K_EEPROM_MISC6 AR5K_EEPROM_INFO(10)
@@ -223,7 +223,7 @@
223#define AR5K_EEPROM_CCK_OFDM_DELTA 15 223#define AR5K_EEPROM_CCK_OFDM_DELTA 15
224#define AR5K_EEPROM_N_IQ_CAL 2 224#define AR5K_EEPROM_N_IQ_CAL 2
225/* 5GHz/2GHz */ 225/* 5GHz/2GHz */
226enum ath5k_eeprom_freq_bands{ 226enum ath5k_eeprom_freq_bands {
227 AR5K_EEPROM_BAND_5GHZ = 0, 227 AR5K_EEPROM_BAND_5GHZ = 0,
228 AR5K_EEPROM_BAND_2GHZ = 1, 228 AR5K_EEPROM_BAND_2GHZ = 1,
229 AR5K_EEPROM_N_FREQ_BANDS, 229 AR5K_EEPROM_N_FREQ_BANDS,
@@ -270,7 +270,7 @@ enum ath5k_ctl_mode {
270 270
271/* Per channel calibration data, used for power table setup */ 271/* Per channel calibration data, used for power table setup */
272struct ath5k_chan_pcal_info_rf5111 { 272struct ath5k_chan_pcal_info_rf5111 {
273 /* Power levels in half dbm units 273 /* Power levels in half dBm units
274 * for one power curve. */ 274 * for one power curve. */
275 u8 pwr[AR5K_EEPROM_N_PWR_POINTS_5111]; 275 u8 pwr[AR5K_EEPROM_N_PWR_POINTS_5111];
276 /* PCDAC table steps 276 /* PCDAC table steps
diff --git a/drivers/net/wireless/ath/ath5k/initvals.c b/drivers/net/wireless/ath/ath5k/initvals.c
index e49340d18df4..855d1af3e710 100644
--- a/drivers/net/wireless/ath/ath5k/initvals.c
+++ b/drivers/net/wireless/ath/ath5k/initvals.c
@@ -113,8 +113,8 @@ static const struct ath5k_ini ar5210_ini[] = {
113 { AR5K_PHY(28), 0x0000000f }, 113 { AR5K_PHY(28), 0x0000000f },
114 { AR5K_PHY(29), 0x00000080 }, 114 { AR5K_PHY(29), 0x00000080 },
115 { AR5K_PHY(30), 0x00000004 }, 115 { AR5K_PHY(30), 0x00000004 },
116 { AR5K_PHY(31), 0x00000018 }, /* 0x987c */ 116 { AR5K_PHY(31), 0x00000018 }, /* 0x987c */
117 { AR5K_PHY(64), 0x00000000 }, /* 0x9900 */ 117 { AR5K_PHY(64), 0x00000000 }, /* 0x9900 */
118 { AR5K_PHY(65), 0x00000000 }, 118 { AR5K_PHY(65), 0x00000000 },
119 { AR5K_PHY(66), 0x00000000 }, 119 { AR5K_PHY(66), 0x00000000 },
120 { AR5K_PHY(67), 0x00800000 }, 120 { AR5K_PHY(67), 0x00800000 },
@@ -549,7 +549,7 @@ static const struct ath5k_ini ar5212_ini_common_start[] = {
549 { AR5K_DIAG_SW_5211, 0x00000000 }, 549 { AR5K_DIAG_SW_5211, 0x00000000 },
550 { AR5K_ADDAC_TEST, 0x00000000 }, 550 { AR5K_ADDAC_TEST, 0x00000000 },
551 { AR5K_DEFAULT_ANTENNA, 0x00000000 }, 551 { AR5K_DEFAULT_ANTENNA, 0x00000000 },
552 { AR5K_FRAME_CTL_QOSM, 0x000fc78f }, 552 { AR5K_FRAME_CTL_QOSM, 0x000fc78f },
553 { AR5K_XRMODE, 0x2a82301a }, 553 { AR5K_XRMODE, 0x2a82301a },
554 { AR5K_XRDELAY, 0x05dc01e0 }, 554 { AR5K_XRDELAY, 0x05dc01e0 },
555 { AR5K_XRTIMEOUT, 0x1f402710 }, 555 { AR5K_XRTIMEOUT, 0x1f402710 },
@@ -760,9 +760,9 @@ static const struct ath5k_ini_mode rf5111_ini_mode_end[] = {
760 760
761static const struct ath5k_ini rf5111_ini_common_end[] = { 761static const struct ath5k_ini rf5111_ini_common_end[] = {
762 { AR5K_DCU_FP, 0x00000000 }, 762 { AR5K_DCU_FP, 0x00000000 },
763 { AR5K_PHY_AGC, 0x00000000 }, 763 { AR5K_PHY_AGC, 0x00000000 },
764 { AR5K_PHY_ADC_CTL, 0x00022ffe }, 764 { AR5K_PHY_ADC_CTL, 0x00022ffe },
765 { 0x983c, 0x00020100 }, 765 { 0x983c, 0x00020100 },
766 { AR5K_PHY_GAIN_OFFSET, 0x1284613c }, 766 { AR5K_PHY_GAIN_OFFSET, 0x1284613c },
767 { AR5K_PHY_PAPD_PROBE, 0x00004883 }, 767 { AR5K_PHY_PAPD_PROBE, 0x00004883 },
768 { 0x9940, 0x00000004 }, 768 { 0x9940, 0x00000004 },
@@ -1409,7 +1409,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu)
1409 * Write initial register settings 1409 * Write initial register settings
1410 */ 1410 */
1411 1411
1412 /* For AR5212 and combatible */ 1412 /* For AR5212 and compatible */
1413 if (ah->ah_version == AR5K_AR5212) { 1413 if (ah->ah_version == AR5K_AR5212) {
1414 1414
1415 /* First set of mode-specific settings */ 1415 /* First set of mode-specific settings */
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index 576edf2965dc..127bfbd35172 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -43,16 +43,16 @@
43#include "ath5k.h" 43#include "ath5k.h"
44#include "base.h" 44#include "base.h"
45 45
46#define ATH_SDEVICE(subv,subd) \ 46#define ATH_SDEVICE(subv, subd) \
47 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ 47 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
48 .subvendor = (subv), .subdevice = (subd) 48 .subvendor = (subv), .subdevice = (subd)
49 49
50#define ATH_LED(pin,polarity) .driver_data = (((pin) << 8) | (polarity)) 50#define ATH_LED(pin, polarity) .driver_data = (((pin) << 8) | (polarity))
51#define ATH_PIN(data) ((data) >> 8) 51#define ATH_PIN(data) ((data) >> 8)
52#define ATH_POLARITY(data) ((data) & 0xff) 52#define ATH_POLARITY(data) ((data) & 0xff)
53 53
54/* Devices we match on for LED config info (typically laptops) */ 54/* Devices we match on for LED config info (typically laptops) */
55static const struct pci_device_id ath5k_led_devices[] = { 55static DEFINE_PCI_DEVICE_TABLE(ath5k_led_devices) = {
56 /* AR5211 */ 56 /* AR5211 */
57 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5211), ATH_LED(0, 0) }, 57 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5211), ATH_LED(0, 0) },
58 /* HP Compaq nc6xx, nc4000, nx6000 */ 58 /* HP Compaq nc6xx, nc4000, nx6000 */
@@ -157,7 +157,7 @@ void ath5k_unregister_leds(struct ath5k_softc *sc)
157 ath5k_unregister_led(&sc->tx_led); 157 ath5k_unregister_led(&sc->tx_led);
158} 158}
159 159
160int ath5k_init_leds(struct ath5k_softc *sc) 160int __devinit ath5k_init_leds(struct ath5k_softc *sc)
161{ 161{
162 int ret = 0; 162 int ret = 0;
163 struct ieee80211_hw *hw = sc->hw; 163 struct ieee80211_hw *hw = sc->hw;
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index 493908299bb4..0d5ab3428be5 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -348,7 +348,7 @@ ath5k_prepare_multicast(struct ieee80211_hw *hw,
348 mfilt[pos / 32] |= (1 << (pos % 32)); 348 mfilt[pos / 32] |= (1 << (pos % 32));
349 /* XXX: we might be able to just do this instead, 349 /* XXX: we might be able to just do this instead,
350 * but not sure, needs testing, if we do use this we'd 350 * but not sure, needs testing, if we do use this we'd
351 * neet to inform below to not reset the mcast */ 351 * need to inform below not to reset the mcast */
352 /* ath5k_hw_set_mcast_filterindex(ah, 352 /* ath5k_hw_set_mcast_filterindex(ah,
353 * ha->addr[5]); */ 353 * ha->addr[5]); */
354 } 354 }
@@ -471,7 +471,7 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
471 if (iter_data.n_stas > 1) { 471 if (iter_data.n_stas > 1) {
472 /* If you have multiple STA interfaces connected to 472 /* If you have multiple STA interfaces connected to
473 * different APs, ARPs are not received (most of the time?) 473 * different APs, ARPs are not received (most of the time?)
474 * Enabling PROMISC appears to fix that probem. 474 * Enabling PROMISC appears to fix that problem.
475 */ 475 */
476 rfilt |= AR5K_RX_FILTER_PROM; 476 rfilt |= AR5K_RX_FILTER_PROM;
477 } 477 }
diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c
index f2c0c236392f..aac5b7831948 100644
--- a/drivers/net/wireless/ath/ath5k/pci.c
+++ b/drivers/net/wireless/ath/ath5k/pci.c
@@ -34,12 +34,12 @@ static DEFINE_PCI_DEVICE_TABLE(ath5k_pci_id_table) = {
34 { PCI_VDEVICE(3COM_2, 0x0013) }, /* 3com 5212 */ 34 { PCI_VDEVICE(3COM_2, 0x0013) }, /* 3com 5212 */
35 { PCI_VDEVICE(3COM, 0x0013) }, /* 3com 3CRDAG675 5212 */ 35 { PCI_VDEVICE(3COM, 0x0013) }, /* 3com 3CRDAG675 5212 */
36 { PCI_VDEVICE(ATHEROS, 0x1014) }, /* IBM minipci 5212 */ 36 { PCI_VDEVICE(ATHEROS, 0x1014) }, /* IBM minipci 5212 */
37 { PCI_VDEVICE(ATHEROS, 0x0014) }, /* 5212 combatible */ 37 { PCI_VDEVICE(ATHEROS, 0x0014) }, /* 5212 compatible */
38 { PCI_VDEVICE(ATHEROS, 0x0015) }, /* 5212 combatible */ 38 { PCI_VDEVICE(ATHEROS, 0x0015) }, /* 5212 compatible */
39 { PCI_VDEVICE(ATHEROS, 0x0016) }, /* 5212 combatible */ 39 { PCI_VDEVICE(ATHEROS, 0x0016) }, /* 5212 compatible */
40 { PCI_VDEVICE(ATHEROS, 0x0017) }, /* 5212 combatible */ 40 { PCI_VDEVICE(ATHEROS, 0x0017) }, /* 5212 compatible */
41 { PCI_VDEVICE(ATHEROS, 0x0018) }, /* 5212 combatible */ 41 { PCI_VDEVICE(ATHEROS, 0x0018) }, /* 5212 compatible */
42 { PCI_VDEVICE(ATHEROS, 0x0019) }, /* 5212 combatible */ 42 { PCI_VDEVICE(ATHEROS, 0x0019) }, /* 5212 compatible */
43 { PCI_VDEVICE(ATHEROS, 0x001a) }, /* 2413 Griffin-lite */ 43 { PCI_VDEVICE(ATHEROS, 0x001a) }, /* 2413 Griffin-lite */
44 { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ 44 { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */
45 { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ 45 { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */
@@ -234,7 +234,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
234 234
235 mem = pci_iomap(pdev, 0, 0); 235 mem = pci_iomap(pdev, 0, 0);
236 if (!mem) { 236 if (!mem) {
237 dev_err(&pdev->dev, "cannot remap PCI memory region\n") ; 237 dev_err(&pdev->dev, "cannot remap PCI memory region\n");
238 ret = -EIO; 238 ret = -EIO;
239 goto err_reg; 239 goto err_reg;
240 } 240 }
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c
index 712a9ac4000e..618ee54d5fe5 100644
--- a/drivers/net/wireless/ath/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -32,7 +32,7 @@
32#include "base.h" 32#include "base.h"
33 33
34/* 34/*
35 * AR5212+ can use higher rates for ack transmition 35 * AR5212+ can use higher rates for ack transmission
36 * based on current tx rate instead of the base rate. 36 * based on current tx rate instead of the base rate.
37 * It does this to better utilize channel usage. 37 * It does this to better utilize channel usage.
38 * This is a mapping between G rates (that cover both 38 * This is a mapping between G rates (that cover both
@@ -534,9 +534,9 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah)
534 534
535 local_irq_restore(flags); 535 local_irq_restore(flags);
536 536
537 WARN_ON( i == ATH5K_MAX_TSF_READ ); 537 WARN_ON(i == ATH5K_MAX_TSF_READ);
538 538
539 return (((u64)tsf_upper1 << 32) | tsf_lower); 539 return ((u64)tsf_upper1 << 32) | tsf_lower;
540} 540}
541 541
542/** 542/**
@@ -643,14 +643,14 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
643 /* Flush any pending BMISS interrupts on ISR by 643 /* Flush any pending BMISS interrupts on ISR by
644 * performing a clear-on-write operation on PISR 644 * performing a clear-on-write operation on PISR
645 * register for the BMISS bit (writing a bit on 645 * register for the BMISS bit (writing a bit on
646 * ISR togles a reset for that bit and leaves 646 * ISR toggles a reset for that bit and leaves
647 * the rest bits intact) */ 647 * the remaining bits intact) */
648 if (ah->ah_version == AR5K_AR5210) 648 if (ah->ah_version == AR5K_AR5210)
649 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_ISR); 649 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_ISR);
650 else 650 else
651 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_PISR); 651 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_PISR);
652 652
653 /* TODO: Set enchanced sleep registers on AR5212 653 /* TODO: Set enhanced sleep registers on AR5212
654 * based on vif->bss_conf params, until then 654 * based on vif->bss_conf params, until then
655 * disable power save reporting.*/ 655 * disable power save reporting.*/
656 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV); 656 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV);
@@ -738,7 +738,7 @@ ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval)
738 dma = ath5k_hw_reg_read(ah, AR5K_TIMER1) >> 3; 738 dma = ath5k_hw_reg_read(ah, AR5K_TIMER1) >> 3;
739 739
740 /* NOTE: SWBA is different. Having a wrong window there does not 740 /* NOTE: SWBA is different. Having a wrong window there does not
741 * stop us from sending data and this condition is catched thru 741 * stop us from sending data and this condition is caught by
742 * other means (SWBA interrupt) */ 742 * other means (SWBA interrupt) */
743 743
744 if (ath5k_check_timer_win(nbtt, atim, 1, intval) && 744 if (ath5k_check_timer_win(nbtt, atim, 1, intval) &&
@@ -896,7 +896,7 @@ void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
896 /* Set RSSI/BRSSI thresholds 896 /* Set RSSI/BRSSI thresholds
897 * 897 *
898 * Note: If we decide to set this value 898 * Note: If we decide to set this value
899 * dynamicaly, have in mind that when AR5K_RSSI_THR 899 * dynamically, have in mind that when AR5K_RSSI_THR
900 * register is read it might return 0x40 if we haven't 900 * register is read it might return 0x40 if we haven't
901 * wrote anything to it plus BMISS RSSI threshold is zeroed. 901 * wrote anything to it plus BMISS RSSI threshold is zeroed.
902 * So doing a save/restore procedure here isn't the right 902 * So doing a save/restore procedure here isn't the right
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 55441913344d..dd2b417729ba 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -105,6 +105,7 @@ bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
105 105
106 if ((ah->ah_radio == AR5K_RF5112) || 106 if ((ah->ah_radio == AR5K_RF5112) ||
107 (ah->ah_radio == AR5K_RF5413) || 107 (ah->ah_radio == AR5K_RF5413) ||
108 (ah->ah_radio == AR5K_RF2413) ||
108 (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4))) 109 (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4)))
109 refclk_freq = 40; 110 refclk_freq = 40;
110 else 111 else
@@ -173,7 +174,7 @@ static unsigned int ath5k_hw_rfb_op(struct ath5k_hw *ah,
173 data = ath5k_hw_bitswap(val, num_bits); 174 data = ath5k_hw_bitswap(val, num_bits);
174 175
175 for (bits_shifted = 0, bits_left = num_bits; bits_left > 0; 176 for (bits_shifted = 0, bits_left = num_bits; bits_left > 0;
176 position = 0, entry++) { 177 position = 0, entry++) {
177 178
178 last_bit = (position + bits_left > 8) ? 8 : 179 last_bit = (position + bits_left > 8) ? 8 :
179 position + bits_left; 180 position + bits_left;
@@ -363,7 +364,7 @@ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah)
363 return 0; 364 return 0;
364} 365}
365 366
366/* Schedule a gain probe check on the next transmited packet. 367/* Schedule a gain probe check on the next transmitted packet.
367 * That means our next packet is going to be sent with lower 368 * That means our next packet is going to be sent with lower
368 * tx power and a Peak to Average Power Detector (PAPD) will try 369 * tx power and a Peak to Average Power Detector (PAPD) will try
369 * to measure the gain. 370 * to measure the gain.
@@ -472,7 +473,7 @@ static bool ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah)
472 level[0] = 0; 473 level[0] = 0;
473 level[1] = (step == 63) ? 50 : step + 4; 474 level[1] = (step == 63) ? 50 : step + 4;
474 level[2] = (step != 63) ? 64 : level[0]; 475 level[2] = (step != 63) ? 64 : level[0];
475 level[3] = level[2] + 50 ; 476 level[3] = level[2] + 50;
476 477
477 ah->ah_gain.g_high = level[3] - 478 ah->ah_gain.g_high = level[3] -
478 (step == 63 ? AR5K_GAIN_DYN_ADJUST_HI_MARGIN : -5); 479 (step == 63 ? AR5K_GAIN_DYN_ADJUST_HI_MARGIN : -5);
@@ -549,7 +550,7 @@ static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah)
549 550
550 for (ah->ah_gain.g_target = ah->ah_gain.g_current; 551 for (ah->ah_gain.g_target = ah->ah_gain.g_current;
551 ah->ah_gain.g_target <= ah->ah_gain.g_low && 552 ah->ah_gain.g_target <= ah->ah_gain.g_low &&
552 ah->ah_gain.g_step_idx < go->go_steps_count-1; 553 ah->ah_gain.g_step_idx < go->go_steps_count - 1;
553 g_step = &go->go_step[ah->ah_gain.g_step_idx]) 554 g_step = &go->go_step[ah->ah_gain.g_step_idx])
554 ah->ah_gain.g_target -= 2 * 555 ah->ah_gain.g_target -= 2 *
555 (go->go_step[++ah->ah_gain.g_step_idx].gos_gain - 556 (go->go_step[++ah->ah_gain.g_step_idx].gos_gain -
@@ -614,13 +615,13 @@ enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah)
614 ath5k_hw_rf_gainf_corr(ah); 615 ath5k_hw_rf_gainf_corr(ah);
615 ah->ah_gain.g_current = 616 ah->ah_gain.g_current =
616 ah->ah_gain.g_current >= ah->ah_gain.g_f_corr ? 617 ah->ah_gain.g_current >= ah->ah_gain.g_f_corr ?
617 (ah->ah_gain.g_current-ah->ah_gain.g_f_corr) : 618 (ah->ah_gain.g_current - ah->ah_gain.g_f_corr) :
618 0; 619 0;
619 } 620 }
620 621
621 /* Check if measurement is ok and if we need 622 /* Check if measurement is ok and if we need
622 * to adjust gain, schedule a gain adjustment, 623 * to adjust gain, schedule a gain adjustment,
623 * else switch back to the acive state */ 624 * else switch back to the active state */
624 if (ath5k_hw_rf_check_gainf_readback(ah) && 625 if (ath5k_hw_rf_check_gainf_readback(ah) &&
625 AR5K_GAIN_CHECK_ADJUST(&ah->ah_gain) && 626 AR5K_GAIN_CHECK_ADJUST(&ah->ah_gain) &&
626 ath5k_hw_rf_gainf_adjust(ah)) { 627 ath5k_hw_rf_gainf_adjust(ah)) {
@@ -807,7 +808,7 @@ static int ath5k_hw_rfregs_init(struct ath5k_hw *ah,
807 * use b_OB and b_DB parameters stored 808 * use b_OB and b_DB parameters stored
808 * in eeprom on ee->ee_ob[ee_mode][0] 809 * in eeprom on ee->ee_ob[ee_mode][0]
809 * 810 *
810 * For all other chips we use OB/DB for 2Ghz 811 * For all other chips we use OB/DB for 2GHz
811 * stored in the b/g modal section just like 812 * stored in the b/g modal section just like
812 * 802.11a on ee->ee_ob[ee_mode][1] */ 813 * 802.11a on ee->ee_ob[ee_mode][1] */
813 if ((ah->ah_radio == AR5K_RF5111) || 814 if ((ah->ah_radio == AR5K_RF5111) ||
@@ -970,17 +971,20 @@ static int ath5k_hw_rfregs_init(struct ath5k_hw *ah,
970 } 971 }
971 972
972 /* Lower synth voltage on Rev 2 */ 973 /* Lower synth voltage on Rev 2 */
973 ath5k_hw_rfb_op(ah, rf_regs, 2, 974 if (ah->ah_radio == AR5K_RF5112 &&
974 AR5K_RF_HIGH_VC_CP, true); 975 (ah->ah_radio_5ghz_revision & AR5K_SREV_REV) > 0) {
976 ath5k_hw_rfb_op(ah, rf_regs, 2,
977 AR5K_RF_HIGH_VC_CP, true);
975 978
976 ath5k_hw_rfb_op(ah, rf_regs, 2, 979 ath5k_hw_rfb_op(ah, rf_regs, 2,
977 AR5K_RF_MID_VC_CP, true); 980 AR5K_RF_MID_VC_CP, true);
978 981
979 ath5k_hw_rfb_op(ah, rf_regs, 2, 982 ath5k_hw_rfb_op(ah, rf_regs, 2,
980 AR5K_RF_LOW_VC_CP, true); 983 AR5K_RF_LOW_VC_CP, true);
981 984
982 ath5k_hw_rfb_op(ah, rf_regs, 2, 985 ath5k_hw_rfb_op(ah, rf_regs, 2,
983 AR5K_RF_PUSH_UP, true); 986 AR5K_RF_PUSH_UP, true);
987 }
984 988
985 /* Decrease power consumption on 5213+ BaseBand */ 989 /* Decrease power consumption on 5213+ BaseBand */
986 if (ah->ah_phy_revision >= AR5K_SREV_PHY_5212A) { 990 if (ah->ah_phy_revision >= AR5K_SREV_PHY_5212A) {
@@ -1259,7 +1263,7 @@ static int ath5k_hw_channel(struct ath5k_hw *ah,
1259{ 1263{
1260 int ret; 1264 int ret;
1261 /* 1265 /*
1262 * Check bounds supported by the PHY (we don't care about regultory 1266 * Check bounds supported by the PHY (we don't care about regulatory
1263 * restrictions at this point). Note: hw_value already has the band 1267 * restrictions at this point). Note: hw_value already has the band
1264 * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok() 1268 * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
1265 * of the band by that */ 1269 * of the band by that */
@@ -1331,7 +1335,7 @@ void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah)
1331static void ath5k_hw_update_nfcal_hist(struct ath5k_hw *ah, s16 noise_floor) 1335static void ath5k_hw_update_nfcal_hist(struct ath5k_hw *ah, s16 noise_floor)
1332{ 1336{
1333 struct ath5k_nfcal_hist *hist = &ah->ah_nfcal_hist; 1337 struct ath5k_nfcal_hist *hist = &ah->ah_nfcal_hist;
1334 hist->index = (hist->index + 1) & (ATH5K_NF_CAL_HIST_MAX-1); 1338 hist->index = (hist->index + 1) & (ATH5K_NF_CAL_HIST_MAX - 1);
1335 hist->nfval[hist->index] = noise_floor; 1339 hist->nfval[hist->index] = noise_floor;
1336} 1340}
1337 1341
@@ -1344,10 +1348,10 @@ static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
1344 memcpy(sort, ah->ah_nfcal_hist.nfval, sizeof(sort)); 1348 memcpy(sort, ah->ah_nfcal_hist.nfval, sizeof(sort));
1345 for (i = 0; i < ATH5K_NF_CAL_HIST_MAX - 1; i++) { 1349 for (i = 0; i < ATH5K_NF_CAL_HIST_MAX - 1; i++) {
1346 for (j = 1; j < ATH5K_NF_CAL_HIST_MAX - i; j++) { 1350 for (j = 1; j < ATH5K_NF_CAL_HIST_MAX - i; j++) {
1347 if (sort[j] > sort[j-1]) { 1351 if (sort[j] > sort[j - 1]) {
1348 tmp = sort[j]; 1352 tmp = sort[j];
1349 sort[j] = sort[j-1]; 1353 sort[j] = sort[j - 1];
1350 sort[j-1] = tmp; 1354 sort[j - 1] = tmp;
1351 } 1355 }
1352 } 1356 }
1353 } 1357 }
@@ -1355,7 +1359,7 @@ static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
1355 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1359 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
1356 "cal %d:%d\n", i, sort[i]); 1360 "cal %d:%d\n", i, sort[i]);
1357 } 1361 }
1358 return sort[(ATH5K_NF_CAL_HIST_MAX-1) / 2]; 1362 return sort[(ATH5K_NF_CAL_HIST_MAX - 1) / 2];
1359} 1363}
1360 1364
1361/* 1365/*
@@ -1604,11 +1608,13 @@ int ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
1604 int ret; 1608 int ret;
1605 1609
1606 if (ah->ah_radio == AR5K_RF5110) 1610 if (ah->ah_radio == AR5K_RF5110)
1607 ret = ath5k_hw_rf5110_calibrate(ah, channel); 1611 return ath5k_hw_rf5110_calibrate(ah, channel);
1608 else { 1612
1609 ret = ath5k_hw_rf511x_iq_calibrate(ah); 1613 ret = ath5k_hw_rf511x_iq_calibrate(ah);
1614
1615 if ((ah->ah_radio == AR5K_RF5111 || ah->ah_radio == AR5K_RF5112) &&
1616 (channel->hw_value & CHANNEL_OFDM))
1610 ath5k_hw_request_rfgain_probe(ah); 1617 ath5k_hw_request_rfgain_probe(ah);
1611 }
1612 1618
1613 return ret; 1619 return ret;
1614} 1620}
@@ -1815,7 +1821,7 @@ ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah,
1815 1821
1816 } else if (ath5k_hw_reg_read(ah, AR5K_PHY_IQ) & 1822 } else if (ath5k_hw_reg_read(ah, AR5K_PHY_IQ) &
1817 AR5K_PHY_IQ_SPUR_FILT_EN) { 1823 AR5K_PHY_IQ_SPUR_FILT_EN) {
1818 /* Clean up spur mitigation settings and disable fliter */ 1824 /* Clean up spur mitigation settings and disable filter */
1819 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL, 1825 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL,
1820 AR5K_PHY_BIN_MASK_CTL_RATE, 0); 1826 AR5K_PHY_BIN_MASK_CTL_RATE, 0);
1821 AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_IQ, 1827 AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_IQ,
@@ -2080,7 +2086,7 @@ ath5k_get_interpolated_value(s16 target, s16 x_left, s16 x_right,
2080 * always 1 instead of 1.25, 1.75 etc). We scale up by 100 2086 * always 1 instead of 1.25, 1.75 etc). We scale up by 100
2081 * to have some accuracy both for 0.5 and 0.25 steps. 2087 * to have some accuracy both for 0.5 and 0.25 steps.
2082 */ 2088 */
2083 ratio = ((100 * y_right - 100 * y_left)/(x_right - x_left)); 2089 ratio = ((100 * y_right - 100 * y_left) / (x_right - x_left));
2084 2090
2085 /* Now scale down to be in range */ 2091 /* Now scale down to be in range */
2086 result = y_left + (ratio * (target - x_left) / 100); 2092 result = y_left + (ratio * (target - x_left) / 100);
@@ -2159,7 +2165,7 @@ ath5k_create_power_curve(s16 pmin, s16 pmax,
2159 u8 *vpd_table, u8 type) 2165 u8 *vpd_table, u8 type)
2160{ 2166{
2161 u8 idx[2] = { 0, 1 }; 2167 u8 idx[2] = { 0, 1 };
2162 s16 pwr_i = 2*pmin; 2168 s16 pwr_i = 2 * pmin;
2163 int i; 2169 int i;
2164 2170
2165 if (num_points < 2) 2171 if (num_points < 2)
@@ -2437,7 +2443,7 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
2437 } 2443 }
2438 2444
2439 if (edge_pwr) 2445 if (edge_pwr)
2440 ah->ah_txpower.txp_max_pwr = 4*min(edge_pwr, max_chan_pwr); 2446 ah->ah_txpower.txp_max_pwr = 4 * min(edge_pwr, max_chan_pwr);
2441} 2447}
2442 2448
2443 2449
@@ -2456,7 +2462,7 @@ static void
2456ath5k_fill_pwr_to_pcdac_table(struct ath5k_hw *ah, s16* table_min, 2462ath5k_fill_pwr_to_pcdac_table(struct ath5k_hw *ah, s16* table_min,
2457 s16 *table_max) 2463 s16 *table_max)
2458{ 2464{
2459 u8 *pcdac_out = ah->ah_txpower.txp_pd_table; 2465 u8 *pcdac_out = ah->ah_txpower.txp_pd_table;
2460 u8 *pcdac_tmp = ah->ah_txpower.tmpL[0]; 2466 u8 *pcdac_tmp = ah->ah_txpower.tmpL[0];
2461 u8 pcdac_0, pcdac_n, pcdac_i, pwr_idx, i; 2467 u8 pcdac_0, pcdac_n, pcdac_i, pwr_idx, i;
2462 s16 min_pwr, max_pwr; 2468 s16 min_pwr, max_pwr;
@@ -2475,8 +2481,8 @@ ath5k_fill_pwr_to_pcdac_table(struct ath5k_hw *ah, s16* table_min,
2475 2481
2476 /* Copy values from pcdac_tmp */ 2482 /* Copy values from pcdac_tmp */
2477 pwr_idx = min_pwr; 2483 pwr_idx = min_pwr;
2478 for (i = 0 ; pwr_idx <= max_pwr && 2484 for (i = 0; pwr_idx <= max_pwr &&
2479 pcdac_i < AR5K_EEPROM_POWER_TABLE_SIZE; i++) { 2485 pcdac_i < AR5K_EEPROM_POWER_TABLE_SIZE; i++) {
2480 pcdac_out[pcdac_i++] = pcdac_tmp[i]; 2486 pcdac_out[pcdac_i++] = pcdac_tmp[i];
2481 pwr_idx++; 2487 pwr_idx++;
2482 } 2488 }
@@ -2502,7 +2508,7 @@ static void
2502ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min, 2508ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2503 s16 *table_max, u8 pdcurves) 2509 s16 *table_max, u8 pdcurves)
2504{ 2510{
2505 u8 *pcdac_out = ah->ah_txpower.txp_pd_table; 2511 u8 *pcdac_out = ah->ah_txpower.txp_pd_table;
2506 u8 *pcdac_low_pwr; 2512 u8 *pcdac_low_pwr;
2507 u8 *pcdac_high_pwr; 2513 u8 *pcdac_high_pwr;
2508 u8 *pcdac_tmp; 2514 u8 *pcdac_tmp;
@@ -2510,8 +2516,8 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2510 s16 max_pwr_idx; 2516 s16 max_pwr_idx;
2511 s16 min_pwr_idx; 2517 s16 min_pwr_idx;
2512 s16 mid_pwr_idx = 0; 2518 s16 mid_pwr_idx = 0;
2513 /* Edge flag turs on the 7nth bit on the PCDAC 2519 /* Edge flag turns on the 7nth bit on the PCDAC
2514 * to delcare the higher power curve (force values 2520 * to declare the higher power curve (force values
2515 * to be greater than 64). If we only have one curve 2521 * to be greater than 64). If we only have one curve
2516 * we don't need to set this, if we have 2 curves and 2522 * we don't need to set this, if we have 2 curves and
2517 * fill the table backwards this can also be used to 2523 * fill the table backwards this can also be used to
@@ -2552,7 +2558,7 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2552 } 2558 }
2553 2559
2554 /* This is used when setting tx power*/ 2560 /* This is used when setting tx power*/
2555 ah->ah_txpower.txp_min_idx = min_pwr_idx/2; 2561 ah->ah_txpower.txp_min_idx = min_pwr_idx / 2;
2556 2562
2557 /* Fill Power to PCDAC table backwards */ 2563 /* Fill Power to PCDAC table backwards */
2558 pwr = max_pwr_idx; 2564 pwr = max_pwr_idx;
@@ -2561,14 +2567,14 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2561 * edge flag and set pcdac_tmp to lower 2567 * edge flag and set pcdac_tmp to lower
2562 * power curve.*/ 2568 * power curve.*/
2563 if (edge_flag == 0x40 && 2569 if (edge_flag == 0x40 &&
2564 (2*pwr <= (table_max[1] - table_min[0]) || pwr == 0)) { 2570 (2 * pwr <= (table_max[1] - table_min[0]) || pwr == 0)) {
2565 edge_flag = 0x00; 2571 edge_flag = 0x00;
2566 pcdac_tmp = pcdac_low_pwr; 2572 pcdac_tmp = pcdac_low_pwr;
2567 pwr = mid_pwr_idx/2; 2573 pwr = mid_pwr_idx / 2;
2568 } 2574 }
2569 2575
2570 /* Don't go below 1, extrapolate below if we have 2576 /* Don't go below 1, extrapolate below if we have
2571 * already swithced to the lower power curve -or 2577 * already switched to the lower power curve -or
2572 * we only have one curve and edge_flag is zero 2578 * we only have one curve and edge_flag is zero
2573 * anyway */ 2579 * anyway */
2574 if (pcdac_tmp[pwr] < 1 && (edge_flag == 0x00)) { 2580 if (pcdac_tmp[pwr] < 1 && (edge_flag == 0x00)) {
@@ -2596,7 +2602,7 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2596static void 2602static void
2597ath5k_write_pcdac_table(struct ath5k_hw *ah) 2603ath5k_write_pcdac_table(struct ath5k_hw *ah)
2598{ 2604{
2599 u8 *pcdac_out = ah->ah_txpower.txp_pd_table; 2605 u8 *pcdac_out = ah->ah_txpower.txp_pd_table;
2600 int i; 2606 int i;
2601 2607
2602 /* 2608 /*
@@ -2604,8 +2610,8 @@ ath5k_write_pcdac_table(struct ath5k_hw *ah)
2604 */ 2610 */
2605 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) { 2611 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
2606 ath5k_hw_reg_write(ah, 2612 ath5k_hw_reg_write(ah,
2607 (((pcdac_out[2*i + 0] << 8 | 0xff) & 0xffff) << 0) | 2613 (((pcdac_out[2 * i + 0] << 8 | 0xff) & 0xffff) << 0) |
2608 (((pcdac_out[2*i + 1] << 8 | 0xff) & 0xffff) << 16), 2614 (((pcdac_out[2 * i + 1] << 8 | 0xff) & 0xffff) << 16),
2609 AR5K_PHY_PCDAC_TXPOWER(i)); 2615 AR5K_PHY_PCDAC_TXPOWER(i));
2610 } 2616 }
2611} 2617}
@@ -2789,10 +2795,10 @@ ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode)
2789 */ 2795 */
2790 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) { 2796 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
2791 ath5k_hw_reg_write(ah, 2797 ath5k_hw_reg_write(ah,
2792 ((pdadc_out[4*i + 0] & 0xff) << 0) | 2798 ((pdadc_out[4 * i + 0] & 0xff) << 0) |
2793 ((pdadc_out[4*i + 1] & 0xff) << 8) | 2799 ((pdadc_out[4 * i + 1] & 0xff) << 8) |
2794 ((pdadc_out[4*i + 2] & 0xff) << 16) | 2800 ((pdadc_out[4 * i + 2] & 0xff) << 16) |
2795 ((pdadc_out[4*i + 3] & 0xff) << 24), 2801 ((pdadc_out[4 * i + 3] & 0xff) << 24),
2796 AR5K_PHY_PDADC_TXPOWER(i)); 2802 AR5K_PHY_PDADC_TXPOWER(i));
2797 } 2803 }
2798} 2804}
@@ -2805,7 +2811,7 @@ ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode)
2805/* 2811/*
2806 * This is the main function that uses all of the above 2812 * This is the main function that uses all of the above
2807 * to set PCDAC/PDADC table on hw for the current channel. 2813 * to set PCDAC/PDADC table on hw for the current channel.
2808 * This table is used for tx power calibration on the basband, 2814 * This table is used for tx power calibration on the baseband,
2809 * without it we get weird tx power levels and in some cases 2815 * without it we get weird tx power levels and in some cases
2810 * distorted spectral mask 2816 * distorted spectral mask
2811 */ 2817 */
diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h
index d12b827033c1..f5c1000045d3 100644
--- a/drivers/net/wireless/ath/ath5k/reg.h
+++ b/drivers/net/wireless/ath/ath5k/reg.h
@@ -72,7 +72,7 @@
72#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */ 72#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */
73#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */ 73#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */
74#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */ 74#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */
75#define AR5K_CFG_IBSS 0x00000020 /* 0-BSS, 1-IBSS [5211+] */ 75#define AR5K_CFG_IBSS 0x00000020 /* 0-BSS, 1-IBSS [5211+] */
76#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */ 76#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */
77#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */ 77#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */
78#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */ 78#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */
@@ -170,7 +170,7 @@
170#define AR5K_TXCFG_SDMAMR_S 0 170#define AR5K_TXCFG_SDMAMR_S 0
171#define AR5K_TXCFG_B_MODE 0x00000008 /* Set b mode for 5111 (enable 2111) */ 171#define AR5K_TXCFG_B_MODE 0x00000008 /* Set b mode for 5111 (enable 2111) */
172#define AR5K_TXCFG_TXFSTP 0x00000008 /* TX DMA full Stop [5210] */ 172#define AR5K_TXCFG_TXFSTP 0x00000008 /* TX DMA full Stop [5210] */
173#define AR5K_TXCFG_TXFULL 0x000003f0 /* TX Triger level mask */ 173#define AR5K_TXCFG_TXFULL 0x000003f0 /* TX Trigger level mask */
174#define AR5K_TXCFG_TXFULL_S 4 174#define AR5K_TXCFG_TXFULL_S 4
175#define AR5K_TXCFG_TXFULL_0B 0x00000000 175#define AR5K_TXCFG_TXFULL_0B 0x00000000
176#define AR5K_TXCFG_TXFULL_64B 0x00000010 176#define AR5K_TXCFG_TXFULL_64B 0x00000010
@@ -283,16 +283,16 @@
283 */ 283 */
284#define AR5K_ISR 0x001c /* Register Address [5210] */ 284#define AR5K_ISR 0x001c /* Register Address [5210] */
285#define AR5K_PISR 0x0080 /* Register Address [5211+] */ 285#define AR5K_PISR 0x0080 /* Register Address [5211+] */
286#define AR5K_ISR_RXOK 0x00000001 /* Frame successfuly received */ 286#define AR5K_ISR_RXOK 0x00000001 /* Frame successfully received */
287#define AR5K_ISR_RXDESC 0x00000002 /* RX descriptor request */ 287#define AR5K_ISR_RXDESC 0x00000002 /* RX descriptor request */
288#define AR5K_ISR_RXERR 0x00000004 /* Receive error */ 288#define AR5K_ISR_RXERR 0x00000004 /* Receive error */
289#define AR5K_ISR_RXNOFRM 0x00000008 /* No frame received (receive timeout) */ 289#define AR5K_ISR_RXNOFRM 0x00000008 /* No frame received (receive timeout) */
290#define AR5K_ISR_RXEOL 0x00000010 /* Empty RX descriptor */ 290#define AR5K_ISR_RXEOL 0x00000010 /* Empty RX descriptor */
291#define AR5K_ISR_RXORN 0x00000020 /* Receive FIFO overrun */ 291#define AR5K_ISR_RXORN 0x00000020 /* Receive FIFO overrun */
292#define AR5K_ISR_TXOK 0x00000040 /* Frame successfuly transmited */ 292#define AR5K_ISR_TXOK 0x00000040 /* Frame successfully transmitted */
293#define AR5K_ISR_TXDESC 0x00000080 /* TX descriptor request */ 293#define AR5K_ISR_TXDESC 0x00000080 /* TX descriptor request */
294#define AR5K_ISR_TXERR 0x00000100 /* Transmit error */ 294#define AR5K_ISR_TXERR 0x00000100 /* Transmit error */
295#define AR5K_ISR_TXNOFRM 0x00000200 /* No frame transmited (transmit timeout) */ 295#define AR5K_ISR_TXNOFRM 0x00000200 /* No frame transmitted (transmit timeout) */
296#define AR5K_ISR_TXEOL 0x00000400 /* Empty TX descriptor */ 296#define AR5K_ISR_TXEOL 0x00000400 /* Empty TX descriptor */
297#define AR5K_ISR_TXURN 0x00000800 /* Transmit FIFO underrun */ 297#define AR5K_ISR_TXURN 0x00000800 /* Transmit FIFO underrun */
298#define AR5K_ISR_MIB 0x00001000 /* Update MIB counters */ 298#define AR5K_ISR_MIB 0x00001000 /* Update MIB counters */
@@ -303,7 +303,7 @@
303#define AR5K_ISR_BRSSI 0x00020000 /* Beacon rssi below threshold (?) */ 303#define AR5K_ISR_BRSSI 0x00020000 /* Beacon rssi below threshold (?) */
304#define AR5K_ISR_BMISS 0x00040000 /* Beacon missed */ 304#define AR5K_ISR_BMISS 0x00040000 /* Beacon missed */
305#define AR5K_ISR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */ 305#define AR5K_ISR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */
306#define AR5K_ISR_BNR 0x00100000 /* Beacon not ready [5211+] */ 306#define AR5K_ISR_BNR 0x00100000 /* Beacon not ready [5211+] */
307#define AR5K_ISR_MCABT 0x00100000 /* Master Cycle Abort [5210] */ 307#define AR5K_ISR_MCABT 0x00100000 /* Master Cycle Abort [5210] */
308#define AR5K_ISR_RXCHIRP 0x00200000 /* CHIRP Received [5212+] */ 308#define AR5K_ISR_RXCHIRP 0x00200000 /* CHIRP Received [5212+] */
309#define AR5K_ISR_SSERR 0x00200000 /* Signaled System Error [5210] */ 309#define AR5K_ISR_SSERR 0x00200000 /* Signaled System Error [5210] */
@@ -377,16 +377,16 @@
377 */ 377 */
378#define AR5K_IMR 0x0020 /* Register Address [5210] */ 378#define AR5K_IMR 0x0020 /* Register Address [5210] */
379#define AR5K_PIMR 0x00a0 /* Register Address [5211+] */ 379#define AR5K_PIMR 0x00a0 /* Register Address [5211+] */
380#define AR5K_IMR_RXOK 0x00000001 /* Frame successfuly received*/ 380#define AR5K_IMR_RXOK 0x00000001 /* Frame successfully received*/
381#define AR5K_IMR_RXDESC 0x00000002 /* RX descriptor request*/ 381#define AR5K_IMR_RXDESC 0x00000002 /* RX descriptor request*/
382#define AR5K_IMR_RXERR 0x00000004 /* Receive error*/ 382#define AR5K_IMR_RXERR 0x00000004 /* Receive error*/
383#define AR5K_IMR_RXNOFRM 0x00000008 /* No frame received (receive timeout)*/ 383#define AR5K_IMR_RXNOFRM 0x00000008 /* No frame received (receive timeout)*/
384#define AR5K_IMR_RXEOL 0x00000010 /* Empty RX descriptor*/ 384#define AR5K_IMR_RXEOL 0x00000010 /* Empty RX descriptor*/
385#define AR5K_IMR_RXORN 0x00000020 /* Receive FIFO overrun*/ 385#define AR5K_IMR_RXORN 0x00000020 /* Receive FIFO overrun*/
386#define AR5K_IMR_TXOK 0x00000040 /* Frame successfuly transmited*/ 386#define AR5K_IMR_TXOK 0x00000040 /* Frame successfully transmitted*/
387#define AR5K_IMR_TXDESC 0x00000080 /* TX descriptor request*/ 387#define AR5K_IMR_TXDESC 0x00000080 /* TX descriptor request*/
388#define AR5K_IMR_TXERR 0x00000100 /* Transmit error*/ 388#define AR5K_IMR_TXERR 0x00000100 /* Transmit error*/
389#define AR5K_IMR_TXNOFRM 0x00000200 /* No frame transmited (transmit timeout)*/ 389#define AR5K_IMR_TXNOFRM 0x00000200 /* No frame transmitted (transmit timeout)*/
390#define AR5K_IMR_TXEOL 0x00000400 /* Empty TX descriptor*/ 390#define AR5K_IMR_TXEOL 0x00000400 /* Empty TX descriptor*/
391#define AR5K_IMR_TXURN 0x00000800 /* Transmit FIFO underrun*/ 391#define AR5K_IMR_TXURN 0x00000800 /* Transmit FIFO underrun*/
392#define AR5K_IMR_MIB 0x00001000 /* Update MIB counters*/ 392#define AR5K_IMR_MIB 0x00001000 /* Update MIB counters*/
@@ -397,7 +397,7 @@
397#define AR5K_IMR_BRSSI 0x00020000 /* Beacon rssi below threshold (?) */ 397#define AR5K_IMR_BRSSI 0x00020000 /* Beacon rssi below threshold (?) */
398#define AR5K_IMR_BMISS 0x00040000 /* Beacon missed*/ 398#define AR5K_IMR_BMISS 0x00040000 /* Beacon missed*/
399#define AR5K_IMR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */ 399#define AR5K_IMR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */
400#define AR5K_IMR_BNR 0x00100000 /* Beacon not ready [5211+] */ 400#define AR5K_IMR_BNR 0x00100000 /* Beacon not ready [5211+] */
401#define AR5K_IMR_MCABT 0x00100000 /* Master Cycle Abort [5210] */ 401#define AR5K_IMR_MCABT 0x00100000 /* Master Cycle Abort [5210] */
402#define AR5K_IMR_RXCHIRP 0x00200000 /* CHIRP Received [5212+]*/ 402#define AR5K_IMR_RXCHIRP 0x00200000 /* CHIRP Received [5212+]*/
403#define AR5K_IMR_SSERR 0x00200000 /* Signaled System Error [5210] */ 403#define AR5K_IMR_SSERR 0x00200000 /* Signaled System Error [5210] */
@@ -601,7 +601,7 @@
601 * QCU misc registers 601 * QCU misc registers
602 */ 602 */
603#define AR5K_QCU_MISC_BASE 0x09c0 /* Register Address -Queue0 MISC */ 603#define AR5K_QCU_MISC_BASE 0x09c0 /* Register Address -Queue0 MISC */
604#define AR5K_QCU_MISC_FRSHED_M 0x0000000f /* Frame sheduling mask */ 604#define AR5K_QCU_MISC_FRSHED_M 0x0000000f /* Frame scheduling mask */
605#define AR5K_QCU_MISC_FRSHED_ASAP 0 /* ASAP */ 605#define AR5K_QCU_MISC_FRSHED_ASAP 0 /* ASAP */
606#define AR5K_QCU_MISC_FRSHED_CBR 1 /* Constant Bit Rate */ 606#define AR5K_QCU_MISC_FRSHED_CBR 1 /* Constant Bit Rate */
607#define AR5K_QCU_MISC_FRSHED_DBA_GT 2 /* DMA Beacon alert gated */ 607#define AR5K_QCU_MISC_FRSHED_DBA_GT 2 /* DMA Beacon alert gated */
@@ -653,13 +653,13 @@
653 * registers [5211+] 653 * registers [5211+]
654 * 654 *
655 * These registers control the various characteristics of each queue 655 * These registers control the various characteristics of each queue
656 * for 802.11e (WME) combatibility so they go together with 656 * for 802.11e (WME) compatibility so they go together with
657 * QCU registers in pairs. For each queue we have a QCU mask register, 657 * QCU registers in pairs. For each queue we have a QCU mask register,
658 * (0x1000 - 0x102c), a local-IFS settings register (0x1040 - 0x106c), 658 * (0x1000 - 0x102c), a local-IFS settings register (0x1040 - 0x106c),
659 * a retry limit register (0x1080 - 0x10ac), a channel time register 659 * a retry limit register (0x1080 - 0x10ac), a channel time register
660 * (0x10c0 - 0x10ec), a misc-settings register (0x1100 - 0x112c) and 660 * (0x10c0 - 0x10ec), a misc-settings register (0x1100 - 0x112c) and
661 * a sequence number register (0x1140 - 0x116c). It seems that "global" 661 * a sequence number register (0x1140 - 0x116c). It seems that "global"
662 * registers here afect all queues (see use of DCU_GBL_IFS_SLOT in ar5k). 662 * registers here affect all queues (see use of DCU_GBL_IFS_SLOT in ar5k).
663 * We use the same macros here for easier register access. 663 * We use the same macros here for easier register access.
664 * 664 *
665 */ 665 */
@@ -779,7 +779,7 @@
779 * and it's used for generating pseudo-random 779 * and it's used for generating pseudo-random
780 * number sequences. 780 * number sequences.
781 * 781 *
782 * (If i understand corectly, random numbers are 782 * (If i understand correctly, random numbers are
783 * used for idle sensing -multiplied with cwmin/max etc-) 783 * used for idle sensing -multiplied with cwmin/max etc-)
784 */ 784 */
785#define AR5K_DCU_GBL_IFS_MISC 0x10f0 /* Register Address */ 785#define AR5K_DCU_GBL_IFS_MISC 0x10f0 /* Register Address */
@@ -1007,7 +1007,7 @@
1007#define AR5K_PCIE_WAEN 0x407c 1007#define AR5K_PCIE_WAEN 0x407c
1008 1008
1009/* 1009/*
1010 * PCI-E Serializer/Desirializer 1010 * PCI-E Serializer/Deserializer
1011 * registers 1011 * registers
1012 */ 1012 */
1013#define AR5K_PCIE_SERDES 0x4080 1013#define AR5K_PCIE_SERDES 0x4080
@@ -1227,7 +1227,7 @@
1227 AR5K_USEC_5210 : AR5K_USEC_5211) 1227 AR5K_USEC_5210 : AR5K_USEC_5211)
1228#define AR5K_USEC_1 0x0000007f /* clock cycles for 1us */ 1228#define AR5K_USEC_1 0x0000007f /* clock cycles for 1us */
1229#define AR5K_USEC_1_S 0 1229#define AR5K_USEC_1_S 0
1230#define AR5K_USEC_32 0x00003f80 /* clock cycles for 1us while on 32Mhz clock */ 1230#define AR5K_USEC_32 0x00003f80 /* clock cycles for 1us while on 32MHz clock */
1231#define AR5K_USEC_32_S 7 1231#define AR5K_USEC_32_S 7
1232#define AR5K_USEC_TX_LATENCY_5211 0x007fc000 1232#define AR5K_USEC_TX_LATENCY_5211 0x007fc000
1233#define AR5K_USEC_TX_LATENCY_5211_S 14 1233#define AR5K_USEC_TX_LATENCY_5211_S 14
@@ -1328,16 +1328,16 @@
1328#define AR5K_RX_FILTER_5211 0x803c /* Register Address [5211+] */ 1328#define AR5K_RX_FILTER_5211 0x803c /* Register Address [5211+] */
1329#define AR5K_RX_FILTER (ah->ah_version == AR5K_AR5210 ? \ 1329#define AR5K_RX_FILTER (ah->ah_version == AR5K_AR5210 ? \
1330 AR5K_RX_FILTER_5210 : AR5K_RX_FILTER_5211) 1330 AR5K_RX_FILTER_5210 : AR5K_RX_FILTER_5211)
1331#define AR5K_RX_FILTER_UCAST 0x00000001 /* Don't filter unicast frames */ 1331#define AR5K_RX_FILTER_UCAST 0x00000001 /* Don't filter unicast frames */
1332#define AR5K_RX_FILTER_MCAST 0x00000002 /* Don't filter multicast frames */ 1332#define AR5K_RX_FILTER_MCAST 0x00000002 /* Don't filter multicast frames */
1333#define AR5K_RX_FILTER_BCAST 0x00000004 /* Don't filter broadcast frames */ 1333#define AR5K_RX_FILTER_BCAST 0x00000004 /* Don't filter broadcast frames */
1334#define AR5K_RX_FILTER_CONTROL 0x00000008 /* Don't filter control frames */ 1334#define AR5K_RX_FILTER_CONTROL 0x00000008 /* Don't filter control frames */
1335#define AR5K_RX_FILTER_BEACON 0x00000010 /* Don't filter beacon frames */ 1335#define AR5K_RX_FILTER_BEACON 0x00000010 /* Don't filter beacon frames */
1336#define AR5K_RX_FILTER_PROM 0x00000020 /* Set promiscuous mode */ 1336#define AR5K_RX_FILTER_PROM 0x00000020 /* Set promiscuous mode */
1337#define AR5K_RX_FILTER_XRPOLL 0x00000040 /* Don't filter XR poll frame [5212+] */ 1337#define AR5K_RX_FILTER_XRPOLL 0x00000040 /* Don't filter XR poll frame [5212+] */
1338#define AR5K_RX_FILTER_PROBEREQ 0x00000080 /* Don't filter probe requests [5212+] */ 1338#define AR5K_RX_FILTER_PROBEREQ 0x00000080 /* Don't filter probe requests [5212+] */
1339#define AR5K_RX_FILTER_PHYERR_5212 0x00000100 /* Don't filter phy errors [5212+] */ 1339#define AR5K_RX_FILTER_PHYERR_5212 0x00000100 /* Don't filter phy errors [5212+] */
1340#define AR5K_RX_FILTER_RADARERR_5212 0x00000200 /* Don't filter phy radar errors [5212+] */ 1340#define AR5K_RX_FILTER_RADARERR_5212 0x00000200 /* Don't filter phy radar errors [5212+] */
1341#define AR5K_RX_FILTER_PHYERR_5211 0x00000040 /* [5211] */ 1341#define AR5K_RX_FILTER_PHYERR_5211 0x00000040 /* [5211] */
1342#define AR5K_RX_FILTER_RADARERR_5211 0x00000080 /* [5211] */ 1342#define AR5K_RX_FILTER_RADARERR_5211 0x00000080 /* [5211] */
1343#define AR5K_RX_FILTER_PHYERR \ 1343#define AR5K_RX_FILTER_PHYERR \
@@ -1461,7 +1461,7 @@
1461 * ADDAC test register [5211+] 1461 * ADDAC test register [5211+]
1462 */ 1462 */
1463#define AR5K_ADDAC_TEST 0x8054 /* Register Address */ 1463#define AR5K_ADDAC_TEST 0x8054 /* Register Address */
1464#define AR5K_ADDAC_TEST_TXCONT 0x00000001 /* Test continuous tx */ 1464#define AR5K_ADDAC_TEST_TXCONT 0x00000001 /* Test continuous tx */
1465#define AR5K_ADDAC_TEST_TST_MODE 0x00000002 /* Test mode */ 1465#define AR5K_ADDAC_TEST_TST_MODE 0x00000002 /* Test mode */
1466#define AR5K_ADDAC_TEST_LOOP_EN 0x00000004 /* Enable loop */ 1466#define AR5K_ADDAC_TEST_LOOP_EN 0x00000004 /* Enable loop */
1467#define AR5K_ADDAC_TEST_LOOP_LEN 0x00000008 /* Loop length (field) */ 1467#define AR5K_ADDAC_TEST_LOOP_LEN 0x00000008 /* Loop length (field) */
@@ -1632,7 +1632,7 @@
1632#define AR5K_SLEEP0_NEXT_DTIM 0x0007ffff /* Mask for next DTIM (?) */ 1632#define AR5K_SLEEP0_NEXT_DTIM 0x0007ffff /* Mask for next DTIM (?) */
1633#define AR5K_SLEEP0_NEXT_DTIM_S 0 1633#define AR5K_SLEEP0_NEXT_DTIM_S 0
1634#define AR5K_SLEEP0_ASSUME_DTIM 0x00080000 /* Assume DTIM */ 1634#define AR5K_SLEEP0_ASSUME_DTIM 0x00080000 /* Assume DTIM */
1635#define AR5K_SLEEP0_ENH_SLEEP_EN 0x00100000 /* Enable enchanced sleep control */ 1635#define AR5K_SLEEP0_ENH_SLEEP_EN 0x00100000 /* Enable enhanced sleep control */
1636#define AR5K_SLEEP0_CABTO 0xff000000 /* Mask for CAB Time Out */ 1636#define AR5K_SLEEP0_CABTO 0xff000000 /* Mask for CAB Time Out */
1637#define AR5K_SLEEP0_CABTO_S 24 1637#define AR5K_SLEEP0_CABTO_S 24
1638 1638
@@ -1657,7 +1657,7 @@
1657/* 1657/*
1658 * TX power control (TPC) register 1658 * TX power control (TPC) register
1659 * 1659 *
1660 * XXX: PCDAC steps (0.5dbm) or DBM ? 1660 * XXX: PCDAC steps (0.5dBm) or dBm ?
1661 * 1661 *
1662 */ 1662 */
1663#define AR5K_TXPC 0x80e8 /* Register Address */ 1663#define AR5K_TXPC 0x80e8 /* Register Address */
@@ -1673,7 +1673,7 @@
1673/* 1673/*
1674 * Profile count registers 1674 * Profile count registers
1675 * 1675 *
1676 * These registers can be cleared and freezed with ATH5K_MIBC, but they do not 1676 * These registers can be cleared and frozen with ATH5K_MIBC, but they do not
1677 * generate a MIB interrupt. 1677 * generate a MIB interrupt.
1678 * Instead of overflowing, they shift by one bit to the right. All registers 1678 * Instead of overflowing, they shift by one bit to the right. All registers
1679 * shift together, i.e. when one reaches the max, all shift at the same time by 1679 * shift together, i.e. when one reaches the max, all shift at the same time by
@@ -1838,7 +1838,7 @@
1838#define AR5K_PHY_TST2_TRIG_SEL 0x00000007 /* Trigger select (?)*/ 1838#define AR5K_PHY_TST2_TRIG_SEL 0x00000007 /* Trigger select (?)*/
1839#define AR5K_PHY_TST2_TRIG 0x00000010 /* Trigger (?) */ 1839#define AR5K_PHY_TST2_TRIG 0x00000010 /* Trigger (?) */
1840#define AR5K_PHY_TST2_CBUS_MODE 0x00000060 /* Cardbus mode (?) */ 1840#define AR5K_PHY_TST2_CBUS_MODE 0x00000060 /* Cardbus mode (?) */
1841#define AR5K_PHY_TST2_CLK32 0x00000400 /* CLK_OUT is CLK32 (32Khz external) */ 1841#define AR5K_PHY_TST2_CLK32 0x00000400 /* CLK_OUT is CLK32 (32kHz external) */
1842#define AR5K_PHY_TST2_CHANCOR_DUMP_EN 0x00000800 /* Enable Chancor dump (?) */ 1842#define AR5K_PHY_TST2_CHANCOR_DUMP_EN 0x00000800 /* Enable Chancor dump (?) */
1843#define AR5K_PHY_TST2_EVEN_CHANCOR_DUMP 0x00001000 /* Even Chancor dump (?) */ 1843#define AR5K_PHY_TST2_EVEN_CHANCOR_DUMP 0x00001000 /* Even Chancor dump (?) */
1844#define AR5K_PHY_TST2_RFSILENT_EN 0x00002000 /* Enable RFSILENT */ 1844#define AR5K_PHY_TST2_RFSILENT_EN 0x00002000 /* Enable RFSILENT */
@@ -2002,7 +2002,7 @@
2002#define AR5K_PHY_AGCCTL_OFDM_DIV_DIS 0x00000008 /* Disable antenna diversity on OFDM modes */ 2002#define AR5K_PHY_AGCCTL_OFDM_DIV_DIS 0x00000008 /* Disable antenna diversity on OFDM modes */
2003#define AR5K_PHY_AGCCTL_NF_EN 0x00008000 /* Enable nf calibration to happen (?) */ 2003#define AR5K_PHY_AGCCTL_NF_EN 0x00008000 /* Enable nf calibration to happen (?) */
2004#define AR5K_PHY_AGCTL_FLTR_CAL 0x00010000 /* Allow filter calibration (?) */ 2004#define AR5K_PHY_AGCTL_FLTR_CAL 0x00010000 /* Allow filter calibration (?) */
2005#define AR5K_PHY_AGCCTL_NF_NOUPDATE 0x00020000 /* Don't update nf automaticaly */ 2005#define AR5K_PHY_AGCCTL_NF_NOUPDATE 0x00020000 /* Don't update nf automatically */
2006 2006
2007/* 2007/*
2008 * PHY noise floor status register (CCA = Clear Channel Assessment) 2008 * PHY noise floor status register (CCA = Clear Channel Assessment)
@@ -2038,7 +2038,7 @@
2038#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2_S 24 2038#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2_S 24
2039 2039
2040/* Low thresholds */ 2040/* Low thresholds */
2041#define AR5K_PHY_WEAK_OFDM_LOW_THR 0x986c 2041#define AR5K_PHY_WEAK_OFDM_LOW_THR 0x986c
2042#define AR5K_PHY_WEAK_OFDM_LOW_THR_SELFCOR_EN 0x00000001 2042#define AR5K_PHY_WEAK_OFDM_LOW_THR_SELFCOR_EN 0x00000001
2043#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT 0x00003f00 2043#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT 0x00003f00
2044#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT_S 8 2044#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT_S 8
@@ -2089,7 +2089,7 @@
2089 * 2089 *
2090 * It's obvious from the code that 0x989c is the buffer register but 2090 * It's obvious from the code that 0x989c is the buffer register but
2091 * for the other special registers that we write to after sending each 2091 * for the other special registers that we write to after sending each
2092 * packet, i have no idea. So i'll name them BUFFER_CONTROL_X registers 2092 * packet, i have no idea. So I'll name them BUFFER_CONTROL_X registers
2093 * for now. It's interesting that they are also used for some other operations. 2093 * for now. It's interesting that they are also used for some other operations.
2094 */ 2094 */
2095 2095
@@ -2259,12 +2259,13 @@
2259#define AR5K_PHY_FRAME_CTL_ILLLEN_ERR 0x08000000 /* Illegal length */ 2259#define AR5K_PHY_FRAME_CTL_ILLLEN_ERR 0x08000000 /* Illegal length */
2260#define AR5K_PHY_FRAME_CTL_SERVICE_ERR 0x20000000 2260#define AR5K_PHY_FRAME_CTL_SERVICE_ERR 0x20000000
2261#define AR5K_PHY_FRAME_CTL_TXURN_ERR 0x40000000 /* TX underrun */ 2261#define AR5K_PHY_FRAME_CTL_TXURN_ERR 0x40000000 /* TX underrun */
2262#define AR5K_PHY_FRAME_CTL_INI AR5K_PHY_FRAME_CTL_SERVICE_ERR | \ 2262#define AR5K_PHY_FRAME_CTL_INI \
2263 AR5K_PHY_FRAME_CTL_TXURN_ERR | \ 2263 (AR5K_PHY_FRAME_CTL_SERVICE_ERR | \
2264 AR5K_PHY_FRAME_CTL_ILLLEN_ERR | \ 2264 AR5K_PHY_FRAME_CTL_TXURN_ERR | \
2265 AR5K_PHY_FRAME_CTL_ILLRATE_ERR | \ 2265 AR5K_PHY_FRAME_CTL_ILLLEN_ERR | \
2266 AR5K_PHY_FRAME_CTL_PARITY_ERR | \ 2266 AR5K_PHY_FRAME_CTL_ILLRATE_ERR | \
2267 AR5K_PHY_FRAME_CTL_TIMING_ERR 2267 AR5K_PHY_FRAME_CTL_PARITY_ERR | \
2268 AR5K_PHY_FRAME_CTL_TIMING_ERR)
2268 2269
2269/* 2270/*
2270 * PHY Tx Power adjustment register [5212A+] 2271 * PHY Tx Power adjustment register [5212A+]
@@ -2281,22 +2282,22 @@
2281#define AR5K_PHY_RADAR 0x9954 2282#define AR5K_PHY_RADAR 0x9954
2282#define AR5K_PHY_RADAR_ENABLE 0x00000001 2283#define AR5K_PHY_RADAR_ENABLE 0x00000001
2283#define AR5K_PHY_RADAR_DISABLE 0x00000000 2284#define AR5K_PHY_RADAR_DISABLE 0x00000000
2284#define AR5K_PHY_RADAR_INBANDTHR 0x0000003e /* Inband threshold 2285#define AR5K_PHY_RADAR_INBANDTHR 0x0000003e /* Inband threshold
2285 5-bits, units unknown {0..31} 2286 5-bits, units unknown {0..31}
2286 (? MHz ?) */ 2287 (? MHz ?) */
2287#define AR5K_PHY_RADAR_INBANDTHR_S 1 2288#define AR5K_PHY_RADAR_INBANDTHR_S 1
2288 2289
2289#define AR5K_PHY_RADAR_PRSSI_THR 0x00000fc0 /* Pulse RSSI/SNR threshold 2290#define AR5K_PHY_RADAR_PRSSI_THR 0x00000fc0 /* Pulse RSSI/SNR threshold
2290 6-bits, dBm range {0..63} 2291 6-bits, dBm range {0..63}
2291 in dBm units. */ 2292 in dBm units. */
2292#define AR5K_PHY_RADAR_PRSSI_THR_S 6 2293#define AR5K_PHY_RADAR_PRSSI_THR_S 6
2293 2294
2294#define AR5K_PHY_RADAR_PHEIGHT_THR 0x0003f000 /* Pulse height threshold 2295#define AR5K_PHY_RADAR_PHEIGHT_THR 0x0003f000 /* Pulse height threshold
2295 6-bits, dBm range {0..63} 2296 6-bits, dBm range {0..63}
2296 in dBm units. */ 2297 in dBm units. */
2297#define AR5K_PHY_RADAR_PHEIGHT_THR_S 12 2298#define AR5K_PHY_RADAR_PHEIGHT_THR_S 12
2298 2299
2299#define AR5K_PHY_RADAR_RSSI_THR 0x00fc0000 /* Radar RSSI/SNR threshold. 2300#define AR5K_PHY_RADAR_RSSI_THR 0x00fc0000 /* Radar RSSI/SNR threshold.
2300 6-bits, dBm range {0..63} 2301 6-bits, dBm range {0..63}
2301 in dBm units. */ 2302 in dBm units. */
2302#define AR5K_PHY_RADAR_RSSI_THR_S 18 2303#define AR5K_PHY_RADAR_RSSI_THR_S 18
@@ -2339,7 +2340,7 @@
2339#define AR5K_PHY_RESTART_DIV_GC_S 18 2340#define AR5K_PHY_RESTART_DIV_GC_S 18
2340 2341
2341/* 2342/*
2342 * RF Bus access request register (for synth-oly channel switching) 2343 * RF Bus access request register (for synth-only channel switching)
2343 */ 2344 */
2344#define AR5K_PHY_RFBUS_REQ 0x997C 2345#define AR5K_PHY_RFBUS_REQ 0x997C
2345#define AR5K_PHY_RFBUS_REQ_REQUEST 0x00000001 2346#define AR5K_PHY_RFBUS_REQ_REQUEST 0x00000001
@@ -2381,7 +2382,7 @@
2381 */ 2382 */
2382#define AR5K_BB_GAIN_BASE 0x9b00 /* BaseBand Amplifier Gain table base address */ 2383#define AR5K_BB_GAIN_BASE 0x9b00 /* BaseBand Amplifier Gain table base address */
2383#define AR5K_BB_GAIN(_n) (AR5K_BB_GAIN_BASE + ((_n) << 2)) 2384#define AR5K_BB_GAIN(_n) (AR5K_BB_GAIN_BASE + ((_n) << 2))
2384#define AR5K_RF_GAIN_BASE 0x9a00 /* RF Amplrifier Gain table base address */ 2385#define AR5K_RF_GAIN_BASE 0x9a00 /* RF Amplifier Gain table base address */
2385#define AR5K_RF_GAIN(_n) (AR5K_RF_GAIN_BASE + ((_n) << 2)) 2386#define AR5K_RF_GAIN(_n) (AR5K_RF_GAIN_BASE + ((_n) << 2))
2386 2387
2387/* 2388/*
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 1676a3e3dc3d..9f9c2ad3ca66 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -25,7 +25,7 @@
25 25
26#include <asm/unaligned.h> 26#include <asm/unaligned.h>
27 27
28#include <linux/pci.h> /* To determine if a card is pci-e */ 28#include <linux/pci.h> /* To determine if a card is pci-e */
29#include <linux/log2.h> 29#include <linux/log2.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include "ath5k.h" 31#include "ath5k.h"
@@ -142,10 +142,11 @@ static void ath5k_hw_init_core_clock(struct ath5k_hw *ah)
142 142
143 /* Set 32MHz USEC counter */ 143 /* Set 32MHz USEC counter */
144 if ((ah->ah_radio == AR5K_RF5112) || 144 if ((ah->ah_radio == AR5K_RF5112) ||
145 (ah->ah_radio == AR5K_RF5413) || 145 (ah->ah_radio == AR5K_RF2413) ||
146 (ah->ah_radio == AR5K_RF2316) || 146 (ah->ah_radio == AR5K_RF5413) ||
147 (ah->ah_radio == AR5K_RF2317)) 147 (ah->ah_radio == AR5K_RF2316) ||
148 /* Remain on 40MHz clock ? */ 148 (ah->ah_radio == AR5K_RF2317))
149 /* Remain on 40MHz clock ? */
149 sclock = 40 - 1; 150 sclock = 40 - 1;
150 else 151 else
151 sclock = 32 - 1; 152 sclock = 32 - 1;
@@ -213,7 +214,7 @@ static void ath5k_hw_init_core_clock(struct ath5k_hw *ah)
213 usec_reg = (usec | sclock | txlat | rxlat); 214 usec_reg = (usec | sclock | txlat | rxlat);
214 ath5k_hw_reg_write(ah, usec_reg, AR5K_USEC); 215 ath5k_hw_reg_write(ah, usec_reg, AR5K_USEC);
215 216
216 /* On 5112 set tx frane to tx data start delay */ 217 /* On 5112 set tx frame to tx data start delay */
217 if (ah->ah_radio == AR5K_RF5112) { 218 if (ah->ah_radio == AR5K_RF5112) {
218 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_RF_CTL2, 219 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_RF_CTL2,
219 AR5K_PHY_RF_CTL2_TXF2TXD_START, 220 AR5K_PHY_RF_CTL2_TXF2TXD_START,
@@ -233,7 +234,7 @@ static void ath5k_hw_init_core_clock(struct ath5k_hw *ah)
233static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) 234static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable)
234{ 235{
235 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 236 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
236 u32 scal, spending; 237 u32 scal, spending, sclock;
237 238
238 /* Only set 32KHz settings if we have an external 239 /* Only set 32KHz settings if we have an external
239 * 32KHz crystal present */ 240 * 32KHz crystal present */
@@ -317,6 +318,15 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable)
317 318
318 /* Set up tsf increment on each cycle */ 319 /* Set up tsf increment on each cycle */
319 AR5K_REG_WRITE_BITS(ah, AR5K_TSF_PARM, AR5K_TSF_PARM_INC, 1); 320 AR5K_REG_WRITE_BITS(ah, AR5K_TSF_PARM, AR5K_TSF_PARM_INC, 1);
321
322 if ((ah->ah_radio == AR5K_RF5112) ||
323 (ah->ah_radio == AR5K_RF5413) ||
324 (ah->ah_radio == AR5K_RF2316) ||
325 (ah->ah_radio == AR5K_RF2317))
326 sclock = 40 - 1;
327 else
328 sclock = 32 - 1;
329 AR5K_REG_WRITE_BITS(ah, AR5K_USEC_5211, AR5K_USEC_32, sclock);
320 } 330 }
321} 331}
322 332
@@ -375,7 +385,7 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val)
375static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) 385static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags)
376{ 386{
377 u32 mask = flags ? flags : ~0U; 387 u32 mask = flags ? flags : ~0U;
378 volatile __iomem u32 *reg; 388 u32 __iomem *reg;
379 u32 regval; 389 u32 regval;
380 u32 val = 0; 390 u32 val = 0;
381 391
@@ -539,7 +549,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah)
539 * 549 *
540 * Note: putting PCI core on warm reset on PCI-E cards 550 * Note: putting PCI core on warm reset on PCI-E cards
541 * results card to hang and always return 0xffff... so 551 * results card to hang and always return 0xffff... so
542 * we ingore that flag for PCI-E cards. On PCI cards 552 * we ignore that flag for PCI-E cards. On PCI cards
543 * this flag gets cleared after 64 PCI clocks. 553 * this flag gets cleared after 64 PCI clocks.
544 */ 554 */
545 bus_flags = (pdev && pci_is_pcie(pdev)) ? 0 : AR5K_RESET_CTL_PCI; 555 bus_flags = (pdev && pci_is_pcie(pdev)) ? 0 : AR5K_RESET_CTL_PCI;
@@ -596,7 +606,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
596 * 606 *
597 * Note: putting PCI core on warm reset on PCI-E cards 607 * Note: putting PCI core on warm reset on PCI-E cards
598 * results card to hang and always return 0xffff... so 608 * results card to hang and always return 0xffff... so
599 * we ingore that flag for PCI-E cards. On PCI cards 609 * we ignore that flag for PCI-E cards. On PCI cards
600 * this flag gets cleared after 64 PCI clocks. 610 * this flag gets cleared after 64 PCI clocks.
601 */ 611 */
602 bus_flags = (pdev && pci_is_pcie(pdev)) ? 0 : AR5K_RESET_CTL_PCI; 612 bus_flags = (pdev && pci_is_pcie(pdev)) ? 0 : AR5K_RESET_CTL_PCI;
@@ -627,7 +637,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
627 return ret; 637 return ret;
628 } 638 }
629 639
630 /* ...reset configuration regiter on Wisoc ... 640 /* ...reset configuration register on Wisoc ...
631 * ...clear reset control register and pull device out of 641 * ...clear reset control register and pull device out of
632 * warm reset on others */ 642 * warm reset on others */
633 if (ath5k_get_bus_type(ah) == ATH_AHB) 643 if (ath5k_get_bus_type(ah) == ATH_AHB)
@@ -704,7 +714,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
704 714
705 /*XXX: Can bwmode be used with dynamic mode ? 715 /*XXX: Can bwmode be used with dynamic mode ?
706 * (I don't think it supports 44MHz) */ 716 * (I don't think it supports 44MHz) */
707 /* On 2425 initvals TURBO_SHORT is not pressent */ 717 /* On 2425 initvals TURBO_SHORT is not present */
708 if (ah->ah_bwmode == AR5K_BWMODE_40MHZ) { 718 if (ah->ah_bwmode == AR5K_BWMODE_40MHZ) {
709 turbo = AR5K_PHY_TURBO_MODE | 719 turbo = AR5K_PHY_TURBO_MODE |
710 (ah->ah_radio == AR5K_RF2425) ? 0 : 720 (ah->ah_radio == AR5K_RF2425) ? 0 :
@@ -1277,11 +1287,16 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1277 ath5k_hw_dma_init(ah); 1287 ath5k_hw_dma_init(ah);
1278 1288
1279 1289
1280 /* Enable 32KHz clock function for AR5212+ chips 1290 /*
1291 * Enable 32KHz clock function for AR5212+ chips
1281 * Set clocks to 32KHz operation and use an 1292 * Set clocks to 32KHz operation and use an
1282 * external 32KHz crystal when sleeping if one 1293 * external 32KHz crystal when sleeping if one
1283 * exists */ 1294 * exists.
1284 if (ah->ah_version == AR5K_AR5212 && 1295 * Disabled by default because it is also disabled in
1296 * other drivers and it is known to cause stability
1297 * issues on some devices
1298 */
1299 if (ah->ah_use_32khz_clock && ah->ah_version == AR5K_AR5212 &&
1285 op_mode != NL80211_IFTYPE_AP) 1300 op_mode != NL80211_IFTYPE_AP)
1286 ath5k_hw_set_sleep_clock(ah, true); 1301 ath5k_hw_set_sleep_clock(ah, true);
1287 1302
diff --git a/drivers/net/wireless/ath/ath5k/rfbuffer.h b/drivers/net/wireless/ath/ath5k/rfbuffer.h
index 16b67e84906d..5d11c23b4297 100644
--- a/drivers/net/wireless/ath/ath5k/rfbuffer.h
+++ b/drivers/net/wireless/ath/ath5k/rfbuffer.h
@@ -254,7 +254,7 @@ static const struct ath5k_ini_rfbuffer rfb_5111[] = {
254 254
255/* RFX112 (Derby 1) */ 255/* RFX112 (Derby 1) */
256 256
257/* BANK 6 len pos col */ 257/* BANK 6 len pos col */
258#define AR5K_RF5112_OB_2GHZ { 3, 269, 0 } 258#define AR5K_RF5112_OB_2GHZ { 3, 269, 0 }
259#define AR5K_RF5112_DB_2GHZ { 3, 272, 0 } 259#define AR5K_RF5112_DB_2GHZ { 3, 272, 0 }
260 260
@@ -495,7 +495,7 @@ static const struct ath5k_ini_rfbuffer rfb_5112a[] = {
495/* BANK 2 len pos col */ 495/* BANK 2 len pos col */
496#define AR5K_RF2413_RF_TURBO { 1, 1, 2 } 496#define AR5K_RF2413_RF_TURBO { 1, 1, 2 }
497 497
498/* BANK 6 len pos col */ 498/* BANK 6 len pos col */
499#define AR5K_RF2413_OB_2GHZ { 3, 168, 0 } 499#define AR5K_RF2413_OB_2GHZ { 3, 168, 0 }
500#define AR5K_RF2413_DB_2GHZ { 3, 165, 0 } 500#define AR5K_RF2413_DB_2GHZ { 3, 165, 0 }
501 501
diff --git a/drivers/net/wireless/ath/ath5k/rfgain.h b/drivers/net/wireless/ath/ath5k/rfgain.h
index 1354d8c392c8..ebfae052d89e 100644
--- a/drivers/net/wireless/ath/ath5k/rfgain.h
+++ b/drivers/net/wireless/ath/ath5k/rfgain.h
@@ -30,7 +30,7 @@ struct ath5k_ini_rfgain {
30 30
31/* Initial RF Gain settings for RF5111 */ 31/* Initial RF Gain settings for RF5111 */
32static const struct ath5k_ini_rfgain rfgain_5111[] = { 32static const struct ath5k_ini_rfgain rfgain_5111[] = {
33 /* 5Ghz 2Ghz */ 33 /* 5GHz 2GHz */
34 { AR5K_RF_GAIN(0), { 0x000001a9, 0x00000000 } }, 34 { AR5K_RF_GAIN(0), { 0x000001a9, 0x00000000 } },
35 { AR5K_RF_GAIN(1), { 0x000001e9, 0x00000040 } }, 35 { AR5K_RF_GAIN(1), { 0x000001e9, 0x00000040 } },
36 { AR5K_RF_GAIN(2), { 0x00000029, 0x00000080 } }, 36 { AR5K_RF_GAIN(2), { 0x00000029, 0x00000080 } },
@@ -99,7 +99,7 @@ static const struct ath5k_ini_rfgain rfgain_5111[] = {
99 99
100/* Initial RF Gain settings for RF5112 */ 100/* Initial RF Gain settings for RF5112 */
101static const struct ath5k_ini_rfgain rfgain_5112[] = { 101static const struct ath5k_ini_rfgain rfgain_5112[] = {
102 /* 5Ghz 2Ghz */ 102 /* 5GHz 2GHz */
103 { AR5K_RF_GAIN(0), { 0x00000007, 0x00000007 } }, 103 { AR5K_RF_GAIN(0), { 0x00000007, 0x00000007 } },
104 { AR5K_RF_GAIN(1), { 0x00000047, 0x00000047 } }, 104 { AR5K_RF_GAIN(1), { 0x00000047, 0x00000047 } },
105 { AR5K_RF_GAIN(2), { 0x00000087, 0x00000087 } }, 105 { AR5K_RF_GAIN(2), { 0x00000087, 0x00000087 } },
@@ -305,7 +305,7 @@ static const struct ath5k_ini_rfgain rfgain_2316[] = {
305 305
306/* Initial RF Gain settings for RF5413 */ 306/* Initial RF Gain settings for RF5413 */
307static const struct ath5k_ini_rfgain rfgain_5413[] = { 307static const struct ath5k_ini_rfgain rfgain_5413[] = {
308 /* 5Ghz 2Ghz */ 308 /* 5GHz 2GHz */
309 { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } }, 309 { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
310 { AR5K_RF_GAIN(1), { 0x00000040, 0x00000040 } }, 310 { AR5K_RF_GAIN(1), { 0x00000040, 0x00000040 } },
311 { AR5K_RF_GAIN(2), { 0x00000080, 0x00000080 } }, 311 { AR5K_RF_GAIN(2), { 0x00000080, 0x00000080 } },
@@ -452,7 +452,7 @@ static const struct ath5k_ini_rfgain rfgain_2425[] = {
452 452
453/* Check if our current measurement is inside our 453/* Check if our current measurement is inside our
454 * current variable attenuation window */ 454 * current variable attenuation window */
455#define AR5K_GAIN_CHECK_ADJUST(_g) \ 455#define AR5K_GAIN_CHECK_ADJUST(_g) \
456 ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high) 456 ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high)
457 457
458struct ath5k_gain_opt_step { 458struct ath5k_gain_opt_step {
diff --git a/drivers/net/wireless/ath/ath5k/sysfs.c b/drivers/net/wireless/ath/ath5k/sysfs.c
index a073cdce1f15..d8ad0e45e1c4 100644
--- a/drivers/net/wireless/ath/ath5k/sysfs.c
+++ b/drivers/net/wireless/ath/ath5k/sysfs.c
@@ -12,7 +12,7 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \
12{ \ 12{ \
13 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 13 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
14 struct ath5k_softc *sc = hw->priv; \ 14 struct ath5k_softc *sc = hw->priv; \
15 return snprintf(buf, PAGE_SIZE, "%d\n", get); \ 15 return snprintf(buf, PAGE_SIZE, "%d\n", get); \
16} \ 16} \
17 \ 17 \
18static ssize_t ath5k_attr_store_##name(struct device *dev, \ 18static ssize_t ath5k_attr_store_##name(struct device *dev, \
@@ -21,9 +21,11 @@ static ssize_t ath5k_attr_store_##name(struct device *dev, \
21{ \ 21{ \
22 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 22 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
23 struct ath5k_softc *sc = hw->priv; \ 23 struct ath5k_softc *sc = hw->priv; \
24 int val; \ 24 int val, ret; \
25 \ 25 \
26 val = (int)simple_strtoul(buf, NULL, 10); \ 26 ret = kstrtoint(buf, 10, &val); \
27 if (ret < 0) \
28 return ret; \
27 set(sc->ah, val); \ 29 set(sc->ah, val); \
28 return count; \ 30 return count; \
29} \ 31} \
@@ -37,7 +39,7 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \
37{ \ 39{ \
38 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 40 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
39 struct ath5k_softc *sc = hw->priv; \ 41 struct ath5k_softc *sc = hw->priv; \
40 return snprintf(buf, PAGE_SIZE, "%d\n", get); \ 42 return snprintf(buf, PAGE_SIZE, "%d\n", get); \
41} \ 43} \
42static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL) 44static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL)
43 45
diff --git a/drivers/net/wireless/ath/ath5k/trace.h b/drivers/net/wireless/ath/ath5k/trace.h
index 2de68adb6240..235e0768ce1d 100644
--- a/drivers/net/wireless/ath/ath5k/trace.h
+++ b/drivers/net/wireless/ath/ath5k/trace.h
@@ -12,9 +12,6 @@ static inline void trace_ ## name(proto) {}
12 12
13struct sk_buff; 13struct sk_buff;
14 14
15#define PRIV_ENTRY __field(struct ath5k_softc *, priv)
16#define PRIV_ASSIGN __entry->priv = priv
17
18#undef TRACE_SYSTEM 15#undef TRACE_SYSTEM
19#define TRACE_SYSTEM ath5k 16#define TRACE_SYSTEM ath5k
20 17
@@ -22,12 +19,12 @@ TRACE_EVENT(ath5k_rx,
22 TP_PROTO(struct ath5k_softc *priv, struct sk_buff *skb), 19 TP_PROTO(struct ath5k_softc *priv, struct sk_buff *skb),
23 TP_ARGS(priv, skb), 20 TP_ARGS(priv, skb),
24 TP_STRUCT__entry( 21 TP_STRUCT__entry(
25 PRIV_ENTRY 22 __field(struct ath5k_softc *, priv)
26 __field(unsigned long, skbaddr) 23 __field(unsigned long, skbaddr)
27 __dynamic_array(u8, frame, skb->len) 24 __dynamic_array(u8, frame, skb->len)
28 ), 25 ),
29 TP_fast_assign( 26 TP_fast_assign(
30 PRIV_ASSIGN; 27 __entry->priv = priv;
31 __entry->skbaddr = (unsigned long) skb; 28 __entry->skbaddr = (unsigned long) skb;
32 memcpy(__get_dynamic_array(frame), skb->data, skb->len); 29 memcpy(__get_dynamic_array(frame), skb->data, skb->len);
33 ), 30 ),
@@ -43,14 +40,14 @@ TRACE_EVENT(ath5k_tx,
43 TP_ARGS(priv, skb, q), 40 TP_ARGS(priv, skb, q),
44 41
45 TP_STRUCT__entry( 42 TP_STRUCT__entry(
46 PRIV_ENTRY 43 __field(struct ath5k_softc *, priv)
47 __field(unsigned long, skbaddr) 44 __field(unsigned long, skbaddr)
48 __field(u8, qnum) 45 __field(u8, qnum)
49 __dynamic_array(u8, frame, skb->len) 46 __dynamic_array(u8, frame, skb->len)
50 ), 47 ),
51 48
52 TP_fast_assign( 49 TP_fast_assign(
53 PRIV_ASSIGN; 50 __entry->priv = priv;
54 __entry->skbaddr = (unsigned long) skb; 51 __entry->skbaddr = (unsigned long) skb;
55 __entry->qnum = (u8) q->qnum; 52 __entry->qnum = (u8) q->qnum;
56 memcpy(__get_dynamic_array(frame), skb->data, skb->len); 53 memcpy(__get_dynamic_array(frame), skb->data, skb->len);
@@ -69,7 +66,7 @@ TRACE_EVENT(ath5k_tx_complete,
69 TP_ARGS(priv, skb, q, ts), 66 TP_ARGS(priv, skb, q, ts),
70 67
71 TP_STRUCT__entry( 68 TP_STRUCT__entry(
72 PRIV_ENTRY 69 __field(struct ath5k_softc *, priv)
73 __field(unsigned long, skbaddr) 70 __field(unsigned long, skbaddr)
74 __field(u8, qnum) 71 __field(u8, qnum)
75 __field(u8, ts_status) 72 __field(u8, ts_status)
@@ -78,7 +75,7 @@ TRACE_EVENT(ath5k_tx_complete,
78 ), 75 ),
79 76
80 TP_fast_assign( 77 TP_fast_assign(
81 PRIV_ASSIGN; 78 __entry->priv = priv;
82 __entry->skbaddr = (unsigned long) skb; 79 __entry->skbaddr = (unsigned long) skb;
83 __entry->qnum = (u8) q->qnum; 80 __entry->qnum = (u8) q->qnum;
84 __entry->ts_status = ts->ts_status; 81 __entry->ts_status = ts->ts_status;
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 441bb33f17ad..fac2c6da6ca4 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -627,6 +627,11 @@ static void ar5008_hw_init_bb(struct ath_hw *ah,
627 else 627 else
628 synthDelay /= 10; 628 synthDelay /= 10;
629 629
630 if (IS_CHAN_HALF_RATE(chan))
631 synthDelay *= 2;
632 else if (IS_CHAN_QUARTER_RATE(chan))
633 synthDelay *= 4;
634
630 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN); 635 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
631 636
632 udelay(synthDelay + BASE_ACTIVATE_DELAY); 637 udelay(synthDelay + BASE_ACTIVATE_DELAY);
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
index f344cc2b3d59..9ff7c30573b8 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
@@ -499,45 +499,6 @@ void ar9002_hw_enable_async_fifo(struct ath_hw *ah)
499 } 499 }
500} 500}
501 501
502/*
503 * If Async FIFO is enabled, the following counters change as MAC now runs
504 * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
505 *
506 * The values below tested for ht40 2 chain.
507 * Overwrite the delay/timeouts initialized in process ini.
508 */
509void ar9002_hw_update_async_fifo(struct ath_hw *ah)
510{
511 if (AR_SREV_9287_13_OR_LATER(ah)) {
512 REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
513 AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
514 REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
515 AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
516 REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
517 AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
518
519 REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
520 REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
521
522 REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
523 AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
524 REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
525 AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
526 }
527}
528
529/*
530 * We don't enable WEP aggregation on mac80211 but we keep this
531 * around for HAL unification purposes.
532 */
533void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
534{
535 if (AR_SREV_9287_13_OR_LATER(ah)) {
536 REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
537 AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
538 }
539}
540
541/* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */ 502/* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
542void ar9002_hw_attach_ops(struct ath_hw *ah) 503void ar9002_hw_attach_ops(struct ath_hw *ah)
543{ 504{
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 2fe0a34cbabc..3cbbb033fcea 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -111,7 +111,9 @@ static int ar9002_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
111 111
112 switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) { 112 switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
113 case 0: 113 case 0:
114 if ((freq % 20) == 0) 114 if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
115 aModeRefSel = 0;
116 else if ((freq % 20) == 0)
115 aModeRefSel = 3; 117 aModeRefSel = 3;
116 else if ((freq % 10) == 0) 118 else if ((freq % 10) == 0)
117 aModeRefSel = 2; 119 aModeRefSel = 2;
@@ -129,8 +131,9 @@ static int ar9002_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
129 channelSel = CHANSEL_5G(freq); 131 channelSel = CHANSEL_5G(freq);
130 132
131 /* RefDivA setting */ 133 /* RefDivA setting */
132 REG_RMW_FIELD(ah, AR_AN_SYNTH9, 134 ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9,
133 AR_AN_SYNTH9_REFDIVA, refDivA); 135 AR_AN_SYNTH9_REFDIVA,
136 AR_AN_SYNTH9_REFDIVA_S, refDivA);
134 137
135 } 138 }
136 139
@@ -447,26 +450,27 @@ static void ar9002_olc_init(struct ath_hw *ah)
447static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah, 450static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
448 struct ath9k_channel *chan) 451 struct ath9k_channel *chan)
449{ 452{
453 int ref_div = 5;
454 int pll_div = 0x2c;
450 u32 pll; 455 u32 pll;
451 456
452 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV); 457 if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) {
458 if (AR_SREV_9280_20(ah)) {
459 ref_div = 10;
460 pll_div = 0x50;
461 } else {
462 pll_div = 0x28;
463 }
464 }
465
466 pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
467 pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
453 468
454 if (chan && IS_CHAN_HALF_RATE(chan)) 469 if (chan && IS_CHAN_HALF_RATE(chan))
455 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); 470 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
456 else if (chan && IS_CHAN_QUARTER_RATE(chan)) 471 else if (chan && IS_CHAN_QUARTER_RATE(chan))
457 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); 472 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
458 473
459 if (chan && IS_CHAN_5GHZ(chan)) {
460 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
461 pll = 0x142c;
462 else if (AR_SREV_9280_20(ah))
463 pll = 0x2850;
464 else
465 pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
466 } else {
467 pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
468 }
469
470 return pll; 474 return pll;
471} 475}
472 476
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
index e8ac70da5ac7..2339728a7306 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
@@ -653,8 +653,8 @@ static const u32 ar9300_2p2_baseband_postamble[][5] = {
653 {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110}, 653 {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110},
654 {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222}, 654 {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
655 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18}, 655 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
656 {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982}, 656 {0x0000a2d0, 0x00041981, 0x00041981, 0x00041981, 0x00041982},
657 {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a}, 657 {0x0000a2d8, 0x7999a83b, 0x7999a83b, 0x7999a83b, 0x7999a83b},
658 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 658 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
659 {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 659 {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
660 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x001c0000}, 660 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x001c0000},
@@ -761,7 +761,7 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
761 {0x0000a3ec, 0x20202020}, 761 {0x0000a3ec, 0x20202020},
762 {0x0000a3f0, 0x00000000}, 762 {0x0000a3f0, 0x00000000},
763 {0x0000a3f4, 0x00000246}, 763 {0x0000a3f4, 0x00000246},
764 {0x0000a3f8, 0x0cdbd380}, 764 {0x0000a3f8, 0x0c9bd380},
765 {0x0000a3fc, 0x000f0f01}, 765 {0x0000a3fc, 0x000f0f01},
766 {0x0000a400, 0x8fa91f01}, 766 {0x0000a400, 0x8fa91f01},
767 {0x0000a404, 0x00000000}, 767 {0x0000a404, 0x00000000},
@@ -780,7 +780,7 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
780 {0x0000a43c, 0x00100000}, 780 {0x0000a43c, 0x00100000},
781 {0x0000a440, 0x00000000}, 781 {0x0000a440, 0x00000000},
782 {0x0000a444, 0x00000000}, 782 {0x0000a444, 0x00000000},
783 {0x0000a448, 0x06000080}, 783 {0x0000a448, 0x05000080},
784 {0x0000a44c, 0x00000001}, 784 {0x0000a44c, 0x00000001},
785 {0x0000a450, 0x00010000}, 785 {0x0000a450, 0x00010000},
786 {0x0000a458, 0x00000000}, 786 {0x0000a458, 0x00000000},
@@ -1500,8 +1500,6 @@ static const u32 ar9300_2p2_mac_core[][2] = {
1500 {0x0000816c, 0x00000000}, 1500 {0x0000816c, 0x00000000},
1501 {0x000081c0, 0x00000000}, 1501 {0x000081c0, 0x00000000},
1502 {0x000081c4, 0x33332210}, 1502 {0x000081c4, 0x33332210},
1503 {0x000081c8, 0x00000000},
1504 {0x000081cc, 0x00000000},
1505 {0x000081ec, 0x00000000}, 1503 {0x000081ec, 0x00000000},
1506 {0x000081f0, 0x00000000}, 1504 {0x000081f0, 0x00000000},
1507 {0x000081f4, 0x00000000}, 1505 {0x000081f4, 0x00000000},
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 575e185f454f..8ff0b88a29b9 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -625,8 +625,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
625 rxs->rs_status |= ATH9K_RXERR_DECRYPT; 625 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
626 else if (rxsp->status11 & AR_MichaelErr) 626 else if (rxsp->status11 & AR_MichaelErr)
627 rxs->rs_status |= ATH9K_RXERR_MIC; 627 rxs->rs_status |= ATH9K_RXERR_MIC;
628 628 else if (rxsp->status11 & AR_KeyMiss)
629 if (rxsp->status11 & AR_KeyMiss)
630 rxs->rs_status |= ATH9K_RXERR_DECRYPT; 629 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
631 } 630 }
632 631
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index de1972307b0a..f80d1d633980 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -21,6 +21,36 @@ void ar9003_paprd_enable(struct ath_hw *ah, bool val)
21{ 21{
22 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); 22 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
23 struct ath9k_channel *chan = ah->curchan; 23 struct ath9k_channel *chan = ah->curchan;
24 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
25
26 /*
27 * 3 bits for modalHeader5G.papdRateMaskHt20
28 * is used for sub-band disabling of PAPRD.
29 * 5G band is divided into 3 sub-bands -- upper,
30 * middle, lower.
31 * if bit 30 of modalHeader5G.papdRateMaskHt20 is set
32 * -- disable PAPRD for upper band 5GHz
33 * if bit 29 of modalHeader5G.papdRateMaskHt20 is set
34 * -- disable PAPRD for middle band 5GHz
35 * if bit 28 of modalHeader5G.papdRateMaskHt20 is set
36 * -- disable PAPRD for lower band 5GHz
37 */
38
39 if (IS_CHAN_5GHZ(chan)) {
40 if (chan->channel >= UPPER_5G_SUB_BAND_START) {
41 if (le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20)
42 & BIT(30))
43 val = false;
44 } else if (chan->channel >= MID_5G_SUB_BAND_START) {
45 if (le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20)
46 & BIT(29))
47 val = false;
48 } else {
49 if (le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20)
50 & BIT(28))
51 val = false;
52 }
53 }
24 54
25 if (val) { 55 if (val) {
26 ah->paprd_table_write_done = true; 56 ah->paprd_table_write_done = true;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 61e6d3950718..3bea7ea86f0a 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -754,6 +754,7 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
754 IEEE80211_HW_RX_INCLUDES_FCS | 754 IEEE80211_HW_RX_INCLUDES_FCS |
755 IEEE80211_HW_SUPPORTS_PS | 755 IEEE80211_HW_SUPPORTS_PS |
756 IEEE80211_HW_PS_NULLFUNC_STACK | 756 IEEE80211_HW_PS_NULLFUNC_STACK |
757 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
757 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING; 758 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
758 759
759 hw->wiphy->interface_modes = 760 hw->wiphy->interface_modes =
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 7b7796895432..7212acb2bd6c 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1294,11 +1294,16 @@ static void ath9k_htc_configure_filter(struct ieee80211_hw *hw,
1294 u32 rfilt; 1294 u32 rfilt;
1295 1295
1296 mutex_lock(&priv->mutex); 1296 mutex_lock(&priv->mutex);
1297 ath9k_htc_ps_wakeup(priv);
1298
1299 changed_flags &= SUPPORTED_FILTERS; 1297 changed_flags &= SUPPORTED_FILTERS;
1300 *total_flags &= SUPPORTED_FILTERS; 1298 *total_flags &= SUPPORTED_FILTERS;
1301 1299
1300 if (priv->op_flags & OP_INVALID) {
1301 ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_ANY,
1302 "Unable to configure filter on invalid state\n");
1303 return;
1304 }
1305 ath9k_htc_ps_wakeup(priv);
1306
1302 priv->rxfilter = *total_flags; 1307 priv->rxfilter = *total_flags;
1303 rfilt = ath9k_htc_calcrxfilter(priv); 1308 rfilt = ath9k_htc_calcrxfilter(priv);
1304 ath9k_hw_setrxfilter(priv->ah, rfilt); 1309 ath9k_hw_setrxfilter(priv->ah, rfilt);
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 07827b55e84b..2a5f908d8037 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -87,7 +87,10 @@ static void ath9k_hw_set_clockrate(struct ath_hw *ah)
87 struct ath_common *common = ath9k_hw_common(ah); 87 struct ath_common *common = ath9k_hw_common(ah);
88 unsigned int clockrate; 88 unsigned int clockrate;
89 89
90 if (!ah->curchan) /* should really check for CCK instead */ 90 /* AR9287 v1.3+ uses async FIFO and runs the MAC at 117 MHz */
91 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah))
92 clockrate = 117;
93 else if (!ah->curchan) /* should really check for CCK instead */
91 clockrate = ATH9K_CLOCK_RATE_CCK; 94 clockrate = ATH9K_CLOCK_RATE_CCK;
92 else if (conf->channel->band == IEEE80211_BAND_2GHZ) 95 else if (conf->channel->band == IEEE80211_BAND_2GHZ)
93 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM; 96 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
@@ -99,6 +102,13 @@ static void ath9k_hw_set_clockrate(struct ath_hw *ah)
99 if (conf_is_ht40(conf)) 102 if (conf_is_ht40(conf))
100 clockrate *= 2; 103 clockrate *= 2;
101 104
105 if (ah->curchan) {
106 if (IS_CHAN_HALF_RATE(ah->curchan))
107 clockrate /= 2;
108 if (IS_CHAN_QUARTER_RATE(ah->curchan))
109 clockrate /= 4;
110 }
111
102 common->clockrate = clockrate; 112 common->clockrate = clockrate;
103} 113}
104 114
@@ -895,6 +905,13 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
895 } 905 }
896} 906}
897 907
908static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
909{
910 u32 val = ath9k_hw_mac_to_clks(ah, us - 2);
911 val = min(val, (u32) 0xFFFF);
912 REG_WRITE(ah, AR_D_GBL_IFS_SIFS, val);
913}
914
898static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us) 915static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
899{ 916{
900 u32 val = ath9k_hw_mac_to_clks(ah, us); 917 u32 val = ath9k_hw_mac_to_clks(ah, us);
@@ -932,25 +949,60 @@ static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu)
932 949
933void ath9k_hw_init_global_settings(struct ath_hw *ah) 950void ath9k_hw_init_global_settings(struct ath_hw *ah)
934{ 951{
935 struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; 952 struct ath_common *common = ath9k_hw_common(ah);
953 struct ieee80211_conf *conf = &common->hw->conf;
954 const struct ath9k_channel *chan = ah->curchan;
936 int acktimeout; 955 int acktimeout;
937 int slottime; 956 int slottime;
938 int sifstime; 957 int sifstime;
958 int rx_lat = 0, tx_lat = 0, eifs = 0;
959 u32 reg;
939 960
940 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", 961 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
941 ah->misc_mode); 962 ah->misc_mode);
942 963
964 if (!chan)
965 return;
966
943 if (ah->misc_mode != 0) 967 if (ah->misc_mode != 0)
944 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode); 968 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
945 969
946 if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ) 970 rx_lat = 37;
947 sifstime = 16; 971 tx_lat = 54;
948 else 972
949 sifstime = 10; 973 if (IS_CHAN_HALF_RATE(chan)) {
974 eifs = 175;
975 rx_lat *= 2;
976 tx_lat *= 2;
977 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
978 tx_lat += 11;
979
980 slottime = 13;
981 sifstime = 32;
982 } else if (IS_CHAN_QUARTER_RATE(chan)) {
983 eifs = 340;
984 rx_lat *= 4;
985 tx_lat *= 4;
986 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
987 tx_lat += 22;
988
989 slottime = 21;
990 sifstime = 64;
991 } else {
992 eifs = REG_READ(ah, AR_D_GBL_IFS_EIFS);
993 reg = REG_READ(ah, AR_USEC);
994 rx_lat = MS(reg, AR_USEC_RX_LAT);
995 tx_lat = MS(reg, AR_USEC_TX_LAT);
996
997 slottime = ah->slottime;
998 if (IS_CHAN_5GHZ(chan))
999 sifstime = 16;
1000 else
1001 sifstime = 10;
1002 }
950 1003
951 /* As defined by IEEE 802.11-2007 17.3.8.6 */ 1004 /* As defined by IEEE 802.11-2007 17.3.8.6 */
952 slottime = ah->slottime + 3 * ah->coverage_class; 1005 acktimeout = slottime + sifstime + 3 * ah->coverage_class;
953 acktimeout = slottime + sifstime;
954 1006
955 /* 1007 /*
956 * Workaround for early ACK timeouts, add an offset to match the 1008 * Workaround for early ACK timeouts, add an offset to match the
@@ -962,11 +1014,20 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah)
962 if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ) 1014 if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
963 acktimeout += 64 - sifstime - ah->slottime; 1015 acktimeout += 64 - sifstime - ah->slottime;
964 1016
965 ath9k_hw_setslottime(ah, ah->slottime); 1017 ath9k_hw_set_sifs_time(ah, sifstime);
1018 ath9k_hw_setslottime(ah, slottime);
966 ath9k_hw_set_ack_timeout(ah, acktimeout); 1019 ath9k_hw_set_ack_timeout(ah, acktimeout);
967 ath9k_hw_set_cts_timeout(ah, acktimeout); 1020 ath9k_hw_set_cts_timeout(ah, acktimeout);
968 if (ah->globaltxtimeout != (u32) -1) 1021 if (ah->globaltxtimeout != (u32) -1)
969 ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout); 1022 ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
1023
1024 REG_WRITE(ah, AR_D_GBL_IFS_EIFS, ath9k_hw_mac_to_clks(ah, eifs));
1025 REG_RMW(ah, AR_USEC,
1026 (common->clockrate - 1) |
1027 SM(rx_lat, AR_USEC_RX_LAT) |
1028 SM(tx_lat, AR_USEC_TX_LAT),
1029 AR_USEC_TX_LAT | AR_USEC_RX_LAT | AR_USEC_USEC);
1030
970} 1031}
971EXPORT_SYMBOL(ath9k_hw_init_global_settings); 1032EXPORT_SYMBOL(ath9k_hw_init_global_settings);
972 1033
@@ -1570,9 +1631,13 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1570 1631
1571 ath9k_hw_init_global_settings(ah); 1632 ath9k_hw_init_global_settings(ah);
1572 1633
1573 if (!AR_SREV_9300_20_OR_LATER(ah)) { 1634 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
1574 ar9002_hw_update_async_fifo(ah); 1635 REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
1575 ar9002_hw_enable_wep_aggregation(ah); 1636 AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
1637 REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
1638 AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
1639 REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
1640 AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
1576 } 1641 }
1577 1642
1578 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM); 1643 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
@@ -2079,10 +2144,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2079 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD; 2144 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
2080 } else { 2145 } else {
2081 pCap->tx_desc_len = sizeof(struct ath_desc); 2146 pCap->tx_desc_len = sizeof(struct ath_desc);
2082 if (AR_SREV_9280_20(ah) && 2147 if (AR_SREV_9280_20(ah))
2083 ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <=
2084 AR5416_EEP_MINOR_VER_16) ||
2085 ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G)))
2086 pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK; 2148 pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
2087 } 2149 }
2088 2150
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 818acdd1ba90..6acd0f975ae1 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -143,6 +143,8 @@
143#define AR_KEYTABLE_SIZE 128 143#define AR_KEYTABLE_SIZE 128
144#define POWER_UP_TIME 10000 144#define POWER_UP_TIME 10000
145#define SPUR_RSSI_THRESH 40 145#define SPUR_RSSI_THRESH 40
146#define UPPER_5G_SUB_BAND_START 5700
147#define MID_5G_SUB_BAND_START 5400
146 148
147#define CAB_TIMEOUT_VAL 10 149#define CAB_TIMEOUT_VAL 10
148#define BEACON_TIMEOUT_VAL 10 150#define BEACON_TIMEOUT_VAL 10
@@ -983,8 +985,6 @@ void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
983void ar9002_hw_cck_chan14_spread(struct ath_hw *ah); 985void ar9002_hw_cck_chan14_spread(struct ath_hw *ah);
984int ar9002_hw_rf_claim(struct ath_hw *ah); 986int ar9002_hw_rf_claim(struct ath_hw *ah);
985void ar9002_hw_enable_async_fifo(struct ath_hw *ah); 987void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
986void ar9002_hw_update_async_fifo(struct ath_hw *ah);
987void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
988 988
989/* 989/*
990 * Code specific to AR9003, we stuff these here to avoid callbacks 990 * Code specific to AR9003, we stuff these here to avoid callbacks
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index c2091f1f4096..b6b523a897e5 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -645,8 +645,7 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
645 rs->rs_status |= ATH9K_RXERR_DECRYPT; 645 rs->rs_status |= ATH9K_RXERR_DECRYPT;
646 else if (ads.ds_rxstatus8 & AR_MichaelErr) 646 else if (ads.ds_rxstatus8 & AR_MichaelErr)
647 rs->rs_status |= ATH9K_RXERR_MIC; 647 rs->rs_status |= ATH9K_RXERR_MIC;
648 648 else if (ads.ds_rxstatus8 & AR_KeyMiss)
649 if (ads.ds_rxstatus8 & AR_KeyMiss)
650 rs->rs_status |= ATH9K_RXERR_DECRYPT; 649 rs->rs_status |= ATH9K_RXERR_DECRYPT;
651 } 650 }
652 651
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index e7fe4d9aee79..c04a6c3cac7f 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -379,7 +379,30 @@ static const struct ath_rate_table ar5416_11g_ratetable = {
379}; 379};
380 380
381static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table, 381static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
382 struct ieee80211_tx_rate *rate); 382 struct ieee80211_tx_rate *rate)
383{
384 int rix = 0, i = 0;
385 static const int mcs_rix_off[] = { 7, 15, 20, 21, 22, 23 };
386
387 if (!(rate->flags & IEEE80211_TX_RC_MCS))
388 return rate->idx;
389
390 while (i < ARRAY_SIZE(mcs_rix_off) && rate->idx > mcs_rix_off[i]) {
391 rix++; i++;
392 }
393
394 rix += rate->idx + rate_table->mcs_start;
395
396 if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
397 (rate->flags & IEEE80211_TX_RC_SHORT_GI))
398 rix = rate_table->info[rix].ht_index;
399 else if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
400 rix = rate_table->info[rix].sgi_index;
401 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
402 rix = rate_table->info[rix].cw40index;
403
404 return rix;
405}
383 406
384static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, 407static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table,
385 struct ath_rate_priv *ath_rc_priv) 408 struct ath_rate_priv *ath_rc_priv)
@@ -1080,31 +1103,6 @@ static void ath_rc_update_ht(struct ath_softc *sc,
1080 1103
1081} 1104}
1082 1105
1083static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
1084 struct ieee80211_tx_rate *rate)
1085{
1086 int rix = 0, i = 0;
1087 static const int mcs_rix_off[] = { 7, 15, 20, 21, 22, 23 };
1088
1089 if (!(rate->flags & IEEE80211_TX_RC_MCS))
1090 return rate->idx;
1091
1092 while (i < ARRAY_SIZE(mcs_rix_off) && rate->idx > mcs_rix_off[i]) {
1093 rix++; i++;
1094 }
1095
1096 rix += rate->idx + rate_table->mcs_start;
1097
1098 if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
1099 (rate->flags & IEEE80211_TX_RC_SHORT_GI))
1100 rix = rate_table->info[rix].ht_index;
1101 else if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
1102 rix = rate_table->info[rix].sgi_index;
1103 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1104 rix = rate_table->info[rix].cw40index;
1105
1106 return rix;
1107}
1108 1106
1109static void ath_rc_tx_status(struct ath_softc *sc, 1107static void ath_rc_tx_status(struct ath_softc *sc,
1110 struct ath_rate_priv *ath_rc_priv, 1108 struct ath_rate_priv *ath_rc_priv,
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index a4833880accd..759b72cca3cc 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -600,7 +600,6 @@
600 600
601#define AR_D_GBL_IFS_SIFS 0x1030 601#define AR_D_GBL_IFS_SIFS 0x1030
602#define AR_D_GBL_IFS_SIFS_M 0x0000FFFF 602#define AR_D_GBL_IFS_SIFS_M 0x0000FFFF
603#define AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR 0x000003AB
604#define AR_D_GBL_IFS_SIFS_RESV0 0xFFFFFFFF 603#define AR_D_GBL_IFS_SIFS_RESV0 0xFFFFFFFF
605 604
606#define AR_D_TXBLK_BASE 0x1038 605#define AR_D_TXBLK_BASE 0x1038
@@ -616,12 +615,10 @@
616#define AR_D_GBL_IFS_SLOT 0x1070 615#define AR_D_GBL_IFS_SLOT 0x1070
617#define AR_D_GBL_IFS_SLOT_M 0x0000FFFF 616#define AR_D_GBL_IFS_SLOT_M 0x0000FFFF
618#define AR_D_GBL_IFS_SLOT_RESV0 0xFFFF0000 617#define AR_D_GBL_IFS_SLOT_RESV0 0xFFFF0000
619#define AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR 0x00000420
620 618
621#define AR_D_GBL_IFS_EIFS 0x10b0 619#define AR_D_GBL_IFS_EIFS 0x10b0
622#define AR_D_GBL_IFS_EIFS_M 0x0000FFFF 620#define AR_D_GBL_IFS_EIFS_M 0x0000FFFF
623#define AR_D_GBL_IFS_EIFS_RESV0 0xFFFF0000 621#define AR_D_GBL_IFS_EIFS_RESV0 0xFFFF0000
624#define AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR 0x0000A5EB
625 622
626#define AR_D_GBL_IFS_MISC 0x10f0 623#define AR_D_GBL_IFS_MISC 0x10f0
627#define AR_D_GBL_IFS_MISC_LFSR_SLICE_SEL 0x00000007 624#define AR_D_GBL_IFS_MISC_LFSR_SLICE_SEL 0x00000007
@@ -1477,7 +1474,6 @@ enum {
1477#define AR_TIME_OUT_ACK_S 0 1474#define AR_TIME_OUT_ACK_S 0
1478#define AR_TIME_OUT_CTS 0x3FFF0000 1475#define AR_TIME_OUT_CTS 0x3FFF0000
1479#define AR_TIME_OUT_CTS_S 16 1476#define AR_TIME_OUT_CTS_S 16
1480#define AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR 0x16001D56
1481 1477
1482#define AR_RSSI_THR 0x8018 1478#define AR_RSSI_THR 0x8018
1483#define AR_RSSI_THR_MASK 0x000000FF 1479#define AR_RSSI_THR_MASK 0x000000FF
@@ -1493,7 +1489,6 @@ enum {
1493#define AR_USEC_TX_LAT_S 14 1489#define AR_USEC_TX_LAT_S 14
1494#define AR_USEC_RX_LAT 0x1F800000 1490#define AR_USEC_RX_LAT 0x1F800000
1495#define AR_USEC_RX_LAT_S 23 1491#define AR_USEC_RX_LAT_S 23
1496#define AR_USEC_ASYNC_FIFO_DUR 0x12e00074
1497 1492
1498#define AR_RESET_TSF 0x8020 1493#define AR_RESET_TSF 0x8020
1499#define AR_RESET_TSF_ONCE 0x01000000 1494#define AR_RESET_TSF_ONCE 0x01000000
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index d2b9f1256bc8..a61cf6781d5e 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1484,6 +1484,13 @@ static void carl9170_op_sta_notify(struct ieee80211_hw *hw,
1484 } 1484 }
1485} 1485}
1486 1486
1487static bool carl9170_tx_frames_pending(struct ieee80211_hw *hw)
1488{
1489 struct ar9170 *ar = hw->priv;
1490
1491 return !!atomic_read(&ar->tx_total_queued);
1492}
1493
1487static const struct ieee80211_ops carl9170_ops = { 1494static const struct ieee80211_ops carl9170_ops = {
1488 .start = carl9170_op_start, 1495 .start = carl9170_op_start,
1489 .stop = carl9170_op_stop, 1496 .stop = carl9170_op_stop,
@@ -1504,6 +1511,7 @@ static const struct ieee80211_ops carl9170_ops = {
1504 .get_survey = carl9170_op_get_survey, 1511 .get_survey = carl9170_op_get_survey,
1505 .get_stats = carl9170_op_get_stats, 1512 .get_stats = carl9170_op_get_stats,
1506 .ampdu_action = carl9170_op_ampdu_action, 1513 .ampdu_action = carl9170_op_ampdu_action,
1514 .tx_frames_pending = carl9170_tx_frames_pending,
1507}; 1515};
1508 1516
1509void *carl9170_alloc(size_t priv_size) 1517void *carl9170_alloc(size_t priv_size)
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index d5add69aac8f..d2293dcc117f 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -90,6 +90,12 @@ config B43_SDIO
90 90
91#Data transfers to the device via PIO. We want it as a fallback even 91#Data transfers to the device via PIO. We want it as a fallback even
92# if we can do DMA. 92# if we can do DMA.
93config B43_BCMA_PIO
94 bool
95 depends on B43_BCMA
96 select BCMA_BLOCKIO
97 default y
98
93config B43_PIO 99config B43_PIO
94 bool 100 bool
95 depends on B43 101 depends on B43
@@ -125,6 +131,14 @@ config B43_PHY_HT
125 131
126 Say N, this is BROKEN and crashes driver. 132 Say N, this is BROKEN and crashes driver.
127 133
134config B43_PHY_LCN
135 bool "Support for LCN-PHY devices (BROKEN)"
136 depends on B43 && BROKEN
137 ---help---
138 Support for the LCN-PHY.
139
140 Say N, this is BROKEN and crashes driver.
141
128# This config option automatically enables b43 LEDS support, 142# This config option automatically enables b43 LEDS support,
129# if it's possible. 143# if it's possible.
130config B43_LEDS 144config B43_LEDS
diff --git a/drivers/net/wireless/b43/Makefile b/drivers/net/wireless/b43/Makefile
index 1b25604be547..4648bbf76abc 100644
--- a/drivers/net/wireless/b43/Makefile
+++ b/drivers/net/wireless/b43/Makefile
@@ -13,6 +13,7 @@ b43-$(CONFIG_B43_PHY_LP) += tables_lpphy.o
13b43-$(CONFIG_B43_PHY_HT) += phy_ht.o 13b43-$(CONFIG_B43_PHY_HT) += phy_ht.o
14b43-$(CONFIG_B43_PHY_HT) += tables_phy_ht.o 14b43-$(CONFIG_B43_PHY_HT) += tables_phy_ht.o
15b43-$(CONFIG_B43_PHY_HT) += radio_2059.o 15b43-$(CONFIG_B43_PHY_HT) += radio_2059.o
16b43-$(CONFIG_B43_PHY_LCN) += phy_lcn.o tables_phy_lcn.o
16b43-y += sysfs.o 17b43-y += sysfs.o
17b43-y += xmit.o 18b43-y += xmit.o
18b43-y += lo.o 19b43-y += lo.o
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 666515e348b5..08a28270bbb3 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -726,7 +726,6 @@ enum {
726 726
727/* Data structure for one wireless device (802.11 core) */ 727/* Data structure for one wireless device (802.11 core) */
728struct b43_wldev { 728struct b43_wldev {
729 struct ssb_device *sdev; /* TODO: remove when b43_bus_dev is ready */
730 struct b43_bus_dev *dev; 729 struct b43_bus_dev *dev;
731 struct b43_wl *wl; 730 struct b43_wl *wl;
732 731
diff --git a/drivers/net/wireless/b43/bus.c b/drivers/net/wireless/b43/bus.c
index 4200713eb597..a5e61a9fb539 100644
--- a/drivers/net/wireless/b43/bus.c
+++ b/drivers/net/wireless/b43/bus.c
@@ -23,6 +23,106 @@
23#include "b43.h" 23#include "b43.h"
24#include "bus.h" 24#include "bus.h"
25 25
26/* BCMA */
27#ifdef CONFIG_B43_BCMA
28static int b43_bus_bcma_bus_may_powerdown(struct b43_bus_dev *dev)
29{
30 return 0; /* bcma_bus_may_powerdown(dev->bdev->bus); */
31}
32static int b43_bus_bcma_bus_powerup(struct b43_bus_dev *dev,
33 bool dynamic_pctl)
34{
35 return 0; /* bcma_bus_powerup(dev->sdev->bus, dynamic_pctl); */
36}
37static int b43_bus_bcma_device_is_enabled(struct b43_bus_dev *dev)
38{
39 return bcma_core_is_enabled(dev->bdev);
40}
41static void b43_bus_bcma_device_enable(struct b43_bus_dev *dev,
42 u32 core_specific_flags)
43{
44 bcma_core_enable(dev->bdev, core_specific_flags);
45}
46static void b43_bus_bcma_device_disable(struct b43_bus_dev *dev,
47 u32 core_specific_flags)
48{
49 bcma_core_disable(dev->bdev, core_specific_flags);
50}
51static u16 b43_bus_bcma_read16(struct b43_bus_dev *dev, u16 offset)
52{
53 return bcma_read16(dev->bdev, offset);
54}
55static u32 b43_bus_bcma_read32(struct b43_bus_dev *dev, u16 offset)
56{
57 return bcma_read32(dev->bdev, offset);
58}
59static
60void b43_bus_bcma_write16(struct b43_bus_dev *dev, u16 offset, u16 value)
61{
62 bcma_write16(dev->bdev, offset, value);
63}
64static
65void b43_bus_bcma_write32(struct b43_bus_dev *dev, u16 offset, u32 value)
66{
67 bcma_write32(dev->bdev, offset, value);
68}
69static
70void b43_bus_bcma_block_read(struct b43_bus_dev *dev, void *buffer,
71 size_t count, u16 offset, u8 reg_width)
72{
73 bcma_block_read(dev->bdev, buffer, count, offset, reg_width);
74}
75static
76void b43_bus_bcma_block_write(struct b43_bus_dev *dev, const void *buffer,
77 size_t count, u16 offset, u8 reg_width)
78{
79 bcma_block_write(dev->bdev, buffer, count, offset, reg_width);
80}
81
82struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core)
83{
84 struct b43_bus_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
85 if (!dev)
86 return NULL;
87
88 dev->bus_type = B43_BUS_BCMA;
89 dev->bdev = core;
90
91 dev->bus_may_powerdown = b43_bus_bcma_bus_may_powerdown;
92 dev->bus_powerup = b43_bus_bcma_bus_powerup;
93 dev->device_is_enabled = b43_bus_bcma_device_is_enabled;
94 dev->device_enable = b43_bus_bcma_device_enable;
95 dev->device_disable = b43_bus_bcma_device_disable;
96
97 dev->read16 = b43_bus_bcma_read16;
98 dev->read32 = b43_bus_bcma_read32;
99 dev->write16 = b43_bus_bcma_write16;
100 dev->write32 = b43_bus_bcma_write32;
101 dev->block_read = b43_bus_bcma_block_read;
102 dev->block_write = b43_bus_bcma_block_write;
103
104 dev->dev = &core->dev;
105 dev->dma_dev = core->dma_dev;
106 dev->irq = core->irq;
107
108 /*
109 dev->board_vendor = core->bus->boardinfo.vendor;
110 dev->board_type = core->bus->boardinfo.type;
111 dev->board_rev = core->bus->boardinfo.rev;
112 */
113
114 dev->chip_id = core->bus->chipinfo.id;
115 dev->chip_rev = core->bus->chipinfo.rev;
116 dev->chip_pkg = core->bus->chipinfo.pkg;
117
118 dev->bus_sprom = &core->bus->sprom;
119
120 dev->core_id = core->id.id;
121 dev->core_rev = core->id.rev;
122
123 return dev;
124}
125#endif /* CONFIG_B43_BCMA */
26 126
27/* SSB */ 127/* SSB */
28#ifdef CONFIG_B43_SSB 128#ifdef CONFIG_B43_SSB
@@ -125,3 +225,32 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev)
125 return dev; 225 return dev;
126} 226}
127#endif /* CONFIG_B43_SSB */ 227#endif /* CONFIG_B43_SSB */
228
229void *b43_bus_get_wldev(struct b43_bus_dev *dev)
230{
231 switch (dev->bus_type) {
232#ifdef CONFIG_B43_BCMA
233 case B43_BUS_BCMA:
234 return bcma_get_drvdata(dev->bdev);
235#endif
236#ifdef CONFIG_B43_SSB
237 case B43_BUS_SSB:
238 return ssb_get_drvdata(dev->sdev);
239#endif
240 }
241 return NULL;
242}
243
244void b43_bus_set_wldev(struct b43_bus_dev *dev, void *wldev)
245{
246 switch (dev->bus_type) {
247#ifdef CONFIG_B43_BCMA
248 case B43_BUS_BCMA:
249 bcma_set_drvdata(dev->bdev, wldev);
250#endif
251#ifdef CONFIG_B43_SSB
252 case B43_BUS_SSB:
253 ssb_set_drvdata(dev->sdev, wldev);
254#endif
255 }
256}
diff --git a/drivers/net/wireless/b43/bus.h b/drivers/net/wireless/b43/bus.h
index 79a5ab4270c3..184c95659279 100644
--- a/drivers/net/wireless/b43/bus.h
+++ b/drivers/net/wireless/b43/bus.h
@@ -2,12 +2,16 @@
2#define B43_BUS_H_ 2#define B43_BUS_H_
3 3
4enum b43_bus_type { 4enum b43_bus_type {
5#ifdef CONFIG_B43_BCMA
6 B43_BUS_BCMA,
7#endif
5 B43_BUS_SSB, 8 B43_BUS_SSB,
6}; 9};
7 10
8struct b43_bus_dev { 11struct b43_bus_dev {
9 enum b43_bus_type bus_type; 12 enum b43_bus_type bus_type;
10 union { 13 union {
14 struct bcma_device *bdev;
11 struct ssb_device *sdev; 15 struct ssb_device *sdev;
12 }; 16 };
13 17
@@ -57,6 +61,10 @@ static inline bool b43_bus_host_is_sdio(struct b43_bus_dev *dev)
57 dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO); 61 dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO);
58} 62}
59 63
64struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
60struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev); 65struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
61 66
67void *b43_bus_get_wldev(struct b43_bus_dev *dev);
68void b43_bus_set_wldev(struct b43_bus_dev *dev, void *data);
69
62#endif /* B43_BUS_H_ */ 70#endif /* B43_BUS_H_ */
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 7a09a467339c..ce572aebeffd 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -1055,7 +1055,14 @@ int b43_dma_init(struct b43_wldev *dev)
1055 err = b43_dma_set_mask(dev, dmamask); 1055 err = b43_dma_set_mask(dev, dmamask);
1056 if (err) 1056 if (err)
1057 return err; 1057 return err;
1058 dma->translation = ssb_dma_translation(dev->sdev); 1058
1059 switch (dev->dev->bus_type) {
1060#ifdef CONFIG_B43_SSB
1061 case B43_BUS_SSB:
1062 dma->translation = ssb_dma_translation(dev->dev->sdev);
1063 break;
1064#endif
1065 }
1059 1066
1060 err = -ENOMEM; 1067 err = -ENOMEM;
1061 /* setup TX DMA channels. */ 1068 /* setup TX DMA channels. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index e9a01e3eede7..092dd9318869 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1155,6 +1155,21 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags)
1155 } 1155 }
1156} 1156}
1157 1157
1158#ifdef CONFIG_B43_BCMA
1159static void b43_bcma_wireless_core_reset(struct b43_wldev *dev, bool gmode)
1160{
1161 u32 flags = 0;
1162
1163 if (gmode)
1164 flags = B43_BCMA_IOCTL_GMODE;
1165 flags |= B43_BCMA_IOCTL_PHY_CLKEN;
1166 flags |= B43_BCMA_IOCTL_PHY_BW_20MHZ; /* Make 20 MHz def */
1167 b43_device_enable(dev, flags);
1168
1169 /* TODO: reset PHY */
1170}
1171#endif
1172
1158static void b43_ssb_wireless_core_reset(struct b43_wldev *dev, bool gmode) 1173static void b43_ssb_wireless_core_reset(struct b43_wldev *dev, bool gmode)
1159{ 1174{
1160 struct ssb_device *sdev = dev->dev->sdev; 1175 struct ssb_device *sdev = dev->dev->sdev;
@@ -1187,7 +1202,18 @@ void b43_wireless_core_reset(struct b43_wldev *dev, bool gmode)
1187{ 1202{
1188 u32 macctl; 1203 u32 macctl;
1189 1204
1190 b43_ssb_wireless_core_reset(dev, gmode); 1205 switch (dev->dev->bus_type) {
1206#ifdef CONFIG_B43_BCMA
1207 case B43_BUS_BCMA:
1208 b43_bcma_wireless_core_reset(dev, gmode);
1209 break;
1210#endif
1211#ifdef CONFIG_B43_SSB
1212 case B43_BUS_SSB:
1213 b43_ssb_wireless_core_reset(dev, gmode);
1214 break;
1215#endif
1216 }
1191 1217
1192 /* Turn Analog ON, but only if we already know the PHY-type. 1218 /* Turn Analog ON, but only if we already know the PHY-type.
1193 * This protects against very early setup where we don't know the 1219 * This protects against very early setup where we don't know the
@@ -1938,7 +1964,7 @@ static irqreturn_t b43_do_interrupt(struct b43_wldev *dev)
1938 return IRQ_NONE; 1964 return IRQ_NONE;
1939 reason &= dev->irq_mask; 1965 reason &= dev->irq_mask;
1940 if (!reason) 1966 if (!reason)
1941 return IRQ_HANDLED; 1967 return IRQ_NONE;
1942 1968
1943 dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON) 1969 dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON)
1944 & 0x0001DC00; 1970 & 0x0001DC00;
@@ -2133,21 +2159,43 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2133 u32 tmshigh; 2159 u32 tmshigh;
2134 int err; 2160 int err;
2135 2161
2162 /* Files for HT and LCN were found by trying one by one */
2163
2136 /* Get microcode */ 2164 /* Get microcode */
2137 if ((rev >= 5) && (rev <= 10)) 2165 if ((rev >= 5) && (rev <= 10)) {
2138 filename = "ucode5"; 2166 filename = "ucode5";
2139 else if ((rev >= 11) && (rev <= 12)) 2167 } else if ((rev >= 11) && (rev <= 12)) {
2140 filename = "ucode11"; 2168 filename = "ucode11";
2141 else if (rev == 13) 2169 } else if (rev == 13) {
2142 filename = "ucode13"; 2170 filename = "ucode13";
2143 else if (rev == 14) 2171 } else if (rev == 14) {
2144 filename = "ucode14"; 2172 filename = "ucode14";
2145 else if (rev == 15) 2173 } else if (rev == 15) {
2146 filename = "ucode15"; 2174 filename = "ucode15";
2147 else if ((rev >= 16) && (rev <= 20)) 2175 } else {
2148 filename = "ucode16_mimo"; 2176 switch (dev->phy.type) {
2149 else 2177 case B43_PHYTYPE_N:
2150 goto err_no_ucode; 2178 if (rev >= 16)
2179 filename = "ucode16_mimo";
2180 else
2181 goto err_no_ucode;
2182 break;
2183 case B43_PHYTYPE_HT:
2184 if (rev == 29)
2185 filename = "ucode29_mimo";
2186 else
2187 goto err_no_ucode;
2188 break;
2189 case B43_PHYTYPE_LCN:
2190 if (rev == 24)
2191 filename = "ucode24_mimo";
2192 else
2193 goto err_no_ucode;
2194 break;
2195 default:
2196 goto err_no_ucode;
2197 }
2198 }
2151 err = b43_do_request_fw(ctx, filename, &fw->ucode); 2199 err = b43_do_request_fw(ctx, filename, &fw->ucode);
2152 if (err) 2200 if (err)
2153 goto err_load; 2201 goto err_load;
@@ -2206,6 +2254,18 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2206 else 2254 else
2207 goto err_no_initvals; 2255 goto err_no_initvals;
2208 break; 2256 break;
2257 case B43_PHYTYPE_HT:
2258 if (rev == 29)
2259 filename = "ht0initvals29";
2260 else
2261 goto err_no_initvals;
2262 break;
2263 case B43_PHYTYPE_LCN:
2264 if (rev == 24)
2265 filename = "lcn0initvals24";
2266 else
2267 goto err_no_initvals;
2268 break;
2209 default: 2269 default:
2210 goto err_no_initvals; 2270 goto err_no_initvals;
2211 } 2271 }
@@ -2253,6 +2313,18 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2253 else 2313 else
2254 goto err_no_initvals; 2314 goto err_no_initvals;
2255 break; 2315 break;
2316 case B43_PHYTYPE_HT:
2317 if (rev == 29)
2318 filename = "ht0bsinitvals29";
2319 else
2320 goto err_no_initvals;
2321 break;
2322 case B43_PHYTYPE_LCN:
2323 if (rev == 24)
2324 filename = "lcn0bsinitvals24";
2325 else
2326 goto err_no_initvals;
2327 break;
2256 default: 2328 default:
2257 goto err_no_initvals; 2329 goto err_no_initvals;
2258 } 2330 }
@@ -2624,11 +2696,24 @@ static int b43_gpio_init(struct b43_wldev *dev)
2624 if (dev->dev->core_rev >= 2) 2696 if (dev->dev->core_rev >= 2)
2625 mask |= 0x0010; /* FIXME: This is redundant. */ 2697 mask |= 0x0010; /* FIXME: This is redundant. */
2626 2698
2627 gpiodev = b43_ssb_gpio_dev(dev); 2699 switch (dev->dev->bus_type) {
2628 if (gpiodev) 2700#ifdef CONFIG_B43_BCMA
2629 ssb_write32(gpiodev, B43_GPIO_CONTROL, 2701 case B43_BUS_BCMA:
2630 (ssb_read32(gpiodev, B43_GPIO_CONTROL) 2702 bcma_cc_write32(&dev->dev->bdev->bus->drv_cc, BCMA_CC_GPIOCTL,
2631 & mask) | set); 2703 (bcma_cc_read32(&dev->dev->bdev->bus->drv_cc,
2704 BCMA_CC_GPIOCTL) & mask) | set);
2705 break;
2706#endif
2707#ifdef CONFIG_B43_SSB
2708 case B43_BUS_SSB:
2709 gpiodev = b43_ssb_gpio_dev(dev);
2710 if (gpiodev)
2711 ssb_write32(gpiodev, B43_GPIO_CONTROL,
2712 (ssb_read32(gpiodev, B43_GPIO_CONTROL)
2713 & mask) | set);
2714 break;
2715#endif
2716 }
2632 2717
2633 return 0; 2718 return 0;
2634} 2719}
@@ -2638,9 +2723,21 @@ static void b43_gpio_cleanup(struct b43_wldev *dev)
2638{ 2723{
2639 struct ssb_device *gpiodev; 2724 struct ssb_device *gpiodev;
2640 2725
2641 gpiodev = b43_ssb_gpio_dev(dev); 2726 switch (dev->dev->bus_type) {
2642 if (gpiodev) 2727#ifdef CONFIG_B43_BCMA
2643 ssb_write32(gpiodev, B43_GPIO_CONTROL, 0); 2728 case B43_BUS_BCMA:
2729 bcma_cc_write32(&dev->dev->bdev->bus->drv_cc, BCMA_CC_GPIOCTL,
2730 0);
2731 break;
2732#endif
2733#ifdef CONFIG_B43_SSB
2734 case B43_BUS_SSB:
2735 gpiodev = b43_ssb_gpio_dev(dev);
2736 if (gpiodev)
2737 ssb_write32(gpiodev, B43_GPIO_CONTROL, 0);
2738 break;
2739#endif
2740 }
2644} 2741}
2645 2742
2646/* http://bcm-specs.sipsolutions.net/EnableMac */ 2743/* http://bcm-specs.sipsolutions.net/EnableMac */
@@ -2712,12 +2809,30 @@ out:
2712/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */ 2809/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
2713void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on) 2810void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)
2714{ 2811{
2715 u32 tmslow = ssb_read32(dev->sdev, SSB_TMSLOW); 2812 u32 tmp;
2716 if (on) 2813
2717 tmslow |= B43_TMSLOW_MACPHYCLKEN; 2814 switch (dev->dev->bus_type) {
2718 else 2815#ifdef CONFIG_B43_BCMA
2719 tmslow &= ~B43_TMSLOW_MACPHYCLKEN; 2816 case B43_BUS_BCMA:
2720 ssb_write32(dev->sdev, SSB_TMSLOW, tmslow); 2817 tmp = bcma_read32(dev->dev->bdev, BCMA_IOCTL);
2818 if (on)
2819 tmp |= B43_BCMA_IOCTL_MACPHYCLKEN;
2820 else
2821 tmp &= ~B43_BCMA_IOCTL_MACPHYCLKEN;
2822 bcma_write32(dev->dev->bdev, BCMA_IOCTL, tmp);
2823 break;
2824#endif
2825#ifdef CONFIG_B43_SSB
2826 case B43_BUS_SSB:
2827 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW);
2828 if (on)
2829 tmp |= B43_TMSLOW_MACPHYCLKEN;
2830 else
2831 tmp &= ~B43_TMSLOW_MACPHYCLKEN;
2832 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp);
2833 break;
2834#endif
2835 }
2721} 2836}
2722 2837
2723static void b43_adjust_opmode(struct b43_wldev *dev) 2838static void b43_adjust_opmode(struct b43_wldev *dev)
@@ -2956,8 +3071,20 @@ static int b43_chip_init(struct b43_wldev *dev)
2956 3071
2957 b43_mac_phy_clock_set(dev, true); 3072 b43_mac_phy_clock_set(dev, true);
2958 3073
2959 b43_write16(dev, B43_MMIO_POWERUP_DELAY, 3074 switch (dev->dev->bus_type) {
2960 dev->sdev->bus->chipco.fast_pwrup_delay); 3075#ifdef CONFIG_B43_BCMA
3076 case B43_BUS_BCMA:
3077 /* FIXME: 0xE74 is quite common, but should be read from CC */
3078 b43_write16(dev, B43_MMIO_POWERUP_DELAY, 0xE74);
3079 break;
3080#endif
3081#ifdef CONFIG_B43_SSB
3082 case B43_BUS_SSB:
3083 b43_write16(dev, B43_MMIO_POWERUP_DELAY,
3084 dev->dev->sdev->bus->chipco.fast_pwrup_delay);
3085 break;
3086#endif
3087 }
2961 3088
2962 err = 0; 3089 err = 0;
2963 b43dbg(dev->wl, "Chip initialized\n"); 3090 b43dbg(dev->wl, "Chip initialized\n");
@@ -3473,21 +3600,33 @@ static void b43_op_set_tsf(struct ieee80211_hw *hw, u64 tsf)
3473 3600
3474static void b43_put_phy_into_reset(struct b43_wldev *dev) 3601static void b43_put_phy_into_reset(struct b43_wldev *dev)
3475{ 3602{
3476 struct ssb_device *sdev = dev->sdev; 3603 u32 tmp;
3477 u32 tmslow;
3478 3604
3479 tmslow = ssb_read32(sdev, SSB_TMSLOW); 3605 switch (dev->dev->bus_type) {
3480 tmslow &= ~B43_TMSLOW_GMODE; 3606#ifdef CONFIG_B43_BCMA
3481 tmslow |= B43_TMSLOW_PHYRESET; 3607 case B43_BUS_BCMA:
3482 tmslow |= SSB_TMSLOW_FGC; 3608 b43err(dev->wl,
3483 ssb_write32(sdev, SSB_TMSLOW, tmslow); 3609 "Putting PHY into reset not supported on BCMA\n");
3484 msleep(1); 3610 break;
3611#endif
3612#ifdef CONFIG_B43_SSB
3613 case B43_BUS_SSB:
3614 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW);
3615 tmp &= ~B43_TMSLOW_GMODE;
3616 tmp |= B43_TMSLOW_PHYRESET;
3617 tmp |= SSB_TMSLOW_FGC;
3618 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp);
3619 msleep(1);
3620
3621 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW);
3622 tmp &= ~SSB_TMSLOW_FGC;
3623 tmp |= B43_TMSLOW_PHYRESET;
3624 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp);
3625 msleep(1);
3485 3626
3486 tmslow = ssb_read32(sdev, SSB_TMSLOW); 3627 break;
3487 tmslow &= ~SSB_TMSLOW_FGC; 3628#endif
3488 tmslow |= B43_TMSLOW_PHYRESET; 3629 }
3489 ssb_write32(sdev, SSB_TMSLOW, tmslow);
3490 msleep(1);
3491} 3630}
3492 3631
3493static const char *band_to_string(enum ieee80211_band band) 3632static const char *band_to_string(enum ieee80211_band band)
@@ -4104,6 +4243,12 @@ static int b43_phy_versioning(struct b43_wldev *dev)
4104 unsupported = 1; 4243 unsupported = 1;
4105 break; 4244 break;
4106#endif 4245#endif
4246#ifdef CONFIG_B43_PHY_LCN
4247 case B43_PHYTYPE_LCN:
4248 if (phy_rev > 1)
4249 unsupported = 1;
4250 break;
4251#endif
4107 default: 4252 default:
4108 unsupported = 1; 4253 unsupported = 1;
4109 } 4254 }
@@ -4117,22 +4262,42 @@ static int b43_phy_versioning(struct b43_wldev *dev)
4117 analog_type, phy_type, phy_rev); 4262 analog_type, phy_type, phy_rev);
4118 4263
4119 /* Get RADIO versioning */ 4264 /* Get RADIO versioning */
4120 if (dev->dev->chip_id == 0x4317) { 4265 if (dev->dev->core_rev >= 24) {
4121 if (dev->dev->chip_rev == 0) 4266 u16 radio24[3];
4122 tmp = 0x3205017F; 4267
4123 else if (dev->dev->chip_rev == 1) 4268 for (tmp = 0; tmp < 3; tmp++) {
4124 tmp = 0x4205017F; 4269 b43_write16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
4125 else 4270 radio24[tmp] = b43_read16(dev, B43_MMIO_RADIO24_DATA);
4126 tmp = 0x5205017F; 4271 }
4272
4273 /* Broadcom uses "id" for our "ver" and has separated "ver" */
4274 /* radio_ver = (radio24[0] & 0xF0) >> 4; */
4275
4276 radio_manuf = 0x17F;
4277 radio_ver = (radio24[2] << 8) | radio24[1];
4278 radio_rev = (radio24[0] & 0xF);
4127 } else { 4279 } else {
4128 b43_write16(dev, B43_MMIO_RADIO_CONTROL, B43_RADIOCTL_ID); 4280 if (dev->dev->chip_id == 0x4317) {
4129 tmp = b43_read16(dev, B43_MMIO_RADIO_DATA_LOW); 4281 if (dev->dev->chip_rev == 0)
4130 b43_write16(dev, B43_MMIO_RADIO_CONTROL, B43_RADIOCTL_ID); 4282 tmp = 0x3205017F;
4131 tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH) << 16; 4283 else if (dev->dev->chip_rev == 1)
4132 } 4284 tmp = 0x4205017F;
4133 radio_manuf = (tmp & 0x00000FFF); 4285 else
4134 radio_ver = (tmp & 0x0FFFF000) >> 12; 4286 tmp = 0x5205017F;
4135 radio_rev = (tmp & 0xF0000000) >> 28; 4287 } else {
4288 b43_write16(dev, B43_MMIO_RADIO_CONTROL,
4289 B43_RADIOCTL_ID);
4290 tmp = b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
4291 b43_write16(dev, B43_MMIO_RADIO_CONTROL,
4292 B43_RADIOCTL_ID);
4293 tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH)
4294 << 16;
4295 }
4296 radio_manuf = (tmp & 0x00000FFF);
4297 radio_ver = (tmp & 0x0FFFF000) >> 12;
4298 radio_rev = (tmp & 0xF0000000) >> 28;
4299 }
4300
4136 if (radio_manuf != 0x17F /* Broadcom */) 4301 if (radio_manuf != 0x17F /* Broadcom */)
4137 unsupported = 1; 4302 unsupported = 1;
4138 switch (phy_type) { 4303 switch (phy_type) {
@@ -4164,6 +4329,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
4164 if (radio_ver != 0x2059) 4329 if (radio_ver != 0x2059)
4165 unsupported = 1; 4330 unsupported = 1;
4166 break; 4331 break;
4332 case B43_PHYTYPE_LCN:
4333 if (radio_ver != 0x2064)
4334 unsupported = 1;
4335 break;
4167 default: 4336 default:
4168 B43_WARN_ON(1); 4337 B43_WARN_ON(1);
4169 } 4338 }
@@ -4347,7 +4516,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
4347/* Initialize a wireless core */ 4516/* Initialize a wireless core */
4348static int b43_wireless_core_init(struct b43_wldev *dev) 4517static int b43_wireless_core_init(struct b43_wldev *dev)
4349{ 4518{
4350 struct ssb_bus *bus = dev->sdev->bus;
4351 struct ssb_sprom *sprom = dev->dev->bus_sprom; 4519 struct ssb_sprom *sprom = dev->dev->bus_sprom;
4352 struct b43_phy *phy = &dev->phy; 4520 struct b43_phy *phy = &dev->phy;
4353 int err; 4521 int err;
@@ -4366,7 +4534,20 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4366 phy->ops->prepare_structs(dev); 4534 phy->ops->prepare_structs(dev);
4367 4535
4368 /* Enable IRQ routing to this device. */ 4536 /* Enable IRQ routing to this device. */
4369 ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->sdev); 4537 switch (dev->dev->bus_type) {
4538#ifdef CONFIG_B43_BCMA
4539 case B43_BUS_BCMA:
4540 bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
4541 dev->dev->bdev, true);
4542 break;
4543#endif
4544#ifdef CONFIG_B43_SSB
4545 case B43_BUS_SSB:
4546 ssb_pcicore_dev_irqvecs_enable(&dev->dev->sdev->bus->pcicore,
4547 dev->dev->sdev);
4548 break;
4549#endif
4550 }
4370 4551
4371 b43_imcfglo_timeouts_workaround(dev); 4552 b43_imcfglo_timeouts_workaround(dev);
4372 b43_bluetooth_coext_disable(dev); 4553 b43_bluetooth_coext_disable(dev);
@@ -4397,8 +4578,9 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4397 if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW) 4578 if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW)
4398 hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */ 4579 hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */
4399#ifdef CONFIG_SSB_DRIVER_PCICORE 4580#ifdef CONFIG_SSB_DRIVER_PCICORE
4400 if ((bus->bustype == SSB_BUSTYPE_PCI) && 4581 if (dev->dev->bus_type == B43_BUS_SSB &&
4401 (bus->pcicore.dev->id.revision <= 10)) 4582 dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI &&
4583 dev->dev->sdev->bus->pcicore.dev->id.revision <= 10)
4402 hf |= B43_HF_PCISCW; /* PCI slow clock workaround. */ 4584 hf |= B43_HF_PCISCW; /* PCI slow clock workaround. */
4403#endif 4585#endif
4404 hf &= ~B43_HF_SKCFPUP; 4586 hf &= ~B43_HF_SKCFPUP;
@@ -4764,8 +4946,7 @@ static void b43_wireless_core_detach(struct b43_wldev *dev)
4764static int b43_wireless_core_attach(struct b43_wldev *dev) 4946static int b43_wireless_core_attach(struct b43_wldev *dev)
4765{ 4947{
4766 struct b43_wl *wl = dev->wl; 4948 struct b43_wl *wl = dev->wl;
4767 struct ssb_bus *bus = dev->sdev->bus; 4949 struct pci_dev *pdev = NULL;
4768 struct pci_dev *pdev = (bus->bustype == SSB_BUSTYPE_PCI) ? bus->host_pci : NULL;
4769 int err; 4950 int err;
4770 bool have_2ghz_phy = 0, have_5ghz_phy = 0; 4951 bool have_2ghz_phy = 0, have_5ghz_phy = 0;
4771 4952
@@ -4776,20 +4957,38 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4776 * that in core_init(), too. 4957 * that in core_init(), too.
4777 */ 4958 */
4778 4959
4960#ifdef CONFIG_B43_SSB
4961 if (dev->dev->bus_type == B43_BUS_SSB &&
4962 dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI)
4963 pdev = dev->dev->sdev->bus->host_pci;
4964#endif
4965
4779 err = b43_bus_powerup(dev, 0); 4966 err = b43_bus_powerup(dev, 0);
4780 if (err) { 4967 if (err) {
4781 b43err(wl, "Bus powerup failed\n"); 4968 b43err(wl, "Bus powerup failed\n");
4782 goto out; 4969 goto out;
4783 } 4970 }
4784 /* Get the PHY type. */
4785 if (dev->dev->core_rev >= 5) {
4786 u32 tmshigh;
4787 4971
4788 tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH); 4972 /* Get the PHY type. */
4789 have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY); 4973 switch (dev->dev->bus_type) {
4790 have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY); 4974#ifdef CONFIG_B43_BCMA
4791 } else 4975 case B43_BUS_BCMA:
4792 B43_WARN_ON(1); 4976 /* FIXME */
4977 have_2ghz_phy = 1;
4978 have_5ghz_phy = 0;
4979 break;
4980#endif
4981#ifdef CONFIG_B43_SSB
4982 case B43_BUS_SSB:
4983 if (dev->dev->core_rev >= 5) {
4984 u32 tmshigh = ssb_read32(dev->dev->sdev, SSB_TMSHIGH);
4985 have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY);
4986 have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY);
4987 } else
4988 B43_WARN_ON(1);
4989 break;
4990#endif
4991 }
4793 4992
4794 dev->phy.gmode = have_2ghz_phy; 4993 dev->phy.gmode = have_2ghz_phy;
4795 dev->phy.radio_on = 1; 4994 dev->phy.radio_on = 1;
@@ -4815,6 +5014,8 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4815#endif 5014#endif
4816 case B43_PHYTYPE_G: 5015 case B43_PHYTYPE_G:
4817 case B43_PHYTYPE_N: 5016 case B43_PHYTYPE_N:
5017 case B43_PHYTYPE_HT:
5018 case B43_PHYTYPE_LCN:
4818 have_2ghz_phy = 1; 5019 have_2ghz_phy = 1;
4819 break; 5020 break;
4820 default: 5021 default:
@@ -4877,13 +5078,13 @@ static void b43_one_core_detach(struct b43_bus_dev *dev)
4877 /* Do not cancel ieee80211-workqueue based work here. 5078 /* Do not cancel ieee80211-workqueue based work here.
4878 * See comment in b43_remove(). */ 5079 * See comment in b43_remove(). */
4879 5080
4880 wldev = ssb_get_drvdata(dev->sdev); 5081 wldev = b43_bus_get_wldev(dev);
4881 wl = wldev->wl; 5082 wl = wldev->wl;
4882 b43_debugfs_remove_device(wldev); 5083 b43_debugfs_remove_device(wldev);
4883 b43_wireless_core_detach(wldev); 5084 b43_wireless_core_detach(wldev);
4884 list_del(&wldev->list); 5085 list_del(&wldev->list);
4885 wl->nr_devs--; 5086 wl->nr_devs--;
4886 ssb_set_drvdata(dev->sdev, NULL); 5087 b43_bus_set_wldev(dev, NULL);
4887 kfree(wldev); 5088 kfree(wldev);
4888} 5089}
4889 5090
@@ -4898,7 +5099,6 @@ static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl)
4898 5099
4899 wldev->use_pio = b43_modparam_pio; 5100 wldev->use_pio = b43_modparam_pio;
4900 wldev->dev = dev; 5101 wldev->dev = dev;
4901 wldev->sdev = dev->sdev; /* TODO: Remove when not needed */
4902 wldev->wl = wl; 5102 wldev->wl = wl;
4903 b43_set_status(wldev, B43_STAT_UNINIT); 5103 b43_set_status(wldev, B43_STAT_UNINIT);
4904 wldev->bad_frames_preempt = modparam_bad_frames_preempt; 5104 wldev->bad_frames_preempt = modparam_bad_frames_preempt;
@@ -4910,7 +5110,7 @@ static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl)
4910 5110
4911 list_add(&wldev->list, &wl->devlist); 5111 list_add(&wldev->list, &wl->devlist);
4912 wl->nr_devs++; 5112 wl->nr_devs++;
4913 ssb_set_drvdata(dev->sdev, wldev); 5113 b43_bus_set_wldev(dev, wldev);
4914 b43_debugfs_add_device(wldev); 5114 b43_debugfs_add_device(wldev);
4915 5115
4916 out: 5116 out:
@@ -4959,9 +5159,9 @@ static void b43_wireless_exit(struct b43_bus_dev *dev, struct b43_wl *wl)
4959 ieee80211_free_hw(hw); 5159 ieee80211_free_hw(hw);
4960} 5160}
4961 5161
4962static struct b43_wl *b43_wireless_init(struct ssb_device *dev) 5162static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
4963{ 5163{
4964 struct ssb_sprom *sprom = &dev->bus->sprom; 5164 struct ssb_sprom *sprom = dev->bus_sprom;
4965 struct ieee80211_hw *hw; 5165 struct ieee80211_hw *hw;
4966 struct b43_wl *wl; 5166 struct b43_wl *wl;
4967 5167
@@ -5003,14 +5203,21 @@ static struct b43_wl *b43_wireless_init(struct ssb_device *dev)
5003 skb_queue_head_init(&wl->tx_queue); 5203 skb_queue_head_init(&wl->tx_queue);
5004 5204
5005 b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", 5205 b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n",
5006 dev->bus->chip_id, dev->id.revision); 5206 dev->chip_id, dev->core_rev);
5007 return wl; 5207 return wl;
5008} 5208}
5009 5209
5010#ifdef CONFIG_B43_BCMA 5210#ifdef CONFIG_B43_BCMA
5011static int b43_bcma_probe(struct bcma_device *core) 5211static int b43_bcma_probe(struct bcma_device *core)
5012{ 5212{
5213 struct b43_bus_dev *dev;
5214
5215 dev = b43_bus_dev_bcma_init(core);
5216 if (!dev)
5217 return -ENODEV;
5218
5013 b43err(NULL, "BCMA is not supported yet!"); 5219 b43err(NULL, "BCMA is not supported yet!");
5220 kfree(dev);
5014 return -EOPNOTSUPP; 5221 return -EOPNOTSUPP;
5015} 5222}
5016 5223
@@ -5045,7 +5252,7 @@ int b43_ssb_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
5045 /* Probing the first core. Must setup common struct b43_wl */ 5252 /* Probing the first core. Must setup common struct b43_wl */
5046 first = 1; 5253 first = 1;
5047 b43_sprom_fixup(sdev->bus); 5254 b43_sprom_fixup(sdev->bus);
5048 wl = b43_wireless_init(sdev); 5255 wl = b43_wireless_init(dev);
5049 if (IS_ERR(wl)) { 5256 if (IS_ERR(wl)) {
5050 err = PTR_ERR(wl); 5257 err = PTR_ERR(wl);
5051 goto out; 5258 goto out;
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 9705950f059a..101957512bcc 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -32,6 +32,7 @@
32#include "phy_n.h" 32#include "phy_n.h"
33#include "phy_lp.h" 33#include "phy_lp.h"
34#include "phy_ht.h" 34#include "phy_ht.h"
35#include "phy_lcn.h"
35#include "b43.h" 36#include "b43.h"
36#include "main.h" 37#include "main.h"
37 38
@@ -65,6 +66,11 @@ int b43_phy_allocate(struct b43_wldev *dev)
65 phy->ops = &b43_phyops_ht; 66 phy->ops = &b43_phyops_ht;
66#endif 67#endif
67 break; 68 break;
69 case B43_PHYTYPE_LCN:
70#ifdef CONFIG_B43_PHY_LCN
71 phy->ops = &b43_phyops_lcn;
72#endif
73 break;
68 } 74 }
69 if (B43_WARN_ON(!phy->ops)) 75 if (B43_WARN_ON(!phy->ops))
70 return -ENODEV; 76 return -ENODEV;
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 47dcb800a3c3..aa77ba612a92 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -195,6 +195,7 @@ struct b43_phy_g;
195struct b43_phy_n; 195struct b43_phy_n;
196struct b43_phy_lp; 196struct b43_phy_lp;
197struct b43_phy_ht; 197struct b43_phy_ht;
198struct b43_phy_lcn;
198 199
199struct b43_phy { 200struct b43_phy {
200 /* Hardware operation callbacks. */ 201 /* Hardware operation callbacks. */
@@ -219,6 +220,8 @@ struct b43_phy {
219 struct b43_phy_lp *lp; 220 struct b43_phy_lp *lp;
220 /* HT-PHY specific information */ 221 /* HT-PHY specific information */
221 struct b43_phy_ht *ht; 222 struct b43_phy_ht *ht;
223 /* LCN-PHY specific information */
224 struct b43_phy_lcn *lcn;
222 }; 225 };
223 226
224 /* Band support flags. */ 227 /* Band support flags. */
diff --git a/drivers/net/wireless/b43/phy_ht.c b/drivers/net/wireless/b43/phy_ht.c
index 30b19c61037d..29821036badf 100644
--- a/drivers/net/wireless/b43/phy_ht.c
+++ b/drivers/net/wireless/b43/phy_ht.c
@@ -373,6 +373,16 @@ static void b43_phy_ht_op_radio_write(struct b43_wldev *dev, u16 reg,
373 b43_write16(dev, B43_MMIO_RADIO24_DATA, value); 373 b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
374} 374}
375 375
376static enum b43_txpwr_result
377b43_phy_ht_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi)
378{
379 return B43_TXPWR_RES_DONE;
380}
381
382static void b43_phy_ht_op_adjust_txpower(struct b43_wldev *dev)
383{
384}
385
376/************************************************** 386/**************************************************
377 * PHY ops struct. 387 * PHY ops struct.
378 **************************************************/ 388 **************************************************/
@@ -391,8 +401,6 @@ const struct b43_phy_operations b43_phyops_ht = {
391 .switch_analog = b43_phy_ht_op_switch_analog, 401 .switch_analog = b43_phy_ht_op_switch_analog,
392 .switch_channel = b43_phy_ht_op_switch_channel, 402 .switch_channel = b43_phy_ht_op_switch_channel,
393 .get_default_chan = b43_phy_ht_op_get_default_chan, 403 .get_default_chan = b43_phy_ht_op_get_default_chan,
394 /*
395 .recalc_txpower = b43_phy_ht_op_recalc_txpower, 404 .recalc_txpower = b43_phy_ht_op_recalc_txpower,
396 .adjust_txpower = b43_phy_ht_op_adjust_txpower, 405 .adjust_txpower = b43_phy_ht_op_adjust_txpower,
397 */
398}; 406};
diff --git a/drivers/net/wireless/b43/phy_lcn.c b/drivers/net/wireless/b43/phy_lcn.c
new file mode 100644
index 000000000000..9f7dbbd5ced6
--- /dev/null
+++ b/drivers/net/wireless/b43/phy_lcn.c
@@ -0,0 +1,52 @@
1/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11n LCN-PHY support
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21*/
22
23#include <linux/slab.h>
24
25#include "b43.h"
26#include "phy_lcn.h"
27#include "tables_phy_lcn.h"
28#include "main.h"
29
30/**************************************************
31 * PHY ops struct.
32 **************************************************/
33
34const struct b43_phy_operations b43_phyops_lcn = {
35 /*
36 .allocate = b43_phy_lcn_op_allocate,
37 .free = b43_phy_lcn_op_free,
38 .prepare_structs = b43_phy_lcn_op_prepare_structs,
39 .init = b43_phy_lcn_op_init,
40 .phy_read = b43_phy_lcn_op_read,
41 .phy_write = b43_phy_lcn_op_write,
42 .phy_maskset = b43_phy_lcn_op_maskset,
43 .radio_read = b43_phy_lcn_op_radio_read,
44 .radio_write = b43_phy_lcn_op_radio_write,
45 .software_rfkill = b43_phy_lcn_op_software_rfkill,
46 .switch_analog = b43_phy_lcn_op_switch_analog,
47 .switch_channel = b43_phy_lcn_op_switch_channel,
48 .get_default_chan = b43_phy_lcn_op_get_default_chan,
49 .recalc_txpower = b43_phy_lcn_op_recalc_txpower,
50 .adjust_txpower = b43_phy_lcn_op_adjust_txpower,
51 */
52};
diff --git a/drivers/net/wireless/b43/phy_lcn.h b/drivers/net/wireless/b43/phy_lcn.h
new file mode 100644
index 000000000000..c046c2a6cab4
--- /dev/null
+++ b/drivers/net/wireless/b43/phy_lcn.h
@@ -0,0 +1,14 @@
1#ifndef B43_PHY_LCN_H_
2#define B43_PHY_LCN_H_
3
4#include "phy_common.h"
5
6
7struct b43_phy_lcn {
8};
9
10
11struct b43_phy_operations;
12extern const struct b43_phy_operations b43_phyops_lcn;
13
14#endif /* B43_PHY_LCN_H_ */ \ No newline at end of file
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index e7dfdac9e4d7..95c28f584ed9 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -603,17 +603,33 @@ static void b43_nphy_tx_lp_fbw(struct b43_wldev *dev)
603/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */ 603/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */
604static void b43_nphy_bmac_clock_fgc(struct b43_wldev *dev, bool force) 604static void b43_nphy_bmac_clock_fgc(struct b43_wldev *dev, bool force)
605{ 605{
606 u32 tmslow; 606 u32 tmp;
607 607
608 if (dev->phy.type != B43_PHYTYPE_N) 608 if (dev->phy.type != B43_PHYTYPE_N)
609 return; 609 return;
610 610
611 tmslow = ssb_read32(dev->sdev, SSB_TMSLOW); 611 switch (dev->dev->bus_type) {
612 if (force) 612#ifdef CONFIG_B43_BCMA
613 tmslow |= SSB_TMSLOW_FGC; 613 case B43_BUS_BCMA:
614 else 614 tmp = bcma_read32(dev->dev->bdev, BCMA_IOCTL);
615 tmslow &= ~SSB_TMSLOW_FGC; 615 if (force)
616 ssb_write32(dev->sdev, SSB_TMSLOW, tmslow); 616 tmp |= BCMA_IOCTL_FGC;
617 else
618 tmp &= ~BCMA_IOCTL_FGC;
619 bcma_write32(dev->dev->bdev, BCMA_IOCTL, tmp);
620 break;
621#endif
622#ifdef CONFIG_B43_SSB
623 case B43_BUS_SSB:
624 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW);
625 if (force)
626 tmp |= SSB_TMSLOW_FGC;
627 else
628 tmp &= ~SSB_TMSLOW_FGC;
629 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp);
630 break;
631#endif
632 }
617} 633}
618 634
619/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */ 635/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */
@@ -958,8 +974,21 @@ static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
958 b43_phy_write(dev, B43_NPHY_GPIO_LOOEN, 0); 974 b43_phy_write(dev, B43_NPHY_GPIO_LOOEN, 0);
959 b43_phy_write(dev, B43_NPHY_GPIO_HIOEN, 0); 975 b43_phy_write(dev, B43_NPHY_GPIO_HIOEN, 0);
960 976
961 ssb_chipco_gpio_control(&dev->sdev->bus->chipco, 0xFC00, 977 switch (dev->dev->bus_type) {
962 0xFC00); 978#ifdef CONFIG_B43_BCMA
979 case B43_BUS_BCMA:
980 bcma_chipco_gpio_control(&dev->dev->bdev->bus->drv_cc,
981 0xFC00, 0xFC00);
982 break;
983#endif
984#ifdef CONFIG_B43_SSB
985 case B43_BUS_SSB:
986 ssb_chipco_gpio_control(&dev->dev->sdev->bus->chipco,
987 0xFC00, 0xFC00);
988 break;
989#endif
990 }
991
963 b43_write32(dev, B43_MMIO_MACCTL, 992 b43_write32(dev, B43_MMIO_MACCTL,
964 b43_read32(dev, B43_MMIO_MACCTL) & 993 b43_read32(dev, B43_MMIO_MACCTL) &
965 ~B43_MACCTL_GPOUTSMSK); 994 ~B43_MACCTL_GPOUTSMSK);
@@ -3600,7 +3629,20 @@ int b43_phy_initn(struct b43_wldev *dev)
3600 if ((dev->phy.rev >= 3) && 3629 if ((dev->phy.rev >= 3) &&
3601 (sprom->boardflags_lo & B43_BFL_EXTLNA) && 3630 (sprom->boardflags_lo & B43_BFL_EXTLNA) &&
3602 (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)) { 3631 (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)) {
3603 chipco_set32(&dev->sdev->bus->chipco, SSB_CHIPCO_CHIPCTL, 0x40); 3632 switch (dev->dev->bus_type) {
3633#ifdef CONFIG_B43_BCMA
3634 case B43_BUS_BCMA:
3635 bcma_cc_set32(&dev->dev->bdev->bus->drv_cc,
3636 BCMA_CC_CHIPCTL, 0x40);
3637 break;
3638#endif
3639#ifdef CONFIG_B43_SSB
3640 case B43_BUS_SSB:
3641 chipco_set32(&dev->dev->sdev->bus->chipco,
3642 SSB_CHIPCO_CHIPCTL, 0x40);
3643 break;
3644#endif
3645 }
3604 } 3646 }
3605 nphy->deaf_count = 0; 3647 nphy->deaf_count = 0;
3606 b43_nphy_tables_init(dev); 3648 b43_nphy_tables_init(dev);
diff --git a/drivers/net/wireless/b43/tables_phy_lcn.c b/drivers/net/wireless/b43/tables_phy_lcn.c
new file mode 100644
index 000000000000..40c1d0915dd3
--- /dev/null
+++ b/drivers/net/wireless/b43/tables_phy_lcn.c
@@ -0,0 +1,34 @@
1/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11n LCN-PHY data tables
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21*/
22
23#include "b43.h"
24#include "tables_phy_lcn.h"
25#include "phy_common.h"
26#include "phy_lcn.h"
27
28/**************************************************
29 * Tables ops.
30 **************************************************/
31
32void b43_phy_lcn_tables_init(struct b43_wldev *dev)
33{
34}
diff --git a/drivers/net/wireless/b43/tables_phy_lcn.h b/drivers/net/wireless/b43/tables_phy_lcn.h
new file mode 100644
index 000000000000..5e31b15b81ec
--- /dev/null
+++ b/drivers/net/wireless/b43/tables_phy_lcn.h
@@ -0,0 +1,6 @@
1#ifndef B43_TABLES_PHY_LCN_H_
2#define B43_TABLES_PHY_LCN_H_
3
4void b43_phy_lcn_tables_init(struct b43_wldev *dev);
5
6#endif /* B43_TABLES_PHY_LCN_H_ */
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 488b898418a3..82bcf7595139 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -323,8 +323,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
323 /* we give the phase1key and iv16 here, the key is stored in 323 /* we give the phase1key and iv16 here, the key is stored in
324 * shm. With that the hardware can do phase 2 and encryption. 324 * shm. With that the hardware can do phase 2 and encryption.
325 */ 325 */
326 ieee80211_get_tkip_key(info->control.hw_key, skb_frag, 326 ieee80211_get_tkip_p1k(info->control.hw_key, skb_frag, phase1key);
327 IEEE80211_TKIP_P1_KEY, (u8*)phase1key);
328 /* phase1key is in host endian. Copy to little-endian txhdr->iv. */ 327 /* phase1key is in host endian. Copy to little-endian txhdr->iv. */
329 for (i = 0; i < 5; i++) { 328 for (i = 0; i < 5; i++) {
330 txhdr->iv[i * 2 + 0] = phase1key[i]; 329 txhdr->iv[i * 2 + 0] = phase1key[i];
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
index 79ac081832fb..ac4f64de1363 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
@@ -240,8 +240,7 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
240 240
241 case WLAN_CIPHER_SUITE_TKIP: 241 case WLAN_CIPHER_SUITE_TKIP:
242 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; 242 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
243 ieee80211_get_tkip_key(keyconf, skb_frag, 243 ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
244 IEEE80211_TKIP_P2_KEY, tx_cmd->key);
245 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); 244 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
246 break; 245 break;
247 246
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
index 46242d2aa5ad..14334668034e 100644
--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
@@ -1484,7 +1484,7 @@ static const char * const desc_lookup_text[] = {
1484 "NMI_INTERRUPT_DATA_ACTION_PT", 1484 "NMI_INTERRUPT_DATA_ACTION_PT",
1485 "NMI_TRM_HW_ER", 1485 "NMI_TRM_HW_ER",
1486 "NMI_INTERRUPT_TRM", 1486 "NMI_INTERRUPT_TRM",
1487 "NMI_INTERRUPT_BREAK_POINT" 1487 "NMI_INTERRUPT_BREAK_POINT",
1488 "DEBUG_0", 1488 "DEBUG_0",
1489 "DEBUG_1", 1489 "DEBUG_1",
1490 "DEBUG_2", 1490 "DEBUG_2",
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index cf1449df4f0b..2f56b343e869 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -125,7 +125,6 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
125 iwlagn_mod_params.num_of_queues; 125 iwlagn_mod_params.num_of_queues;
126 126
127 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; 127 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
128 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
129 priv->hw_params.scd_bc_tbls_size = 128 priv->hw_params.scd_bc_tbls_size =
130 priv->cfg->base_params->num_of_queues * 129 priv->cfg->base_params->num_of_queues *
131 sizeof(struct iwlagn_scd_bc_tbl); 130 sizeof(struct iwlagn_scd_bc_tbl);
@@ -172,11 +171,7 @@ static struct iwl_lib_ops iwl1000_lib = {
172 .rx_handler_setup = iwlagn_rx_handler_setup, 171 .rx_handler_setup = iwlagn_rx_handler_setup,
173 .setup_deferred_work = iwlagn_setup_deferred_work, 172 .setup_deferred_work = iwlagn_setup_deferred_work,
174 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 173 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
175 .update_chain_flags = iwl_update_chain_flags, 174 .nic_config = iwl1000_nic_config,
176 .apm_ops = {
177 .init = iwl_apm_init,
178 .config = iwl1000_nic_config,
179 },
180 .eeprom_ops = { 175 .eeprom_ops = {
181 .regulatory_bands = { 176 .regulatory_bands = {
182 EEPROM_REG_BAND_1_CHANNELS, 177 EEPROM_REG_BAND_1_CHANNELS,
@@ -187,16 +182,12 @@ static struct iwl_lib_ops iwl1000_lib = {
187 EEPROM_REG_BAND_24_HT40_CHANNELS, 182 EEPROM_REG_BAND_24_HT40_CHANNELS,
188 EEPROM_REGULATORY_BAND_NO_HT40, 183 EEPROM_REGULATORY_BAND_NO_HT40,
189 }, 184 },
190 .query_addr = iwlagn_eeprom_query_addr,
191 }, 185 },
192 .temp_ops = { 186 .temperature = iwlagn_temperature,
193 .temperature = iwlagn_temperature,
194 },
195}; 187};
196 188
197static const struct iwl_ops iwl1000_ops = { 189static const struct iwl_ops iwl1000_ops = {
198 .lib = &iwl1000_lib, 190 .lib = &iwl1000_lib,
199 .utils = &iwlagn_hcmd_utils,
200}; 191};
201 192
202static struct iwl_base_params iwl1000_base_params = { 193static struct iwl_base_params iwl1000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index a401113c065a..32ac8654b79a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -123,7 +123,6 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
123 iwlagn_mod_params.num_of_queues; 123 iwlagn_mod_params.num_of_queues;
124 124
125 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; 125 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
126 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
127 priv->hw_params.scd_bc_tbls_size = 126 priv->hw_params.scd_bc_tbls_size =
128 priv->cfg->base_params->num_of_queues * 127 priv->cfg->base_params->num_of_queues *
129 sizeof(struct iwlagn_scd_bc_tbl); 128 sizeof(struct iwlagn_scd_bc_tbl);
@@ -169,14 +168,31 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
169static struct iwl_lib_ops iwl2000_lib = { 168static struct iwl_lib_ops iwl2000_lib = {
170 .set_hw_params = iwl2000_hw_set_hw_params, 169 .set_hw_params = iwl2000_hw_set_hw_params,
171 .rx_handler_setup = iwlagn_rx_handler_setup, 170 .rx_handler_setup = iwlagn_rx_handler_setup,
171 .setup_deferred_work = iwlagn_setup_deferred_work,
172 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
173 .nic_config = iwl2000_nic_config,
174 .eeprom_ops = {
175 .regulatory_bands = {
176 EEPROM_REG_BAND_1_CHANNELS,
177 EEPROM_REG_BAND_2_CHANNELS,
178 EEPROM_REG_BAND_3_CHANNELS,
179 EEPROM_REG_BAND_4_CHANNELS,
180 EEPROM_REG_BAND_5_CHANNELS,
181 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
182 EEPROM_REGULATORY_BAND_NO_HT40,
183 },
184 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
185 },
186 .temperature = iwlagn_temperature,
187};
188
189static struct iwl_lib_ops iwl2030_lib = {
190 .set_hw_params = iwl2000_hw_set_hw_params,
191 .rx_handler_setup = iwlagn_bt_rx_handler_setup,
172 .setup_deferred_work = iwlagn_bt_setup_deferred_work, 192 .setup_deferred_work = iwlagn_bt_setup_deferred_work,
173 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, 193 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
174 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 194 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
175 .update_chain_flags = iwl_update_chain_flags, 195 .nic_config = iwl2000_nic_config,
176 .apm_ops = {
177 .init = iwl_apm_init,
178 .config = iwl2000_nic_config,
179 },
180 .eeprom_ops = { 196 .eeprom_ops = {
181 .regulatory_bands = { 197 .regulatory_bands = {
182 EEPROM_REG_BAND_1_CHANNELS, 198 EEPROM_REG_BAND_1_CHANNELS,
@@ -187,32 +203,25 @@ static struct iwl_lib_ops iwl2000_lib = {
187 EEPROM_6000_REG_BAND_24_HT40_CHANNELS, 203 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
188 EEPROM_REGULATORY_BAND_NO_HT40, 204 EEPROM_REGULATORY_BAND_NO_HT40,
189 }, 205 },
190 .query_addr = iwlagn_eeprom_query_addr,
191 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower, 206 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
192 }, 207 },
193 .temp_ops = { 208 .temperature = iwlagn_temperature,
194 .temperature = iwlagn_temperature,
195 },
196}; 209};
197 210
198static const struct iwl_ops iwl2000_ops = { 211static const struct iwl_ops iwl2000_ops = {
199 .lib = &iwl2000_lib, 212 .lib = &iwl2000_lib,
200 .utils = &iwlagn_hcmd_utils,
201}; 213};
202 214
203static const struct iwl_ops iwl2030_ops = { 215static const struct iwl_ops iwl2030_ops = {
204 .lib = &iwl2000_lib, 216 .lib = &iwl2030_lib,
205 .utils = &iwlagn_hcmd_utils,
206}; 217};
207 218
208static const struct iwl_ops iwl105_ops = { 219static const struct iwl_ops iwl105_ops = {
209 .lib = &iwl2000_lib, 220 .lib = &iwl2000_lib,
210 .utils = &iwlagn_hcmd_utils,
211}; 221};
212 222
213static const struct iwl_ops iwl135_ops = { 223static const struct iwl_ops iwl135_ops = {
214 .lib = &iwl2000_lib, 224 .lib = &iwl2030_lib,
215 .utils = &iwlagn_hcmd_utils,
216}; 225};
217 226
218static struct iwl_base_params iwl2000_base_params = { 227static struct iwl_base_params iwl2000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index c55cec853f50..556489302da3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -46,6 +46,7 @@
46#include "iwl-agn.h" 46#include "iwl-agn.h"
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-5000-hw.h" 48#include "iwl-5000-hw.h"
49#include "iwl-trans.h"
49 50
50/* Highest firmware API version supported */ 51/* Highest firmware API version supported */
51#define IWL5000_UCODE_API_MAX 5 52#define IWL5000_UCODE_API_MAX 5
@@ -156,7 +157,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
156 iwlagn_mod_params.num_of_queues; 157 iwlagn_mod_params.num_of_queues;
157 158
158 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; 159 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
159 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
160 priv->hw_params.scd_bc_tbls_size = 160 priv->hw_params.scd_bc_tbls_size =
161 priv->cfg->base_params->num_of_queues * 161 priv->cfg->base_params->num_of_queues *
162 sizeof(struct iwlagn_scd_bc_tbl); 162 sizeof(struct iwlagn_scd_bc_tbl);
@@ -200,7 +200,6 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv)
200 iwlagn_mod_params.num_of_queues; 200 iwlagn_mod_params.num_of_queues;
201 201
202 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; 202 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
203 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
204 priv->hw_params.scd_bc_tbls_size = 203 priv->hw_params.scd_bc_tbls_size =
205 priv->cfg->base_params->num_of_queues * 204 priv->cfg->base_params->num_of_queues *
206 sizeof(struct iwlagn_scd_bc_tbl); 205 sizeof(struct iwlagn_scd_bc_tbl);
@@ -316,7 +315,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
316 return -EFAULT; 315 return -EFAULT;
317 } 316 }
318 317
319 return iwl_send_cmd_sync(priv, &hcmd); 318 return trans_send_cmd(priv, &hcmd);
320} 319}
321 320
322static struct iwl_lib_ops iwl5000_lib = { 321static struct iwl_lib_ops iwl5000_lib = {
@@ -324,12 +323,8 @@ static struct iwl_lib_ops iwl5000_lib = {
324 .rx_handler_setup = iwlagn_rx_handler_setup, 323 .rx_handler_setup = iwlagn_rx_handler_setup,
325 .setup_deferred_work = iwlagn_setup_deferred_work, 324 .setup_deferred_work = iwlagn_setup_deferred_work,
326 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 325 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
327 .update_chain_flags = iwl_update_chain_flags,
328 .set_channel_switch = iwl5000_hw_channel_switch, 326 .set_channel_switch = iwl5000_hw_channel_switch,
329 .apm_ops = { 327 .nic_config = iwl5000_nic_config,
330 .init = iwl_apm_init,
331 .config = iwl5000_nic_config,
332 },
333 .eeprom_ops = { 328 .eeprom_ops = {
334 .regulatory_bands = { 329 .regulatory_bands = {
335 EEPROM_REG_BAND_1_CHANNELS, 330 EEPROM_REG_BAND_1_CHANNELS,
@@ -340,11 +335,8 @@ static struct iwl_lib_ops iwl5000_lib = {
340 EEPROM_REG_BAND_24_HT40_CHANNELS, 335 EEPROM_REG_BAND_24_HT40_CHANNELS,
341 EEPROM_REG_BAND_52_HT40_CHANNELS 336 EEPROM_REG_BAND_52_HT40_CHANNELS
342 }, 337 },
343 .query_addr = iwlagn_eeprom_query_addr,
344 }, 338 },
345 .temp_ops = { 339 .temperature = iwlagn_temperature,
346 .temperature = iwlagn_temperature,
347 },
348}; 340};
349 341
350static struct iwl_lib_ops iwl5150_lib = { 342static struct iwl_lib_ops iwl5150_lib = {
@@ -352,12 +344,8 @@ static struct iwl_lib_ops iwl5150_lib = {
352 .rx_handler_setup = iwlagn_rx_handler_setup, 344 .rx_handler_setup = iwlagn_rx_handler_setup,
353 .setup_deferred_work = iwlagn_setup_deferred_work, 345 .setup_deferred_work = iwlagn_setup_deferred_work,
354 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 346 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
355 .update_chain_flags = iwl_update_chain_flags,
356 .set_channel_switch = iwl5000_hw_channel_switch, 347 .set_channel_switch = iwl5000_hw_channel_switch,
357 .apm_ops = { 348 .nic_config = iwl5000_nic_config,
358 .init = iwl_apm_init,
359 .config = iwl5000_nic_config,
360 },
361 .eeprom_ops = { 349 .eeprom_ops = {
362 .regulatory_bands = { 350 .regulatory_bands = {
363 EEPROM_REG_BAND_1_CHANNELS, 351 EEPROM_REG_BAND_1_CHANNELS,
@@ -368,21 +356,16 @@ static struct iwl_lib_ops iwl5150_lib = {
368 EEPROM_REG_BAND_24_HT40_CHANNELS, 356 EEPROM_REG_BAND_24_HT40_CHANNELS,
369 EEPROM_REG_BAND_52_HT40_CHANNELS 357 EEPROM_REG_BAND_52_HT40_CHANNELS
370 }, 358 },
371 .query_addr = iwlagn_eeprom_query_addr,
372 }, 359 },
373 .temp_ops = { 360 .temperature = iwl5150_temperature,
374 .temperature = iwl5150_temperature,
375 },
376}; 361};
377 362
378static const struct iwl_ops iwl5000_ops = { 363static const struct iwl_ops iwl5000_ops = {
379 .lib = &iwl5000_lib, 364 .lib = &iwl5000_lib,
380 .utils = &iwlagn_hcmd_utils,
381}; 365};
382 366
383static const struct iwl_ops iwl5150_ops = { 367static const struct iwl_ops iwl5150_ops = {
384 .lib = &iwl5150_lib, 368 .lib = &iwl5150_lib,
385 .utils = &iwlagn_hcmd_utils,
386}; 369};
387 370
388static struct iwl_base_params iwl5000_base_params = { 371static struct iwl_base_params iwl5000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 965d010794b4..80f1ef61a3d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -45,6 +45,7 @@
45#include "iwl-helpers.h" 45#include "iwl-helpers.h"
46#include "iwl-agn-hw.h" 46#include "iwl-agn-hw.h"
47#include "iwl-6000-hw.h" 47#include "iwl-6000-hw.h"
48#include "iwl-trans.h"
48 49
49/* Highest firmware API version supported */ 50/* Highest firmware API version supported */
50#define IWL6000_UCODE_API_MAX 4 51#define IWL6000_UCODE_API_MAX 4
@@ -144,7 +145,6 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
144 iwlagn_mod_params.num_of_queues; 145 iwlagn_mod_params.num_of_queues;
145 146
146 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; 147 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
147 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
148 priv->hw_params.scd_bc_tbls_size = 148 priv->hw_params.scd_bc_tbls_size =
149 priv->cfg->base_params->num_of_queues * 149 priv->cfg->base_params->num_of_queues *
150 sizeof(struct iwlagn_scd_bc_tbl); 150 sizeof(struct iwlagn_scd_bc_tbl);
@@ -255,7 +255,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
255 return -EFAULT; 255 return -EFAULT;
256 } 256 }
257 257
258 return iwl_send_cmd_sync(priv, &hcmd); 258 return trans_send_cmd(priv, &hcmd);
259} 259}
260 260
261static struct iwl_lib_ops iwl6000_lib = { 261static struct iwl_lib_ops iwl6000_lib = {
@@ -263,12 +263,8 @@ static struct iwl_lib_ops iwl6000_lib = {
263 .rx_handler_setup = iwlagn_rx_handler_setup, 263 .rx_handler_setup = iwlagn_rx_handler_setup,
264 .setup_deferred_work = iwlagn_setup_deferred_work, 264 .setup_deferred_work = iwlagn_setup_deferred_work,
265 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 265 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
266 .update_chain_flags = iwl_update_chain_flags,
267 .set_channel_switch = iwl6000_hw_channel_switch, 266 .set_channel_switch = iwl6000_hw_channel_switch,
268 .apm_ops = { 267 .nic_config = iwl6000_nic_config,
269 .init = iwl_apm_init,
270 .config = iwl6000_nic_config,
271 },
272 .eeprom_ops = { 268 .eeprom_ops = {
273 .regulatory_bands = { 269 .regulatory_bands = {
274 EEPROM_REG_BAND_1_CHANNELS, 270 EEPROM_REG_BAND_1_CHANNELS,
@@ -279,12 +275,9 @@ static struct iwl_lib_ops iwl6000_lib = {
279 EEPROM_6000_REG_BAND_24_HT40_CHANNELS, 275 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
280 EEPROM_REG_BAND_52_HT40_CHANNELS 276 EEPROM_REG_BAND_52_HT40_CHANNELS
281 }, 277 },
282 .query_addr = iwlagn_eeprom_query_addr,
283 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower, 278 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
284 }, 279 },
285 .temp_ops = { 280 .temperature = iwlagn_temperature,
286 .temperature = iwlagn_temperature,
287 },
288}; 281};
289 282
290static struct iwl_lib_ops iwl6030_lib = { 283static struct iwl_lib_ops iwl6030_lib = {
@@ -293,12 +286,8 @@ static struct iwl_lib_ops iwl6030_lib = {
293 .setup_deferred_work = iwlagn_bt_setup_deferred_work, 286 .setup_deferred_work = iwlagn_bt_setup_deferred_work,
294 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, 287 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
295 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr, 288 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
296 .update_chain_flags = iwl_update_chain_flags,
297 .set_channel_switch = iwl6000_hw_channel_switch, 289 .set_channel_switch = iwl6000_hw_channel_switch,
298 .apm_ops = { 290 .nic_config = iwl6000_nic_config,
299 .init = iwl_apm_init,
300 .config = iwl6000_nic_config,
301 },
302 .eeprom_ops = { 291 .eeprom_ops = {
303 .regulatory_bands = { 292 .regulatory_bands = {
304 EEPROM_REG_BAND_1_CHANNELS, 293 EEPROM_REG_BAND_1_CHANNELS,
@@ -309,12 +298,9 @@ static struct iwl_lib_ops iwl6030_lib = {
309 EEPROM_6000_REG_BAND_24_HT40_CHANNELS, 298 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
310 EEPROM_REG_BAND_52_HT40_CHANNELS 299 EEPROM_REG_BAND_52_HT40_CHANNELS
311 }, 300 },
312 .query_addr = iwlagn_eeprom_query_addr,
313 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower, 301 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
314 }, 302 },
315 .temp_ops = { 303 .temperature = iwlagn_temperature,
316 .temperature = iwlagn_temperature,
317 },
318}; 304};
319 305
320static struct iwl_nic_ops iwl6050_nic_ops = { 306static struct iwl_nic_ops iwl6050_nic_ops = {
@@ -327,24 +313,20 @@ static struct iwl_nic_ops iwl6150_nic_ops = {
327 313
328static const struct iwl_ops iwl6000_ops = { 314static const struct iwl_ops iwl6000_ops = {
329 .lib = &iwl6000_lib, 315 .lib = &iwl6000_lib,
330 .utils = &iwlagn_hcmd_utils,
331}; 316};
332 317
333static const struct iwl_ops iwl6050_ops = { 318static const struct iwl_ops iwl6050_ops = {
334 .lib = &iwl6000_lib, 319 .lib = &iwl6000_lib,
335 .utils = &iwlagn_hcmd_utils,
336 .nic = &iwl6050_nic_ops, 320 .nic = &iwl6050_nic_ops,
337}; 321};
338 322
339static const struct iwl_ops iwl6150_ops = { 323static const struct iwl_ops iwl6150_ops = {
340 .lib = &iwl6000_lib, 324 .lib = &iwl6000_lib,
341 .utils = &iwlagn_hcmd_utils,
342 .nic = &iwl6150_nic_ops, 325 .nic = &iwl6150_nic_ops,
343}; 326};
344 327
345static const struct iwl_ops iwl6030_ops = { 328static const struct iwl_ops iwl6030_ops = {
346 .lib = &iwl6030_lib, 329 .lib = &iwl6030_lib,
347 .utils = &iwlagn_hcmd_utils,
348}; 330};
349 331
350static struct iwl_base_params iwl6000_base_params = { 332static struct iwl_base_params iwl6000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index c9255def1080..02c7c65ee86a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -66,6 +66,8 @@
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67#include "iwl-core.h" 67#include "iwl-core.h"
68#include "iwl-agn-calib.h" 68#include "iwl-agn-calib.h"
69#include "iwl-trans.h"
70#include "iwl-agn.h"
69 71
70/***************************************************************************** 72/*****************************************************************************
71 * INIT calibrations framework 73 * INIT calibrations framework
@@ -87,6 +89,7 @@ int iwl_send_calib_results(struct iwl_priv *priv)
87 89
88 struct iwl_host_cmd hcmd = { 90 struct iwl_host_cmd hcmd = {
89 .id = REPLY_PHY_CALIBRATION_CMD, 91 .id = REPLY_PHY_CALIBRATION_CMD,
92 .flags = CMD_SYNC,
90 }; 93 };
91 94
92 for (i = 0; i < IWL_CALIB_MAX; i++) { 95 for (i = 0; i < IWL_CALIB_MAX; i++) {
@@ -95,7 +98,7 @@ int iwl_send_calib_results(struct iwl_priv *priv)
95 hcmd.len[0] = priv->calib_results[i].buf_len; 98 hcmd.len[0] = priv->calib_results[i].buf_len;
96 hcmd.data[0] = priv->calib_results[i].buf; 99 hcmd.data[0] = priv->calib_results[i].buf;
97 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; 100 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
98 ret = iwl_send_cmd_sync(priv, &hcmd); 101 ret = trans_send_cmd(priv, &hcmd);
99 if (ret) { 102 if (ret) {
100 IWL_ERR(priv, "Error %d iteration %d\n", 103 IWL_ERR(priv, "Error %d iteration %d\n",
101 ret, i); 104 ret, i);
@@ -481,7 +484,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
481 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), 484 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]),
482 sizeof(u16)*HD_TABLE_SIZE); 485 sizeof(u16)*HD_TABLE_SIZE);
483 486
484 return iwl_send_cmd(priv, &cmd_out); 487 return trans_send_cmd(priv, &cmd_out);
485} 488}
486 489
487/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 490/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
@@ -545,7 +548,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
545 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), 548 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]),
546 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); 549 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES);
547 550
548 return iwl_send_cmd(priv, &cmd_out); 551 return trans_send_cmd(priv, &cmd_out);
549} 552}
550 553
551void iwl_init_sensitivity(struct iwl_priv *priv) 554void iwl_init_sensitivity(struct iwl_priv *priv)
@@ -991,16 +994,14 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
991 IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", 994 IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n",
992 min_average_noise, min_average_noise_antenna_i); 995 min_average_noise, min_average_noise_antenna_i);
993 996
994 if (priv->cfg->ops->utils->gain_computation) 997 iwlagn_gain_computation(priv, average_noise,
995 priv->cfg->ops->utils->gain_computation(priv, average_noise,
996 min_average_noise_antenna_i, min_average_noise, 998 min_average_noise_antenna_i, min_average_noise,
997 find_first_chain(priv->cfg->valid_rx_ant)); 999 find_first_chain(priv->cfg->valid_rx_ant));
998 1000
999 /* Some power changes may have been made during the calibration. 1001 /* Some power changes may have been made during the calibration.
1000 * Update and commit the RXON 1002 * Update and commit the RXON
1001 */ 1003 */
1002 if (priv->cfg->ops->lib->update_chain_flags) 1004 iwl_update_chain_flags(priv);
1003 priv->cfg->ops->lib->update_chain_flags(priv);
1004 1005
1005 data->state = IWL_CHAIN_NOISE_DONE; 1006 data->state = IWL_CHAIN_NOISE_DONE;
1006 iwl_power_update_mode(priv, false); 1007 iwl_power_update_mode(priv, false);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
index 4ef4dd934254..a869fc9205d2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
@@ -71,13 +71,6 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv);
71 71
72void iwl_init_sensitivity(struct iwl_priv *priv); 72void iwl_init_sensitivity(struct iwl_priv *priv);
73void iwl_reset_run_time_calib(struct iwl_priv *priv); 73void iwl_reset_run_time_calib(struct iwl_priv *priv);
74static inline void iwl_chain_noise_reset(struct iwl_priv *priv)
75{
76
77 if (!priv->disable_chain_noise_cal &&
78 priv->cfg->ops->utils->chain_noise_reset)
79 priv->cfg->ops->utils->chain_noise_reset(priv);
80}
81 74
82int iwl_send_calib_results(struct iwl_priv *priv); 75int iwl_send_calib_results(struct iwl_priv *priv);
83int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len); 76int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
index 7745816eaff4..b8347db850e7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
@@ -150,7 +150,7 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv)
150 150
151void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) 151void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac)
152{ 152{
153 const u8 *addr = priv->cfg->ops->lib->eeprom_ops.query_addr(priv, 153 const u8 *addr = iwl_eeprom_query_addr(priv,
154 EEPROM_MAC_ADDRESS); 154 EEPROM_MAC_ADDRESS);
155 memcpy(mac, addr, ETH_ALEN); 155 memcpy(mac, addr, ETH_ALEN);
156} 156}
@@ -245,10 +245,10 @@ void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv)
245 BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8); 245 BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8);
246 246
247 /* the length is in 16-bit words, but we want entries */ 247 /* the length is in 16-bit words, but we want entries */
248 txp_len = (__le16 *) iwlagn_eeprom_query_addr(priv, EEPROM_TXP_SZ_OFFS); 248 txp_len = (__le16 *) iwl_eeprom_query_addr(priv, EEPROM_TXP_SZ_OFFS);
249 entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN; 249 entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN;
250 250
251 txp_array = (void *) iwlagn_eeprom_query_addr(priv, EEPROM_TXP_OFFS); 251 txp_array = (void *) iwl_eeprom_query_addr(priv, EEPROM_TXP_OFFS);
252 252
253 for (idx = 0; idx < entries; idx++) { 253 for (idx = 0; idx < entries; idx++) {
254 txp = &txp_array[idx]; 254 txp = &txp_array[idx];
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index ce7d4b56d9b2..f0f5f5eada75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -36,6 +36,7 @@
36#include "iwl-core.h" 36#include "iwl-core.h"
37#include "iwl-io.h" 37#include "iwl-io.h"
38#include "iwl-agn.h" 38#include "iwl-agn.h"
39#include "iwl-trans.h"
39 40
40int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) 41int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
41{ 42{
@@ -45,7 +46,9 @@ int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
45 46
46 if (IWL_UCODE_API(priv->ucode_ver) > 1) { 47 if (IWL_UCODE_API(priv->ucode_ver) > 1) {
47 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); 48 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
48 return iwl_send_cmd_pdu(priv, TX_ANT_CONFIGURATION_CMD, 49 return trans_send_cmd_pdu(priv,
50 TX_ANT_CONFIGURATION_CMD,
51 CMD_SYNC,
49 sizeof(struct iwl_tx_ant_config_cmd), 52 sizeof(struct iwl_tx_ant_config_cmd),
50 &tx_ant_cmd); 53 &tx_ant_cmd);
51 } else { 54 } else {
@@ -54,17 +57,7 @@ int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
54 } 57 }
55} 58}
56 59
57static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) 60void iwlagn_gain_computation(struct iwl_priv *priv,
58{
59 u16 size = (u16)sizeof(struct iwl_addsta_cmd);
60 struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data;
61 memcpy(addsta, cmd, size);
62 /* resrved in 5000 */
63 addsta->rate_n_flags = cpu_to_le16(0);
64 return size;
65}
66
67static void iwlagn_gain_computation(struct iwl_priv *priv,
68 u32 average_noise[NUM_RX_CHAINS], 61 u32 average_noise[NUM_RX_CHAINS],
69 u16 min_average_noise_antenna_i, 62 u16 min_average_noise_antenna_i,
70 u32 min_average_noise, 63 u32 min_average_noise,
@@ -115,96 +108,14 @@ static void iwlagn_gain_computation(struct iwl_priv *priv,
115 priv->_agn.phy_calib_chain_noise_gain_cmd); 108 priv->_agn.phy_calib_chain_noise_gain_cmd);
116 cmd.delta_gain_1 = data->delta_gain_code[1]; 109 cmd.delta_gain_1 = data->delta_gain_code[1];
117 cmd.delta_gain_2 = data->delta_gain_code[2]; 110 cmd.delta_gain_2 = data->delta_gain_code[2];
118 iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, 111 trans_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
119 sizeof(cmd), &cmd, NULL); 112 CMD_ASYNC, sizeof(cmd), &cmd);
120 113
121 data->radio_write = 1; 114 data->radio_write = 1;
122 data->state = IWL_CHAIN_NOISE_CALIBRATED; 115 data->state = IWL_CHAIN_NOISE_CALIBRATED;
123 } 116 }
124} 117}
125 118
126static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
127{
128 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
129 int ret;
130
131 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
132 iwl_is_any_associated(priv)) {
133 struct iwl_calib_chain_noise_reset_cmd cmd;
134
135 /* clear data for chain noise calibration algorithm */
136 data->chain_noise_a = 0;
137 data->chain_noise_b = 0;
138 data->chain_noise_c = 0;
139 data->chain_signal_a = 0;
140 data->chain_signal_b = 0;
141 data->chain_signal_c = 0;
142 data->beacon_count = 0;
143
144 memset(&cmd, 0, sizeof(cmd));
145 iwl_set_calib_hdr(&cmd.hdr,
146 priv->_agn.phy_calib_chain_noise_reset_cmd);
147 ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
148 sizeof(cmd), &cmd);
149 if (ret)
150 IWL_ERR(priv,
151 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
152 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
153 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
154 }
155}
156
157static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
158 struct ieee80211_tx_info *info,
159 __le16 fc, __le32 *tx_flags)
160{
161 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS ||
162 info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT ||
163 info->flags & IEEE80211_TX_CTL_AMPDU)
164 *tx_flags |= TX_CMD_FLG_PROT_REQUIRE_MSK;
165}
166
167/* Calc max signal level (dBm) among 3 possible receivers */
168static int iwlagn_calc_rssi(struct iwl_priv *priv,
169 struct iwl_rx_phy_res *rx_resp)
170{
171 /* data from PHY/DSP regarding signal strength, etc.,
172 * contents are always there, not configurable by host
173 */
174 struct iwlagn_non_cfg_phy *ncphy =
175 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
176 u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
177 u8 agc;
178
179 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
180 agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
181
182 /* Find max rssi among 3 possible receivers.
183 * These values are measured by the digital signal processor (DSP).
184 * They should stay fairly constant even as the signal strength varies,
185 * if the radio's automatic gain control (AGC) is working right.
186 * AGC value (see below) will provide the "interesting" info.
187 */
188 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
189 rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
190 IWLAGN_OFDM_RSSI_A_BIT_POS;
191 rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
192 IWLAGN_OFDM_RSSI_B_BIT_POS;
193 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
194 rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
195 IWLAGN_OFDM_RSSI_C_BIT_POS;
196
197 max_rssi = max_t(u32, rssi_a, rssi_b);
198 max_rssi = max_t(u32, max_rssi, rssi_c);
199
200 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
201 rssi_a, rssi_b, rssi_c, max_rssi, agc);
202
203 /* dBm = max_rssi dB - agc dB - constant.
204 * Higher AGC (higher radio gain) means lower signal. */
205 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
206}
207
208int iwlagn_set_pan_params(struct iwl_priv *priv) 119int iwlagn_set_pan_params(struct iwl_priv *priv)
209{ 120{
210 struct iwl_wipan_params_cmd cmd; 121 struct iwl_wipan_params_cmd cmd;
@@ -290,18 +201,10 @@ int iwlagn_set_pan_params(struct iwl_priv *priv)
290 cmd.slots[0].width = cpu_to_le16(slot0); 201 cmd.slots[0].width = cpu_to_le16(slot0);
291 cmd.slots[1].width = cpu_to_le16(slot1); 202 cmd.slots[1].width = cpu_to_le16(slot1);
292 203
293 ret = iwl_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, sizeof(cmd), &cmd); 204 ret = trans_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
205 sizeof(cmd), &cmd);
294 if (ret) 206 if (ret)
295 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret); 207 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
296 208
297 return ret; 209 return ret;
298} 210}
299
300struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = {
301 .build_addsta_hcmd = iwlagn_build_addsta_hcmd,
302 .gain_computation = iwlagn_gain_computation,
303 .chain_noise_reset = iwlagn_chain_noise_reset,
304 .tx_cmd_protection = iwlagn_tx_cmd_protection,
305 .calc_rssi = iwlagn_calc_rssi,
306 .request_scan = iwlagn_request_scan,
307};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 90d366e15d2f..eb2be0d30483 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -39,6 +39,7 @@
39#include "iwl-agn-hw.h" 39#include "iwl-agn-hw.h"
40#include "iwl-agn.h" 40#include "iwl-agn.h"
41#include "iwl-sta.h" 41#include "iwl-sta.h"
42#include "iwl-trans.h"
42 43
43static inline u32 iwlagn_get_scd_ssn(struct iwlagn_tx_resp *tx_resp) 44static inline u32 iwlagn_get_scd_ssn(struct iwlagn_tx_resp *tx_resp)
44{ 45{
@@ -540,8 +541,8 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
540 else 541 else
541 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD; 542 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
542 543
543 return iwl_send_cmd_pdu(priv, tx_ant_cfg_cmd, sizeof(tx_power_cmd), 544 return trans_send_cmd_pdu(priv, tx_ant_cfg_cmd, CMD_SYNC,
544 &tx_power_cmd); 545 sizeof(tx_power_cmd), &tx_power_cmd);
545} 546}
546 547
547void iwlagn_temperature(struct iwl_priv *priv) 548void iwlagn_temperature(struct iwl_priv *priv)
@@ -610,8 +611,7 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
610 return (address & ADDRESS_MSK) + (offset << 1); 611 return (address & ADDRESS_MSK) + (offset << 1);
611} 612}
612 613
613const u8 *iwlagn_eeprom_query_addr(const struct iwl_priv *priv, 614const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
614 size_t offset)
615{ 615{
616 u32 address = eeprom_indirect_address(priv, offset); 616 u32 address = eeprom_indirect_address(priv, offset);
617 BUG_ON(address >= priv->cfg->base_params->eeprom_size); 617 BUG_ON(address >= priv->cfg->base_params->eeprom_size);
@@ -702,7 +702,7 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv)
702 702
703 /* nic_init */ 703 /* nic_init */
704 spin_lock_irqsave(&priv->lock, flags); 704 spin_lock_irqsave(&priv->lock, flags);
705 priv->cfg->ops->lib->apm_ops.init(priv); 705 iwl_apm_init(priv);
706 706
707 /* Set interrupt coalescing calibration timer to default (512 usecs) */ 707 /* Set interrupt coalescing calibration timer to default (512 usecs) */
708 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); 708 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
@@ -711,10 +711,10 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv)
711 711
712 iwlagn_set_pwr_vmain(priv); 712 iwlagn_set_pwr_vmain(priv);
713 713
714 priv->cfg->ops->lib->apm_ops.config(priv); 714 priv->cfg->ops->lib->nic_config(priv);
715 715
716 /* Allocate the RX queue, or reset if it is already allocated */ 716 /* Allocate the RX queue, or reset if it is already allocated */
717 priv->trans.ops->rx_init(priv); 717 trans_rx_init(priv);
718 718
719 iwlagn_rx_replenish(priv); 719 iwlagn_rx_replenish(priv);
720 720
@@ -728,7 +728,7 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv)
728 spin_unlock_irqrestore(&priv->lock, flags); 728 spin_unlock_irqrestore(&priv->lock, flags);
729 729
730 /* Allocate or reset and init all Tx and Command queues */ 730 /* Allocate or reset and init all Tx and Command queues */
731 if (priv->trans.ops->tx_init(priv)) 731 if (trans_tx_init(priv))
732 return -ENOMEM; 732 return -ENOMEM;
733 733
734 if (priv->cfg->base_params->shadow_reg_enable) { 734 if (priv->cfg->base_params->shadow_reg_enable) {
@@ -905,17 +905,6 @@ void iwlagn_rx_replenish_now(struct iwl_priv *priv)
905 iwlagn_rx_queue_restock(priv); 905 iwlagn_rx_queue_restock(priv);
906} 906}
907 907
908int iwlagn_rxq_stop(struct iwl_priv *priv)
909{
910
911 /* stop Rx DMA */
912 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
913 iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG,
914 FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
915
916 return 0;
917}
918
919int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) 908int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band)
920{ 909{
921 int idx = 0; 910 int idx = 0;
@@ -1074,6 +1063,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1074 struct iwl_host_cmd cmd = { 1063 struct iwl_host_cmd cmd = {
1075 .id = REPLY_SCAN_CMD, 1064 .id = REPLY_SCAN_CMD,
1076 .len = { sizeof(struct iwl_scan_cmd), }, 1065 .len = { sizeof(struct iwl_scan_cmd), },
1066 .flags = CMD_SYNC,
1077 }; 1067 };
1078 struct iwl_scan_cmd *scan; 1068 struct iwl_scan_cmd *scan;
1079 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1069 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
@@ -1370,7 +1360,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1370 if (ret) 1360 if (ret)
1371 return ret; 1361 return ret;
1372 1362
1373 ret = iwl_send_cmd_sync(priv, &cmd); 1363 ret = trans_send_cmd(priv, &cmd);
1374 if (ret) { 1364 if (ret) {
1375 clear_bit(STATUS_SCAN_HW, &priv->status); 1365 clear_bit(STATUS_SCAN_HW, &priv->status);
1376 iwlagn_set_pan_params(priv); 1366 iwlagn_set_pan_params(priv);
@@ -1476,7 +1466,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
1476 flush_cmd.fifo_control); 1466 flush_cmd.fifo_control);
1477 flush_cmd.flush_control = cpu_to_le16(flush_control); 1467 flush_cmd.flush_control = cpu_to_le16(flush_control);
1478 1468
1479 return iwl_send_cmd(priv, &cmd); 1469 return trans_send_cmd(priv, &cmd);
1480} 1470}
1481 1471
1482void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) 1472void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
@@ -1644,9 +1634,11 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
1644 } else { 1634 } else {
1645 basic.flags = IWLAGN_BT_FLAG_COEX_MODE_3W << 1635 basic.flags = IWLAGN_BT_FLAG_COEX_MODE_3W <<
1646 IWLAGN_BT_FLAG_COEX_MODE_SHIFT; 1636 IWLAGN_BT_FLAG_COEX_MODE_SHIFT;
1647 if (priv->cfg->bt_params && 1637
1648 priv->cfg->bt_params->bt_sco_disable) 1638 if (!priv->bt_enable_pspoll)
1649 basic.flags |= IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE; 1639 basic.flags |= IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE;
1640 else
1641 basic.flags &= ~IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE;
1650 1642
1651 if (priv->bt_ch_announce) 1643 if (priv->bt_ch_announce)
1652 basic.flags |= IWLAGN_BT_FLAG_CHANNEL_INHIBITION; 1644 basic.flags |= IWLAGN_BT_FLAG_CHANNEL_INHIBITION;
@@ -1668,19 +1660,97 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
1668 if (priv->cfg->bt_params->bt_session_2) { 1660 if (priv->cfg->bt_params->bt_session_2) {
1669 memcpy(&bt_cmd_2000.basic, &basic, 1661 memcpy(&bt_cmd_2000.basic, &basic,
1670 sizeof(basic)); 1662 sizeof(basic));
1671 ret = iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1663 ret = trans_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1672 sizeof(bt_cmd_2000), &bt_cmd_2000); 1664 CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000);
1673 } else { 1665 } else {
1674 memcpy(&bt_cmd_6000.basic, &basic, 1666 memcpy(&bt_cmd_6000.basic, &basic,
1675 sizeof(basic)); 1667 sizeof(basic));
1676 ret = iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1668 ret = trans_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1677 sizeof(bt_cmd_6000), &bt_cmd_6000); 1669 CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000);
1678 } 1670 }
1679 if (ret) 1671 if (ret)
1680 IWL_ERR(priv, "failed to send BT Coex Config\n"); 1672 IWL_ERR(priv, "failed to send BT Coex Config\n");
1681 1673
1682} 1674}
1683 1675
1676void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena)
1677{
1678 struct iwl_rxon_context *ctx, *found_ctx = NULL;
1679 bool found_ap = false;
1680
1681 lockdep_assert_held(&priv->mutex);
1682
1683 /* Check whether AP or GO mode is active. */
1684 if (rssi_ena) {
1685 for_each_context(priv, ctx) {
1686 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_AP &&
1687 iwl_is_associated_ctx(ctx)) {
1688 found_ap = true;
1689 break;
1690 }
1691 }
1692 }
1693
1694 /*
1695 * If disable was received or If GO/AP mode, disable RSSI
1696 * measurements.
1697 */
1698 if (!rssi_ena || found_ap) {
1699 if (priv->cur_rssi_ctx) {
1700 ctx = priv->cur_rssi_ctx;
1701 ieee80211_disable_rssi_reports(ctx->vif);
1702 priv->cur_rssi_ctx = NULL;
1703 }
1704 return;
1705 }
1706
1707 /*
1708 * If rssi measurements need to be enabled, consider all cases now.
1709 * Figure out how many contexts are active.
1710 */
1711 for_each_context(priv, ctx) {
1712 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION &&
1713 iwl_is_associated_ctx(ctx)) {
1714 found_ctx = ctx;
1715 break;
1716 }
1717 }
1718
1719 /*
1720 * rssi monitor already enabled for the correct interface...nothing
1721 * to do.
1722 */
1723 if (found_ctx == priv->cur_rssi_ctx)
1724 return;
1725
1726 /*
1727 * Figure out if rssi monitor is currently enabled, and needs
1728 * to be changed. If rssi monitor is already enabled, disable
1729 * it first else just enable rssi measurements on the
1730 * interface found above.
1731 */
1732 if (priv->cur_rssi_ctx) {
1733 ctx = priv->cur_rssi_ctx;
1734 if (ctx->vif)
1735 ieee80211_disable_rssi_reports(ctx->vif);
1736 }
1737
1738 priv->cur_rssi_ctx = found_ctx;
1739
1740 if (!found_ctx)
1741 return;
1742
1743 ieee80211_enable_rssi_reports(found_ctx->vif,
1744 IWLAGN_BT_PSP_MIN_RSSI_THRESHOLD,
1745 IWLAGN_BT_PSP_MAX_RSSI_THRESHOLD);
1746}
1747
1748static bool iwlagn_bt_traffic_is_sco(struct iwl_bt_uart_msg *uart_msg)
1749{
1750 return BT_UART_MSG_FRAME3SCOESCO_MSK & uart_msg->frame3 >>
1751 BT_UART_MSG_FRAME3SCOESCO_POS;
1752}
1753
1684static void iwlagn_bt_traffic_change_work(struct work_struct *work) 1754static void iwlagn_bt_traffic_change_work(struct work_struct *work)
1685{ 1755{
1686 struct iwl_priv *priv = 1756 struct iwl_priv *priv =
@@ -1733,8 +1803,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
1733 if (test_bit(STATUS_SCAN_HW, &priv->status)) 1803 if (test_bit(STATUS_SCAN_HW, &priv->status))
1734 goto out; 1804 goto out;
1735 1805
1736 if (priv->cfg->ops->lib->update_chain_flags) 1806 iwl_update_chain_flags(priv);
1737 priv->cfg->ops->lib->update_chain_flags(priv);
1738 1807
1739 if (smps_request != -1) { 1808 if (smps_request != -1) {
1740 priv->current_ht_config.smps = smps_request; 1809 priv->current_ht_config.smps = smps_request;
@@ -1743,10 +1812,30 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
1743 ieee80211_request_smps(ctx->vif, smps_request); 1812 ieee80211_request_smps(ctx->vif, smps_request);
1744 } 1813 }
1745 } 1814 }
1815
1816 /*
1817 * Dynamic PS poll related functionality. Adjust RSSI measurements if
1818 * necessary.
1819 */
1820 iwlagn_bt_coex_rssi_monitor(priv);
1746out: 1821out:
1747 mutex_unlock(&priv->mutex); 1822 mutex_unlock(&priv->mutex);
1748} 1823}
1749 1824
1825/*
1826 * If BT sco traffic, and RSSI monitor is enabled, move measurements to the
1827 * correct interface or disable it if this is the last interface to be
1828 * removed.
1829 */
1830void iwlagn_bt_coex_rssi_monitor(struct iwl_priv *priv)
1831{
1832 if (priv->bt_is_sco &&
1833 priv->bt_traffic_load == IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS)
1834 iwlagn_bt_adjust_rssi_monitor(priv, true);
1835 else
1836 iwlagn_bt_adjust_rssi_monitor(priv, false);
1837}
1838
1750static void iwlagn_print_uartmsg(struct iwl_priv *priv, 1839static void iwlagn_print_uartmsg(struct iwl_priv *priv,
1751 struct iwl_bt_uart_msg *uart_msg) 1840 struct iwl_bt_uart_msg *uart_msg)
1752{ 1841{
@@ -1862,6 +1951,8 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
1862 iwlagn_print_uartmsg(priv, uart_msg); 1951 iwlagn_print_uartmsg(priv, uart_msg);
1863 1952
1864 priv->last_bt_traffic_load = priv->bt_traffic_load; 1953 priv->last_bt_traffic_load = priv->bt_traffic_load;
1954 priv->bt_is_sco = iwlagn_bt_traffic_is_sco(uart_msg);
1955
1865 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) { 1956 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
1866 if (priv->bt_status != coex->bt_status || 1957 if (priv->bt_status != coex->bt_status ||
1867 priv->last_bt_traffic_load != coex->bt_traffic_load) { 1958 priv->last_bt_traffic_load != coex->bt_traffic_load) {
@@ -2321,13 +2412,14 @@ void iwlagn_stop_device(struct iwl_priv *priv)
2321 * already dead. 2412 * already dead.
2322 */ 2413 */
2323 if (test_bit(STATUS_DEVICE_ENABLED, &priv->status)) { 2414 if (test_bit(STATUS_DEVICE_ENABLED, &priv->status)) {
2324 iwlagn_txq_ctx_stop(priv); 2415 trans_tx_stop(priv);
2325 iwlagn_rxq_stop(priv); 2416 trans_rx_stop(priv);
2326 2417
2327 /* Power-down device's busmaster DMA clocks */ 2418 /* Power-down device's busmaster DMA clocks */
2328 iwl_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); 2419 iwl_write_prph(priv, APMG_CLK_DIS_REG,
2329 udelay(5); 2420 APMG_CLK_VAL_DMA_CLK_RQT);
2330 } 2421 udelay(5);
2422 }
2331 2423
2332 /* Make sure (redundant) we've released our request to stay awake */ 2424 /* Make sure (redundant) we've released our request to stay awake */
2333 iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 2425 iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 85e082830c1e..ebcd13bc10d9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -336,6 +336,12 @@ static u8 rs_tl_add_packet(struct iwl_lq_sta *lq_data,
336} 336}
337 337
338#ifdef CONFIG_MAC80211_DEBUGFS 338#ifdef CONFIG_MAC80211_DEBUGFS
339/**
340 * Program the device to use fixed rate for frame transmit
341 * This is for debugging/testing only
342 * once the device start use fixed rate, we need to reload the module
343 * to being back the normal operation.
344 */
339static void rs_program_fix_rate(struct iwl_priv *priv, 345static void rs_program_fix_rate(struct iwl_priv *priv,
340 struct iwl_lq_sta *lq_sta) 346 struct iwl_lq_sta *lq_sta)
341{ 347{
@@ -348,13 +354,15 @@ static void rs_program_fix_rate(struct iwl_priv *priv,
348 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 354 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
349 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 355 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
350 356
351 lq_sta->dbg_fixed_rate = priv->dbg_fixed_rate; 357 /* testmode has higher priority to overwirte the fixed rate */
358 if (priv->tm_fixed_rate)
359 lq_sta->dbg_fixed_rate = priv->tm_fixed_rate;
352 360
353 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", 361 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n",
354 lq_sta->lq.sta_id, priv->dbg_fixed_rate); 362 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate);
355 363
356 if (priv->dbg_fixed_rate) { 364 if (lq_sta->dbg_fixed_rate) {
357 rs_fill_link_cmd(NULL, lq_sta, priv->dbg_fixed_rate); 365 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate);
358 iwl_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, 366 iwl_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC,
359 false); 367 false);
360 } 368 }
@@ -1073,7 +1081,8 @@ done:
1073 if (sta && sta->supp_rates[sband->band]) 1081 if (sta && sta->supp_rates[sband->band])
1074 rs_rate_scale_perform(priv, skb, sta, lq_sta); 1082 rs_rate_scale_perform(priv, skb, sta, lq_sta);
1075#ifdef CONFIG_MAC80211_DEBUGFS 1083#ifdef CONFIG_MAC80211_DEBUGFS
1076 if (priv->dbg_fixed_rate != lq_sta->dbg_fixed_rate) 1084 if ((priv->tm_fixed_rate) &&
1085 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate))
1077 rs_program_fix_rate(priv, lq_sta); 1086 rs_program_fix_rate(priv, lq_sta);
1078#endif 1087#endif
1079 if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist) 1088 if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist)
@@ -2896,7 +2905,7 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i
2896 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2905 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2897 lq_sta->is_agg = 0; 2906 lq_sta->is_agg = 0;
2898 2907
2899 priv->dbg_fixed_rate = 0; 2908 priv->tm_fixed_rate = 0;
2900#ifdef CONFIG_MAC80211_DEBUGFS 2909#ifdef CONFIG_MAC80211_DEBUGFS
2901 lq_sta->dbg_fixed_rate = 0; 2910 lq_sta->dbg_fixed_rate = 0;
2902#endif 2911#endif
@@ -3095,7 +3104,6 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
3095 IWL_DEBUG_RATE(priv, "Fixed rate ON\n"); 3104 IWL_DEBUG_RATE(priv, "Fixed rate ON\n");
3096 } else { 3105 } else {
3097 lq_sta->dbg_fixed_rate = 0; 3106 lq_sta->dbg_fixed_rate = 0;
3098 priv->dbg_fixed_rate = 0;
3099 IWL_ERR(priv, 3107 IWL_ERR(priv,
3100 "Invalid antenna selection 0x%X, Valid is 0x%X\n", 3108 "Invalid antenna selection 0x%X, Valid is 0x%X\n",
3101 ant_sel_tx, valid_tx_ant); 3109 ant_sel_tx, valid_tx_ant);
@@ -3123,9 +3131,9 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
3123 return -EFAULT; 3131 return -EFAULT;
3124 3132
3125 if (sscanf(buf, "%x", &parsed_rate) == 1) 3133 if (sscanf(buf, "%x", &parsed_rate) == 1)
3126 priv->dbg_fixed_rate = lq_sta->dbg_fixed_rate = parsed_rate; 3134 lq_sta->dbg_fixed_rate = parsed_rate;
3127 else 3135 else
3128 priv->dbg_fixed_rate = lq_sta->dbg_fixed_rate = 0; 3136 lq_sta->dbg_fixed_rate = 0;
3129 3137
3130 rs_program_fix_rate(priv, lq_sta); 3138 rs_program_fix_rate(priv, lq_sta);
3131 3139
@@ -3155,7 +3163,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
3155 lq_sta->total_failed, lq_sta->total_success, 3163 lq_sta->total_failed, lq_sta->total_success,
3156 lq_sta->active_legacy_rate); 3164 lq_sta->active_legacy_rate);
3157 desc += sprintf(buff+desc, "fixed rate 0x%X\n", 3165 desc += sprintf(buff+desc, "fixed rate 0x%X\n",
3158 priv->dbg_fixed_rate); 3166 lq_sta->dbg_fixed_rate);
3159 desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", 3167 desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n",
3160 (priv->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", 3168 (priv->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "",
3161 (priv->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", 3169 (priv->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "",
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index c6bb73a66d9f..dc64f2515357 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -30,6 +30,7 @@
30#include "iwl-core.h" 30#include "iwl-core.h"
31#include "iwl-agn-calib.h" 31#include "iwl-agn-calib.h"
32#include "iwl-helpers.h" 32#include "iwl-helpers.h"
33#include "iwl-trans.h"
33 34
34static int iwlagn_disable_bss(struct iwl_priv *priv, 35static int iwlagn_disable_bss(struct iwl_priv *priv,
35 struct iwl_rxon_context *ctx, 36 struct iwl_rxon_context *ctx,
@@ -39,7 +40,8 @@ static int iwlagn_disable_bss(struct iwl_priv *priv,
39 int ret; 40 int ret;
40 41
41 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 42 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
42 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, sizeof(*send), send); 43 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd,
44 CMD_SYNC, sizeof(*send), send);
43 45
44 send->filter_flags = old_filter; 46 send->filter_flags = old_filter;
45 47
@@ -64,7 +66,8 @@ static int iwlagn_disable_pan(struct iwl_priv *priv,
64 66
65 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 67 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
66 send->dev_type = RXON_DEV_TYPE_P2P; 68 send->dev_type = RXON_DEV_TYPE_P2P;
67 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, sizeof(*send), send); 69 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd,
70 CMD_SYNC, sizeof(*send), send);
68 71
69 send->filter_flags = old_filter; 72 send->filter_flags = old_filter;
70 send->dev_type = old_dev_type; 73 send->dev_type = old_dev_type;
@@ -89,7 +92,8 @@ static int iwlagn_disconn_pan(struct iwl_priv *priv,
89 int ret; 92 int ret;
90 93
91 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 94 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
92 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, sizeof(*send), send); 95 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
96 sizeof(*send), send);
93 97
94 send->filter_flags = old_filter; 98 send->filter_flags = old_filter;
95 99
@@ -117,7 +121,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv,
117 ctx->qos_data.qos_active, 121 ctx->qos_data.qos_active,
118 ctx->qos_data.def_qos_parm.qos_flags); 122 ctx->qos_data.def_qos_parm.qos_flags);
119 123
120 ret = iwl_send_cmd_pdu(priv, ctx->qos_cmd, 124 ret = trans_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC,
121 sizeof(struct iwl_qosparam_cmd), 125 sizeof(struct iwl_qosparam_cmd),
122 &ctx->qos_data.def_qos_parm); 126 &ctx->qos_data.def_qos_parm);
123 if (ret) 127 if (ret)
@@ -176,8 +180,8 @@ static int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
176 ctx->staging.ofdm_ht_triple_stream_basic_rates; 180 ctx->staging.ofdm_ht_triple_stream_basic_rates;
177 rxon_assoc.acquisition_data = ctx->staging.acquisition_data; 181 rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
178 182
179 ret = iwl_send_cmd_pdu_async(priv, ctx->rxon_assoc_cmd, 183 ret = trans_send_cmd_pdu(priv, ctx->rxon_assoc_cmd,
180 sizeof(rxon_assoc), &rxon_assoc, NULL); 184 CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc);
181 return ret; 185 return ret;
182} 186}
183 187
@@ -262,7 +266,7 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
262 * Associated RXON doesn't clear the station table in uCode, 266 * Associated RXON doesn't clear the station table in uCode,
263 * so we don't need to restore stations etc. after this. 267 * so we don't need to restore stations etc. after this.
264 */ 268 */
265 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, 269 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
266 sizeof(struct iwl_rxon_cmd), &ctx->staging); 270 sizeof(struct iwl_rxon_cmd), &ctx->staging);
267 if (ret) { 271 if (ret) {
268 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 272 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
@@ -670,6 +674,38 @@ static void iwlagn_check_needed_chains(struct iwl_priv *priv,
670 ht_conf->single_chain_sufficient = !need_multiple; 674 ht_conf->single_chain_sufficient = !need_multiple;
671} 675}
672 676
677static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
678{
679 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
680 int ret;
681
682 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
683 iwl_is_any_associated(priv)) {
684 struct iwl_calib_chain_noise_reset_cmd cmd;
685
686 /* clear data for chain noise calibration algorithm */
687 data->chain_noise_a = 0;
688 data->chain_noise_b = 0;
689 data->chain_noise_c = 0;
690 data->chain_signal_a = 0;
691 data->chain_signal_b = 0;
692 data->chain_signal_c = 0;
693 data->beacon_count = 0;
694
695 memset(&cmd, 0, sizeof(cmd));
696 iwl_set_calib_hdr(&cmd.hdr,
697 priv->_agn.phy_calib_chain_noise_reset_cmd);
698 ret = trans_send_cmd_pdu(priv,
699 REPLY_PHY_CALIBRATION_CMD,
700 CMD_SYNC, sizeof(cmd), &cmd);
701 if (ret)
702 IWL_ERR(priv,
703 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
704 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
705 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
706 }
707}
708
673void iwlagn_bss_info_changed(struct ieee80211_hw *hw, 709void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
674 struct ieee80211_vif *vif, 710 struct ieee80211_vif *vif,
675 struct ieee80211_bss_conf *bss_conf, 711 struct ieee80211_bss_conf *bss_conf,
@@ -727,6 +763,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
727 } 763 }
728 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 764 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
729 } 765 }
766
767 iwlagn_bt_coex_rssi_monitor(priv);
730 } 768 }
731 769
732 if (ctx->ht.enabled) { 770 if (ctx->ht.enabled) {
@@ -776,7 +814,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
776 iwl_power_update_mode(priv, false); 814 iwl_power_update_mode(priv, false);
777 815
778 /* Enable RX differential gain and sensitivity calibrations */ 816 /* Enable RX differential gain and sensitivity calibrations */
779 iwl_chain_noise_reset(priv); 817 if (!priv->disable_chain_noise_cal)
818 iwlagn_chain_noise_reset(priv);
780 priv->start_calib = 1; 819 priv->start_calib = 1;
781 } 820 }
782 821
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
index 9b32f83f0b7f..001622c06526 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
@@ -33,6 +33,7 @@
33#include "iwl-core.h" 33#include "iwl-core.h"
34#include "iwl-sta.h" 34#include "iwl-sta.h"
35#include "iwl-agn.h" 35#include "iwl-agn.h"
36#include "iwl-trans.h"
36 37
37static struct iwl_link_quality_cmd * 38static struct iwl_link_quality_cmd *
38iwl_sta_alloc_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id) 39iwl_sta_alloc_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id)
@@ -180,7 +181,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
180 cmd.len[0] = cmd_size; 181 cmd.len[0] = cmd_size;
181 182
182 if (not_empty || send_if_empty) 183 if (not_empty || send_if_empty)
183 return iwl_send_cmd(priv, &cmd); 184 return trans_send_cmd(priv, &cmd);
184 else 185 else
185 return 0; 186 return 0;
186} 187}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index c05a8d9fbd2e..7d3aad83e0d6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -339,6 +339,16 @@ void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
339 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask); 339 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
340} 340}
341 341
342static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
343 struct ieee80211_tx_info *info,
344 __le16 fc, __le32 *tx_flags)
345{
346 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS ||
347 info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT ||
348 info->flags & IEEE80211_TX_CTL_AMPDU)
349 *tx_flags |= TX_CMD_FLG_PROT_REQUIRE_MSK;
350}
351
342/* 352/*
343 * handle build REPLY_TX command notification. 353 * handle build REPLY_TX command notification.
344 */ 354 */
@@ -388,7 +398,7 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
388 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 398 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
389 } 399 }
390 400
391 priv->cfg->ops->utils->tx_cmd_protection(priv, info, fc, &tx_flags); 401 iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags);
392 402
393 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); 403 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK);
394 if (ieee80211_is_mgmt(fc)) { 404 if (ieee80211_is_mgmt(fc)) {
@@ -436,6 +446,16 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
436 if (ieee80211_is_data(fc)) { 446 if (ieee80211_is_data(fc)) {
437 tx_cmd->initial_rate_index = 0; 447 tx_cmd->initial_rate_index = 0;
438 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 448 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
449 if (priv->tm_fixed_rate) {
450 /*
451 * rate overwrite by testmode
452 * we not only send lq command to change rate
453 * we also re-enforce per data pkt base.
454 */
455 tx_cmd->tx_flags &= ~TX_CMD_FLG_STA_RATE_MSK;
456 memcpy(&tx_cmd->rate_n_flags, &priv->tm_fixed_rate,
457 sizeof(tx_cmd->rate_n_flags));
458 }
439 return; 459 return;
440 } 460 }
441 461
@@ -497,8 +517,7 @@ static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
497 517
498 case WLAN_CIPHER_SUITE_TKIP: 518 case WLAN_CIPHER_SUITE_TKIP:
499 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; 519 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
500 ieee80211_get_tkip_key(keyconf, skb_frag, 520 ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
501 IEEE80211_TKIP_P2_KEY, tx_cmd->key);
502 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); 521 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
503 break; 522 break;
504 523
@@ -831,88 +850,6 @@ drop_unlock_priv:
831 return -1; 850 return -1;
832} 851}
833 852
834static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv,
835 struct iwl_dma_ptr *ptr, size_t size)
836{
837 ptr->addr = dma_alloc_coherent(priv->bus.dev, size,
838 &ptr->dma, GFP_KERNEL);
839 if (!ptr->addr)
840 return -ENOMEM;
841 ptr->size = size;
842 return 0;
843}
844
845static inline void iwlagn_free_dma_ptr(struct iwl_priv *priv,
846 struct iwl_dma_ptr *ptr)
847{
848 if (unlikely(!ptr->addr))
849 return;
850
851 dma_free_coherent(priv->bus.dev, ptr->size, ptr->addr, ptr->dma);
852 memset(ptr, 0, sizeof(*ptr));
853}
854
855/**
856 * iwlagn_hw_txq_ctx_free - Free TXQ Context
857 *
858 * Destroy all TX DMA queues and structures
859 */
860void iwlagn_hw_txq_ctx_free(struct iwl_priv *priv)
861{
862 int txq_id;
863
864 /* Tx queues */
865 if (priv->txq) {
866 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
867 if (txq_id == priv->cmd_queue)
868 iwl_cmd_queue_free(priv);
869 else
870 iwl_tx_queue_free(priv, txq_id);
871 }
872 iwlagn_free_dma_ptr(priv, &priv->kw);
873
874 iwlagn_free_dma_ptr(priv, &priv->scd_bc_tbls);
875
876 /* free tx queue structure */
877 iwl_free_txq_mem(priv);
878}
879
880/**
881 * iwlagn_txq_ctx_stop - Stop all Tx DMA channels
882 */
883void iwlagn_txq_ctx_stop(struct iwl_priv *priv)
884{
885 int ch, txq_id;
886 unsigned long flags;
887
888 /* Turn off all Tx DMA fifos */
889 spin_lock_irqsave(&priv->lock, flags);
890
891 iwlagn_txq_set_sched(priv, 0);
892
893 /* Stop each Tx DMA channel, and wait for it to be idle */
894 for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) {
895 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0);
896 if (iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG,
897 FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch),
898 1000))
899 IWL_ERR(priv, "Failing on timeout while stopping"
900 " DMA channel %d [0x%08x]", ch,
901 iwl_read_direct32(priv, FH_TSSR_TX_STATUS_REG));
902 }
903 spin_unlock_irqrestore(&priv->lock, flags);
904
905 if (!priv->txq)
906 return;
907
908 /* Unmap DMA from host system and free skb's */
909 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
910 if (txq_id == priv->cmd_queue)
911 iwl_cmd_queue_unmap(priv);
912 else
913 iwl_tx_queue_unmap(priv, txq_id);
914}
915
916/* 853/*
917 * Find first available (lowest unused) Tx Queue, mark it "active". 854 * Find first available (lowest unused) Tx Queue, mark it "active".
918 * Called only when finding queue for aggregation. 855 * Called only when finding queue for aggregation.
@@ -1171,7 +1108,7 @@ int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
1171 1108
1172 iwlagn_txq_inval_byte_cnt_tbl(priv, txq); 1109 iwlagn_txq_inval_byte_cnt_tbl(priv, txq);
1173 1110
1174 iwlagn_txq_free_tfd(priv, txq); 1111 iwlagn_txq_free_tfd(priv, txq, txq->q.read_ptr);
1175 } 1112 }
1176 return nfreed; 1113 return nfreed;
1177} 1114}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 2043c8b3139b..06304a681ed3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -39,6 +39,7 @@
39#include "iwl-agn-hw.h" 39#include "iwl-agn-hw.h"
40#include "iwl-agn.h" 40#include "iwl-agn.h"
41#include "iwl-agn-calib.h" 41#include "iwl-agn-calib.h"
42#include "iwl-trans.h"
42 43
43#define IWL_AC_UNSET -1 44#define IWL_AC_UNSET -1
44 45
@@ -223,7 +224,7 @@ static int iwlagn_send_calib_cfg(struct iwl_priv *priv)
223 calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; 224 calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
224 calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL; 225 calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL;
225 226
226 return iwl_send_cmd(priv, &cmd); 227 return trans_send_cmd(priv, &cmd);
227} 228}
228 229
229void iwlagn_rx_calib_result(struct iwl_priv *priv, 230void iwlagn_rx_calib_result(struct iwl_priv *priv,
@@ -321,7 +322,8 @@ static int iwlagn_send_wimax_coex(struct iwl_priv *priv)
321 /* coexistence is disabled */ 322 /* coexistence is disabled */
322 memset(&coex_cmd, 0, sizeof(coex_cmd)); 323 memset(&coex_cmd, 0, sizeof(coex_cmd));
323 } 324 }
324 return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD, 325 return trans_send_cmd_pdu(priv,
326 COEX_PRIORITY_TABLE_CMD, CMD_SYNC,
325 sizeof(coex_cmd), &coex_cmd); 327 sizeof(coex_cmd), &coex_cmd);
326} 328}
327 329
@@ -353,7 +355,8 @@ void iwlagn_send_prio_tbl(struct iwl_priv *priv)
353 355
354 memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, 356 memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl,
355 sizeof(iwlagn_bt_prio_tbl)); 357 sizeof(iwlagn_bt_prio_tbl));
356 if (iwl_send_cmd_pdu(priv, REPLY_BT_COEX_PRIO_TABLE, 358 if (trans_send_cmd_pdu(priv,
359 REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC,
357 sizeof(prio_tbl_cmd), &prio_tbl_cmd)) 360 sizeof(prio_tbl_cmd), &prio_tbl_cmd))
358 IWL_ERR(priv, "failed to send BT prio tbl command\n"); 361 IWL_ERR(priv, "failed to send BT prio tbl command\n");
359} 362}
@@ -365,7 +368,8 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
365 368
366 env_cmd.action = action; 369 env_cmd.action = action;
367 env_cmd.type = type; 370 env_cmd.type = type;
368 ret = iwl_send_cmd_pdu(priv, REPLY_BT_COEX_PROT_ENV, 371 ret = trans_send_cmd_pdu(priv,
372 REPLY_BT_COEX_PROT_ENV, CMD_SYNC,
369 sizeof(env_cmd), &env_cmd); 373 sizeof(env_cmd), &env_cmd);
370 if (ret) 374 if (ret)
371 IWL_ERR(priv, "failed to send BT env command\n"); 375 IWL_ERR(priv, "failed to send BT env command\n");
@@ -403,7 +407,7 @@ static int iwlagn_alive_notify(struct iwl_priv *priv)
403 priv->scd_bc_tbls.dma >> 10); 407 priv->scd_bc_tbls.dma >> 10);
404 408
405 /* Enable DMA channel */ 409 /* Enable DMA channel */
406 for (chan = 0; chan < FH50_TCSR_CHNL_NUM ; chan++) 410 for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++)
407 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan), 411 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
408 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | 412 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
409 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); 413 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 7e6c463abbdf..38a1e4f58829 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -129,6 +129,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
129 struct iwl_tx_beacon_cmd *tx_beacon_cmd; 129 struct iwl_tx_beacon_cmd *tx_beacon_cmd;
130 struct iwl_host_cmd cmd = { 130 struct iwl_host_cmd cmd = {
131 .id = REPLY_TX_BEACON, 131 .id = REPLY_TX_BEACON,
132 .flags = CMD_SYNC,
132 }; 133 };
133 struct ieee80211_tx_info *info; 134 struct ieee80211_tx_info *info;
134 u32 frame_size; 135 u32 frame_size;
@@ -205,7 +206,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
205 cmd.data[1] = priv->beacon_skb->data; 206 cmd.data[1] = priv->beacon_skb->data;
206 cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY; 207 cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY;
207 208
208 return iwl_send_cmd_sync(priv, &cmd); 209 return trans_send_cmd(priv, &cmd);
209} 210}
210 211
211static void iwl_bg_beacon_update(struct work_struct *work) 212static void iwl_bg_beacon_update(struct work_struct *work)
@@ -578,7 +579,8 @@ static void iwl_rx_handle(struct iwl_priv *priv)
578 579
579 if (reclaim) { 580 if (reclaim) {
580 /* Invoke any callbacks, transfer the buffer to caller, 581 /* Invoke any callbacks, transfer the buffer to caller,
581 * and fire off the (possibly) blocking iwl_send_cmd() 582 * and fire off the (possibly) blocking
583 * trans_send_cmd()
582 * as we reclaim the driver command queue */ 584 * as we reclaim the driver command queue */
583 if (rxb->page) 585 if (rxb->page)
584 iwl_tx_cmd_complete(priv, rxb); 586 iwl_tx_cmd_complete(priv, rxb);
@@ -1563,7 +1565,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1563 release_firmware(ucode_raw); 1565 release_firmware(ucode_raw);
1564} 1566}
1565 1567
1566static const char *desc_lookup_text[] = { 1568static const char * const desc_lookup_text[] = {
1567 "OK", 1569 "OK",
1568 "FAIL", 1570 "FAIL",
1569 "BAD_PARAM", 1571 "BAD_PARAM",
@@ -1587,7 +1589,7 @@ static const char *desc_lookup_text[] = {
1587 "NMI_INTERRUPT_DATA_ACTION_PT", 1589 "NMI_INTERRUPT_DATA_ACTION_PT",
1588 "NMI_TRM_HW_ER", 1590 "NMI_TRM_HW_ER",
1589 "NMI_INTERRUPT_TRM", 1591 "NMI_INTERRUPT_TRM",
1590 "NMI_INTERRUPT_BREAK_POINT" 1592 "NMI_INTERRUPT_BREAK_POINT",
1591 "DEBUG_0", 1593 "DEBUG_0",
1592 "DEBUG_1", 1594 "DEBUG_1",
1593 "DEBUG_2", 1595 "DEBUG_2",
@@ -1940,8 +1942,9 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1940 adv_cmd.critical_temperature_exit = 1942 adv_cmd.critical_temperature_exit =
1941 cpu_to_le32(priv->hw_params.ct_kill_exit_threshold); 1943 cpu_to_le32(priv->hw_params.ct_kill_exit_threshold);
1942 1944
1943 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, 1945 ret = trans_send_cmd_pdu(priv,
1944 sizeof(adv_cmd), &adv_cmd); 1946 REPLY_CT_KILL_CONFIG_CMD,
1947 CMD_SYNC, sizeof(adv_cmd), &adv_cmd);
1945 if (ret) 1948 if (ret)
1946 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); 1949 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
1947 else 1950 else
@@ -1955,8 +1958,9 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1955 cmd.critical_temperature_R = 1958 cmd.critical_temperature_R =
1956 cpu_to_le32(priv->hw_params.ct_kill_threshold); 1959 cpu_to_le32(priv->hw_params.ct_kill_threshold);
1957 1960
1958 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, 1961 ret = trans_send_cmd_pdu(priv,
1959 sizeof(cmd), &cmd); 1962 REPLY_CT_KILL_CONFIG_CMD,
1963 CMD_SYNC, sizeof(cmd), &cmd);
1960 if (ret) 1964 if (ret)
1961 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); 1965 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
1962 else 1966 else
@@ -1980,7 +1984,7 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
1980 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; 1984 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
1981 calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg); 1985 calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg);
1982 1986
1983 return iwl_send_cmd(priv, &cmd); 1987 return trans_send_cmd(priv, &cmd);
1984} 1988}
1985 1989
1986 1990
@@ -2011,11 +2015,18 @@ int iwl_alive_start(struct iwl_priv *priv)
2011 if (priv->cfg->bt_params && 2015 if (priv->cfg->bt_params &&
2012 priv->cfg->bt_params->advanced_bt_coexist) { 2016 priv->cfg->bt_params->advanced_bt_coexist) {
2013 /* Configure Bluetooth device coexistence support */ 2017 /* Configure Bluetooth device coexistence support */
2018 if (priv->cfg->bt_params->bt_sco_disable)
2019 priv->bt_enable_pspoll = false;
2020 else
2021 priv->bt_enable_pspoll = true;
2022
2014 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; 2023 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
2015 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; 2024 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
2016 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; 2025 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
2017 iwlagn_send_advance_bt_config(priv); 2026 iwlagn_send_advance_bt_config(priv);
2018 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; 2027 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
2028 priv->cur_rssi_ctx = NULL;
2029
2019 iwlagn_send_prio_tbl(priv); 2030 iwlagn_send_prio_tbl(priv);
2020 2031
2021 /* FIXME: w/a to force change uCode BT state machine */ 2032 /* FIXME: w/a to force change uCode BT state machine */
@@ -2098,6 +2109,8 @@ static void __iwl_down(struct iwl_priv *priv)
2098 2109
2099 /* reset BT coex data */ 2110 /* reset BT coex data */
2100 priv->bt_status = 0; 2111 priv->bt_status = 0;
2112 priv->cur_rssi_ctx = NULL;
2113 priv->bt_is_sco = 0;
2101 if (priv->cfg->bt_params) 2114 if (priv->cfg->bt_params)
2102 priv->bt_traffic_load = 2115 priv->bt_traffic_load =
2103 priv->cfg->bt_params->bt_init_traffic_load; 2116 priv->cfg->bt_params->bt_init_traffic_load;
@@ -2273,6 +2286,7 @@ static void iwlagn_prepare_restart(struct iwl_priv *priv)
2273 u8 bt_ci_compliance; 2286 u8 bt_ci_compliance;
2274 u8 bt_load; 2287 u8 bt_load;
2275 u8 bt_status; 2288 u8 bt_status;
2289 bool bt_is_sco;
2276 2290
2277 lockdep_assert_held(&priv->mutex); 2291 lockdep_assert_held(&priv->mutex);
2278 2292
@@ -2293,6 +2307,7 @@ static void iwlagn_prepare_restart(struct iwl_priv *priv)
2293 bt_ci_compliance = priv->bt_ci_compliance; 2307 bt_ci_compliance = priv->bt_ci_compliance;
2294 bt_load = priv->bt_traffic_load; 2308 bt_load = priv->bt_traffic_load;
2295 bt_status = priv->bt_status; 2309 bt_status = priv->bt_status;
2310 bt_is_sco = priv->bt_is_sco;
2296 2311
2297 __iwl_down(priv); 2312 __iwl_down(priv);
2298 2313
@@ -2300,6 +2315,7 @@ static void iwlagn_prepare_restart(struct iwl_priv *priv)
2300 priv->bt_ci_compliance = bt_ci_compliance; 2315 priv->bt_ci_compliance = bt_ci_compliance;
2301 priv->bt_traffic_load = bt_load; 2316 priv->bt_traffic_load = bt_load;
2302 priv->bt_status = bt_status; 2317 priv->bt_status = bt_status;
2318 priv->bt_is_sco = bt_is_sco;
2303} 2319}
2304 2320
2305static void iwl_bg_restart(struct work_struct *data) 2321static void iwl_bg_restart(struct work_struct *data)
@@ -3326,6 +3342,29 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3326 kfree(priv->beacon_cmd); 3342 kfree(priv->beacon_cmd);
3327} 3343}
3328 3344
3345static void iwl_mac_rssi_callback(struct ieee80211_hw *hw,
3346 enum ieee80211_rssi_event rssi_event)
3347{
3348 struct iwl_priv *priv = hw->priv;
3349
3350 mutex_lock(&priv->mutex);
3351
3352 if (priv->cfg->bt_params &&
3353 priv->cfg->bt_params->advanced_bt_coexist) {
3354 if (rssi_event == RSSI_EVENT_LOW)
3355 priv->bt_enable_pspoll = true;
3356 else if (rssi_event == RSSI_EVENT_HIGH)
3357 priv->bt_enable_pspoll = false;
3358
3359 iwlagn_send_advance_bt_config(priv);
3360 } else {
3361 IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled,"
3362 "ignoring RSSI callback\n");
3363 }
3364
3365 mutex_unlock(&priv->mutex);
3366}
3367
3329struct ieee80211_ops iwlagn_hw_ops = { 3368struct ieee80211_ops iwlagn_hw_ops = {
3330 .tx = iwlagn_mac_tx, 3369 .tx = iwlagn_mac_tx,
3331 .start = iwlagn_mac_start, 3370 .start = iwlagn_mac_start,
@@ -3351,6 +3390,7 @@ struct ieee80211_ops iwlagn_hw_ops = {
3351 .cancel_remain_on_channel = iwl_mac_cancel_remain_on_channel, 3390 .cancel_remain_on_channel = iwl_mac_cancel_remain_on_channel,
3352 .offchannel_tx = iwl_mac_offchannel_tx, 3391 .offchannel_tx = iwl_mac_offchannel_tx,
3353 .offchannel_tx_cancel_wait = iwl_mac_offchannel_tx_cancel_wait, 3392 .offchannel_tx_cancel_wait = iwl_mac_offchannel_tx_cancel_wait,
3393 .rssi_callback = iwl_mac_rssi_callback,
3354 CFG80211_TESTMODE_CMD(iwl_testmode_cmd) 3394 CFG80211_TESTMODE_CMD(iwl_testmode_cmd)
3355 CFG80211_TESTMODE_DUMP(iwl_testmode_dump) 3395 CFG80211_TESTMODE_DUMP(iwl_testmode_dump)
3356}; 3396};
@@ -3709,8 +3749,8 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3709 3749
3710 iwl_dealloc_ucode(priv); 3750 iwl_dealloc_ucode(priv);
3711 3751
3712 priv->trans.ops->rx_free(priv); 3752 trans_rx_free(priv);
3713 iwlagn_hw_txq_ctx_free(priv); 3753 trans_tx_free(priv);
3714 3754
3715 iwl_eeprom_free(priv); 3755 iwl_eeprom_free(priv);
3716 3756
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 4351151e2a91..5f58b44bb2a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -109,9 +109,6 @@ extern struct iwl_cfg iwl135_bg_cfg;
109extern struct iwl_cfg iwl135_bgn_cfg; 109extern struct iwl_cfg iwl135_bgn_cfg;
110 110
111extern struct iwl_mod_params iwlagn_mod_params; 111extern struct iwl_mod_params iwlagn_mod_params;
112extern struct iwl_hcmd_ops iwlagn_hcmd;
113extern struct iwl_hcmd_ops iwlagn_bt_hcmd;
114extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
115 112
116extern struct ieee80211_ops iwlagn_hw_ops; 113extern struct ieee80211_ops iwlagn_hw_ops;
117 114
@@ -180,8 +177,6 @@ int iwlagn_hw_valid_rtc_data_addr(u32 addr);
180int iwlagn_send_tx_power(struct iwl_priv *priv); 177int iwlagn_send_tx_power(struct iwl_priv *priv);
181void iwlagn_temperature(struct iwl_priv *priv); 178void iwlagn_temperature(struct iwl_priv *priv);
182u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); 179u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv);
183const u8 *iwlagn_eeprom_query_addr(const struct iwl_priv *priv,
184 size_t offset);
185int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 180int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
186int iwlagn_hw_nic_init(struct iwl_priv *priv); 181int iwlagn_hw_nic_init(struct iwl_priv *priv);
187int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); 182int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv);
@@ -193,12 +188,12 @@ void iwlagn_rx_queue_restock(struct iwl_priv *priv);
193void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority); 188void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority);
194void iwlagn_rx_replenish(struct iwl_priv *priv); 189void iwlagn_rx_replenish(struct iwl_priv *priv);
195void iwlagn_rx_replenish_now(struct iwl_priv *priv); 190void iwlagn_rx_replenish_now(struct iwl_priv *priv);
196int iwlagn_rxq_stop(struct iwl_priv *priv);
197int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); 191int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
198void iwl_setup_rx_handlers(struct iwl_priv *priv); 192void iwl_setup_rx_handlers(struct iwl_priv *priv);
199 193
200/* tx */ 194/* tx */
201void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); 195void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
196 int index);
202int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv, 197int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
203 struct iwl_tx_queue *txq, 198 struct iwl_tx_queue *txq,
204 dma_addr_t addr, u16 len, u8 reset); 199 dma_addr_t addr, u16 len, u8 reset);
@@ -217,8 +212,6 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
217void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, 212void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
218 struct iwl_rx_mem_buffer *rxb); 213 struct iwl_rx_mem_buffer *rxb);
219int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); 214int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
220void iwlagn_hw_txq_ctx_free(struct iwl_priv *priv);
221void iwlagn_txq_ctx_stop(struct iwl_priv *priv);
222 215
223static inline u32 iwl_tx_status_to_mac80211(u32 status) 216static inline u32 iwl_tx_status_to_mac80211(u32 status)
224{ 217{
@@ -257,6 +250,12 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
257int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant); 250int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant);
258int iwlagn_send_beacon_cmd(struct iwl_priv *priv); 251int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
259int iwlagn_set_pan_params(struct iwl_priv *priv); 252int iwlagn_set_pan_params(struct iwl_priv *priv);
253void iwlagn_gain_computation(struct iwl_priv *priv,
254 u32 average_noise[NUM_RX_CHAINS],
255 u16 min_average_noise_antenna_i,
256 u32 min_average_noise,
257 u8 default_chain);
258
260 259
261/* bt coex */ 260/* bt coex */
262void iwlagn_send_advance_bt_config(struct iwl_priv *priv); 261void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
@@ -265,6 +264,8 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
265void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv); 264void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
266void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv); 265void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
267void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv); 266void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv);
267void iwlagn_bt_coex_rssi_monitor(struct iwl_priv *priv);
268void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena);
268 269
269#ifdef CONFIG_IWLWIFI_DEBUG 270#ifdef CONFIG_IWLWIFI_DEBUG
270const char *iwl_get_tx_fail_reason(u32 status); 271const char *iwl_get_tx_fail_reason(u32 status);
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 8a2edf8dce32..ee2563777e8d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -1931,6 +1931,9 @@ struct iwl_bt_cmd {
1931/* Disable Sync PSPoll on SCO/eSCO */ 1931/* Disable Sync PSPoll on SCO/eSCO */
1932#define IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE BIT(7) 1932#define IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE BIT(7)
1933 1933
1934#define IWLAGN_BT_PSP_MIN_RSSI_THRESHOLD -75 /* dBm */
1935#define IWLAGN_BT_PSP_MAX_RSSI_THRESHOLD -65 /* dBm */
1936
1934#define IWLAGN_BT_PRIO_BOOST_MAX 0xFF 1937#define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
1935#define IWLAGN_BT_PRIO_BOOST_MIN 0x00 1938#define IWLAGN_BT_PRIO_BOOST_MIN 0x00
1936#define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0 1939#define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index f91e306c2498..fa3d5bacbde2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -42,6 +42,7 @@
42#include "iwl-sta.h" 42#include "iwl-sta.h"
43#include "iwl-helpers.h" 43#include "iwl-helpers.h"
44#include "iwl-agn.h" 44#include "iwl-agn.h"
45#include "iwl-trans.h"
45 46
46u32 iwl_debug_level; 47u32 iwl_debug_level;
47 48
@@ -375,8 +376,8 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
375 le32_to_cpu(ctx->timing.beacon_init_val), 376 le32_to_cpu(ctx->timing.beacon_init_val),
376 le16_to_cpu(ctx->timing.atim_window)); 377 le16_to_cpu(ctx->timing.atim_window));
377 378
378 return iwl_send_cmd_pdu(priv, ctx->rxon_timing_cmd, 379 return trans_send_cmd_pdu(priv, ctx->rxon_timing_cmd,
379 sizeof(ctx->timing), &ctx->timing); 380 CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
380} 381}
381 382
382void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 383void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
@@ -1131,8 +1132,8 @@ void iwl_send_bt_config(struct iwl_priv *priv)
1131 IWL_DEBUG_INFO(priv, "BT coex %s\n", 1132 IWL_DEBUG_INFO(priv, "BT coex %s\n",
1132 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); 1133 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
1133 1134
1134 if (iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1135 if (trans_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1135 sizeof(struct iwl_bt_cmd), &bt_cmd)) 1136 CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd))
1136 IWL_ERR(priv, "failed to send BT Coex Config\n"); 1137 IWL_ERR(priv, "failed to send BT Coex Config\n");
1137} 1138}
1138 1139
@@ -1144,11 +1145,13 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
1144 }; 1145 };
1145 1146
1146 if (flags & CMD_ASYNC) 1147 if (flags & CMD_ASYNC)
1147 return iwl_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, 1148 return trans_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
1149 CMD_ASYNC,
1148 sizeof(struct iwl_statistics_cmd), 1150 sizeof(struct iwl_statistics_cmd),
1149 &statistics_cmd, NULL); 1151 &statistics_cmd);
1150 else 1152 else
1151 return iwl_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, 1153 return trans_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
1154 CMD_SYNC,
1152 sizeof(struct iwl_statistics_cmd), 1155 sizeof(struct iwl_statistics_cmd),
1153 &statistics_cmd); 1156 &statistics_cmd);
1154} 1157}
@@ -1370,12 +1373,6 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
1370 1373
1371} 1374}
1372 1375
1373void iwl_free_txq_mem(struct iwl_priv *priv)
1374{
1375 kfree(priv->txq);
1376 priv->txq = NULL;
1377}
1378
1379#ifdef CONFIG_IWLWIFI_DEBUGFS 1376#ifdef CONFIG_IWLWIFI_DEBUGFS
1380 1377
1381#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES) 1378#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 6c21de9f5b60..692c30cb2fac 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -80,31 +80,6 @@ struct iwl_cmd;
80 80
81#define IWL_CMD(x) case x: return #x 81#define IWL_CMD(x) case x: return #x
82 82
83struct iwl_hcmd_utils_ops {
84 u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data);
85 void (*gain_computation)(struct iwl_priv *priv,
86 u32 *average_noise,
87 u16 min_average_noise_antennat_i,
88 u32 min_average_noise,
89 u8 default_chain);
90 void (*chain_noise_reset)(struct iwl_priv *priv);
91 void (*tx_cmd_protection)(struct iwl_priv *priv,
92 struct ieee80211_tx_info *info,
93 __le16 fc, __le32 *tx_flags);
94 int (*calc_rssi)(struct iwl_priv *priv,
95 struct iwl_rx_phy_res *rx_resp);
96 int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
97};
98
99struct iwl_apm_ops {
100 int (*init)(struct iwl_priv *priv);
101 void (*config)(struct iwl_priv *priv);
102};
103
104struct iwl_temp_ops {
105 void (*temperature)(struct iwl_priv *priv);
106};
107
108struct iwl_lib_ops { 83struct iwl_lib_ops {
109 /* set hw dependent parameters */ 84 /* set hw dependent parameters */
110 int (*set_hw_params)(struct iwl_priv *priv); 85 int (*set_hw_params)(struct iwl_priv *priv);
@@ -118,17 +93,14 @@ struct iwl_lib_ops {
118 int (*is_valid_rtc_data_addr)(u32 addr); 93 int (*is_valid_rtc_data_addr)(u32 addr);
119 int (*set_channel_switch)(struct iwl_priv *priv, 94 int (*set_channel_switch)(struct iwl_priv *priv,
120 struct ieee80211_channel_switch *ch_switch); 95 struct ieee80211_channel_switch *ch_switch);
121 /* power management */ 96 /* device specific configuration */
122 struct iwl_apm_ops apm_ops; 97 void (*nic_config)(struct iwl_priv *priv);
123
124 /* power */
125 void (*update_chain_flags)(struct iwl_priv *priv);
126 98
127 /* eeprom operations (as defined in iwl-eeprom.h) */ 99 /* eeprom operations (as defined in iwl-eeprom.h) */
128 struct iwl_eeprom_ops eeprom_ops; 100 struct iwl_eeprom_ops eeprom_ops;
129 101
130 /* temperature */ 102 /* temperature */
131 struct iwl_temp_ops temp_ops; 103 void (*temperature)(struct iwl_priv *priv);
132}; 104};
133 105
134/* NIC specific ops */ 106/* NIC specific ops */
@@ -138,7 +110,6 @@ struct iwl_nic_ops {
138 110
139struct iwl_ops { 111struct iwl_ops {
140 const struct iwl_lib_ops *lib; 112 const struct iwl_lib_ops *lib;
141 const struct iwl_hcmd_utils_ops *utils;
142 const struct iwl_nic_ops *nic; 113 const struct iwl_nic_ops *nic;
143}; 114};
144 115
@@ -328,8 +299,6 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
328int iwl_mac_change_interface(struct ieee80211_hw *hw, 299int iwl_mac_change_interface(struct ieee80211_hw *hw,
329 struct ieee80211_vif *vif, 300 struct ieee80211_vif *vif,
330 enum nl80211_iftype newtype, bool newp2p); 301 enum nl80211_iftype newtype, bool newp2p);
331void iwl_free_txq_mem(struct iwl_priv *priv);
332
333#ifdef CONFIG_IWLWIFI_DEBUGFS 302#ifdef CONFIG_IWLWIFI_DEBUGFS
334int iwl_alloc_traffic_mem(struct iwl_priv *priv); 303int iwl_alloc_traffic_mem(struct iwl_priv *priv);
335void iwl_free_traffic_mem(struct iwl_priv *priv); 304void iwl_free_traffic_mem(struct iwl_priv *priv);
@@ -371,8 +340,6 @@ static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
371/***************************************************** 340/*****************************************************
372* RX 341* RX
373******************************************************/ 342******************************************************/
374void iwl_cmd_queue_free(struct iwl_priv *priv);
375void iwl_cmd_queue_unmap(struct iwl_priv *priv);
376void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, 343void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
377 struct iwl_rx_queue *q); 344 struct iwl_rx_queue *q);
378int iwl_rx_queue_space(const struct iwl_rx_queue *q); 345int iwl_rx_queue_space(const struct iwl_rx_queue *q);
@@ -386,10 +353,8 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
386* TX 353* TX
387******************************************************/ 354******************************************************/
388void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 355void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
389void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id);
390int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, 356int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
391 int count, int slots_num, u32 id); 357 int count, int slots_num, u32 id);
392void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id);
393void iwl_setup_watchdog(struct iwl_priv *priv); 358void iwl_setup_watchdog(struct iwl_priv *priv);
394/***************************************************** 359/*****************************************************
395 * TX power 360 * TX power
@@ -440,16 +405,9 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
440 *****************************************************/ 405 *****************************************************/
441 406
442const char *get_cmd_string(u8 cmd); 407const char *get_cmd_string(u8 cmd);
443int __must_check iwl_send_cmd_sync(struct iwl_priv *priv,
444 struct iwl_host_cmd *cmd);
445int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); 408int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
446int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, 409int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags,
447 u16 len, const void *data); 410 u16 len, const void *data);
448int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
449 const void *data,
450 void (*callback)(struct iwl_priv *priv,
451 struct iwl_device_cmd *cmd,
452 struct iwl_rx_packet *pkt));
453 411
454int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); 412int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
455 413
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c6560e97a62b..424c45c43f5b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -260,11 +260,9 @@ struct iwl_channel_info {
260 260
261enum { 261enum {
262 CMD_SYNC = 0, 262 CMD_SYNC = 0,
263 CMD_SIZE_NORMAL = 0, 263 CMD_ASYNC = BIT(0),
264 CMD_NO_SKB = 0, 264 CMD_WANT_SKB = BIT(1),
265 CMD_ASYNC = (1 << 1), 265 CMD_ON_DEMAND = BIT(2),
266 CMD_WANT_SKB = (1 << 2),
267 CMD_MAPPED = (1 << 3),
268}; 266};
269 267
270#define DEF_CMD_PAYLOAD_SIZE 320 268#define DEF_CMD_PAYLOAD_SIZE 320
@@ -297,6 +295,16 @@ enum iwl_hcmd_dataflag {
297 IWL_HCMD_DFL_NOCOPY = BIT(0), 295 IWL_HCMD_DFL_NOCOPY = BIT(0),
298}; 296};
299 297
298/**
299 * struct iwl_host_cmd - Host command to the uCode
300 * @data: array of chunks that composes the data of the host command
301 * @reply_page: pointer to the page that holds the response to the host command
302 * @callback:
303 * @flags: can be CMD_* note CMD_WANT_SKB is incompatible withe CMD_ASYNC
304 * @len: array of the lenths of the chunks in data
305 * @dataflags:
306 * @id: id of the host command
307 */
300struct iwl_host_cmd { 308struct iwl_host_cmd {
301 const void *data[IWL_MAX_CMD_TFDS]; 309 const void *data[IWL_MAX_CMD_TFDS];
302 unsigned long reply_page; 310 unsigned long reply_page;
@@ -634,7 +642,6 @@ struct iwl_sensitivity_ranges {
634/** 642/**
635 * struct iwl_hw_params 643 * struct iwl_hw_params
636 * @max_txq_num: Max # Tx queues supported 644 * @max_txq_num: Max # Tx queues supported
637 * @dma_chnl_num: Number of Tx DMA/FIFO channels
638 * @scd_bc_tbls_size: size of scheduler byte count tables 645 * @scd_bc_tbls_size: size of scheduler byte count tables
639 * @tfd_size: TFD size 646 * @tfd_size: TFD size
640 * @tx/rx_chains_num: Number of TX/RX chains 647 * @tx/rx_chains_num: Number of TX/RX chains
@@ -656,7 +663,6 @@ struct iwl_sensitivity_ranges {
656 */ 663 */
657struct iwl_hw_params { 664struct iwl_hw_params {
658 u8 max_txq_num; 665 u8 max_txq_num;
659 u8 dma_chnl_num;
660 u16 scd_bc_tbls_size; 666 u16 scd_bc_tbls_size;
661 u32 tfd_size; 667 u32 tfd_size;
662 u8 tx_chains_num; 668 u8 tx_chains_num;
@@ -696,8 +702,6 @@ struct iwl_hw_params {
696 ****************************************************************************/ 702 ****************************************************************************/
697extern void iwl_update_chain_flags(struct iwl_priv *priv); 703extern void iwl_update_chain_flags(struct iwl_priv *priv);
698extern const u8 iwl_bcast_addr[ETH_ALEN]; 704extern const u8 iwl_bcast_addr[ETH_ALEN];
699extern int iwl_rxq_stop(struct iwl_priv *priv);
700extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
701extern int iwl_queue_space(const struct iwl_queue *q); 705extern int iwl_queue_space(const struct iwl_queue *q);
702static inline int iwl_queue_used(const struct iwl_queue *q, int i) 706static inline int iwl_queue_used(const struct iwl_queue *q, int i)
703{ 707{
@@ -1233,19 +1237,37 @@ struct iwl_trans;
1233 * struct iwl_trans_ops - transport specific operations 1237 * struct iwl_trans_ops - transport specific operations
1234 1238
1235 * @rx_init: inits the rx memory, allocate it if needed 1239 * @rx_init: inits the rx memory, allocate it if needed
1240 * @rx_stop: stop the rx
1236 * @rx_free: frees the rx memory 1241 * @rx_free: frees the rx memory
1237 * @tx_init:inits the tx memory, allocate if needed 1242 * @tx_init:inits the tx memory, allocate if needed
1243 * @tx_stop: stop the tx
1244 * @tx_free: frees the tx memory
1245 * @send_cmd:send a host command
1246 * @send_cmd_pdu:send a host command: flags can be CMD_*
1238 */ 1247 */
1239struct iwl_trans_ops { 1248struct iwl_trans_ops {
1240 int (*rx_init)(struct iwl_priv *priv); 1249 int (*rx_init)(struct iwl_priv *priv);
1250 int (*rx_stop)(struct iwl_priv *priv);
1241 void (*rx_free)(struct iwl_priv *priv); 1251 void (*rx_free)(struct iwl_priv *priv);
1252
1242 int (*tx_init)(struct iwl_priv *priv); 1253 int (*tx_init)(struct iwl_priv *priv);
1254 int (*tx_stop)(struct iwl_priv *priv);
1255 void (*tx_free)(struct iwl_priv *priv);
1256
1257 int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
1258
1259 int (*send_cmd_pdu)(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
1260 const void *data);
1243}; 1261};
1244 1262
1245struct iwl_trans { 1263struct iwl_trans {
1246 const struct iwl_trans_ops *ops; 1264 const struct iwl_trans_ops *ops;
1247}; 1265};
1248 1266
1267/* uCode ownership */
1268#define IWL_OWNERSHIP_DRIVER 0
1269#define IWL_OWNERSHIP_TM 1
1270
1249struct iwl_priv { 1271struct iwl_priv {
1250 1272
1251 /* ieee device used by generic ieee processing code */ 1273 /* ieee device used by generic ieee processing code */
@@ -1334,6 +1356,10 @@ struct iwl_priv {
1334 int fw_index; /* firmware we're trying to load */ 1356 int fw_index; /* firmware we're trying to load */
1335 u32 ucode_ver; /* version of ucode, copy of 1357 u32 ucode_ver; /* version of ucode, copy of
1336 iwl_ucode.ver */ 1358 iwl_ucode.ver */
1359
1360 /* uCode owner: default: IWL_OWNERSHIP_DRIVER */
1361 u8 ucode_owner;
1362
1337 struct fw_img ucode_rt; 1363 struct fw_img ucode_rt;
1338 struct fw_img ucode_init; 1364 struct fw_img ucode_init;
1339 1365
@@ -1509,6 +1535,9 @@ struct iwl_priv {
1509 u16 dynamic_frag_thresh; 1535 u16 dynamic_frag_thresh;
1510 u8 bt_ci_compliance; 1536 u8 bt_ci_compliance;
1511 struct work_struct bt_traffic_change_work; 1537 struct work_struct bt_traffic_change_work;
1538 bool bt_enable_pspoll;
1539 struct iwl_rxon_context *cur_rssi_ctx;
1540 bool bt_is_sco;
1512 1541
1513 struct iwl_hw_params hw_params; 1542 struct iwl_hw_params hw_params;
1514 1543
@@ -1577,7 +1606,7 @@ struct iwl_priv {
1577#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL 1606#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
1578 struct iwl_testmode_trace testmode_trace; 1607 struct iwl_testmode_trace testmode_trace;
1579#endif 1608#endif
1580 u32 dbg_fixed_rate; 1609 u32 tm_fixed_rate;
1581 1610
1582}; /*iwl_priv */ 1611}; /*iwl_priv */
1583 1612
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 768d0ee276f7..eee97bcf9802 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -407,11 +407,6 @@ static int iwl_find_otp_image(struct iwl_priv *priv,
407 return -EINVAL; 407 return -EINVAL;
408} 408}
409 409
410const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
411{
412 return priv->cfg->ops->lib->eeprom_ops.query_addr(priv, offset);
413}
414
415u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset) 410u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset)
416{ 411{
417 if (!priv->eeprom) 412 if (!priv->eeprom)
@@ -449,7 +444,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
449 } 444 }
450 e = (__le16 *)priv->eeprom; 445 e = (__le16 *)priv->eeprom;
451 446
452 priv->cfg->ops->lib->apm_ops.init(priv); 447 iwl_apm_init(priv);
453 448
454 ret = iwl_eeprom_verify_signature(priv); 449 ret = iwl_eeprom_verify_signature(priv);
455 if (ret < 0) { 450 if (ret < 0) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 804f910c651e..e4bf8ac5e64e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -292,7 +292,6 @@ extern const u8 iwl_eeprom_band_1[14];
292 292
293struct iwl_eeprom_ops { 293struct iwl_eeprom_ops {
294 const u32 regulatory_bands[7]; 294 const u32 regulatory_bands[7];
295 const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset);
296 void (*update_enhanced_txpower) (struct iwl_priv *priv); 295 void (*update_enhanced_txpower) (struct iwl_priv *priv);
297}; 296};
298 297
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index 6dfa806aefec..0ad60b3c04db 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -326,7 +326,7 @@
326#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60) 326#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60)
327 327
328/* Find Control/Status reg for given Tx DMA/FIFO channel */ 328/* Find Control/Status reg for given Tx DMA/FIFO channel */
329#define FH50_TCSR_CHNL_NUM (8) 329#define FH_TCSR_CHNL_NUM (8)
330 330
331/* TCSR: tx_config register values */ 331/* TCSR: tx_config register values */
332#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ 332#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 107b38e2ee93..6cff8c165ce9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -143,9 +143,6 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
143{ 143{
144 int ret; 144 int ret;
145 145
146 if (WARN_ON(!(cmd->flags & CMD_ASYNC)))
147 return -EINVAL;
148
149 /* An asynchronous command can not expect an SKB to be set. */ 146 /* An asynchronous command can not expect an SKB to be set. */
150 if (WARN_ON(cmd->flags & CMD_WANT_SKB)) 147 if (WARN_ON(cmd->flags & CMD_WANT_SKB))
151 return -EINVAL; 148 return -EINVAL;
@@ -166,16 +163,13 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
166 return 0; 163 return 0;
167} 164}
168 165
169int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) 166static int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
170{ 167{
171 int cmd_idx; 168 int cmd_idx;
172 int ret; 169 int ret;
173 170
174 lockdep_assert_held(&priv->mutex); 171 lockdep_assert_held(&priv->mutex);
175 172
176 if (WARN_ON(cmd->flags & CMD_ASYNC))
177 return -EINVAL;
178
179 /* A synchronous command can not have a callback set. */ 173 /* A synchronous command can not have a callback set. */
180 if (WARN_ON(cmd->callback)) 174 if (WARN_ON(cmd->callback))
181 return -EINVAL; 175 return -EINVAL;
@@ -263,31 +257,15 @@ int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
263 return iwl_send_cmd_sync(priv, cmd); 257 return iwl_send_cmd_sync(priv, cmd);
264} 258}
265 259
266int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len, const void *data) 260int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
267{ 261 const void *data)
268 struct iwl_host_cmd cmd = {
269 .id = id,
270 .len = { len, },
271 .data = { data, },
272 };
273
274 return iwl_send_cmd_sync(priv, &cmd);
275}
276
277int iwl_send_cmd_pdu_async(struct iwl_priv *priv,
278 u8 id, u16 len, const void *data,
279 void (*callback)(struct iwl_priv *priv,
280 struct iwl_device_cmd *cmd,
281 struct iwl_rx_packet *pkt))
282{ 262{
283 struct iwl_host_cmd cmd = { 263 struct iwl_host_cmd cmd = {
284 .id = id, 264 .id = id,
285 .len = { len, }, 265 .len = { len, },
286 .data = { data, }, 266 .data = { data, },
267 .flags = flags,
287 }; 268 };
288 269
289 cmd.flags |= CMD_ASYNC; 270 return iwl_send_cmd(priv, &cmd);
290 cmd.callback = callback;
291
292 return iwl_send_cmd_async(priv, &cmd);
293} 271}
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index ff08da099754..60e4169f25e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -40,6 +40,7 @@
40#include "iwl-core.h" 40#include "iwl-core.h"
41#include "iwl-agn.h" 41#include "iwl-agn.h"
42#include "iwl-io.h" 42#include "iwl-io.h"
43#include "iwl-trans.h"
43 44
44/* Throughput OFF time(ms) ON time (ms) 45/* Throughput OFF time(ms) ON time (ms)
45 * >300 25 25 46 * >300 25 25
@@ -111,7 +112,7 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
111 if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) 112 if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
112 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); 113 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
113 114
114 return iwl_send_cmd(priv, &cmd); 115 return trans_send_cmd(priv, &cmd);
115} 116}
116 117
117/* Set led pattern command */ 118/* Set led pattern command */
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 565e57e48be8..64ff40ae1026 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -42,6 +42,7 @@
42#include "iwl-commands.h" 42#include "iwl-commands.h"
43#include "iwl-debug.h" 43#include "iwl-debug.h"
44#include "iwl-power.h" 44#include "iwl-power.h"
45#include "iwl-trans.h"
45 46
46/* 47/*
47 * Setting power level allows the card to go to sleep when not busy. 48 * Setting power level allows the card to go to sleep when not busy.
@@ -334,7 +335,7 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
334 le32_to_cpu(cmd->sleep_interval[3]), 335 le32_to_cpu(cmd->sleep_interval[3]),
335 le32_to_cpu(cmd->sleep_interval[4])); 336 le32_to_cpu(cmd->sleep_interval[4]));
336 337
337 return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD, 338 return trans_send_cmd_pdu(priv, POWER_TABLE_CMD, CMD_SYNC,
338 sizeof(struct iwl_powertable_cmd), cmd); 339 sizeof(struct iwl_powertable_cmd), cmd);
339} 340}
340 341
@@ -405,9 +406,9 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
405 if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)) 406 if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
406 clear_bit(STATUS_POWER_PMI, &priv->status); 407 clear_bit(STATUS_POWER_PMI, &priv->status);
407 408
408 if (priv->cfg->ops->lib->update_chain_flags && update_chains) 409 if (update_chains)
409 priv->cfg->ops->lib->update_chain_flags(priv); 410 iwl_update_chain_flags(priv);
410 else if (priv->cfg->ops->lib->update_chain_flags) 411 else
411 IWL_DEBUG_POWER(priv, 412 IWL_DEBUG_POWER(priv,
412 "Cannot update the power, chain noise " 413 "Cannot update the power, chain noise "
413 "calibration running: %d\n", 414 "calibration running: %d\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 87148bb3f628..f3f3efe38ce2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -624,8 +624,8 @@ static void iwl_rx_statistics(struct iwl_priv *priv,
624 iwl_rx_calc_noise(priv); 624 iwl_rx_calc_noise(priv);
625 queue_work(priv->workqueue, &priv->run_time_calib_work); 625 queue_work(priv->workqueue, &priv->run_time_calib_work);
626 } 626 }
627 if (priv->cfg->ops->lib->temp_ops.temperature && change) 627 if (priv->cfg->ops->lib->temperature && change)
628 priv->cfg->ops->lib->temp_ops.temperature(priv); 628 priv->cfg->ops->lib->temperature(priv);
629} 629}
630 630
631static void iwl_rx_reply_statistics(struct iwl_priv *priv, 631static void iwl_rx_reply_statistics(struct iwl_priv *priv,
@@ -902,6 +902,47 @@ static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
902 return decrypt_out; 902 return decrypt_out;
903} 903}
904 904
905/* Calc max signal level (dBm) among 3 possible receivers */
906static int iwlagn_calc_rssi(struct iwl_priv *priv,
907 struct iwl_rx_phy_res *rx_resp)
908{
909 /* data from PHY/DSP regarding signal strength, etc.,
910 * contents are always there, not configurable by host
911 */
912 struct iwlagn_non_cfg_phy *ncphy =
913 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
914 u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
915 u8 agc;
916
917 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
918 agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
919
920 /* Find max rssi among 3 possible receivers.
921 * These values are measured by the digital signal processor (DSP).
922 * They should stay fairly constant even as the signal strength varies,
923 * if the radio's automatic gain control (AGC) is working right.
924 * AGC value (see below) will provide the "interesting" info.
925 */
926 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
927 rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
928 IWLAGN_OFDM_RSSI_A_BIT_POS;
929 rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
930 IWLAGN_OFDM_RSSI_B_BIT_POS;
931 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
932 rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
933 IWLAGN_OFDM_RSSI_C_BIT_POS;
934
935 max_rssi = max_t(u32, rssi_a, rssi_b);
936 max_rssi = max_t(u32, max_rssi, rssi_c);
937
938 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
939 rssi_a, rssi_b, rssi_c, max_rssi, agc);
940
941 /* dBm = max_rssi dB - agc dB - constant.
942 * Higher AGC (higher radio gain) means lower signal. */
943 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
944}
945
905/* Called for REPLY_RX (legacy ABG frames), or 946/* Called for REPLY_RX (legacy ABG frames), or
906 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ 947 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
907static void iwl_rx_reply_rx(struct iwl_priv *priv, 948static void iwl_rx_reply_rx(struct iwl_priv *priv,
@@ -983,7 +1024,7 @@ static void iwl_rx_reply_rx(struct iwl_priv *priv,
983 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); 1024 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);
984 1025
985 /* Find max signal strength (dBm) among 3 antenna/receiver chains */ 1026 /* Find max signal strength (dBm) among 3 antenna/receiver chains */
986 rx_status.signal = priv->cfg->ops->utils->calc_rssi(priv, phy_res); 1027 rx_status.signal = iwlagn_calc_rssi(priv, phy_res);
987 1028
988 iwl_dbg_log_rx_data_frame(priv, len, header); 1029 iwl_dbg_log_rx_data_frame(priv, len, header);
989 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", 1030 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 438eecd87335..f6ebe29eb790 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -37,6 +37,7 @@
37#include "iwl-io.h" 37#include "iwl-io.h"
38#include "iwl-helpers.h" 38#include "iwl-helpers.h"
39#include "iwl-agn.h" 39#include "iwl-agn.h"
40#include "iwl-trans.h"
40 41
41/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 42/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
42 * sending probe req. This should be set long enough to hear probe responses 43 * sending probe req. This should be set long enough to hear probe responses
@@ -61,7 +62,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
61 struct iwl_rx_packet *pkt; 62 struct iwl_rx_packet *pkt;
62 struct iwl_host_cmd cmd = { 63 struct iwl_host_cmd cmd = {
63 .id = REPLY_SCAN_ABORT_CMD, 64 .id = REPLY_SCAN_ABORT_CMD,
64 .flags = CMD_WANT_SKB, 65 .flags = CMD_SYNC | CMD_WANT_SKB,
65 }; 66 };
66 67
67 /* Exit instantly with error when device is not ready 68 /* Exit instantly with error when device is not ready
@@ -74,7 +75,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
74 test_bit(STATUS_EXIT_PENDING, &priv->status)) 75 test_bit(STATUS_EXIT_PENDING, &priv->status))
75 return -EIO; 76 return -EIO;
76 77
77 ret = iwl_send_cmd_sync(priv, &cmd); 78 ret = trans_send_cmd(priv, &cmd);
78 if (ret) 79 if (ret)
79 return ret; 80 return ret;
80 81
@@ -349,9 +350,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
349 350
350 lockdep_assert_held(&priv->mutex); 351 lockdep_assert_held(&priv->mutex);
351 352
352 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
353 return -EOPNOTSUPP;
354
355 cancel_delayed_work(&priv->scan_check); 353 cancel_delayed_work(&priv->scan_check);
356 354
357 if (!iwl_is_ready_rf(priv)) { 355 if (!iwl_is_ready_rf(priv)) {
@@ -380,7 +378,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
380 priv->scan_start = jiffies; 378 priv->scan_start = jiffies;
381 priv->scan_band = band; 379 priv->scan_band = band;
382 380
383 ret = priv->cfg->ops->utils->request_scan(priv, vif); 381 ret = iwlagn_request_scan(priv, vif);
384 if (ret) { 382 if (ret) {
385 clear_bit(STATUS_SCANNING, &priv->status); 383 clear_bit(STATUS_SCANNING, &priv->status);
386 priv->scan_type = IWL_SCAN_NORMAL; 384 priv->scan_type = IWL_SCAN_NORMAL;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 7df2814fd4f8..65386e575b1c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -35,6 +35,8 @@
35#include "iwl-dev.h" 35#include "iwl-dev.h"
36#include "iwl-core.h" 36#include "iwl-core.h"
37#include "iwl-sta.h" 37#include "iwl-sta.h"
38#include "iwl-trans.h"
39#include "iwl-agn.h"
38 40
39/* priv->sta_lock must be held */ 41/* priv->sta_lock must be held */
40static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) 42static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
@@ -132,6 +134,16 @@ static void iwl_add_sta_callback(struct iwl_priv *priv,
132 134
133} 135}
134 136
137static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
138{
139 u16 size = (u16)sizeof(struct iwl_addsta_cmd);
140 struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data;
141 memcpy(addsta, cmd, size);
142 /* resrved in 5000 */
143 addsta->rate_n_flags = cpu_to_le16(0);
144 return size;
145}
146
135int iwl_send_add_sta(struct iwl_priv *priv, 147int iwl_send_add_sta(struct iwl_priv *priv,
136 struct iwl_addsta_cmd *sta, u8 flags) 148 struct iwl_addsta_cmd *sta, u8 flags)
137{ 149{
@@ -155,8 +167,8 @@ int iwl_send_add_sta(struct iwl_priv *priv,
155 might_sleep(); 167 might_sleep();
156 } 168 }
157 169
158 cmd.len[0] = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); 170 cmd.len[0] = iwlagn_build_addsta_hcmd(sta, data);
159 ret = iwl_send_cmd(priv, &cmd); 171 ret = trans_send_cmd(priv, &cmd);
160 172
161 if (ret || (flags & CMD_ASYNC)) 173 if (ret || (flags & CMD_ASYNC))
162 return ret; 174 return ret;
@@ -412,7 +424,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
412 424
413 cmd.flags |= CMD_WANT_SKB; 425 cmd.flags |= CMD_WANT_SKB;
414 426
415 ret = iwl_send_cmd(priv, &cmd); 427 ret = trans_send_cmd(priv, &cmd);
416 428
417 if (ret) 429 if (ret)
418 return ret; 430 return ret;
@@ -781,7 +793,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
781 return -EINVAL; 793 return -EINVAL;
782 794
783 if (is_lq_table_valid(priv, ctx, lq)) 795 if (is_lq_table_valid(priv, ctx, lq))
784 ret = iwl_send_cmd(priv, &cmd); 796 ret = trans_send_cmd(priv, &cmd);
785 else 797 else
786 ret = -EINVAL; 798 ret = -EINVAL;
787 799
diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
index c00aa5a1b8b8..77ed1c295da4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
@@ -76,7 +76,7 @@
76#include "iwl-io.h" 76#include "iwl-io.h"
77#include "iwl-agn.h" 77#include "iwl-agn.h"
78#include "iwl-testmode.h" 78#include "iwl-testmode.h"
79 79#include "iwl-trans.h"
80 80
81/* The TLVs used in the gnl message policy between the kernel module and 81/* The TLVs used in the gnl message policy between the kernel module and
82 * user space application. iwl_testmode_gnl_msg_policy is to be carried 82 * user space application. iwl_testmode_gnl_msg_policy is to be carried
@@ -105,6 +105,7 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
105 105
106 [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, 106 [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, },
107 107
108 [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, },
108}; 109};
109 110
110/* 111/*
@@ -232,6 +233,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
232 return -ENOMSG; 233 return -ENOMSG;
233 } 234 }
234 235
236 cmd.flags = CMD_ON_DEMAND;
235 cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); 237 cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]);
236 cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); 238 cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
237 cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); 239 cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
@@ -239,7 +241,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
239 IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," 241 IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x,"
240 " len %d\n", cmd.id, cmd.flags, cmd.len[0]); 242 " len %d\n", cmd.id, cmd.flags, cmd.len[0]);
241 /* ok, let's submit the command to ucode */ 243 /* ok, let's submit the command to ucode */
242 return iwl_send_cmd(priv, &cmd); 244 return trans_send_cmd(priv, &cmd);
243} 245}
244 246
245 247
@@ -452,7 +454,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
452 "Error finding fixrate setting\n"); 454 "Error finding fixrate setting\n");
453 return -ENOMSG; 455 return -ENOMSG;
454 } 456 }
455 priv->dbg_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); 457 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
456 break; 458 break;
457 459
458 default: 460 default:
@@ -586,6 +588,42 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb,
586 return -ENOBUFS; 588 return -ENOBUFS;
587} 589}
588 590
591/*
592 * This function handles the user application switch ucode ownership.
593 *
594 * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and
595 * decide who the current owner of the uCode
596 *
597 * If the current owner is OWNERSHIP_TM, then the only host command
598 * can deliver to uCode is from testmode, all the other host commands
599 * will dropped.
600 *
601 * default driver is the owner of uCode in normal operational mode
602 *
603 * @hw: ieee80211_hw object that represents the device
604 * @tb: gnl message fields from the user space
605 */
606static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
607{
608 struct iwl_priv *priv = hw->priv;
609 u8 owner;
610
611 if (!tb[IWL_TM_ATTR_UCODE_OWNER]) {
612 IWL_DEBUG_INFO(priv, "Error finding ucode owner\n");
613 return -ENOMSG;
614 }
615
616 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
617 if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM))
618 priv->ucode_owner = owner;
619 else {
620 IWL_DEBUG_INFO(priv, "Invalid owner\n");
621 return -EINVAL;
622 }
623 return 0;
624}
625
626
589/* The testmode gnl message handler that takes the gnl message from the 627/* The testmode gnl message handler that takes the gnl message from the
590 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then 628 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then
591 * invoke the corresponding handlers. 629 * invoke the corresponding handlers.
@@ -607,7 +645,7 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb,
607 */ 645 */
608int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) 646int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
609{ 647{
610 struct nlattr *tb[IWL_TM_ATTR_MAX - 1]; 648 struct nlattr *tb[IWL_TM_ATTR_MAX];
611 struct iwl_priv *priv = hw->priv; 649 struct iwl_priv *priv = hw->priv;
612 int result; 650 int result;
613 651
@@ -655,6 +693,11 @@ int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
655 result = iwl_testmode_trace(hw, tb); 693 result = iwl_testmode_trace(hw, tb);
656 break; 694 break;
657 695
696 case IWL_TM_CMD_APP2DEV_OWNERSHIP:
697 IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n");
698 result = iwl_testmode_ownership(hw, tb);
699 break;
700
658 default: 701 default:
659 IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); 702 IWL_DEBUG_INFO(priv, "Unknown testmode command\n");
660 result = -ENOSYS; 703 result = -ENOSYS;
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h
index d825188e5215..b980bda4b0f8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-testmode.h
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h
@@ -103,6 +103,10 @@
103 * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: 103 * @IWL_TM_CMD_DEV2APP_EEPROM_RSP:
104 * commands from kernel space to carry the eeprom response 104 * commands from kernel space to carry the eeprom response
105 * to user application 105 * to user application
106 * @IWL_TM_CMD_APP2DEV_OWNERSHIP:
107 * commands from user application to own change the ownership of the uCode
108 * if application has the ownership, the only host command from
109 * testmode will deliver to uCode. Default owner is driver
106 */ 110 */
107enum iwl_tm_cmd_t { 111enum iwl_tm_cmd_t {
108 IWL_TM_CMD_APP2DEV_UCODE = 1, 112 IWL_TM_CMD_APP2DEV_UCODE = 1,
@@ -121,7 +125,8 @@ enum iwl_tm_cmd_t {
121 IWL_TM_CMD_DEV2APP_SYNC_RSP = 14, 125 IWL_TM_CMD_DEV2APP_SYNC_RSP = 14,
122 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15, 126 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15,
123 IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16, 127 IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16,
124 IWL_TM_CMD_MAX = 17, 128 IWL_TM_CMD_APP2DEV_OWNERSHIP = 17,
129 IWL_TM_CMD_MAX = 18,
125}; 130};
126 131
127/* 132/*
@@ -187,6 +192,10 @@ enum iwl_tm_cmd_t {
187 * The mandatory fields are: 192 * The mandatory fields are:
188 * IWL_TM_ATTR_FIXRATE for the fixed rate 193 * IWL_TM_ATTR_FIXRATE for the fixed rate
189 * 194 *
195 * @IWL_TM_ATTR_UCODE_OWNER:
196 * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_OWNERSHIP,
197 * The mandatory fields are:
198 * IWL_TM_ATTR_UCODE_OWNER for the new owner
190 */ 199 */
191enum iwl_tm_attr_t { 200enum iwl_tm_attr_t {
192 IWL_TM_ATTR_NOT_APPLICABLE = 0, 201 IWL_TM_ATTR_NOT_APPLICABLE = 0,
@@ -203,7 +212,8 @@ enum iwl_tm_attr_t {
203 IWL_TM_ATTR_TRACE_SIZE = 11, 212 IWL_TM_ATTR_TRACE_SIZE = 11,
204 IWL_TM_ATTR_TRACE_DUMP = 12, 213 IWL_TM_ATTR_TRACE_DUMP = 12,
205 IWL_TM_ATTR_FIXRATE = 13, 214 IWL_TM_ATTR_FIXRATE = 13,
206 IWL_TM_ATTR_MAX = 14, 215 IWL_TM_ATTR_UCODE_OWNER = 14,
216 IWL_TM_ATTR_MAX = 15,
207}; 217};
208 218
209/* uCode trace buffer */ 219/* uCode trace buffer */
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index 7b7b97d8c2e1..d760857c8636 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -66,6 +66,7 @@
66#include "iwl-helpers.h" 66#include "iwl-helpers.h"
67/*TODO remove uneeded includes when the transport layer tx_free will be here */ 67/*TODO remove uneeded includes when the transport layer tx_free will be here */
68#include "iwl-agn.h" 68#include "iwl-agn.h"
69#include "iwl-core.h"
69 70
70static int iwl_trans_rx_alloc(struct iwl_priv *priv) 71static int iwl_trans_rx_alloc(struct iwl_priv *priv)
71{ 72{
@@ -188,7 +189,15 @@ static void iwl_trans_rx_free(struct iwl_priv *priv)
188 rxq->rb_stts = NULL; 189 rxq->rb_stts = NULL;
189} 190}
190 191
191/* TODO:remove this code duplication */ 192static int iwl_trans_rx_stop(struct iwl_priv *priv)
193{
194
195 /* stop Rx DMA */
196 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
197 return iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG,
198 FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
199}
200
192static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv, 201static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv,
193 struct iwl_dma_ptr *ptr, size_t size) 202 struct iwl_dma_ptr *ptr, size_t size)
194{ 203{
@@ -203,6 +212,16 @@ static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv,
203 return 0; 212 return 0;
204} 213}
205 214
215static inline void iwlagn_free_dma_ptr(struct iwl_priv *priv,
216 struct iwl_dma_ptr *ptr)
217{
218 if (unlikely(!ptr->addr))
219 return;
220
221 dma_free_coherent(priv->bus.dev, ptr->size, ptr->addr, ptr->dma);
222 memset(ptr, 0, sizeof(*ptr));
223}
224
206static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq, 225static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq,
207 int slots_num, u32 txq_id) 226 int slots_num, u32 txq_id)
208{ 227{
@@ -212,6 +231,8 @@ static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq,
212 if (WARN_ON(txq->meta || txq->cmd || txq->txb || txq->tfds)) 231 if (WARN_ON(txq->meta || txq->cmd || txq->txb || txq->tfds))
213 return -EINVAL; 232 return -EINVAL;
214 233
234 txq->q.n_window = slots_num;
235
215 txq->meta = kzalloc(sizeof(txq->meta[0]) * slots_num, 236 txq->meta = kzalloc(sizeof(txq->meta[0]) * slots_num,
216 GFP_KERNEL); 237 GFP_KERNEL);
217 txq->cmd = kzalloc(sizeof(txq->cmd[0]) * slots_num, 238 txq->cmd = kzalloc(sizeof(txq->cmd[0]) * slots_num,
@@ -307,6 +328,90 @@ static int iwl_trans_txq_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
307} 328}
308 329
309/** 330/**
331 * iwl_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's
332 */
333static void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id)
334{
335 struct iwl_tx_queue *txq = &priv->txq[txq_id];
336 struct iwl_queue *q = &txq->q;
337
338 if (!q->n_bd)
339 return;
340
341 while (q->write_ptr != q->read_ptr) {
342 /* The read_ptr needs to bound by q->n_window */
343 iwlagn_txq_free_tfd(priv, txq, get_cmd_index(q, q->read_ptr));
344 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
345 }
346}
347
348/**
349 * iwl_tx_queue_free - Deallocate DMA queue.
350 * @txq: Transmit queue to deallocate.
351 *
352 * Empty queue by removing and destroying all BD's.
353 * Free all buffers.
354 * 0-fill, but do not free "txq" descriptor structure.
355 */
356static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
357{
358 struct iwl_tx_queue *txq = &priv->txq[txq_id];
359 struct device *dev = priv->bus.dev;
360 int i;
361 if (WARN_ON(!txq))
362 return;
363
364 iwl_tx_queue_unmap(priv, txq_id);
365
366 /* De-alloc array of command/tx buffers */
367 for (i = 0; i < txq->q.n_window; i++)
368 kfree(txq->cmd[i]);
369
370 /* De-alloc circular buffer of TFDs */
371 if (txq->q.n_bd) {
372 dma_free_coherent(dev, priv->hw_params.tfd_size *
373 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
374 memset(&txq->q.dma_addr, 0, sizeof(txq->q.dma_addr));
375 }
376
377 /* De-alloc array of per-TFD driver data */
378 kfree(txq->txb);
379 txq->txb = NULL;
380
381 /* deallocate arrays */
382 kfree(txq->cmd);
383 kfree(txq->meta);
384 txq->cmd = NULL;
385 txq->meta = NULL;
386
387 /* 0-fill queue descriptor structure */
388 memset(txq, 0, sizeof(*txq));
389}
390
391/**
392 * iwl_trans_tx_free - Free TXQ Context
393 *
394 * Destroy all TX DMA queues and structures
395 */
396static void iwl_trans_tx_free(struct iwl_priv *priv)
397{
398 int txq_id;
399
400 /* Tx queues */
401 if (priv->txq) {
402 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
403 iwl_tx_queue_free(priv, txq_id);
404 }
405
406 kfree(priv->txq);
407 priv->txq = NULL;
408
409 iwlagn_free_dma_ptr(priv, &priv->kw);
410
411 iwlagn_free_dma_ptr(priv, &priv->scd_bc_tbls);
412}
413
414/**
310 * iwl_trans_tx_alloc - allocate TX context 415 * iwl_trans_tx_alloc - allocate TX context
311 * Allocate all Tx DMA structures and initialize them 416 * Allocate all Tx DMA structures and initialize them
312 * 417 *
@@ -362,7 +467,7 @@ static int iwl_trans_tx_alloc(struct iwl_priv *priv)
362 return 0; 467 return 0;
363 468
364error: 469error:
365 iwlagn_hw_txq_ctx_free(priv); 470 trans_tx_free(priv);
366 471
367 return ret; 472 return ret;
368} 473}
@@ -406,15 +511,58 @@ static int iwl_trans_tx_init(struct iwl_priv *priv)
406error: 511error:
407 /*Upon error, free only if we allocated something */ 512 /*Upon error, free only if we allocated something */
408 if (alloc) 513 if (alloc)
409 iwlagn_hw_txq_ctx_free(priv); 514 trans_tx_free(priv);
410 return ret; 515 return ret;
411} 516}
412 517
518/**
519 * iwlagn_txq_ctx_stop - Stop all Tx DMA channels
520 */
521static int iwl_trans_tx_stop(struct iwl_priv *priv)
522{
523 int ch, txq_id;
524 unsigned long flags;
525
526 /* Turn off all Tx DMA fifos */
527 spin_lock_irqsave(&priv->lock, flags);
528
529 iwlagn_txq_set_sched(priv, 0);
530
531 /* Stop each Tx DMA channel, and wait for it to be idle */
532 for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) {
533 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0);
534 if (iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG,
535 FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch),
536 1000))
537 IWL_ERR(priv, "Failing on timeout while stopping"
538 " DMA channel %d [0x%08x]", ch,
539 iwl_read_direct32(priv, FH_TSSR_TX_STATUS_REG));
540 }
541 spin_unlock_irqrestore(&priv->lock, flags);
542
543 if (!priv->txq) {
544 IWL_WARN(priv, "Stopping tx queues that aren't allocated...");
545 return 0;
546 }
547
548 /* Unmap DMA from host system and free skb's */
549 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
550 iwl_tx_queue_unmap(priv, txq_id);
551
552 return 0;
553}
554
413static const struct iwl_trans_ops trans_ops = { 555static const struct iwl_trans_ops trans_ops = {
414 .rx_init = iwl_trans_rx_init, 556 .rx_init = iwl_trans_rx_init,
557 .rx_stop = iwl_trans_rx_stop,
415 .rx_free = iwl_trans_rx_free, 558 .rx_free = iwl_trans_rx_free,
416 559
417 .tx_init = iwl_trans_tx_init, 560 .tx_init = iwl_trans_tx_init,
561 .tx_stop = iwl_trans_tx_stop,
562 .tx_free = iwl_trans_tx_free,
563
564 .send_cmd = iwl_send_cmd,
565 .send_cmd_pdu = iwl_send_cmd_pdu,
418}; 566};
419 567
420void iwl_trans_register(struct iwl_trans *trans) 568void iwl_trans_register(struct iwl_trans *trans)
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index bec494c5a979..111acca07d75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -60,5 +60,46 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63static inline int trans_rx_init(struct iwl_priv *priv)
64{
65 return priv->trans.ops->rx_init(priv);
66}
67
68static inline int trans_rx_stop(struct iwl_priv *priv)
69{
70 return priv->trans.ops->rx_stop(priv);
71}
72
73static inline void trans_rx_free(struct iwl_priv *priv)
74{
75 priv->trans.ops->rx_free(priv);
76}
77
78static inline int trans_tx_init(struct iwl_priv *priv)
79{
80 return priv->trans.ops->tx_init(priv);
81}
82
83static inline int trans_tx_stop(struct iwl_priv *priv)
84{
85 return priv->trans.ops->tx_stop(priv);
86}
87
88static inline void trans_tx_free(struct iwl_priv *priv)
89{
90 priv->trans.ops->tx_free(priv);
91}
92
93static inline int trans_send_cmd(struct iwl_priv *priv,
94 struct iwl_host_cmd *cmd)
95{
96 return priv->trans.ops->send_cmd(priv, cmd);
97}
98
99static inline int trans_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags,
100 u16 len, const void *data)
101{
102 return priv->trans.ops->send_cmd_pdu(priv, id, flags, len, data);
103}
63 104
64void iwl_trans_register(struct iwl_trans *trans); 105void iwl_trans_register(struct iwl_trans *trans);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index db5abaa2ff7e..9b07e07f1689 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -157,14 +157,15 @@ static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta,
157 * iwlagn_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] 157 * iwlagn_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
158 * @priv - driver private data 158 * @priv - driver private data
159 * @txq - tx queue 159 * @txq - tx queue
160 * @index - the index of the TFD to be freed
160 * 161 *
161 * Does NOT advance any TFD circular buffer read/write indexes 162 * Does NOT advance any TFD circular buffer read/write indexes
162 * Does NOT free the TFD itself (which is within circular buffer) 163 * Does NOT free the TFD itself (which is within circular buffer)
163 */ 164 */
164void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) 165void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
166 int index)
165{ 167{
166 struct iwl_tfd *tfd_tmp = txq->tfds; 168 struct iwl_tfd *tfd_tmp = txq->tfds;
167 int index = txq->q.read_ptr;
168 169
169 iwlagn_unmap_tfd(priv, &txq->meta[index], &tfd_tmp[index], 170 iwlagn_unmap_tfd(priv, &txq->meta[index], &tfd_tmp[index],
170 DMA_TO_DEVICE); 171 DMA_TO_DEVICE);
@@ -173,12 +174,12 @@ void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
173 if (txq->txb) { 174 if (txq->txb) {
174 struct sk_buff *skb; 175 struct sk_buff *skb;
175 176
176 skb = txq->txb[txq->q.read_ptr].skb; 177 skb = txq->txb[index].skb;
177 178
178 /* can be called from irqs-disabled context */ 179 /* can be called from irqs-disabled context */
179 if (skb) { 180 if (skb) {
180 dev_kfree_skb_any(skb); 181 dev_kfree_skb_any(skb);
181 txq->txb[txq->q.read_ptr].skb = NULL; 182 txq->txb[index].skb = NULL;
182 } 183 }
183 } 184 }
184} 185}
@@ -220,122 +221,6 @@ int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
220 return 0; 221 return 0;
221} 222}
222 223
223/**
224 * iwl_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's
225 */
226void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id)
227{
228 struct iwl_tx_queue *txq = &priv->txq[txq_id];
229 struct iwl_queue *q = &txq->q;
230
231 if (q->n_bd == 0)
232 return;
233
234 while (q->write_ptr != q->read_ptr) {
235 iwlagn_txq_free_tfd(priv, txq);
236 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
237 }
238}
239
240/**
241 * iwl_tx_queue_free - Deallocate DMA queue.
242 * @txq: Transmit queue to deallocate.
243 *
244 * Empty queue by removing and destroying all BD's.
245 * Free all buffers.
246 * 0-fill, but do not free "txq" descriptor structure.
247 */
248void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
249{
250 struct iwl_tx_queue *txq = &priv->txq[txq_id];
251 struct device *dev = priv->bus.dev;
252 int i;
253
254 iwl_tx_queue_unmap(priv, txq_id);
255
256 /* De-alloc array of command/tx buffers */
257 for (i = 0; i < TFD_TX_CMD_SLOTS; i++)
258 kfree(txq->cmd[i]);
259
260 /* De-alloc circular buffer of TFDs */
261 if (txq->q.n_bd)
262 dma_free_coherent(dev, priv->hw_params.tfd_size *
263 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
264
265 /* De-alloc array of per-TFD driver data */
266 kfree(txq->txb);
267 txq->txb = NULL;
268
269 /* deallocate arrays */
270 kfree(txq->cmd);
271 kfree(txq->meta);
272 txq->cmd = NULL;
273 txq->meta = NULL;
274
275 /* 0-fill queue descriptor structure */
276 memset(txq, 0, sizeof(*txq));
277}
278
279/**
280 * iwl_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue
281 */
282void iwl_cmd_queue_unmap(struct iwl_priv *priv)
283{
284 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
285 struct iwl_queue *q = &txq->q;
286 int i;
287
288 if (q->n_bd == 0)
289 return;
290
291 while (q->read_ptr != q->write_ptr) {
292 i = get_cmd_index(q, q->read_ptr);
293
294 if (txq->meta[i].flags & CMD_MAPPED) {
295 iwlagn_unmap_tfd(priv, &txq->meta[i], &txq->tfds[i],
296 DMA_BIDIRECTIONAL);
297 txq->meta[i].flags = 0;
298 }
299
300 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
301 }
302}
303
304/**
305 * iwl_cmd_queue_free - Deallocate DMA queue.
306 * @txq: Transmit queue to deallocate.
307 *
308 * Empty queue by removing and destroying all BD's.
309 * Free all buffers.
310 * 0-fill, but do not free "txq" descriptor structure.
311 */
312void iwl_cmd_queue_free(struct iwl_priv *priv)
313{
314 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
315 struct device *dev = priv->bus.dev;
316 int i;
317
318 iwl_cmd_queue_unmap(priv);
319
320 /* De-alloc array of command/tx buffers */
321 for (i = 0; i < TFD_CMD_SLOTS; i++)
322 kfree(txq->cmd[i]);
323
324 /* De-alloc circular buffer of TFDs */
325 if (txq->q.n_bd)
326 dma_free_coherent(dev, priv->hw_params.tfd_size * txq->q.n_bd,
327 txq->tfds, txq->q.dma_addr);
328
329 /* deallocate arrays */
330 kfree(txq->cmd);
331 kfree(txq->meta);
332 txq->cmd = NULL;
333 txq->meta = NULL;
334
335 /* 0-fill queue descriptor structure */
336 memset(txq, 0, sizeof(*txq));
337}
338
339/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 224/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
340 * DMA services 225 * DMA services
341 * 226 *
@@ -443,6 +328,12 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
443 return -EIO; 328 return -EIO;
444 } 329 }
445 330
331 if ((priv->ucode_owner == IWL_OWNERSHIP_TM) &&
332 !(cmd->flags & CMD_ON_DEMAND)) {
333 IWL_DEBUG_HC(priv, "tm own the uCode, no regular hcmd send\n");
334 return -EIO;
335 }
336
446 copy_size = sizeof(out_cmd->hdr); 337 copy_size = sizeof(out_cmd->hdr);
447 cmd_size = sizeof(out_cmd->hdr); 338 cmd_size = sizeof(out_cmd->hdr);
448 339
@@ -496,11 +387,6 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
496 out_cmd = txq->cmd[idx]; 387 out_cmd = txq->cmd[idx];
497 out_meta = &txq->meta[idx]; 388 out_meta = &txq->meta[idx];
498 389
499 if (WARN_ON(out_meta->flags & CMD_MAPPED)) {
500 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
501 return -ENOSPC;
502 }
503
504 memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ 390 memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */
505 if (cmd->flags & CMD_WANT_SKB) 391 if (cmd->flags & CMD_WANT_SKB)
506 out_meta->source = cmd; 392 out_meta->source = cmd;
@@ -574,7 +460,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
574#endif 460#endif
575 } 461 }
576 462
577 out_meta->flags = cmd->flags | CMD_MAPPED; 463 out_meta->flags = cmd->flags;
578 464
579 txq->need_update = 1; 465 txq->need_update = 1;
580 466
@@ -684,7 +570,6 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
684 wake_up_interruptible(&priv->wait_command_queue); 570 wake_up_interruptible(&priv->wait_command_queue);
685 } 571 }
686 572
687 /* Mark as unmapped */
688 meta->flags = 0; 573 meta->flags = 0;
689 574
690 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 575 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 9dcf967e1ee4..dbd24a4607ec 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -874,6 +874,7 @@ int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value)
874 memset(&cmd, 0, sizeof(cmd)); 874 memset(&cmd, 0, sizeof(cmd));
875 cmd.hdr.size = cpu_to_le16(sizeof(cmd)); 875 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
876 cmd.action = cpu_to_le16(CMD_ACT_GET); 876 cmd.action = cpu_to_le16(CMD_ACT_GET);
877 cmd.offset = cpu_to_le16(offset);
877 878
878 if (reg != CMD_MAC_REG_ACCESS && 879 if (reg != CMD_MAC_REG_ACCESS &&
879 reg != CMD_BBP_REG_ACCESS && 880 reg != CMD_BBP_REG_ACCESS &&
@@ -883,7 +884,7 @@ int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value)
883 } 884 }
884 885
885 ret = lbs_cmd_with_response(priv, reg, &cmd); 886 ret = lbs_cmd_with_response(priv, reg, &cmd);
886 if (ret) { 887 if (!ret) {
887 if (reg == CMD_BBP_REG_ACCESS || reg == CMD_RF_REG_ACCESS) 888 if (reg == CMD_BBP_REG_ACCESS || reg == CMD_RF_REG_ACCESS)
888 *value = cmd.value.bbp_rf; 889 *value = cmd.value.bbp_rf;
889 else if (reg == CMD_MAC_REG_ACCESS) 890 else if (reg == CMD_MAC_REG_ACCESS)
@@ -916,6 +917,7 @@ int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value)
916 memset(&cmd, 0, sizeof(cmd)); 917 memset(&cmd, 0, sizeof(cmd));
917 cmd.hdr.size = cpu_to_le16(sizeof(cmd)); 918 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
918 cmd.action = cpu_to_le16(CMD_ACT_SET); 919 cmd.action = cpu_to_le16(CMD_ACT_SET);
920 cmd.offset = cpu_to_le16(offset);
919 921
920 if (reg == CMD_BBP_REG_ACCESS || reg == CMD_RF_REG_ACCESS) 922 if (reg == CMD_BBP_REG_ACCESS || reg == CMD_RF_REG_ACCESS)
921 cmd.value.bbp_rf = (u8) (value & 0xFF); 923 cmd.value.bbp_rf = (u8) (value & 0xFF);
@@ -1068,16 +1070,34 @@ static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
1068 spin_unlock_irqrestore(&priv->driver_lock, flags); 1070 spin_unlock_irqrestore(&priv->driver_lock, flags);
1069} 1071}
1070 1072
1071void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd, 1073void __lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
1072 int result) 1074 int result)
1073{ 1075{
1076 /*
1077 * Normally, commands are removed from cmdpendingq before being
1078 * submitted. However, we can arrive here on alternative codepaths
1079 * where the command is still pending. Make sure the command really
1080 * isn't part of a list at this point.
1081 */
1082 list_del_init(&cmd->list);
1083
1074 cmd->result = result; 1084 cmd->result = result;
1075 cmd->cmdwaitqwoken = 1; 1085 cmd->cmdwaitqwoken = 1;
1076 wake_up_interruptible(&cmd->cmdwait_q); 1086 wake_up(&cmd->cmdwait_q);
1077 1087
1078 if (!cmd->callback || cmd->callback == lbs_cmd_async_callback) 1088 if (!cmd->callback || cmd->callback == lbs_cmd_async_callback)
1079 __lbs_cleanup_and_insert_cmd(priv, cmd); 1089 __lbs_cleanup_and_insert_cmd(priv, cmd);
1080 priv->cur_cmd = NULL; 1090 priv->cur_cmd = NULL;
1091 wake_up_interruptible(&priv->waitq);
1092}
1093
1094void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
1095 int result)
1096{
1097 unsigned long flags;
1098 spin_lock_irqsave(&priv->driver_lock, flags);
1099 __lbs_complete_command(priv, cmd, result);
1100 spin_unlock_irqrestore(&priv->driver_lock, flags);
1081} 1101}
1082 1102
1083int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on) 1103int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
@@ -1249,7 +1269,7 @@ static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv)
1249 if (!list_empty(&priv->cmdfreeq)) { 1269 if (!list_empty(&priv->cmdfreeq)) {
1250 tempnode = list_first_entry(&priv->cmdfreeq, 1270 tempnode = list_first_entry(&priv->cmdfreeq,
1251 struct cmd_ctrl_node, list); 1271 struct cmd_ctrl_node, list);
1252 list_del(&tempnode->list); 1272 list_del_init(&tempnode->list);
1253 } else { 1273 } else {
1254 lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n"); 1274 lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n");
1255 tempnode = NULL; 1275 tempnode = NULL;
@@ -1357,10 +1377,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
1357 cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { 1377 cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) {
1358 lbs_deb_host( 1378 lbs_deb_host(
1359 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); 1379 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
1360 spin_lock_irqsave(&priv->driver_lock, flags);
1361 list_del(&cmdnode->list);
1362 lbs_complete_command(priv, cmdnode, 0); 1380 lbs_complete_command(priv, cmdnode, 0);
1363 spin_unlock_irqrestore(&priv->driver_lock, flags);
1364 1381
1365 ret = 0; 1382 ret = 0;
1366 goto done; 1383 goto done;
@@ -1370,10 +1387,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
1370 (priv->psstate == PS_STATE_PRE_SLEEP)) { 1387 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1371 lbs_deb_host( 1388 lbs_deb_host(
1372 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); 1389 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
1373 spin_lock_irqsave(&priv->driver_lock, flags);
1374 list_del(&cmdnode->list);
1375 lbs_complete_command(priv, cmdnode, 0); 1390 lbs_complete_command(priv, cmdnode, 0);
1376 spin_unlock_irqrestore(&priv->driver_lock, flags);
1377 priv->needtowakeup = 1; 1391 priv->needtowakeup = 1;
1378 1392
1379 ret = 0; 1393 ret = 0;
@@ -1385,7 +1399,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
1385 } 1399 }
1386 } 1400 }
1387 spin_lock_irqsave(&priv->driver_lock, flags); 1401 spin_lock_irqsave(&priv->driver_lock, flags);
1388 list_del(&cmdnode->list); 1402 list_del_init(&cmdnode->list);
1389 spin_unlock_irqrestore(&priv->driver_lock, flags); 1403 spin_unlock_irqrestore(&priv->driver_lock, flags);
1390 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", 1404 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
1391 le16_to_cpu(cmd->command)); 1405 le16_to_cpu(cmd->command));
@@ -1668,7 +1682,13 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
1668 } 1682 }
1669 1683
1670 might_sleep(); 1684 might_sleep();
1671 wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken); 1685
1686 /*
1687 * Be careful with signals here. A signal may be received as the system
1688 * goes into suspend or resume. We do not want this to interrupt the
1689 * command, so we perform an uninterruptible sleep.
1690 */
1691 wait_event(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken);
1672 1692
1673 spin_lock_irqsave(&priv->driver_lock, flags); 1693 spin_lock_irqsave(&priv->driver_lock, flags);
1674 ret = cmdnode->result; 1694 ret = cmdnode->result;
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 7109d6b717ea..b280ef7a0aea 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -59,6 +59,8 @@ int lbs_allocate_cmd_buffer(struct lbs_private *priv);
59int lbs_free_cmd_buffer(struct lbs_private *priv); 59int lbs_free_cmd_buffer(struct lbs_private *priv);
60 60
61int lbs_execute_next_command(struct lbs_private *priv); 61int lbs_execute_next_command(struct lbs_private *priv);
62void __lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
63 int result);
62void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd, 64void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
63 int result); 65 int result);
64int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len); 66int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len);
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 2ffe5a1ff003..178b222b3ce1 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -166,7 +166,7 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
166 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); 166 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
167 } 167 }
168 168
169 lbs_complete_command(priv, priv->cur_cmd, result); 169 __lbs_complete_command(priv, priv->cur_cmd, result);
170 spin_unlock_irqrestore(&priv->driver_lock, flags); 170 spin_unlock_irqrestore(&priv->driver_lock, flags);
171 171
172 ret = 0; 172 ret = 0;
@@ -187,7 +187,7 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
187 break; 187 break;
188 188
189 } 189 }
190 lbs_complete_command(priv, priv->cur_cmd, result); 190 __lbs_complete_command(priv, priv->cur_cmd, result);
191 spin_unlock_irqrestore(&priv->driver_lock, flags); 191 spin_unlock_irqrestore(&priv->driver_lock, flags);
192 192
193 ret = -1; 193 ret = -1;
@@ -205,7 +205,7 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
205 205
206 if (priv->cur_cmd) { 206 if (priv->cur_cmd) {
207 /* Clean up and Put current command back to cmdfreeq */ 207 /* Clean up and Put current command back to cmdfreeq */
208 lbs_complete_command(priv, priv->cur_cmd, result); 208 __lbs_complete_command(priv, priv->cur_cmd, result);
209 } 209 }
210 spin_unlock_irqrestore(&priv->driver_lock, flags); 210 spin_unlock_irqrestore(&priv->driver_lock, flags);
211 211
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index cf3d2c8e1969..c79aac4b1dae 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -639,6 +639,14 @@ static void lbs_cmd_timeout_handler(unsigned long data)
639 le16_to_cpu(priv->cur_cmd->cmdbuf->command)); 639 le16_to_cpu(priv->cur_cmd->cmdbuf->command));
640 640
641 priv->cmd_timed_out = 1; 641 priv->cmd_timed_out = 1;
642
643 /*
644 * If the device didn't even acknowledge the command, reset the state
645 * so that we don't block all future commands due to this one timeout.
646 */
647 if (priv->dnld_sent == DNLD_CMD_SENT)
648 priv->dnld_sent = DNLD_RES_RECEIVED;
649
642 wake_up_interruptible(&priv->waitq); 650 wake_up_interruptible(&priv->waitq);
643out: 651out:
644 spin_unlock_irqrestore(&priv->driver_lock, flags); 652 spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -995,7 +1003,7 @@ void lbs_stop_card(struct lbs_private *priv)
995 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) { 1003 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
996 cmdnode->result = -ENOENT; 1004 cmdnode->result = -ENOENT;
997 cmdnode->cmdwaitqwoken = 1; 1005 cmdnode->cmdwaitqwoken = 1;
998 wake_up_interruptible(&cmdnode->cmdwait_q); 1006 wake_up(&cmdnode->cmdwait_q);
999 } 1007 }
1000 1008
1001 /* Flush the command the card is currently processing */ 1009 /* Flush the command the card is currently processing */
@@ -1003,7 +1011,7 @@ void lbs_stop_card(struct lbs_private *priv)
1003 lbs_deb_main("clearing current command\n"); 1011 lbs_deb_main("clearing current command\n");
1004 priv->cur_cmd->result = -ENOENT; 1012 priv->cur_cmd->result = -ENOENT;
1005 priv->cur_cmd->cmdwaitqwoken = 1; 1013 priv->cur_cmd->cmdwaitqwoken = 1;
1006 wake_up_interruptible(&priv->cur_cmd->cmdwait_q); 1014 wake_up(&priv->cur_cmd->cmdwait_q);
1007 } 1015 }
1008 lbs_deb_main("done clearing commands\n"); 1016 lbs_deb_main("done clearing commands\n");
1009 spin_unlock_irqrestore(&priv->driver_lock, flags); 1017 spin_unlock_irqrestore(&priv->driver_lock, flags);
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 687c1f223497..352d2c5da1fc 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -672,6 +672,59 @@ static const u32 mwifiex_cipher_suites[] = {
672}; 672};
673 673
674/* 674/*
675 * CFG802.11 operation handler for setting bit rates.
676 *
677 * Function selects legacy bang B/G/BG from corresponding bitrates selection.
678 * Currently only 2.4GHz band is supported.
679 */
680static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy *wiphy,
681 struct net_device *dev,
682 const u8 *peer,
683 const struct cfg80211_bitrate_mask *mask)
684{
685 struct mwifiex_ds_band_cfg band_cfg;
686 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
687 int index = 0, mode = 0, i;
688
689 /* Currently only 2.4GHz is supported */
690 for (i = 0; i < mwifiex_band_2ghz.n_bitrates; i++) {
691 /*
692 * Rates below 6 Mbps in the table are CCK rates; 802.11b
693 * and from 6 they are OFDM; 802.11G
694 */
695 if (mwifiex_rates[i].bitrate == 60) {
696 index = 1 << i;
697 break;
698 }
699 }
700
701 if (mask->control[IEEE80211_BAND_2GHZ].legacy < index) {
702 mode = BAND_B;
703 } else {
704 mode = BAND_G;
705 if (mask->control[IEEE80211_BAND_2GHZ].legacy % index)
706 mode |= BAND_B;
707 }
708
709 memset(&band_cfg, 0, sizeof(band_cfg));
710 band_cfg.config_bands = mode;
711
712 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
713 band_cfg.adhoc_start_band = mode;
714
715 band_cfg.sec_chan_offset = NO_SEC_CHANNEL;
716
717 if (mwifiex_set_radio_band_cfg(priv, &band_cfg))
718 return -EFAULT;
719
720 wiphy_debug(wiphy, "info: device configured in 802.11%s%s mode\n",
721 (mode & BAND_B) ? "b" : "",
722 (mode & BAND_G) ? "g" : "");
723
724 return 0;
725}
726
727/*
675 * CFG802.11 operation handler for disconnection request. 728 * CFG802.11 operation handler for disconnection request.
676 * 729 *
677 * This function does not work when there is already a disconnection 730 * This function does not work when there is already a disconnection
@@ -960,7 +1013,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
960 ret = mwifiex_set_gen_ie(priv, sme->ie, sme->ie_len); 1013 ret = mwifiex_set_gen_ie(priv, sme->ie, sme->ie_len);
961 1014
962 if (sme->key) { 1015 if (sme->key) {
963 if (mwifiex_is_alg_wep(0) | mwifiex_is_alg_wep(0)) { 1016 if (mwifiex_is_alg_wep(priv->sec_info.encryption_mode)) {
964 dev_dbg(priv->adapter->dev, 1017 dev_dbg(priv->adapter->dev,
965 "info: setting wep encryption" 1018 "info: setting wep encryption"
966 " with key len %d\n", sme->key_len); 1019 " with key len %d\n", sme->key_len);
@@ -1225,6 +1278,7 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = {
1225 .set_default_key = mwifiex_cfg80211_set_default_key, 1278 .set_default_key = mwifiex_cfg80211_set_default_key,
1226 .set_power_mgmt = mwifiex_cfg80211_set_power_mgmt, 1279 .set_power_mgmt = mwifiex_cfg80211_set_power_mgmt,
1227 .set_tx_power = mwifiex_cfg80211_set_tx_power, 1280 .set_tx_power = mwifiex_cfg80211_set_tx_power,
1281 .set_bitrate_mask = mwifiex_cfg80211_set_bitrate_mask,
1228}; 1282};
1229 1283
1230/* 1284/*
diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
index 46d65e02c7ba..1bcf9eaa107d 100644
--- a/drivers/net/wireless/mwifiex/debugfs.c
+++ b/drivers/net/wireless/mwifiex/debugfs.c
@@ -27,8 +27,8 @@ static struct dentry *mwifiex_dfs_dir;
27 27
28static char *bss_modes[] = { 28static char *bss_modes[] = {
29 "Unknown", 29 "Unknown",
30 "Managed",
31 "Ad-hoc", 30 "Ad-hoc",
31 "Managed",
32 "Auto" 32 "Auto"
33}; 33};
34 34
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index 0e90b0986ed8..94ddc9038cb3 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -30,7 +30,9 @@
30 30
31#define MWIFIEX_MAX_BSS_NUM (1) 31#define MWIFIEX_MAX_BSS_NUM (1)
32 32
33#define MWIFIEX_MIN_DATA_HEADER_LEN 32 /* (sizeof(mwifiex_txpd)) */ 33#define MWIFIEX_MIN_DATA_HEADER_LEN 36 /* sizeof(mwifiex_txpd)
34 * + 4 byte alignment
35 */
34 36
35#define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED 2 37#define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED 2
36#define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED 16 38#define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED 16
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
index afdd145dff0b..4fee0993b186 100644
--- a/drivers/net/wireless/mwifiex/fw.h
+++ b/drivers/net/wireless/mwifiex/fw.h
@@ -157,6 +157,17 @@ enum MWIFIEX_802_11_WEP_STATUS {
157#define ISSUPP_RXSTBC(Dot11nDevCap) (Dot11nDevCap & BIT(26)) 157#define ISSUPP_RXSTBC(Dot11nDevCap) (Dot11nDevCap & BIT(26))
158#define ISSUPP_GREENFIELD(Dot11nDevCap) (Dot11nDevCap & BIT(29)) 158#define ISSUPP_GREENFIELD(Dot11nDevCap) (Dot11nDevCap & BIT(29))
159 159
160/* httxcfg bitmap
161 * 0 reserved
162 * 1 20/40 Mhz enable(1)/disable(0)
163 * 2-3 reserved
164 * 4 green field enable(1)/disable(0)
165 * 5 short GI in 20 Mhz enable(1)/disable(0)
166 * 6 short GI in 40 Mhz enable(1)/disable(0)
167 * 7-15 reserved
168 */
169#define MWIFIEX_FW_DEF_HTTXCFG (BIT(1) | BIT(4) | BIT(5) | BIT(6))
170
160#define GET_RXMCSSUPP(DevMCSSupported) (DevMCSSupported & 0x0f) 171#define GET_RXMCSSUPP(DevMCSSupported) (DevMCSSupported & 0x0f)
161#define SETHT_MCS32(x) (x[4] |= 1) 172#define SETHT_MCS32(x) (x[4] |= 1)
162 173
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 49b9c1309f7a..c54ee287b878 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -1113,6 +1113,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1113 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl; 1113 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1114 struct mwifiex_ds_auto_ds auto_ds; 1114 struct mwifiex_ds_auto_ds auto_ds;
1115 enum state_11d_t state_11d; 1115 enum state_11d_t state_11d;
1116 struct mwifiex_ds_11n_tx_cfg tx_cfg;
1116 1117
1117 if (first_sta) { 1118 if (first_sta) {
1118 1119
@@ -1198,8 +1199,15 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1198 if (ret) 1199 if (ret)
1199 dev_err(priv->adapter->dev, "11D: failed to enable 11D\n"); 1200 dev_err(priv->adapter->dev, "11D: failed to enable 11D\n");
1200 1201
1202 /* Send cmd to FW to configure 11n specific configuration
1203 * (Short GI, Channel BW, Green field support etc.) for transmit
1204 */
1205 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
1206 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_CFG,
1207 HostCmd_ACT_GEN_SET, 0, &tx_cfg);
1208
1201 /* set last_init_cmd */ 1209 /* set last_init_cmd */
1202 priv->adapter->last_init_cmd = HostCmd_CMD_802_11_SNMP_MIB; 1210 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;
1203 ret = -EINPROGRESS; 1211 ret = -EINPROGRESS;
1204 1212
1205 return ret; 1213 return ret;
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c
index fa6221bc9104..1822bfad8896 100644
--- a/drivers/net/wireless/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/mwifiex/sta_tx.c
@@ -47,6 +47,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
47 struct mwifiex_adapter *adapter = priv->adapter; 47 struct mwifiex_adapter *adapter = priv->adapter;
48 struct txpd *local_tx_pd; 48 struct txpd *local_tx_pd;
49 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); 49 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb);
50 u8 pad;
50 51
51 if (!skb->len) { 52 if (!skb->len) {
52 dev_err(adapter->dev, "Tx: bad packet length: %d\n", 53 dev_err(adapter->dev, "Tx: bad packet length: %d\n",
@@ -55,15 +56,19 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
55 return skb->data; 56 return skb->data;
56 } 57 }
57 58
58 BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN)); 59 /* If skb->data is not aligned; add padding */
59 skb_push(skb, sizeof(*local_tx_pd)); 60 pad = (4 - (((void *)skb->data - NULL) & 0x3)) % 4;
61
62 BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN
63 + pad));
64 skb_push(skb, sizeof(*local_tx_pd) + pad);
60 65
61 local_tx_pd = (struct txpd *) skb->data; 66 local_tx_pd = (struct txpd *) skb->data;
62 memset(local_tx_pd, 0, sizeof(struct txpd)); 67 memset(local_tx_pd, 0, sizeof(struct txpd));
63 local_tx_pd->bss_num = priv->bss_num; 68 local_tx_pd->bss_num = priv->bss_num;
64 local_tx_pd->bss_type = priv->bss_type; 69 local_tx_pd->bss_type = priv->bss_type;
65 local_tx_pd->tx_pkt_length = cpu_to_le16((u16) (skb->len - 70 local_tx_pd->tx_pkt_length = cpu_to_le16((u16) (skb->len -
66 sizeof(struct txpd))); 71 (sizeof(struct txpd) + pad)));
67 72
68 local_tx_pd->priority = (u8) skb->priority; 73 local_tx_pd->priority = (u8) skb->priority;
69 local_tx_pd->pkt_delay_2ms = 74 local_tx_pd->pkt_delay_2ms =
@@ -88,7 +93,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
88 } 93 }
89 94
90 /* Offset of actual data */ 95 /* Offset of actual data */
91 local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd)); 96 local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd) + pad);
92 97
93 /* make space for INTF_HEADER_LEN */ 98 /* make space for INTF_HEADER_LEN */
94 skb_push(skb, INTF_HEADER_LEN); 99 skb_push(skb, INTF_HEADER_LEN);
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 59e77797c0fa..507559361d87 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1054,6 +1054,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
1054 { USB_DEVICE(0x0586, 0x341e) }, 1054 { USB_DEVICE(0x0586, 0x341e) },
1055 { USB_DEVICE(0x0586, 0x343e) }, 1055 { USB_DEVICE(0x0586, 0x343e) },
1056#ifdef CONFIG_RT2800USB_RT33XX 1056#ifdef CONFIG_RT2800USB_RT33XX
1057 /* Belkin */
1058 { USB_DEVICE(0x050d, 0x945b) },
1057 /* Ralink */ 1059 /* Ralink */
1058 { USB_DEVICE(0x148f, 0x3370) }, 1060 { USB_DEVICE(0x148f, 0x3370) },
1059 { USB_DEVICE(0x148f, 0x8070) }, 1061 { USB_DEVICE(0x148f, 0x8070) },
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
index 1e851aae58db..17a8e9628512 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
@@ -104,7 +104,7 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
104 tx_agc[RF90_PATH_A] = 0x10101010; 104 tx_agc[RF90_PATH_A] = 0x10101010;
105 tx_agc[RF90_PATH_B] = 0x10101010; 105 tx_agc[RF90_PATH_B] = 0x10101010;
106 } else if (rtlpriv->dm.dynamic_txhighpower_lvl == 106 } else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
107 TXHIGHPWRLEVEL_LEVEL1) { 107 TXHIGHPWRLEVEL_LEVEL2) {
108 tx_agc[RF90_PATH_A] = 0x00000000; 108 tx_agc[RF90_PATH_A] = 0x00000000;
109 tx_agc[RF90_PATH_B] = 0x00000000; 109 tx_agc[RF90_PATH_B] = 0x00000000;
110 } else{ 110 } else{
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
index 87caa94fd815..7e33f1f4f3d4 100644
--- a/drivers/net/wireless/wl12xx/acx.c
+++ b/drivers/net/wireless/wl12xx/acx.c
@@ -90,7 +90,7 @@ int wl1271_acx_tx_power(struct wl1271 *wl, int power)
90 struct acx_current_tx_power *acx; 90 struct acx_current_tx_power *acx;
91 int ret; 91 int ret;
92 92
93 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); 93 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
94 94
95 if (power < 0 || power > 25) 95 if (power < 0 || power > 25)
96 return -EINVAL; 96 return -EINVAL;
@@ -1624,22 +1624,22 @@ out:
1624 return ret; 1624 return ret;
1625} 1625}
1626 1626
1627int wl1271_acx_max_tx_retry(struct wl1271 *wl) 1627int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
1628{ 1628{
1629 struct wl1271_acx_max_tx_retry *acx = NULL; 1629 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
1630 int ret; 1630 int ret;
1631 1631
1632 wl1271_debug(DEBUG_ACX, "acx max tx retry"); 1632 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
1633 1633
1634 acx = kzalloc(sizeof(*acx), GFP_KERNEL); 1634 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1635 if (!acx) 1635 if (!acx)
1636 return -ENOMEM; 1636 return -ENOMEM;
1637 1637
1638 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.ap_max_tx_retries); 1638 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
1639 1639
1640 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx)); 1640 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1641 if (ret < 0) { 1641 if (ret < 0) {
1642 wl1271_warning("acx max tx retry failed: %d", ret); 1642 wl1271_warning("acx ap max tx retry failed: %d", ret);
1643 goto out; 1643 goto out;
1644 } 1644 }
1645 1645
diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h
index d303265f163a..d2eb86eccc04 100644
--- a/drivers/net/wireless/wl12xx/acx.h
+++ b/drivers/net/wireless/wl12xx/acx.h
@@ -1168,7 +1168,7 @@ struct wl1271_acx_ps_rx_streaming {
1168 u8 timeout; 1168 u8 timeout;
1169} __packed; 1169} __packed;
1170 1170
1171struct wl1271_acx_max_tx_retry { 1171struct wl1271_acx_ap_max_tx_retry {
1172 struct acx_header header; 1172 struct acx_header header;
1173 1173
1174 /* 1174 /*
@@ -1400,7 +1400,7 @@ int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn,
1400 bool enable); 1400 bool enable);
1401int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); 1401int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime);
1402int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); 1402int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable);
1403int wl1271_acx_max_tx_retry(struct wl1271 *wl); 1403int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl);
1404int wl1271_acx_config_ps(struct wl1271 *wl); 1404int wl1271_acx_config_ps(struct wl1271 *wl);
1405int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); 1405int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr);
1406int wl1271_acx_set_ap_beacon_filter(struct wl1271 *wl, bool enable); 1406int wl1271_acx_set_ap_beacon_filter(struct wl1271 *wl, bool enable);
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c
index 101f7e0f6329..5ebc64d89407 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -513,7 +513,9 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl)
513 PERIODIC_SCAN_COMPLETE_EVENT_ID; 513 PERIODIC_SCAN_COMPLETE_EVENT_ID;
514 514
515 if (wl->bss_type == BSS_TYPE_AP_BSS) 515 if (wl->bss_type == BSS_TYPE_AP_BSS)
516 wl->event_mask |= STA_REMOVE_COMPLETE_EVENT_ID; 516 wl->event_mask |= STA_REMOVE_COMPLETE_EVENT_ID |
517 INACTIVE_STA_EVENT_ID |
518 MAX_TX_RETRY_EVENT_ID;
517 else 519 else
518 wl->event_mask |= DUMMY_PACKET_EVENT_ID | 520 wl->event_mask |= DUMMY_PACKET_EVENT_ID |
519 BA_SESSION_RX_CONSTRAINT_EVENT_ID; 521 BA_SESSION_RX_CONSTRAINT_EVENT_ID;
diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c
index 68972cbc68b4..97dd237a9580 100644
--- a/drivers/net/wireless/wl12xx/cmd.c
+++ b/drivers/net/wireless/wl12xx/cmd.c
@@ -400,10 +400,6 @@ int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
400 400
401 join->ctrl |= wl->session_counter << WL1271_JOIN_CMD_TX_SESSION_OFFSET; 401 join->ctrl |= wl->session_counter << WL1271_JOIN_CMD_TX_SESSION_OFFSET;
402 402
403 /* reset TX security counters */
404 wl->tx_security_last_seq = 0;
405 wl->tx_security_seq = 0;
406
407 wl1271_debug(DEBUG_CMD, "cmd join: basic_rate_set=0x%x, rate_set=0x%x", 403 wl1271_debug(DEBUG_CMD, "cmd join: basic_rate_set=0x%x, rate_set=0x%x",
408 join->basic_rate_set, join->supported_rate_set); 404 join->basic_rate_set, join->supported_rate_set);
409 405
@@ -1084,7 +1080,7 @@ int wl1271_cmd_start_bss(struct wl1271 *wl)
1084 1080
1085 memcpy(cmd->bssid, bss_conf->bssid, ETH_ALEN); 1081 memcpy(cmd->bssid, bss_conf->bssid, ETH_ALEN);
1086 1082
1087 cmd->aging_period = cpu_to_le16(WL1271_AP_DEF_INACTIV_SEC); 1083 cmd->aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period);
1088 cmd->bss_index = WL1271_AP_BSS_INDEX; 1084 cmd->bss_index = WL1271_AP_BSS_INDEX;
1089 cmd->global_hlid = WL1271_AP_GLOBAL_HLID; 1085 cmd->global_hlid = WL1271_AP_GLOBAL_HLID;
1090 cmd->broadcast_hlid = WL1271_AP_BROADCAST_HLID; 1086 cmd->broadcast_hlid = WL1271_AP_BROADCAST_HLID;
diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h
index b5a7b30afda3..6080e01d92c6 100644
--- a/drivers/net/wireless/wl12xx/conf.h
+++ b/drivers/net/wireless/wl12xx/conf.h
@@ -713,8 +713,16 @@ struct conf_tx_settings {
713 /* 713 /*
714 * AP-mode - allow this number of TX retries to a station before an 714 * AP-mode - allow this number of TX retries to a station before an
715 * event is triggered from FW. 715 * event is triggered from FW.
716 * In AP-mode the hlids of unreachable stations are given in the
717 * "sta_tx_retry_exceeded" member in the event mailbox.
716 */ 718 */
717 u16 ap_max_tx_retries; 719 u8 max_tx_retries;
720
721 /*
722 * AP-mode - after this number of seconds a connected station is
723 * considered inactive.
724 */
725 u16 ap_aging_period;
718 726
719 /* 727 /*
720 * Configuration for TID parameters. 728 * Configuration for TID parameters.
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c
index da2127018300..37934b5601cd 100644
--- a/drivers/net/wireless/wl12xx/debugfs.c
+++ b/drivers/net/wireless/wl12xx/debugfs.c
@@ -30,6 +30,7 @@
30#include "acx.h" 30#include "acx.h"
31#include "ps.h" 31#include "ps.h"
32#include "io.h" 32#include "io.h"
33#include "tx.h"
33 34
34/* ms */ 35/* ms */
35#define WL1271_DEBUGFS_STATS_LIFETIME 1000 36#define WL1271_DEBUGFS_STATS_LIFETIME 1000
@@ -233,7 +234,7 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
233 char buf[20]; 234 char buf[20];
234 int res; 235 int res;
235 236
236 queue_len = wl->tx_queue_count; 237 queue_len = wl1271_tx_total_queue_count(wl);
237 238
238 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len); 239 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
239 return simple_read_from_buffer(userbuf, count, ppos, buf, res); 240 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
@@ -338,10 +339,16 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
338#define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x") 339#define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x")
339 340
340 DRIVER_STATE_PRINT_INT(tx_blocks_available); 341 DRIVER_STATE_PRINT_INT(tx_blocks_available);
341 DRIVER_STATE_PRINT_INT(tx_allocated_blocks); 342 DRIVER_STATE_PRINT_INT(tx_allocated_blocks[0]);
343 DRIVER_STATE_PRINT_INT(tx_allocated_blocks[1]);
344 DRIVER_STATE_PRINT_INT(tx_allocated_blocks[2]);
345 DRIVER_STATE_PRINT_INT(tx_allocated_blocks[3]);
342 DRIVER_STATE_PRINT_INT(tx_frames_cnt); 346 DRIVER_STATE_PRINT_INT(tx_frames_cnt);
343 DRIVER_STATE_PRINT_LHEX(tx_frames_map[0]); 347 DRIVER_STATE_PRINT_LHEX(tx_frames_map[0]);
344 DRIVER_STATE_PRINT_INT(tx_queue_count); 348 DRIVER_STATE_PRINT_INT(tx_queue_count[0]);
349 DRIVER_STATE_PRINT_INT(tx_queue_count[1]);
350 DRIVER_STATE_PRINT_INT(tx_queue_count[2]);
351 DRIVER_STATE_PRINT_INT(tx_queue_count[3]);
345 DRIVER_STATE_PRINT_INT(tx_packets_count); 352 DRIVER_STATE_PRINT_INT(tx_packets_count);
346 DRIVER_STATE_PRINT_INT(tx_results_count); 353 DRIVER_STATE_PRINT_INT(tx_results_count);
347 DRIVER_STATE_PRINT_LHEX(flags); 354 DRIVER_STATE_PRINT_LHEX(flags);
@@ -349,7 +356,7 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
349 DRIVER_STATE_PRINT_INT(tx_blocks_freed[1]); 356 DRIVER_STATE_PRINT_INT(tx_blocks_freed[1]);
350 DRIVER_STATE_PRINT_INT(tx_blocks_freed[2]); 357 DRIVER_STATE_PRINT_INT(tx_blocks_freed[2]);
351 DRIVER_STATE_PRINT_INT(tx_blocks_freed[3]); 358 DRIVER_STATE_PRINT_INT(tx_blocks_freed[3]);
352 DRIVER_STATE_PRINT_INT(tx_security_last_seq); 359 DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb);
353 DRIVER_STATE_PRINT_INT(rx_counter); 360 DRIVER_STATE_PRINT_INT(rx_counter);
354 DRIVER_STATE_PRINT_INT(session_counter); 361 DRIVER_STATE_PRINT_INT(session_counter);
355 DRIVER_STATE_PRINT_INT(state); 362 DRIVER_STATE_PRINT_INT(state);
diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c
index a16dee58a664..304aaa2ee011 100644
--- a/drivers/net/wireless/wl12xx/event.c
+++ b/drivers/net/wireless/wl12xx/event.c
@@ -214,6 +214,8 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox)
214 u32 vector; 214 u32 vector;
215 bool beacon_loss = false; 215 bool beacon_loss = false;
216 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 216 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
217 bool disconnect_sta = false;
218 unsigned long sta_bitmap = 0;
217 219
218 wl1271_event_mbox_dump(mbox); 220 wl1271_event_mbox_dump(mbox);
219 221
@@ -295,6 +297,46 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox)
295 wl1271_tx_dummy_packet(wl); 297 wl1271_tx_dummy_packet(wl);
296 } 298 }
297 299
300 /*
301 * "TX retries exceeded" has a different meaning according to mode.
302 * In AP mode the offending station is disconnected.
303 */
304 if ((vector & MAX_TX_RETRY_EVENT_ID) && is_ap) {
305 wl1271_debug(DEBUG_EVENT, "MAX_TX_RETRY_EVENT_ID");
306 sta_bitmap |= le16_to_cpu(mbox->sta_tx_retry_exceeded);
307 disconnect_sta = true;
308 }
309
310 if ((vector & INACTIVE_STA_EVENT_ID) && is_ap) {
311 wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID");
312 sta_bitmap |= le16_to_cpu(mbox->sta_aging_status);
313 disconnect_sta = true;
314 }
315
316 if (is_ap && disconnect_sta) {
317 u32 num_packets = wl->conf.tx.max_tx_retries;
318 struct ieee80211_sta *sta;
319 const u8 *addr;
320 int h;
321
322 for (h = find_first_bit(&sta_bitmap, AP_MAX_LINKS);
323 h < AP_MAX_LINKS;
324 h = find_next_bit(&sta_bitmap, AP_MAX_LINKS, h+1)) {
325 if (!wl1271_is_active_sta(wl, h))
326 continue;
327
328 addr = wl->links[h].addr;
329
330 rcu_read_lock();
331 sta = ieee80211_find_sta(wl->vif, addr);
332 if (sta) {
333 wl1271_debug(DEBUG_EVENT, "remove sta %d", h);
334 ieee80211_report_low_ack(sta, num_packets);
335 }
336 rcu_read_unlock();
337 }
338 }
339
298 if (wl->vif && beacon_loss) 340 if (wl->vif && beacon_loss)
299 ieee80211_connection_loss(wl->vif); 341 ieee80211_connection_loss(wl->vif);
300 342
diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h
index ce99adf4256e..e524ad6fe4e3 100644
--- a/drivers/net/wireless/wl12xx/event.h
+++ b/drivers/net/wireless/wl12xx/event.h
@@ -58,13 +58,16 @@ enum {
58 CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(17), 58 CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(17),
59 BSS_LOSE_EVENT_ID = BIT(18), 59 BSS_LOSE_EVENT_ID = BIT(18),
60 REGAINED_BSS_EVENT_ID = BIT(19), 60 REGAINED_BSS_EVENT_ID = BIT(19),
61 ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID = BIT(20), 61 MAX_TX_RETRY_EVENT_ID = BIT(20),
62 /* STA: dummy paket for dynamic mem blocks */ 62 /* STA: dummy paket for dynamic mem blocks */
63 DUMMY_PACKET_EVENT_ID = BIT(21), 63 DUMMY_PACKET_EVENT_ID = BIT(21),
64 /* AP: STA remove complete */ 64 /* AP: STA remove complete */
65 STA_REMOVE_COMPLETE_EVENT_ID = BIT(21), 65 STA_REMOVE_COMPLETE_EVENT_ID = BIT(21),
66 SOFT_GEMINI_SENSE_EVENT_ID = BIT(22), 66 SOFT_GEMINI_SENSE_EVENT_ID = BIT(22),
67 /* STA: SG prediction */
67 SOFT_GEMINI_PREDICTION_EVENT_ID = BIT(23), 68 SOFT_GEMINI_PREDICTION_EVENT_ID = BIT(23),
69 /* AP: Inactive STA */
70 INACTIVE_STA_EVENT_ID = BIT(23),
68 SOFT_GEMINI_AVALANCHE_EVENT_ID = BIT(24), 71 SOFT_GEMINI_AVALANCHE_EVENT_ID = BIT(24),
69 PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(25), 72 PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(25),
70 DBG_EVENT_ID = BIT(26), 73 DBG_EVENT_ID = BIT(26),
@@ -119,7 +122,11 @@ struct event_mailbox {
119 122
120 /* AP FW only */ 123 /* AP FW only */
121 u8 hlid_removed; 124 u8 hlid_removed;
125
126 /* a bitmap of hlids for stations that have been inactive too long */
122 __le16 sta_aging_status; 127 __le16 sta_aging_status;
128
129 /* a bitmap of hlids for stations which didn't respond to TX */
123 __le16 sta_tx_retry_exceeded; 130 __le16 sta_tx_retry_exceeded;
124 131
125 /* 132 /*
@@ -143,4 +150,7 @@ void wl1271_event_mbox_config(struct wl1271 *wl);
143int wl1271_event_handle(struct wl1271 *wl, u8 mbox); 150int wl1271_event_handle(struct wl1271 *wl, u8 mbox);
144void wl1271_pspoll_work(struct work_struct *work); 151void wl1271_pspoll_work(struct work_struct *work);
145 152
153/* Functions from main.c */
154bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid);
155
146#endif 156#endif
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
index cf40ac93cead..c3e9a2e4410e 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -447,7 +447,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
447 if (ret < 0) 447 if (ret < 0)
448 return ret; 448 return ret;
449 449
450 ret = wl1271_acx_max_tx_retry(wl); 450 ret = wl1271_acx_ap_max_tx_retry(wl);
451 if (ret < 0) 451 if (ret < 0)
452 return ret; 452 return ret;
453 453
@@ -455,6 +455,11 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
455 if (ret < 0) 455 if (ret < 0)
456 return ret; 456 return ret;
457 457
458 /* initialize Tx power */
459 ret = wl1271_acx_tx_power(wl, wl->power_level);
460 if (ret < 0)
461 return ret;
462
458 return 0; 463 return 0;
459} 464}
460 465
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index a3734bdf5119..e58c22d21e39 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -210,7 +210,8 @@ static struct conf_drv_settings default_conf = {
210 .tx_op_limit = 1504, 210 .tx_op_limit = 1504,
211 }, 211 },
212 }, 212 },
213 .ap_max_tx_retries = 100, 213 .max_tx_retries = 100,
214 .ap_aging_period = 300,
214 .tid_conf_count = 4, 215 .tid_conf_count = 4,
215 .tid_conf = { 216 .tid_conf = {
216 [CONF_TX_AC_BE] = { 217 [CONF_TX_AC_BE] = {
@@ -823,13 +824,24 @@ static void wl1271_irq_update_links_status(struct wl1271 *wl,
823 } 824 }
824} 825}
825 826
827static u32 wl1271_tx_allocated_blocks(struct wl1271 *wl)
828{
829 int i;
830 u32 total_alloc_blocks = 0;
831
832 for (i = 0; i < NUM_TX_QUEUES; i++)
833 total_alloc_blocks += wl->tx_allocated_blocks[i];
834
835 return total_alloc_blocks;
836}
837
826static void wl1271_fw_status(struct wl1271 *wl, 838static void wl1271_fw_status(struct wl1271 *wl,
827 struct wl1271_fw_full_status *full_status) 839 struct wl1271_fw_full_status *full_status)
828{ 840{
829 struct wl1271_fw_common_status *status = &full_status->common; 841 struct wl1271_fw_common_status *status = &full_status->common;
830 struct timespec ts; 842 struct timespec ts;
831 u32 old_tx_blk_count = wl->tx_blocks_available; 843 u32 old_tx_blk_count = wl->tx_blocks_available;
832 u32 freed_blocks = 0; 844 u32 freed_blocks = 0, ac_freed_blocks;
833 int i; 845 int i;
834 846
835 if (wl->bss_type == BSS_TYPE_AP_BSS) { 847 if (wl->bss_type == BSS_TYPE_AP_BSS) {
@@ -849,21 +861,23 @@ static void wl1271_fw_status(struct wl1271 *wl,
849 861
850 /* update number of available TX blocks */ 862 /* update number of available TX blocks */
851 for (i = 0; i < NUM_TX_QUEUES; i++) { 863 for (i = 0; i < NUM_TX_QUEUES; i++) {
852 freed_blocks += le32_to_cpu(status->tx_released_blks[i]) - 864 ac_freed_blocks = le32_to_cpu(status->tx_released_blks[i]) -
853 wl->tx_blocks_freed[i]; 865 wl->tx_blocks_freed[i];
866 freed_blocks += ac_freed_blocks;
867
868 wl->tx_allocated_blocks[i] -= ac_freed_blocks;
854 869
855 wl->tx_blocks_freed[i] = 870 wl->tx_blocks_freed[i] =
856 le32_to_cpu(status->tx_released_blks[i]); 871 le32_to_cpu(status->tx_released_blks[i]);
857 } 872 }
858 873
859 wl->tx_allocated_blocks -= freed_blocks;
860
861 if (wl->bss_type == BSS_TYPE_AP_BSS) { 874 if (wl->bss_type == BSS_TYPE_AP_BSS) {
862 /* Update num of allocated TX blocks per link and ps status */ 875 /* Update num of allocated TX blocks per link and ps status */
863 wl1271_irq_update_links_status(wl, &full_status->ap); 876 wl1271_irq_update_links_status(wl, &full_status->ap);
864 wl->tx_blocks_available += freed_blocks; 877 wl->tx_blocks_available += freed_blocks;
865 } else { 878 } else {
866 int avail = full_status->sta.tx_total - wl->tx_allocated_blocks; 879 int avail = full_status->sta.tx_total -
880 wl1271_tx_allocated_blocks(wl);
867 881
868 /* 882 /*
869 * The FW might change the total number of TX memblocks before 883 * The FW might change the total number of TX memblocks before
@@ -978,7 +992,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie)
978 /* Check if any tx blocks were freed */ 992 /* Check if any tx blocks were freed */
979 spin_lock_irqsave(&wl->wl_lock, flags); 993 spin_lock_irqsave(&wl->wl_lock, flags);
980 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) && 994 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
981 wl->tx_queue_count) { 995 wl1271_tx_total_queue_count(wl) > 0) {
982 spin_unlock_irqrestore(&wl->wl_lock, flags); 996 spin_unlock_irqrestore(&wl->wl_lock, flags);
983 /* 997 /*
984 * In order to avoid starvation of the TX path, 998 * In order to avoid starvation of the TX path,
@@ -1026,7 +1040,7 @@ out:
1026 /* In case TX was not handled here, queue TX work */ 1040 /* In case TX was not handled here, queue TX work */
1027 clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags); 1041 clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
1028 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) && 1042 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
1029 wl->tx_queue_count) 1043 wl1271_tx_total_queue_count(wl) > 0)
1030 ieee80211_queue_work(wl->hw, &wl->tx_work); 1044 ieee80211_queue_work(wl->hw, &wl->tx_work);
1031 spin_unlock_irqrestore(&wl->wl_lock, flags); 1045 spin_unlock_irqrestore(&wl->wl_lock, flags);
1032 1046
@@ -1227,6 +1241,15 @@ static void wl1271_recovery_work(struct work_struct *work)
1227 wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x", 1241 wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x",
1228 wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4)); 1242 wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4));
1229 1243
1244 /*
1245 * Advance security sequence number to overcome potential progress
1246 * in the firmware during recovery. This doens't hurt if the network is
1247 * not encrypted.
1248 */
1249 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) ||
1250 test_bit(WL1271_FLAG_AP_STARTED, &wl->flags))
1251 wl->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING;
1252
1230 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) 1253 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
1231 ieee80211_connection_loss(wl->vif); 1254 ieee80211_connection_loss(wl->vif);
1232 1255
@@ -1474,26 +1497,27 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1474{ 1497{
1475 struct wl1271 *wl = hw->priv; 1498 struct wl1271 *wl = hw->priv;
1476 unsigned long flags; 1499 unsigned long flags;
1477 int q; 1500 int q, mapping;
1478 u8 hlid = 0; 1501 u8 hlid = 0;
1479 1502
1480 q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); 1503 mapping = skb_get_queue_mapping(skb);
1504 q = wl1271_tx_get_queue(mapping);
1481 1505
1482 if (wl->bss_type == BSS_TYPE_AP_BSS) 1506 if (wl->bss_type == BSS_TYPE_AP_BSS)
1483 hlid = wl1271_tx_get_hlid(skb); 1507 hlid = wl1271_tx_get_hlid(skb);
1484 1508
1485 spin_lock_irqsave(&wl->wl_lock, flags); 1509 spin_lock_irqsave(&wl->wl_lock, flags);
1486 1510
1487 wl->tx_queue_count++; 1511 wl->tx_queue_count[q]++;
1488 1512
1489 /* 1513 /*
1490 * The workqueue is slow to process the tx_queue and we need stop 1514 * The workqueue is slow to process the tx_queue and we need stop
1491 * the queue here, otherwise the queue will get too long. 1515 * the queue here, otherwise the queue will get too long.
1492 */ 1516 */
1493 if (wl->tx_queue_count >= WL1271_TX_QUEUE_HIGH_WATERMARK) { 1517 if (wl->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK) {
1494 wl1271_debug(DEBUG_TX, "op_tx: stopping queues"); 1518 wl1271_debug(DEBUG_TX, "op_tx: stopping queues for q %d", q);
1495 ieee80211_stop_queues(wl->hw); 1519 ieee80211_stop_queue(wl->hw, mapping);
1496 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags); 1520 set_bit(q, &wl->stopped_queues_map);
1497 } 1521 }
1498 1522
1499 /* queue the packet */ 1523 /* queue the packet */
@@ -1519,10 +1543,11 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1519int wl1271_tx_dummy_packet(struct wl1271 *wl) 1543int wl1271_tx_dummy_packet(struct wl1271 *wl)
1520{ 1544{
1521 unsigned long flags; 1545 unsigned long flags;
1546 int q = wl1271_tx_get_queue(skb_get_queue_mapping(wl->dummy_packet));
1522 1547
1523 spin_lock_irqsave(&wl->wl_lock, flags); 1548 spin_lock_irqsave(&wl->wl_lock, flags);
1524 set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); 1549 set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags);
1525 wl->tx_queue_count++; 1550 wl->tx_queue_count[q]++;
1526 spin_unlock_irqrestore(&wl->wl_lock, flags); 1551 spin_unlock_irqrestore(&wl->wl_lock, flags);
1527 1552
1528 /* The FW is low on RX memory blocks, so send the dummy packet asap */ 1553 /* The FW is low on RX memory blocks, so send the dummy packet asap */
@@ -1586,10 +1611,13 @@ static struct notifier_block wl1271_dev_notifier = {
1586#ifdef CONFIG_PM 1611#ifdef CONFIG_PM
1587static int wl1271_configure_suspend_sta(struct wl1271 *wl) 1612static int wl1271_configure_suspend_sta(struct wl1271 *wl)
1588{ 1613{
1589 int ret; 1614 int ret = 0;
1590 1615
1591 mutex_lock(&wl->mutex); 1616 mutex_lock(&wl->mutex);
1592 1617
1618 if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
1619 goto out_unlock;
1620
1593 ret = wl1271_ps_elp_wakeup(wl); 1621 ret = wl1271_ps_elp_wakeup(wl);
1594 if (ret < 0) 1622 if (ret < 0)
1595 goto out_unlock; 1623 goto out_unlock;
@@ -1634,10 +1662,13 @@ out:
1634 1662
1635static int wl1271_configure_suspend_ap(struct wl1271 *wl) 1663static int wl1271_configure_suspend_ap(struct wl1271 *wl)
1636{ 1664{
1637 int ret; 1665 int ret = 0;
1638 1666
1639 mutex_lock(&wl->mutex); 1667 mutex_lock(&wl->mutex);
1640 1668
1669 if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags))
1670 goto out_unlock;
1671
1641 ret = wl1271_ps_elp_wakeup(wl); 1672 ret = wl1271_ps_elp_wakeup(wl);
1642 if (ret < 0) 1673 if (ret < 0)
1643 goto out_unlock; 1674 goto out_unlock;
@@ -1705,7 +1736,6 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
1705 } 1736 }
1706 /* flush any remaining work */ 1737 /* flush any remaining work */
1707 wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); 1738 wl1271_debug(DEBUG_MAC80211, "flushing remaining works");
1708 flush_delayed_work(&wl->scan_complete_work);
1709 1739
1710 /* 1740 /*
1711 * disable and re-enable interrupts in order to flush 1741 * disable and re-enable interrupts in order to flush
@@ -1977,11 +2007,8 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
1977 wl->psm_entry_retry = 0; 2007 wl->psm_entry_retry = 0;
1978 wl->power_level = WL1271_DEFAULT_POWER_LEVEL; 2008 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
1979 wl->tx_blocks_available = 0; 2009 wl->tx_blocks_available = 0;
1980 wl->tx_allocated_blocks = 0;
1981 wl->tx_results_count = 0; 2010 wl->tx_results_count = 0;
1982 wl->tx_packets_count = 0; 2011 wl->tx_packets_count = 0;
1983 wl->tx_security_last_seq = 0;
1984 wl->tx_security_seq = 0;
1985 wl->time_offset = 0; 2012 wl->time_offset = 0;
1986 wl->session_counter = 0; 2013 wl->session_counter = 0;
1987 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 2014 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
@@ -2000,8 +2027,10 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
2000 */ 2027 */
2001 wl->flags = 0; 2028 wl->flags = 0;
2002 2029
2003 for (i = 0; i < NUM_TX_QUEUES; i++) 2030 for (i = 0; i < NUM_TX_QUEUES; i++) {
2004 wl->tx_blocks_freed[i] = 0; 2031 wl->tx_blocks_freed[i] = 0;
2032 wl->tx_allocated_blocks[i] = 0;
2033 }
2005 2034
2006 wl1271_debugfs_reset(wl); 2035 wl1271_debugfs_reset(wl);
2007 2036
@@ -2154,6 +2183,10 @@ static int wl1271_unjoin(struct wl1271 *wl)
2154 clear_bit(WL1271_FLAG_JOINED, &wl->flags); 2183 clear_bit(WL1271_FLAG_JOINED, &wl->flags);
2155 memset(wl->bssid, 0, ETH_ALEN); 2184 memset(wl->bssid, 0, ETH_ALEN);
2156 2185
2186 /* reset TX security counters on a clean disconnect */
2187 wl->tx_security_last_seq_lsb = 0;
2188 wl->tx_security_seq = 0;
2189
2157 /* stop filtering packets based on bssid */ 2190 /* stop filtering packets based on bssid */
2158 wl1271_configure_filters(wl, FIF_OTHER_BSS); 2191 wl1271_configure_filters(wl, FIF_OTHER_BSS);
2159 2192
@@ -2246,6 +2279,9 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2246 wl->channel = channel; 2279 wl->channel = channel;
2247 } 2280 }
2248 2281
2282 if ((changed & IEEE80211_CONF_CHANGE_POWER))
2283 wl->power_level = conf->power_level;
2284
2249 goto out; 2285 goto out;
2250 } 2286 }
2251 2287
@@ -2753,6 +2789,44 @@ out:
2753 return ret; 2789 return ret;
2754} 2790}
2755 2791
2792static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw,
2793 struct ieee80211_vif *vif)
2794{
2795 struct wl1271 *wl = hw->priv;
2796 int ret;
2797
2798 wl1271_debug(DEBUG_MAC80211, "mac80211 cancel hw scan");
2799
2800 mutex_lock(&wl->mutex);
2801
2802 if (wl->state == WL1271_STATE_OFF)
2803 goto out;
2804
2805 if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
2806 goto out;
2807
2808 ret = wl1271_ps_elp_wakeup(wl);
2809 if (ret < 0)
2810 goto out;
2811
2812 if (wl->scan.state != WL1271_SCAN_STATE_DONE) {
2813 ret = wl1271_scan_stop(wl);
2814 if (ret < 0)
2815 goto out_sleep;
2816 }
2817 wl->scan.state = WL1271_SCAN_STATE_IDLE;
2818 memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
2819 wl->scan.req = NULL;
2820 ieee80211_scan_completed(wl->hw, true);
2821
2822out_sleep:
2823 wl1271_ps_elp_sleep(wl);
2824out:
2825 mutex_unlock(&wl->mutex);
2826
2827 cancel_delayed_work_sync(&wl->scan_complete_work);
2828}
2829
2756static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, 2830static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw,
2757 struct ieee80211_vif *vif, 2831 struct ieee80211_vif *vif,
2758 struct cfg80211_sched_scan_request *req, 2832 struct cfg80211_sched_scan_request *req,
@@ -3515,6 +3589,12 @@ static void wl1271_free_sta(struct wl1271 *wl, u8 hlid)
3515 __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); 3589 __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
3516} 3590}
3517 3591
3592bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid)
3593{
3594 int id = hlid - WL1271_AP_STA_HLID_START;
3595 return test_bit(id, wl->ap_hlid_map);
3596}
3597
3518static int wl1271_op_sta_add(struct ieee80211_hw *hw, 3598static int wl1271_op_sta_add(struct ieee80211_hw *hw,
3519 struct ieee80211_vif *vif, 3599 struct ieee80211_vif *vif,
3520 struct ieee80211_sta *sta) 3600 struct ieee80211_sta *sta)
@@ -3673,7 +3753,7 @@ static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw)
3673 goto out; 3753 goto out;
3674 3754
3675 /* packets are considered pending if in the TX queue or the FW */ 3755 /* packets are considered pending if in the TX queue or the FW */
3676 ret = (wl->tx_queue_count > 0) || (wl->tx_frames_cnt > 0); 3756 ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0);
3677 3757
3678 /* the above is appropriate for STA mode for PS purposes */ 3758 /* the above is appropriate for STA mode for PS purposes */
3679 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); 3759 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS);
@@ -3836,40 +3916,40 @@ static struct ieee80211_rate wl1271_rates_5ghz[] = {
3836 3916
3837/* 5 GHz band channels for WL1273 */ 3917/* 5 GHz band channels for WL1273 */
3838static struct ieee80211_channel wl1271_channels_5ghz[] = { 3918static struct ieee80211_channel wl1271_channels_5ghz[] = {
3839 { .hw_value = 7, .center_freq = 5035}, 3919 { .hw_value = 7, .center_freq = 5035, .max_power = 25 },
3840 { .hw_value = 8, .center_freq = 5040}, 3920 { .hw_value = 8, .center_freq = 5040, .max_power = 25 },
3841 { .hw_value = 9, .center_freq = 5045}, 3921 { .hw_value = 9, .center_freq = 5045, .max_power = 25 },
3842 { .hw_value = 11, .center_freq = 5055}, 3922 { .hw_value = 11, .center_freq = 5055, .max_power = 25 },
3843 { .hw_value = 12, .center_freq = 5060}, 3923 { .hw_value = 12, .center_freq = 5060, .max_power = 25 },
3844 { .hw_value = 16, .center_freq = 5080}, 3924 { .hw_value = 16, .center_freq = 5080, .max_power = 25 },
3845 { .hw_value = 34, .center_freq = 5170}, 3925 { .hw_value = 34, .center_freq = 5170, .max_power = 25 },
3846 { .hw_value = 36, .center_freq = 5180}, 3926 { .hw_value = 36, .center_freq = 5180, .max_power = 25 },
3847 { .hw_value = 38, .center_freq = 5190}, 3927 { .hw_value = 38, .center_freq = 5190, .max_power = 25 },
3848 { .hw_value = 40, .center_freq = 5200}, 3928 { .hw_value = 40, .center_freq = 5200, .max_power = 25 },
3849 { .hw_value = 42, .center_freq = 5210}, 3929 { .hw_value = 42, .center_freq = 5210, .max_power = 25 },
3850 { .hw_value = 44, .center_freq = 5220}, 3930 { .hw_value = 44, .center_freq = 5220, .max_power = 25 },
3851 { .hw_value = 46, .center_freq = 5230}, 3931 { .hw_value = 46, .center_freq = 5230, .max_power = 25 },
3852 { .hw_value = 48, .center_freq = 5240}, 3932 { .hw_value = 48, .center_freq = 5240, .max_power = 25 },
3853 { .hw_value = 52, .center_freq = 5260}, 3933 { .hw_value = 52, .center_freq = 5260, .max_power = 25 },
3854 { .hw_value = 56, .center_freq = 5280}, 3934 { .hw_value = 56, .center_freq = 5280, .max_power = 25 },
3855 { .hw_value = 60, .center_freq = 5300}, 3935 { .hw_value = 60, .center_freq = 5300, .max_power = 25 },
3856 { .hw_value = 64, .center_freq = 5320}, 3936 { .hw_value = 64, .center_freq = 5320, .max_power = 25 },
3857 { .hw_value = 100, .center_freq = 5500}, 3937 { .hw_value = 100, .center_freq = 5500, .max_power = 25 },
3858 { .hw_value = 104, .center_freq = 5520}, 3938 { .hw_value = 104, .center_freq = 5520, .max_power = 25 },
3859 { .hw_value = 108, .center_freq = 5540}, 3939 { .hw_value = 108, .center_freq = 5540, .max_power = 25 },
3860 { .hw_value = 112, .center_freq = 5560}, 3940 { .hw_value = 112, .center_freq = 5560, .max_power = 25 },
3861 { .hw_value = 116, .center_freq = 5580}, 3941 { .hw_value = 116, .center_freq = 5580, .max_power = 25 },
3862 { .hw_value = 120, .center_freq = 5600}, 3942 { .hw_value = 120, .center_freq = 5600, .max_power = 25 },
3863 { .hw_value = 124, .center_freq = 5620}, 3943 { .hw_value = 124, .center_freq = 5620, .max_power = 25 },
3864 { .hw_value = 128, .center_freq = 5640}, 3944 { .hw_value = 128, .center_freq = 5640, .max_power = 25 },
3865 { .hw_value = 132, .center_freq = 5660}, 3945 { .hw_value = 132, .center_freq = 5660, .max_power = 25 },
3866 { .hw_value = 136, .center_freq = 5680}, 3946 { .hw_value = 136, .center_freq = 5680, .max_power = 25 },
3867 { .hw_value = 140, .center_freq = 5700}, 3947 { .hw_value = 140, .center_freq = 5700, .max_power = 25 },
3868 { .hw_value = 149, .center_freq = 5745}, 3948 { .hw_value = 149, .center_freq = 5745, .max_power = 25 },
3869 { .hw_value = 153, .center_freq = 5765}, 3949 { .hw_value = 153, .center_freq = 5765, .max_power = 25 },
3870 { .hw_value = 157, .center_freq = 5785}, 3950 { .hw_value = 157, .center_freq = 5785, .max_power = 25 },
3871 { .hw_value = 161, .center_freq = 5805}, 3951 { .hw_value = 161, .center_freq = 5805, .max_power = 25 },
3872 { .hw_value = 165, .center_freq = 5825}, 3952 { .hw_value = 165, .center_freq = 5825, .max_power = 25 },
3873}; 3953};
3874 3954
3875/* mapping to indexes for wl1271_rates_5ghz */ 3955/* mapping to indexes for wl1271_rates_5ghz */
@@ -3930,6 +4010,7 @@ static const struct ieee80211_ops wl1271_ops = {
3930 .tx = wl1271_op_tx, 4010 .tx = wl1271_op_tx,
3931 .set_key = wl1271_op_set_key, 4011 .set_key = wl1271_op_set_key,
3932 .hw_scan = wl1271_op_hw_scan, 4012 .hw_scan = wl1271_op_hw_scan,
4013 .cancel_hw_scan = wl1271_op_cancel_hw_scan,
3933 .sched_scan_start = wl1271_op_sched_scan_start, 4014 .sched_scan_start = wl1271_op_sched_scan_start,
3934 .sched_scan_stop = wl1271_op_sched_scan_stop, 4015 .sched_scan_stop = wl1271_op_sched_scan_stop,
3935 .bss_info_changed = wl1271_op_bss_info_changed, 4016 .bss_info_changed = wl1271_op_bss_info_changed,
@@ -4327,6 +4408,9 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
4327 wl->quirks = 0; 4408 wl->quirks = 0;
4328 wl->platform_quirks = 0; 4409 wl->platform_quirks = 0;
4329 wl->sched_scanning = false; 4410 wl->sched_scanning = false;
4411 wl->tx_security_seq = 0;
4412 wl->tx_security_last_seq_lsb = 0;
4413
4330 setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, 4414 setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer,
4331 (unsigned long) wl); 4415 (unsigned long) wl);
4332 wl->fwlog_size = 0; 4416 wl->fwlog_size = 0;
diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c
index 3e68a664c9de..3548377ab9c2 100644
--- a/drivers/net/wireless/wl12xx/ps.c
+++ b/drivers/net/wireless/wl12xx/ps.c
@@ -193,24 +193,27 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode,
193 193
194static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid) 194static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid)
195{ 195{
196 int i, filtered = 0; 196 int i;
197 struct sk_buff *skb; 197 struct sk_buff *skb;
198 struct ieee80211_tx_info *info; 198 struct ieee80211_tx_info *info;
199 unsigned long flags; 199 unsigned long flags;
200 int filtered[NUM_TX_QUEUES];
200 201
201 /* filter all frames currently the low level queus for this hlid */ 202 /* filter all frames currently the low level queus for this hlid */
202 for (i = 0; i < NUM_TX_QUEUES; i++) { 203 for (i = 0; i < NUM_TX_QUEUES; i++) {
204 filtered[i] = 0;
203 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) { 205 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {
204 info = IEEE80211_SKB_CB(skb); 206 info = IEEE80211_SKB_CB(skb);
205 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 207 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
206 info->status.rates[0].idx = -1; 208 info->status.rates[0].idx = -1;
207 ieee80211_tx_status_ni(wl->hw, skb); 209 ieee80211_tx_status_ni(wl->hw, skb);
208 filtered++; 210 filtered[i]++;
209 } 211 }
210 } 212 }
211 213
212 spin_lock_irqsave(&wl->wl_lock, flags); 214 spin_lock_irqsave(&wl->wl_lock, flags);
213 wl->tx_queue_count -= filtered; 215 for (i = 0; i < NUM_TX_QUEUES; i++)
216 wl->tx_queue_count[i] -= filtered[i];
214 spin_unlock_irqrestore(&wl->wl_lock, flags); 217 spin_unlock_irqrestore(&wl->wl_lock, flags);
215 218
216 wl1271_handle_tx_low_watermark(wl); 219 wl1271_handle_tx_low_watermark(wl);
diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c
index 5e5c66dd06d5..edfe01c321ca 100644
--- a/drivers/net/wireless/wl12xx/scan.c
+++ b/drivers/net/wireless/wl12xx/scan.c
@@ -321,6 +321,33 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
321 return 0; 321 return 0;
322} 322}
323 323
324int wl1271_scan_stop(struct wl1271 *wl)
325{
326 struct wl1271_cmd_header *cmd = NULL;
327 int ret = 0;
328
329 if (WARN_ON(wl->scan.state == WL1271_SCAN_STATE_IDLE))
330 return -EINVAL;
331
332 wl1271_debug(DEBUG_CMD, "cmd scan stop");
333
334 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
335 if (!cmd) {
336 ret = -ENOMEM;
337 goto out;
338 }
339
340 ret = wl1271_cmd_send(wl, CMD_STOP_SCAN, cmd,
341 sizeof(*cmd), 0);
342 if (ret < 0) {
343 wl1271_error("cmd stop_scan failed");
344 goto out;
345 }
346out:
347 kfree(cmd);
348 return ret;
349}
350
324static int 351static int
325wl1271_scan_get_sched_scan_channels(struct wl1271 *wl, 352wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
326 struct cfg80211_sched_scan_request *req, 353 struct cfg80211_sched_scan_request *req,
diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h
index ca81de20ebef..d882e4da71b7 100644
--- a/drivers/net/wireless/wl12xx/scan.h
+++ b/drivers/net/wireless/wl12xx/scan.h
@@ -28,6 +28,7 @@
28 28
29int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, 29int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
30 struct cfg80211_scan_request *req); 30 struct cfg80211_scan_request *req);
31int wl1271_scan_stop(struct wl1271 *wl);
31int wl1271_scan_build_probe_req(struct wl1271 *wl, 32int wl1271_scan_build_probe_req(struct wl1271 *wl,
32 const u8 *ssid, size_t ssid_len, 33 const u8 *ssid, size_t ssid_len,
33 const u8 *ie, size_t ie_len, u8 band); 34 const u8 *ie, size_t ie_len, u8 band);
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 4dc4573b6861..5cf18c2c23f0 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -166,13 +166,13 @@ static int wl1271_sdio_power_on(struct wl1271 *wl)
166 ret = pm_runtime_get_sync(&func->dev); 166 ret = pm_runtime_get_sync(&func->dev);
167 if (ret) 167 if (ret)
168 goto out; 168 goto out;
169 } else {
170 /* Runtime PM is disabled: power up the card manually */
171 ret = mmc_power_restore_host(func->card->host);
172 if (ret < 0)
173 goto out;
169 } 174 }
170 175
171 /* Runtime PM might be disabled, so power up the card manually */
172 ret = mmc_power_restore_host(func->card->host);
173 if (ret < 0)
174 goto out;
175
176 sdio_claim_host(func); 176 sdio_claim_host(func);
177 sdio_enable_func(func); 177 sdio_enable_func(func);
178 178
@@ -188,7 +188,7 @@ static int wl1271_sdio_power_off(struct wl1271 *wl)
188 sdio_disable_func(func); 188 sdio_disable_func(func);
189 sdio_release_host(func); 189 sdio_release_host(func);
190 190
191 /* Runtime PM might be disabled, so power off the card manually */ 191 /* Power off the card manually, even if runtime PM is enabled. */
192 ret = mmc_power_save_host(func->card->host); 192 ret = mmc_power_save_host(func->card->host);
193 if (ret < 0) 193 if (ret < 0)
194 return ret; 194 return ret;
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c
index 200590c0d9e3..48fde96ce0d4 100644
--- a/drivers/net/wireless/wl12xx/tx.c
+++ b/drivers/net/wireless/wl12xx/tx.c
@@ -168,7 +168,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
168 u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; 168 u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;
169 u32 len; 169 u32 len;
170 u32 total_blocks; 170 u32 total_blocks;
171 int id, ret = -EBUSY; 171 int id, ret = -EBUSY, ac;
172 u32 spare_blocks; 172 u32 spare_blocks;
173 173
174 if (unlikely(wl->quirks & WL12XX_QUIRK_USE_2_SPARE_BLOCKS)) 174 if (unlikely(wl->quirks & WL12XX_QUIRK_USE_2_SPARE_BLOCKS))
@@ -206,7 +206,9 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
206 desc->id = id; 206 desc->id = id;
207 207
208 wl->tx_blocks_available -= total_blocks; 208 wl->tx_blocks_available -= total_blocks;
209 wl->tx_allocated_blocks += total_blocks; 209
210 ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
211 wl->tx_allocated_blocks[ac] += total_blocks;
210 212
211 if (wl->bss_type == BSS_TYPE_AP_BSS) 213 if (wl->bss_type == BSS_TYPE_AP_BSS)
212 wl->links[hlid].allocated_blks += total_blocks; 214 wl->links[hlid].allocated_blks += total_blocks;
@@ -383,6 +385,8 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb,
383 if (ret < 0) 385 if (ret < 0)
384 return ret; 386 return ret;
385 387
388 wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);
389
386 if (wl->bss_type == BSS_TYPE_AP_BSS) { 390 if (wl->bss_type == BSS_TYPE_AP_BSS) {
387 wl1271_tx_ap_update_inconnection_sta(wl, skb); 391 wl1271_tx_ap_update_inconnection_sta(wl, skb);
388 wl1271_tx_regulate_link(wl, hlid); 392 wl1271_tx_regulate_link(wl, hlid);
@@ -390,8 +394,6 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb,
390 wl1271_tx_update_filters(wl, skb); 394 wl1271_tx_update_filters(wl, skb);
391 } 395 }
392 396
393 wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);
394
395 /* 397 /*
396 * The length of each packet is stored in terms of 398 * The length of each packet is stored in terms of
397 * words. Thus, we must pad the skb data to make sure its 399 * words. Thus, we must pad the skb data to make sure its
@@ -442,37 +444,62 @@ u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set)
442void wl1271_handle_tx_low_watermark(struct wl1271 *wl) 444void wl1271_handle_tx_low_watermark(struct wl1271 *wl)
443{ 445{
444 unsigned long flags; 446 unsigned long flags;
447 int i;
445 448
446 if (test_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags) && 449 for (i = 0; i < NUM_TX_QUEUES; i++) {
447 wl->tx_queue_count <= WL1271_TX_QUEUE_LOW_WATERMARK) { 450 if (test_bit(i, &wl->stopped_queues_map) &&
448 /* firmware buffer has space, restart queues */ 451 wl->tx_queue_count[i] <= WL1271_TX_QUEUE_LOW_WATERMARK) {
449 spin_lock_irqsave(&wl->wl_lock, flags); 452 /* firmware buffer has space, restart queues */
450 ieee80211_wake_queues(wl->hw); 453 spin_lock_irqsave(&wl->wl_lock, flags);
451 clear_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags); 454 ieee80211_wake_queue(wl->hw,
452 spin_unlock_irqrestore(&wl->wl_lock, flags); 455 wl1271_tx_get_mac80211_queue(i));
456 clear_bit(i, &wl->stopped_queues_map);
457 spin_unlock_irqrestore(&wl->wl_lock, flags);
458 }
453 } 459 }
454} 460}
455 461
462static struct sk_buff_head *wl1271_select_queue(struct wl1271 *wl,
463 struct sk_buff_head *queues)
464{
465 int i, q = -1;
466 u32 min_blks = 0xffffffff;
467
468 /*
469 * Find a non-empty ac where:
470 * 1. There are packets to transmit
471 * 2. The FW has the least allocated blocks
472 */
473 for (i = 0; i < NUM_TX_QUEUES; i++)
474 if (!skb_queue_empty(&queues[i]) &&
475 (wl->tx_allocated_blocks[i] < min_blks)) {
476 q = i;
477 min_blks = wl->tx_allocated_blocks[q];
478 }
479
480 if (q == -1)
481 return NULL;
482
483 return &queues[q];
484}
485
456static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl) 486static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl)
457{ 487{
458 struct sk_buff *skb = NULL; 488 struct sk_buff *skb = NULL;
459 unsigned long flags; 489 unsigned long flags;
490 struct sk_buff_head *queue;
460 491
461 skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_VO]); 492 queue = wl1271_select_queue(wl, wl->tx_queue);
462 if (skb) 493 if (!queue)
463 goto out;
464 skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_VI]);
465 if (skb)
466 goto out; 494 goto out;
467 skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_BE]); 495
468 if (skb) 496 skb = skb_dequeue(queue);
469 goto out;
470 skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_BK]);
471 497
472out: 498out:
473 if (skb) { 499 if (skb) {
500 int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
474 spin_lock_irqsave(&wl->wl_lock, flags); 501 spin_lock_irqsave(&wl->wl_lock, flags);
475 wl->tx_queue_count--; 502 wl->tx_queue_count[q]--;
476 spin_unlock_irqrestore(&wl->wl_lock, flags); 503 spin_unlock_irqrestore(&wl->wl_lock, flags);
477 } 504 }
478 505
@@ -484,6 +511,7 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl)
484 struct sk_buff *skb = NULL; 511 struct sk_buff *skb = NULL;
485 unsigned long flags; 512 unsigned long flags;
486 int i, h, start_hlid; 513 int i, h, start_hlid;
514 struct sk_buff_head *queue;
487 515
488 /* start from the link after the last one */ 516 /* start from the link after the last one */
489 start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS; 517 start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS;
@@ -492,25 +520,25 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl)
492 for (i = 0; i < AP_MAX_LINKS; i++) { 520 for (i = 0; i < AP_MAX_LINKS; i++) {
493 h = (start_hlid + i) % AP_MAX_LINKS; 521 h = (start_hlid + i) % AP_MAX_LINKS;
494 522
495 skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VO]); 523 /* only consider connected stations */
496 if (skb) 524 if (h >= WL1271_AP_STA_HLID_START &&
497 goto out; 525 !test_bit(h - WL1271_AP_STA_HLID_START, wl->ap_hlid_map))
498 skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VI]); 526 continue;
499 if (skb) 527
500 goto out; 528 queue = wl1271_select_queue(wl, wl->links[h].tx_queue);
501 skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BE]); 529 if (!queue)
502 if (skb) 530 continue;
503 goto out; 531
504 skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BK]); 532 skb = skb_dequeue(queue);
505 if (skb) 533 if (skb)
506 goto out; 534 break;
507 } 535 }
508 536
509out:
510 if (skb) { 537 if (skb) {
538 int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
511 wl->last_tx_hlid = h; 539 wl->last_tx_hlid = h;
512 spin_lock_irqsave(&wl->wl_lock, flags); 540 spin_lock_irqsave(&wl->wl_lock, flags);
513 wl->tx_queue_count--; 541 wl->tx_queue_count[q]--;
514 spin_unlock_irqrestore(&wl->wl_lock, flags); 542 spin_unlock_irqrestore(&wl->wl_lock, flags);
515 } else { 543 } else {
516 wl->last_tx_hlid = 0; 544 wl->last_tx_hlid = 0;
@@ -531,9 +559,12 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
531 559
532 if (!skb && 560 if (!skb &&
533 test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { 561 test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) {
562 int q;
563
534 skb = wl->dummy_packet; 564 skb = wl->dummy_packet;
565 q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
535 spin_lock_irqsave(&wl->wl_lock, flags); 566 spin_lock_irqsave(&wl->wl_lock, flags);
536 wl->tx_queue_count--; 567 wl->tx_queue_count[q]--;
537 spin_unlock_irqrestore(&wl->wl_lock, flags); 568 spin_unlock_irqrestore(&wl->wl_lock, flags);
538 } 569 }
539 570
@@ -558,7 +589,7 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb)
558 } 589 }
559 590
560 spin_lock_irqsave(&wl->wl_lock, flags); 591 spin_lock_irqsave(&wl->wl_lock, flags);
561 wl->tx_queue_count++; 592 wl->tx_queue_count[q]++;
562 spin_unlock_irqrestore(&wl->wl_lock, flags); 593 spin_unlock_irqrestore(&wl->wl_lock, flags);
563} 594}
564 595
@@ -704,10 +735,24 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
704 735
705 wl->stats.retry_count += result->ack_failures; 736 wl->stats.retry_count += result->ack_failures;
706 737
707 /* update security sequence number */ 738 /*
708 wl->tx_security_seq += (result->lsb_security_sequence_number - 739 * update sequence number only when relevant, i.e. only in
709 wl->tx_security_last_seq); 740 * sessions of TKIP, AES and GEM (not in open or WEP sessions)
710 wl->tx_security_last_seq = result->lsb_security_sequence_number; 741 */
742 if (info->control.hw_key &&
743 (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP ||
744 info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP ||
745 info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) {
746 u8 fw_lsb = result->tx_security_sequence_number_lsb;
747 u8 cur_lsb = wl->tx_security_last_seq_lsb;
748
749 /*
750 * update security sequence number, taking care of potential
751 * wrap-around
752 */
753 wl->tx_security_seq += (fw_lsb - cur_lsb + 256) % 256;
754 wl->tx_security_last_seq_lsb = fw_lsb;
755 }
711 756
712 /* remove private header from packet */ 757 /* remove private header from packet */
713 skb_pull(skb, sizeof(struct wl1271_tx_hw_descr)); 758 skb_pull(skb, sizeof(struct wl1271_tx_hw_descr));
@@ -772,23 +817,26 @@ void wl1271_tx_complete(struct wl1271 *wl)
772void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) 817void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
773{ 818{
774 struct sk_buff *skb; 819 struct sk_buff *skb;
775 int i, total = 0; 820 int i;
776 unsigned long flags; 821 unsigned long flags;
777 struct ieee80211_tx_info *info; 822 struct ieee80211_tx_info *info;
823 int total[NUM_TX_QUEUES];
778 824
779 for (i = 0; i < NUM_TX_QUEUES; i++) { 825 for (i = 0; i < NUM_TX_QUEUES; i++) {
826 total[i] = 0;
780 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) { 827 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {
781 wl1271_debug(DEBUG_TX, "link freeing skb 0x%p", skb); 828 wl1271_debug(DEBUG_TX, "link freeing skb 0x%p", skb);
782 info = IEEE80211_SKB_CB(skb); 829 info = IEEE80211_SKB_CB(skb);
783 info->status.rates[0].idx = -1; 830 info->status.rates[0].idx = -1;
784 info->status.rates[0].count = 0; 831 info->status.rates[0].count = 0;
785 ieee80211_tx_status_ni(wl->hw, skb); 832 ieee80211_tx_status_ni(wl->hw, skb);
786 total++; 833 total[i]++;
787 } 834 }
788 } 835 }
789 836
790 spin_lock_irqsave(&wl->wl_lock, flags); 837 spin_lock_irqsave(&wl->wl_lock, flags);
791 wl->tx_queue_count -= total; 838 for (i = 0; i < NUM_TX_QUEUES; i++)
839 wl->tx_queue_count[i] -= total[i];
792 spin_unlock_irqrestore(&wl->wl_lock, flags); 840 spin_unlock_irqrestore(&wl->wl_lock, flags);
793 841
794 wl1271_handle_tx_low_watermark(wl); 842 wl1271_handle_tx_low_watermark(wl);
@@ -823,10 +871,11 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues)
823 ieee80211_tx_status_ni(wl->hw, skb); 871 ieee80211_tx_status_ni(wl->hw, skb);
824 } 872 }
825 } 873 }
874 wl->tx_queue_count[i] = 0;
826 } 875 }
827 } 876 }
828 877
829 wl->tx_queue_count = 0; 878 wl->stopped_queues_map = 0;
830 879
831 /* 880 /*
832 * Make sure the driver is at a consistent state, in case this 881 * Make sure the driver is at a consistent state, in case this
@@ -879,8 +928,10 @@ void wl1271_tx_flush(struct wl1271 *wl)
879 while (!time_after(jiffies, timeout)) { 928 while (!time_after(jiffies, timeout)) {
880 mutex_lock(&wl->mutex); 929 mutex_lock(&wl->mutex);
881 wl1271_debug(DEBUG_TX, "flushing tx buffer: %d %d", 930 wl1271_debug(DEBUG_TX, "flushing tx buffer: %d %d",
882 wl->tx_frames_cnt, wl->tx_queue_count); 931 wl->tx_frames_cnt,
883 if ((wl->tx_frames_cnt == 0) && (wl->tx_queue_count == 0)) { 932 wl1271_tx_total_queue_count(wl));
933 if ((wl->tx_frames_cnt == 0) &&
934 (wl1271_tx_total_queue_count(wl) == 0)) {
884 mutex_unlock(&wl->mutex); 935 mutex_unlock(&wl->mutex);
885 return; 936 return;
886 } 937 }
diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h
index 832f9258d675..5d719b5a3d1d 100644
--- a/drivers/net/wireless/wl12xx/tx.h
+++ b/drivers/net/wireless/wl12xx/tx.h
@@ -150,7 +150,7 @@ struct wl1271_tx_hw_res_descr {
150 (from 1st EDCA AIFS counter until TX Complete). */ 150 (from 1st EDCA AIFS counter until TX Complete). */
151 __le32 medium_delay; 151 __le32 medium_delay;
152 /* LS-byte of last TKIP seq-num (saved per AC for recovery). */ 152 /* LS-byte of last TKIP seq-num (saved per AC for recovery). */
153 u8 lsb_security_sequence_number; 153 u8 tx_security_sequence_number_lsb;
154 /* Retry count - number of transmissions without successful ACK.*/ 154 /* Retry count - number of transmissions without successful ACK.*/
155 u8 ack_failures; 155 u8 ack_failures;
156 /* The rate that succeeded getting ACK 156 /* The rate that succeeded getting ACK
@@ -182,6 +182,32 @@ static inline int wl1271_tx_get_queue(int queue)
182 } 182 }
183} 183}
184 184
185static inline int wl1271_tx_get_mac80211_queue(int queue)
186{
187 switch (queue) {
188 case CONF_TX_AC_VO:
189 return 0;
190 case CONF_TX_AC_VI:
191 return 1;
192 case CONF_TX_AC_BE:
193 return 2;
194 case CONF_TX_AC_BK:
195 return 3;
196 default:
197 return 2;
198 }
199}
200
201static inline int wl1271_tx_total_queue_count(struct wl1271 *wl)
202{
203 int i, count = 0;
204
205 for (i = 0; i < NUM_TX_QUEUES; i++)
206 count += wl->tx_queue_count[i];
207
208 return count;
209}
210
185void wl1271_tx_work(struct work_struct *work); 211void wl1271_tx_work(struct work_struct *work);
186void wl1271_tx_work_locked(struct wl1271 *wl); 212void wl1271_tx_work_locked(struct wl1271 *wl);
187void wl1271_tx_complete(struct wl1271 *wl); 213void wl1271_tx_complete(struct wl1271 *wl);
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index d7db6e77047a..1a8751eb8140 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -144,6 +144,7 @@ extern u32 wl12xx_debug_level;
144 144
145#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff)) 145#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
146#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff)) 146#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
147#define WL1271_TX_SQN_POST_RECOVERY_PADDING 0xff
147 148
148#define WL1271_CIPHER_SUITE_GEM 0x00147201 149#define WL1271_CIPHER_SUITE_GEM 0x00147201
149 150
@@ -172,7 +173,6 @@ extern u32 wl12xx_debug_level;
172#define WL1271_PS_STA_MAX_BLOCKS (2 * 9) 173#define WL1271_PS_STA_MAX_BLOCKS (2 * 9)
173 174
174#define WL1271_AP_BSS_INDEX 0 175#define WL1271_AP_BSS_INDEX 0
175#define WL1271_AP_DEF_INACTIV_SEC 300
176#define WL1271_AP_DEF_BEACON_EXP 20 176#define WL1271_AP_DEF_BEACON_EXP 20
177 177
178#define ACX_TX_DESCRIPTORS 32 178#define ACX_TX_DESCRIPTORS 32
@@ -424,7 +424,7 @@ struct wl1271 {
424 /* Accounting for allocated / available TX blocks on HW */ 424 /* Accounting for allocated / available TX blocks on HW */
425 u32 tx_blocks_freed[NUM_TX_QUEUES]; 425 u32 tx_blocks_freed[NUM_TX_QUEUES];
426 u32 tx_blocks_available; 426 u32 tx_blocks_available;
427 u32 tx_allocated_blocks; 427 u32 tx_allocated_blocks[NUM_TX_QUEUES];
428 u32 tx_results_count; 428 u32 tx_results_count;
429 429
430 /* Transmitted TX packets counter for chipset interface */ 430 /* Transmitted TX packets counter for chipset interface */
@@ -438,7 +438,8 @@ struct wl1271 {
438 438
439 /* Frames scheduled for transmission, not handled yet */ 439 /* Frames scheduled for transmission, not handled yet */
440 struct sk_buff_head tx_queue[NUM_TX_QUEUES]; 440 struct sk_buff_head tx_queue[NUM_TX_QUEUES];
441 int tx_queue_count; 441 int tx_queue_count[NUM_TX_QUEUES];
442 long stopped_queues_map;
442 443
443 /* Frames received, not handled yet by mac80211 */ 444 /* Frames received, not handled yet by mac80211 */
444 struct sk_buff_head deferred_rx_queue; 445 struct sk_buff_head deferred_rx_queue;
@@ -454,9 +455,16 @@ struct wl1271 {
454 struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS]; 455 struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS];
455 int tx_frames_cnt; 456 int tx_frames_cnt;
456 457
457 /* Security sequence number counters */ 458 /*
458 u8 tx_security_last_seq; 459 * Security sequence number
459 s64 tx_security_seq; 460 * bits 0-15: lower 16 bits part of sequence number
461 * bits 16-47: higher 32 bits part of sequence number
462 * bits 48-63: not in use
463 */
464 u64 tx_security_seq;
465
466 /* 8 bits of the last sequence number in use */
467 u8 tx_security_last_seq_lsb;
460 468
461 /* FW Rx counter */ 469 /* FW Rx counter */
462 u32 rx_counter; 470 u32 rx_counter;
@@ -632,8 +640,8 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
632 640
633#define WL1271_DEFAULT_POWER_LEVEL 0 641#define WL1271_DEFAULT_POWER_LEVEL 0
634 642
635#define WL1271_TX_QUEUE_LOW_WATERMARK 10 643#define WL1271_TX_QUEUE_LOW_WATERMARK 32
636#define WL1271_TX_QUEUE_HIGH_WATERMARK 25 644#define WL1271_TX_QUEUE_HIGH_WATERMARK 256
637 645
638#define WL1271_DEFERRED_QUEUE_LIMIT 64 646#define WL1271_DEFERRED_QUEUE_LIMIT 64
639 647