From 99a41c0ace85fce0efca7bedd39d0c88429fdc12 Mon Sep 17 00:00:00 2001
From: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Mon, 1 Aug 2011 12:15:15 +0000
Subject: [PATCH] ath9k: fold patches that were merged upstream into
 300-pending_work.patch

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27860 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 .../mac80211/patches/300-pending_work.patch   | 499 ++++++++++++++++++
 ...h9k-fix-invalid-mac-address-handling.patch |   2 +-
 .../510-ath9k_intr_mitigation_tweak.patch     |   2 +-
 .../patches/511-ath9k_increase_bcbuf.patch    |   2 +-
 ...atch => 513-ath9k_channelbw_debugfs.patch} |   0
 .../patches/530-ath9k_noise_dbm_fixup.patch   |   6 +-
 ..._rx_stop.patch => 540-ath9k_rx_stop.patch} |   0
 .../patches/541-ath9k_pllclock_fix.patch      |  42 --
 .../542-ath9k_always_enable_fastclock.patch   |  14 -
 .../patches/543-ath9k_fix_mac_clock_div.patch |  16 -
 .../544-ath9k_fix_ar9287_mac_clock.patch      |  14 -
 .../patches/545-ath9k_timing_settings.patch   | 106 ----
 .../546-ath9k_cleanup_ar9287_settings.patch   | 117 ----
 ...-ath9k_half_quarter_set_channel_frac.patch |  13 -
 .../548-ath9k_half_quarter_synth_delay.patch  |  14 -
 .../patches/549-ath9k_shift_reg_delay.patch   |  14 -
 .../patches/550-ath9k_mmic_verify.patch       | 103 ----
 ...r.patch => 550-mac80211_cur_txpower.patch} |   0
 ...h => 551-ath9k_initialize_chainmask.patch} |   0
 ... => 552-ath9k_remove_tx_indexoffset.patch} |   0
 ...r.patch => 553-ath9k_fix_rate_power.patch} |   0
 ...wer.patch => 554-ath9k_test_txpower.patch} |   1 -
 ...ower.patch => 555-ath9k_cur_txpower.patch} |   0
 .../patches/570-mac80211_agg_buf_size.patch   |  11 -
 .../patches/580-ath9k_fixup_chainmask.patch   |  51 --
 .../mac80211/patches/820-b43-backport.patch   |   2 +-
 ...b43-add-core-rev-17-used-on-bcma-SoC.patch |   2 +-
 27 files changed, 507 insertions(+), 524 deletions(-)
 rename package/mac80211/patches/{540-ath9k_channelbw_debugfs.patch => 513-ath9k_channelbw_debugfs.patch} (100%)
 rename package/mac80211/patches/{560-ath9k_rx_stop.patch => 540-ath9k_rx_stop.patch} (100%)
 delete mode 100644 package/mac80211/patches/541-ath9k_pllclock_fix.patch
 delete mode 100644 package/mac80211/patches/542-ath9k_always_enable_fastclock.patch
 delete mode 100644 package/mac80211/patches/543-ath9k_fix_mac_clock_div.patch
 delete mode 100644 package/mac80211/patches/544-ath9k_fix_ar9287_mac_clock.patch
 delete mode 100644 package/mac80211/patches/545-ath9k_timing_settings.patch
 delete mode 100644 package/mac80211/patches/546-ath9k_cleanup_ar9287_settings.patch
 delete mode 100644 package/mac80211/patches/547-ath9k_half_quarter_set_channel_frac.patch
 delete mode 100644 package/mac80211/patches/548-ath9k_half_quarter_synth_delay.patch
 delete mode 100644 package/mac80211/patches/549-ath9k_shift_reg_delay.patch
 delete mode 100644 package/mac80211/patches/550-ath9k_mmic_verify.patch
 rename package/mac80211/patches/{590-mac80211_cur_txpower.patch => 550-mac80211_cur_txpower.patch} (100%)
 rename package/mac80211/patches/{591-ath9k_initialize_chainmask.patch => 551-ath9k_initialize_chainmask.patch} (100%)
 rename package/mac80211/patches/{592-ath9k_remove_tx_indexoffset.patch => 552-ath9k_remove_tx_indexoffset.patch} (100%)
 rename package/mac80211/patches/{593-ath9k_fix_rate_power.patch => 553-ath9k_fix_rate_power.patch} (100%)
 rename package/mac80211/patches/{594-ath9k_test_txpower.patch => 554-ath9k_test_txpower.patch} (99%)
 rename package/mac80211/patches/{595-ath9k_cur_txpower.patch => 555-ath9k_cur_txpower.patch} (100%)
 delete mode 100644 package/mac80211/patches/570-mac80211_agg_buf_size.patch
 delete mode 100644 package/mac80211/patches/580-ath9k_fixup_chainmask.patch

diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
index f2e4fdb44..a36f99ce6 100644
--- a/package/mac80211/patches/300-pending_work.patch
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -44,6 +44,15 @@
  		return -EINVAL;
  
  	if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
