summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbschmidt <bschmidt@FreeBSD.org>2011-04-09 14:45:50 +0000
committerbschmidt <bschmidt@FreeBSD.org>2011-04-09 14:45:50 +0000
commit153b81554cb794fe75370f094f6cd8c6c52fa7d2 (patch)
tree973b55cef9d863e2c37af2e803d986eda07e9065 /sys
parent7c133a7cf35fb94b265126882dca7bea40c91bee (diff)
downloadFreeBSD-src-153b81554cb794fe75370f094f6cd8c6c52fa7d2.zip
FreeBSD-src-153b81554cb794fe75370f094f6cd8c6c52fa7d2.tar.gz
Don't hardcode assumptions about basic rates, similar to what the rt2661
support code does. While here remove an unnecessary loop.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ral/rt2560.c34
-rw-r--r--sys/dev/ral/rt2661.c10
2 files changed, 23 insertions, 21 deletions
diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c
index f3c8c3f..6064707 100644
--- a/sys/dev/ral/rt2560.c
+++ b/sys/dev/ral/rt2560.c
@@ -144,7 +144,8 @@ static void rt2560_enable_tsf_sync(struct rt2560_softc *);
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, enum ieee80211_state nstate, int arg)
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
diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c
index 2d51dc2..372fcff 100644
--- a/sys/dev/ral/rt2661.c
+++ b/sys/dev/ral/rt2661.c
@@ -1915,7 +1915,7 @@ rt2661_set_basicrates(struct rt2661_softc *sc,
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_softc *sc,
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);
OpenPOWER on IntegriCloud