summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2004-12-31 20:20:02 +0000
committersam <sam@FreeBSD.org>2004-12-31 20:20:02 +0000
commit498543a7bd20888a494899a50449a15925d2ceab (patch)
tree3179842da57fee1e67c2be5d310ae45536d8bed4
parent4f85af0286f0bda0a03d84a8450f78961cb109a7 (diff)
downloadFreeBSD-src-498543a7bd20888a494899a50449a15925d2ceab.zip
FreeBSD-src-498543a7bd20888a494899a50449a15925d2ceab.tar.gz
Correct beacon timer setup logic:
o lintval is in ms; must convert to TU's for passing to the hal o roundup to calculate nexttbtt (should look at current tsf and pull the calculated nextbtt forward but this'll do for now) o don't or- in HAL_BEACON_RESET_TSF when doing station timer setup; this is not needed and messes up the sleep timer calcs, though it's unclear if it mattered as the hal masks these values before use Submitted by: Thorsten von Eicken
-rw-r--r--sys/dev/ath/if_ath.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index d21808c..237fc47 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -1973,6 +1973,7 @@ ath_beacon_free(struct ath_softc *sc)
static void
ath_beacon_config(struct ath_softc *sc)
{
+#define MS_TO_TU(x) (((x) * 1000) / 1024)
struct ath_hal *ah = sc->sc_ah;
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211_node *ni = ic->ic_bss;
@@ -1980,22 +1981,20 @@ ath_beacon_config(struct ath_softc *sc)
nexttbtt = (LE_READ_4(ni->ni_tstamp.data + 4) << 22) |
(LE_READ_4(ni->ni_tstamp.data) >> 10);
- DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt %u intval %u\n",
- __func__, nexttbtt, ni->ni_intval);
- nexttbtt += ni->ni_intval;
- intval = ni->ni_intval & HAL_BEACON_PERIOD;
+ intval = MS_TO_TU(ni->ni_intval) & HAL_BEACON_PERIOD;
+ if (nexttbtt == 0) /* e.g. for ap mode */
+ nexttbtt = intval;
+ else if (intval) /* NB: can be 0 for monitor mode */
+ nexttbtt = roundup(nexttbtt, intval);
+ DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt %u intval %u (%u)\n",
+ __func__, nexttbtt, intval, ni->ni_intval);
if (ic->ic_opmode == IEEE80211_M_STA) {
HAL_BEACON_STATE bs;
u_int32_t bmisstime;
/* NB: no PCF support right now */
memset(&bs, 0, sizeof(bs));
- /*
- * Reset our tsf so the hardware will update the
- * tsf register to reflect timestamps found in
- * received beacons.
- */
- bs.bs_intval = intval | HAL_BEACON_RESET_TSF;
+ bs.bs_intval = intval;
bs.bs_nexttbtt = nexttbtt;
bs.bs_dtimperiod = bs.bs_intval;
bs.bs_nextdtim = nexttbtt;
@@ -2014,8 +2013,8 @@ ath_beacon_config(struct ath_softc *sc)
* TU's and then calculate based on the beacon interval.
* Note that we clamp the result to at most 10 beacons.
*/
- bmisstime = (ic->ic_bmisstimeout * 1000) / 1024;
- bs.bs_bmissthreshold = howmany(bmisstime,ni->ni_intval);
+ bmisstime = MS_TO_TU(ic->ic_bmisstimeout);
+ bs.bs_bmissthreshold = howmany(bmisstime, intval);
if (bs.bs_bmissthreshold > 10)
bs.bs_bmissthreshold = 10;
else if (bs.bs_bmissthreshold <= 0)
@@ -2030,8 +2029,7 @@ ath_beacon_config(struct ath_softc *sc)
*
* XXX fixed at 100ms
*/
- bs.bs_sleepduration =
- roundup((100 * 1000) / 1024, bs.bs_intval);
+ bs.bs_sleepduration = roundup(MS_TO_TU(100), bs.bs_intval);
if (bs.bs_sleepduration > bs.bs_dtimperiod)
bs.bs_sleepduration = roundup(bs.bs_sleepduration, bs.bs_dtimperiod);
@@ -2055,7 +2053,7 @@ ath_beacon_config(struct ath_softc *sc)
ath_hal_intrset(ah, sc->sc_imask);
} else {
ath_hal_intrset(ah, 0);
- if (nexttbtt == ni->ni_intval)
+ if (nexttbtt == intval)
intval |= HAL_BEACON_RESET_TSF;
if (ic->ic_opmode == IEEE80211_M_IBSS) {
/*
@@ -2086,6 +2084,7 @@ ath_beacon_config(struct ath_softc *sc)
if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol)
ath_beacon_proc(sc, 0);
}
+#undef MS_TO_TU
}
static void
OpenPOWER on IntegriCloud