From a8a91697ce4c8f9d1e701b52356f69702741d5cd Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Thu, 7 May 2009 21:00:35 +0000
Subject: madwifi: improve autochannel, nuke some dead code, fix scanlist
 building from channel mode

SVN-Revision: 15702
---
 package/madwifi/patches/389-autochannel.patch      | 139 +++++++++++++++++++--
 package/madwifi/patches/393-mbss_vap_auth.patch    |  10 +-
 package/madwifi/patches/395-ath_ff_unmap.patch     |   2 +-
 package/madwifi/patches/396-napi_ff_fix.patch      |   6 +-
 package/madwifi/patches/400-new_hal.patch          |   2 +-
 package/madwifi/patches/406-monitor_r3711.patch    |   4 +-
 package/madwifi/patches/408-changeset_r3337.patch  |   2 +-
 .../madwifi/patches/411-autochannel_multi.patch    |  16 +--
 .../madwifi/patches/412-fragmentation_fix.patch    |   2 +-
 package/madwifi/patches/414-txpower.patch          |   6 +-
 package/madwifi/patches/416-wprobe.patch           |  10 +-
 package/madwifi/patches/417-beacon_txpower.patch   |   4 +-
 package/madwifi/patches/419-skb_unmap_crash.patch  |   4 +-
 package/madwifi/patches/420-diversity_fix.patch    |   8 +-
 package/madwifi/patches/421-channel_handling.patch |  56 ++++-----
 15 files changed, 197 insertions(+), 74 deletions(-)

(limited to 'package/madwifi/patches')

