Revert r3905

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3098 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
mentor 2007-12-29 17:21:10 +00:00
parent fd43343eb6
commit 90e92ad904

View File

@ -4585,6 +4585,8 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar
static void static void
ath_beacon_send(struct ath_softc *sc, int *needmark) 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 ath_hal *ah = sc->sc_ah;
struct ieee80211vap *vap; struct ieee80211vap *vap;
struct ath_buf *bf; struct ath_buf *bf;
@ -4628,16 +4630,17 @@ ath_beacon_send(struct ath_softc *sc, int *needmark)
*/ */
if (sc->sc_stagbeacons) { /* staggered beacons */ if (sc->sc_stagbeacons) { /* staggered beacons */
struct ieee80211com *ic = &sc->sc_ic; struct ieee80211com *ic = &sc->sc_ic;
u_int64_t tsf, tsftu; u_int64_t tsf;
u_int32_t tsftu;
tsf = ath_hal_gettsf64(ah); 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; slot = ((tsftu % ic->ic_lintval) * ATH_BCBUF) / ic->ic_lintval;
vap = sc->sc_bslot[(slot + 1) % ATH_BCBUF]; vap = sc->sc_bslot[(slot + 1) % ATH_BCBUF];
DPRINTF(sc, ATH_DEBUG_BEACON_PROC, DPRINTF(sc, ATH_DEBUG_BEACON_PROC,
"%s: slot %d [tsf %llu tsftu %llu intval %u] vap %p\n", "%s: slot %d [tsf %llu tsftu %u intval %u] vap %p\n",
__func__, slot, (unsigned long long)tsf, __func__, slot, (unsigned long long) tsf, tsftu,
(unsigned long long)tsftu, ic->ic_lintval, vap); ic->ic_lintval, vap);
bfaddr = 0; bfaddr = 0;
if (vap != NULL) { if (vap != NULL) {
bf = ath_beacon_generate(sc, vap, needmark); 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? */ 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 static void
ath_beacon_update_timers(struct ath_softc *sc, struct ieee80211vap *vap) 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 ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah; struct ath_hal *ah = sc->sc_ah;
struct ieee80211_node *ni; 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 tsf, hw_tsf;
u_int64_t tsftu, hw_tsftu; u_int32_t tsftu, hw_tsftu;
int reset_tsf = 0; int reset_tsf = 0;
if (vap == NULL) 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 * ensure that it is at least FUDGE ms ahead
* of the current TSF. Otherwise, we use the * of the current TSF. Otherwise, we use the
* next beacon timestamp again */ * next beacon timestamp again */
nexttbtt = roundup(hw_tsftu + FUDGE, intval);
nexttbtt = roundup(hw_tsftu +1, intval);
while (nexttbtt <= hw_tsftu + FUDGE) {
nexttbtt += intval;
}
} else { } else {
if (tsf > hw_tsf) { if (tsf > hw_tsf) {
/* We received a beacon, but the HW TSF has /* 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 /* Normal case: we received a beacon to which
* we have synchronized. Make sure that nexttbtt * we have synchronized. Make sure that nexttbtt
* is at least FUDGE ms ahead of hw_tsf */ * is at least FUDGE ms ahead of hw_tsf */
nexttbtt = tsftu + roundup(hw_tsftu + FUDGE - nexttbtt = tsftu + intval;
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); bs.bs_dtimperiod);
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: tsf %llu tsf:tu %llu intval %u nexttbtt %u " "%s: tsf %llu tsf:tu %u intval %u nexttbtt %u dtim %u "
"dtim %u nextdtim %u bmiss %u sleep %u cfp:period %u " "nextdtim %u bmiss %u sleep %u cfp:period %u "
"maxdur %u next %u timoffset %u\n", "maxdur %u next %u timoffset %u\n",
__func__, __func__,
(unsigned long long)tsf, (unsigned long long) tsf, tsftu,
(unsigned long long)tsftu,
bs.bs_intval, bs.bs_intval,
bs.bs_nexttbtt, bs.bs_nexttbtt,
bs.bs_dtimperiod, 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); ath_hal_intrset(ah, sc->sc_imask);
} }
sc->sc_syncbeacon = 0; sc->sc_syncbeacon = 0;
#undef TSF_TO_TU
ath_beacon_config_debug: ath_beacon_config_debug:
/* We print all debug messages here, in order to preserve the /* We print all debug messages here, in order to preserve the
* time critical aspect of this function */ * time critical aspect of this function */
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: ni=%p tsf=%llu hw_tsf=%llu tsftu=%llu hw_tsftu=%llu\n", "%s: ni=%p tsf=%llu hw_tsf=%llu tsftu=%u hw_tsftu=%u\n",
__func__, ni, tsf, hw_tsf, __func__, ni, tsf, hw_tsf, tsftu, hw_tsftu);
(unsigned long long)tsftu, (unsigned long long)hw_tsftu);
if (reset_tsf) { if (reset_tsf) {
/* We just created the interface */ /* We just created the interface */
@ -5101,10 +5113,8 @@ ath_beacon_config_debug:
} }
} }
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt=%10x intval=%u%s%s imask=%s%s\n",
"%s: nexttbtt=%10llx intval=%llu%s%s imask=%s%s\n", __func__, __func__, nexttbtt, intval & HAL_BEACON_PERIOD,
(unsigned long long)nexttbtt,
(unsigned long long)intval & HAL_BEACON_PERIOD,
intval & HAL_BEACON_ENA ? " HAL_BEACON_ENA" : "", intval & HAL_BEACON_ENA ? " HAL_BEACON_ENA" : "",
intval & HAL_BEACON_RESET_TSF ? " HAL_BEACON_RESET_TSF" : "", intval & HAL_BEACON_RESET_TSF ? " HAL_BEACON_RESET_TSF" : "",
sc->sc_imask & HAL_INT_BMISS ? " HAL_INT_BMISS" : "", 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 ath_softc *sc = ni->ni_ic->ic_dev->priv;
struct ieee80211vap *vap = ni->ni_vap; struct ieee80211vap *vap = ni->ni_vap;
u_int64_t hw_tsf, beacon_tsf; u_int64_t hw_tsf, beacon_tsf;
u_int64_t hw_tu; u_int32_t hw_tu;
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: vap:%p[" MAC_FMT "] ni:%p[" MAC_FMT "]\n", "%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: case IEEE80211_FC0_SUBTYPE_PROBE_RESP:
if (vap->iv_opmode == IEEE80211_M_IBSS && if (vap->iv_opmode == IEEE80211_M_IBSS &&
vap->iv_state == IEEE80211_S_RUN) { vap->iv_state == IEEE80211_S_RUN) {
/* Don't merge if we have a desired BSSID */ /* Don't merge if we have a desired BSSID */
if (vap->iv_flags & IEEE80211_F_DESBSSID) if (vap->iv_flags & IEEE80211_F_DESBSSID)
break; break;
@ -5974,6 +5985,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb,
* reconfiguration happens through callback to * reconfiguration happens through callback to
* ath_newstate as the state machine will go from * ath_newstate as the state machine will go from
* RUN -> RUN when this happens. */ * RUN -> RUN when this happens. */
hw_tsf = ath_hal_gettsf64(sc->sc_ah); hw_tsf = ath_hal_gettsf64(sc->sc_ah);
hw_tu = hw_tsf >> 10; hw_tu = hw_tsf >> 10;
beacon_tsf = le64_to_cpu(ni->ni_tstamp.tsf); 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) { if (sc->sc_nexttbtt < hw_tu) {
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"sc_nexttbtt (%8x TU) is in the past " "sc_nexttbtt (%8x TU) is in the past "
"(tsf %8llx TU), updating timers\n", "(tsf %8x TU), updating timers\n",
sc->sc_nexttbtt, sc->sc_nexttbtt, hw_tu);
(unsigned long long)hw_tu);
ath_beacon_update_timers(sc, vap); ath_beacon_update_timers(sc, vap);
} }
} }