From owner-p4-projects@FreeBSD.ORG Sat Dec 25 19:31:08 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0EF8216A4D0; Sat, 25 Dec 2004 19:31:08 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE12816A4CE for ; Sat, 25 Dec 2004 19:31:07 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9A1C43D2D for ; Sat, 25 Dec 2004 19:31:07 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id iBPJV7qh056318 for ; Sat, 25 Dec 2004 19:31:07 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id iBPJV7tK056315 for perforce@freebsd.org; Sat, 25 Dec 2004 19:31:07 GMT (envelope-from sam@freebsd.org) Date: Sat, 25 Dec 2004 19:31:07 GMT Message-Id: <200412251931.iBPJV7tK056315@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 67688 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Dec 2004 19:31:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=67688 Change 67688 by sam@sam_ebb on 2004/12/25 19:30:46 Fixup beacon timer calculations: o lintval is specified in ms and must be converted to TU's o roundup when calculating the nexttbtt to insure things are multiple of the beacon interval o remove bogus use of HAL_BEACON_RESET_TSF when setting station timers; there's an implicit reset done and setting the flag screwed up the sleep timer calculations (though all of this turned into a noop because of masking done by the hal) Affected files ... .. //depot/projects/wifi/sys/dev/ath/if_ath.c#46 edit Differences ... ==== //depot/projects/wifi/sys/dev/ath/if_ath.c#46 (text+ko) ==== @@ -1975,6 +1975,7 @@ static void ath_beacon_config(struct ath_softc *sc) { +#define MS_TO_TU(x) (((x) * 1000) / 1024) struct ath_hal *ah = sc->sc_ah; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni = ic->ic_bss; @@ -1984,20 +1985,15 @@ (LE_READ_4(ni->ni_tstamp.data) >> 10); DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt %u intval %u\n", __func__, nexttbtt, ni->ni_intval); - nexttbtt += ni->ni_intval; - intval = ni->ni_intval & HAL_BEACON_PERIOD; + intval = MS_TO_TU(ni->ni_intval) & HAL_BEACON_PERIOD; + nexttbtt = roundup(nexttbtt, intval); if (ic->ic_opmode == IEEE80211_M_STA) { HAL_BEACON_STATE bs; u_int32_t bmisstime; /* NB: no PCF support right now */ memset(&bs, 0, sizeof(bs)); - /* - * Reset our tsf so the hardware will update the - * tsf register to reflect timestamps found in - * received beacons. - */ - bs.bs_intval = intval | HAL_BEACON_RESET_TSF; + bs.bs_intval = intval; bs.bs_nexttbtt = nexttbtt; bs.bs_dtimperiod = bs.bs_intval; bs.bs_nextdtim = nexttbtt; @@ -2016,8 +2012,8 @@ * TU's and then calculate based on the beacon interval. * Note that we clamp the result to at most 10 beacons. */ - bmisstime = (ic->ic_bmisstimeout * 1000) / 1024; - bs.bs_bmissthreshold = howmany(bmisstime,ni->ni_intval); + bmisstime = MS_TO_TU(ic->ic_bmisstimeout); + bs.bs_bmissthreshold = howmany(bmisstime, intval); if (bs.bs_bmissthreshold > 10) bs.bs_bmissthreshold = 10; else if (bs.bs_bmissthreshold <= 0) @@ -2032,8 +2028,7 @@ * * XXX fixed at 100ms */ - bs.bs_sleepduration = - roundup((100 * 1000) / 1024, bs.bs_intval); + bs.bs_sleepduration = roundup(MS_TO_TU(100), bs.bs_intval); if (bs.bs_sleepduration > bs.bs_dtimperiod) bs.bs_sleepduration = roundup(bs.bs_sleepduration, bs.bs_dtimperiod); @@ -2057,7 +2052,7 @@ ath_hal_intrset(ah, sc->sc_imask); } else { ath_hal_intrset(ah, 0); - if (nexttbtt == ni->ni_intval) + if (nexttbtt == intval) intval |= HAL_BEACON_RESET_TSF; if (ic->ic_opmode == IEEE80211_M_IBSS) { /* @@ -2088,6 +2083,7 @@ if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) ath_beacon_proc(sc, 0); } +#undef MS_TO_TU } static void