From 90e92ad904075cc51dccf6f4099620b88f4dcb5c Mon Sep 17 00:00:00 2001 From: mentor Date: Sat, 29 Dec 2007 17:21:10 +0000 Subject: [PATCH] Revert r3905 git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3098 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath/if_ath.c | 61 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/ath/if_ath.c b/ath/if_ath.c index 13222d4..8217929 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -4585,6 +4585,8 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar static void ath_beacon_send(struct ath_softc *sc, int *needmark) { +#define TSF_TO_TU(_h,_l) \ + ((((u_int32_t)(_h)) << 22) | (((u_int32_t)(_l)) >> 10)) struct ath_hal *ah = sc->sc_ah; struct ieee80211vap *vap; struct ath_buf *bf; @@ -4628,16 +4630,17 @@ ath_beacon_send(struct ath_softc *sc, int *needmark) */ if (sc->sc_stagbeacons) { /* staggered beacons */ struct ieee80211com *ic = &sc->sc_ic; - u_int64_t tsf, tsftu; + u_int64_t tsf; + u_int32_t tsftu; tsf = ath_hal_gettsf64(ah); - tsftu = tsf >> 10; + tsftu = TSF_TO_TU(tsf >> 32, tsf); slot = ((tsftu % ic->ic_lintval) * ATH_BCBUF) / ic->ic_lintval; vap = sc->sc_bslot[(slot + 1) % ATH_BCBUF]; DPRINTF(sc, ATH_DEBUG_BEACON_PROC, - "%s: slot %d [tsf %llu tsftu %llu intval %u] vap %p\n", - __func__, slot, (unsigned long long)tsf, - (unsigned long long)tsftu, ic->ic_lintval, vap); + "%s: slot %d [tsf %llu tsftu %u intval %u] vap %p\n", + __func__, slot, (unsigned long long) tsf, tsftu, + ic->ic_lintval, vap); bfaddr = 0; if (vap != NULL) { bf = ath_beacon_generate(sc, vap, needmark); @@ -4742,6 +4745,7 @@ ath_beacon_send(struct ath_softc *sc, int *needmark) sc->sc_stats.ast_be_xmit++; /* XXX per-VAP? */ } +#undef TSF_TO_TU } /* @@ -4860,12 +4864,15 @@ ath_beacon_free(struct ath_softc *sc) static void ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) { +#define TSF_TO_TU(_h,_l) \ + ((((u_int32_t)(_h)) << 22) | (((u_int32_t)(_l)) >> 10)) struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_node *ni; - u_int64_t intval, nexttbtt = 0; + u_int32_t nexttbtt = 0; + u_int32_t intval; u_int64_t tsf, hw_tsf; - u_int64_t tsftu, hw_tsftu; + u_int32_t tsftu, hw_tsftu; int reset_tsf = 0; if (vap == NULL) @@ -4919,7 +4926,11 @@ ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) * ensure that it is at least FUDGE ms ahead * of the current TSF. Otherwise, we use the * next beacon timestamp again */ - nexttbtt = roundup(hw_tsftu + FUDGE, intval); + + nexttbtt = roundup(hw_tsftu +1, intval); + while (nexttbtt <= hw_tsftu + FUDGE) { + nexttbtt += intval; + } } else { if (tsf > hw_tsf) { /* We received a beacon, but the HW TSF has @@ -4932,8 +4943,10 @@ ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) /* Normal case: we received a beacon to which * we have synchronized. Make sure that nexttbtt * is at least FUDGE ms ahead of hw_tsf */ - nexttbtt = tsftu + roundup(hw_tsftu + FUDGE - - tsftu, intval); + nexttbtt = tsftu + intval; + while (nexttbtt <= hw_tsftu + FUDGE) { + nexttbtt += intval; + } } } } @@ -5018,12 +5031,11 @@ ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) bs.bs_dtimperiod); DPRINTF(sc, ATH_DEBUG_BEACON, - "%s: tsf %llu tsf:tu %llu intval %u nexttbtt %u " - "dtim %u nextdtim %u bmiss %u sleep %u cfp:period %u " + "%s: tsf %llu tsf:tu %u intval %u nexttbtt %u dtim %u " + "nextdtim %u bmiss %u sleep %u cfp:period %u " "maxdur %u next %u timoffset %u\n", __func__, - (unsigned long long)tsf, - (unsigned long long)tsftu, + (unsigned long long) tsf, tsftu, bs.bs_intval, bs.bs_nexttbtt, bs.bs_dtimperiod, @@ -5067,14 +5079,14 @@ ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) ath_hal_intrset(ah, sc->sc_imask); } sc->sc_syncbeacon = 0; +#undef TSF_TO_TU ath_beacon_config_debug: /* We print all debug messages here, in order to preserve the * time critical aspect of this function */ DPRINTF(sc, ATH_DEBUG_BEACON, - "%s: ni=%p tsf=%llu hw_tsf=%llu tsftu=%llu hw_tsftu=%llu\n", - __func__, ni, tsf, hw_tsf, - (unsigned long long)tsftu, (unsigned long long)hw_tsftu); + "%s: ni=%p tsf=%llu hw_tsf=%llu tsftu=%u hw_tsftu=%u\n", + __func__, ni, tsf, hw_tsf, tsftu, hw_tsftu); if (reset_tsf) { /* We just created the interface */ @@ -5101,10 +5113,8 @@ ath_beacon_config_debug: } } - DPRINTF(sc, ATH_DEBUG_BEACON, - "%s: nexttbtt=%10llx intval=%llu%s%s imask=%s%s\n", __func__, - (unsigned long long)nexttbtt, - (unsigned long long)intval & HAL_BEACON_PERIOD, + DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt=%10x intval=%u%s%s imask=%s%s\n", + __func__, nexttbtt, intval & HAL_BEACON_PERIOD, intval & HAL_BEACON_ENA ? " HAL_BEACON_ENA" : "", intval & HAL_BEACON_RESET_TSF ? " HAL_BEACON_RESET_TSF" : "", sc->sc_imask & HAL_INT_BMISS ? " HAL_INT_BMISS" : "", @@ -5929,7 +5939,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb, struct ath_softc *sc = ni->ni_ic->ic_dev->priv; struct ieee80211vap *vap = ni->ni_vap; u_int64_t hw_tsf, beacon_tsf; - u_int64_t hw_tu; + u_int32_t hw_tu; DPRINTF(sc, ATH_DEBUG_BEACON, "%s: vap:%p[" MAC_FMT "] ni:%p[" MAC_FMT "]\n", @@ -5962,6 +5972,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb, case IEEE80211_FC0_SUBTYPE_PROBE_RESP: if (vap->iv_opmode == IEEE80211_M_IBSS && vap->iv_state == IEEE80211_S_RUN) { + /* Don't merge if we have a desired BSSID */ if (vap->iv_flags & IEEE80211_F_DESBSSID) break; @@ -5974,6 +5985,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb, * reconfiguration happens through callback to * ath_newstate as the state machine will go from * RUN -> RUN when this happens. */ + hw_tsf = ath_hal_gettsf64(sc->sc_ah); hw_tu = hw_tsf >> 10; beacon_tsf = le64_to_cpu(ni->ni_tstamp.tsf); @@ -5998,9 +6010,8 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb, if (sc->sc_nexttbtt < hw_tu) { DPRINTF(sc, ATH_DEBUG_BEACON, "sc_nexttbtt (%8x TU) is in the past " - "(tsf %8llx TU), updating timers\n", - sc->sc_nexttbtt, - (unsigned long long)hw_tu); + "(tsf %8x TU), updating timers\n", + sc->sc_nexttbtt, hw_tu); ath_beacon_update_timers(sc, vap); } } -- 2.35.1