Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Aug 2011 05:27:35 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225226 - user/adrian/if_ath_tx/sys/dev/ath
Message-ID:  <201108280527.p7S5RZZM036028@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Aug 28 05:27:34 2011
New Revision: 225226
URL: http://svn.freebsd.org/changeset/base/225226

Log:
  Shift over to using the software txq drain code from the reference
  driver.
  
  This avoids calling ieee80211_iterate_nodes() to flush the nodes for
  a given softc.

Modified:
  user/adrian/if_ath_tx/sys/dev/ath/if_ath.c
  user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c
  user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h

Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c
==============================================================================
--- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c	Sun Aug 28 04:17:56 2011	(r225225)
+++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c	Sun Aug 28 05:27:34 2011	(r225226)
@@ -202,7 +202,6 @@ static void	ath_setcurmode(struct ath_so
 static void	ath_announce(struct ath_softc *);
 
 static void	ath_dfs_tasklet(void *, int);
-static void	ath_sc_flushtxq(struct ath_softc *sc);
 
 #ifdef IEEE80211_SUPPORT_TDMA
 static void	ath_tdma_settimers(struct ath_softc *sc, u_int32_t nexttbtt,
@@ -1148,7 +1147,6 @@ ath_vap_delete(struct ieee80211vap *vap)
 		ath_hal_intrset(ah, 0);		/* disable interrupts */
 		ath_draintxq(sc);		/* stop hw xmit side */
 		/* XXX Do all frames from all vaps/nodes need draining here? */
-		ath_sc_flushtxq(sc);		/* drain sw xmit side */
 		ath_stoprecv(sc);		/* stop recv side */
 	}
 
@@ -1172,8 +1170,6 @@ ath_vap_delete(struct ieee80211vap *vap)
 	 */
 
 	ath_draintxq(sc);
-	/* XXX Do all frames from all vaps/nodes need draining here? */
-	ath_sc_flushtxq(sc);
 
 	ATH_LOCK(sc);
 	/*
@@ -1756,11 +1752,6 @@ ath_stop_locked(struct ifnet *ifp)
 			ath_hal_intrset(ah, 0);
 		}
 		ath_draintxq(sc);
-		/*
-		 * XXX Draining these packets may create a hole in the
-		 * XXX BAW.
-		 */
-		ath_sc_flushtxq(sc);		/* drain sw xmit side */
 		if (!sc->sc_invalid) {
 			ath_stoprecv(sc);
 			ath_hal_phydisable(ah);
@@ -1799,19 +1790,6 @@ ath_reset(struct ifnet *ifp)
 
 	ath_hal_intrset(ah, 0);		/* disable interrupts */
 	ath_draintxq(sc);		/* stop xmit side */
-	/*
-	 * XXX as long as ath_reset() isn't called during a state
-	 * transition (eg channel change, mode change, etc)
-	 * then there's no need to flush the software TXQ.
-	 * Doing this here messes with the BAW tracking, as
-	 * there may be aggregate packets in the software TXQ
-	 * which haven't been queued to the hardware, and thus
-	 * the BAW hasn't been set. Freeing those packets will
-	 * create a "hole" in the BAW.
-	 */
-#if 0
-	ath_sc_flushtxq(sc);		/* drain sw xmit side */
-#endif
 	ath_stoprecv(sc);		/* stop recv side */
 	ath_settkipmic(sc);		/* configure TKIP MIC handling */
 	/* NB: indicate channel change so we do a full reset */
@@ -4677,6 +4655,12 @@ ath_tx_draintxq(struct ath_softc *sc, st
 		else
 			ath_tx_default_comp(sc, bf, 1);
 	}
+
+	/*
+	 * Drain software queued frames which are on
+	 * active TIDs.
+	 */
+	ath_tx_txq_drain(sc, txq);
 	ATH_TXQ_UNLOCK(txq);
 }
 
@@ -4849,18 +4833,6 @@ ath_chan_set(struct ath_softc *sc, struc
 		 */
 		ath_hal_intrset(ah, 0);		/* disable interrupts */
 		ath_draintxq(sc);		/* clear pending tx frames */
-		/*
-		 * XXX This may create holes in the BAW, since some
-		 * XXX aggregate packets may have not yet been scheduled
-		 * XXX to the hardware, and thus ath_tx_addto_baw() has
-		 * XXX never been called.
-		 *
-		 * But we can't _not_ call this here, because the current
-		 * TX code doesn't handle the potential rate/flags change
-		 * (eg a 40->20mhz change, or HT->non-HT change, or 11a<->g
-		 * change, etc.)
-		 */
-		ath_sc_flushtxq(sc);		/* drain sw xmit side */
 		ath_stoprecv(sc);		/* turn off frame recv */
 		if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, &status)) {
 			if_printf(ifp, "%s: unable to reset "
@@ -6184,40 +6156,5 @@ ath_dfs_tasklet(void *p, int npending)
 	}
 }
 
-/*
- * Flush all software queued packets for the given VAP.
- *
- * The ieee80211 common lock should be held.
- */
-static void
-ath_vap_flush_node(void *arg, struct ieee80211_node *ni)
-{
-	struct ath_softc *sc = (struct ath_softc *) arg;
-
-	ath_tx_node_flush(sc, ATH_NODE(ni));
-}
-
-/*
- * Flush all software queued packets for the given sc.
- *
- * The ieee80211 common lock should be held.
- */
-static void
-ath_sc_flushtxq(struct ath_softc *sc)
-{
-	struct ieee80211com *ic = sc->sc_ifp->if_l2com;
-
-#if 0
-	//IEEE80211_LOCK_ASSERT(ic);
-	/* Debug if we don't own the lock! */
-	if (! mtx_owned(IEEE80211_LOCK_OBJ(ic))) {
-		device_printf(sc->sc_dev, "%s: comlock not owned?\n",
-		    __func__);
-	}
-#endif
-
-	ieee80211_iterate_nodes(&ic->ic_sta, ath_vap_flush_node, sc);
-}
-
 MODULE_VERSION(if_ath, 1);
 MODULE_DEPEND(if_ath, wlan, 1, 1, 1);          /* 802.11 media layer */

Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c
==============================================================================
--- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c	Sun Aug 28 04:17:56 2011	(r225225)
+++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c	Sun Aug 28 05:27:34 2011	(r225226)
@@ -2186,6 +2186,28 @@ ath_tx_node_flush(struct ath_softc *sc, 
 }
 
 /*
+ * Drain all the software TXQs currently with traffic queued.
+ */
+void
+ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq)
+{
+	struct ath_tid *tid;
+
+	ATH_TXQ_LOCK_ASSERT(txq);
+
+	/*
+	 * Iterate over all active tids for the given txq,
+	 * flushing and unsched'ing them
+	 */
+	while (! TAILQ_EMPTY(&txq->axq_tidq)) {
+		tid = TAILQ_FIRST(&txq->axq_tidq);
+		ath_tx_tid_drain(sc, tid->an, tid);
+		ath_tx_tid_unsched(sc, tid->an, tid->tid);
+	}
+
+}
+
+/*
  * Free the per-TID node state.
  *
  * This frees any packets currently in the software queue and frees

Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h
==============================================================================
--- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h	Sun Aug 28 04:17:56 2011	(r225225)
+++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h	Sun Aug 28 05:27:34 2011	(r225226)
@@ -81,6 +81,7 @@
 
 extern void ath_freetx(struct mbuf *m);
 extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
+extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
 extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags,
     struct ieee80211_node *ni);
 extern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108280527.p7S5RZZM036028>