From patchwork Thu Dec 27 21:43:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Pedersen X-Patchwork-Id: 1913691 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 3C70F3FF0F for ; Thu, 27 Dec 2012 21:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751765Ab2L0Vo3 (ORCPT ); Thu, 27 Dec 2012 16:44:29 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:38742 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751492Ab2L0Vo3 (ORCPT ); Thu, 27 Dec 2012 16:44:29 -0500 Received: by mail-pb0-f50.google.com with SMTP id wz7so5566984pbc.9 for ; Thu, 27 Dec 2012 13:44:28 -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=lcM3V95aAtYtO0NjonuT1L1pwCG4ilIB9gV9ZgMKWoDSc5AIlKpL0flMPSdEqxsjG0 lS/sHH82FeBZiFnJjE19P4R+Ak8frUpxJN1oXqlSAb9P7jS3aLc8CfwyPFUI3MLGL6gl sdR0Zt3RxOCjUaL6gux9pCpz98hpZaPf3mtl+zGyYEAAq//KPnMUx0WjauNo+r1c3KUV fjtc4MUmPEUxP2tVq1bR4gs8qgM9r1hDIjNj3O/7tHgOxfsT2yMj3cPENpj+J5rMMCcK y44e763d4YbwJr2VSIrvTJriYdm1sPI7Tzt/fSp1rC0Ncwes/6e3MC7Zoxc7XQtLHasy Yeag== X-Received: by 10.68.209.170 with SMTP id mn10mr99031466pbc.11.1356644668477; Thu, 27 Dec 2012 13:44:28 -0800 (PST) Received: from cable.lan (70-35-43-50.static.wiline.com. [70.35.43.50]) by mx.google.com with ESMTPS id kl3sm18416026pbc.15.2012.12.27.13.44.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Dec 2012 13:44:26 -0800 (PST) From: Thomas Pedersen To: linville@tuxdriver.org Cc: j@w1.fi, linux-wireless@vger.kernel.org, johannes@sipsolutions.net, Thomas Pedersen Subject: [PATCH 1/4] mac80211_hwsim: fix tsf adjustment Date: Thu, 27 Dec 2012 13:43:53 -0800 Message-Id: <1356644636-5309-1-git-send-email-thomas@cozybit.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlyJ4mkYMM1K4f0X+54CKWZgHIEE/8yoFoixHOeTZifHzM1lVhe3DDVntXWHHGWtThhIVWS 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,