mac80211_hwsim: write TSF timestamp correctly to S1G beacon
authorThomas Pedersen <thomas@adapt-ip.com>
Tue, 22 Sep 2020 02:28:17 +0000 (19:28 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 28 Sep 2020 12:10:13 +0000 (14:10 +0200)
S1G beacons are different from normal management beacons, so write
the timestamp to the correct location there.

Signed-off-by: Thomas 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: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/mac80211_hwsim.c

index d3d0fb8..cb624b2 100644 (file)
@@ -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();
-       mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts +
-                                              data->tsf_offset +
-                                              24 * 8 * 10 / txrate->bitrate);
+       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);
+       }
 
        mac80211_hwsim_tx_frame(hw, skb,
                                rcu_dereference(vif->chanctx_conf)->def.chan);