From patchwork Wed Jan 2 22:55:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Pedersen X-Patchwork-Id: 1925591 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AF2933FE37 for ; Wed, 2 Jan 2013 22:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752711Ab3ABWzw (ORCPT ); Wed, 2 Jan 2013 17:55:52 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:52267 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752635Ab3ABWzv (ORCPT ); Wed, 2 Jan 2013 17:55:51 -0500 Received: by mail-pa0-f47.google.com with SMTP id fa10so8239253pad.34 for ; Wed, 02 Jan 2013 14:55:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=gGmHbfrAVNYQ8mXijWc8LOkB46BrL9IYvGIYPJDoyYY=; b=c7bQtk9y4nPSiyB+zr5KNflFsllt+2x6yc0kpsf8sNSokN0RqYbYb8v328NwQMrOsi UMrmxJCOLMyvlLd4oBHWZP0x3DZF8ZB+ZgwWmkUeOp+Y5Uq2bu0Td6W70jb77afLOzjB n82T+4f8lPB1qr9CQdSWu0RfmNQHcQmpgvG1xN1mZ+gShwzt35YTr3rtJXhDTOt+ufpY 4XNQrpFQ75iofgyQF35gD5RKFCOVYy2PegASFcQ9cU64lU7LdhxecKhRE6cbbo+AADSB Utm5pNvlWGgITmRTKDGU2fJ67wYfHSDKHQKj24LYTiWN9/jGFJDBbIu0RvSyTAd+/ODS Kofg== X-Received: by 10.66.72.225 with SMTP id g1mr140216664pav.79.1357167351063; Wed, 02 Jan 2013 14:55:51 -0800 (PST) Received: from cable.lan (70-35-43-50.static.wiline.com. [70.35.43.50]) by mx.google.com with ESMTPS id gl9sm29119358pbc.51.2013.01.02.14.55.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Jan 2013 14:55:49 -0800 (PST) From: Thomas Pedersen To: linville@tuxdriver.org Cc: j@w1.fi, linux-wireless@vger.kernel.org, johannes@sipsolutions.net, devel@lists.open80211s.org, Thomas Pedersen Subject: [PATCH v2 1/4] mac80211_hwsim: fix tsf adjustment Date: Wed, 2 Jan 2013 14:55:16 -0800 Message-Id: <1357167319-13338-1-git-send-email-thomas@cozybit.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlgG+W+So1TGBKiRkHlDfujuw6g2wh6Ohru2nPhF8PcOL09YWPS+uDpBeTUfsUoUcEoORkD Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Make hwsim TSF offset adjustments cumulative and relative to the fake PHY TSF. Now adding 1000us, then adding -1000us doesn't result in a tsf_offset of -1000. Also the beacon timestamp can now correctly be expressed as (tsf + data->tsf_offset), which will be done in a later patch. Signed-off-by: Thomas Pedersen --- drivers/net/wireless/mac80211_hwsim.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index ff90855..59761fb 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -357,7 +357,7 @@ struct mac80211_hwsim_data { int power_level; /* difference between this hw's clock and the real clock, in usecs */ - u64 tsf_offset; + s64 tsf_offset; }; @@ -423,9 +423,10 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u64 tsf) { struct mac80211_hwsim_data *data = hw->priv; - struct timeval tv = ktime_to_timeval(ktime_get_real()); - u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec; - data->tsf_offset = tsf - now; + u64 now = mac80211_hwsim_get_tsf(hw, vif); + s64 delta = tsf - now; + + data->tsf_offset += delta; } static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,