Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 May 2009 00:35:33 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191866 - head/sys/dev/ath
Message-ID:  <200905070035.n470ZX7V034694@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sam
Date: Thu May  7 00:35:32 2009
New Revision: 191866
URL: http://svn.freebsd.org/changeset/base/191866

Log:
  optimize ath_tx_findrix: there's no need to walk the rates table as
  sc_rixmap is an inverse map
  
  NB: could eliminate the check for an invalid rate by filling in 0 for
      invalid entries but the rate control modules use it to identify
      bogus rates so leave it for now

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Wed May  6 23:49:55 2009	(r191865)
+++ head/sys/dev/ath/if_ath.c	Thu May  7 00:35:32 2009	(r191866)
@@ -4222,17 +4222,15 @@ ath_tx_cleanup(struct ath_softc *sc)
 }
 
 /*
- * Return h/w rate index for an IEEE rate (w/o basic rate bit).
+ * Return h/w rate index for an IEEE rate (w/o basic rate bit)
+ * using the current rates in sc_rixmap.
  */
-static int
-ath_tx_findrix(const HAL_RATE_TABLE *rt, int rate)
+static __inline int
+ath_tx_findrix(const struct ath_softc *sc, uint8_t rate)
 {
-	int i;
-
-	for (i = 0; i < rt->rateCount; i++)
-		if ((rt->info[i].dot11Rate & IEEE80211_RATE_VAL) == rate)
-			return i;
-	return 0;		/* NB: lowest rate */
+	int rix = sc->sc_rixmap[rate];
+	/* NB: return lowest rix for invalid rate */
+	return (rix == 0xff ? 0 : rix);
 }
 
 /*
@@ -5760,8 +5758,8 @@ ath_newassoc(struct ieee80211_node *ni, 
 	struct ath_softc *sc = vap->iv_ic->ic_ifp->if_softc;
 	const struct ieee80211_txparam *tp = ni->ni_txparms;
 
-	an->an_mcastrix = ath_tx_findrix(sc->sc_currates, tp->mcastrate);
-	an->an_mgmtrix = ath_tx_findrix(sc->sc_currates, tp->mgmtrate);
+	an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate);
+	an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate);
 
 	ath_rate_newassoc(sc, an, isnew);
 	if (isnew && 
@@ -6009,9 +6007,9 @@ ath_setcurmode(struct ath_softc *sc, enu
 	 * 11g, otherwise at 1Mb/s.
 	 */
 	if (mode == IEEE80211_MODE_11G)
-		sc->sc_protrix = ath_tx_findrix(rt, 2*2);
+		sc->sc_protrix = ath_tx_findrix(sc, 2*2);
 	else
-		sc->sc_protrix = ath_tx_findrix(rt, 2*1);
+		sc->sc_protrix = ath_tx_findrix(sc, 2*1);
 	/* NB: caller is responsible for reseting rate control state */
 #undef N
 }
@@ -6749,7 +6747,7 @@ ath_tx_raw_start(struct ath_softc *sc, s
 
 	rt = sc->sc_currates;
 	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
-	rix = ath_tx_findrix(rt, params->ibp_rate0);
+	rix = ath_tx_findrix(sc, params->ibp_rate0);
 	txrate = rt->info[rix].rateCode;
 	if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
 		txrate |= rt->info[rix].shortPreamble;
@@ -6761,7 +6759,7 @@ ath_tx_raw_start(struct ath_softc *sc, s
 		txantenna = sc->sc_txantenna;
 	ctsduration = 0;
 	if (flags & (HAL_TXDESC_CTSENA | HAL_TXDESC_RTSENA)) {
-		cix = ath_tx_findrix(rt, params->ibp_ctsrate);
+		cix = ath_tx_findrix(sc, params->ibp_ctsrate);
 		ctsrate = rt->info[cix].rateCode;
 		if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) {
 			ctsrate |= rt->info[cix].shortPreamble;
@@ -6827,19 +6825,19 @@ ath_tx_raw_start(struct ath_softc *sc, s
 	bf->bf_txflags = flags;
 
 	if (ismrr) {
-		rix = ath_tx_findrix(rt, params->ibp_rate1);
+		rix = ath_tx_findrix(sc, params->ibp_rate1);
 		rate1 = rt->info[rix].rateCode;
 		if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
 			rate1 |= rt->info[rix].shortPreamble;
 		if (params->ibp_try2) {
-			rix = ath_tx_findrix(rt, params->ibp_rate2);
+			rix = ath_tx_findrix(sc, params->ibp_rate2);
 			rate2 = rt->info[rix].rateCode;
 			if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
 				rate2 |= rt->info[rix].shortPreamble;
 		} else
 			rate2 = 0;
 		if (params->ibp_try3) {
-			rix = ath_tx_findrix(rt, params->ibp_rate3);
+			rix = ath_tx_findrix(sc, params->ibp_rate3);
 			rate3 = rt->info[rix].rateCode;
 			if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
 				rate3 |= rt->info[rix].shortPreamble;
@@ -7063,9 +7061,9 @@ ath_tdma_config(struct ath_softc *sc, st
 	 */
 	tdma = vap->iv_tdma;
 	if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
-		rix = ath_tx_findrix(sc->sc_currates, tp->ucastrate);
+		rix = ath_tx_findrix(sc, tp->ucastrate);
 	else
-		rix = ath_tx_findrix(sc->sc_currates, tp->mcastrate);
+		rix = ath_tx_findrix(sc, tp->mcastrate);
 	/* XXX short preamble assumed */
 	sc->sc_tdmaguard = ath_hal_computetxtime(ah, sc->sc_currates,
 		ifp->if_mtu + IEEE80211_MAXOVERHEAD, rix, AH_TRUE);



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