Changeset 3635

Show
Ignore:
Timestamp:
05/16/08 18:09:36 (5 months ago)
Author:
br1
Message:

add IEEE80211_TSF_TO_TU macro again and explain it once there instead of
open coding >> 10 and putting notes all over the place.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/ath/if_ath.c

    r3634 r3635  
    52595259                u_int32_t tsftu; 
    52605260 
    5261                 tsftu = hw_tsf >> 10; /* NB: 64 -> 32: See note far above. */ 
     5261                tsftu = IEEE80211_TSF_TO_TU(hw_tsf); 
    52625262                slot = ((tsftu % ic->ic_lintval) * ath_maxvaps) / ic->ic_lintval; 
    52635263                vap = sc->sc_bslot[(slot + 1) % ath_maxvaps]; 
     
    54535453 * Note : TBTT is Target Beacon Transmission Time (see IEEE 802.11-1999: 4 & 
    54545454 * 11.2.1.3). 
    5455  * 
    5456  * Note: TSF is right shifter by 10 and then put into a 32-bit int, which will  
    5457  * truncate. This does not affect the calculation as long as no more than one  
    5458  * overflow/wraparound occurs between beacons. This is not going to happen as 
    5459  * (2^(32 + 10 - 1) - 1)us is a really long time. 
    54605455 */ 
    54615456static void 
     
    54775472        hw_tsf = ath_hal_gettsf64(ah); 
    54785473        tsf = le64_to_cpu(ni->ni_tstamp.tsf); 
    5479         hw_tsftu = hw_tsf >> 10
    5480         tsftu = tsf >> 10; /* NB: 64 -> 32. See note above. */ 
     5474        hw_tsftu = IEEE80211_TSF_TO_TU(hw_tsf)
     5475        tsftu = IEEE80211_TSF_TO_TU(tsf); 
    54815476 
    54825477        /* We should reset hw TSF only once, so we increment 
     
    65026497                         * RUN -> RUN when this happens. */ 
    65036498                        hw_tsf = ath_hal_gettsf64(sc->sc_ah); 
    6504                         hw_tu  = hw_tsf >> 10
     6499                        hw_tu  = IEEE80211_TSF_TO_TU(hw_tsf)
    65056500 
    65066501                        beacon_tsf = le64_to_cpu(ni->ni_tstamp.tsf); 
    6507                         beacon_tu  = beacon_tsf >> 10
     6502                        beacon_tu  = IEEE80211_TSF_TO_TU(beacon_tsf)
    65086503 
    65096504                        DPRINTF(sc, ATH_DEBUG_BEACON, 
  • madwifi/trunk/net80211/ieee80211_var.h

    r3634 r3635  
    122122          DEV_NAME(_v->iv_ic->ic_dev)) 
    123123 
     124/* 
     125 * TU conversions: 
     126 * 
     127 * TU is a 32bit value and defined by IEEE802.11 (page 6) as "A measurement of 
     128 * time equal to 1024 usec (microseconds)". 
     129 * 
     130 * TSF is a 64bit value in usec, therefore if we right shift it by 10 bit this 
     131 * will directly convert it to TU. The rest is truncated to fit into 32 bit. 
     132 */ 
     133#define IEEE80211_TSF_TO_TU(_tsf)       ((u_int32_t)((_tsf) >> 10)) 
    124134#define IEEE80211_MS_TO_TU(x)   (((x) * 1000) / 1024) 
    125135#define IEEE80211_TU_TO_MS(x)   (((x) * 1024) / 1000)