Commit 45034bfb authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg

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: default avatarThomas Pedersen <thomas@cozybit.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 75ea719c
...@@ -361,7 +361,7 @@ struct mac80211_hwsim_data { ...@@ -361,7 +361,7 @@ struct mac80211_hwsim_data {
int power_level; int power_level;
/* difference between this hw's clock and the real clock, in usecs */ /* difference between this hw's clock and the real clock, in usecs */
u64 tsf_offset; s64 tsf_offset;
}; };
...@@ -427,9 +427,10 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, ...@@ -427,9 +427,10 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, u64 tsf) struct ieee80211_vif *vif, u64 tsf)
{ {
struct mac80211_hwsim_data *data = hw->priv; struct mac80211_hwsim_data *data = hw->priv;
struct timeval tv = ktime_to_timeval(ktime_get_real()); u64 now = mac80211_hwsim_get_tsf(hw, vif);
u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec; s64 delta = tsf - now;
data->tsf_offset = tsf - now;
data->tsf_offset += delta;
} }
static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment