PKG_NAME:=mac80211
-PKG_VERSION:=2011-04-06
+PKG_VERSION:=2011-04-19
PKG_RELEASE:=3
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
-PKG_MD5SUM:=7ef8c2d9ee25af7ed33cf339f2484249
+PKG_MD5SUM:=7b789b726927bcc8e3b06c7df40214d9
PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
$(if $(CONFIG_PCI),-DCONFIG_B43_PCI_AUTOSELECT -DCONFIG_B43_PCICORE_AUTOSELECT) \
$(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS -DCONFIG_B43_LEDS -DCONFIG_B43LEGACY_LEDS -DCONFIG_AR9170_LEDS) \
-DCONFIG_B43_HWRNG -DCONFIG_B43LEGACY_HWRNG \
+ -DCONFIG_ATH9K_PCI $(if $(CONFIG_TARGET_ar71xx),-DCONFIG_ATH9K_AHB) \
$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),-DCONFIG_MAC80211_DEBUGFS -DCONFIG_ATH9K_DEBUGFS -DCONFIG_CARL9170_DEBUGFS -DCONFIG_ATH9K_HTC_DEBUGFS -DCONFIG_ATH5K_DEBUG) \
$(if $(CONFIG_PACKAGE_ATH_DEBUG),-DCONFIG_ATH_DEBUG -DCONFIG_ATH9K_PKTLOG) \
-D__CONFIG_MAC80211_RC_DEFAULT=minstrel \
CONFIG_ATH5K_AHB=$(if $(CONFIG_TARGET_atheros),y) \
CONFIG_ATH5K_DEBUG=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
CONFIG_ATH9K=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
+ CONFIG_ATH9K_PCI=y \
+ CONFIG_ATH9K_AHB=$(if $(CONFIG_TARGET_ar71xx),y) \
CONFIG_ATH9K_HTC=$(if $(CONFIG_PACKAGE_kmod-ath9k-htc),m) \
CONFIG_ATH9K_HW=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
CONFIG_ATH9K_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
--- a/config.mk
+++ b/config.mk
-@@ -316,8 +316,8 @@ endif #CONFIG_SSB
+@@ -311,8 +311,8 @@ endif #CONFIG_SSB
CONFIG_P54_PCI=m
ifeq ($(CONFIG_MAC80211),y)
$(error "ERROR: you have MAC80211 compiled into the kernel, CONFIG_MAC80211=y, as such you cannot replace its mac80211 driver. You need this set to CONFIG_MAC80211=m. If you are using Fedora upgrade your kernel as later version should this set as modular. For further information on Fedora see https://bugzilla.redhat.com/show_bug.cgi?id=470143. If you are using your own kernel recompile it and make mac80211 modular")
-@@ -626,10 +626,10 @@ endif #CONFIG_COMPAT_KERNEL_27
+@@ -614,10 +614,10 @@ endif #CONFIG_COMPAT_KERNEL_27
# We need the backported rfkill module on kernel < 2.6.31.
# In more recent kernel versions use the in kernel rfkill module.
ifdef CONFIG_COMPAT_KERNEL_31
else
include $(KLIB_BUILD)/.config
endif
-@@ -300,19 +299,18 @@ CONFIG_IPW2200_QOS=y
+@@ -295,19 +294,18 @@ CONFIG_IPW2200_QOS=y
# % echo 1 > /sys/bus/pci/drivers/ipw2200/*/rtap_iface
endif #CONFIG_WIRELESS_EXT
CONFIG_P54_PCI=m
-@@ -514,7 +512,6 @@ endif #CONFIG_SPI_MASTER end of SPI driv
+@@ -502,7 +500,6 @@ endif #CONFIG_SPI_MASTER end of SPI driv
ifdef CONFIG_MMC
--- a/config.mk
+++ b/config.mk
-@@ -204,7 +204,7 @@ $(warning "WARNING: CONFIG_CFG80211_WEXT
+@@ -199,7 +199,7 @@ $(warning "WARNING: CONFIG_CFG80211_WEXT
endif #CONFIG_WIRELESS_EXT
ifdef CONFIG_STAGING
endif #CONFIG_STAGING
# mac80211 test driver
-@@ -342,13 +342,13 @@ endif #CONFIG_CRC_ITU_T
+@@ -337,13 +337,13 @@ endif #CONFIG_CRC_ITU_T
CONFIG_MWL8K=m
# Ethernet drivers go here
endif #CONFIG_COMPAT_KERNEL_27
ifdef CONFIG_WIRELESS_EXT
-@@ -403,21 +403,21 @@ endif #CONFIG_COMPAT_KERNEL_29
+@@ -398,21 +398,21 @@ endif #CONFIG_COMPAT_KERNEL_29
# Note: this depends on CONFIG_USB_NET_RNDIS_HOST and CONFIG_USB_NET_CDCETHER
# it also requires new RNDIS_HOST and CDC_ETHER modules which we add
ifdef CONFIG_COMPAT_KERNEL_29
else
include $(KLIB_BUILD)/.config
endif
-@@ -234,7 +234,7 @@ CONFIG_B43=m
+@@ -229,7 +229,7 @@ CONFIG_B43=m
CONFIG_B43_HWRNG=y
CONFIG_B43_PCI_AUTOSELECT=y
ifdef CONFIG_PCMCIA
--- a/config.mk
+++ b/config.mk
-@@ -495,7 +495,7 @@ endif #CONFIG_SPI_MASTER end of SPI driv
+@@ -483,7 +483,7 @@ endif #CONFIG_SPI_MASTER end of SPI driv
ifdef CONFIG_MMC
--- a/config.mk
+++ b/config.mk
-@@ -240,7 +240,7 @@ ifdef CONFIG_MAC80211_LEDS
+@@ -235,7 +235,7 @@ ifdef CONFIG_MAC80211_LEDS
CONFIG_B43_LEDS=y
endif #CONFIG_MAC80211_LEDS
CONFIG_B43_PHY_LP=y
--- a/config.mk
+++ b/config.mk
-@@ -304,7 +304,7 @@ CONFIG_RTL8180=m
+@@ -299,7 +299,7 @@ CONFIG_RTL8180=m
CONFIG_ADM8211=m
CONFIG_RT2400PCI=m
CONFIG_RT2500PCI=m
ifdef CONFIG_CRC_CCITT
-@@ -444,7 +444,7 @@ CONFIG_RT2800USB=m
+@@ -432,7 +432,7 @@ CONFIG_RT2800USB=m
# CONFIG_RT2800USB_RT35XX=y
CONFIG_RT2800USB_UNKNOWN=y
endif #CONFIG_CRC_CCITT
--- a/config.mk
+++ b/config.mk
-@@ -116,7 +116,7 @@ CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+@@ -111,7 +111,7 @@ CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
# This is the one used by our compat-wireless net/mac80211/rate.c
# in case you have and old kernel which is overriding this to pid.
CONFIG_COMPAT_MAC80211_RC_DEFAULT=minstrel_ht
--- a/config.mk
+++ b/config.mk
-@@ -207,7 +207,7 @@ CONFIG_ATH9K_COMMON=m
+@@ -202,7 +202,7 @@ CONFIG_ATH9K_COMMON=m
# as default once we get minstrel properly tested and blessed by
# our systems engineering team. CCK rates also need to be used
# for long range considerations.
--- a/config.mk
+++ b/config.mk
-@@ -212,7 +212,7 @@ CONFIG_ATH9K_COMMON=m
+@@ -207,7 +207,7 @@ CONFIG_ATH9K_COMMON=m
# PCI Drivers
ifdef CONFIG_PCI
+++ /dev/null
---- a/compat/Makefile
-+++ b/compat/Makefile
-@@ -2,9 +2,9 @@ obj-m += compat.o
- #compat-objs :=
-
- obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o
--obj-$(CONFIG_COMPAT_KFIFO) += kfifo.o
-
- compat-y += main.o
-+compat-$(CONFIG_COMPAT_KFIFO) += kfifo.o
-
- # Compat kernel compatibility code
- compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o
---- a/config.mk
-+++ b/config.mk
-@@ -90,7 +90,7 @@ endif #CONFIG_FW_LOADER
- endif #CONFIG_COMPAT_KERNEL_33
-
- ifdef CONFIG_COMPAT_KERNEL_36
--CONFIG_COMPAT_KFIFO=m
-+CONFIG_COMPAT_KFIFO=y
- endif #CONFIG_COMPAT_KERNEL_36
-
-
+#undef CR3
+
/* 8-bit hardware registers */
- #define CR0 CTL_REG(0x0000)
- #define CR1 CTL_REG(0x0004)
+ #define ZD_CR0 CTL_REG(0x0000)
+ #define ZD_CR1 CTL_REG(0x0004)
#endif
--- a/config.mk
+++ b/config.mk
-@@ -431,7 +431,7 @@ endif #CONFIG_COMPAT_KERNEL_29
+@@ -419,7 +419,7 @@ endif #CONFIG_COMPAT_KERNEL_29
# This activates a threading fix for usb urb.
# this is mainline commit: b3e670443b7fb8a2d29831b62b44a039c283e351
# This fix will be included in some stable releases.
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -324,7 +324,6 @@ static void ath_paprd_activate(struct at
- if (!caldata || !caldata->paprd_done)
- return;
-
-- ath9k_ps_wakeup(sc);
- ar9003_paprd_enable(ah, false);
- for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
- if (!(common->tx_chainmask & BIT(chain)))
-@@ -334,7 +333,6 @@ static void ath_paprd_activate(struct at
- }
-
- ar9003_paprd_enable(ah, true);
-- ath9k_ps_restore(sc);
- }
-
- static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int chain)
-@@ -554,8 +552,11 @@ set_timer:
- if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) {
- if (!ah->caldata->paprd_done)
- ieee80211_queue_work(sc->hw, &sc->paprd_work);
-- else if (!ah->paprd_table_write_done)
-+ else if (!ah->paprd_table_write_done) {
-+ ath9k_ps_wakeup(sc);
- ath_paprd_activate(sc);
-+ ath9k_ps_restore(sc);
-+ }
- }
- }
-
-@@ -1376,7 +1377,6 @@ static void ath9k_calculate_summary_stat
-
- ath9k_calculate_iter_data(hw, vif, &iter_data);
-
-- ath9k_ps_wakeup(sc);
- /* Set BSSID mask. */
- memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
- ath_hw_setbssidmask(common);
-@@ -1411,7 +1411,6 @@ static void ath9k_calculate_summary_stat
- }
-
- ath9k_hw_set_interrupts(ah, ah->imask);
-- ath9k_ps_restore(sc);
-
- /* Set up ANI */
- if ((iter_data.naps + iter_data.nadhocs) > 0) {
-@@ -1457,6 +1456,7 @@ static int ath9k_add_interface(struct ie
- struct ath_vif *avp = (void *)vif->drv_priv;
- int ret = 0;
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- switch (vif->type) {
-@@ -1503,6 +1503,7 @@ static int ath9k_add_interface(struct ie
- ath9k_do_vif_add_setup(hw, vif);
- out:
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
- return ret;
- }
-
-@@ -1517,6 +1518,7 @@ static int ath9k_change_interface(struct
-
- ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n");
- mutex_lock(&sc->mutex);
-+ ath9k_ps_wakeup(sc);
-
- /* See if new interface type is valid. */
- if ((new_type == NL80211_IFTYPE_ADHOC) &&
-@@ -1546,6 +1548,7 @@ static int ath9k_change_interface(struct
-
- ath9k_do_vif_add_setup(hw, vif);
- out:
-+ ath9k_ps_restore(sc);
- mutex_unlock(&sc->mutex);
- return ret;
- }
-@@ -1558,6 +1561,7 @@ static void ath9k_remove_interface(struc
-
- ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- sc->nvifs--;
-@@ -1569,6 +1573,7 @@ static void ath9k_remove_interface(struc
- ath9k_calculate_summary_state(hw, NULL);
-
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
- }
-
- static void ath9k_enable_ps(struct ath_softc *sc)
-@@ -1809,6 +1814,7 @@ static int ath9k_conf_tx(struct ieee8021
-
- txq = sc->tx.txq_map[queue];
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
-@@ -1832,6 +1838,7 @@ static int ath9k_conf_tx(struct ieee8021
- ath_beaconq_config(sc);
-
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
-
- return ret;
- }
-@@ -1908,6 +1915,7 @@ static void ath9k_bss_info_changed(struc
- int slottime;
- int error;
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- if (changed & BSS_CHANGED_BSSID) {
-@@ -2008,6 +2016,7 @@ static void ath9k_bss_info_changed(struc
- }
-
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
- }
-
- static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -392,14 +392,6 @@ void ath_beacon_tasklet(unsigned long da
- tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
- tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
- slot = (tsftu % (intval * ATH_BCBUF)) / intval;
-- /*
-- * Reverse the slot order to get slot 0 on the TBTT offset that does
-- * not require TSF adjustment and other slots adding
-- * slot/ATH_BCBUF * beacon_int to timestamp. For example, with
-- * ATH_BCBUF = 4, we process beacon slots as follows: 3 2 1 0 3 2 1 ..
-- * and slot 0 is at correct offset to TBTT.
-- */
-- slot = ATH_BCBUF - slot - 1;
- vif = sc->beacon.bslot[slot];
-
- ath_dbg(common, ATH_DBG_BEACON,
-@@ -708,7 +700,7 @@ void ath_beacon_config(struct ath_softc
- if (cur_conf->dtim_period == 0)
- cur_conf->dtim_period = 1;
-
-- switch (iftype) {
-+ switch (sc->sc_ah->opmode) {
- case NL80211_IFTYPE_AP:
- ath_beacon_config_ap(sc, cur_conf);
- break;
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -1585,7 +1585,7 @@ ieee80211_drop_unencrypted_mgmt(struct i
- }
-
- static int
--__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
-+__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
- {
- struct ieee80211_sub_if_data *sdata = rx->sdata;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
-@@ -1593,6 +1593,7 @@ __ieee80211_data_to_8023(struct ieee8021
- struct ethhdr *ehdr;
- int ret;
-
-+ *port_control = false;
- if (ieee80211_has_a4(hdr->frame_control) &&
- sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
- return -1;
-@@ -1611,11 +1612,13 @@ __ieee80211_data_to_8023(struct ieee8021
- return -1;
-
- ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
-- if (ret < 0 || !check_port_control)
-+ if (ret < 0)
- return ret;
-
- ehdr = (struct ethhdr *) rx->skb->data;
-- if (ehdr->h_proto != rx->sdata->control_port_protocol)
-+ if (ehdr->h_proto == rx->sdata->control_port_protocol)
-+ *port_control = true;
-+ else if (check_port_control)
- return -1;
-
- return 0;
-@@ -1916,6 +1919,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_
- struct net_device *dev = sdata->dev;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
- __le16 fc = hdr->frame_control;
-+ bool port_control;
- int err;
-
- if (unlikely(!ieee80211_is_data(hdr->frame_control)))
-@@ -1932,13 +1936,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_
- sdata->vif.type == NL80211_IFTYPE_AP)
- return RX_DROP_MONITOR;
-
-- err = __ieee80211_data_to_8023(rx);
-+ err = __ieee80211_data_to_8023(rx, &port_control);
- if (unlikely(err))
- return RX_DROP_UNUSABLE;
-
- if (!ieee80211_frame_allowed(rx, fc))
- return RX_DROP_MONITOR;
-
-+ if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
-+ unlikely(port_control) && sdata->bss) {
-+ sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
-+ u.ap);
-+ dev = sdata->dev;
-+ rx->sdata = sdata;
-+ }
-+
- rx->skb->dev = dev;
-
- dev->stats.rx_packets++;
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -75,7 +75,6 @@ static void ath_rx_buf_link(struct ath_s
- *sc->rx.rxlink = bf->bf_daddr;
-
- sc->rx.rxlink = &ds->ds_link;
-- ath9k_hw_rxena(ah);
- }
-
- static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
-@@ -426,9 +425,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
- else
- rfilt |= ATH9K_RX_FILTER_BEACON;
-
-- if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
-- AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
-- (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
-+ if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
- (sc->rx.rxfilter & FIF_PSPOLL))
- rfilt |= ATH9K_RX_FILTER_PSPOLL;
-
-@@ -486,12 +483,12 @@ start_recv:
- bool ath_stoprecv(struct ath_softc *sc)
- {
- struct ath_hw *ah = sc->sc_ah;
-- bool stopped;
-+ bool stopped, reset = false;
-
- spin_lock_bh(&sc->rx.rxbuflock);
- ath9k_hw_abortpcurecv(ah);
- ath9k_hw_setrxfilter(ah, 0);
-- stopped = ath9k_hw_stopdmarecv(ah);
-+ stopped = ath9k_hw_stopdmarecv(ah, &reset);
-
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
- ath_edma_stop_recv(sc);
-@@ -506,7 +503,7 @@ bool ath_stoprecv(struct ath_softc *sc)
- "confusing the DMA engine when we start RX up\n");
- ATH_DBG_WARN_ON_ONCE(!stopped);
- }
-- return stopped;
-+ return stopped && !reset;
- }
-
- void ath_flushrecv(struct ath_softc *sc)
-@@ -1767,6 +1764,7 @@ requeue:
- } else {
- list_move_tail(&bf->list, &sc->rx.rxbuf);
- ath_rx_buf_link(sc, bf);
-+ ath9k_hw_rxena(ah);
- }
- } while (1);
-
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1249,15 +1249,6 @@ int ath9k_hw_reset(struct ath_hw *ah, st
- ah->txchainmask = common->tx_chainmask;
- ah->rxchainmask = common->rx_chainmask;
-
-- if ((common->bus_ops->ath_bus_type != ATH_USB) && !ah->chip_fullsleep) {
-- ath9k_hw_abortpcurecv(ah);
-- if (!ath9k_hw_stopdmarecv(ah)) {
-- ath_dbg(common, ATH_DBG_XMIT,
-- "Failed to stop receive dma\n");
-- bChannelChange = false;
-- }
-- }
--
- if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
- return -EIO;
-
---- a/drivers/net/wireless/ath/ath9k/mac.c
-+++ b/drivers/net/wireless/ath/ath9k/mac.c
-@@ -710,27 +710,46 @@ void ath9k_hw_abortpcurecv(struct ath_hw
- }
- EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
-
--bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
-+bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
- {
- #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
- struct ath_common *common = ath9k_hw_common(ah);
-+ u32 mac_status, last_mac_status = 0;
- int i;
-
-+ /* Enable access to the DMA observation bus */
-+ REG_WRITE(ah, AR_MACMISC,
-+ ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
-+ (AR_MACMISC_MISC_OBS_BUS_1 <<
-+ AR_MACMISC_MISC_OBS_BUS_MSB_S)));
-+
- REG_WRITE(ah, AR_CR, AR_CR_RXD);
-
- /* Wait for rx enable bit to go low */
- for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
- if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
- break;
-+
-+ if (!AR_SREV_9300_20_OR_LATER(ah)) {
-+ mac_status = REG_READ(ah, AR_DMADBG_7) & 0x7f0;
-+ if (mac_status == 0x1c0 && mac_status == last_mac_status) {
-+ *reset = true;
-+ break;
-+ }
-+
-+ last_mac_status = mac_status;
-+ }
-+
- udelay(AH_TIME_QUANTUM);
- }
-
- if (i == 0) {
- ath_err(common,
-- "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
-+ "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
- AH_RX_STOP_DMA_TIMEOUT / 1000,
- REG_READ(ah, AR_CR),
-- REG_READ(ah, AR_DIAG_SW));
-+ REG_READ(ah, AR_DIAG_SW),
-+ REG_READ(ah, AR_DMADBG_7));
- return false;
- } else {
- return true;
---- a/drivers/net/wireless/ath/ath9k/mac.h
-+++ b/drivers/net/wireless/ath/ath9k/mac.h
-@@ -695,7 +695,7 @@ bool ath9k_hw_setrxabort(struct ath_hw *
- void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
- void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
- void ath9k_hw_abortpcurecv(struct ath_hw *ah);
--bool ath9k_hw_stopdmarecv(struct ath_hw *ah);
-+bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset);
- int ath9k_hw_beaconq_setup(struct ath_hw *ah);
-
- /* Interrupt Handling */
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
-@@ -192,6 +192,10 @@ ath_reg_apply_beaconing_flags(struct wip
+@@ -193,6 +193,10 @@ ath_reg_apply_beaconing_flags(struct wip
u32 bandwidth = 0;
int r;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
if (!wiphy->bands[band])
-@@ -251,6 +255,10 @@ ath_reg_apply_active_scan_flags(struct w
+@@ -252,6 +256,10 @@ ath_reg_apply_active_scan_flags(struct w
u32 bandwidth = 0;
int r;
sband = wiphy->bands[IEEE80211_BAND_2GHZ];
/*
-@@ -298,6 +306,10 @@ static void ath_reg_apply_radar_flags(st
+@@ -299,6 +307,10 @@ static void ath_reg_apply_radar_flags(st
struct ieee80211_channel *ch;
unsigned int i;
if (!wiphy->bands[IEEE80211_BAND_5GHZ])
return;
-@@ -464,6 +476,10 @@ ath_regd_init_wiphy(struct ath_regulator
+@@ -466,6 +478,10 @@ ath_regd_init_wiphy(struct ath_regulator
{
const struct ieee80211_regdomain *regd;
+ )
};
- /* Can be used by 0x67, 0x6A and 0x68 */
- static const struct ieee80211_regdomain ath_world_regdom_67_68_6A = {
+ /* Can be used by 0x67, 0x68, 0x6A and 0x6C */
+ static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
- .n_reg_rules = 4,
.alpha2 = "99",
- .reg_rules = {
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
-@@ -1629,6 +1629,8 @@ void regulatory_hint_11d(struct wiphy *w
+@@ -1644,6 +1644,8 @@ void regulatory_hint_11d(struct wiphy *w
enum environment_cap env = ENVIRON_ANY;
struct regulatory_request *request;
mutex_lock(®_mutex);
if (unlikely(!last_request))
-@@ -1791,6 +1793,8 @@ static void restore_regulatory_settings(
+@@ -1850,6 +1852,8 @@ static void restore_regulatory_settings(
void regulatory_hint_disconnect(void)
{
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1483,14 +1483,6 @@ static int ath9k_add_interface(struct ie
+@@ -1439,15 +1439,6 @@ static int ath9k_add_interface(struct ie
}
}
-- if ((vif->type == NL80211_IFTYPE_ADHOC) &&
-- sc->nvifs > 0) {
+- if ((ah->opmode == NL80211_IFTYPE_ADHOC) ||
+- ((vif->type == NL80211_IFTYPE_ADHOC) &&
+- sc->nvifs > 0)) {
- ath_err(common, "Cannot create ADHOC interface when other"
- " interfaces already exist.\n");
- ret = -EINVAL;
ath_dbg(common, ATH_DBG_CONFIG,
"Attach a VIF of type: %d\n", vif->type);
+@@ -1473,15 +1464,6 @@ static int ath9k_change_interface(struct
+ mutex_lock(&sc->mutex);
+ ath9k_ps_wakeup(sc);
+
+- /* See if new interface type is valid. */
+- if ((new_type == NL80211_IFTYPE_ADHOC) &&
+- (sc->nvifs > 1)) {
+- ath_err(common, "When using ADHOC, it must be the only"
+- " interface.\n");
+- ret = -EINVAL;
+- goto out;
+- }
+-
+ if (ath9k_uses_beacons(new_type) &&
+ !ath9k_uses_beacons(vif->type)) {
+ if (sc->nbcnvifs >= ATH_BCBUF) {
goto end;
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -1857,7 +1857,7 @@ ath5k_beacon_send(struct ath5k_softc *sc
+@@ -1880,7 +1880,7 @@ ath5k_beacon_send(struct ath5k_softc *sc
sc->bmisscount = 0;
}
sc->opmode == NL80211_IFTYPE_MESH_POINT) {
u64 tsf = ath5k_hw_get_tsf64(ah);
u32 tsftu = TSF_TO_TU(tsf);
-@@ -1935,7 +1935,7 @@ ath5k_beacon_update_timers(struct ath5k_
+@@ -1958,7 +1958,7 @@ ath5k_beacon_update_timers(struct ath5k_
u64 hw_tsf;
intval = sc->bintval & AR5K_BEACON_PERIOD;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/eeprom.c
-+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
-@@ -22,6 +22,8 @@
- \*************************************/
-
- #include <linux/slab.h>
-+#include <linux/ath5k_platform.h>
-+#include <linux/pci.h>
-
- #include "ath5k.h"
- #include "reg.h"
-@@ -1722,7 +1724,7 @@ ath5k_eeprom_read_spur_chans(struct ath5
- }
-
- /*
-- * Read the MAC address from eeprom
-+ * Read the MAC address from eeprom or platform_data
- */
- int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
- {
-@@ -1730,6 +1732,16 @@ int ath5k_eeprom_read_mac(struct ath5k_h
- u32 total, offset;
- u16 data;
- int octet;
-+ struct ath5k_platform_data *pdata = NULL;
-+
-+ if (ah->ah_sc->pdev)
-+ pdata = ah->ah_sc->pdev->dev.platform_data;
-+
-+ if (pdata && pdata->macaddr)
-+ {
-+ memcpy(mac, pdata->macaddr, ETH_ALEN);
-+ return 0;
-+ }
-
- AR5K_EEPROM_READ(0x20, data);
-
---- a/drivers/net/wireless/ath/ath5k/pci.c
-+++ b/drivers/net/wireless/ath/ath5k/pci.c
-@@ -17,6 +17,7 @@
- #include <linux/nl80211.h>
- #include <linux/pci.h>
- #include <linux/pci-aspm.h>
-+#include <linux/ath5k_platform.h>
- #include "../ath.h"
- #include "ath5k.h"
- #include "debug.h"
-@@ -74,6 +75,19 @@ ath5k_pci_eeprom_read(struct ath_common
- {
- struct ath5k_hw *ah = (struct ath5k_hw *) common->ah;
- u32 status, timeout;
-+ struct ath5k_platform_data *pdata = NULL;
-+
-+ if (ah->ah_sc->pdev)
-+ pdata = ah->ah_sc->pdev->dev.platform_data;
-+
-+ if (pdata && pdata->eeprom_data && pdata->eeprom_data[0] == AR5K_EEPROM_MAGIC_VALUE)
-+ {
-+ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS)
-+ return -EIO;
-+
-+ *data = pdata->eeprom_data[offset];
-+ return 0;
-+ }
-
- /*
- * Initialize EEPROM access
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/base.c
-+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -1580,21 +1580,14 @@ ath5k_tx_frame_completed(struct ath5k_so
- info = IEEE80211_SKB_CB(skb);
-
- ieee80211_tx_info_clear_status(info);
-- for (i = 0; i < 4; i++) {
-+ for (i = 0; i <= ts->ts_final_idx; i++) {
- struct ieee80211_tx_rate *r =
- &info->status.rates[i];
-
-- if (ts->ts_rate[i]) {
-- r->idx = ath5k_hw_to_driver_rix(sc, ts->ts_rate[i]);
-- r->count = ts->ts_retry[i];
-- } else {
-- r->idx = -1;
-- r->count = 0;
-- }
-+ r->count = ts->ts_retry[i];
- }
-
-- /* count the successful attempt as well */
-- info->status.rates[ts->ts_final_idx].count++;
-+ info->status.rates[ts->ts_final_idx + 1].idx = -1;
-
- if (unlikely(ts->ts_status)) {
- sc->stats.ack_fail++;
-@@ -1609,6 +1602,9 @@ ath5k_tx_frame_completed(struct ath5k_so
- } else {
- info->flags |= IEEE80211_TX_STAT_ACK;
- info->status.ack_signal = ts->ts_rssi;
-+
-+ /* count the successful attempt as well */
-+ info->status.rates[ts->ts_final_idx].count++;
- }
-
- /*
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -1233,7 +1233,7 @@ int ath5k_eeprom_read_mac(struct ath5k_h
- /* Protocol Control Unit Functions */
- /* Helpers */
- int ath5k_hw_get_frame_duration(struct ath5k_hw *ah,
-- int len, struct ieee80211_rate *rate);
-+ int len, struct ieee80211_rate *rate, bool shortpre);
- unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah);
- unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah);
- extern int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode);
---- a/drivers/net/wireless/ath/ath5k/pcu.c
-+++ b/drivers/net/wireless/ath/ath5k/pcu.c
-@@ -75,7 +75,7 @@ static const unsigned int ack_rates_high
- * bwmodes.
- */
- int ath5k_hw_get_frame_duration(struct ath5k_hw *ah,
-- int len, struct ieee80211_rate *rate)
-+ int len, struct ieee80211_rate *rate, bool shortpre)
- {
- struct ath5k_softc *sc = ah->ah_sc;
- int sifs, preamble, plcp_bits, sym_time;
-@@ -84,9 +84,15 @@ int ath5k_hw_get_frame_duration(struct a
-
- /* Fallback */
- if (!ah->ah_bwmode) {
-- dur = ieee80211_generic_frame_duration(sc->hw,
-- NULL, len, rate);
-- return le16_to_cpu(dur);
-+ __le16 raw_dur = ieee80211_generic_frame_duration(sc->hw,
-+ NULL, len, rate);
-+
-+ /* subtract difference between long and short preamble */
-+ dur = le16_to_cpu(raw_dur);
-+ if (shortpre)
-+ dur -= 96;
-+
-+ return dur;
- }
-
- bitrate = rate->bitrate;
-@@ -263,27 +269,14 @@ static inline void ath5k_hw_write_rate_d
- * actual rate for this rate. See mac80211 tx.c
- * ieee80211_duration() for a brief description of
- * what rate we should choose to TX ACKs. */
-- tx_time = ath5k_hw_get_frame_duration(ah, 10, rate);
-+ tx_time = ath5k_hw_get_frame_duration(ah, 10, rate, false);
-
- ath5k_hw_reg_write(ah, tx_time, reg);
-
- if (!(rate->flags & IEEE80211_RATE_SHORT_PREAMBLE))
- continue;
-
-- /*
-- * We're not distinguishing short preamble here,
-- * This is true, all we'll get is a longer value here
-- * which is not necessarilly bad. We could use
-- * export ieee80211_frame_duration() but that needs to be
-- * fixed first to be properly used by mac802111 drivers:
-- *
-- * - remove erp stuff and let the routine figure ofdm
-- * erp rates
-- * - remove passing argument ieee80211_local as
-- * drivers don't have access to it
-- * - move drivers using ieee80211_generic_frame_duration()
-- * to this
-- */
-+ tx_time = ath5k_hw_get_frame_duration(ah, 10, rate, true);
- ath5k_hw_reg_write(ah, tx_time,
- reg + (AR5K_SET_SHORT_PREAMBLE << 2));
- }
---- a/drivers/net/wireless/ath/ath5k/qcu.c
-+++ b/drivers/net/wireless/ath/ath5k/qcu.c
-@@ -550,7 +550,7 @@ int ath5k_hw_set_ifs_intervals(struct at
- else
- rate = &sc->sbands[IEEE80211_BAND_2GHZ].bitrates[0];
-
-- ack_tx_time = ath5k_hw_get_frame_duration(ah, 10, rate);
-+ ack_tx_time = ath5k_hw_get_frame_duration(ah, 10, rate, false);
-
- /* ack_tx_time includes an SIFS already */
- eifs = ack_tx_time + sifs + 2 * slot_time;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -224,8 +224,7 @@
-
- /* SIFS */
- #define AR5K_INIT_SIFS_TURBO 6
--/* XXX: 8 from initvals 10 from standard */
--#define AR5K_INIT_SIFS_DEFAULT_BG 8
-+#define AR5K_INIT_SIFS_DEFAULT_BG 10
- #define AR5K_INIT_SIFS_DEFAULT_A 16
- #define AR5K_INIT_SIFS_HALF_RATE 32
- #define AR5K_INIT_SIFS_QUARTER_RATE 64
---- a/drivers/net/wireless/ath/ath5k/qcu.c
-+++ b/drivers/net/wireless/ath/ath5k/qcu.c
-@@ -519,7 +519,7 @@ int ath5k_hw_set_ifs_intervals(struct at
- return -EINVAL;
-
- sifs = ath5k_hw_get_default_sifs(ah);
-- sifs_clock = ath5k_hw_htoclock(ah, sifs);
-+ sifs_clock = ath5k_hw_htoclock(ah, sifs - 2);
-
- /* EIFS
- * Txtime of ack at lowest rate + SIFS + DIFS
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -1057,6 +1057,7 @@ struct ath5k_hw {
- u8 ah_coverage_class;
- bool ah_ack_bitrate_high;
- u8 ah_bwmode;
-+ bool ah_short_slot;
-
- /* Antenna Control */
- u32 ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
---- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
-+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
-@@ -277,6 +277,15 @@ ath5k_bss_info_changed(struct ieee80211_
- if (changes & BSS_CHANGED_BEACON_INT)
- sc->bintval = bss_conf->beacon_int;
-
-+ if (changes & BSS_CHANGED_ERP_SLOT) {
-+ int slot_time;
-+
-+ ah->ah_short_slot = bss_conf->use_short_slot;
-+ slot_time = ath5k_hw_get_default_slottime(ah) +
-+ 3 * ah->ah_coverage_class;
-+ ath5k_hw_set_ifs_intervals(ah, slot_time);
-+ }
-+
- if (changes & BSS_CHANGED_ASSOC) {
- avf->assoc = bss_conf->assoc;
- if (bss_conf->assoc)
---- a/drivers/net/wireless/ath/ath5k/pcu.c
-+++ b/drivers/net/wireless/ath/ath5k/pcu.c
-@@ -151,9 +151,9 @@ unsigned int ath5k_hw_get_default_slotti
- slot_time = AR5K_INIT_SLOT_TIME_QUARTER_RATE;
- break;
- case AR5K_BWMODE_DEFAULT:
-- slot_time = AR5K_INIT_SLOT_TIME_DEFAULT;
- default:
-- if (channel->hw_value & CHANNEL_CCK)
-+ slot_time = AR5K_INIT_SLOT_TIME_DEFAULT;
-+ if ((channel->hw_value & CHANNEL_CCK) && !ah->ah_short_slot)
- slot_time = AR5K_INIT_SLOT_TIME_B;
- break;
- }
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/desc.c
-+++ b/drivers/net/wireless/ath/ath5k/desc.c
-@@ -184,6 +184,7 @@ static int ath5k_hw_setup_4word_tx_desc(
- {
- struct ath5k_hw_4w_tx_ctl *tx_ctl;
- unsigned int frame_len;
-+ u32 txctl0 = 0, txctl1 = 0, txctl2 = 0, txctl3 = 0;
-
- tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
-
-@@ -209,7 +210,8 @@ static int ath5k_hw_setup_4word_tx_desc(
- tx_power = AR5K_TUNE_MAX_TXPOWER;
-
- /* Clear descriptor */
-- memset(&desc->ud.ds_tx5212, 0, sizeof(struct ath5k_hw_5212_tx_desc));
-+ memset(&desc->ud.ds_tx5212.tx_stat, 0,
-+ sizeof(desc->ud.ds_tx5212.tx_stat));
-
- /* Setup control descriptor */
-
-@@ -221,7 +223,7 @@ static int ath5k_hw_setup_4word_tx_desc(
- if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
- return -EINVAL;
-
-- tx_ctl->tx_control_0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
-+ txctl0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
-
- /* Verify and set buffer length */
-
-@@ -232,21 +234,17 @@ static int ath5k_hw_setup_4word_tx_desc(
- if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN)
- return -EINVAL;
-
-- tx_ctl->tx_control_1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
-+ txctl1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
-
-- tx_ctl->tx_control_0 |=
-- AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
-- AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
-- tx_ctl->tx_control_1 |= AR5K_REG_SM(type,
-- AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
-- tx_ctl->tx_control_2 = AR5K_REG_SM(tx_tries0,
-- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
-- tx_ctl->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
-+ txctl0 |= AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
-+ AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
-+ txctl1 |= AR5K_REG_SM(type, AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
-+ txctl2 = AR5K_REG_SM(tx_tries0, AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
-+ txctl3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
-
- #define _TX_FLAGS(_c, _flag) \
- if (flags & AR5K_TXDESC_##_flag) { \
-- tx_ctl->tx_control_##_c |= \
-- AR5K_4W_TX_DESC_CTL##_c##_##_flag; \
-+ txctl##_c |= AR5K_4W_TX_DESC_CTL##_c##_##_flag; \
- }
-
- _TX_FLAGS(0, CLRDMASK);
-@@ -262,8 +260,8 @@ static int ath5k_hw_setup_4word_tx_desc(
- * WEP crap
- */
- if (key_index != AR5K_TXKEYIX_INVALID) {
-- tx_ctl->tx_control_0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
-- tx_ctl->tx_control_1 |= AR5K_REG_SM(key_index,
-+ txctl0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
-+ txctl1 |= AR5K_REG_SM(key_index,
- AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_IDX);
- }
-
-@@ -274,12 +272,16 @@ static int ath5k_hw_setup_4word_tx_desc(
- if ((flags & AR5K_TXDESC_RTSENA) &&
- (flags & AR5K_TXDESC_CTSENA))
- return -EINVAL;
-- tx_ctl->tx_control_2 |= rtscts_duration &
-- AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
-- tx_ctl->tx_control_3 |= AR5K_REG_SM(rtscts_rate,
-+ txctl2 |= rtscts_duration & AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
-+ txctl3 |= AR5K_REG_SM(rtscts_rate,
- AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE);
- }
-
-+ tx_ctl->tx_control_0 = txctl0;
-+ tx_ctl->tx_control_1 = txctl1;
-+ tx_ctl->tx_control_2 = txctl2;
-+ tx_ctl->tx_control_3 = txctl3;
-+
- return 0;
- }
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -452,7 +452,6 @@ struct ath5k_tx_status {
- u16 ts_seqnum;
- u16 ts_tstamp;
- u8 ts_status;
-- u8 ts_rate[4];
- u8 ts_retry[4];
- u8 ts_final_idx;
- s8 ts_rssi;
---- a/drivers/net/wireless/ath/ath5k/desc.c
-+++ b/drivers/net/wireless/ath/ath5k/desc.c
-@@ -375,8 +375,6 @@ static int ath5k_hw_proc_2word_tx_status
- AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
- ts->ts_antenna = 1;
- ts->ts_status = 0;
-- ts->ts_rate[0] = AR5K_REG_MS(tx_ctl->tx_control_0,
-- AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
- ts->ts_retry[0] = ts->ts_longretry;
- ts->ts_final_idx = 0;
-
-@@ -439,32 +437,21 @@ static int ath5k_hw_proc_4word_tx_status
- ts->ts_retry[ts->ts_final_idx] = ts->ts_longretry;
- switch (ts->ts_final_idx) {
- case 3:
-- ts->ts_rate[3] = AR5K_REG_MS(tx_ctl->tx_control_3,
-- AR5K_4W_TX_DESC_CTL3_XMIT_RATE3);
--
- ts->ts_retry[2] = AR5K_REG_MS(tx_ctl->tx_control_2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2);
- ts->ts_longretry += ts->ts_retry[2];
- /* fall through */
- case 2:
-- ts->ts_rate[2] = AR5K_REG_MS(tx_ctl->tx_control_3,
-- AR5K_4W_TX_DESC_CTL3_XMIT_RATE2);
--
- ts->ts_retry[1] = AR5K_REG_MS(tx_ctl->tx_control_2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
- ts->ts_longretry += ts->ts_retry[1];
- /* fall through */
- case 1:
-- ts->ts_rate[1] = AR5K_REG_MS(tx_ctl->tx_control_3,
-- AR5K_4W_TX_DESC_CTL3_XMIT_RATE1);
--
- ts->ts_retry[0] = AR5K_REG_MS(tx_ctl->tx_control_2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
- ts->ts_longretry += ts->ts_retry[0];
- /* fall through */
- case 0:
-- ts->ts_rate[0] = tx_ctl->tx_control_3 &
-- AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
- break;
- }
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/desc.c
-+++ b/drivers/net/wireless/ath/ath5k/desc.c
-@@ -401,32 +401,38 @@ static int ath5k_hw_proc_4word_tx_status
- {
- struct ath5k_hw_4w_tx_ctl *tx_ctl;
- struct ath5k_hw_tx_status *tx_status;
-+ u32 txstat0, txstat1, txctl2;
-
- tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
- tx_status = &desc->ud.ds_tx5212.tx_stat;
-
-+ txstat1 = ACCESS_ONCE(tx_status->tx_status_1);
-+
- /* No frame has been send or error */
-- if (unlikely(!(tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE)))
-+ if (unlikely(!(txstat1 & AR5K_DESC_TX_STATUS1_DONE)))
- return -EINPROGRESS;
-
-+ txstat0 = ACCESS_ONCE(tx_status->tx_status_0);
-+ txctl2 = ACCESS_ONCE(tx_ctl->tx_control_2);
-+
- /*
- * Get descriptor status
- */
-- ts->ts_tstamp = AR5K_REG_MS(tx_status->tx_status_0,
-+ ts->ts_tstamp = AR5K_REG_MS(txstat0,
- AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
-- ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
-+ ts->ts_shortretry = AR5K_REG_MS(txstat0,
- AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
-- ts->ts_longretry = AR5K_REG_MS(tx_status->tx_status_0,
-+ ts->ts_longretry = AR5K_REG_MS(txstat0,
- AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
-- ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
-+ ts->ts_seqnum = AR5K_REG_MS(txstat1,
- AR5K_DESC_TX_STATUS1_SEQ_NUM);
-- ts->ts_rssi = AR5K_REG_MS(tx_status->tx_status_1,
-+ ts->ts_rssi = AR5K_REG_MS(txstat1,
- AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
-- ts->ts_antenna = (tx_status->tx_status_1 &
-+ ts->ts_antenna = (txstat1 &
- AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212) ? 2 : 1;
- ts->ts_status = 0;
-
-- ts->ts_final_idx = AR5K_REG_MS(tx_status->tx_status_1,
-+ ts->ts_final_idx = AR5K_REG_MS(txstat1,
- AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212);
-
- /* The longretry counter has the number of un-acked retries
-@@ -437,17 +443,17 @@ static int ath5k_hw_proc_4word_tx_status
- ts->ts_retry[ts->ts_final_idx] = ts->ts_longretry;
- switch (ts->ts_final_idx) {
- case 3:
-- ts->ts_retry[2] = AR5K_REG_MS(tx_ctl->tx_control_2,
-+ ts->ts_retry[2] = AR5K_REG_MS(txctl2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2);
- ts->ts_longretry += ts->ts_retry[2];
- /* fall through */
- case 2:
-- ts->ts_retry[1] = AR5K_REG_MS(tx_ctl->tx_control_2,
-+ ts->ts_retry[1] = AR5K_REG_MS(txctl2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
- ts->ts_longretry += ts->ts_retry[1];
- /* fall through */
- case 1:
-- ts->ts_retry[0] = AR5K_REG_MS(tx_ctl->tx_control_2,
-+ ts->ts_retry[0] = AR5K_REG_MS(txctl2,
- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
- ts->ts_longretry += ts->ts_retry[0];
- /* fall through */
-@@ -456,15 +462,14 @@ static int ath5k_hw_proc_4word_tx_status
- }
-
- /* TX error */
-- if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
-- if (tx_status->tx_status_0 &
-- AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
-+ if (!(txstat0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
-+ if (txstat0 & AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
- ts->ts_status |= AR5K_TXERR_XRETRY;
-
-- if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
-+ if (txstat0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
- ts->ts_status |= AR5K_TXERR_FIFO;
-
-- if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FILTERED)
-+ if (txstat0 & AR5K_DESC_TX_STATUS0_FILTERED)
- ts->ts_status |= AR5K_TXERR_FILT;
- }
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/desc.c
-+++ b/drivers/net/wireless/ath/ath5k/desc.c
-@@ -603,37 +603,37 @@ static int ath5k_hw_proc_5212_rx_status(
- struct ath5k_rx_status *rs)
- {
- struct ath5k_hw_rx_status *rx_status;
-+ u32 rxstat0, rxstat1;
-
- rx_status = &desc->ud.ds_rx.rx_stat;
-+ rxstat1 = ACCESS_ONCE(rx_status->rx_status_1);
-
- /* No frame received / not ready */
-- if (unlikely(!(rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_DONE)))
-+ if (unlikely(!(rxstat1 & AR5K_5212_RX_DESC_STATUS1_DONE)))
- return -EINPROGRESS;
-
- memset(rs, 0, sizeof(struct ath5k_rx_status));
-+ rxstat0 = ACCESS_ONCE(rx_status->rx_status_0);
-
- /*
- * Frame receive status
- */
-- rs->rs_datalen = rx_status->rx_status_0 &
-- AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
-- rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
-+ rs->rs_datalen = rxstat0 & AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
-+ rs->rs_rssi = AR5K_REG_MS(rxstat0,
- AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL);
-- rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
-+ rs->rs_rate = AR5K_REG_MS(rxstat0,
- AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE);
-- rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
-+ rs->rs_antenna = AR5K_REG_MS(rxstat0,
- AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA);
-- rs->rs_more = !!(rx_status->rx_status_0 &
-- AR5K_5212_RX_DESC_STATUS0_MORE);
-- rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
-+ rs->rs_more = !!(rxstat0 & AR5K_5212_RX_DESC_STATUS0_MORE);
-+ rs->rs_tstamp = AR5K_REG_MS(rxstat1,
- AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
-
- /*
- * Key table status
- */
-- if (rx_status->rx_status_1 & AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID)
-- rs->rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
-+ if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID)
-+ rs->rs_keyix = AR5K_REG_MS(rxstat1,
- AR5K_5212_RX_DESC_STATUS1_KEY_INDEX);
- else
- rs->rs_keyix = AR5K_RXKEYIX_INVALID;
-@@ -641,27 +641,22 @@ static int ath5k_hw_proc_5212_rx_status(
- /*
- * Receive/descriptor errors
- */
-- if (!(rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
-- if (rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
-+ if (!(rxstat1 & AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
-+ if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
- rs->rs_status |= AR5K_RXERR_CRC;
-
-- if (rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
-+ if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
- rs->rs_status |= AR5K_RXERR_PHY;
-- rs->rs_phyerr = AR5K_REG_MS(rx_status->rx_status_1,
-+ rs->rs_phyerr = AR5K_REG_MS(rxstat1,
- AR5K_5212_RX_DESC_STATUS1_PHY_ERROR_CODE);
- if (!ah->ah_capabilities.cap_has_phyerr_counters)
- ath5k_ani_phy_error_report(ah, rs->rs_phyerr);
- }
-
-- if (rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
-+ if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
- rs->rs_status |= AR5K_RXERR_DECRYPT;
-
-- if (rx_status->rx_status_1 &
-- AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
-+ if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
- rs->rs_status |= AR5K_RXERR_MIC;
- }
- return 0;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -452,11 +452,10 @@ struct ath5k_tx_status {
- u16 ts_seqnum;
- u16 ts_tstamp;
- u8 ts_status;
-- u8 ts_retry[4];
- u8 ts_final_idx;
-+ u8 ts_final_retry;
- s8 ts_rssi;
- u8 ts_shortretry;
-- u8 ts_longretry;
- u8 ts_virtcol;
- u8 ts_antenna;
- };
---- a/drivers/net/wireless/ath/ath5k/base.c
-+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -1573,20 +1573,27 @@ ath5k_tx_frame_completed(struct ath5k_so
- struct ath5k_txq *txq, struct ath5k_tx_status *ts)
- {
- struct ieee80211_tx_info *info;
-+ u8 tries[3];
- int i;
-
- sc->stats.tx_all_count++;
- sc->stats.tx_bytes_count += skb->len;
- info = IEEE80211_SKB_CB(skb);
-
-+ tries[0] = info->status.rates[0].count;
-+ tries[1] = info->status.rates[1].count;
-+ tries[2] = info->status.rates[2].count;
-+
- ieee80211_tx_info_clear_status(info);
-- for (i = 0; i <= ts->ts_final_idx; i++) {
-+
-+ for (i = 0; i < ts->ts_final_idx; i++) {
- struct ieee80211_tx_rate *r =
- &info->status.rates[i];
-
-- r->count = ts->ts_retry[i];
-+ r->count = tries[i];
- }
-
-+ info->status.rates[ts->ts_final_idx].count = ts->ts_final_retry;
- info->status.rates[ts->ts_final_idx + 1].idx = -1;
-
- if (unlikely(ts->ts_status)) {
---- a/drivers/net/wireless/ath/ath5k/desc.c
-+++ b/drivers/net/wireless/ath/ath5k/desc.c
-@@ -366,7 +366,7 @@ static int ath5k_hw_proc_2word_tx_status
- AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
- ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
- AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
-- ts->ts_longretry = AR5K_REG_MS(tx_status->tx_status_0,
-+ ts->ts_final_retry = AR5K_REG_MS(tx_status->tx_status_0,
- AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
- /*TODO: ts->ts_virtcol + test*/
- ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
-@@ -375,7 +375,6 @@ static int ath5k_hw_proc_2word_tx_status
- AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
- ts->ts_antenna = 1;
- ts->ts_status = 0;
-- ts->ts_retry[0] = ts->ts_longretry;
- ts->ts_final_idx = 0;
-
- if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
-@@ -401,7 +400,7 @@ static int ath5k_hw_proc_4word_tx_status
- {
- struct ath5k_hw_4w_tx_ctl *tx_ctl;
- struct ath5k_hw_tx_status *tx_status;
-- u32 txstat0, txstat1, txctl2;
-+ u32 txstat0, txstat1;
-
- tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
- tx_status = &desc->ud.ds_tx5212.tx_stat;
-@@ -413,7 +412,6 @@ static int ath5k_hw_proc_4word_tx_status
- return -EINPROGRESS;
-
- txstat0 = ACCESS_ONCE(tx_status->tx_status_0);
-- txctl2 = ACCESS_ONCE(tx_ctl->tx_control_2);
-
- /*
- * Get descriptor status
-@@ -422,7 +420,7 @@ static int ath5k_hw_proc_4word_tx_status
- AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
- ts->ts_shortretry = AR5K_REG_MS(txstat0,
- AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
-- ts->ts_longretry = AR5K_REG_MS(txstat0,
-+ ts->ts_final_retry = AR5K_REG_MS(txstat0,
- AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
- ts->ts_seqnum = AR5K_REG_MS(txstat1,
- AR5K_DESC_TX_STATUS1_SEQ_NUM);
-@@ -435,32 +433,6 @@ static int ath5k_hw_proc_4word_tx_status
- ts->ts_final_idx = AR5K_REG_MS(txstat1,
- AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212);
-
-- /* The longretry counter has the number of un-acked retries
-- * for the final rate. To get the total number of retries
-- * we have to add the retry counters for the other rates
-- * as well
-- */
-- ts->ts_retry[ts->ts_final_idx] = ts->ts_longretry;
-- switch (ts->ts_final_idx) {
-- case 3:
-- ts->ts_retry[2] = AR5K_REG_MS(txctl2,
-- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2);
-- ts->ts_longretry += ts->ts_retry[2];
-- /* fall through */
-- case 2:
-- ts->ts_retry[1] = AR5K_REG_MS(txctl2,
-- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
-- ts->ts_longretry += ts->ts_retry[1];
-- /* fall through */
-- case 1:
-- ts->ts_retry[0] = AR5K_REG_MS(txctl2,
-- AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
-- ts->ts_longretry += ts->ts_retry[0];
-- /* fall through */
-- case 0:
-- break;
-- }
--
- /* TX error */
- if (!(txstat0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
- if (txstat0 & AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/debug.c
-+++ b/drivers/net/wireless/ath/ath5k/debug.c
-@@ -888,64 +888,37 @@ static const struct file_operations fops
- void
- ath5k_debug_init_device(struct ath5k_softc *sc)
- {
-+ struct dentry *phydir;
-+
- sc->debug.level = ath5k_debug;
-
-- sc->debug.debugfs_phydir = debugfs_create_dir("ath5k",
-- sc->hw->wiphy->debugfsdir);
-+ phydir = debugfs_create_dir("ath5k", sc->hw->wiphy->debugfsdir);
-+ if (!phydir)
-+ return;
-
-- sc->debug.debugfs_debug = debugfs_create_file("debug",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc, &fops_debug);
--
-- sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUSR,
-- sc->debug.debugfs_phydir, sc, &fops_registers);
--
-- sc->debug.debugfs_beacon = debugfs_create_file("beacon",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc, &fops_beacon);
--
-- sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
-- sc->debug.debugfs_phydir, sc, &fops_reset);
--
-- sc->debug.debugfs_antenna = debugfs_create_file("antenna",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc, &fops_antenna);
--
-- sc->debug.debugfs_misc = debugfs_create_file("misc",
-- S_IRUSR,
-- sc->debug.debugfs_phydir, sc, &fops_misc);
--
-- sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc,
-- &fops_frameerrors);
--
-- sc->debug.debugfs_ani = debugfs_create_file("ani",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc,
-- &fops_ani);
--
-- sc->debug.debugfs_queue = debugfs_create_file("queue",
-- S_IWUSR | S_IRUSR,
-- sc->debug.debugfs_phydir, sc,
-- &fops_queue);
--}
-+ debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, sc,
-+ &fops_debug);
-
--void
--ath5k_debug_finish_device(struct ath5k_softc *sc)
--{
-- debugfs_remove(sc->debug.debugfs_debug);
-- debugfs_remove(sc->debug.debugfs_registers);
-- debugfs_remove(sc->debug.debugfs_beacon);
-- debugfs_remove(sc->debug.debugfs_reset);
-- debugfs_remove(sc->debug.debugfs_antenna);
-- debugfs_remove(sc->debug.debugfs_misc);
-- debugfs_remove(sc->debug.debugfs_frameerrors);
-- debugfs_remove(sc->debug.debugfs_ani);
-- debugfs_remove(sc->debug.debugfs_queue);
-- debugfs_remove(sc->debug.debugfs_phydir);
--}
-+ debugfs_create_file("registers", S_IRUSR, phydir, sc, &fops_registers);
-+
-+ debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, sc,
-+ &fops_beacon);
-
-+ debugfs_create_file("reset", S_IWUSR, phydir, sc, &fops_reset);
-+
-+ debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, sc,
-+ &fops_antenna);
-+
-+ debugfs_create_file("misc", S_IRUSR, phydir, sc, &fops_misc);
-+
-+ debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, sc,
-+ &fops_frameerrors);
-+
-+ debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, sc, &fops_ani);
-+
-+ debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, sc,
-+ &fops_queue);
-+}
-
- /* functions used in other places */
-
---- a/drivers/net/wireless/ath/ath5k/debug.h
-+++ b/drivers/net/wireless/ath/ath5k/debug.h
-@@ -68,17 +68,6 @@ struct ath5k_buf;
-
- struct ath5k_dbg_info {
- unsigned int level; /* debug level */
-- /* debugfs entries */
-- struct dentry *debugfs_phydir;
-- struct dentry *debugfs_debug;
-- struct dentry *debugfs_registers;
-- struct dentry *debugfs_beacon;
-- struct dentry *debugfs_reset;
-- struct dentry *debugfs_antenna;
-- struct dentry *debugfs_misc;
-- struct dentry *debugfs_frameerrors;
-- struct dentry *debugfs_ani;
-- struct dentry *debugfs_queue;
- };
-
- /**
-@@ -141,9 +130,6 @@ void
- ath5k_debug_init_device(struct ath5k_softc *sc);
-
- void
--ath5k_debug_finish_device(struct ath5k_softc *sc);
--
--void
- ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah);
-
- void
-@@ -167,9 +153,6 @@ static inline void
- ath5k_debug_init_device(struct ath5k_softc *sc) {}
-
- static inline void
--ath5k_debug_finish_device(struct ath5k_softc *sc) {}
--
--static inline void
- ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) {}
-
- static inline void
---- a/drivers/net/wireless/ath/ath5k/base.c
-+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -2901,7 +2901,6 @@ ath5k_deinit_softc(struct ath5k_softc *s
- * XXX: ??? detach ath5k_hw ???
- * Other than that, it's straightforward...
- */
-- ath5k_debug_finish_device(sc);
- ieee80211_unregister_hw(hw);
- ath5k_desc_free(sc);
- ath5k_txq_release(sc);
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -872,6 +872,19 @@ enum ath5k_int {
- AR5K_INT_QTRIG = 0x40000000, /* Non common */
- AR5K_INT_GLOBAL = 0x80000000,
-
-+ AR5K_INT_TX_ALL = AR5K_INT_TXOK
-+ | AR5K_INT_TXDESC
-+ | AR5K_INT_TXERR
-+ | AR5K_INT_TXEOL
-+ | AR5K_INT_TXURN,
-+
-+ AR5K_INT_RX_ALL = AR5K_INT_RXOK
-+ | AR5K_INT_RXDESC
-+ | AR5K_INT_RXERR
-+ | AR5K_INT_RXNOFRM
-+ | AR5K_INT_RXEOL
-+ | AR5K_INT_RXORN,
-+
- AR5K_INT_COMMON = AR5K_INT_RXOK
- | AR5K_INT_RXDESC
- | AR5K_INT_RXERR
---- a/drivers/net/wireless/ath/ath5k/base.c
-+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -1444,6 +1444,21 @@ ath5k_receive_frame_ok(struct ath5k_soft
- }
-
- static void
-+ath5k_set_current_imask(struct ath5k_softc *sc)
-+{
-+ enum ath5k_int imask = sc->imask;
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&sc->irqlock, flags);
-+ if (sc->rx_pending)
-+ imask &= ~AR5K_INT_RX_ALL;
-+ if (sc->tx_pending)
-+ imask &= ~AR5K_INT_TX_ALL;
-+ ath5k_hw_set_imr(sc->ah, imask);
-+ spin_unlock_irqrestore(&sc->irqlock, flags);
-+}
-+
-+static void
- ath5k_tasklet_rx(unsigned long data)
- {
- struct ath5k_rx_status rs = {};
-@@ -1506,6 +1521,8 @@ next:
- } while (ath5k_rxbuf_setup(sc, bf) == 0);
- unlock:
- spin_unlock(&sc->rxbuflock);
-+ sc->rx_pending = false;
-+ ath5k_set_current_imask(sc);
- }
-
-
-@@ -1693,6 +1710,9 @@ ath5k_tasklet_tx(unsigned long data)
- for (i=0; i < AR5K_NUM_TX_QUEUES; i++)
- if (sc->txqs[i].setup && (sc->ah->ah_txq_isr & BIT(i)))
- ath5k_tx_processq(sc, &sc->txqs[i]);
-+
-+ sc->tx_pending = false;
-+ ath5k_set_current_imask(sc);
- }
-
-
-@@ -2122,6 +2142,20 @@ ath5k_intr_calibration_poll(struct ath5k
- * AR5K_REG_ENABLE_BITS(ah, AR5K_CR, AR5K_CR_SWI); */
- }
-
-+static void
-+ath5k_schedule_rx(struct ath5k_softc *sc)
-+{
-+ sc->rx_pending = true;
-+ tasklet_schedule(&sc->rxtq);
-+}
-+
-+static void
-+ath5k_schedule_tx(struct ath5k_softc *sc)
-+{
-+ sc->tx_pending = true;
-+ tasklet_schedule(&sc->txtq);
-+}
-+
- irqreturn_t
- ath5k_intr(int irq, void *dev_id)
- {
-@@ -2164,7 +2198,7 @@ ath5k_intr(int irq, void *dev_id)
- ieee80211_queue_work(sc->hw, &sc->reset_work);
- }
- else
-- tasklet_schedule(&sc->rxtq);
-+ ath5k_schedule_rx(sc);
- } else {
- if (status & AR5K_INT_SWBA) {
- tasklet_hi_schedule(&sc->beacontq);
-@@ -2182,10 +2216,10 @@ ath5k_intr(int irq, void *dev_id)
- ath5k_hw_update_tx_triglevel(ah, true);
- }
- if (status & (AR5K_INT_RXOK | AR5K_INT_RXERR))
-- tasklet_schedule(&sc->rxtq);
-+ ath5k_schedule_rx(sc);
- if (status & (AR5K_INT_TXOK | AR5K_INT_TXDESC
- | AR5K_INT_TXERR | AR5K_INT_TXEOL))
-- tasklet_schedule(&sc->txtq);
-+ ath5k_schedule_tx(sc);
- if (status & AR5K_INT_BMISS) {
- /* TODO */
- }
-@@ -2204,6 +2238,9 @@ ath5k_intr(int irq, void *dev_id)
-
- } while (ath5k_hw_is_intr_pending(ah) && --counter > 0);
-
-+ if (sc->rx_pending || sc->tx_pending)
-+ ath5k_set_current_imask(sc);
-+
- if (unlikely(!counter))
- ATH5K_WARN(sc, "too many interrupts, giving up for now\n");
-
-@@ -2575,6 +2612,8 @@ done:
-
- static void stop_tasklets(struct ath5k_softc *sc)
- {
-+ sc->rx_pending = false;
-+ sc->tx_pending = false;
- tasklet_kill(&sc->rxtq);
- tasklet_kill(&sc->txtq);
- tasklet_kill(&sc->calib);
---- a/drivers/net/wireless/ath/ath5k/base.h
-+++ b/drivers/net/wireless/ath/ath5k/base.h
-@@ -207,6 +207,10 @@ struct ath5k_softc {
-
- enum ath5k_int imask; /* interrupt mask copy */
-
-+ spinlock_t irqlock;
-+ bool rx_pending; /* rx tasklet pending */
-+ bool tx_pending; /* tx tasklet pending */
-+
- u8 lladdr[ETH_ALEN];
- u8 bssidmask[ETH_ALEN];
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/caps.c
-+++ b/drivers/net/wireless/ath/ath5k/caps.c
-@@ -94,6 +94,9 @@ int ath5k_hw_set_capabilities(struct ath
- }
- }
-
-+ if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112)
-+ __clear_bit(AR5K_MODE_11A, caps->cap_mode);
-+
- /* Set number of supported TX queues */
- if (ah->ah_version == AR5K_AR5210)
- caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath.h
-+++ b/drivers/net/wireless/ath/ath.h
-@@ -123,14 +123,7 @@ struct ath_ops {
- };
-
- struct ath_common;
--
--struct ath_bus_ops {
-- enum ath_bus_type ath_bus_type;
-- void (*read_cachesize)(struct ath_common *common, int *csz);
-- bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
-- void (*bt_coex_prep)(struct ath_common *common);
-- void (*extn_synch_en)(struct ath_common *common);
--};
-+struct ath_bus_ops;
-
- struct ath_common {
- void *ah;
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -846,6 +846,14 @@ struct ath_hw {
- u32 ent_mode;
- };
-
-+struct ath_bus_ops {
-+ enum ath_bus_type ath_bus_type;
-+ void (*read_cachesize)(struct ath_common *common, int *csz);
-+ bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
-+ void (*bt_coex_prep)(struct ath_common *common);
-+ void (*extn_synch_en)(struct ath_common *common);
-+};
-+
- static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
- {
- return &ah->common;
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -1155,6 +1155,12 @@ struct ath5k_hw {
- struct ath5k_rx_status *);
- };
-
-+struct ath_bus_ops {
-+ enum ath_bus_type ath_bus_type;
-+ void (*read_cachesize)(struct ath_common *common, int *csz);
-+ bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
-+};
-+
- /*
- * Prototypes
- */
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/ath5k.h
-+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
-@@ -1159,6 +1159,7 @@ struct ath_bus_ops {
- enum ath_bus_type ath_bus_type;
- void (*read_cachesize)(struct ath_common *common, int *csz);
- bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
-+ int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac);
- };
-
- /*
-@@ -1244,7 +1245,6 @@ int ath5k_hw_dma_stop(struct ath5k_hw *a
- /* EEPROM access functions */
- int ath5k_eeprom_init(struct ath5k_hw *ah);
- void ath5k_eeprom_detach(struct ath5k_hw *ah);
--int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac);
-
-
- /* Protocol Control Unit Functions */
---- a/drivers/net/wireless/ath/ath5k/eeprom.c
-+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
-@@ -1723,46 +1723,6 @@ ath5k_eeprom_read_spur_chans(struct ath5
- return ret;
- }
-
--/*
-- * Read the MAC address from eeprom or platform_data
-- */
--int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
--{
-- u8 mac_d[ETH_ALEN] = {};
-- u32 total, offset;
-- u16 data;
-- int octet;
-- struct ath5k_platform_data *pdata = NULL;
--
-- if (ah->ah_sc->pdev)
-- pdata = ah->ah_sc->pdev->dev.platform_data;
--
-- if (pdata && pdata->macaddr)
-- {
-- memcpy(mac, pdata->macaddr, ETH_ALEN);
-- return 0;
-- }
--
-- AR5K_EEPROM_READ(0x20, data);
--
-- for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
-- AR5K_EEPROM_READ(offset, data);
--
-- total += data;
-- mac_d[octet + 1] = data & 0xff;
-- mac_d[octet] = data >> 8;
-- octet += 2;
-- }
--
-- if (!total || total == 3 * 0xffff)
-- return -EINVAL;
--
-- memcpy(mac, mac_d, ETH_ALEN);
--
-- return 0;
--}
--
--
- /***********************\
- * Init/Detach functions *
- \***********************/
---- a/drivers/net/wireless/ath/ath5k/pci.c
-+++ b/drivers/net/wireless/ath/ath5k/pci.c
-@@ -18,6 +18,7 @@
- #include <linux/pci.h>
- #include <linux/pci-aspm.h>
- #include <linux/ath5k_platform.h>
-+#include <linux/etherdevice.h>
- #include "../ath.h"
- #include "ath5k.h"
- #include "debug.h"
-@@ -122,11 +123,52 @@ int ath5k_hw_read_srev(struct ath5k_hw *
- return 0;
- }
-
-+/*
-+ * Read the MAC address from eeprom or platform_data
-+ */
-+static int ath5k_pci_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
-+{
-+ u8 mac_d[ETH_ALEN] = {};
-+ u32 total, offset;
-+ u16 data;
-+ int octet;
-+ struct ath5k_platform_data *pdata = NULL;
-+
-+ if (ah->ah_sc->pdev)
-+ pdata = ah->ah_sc->pdev->dev.platform_data;
-+
-+ if (pdata && pdata->macaddr)
-+ {
-+ memcpy(mac, pdata->macaddr, ETH_ALEN);
-+ return 0;
-+ }
-+
-+ AR5K_EEPROM_READ(0x20, data);
-+
-+ for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
-+ AR5K_EEPROM_READ(offset, data);
-+
-+ total += data;
-+ mac_d[octet + 1] = data & 0xff;
-+ mac_d[octet] = data >> 8;
-+ octet += 2;
-+ }
-+
-+ if (!total || total == 3 * 0xffff)
-+ return -EINVAL;
-+
-+ memcpy(mac, mac_d, ETH_ALEN);
-+
-+ return 0;
-+}
-+
-+
- /* Common ath_bus_opts structure */
- static const struct ath_bus_ops ath_pci_bus_ops = {
- .ath_bus_type = ATH_PCI,
- .read_cachesize = ath5k_pci_read_cachesize,
- .eeprom_read = ath5k_pci_eeprom_read,
-+ .eeprom_read_mac = ath5k_pci_eeprom_read_mac,
- };
-
- /********************\
---- a/drivers/net/wireless/ath/ath5k/ahb.c
-+++ b/drivers/net/wireless/ath/ath5k/ahb.c
-@@ -18,6 +18,7 @@
-
- #include <linux/nl80211.h>
- #include <linux/platform_device.h>
-+#include <linux/etherdevice.h>
- #include <ar231x_platform.h>
- #include "ath5k.h"
- #include "debug.h"
-@@ -62,10 +63,27 @@ int ath5k_hw_read_srev(struct ath5k_hw *
- return 0;
- }
-
-+static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
-+{
-+ struct ath5k_softc *sc = ah->ah_sc;
-+ struct platform_device *pdev = to_platform_device(sc->dev);
-+ struct ar231x_board_config *bcfg = pdev->dev.platform_data;
-+ u8 *cfg_mac;
-+
-+ if (to_platform_device(sc->dev)->id == 0)
-+ cfg_mac = bcfg->config->wlan0_mac;
-+ else
-+ cfg_mac = bcfg->config->wlan1_mac;
-+
-+ memcpy(mac, cfg_mac, ETH_ALEN);
-+ return 0;
-+}
-+
- static const struct ath_bus_ops ath_ahb_bus_ops = {
- .ath_bus_type = ATH_AHB,
- .read_cachesize = ath5k_ahb_read_cachesize,
- .eeprom_read = ath5k_ahb_eeprom_read,
-+ .eeprom_read_mac = ath5k_ahb_eeprom_read_mac,
- };
-
- /*Initialization*/
---- a/drivers/net/wireless/ath/ath5k/base.c
-+++ b/drivers/net/wireless/ath/ath5k/base.c
-@@ -2880,7 +2880,7 @@ ath5k_init(struct ieee80211_hw *hw)
- INIT_WORK(&sc->reset_work, ath5k_reset_work);
- INIT_DELAYED_WORK(&sc->tx_complete_work, ath5k_tx_complete_poll_work);
-
-- ret = ath5k_eeprom_read_mac(ah, mac);
-+ ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac);
- if (ret) {
- ATH5K_ERR(sc, "unable to read address from EEPROM\n");
- goto err_queues;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/attach.c
-+++ b/drivers/net/wireless/ath/ath5k/attach.c
-@@ -318,7 +318,7 @@ int ath5k_hw_init(struct ath5k_softc *sc
- AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211);
-
- if (srev >= AR5K_SREV_AR5212_V4 &&
-- (ee->ee_version >= AR5K_EEPROM_VERSION_5_0 &&
-+ (ee->ee_version < AR5K_EEPROM_VERSION_5_0 ||
- !AR5K_EEPROM_AES_DIS(ee->ee_misc5)))
- common->crypt_caps |= ATH_CRYPT_CAP_CIPHER_AESCCM;
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/base.h
-+++ b/drivers/net/wireless/ath/ath5k/base.h
-@@ -193,12 +193,13 @@ struct ath5k_softc {
- dma_addr_t desc_daddr; /* DMA (physical) address */
- size_t desc_len; /* size of TX/RX descriptors */
-
-- DECLARE_BITMAP(status, 5);
-+ DECLARE_BITMAP(status, 6);
- #define ATH_STAT_INVALID 0 /* disable hardware accesses */
- #define ATH_STAT_MRRETRY 1 /* multi-rate retry support */
- #define ATH_STAT_PROMISC 2
- #define ATH_STAT_LEDSOFT 3 /* enable LED gpio status */
- #define ATH_STAT_STARTED 4 /* opened & irqs enabled */
-+#define ATH_STAT_2G_DISABLED 5 /* multiband radio without 2G */
-
- unsigned int filter_flags; /* HW flags, AR5K_RX_FILTER_* */
- struct ieee80211_channel *curchan; /* current h/w channel */
---- a/drivers/net/wireless/ath/ath5k/ahb.c
-+++ b/drivers/net/wireless/ath/ath5k/ahb.c
-@@ -160,6 +160,16 @@ static int ath_ahb_probe(struct platform
- else
- reg |= AR5K_AR5312_ENABLE_WLAN1;
- __raw_writel(reg, (void __iomem *) AR5K_AR5312_ENABLE);
-+
-+ /*
-+ * On a dual-band AR5312, the multiband radio is only
-+ * used as pass-through. Disable 2 GHz support in the
-+ * driver for it
-+ */
-+ if (to_platform_device(sc->dev)->id == 0 &&
-+ (bcfg->config->flags & (BD_WLAN0|BD_WLAN1)) ==
-+ (BD_WLAN1|BD_WLAN0))
-+ __set_bit(ATH_STAT_2G_DISABLED, sc->status);
- }
-
- ret = ath5k_init_softc(sc, &ath_ahb_bus_ops);
---- a/drivers/net/wireless/ath/ath5k/attach.c
-+++ b/drivers/net/wireless/ath/ath5k/attach.c
-@@ -313,6 +313,11 @@ int ath5k_hw_init(struct ath5k_softc *sc
- goto err;
- }
-
-+ if (test_bit(ATH_STAT_2G_DISABLED, sc->status)) {
-+ __clear_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode);
-+ __clear_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode);
-+ }
-+
- /* Crypto settings */
- common->keymax = (sc->ah->ah_version == AR5K_AR5210 ?
- AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211);
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1077,6 +1077,53 @@ static const struct file_operations fops
+@@ -1115,6 +1115,53 @@ static const struct file_operations fops
.llseek = default_llseek,/* read accesses f_pos */
};
int ath9k_init_debug(struct ath_hw *ah)
{
struct ath_common *common = ath9k_hw_common(ah);
-@@ -1125,6 +1172,9 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1163,6 +1210,9 @@ int ath9k_init_debug(struct ath_hw *ah)
debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1437,8 +1437,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -1450,8 +1450,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
REG_WRITE(ah, AR_OBS, 8);
if (ah->config.rx_intr_mitigation) {
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -361,7 +361,7 @@ struct ath_vif {
+@@ -367,7 +367,7 @@ struct ath_vif {
* number of beacon intervals, the game's up.
*/
#define BSTUCK_THRESH 9
+++ /dev/null
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -2227,6 +2227,18 @@ static inline int ieee80211_sta_ps_trans
- #define IEEE80211_TX_STATUS_HEADROOM 13
-
- /**
-+ * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
-+ *
-+ * If a driver buffers frames for a powersave station instead of passing
-+ * them back to mac80211 for retransmission, the station needs to be told
-+ * to wake up using the TIM bitmap in the beacon.
-+ *
-+ * This function sets the station's TIM bit - it will be cleared when the
-+ * station wakes up.
-+ */
-+void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
-+
-+/**
- * ieee80211_tx_status - transmit status callback
- *
- * Call this function for all transmitted frames after they have been
---- a/net/mac80211/sta_info.c
-+++ b/net/mac80211/sta_info.c
-@@ -609,7 +609,8 @@ static bool sta_info_cleanup_expire_buff
- #endif
- dev_kfree_skb(skb);
-
-- if (skb_queue_empty(&sta->ps_tx_buf))
-+ if (skb_queue_empty(&sta->ps_tx_buf) &&
-+ !test_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF))
- sta_info_clear_tim_bit(sta);
- }
-
-@@ -893,6 +894,7 @@ void ieee80211_sta_ps_deliver_wakeup(str
- struct ieee80211_local *local = sdata->local;
- int sent, buffered;
-
-+ clear_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
- if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
- drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
-
-@@ -985,3 +987,12 @@ void ieee80211_sta_block_awake(struct ie
- ieee80211_queue_work(hw, &sta->drv_unblock_wk);
- }
- EXPORT_SYMBOL(ieee80211_sta_block_awake);
-+
-+void ieee80211_sta_set_tim(struct ieee80211_sta *pubsta)
-+{
-+ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
-+
-+ set_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
-+ sta_info_set_tim_bit(sta);
-+}
-+EXPORT_SYMBOL(ieee80211_sta_set_tim);
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -43,6 +43,8 @@
- * be in the queues
- * @WLAN_STA_PSPOLL: Station sent PS-poll while driver was keeping
- * station in power-save mode, reply when the driver unblocks.
-+ * @WLAN_STA_PS_DRIVER_BUF: Station has frames pending in driver internal
-+ * buffers. Automatically cleared on station wake-up.
- */
- enum ieee80211_sta_info_flags {
- WLAN_STA_AUTH = 1<<0,
-@@ -58,6 +60,7 @@ enum ieee80211_sta_info_flags {
- WLAN_STA_BLOCK_BA = 1<<11,
- WLAN_STA_PS_DRIVER = 1<<12,
- WLAN_STA_PSPOLL = 1<<13,
-+ WLAN_STA_PS_DRIVER_BUF = 1<<14,
- };
-
- #define STA_TID_NUM 16
--- /dev/null
+--- a/net/mac80211/rc80211_minstrel_ht.c
++++ b/net/mac80211/rc80211_minstrel_ht.c
+@@ -355,10 +355,12 @@ minstrel_downgrade_rate(struct minstrel_
+ }
+
+ static void
+-minstrel_aggr_check(struct minstrel_priv *mp, struct ieee80211_sta *pubsta, struct sk_buff *skb)
++minstrel_aggr_check(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
++ struct ieee80211_sta *pubsta, struct sk_buff *skb)
+ {
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
++ unsigned long t1, t2;
+ u16 tid;
+
+ if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
+@@ -374,6 +376,12 @@ minstrel_aggr_check(struct minstrel_priv
+ if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO)
+ return;
+
++ t1 = mi->last_aggr_start_time[tid];
++ t2 = t1 + msecs_to_jiffies(5000);
++ if (unlikely(time_in_range(jiffies, t1, t2)))
++ return;
++
++ mi->last_aggr_start_time[tid] = jiffies;
+ ieee80211_start_tx_ba_session(pubsta, tid, 5000);
+ }
+
+@@ -452,7 +460,7 @@ minstrel_ht_tx_status(void *priv, struct
+
+ if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
+ minstrel_ht_update_stats(mp, mi);
+- minstrel_aggr_check(mp, sta, skb);
++ minstrel_aggr_check(mp, mi, sta, skb);
+ }
+ }
+
+--- a/net/mac80211/rc80211_minstrel_ht.h
++++ b/net/mac80211/rc80211_minstrel_ht.h
+@@ -109,6 +109,8 @@ struct minstrel_ht_sta {
+
+ /* MCS rate group info and statistics */
+ struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
++
++ unsigned long last_aggr_start_time[IEEE80211_QOS_CTL_TID_MASK + 1];
+ };
+
+ struct minstrel_ht_sta_priv {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -200,6 +200,7 @@ struct ath_atx_ac {
- int sched;
- struct list_head list;
- struct list_head tid_q;
-+ bool clear_ps_filter;
- };
-
- struct ath_frame_info {
-@@ -257,6 +258,8 @@ struct ath_node {
- struct ath_atx_ac ac[WME_NUM_AC];
- u16 maxampdu;
- u8 mpdudensity;
-+
-+ bool sleeping;
- };
-
- #define AGGR_CLEANUP BIT(1)
-@@ -338,6 +341,9 @@ int ath_tx_aggr_start(struct ath_softc *
- void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
- void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
-
-+void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
-+bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an);
-+
- /********/
- /* VIFs */
- /********/
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1792,6 +1792,27 @@ static int ath9k_sta_remove(struct ieee8
- return 0;
- }
-
-+static void ath9k_sta_notify(struct ieee80211_hw *hw,
-+ struct ieee80211_vif *vif,
-+ enum sta_notify_cmd cmd,
-+ struct ieee80211_sta *sta)
-+{
-+ struct ath_softc *sc = hw->priv;
-+ struct ath_node *an = (struct ath_node *) sta->drv_priv;
-+
-+ switch (cmd) {
-+ case STA_NOTIFY_SLEEP:
-+ an->sleeping = true;
-+ if (ath_tx_aggr_sleep(sc, an))
-+ ieee80211_sta_set_tim(sta);
-+ break;
-+ case STA_NOTIFY_AWAKE:
-+ an->sleeping = false;
-+ ath_tx_aggr_wakeup(sc, an);
-+ break;
-+ }
-+}
-+
- static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
- const struct ieee80211_tx_queue_params *params)
- {
-@@ -2198,6 +2219,7 @@ struct ieee80211_ops ath9k_ops = {
- .configure_filter = ath9k_configure_filter,
- .sta_add = ath9k_sta_add,
- .sta_remove = ath9k_sta_remove,
-+ .sta_notify = ath9k_sta_notify,
- .conf_tx = ath9k_conf_tx,
- .bss_info_changed = ath9k_bss_info_changed,
- .set_key = ath9k_set_key,
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -357,6 +357,7 @@ static void ath_tx_complete_aggr(struct
- struct ath_frame_info *fi;
- int nframes;
- u8 tidno;
-+ bool clear_filter;
-
- skb = bf->bf_mpdu;
- hdr = (struct ieee80211_hdr *)skb->data;
-@@ -441,22 +442,24 @@ static void ath_tx_complete_aggr(struct
- /* transmit completion */
- acked_cnt++;
- } else {
-- if (!(tid->state & AGGR_CLEANUP) && retry) {
-- if (fi->retries < ATH_MAX_SW_RETRIES) {
-- ath_tx_set_retry(sc, txq, bf->bf_mpdu);
-- txpending = 1;
-- } else {
-- bf->bf_state.bf_type |= BUF_XRETRY;
-- txfail = 1;
-- sendbar = 1;
-- txfail_cnt++;
-- }
-- } else {
-+ if ((tid->state & AGGR_CLEANUP) || !retry) {
- /*
- * cleanup in progress, just fail
- * the un-acked sub-frames
- */
- txfail = 1;
-+ } else if (fi->retries < ATH_MAX_SW_RETRIES) {
-+ if (!(ts->ts_status & ATH9K_TXERR_FILT) ||
-+ !an->sleeping)
-+ ath_tx_set_retry(sc, txq, bf->bf_mpdu);
-+
-+ clear_filter = true;
-+ txpending = 1;
-+ } else {
-+ bf->bf_state.bf_type |= BUF_XRETRY;
-+ txfail = 1;
-+ sendbar = 1;
-+ txfail_cnt++;
- }
- }
-
-@@ -496,6 +499,7 @@ static void ath_tx_complete_aggr(struct
- !txfail, sendbar);
- } else {
- /* retry the un-acked ones */
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, false);
- if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) {
- if (bf->bf_next == NULL && bf_last->bf_stale) {
- struct ath_buf *tbf;
-@@ -546,7 +550,12 @@ static void ath_tx_complete_aggr(struct
-
- /* prepend un-acked frames to the beginning of the pending frame queue */
- if (!list_empty(&bf_pending)) {
-+ if (an->sleeping)
-+ ieee80211_sta_set_tim(sta);
-+
- spin_lock_bh(&txq->axq_lock);
-+ if (clear_filter)
-+ tid->ac->clear_ps_filter = true;
- list_splice(&bf_pending, &tid->buf_q);
- ath_tx_queue_tid(txq, tid);
- spin_unlock_bh(&txq->axq_lock);
-@@ -816,6 +825,11 @@ static void ath_tx_sched_aggr(struct ath
- bf = list_first_entry(&bf_q, struct ath_buf, list);
- bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
-
-+ if (tid->ac->clear_ps_filter) {
-+ tid->ac->clear_ps_filter = false;
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
-+ }
-+
- /* if only one frame, send as non-aggregate */
- if (bf == bf->bf_lastbf) {
- fi = get_frame_info(bf->bf_mpdu);
-@@ -896,6 +910,67 @@ void ath_tx_aggr_stop(struct ath_softc *
- ath_tx_flush_tid(sc, txtid);
- }
-
-+bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
-+{
-+ struct ath_atx_tid *tid;
-+ struct ath_atx_ac *ac;
-+ struct ath_txq *txq;
-+ bool buffered = false;
-+ int tidno;
-+
-+ for (tidno = 0, tid = &an->tid[tidno];
-+ tidno < WME_NUM_TID; tidno++, tid++) {
-+
-+ if (!tid->sched)
-+ continue;
-+
-+ ac = tid->ac;
-+ txq = ac->txq;
-+
-+ spin_lock_bh(&txq->axq_lock);
-+
-+ if (!list_empty(&tid->buf_q))
-+ buffered = true;
-+
-+ tid->sched = false;
-+ list_del(&tid->list);
-+
-+ if (ac->sched) {
-+ ac->sched = false;
-+ list_del(&ac->list);
-+ }
-+
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-+
-+ return buffered;
-+}
-+
-+void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
-+{
-+ struct ath_atx_tid *tid;
-+ struct ath_atx_ac *ac;
-+ struct ath_txq *txq;
-+ int tidno;
-+
-+ for (tidno = 0, tid = &an->tid[tidno];
-+ tidno < WME_NUM_TID; tidno++, tid++) {
-+
-+ ac = tid->ac;
-+ txq = ac->txq;
-+
-+ spin_lock_bh(&txq->axq_lock);
-+ ac->clear_ps_filter = true;
-+
-+ if (!list_empty(&tid->buf_q) && !tid->paused) {
-+ ath_tx_queue_tid(txq, tid);
-+ ath_txq_schedule(sc, txq);
-+ }
-+
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-+}
-+
- void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
- {
- struct ath_atx_tid *txtid;
-@@ -1491,7 +1566,6 @@ static int setup_tx_flags(struct sk_buff
- struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
- int flags = 0;
-
-- flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */
- flags |= ATH9K_TXDESC_INTREQ;
-
- if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
-@@ -1754,6 +1828,9 @@ static void ath_tx_start_dma(struct ath_
- if (txctl->paprd)
- bf->bf_state.bfs_paprd_timestamp = jiffies;
-
-+ if (tx_info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
-+
- ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
- }
-
---- a/drivers/net/wireless/ath/ath9k/hw-ops.h
-+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
-@@ -122,6 +122,11 @@ static inline void ath9k_hw_set11n_burst
- ath9k_hw_ops(ah)->set11n_burstduration(ah, ds, burstDuration);
- }
-
-+static inline void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ ath9k_hw_ops(ah)->set_clrdmask(ah, ds, val);
-+}
-+
- /* Private hardware call ops */
-
- /* PHY ops */
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -626,6 +626,7 @@ struct ath_hw_ops {
- void (*clr11n_aggr)(struct ath_hw *ah, void *ds);
- void (*set11n_burstduration)(struct ath_hw *ah, void *ds,
- u32 burstDuration);
-+ void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
- };
-
- struct ath_nf_limits {
---- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-@@ -290,7 +290,6 @@ static void ar9002_hw_set11n_txdesc(stru
- | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
- | SM(txPower, AR_XmitPower)
- | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
-- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
- | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
- | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
-
-@@ -311,6 +310,16 @@ static void ar9002_hw_set11n_txdesc(stru
- }
- }
-
-+static void ar9002_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ struct ar5416_desc *ads = AR5416DESC(ds);
-+
-+ if (val)
-+ ads->ds_ctl0 |= AR_ClrDestMask;
-+ else
-+ ads->ds_ctl0 &= ~AR_ClrDestMask;
-+}
-+
- static void ar9002_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
- void *lastds,
- u32 durUpdateEn, u32 rtsctsRate,
-@@ -448,4 +457,5 @@ void ar9002_hw_attach_mac_ops(struct ath
- ops->set11n_aggr_last = ar9002_hw_set11n_aggr_last;
- ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
- ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
-+ ops->set_clrdmask = ar9002_hw_set_clrdmask;
- }
---- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
-@@ -329,7 +329,6 @@ static void ar9003_hw_set11n_txdesc(stru
- | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
- | SM(txpower, AR_XmitPower)
- | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
-- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
- | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
- | (flags & ATH9K_TXDESC_LOWRXCHAIN ? AR_LowRxChain : 0);
-
-@@ -350,6 +349,16 @@ static void ar9003_hw_set11n_txdesc(stru
- ads->ctl22 = 0;
- }
-
-+static void ar9003_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ struct ar9003_txc *ads = (struct ar9003_txc *) ds;
-+
-+ if (val)
-+ ads->ctl11 |= AR_ClrDestMask;
-+ else
-+ ads->ctl11 &= ~AR_ClrDestMask;
-+}
-+
- static void ar9003_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
- void *lastds,
- u32 durUpdateEn, u32 rtsctsRate,
-@@ -510,6 +519,7 @@ void ar9003_hw_attach_mac_ops(struct ath
- ops->set11n_aggr_last = ar9003_hw_set11n_aggr_last;
- ops->clr11n_aggr = ar9003_hw_clr11n_aggr;
- ops->set11n_burstduration = ar9003_hw_set11n_burstduration;
-+ ops->set_clrdmask = ar9003_hw_set_clrdmask;
- }
-
- void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
---- a/drivers/net/wireless/ath/ath9k/mac.h
-+++ b/drivers/net/wireless/ath/ath9k/mac.h
-@@ -239,7 +239,6 @@ struct ath_desc {
- void *ds_vdata;
- } __packed __aligned(4);
-
--#define ATH9K_TXDESC_CLRDMASK 0x0001
- #define ATH9K_TXDESC_NOACK 0x0002
- #define ATH9K_TXDESC_RTSENA 0x0004
- #define ATH9K_TXDESC_CTSENA 0x0008
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -956,6 +956,9 @@ static int ath9k_rx_skb_preprocess(struc
+ struct ieee80211_rx_status *rx_status,
+ bool *decrypt_error)
+ {
++ struct ath_hw *ah = common->ah;
++ int noise;
++
+ memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
+
+ /*
+@@ -976,7 +979,13 @@ static int ath9k_rx_skb_preprocess(struc
+
+ rx_status->band = hw->conf.channel->band;
+ rx_status->freq = hw->conf.channel->center_freq;
+- rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
++
++ if (ah->curchan && ah->curchan->noisefloor)
++ noise = ah->curchan->noisefloor;
++ else
++ noise = ATH_DEFAULT_NOISE_FLOOR;
++
++ rx_status->signal = noise + rx_stats->rs_rssi;
+ rx_status->antenna = rx_stats->rs_antenna;
+ rx_status->flag |= RX_FLAG_MACTIME_MPDU;
+
+++ /dev/null
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -355,10 +355,12 @@ minstrel_downgrade_rate(struct minstrel_
- }
-
- static void
--minstrel_aggr_check(struct minstrel_priv *mp, struct ieee80211_sta *pubsta, struct sk_buff *skb)
-+minstrel_aggr_check(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
-+ struct ieee80211_sta *pubsta, struct sk_buff *skb)
- {
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
- struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
-+ unsigned long t1, t2;
- u16 tid;
-
- if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
-@@ -374,6 +376,12 @@ minstrel_aggr_check(struct minstrel_priv
- if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO)
- return;
-
-+ t1 = mi->last_aggr_start_time[tid];
-+ t2 = t1 + msecs_to_jiffies(5000);
-+ if (unlikely(time_in_range(jiffies, t1, t2)))
-+ return;
-+
-+ mi->last_aggr_start_time[tid] = jiffies;
- ieee80211_start_tx_ba_session(pubsta, tid, 5000);
- }
-
-@@ -452,7 +460,7 @@ minstrel_ht_tx_status(void *priv, struct
-
- if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
- minstrel_ht_update_stats(mp, mi);
-- minstrel_aggr_check(mp, sta, skb);
-+ minstrel_aggr_check(mp, mi, sta, skb);
- }
- }
-
---- a/net/mac80211/rc80211_minstrel_ht.h
-+++ b/net/mac80211/rc80211_minstrel_ht.h
-@@ -109,6 +109,8 @@ struct minstrel_ht_sta {
-
- /* MCS rate group info and statistics */
- struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
-+
-+ unsigned long last_aggr_start_time[IEEE80211_QOS_CTL_TID_MASK + 1];
- };
-
- struct minstrel_ht_sta_priv {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -956,6 +956,9 @@ static int ath9k_rx_skb_preprocess(struc
- struct ieee80211_rx_status *rx_status,
- bool *decrypt_error)
- {
-+ struct ath_hw *ah = common->ah;
-+ int noise;
-+
- memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
-
- /*
-@@ -976,7 +979,13 @@ static int ath9k_rx_skb_preprocess(struc
-
- rx_status->band = hw->conf.channel->band;
- rx_status->freq = hw->conf.channel->center_freq;
-- rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
-+
-+ if (ah->curchan && ah->curchan->noisefloor)
-+ noise = ah->curchan->noisefloor;
-+ else
-+ noise = ATH_DEFAULT_NOISE_FLOOR;
-+
-+ rx_status->signal = noise + rx_stats->rs_rssi;
- rx_status->antenna = rx_stats->rs_antenna;
- rx_status->flag |= RX_FLAG_MACTIME_MPDU;
-
--- /dev/null
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -31,7 +31,6 @@
+ * frames.
+ * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
+ * @WLAN_STA_WME: Station is a QoS-STA.
+- * @WLAN_STA_WDS: Station is one of our WDS peers.
+ * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
+ * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
+ * frame to this station is transmitted.
+@@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
+ WLAN_STA_SHORT_PREAMBLE = 1<<4,
+ WLAN_STA_ASSOC_AP = 1<<5,
+ WLAN_STA_WME = 1<<6,
+- WLAN_STA_WDS = 1<<7,
+ WLAN_STA_CLEAR_PS_FILT = 1<<9,
+ WLAN_STA_MFP = 1<<10,
+ WLAN_STA_BLOCK_BA = 1<<11,
+--- a/net/mac80211/debugfs_sta.c
++++ b/net/mac80211/debugfs_sta.c
+@@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
+ char buf[100];
+ struct sta_info *sta = file->private_data;
+ u32 staflags = get_sta_flags(sta);
+- int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
++ int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
+ staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
+ staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
+ staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
+@@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
+ staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
+ staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
+ staflags & WLAN_STA_WME ? "WME\n" : "",
+- staflags & WLAN_STA_WDS ? "WDS\n" : "",
+ staflags & WLAN_STA_MFP ? "MFP\n" : "");
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+ }
--- /dev/null
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2330,13 +2330,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
+
+ if (!ieee80211_vif_is_mesh(&sdata->vif) &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC &&
+- sdata->vif.type != NL80211_IFTYPE_STATION)
++ sdata->vif.type != NL80211_IFTYPE_STATION &&
++ sdata->vif.type != NL80211_IFTYPE_WDS)
+ return RX_DROP_MONITOR;
+
+ switch (stype) {
+ case cpu_to_le16(IEEE80211_STYPE_BEACON):
+ case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
+- /* process for all: mesh, mlme, ibss */
++ /* process for all: mesh, mlme, ibss, wds */
+ break;
+ case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
+ case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
+@@ -2716,7 +2717,10 @@ static int prepare_for_handlers(struct i
+ }
+ break;
+ case NL80211_IFTYPE_WDS:
+- if (bssid || !ieee80211_is_data(hdr->frame_control))
++ if (bssid) {
++ if (!ieee80211_is_beacon(hdr->frame_control))
++ return 0;
++ } else if (!ieee80211_is_data(hdr->frame_control))
+ return 0;
+ if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
+ return 0;
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
+ {
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_local *local = sdata->local;
+- struct sta_info *sta;
+ u32 changed = 0;
+ int res;
+ u32 hw_reconf_flags = 0;
+@@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
+
+ set_bit(SDATA_STATE_RUNNING, &sdata->state);
+
+- if (sdata->vif.type == NL80211_IFTYPE_WDS) {
+- /* Create STA entry for the WDS peer */
+- sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
+- GFP_KERNEL);
+- if (!sta) {
+- res = -ENOMEM;
+- goto err_del_interface;
+- }
+-
+- /* no locking required since STA is not live yet */
+- sta->flags |= WLAN_STA_AUTHORIZED;
+-
+- res = sta_info_insert(sta);
+- if (res) {
+- /* STA has been freed */
+- goto err_del_interface;
+- }
+-
+- rate_control_rate_init(sta);
+- }
+-
+ /*
+ * set_multicast_list will be invoked by the networking core
+ * which will check whether any increments here were done in
+@@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
+ netif_tx_start_all_queues(dev);
+
+ return 0;
+- err_del_interface:
+- drv_remove_interface(local, &sdata->vif);
++
+ err_stop:
+ if (!local->open_count)
+ drv_stop(local);
+@@ -717,6 +694,70 @@ static void ieee80211_if_setup(struct ne
+ dev->destructor = free_netdev;
+ }
+
++static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
++ struct sk_buff *skb)
++{
++ struct ieee80211_local *local = sdata->local;
++ struct ieee80211_rx_status *rx_status;
++ struct ieee802_11_elems elems;
++ struct ieee80211_mgmt *mgmt;
++ struct sta_info *sta;
++ size_t baselen;
++ u32 rates = 0;
++ u16 stype;
++ bool new = false;
++ enum ieee80211_band band = local->hw.conf.channel->band;
++ struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
++
++ rx_status = IEEE80211_SKB_RXCB(skb);
++ mgmt = (struct ieee80211_mgmt *) skb->data;
++ stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
++
++ if (stype != IEEE80211_STYPE_BEACON)
++ return;
++
++ baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
++ if (baselen > skb->len)
++ return;
++
++ ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
++ skb->len - baselen, &elems);
++
++ rates = ieee80211_sta_get_rates(local, &elems, band);
++
++ rcu_read_lock();
++
++ sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
++
++ if (!sta) {
++ rcu_read_unlock();
++ sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
++ GFP_KERNEL);
++ if (!sta)
++ return;
++
++ new = true;
++ }
++
++ sta->last_rx = jiffies;
++ sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
++
++ if (elems.ht_cap_elem)
++ ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
++ elems.ht_cap_elem, &sta->sta.ht_cap);
++
++ if (elems.wmm_param)
++ set_sta_flags(sta, WLAN_STA_WME);
++
++ if (new) {
++ sta->flags = WLAN_STA_AUTHORIZED;
++ rate_control_rate_init(sta);
++ sta_info_insert_rcu(sta);
++ }
++
++ rcu_read_unlock();
++}
++
+ static void ieee80211_iface_work(struct work_struct *work)
+ {
+ struct ieee80211_sub_if_data *sdata =
+@@ -821,6 +862,9 @@ static void ieee80211_iface_work(struct
+ break;
+ ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+ break;
++ case NL80211_IFTYPE_WDS:
++ ieee80211_wds_rx_queued_mgmt(sdata, skb);
++ break;
+ default:
+ WARN(1, "frame for unexpected interface type");
+ break;
--- /dev/null
+--- a/net/mac80211/agg-tx.c
++++ b/net/mac80211/agg-tx.c
+@@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
+ memcpy(mgmt->da, da, ETH_ALEN);
+ memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
+ if (sdata->vif.type == NL80211_IFTYPE_AP ||
+- sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
++ sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
++ sdata->vif.type == NL80211_IFTYPE_WDS)
+ memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_STATION)
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+@@ -377,7 +378,8 @@ int ieee80211_start_tx_ba_session(struct
+ */
+ if (sdata->vif.type != NL80211_IFTYPE_STATION &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+- sdata->vif.type != NL80211_IFTYPE_AP)
++ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS)
+ return -EINVAL;
+
+ if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
+--- a/net/mac80211/agg-rx.c
++++ b/net/mac80211/agg-rx.c
+@@ -160,6 +160,8 @@ static void ieee80211_send_addba_resp(st
+ memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_STATION)
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
++ else if (sdata->vif.type == NL80211_IFTYPE_WDS)
++ memcpy(mgmt->bssid, da, ETH_ALEN);
+
+ mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+ IEEE80211_STYPE_ACTION);
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2132,7 +2132,8 @@ ieee80211_rx_h_action(struct ieee80211_r
+ */
+ if (sdata->vif.type != NL80211_IFTYPE_STATION &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+- sdata->vif.type != NL80211_IFTYPE_AP)
++ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS)
+ break;
+
+ /* verify action_code is present */
+@@ -2717,13 +2718,16 @@ static int prepare_for_handlers(struct i
+ }
+ break;
+ case NL80211_IFTYPE_WDS:
+- if (bssid) {
+- if (!ieee80211_is_beacon(hdr->frame_control))
+- return 0;
+- } else if (!ieee80211_is_data(hdr->frame_control))
+- return 0;
+ if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
+ return 0;
++
++ if (ieee80211_is_data(hdr->frame_control) ||
++ ieee80211_is_action(hdr->frame_control)) {
++ if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
++ return 0;
++ } else if (!ieee80211_is_beacon(hdr->frame_control))
++ return 0;
++
+ break;
+ default:
+ /* should never get here */
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -543,6 +543,7 @@ static ssize_t read_file_xmit(struct fil
+
+ PR("MPDUs Queued: ", queued);
+ PR("MPDUs Completed: ", completed);
++ PR("MPDUs XRetried: ", xretries);
+ PR("Aggregates: ", a_aggr);
+ PR("AMPDUs Queued HW:", a_queued_hw);
+ PR("AMPDUs Queued SW:", a_queued_sw);
+@@ -798,7 +799,10 @@ void ath_debug_stat_tx(struct ath_softc
+ else
+ TX_STAT_INC(qnum, a_completed);
+ } else {
+- TX_STAT_INC(qnum, completed);
++ if (bf_isxretried(bf))
++ TX_STAT_INC(qnum, xretries);
++ else
++ TX_STAT_INC(qnum, completed);
+ }
+
+ if (ts->ts_status & ATH9K_TXERR_FIFO)
+--- a/drivers/net/wireless/ath/ath9k/debug.h
++++ b/drivers/net/wireless/ath/ath9k/debug.h
+@@ -112,6 +112,7 @@ struct ath_tx_stats {
+ u32 tx_bytes_all;
+ u32 queued;
+ u32 completed;
++ u32 xretries;
+ u32 a_aggr;
+ u32 a_queued_hw;
+ u32 a_queued_sw;
+++ /dev/null
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -31,7 +31,6 @@
- * frames.
- * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
- * @WLAN_STA_WME: Station is a QoS-STA.
-- * @WLAN_STA_WDS: Station is one of our WDS peers.
- * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
- * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
- * frame to this station is transmitted.
-@@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
- WLAN_STA_SHORT_PREAMBLE = 1<<4,
- WLAN_STA_ASSOC_AP = 1<<5,
- WLAN_STA_WME = 1<<6,
-- WLAN_STA_WDS = 1<<7,
- WLAN_STA_CLEAR_PS_FILT = 1<<9,
- WLAN_STA_MFP = 1<<10,
- WLAN_STA_BLOCK_BA = 1<<11,
---- a/net/mac80211/debugfs_sta.c
-+++ b/net/mac80211/debugfs_sta.c
-@@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
- char buf[100];
- struct sta_info *sta = file->private_data;
- u32 staflags = get_sta_flags(sta);
-- int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
-+ int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
- staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
- staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
- staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
-@@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
- staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
- staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
- staflags & WLAN_STA_WME ? "WME\n" : "",
-- staflags & WLAN_STA_WDS ? "WDS\n" : "",
- staflags & WLAN_STA_MFP ? "MFP\n" : "");
- return simple_read_from_buffer(userbuf, count, ppos, buf, res);
- }
+++ /dev/null
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -2328,13 +2328,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
-
- if (!ieee80211_vif_is_mesh(&sdata->vif) &&
- sdata->vif.type != NL80211_IFTYPE_ADHOC &&
-- sdata->vif.type != NL80211_IFTYPE_STATION)
-+ sdata->vif.type != NL80211_IFTYPE_STATION &&
-+ sdata->vif.type != NL80211_IFTYPE_WDS)
- return RX_DROP_MONITOR;
-
- switch (stype) {
- case cpu_to_le16(IEEE80211_STYPE_BEACON):
- case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
-- /* process for all: mesh, mlme, ibss */
-+ /* process for all: mesh, mlme, ibss, wds */
- break;
- case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
- case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
-@@ -2714,7 +2715,10 @@ static int prepare_for_handlers(struct i
- }
- break;
- case NL80211_IFTYPE_WDS:
-- if (bssid || !ieee80211_is_data(hdr->frame_control))
-+ if (bssid) {
-+ if (!ieee80211_is_beacon(hdr->frame_control))
-+ return 0;
-+ } else if (!ieee80211_is_data(hdr->frame_control))
- return 0;
- if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
- return 0;
---- a/net/mac80211/iface.c
-+++ b/net/mac80211/iface.c
-@@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
- {
- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- struct ieee80211_local *local = sdata->local;
-- struct sta_info *sta;
- u32 changed = 0;
- int res;
- u32 hw_reconf_flags = 0;
-@@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
-
- set_bit(SDATA_STATE_RUNNING, &sdata->state);
-
-- if (sdata->vif.type == NL80211_IFTYPE_WDS) {
-- /* Create STA entry for the WDS peer */
-- sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
-- GFP_KERNEL);
-- if (!sta) {
-- res = -ENOMEM;
-- goto err_del_interface;
-- }
--
-- /* no locking required since STA is not live yet */
-- sta->flags |= WLAN_STA_AUTHORIZED;
--
-- res = sta_info_insert(sta);
-- if (res) {
-- /* STA has been freed */
-- goto err_del_interface;
-- }
--
-- rate_control_rate_init(sta);
-- }
--
- /*
- * set_multicast_list will be invoked by the networking core
- * which will check whether any increments here were done in
-@@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
- netif_tx_start_all_queues(dev);
-
- return 0;
-- err_del_interface:
-- drv_remove_interface(local, &sdata->vif);
-+
- err_stop:
- if (!local->open_count)
- drv_stop(local);
-@@ -717,6 +694,70 @@ static void ieee80211_if_setup(struct ne
- dev->destructor = free_netdev;
- }
-
-+static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
-+ struct sk_buff *skb)
-+{
-+ struct ieee80211_local *local = sdata->local;
-+ struct ieee80211_rx_status *rx_status;
-+ struct ieee802_11_elems elems;
-+ struct ieee80211_mgmt *mgmt;
-+ struct sta_info *sta;
-+ size_t baselen;
-+ u32 rates = 0;
-+ u16 stype;
-+ bool new = false;
-+ enum ieee80211_band band = local->hw.conf.channel->band;
-+ struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
-+
-+ rx_status = IEEE80211_SKB_RXCB(skb);
-+ mgmt = (struct ieee80211_mgmt *) skb->data;
-+ stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
-+
-+ if (stype != IEEE80211_STYPE_BEACON)
-+ return;
-+
-+ baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
-+ if (baselen > skb->len)
-+ return;
-+
-+ ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
-+ skb->len - baselen, &elems);
-+
-+ rates = ieee80211_sta_get_rates(local, &elems, band);
-+
-+ rcu_read_lock();
-+
-+ sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
-+
-+ if (!sta) {
-+ rcu_read_unlock();
-+ sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
-+ GFP_KERNEL);
-+ if (!sta)
-+ return;
-+
-+ new = true;
-+ }
-+
-+ sta->last_rx = jiffies;
-+ sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
-+
-+ if (elems.ht_cap_elem)
-+ ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
-+ elems.ht_cap_elem, &sta->sta.ht_cap);
-+
-+ if (elems.wmm_param)
-+ set_sta_flags(sta, WLAN_STA_WME);
-+
-+ if (new) {
-+ sta->flags = WLAN_STA_AUTHORIZED;
-+ rate_control_rate_init(sta);
-+ sta_info_insert_rcu(sta);
-+ }
-+
-+ rcu_read_unlock();
-+}
-+
- static void ieee80211_iface_work(struct work_struct *work)
- {
- struct ieee80211_sub_if_data *sdata =
-@@ -821,6 +862,9 @@ static void ieee80211_iface_work(struct
- break;
- ieee80211_mesh_rx_queued_mgmt(sdata, skb);
- break;
-+ case NL80211_IFTYPE_WDS:
-+ ieee80211_wds_rx_queued_mgmt(sdata, skb);
-+ break;
- default:
- WARN(1, "frame for unexpected interface type");
- break;
+++ /dev/null
---- a/net/mac80211/agg-tx.c
-+++ b/net/mac80211/agg-tx.c
-@@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
- memcpy(mgmt->da, da, ETH_ALEN);
- memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
- if (sdata->vif.type == NL80211_IFTYPE_AP ||
-- sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
-+ sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
-+ sdata->vif.type == NL80211_IFTYPE_WDS)
- memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
- else if (sdata->vif.type == NL80211_IFTYPE_STATION)
- memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
-@@ -377,7 +378,8 @@ int ieee80211_start_tx_ba_session(struct
- */
- if (sdata->vif.type != NL80211_IFTYPE_STATION &&
- sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
-- sdata->vif.type != NL80211_IFTYPE_AP)
-+ sdata->vif.type != NL80211_IFTYPE_AP &&
-+ sdata->vif.type != NL80211_IFTYPE_WDS)
- return -EINVAL;
-
- if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
---- a/net/mac80211/agg-rx.c
-+++ b/net/mac80211/agg-rx.c
-@@ -160,6 +160,8 @@ static void ieee80211_send_addba_resp(st
- memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
- else if (sdata->vif.type == NL80211_IFTYPE_STATION)
- memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
-+ else if (sdata->vif.type == NL80211_IFTYPE_WDS)
-+ memcpy(mgmt->bssid, da, ETH_ALEN);
-
- mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
- IEEE80211_STYPE_ACTION);
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -2130,7 +2130,8 @@ ieee80211_rx_h_action(struct ieee80211_r
- */
- if (sdata->vif.type != NL80211_IFTYPE_STATION &&
- sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
-- sdata->vif.type != NL80211_IFTYPE_AP)
-+ sdata->vif.type != NL80211_IFTYPE_AP &&
-+ sdata->vif.type != NL80211_IFTYPE_WDS)
- break;
-
- /* verify action_code is present */
-@@ -2715,13 +2716,16 @@ static int prepare_for_handlers(struct i
- }
- break;
- case NL80211_IFTYPE_WDS:
-- if (bssid) {
-- if (!ieee80211_is_beacon(hdr->frame_control))
-- return 0;
-- } else if (!ieee80211_is_data(hdr->frame_control))
-- return 0;
- if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
- return 0;
-+
-+ if (ieee80211_is_data(hdr->frame_control) ||
-+ ieee80211_is_action(hdr->frame_control)) {
-+ if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
-+ return 0;
-+ } else if (!ieee80211_is_beacon(hdr->frame_control))
-+ return 0;
-+
- break;
- default:
- /* should never get here */
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ahb.c
-+++ b/drivers/net/wireless/ath/ath9k/ahb.c
-@@ -21,6 +21,14 @@
- #include <linux/ath9k_platform.h>
- #include "ath9k.h"
-
-+const struct platform_device_id ath9k_platform_id_table[] = {
-+ {
-+ .name = "ath9k",
-+ .driver_data = AR5416_AR9100_DEVID,
-+ },
-+ {},
-+};
-+
- /* return bus cachesize in 4B word units */
- static void ath_ahb_read_cachesize(struct ath_common *common, int *csz)
- {
-@@ -57,6 +65,7 @@ static int ath_ahb_probe(struct platform
- struct ath_softc *sc;
- struct ieee80211_hw *hw;
- struct resource *res;
-+ const struct platform_device_id *id = platform_get_device_id(pdev);
- int irq;
- int ret = 0;
- struct ath_hw *ah;
-@@ -116,7 +125,7 @@ static int ath_ahb_probe(struct platform
- goto err_free_hw;
- }
-
-- ret = ath9k_init_device(AR5416_AR9100_DEVID, sc, 0x0, &ath_ahb_bus_ops);
-+ ret = ath9k_init_device(id->driver_data, sc, 0x0, &ath_ahb_bus_ops);
- if (ret) {
- dev_err(&pdev->dev, "failed to initialize device\n");
- goto err_irq;
-@@ -165,8 +174,11 @@ static struct platform_driver ath_ahb_dr
- .name = "ath9k",
- .owner = THIS_MODULE,
- },
-+ .id_table = ath9k_platform_id_table,
- };
-
-+MODULE_DEVICE_TABLE(platform, ath9k_platform_id_table);
-+
- int ath_ahb_init(void)
- {
- return platform_driver_register(&ath_ahb_driver);
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -543,6 +543,7 @@ static ssize_t read_file_xmit(struct fil
-
- PR("MPDUs Queued: ", queued);
- PR("MPDUs Completed: ", completed);
-+ PR("MPDUs XRetried: ", xretries);
- PR("Aggregates: ", a_aggr);
- PR("AMPDUs Queued HW:", a_queued_hw);
- PR("AMPDUs Queued SW:", a_queued_sw);
-@@ -798,7 +799,10 @@ void ath_debug_stat_tx(struct ath_softc
- else
- TX_STAT_INC(qnum, a_completed);
- } else {
-- TX_STAT_INC(qnum, completed);
-+ if (bf_isxretried(bf))
-+ TX_STAT_INC(qnum, xretries);
-+ else
-+ TX_STAT_INC(qnum, completed);
- }
-
- if (ts->ts_status & ATH9K_TXERR_FIFO)
---- a/drivers/net/wireless/ath/ath9k/debug.h
-+++ b/drivers/net/wireless/ath/ath9k/debug.h
-@@ -112,6 +112,7 @@ struct ath_tx_stats {
- u32 tx_bytes_all;
- u32 queued;
- u32 completed;
-+ u32 xretries;
- u32 a_aggr;
- u32 a_queued_hw;
- u32 a_queued_sw;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -256,6 +256,8 @@ struct ath_node {
- #endif
- struct ath_atx_tid tid[WME_NUM_TID];
- struct ath_atx_ac ac[WME_NUM_AC];
-+ int ps_key;
-+
- u16 maxampdu;
- u8 mpdudensity;
-
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1775,18 +1775,37 @@ static int ath9k_sta_add(struct ieee8021
- struct ieee80211_sta *sta)
- {
- struct ath_softc *sc = hw->priv;
-+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+ struct ath_node *an = (struct ath_node *) sta->drv_priv;
-+ struct ieee80211_key_conf ps_key = { };
-
- ath_node_attach(sc, sta);
-+ an->ps_key = ath_key_config(common, vif, sta, &ps_key);
-
- return 0;
- }
-
-+static void ath9k_del_ps_key(struct ath_softc *sc,
-+ struct ieee80211_vif *vif,
-+ struct ieee80211_sta *sta)
-+{
-+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+ struct ath_node *an = (struct ath_node *) sta->drv_priv;
-+ struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
-+
-+ if (!an->ps_key)
-+ return;
-+
-+ ath_key_delete(common, &ps_key);
-+}
-+
- static int ath9k_sta_remove(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
- {
- struct ath_softc *sc = hw->priv;
-
-+ ath9k_del_ps_key(sc, vif, sta);
- ath_node_detach(sc, sta);
-
- return 0;
-@@ -1889,6 +1908,9 @@ static int ath9k_set_key(struct ieee8021
-
- switch (cmd) {
- case SET_KEY:
-+ if (sta)
-+ ath9k_del_ps_key(sc, vif, sta);
-+
- ret = ath_key_config(common, vif, sta, key);
- if (ret >= 0) {
- key->hw_key_idx = ret;
---- a/drivers/net/wireless/ath/key.c
-+++ b/drivers/net/wireless/ath/key.c
-@@ -483,6 +483,9 @@ int ath_key_config(struct ath_common *co
- memset(&hk, 0, sizeof(hk));
-
- switch (key->cipher) {
-+ case 0:
-+ hk.kv_type = ATH_CIPHER_CLR;
-+ break;
- case WLAN_CIPHER_SUITE_WEP40:
- case WLAN_CIPHER_SUITE_WEP104:
- hk.kv_type = ATH_CIPHER_WEP;
-@@ -498,7 +501,8 @@ int ath_key_config(struct ath_common *co
- }
-
- hk.kv_len = key->keylen;
-- memcpy(hk.kv_val, key->key, key->keylen);
-+ if (key->keylen)
-+ memcpy(hk.kv_val, key->key, key->keylen);
-
- if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
- switch (vif->type) {
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1526,7 +1526,7 @@ static void setup_frame_info(struct ieee
- struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
- struct ieee80211_hdr *hdr;
- struct ath_frame_info *fi = get_frame_info(skb);
-- struct ath_node *an;
-+ struct ath_node *an = NULL;
- struct ath_atx_tid *tid;
- enum ath9k_key_type keytype;
- u16 seqno = 0;
-@@ -1534,11 +1534,13 @@ static void setup_frame_info(struct ieee
-
- keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
-
-+ if (sta)
-+ an = (struct ath_node *) sta->drv_priv;
-+
- hdr = (struct ieee80211_hdr *)skb->data;
-- if (sta && ieee80211_is_data_qos(hdr->frame_control) &&
-+ if (an && ieee80211_is_data_qos(hdr->frame_control) &&
- conf_is_ht(&hw->conf) && (sc->sc_flags & SC_OP_TXAGGR)) {
-
-- an = (struct ath_node *) sta->drv_priv;
- tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
-
- /*
-@@ -1554,6 +1556,8 @@ static void setup_frame_info(struct ieee
- memset(fi, 0, sizeof(*fi));
- if (hw_key)
- fi->keyix = hw_key->hw_key_idx;
-+ else if (an && ieee80211_is_data(hdr->frame_control) && an->ps_key > 0)
-+ fi->keyix = an->ps_key;
- else
- fi->keyix = ATH9K_TXKEYIX_INVALID;
- fi->keytype = keytype;
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
-@@ -199,6 +199,7 @@ void rt2x00pci_uninitialize(struct rt2x0
+@@ -208,6 +208,7 @@ void rt2x00pci_uninitialize(struct rt2x0
}
EXPORT_SYMBOL_GPL(rt2x00pci_uninitialize);
/*
* PCI driver handlers.
*/
-@@ -375,6 +376,7 @@ int rt2x00pci_resume(struct pci_dev *pci
+@@ -383,6 +384,7 @@ int rt2x00pci_resume(struct pci_dev *pci
}
EXPORT_SYMBOL_GPL(rt2x00pci_resume);
#endif /* CONFIG_PM */
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
-@@ -264,8 +264,10 @@ int rt2x00pci_probe(struct pci_dev *pci_
+@@ -272,8 +272,10 @@ int rt2x00pci_probe(struct pci_dev *pci_
pci_set_master(pci_dev);
+++ /dev/null
---- a/drivers/net/wireless/rt2x00/rt2800lib.c
-+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
-@@ -938,6 +938,7 @@ EXPORT_SYMBOL_GPL(rt2800_rfkill_poll);
- static void rt2800_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness brightness)
- {
-+ u32 reg;
- struct rt2x00_led *led =
- container_of(led_cdev, struct rt2x00_led, led_dev);
- unsigned int enabled = brightness != LED_OFF;
-@@ -950,24 +951,46 @@ static void rt2800_brightness_set(struct
- rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
- EEPROM_FREQ_LED_MODE);
-
-- if (led->type == LED_TYPE_RADIO) {
-- rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
-- enabled ? 0x20 : 0);
-- } else if (led->type == LED_TYPE_ASSOC) {
-- rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
-- enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
-- } else if (led->type == LED_TYPE_QUALITY) {
-- /*
-- * The brightness is divided into 6 levels (0 - 5),
-- * The specs tell us the following levels:
-- * 0, 1 ,3, 7, 15, 31
-- * to determine the level in a simple way we can simply
-- * work with bitshifting:
-- * (1 << level) - 1
-- */
-- rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
-- (1 << brightness / (LED_FULL / 6)) - 1,
-- polarity);
-+ /* Check for SoC (SOC devices don't support MCU requests) */
-+ if (rt2x00_is_soc(led->rt2x00dev)) {
-+ rt2800_register_read(led->rt2x00dev, LED_CFG, ®);
-+
-+ /* Set LED Polarity */
-+ rt2x00_set_field32(®, LED_CFG_LED_POLAR, polarity);
-+
-+ /* Set LED Mode */
-+ if (led->type == LED_TYPE_RADIO) {
-+ rt2x00_set_field32(®, LED_CFG_G_LED_MODE,
-+ enabled ? 3 : 0);
-+ } else if (led->type == LED_TYPE_ASSOC) {
-+ rt2x00_set_field32(®, LED_CFG_Y_LED_MODE,
-+ enabled ? 3 : 0);
-+ } else if (led->type == LED_TYPE_QUALITY) {
-+ rt2x00_set_field32(®, LED_CFG_R_LED_MODE,
-+ enabled ? 3 : 0);
-+ }
-+ rt2800_register_write(led->rt2x00dev, LED_CFG, reg);
-+ }
-+ else {
-+ if (led->type == LED_TYPE_RADIO) {
-+ rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
-+ enabled ? 0x20 : 0);
-+ } else if (led->type == LED_TYPE_ASSOC) {
-+ rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
-+ enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
-+ } else if (led->type == LED_TYPE_QUALITY) {
-+ /*
-+ * The brightness is divided into 6 levels (0 - 5),
-+ * The specs tell us the following levels:
-+ * 0, 1 ,3, 7, 15, 31
-+ * to determine the level in a simple way we can simply
-+ * work with bitshifting:
-+ * (1 << level) - 1
-+ */
-+ rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
-+ (1 << brightness / (LED_FULL / 6)) - 1,
-+ polarity);
-+ }
- }
- }
-
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
-@@ -5111,6 +5111,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
+@@ -5165,6 +5165,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {