From owner-svn-src-all@FreeBSD.ORG Wed Apr 30 02:44:07 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CD51B8E5; Wed, 30 Apr 2014 02:44:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE6BF190B; Wed, 30 Apr 2014 02:44:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3U2i7gF079997; Wed, 30 Apr 2014 02:44:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3U2i7pQ079996; Wed, 30 Apr 2014 02:44:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201404300244.s3U2i7pQ079996@svn.freebsd.org> From: Adrian Chadd Date: Wed, 30 Apr 2014 02:44:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265117 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2014 02:44:08 -0000 Author: adrian Date: Wed Apr 30 02:44:07 2014 New Revision: 265117 URL: http://svnweb.freebsd.org/changeset/base/265117 Log: * Modify the beacon interval in debugging to be ni_intval, not 102400 * Be paranoid about avoiding divide-by-zero. Tested: * AR9380, STA mode Modified: head/sys/dev/ath/if_ath_rx.c Modified: head/sys/dev/ath/if_ath_rx.c ============================================================================== --- head/sys/dev/ath/if_ath_rx.c Wed Apr 30 02:29:31 2014 (r265116) +++ head/sys/dev/ath/if_ath_rx.c Wed Apr 30 02:44:07 2014 (r265117) @@ -335,10 +335,18 @@ ath_recv_mgmt(struct ieee80211_node *ni, int32_t tsf_delta_bmiss; int32_t tsf_remainder; uint64_t tsf_beacon_target; + int tsf_intval; tsf_beacon_old = ((uint64_t) LE_READ_4(ni->ni_tstamp.data + 4)) << 32; tsf_beacon_old |= LE_READ_4(ni->ni_tstamp.data); +#define TU_TO_TSF(_tu) (((u_int64_t)(_tu)) << 10) + tsf_intval = 1; + if (ni != NULL && ni->ni_intval > 0) { + tsf_intval = TU_TO_TSF(ni->ni_intval); + } +#undef TU_TO_TSF + /* * Call up first so subsequent work can use information * potentially stored in the node (e.g. for ibss merge). @@ -362,12 +370,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, */ tsf_delta = (long long) tsf_beacon - (long long) tsf_beacon_old; - /* - * For now let's just assume the intval is 100TU, which is - * 102400uS. So, we can just calculate the remainder from - * that. - */ - tsf_delta_bmiss = tsf_delta / 102400; + tsf_delta_bmiss = tsf_delta / tsf_intval; /* * If our delta is greater than half the beacon interval, @@ -375,25 +378,26 @@ ath_recv_mgmt(struct ieee80211_node *ni, * interval. Ie, we're running really, really early * on the next beacon. */ - if (tsf_delta % 102400 > 51200) + if (tsf_delta % tsf_intval > (tsf_intval / 2)) tsf_delta_bmiss ++; tsf_beacon_target = tsf_beacon_old + - (((unsigned long long) tsf_delta_bmiss) * 102400ULL); + (((unsigned long long) tsf_delta_bmiss) * (long long) tsf_intval); /* - * The remainder using '%' is between 0 .. 102400-1. + * The remainder using '%' is between 0 .. intval-1. * If we're actually running too fast, then the remainder - * will be some large number just under 102400-1. + * will be some large number just under intval-1. * So we need to look at whether we're running * before or after the target beacon interval * and if we are, modify how we do the remainder * calculation. */ if (tsf_beacon < tsf_beacon_target) { - tsf_remainder = -(102400 - ((tsf_beacon - tsf_beacon_old) % 102400)); + tsf_remainder = + -(tsf_intval - ((tsf_beacon - tsf_beacon_old) % tsf_intval)); } else { - tsf_remainder = (tsf_beacon - tsf_beacon_old) % 102400; + tsf_remainder = (tsf_beacon - tsf_beacon_old) % tsf_intval; } DPRINTF(sc, ATH_DEBUG_BEACON, "%s: old_tsf=%llu, new_tsf=%llu, target_tsf=%llu, delta=%lld, bmiss=%d, remainder=%d\n", @@ -409,7 +413,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, __func__, (unsigned long long) tsf_beacon, (unsigned long long) nexttbtt, - (int32_t) tsf_beacon - (int32_t) nexttbtt + 102400); + (int32_t) tsf_beacon - (int32_t) nexttbtt + tsf_intval); if (sc->sc_syncbeacon && ni == vap->iv_bss &&