Merge time conversion macros, users of IEEE80211_TU_TO_TSF from madwifi-dfs
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 25 Jun 2009 01:03:32 +0000 (01:03 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 25 Jun 2009 01:03:32 +0000 (01:03 +0000)
git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4054 0192ed92-7a03-0410-a25b-9323aeb14dbd

ath/if_ath.c
net80211/ieee80211_var.h

index cdd26c83482fdefb006fa405a881d77f114bfdde..882de66ba0593c252a72116c49977fbdc75ecd23 100644 (file)
@@ -2411,17 +2411,20 @@ ath_intr(int irq, void *dev_id, struct pt_regs *regs)
                ATH_SCHEDULE_TQUEUE(&sc->sc_rxorntq, &needmark);
        } else {
                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 */
                        vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps);
                        sc->sc_nexttbtt += vap->iv_bss->ni_intval;
 
                        DPRINTF(sc, ATH_DEBUG_BEACON,
-                               "ath_intr HAL_INT_SWBA at "
-                               "tsf %10llx nexttbtt %10llx\n",
+                               "HAL_INT_SWBA at "
+                               "hw_tsf=%10llx nexttbtt_tsf=%10llx "
+                               "hwtsf_tu=%6u nexttbtt=%6u\n",
                                (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.
                         * 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.
                 */
                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,
                        "%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). */ 
 #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); 
                        if ((bf->bf_tsf & TSTAMP_TX_MASK) < tstamp) 
                                bf->bf_tsf -= TSTAMP_TX_MASK + 1; 
index f62cdf2706685b237d903b97275b8d6a0ba2a096..d5890705cd4ed05afe058c38306324f91b3b41ea 100644 (file)
  * 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_TU_TO_TSF(_tu)        (((u_int64_t)(_tu)) << 10)
+
 #define        IEEE80211_MS_TO_TU(x)   (((x) * 1000) / 1024)
 #define        IEEE80211_TU_TO_MS(x)   (((x) * 1024) / 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_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_PWRCONSTRAINT_VAL(ic) \