]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mld: add debugfs for using ptp clock time for monitor interface
authorAvraham Stern <avraham.stern@intel.com>
Mon, 5 May 2025 18:56:44 +0000 (21:56 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 7 May 2025 03:08:01 +0000 (06:08 +0300)
Add a debugfs option to use the ptp clock time for Rx device
timestamps on a monitor interface. This can be useful for e.g.
synchronizing multiple NICs or reporting the timestamp in the
system clock instead of the GP2.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Link: https://patch.msgid.link/20250505215513.fffe6718fbca.I75f034005851a2d0c8ba5b015b9fdcad8a7c550d@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/debugfs.c
drivers/net/wireless/intel/iwlwifi/mld/mld.h
drivers/net/wireless/intel/iwlwifi/mld/rx.c

index 89d95e9b4f301a7c26308239b8fecd8e2a2c194e..0c896b4dba65d9c4fd4bb597f26ebd97adeb03b1 100644 (file)
@@ -546,6 +546,9 @@ iwl_mld_add_debugfs_files(struct iwl_mld *mld, struct dentry *debugfs_dir)
 #endif
        MLD_DEBUGFS_ADD_FILE(inject_packet, debugfs_dir, 0200);
 
+       debugfs_create_bool("rx_ts_ptp", 0600, debugfs_dir,
+                           &mld->monitor.ptp_time);
+
        /* Create a symlink with mac80211. It will be removed when mac80211
         * exits (before the opmode exits which removes the target.)
         */
index 0e4cc90fb6fc7389c8e7ea0874cf50e10b9f9319..cdbfe77e73f9ce74e101ab55cbd59266117be992 100644 (file)
  * @monitor.ampdu_toggle: the state of the previous packet to track A-MPDU
  * @monitor.cur_aid: current association id tracked by the sniffer
  * @monitor.cur_bssid: current bssid tracked by the sniffer
+ * @monitor.ptp_time: set the Rx mactime using the device's PTP clock time
  * @monitor.p80: primary channel position relative to he whole bandwidth, in
  * steps of 80 MHz
  * @fw_id_to_link_sta: maps a fw id of a sta to the corresponding
@@ -201,6 +202,7 @@ struct iwl_mld {
 #ifdef CONFIG_IWLWIFI_DEBUGFS
                        __le16 cur_aid;
                        u8 cur_bssid[ETH_ALEN];
+                       bool ptp_time;
 #endif
                } monitor;
 #ifdef CONFIG_PM_SLEEP
index d95603e6ac78444dda81740c8584ffdbd0a5a2e3..a27cdb77e446b73e0690ef733441710b7c68726b 100644 (file)
@@ -1213,8 +1213,20 @@ static void iwl_mld_rx_fill_status(struct iwl_mld *mld, struct sk_buff *skb,
                iwl_mld_rx_eht(mld, skb, phy_data, queue);
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
-       if (unlikely(mld->monitor.on))
+       if (unlikely(mld->monitor.on)) {
                iwl_mld_add_rtap_sniffer_config(mld, skb);
+
+               if (mld->monitor.ptp_time) {
+                       u64 adj_time =
+                           iwl_mld_ptp_get_adj_time(mld,
+                                                    phy_data->gp2_on_air_rise *
+                                                    NSEC_PER_USEC);
+
+                       rx_status->mactime = div64_u64(adj_time, NSEC_PER_USEC);
+                       rx_status->flag |= RX_FLAG_MACTIME_IS_RTAP_TS64;
+                       rx_status->flag &= ~RX_FLAG_MACTIME;
+               }
+       }
 #endif
 
        if (format != RATE_MCS_MOD_TYPE_CCK && is_sgi)