aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mac80211_hwsim.c
diff options
context:
space:
mode:
authorThomas Pedersen <thomas@cozybit.com>2013-01-02 17:55:16 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-04 07:52:50 -0500
commit45034bfb8c9ecc62db40b438bea7fe728ac8facf (patch)
tree493e034209fe4e152942f1613f67e8f57b5f4127 /drivers/net/wireless/mac80211_hwsim.c
parent75ea719cb4773b05cc48e741feb4e267522b9656 (diff)
mac80211_hwsim: fix tsf adjustment
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 <thomas@cozybit.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index d248a4cc6656..807d713414f8 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -361,7 +361,7 @@ struct mac80211_hwsim_data {
361 int power_level; 361 int power_level;
362 362
363 /* difference between this hw's clock and the real clock, in usecs */ 363 /* difference between this hw's clock and the real clock, in usecs */
364 u64 tsf_offset; 364 s64 tsf_offset;
365}; 365};
366 366
367 367
@@ -427,9 +427,10 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
427 struct ieee80211_vif *vif, u64 tsf) 427 struct ieee80211_vif *vif, u64 tsf)
428{ 428{
429 struct mac80211_hwsim_data *data = hw->priv; 429 struct mac80211_hwsim_data *data = hw->priv;
430 struct timeval tv = ktime_to_timeval(ktime_get_real()); 430 u64 now = mac80211_hwsim_get_tsf(hw, vif);
431 u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec; 431 s64 delta = tsf - now;
432 data->tsf_offset = tsf - now; 432
433 data->tsf_offset += delta;
433} 434}
434 435
435static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, 436static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,