From owner-p4-projects@FreeBSD.ORG Thu Nov 24 05:12:51 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 49C9E16A421; Thu, 24 Nov 2005 05:12:51 +0000 (GMT) X-Original-To: perforce@freebsd.org 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 0D37116A41F for ; Thu, 24 Nov 2005 05:12:51 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACFD643D46 for ; Thu, 24 Nov 2005 05:12:50 +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 jAO5CoMZ048544 for ; Thu, 24 Nov 2005 05:12:50 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jAO5Co46048541 for perforce@freebsd.org; Thu, 24 Nov 2005 05:12:50 GMT (envelope-from sam@freebsd.org) Date: Thu, 24 Nov 2005 05:12:50 GMT Message-Id: <200511240512.jAO5Co46048541@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 Cc: Subject: PERFORCE change 87168 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2005 05:12:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=87168 Change 87168 by sam@sam_ebb on 2005/11/24 05:11:53 pull nexttbtt forward when joining an existing ibss Affected files ... .. //depot/projects/wifi/sys/dev/ath/if_ath.c#113 edit Differences ... ==== //depot/projects/wifi/sys/dev/ath/if_ath.c#113 (text+ko) ==== @@ -2570,11 +2570,14 @@ static void ath_beacon_config(struct ath_softc *sc) { -#define TSF_TO_TU(_h,_l) (((_h) << 22) | ((_l) >> 10)) +#define TSF_TO_TU(_h,_l) \ + ((((u_int32_t)(_h)) << 22) | (((u_int32_t)(_l)) >> 10)) +#define FUDGE 2 struct ath_hal *ah = sc->sc_ah; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni = ic->ic_bss; - u_int32_t nexttbtt, intval; + u_int32_t nexttbtt, intval, tsftu; + u_int64_t tsf; /* extract tstamp from last beacon and convert to TU */ nexttbtt = TSF_TO_TU(LE_READ_4(ni->ni_tstamp.data + 4), @@ -2589,8 +2592,6 @@ __func__, nexttbtt, intval, ni->ni_intval); if (ic->ic_opmode == IEEE80211_M_STA) { HAL_BEACON_STATE bs; - u_int64_t tsf; - u_int32_t tsftu; int dtimperiod, dtimcount; int cfpperiod, cfpcount; @@ -2606,13 +2607,12 @@ dtimcount = 0; /* XXX? */ cfpperiod = 1; /* NB: no PCF support yet */ cfpcount = 0; -#define FUDGE 2 /* * Pull nexttbtt forward to reflect the current * TSF and calculate dtim+cfp state for the result. */ tsf = ath_hal_gettsf64(ah); - tsftu = TSF_TO_TU((u_int32_t)(tsf>>32), (u_int32_t)tsf) + FUDGE; + tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; do { nexttbtt += intval; if (--dtimcount < 0) { @@ -2621,7 +2621,6 @@ cfpcount = cfpperiod - 1; } } while (nexttbtt < tsftu); -#undef FUDGE memset(&bs, 0, sizeof(bs)); bs.bs_intval = intval; bs.bs_nexttbtt = nexttbtt; @@ -2703,6 +2702,17 @@ intval |= HAL_BEACON_ENA; if (!sc->sc_hasveol) sc->sc_imask |= HAL_INT_SWBA; + if ((intval & HAL_BEACON_RESET_TSF) == 0) { + /* + * Pull nexttbtt forward to reflect + * the current TSF. + */ + tsf = ath_hal_gettsf64(ah); + tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; + do { + nexttbtt += intval; + } while (nexttbtt < tsftu); + } ath_beaconq_config(sc); } else if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* @@ -2724,6 +2734,7 @@ ath_beacon_proc(sc, 0); } sc->sc_syncbeacon = 0; +#undef FUDGE #undef TSF_TO_TU }