Skip to contentSkip to conversation

idpf: add HW timestamping statistics

PATCH In review Anton Nadezhdin 4 participants 4 messages Aug 29, 2025 – Sep 15, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 idpf: add HW timestamping statistics

From: Milena Olech <[email protected]>

Add HW timestamping statistics support - through implementing get_ts_stats. Timestamp statistics include correctly timestamped packets, discarded, skipped and flushed during PTP release.

Most of the stats are collected per vport, only requests skipped due to lack of free latch index are collected per Tx queue.

Statistics can be obtained using kernel ethtool since version 6.10 with:
ethtool -I -T <interface>

The output will include:
Statistics:
tx_pkts: 15
tx_lost: 0
tx_err: 0

---
Changelog:
v2: Add testing information
v3: Add check for port status to resolve driver crash during statistic
read when port is down

---
 drivers/net/ethernet/intel/idpf/idpf.h        | 17 ++++++
 .../net/ethernet/intel/idpf/idpf_ethtool.c    | 56 +++++++++++++++++++
 drivers/net/ethernet/intel/idpf/idpf_ptp.c    | 11 +++-
 .../ethernet/intel/idpf/idpf_virtchnl_ptp.c   |  4 ++
 4 files changed, 87 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf.h +17 -0
index 6e79fa8556e9..6db6d6f0562a 100644
@@ -256,6 +256,21 @@ enum idpf_vport_flags {
 	IDPF_VPORT_FLAGS_NBITS,
 };
 
