From owner-svn-src-all@FreeBSD.ORG Fri Nov 23 05:38:38 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E5A31862; Fri, 23 Nov 2012 05:38:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B0ED58FC15; Fri, 23 Nov 2012 05:38:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAN5ccji046683; Fri, 23 Nov 2012 05:38:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAN5ccsl046682; Fri, 23 Nov 2012 05:38:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201211230538.qAN5ccsl046682@svn.freebsd.org> From: Adrian Chadd Date: Fri, 23 Nov 2012 05:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243426 - 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.14 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: Fri, 23 Nov 2012 05:38:39 -0000 Author: adrian Date: Fri Nov 23 05:38:38 2012 New Revision: 243426 URL: http://svnweb.freebsd.org/changeset/base/243426 Log: Fix up the nexttbtt -> TSF delta calculation to not wrap ridiculously on the 802.11n NICs. The 802.11n NICs return a TBTT value that continues far past the 16 bit HAL_BEACON_PERIOD time (in TU.) The code would constrain nextslot to HAL_BEACON_PERIOD, but it wasn't constraining nexttbtt - the pre-11n NICs would only return TU values from 0 -> HAL_BEACON_PERIOD. Thus, when nexttbtt exceeded 64 milliseconds, it would not wrap (but nextslot did) which lead to a huge tsfdelta. So until the slot calculation is converted to work in TSF rather than a mix of TSF and TU, "make" the nexttbtt values match the TU assumptions for pre-11n NICs. This fixes the crazy deltatsf calculations but it doesn't fix the non-convergent tsfdelta issue. That'll be fixed in a subsequent commit. Modified: head/sys/dev/ath/if_ath_tdma.c Modified: head/sys/dev/ath/if_ath_tdma.c ============================================================================== --- head/sys/dev/ath/if_ath_tdma.c Fri Nov 23 05:33:01 2012 (r243425) +++ head/sys/dev/ath/if_ath_tdma.c Fri Nov 23 05:38:38 2012 (r243426) @@ -336,7 +336,21 @@ ath_tdma_update(struct ieee80211_node *n * adjustments are done by pulling the TSF forward and possibly * rewriting the beacon timers. */ - nexttbtt = ath_hal_getnexttbtt(ah); + /* + * The logic here assumes the nexttbtt counter is in TSF + * but the prr-11n NICs are in TU. The HAL shifts them + * to TSF but there's two important differences: + * + * + The TU->TSF values have 0's for the low 9 bits, and + * + The counter wraps at TU_TO_TSF(HAL_BEACON_PERIOD + 1) for + * the pre-11n NICs, but not for the 11n NICs. + * + * So for now, just make sure the nexttbtt value we get + * matches the second issue or once nexttbtt exceeds this + * value, tsfdelta ends up becoming very negative and all + * of the adjustments get very messed up. + */ + nexttbtt = ath_hal_getnexttbtt(ah) % (TU_TO_TSF(HAL_BEACON_PERIOD + 1)); tsfdelta = (int32_t)((nextslot % TU_TO_TSF(HAL_BEACON_PERIOD + 1)) - nexttbtt); DPRINTF(sc, ATH_DEBUG_TDMA_TIMER,