Commit a3ffee47 authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg
Browse files

mac80211_hwsim: write TSF timestamp correctly to S1G beacon



S1G beacons are different from normal management beacons, so write
the timestamp to the correct location there.

Signed-off-by: default avatarThomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200922022818.15855-17-thomas@adapt-ip.com


[rewrite commit message that was not useful after patch reordering]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 58ef7c1b
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -1687,9 +1687,19 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
	mgmt = (struct ieee80211_mgmt *) skb->data;
	/* fake header transmission time */
	data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw();
	if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
		struct ieee80211_ext *ext = (void *) mgmt;

		ext->u.s1g_beacon.timestamp = cpu_to_le32(data->abs_bcn_ts +
							  data->tsf_offset +
							  10 * 8 * 10 /
							  txrate->bitrate);
	} else {
		mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts +
						       data->tsf_offset +
					       24 * 8 * 10 / txrate->bitrate);
						       24 * 8 * 10 /
						       txrate->bitrate);
	}

	mac80211_hwsim_tx_frame(hw, skb,
				rcu_dereference(vif->chanctx_conf)->def.chan);