+@@ -809,7 +811,7 @@ void ieee80211_process_addba_resp(struct
+ 		 * of at least 1.
+ 		 */
+ 		if (!buf_size)
+-			goto out;
++			buf_size = 1;
+ 
+ 		if (test_and_set_bit(HT_AGG_STATE_RESPONSE_RECEIVED,
+ 				     &tid_tx->state)) {
 --- a/net/mac80211/debugfs_sta.c
 +++ b/net/mac80211/debugfs_sta.c
 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
@@ -1144,3 +1153,493 @@
  			ieee80211_hw_config(local, 0);
  
  		/* At the least, we need to disable offchannel_ps,
+--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+@@ -627,6 +627,11 @@ static void ar5008_hw_init_bb(struct ath
+ 	else
+ 		synthDelay /= 10;
+ 
++	if (IS_CHAN_HALF_RATE(chan))
++		synthDelay *= 2;
++	else if (IS_CHAN_QUARTER_RATE(chan))
++		synthDelay *= 4;
++
+ 	REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
+ 
+ 	udelay(synthDelay + BASE_ACTIVATE_DELAY);
+--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
++++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+@@ -499,45 +499,6 @@ void ar9002_hw_enable_async_fifo(struct 
+ 	}
+ }
+ 
+-/*
+- * If Async FIFO is enabled, the following counters change as MAC now runs
+- * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
+- *
+- * The values below tested for ht40 2 chain.
+- * Overwrite the delay/timeouts initialized in process ini.
+- */
+-void ar9002_hw_update_async_fifo(struct ath_hw *ah)
+-{
+-	if (AR_SREV_9287_13_OR_LATER(ah)) {
+-		REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
+-			  AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
+-		REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
+-			  AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
+-		REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
+-			  AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
+-
+-		REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
+-		REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
+-
+-		REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
+-			    AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
+-		REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
+-			      AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
+-	}
+-}
+-
+-/*
+- * We don't enable WEP aggregation on mac80211 but we keep this
+- * around for HAL unification purposes.
+- */
+-void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
+-{
+-	if (AR_SREV_9287_13_OR_LATER(ah)) {
+-		REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
+-			    AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
+-	}
+-}
+-
+ /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
+ void ar9002_hw_attach_ops(struct ath_hw *ah)
+ {
+--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
++++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+@@ -111,7 +111,9 @@ static int ar9002_hw_set_channel(struct 
+ 
+ 		switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
+ 		case 0:
+-			if ((freq % 20) == 0)
++			if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
++				aModeRefSel = 0;
++			else if ((freq % 20) == 0)
+ 				aModeRefSel = 3;
+ 			else if ((freq % 10) == 0)
+ 				aModeRefSel = 2;
+@@ -129,8 +131,9 @@ static int ar9002_hw_set_channel(struct 
+ 			channelSel = CHANSEL_5G(freq);
+ 
+ 			/* RefDivA setting */
+-			REG_RMW_FIELD(ah, AR_AN_SYNTH9,
+-				      AR_AN_SYNTH9_REFDIVA, refDivA);
++			ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9,
++				      AR_AN_SYNTH9_REFDIVA,
++				      AR_AN_SYNTH9_REFDIVA_S, refDivA);
+ 
+ 		}
+ 
+@@ -447,26 +450,27 @@ static void ar9002_olc_init(struct ath_h
+ static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
+ 					 struct ath9k_channel *chan)
+ {
++	int ref_div = 5;
++	int pll_div = 0x2c;
+ 	u32 pll;
+ 
+-	pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
++	if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) {
++		if (AR_SREV_9280_20(ah)) {
++			ref_div = 10;
++			pll_div = 0x50;
++		} else {
++			pll_div = 0x28;
++		}
++	}
++
++	pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
++	pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
+ 
+ 	if (chan && IS_CHAN_HALF_RATE(chan))
+ 		pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
+ 	else if (chan && IS_CHAN_QUARTER_RATE(chan))
+ 		pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
+ 
+-	if (chan && IS_CHAN_5GHZ(chan)) {
+-		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
+-			pll = 0x142c;
+-		else if (AR_SREV_9280_20(ah))
+-			pll = 0x2850;
+-		else
+-			pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
+-	} else {
+-		pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
+-	}
+-
+ 	return pll;
+ }
+ 
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -87,7 +87,10 @@ static void ath9k_hw_set_clockrate(struc
+ 	struct ath_common *common = ath9k_hw_common(ah);
+ 	unsigned int clockrate;
+ 
+-	if (!ah->curchan) /* should really check for CCK instead */
++	/* AR9287 v1.3+ uses async FIFO and runs the MAC at 117 MHz */
++	if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah))
++		clockrate = 117;
++	else if (!ah->curchan) /* should really check for CCK instead */
+ 		clockrate = ATH9K_CLOCK_RATE_CCK;
+ 	else if (conf->channel->band == IEEE80211_BAND_2GHZ)
+ 		clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
+@@ -99,6 +102,13 @@ static void ath9k_hw_set_clockrate(struc
+ 	if (conf_is_ht40(conf))
+ 		clockrate *= 2;
+ 
++	if (ah->curchan) {
++		if (IS_CHAN_HALF_RATE(ah->curchan))
++			clockrate /= 2;
++		if (IS_CHAN_QUARTER_RATE(ah->curchan))
++			clockrate /= 4;
++	}
++
+ 	common->clockrate = clockrate;
+ }
+ 
+@@ -895,6 +905,13 @@ static void ath9k_hw_init_interrupt_mask
+ 	}
+ }
+ 
++static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
++{
++	u32 val = ath9k_hw_mac_to_clks(ah, us - 2);
++	val = min(val, (u32) 0xFFFF);
++	REG_WRITE(ah, AR_D_GBL_IFS_SIFS, val);
++}
++
+ static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
+ {
+ 	u32 val = ath9k_hw_mac_to_clks(ah, us);
+@@ -932,25 +949,60 @@ static bool ath9k_hw_set_global_txtimeou
+ 
+ void ath9k_hw_init_global_settings(struct ath_hw *ah)
+ {
+-	struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
++	struct ath_common *common = ath9k_hw_common(ah);
++	struct ieee80211_conf *conf = &common->hw->conf;
++	const struct ath9k_channel *chan = ah->curchan;
+ 	int acktimeout;
+ 	int slottime;
+ 	int sifstime;
++	int rx_lat = 0, tx_lat = 0, eifs = 0;
++	u32 reg;
+ 
+ 	ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
+ 		ah->misc_mode);
+ 
++	if (!chan)
++		return;
++
+ 	if (ah->misc_mode != 0)
+ 		REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
+ 
+-	if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
+-		sifstime = 16;
+-	else
+-		sifstime = 10;
++	rx_lat = 37;
++	tx_lat = 54;
++
++	if (IS_CHAN_HALF_RATE(chan)) {
++		eifs = 175;
++		rx_lat *= 2;
++		tx_lat *= 2;
++		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
++		    tx_lat += 11;
++
++		slottime = 13;
++		sifstime = 32;
++	} else if (IS_CHAN_QUARTER_RATE(chan)) {
++		eifs = 340;
++		rx_lat *= 4;
++		tx_lat *= 4;
++		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
++		    tx_lat += 22;
++
++		slottime = 21;
++		sifstime = 64;
++	} else {
++		eifs = REG_READ(ah, AR_D_GBL_IFS_EIFS);
++		reg = REG_READ(ah, AR_USEC);
++		rx_lat = MS(reg, AR_USEC_RX_LAT);
++		tx_lat = MS(reg, AR_USEC_TX_LAT);
++
++		slottime = ah->slottime;
++		if (IS_CHAN_5GHZ(chan))
++			sifstime = 16;
++		else
++			sifstime = 10;
++	}
+ 
+ 	/* As defined by IEEE 802.11-2007 17.3.8.6 */
+-	slottime = ah->slottime + 3 * ah->coverage_class;
+-	acktimeout = slottime + sifstime;
++	acktimeout = slottime + sifstime + 3 * ah->coverage_class;
+ 
+ 	/*
+ 	 * Workaround for early ACK timeouts, add an offset to match the
+@@ -962,11 +1014,20 @@ void ath9k_hw_init_global_settings(struc
+ 	if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
+ 		acktimeout += 64 - sifstime - ah->slottime;
+ 
+-	ath9k_hw_setslottime(ah, ah->slottime);
++	ath9k_hw_set_sifs_time(ah, sifstime);
++	ath9k_hw_setslottime(ah, slottime);
+ 	ath9k_hw_set_ack_timeout(ah, acktimeout);
+ 	ath9k_hw_set_cts_timeout(ah, acktimeout);
+ 	if (ah->globaltxtimeout != (u32) -1)
+ 		ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
++
++	REG_WRITE(ah, AR_D_GBL_IFS_EIFS, ath9k_hw_mac_to_clks(ah, eifs));
++	REG_RMW(ah, AR_USEC,
++		(common->clockrate - 1) |
++		SM(rx_lat, AR_USEC_RX_LAT) |
++		SM(tx_lat, AR_USEC_TX_LAT),
++		AR_USEC_TX_LAT | AR_USEC_RX_LAT | AR_USEC_USEC);
++
+ }
+ EXPORT_SYMBOL(ath9k_hw_init_global_settings);
+ 
+@@ -1570,9 +1631,13 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ 
+ 	ath9k_hw_init_global_settings(ah);
+ 
+-	if (!AR_SREV_9300_20_OR_LATER(ah)) {
+-		ar9002_hw_update_async_fifo(ah);
+-		ar9002_hw_enable_wep_aggregation(ah);
++	if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
++		REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
++			    AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
++		REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
++			      AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
++		REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
++			    AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
+ 	}
+ 
+ 	REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
+@@ -1932,12 +1997,22 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_ti
+ /* HW Capabilities */
+ /*******************/
+ 
++static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask)
++{
++	eeprom_chainmask &= chip_chainmask;
++	if (eeprom_chainmask)
++		return eeprom_chainmask;
++	else
++		return chip_chainmask;
++}
++
+ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
+ {
+ 	struct ath9k_hw_capabilities *pCap = &ah->caps;
+ 	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+ 	struct ath_common *common = ath9k_hw_common(ah);
+ 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
++	unsigned int chip_chainmask;
+ 
+ 	u16 eeval;
+ 	u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
+@@ -1974,6 +2049,15 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+ 	if (eeval & AR5416_OPFLAGS_11G)
+ 		pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
+ 
++	if (AR_SREV_9485(ah) || AR_SREV_9285(ah) || AR_SREV_9330(ah))
++		chip_chainmask = 1;
++	else if (!AR_SREV_9280_20_OR_LATER(ah))
++		chip_chainmask = 7;
++	else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah))
++		chip_chainmask = 3;
++	else
++		chip_chainmask = 7;
++
+ 	pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
+ 	/*
+ 	 * For AR9271 we will temporarilly uses the rx chainmax as read from
+@@ -1990,6 +2074,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+ 		/* Use rx_chainmask from EEPROM. */
+ 		pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
+ 
++	pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask);
++	pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask);
++
+ 	ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
+ 
+ 	/* enable key search for every frame in an aggregate */
+@@ -2079,10 +2166,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+ 			pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
+ 	} else {
+ 		pCap->tx_desc_len = sizeof(struct ath_desc);
+-		if (AR_SREV_9280_20(ah) &&
+-		    ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <=
+-		      AR5416_EEP_MINOR_VER_16) ||
+-		     ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G)))
++		if (AR_SREV_9280_20(ah))
+ 			pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
+ 	}
+ 
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -983,8 +983,6 @@ void ath9k_hw_get_delta_slope_vals(struc
+ void ar9002_hw_cck_chan14_spread(struct ath_hw *ah);
+ int ar9002_hw_rf_claim(struct ath_hw *ah);
+ void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
+-void ar9002_hw_update_async_fifo(struct ath_hw *ah);
+-void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
+ 
+ /*
+  * Code specific to AR9003, we stuff these here to avoid callbacks
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -814,16 +814,19 @@ static bool ath9k_rx_accept(struct ath_c
+ 			    struct ath_rx_status *rx_stats,
+ 			    bool *decrypt_error)
+ {
+-#define is_mc_or_valid_tkip_keyix ((is_mc ||			\
+-		(rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
+-		test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
+-
++	bool is_mc, is_valid_tkip, strip_mic, mic_error = false;
+ 	struct ath_hw *ah = common->ah;
+ 	__le16 fc;
+ 	u8 rx_status_len = ah->caps.rx_status_len;
+ 
+ 	fc = hdr->frame_control;
+ 
++	is_mc = !!is_multicast_ether_addr(hdr->addr1);
++	is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
++		test_bit(rx_stats->rs_keyix, common->tkip_keymap);
++	strip_mic = is_valid_tkip && !(rx_stats->rs_status &
++		(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
++
+ 	if (!rx_stats->rs_datalen)
+ 		return false;
+         /*
+@@ -838,6 +841,11 @@ static bool ath9k_rx_accept(struct ath_c
+ 	if (rx_stats->rs_more)
+ 		return true;
+ 
++	mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
++		!ieee80211_has_morefrags(fc) &&
++		!(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
++		(rx_stats->rs_status & ATH9K_RXERR_MIC);
++
+ 	/*
+ 	 * The rx_stats->rs_status will not be set until the end of the
+ 	 * chained descriptors so it can be ignored if rs_more is set. The
+@@ -845,30 +853,18 @@ static bool ath9k_rx_accept(struct ath_c
+ 	 * descriptors.
+ 	 */
+ 	if (rx_stats->rs_status != 0) {
+-		if (rx_stats->rs_status & ATH9K_RXERR_CRC)
++		if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
+ 			rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
++			mic_error = false;
++		}
+ 		if (rx_stats->rs_status & ATH9K_RXERR_PHY)
+ 			return false;
+ 
+ 		if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
+ 			*decrypt_error = true;
+-		} else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
+-			bool is_mc;
+-			/*
+-			 * The MIC error bit is only valid if the frame
+-			 * is not a control frame or fragment, and it was
+-			 * decrypted using a valid TKIP key.
+-			 */
+-			is_mc = !!is_multicast_ether_addr(hdr->addr1);
+-
+-			if (!ieee80211_is_ctl(fc) &&
+-			    !ieee80211_has_morefrags(fc) &&
+-			    !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
+-			    is_mc_or_valid_tkip_keyix)
+-				rxs->flag |= RX_FLAG_MMIC_ERROR;
+-			else
+-				rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
++			mic_error = false;
+ 		}
++
+ 		/*
+ 		 * Reject error frames with the exception of
+ 		 * decryption and MIC failures. For monitor mode,
+@@ -886,6 +882,18 @@ static bool ath9k_rx_accept(struct ath_c
+ 			}
+ 		}
+ 	}
++
++	/*
++	 * For unicast frames the MIC error bit can have false positives,
++	 * so all MIC error reports need to be validated in software.
++	 * False negatives are not common, so skip software verification
++	 * if the hardware considers the MIC valid.
++	 */
++	if (strip_mic)
++		rxs->flag |= RX_FLAG_MMIC_STRIPPED;
++	else if (is_mc && mic_error)
++		rxs->flag |= RX_FLAG_MMIC_ERROR;
++
+ 	return true;
+ }
+ 
+@@ -1938,6 +1946,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
+ 			sc->rx.rxotherant = 0;
+ 		}
+ 
++		if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
++			skb_trim(skb, skb->len - 8);
++
+ 		spin_lock_irqsave(&sc->sc_pm_lock, flags);
+ 
+ 		if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
+--- a/drivers/net/wireless/ath/ath9k/reg.h
++++ b/drivers/net/wireless/ath/ath9k/reg.h
+@@ -600,7 +600,6 @@
+ 
+ #define AR_D_GBL_IFS_SIFS         0x1030
+ #define AR_D_GBL_IFS_SIFS_M       0x0000FFFF
+-#define AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR 0x000003AB
+ #define AR_D_GBL_IFS_SIFS_RESV0   0xFFFFFFFF
+ 
+ #define AR_D_TXBLK_BASE            0x1038
+@@ -616,12 +615,10 @@
+ #define AR_D_GBL_IFS_SLOT         0x1070
+ #define AR_D_GBL_IFS_SLOT_M       0x0000FFFF
+ #define AR_D_GBL_IFS_SLOT_RESV0   0xFFFF0000
+-#define AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR   0x00000420
+ 
+ #define AR_D_GBL_IFS_EIFS         0x10b0
+ #define AR_D_GBL_IFS_EIFS_M       0x0000FFFF
+ #define AR_D_GBL_IFS_EIFS_RESV0   0xFFFF0000
+-#define AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR   0x0000A5EB
+ 
+ #define AR_D_GBL_IFS_MISC        0x10f0
+ #define AR_D_GBL_IFS_MISC_LFSR_SLICE_SEL        0x00000007
+@@ -1477,7 +1474,6 @@ enum {
+ #define AR_TIME_OUT_ACK_S    0
+ #define AR_TIME_OUT_CTS      0x3FFF0000
+ #define AR_TIME_OUT_CTS_S    16
+-#define AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR    0x16001D56
+ 
+ #define AR_RSSI_THR          0x8018
+ #define AR_RSSI_THR_MASK     0x000000FF
+@@ -1493,7 +1489,6 @@ enum {
+ #define AR_USEC_TX_LAT_S     14
+ #define AR_USEC_RX_LAT       0x1F800000
+ #define AR_USEC_RX_LAT_S     23
+-#define AR_USEC_ASYNC_FIFO_DUR    0x12e00074
+ 
+ #define AR_RESET_TSF        0x8020
+ #define AR_RESET_TSF_ONCE   0x01000000
diff --git a/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch b/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch
index 767f905a7..88038883b 100644
--- a/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch
+++ b/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch
@@ -8,7 +8,7 @@
  #include <asm/unaligned.h>
  
  #include "hw.h"
-@@ -443,8 +444,16 @@ static int ath9k_hw_init_macaddr(struct 
+@@ -453,8 +454,16 @@ static int ath9k_hw_init_macaddr(struct 
  		common->macaddr[2 * i] = eeval >> 8;
  		common->macaddr[2 * i + 1] = eeval & 0xff;
  	}
diff --git a/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch b/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
index c3e56d3f1..d93686c50 100644
--- a/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
+++ b/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1591,8 +1591,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -1656,8 +1656,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
  	REG_WRITE(ah, AR_OBS, 8);
  
  	if (ah->config.rx_intr_mitigation) {
diff --git a/package/mac80211/patches/511-ath9k_increase_bcbuf.patch b/package/mac80211/patches/511-ath9k_increase_bcbuf.patch
index d9e996a72..0b829ec79 100644
--- a/package/mac80211/patches/511-ath9k_increase_bcbuf.patch
+++ b/package/mac80211/patches/511-ath9k_increase_bcbuf.patch
@@ -11,7 +11,7 @@
  #define IEEE80211_MS_TO_TU(x)           (((x) * 1000) / 1024)
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -364,8 +364,8 @@ static void ath9k_hw_init_config(struct 
+@@ -374,8 +374,8 @@ static void ath9k_hw_init_config(struct 
  {
  	int i;
  
diff --git a/package/mac80211/patches/540-ath9k_channelbw_debugfs.patch b/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
similarity index 100%
rename from package/mac80211/patches/540-ath9k_channelbw_debugfs.patch
rename to package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
diff --git a/package/mac80211/patches/530-ath9k_noise_dbm_fixup.patch b/package/mac80211/patches/530-ath9k_noise_dbm_fixup.patch
index 7e41b2cb6..4e9f38743 100644
--- a/package/mac80211/patches/530-ath9k_noise_dbm_fixup.patch
+++ b/package/mac80211/patches/530-ath9k_noise_dbm_fixup.patch
@@ -38,7 +38,7 @@
  
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1427,6 +1427,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -1488,6 +1488,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
  		memset(caldata, 0, sizeof(*caldata));
  		ath9k_init_nfcal_hist_buffer(ah, chan);
  	}
@@ -69,7 +69,7 @@
  
 --- a/drivers/net/wireless/ath/ath9k/recv.c
 +++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -986,6 +986,8 @@ static int ath9k_rx_skb_preprocess(struc
+@@ -994,6 +994,8 @@ static int ath9k_rx_skb_preprocess(struc
  				   struct ieee80211_rx_status *rx_status,
  				   bool *decrypt_error)
  {
@@ -78,7 +78,7 @@
  	memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
  
  	/*
-@@ -1006,7 +1008,7 @@ static int ath9k_rx_skb_preprocess(struc
+@@ -1014,7 +1016,7 @@ static int ath9k_rx_skb_preprocess(struc
  
  	rx_status->band = hw->conf.channel->band;
  	rx_status->freq = hw->conf.channel->center_freq;
diff --git a/package/mac80211/patches/560-ath9k_rx_stop.patch b/package/mac80211/patches/540-ath9k_rx_stop.patch
similarity index 100%
rename from package/mac80211/patches/560-ath9k_rx_stop.patch
rename to package/mac80211/patches/540-ath9k_rx_stop.patch
diff --git a/package/mac80211/patches/541-ath9k_pllclock_fix.patch b/package/mac80211/patches/541-ath9k_pllclock_fix.patch
deleted file mode 100644
index 4738159fd..000000000
--- a/package/mac80211/patches/541-ath9k_pllclock_fix.patch
+++ /dev/null
@@ -1,42 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-@@ -447,26 +447,27 @@ static void ar9002_olc_init(struct ath_h
- static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
- 					 struct ath9k_channel *chan)
- {
-+	int ref_div = 5;
-+	int pll_div = 0x2c;
- 	u32 pll;
- 
--	pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
-+	if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) {
-+		if (AR_SREV_9280_20(ah)) {
-+			ref_div = 10;
-+			pll_div = 0x50;
-+		} else {
-+			pll_div = 0x28;
-+		}
-+	}
-+
-+	pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
-+	pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
- 
- 	if (chan && IS_CHAN_HALF_RATE(chan))
- 		pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
- 	else if (chan && IS_CHAN_QUARTER_RATE(chan))
- 		pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
- 
--	if (chan && IS_CHAN_5GHZ(chan)) {
--		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
--			pll = 0x142c;
--		else if (AR_SREV_9280_20(ah))
--			pll = 0x2850;
--		else
--			pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
--	} else {
--		pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
--	}
--
- 	return pll;
- }
- 
diff --git a/package/mac80211/patches/542-ath9k_always_enable_fastclock.patch b/package/mac80211/patches/542-ath9k_always_enable_fastclock.patch
deleted file mode 100644
index c3e4a98e9..000000000
--- a/package/mac80211/patches/542-ath9k_always_enable_fastclock.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2089,10 +2089,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
- 			pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
- 	} else {
- 		pCap->tx_desc_len = sizeof(struct ath_desc);
--		if (AR_SREV_9280_20(ah) &&
--		    ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <=
--		      AR5416_EEP_MINOR_VER_16) ||
--		     ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G)))
-+		if (AR_SREV_9280_20(ah))
- 			pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
- 	}
- 
diff --git a/package/mac80211/patches/543-ath9k_fix_mac_clock_div.patch b/package/mac80211/patches/543-ath9k_fix_mac_clock_div.patch
deleted file mode 100644
index f76c54229..000000000
--- a/package/mac80211/patches/543-ath9k_fix_mac_clock_div.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -100,6 +100,13 @@ static void ath9k_hw_set_clockrate(struc
- 	if (conf_is_ht40(conf))
- 		clockrate *= 2;
- 
-+	if (ah->curchan) {
-+		if (IS_CHAN_HALF_RATE(ah->curchan))
-+			clockrate /= 2;
-+		if (IS_CHAN_QUARTER_RATE(ah->curchan))
-+			clockrate /= 4;
-+	}
-+
- 	common->clockrate = clockrate;
- }
- 
diff --git a/package/mac80211/patches/544-ath9k_fix_ar9287_mac_clock.patch b/package/mac80211/patches/544-ath9k_fix_ar9287_mac_clock.patch
deleted file mode 100644
index f749f1d62..000000000
--- a/package/mac80211/patches/544-ath9k_fix_ar9287_mac_clock.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -88,7 +88,10 @@ static void ath9k_hw_set_clockrate(struc
- 	struct ath_common *common = ath9k_hw_common(ah);
- 	unsigned int clockrate;
- 
--	if (!ah->curchan) /* should really check for CCK instead */
-+	/* AR9287 v1.3+ uses async FIFO and runs the MAC at 117 MHz */
-+	if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah))
-+		clockrate = 117;
-+	else if (!ah->curchan) /* should really check for CCK instead */
- 		clockrate = ATH9K_CLOCK_RATE_CCK;
- 	else if (conf->channel->band == IEEE80211_BAND_2GHZ)
- 		clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
diff --git a/package/mac80211/patches/545-ath9k_timing_settings.patch b/package/mac80211/patches/545-ath9k_timing_settings.patch
deleted file mode 100644
index d83b15082..000000000
--- a/package/mac80211/patches/545-ath9k_timing_settings.patch
+++ /dev/null
@@ -1,106 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -914,6 +914,13 @@ static void ath9k_hw_init_interrupt_mask
- 	}
- }
- 
-+static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
-+{
-+	u32 val = ath9k_hw_mac_to_clks(ah, us - 2);
-+	val = min(val, (u32) 0xFFFF);
-+	REG_WRITE(ah, AR_D_GBL_IFS_SIFS, val);
-+}
-+
- static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
- {
- 	u32 val = ath9k_hw_mac_to_clks(ah, us);
-@@ -951,25 +958,60 @@ static bool ath9k_hw_set_global_txtimeou
- 
- void ath9k_hw_init_global_settings(struct ath_hw *ah)
- {
--	struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
-+	struct ath_common *common = ath9k_hw_common(ah);
-+	struct ieee80211_conf *conf = &common->hw->conf;
-+	const struct ath9k_channel *chan = ah->curchan;
- 	int acktimeout;
- 	int slottime;
- 	int sifstime;
-+	int rx_lat = 0, tx_lat = 0, eifs = 0;
-+	u32 reg;
- 
- 	ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
- 		ah->misc_mode);
- 
-+	if (!chan)
-+		return;
-+
- 	if (ah->misc_mode != 0)
- 		REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
- 
--	if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
--		sifstime = 16;
--	else
--		sifstime = 10;
-+	rx_lat = 37;
-+	tx_lat = 54;
-+
-+	if (IS_CHAN_HALF_RATE(chan)) {
-+		eifs = 175;
-+		rx_lat *= 2;
-+		tx_lat *= 2;
-+		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
-+		    tx_lat += 11;
-+
-+		slottime = 13;
-+		sifstime = 32;
-+	} else if (IS_CHAN_QUARTER_RATE(chan)) {
-+		eifs = 340;
-+		rx_lat *= 4;
-+		tx_lat *= 4;
-+		if (IS_CHAN_A_FAST_CLOCK(ah, chan))
-+		    tx_lat += 22;
-+
-+		slottime = 21;
-+		sifstime = 64;
-+	} else {
-+		eifs = REG_READ(ah, AR_D_GBL_IFS_EIFS);
-+		reg = REG_READ(ah, AR_USEC);
-+		rx_lat = MS(reg, AR_USEC_RX_LAT);
-+		tx_lat = MS(reg, AR_USEC_TX_LAT);
-+
-+		slottime = ah->slottime;
-+		if (IS_CHAN_5GHZ(chan))
-+			sifstime = 16;
-+		else
-+			sifstime = 10;
-+	}
- 
- 	/* As defined by IEEE 802.11-2007 17.3.8.6 */
--	slottime = ah->slottime + 3 * ah->coverage_class;
--	acktimeout = slottime + sifstime;
-+	acktimeout = slottime + sifstime + 3 * ah->coverage_class;
- 
- 	/*
- 	 * Workaround for early ACK timeouts, add an offset to match the
-@@ -981,11 +1023,20 @@ void ath9k_hw_init_global_settings(struc
- 	if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
- 		acktimeout += 64 - sifstime - ah->slottime;
- 
--	ath9k_hw_setslottime(ah, ah->slottime);
-+	ath9k_hw_set_sifs_time(ah, sifstime);
-+	ath9k_hw_setslottime(ah, slottime);
- 	ath9k_hw_set_ack_timeout(ah, acktimeout);
- 	ath9k_hw_set_cts_timeout(ah, acktimeout);
- 	if (ah->globaltxtimeout != (u32) -1)
- 		ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
-+
-+	REG_WRITE(ah, AR_D_GBL_IFS_EIFS, ath9k_hw_mac_to_clks(ah, eifs));
-+	REG_RMW(ah, AR_USEC,
-+		(common->clockrate - 1) |
-+		SM(rx_lat, AR_USEC_RX_LAT) |
-+		SM(tx_lat, AR_USEC_TX_LAT),
-+		AR_USEC_TX_LAT | AR_USEC_RX_LAT | AR_USEC_USEC);
-+
- }
- EXPORT_SYMBOL(ath9k_hw_init_global_settings);
- 
diff --git a/package/mac80211/patches/546-ath9k_cleanup_ar9287_settings.patch b/package/mac80211/patches/546-ath9k_cleanup_ar9287_settings.patch
deleted file mode 100644
index a160feed8..000000000
--- a/package/mac80211/patches/546-ath9k_cleanup_ar9287_settings.patch
+++ /dev/null
@@ -1,117 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
-@@ -499,45 +499,6 @@ void ar9002_hw_enable_async_fifo(struct 
- 	}
- }
- 
--/*
-- * If Async FIFO is enabled, the following counters change as MAC now runs
-- * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
-- *
-- * The values below tested for ht40 2 chain.
-- * Overwrite the delay/timeouts initialized in process ini.
-- */
--void ar9002_hw_update_async_fifo(struct ath_hw *ah)
--{
--	if (AR_SREV_9287_13_OR_LATER(ah)) {
--		REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
--			  AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
--		REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
--			  AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
--		REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
--			  AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
--
--		REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
--		REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
--
--		REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
--			    AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
--		REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
--			      AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
--	}
--}
--
--/*
-- * We don't enable WEP aggregation on mac80211 but we keep this
-- * around for HAL unification purposes.
-- */
--void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
--{
--	if (AR_SREV_9287_13_OR_LATER(ah)) {
--		REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
--			    AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
--	}
--}
--
- /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
- void ar9002_hw_attach_ops(struct ath_hw *ah)
- {
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1641,9 +1641,13 @@ int ath9k_hw_reset(struct ath_hw *ah, st
- 
- 	ath9k_hw_init_global_settings(ah);
- 
--	if (!AR_SREV_9300_20_OR_LATER(ah)) {
--		ar9002_hw_update_async_fifo(ah);
--		ar9002_hw_enable_wep_aggregation(ah);
-+	if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
-+		REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
-+			    AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
-+		REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
-+			      AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
-+		REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
-+			    AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
- 	}
- 
- 	REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -984,8 +984,6 @@ void ath9k_hw_get_delta_slope_vals(struc
- void ar9002_hw_cck_chan14_spread(struct ath_hw *ah);
- int ar9002_hw_rf_claim(struct ath_hw *ah);
- void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
--void ar9002_hw_update_async_fifo(struct ath_hw *ah);
--void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
- 
- /*
-  * Code specific to AR9003, we stuff these here to avoid callbacks
---- a/drivers/net/wireless/ath/ath9k/reg.h
-+++ b/drivers/net/wireless/ath/ath9k/reg.h
-@@ -600,7 +600,6 @@
- 
- #define AR_D_GBL_IFS_SIFS         0x1030
- #define AR_D_GBL_IFS_SIFS_M       0x0000FFFF
--#define AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR 0x000003AB
- #define AR_D_GBL_IFS_SIFS_RESV0   0xFFFFFFFF
- 
- #define AR_D_TXBLK_BASE            0x1038
-@@ -616,12 +615,10 @@
- #define AR_D_GBL_IFS_SLOT         0x1070
- #define AR_D_GBL_IFS_SLOT_M       0x0000FFFF
- #define AR_D_GBL_IFS_SLOT_RESV0   0xFFFF0000
--#define AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR   0x00000420
- 
- #define AR_D_GBL_IFS_EIFS         0x10b0
- #define AR_D_GBL_IFS_EIFS_M       0x0000FFFF
- #define AR_D_GBL_IFS_EIFS_RESV0   0xFFFF0000
--#define AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR   0x0000A5EB
- 
- #define AR_D_GBL_IFS_MISC        0x10f0
- #define AR_D_GBL_IFS_MISC_LFSR_SLICE_SEL        0x00000007
-@@ -1477,7 +1474,6 @@ enum {
- #define AR_TIME_OUT_ACK_S    0
- #define AR_TIME_OUT_CTS      0x3FFF0000
- #define AR_TIME_OUT_CTS_S    16
--#define AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR    0x16001D56
- 
- #define AR_RSSI_THR          0x8018
- #define AR_RSSI_THR_MASK     0x000000FF
-@@ -1493,7 +1489,6 @@ enum {
- #define AR_USEC_TX_LAT_S     14
- #define AR_USEC_RX_LAT       0x1F800000
- #define AR_USEC_RX_LAT_S     23
--#define AR_USEC_ASYNC_FIFO_DUR    0x12e00074
- 
- #define AR_RESET_TSF        0x8020
- #define AR_RESET_TSF_ONCE   0x01000000
diff --git a/package/mac80211/patches/547-ath9k_half_quarter_set_channel_frac.patch b/package/mac80211/patches/547-ath9k_half_quarter_set_channel_frac.patch
deleted file mode 100644
index cb215b8c6..000000000
--- a/package/mac80211/patches/547-ath9k_half_quarter_set_channel_frac.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-@@ -111,7 +111,9 @@ static int ar9002_hw_set_channel(struct 
- 
- 		switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
- 		case 0:
--			if ((freq % 20) == 0)
-+			if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
-+				aModeRefSel = 0;
-+			else if ((freq % 20) == 0)
- 				aModeRefSel = 3;
- 			else if ((freq % 10) == 0)
- 				aModeRefSel = 2;
diff --git a/package/mac80211/patches/548-ath9k_half_quarter_synth_delay.patch b/package/mac80211/patches/548-ath9k_half_quarter_synth_delay.patch
deleted file mode 100644
index 6429d1907..000000000
--- a/package/mac80211/patches/548-ath9k_half_quarter_synth_delay.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-@@ -627,6 +627,11 @@ static void ar5008_hw_init_bb(struct ath
- 	else
- 		synthDelay /= 10;
- 
-+	if (IS_CHAN_HALF_RATE(chan))
-+		synthDelay *= 2;
-+	else if (IS_CHAN_QUARTER_RATE(chan))
-+		synthDelay *= 4;
-+
- 	REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
- 
- 	udelay(synthDelay + BASE_ACTIVATE_DELAY);
diff --git a/package/mac80211/patches/549-ath9k_shift_reg_delay.patch b/package/mac80211/patches/549-ath9k_shift_reg_delay.patch
deleted file mode 100644
index 3676ae42a..000000000
--- a/package/mac80211/patches/549-ath9k_shift_reg_delay.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
-@@ -131,8 +131,9 @@ static int ar9002_hw_set_channel(struct 
- 			channelSel = CHANSEL_5G(freq);
- 
- 			/* RefDivA setting */
--			REG_RMW_FIELD(ah, AR_AN_SYNTH9,
--				      AR_AN_SYNTH9_REFDIVA, refDivA);
-+			ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9,
-+				      AR_AN_SYNTH9_REFDIVA,
-+				      AR_AN_SYNTH9_REFDIVA_S, refDivA);
- 
- 		}
- 
diff --git a/package/mac80211/patches/550-ath9k_mmic_verify.patch b/package/mac80211/patches/550-ath9k_mmic_verify.patch
deleted file mode 100644
index a6b2502bf..000000000
--- a/package/mac80211/patches/550-ath9k_mmic_verify.patch
+++ /dev/null
@@ -1,103 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -814,16 +814,19 @@ static bool ath9k_rx_accept(struct ath_c
- 			    struct ath_rx_status *rx_stats,
- 			    bool *decrypt_error)
- {
--#define is_mc_or_valid_tkip_keyix ((is_mc ||			\
--		(rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
--		test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
--
-+	bool is_mc, is_valid_tkip, strip_mic, mic_error = false;
- 	struct ath_hw *ah = common->ah;
- 	__le16 fc;
- 	u8 rx_status_len = ah->caps.rx_status_len;
- 
- 	fc = hdr->frame_control;
- 
-+	is_mc = !!is_multicast_ether_addr(hdr->addr1);
-+	is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
-+		test_bit(rx_stats->rs_keyix, common->tkip_keymap);
-+	strip_mic = is_valid_tkip && !(rx_stats->rs_status &
-+		(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
-+
- 	if (!rx_stats->rs_datalen)
- 		return false;
-         /*
-@@ -838,6 +841,11 @@ static bool ath9k_rx_accept(struct ath_c
- 	if (rx_stats->rs_more)
- 		return true;
- 
-+	mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
-+		!ieee80211_has_morefrags(fc) &&
-+		!(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
-+		(rx_stats->rs_status & ATH9K_RXERR_MIC);
-+
- 	/*
- 	 * The rx_stats->rs_status will not be set until the end of the
- 	 * chained descriptors so it can be ignored if rs_more is set. The
-@@ -845,30 +853,18 @@ static bool ath9k_rx_accept(struct ath_c
- 	 * descriptors.
- 	 */
- 	if (rx_stats->rs_status != 0) {
--		if (rx_stats->rs_status & ATH9K_RXERR_CRC)
-+		if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
- 			rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
-+			mic_error = false;
-+		}
- 		if (rx_stats->rs_status & ATH9K_RXERR_PHY)
- 			return false;
- 
- 		if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
- 			*decrypt_error = true;
--		} else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
--			bool is_mc;
--			/*
--			 * The MIC error bit is only valid if the frame
--			 * is not a control frame or fragment, and it was
--			 * decrypted using a valid TKIP key.
--			 */
--			is_mc = !!is_multicast_ether_addr(hdr->addr1);
--
--			if (!ieee80211_is_ctl(fc) &&
--			    !ieee80211_has_morefrags(fc) &&
--			    !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
--			    is_mc_or_valid_tkip_keyix)
--				rxs->flag |= RX_FLAG_MMIC_ERROR;
--			else
--				rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
-+			mic_error = false;
- 		}
-+
- 		/*
- 		 * Reject error frames with the exception of
- 		 * decryption and MIC failures. For monitor mode,
-@@ -886,6 +882,18 @@ static bool ath9k_rx_accept(struct ath_c
- 			}
- 		}
- 	}
-+
-+	/*
-+	 * For unicast frames the MIC error bit can have false positives,
-+	 * so all MIC error reports need to be validated in software.
-+	 * False negatives are not common, so skip software verification
-+	 * if the hardware considers the MIC valid.
-+	 */
-+	if (strip_mic)
-+		rxs->flag |= RX_FLAG_MMIC_STRIPPED;
-+	else if (is_mc && mic_error)
-+		rxs->flag |= RX_FLAG_MMIC_ERROR;
-+
- 	return true;
- }
- 
-@@ -1940,6 +1948,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
- 			sc->rx.rxotherant = 0;
- 		}
- 
-+		if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
-+			skb_trim(skb, skb->len - 8);
-+
- 		spin_lock_irqsave(&sc->sc_pm_lock, flags);
- 
- 		if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
diff --git a/package/mac80211/patches/590-mac80211_cur_txpower.patch b/package/mac80211/patches/550-mac80211_cur_txpower.patch
similarity index 100%
rename from package/mac80211/patches/590-mac80211_cur_txpower.patch
rename to package/mac80211/patches/550-mac80211_cur_txpower.patch
diff --git a/package/mac80211/patches/591-ath9k_initialize_chainmask.patch b/package/mac80211/patches/551-ath9k_initialize_chainmask.patch
similarity index 100%
rename from package/mac80211/patches/591-ath9k_initialize_chainmask.patch
rename to package/mac80211/patches/551-ath9k_initialize_chainmask.patch
diff --git a/package/mac80211/patches/592-ath9k_remove_tx_indexoffset.patch b/package/mac80211/patches/552-ath9k_remove_tx_indexoffset.patch
similarity index 100%
rename from package/mac80211/patches/592-ath9k_remove_tx_indexoffset.patch
rename to package/mac80211/patches/552-ath9k_remove_tx_indexoffset.patch
diff --git a/package/mac80211/patches/593-ath9k_fix_rate_power.patch b/package/mac80211/patches/553-ath9k_fix_rate_power.patch
similarity index 100%
rename from package/mac80211/patches/593-ath9k_fix_rate_power.patch
rename to package/mac80211/patches/553-ath9k_fix_rate_power.patch
diff --git a/package/mac80211/patches/594-ath9k_test_txpower.patch b/package/mac80211/patches/554-ath9k_test_txpower.patch
similarity index 99%
rename from package/mac80211/patches/594-ath9k_test_txpower.patch
rename to package/mac80211/patches/554-ath9k_test_txpower.patch
index 45a51be61..96131dc9d 100644
--- a/package/mac80211/patches/594-ath9k_test_txpower.patch
+++ b/package/mac80211/patches/554-ath9k_test_txpower.patch
@@ -22,4 +22,3 @@
  }
  EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
  
-
diff --git a/package/mac80211/patches/595-ath9k_cur_txpower.patch b/package/mac80211/patches/555-ath9k_cur_txpower.patch
similarity index 100%
rename from package/mac80211/patches/595-ath9k_cur_txpower.patch
rename to package/mac80211/patches/555-ath9k_cur_txpower.patch
diff --git a/package/mac80211/patches/570-mac80211_agg_buf_size.patch b/package/mac80211/patches/570-mac80211_agg_buf_size.patch
deleted file mode 100644
index e7efd7068..000000000
--- a/package/mac80211/patches/570-mac80211_agg_buf_size.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/mac80211/agg-tx.c
-+++ b/net/mac80211/agg-tx.c
-@@ -814,7 +814,7 @@ void ieee80211_process_addba_resp(struct
- 		 * of at least 1.
- 		 */
- 		if (!buf_size)
--			goto out;
-+			buf_size = 1;
- 
- 		if (test_and_set_bit(HT_AGG_STATE_RESPONSE_RECEIVED,
- 				     &tid_tx->state)) {
diff --git a/package/mac80211/patches/580-ath9k_fixup_chainmask.patch b/package/mac80211/patches/580-ath9k_fixup_chainmask.patch
deleted file mode 100644
index 07e78d3b3..000000000
--- a/package/mac80211/patches/580-ath9k_fixup_chainmask.patch
+++ /dev/null
@@ -1,51 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2007,12 +2007,22 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_ti
- /* HW Capabilities */
- /*******************/
- 
-+static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask)
-+{
-+	eeprom_chainmask &= chip_chainmask;
-+	if (eeprom_chainmask)
-+		return eeprom_chainmask;
-+	else
-+		return chip_chainmask;
-+}
-+
- int ath9k_hw_fill_cap_info(struct ath_hw *ah)
- {
- 	struct ath9k_hw_capabilities *pCap = &ah->caps;
- 	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- 	struct ath_common *common = ath9k_hw_common(ah);
- 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
-+	unsigned int chip_chainmask;
- 
- 	u16 eeval;
- 	u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
-@@ -2049,6 +2059,15 @@ int ath9k_hw_fill_cap_info(struct ath_hw
- 	if (eeval & AR5416_OPFLAGS_11G)
- 		pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
- 
-+	if (AR_SREV_9485(ah) || AR_SREV_9285(ah) || AR_SREV_9330(ah))
-+		chip_chainmask = 1;
-+	else if (!AR_SREV_9280_20_OR_LATER(ah))
-+		chip_chainmask = 7;
-+	else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah))
-+		chip_chainmask = 3;
-+	else
-+		chip_chainmask = 7;
-+
- 	pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
- 	/*
- 	 * For AR9271 we will temporarilly uses the rx chainmax as read from
-@@ -2065,6 +2084,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw
- 		/* Use rx_chainmask from EEPROM. */
- 		pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
- 
-+	pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask);
-+	pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask);
-+
- 	ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
- 
- 	/* enable key search for every frame in an aggregate */
diff --git a/package/mac80211/patches/820-b43-backport.patch b/package/mac80211/patches/820-b43-backport.patch
index ec3b1440c..3dbf9367f 100644
--- a/package/mac80211/patches/820-b43-backport.patch
+++ b/package/mac80211/patches/820-b43-backport.patch
@@ -309,7 +309,7 @@
  #endif /* B43_BUS_H_ */
 --- a/drivers/net/wireless/b43/dma.c
 +++ b/drivers/net/wireless/b43/dma.c
-@@ -174,7 +174,7 @@ static void op64_fill_descriptor(struct
+@@ -174,7 +174,7 @@ static void op64_fill_descriptor(struct 
  	addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
  	addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
  	    >> SSB_DMA_TRANSLATION_SHIFT;
diff --git a/package/mac80211/patches/850-b43-add-core-rev-17-used-on-bcma-SoC.patch b/package/mac80211/patches/850-b43-add-core-rev-17-used-on-bcma-SoC.patch
index 24a38b596..91a836459 100644
--- a/package/mac80211/patches/850-b43-add-core-rev-17-used-on-bcma-SoC.patch
+++ b/package/mac80211/patches/850-b43-add-core-rev-17-used-on-bcma-SoC.patch
@@ -11,7 +11,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
 
 --- a/drivers/net/wireless/b43/main.c
 +++ b/drivers/net/wireless/b43/main.c
-@@ -120,6 +120,7 @@ MODULE_PARM_DESC(pio, "Use PIO accesses
+@@ -120,6 +120,7 @@ MODULE_PARM_DESC(pio, "Use PIO accesses 
  
  #ifdef CONFIG_B43_BCMA
  static const struct bcma_device_id b43_bcma_tbl[] = {
-- 
2.20.1