Merge time conversion macros, users of IEEE80211_TU_TO_TSF from madwifi-dfs

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4054 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
proski 2009-06-25 01:03:32 +00:00
parent 892214198a
commit 489d0d146d
2 changed files with 15 additions and 6 deletions

View File

@ -2412,16 +2412,19 @@ ath_intr(int irq, void *dev_id, struct pt_regs *regs)
} else { } else {
if (status & HAL_INT_SWBA) { if (status & HAL_INT_SWBA) {
struct ieee80211vap *vap; struct ieee80211vap *vap;
u_int32_t hw_tsftu = IEEE80211_TSF_TO_TU(hw_tsf);
/* Updates sc_nexttbtt */ /* Updates sc_nexttbtt */
vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps); vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps);
sc->sc_nexttbtt += vap->iv_bss->ni_intval; sc->sc_nexttbtt += vap->iv_bss->ni_intval;
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"ath_intr HAL_INT_SWBA at " "HAL_INT_SWBA at "
"tsf %10llx nexttbtt %10llx\n", "hw_tsf=%10llx nexttbtt_tsf=%10llx "
"hwtsf_tu=%6u nexttbtt=%6u\n",
(unsigned long long)hw_tsf, (unsigned long long)hw_tsf,
(unsigned long long)sc->sc_nexttbtt << 10); (unsigned long long)IEEE80211_TU_TO_TSF(sc->sc_nexttbtt),
hw_tsftu, sc->sc_nexttbtt);
/* Software beacon alert--time to send a beacon. /* Software beacon alert--time to send a beacon.
* Handle beacon transmission directly; deferring * Handle beacon transmission directly; deferring
@ -4867,7 +4870,7 @@ ath_beacon_alloc_internal(struct ath_softc *sc, struct ieee80211_node *ni)
* others get a timestamp aligned to the next interval. * others get a timestamp aligned to the next interval.
*/ */
tuadjust = (ni->ni_intval * (ath_maxvaps - avp->av_bslot)) / ath_maxvaps; tuadjust = (ni->ni_intval * (ath_maxvaps - avp->av_bslot)) / ath_maxvaps;
tsfadjust = cpu_to_le64(tuadjust << 10); /* TU->TSF */ tsfadjust = cpu_to_le64(IEEE80211_TU_TO_TSF(tuadjust));
DPRINTF(sc, ATH_DEBUG_BEACON, DPRINTF(sc, ATH_DEBUG_BEACON,
"%s beacons, bslot %d intval %u tsfadjust(Kus) %llu\n", "%s beacons, bslot %d intval %u tsfadjust(Kus) %llu\n",
@ -8343,7 +8346,7 @@ ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
* (bits 25-10 of the TSF). */ * (bits 25-10 of the TSF). */
#define TSTAMP_TX_MASK ((2 ^ (27 - 1)) - 1) /* First 27 bits. */ #define TSTAMP_TX_MASK ((2 ^ (27 - 1)) - 1) /* First 27 bits. */
tstamp = ts->ts_tstamp << 10; tstamp = IEEE80211_TU_TO_TSF(ts->ts_tstamp);
bf->bf_tsf = ((bf->bf_tsf & ~TSTAMP_TX_MASK) | tstamp); bf->bf_tsf = ((bf->bf_tsf & ~TSTAMP_TX_MASK) | tstamp);
if ((bf->bf_tsf & TSTAMP_TX_MASK) < tstamp) if ((bf->bf_tsf & TSTAMP_TX_MASK) < tstamp)
bf->bf_tsf -= TSTAMP_TX_MASK + 1; bf->bf_tsf -= TSTAMP_TX_MASK + 1;

View File

@ -131,11 +131,17 @@
* will directly convert it to TU. The rest is truncated to fit into 32 bit. * will directly convert it to TU. The rest is truncated to fit into 32 bit.
*/ */
#define IEEE80211_TSF_TO_TU(_tsf) ((u_int32_t)((_tsf) >> 10)) #define IEEE80211_TSF_TO_TU(_tsf) ((u_int32_t)((_tsf) >> 10))
#define IEEE80211_TU_TO_TSF(_tu) (((u_int64_t)(_tu)) << 10)
#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
#define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000) #define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000)
#define IEEE80211_TU_TO_JIFFIES(x) ((IEEE80211_TU_TO_MS(x) * HZ) / 1000) #define IEEE80211_TU_TO_JIFFIES(x) ((IEEE80211_TU_TO_MS(x) * HZ) / 1000)
#define IEEE80211_JIFFIES_TO_TU(x) IEEE80211_MS_TO_TU((x) * 1000 / HZ) #define IEEE80211_JIFFIES_TO_TU(x) IEEE80211_MS_TO_TU((x) * 1000 / HZ)
#define IEEE80211_TU_TO_MS_UP(x) (((x) * 1024 + 1000 - 1) / 1000)
#define IEEE80211_TU_TO_JIFFIES_UP(x) \
((IEEE80211_TU_TO_MS_UP(x) * HZ + 1000 - 1) / 1000)
#define IEEE80211_APPIE_MAX 1024 #define IEEE80211_APPIE_MAX 1024
#define IEEE80211_PWRCONSTRAINT_VAL(ic) \ #define IEEE80211_PWRCONSTRAINT_VAL(ic) \