]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
wifi: mac80211: export ieee80211_calculate_rx_timestamp
authorBenjamin Berg <benjamin.berg@intel.com>
Thu, 26 Mar 2026 10:14:33 +0000 (12:14 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 7 Apr 2026 13:36:02 +0000 (15:36 +0200)
The function is quite useful when handling beacon timestamps. Export it
so that it can be used by mac80211_hwsim and others.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260326121156.a1abc9c52f37.Ieabfe66768b1bf64c3076d62e73c50794faeacdc@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/mesh_sync.c
net/mac80211/rx.c
net/mac80211/scan.c
net/mac80211/util.c

index b1c412eabf2b1fd0fb48a211d3b456d4e394e7ab..8b513f777187edafdfcfacdc5bf0f8717d7b8622 100644 (file)
@@ -7393,6 +7393,24 @@ void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif);
  */
 int ieee80211_ave_rssi(struct ieee80211_vif *vif, int link_id);
 
+/**
+ * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @status: RX status
+ * @mpdu_len: total MPDU length (including FCS)
+ * @mpdu_offset: offset into MPDU to calculate timestamp at
+ *
+ * This function calculates the RX timestamp at the given MPDU offset, taking
+ * into account what the RX timestamp was. An offset of 0 will just normalize
+ * the timestamp to TSF at beginning of MPDU reception.
+ *
+ * Returns: the calculated timestamp
+ */
+u64 ieee80211_calculate_rx_timestamp(struct ieee80211_hw *hw,
+                                    struct ieee80211_rx_status *status,
+                                    unsigned int mpdu_len,
+                                    unsigned int mpdu_offset);
+
 /**
  * ieee80211_report_wowlan_wakeup - report WoWLAN wakeup
  * @vif: virtual interface
index 1e1ab25d9d8ded71cfc85962a385daa5dd5a9a08..97292ff51475fde04c0132192ca8b9dd4a74e4dd 100644 (file)
@@ -1127,7 +1127,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
        if (ieee80211_have_rx_timestamp(rx_status)) {
                /* time when timestamp field was received */
                rx_timestamp =
-                       ieee80211_calculate_rx_timestamp(local, rx_status,
+                       ieee80211_calculate_rx_timestamp(&local->hw, rx_status,
                                                         len + FCS_LEN, 24);
        } else {
                /*
index bacb49ad281738a54d79e844c3710efdc2c2ebc0..53d78376964245f48ee946da38bf18c575b9924f 100644 (file)
@@ -1922,10 +1922,6 @@ ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
        return -1;
 }
 
-u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
-                                    struct ieee80211_rx_status *status,
-                                    unsigned int mpdu_len,
-                                    unsigned int mpdu_offset);
 int ieee80211_hw_config(struct ieee80211_local *local, int radio_idx,
                        u32 changed);
 int ieee80211_hw_conf_chan(struct ieee80211_local *local);
index 3a66b4cefca7bd9ee205ecced24efe7c5c52139a..24a68eef7db89249d228884f3e7e1bb29e4b61aa 100644 (file)
@@ -103,7 +103,7 @@ mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, u16 stype,
         * section.
         */
        if (ieee80211_have_rx_timestamp(rx_status))
-               t_r = ieee80211_calculate_rx_timestamp(local, rx_status,
+               t_r = ieee80211_calculate_rx_timestamp(&local->hw, rx_status,
                                                       len + FCS_LEN, 24);
        else
                t_r = drv_get_tsf(local, sdata);
index d9a654ef082d11fdd117a7d3540618c4893afe13..dbdd67c181d8a275c5d0f5f7d75aa8acb04074f4 100644 (file)
@@ -404,7 +404,7 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
                while ((pos - (u8 *)rthdr) & 7)
                        *pos++ = 0;
                put_unaligned_le64(
-                       ieee80211_calculate_rx_timestamp(local, status,
+                       ieee80211_calculate_rx_timestamp(&local->hw, status,
                                                         mpdulen, 0),
                        pos);
                rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_TSFT));
index 4823c8d4563992790dfae861795e09ac7f3f5c97..eeff230bd909fe72dfe233d12fd8eabc66e2843e 100644 (file)
@@ -216,7 +216,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
 
                if (link_conf) {
                        bss_meta.parent_tsf =
-                               ieee80211_calculate_rx_timestamp(local,
+                               ieee80211_calculate_rx_timestamp(&local->hw,
                                                                 rx_status,
                                                                 len + FCS_LEN,
                                                                 24);
index 72e73f4f79c5f6ff2bd0eb98ef03ef72fd71fb10..38b0c42c4c131316f2f9f4e008e2c0e5c8b56dbe 100644 (file)
@@ -3423,20 +3423,7 @@ u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs)
        return 1;
 }
 
-/**
- * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
- * @local: mac80211 hw info struct
- * @status: RX status
- * @mpdu_len: total MPDU length (including FCS)
- * @mpdu_offset: offset into MPDU to calculate timestamp at
- *
- * This function calculates the RX timestamp at the given MPDU offset, taking
- * into account what the RX timestamp was. An offset of 0 will just normalize
- * the timestamp to TSF at beginning of MPDU reception.
- *
- * Returns: the calculated timestamp
- */
-u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
+u64 ieee80211_calculate_rx_timestamp(struct ieee80211_hw *hw,
                                     struct ieee80211_rx_status *status,
                                     unsigned int mpdu_len,
                                     unsigned int mpdu_offset)
@@ -3555,7 +3542,7 @@ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
        case RX_ENC_LEGACY: {
                struct ieee80211_supported_band *sband;
 
-               sband = local->hw.wiphy->bands[status->band];
+               sband = hw->wiphy->bands[status->band];
                ri.legacy = sband->bitrates[status->rate_idx].bitrate;
 
                if (mactime_plcp_start) {
@@ -3587,6 +3574,7 @@ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
 
        return ts;
 }
+EXPORT_SYMBOL_GPL(ieee80211_calculate_rx_timestamp);
 
 /* Cancel CAC for the interfaces under the specified @local. If @ctx is
  * also provided, only the interfaces using that ctx will be canceled.