Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 May 2012 16:52:00 +0000 (UTC)
From:      Bernhard Schmidt <bschmidt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r236010 - stable/8/sys/dev/ral
Message-ID:  <201205251652.q4PGq0AW021987@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bschmidt
Date: Fri May 25 16:52:00 2012
New Revision: 236010
URL: http://svn.freebsd.org/changeset/base/236010

Log:
  MFC r220502:
  Don't hardcode assumptions about basic rates, similar to what the rt2661
  support code does. While here remove an unnecessary loop.

Modified:
  stable/8/sys/dev/ral/rt2560.c
  stable/8/sys/dev/ral/rt2661.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/dev/ral/rt2560.c
==============================================================================
--- stable/8/sys/dev/ral/rt2560.c	Fri May 25 16:45:56 2012	(r236009)
+++ stable/8/sys/dev/ral/rt2560.c	Fri May 25 16:52:00 2012	(r236010)
@@ -144,7 +144,8 @@ static void		rt2560_enable_tsf_sync(stru
 static void		rt2560_enable_tsf(struct rt2560_softc *);
 static void		rt2560_update_plcp(struct rt2560_softc *);
 static void		rt2560_update_slot(struct ifnet *);
-static void		rt2560_set_basicrates(struct rt2560_softc *);
+static void		rt2560_set_basicrates(struct rt2560_softc *,
+			    const struct ieee80211_rateset *);
 static void		rt2560_update_led(struct rt2560_softc *, int, int);
 static void		rt2560_set_bssid(struct rt2560_softc *, const uint8_t *);
 static void		rt2560_set_macaddr(struct rt2560_softc *, uint8_t *);
@@ -779,7 +780,7 @@ rt2560_newstate(struct ieee80211vap *vap
 
 		if (vap->iv_opmode != IEEE80211_M_MONITOR) {
 			rt2560_update_plcp(sc);
-			rt2560_set_basicrates(sc);
+			rt2560_set_basicrates(sc, &ni->ni_rates);
 			rt2560_set_bssid(sc, ni->ni_bssid);
 		}
 
@@ -2353,22 +2354,29 @@ rt2560_update_slot(struct ifnet *ifp)
 }
 
 static void
-rt2560_set_basicrates(struct rt2560_softc *sc)
+rt2560_set_basicrates(struct rt2560_softc *sc,
+    const struct ieee80211_rateset *rs)
 {
+#define RV(r)	((r) & IEEE80211_RATE_VAL)
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
+	uint32_t mask = 0;
+	uint8_t rate;
+	int i;
 
-	/* update basic rate set */
-	if (ic->ic_curmode == IEEE80211_MODE_11B) {
-		/* 11b basic rates: 1, 2Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x3);
-	} else if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) {
-		/* 11a basic rates: 6, 12, 24Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x150);
-	} else {
-		/* 11g basic rates: 1, 2, 5.5, 11, 6, 12, 24Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x15f);
+	for (i = 0; i < rs->rs_nrates; i++) {
+		rate = rs->rs_rates[i];
+
+		if (!(rate & IEEE80211_RATE_BASIC))
+			continue;
+
+		mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
 	}
+
+	RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask);
+
+	DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
+#undef RV
 }
 
 static void

Modified: stable/8/sys/dev/ral/rt2661.c
==============================================================================
--- stable/8/sys/dev/ral/rt2661.c	Fri May 25 16:45:56 2012	(r236009)
+++ stable/8/sys/dev/ral/rt2661.c	Fri May 25 16:52:00 2012	(r236010)
@@ -1915,7 +1915,7 @@ rt2661_set_basicrates(struct rt2661_soft
 	struct ieee80211com *ic = ifp->if_l2com;
 	uint32_t mask = 0;
 	uint8_t rate;
-	int i, j;
+	int i;
 
 	for (i = 0; i < rs->rs_nrates; i++) {
 		rate = rs->rs_rates[i];
@@ -1923,13 +1923,7 @@ rt2661_set_basicrates(struct rt2661_soft
 		if (!(rate & IEEE80211_RATE_BASIC))
 			continue;
 
-		/*
-		 * Find h/w rate index.  We know it exists because the rate
-		 * set has already been negotiated.
-		 */
-		for (j = 0; ic->ic_sup_rates[IEEE80211_MODE_11G].rs_rates[j] != RV(rate); j++);
-
-		mask |= 1 << j;
+		mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
 	}
 
 	RAL_WRITE(sc, RT2661_TXRX_CSR5, mask);



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