mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-24 13:52:58 -04:00
wifi: mac80211_hwsim: rename and switch simulation time to boottime
The mac80211_hwsim base time for the simulation of the TSF was based on the real time of the system. This clock is subject to unexpected changes. Switch it to use boottime which is always monotonic and also continues to run through times where the system is suspended. Also change the function name from tsf_raw to sim_tsf to better differentiate between the TSF of the mac and the TSF base of the simulation. Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260504101829.2a64333111ff.I2ef047f3cdd6dc52af4bb7bf747368fb78014f18@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
committed by
Johannes Berg
parent
340f2ab83a
commit
1926f4e06d
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user