diff --git a/package/madwifi/patches/389-autochannel.patch b/package/madwifi/patches/389-autochannel.patch
index 65e03e7381..8f7437a3f4 100644
--- a/package/madwifi/patches/389-autochannel.patch
+++ b/package/madwifi/patches/389-autochannel.patch
@@ -16,10 +16,14 @@
  	sc->sc_curchan.channel = ic->ic_curchan->ic_freq;
  	sc->sc_curchan.channelFlags = ath_chan2flags(ic->ic_curchan);
  	if (!ath_hal_reset(ah, sc->sc_opmode, &sc->sc_curchan, AH_FALSE, &status)) {
-@@ -2914,6 +2916,40 @@ ath_hw_check_atim(struct ath_softc *sc, 
+@@ -2913,6 +2915,48 @@ ath_hw_check_atim(struct ath_softc *sc, 
+ 	return 0;
  }
  
- 
++#define AR5K_MIBC       0x0040
++#define AR5K_MIBC_FREEZE   (1 << 1)
++#define AR5K_TXFC       0x80ec
++#define AR5K_RXFC       0x80f0
 +#define AR5K_RXCLEAR	0x80f4
 +#define AR5K_CYCLES		0x80f8
 +static void
@@ -36,13 +40,15 @@
 +	if (!ic->ic_curchan || (ic->ic_curchan == IEEE80211_CHAN_ANYC))
 +		return;
 +
++	OS_REG_WRITE(ah, AR5K_MIBC, AR5K_MIBC_FREEZE);
 +	rx = OS_REG_READ(ah, AR5K_RXCLEAR);
 +	cc = OS_REG_READ(ah, AR5K_CYCLES);
++
 +	if (!cc)
 +		return;
 +
 +	if (rx > cc)
-+		return; /* wraparound */
++		return; /* should not happen */
 +
 +	if (sc->sc_last_chan)
 +		sc->sc_last_chan->ic_idletime = 100 * (cc - rx) / cc;
@@ -50,14 +56,16 @@
 +
 +	OS_REG_WRITE(ah, AR5K_RXCLEAR, 0);
 +	OS_REG_WRITE(ah, AR5K_CYCLES, 0);
++	OS_REG_WRITE(ah, AR5K_TXFC, 0);
++	OS_REG_WRITE(ah, AR5K_RXFC, 0);
++	OS_REG_WRITE(ah, AR5K_MIBC, 0);
 +}
 +#undef AR5K_RXCLEAR
 +#undef AR5K_CYCLES
-+
+ 
  /*
   * Reset the hardware w/o losing operational state.  This is
-  * basically a more efficient way of doing ath_stop, ath_init,
-@@ -2940,6 +2976,7 @@ ath_reset(struct net_device *dev)
+@@ -2940,6 +2984,7 @@ ath_reset(struct net_device *dev)
  	 * Convert to a HAL channel description with the flags
  	 * constrained to reflect the current operating mode.
  	 */
@@ -65,14 +73,29 @@
  	c = ic->ic_curchan;
  	sc->sc_curchan.channel = c->ic_freq;
  	sc->sc_curchan.channelFlags = ath_chan2flags(c);
-@@ -9022,6 +9059,7 @@ ath_chan_set(struct ath_softc *sc, struc
+@@ -9022,6 +9067,7 @@ ath_chan_set(struct ath_softc *sc, struc
  	u_int8_t channel_change_required = 0;
  	struct timeval tv;
  
-+	ath_fetch_idle_time(sc);
++
  	/*
  	 * Convert to a HAL channel description with
  	 * the flags constrained to reflect the current
+@@ -9030,6 +9076,14 @@ ath_chan_set(struct ath_softc *sc, struc
+ 	memset(&hchan, 0, sizeof(HAL_CHANNEL));
+ 	hchan.channel = chan->ic_freq;
+ 	hchan.channelFlags = ath_chan2flags(chan);
++
++	/* don't do duplicate channel changes, but do
++	 * store the available idle time */
++	ath_fetch_idle_time(sc);
++	if ((sc->sc_curchan.channel == hchan.channel) &&
++		(sc->sc_curchan.channelFlags == hchan.channelFlags))
++		return 0;
++
+ 	KASSERT(hchan.channel != 0,
+ 		("bogus channel %u/0x%x", hchan.channel, hchan.channelFlags));
+ 	do_gettimeofday(&tv);
 --- a/ath/if_athvar.h
 +++ b/ath/if_athvar.h
 @@ -773,6 +773,7 @@ struct ath_softc {
@@ -123,3 +146,103 @@
  	EVALUATE_CRITERION(sc, ic, a, b);
  	/* XXX: rssi useless? pick_channel evaluates it anyway */
  	EVALUATE_CRITERION(rssi, params->ss->ss_priv, a, b);
+@@ -519,16 +533,9 @@ pick_channel(struct ieee80211_scan_state
+ #endif
+ 
+ 	best = NULL;
+-	best_rssi = 0xff; /* If signal is bigger than 0xff, we'd be melting. */
+ 
+ 	for (i = 0; i < ss_last; i++) {
+ 		c = &chans[i];
+-		benefit = best_rssi - as->as_maxrssi[c->chan->ic_ieee];
+-		sta_assoc = ic->ic_sta_assoc;
+-
+-		/* Don't switch... */
+-		if (benefit <= 0)
+-			continue;
+ 
+ 		/* Verify channel is not marked for non-occupancy */
+ 		if (IEEE80211_IS_CHAN_RADAR(c->chan))
+@@ -546,31 +553,8 @@ pick_channel(struct ieee80211_scan_state
+ 				break;
+ 		}
+ 
+-		if (sta_assoc != 0) {
+-			int sl = ic->ic_cn_total - 
+-				ic->ic_chan_nodes[c->chan->ic_ieee]; /* count */
+-			if (ic->ic_sc_algorithm == IEEE80211_SC_LOOSE) {
+-				int sl_max = ic->ic_sc_sldg * benefit;
+-				sl = 1000 * sl / sta_assoc; /* permil */
+-				IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+-						"%s: chan %d, dB gained: %d, "
+-						"STAs lost: %d permil (max %d)\n",
+-						__func__, c->chan->ic_ieee, 
+-						benefit, sl, sl_max);
+-				if (sl > sl_max)
+-					continue;
+-			} else if (((ic->ic_sc_algorithm == 
+-						 IEEE80211_SC_TIGHT) ||
+-					(ic->ic_sc_algorithm == 
+-						 IEEE80211_SC_STRICT)) && 
+-					(sl > 0)) {
+-				/* Break the loop as the subsequent chans 
+-				 * won't be better. */
+-				break;
+-			}
+-		}
+ 		best = c->chan;
+-		best_rssi = as->as_maxrssi[best->ic_ieee];
++		break;
+ 	}
+ 
+ 	if (best != NULL) {
+@@ -599,6 +583,9 @@ ap_end(struct ieee80211_scan_state *ss, 
+ 		("wrong opmode %u", vap->iv_opmode));
+ 
+ 	ic = vap->iv_ic;
++
++	/* record stats for the channel that was scanned last */
++	ic->ic_set_channel(ic);
+ 	bestchan = pick_channel(ss, vap, flags);
+ 	if (bestchan == NULL) {
+ 		if (ss->ss_last > 0) {
+--- a/net80211/ieee80211_scan.c
++++ b/net80211/ieee80211_scan.c
+@@ -1002,20 +1002,33 @@ ieee80211_scan_add_channels(struct ieee8
+ {
+ 	struct ieee80211_channel *c, *cg;
+ 	u_int modeflags;
++	int has_non_turbo = 0;
+ 	int i;
+ 
+ 	KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
+ 	modeflags = chanflags[mode];
+ 	for (i = 0; i < ic->ic_nchans; i++) {
++		if (c->ic_flags & (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO))
++			continue;
++
++		has_non_turbo = 1;
++		break;
++	}
++	for (i = 0; i < ic->ic_nchans; i++) {
+ 		c = &ic->ic_channels[i];
+ 		if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
+ 			continue;
+ 		if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
+ 			continue;
+-		if (modeflags &&
+-			((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
+-			 (modeflags & IEEE80211_CHAN_ALLTURBO)))
+-			continue;
++		if (modeflags) {
++			if ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
++				 (modeflags & IEEE80211_CHAN_ALLTURBO))
++				continue;
++		} else if (has_non_turbo) {
++			if ((ss->ss_vap->iv_opmode == IEEE80211_M_HOSTAP) &&
++				(c->ic_flags & (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)))
++				continue;
++		}
+ 		if (mode == IEEE80211_MODE_AUTO) {
+ 			/*
+ 			 * XXX special-case 11b/g channels so we select
diff --git a/package/madwifi/patches/393-mbss_vap_auth.patch b/package/madwifi/patches/393-mbss_vap_auth.patch
index 233aeedb5c..e1c9cae0d0 100644
--- a/package/madwifi/patches/393-mbss_vap_auth.patch
+++ b/package/madwifi/patches/393-mbss_vap_auth.patch
@@ -319,7 +319,7 @@
  
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -6580,9 +6580,8 @@ ath_recv_mgmt(struct ieee80211vap * vap,
+@@ -6588,9 +6588,8 @@ ath_recv_mgmt(struct ieee80211vap * vap,
  
  	sc->sc_recv_mgmt(vap, ni_or_null, skb, subtype, rssi, rtsf);
  
@@ -330,7 +330,7 @@
  	         (const struct ieee80211_frame_min *)skb->data);
  	if (ni == NULL) {
  		DPRINTF(sc, ATH_DEBUG_BEACON, "Dropping; node unknown.\n");
-@@ -6737,7 +6736,9 @@ ath_rx_poll(struct net_device *dev, int 
+@@ -6745,7 +6744,9 @@ ath_rx_poll(struct net_device *dev, int 
  	struct ath_desc *ds;
  	struct ath_rx_status *rs;
  	struct sk_buff *skb = NULL;
@@ -340,7 +340,7 @@
  	unsigned int len;
  	int type;
  	u_int phyerr;
-@@ -6892,12 +6893,15 @@ rx_accept:
+@@ -6900,12 +6901,15 @@ rx_accept:
  		skb_trim(skb, skb->len - IEEE80211_CRC_LEN);
  
  		if (mic_fail) {
@@ -358,7 +358,7 @@
  
  			if (ni && ni->ni_table) {
  				ieee80211_check_mic(ni, skb);
-@@ -6959,11 +6963,24 @@ drop_micfail:
+@@ -6967,11 +6971,24 @@ drop_micfail:
  		 * for its use.  If the sender is unknown spam the
  		 * frame; it'll be dropped where it's not wanted.
  		 */
@@ -385,7 +385,7 @@
  			ATH_RSSI_LPF(ATH_NODE(ni)->an_avgrssi, rs->rs_rssi);
  			type = ieee80211_input(ni->ni_vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
  			ieee80211_unref_node(&ni);
-@@ -6972,24 +6989,35 @@ drop_micfail:
+@@ -6980,24 +6997,35 @@ drop_micfail:
  			 * No key index or no entry, do a lookup and
  			 * add the node to the mapping table if possible.
  			 */
diff --git a/package/madwifi/patches/395-ath_ff_unmap.patch b/package/madwifi/patches/395-ath_ff_unmap.patch
index 4c32995c87..6ba99caf31 100644
--- a/package/madwifi/patches/395-ath_ff_unmap.patch
+++ b/package/madwifi/patches/395-ath_ff_unmap.patch
@@ -1,6 +1,6 @@
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -13511,7 +13511,7 @@ cleanup_ath_buf(struct ath_softc *sc, st
+@@ -13527,7 +13527,7 @@ cleanup_ath_buf(struct ath_softc *sc, st
  				bus_unmap_single(
  					sc->sc_bdev,
  					bf->bf_skbaddrff[i], 
diff --git a/package/madwifi/patches/396-napi_ff_fix.patch b/package/madwifi/patches/396-napi_ff_fix.patch
index 0b9acdfb79..fbfd30e266 100644
--- a/package/madwifi/patches/396-napi_ff_fix.patch
+++ b/package/madwifi/patches/396-napi_ff_fix.patch
@@ -1,6 +1,6 @@
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -6725,10 +6725,10 @@ ath_rx_poll(struct net_device *dev, int 
+@@ -6733,10 +6733,10 @@ ath_rx_poll(struct net_device *dev, int 
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
  	struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
  	struct net_device *dev = sc->sc_dev;
@@ -13,7 +13,7 @@
  #endif
  	struct ath_buf *bf;
  	struct ieee80211com *ic = &sc->sc_ic;
-@@ -6771,13 +6771,15 @@ process_rx_again:
+@@ -6779,13 +6779,15 @@ process_rx_again:
  			break;
  		}
  
@@ -33,7 +33,7 @@
  
  		skb = bf->bf_skb;
  		if (skb == NULL) {
-@@ -7061,8 +7063,8 @@ rx_next:
+@@ -7069,8 +7071,8 @@ rx_next:
  		if (sc->sc_isr & HAL_INT_RX) {
  			u_int64_t hw_tsf = ath_hal_gettsf64(ah);
  			sc->sc_isr &= ~HAL_INT_RX;
diff --git a/package/madwifi/patches/400-new_hal.patch b/package/madwifi/patches/400-new_hal.patch
index 0db41683f0..085b602051 100644
--- a/package/madwifi/patches/400-new_hal.patch
+++ b/package/madwifi/patches/400-new_hal.patch
@@ -15,7 +15,7 @@
  	/*
  	 * Check if the MAC has multi-rate retry support.
  	 * We do this by trying to setup a fake extended
-@@ -7555,7 +7563,7 @@ ath_txq_setup(struct ath_softc *sc, int 
+@@ -7563,7 +7571,7 @@ ath_txq_setup(struct ath_softc *sc, int 
  	if (qtype == HAL_TX_QUEUE_UAPSD)
  		qi.tqi_qflags = HAL_TXQ_TXDESCINT_ENABLE;
  	else
diff --git a/package/madwifi/patches/406-monitor_r3711.patch b/package/madwifi/patches/406-monitor_r3711.patch
index af02edce85..13d1d54904 100644
--- a/package/madwifi/patches/406-monitor_r3711.patch
+++ b/package/madwifi/patches/406-monitor_r3711.patch
@@ -1,6 +1,6 @@
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -6521,7 +6521,7 @@ ath_capture(struct net_device *dev, cons
+@@ -6529,7 +6529,7 @@ ath_capture(struct net_device *dev, cons
  
  	/* Never copy the SKB, as it is ours on the RX side, and this is the 
  	 * last process on the TX side and we only modify our own headers. */
@@ -9,7 +9,7 @@
  	if (tskb == NULL) {
  		DPRINTF(sc, ATH_DEBUG_ANY,
  			"Dropping; ath_skb_removepad failed!\n");
-@@ -6529,6 +6529,8 @@ ath_capture(struct net_device *dev, cons
+@@ -6537,6 +6537,8 @@ ath_capture(struct net_device *dev, cons
  	}
  	
  	ieee80211_input_monitor(ic, tskb, bf, tx, tsf, sc);
diff --git a/package/madwifi/patches/408-changeset_r3337.patch b/package/madwifi/patches/408-changeset_r3337.patch
index b798082412..78f89d273a 100644
--- a/package/madwifi/patches/408-changeset_r3337.patch
+++ b/package/madwifi/patches/408-changeset_r3337.patch
@@ -10,7 +10,7 @@
  Please let us know if you think your name should be mentioned here!
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -3138,7 +3138,7 @@ ath_tx_startraw(struct net_device *dev, 
+@@ -3146,7 +3146,7 @@ ath_tx_startraw(struct net_device *dev, 
  	struct ath_softc *sc = dev->priv;
  	struct ath_hal *ah = sc->sc_ah;
  	struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *)
diff --git a/package/madwifi/patches/411-autochannel_multi.patch b/package/madwifi/patches/411-autochannel_multi.patch
index b6093cfcd5..827ab5800a 100644
--- a/package/madwifi/patches/411-autochannel_multi.patch
+++ b/package/madwifi/patches/411-autochannel_multi.patch
@@ -124,7 +124,7 @@
  void
  ieee80211_scan_attach(struct ieee80211com *ic)
  {
-@@ -1155,7 +1272,7 @@ ieee80211_scan_dfs_action(struct ieee802
+@@ -1168,7 +1285,7 @@ ieee80211_scan_dfs_action(struct ieee802
  				IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT;
  			ic->ic_flags |= IEEE80211_F_CHANSWITCH;
  		} else {
@@ -133,7 +133,7 @@
  			IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH,
  					"%s: directly switching to channel "
  					"%3d (%4d MHz)\n", __func__,
-@@ -1166,6 +1283,9 @@ ieee80211_scan_dfs_action(struct ieee802
+@@ -1179,6 +1296,9 @@ ieee80211_scan_dfs_action(struct ieee802
  			 * change the channel here. */
  			change_channel(ic, new_channel);
  			ic->ic_bsschan = new_channel;
@@ -307,7 +307,7 @@
  }
  
  
-@@ -605,6 +613,7 @@ ap_end(struct ieee80211_scan_state *ss, 
+@@ -575,6 +583,7 @@ ap_end(struct ieee80211_scan_state *ss, 
  	struct ap_state *as = ss->ss_priv;
  	struct ieee80211_channel *bestchan = NULL;
  	struct ieee80211com *ic = NULL;
@@ -315,10 +315,10 @@
  	int res = 1;
  
  	SCAN_AP_LOCK_IRQ(as);
-@@ -613,8 +622,11 @@ ap_end(struct ieee80211_scan_state *ss, 
- 		("wrong opmode %u", vap->iv_opmode));
+@@ -586,8 +595,11 @@ ap_end(struct ieee80211_scan_state *ss, 
  
- 	ic = vap->iv_ic;
+ 	/* record stats for the channel that was scanned last */
+ 	ic->ic_set_channel(ic);
 +	spin_lock_irqsave(&channel_lock, sflags);
 +	ieee80211_scan_set_bss_channel(ic, NULL);
  	bestchan = pick_channel(ss, vap, flags);
@@ -327,7 +327,7 @@
  		if (ss->ss_last > 0) {
  			/* no suitable channel, should not happen */
  			printk(KERN_ERR "%s: %s: no suitable channel! "
-@@ -633,6 +645,7 @@ ap_end(struct ieee80211_scan_state *ss, 
+@@ -606,6 +618,7 @@ ap_end(struct ieee80211_scan_state *ss, 
  					bestchan->ic_freq, bestchan->ic_flags &
  					~IEEE80211_CHAN_TURBO)) == NULL) {
  				/* should never happen ?? */
@@ -335,7 +335,7 @@
  				SCAN_AP_UNLOCK_IRQ_EARLY(as);
  				return 0;
  			}
-@@ -645,6 +658,9 @@ ap_end(struct ieee80211_scan_state *ss, 
+@@ -618,6 +631,9 @@ ap_end(struct ieee80211_scan_state *ss, 
  			as->as_action = action;
  		as->as_selbss = se;
  
diff --git a/package/madwifi/patches/412-fragmentation_fix.patch b/package/madwifi/patches/412-fragmentation_fix.patch
index 8c72f547ab..dbe9f8e4f6 100644
--- a/package/madwifi/patches/412-fragmentation_fix.patch
+++ b/package/madwifi/patches/412-fragmentation_fix.patch
@@ -1,6 +1,6 @@
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -3675,6 +3675,7 @@ ff_bypass:
+@@ -3683,6 +3683,7 @@ ff_bypass:
  		 *  already alloc'd
  		 */
  		ATH_TXBUF_LOCK_IRQ(sc);
diff --git a/package/madwifi/patches/414-txpower.patch b/package/madwifi/patches/414-txpower.patch
index 5300de90c6..68e7942d48 100644
--- a/package/madwifi/patches/414-txpower.patch
+++ b/package/madwifi/patches/414-txpower.patch
@@ -165,7 +165,7 @@
  
  static void ath_poll_disable(struct net_device *dev);
  static void ath_poll_enable(struct net_device *dev);
-@@ -3159,7 +3158,7 @@ ath_tx_startraw(struct net_device *dev, 
+@@ -3167,7 +3166,7 @@ ath_tx_startraw(struct net_device *dev, 
  	try0 = ph->try0;
  	rt = sc->sc_currates;
  	txrate = dot11_to_ratecode(sc, rt, ph->rate0);
@@ -174,7 +174,7 @@
  	hdrlen = ieee80211_anyhdrsize(wh);
  	pktlen = skb->len + IEEE80211_CRC_LEN;
  
-@@ -8381,7 +8380,7 @@ ath_tx_start(struct net_device *dev, str
+@@ -8389,7 +8388,7 @@ ath_tx_start(struct net_device *dev, str
  			    pktlen,			/* packet length */
  			    hdrlen,			/* header length */
  			    atype,			/* Atheros packet type */
@@ -183,7 +183,7 @@
  			    txrate, try0,		/* series 0 rate/tries */
  			    keyix,			/* key cache index */
  			    antenna,			/* antenna mode */
-@@ -10364,59 +10363,16 @@ ath_get_clamped_maxtxpower(struct ath_so
+@@ -10380,59 +10379,16 @@ ath_get_clamped_maxtxpower(struct ath_so
  
  /* XXX: this function needs some locking to avoid being called 
   * twice/interrupted */
diff --git a/package/madwifi/patches/416-wprobe.patch b/package/madwifi/patches/416-wprobe.patch
index 4530737829..0eb5f8928d 100644
--- a/package/madwifi/patches/416-wprobe.patch
+++ b/package/madwifi/patches/416-wprobe.patch
@@ -419,7 +419,7 @@
  	/* NB: memory is reclaimed through dev->destructor callback */
  	if (decrease)
  		sc->sc_nvaps--;
-@@ -5931,6 +5934,7 @@ ath_node_cleanup(struct ieee80211_node *
+@@ -5939,6 +5942,7 @@ ath_node_cleanup(struct ieee80211_node *
  	/* Clean up node-specific rate things - this currently appears to 
  	 * always be a no-op */
  	sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni));
@@ -427,7 +427,7 @@
  
  	ATH_NODE_UAPSD_LOCK_IRQ(an);
  #ifdef IEEE80211_DEBUG_REFCNT
-@@ -7001,6 +7005,8 @@ drop_micfail:
+@@ -7009,6 +7013,8 @@ drop_micfail:
  				goto lookup_slowpath;
  			}
  			ATH_RSSI_LPF(ATH_NODE(ni)->an_avgrssi, rs->rs_rssi);
@@ -436,7 +436,7 @@
  			type = ieee80211_input(ni->ni_vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
  			ieee80211_unref_node(&ni);
  		} else {
-@@ -7011,15 +7017,22 @@ drop_micfail:
+@@ -7019,15 +7025,22 @@ drop_micfail:
  
  lookup_slowpath:
  			vap = ieee80211_find_rxvap(ic, wh->i_addr1);
@@ -461,7 +461,7 @@
  				type = ieee80211_input(vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
  				/*
  				 * If the station has a key cache slot assigned
-@@ -8599,6 +8612,7 @@ ath_tx_processq(struct ath_softc *sc, st
+@@ -8607,6 +8620,7 @@ ath_tx_processq(struct ath_softc *sc, st
  				sc->sc_stats.ast_tx_rssi = ts->ts_rssi;
  				ATH_RSSI_LPF(an->an_halstats.ns_avgtxrssi,
  					ts->ts_rssi);
@@ -469,7 +469,7 @@
  				if (bf->bf_skb->priority == WME_AC_VO ||
  				    bf->bf_skb->priority == WME_AC_VI)
  					ni->ni_ic->ic_wme.wme_hipri_traffic++;
-@@ -10090,6 +10104,7 @@ ath_newassoc(struct ieee80211_node *ni, 
+@@ -10106,6 +10120,7 @@ ath_newassoc(struct ieee80211_node *ni, 
  	struct ath_softc *sc = ic->ic_dev->priv;
  
  	sc->sc_rc->ops->newassoc(sc, ATH_NODE(ni), isnew);
diff --git a/package/madwifi/patches/417-beacon_txpower.patch b/package/madwifi/patches/417-beacon_txpower.patch
index 4746116c41..80d810a7db 100644
--- a/package/madwifi/patches/417-beacon_txpower.patch
+++ b/package/madwifi/patches/417-beacon_txpower.patch
@@ -9,7 +9,7 @@
  static int countrycode = -1;
  static int maxvaps = -1;
  static int outdoor = -1;
-@@ -4923,6 +4923,7 @@ ath_beacon_setup(struct ath_softc *sc, s
+@@ -4931,6 +4931,7 @@ ath_beacon_setup(struct ath_softc *sc, s
  	(((_ic)->ic_flags & (IEEE80211_F_SHPREAMBLE | IEEE80211_F_USEBARKER))\
  		== IEEE80211_F_SHPREAMBLE)
  	struct ieee80211com *ic = bf->bf_node->ni_ic;
@@ -17,7 +17,7 @@
  	struct sk_buff *skb = bf->bf_skb;
  	struct ath_hal *ah = sc->sc_ah;
  	struct ath_desc *ds;
-@@ -4990,7 +4991,7 @@ ath_beacon_setup(struct ath_softc *sc, s
+@@ -4998,7 +4999,7 @@ ath_beacon_setup(struct ath_softc *sc, s
  		skb->len + IEEE80211_CRC_LEN,	/* frame length */
  		sizeof(struct ieee80211_frame), /* header length */
  		HAL_PKT_TYPE_BEACON,		/* Atheros packet type */
diff --git a/package/madwifi/patches/419-skb_unmap_crash.patch b/package/madwifi/patches/419-skb_unmap_crash.patch
index 28e72747c6..90c67edf58 100644
--- a/package/madwifi/patches/419-skb_unmap_crash.patch
+++ b/package/madwifi/patches/419-skb_unmap_crash.patch
@@ -1,6 +1,6 @@
 --- a/ath/if_ath.c
 +++ b/ath/if_ath.c
-@@ -13477,7 +13477,7 @@ cleanup_ath_buf(struct ath_softc *sc, st
+@@ -13493,7 +13493,7 @@ cleanup_ath_buf(struct ath_softc *sc, st
  	if (bf == NULL) 
  		return bf;
  
@@ -9,7 +9,7 @@
  		bus_unmap_single(
  			sc->sc_bdev,
  			bf->bf_skbaddr, 
-@@ -13485,8 +13485,6 @@ cleanup_ath_buf(struct ath_softc *sc, st
+@@ -13501,8 +13501,6 @@ cleanup_ath_buf(struct ath_softc *sc, st
  				sc->sc_rxbufsize : bf->bf_skb->len),
  			direction);
  		bf->bf_skbaddr = 0;
diff --git a/package/madwifi/patches/420-diversity_fix.patch b/package/madwifi/patches/420-diversity_fix.patch
index e12de72ded..bfb4f7620c 100644
--- a/package/madwifi/patches/420-diversity_fix.patch
+++ b/package/madwifi/patches/420-diversity_fix.patch
@@ -18,7 +18,7 @@
  	/*
  	 * Setup the hardware after reset: the key cache
  	 * is filled as needed and the receive engine is
-@@ -3010,7 +3006,6 @@ ath_reset(struct net_device *dev)
+@@ -3018,7 +3014,6 @@ ath_reset(struct net_device *dev)
  	ath_setintmit(sc);
  	ath_update_txpow(sc);		/* update tx power state */
  	ath_radar_update(sc);
@@ -26,7 +26,7 @@
  	if (ath_startrecv(sc) != 0)	/* restart recv */
  		EPRINTF(sc, "Unable to start receive logic.\n");
  	if (sc->sc_softled)
-@@ -5344,27 +5339,6 @@ ath_beacon_send(struct ath_softc *sc, in
+@@ -5352,27 +5347,6 @@ ath_beacon_send(struct ath_softc *sc, in
  	} else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot))
  		ath_setslottime(sc);		/* commit change to hardware */
  
@@ -54,7 +54,7 @@
  	if (bfaddr != 0) {
  		/*
  		 * Stop any current DMA and put the new frame(s) on the queue.
-@@ -6725,9 +6699,8 @@ ath_setdefantenna(struct ath_softc *sc, 
+@@ -6733,9 +6707,8 @@ ath_setdefantenna(struct ath_softc *sc, 
  {
  	struct ath_hal *ah = sc->sc_ah;
  
@@ -65,7 +65,7 @@
  	if (sc->sc_defant != antenna)
  		sc->sc_stats.ast_ant_defswitch++;
  	sc->sc_defant = antenna;
-@@ -11138,7 +11111,7 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
+@@ -11154,7 +11127,7 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
  					break;
  				}
  				sc->sc_diversity = val;
diff --git a/package/madwifi/patches/421-channel_handling.patch b/package/madwifi/patches/421-channel_handling.patch
index 820e09aafb..6531a9ec19 100644
--- a/package/madwifi/patches/421-channel_handling.patch
+++ b/package/madwifi/patches/421-channel_handling.patch
@@ -184,7 +184,7 @@
  #ifdef ATH_SUPERG_XR
  	ic->ic_ath_cap |= (ath_hal_xrsupported(ah) ? IEEE80211_ATHC_XR : 0);
  #endif
-@@ -4461,17 +4477,17 @@ ath_mode_init(struct net_device *dev)
+@@ -4469,17 +4485,17 @@ ath_mode_init(struct net_device *dev)
   * Set the slot time based on the current setting.
   */
  static void
@@ -210,7 +210,7 @@
  	sc->sc_updateslot = OK;
  }
  
-@@ -4493,7 +4509,7 @@ ath_updateslot(struct net_device *dev)
+@@ -4501,7 +4517,7 @@ ath_updateslot(struct net_device *dev)
  	if (ic->ic_opmode == IEEE80211_M_HOSTAP)
  		sc->sc_updateslot = UPDATE;
  	else if (dev->flags & IFF_RUNNING)
@@ -219,7 +219,7 @@
  }
  
  #ifdef ATH_SUPERG_DYNTURBO
-@@ -5337,7 +5353,7 @@ ath_beacon_send(struct ath_softc *sc, in
+@@ -5345,7 +5361,7 @@ ath_beacon_send(struct ath_softc *sc, in
  		sc->sc_updateslot = COMMIT;	/* commit next beacon */
  		sc->sc_slotupdate = slot;
  	} else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot))
@@ -228,7 +228,7 @@
  
  	if (bfaddr != 0) {
  		/*
-@@ -7790,12 +7806,14 @@ ath_get_ivlen(struct ieee80211_key *k)
+@@ -7798,12 +7814,14 @@ ath_get_ivlen(struct ieee80211_key *k)
   * Get transmit rate index using rate in Kbps
   */
  static __inline int
@@ -245,7 +245,7 @@
  			ndx = i;
  			break;
  		}
-@@ -8088,7 +8106,7 @@ ath_tx_start(struct net_device *dev, str
+@@ -8096,7 +8114,7 @@ ath_tx_start(struct net_device *dev, str
  		atype = HAL_PKT_TYPE_NORMAL;		/* default */
  
  		if (ismcast) {
@@ -254,7 +254,7 @@
  			txrate = rt->info[rix].rateCode;
  			if (shortPreamble)
  				txrate |= rt->info[rix].shortPreamble;
-@@ -9055,7 +9073,7 @@ ath_chan_change(struct ath_softc *sc, st
+@@ -9063,7 +9081,7 @@ ath_chan_change(struct ath_softc *sc, st
  	struct net_device *dev = sc->sc_dev;
  	enum ieee80211_phymode mode;
  
@@ -263,7 +263,7 @@
  
  	ath_rate_setup(dev, mode);
  	ath_setcurmode(sc, mode);
-@@ -10104,8 +10122,7 @@ ath_newassoc(struct ieee80211_node *ni, 
+@@ -10120,8 +10138,7 @@ ath_newassoc(struct ieee80211_node *ni, 
  }
  
  static int
@@ -273,7 +273,7 @@
  {
  	struct ath_softc *sc = dev->priv;
  	struct ieee80211com *ic = &sc->sc_ic;
-@@ -10119,17 +10136,31 @@ ath_getchannels(struct net_device *dev, 
+@@ -10135,17 +10152,31 @@ ath_getchannels(struct net_device *dev, 
  		EPRINTF(sc, "Insufficient memory for channel table!\n");
  		return -ENOMEM;
  	}
@@ -307,7 +307,7 @@
  	/*
  	 * Convert HAL channels to ieee80211 ones.
  	 */
-@@ -10373,7 +10404,7 @@ ath_xr_rate_setup(struct net_device *dev
+@@ -10389,7 +10420,7 @@ ath_xr_rate_setup(struct net_device *dev
  	struct ieee80211com *ic = &sc->sc_ic;
  	const HAL_RATE_TABLE *rt;
  	struct ieee80211_rateset *rs;
@@ -316,7 +316,7 @@
  	sc->sc_xr_rates = ath_hal_getratetable(ah, HAL_MODE_XR);
  	rt = sc->sc_xr_rates;
  	if (rt == NULL)
-@@ -10386,57 +10417,16 @@ ath_xr_rate_setup(struct net_device *dev
+@@ -10402,57 +10433,16 @@ ath_xr_rate_setup(struct net_device *dev
  	} else
  		maxrates = rt->rateCount;
  	rs = &ic->ic_sup_xr_rates;
@@ -380,7 +380,7 @@
  static int
  ath_rate_setup(struct net_device *dev, u_int mode)
  {
-@@ -10445,7 +10435,7 @@ ath_rate_setup(struct net_device *dev, u
+@@ -10461,7 +10451,7 @@ ath_rate_setup(struct net_device *dev, u
  	struct ieee80211com *ic = &sc->sc_ic;
  	const HAL_RATE_TABLE *rt;
  	struct ieee80211_rateset *rs;
@@ -389,7 +389,7 @@
  
  	switch (mode) {
  	case IEEE80211_MODE_11A:
-@@ -10463,6 +10453,12 @@ ath_rate_setup(struct net_device *dev, u
+@@ -10479,6 +10469,12 @@ ath_rate_setup(struct net_device *dev, u
  	case IEEE80211_MODE_TURBO_G:
  		sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_108G);
  		break;
@@ -402,7 +402,7 @@
  	default:
  		DPRINTF(sc, ATH_DEBUG_ANY, "Invalid mode %u\n", mode);
  		return 0;
-@@ -10477,10 +10473,16 @@ ath_rate_setup(struct net_device *dev, u
+@@ -10493,10 +10489,16 @@ ath_rate_setup(struct net_device *dev, u
  		maxrates = IEEE80211_RATE_MAXSIZE;
  	} else
  		maxrates = rt->rateCount;
@@ -419,7 +419,7 @@
  	return 1;
  }
  
-@@ -10509,13 +10511,18 @@ ath_setcurmode(struct ath_softc *sc, enu
+@@ -10525,13 +10527,18 @@ ath_setcurmode(struct ath_softc *sc, enu
  		{   0, 500, 130 },
  	};
  	const HAL_RATE_TABLE *rt;
@@ -440,7 +440,7 @@
  	memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
  	for (i = 0; i < 32; i++) {
  		u_int8_t ix = rt->rateCodeToIndex[i];
-@@ -10525,7 +10532,7 @@ ath_setcurmode(struct ath_softc *sc, enu
+@@ -10541,7 +10548,7 @@ ath_setcurmode(struct ath_softc *sc, enu
  			continue;
  		}
  		sc->sc_hwmap[i].ieeerate =
@@ -449,7 +449,7 @@
  		if (rt->info[ix].shortPreamble ||
  		    rt->info[ix].phy == IEEE80211_T_OFDM)
  			sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
-@@ -10926,9 +10933,106 @@ enum {
+@@ -10942,9 +10949,106 @@ enum {
  	ATH_MAXVAPS  		= 26,
  	ATH_INTMIT			= 27,
  	ATH_NOISE_IMMUNITY	= 28,
@@ -557,7 +557,7 @@
  static int
  ath_sysctl_set_intmit(struct ath_softc *sc, long ctl, u_int val)
  {
-@@ -11007,6 +11111,7 @@ static int
+@@ -11023,6 +11127,7 @@ static int
  ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
  {
  	struct ath_softc *sc = ctl->extra1;
@@ -565,7 +565,7 @@
  	struct ath_hal *ah = sc->sc_ah;
  	u_int val;
  	u_int tab_3_val[3];
-@@ -11030,25 +11135,34 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
+@@ -11046,25 +11151,34 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
  				lenp, ppos);
  		if (ret == 0) {
  			switch ((long)ctl->extra2) {
@@ -613,7 +613,7 @@
  				break;
  			case ATH_SOFTLED:
  				if (val != sc->sc_softled) {
-@@ -11201,6 +11315,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
+@@ -11217,6 +11331,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
  		}
  	} else {
  		switch ((long)ctl->extra2) {
@@ -623,7 +623,7 @@
  		case ATH_SLOTTIME:
  			val = ath_hal_getslottime(ah);
  			break;
-@@ -11219,6 +11336,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
+@@ -11235,6 +11352,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
  		case ATH_COUNTRYCODE:
  			ath_hal_getcountrycode(ah, &val);
  			break;
@@ -633,7 +633,7 @@
  		case ATH_MAXVAPS:
  			val = ath_maxvaps;
  			break;
-@@ -11332,11 +11452,17 @@ static const ctl_table ath_sysctl_templa
+@@ -11348,11 +11468,17 @@ static const ctl_table ath_sysctl_templa
  	},
  	{ .ctl_name	= CTL_AUTO,
  	  .procname	= "countrycode",
@@ -652,7 +652,7 @@
  	  .procname	= "maxvaps",
  	  .mode		= 0444,
  	  .proc_handler	= ath_sysctl_halparam,
-@@ -11344,7 +11470,7 @@ static const ctl_table ath_sysctl_templa
+@@ -11360,7 +11486,7 @@ static const ctl_table ath_sysctl_templa
  	},
  	{ .ctl_name	= CTL_AUTO,
  	  .procname	= "regdomain",
@@ -661,7 +661,7 @@
  	  .proc_handler	= ath_sysctl_halparam,
  	  .extra2	= (void *)ATH_REGDOMAIN,
  	},
-@@ -11407,6 +11533,12 @@ static const ctl_table ath_sysctl_templa
+@@ -11423,6 +11549,12 @@ static const ctl_table ath_sysctl_templa
  	  .extra2	= (void *)ATH_ACKRATE,
  	},
  	{ .ctl_name	= CTL_AUTO,
@@ -674,7 +674,7 @@
  	  .procname     = "rp",
  	  .mode         = 0200,
  	  .proc_handler = ath_sysctl_halparam,
-@@ -11647,13 +11779,6 @@ static ctl_table ath_static_sysctls[] = 
+@@ -11663,13 +11795,6 @@ static ctl_table ath_static_sysctls[] = 
  	},
  #endif
  	{ .ctl_name	= CTL_AUTO,
@@ -688,7 +688,7 @@
  	  .procname	= "maxvaps",
  	  .mode		= 0444,
  	  .data		= &ath_maxvaps,
-@@ -11661,13 +11786,6 @@ static ctl_table ath_static_sysctls[] = 
+@@ -11677,13 +11802,6 @@ static ctl_table ath_static_sysctls[] = 
  	  .proc_handler	= proc_dointvec
  	},
  	{ .ctl_name	= CTL_AUTO,
@@ -1284,7 +1284,7 @@
  	for (i = 0; i < ss_last; i++) {
  		chans[i].chan = ss->ss_chans[i];
  		chans[i].orig = i;
-@@ -601,6 +602,7 @@ pick_channel(struct ieee80211_scan_state
+@@ -571,6 +572,7 @@ pick_channel(struct ieee80211_scan_state
  				"%s: best: channel %u rssi %d\n",
  				__func__, i, as->as_maxrssi[i]);
  	}
@@ -1292,7 +1292,7 @@
  	return best;
  }
  
-@@ -636,6 +638,7 @@ ap_end(struct ieee80211_scan_state *ss, 
+@@ -609,6 +611,7 @@ ap_end(struct ieee80211_scan_state *ss, 
  		res = 1; /* Do NOT restart scan */
  	} else {
  		struct ieee80211_scan_entry se;
@@ -1300,7 +1300,7 @@
  		/* XXX: notify all VAPs? */
  		/* if this is a dynamic turbo frequency , start with normal 
  		 * mode first */
-@@ -650,6 +653,11 @@ ap_end(struct ieee80211_scan_state *ss, 
+@@ -623,6 +626,11 @@ ap_end(struct ieee80211_scan_state *ss, 
  				return 0;
  			}
  		}
-- 
cgit v1.2.3