diff options
| author | Sam Leffler <sam@FreeBSD.org> | 2004-12-31 20:20:02 +0000 |
|---|---|---|
| committer | Sam Leffler <sam@FreeBSD.org> | 2004-12-31 20:20:02 +0000 |
| commit | a6c992f43cacdbcb3946b692c31c2fb6c82ac067 (patch) | |
| tree | 3179842da57fee1e67c2be5d310ae45536d8bed4 /sys/dev/ath | |
| parent | 0eb68df4c5f7dc2f0ce504b6b4b0c57dce5bb8b6 (diff) | |
Notes
Diffstat (limited to 'sys/dev/ath')
| -rw-r--r-- | sys/dev/ath/if_ath.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index d21808c441ad..237fc47e9b4e 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 |
