From patchwork Mon Nov 18 22:25:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 3199271 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 82DCCC045C for ; Mon, 18 Nov 2013 22:28:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 851082015E for ; Mon, 18 Nov 2013 22:28:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E38020157 for ; Mon, 18 Nov 2013 22:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751503Ab3KRW2V (ORCPT ); Mon, 18 Nov 2013 17:28:21 -0500 Received: from mail-ie0-f179.google.com ([209.85.223.179]:58413 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281Ab3KRW2U (ORCPT ); Mon, 18 Nov 2013 17:28:20 -0500 Received: by mail-ie0-f179.google.com with SMTP id u16so9402328iet.24 for ; Mon, 18 Nov 2013 14:28:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=I/djICPhhdy41woI416PW8vu6aK40k30/sr4BUuURF4=; b=GhwXcPytNS72z3nY0hfBsVKuXrGF7fTRh0f6QJdXDbRzlYg+o282mY3ZSPAczta2rh OjobWNXTs89eYa7rX4Jmvpun6wkQ9s61R94spqTsfQzbmlm9gU/QAtfmWKGEIjIuIWd+ ZEpkvw9/Ea+vc9UUoWAs/0umaJa+uWReExbzA/GBGW4Gq7MKi+BzTEJ2QyIc4lDmxKDZ K9RUbIYDpAsk2jvcjE83kgnaYTXoTDsxhyMkEjOLAXx3q3UF0L6vcaJArVXoBiyMyoLg /noTx7zbE9DFSkNzaC1gCufqxAoJlJ6fYkSPiDaKPQ1YWYAzQjx0tyxTWCDUe0S66TUr 3syA== X-Gm-Message-State: ALoCoQkQjtmLiOjCA4s9xCdr9otCuCdekNZ/+TVYrTHKKbXM4hCYEPE9QkSLMpRdNnqcHjRSSepw X-Received: by 10.50.29.43 with SMTP id g11mr12436017igh.25.1384813700458; Mon, 18 Nov 2013 14:28:20 -0800 (PST) Received: from hash (CPE0018e7fe5281-CM78cd8ec60a0d.cpe.net.cable.rogers.com. [99.242.215.162]) by mx.google.com with ESMTPSA id p5sm15937825igj.10.2013.11.18.14.28.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 18 Nov 2013 14:28:19 -0800 (PST) Received: from bob by hash with local (Exim 4.80) (envelope-from ) id 1ViXGG-0007uD-Se; Mon, 18 Nov 2013 17:25:40 -0500 From: Bob Copeland To: johannes@sipsolutions.net, thomas@cozybit.com Cc: linux-wireless@vger.kernel.org, Bob Copeland , Bob Copeland Subject: [PATCH] mac80211: mesh: only get tsf if we need it Date: Mon, 18 Nov 2013 17:25:28 -0500 Message-Id: <1384813528-30359-1-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The local TSF timer is used to compute the timing offset between mesh peers on beacon reception. However, asking the device for the TSF is not very accurate, so we prefer to use rx->mactime if available. In the latter case, calling drv_get_tsf() just adds more delay into the RX path, so skip it if we can. Signed-off-by: Bob Copeland --- net/mac80211/mesh_sync.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c index 05a256b..d1cf2d5 100644 --- a/net/mac80211/mesh_sync.c +++ b/net/mac80211/mesh_sync.c @@ -92,12 +92,20 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, if (stype != IEEE80211_STYPE_BEACON) return; - /* The current tsf is a first approximation for the timestamp - * for the received beacon. Further down we try to get a - * better value from the rx_status->mactime field if - * available. Also we have to call drv_get_tsf() before - * entering the rcu-read section.*/ - t_r = drv_get_tsf(local, sdata); + /* + * Get time when timestamp field was received. If we don't + * have rx timestamps, then use current tsf as an approximation. + * drv_get_tsf() must be called before entering the rcu-read + * section. + */ + if (ieee80211_have_rx_timestamp(rx_status)) + t_r = ieee80211_calculate_rx_timestamp(local, rx_status, + 24 + 12 + + elems->total_len + + FCS_LEN, + 24); + else + t_r = drv_get_tsf(local, sdata); rcu_read_lock(); sta = sta_info_get(sdata, mgmt->sa); @@ -117,14 +125,6 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, goto no_sync; } - if (ieee80211_have_rx_timestamp(rx_status)) - /* time when timestamp field was received */ - t_r = ieee80211_calculate_rx_timestamp(local, rx_status, - 24 + 12 + - elems->total_len + - FCS_LEN, - 24); - /* Timing offset calculation (see 13.13.2.2.2) */ t_t = le64_to_cpu(mgmt->u.beacon.timestamp); sta->t_offset = t_t - t_r;