diff options
| -rw-r--r-- | drivers/net/wireless/virtual/mac80211_hwsim_main.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c index 4ad2c6f38663..3bda5532ab62 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c @@ -1211,22 +1211,25 @@ static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb, return NETDEV_TX_OK; } -static inline u64 mac80211_hwsim_get_tsf_raw(void) +static inline u64 mac80211_hwsim_get_sim_tsf(void) { - return ktime_to_us(ktime_get_real()); -} - -static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data) -{ - u64 now = mac80211_hwsim_get_tsf_raw(); - return cpu_to_le64(now + data->tsf_offset); + return ktime_to_us(ktime_get_boottime()); } u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct mac80211_hwsim_data *data = hw->priv; - return le64_to_cpu(__mac80211_hwsim_get_tsf(data)); + u64 sim_time = mac80211_hwsim_get_sim_tsf(); + + return sim_time + data->tsf_offset; +} + +static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data) +{ + u64 sim_time = mac80211_hwsim_get_sim_tsf(); + + return cpu_to_le64(sim_time + data->tsf_offset); } static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, @@ -1778,7 +1781,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_rx_status rx_status; - u64 now; + u64 sim_tsf; memset(&rx_status, 0, sizeof(rx_status)); rx_status.flag |= RX_FLAG_MACTIME_START; @@ -1831,9 +1834,9 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, if (ieee80211_is_beacon(hdr->frame_control) || ieee80211_is_probe_resp(hdr->frame_control)) { rx_status.boottime_ns = ktime_get_boottime_ns(); - now = data->abs_bcn_ts; + sim_tsf = data->abs_bcn_ts; } else { - now = mac80211_hwsim_get_tsf_raw(); + sim_tsf = mac80211_hwsim_get_sim_tsf(); } /* Copy skb to all enabled radios that are on the current frequency */ @@ -1894,7 +1897,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, if (mac80211_hwsim_addr_match(data2, hdr->addr1)) ack = true; - rx_status.mactime = now + data2->tsf_offset; + rx_status.mactime = sim_tsf + data2->tsf_offset; mac80211_hwsim_rx(data2, &rx_status, nskb); } @@ -2147,7 +2150,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, txrate = ieee80211_get_tx_rate(hw, txi); if (txrate) bitrate = txrate->bitrate; - ts = mac80211_hwsim_get_tsf_raw(); + ts = mac80211_hwsim_get_sim_tsf(); mgmt->u.probe_resp.timestamp = cpu_to_le64(ts + data->tsf_offset + 24 * 8 * 10 / bitrate); @@ -2330,7 +2333,7 @@ static void __mac80211_hwsim_beacon_tx(struct ieee80211_bss_conf *link_conf, mgmt = (struct ieee80211_mgmt *) skb->data; /* fake header transmission time */ - data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw(); + data->abs_bcn_ts = mac80211_hwsim_get_sim_tsf(); if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { struct ieee80211_ext *ext = (void *) mgmt; |
