From owner-svn-src-stable@FreeBSD.ORG Fri May 25 16:52:01 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B38C1065686; Fri, 25 May 2012 16:52:01 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05AEA8FC0C; Fri, 25 May 2012 16:52:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4PGq0sk021990; Fri, 25 May 2012 16:52:00 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4PGq0AW021987; Fri, 25 May 2012 16:52:00 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201205251652.q4PGq0AW021987@svn.freebsd.org> From: Bernhard Schmidt Date: Fri, 25 May 2012 16:52:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236010 - stable/8/sys/dev/ral X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2012 16:52:01 -0000 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);