+/**
+ * struct idpf_tstamp_stats - Tx timestamp statistics
+ * @stats_sync: See struct u64_stats_sync
+ * @packets: Number of packets successfully timestamped by the hardware
+ * @discarded: Number of Tx skbs discarded due to cached PHC
+ *	       being too old to correctly extend timestamp
+ * @flushed: Number of Tx skbs flushed due to interface closed
+ */
+struct idpf_tstamp_stats {
+	struct u64_stats_sync stats_sync;
+	u64_stats_t packets;
+	u64_stats_t discarded;
+	u64_stats_t flushed;
+};
+
 struct idpf_port_stats {
 	struct u64_stats_sync stats_sync;
 	u64_stats_t rx_hw_csum_err;
@@ -328,6 +343,7 @@ struct idpf_fsteer_fltr {
  * @tx_tstamp_caps: Capabilities negotiated for Tx timestamping
  * @tstamp_config: The Tx tstamp config
  * @tstamp_task: Tx timestamping task
+ * @tstamp_stats: Tx timestamping statistics
  */
 struct idpf_vport {
 	u16 num_txq;
@@ -386,6 +402,7 @@ struct idpf_vport {
 	struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
 	struct kernel_hwtstamp_config tstamp_config;
 	struct work_struct tstamp_task;
+	struct idpf_tstamp_stats tstamp_stats;
 };
 
 /**
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +56 -0

68 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_ptp.c +10 -1
index 63a41e688733..3e1052d070cf 100644
@@ -618,8 +618,13 @@ u64 idpf_ptp_extend_ts(struct idpf_vport *vport, u64 in_tstamp)
 
 	discard_time = ptp->cached_phc_jiffies + 2 * HZ;
 
-	if (time_is_before_jiffies(discard_time))
+	if (time_is_before_jiffies(discard_time)) {
+		u64_stats_update_begin(&vport->tstamp_stats.stats_sync);
+		u64_stats_inc(&vport->tstamp_stats.discarded);
+		u64_stats_update_end(&vport->tstamp_stats.stats_sync);
+
 		return 0;
+	}
 
 	return idpf_ptp_tstamp_extend_32b_to_64b(ptp->cached_phc_time,
 						 lower_32_bits(in_tstamp));
@@ -853,13 +858,17 @@ static void idpf_ptp_release_vport_tstamp(struct idpf_vport *vport)
 
 	/* Remove list with latches in use */
 	head = &vport->tx_tstamp_caps->latches_in_use;
+	u64_stats_update_begin(&vport->tstamp_stats.stats_sync);
 	list_for_each_entry_safe(ptp_tx_tstamp, tmp, head, list_member) {
+		u64_stats_inc(&vport->tstamp_stats.flushed);
+
 		list_del(&ptp_tx_tstamp->list_member);
 		if (ptp_tx_tstamp->skb)
 			consume_skb(ptp_tx_tstamp->skb);
 
 		kfree(ptp_tx_tstamp);
 	}
+	u64_stats_update_end(&vport->tstamp_stats.stats_sync);
 
 	spin_unlock_bh(&vport->tx_tstamp_caps->latches_lock);
 
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +4 -0
index 688a6f4e0acc..61cedb6f2854 100644
@@ -522,6 +522,10 @@ idpf_ptp_get_tstamp_value(struct idpf_vport *vport,
 	list_add(&ptp_tx_tstamp->list_member,
 		 &tx_tstamp_caps->latches_free);
 
+	u64_stats_update_begin(&vport->tstamp_stats.stats_sync);
+	u64_stats_inc(&vport->tstamp_stats.packets);
+	u64_stats_update_end(&vport->tstamp_stats.stats_sync);
+
 	return 0;
 }
 

base-commit: e9d3c152a5c44376d901100fac80858278acc3eb

Signature · 1 line
2.42.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 19 lines · Anton Nadezhdin

From: Milena Olech <[email protected]>

Add HW timestamping statistics support - through implementing get_ts_stats. Timestamp statistics include correctly timestamped packets, discarded, skipped and flushed during PTP release.

Most of the stats are collected per vport, only requests skipped due to lack of free latch index are collected per Tx queue.

Statistics can be obtained using kernel ethtool since version 6.10 with:
ethtool -I -T <interface>

The output will include:
Statistics:
tx_pkts: 15
tx_lost: 0
tx_err: 0

Quoted 5 lines

---

Tested-by
#2 lore raw
Quoted 36 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Friday, August 29, 2025 2:02 PM
To: Nadezhdin, Anton <[email protected]>; intel-wired- [email protected]
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; Olech, Milena <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v3] idpf: add HW timestamping statistics

Quoted 3 lines · Anton Nadezhdin

From: Milena Olech <[email protected]>

Add HW timestamping statistics support - through implementing

get_ts_stats.

Quoted 16 lines

Timestamp statistics include correctly timestamped packets, discarded, skipped and flushed during PTP release.

Most of the stats are collected per vport, only requests skipped due to lack of free latch index are collected per Tx queue.

Statistics can be obtained using kernel ethtool since version 6.10 with:
ethtool -I -T <interface>

The output will include:
Statistics:
tx_pkts: 15
tx_lost: 0
tx_err: 0

Quoted 7 lines
Quoted 5 lines

---

Reviewed-by on v3 1/1
#3 lore raw
In reply to Anton Nadezhdin

Dear Anton,

Thank you for the improved patch.

Am 29.08.25 um 19:57 schrieb Anton Nadezhdin:

Quoted 34 lines

From: Milena Olech <[email protected]>

Add HW timestamping statistics support - through implementing get_ts_stats. Timestamp statistics include correctly timestamped packets, discarded, skipped and flushed during PTP release.

Most of the stats are collected per vport, only requests skipped due to lack of free latch index are collected per Tx queue.

Statistics can be obtained using kernel ethtool since version 6.10 with:
ethtool -I -T <interface>

The output will include:
Statistics:

   tx_pkts: 15
   tx_lost: 0
   tx_err: 0

---
Changelog:
v2: Add testing information
v3: Add check for port status to resolve driver crash during statistic
read when port is down

---
  drivers/net/ethernet/intel/idpf/idpf.h        | 17 ++++++
  .../net/ethernet/intel/idpf/idpf_ethtool.c    | 56 +++++++++++++++++++
  drivers/net/ethernet/intel/idpf/idpf_ptp.c    | 11 +++-
  .../ethernet/intel/idpf/idpf_virtchnl_ptp.c   |  4 ++
  4 files changed, 87 insertions(+), 1 deletion(-)

[…]

Kind regards,

Paul