Skip to contentSkip to conversation

ethdev: per-packet Tx timestamp slot management

RFC Superseded Rajesh Kumar 3 participants 30 messages Aug 17 – Oct 6 Network drivers

lore
Share & tools
lore
#0 lore raw

cover ethdev: per-packet Tx timestamp slot management

The current DPDK ethdev time synchronization framework is architected around a single, shared hardware latch. The existing API, rte_eth_timesync_read_tx_timestamp(), assumes a serialization model where only one TX timestamp is outstanding at any given time.

This model creates severe limitations for modern high-throughput network interface cards (NICs). When multiple packets requiring precise transmit timestamps are sent concurrently, the shared latch becomes a race-condition bottleneck. It makes timestamp retrieval unreliable and drops accuracy. Furthermore, Poll Mode Drivers (PMDs) backed by hardware that supports independent, per-packet timestamping slots have no way to expose this capability to the user.

To solve this, this RFC introduces a formal slot-based lifecycle API for per-packet Tx timestamp management. The API decouples timestamp tracking from the global latch model, enabling true asynchronous, parallel hardware timestamping.

Key Components of the Proposal:
================================
1. **Slot Lifecycle Management APIs**:
- rte_eth_timesync_tx_timestamp_slot_alloc(): Allocates and locks a unique hardware slot prior to frame transmission.
- rte_eth_timesync_tx_timestamp_stamp_mbuf(): Embeds the allocated slot handle into an mbuf dynamic field, allowing the PMD to program the specific hardware descriptor during the Tx burst.
- rte_eth_timesync_read_tx_timestamp_slot(): Asynchronously polls a specific slot for its captured value, safely returning -EAGAIN if the hardware has not yet written back the timestamp.
- rte_eth_timesync_tx_timestamp_slot_release(): Recycles the hardware slot back to the PMD resource pool after successful retrieval or an application timeout.

2. **Dual-Domain Timing Mechanics**:
- Introduces struct rte_eth_timesync_dual_domain_timestamp to simultaneously capture both the adjusted PTP Hardware Clock (PHC) domain (adjusted_ns) and the raw, free-running cycles domain (cycles_ns).
- A dedicated valid_mask tracks the validity of each time domain independently, giving applications granular telemetry options.

Scope of this RFC & Open Questions for the Community:
======================================================
This RFC establishes the structural definition of the APIs and driver interfaces. Before proceeding to a full v1 patch with active PMD implementations, we would highly appreciate the community's feedback on the following design choices:

- **Mbuf Dynamic Field Layout**: Is the encapsulation of the slot handle into an mbuf dynamic field using standard dynamic registration the preferred mechanism for passing steering context to the Tx descriptor path?
- **Dual-Domain Structure**: Does tracking both the adjusted PHC and the cycle counter within rte_eth_timesync_dual_domain_timestamp cover the needs of other hardware vendors supporting concurrent domains?
- **Error States**: Is -EAGAIN an acceptable return code for non-blocking polling of incomplete timestamps, or should we consider an explicit bitmask status?

Please review the proposed design. We welcome your feedback, design suggestions, and critique.

Rajesh Kumar (1):
ethdev: add per-packet Tx timestamp slot APIs

 lib/ethdev/ethdev_driver.h |  19 ++++++
 lib/ethdev/rte_ethdev.c    | 121 +++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 108 +++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+)
Signature · 1 line
2.54.0
#1 lore raw

RFC 1/1 ethdev: add per-packet Tx timestamp slot APIs

Add ethdev public and driver-facing APIs for per-packet Tx hardware timestamp slot management.

The existing rte_eth_timesync_read_tx_timestamp() exposes a single shared latch, making it unreliable when multiple Tx timestamps are outstanding concurrently. PMDs with per-packet slot hardware cannot be exploited through this interface.

Introduce a slot lifecycle API:
- rte_eth_timesync_tx_timestamp_slot_alloc(): reserve a hardware slot before transmit
- rte_eth_timesync_tx_timestamp_stamp_mbuf(): embed slot handle into mbuf dynfield for per-packet NIC steering
- rte_eth_timesync_read_tx_timestamp_slot(): poll slot for a captured timestamp; returns -EAGAIN if not ready
- rte_eth_timesync_tx_timestamp_slot_release(): return slot to PMD after readback or timeout

Introduce rte_eth_timesync_dual_domain_timestamp to carry both the adjusted PHC time (adjusted_ns) and free-running cycles-domain time (cycles_ns), each with an individual validity bit in valid_mask.

---
 lib/ethdev/ethdev_driver.h |  19 ++++++
 lib/ethdev/rte_ethdev.c    | 121 +++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 108 +++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+)
lib/ethdev/ethdev_driver.h +19 -0
index 0f336f9567..61dadcea49 100644
@@ -795,6 +795,19 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint16_t tx_queue_id, uint32_t *slot_id);
+
+/** @internal Read TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1574,12 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Allocate a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+	/** Read a TX timestamp using a slot handle */
+	eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+	/** Release a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +121 -0

127 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +108 -0

114 lines not on this page · raw message

Signature · 1 line
2.54.0
#2 lore raw

Re: [RFC 1/1] ethdev: add per-packet Tx timestamp slot APIs

________________________________
From: Rajesh Kumar <[email protected]>
Sent: Tuesday, August 18, 2026 12:54 AM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Richardson, Bruce <[email protected]>; [email protected] <[email protected]>; Kumar, Rajesh3 <[email protected]>
Subject: [RFC 1/1] ethdev: add per-packet Tx timestamp slot APIs

Add ethdev public and driver-facing APIs for per-packet Tx hardware timestamp slot management.

The existing rte_eth_timesync_read_tx_timestamp() exposes a single shared latch, making it unreliable when multiple Tx timestamps are outstanding concurrently. PMDs with per-packet slot hardware cannot be exploited through this interface.

Introduce a slot lifecycle API:
- rte_eth_timesync_tx_timestamp_slot_alloc(): reserve a hardware slot before transmit
- rte_eth_timesync_tx_timestamp_stamp_mbuf(): embed slot handle into mbuf dynfield for per-packet NIC steering
- rte_eth_timesync_read_tx_timestamp_slot(): poll slot for a captured timestamp; returns -EAGAIN if not ready
- rte_eth_timesync_tx_timestamp_slot_release(): return slot to PMD after readback or timeout

Introduce rte_eth_timesync_dual_domain_timestamp to carry both the adjusted PHC time (adjusted_ns) and free-running cycles-domain time (cycles_ns), each with an individual validity bit in valid_mask.

---
 lib/ethdev/ethdev_driver.h |  19 ++++++
 lib/ethdev/rte_ethdev.c    | 121 +++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 108 +++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+)
lib/ethdev/ethdev_driver.h +19 -0
index 0f336f9567..61dadcea49 100644
@@ -795,6 +795,19 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
                                                 struct timespec *timestamp);
 
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+               uint16_t tx_queue_id, uint32_t *slot_id);
+
+/** @internal Read TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+               uint32_t slot_id,
+               struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+               uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1574,12 @@ struct eth_dev_ops {
         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
         /** Read the IEEE1588/802.1AS Tx timestamp */
         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+       /** Allocate a TX timestamp slot handle */
+       eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+       /** Read a TX timestamp using a slot handle */
+       eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+       /** Release a TX timestamp slot handle */
+       eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
         /** Adjust the device clock */
         eth_timesync_adjust_time   timesync_adjust_time;
         /** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +121 -0

127 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +63 -0

67 lines not on this page · raw message

How is the egress port information conveyed?
The timestamp slot is a resource of the physical egress port.

+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Release a previously allocated TX timestamp slot handle.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param slot_id
+ * Slot handle to release.
+ *
+ * @return

+ *   - 0: Success.
+ *   - -ENODEV: The port ID is invalid.
+ *   - -EIO: if device is removed.
+ *   - -ENOTSUP: The function is not supported by the Ethernet driver.
+ *   - -EINVAL: Invalid parameters.

+ */
+__rte_experimental
+int rte_eth_timesync_tx_timestamp_slot_release(uint16_t port_id,
+ uint32_t slot_id);
+
+/** Mbuf dynfield name for the TX timestamp slot handle. */ +#define RTE_ETH_TIMESYNC_TX_SLOT_DYNFIELD_NAME "rte_eth_timesync_tx_slot" +
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Stamp an mbuf with a TX timestamp slot handle so the TX path steers the
+ * NIC to capture the timestamp in the correct per-packet slot.
+ *
+ * Must be called after rte_eth_timesync_tx_timestamp_slot_alloc() and before
+ * rte_eth_tx_burst(). Safe for concurrent callers — slot is stored per-mbuf.
+ *

+ * @param port_id  The port identifier (unused; reserved for future PMD use).
+ * @param slot_id  Slot handle from rte_eth_timesync_tx_timestamp_slot_alloc().
+ * @param m        Mbuf to stamp.

+ * @return 0 on success, -ENOTSUP if dynfield registration failed.
+ */
+__rte_experimental
+int rte_eth_timesync_tx_timestamp_stamp_mbuf(uint16_t port_id,
+ uint32_t slot_id, struct rte_mbuf *m);
+
/**
* Adjust the timesync clock on an Ethernet device.
*
--
2.54.0

#3 lore raw
In reply to Rajesh Kumar
Quoted 13 lines · On Tue, 18 Aug 2026 00:54:14 +0530 Rajesh Kumar <[email protected]> wrote:

The current DPDK ethdev time synchronization framework is architected around a single, shared hardware latch. The existing API, rte_eth_timesync_read_tx_timestamp(), assumes a serialization model where only one TX timestamp is outstanding at any given time.

This model creates severe limitations for modern high-throughput network interface cards (NICs). When multiple packets requiring precise transmit timestamps are sent concurrently, the shared latch becomes a race-condition bottleneck. It makes timestamp retrieval unreliable and drops accuracy. Furthermore, Poll Mode Drivers (PMDs) backed by hardware that supports independent, per-packet timestamping slots have no way to expose this capability to the user.

Quoted 4 lines

To solve this, this RFC introduces a formal slot-based lifecycle API for per-packet Tx timestamp management. The API decouples timestamp tracking from the global latch model, enabling true asynchronous, parallel hardware timestamping.

Lots of reasonable AI feedback to the design.

Review of the RFC. Design issues first since that's what they're asking for, then code defects.

Design

No capability discovery or exhaustion semantics. Nothing reports how many slots exist, whether they're per-port or per-queue, and slot_alloc() doesn't document what it returns when slots run out (-ENOSPC? -EAGAIN?). That's the first thing an application hits. Needs a rte_eth_dev_info field or query, and a defined out-of-slots errno. Queue asymmetry: alloc() takes tx_queue_id but read() and release() don't. Either slot_id is port-global (then why does alloc need the queue?) or it's per-queue (then read/release are ambiguous). Pick one and document it. Also tx_queue_id is never validated against nb_tx_queues in the ethdev layer.
Interaction with the existing mechanism is undefined. Does the app still set RTE_MBUF_F_TX_IEEE1588_TMST? Can the legacy latch API and the slot API coexist on one port? PMDs today key tx timestamping off that flag; the RFC needs to say what supersedes what.
Fast-path cost contradicts the stated motivation. The cover letter argues high-throughput concurrent timestamping, but the lifecycle is three dev_ops indirect calls plus a dynfield write per packet, all through the slow path. Fine for PTP rates; if the claim is more than that, alloc/release want burst variants or the intended rate should be stated. cycles_ns is self-contradictory: is it raw counter cycles or nanoseconds from the free-running clock? If cycles, drop the _ns and expose the frequency; if ns, call it raw_ns or free_ns. Also this struct switches to int64 ns while every other timesync call uses struct timespec; probably the right move but justify it in the cover letter. PMDs can't consume the dynfield as written. The offset and flag are static in rte_ethdev.c and not exposed to drivers. A PMD has to re-lookup by name, and the dynflag name only exists as a string concat inside the .c file, so drivers would hardcode "..._flag". Define the flag name macro in the header and provide a lookup helper, following the RTE_MBUF_DYNFIELD_TIMESTAMP_NAME pattern.
Naming: rte_eth_timesync_tx_timestamp_stamp_mbuf stutters. ..._tx_slot_set_mbuf or similar.

Defects

Silent dynflag failure in rte_eth_timesync_tx_slot_dynfield_register(). If both rte_mbuf_dynflag_register() and the lookup fail, rte_eth_timesync_tx_slot_dynflag stays 0, the function returns 0, and stamp_mbuf() ORs 0 into ol_flags and reports success. The PMD never sees the request. Must return error. Worse, the early return on offset >= 0 means the flag is never retried on subsequent calls, so one transient failure is permanent. Likely doesn't compile as posted: the diff adds no includes, but uses struct rte_mbuf_dynfield, rte_mbuf_dynflag_register() (needs rte_mbuf_dyn.h) and alignof (needs stdalign.h pre-C23). Check whether rte_ethdev.c already pulls those in; I don't believe it does.
stamp_mbuf() takes port_id and ignores it, documented as "reserved for future PMD use". Either validate it or drop it; a parameter whose semantics arrive later is an API trap. Dropping it also removes the false implication that the call is port-scoped.

Nits

stamp_mbuf() doxygen deviates from the file's param style, omits the -EINVAL return the code actually produces, and contains an em-dash. The dual_domain_timestamp struct fields lack doxygen comments. v1 needs rel_notes and prog_guide (ptp section) updates; RFC is fine without.

#4 lore raw
In reply to Rajesh Kumar

________________________________
From: Rajesh Kumar <[email protected]>
Sent: Tuesday, August 18, 2026 12:54 AM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Richardson, Bruce <[email protected]>; [email protected] <[email protected]>; Kumar, Rajesh3 <[email protected]>
Subject: [RFC 0/1] ethdev: per-packet Tx timestamp slot management

The current DPDK ethdev time synchronization framework is architected around a single, shared hardware latch. The existing API, rte_eth_timesync_read_tx_timestamp(), assumes a serialization model where only one TX timestamp is outstanding at any given time.

This model creates severe limitations for modern high-throughput network interface cards (NICs). When multiple packets requiring precise transmit timestamps are sent concurrently, the shared latch becomes a race-condition bottleneck. It makes timestamp retrieval unreliable and drops accuracy. Furthermore, Poll Mode Drivers (PMDs) backed by hardware that supports independent, per-packet timestamping slots have no way to expose this capability to the user.

To solve this, this RFC introduces a formal slot-based lifecycle API for per-packet Tx timestamp management. The API decouples timestamp tracking from the global latch model, enabling true asynchronous, parallel hardware timestamping.

Key Components of the Proposal:
================================
1. **Slot Lifecycle Management APIs**:
- rte_eth_timesync_tx_timestamp_slot_alloc(): Allocates and locks a unique hardware slot prior to frame transmission.
- rte_eth_timesync_tx_timestamp_stamp_mbuf(): Embeds the allocated slot handle into an mbuf dynamic field, allowing the PMD to program the specific hardware descriptor during the Tx burst.
- rte_eth_timesync_read_tx_timestamp_slot(): Asynchronously polls a specific slot for its captured value, safely returning -EAGAIN if the hardware has not yet written back the timestamp.
- rte_eth_timesync_tx_timestamp_slot_release(): Recycles the hardware slot back to the PMD resource pool after successful retrieval or an application timeout.

2. **Dual-Domain Timing Mechanics**:
- Introduces struct rte_eth_timesync_dual_domain_timestamp to simultaneously capture both the adjusted PTP Hardware Clock (PHC) domain (adjusted_ns) and the raw, free-running cycles domain (cycles_ns).
- A dedicated valid_mask tracks the validity of each time domain independently, giving applications granular telemetry options.

Scope of this RFC & Open Questions for the Community:
======================================================
This RFC establishes the structural definition of the APIs and driver interfaces. Before proceeding to a full v1 patch with active PMD implementations, we would highly appreciate the community's feedback on the following design choices:

- **Mbuf Dynamic Field Layout**: Is the encapsulation of the slot handle into an mbuf dynamic field using standard dynamic registration the preferred mechanism for passing steering context to the Tx descriptor path?

rte_mbuf structure has "timesync" field, which can be used for the slot. This way mbuf dynamic field use can be avoided.

- **Dual-Domain Structure**: Does tracking both the adjusted PHC and the cycle counter within rte_eth_timesync_dual_domain_timestamp cover the needs of other hardware vendors supporting concurrent domains?
- **Error States**: Is -EAGAIN an acceptable return code for non-blocking polling of incomplete timestamps, or should we consider an explicit bitmask status?

Please review the proposed design. We welcome your feedback, design suggestions, and critique.

Rajesh Kumar (1):
ethdev: add per-packet Tx timestamp slot APIs

 lib/ethdev/ethdev_driver.h |  19 ++++++
 lib/ethdev/rte_ethdev.c    | 121 +++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 108 +++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+)

--
2.54.0

#5 lore raw
Quoted 2 lines · S V

rte_mbuf structure has "timesync" field, which can be used for the slot. This way mbuf dynamic field use can be avoided.

"timesync" in rte_mbuf is already an established RX-side metadata field and not a generic TX slot carrier. As it is used as RX-side timestamp metadata, not as a generic TX slot ID. If the same field suddenly meant “TX slot handle” for one PMD and “RX queue/timestamp tag” for another, the ABI would become ambiguous and driver-specific, while the dynamic-field approach keeps the per-packet slot metadata explicit and portable. For that reason, we prefer the dynamic-field design for this feature.

#6 lore raw

v2 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx.
* Registration and process-local disabling of slot metadata.
* A compatibility alias for the mbuf stamping helper.
* Programmer-guide and NIC feature documentation.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register. This RFC adds the ethdev and PMD interfaces but does not add a hardware-specific PMD implementation.

The following areas would benefit from review:

* Is the capability model sufficient for devices with different slot allocation or completion mechanisms?
* Is an mbuf dynamic field and dynflag the appropriate way to pass the slot handle into the Tx datapath?
* Is -EAGAIN the appropriate result while a slot timestamp is pending?
* Should the adjusted and raw timestamp domains use nanoseconds in the public structure, or should one domain expose hardware cycles instead?

Rajesh Kumar (1):
ethdev: add Tx timestamp slot management APIs

 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 216 +++++++++++++++++++
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 152 +++++++++++++
 lib/ethdev/rte_ethdev.h                   | 251 ++++++++++++++++++++++
 6 files changed, 657 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#7 lore raw

RFC PATCH v2 1/1 ethdev: add Tx timestamp slot management APIs

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Keep the legacy Tx timestamp API for shared-register hardware and provide a compatibility alias for the mbuf stamping helper.

Document the timestamp capability model, slot lifecycle, and application workflow.

---
 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 216 +++++++++++++++++++
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 152 +++++++++++++
 lib/ethdev/rte_ethdev.h                   | 251 ++++++++++++++++++++++
 6 files changed, 657 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
doc/guides/nics/features.rst +12 -4
index 0b0c69e7cd..171e2aabba 100644
@@ -692,14 +692,22 @@ Timesync
 
 Supports IEEE1588/802.1AS timestamping.
 
-* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``
+* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``,
   ``timesync_read_rx_timestamp``, ``timesync_read_tx_timestamp``,
+  ``timesync_tx_ts_get_capabilities``, ``timesync_tx_timestamp_slot_alloc``,
+  ``timesync_read_tx_timestamp_slot``, ``timesync_tx_timestamp_slot_release``,
   ``timesync_adjust_time``, ``timesync_adjust_freq``,
   ``timesync_read_time``, ``timesync_write_time``.
 * **[related]    API**: ``rte_eth_timesync_enable()``, ``rte_eth_timesync_disable()``,
-  ``rte_eth_timesync_read_rx_timestamp()``,
-  ``rte_eth_timesync_read_tx_timestamp``, ``rte_eth_timesync_adjust_time()``,
-  ``rte_eth_timesync_adjust_freq()``,
+  ``rte_eth_timesync_read_rx_timestamp()``, ``rte_eth_timesync_read_tx_timestamp()``,
+  ``rte_eth_timesync_tx_timestamp_slot_get_capabilities()``,
+  ``rte_eth_timesync_tx_timestamp_slot_alloc()``,
+  ``rte_eth_timesync_read_tx_timestamp_slot()``,
+  ``rte_eth_timesync_tx_timestamp_slot_release()``,
+  ``rte_eth_timesync_tx_slot_dynfield_register()``,
+  ``rte_eth_timesync_tx_slot_dynfield_unregister()``,
+  ``rte_eth_timesync_tx_slot_set_mbuf()``,
+  ``rte_eth_timesync_adjust_time()``, ``rte_eth_timesync_adjust_freq()``,
   ``rte_eth_timesync_read_time()``, ``rte_eth_timesync_write_time()``.
 
 
doc/guides/prog_guide/ethdev/index.rst +1 -0
index 392ced0a2e..bc21f28091 100644
@@ -13,3 +13,4 @@ Ethernet Device Library
     traffic_metering_and_policing
     traffic_management
     qos_framework
+    timesync
doc/guides/prog_guide/ethdev/timesync.rst new file +216 -0

216 lines not on this page · raw message

lib/ethdev/ethdev_driver.h +25 -0
index 0f336f9567..9d981995ea 100644
@@ -795,6 +795,23 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Query TX timestamp hardware capability (single-register vs per-packet slot bank). */
+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,
+		struct rte_eth_timesync_tx_ts_caps *caps);
+
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint32_t *slot_id);
+
+/** @internal Read a dual-domain TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1578,14 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Allocate a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+	/** Query TX timestamp hardware capability (single-reg vs per-packet) */
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;
+	/** Read a TX timestamp using a slot handle */
+	eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+	/** Release a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +152 -0

164 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +251 -0

263 lines not on this page · raw message

Signature · 1 line
2.55.0
#8 lore raw

Re: [RFC PATCH v2 0/1] ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar
Quoted 9 lines · On Thu, 27 Aug 2026 18:04:33 +0530 Rajesh Kumar <[email protected]> wrote:

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

Later review with AI assistance also reached conclusion:

Overall, this adds seven new experimental functions plus an exported array to solve one problem. Before going further, cut it down:

- drop rte_eth_timesync_tx_slot_dynfield_unregister(), it does nothing
- drop rte_eth_timesync_tx_slot_dynfield_register(), do it inside rte_eth_timesync_enable() and fail enable if there is no dynfield space
- drop rte_eth_timesync_tx_timestamp_stamp_mbuf(), export the offset and flag the same way rte_mbuf_dyn_rx_timestamp does and let the app write the field
- drop the rte_eth_timesync_tx_slot_infos[] array and the static inline, PMDs get the two globals from ethdev_driver.h

That leaves caps, alloc, read, release.

For the legacy API: rather than a doc comment pointing at the new one, have ethdev synthesize SINGLE_REG / max_slots=1 from timesync_read_tx_timestamp for PMDs without slot ops, convert testpmd ieee1588fwd and examples/ptpclient in this series, and add a deprecation notice with a removal release. Otherwise we end up carrying both forever.

#9 lore raw

v2 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx.
* Registration and process-local disabling of slot metadata.
* A compatibility alias for the mbuf stamping helper.
* Programmer-guide and NIC feature documentation.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register. This RFC adds the ethdev and PMD interfaces but does not add a hardware-specific PMD implementation.

The following areas would benefit from review:

* Is the capability model sufficient for devices with different slot allocation or completion mechanisms?
* Is an mbuf dynamic field and dynflag the appropriate way to pass the slot handle into the Tx datapath?
* Is -EAGAIN the appropriate result while a slot timestamp is pending?
* Should the adjusted and raw timestamp domains use nanoseconds in the public structure, or should one domain expose hardware cycles instead?

Rajesh Kumar (1):
ethdev: add Tx timestamp slot management APIs

 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 217 +++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 158 ++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 242 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#10 lore raw

RFC PATCH v3 1/1 ethdev: add Tx timestamp slot management APIs

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Keep the legacy Tx timestamp API for shared-register hardware and provide a compatibility alias for the mbuf stamping helper.

Document the timestamp capability model, slot lifecycle, and application workflow.

---
 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 217 +++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 158 ++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 242 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
doc/guides/nics/features.rst +12 -4
index 0b0c69e7cd..040a996156 100644
@@ -692,14 +692,22 @@ Timesync
 
 Supports IEEE1588/802.1AS timestamping.
 
-* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``
+* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``,
   ``timesync_read_rx_timestamp``, ``timesync_read_tx_timestamp``,
+  ``timesync_tx_ts_get_capabilities``, ``timesync_tx_timestamp_slot_alloc``,
+  ``timesync_read_tx_timestamp_slot``, ``timesync_tx_timestamp_slot_release``,
   ``timesync_adjust_time``, ``timesync_adjust_freq``,
   ``timesync_read_time``, ``timesync_write_time``.
 * **[related]    API**: ``rte_eth_timesync_enable()``, ``rte_eth_timesync_disable()``,
-  ``rte_eth_timesync_read_rx_timestamp()``,
-  ``rte_eth_timesync_read_tx_timestamp``, ``rte_eth_timesync_adjust_time()``,
-  ``rte_eth_timesync_adjust_freq()``,
+  ``rte_eth_timesync_read_rx_timestamp()``, ``rte_eth_timesync_read_tx_timestamp()``,
+  ``rte_eth_timesync_tx_timestamp_slot_get_capabilities()``,
+  ``rte_eth_timesync_tx_timestamp_slot_alloc()``,
+  ``rte_eth_timesync_read_tx_timestamp_slot()``,
+  ``rte_eth_timesync_tx_timestamp_slot_release()``,
+  ``rte_eth_timesync_tx_slot_dynfield_register()``,
+  ``rte_eth_timesync_tx_slot_dynfield_unregister()``,
+  ``rte_eth_timesync_tx_timestamp_stamp_mbuf()``,
+  ``rte_eth_timesync_adjust_time()``, ``rte_eth_timesync_adjust_freq()``,
   ``rte_eth_timesync_read_time()``, ``rte_eth_timesync_write_time()``.
 
 
doc/guides/prog_guide/ethdev/index.rst +1 -0
index 392ced0a2e..bc21f28091 100644
@@ -13,3 +13,4 @@ Ethernet Device Library
     traffic_metering_and_policing
     traffic_management
     qos_framework
+    timesync
doc/guides/prog_guide/ethdev/timesync.rst new file +217 -0

217 lines not on this page · raw message

doc/guides/rel_notes/release_26_11.rst +7 -0
index c8cc86295d..122d44afeb 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **ethdev: Added experimental per-packet Tx timestamp slot APIs.**
+
+  Added slot-based TX timestamp allocation, mbuf stamping, and per-packet
+  timestamp reads for timesync-capable Ethernet devices. The new APIs support
+  both shared-register and slot-bank usage models through the
+  ``rte_eth_timesync_tx_timestamp_slot_*`` interface family.
+
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +25 -0
index 0f336f9567..9d981995ea 100644
@@ -795,6 +795,23 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Query TX timestamp hardware capability (single-register vs per-packet slot bank). */
+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,
+		struct rte_eth_timesync_tx_ts_caps *caps);
+
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint32_t *slot_id);
+
+/** @internal Read a dual-domain TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1578,14 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Allocate a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+	/** Query TX timestamp hardware capability (single-reg vs per-packet) */
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;
+	/** Read a TX timestamp using a slot handle */
+	eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+	/** Release a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +158 -0

170 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +242 -0

254 lines not on this page · raw message

Signature · 1 line
2.55.0
#11 lore raw

v3 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx.
* Registration and process-local disabling of slot metadata.
* A compatibility alias for the mbuf stamping helper.
* Programmer-guide and NIC feature documentation.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register. This RFC adds the ethdev and PMD interfaces but does not add a hardware-specific PMD implementation.

The following areas would benefit from review:

* Is the capability model sufficient for devices with different slot allocation or completion mechanisms?
* Is an mbuf dynamic field and dynflag the appropriate way to pass the slot handle into the Tx datapath?
* Is -EAGAIN the appropriate result while a slot timestamp is pending?
* Should the adjusted and raw timestamp domains use nanoseconds in the public structure, or should one domain expose hardware cycles instead?

Rajesh Kumar (1):
ethdev: add Tx timestamp slot management APIs

 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 217 +++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 158 ++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 242 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#12 lore raw

v3 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx.
* Registration and process-local disabling of slot metadata.
* A compatibility alias for the mbuf stamping helper.
* Programmer-guide and NIC feature documentation.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register. This RFC adds the ethdev and PMD interfaces but does not add a hardware-specific PMD implementation.

The following areas would benefit from review:

* Is the capability model sufficient for devices with different slot allocation or completion mechanisms?
* Is an mbuf dynamic field and dynflag the appropriate way to pass the slot handle into the Tx datapath?
* Is -EAGAIN the appropriate result while a slot timestamp is pending?
* Should the adjusted and raw timestamp domains use nanoseconds in the public structure, or should one domain expose hardware cycles instead?

Rajesh Kumar (1):
ethdev: add Tx timestamp slot management APIs

 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 217 +++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 158 ++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 242 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#13 lore raw

RFC PATCH v3 1/1 ethdev: add Tx timestamp slot management APIs

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Keep the legacy Tx timestamp API for shared-register hardware and provide a compatibility alias for the mbuf stamping helper.

Document the timestamp capability model, slot lifecycle, and application workflow.

---
 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 217 +++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 +++
 lib/ethdev/rte_ethdev.c                   | 158 ++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 242 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
doc/guides/nics/features.rst +12 -4
index 0b0c69e7cd..040a996156 100644
@@ -692,14 +692,22 @@ Timesync
 
 Supports IEEE1588/802.1AS timestamping.
 
-* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``
+* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``,
   ``timesync_read_rx_timestamp``, ``timesync_read_tx_timestamp``,
+  ``timesync_tx_ts_get_capabilities``, ``timesync_tx_timestamp_slot_alloc``,
+  ``timesync_read_tx_timestamp_slot``, ``timesync_tx_timestamp_slot_release``,
   ``timesync_adjust_time``, ``timesync_adjust_freq``,
   ``timesync_read_time``, ``timesync_write_time``.
 * **[related]    API**: ``rte_eth_timesync_enable()``, ``rte_eth_timesync_disable()``,
-  ``rte_eth_timesync_read_rx_timestamp()``,
-  ``rte_eth_timesync_read_tx_timestamp``, ``rte_eth_timesync_adjust_time()``,
-  ``rte_eth_timesync_adjust_freq()``,
+  ``rte_eth_timesync_read_rx_timestamp()``, ``rte_eth_timesync_read_tx_timestamp()``,
+  ``rte_eth_timesync_tx_timestamp_slot_get_capabilities()``,
+  ``rte_eth_timesync_tx_timestamp_slot_alloc()``,
+  ``rte_eth_timesync_read_tx_timestamp_slot()``,
+  ``rte_eth_timesync_tx_timestamp_slot_release()``,
+  ``rte_eth_timesync_tx_slot_dynfield_register()``,
+  ``rte_eth_timesync_tx_slot_dynfield_unregister()``,
+  ``rte_eth_timesync_tx_timestamp_stamp_mbuf()``,
+  ``rte_eth_timesync_adjust_time()``, ``rte_eth_timesync_adjust_freq()``,
   ``rte_eth_timesync_read_time()``, ``rte_eth_timesync_write_time()``.
 
 
doc/guides/prog_guide/ethdev/index.rst +1 -0
index 392ced0a2e..bc21f28091 100644
@@ -13,3 +13,4 @@ Ethernet Device Library
     traffic_metering_and_policing
     traffic_management
     qos_framework
+    timesync
doc/guides/prog_guide/ethdev/timesync.rst new file +217 -0

217 lines not on this page · raw message

doc/guides/rel_notes/release_26_11.rst +7 -0
index c8cc86295d..122d44afeb 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **ethdev: Added experimental per-packet Tx timestamp slot APIs.**
+
+  Added slot-based TX timestamp allocation, mbuf stamping, and per-packet
+  timestamp reads for timesync-capable Ethernet devices. The new APIs support
+  both shared-register and slot-bank usage models through the
+  ``rte_eth_timesync_tx_timestamp_slot_*`` interface family.
+
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +25 -0
index 0f336f9567..9d981995ea 100644
@@ -795,6 +795,23 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Query TX timestamp hardware capability (single-register vs per-packet slot bank). */
+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,
+		struct rte_eth_timesync_tx_ts_caps *caps);
+
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint32_t *slot_id);
+
+/** @internal Read a dual-domain TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1578,14 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Allocate a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+	/** Query TX timestamp hardware capability (single-reg vs per-packet) */
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;
+	/** Read a TX timestamp using a slot handle */
+	eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+	/** Release a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +158 -0

170 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +242 -0

254 lines not on this page · raw message

Signature · 1 line
2.55.0
#14 lore raw

Re: [RFC PATCH v3 1/1] ethdev: add Tx timestamp slot management APIs

Quoted 14 lines · On Thu, 27 Aug 2026 17:51:59 +0530 Rajesh Kumar <[email protected]> wrote:

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Quoted 8 lines

Keep the legacy Tx timestamp API for shared-register hardware and provide a compatibility alias for the mbuf stamping helper.

Document the timestamp capability model, slot lifecycle, and application workflow.

---

Lots of feedback for AI review that needs addressing (Claude Fable). Also a feature like this needs some form of test coverage. Perhaps mocking up something in null PMD or related.

Review of [RFC PATCH v3 1/1] ethdev: add Tx timestamp slot management APIs

Applied cleanly to current main and read post-apply. No build performed (meson not available here); nothing in the diff looks like it would fail to compile.

Errors:

1. Documentation and Doxygen claim rte_eth_timesync_enable() registers the dynfield/dynflag automatically. It does not. The patch does not touch rte_eth_timesync_enable(); post-apply it still just calls the PMD op. So the .. note:: in timesync.rst ("registers the dynamic field automatically ... Call ... explicitly only if creating mempools before enabling timesync") and the same statement in the header Doxygen for rte_eth_timesync_tx_slot_dynfield_register() are false. An application that follows the doc and relies on timesync_enable will get -ENOTSUP from stamp_mbuf (or worse, a late registration that fails after pools are created). Either add the call in rte_eth_timesync_enable() or drop the claim; given the "must register before pool create" constraint, dropping the claim and making the explicit call mandatory is the safer contract.

2. Commit message says "provide a compatibility alias for the mbuf stamping helper". No such alias exists in the diff. Either the alias was dropped between v2 and v3 and the message is stale, or it is missing. Fix one or the other.

3. Dead macros referencing a nonexistent structure:
RTE_ETH_TIMESYNC_TX_TIMESTAMP_SLOT_INFO_MAX_VALID RTE_ETH_TIMESYNC_TX_TIMESTAMP_SLOT_INFO_FREE_VALID
Doxygen says they are valid bits for rte_eth_timesync_tx_timestamp_slot_info.max_slots / .free_slots, but that struct is not defined anywhere. Leftover from an earlier revision; remove them.

4. The PMD contract is incomplete: the datapath needs the dynfield offset and dynflag bit, but they are file-static in rte_ethdev.c with no accessor in ethdev_driver.h. A PMD is forced to do its own rte_mbuf_dynfield_lookup()/dynflag_lookup() by name, which then cannot observe rte_eth_timesync_tx_slot_dynfield_unregister() resetting the library-side cache. So the documented behaviour that after unregister "PMD Tx datapaths fall back to port-level legacy mode" cannot actually happen: the PMD keeps testing the dynflag it looked up, and mbufs stamped before unregister still carry it. Either export an internal accessor (offset + flag) in ethdev_driver.h that PMDs must use, or drop the unregister API and its fallback claim. As written, the unregister function only changes library-local state and cannot deliver what its Doxygen promises.

Warnings:

5. rte_ethdev.h Doxygen for rte_eth_timesync_tx_slot_dynfield_unregister refers to "the port-level ptp_tx_index". That is an Intel driver internal, not an ethdev concept; a generic header should not reference it.

6. rte_eth_timesync_tx_timestamp_stamp_mbuf() calls rte_eth_timesync_tx_slot_dynfield_register() on every invocation. Post-registration this is just an int compare, but it also means the first stamp_mbuf call can silently register the dynfield after pools exist, which the register() Doxygen says may fail. It is also inconsistent with the "-ENOTSUP after unregister" contract: after unregister, stamp_mbuf will simply re-register (lookup succeeds) and go on working. Do the offset check inline and return -ENOTSUP if the offset is < 0 rather than re-registering.

7. Slot handles are uint32_t, but rte_eth_timesync_tx_ts_caps has no way to express the free-slot count, and slot_release() has no documented behaviour for double-release or release of a slot whose timestamp was never read. For an RFC that is acceptable, but the PMD contract section in timesync.rst should say what a PMD must do for an invalid or already-free slot_id (-EINVAL is the obvious answer, and the ethdev wrapper could enforce slot_id < max_slots if caps are cached).

8. Release notes and header call these experimental, but the new eth_dev_ops members are inserted in the middle of struct eth_dev_ops rather than at the end. eth_dev_ops is internal so this is not an ABI issue, but the ordering in the struct (alloc, get_capabilities, read_slot, release) does not match the typedef order or the order in features.rst (get_capabilities, alloc, read_slot, release). Make them consistent.

9. features.rst adds the ops and API names, but there is no PMD implementing them in this series and no testpmd hook or unit test exercising the new API. Per contributing guidelines a new ethdev API needs at least one driver implementation and a testpmd hook before it can be merged out of RFC.

Info:

10. timesync.rst: the "Clock Management & Control", "Rx Timestamp Extraction Workflow" and "PMD Implementation Requirements" sections use bullet lists with bold term + description; RST definition lists would render better. Several lines in the .rst are well over 100 columns; wrap at sentence boundaries.

11. In rte_eth_timesync_tx_slot_dynfield_register(), the inner braced block for flag_bit is unusual style in DPDK; declare flag_bit at function top or at point of use without the block.

12. Blank line separating the slot_release function from the "Internal process-local cache" comment is missing; there is a double blank line before stamp_mbuf.

#15 lore raw

v4 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx, with a helper that stamps a slot handle onto an mbuf.
* Registration and process-local reset of the cached dynfield state.
* An ice PMD implementation using the 64 per-port PHY timestamp slots.
* A testpmd command to report the slot capabilities of a port.
* Programmer-guide and NIC feature documentation.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register.

Changes since v3:

* Added an ice PMD implementation of the new slot ops. The ice PHY exposes 64 Tx timestamp slots per port, which are now tracked in an atomic per-adapter bitmap instead of the single static slot the driver used before. On E822 the 64 quad slots are split evenly between the PFs sharing the quad so allocations never overlap.
* The ice Tx context descriptor now takes the timestamp index from the mbuf dynamic field when the packet carries the slot dynflag, and falls back to the legacy static index otherwise.
* The ice legacy single-slot read path now uses ptp_tx_index instead of a hardcoded slot 0, and clears the PHY timestamp on E810 after a read or a timeout so a stale entry cannot block later requests.
* Added a testpmd command, "show port <port_id> tx_timestamp_caps", that reports the slot capabilities of a port and performs an allocate and release round-trip to exercise the API.

Comments and suggestions on the interface and the ice implementation are welcome.

Rajesh Kumar (3):
ethdev: add Tx timestamp slot management APIs net/ice: support per-packet Tx timestamp slots app/testpmd: add Tx timestamp capabilities command

 app/test-pmd/cmdline.c                    |  79 ++++++
 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 223 +++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 drivers/net/intel/ice/ice_ethdev.c        | 210 +++++++++++++++-
 drivers/net/intel/ice/ice_ethdev.h        |   2 +
 drivers/net/intel/ice/ice_rxtx.c          |  11 +-
 lib/ethdev/ethdev_driver.h                |  25 ++
 lib/ethdev/rte_ethdev.c                   | 202 ++++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 278 ++++++++++++++++++++++
 11 files changed, 1047 insertions(+), 7 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#16 lore raw

RFC PATCH v4 1/3 ethdev: add Tx timestamp slot management APIs

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Keep the legacy Tx timestamp API for shared-register hardware.

Document the timestamp capability model, slot lifecycle, and application workflow.

---
 doc/guides/nics/features.rst              |  16 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 223 +++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 lib/ethdev/ethdev_driver.h                |  25 ++
 lib/ethdev/rte_ethdev.c                   | 202 ++++++++++++++++
 lib/ethdev/rte_ethdev.h                   | 278 ++++++++++++++++++++++
 7 files changed, 748 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
doc/guides/nics/features.rst +12 -4
index 0b0c69e7cd..040a996156 100644
@@ -692,14 +692,22 @@ Timesync
 
 Supports IEEE1588/802.1AS timestamping.
 
-* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``
+* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``,
   ``timesync_read_rx_timestamp``, ``timesync_read_tx_timestamp``,
+  ``timesync_tx_ts_get_capabilities``, ``timesync_tx_timestamp_slot_alloc``,
+  ``timesync_read_tx_timestamp_slot``, ``timesync_tx_timestamp_slot_release``,
   ``timesync_adjust_time``, ``timesync_adjust_freq``,
   ``timesync_read_time``, ``timesync_write_time``.
 * **[related]    API**: ``rte_eth_timesync_enable()``, ``rte_eth_timesync_disable()``,
-  ``rte_eth_timesync_read_rx_timestamp()``,
-  ``rte_eth_timesync_read_tx_timestamp``, ``rte_eth_timesync_adjust_time()``,
-  ``rte_eth_timesync_adjust_freq()``,
+  ``rte_eth_timesync_read_rx_timestamp()``, ``rte_eth_timesync_read_tx_timestamp()``,
+  ``rte_eth_timesync_tx_timestamp_slot_get_capabilities()``,
+  ``rte_eth_timesync_tx_timestamp_slot_alloc()``,
+  ``rte_eth_timesync_read_tx_timestamp_slot()``,
+  ``rte_eth_timesync_tx_timestamp_slot_release()``,
+  ``rte_eth_timesync_tx_slot_dynfield_register()``,
+  ``rte_eth_timesync_tx_slot_dynfield_unregister()``,
+  ``rte_eth_timesync_tx_timestamp_stamp_mbuf()``,
+  ``rte_eth_timesync_adjust_time()``, ``rte_eth_timesync_adjust_freq()``,
   ``rte_eth_timesync_read_time()``, ``rte_eth_timesync_write_time()``.
 
 
doc/guides/prog_guide/ethdev/index.rst +1 -0
index 392ced0a2e..bc21f28091 100644
@@ -13,3 +13,4 @@ Ethernet Device Library
     traffic_metering_and_policing
     traffic_management
     qos_framework
+    timesync
doc/guides/prog_guide/ethdev/timesync.rst new file +223 -0

223 lines not on this page · raw message

doc/guides/rel_notes/release_26_11.rst +7 -0
index c8cc86295d..122d44afeb 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **ethdev: Added experimental per-packet Tx timestamp slot APIs.**
+
+  Added slot-based TX timestamp allocation, mbuf stamping, and per-packet
+  timestamp reads for timesync-capable Ethernet devices. The new APIs support
+  both shared-register and slot-bank usage models through the
+  ``rte_eth_timesync_tx_timestamp_slot_*`` interface family.
+
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +25 -0
index 0f336f9567..36c48727f6 100644
@@ -795,6 +795,23 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Query TX timestamp hardware capability (single-register vs per-packet slot bank). */
+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,
+		struct rte_eth_timesync_tx_ts_caps *caps);
+
+/** @internal Allocate a per-packet TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint32_t *slot_id);
+
+/** @internal Read a dual-domain TX timestamp by slot handle. */
+typedef int (*eth_timesync_read_tx_timestamp_slot_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated TX timestamp slot handle. */
+typedef int (*eth_timesync_tx_timestamp_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1578,14 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Query TX timestamp hardware capability (single-reg vs per-packet) */
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;
+	/** Allocate a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_alloc_t timesync_tx_timestamp_slot_alloc;
+	/** Read a TX timestamp using a slot handle */
+	eth_timesync_read_tx_timestamp_slot_t timesync_read_tx_timestamp_slot;
+	/** Release a TX timestamp slot handle */
+	eth_timesync_tx_timestamp_slot_release_t timesync_tx_timestamp_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +202 -0

232 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +278 -0

290 lines not on this page · raw message

Signature · 1 line
2.55.0
#17 lore raw

Re: [RFC PATCH v4 1/3] ethdev: add Tx timestamp slot management APIs

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6713

Quoted 4 lines · On Wed, 2 Sep 2026 11:21:22 +0530 Rajesh Kumar <[email protected]> wrote:
lib/ethdev/rte_ethdev.c +4 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_timestamp_slot_alloc, 26.11)
+int
+rte_eth_timesync_tx_timestamp_slot_alloc(uint16_t port_id,
+					 uint32_t *slot_id)

Could join to one line, max line line is now 100

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6723

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (slot_id == NULL) {
+		RTE_ETHDEV_LOG_LINE(ERR,
+			"Cannot allocate ethdev port %u Tx timestamp slot to NULL",
+			port_id);

Minor nit the wording of that error message is awkward. Similar problem in other messages.

Quoted 24 lines
lib/ethdev/rte_ethdev.c +24 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_dynfield_register, 26.11)
+int
+rte_eth_timesync_tx_slot_dynfield_register(void)
+{
+	const struct rte_mbuf_dynfield slot_dynfield = {
+		.name  = RTE_ETH_TIMESYNC_TX_SLOT_DYNFIELD_NAME,
+		.size  = sizeof(uint32_t),
+		.align = alignof(uint32_t),
+	};
+	uint16_t port_id;
+
+	if (rte_eth_timesync_tx_slot_dynfield_offset >= 0)
+		return 0;
+
+	rte_eth_timesync_tx_slot_dynfield_offset =
+			rte_mbuf_dynfield_register(&slot_dynfield);
+	if (rte_eth_timesync_tx_slot_dynfield_offset < 0)
+		rte_eth_timesync_tx_slot_dynfield_offset =
+				rte_mbuf_dynfield_lookup(
+					RTE_ETH_TIMESYNC_TX_SLOT_DYNFIELD_NAME, NULL);
+	if (rte_eth_timesync_tx_slot_dynfield_offset < 0)
+		return -ENOTSUP;
+
+	{

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6863

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+		int flag_bit = rte_mbuf_dynflag_register(
+			&(const struct rte_mbuf_dynflag){
+				.name = RTE_ETH_TIMESYNC_TX_SLOT_DYNFLAG_NAME});
+		if (flag_bit < 0)
+			flag_bit = rte_mbuf_dynflag_lookup(
+				RTE_ETH_TIMESYNC_TX_SLOT_DYNFLAG_NAME, NULL);
+		if (flag_bit < 0)
+			return -ENOTSUP;
+		rte_eth_timesync_tx_slot_dynflag = RTE_BIT64(flag_bit);
+	}

No need for basic block {} here.

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_dynfield_unregister, 26.11)
+int
+rte_eth_timesync_tx_slot_dynfield_unregister(void)
+{
+	uint16_t port_id;
+

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6886

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+	/* Reset cached state without freeing dynamic-field bytes. */
+	rte_eth_timesync_tx_slot_dynfield_offset = -1;
+	rte_eth_timesync_tx_slot_dynflag = 0;
+
+	RTE_ETH_FOREACH_VALID_DEV(port_id)
+		eth_timesync_tx_slot_info_refresh(port_id);
+
+	return 0;
+}
+

If it always returns 0 why not void.
Not sure what the point of this function is. It doesn't really do anything.

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_timestamp_stamp_mbuf, 26.11)
+int
+rte_eth_timesync_tx_timestamp_stamp_mbuf(uint16_t port_id,
+						 uint32_t slot_id, struct rte_mbuf *m)
+{

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6902

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	if (m == NULL)
+		return -EINVAL;
+	if (rte_eth_timesync_tx_slot_dynfield_register() != 0)
+		return -ENOTSUP;
+	*RTE_MBUF_DYNFIELD(m, rte_eth_timesync_tx_slot_dynfield_offset,
+			   uint32_t *) = slot_id;
+	m->ol_flags |= rte_eth_timesync_tx_slot_dynflag;
+	return 0;
+}

This is possibly in data path, use unlikely() here.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5518

Quoted 11 lines
lib/ethdev/rte_ethdev.h +3 -0
index ee400b386f..bde391dea4 100644
@@ -5513,6 +5513,19 @@ int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
 /**
  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
  *
+ * This is the legacy Tx timestamp API and is intended for register-based
+ * timestamp reads. It does not provide per-packet correlation.
+ *

Rather than weak guidance which will get ignored and stale.
1. Convert all in-tree uses of old API
2. Announce deprecation in this release
3. Mark legacy API as deprecated

AI had even more observations (Fable 5.1)

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5521

Quoted 3 lines
lib/ethdev/rte_ethdev.h +3 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_infos, 26.11)
+struct rte_eth_timesync_tx_slot_info
+rte_eth_timesync_tx_slot_infos[RTE_MAX_ETHPORTS];

Exporting a RTE_MAX_ETHPORTS sized array from the public header bakes build config into ABI. rte_eth_fp_ops lives in ethdev_driver.h, this should too; only PMDs read it.

The per-port array also has no per-port content. offset and dynflag are process globals; the only per-port part is "caps say PER_PACKET". Put the two globals in ethdev_driver.h and let the PMD that implements slots check them. Drops the array, the refresh loop, and the forward declaration.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5522

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+static void eth_timesync_tx_slot_info_refresh(uint16_t port_id);

Move the definitions above first use instead.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5525

Quoted 3 lines
lib/ethdev/rte_ethdev.h +3 -0
+	ret = eth_err(port_id, dev->dev_ops->timesync_enable(dev));
+	if (ret == 0)
+		eth_timesync_tx_slot_info_refresh(port_id);

No matching reset in timesync_disable. Info stays stale after disable.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,

Quoted 9 lines
lib/ethdev/rte_ethdev.h +9 -0
+int
+rte_eth_timesync_tx_timestamp_stamp_mbuf(uint16_t port_id,
+						 uint32_t slot_id, struct rte_mbuf *m)
+{
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	if (m == NULL)
+		return -EINVAL;
+	if (rte_eth_timesync_tx_slot_dynfield_register() != 0)
+		return -ENOTSUP;

Calling register from the per-packet path is wrong. First call takes the mbuf dyn lock and walks every port calling into driver dev_ops. Header says "safe for concurrent callers"; it is not, two threads racing on first stamp both run registration on plain globals.

port_id is validated but otherwise unused. Stamping a SINGLE_REG port succeeds and sets a flag nothing reads. Check the port's slot info, return -ENOTSUP if dynflag == 0, and require the app to have called register up front (which the doc already says it must, before pool create).

lib/ethdev/rte_ethdev.h

Quoted 2 lines
lib/ethdev/rte_ethdev.h +2 -0
+	rte_eth_timesync_tx_slot_dynfield_offset = -1;
+	rte_eth_timesync_tx_slot_dynflag = 0;

Written unlocked, read from Tx datapath on other cores. Also cannot free the dynfield. Agree with dropping unregister entirely.

Quoted 2 lines

+ * -ENOTSUP and the PMD TX path falls back to the port-level ptp_tx_index
+ * (legacy mode) on every port.

ptp_tx_index is an Intel driver internal. Does not belong in rte_ethdev.h.

Quoted 1 line

+ * The underlying DPDK dynfield bytes are NOT freed — DPDK provides no dynfield

Non-ASCII dash in source.

Quoted 1 line

+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,

...

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;

...

Quoted 1 line

+int rte_eth_timesync_tx_timestamp_slot_get_capabilities(uint16_t port_id,

...

Quoted 1 line

+int rte_eth_timesync_read_tx_timestamp_slot(uint16_t port_id,

Three spellings of the same op, and the read function breaks the rte_eth_timesync_tx_timestamp_slot_* prefix the release note advertises. One prefix for all of it, rte_eth_timesync_tx_slot_{caps, alloc,read,release,stamp} is shorter and consistent.

Also TX/Tx mixed throughout comments and docs. Tx.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5563

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+struct rte_eth_timesync_dual_domain_timestamp {
+	int64_t adjusted_ns;
+	int64_t raw_ns;
+	uint32_t valid_mask;
+};

4 byte tail hole. Fine for experimental, but say so or reorder before it goes stable.

Quoted 1 line

+++ b/doc/guides/prog_guide/ethdev/timesync.rst

Lines up to 150+ chars. Doc guideline is one sentence per line. Half of this file documents existing clock/Rx API, which is a separate patch from the slot feature.

#18 lore raw

Re: [RFC PATCH v4 1/3] ethdev: add Tx timestamp slot management APIs

Quoted 8 lines · Stephen Hemminger

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6713

Quoted 4 lines · On Wed, 2 Sep 2026 11:21:22 +0530 Rajesh Kumar <[email protected]> wrote:
lib/ethdev/rte_ethdev.c +4 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_timestamp_slot_alloc, 26.11)
+int
+rte_eth_timesync_tx_timestamp_slot_alloc(uint16_t port_id,
+					 uint32_t *slot_id)

Could join to one line, max line line is now 100

Acked. Fixed in v5.

Quoted 13 lines

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6723

Quoted 11 lines
lib/ethdev/rte_ethdev.c +10 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (slot_id == NULL) {
+		RTE_ETHDEV_LOG_LINE(ERR,
+			"Cannot allocate ethdev port %u Tx timestamp slot to NULL",
+			port_id);

Minor nit the wording of that error message is awkward. Similar problem in other messages.

Acked. Fixed in v5.

Quoted 28 lines
Quoted 28 lines
lib/ethdev/rte_ethdev.c +27 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_dynfield_register, 26.11)
+int
+rte_eth_timesync_tx_slot_dynfield_register(void)
+{
+	const struct rte_mbuf_dynfield slot_dynfield = {
+		.name  = RTE_ETH_TIMESYNC_TX_SLOT_DYNFIELD_NAME,
+		.size  = sizeof(uint32_t),
+		.align = alignof(uint32_t),
+	};
+	uint16_t port_id;
+
+	if (rte_eth_timesync_tx_slot_dynfield_offset >= 0)
+		return 0;
+
+	rte_eth_timesync_tx_slot_dynfield_offset =
+			rte_mbuf_dynfield_register(&slot_dynfield);
+	if (rte_eth_timesync_tx_slot_dynfield_offset < 0)
+		rte_eth_timesync_tx_slot_dynfield_offset =
+				rte_mbuf_dynfield_lookup(
+					RTE_ETH_TIMESYNC_TX_SLOT_DYNFIELD_NAME, NULL);
+	if (rte_eth_timesync_tx_slot_dynfield_offset < 0)
+		return -ENOTSUP;
+
+	{
+		int flag_bit = rte_mbuf_dynflag_register(
+			&(const struct rte_mbuf_dynflag){
+				.name = RTE_ETH_TIMESYNC_TX_SLOT_DYNFLAG_NAME});
Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6863

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+		if (flag_bit < 0)
+			flag_bit = rte_mbuf_dynflag_lookup(
+				RTE_ETH_TIMESYNC_TX_SLOT_DYNFLAG_NAME, NULL);
+		if (flag_bit < 0)
+			return -ENOTSUP;
+		rte_eth_timesync_tx_slot_dynflag = RTE_BIT64(flag_bit);
+	}

No need for basic block {} here.

Acked. Fixed in v5.

Quoted 11 lines
Quoted 11 lines
lib/ethdev/rte_ethdev.c +10 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_dynfield_unregister, 26.11)
+int
+rte_eth_timesync_tx_slot_dynfield_unregister(void)
+{
+	uint16_t port_id;
+
+	/* Reset cached state without freeing dynamic-field bytes. */
+	rte_eth_timesync_tx_slot_dynfield_offset = -1;
+	rte_eth_timesync_tx_slot_dynflag = 0;
+
Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6870

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+	RTE_ETH_FOREACH_VALID_DEV(port_id)
+		eth_timesync_tx_slot_info_refresh(port_id);
+
+	return 0;
+}
+

If it always returns 0 why not void.
Not sure what the point of this function is. It doesn't really do anything.

Acked, removed this function in v5.

Quoted 17 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.c +5 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_timestamp_stamp_mbuf, 26.11)
+int
+rte_eth_timesync_tx_timestamp_stamp_mbuf(uint16_t port_id,
+						 uint32_t slot_id, struct rte_mbuf *m)
+{

lib/ethdev/rte_ethdev.c rte_eth_timesync_read_tx_timestamp(uint16_t port_id, · line 6902

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	if (m == NULL)
+		return -EINVAL;
+	if (rte_eth_timesync_tx_slot_dynfield_register() != 0)
+		return -ENOTSUP;
+	*RTE_MBUF_DYNFIELD(m, rte_eth_timesync_tx_slot_dynfield_offset,
+			   uint32_t *) = slot_id;
+	m->ol_flags |= rte_eth_timesync_tx_slot_dynflag;
+	return 0;
+}

This is possibly in data path, use unlikely() here.

Acked. Fixed in v5.

Quoted 17 lines

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5518

Quoted 13 lines
lib/ethdev/rte_ethdev.h +3 -0
index ee400b386f..bde391dea4 100644
@@ -5513,6 +5513,19 @@ int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
  /**
   * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
   *
+ * This is the legacy Tx timestamp API and is intended for register-based
+ * timestamp reads. It does not provide per-packet correlation.
+ *

Rather than weak guidance which will get ignored and stale.
1. Convert all in-tree uses of old API
2. Announce deprecation in this release
3. Mark legacy API as deprecated

The slot APIs are additive, not a drop-in replacement for rte_eth_timesync_read_tx_timestamp(). Existing hardware/PMDs may expose only a single TX timestamp latch and cannot implement per-packet slots. We will not label or deprecate the existing API in this series. Instead, the new capability-query API lets applications select slot-based timestamping when supported. Removed the “legacy” wording from the existing API documentation.

Quoted 10 lines

AI had even more observations (Fable 5.1)

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5521

Quoted 3 lines
lib/ethdev/rte_ethdev.h +3 -0
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_timesync_tx_slot_infos, 26.11)
+struct rte_eth_timesync_tx_slot_info
+rte_eth_timesync_tx_slot_infos[RTE_MAX_ETHPORTS];

Exporting a RTE_MAX_ETHPORTS sized array from the public header bakes build config into ABI. rte_eth_fp_ops lives in ethdev_driver.h, this should too; only PMDs read it.

Quoted 8 lines

The per-port array also has no per-port content. offset and dynflag are process globals; the only per-port part is "caps say PER_PACKET". Put the two globals in ethdev_driver.h and let the PMD that implements slots check them. Drops the array, the refresh loop, and the forward declaration.

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5522

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+static void eth_timesync_tx_slot_info_refresh(uint16_t port_id);

Move the definitions above first use instead.

Acked. this function is dropped in v5.

Quoted 5 lines

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5525

Quoted 4 lines
lib/ethdev/rte_ethdev.h +3 -0
+	ret = eth_err(port_id, dev->dev_ops->timesync_enable(dev));
+	if (ret == 0)
+		eth_timesync_tx_slot_info_refresh(port_id);

No matching reset in timesync_disable. Info stays stale after disable.

Acked. in v5, eth_timesync_tx_slot_info_refresh itself is dropped entirely, we don't need to call in timesync enable/disable

Quoted 15 lines

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,

Quoted 10 lines
lib/ethdev/rte_ethdev.h +9 -0
+int
+rte_eth_timesync_tx_timestamp_stamp_mbuf(uint16_t port_id,
+						 uint32_t slot_id, struct rte_mbuf *m)
+{
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	if (m == NULL)
+		return -EINVAL;
+	if (rte_eth_timesync_tx_slot_dynfield_register() != 0)
+		return -ENOTSUP;

Calling register from the per-packet path is wrong. First call takes the mbuf dyn lock and walks every port calling into driver dev_ops. Header says "safe for concurrent callers"; it is not, two threads racing on first stamp both run registration on plain globals.

Quoted 5 lines

port_id is validated but otherwise unused. Stamping a SINGLE_REG port succeeds and sets a flag nothing reads. Check the port's slot info, return -ENOTSUP if dynflag == 0, and require the app to have called register up front (which the doc already says it must, before pool create).

Acked. in v5 register is no longer being called from per-packet path.

Quoted 5 lines

lib/ethdev/rte_ethdev.h

Quoted 3 lines
lib/ethdev/rte_ethdev.h +2 -0
+	rte_eth_timesync_tx_slot_dynfield_offset = -1;
+	rte_eth_timesync_tx_slot_dynflag = 0;

Written unlocked, read from Tx datapath on other cores. Also cannot free the dynfield. Agree with dropping unregister entirely.

Acked. Droped the unregister entirely in v5.

Quoted 7 lines
Quoted 3 lines

+ * -ENOTSUP and the PMD TX path falls back to the port-level ptp_tx_index
+ * (legacy mode) on every port.

ptp_tx_index is an Intel driver internal. Does not belong in rte_ethdev.h.

Quoted 1 line

+ * The underlying DPDK dynfield bytes are NOT freed — DPDK provides no dynfield

Non-ASCII dash in source.

Acked. Fixed in v5.

Quoted 6 lines
Quoted 2 lines

+typedef int (*eth_timesync_tx_ts_get_caps_t)(struct rte_eth_dev *dev,

...

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	eth_timesync_tx_ts_get_caps_t timesync_tx_ts_get_capabilities;

...

Quoted 1 line

+int rte_eth_timesync_tx_timestamp_slot_get_capabilities(uint16_t port_id,

Quoted 8 lines

...

Quoted 1 line

+int rte_eth_timesync_read_tx_timestamp_slot(uint16_t port_id,

Three spellings of the same op, and the read function breaks the rte_eth_timesync_tx_timestamp_slot_* prefix the release note advertises. One prefix for all of it, rte_eth_timesync_tx_slot_{caps, alloc,read,release,stamp} is shorter and consistent.

Also TX/Tx mixed throughout comments and docs. Tx.

Acked. Fixed in v5.

Quoted 8 lines

lib/ethdev/rte_ethdev.h int rte_eth_timesync_read_rx_timestamp(uint16_t port_id, · line 5563

Quoted 6 lines
lib/ethdev/rte_ethdev.h +5 -0
+struct rte_eth_timesync_dual_domain_timestamp {
+	int64_t adjusted_ns;
+	int64_t raw_ns;
+	uint32_t valid_mask;
+};

4 byte tail hole. Fine for experimental, but say so or reorder before it goes stable.

Acked. added 4 byte reserved field to fix 4 byte tail hole.

Quoted 5 lines
Quoted 2 lines

+++ b/doc/guides/prog_guide/ethdev/timesync.rst

Lines up to 150+ chars. Doc guideline is one sentence per line. Half of this file documents existing clock/Rx API, which is a separate patch from the slot feature.

 Acked. Created a separate patch in the series to add documentation for existing clock/Rx API

#19 lore raw

RFC PATCH v4 2/3 net/ice: support per-packet Tx timestamp slots

In reply to Rajesh Kumar

The ice PHY provides 64 Tx timestamp slots per port, but the driver only ever used a single static slot (ptp_tx_index), which limits PTP Tx timestamping to one in-flight packet at a time.

Implement the ethdev Tx timestamp slot management ops on top of an atomic per-adapter slot bitmap:

- timesync_tx_ts_get_capabilities reports the per-packet slot type and the number of slots,
- timesync_tx_timestamp_slot_alloc reserves a free slot using a compare-exchange loop; on E822 the 64 quad slots are split evenly between the PFs sharing the quad so allocations never overlap,
- timesync_read_tx_timestamp_slot polls the PHY ready bitmap for the given slot and returns the adjusted timestamp,
- timesync_tx_timestamp_slot_release clears the PHY timestamp (E810) and frees the bitmap bit.

The Tx context descriptor now takes the timestamp index from the mbuf dynamic field registered by the ethdev layer when the packet carries the Tx timestamp slot dynamic flag, and falls back to the legacy static index otherwise.

While at it, make the legacy single-slot read path use ptp_tx_index instead of a hardcoded slot 0, and clear the PHY timestamp on E810 after a read or a timeout so a stale entry cannot block later requests.

---
 drivers/net/intel/ice/ice_ethdev.c | 210 ++++++++++++++++++++++++++++-
 drivers/net/intel/ice/ice_ethdev.h |   2 +
 drivers/net/intel/ice/ice_rxtx.c   |  11 +-
 3 files changed, 220 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +208 -2
index 76b8ff0a72..0109dc2621 100644
@@ -196,6 +196,14 @@ static int ice_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
 					  uint32_t flags);
 static int ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 					  struct timespec *timestamp);
+static int ice_timesync_tx_timestamp_slot_alloc(struct rte_eth_dev *dev,
+						uint32_t *slot_id);
+static int ice_timesync_tx_ts_get_capabilities(struct rte_eth_dev *dev,
+					       struct rte_eth_timesync_tx_ts_caps *caps);
+static int ice_timesync_read_tx_timestamp_slot(struct rte_eth_dev *dev, uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+static int ice_timesync_tx_timestamp_slot_release(struct rte_eth_dev *dev,
+						  uint32_t slot_id);
 static int ice_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
 static int ice_timesync_adjust_freq(struct rte_eth_dev *dev, int64_t ppm);
 static int ice_timesync_read_time(struct rte_eth_dev *dev,
@@ -340,6 +348,10 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
 	.timesync_enable              = ice_timesync_enable,
 	.timesync_read_rx_timestamp   = ice_timesync_read_rx_timestamp,
 	.timesync_read_tx_timestamp   = ice_timesync_read_tx_timestamp,
+	.timesync_tx_timestamp_slot_alloc = ice_timesync_tx_timestamp_slot_alloc,
+	.timesync_tx_ts_get_capabilities  = ice_timesync_tx_ts_get_capabilities,
+	.timesync_read_tx_timestamp_slot  = ice_timesync_read_tx_timestamp_slot,
+	.timesync_tx_timestamp_slot_release = ice_timesync_tx_timestamp_slot_release,
 	.timesync_adjust_time         = ice_timesync_adjust_time,
 	.timesync_adjust_freq         = ice_timesync_adjust_freq,
 	.timesync_read_time           = ice_timesync_read_time,
@@ -7157,6 +7169,188 @@ static int ice_ptp_write_init(struct ice_hw *hw)
 	return ice_ptp_init_time(hw, ns, true);
 }
 
+/*
+ * Allocate one TX timestamp slot from the per-port 64-slot bitmap using CAS.
+ * Returns slot index [0..max-1] or -ENOSPC if all slots are taken.
+ * For E822, max is capped so PFs sharing a quad use non-overlapping ranges.
+ */
+static int
+ice_ptp_alloc_tx_slot(struct ice_adapter *ad)
+{
+	uint64_t old, new_bm, range_mask, free_in_range;
+	uint8_t slot, max_slots, base_slot;
+	bool swapped;
+
+	/*
+	 * E822: multiple PFs share one quad's 64 slots.
+	 * Divide evenly: each PF occupies (64 / ports_per_quad) slots starting
+	 * at (pf_offset_in_quad * slots_per_pf).
+	 */
+	if (ad->hw.phy_model == ICE_PHY_E822) {
+		uint8_t ppq = ICE_PORTS_PER_QUAD;
+		uint8_t slots_per_pf = 64 / ppq;
+		uint8_t pf_offset = ad->hw.pf_id % ppq;
+
+		base_slot = pf_offset * slots_per_pf;
+		max_slots = slots_per_pf;
+	} else {
+		/* E810, E830, ETH56G: full 64 slots per PF BAR / per lport */
+		base_slot = 0;
+		max_slots = 64;
+	}
+
+	range_mask = (max_slots == 64) ? UINT64_MAX :
+		     (((uint64_t)1 << max_slots) - 1) << base_slot;
+
+	do {
+		old = rte_atomic_load_explicit(&ad->ts_slot_bitmap,
+					       rte_memory_order_relaxed);
+		free_in_range = ~old & range_mask;
+		if (free_in_range == 0)
+			return -ENOSPC;
+
+		slot = (uint8_t)rte_ctz64(free_in_range);
+		new_bm = old | RTE_BIT64(slot);
+		swapped = rte_atomic_compare_exchange_weak_explicit(&ad->ts_slot_bitmap,
+				&old, new_bm, rte_memory_order_acquire,
+				rte_memory_order_relaxed);
+	} while (!swapped);
+	return slot;
+}
+
+/* Release a TX timestamp slot back to the bitmap. */
+static void
+ice_ptp_release_tx_slot(struct ice_adapter *ad, uint8_t slot)
+{
+	rte_atomic_fetch_and_explicit(&ad->ts_slot_bitmap, ~RTE_BIT64(slot),
+				      rte_memory_order_release);
+}
+
+/* Allocate a TX timestamp slot from the per-port bitmap for the per-packet slot API. */
+static int
+ice_get_next_tx_desc_idx(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *ad;
+	int slot;
+
+	if (dev == NULL)
+		return -EINVAL;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	slot = ice_ptp_alloc_tx_slot(ad);
+	if (slot < 0) {
+		PMD_DRV_LOG(DEBUG, "PTP TX: all 64 timestamp slots busy");
+		return slot;
+	}
+
+	/*
+	 * Do NOT update ptp_tx_index: that field belongs to the legacy
+	 * single-inflight path and is set statically in ice_ptp_init_info().
+	 */
+	return slot;
+}
+
+static int
+ice_ptp_read_tx_dual_timestamp(struct rte_eth_dev *dev, uint8_t slot,
+			       struct rte_eth_timesync_dual_domain_timestamp *dual)
+{
+	struct ice_adapter *ad;
+	struct ice_hw *hw;
+	uint64_t tstamp_ready, tstamp, adjusted_ns;
+	int ret;
+
+	if (dev == NULL || dual == NULL)
+		return -EINVAL;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready);
+	if (ret)
+		return -EAGAIN;
+
+	if (!(tstamp_ready & RTE_BIT64(slot)))
+		return -EAGAIN;
+
+	ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, slot, &tstamp);
+	if (ret || tstamp == 0)
+		return -EAGAIN;
+
+	adjusted_ns = ice_tstamp_convert_32b_64b(hw, ad, 1,
+			(tstamp >> 8) & 0xFFFFFFFF);
+
+	dual->adjusted_ns = (int64_t)adjusted_ns;
+	dual->raw_ns = 0;
+	dual->valid_mask = RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_ADJUSTED_VALID;
+
+	return 0;
+}
+
+static void
+ice_ptp_free_tx_slot(struct rte_eth_dev *dev, uint8_t slot)
+{
+	struct ice_adapter *ad;
+	struct ice_hw *hw;
+
+	if (dev == NULL)
+		return;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->phy_model == ICE_PHY_E810)
+		(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block, slot);
+	ice_ptp_release_tx_slot(ad, slot);
+}
+
+static int
+ice_timesync_tx_ts_get_capabilities(struct rte_eth_dev *dev __rte_unused,
+				    struct rte_eth_timesync_tx_ts_caps *caps)
+{
+	caps->type = RTE_ETH_TIMESYNC_TX_TS_PER_PACKET;
+	caps->max_slots = 64;
+	return 0;
+}
+
+static int
+ice_timesync_tx_timestamp_slot_alloc(struct rte_eth_dev *dev,
+				     uint32_t *slot_id)
+{
+	int idx;
+
+	if (dev == NULL || slot_id == NULL)
+		return -EINVAL;
+
+	idx = ice_get_next_tx_desc_idx(dev);
+	if (idx < 0)
+		return idx;
+
+	*slot_id = (uint32_t)(uint16_t)idx;
+	return 0;
+}
+
+static int
+ice_timesync_read_tx_timestamp_slot(struct rte_eth_dev *dev, uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp)
+{
+	if (dev == NULL || timestamp == NULL || slot_id > 63)
+		return -EINVAL;
+
+	memset(timestamp, 0, sizeof(*timestamp));
+
+	return ice_ptp_read_tx_dual_timestamp(dev, (uint8_t)slot_id, timestamp);
+}
+
+static int
+ice_timesync_tx_timestamp_slot_release(struct rte_eth_dev *dev, uint32_t slot_id)
+{
+	if (dev == NULL || slot_id > 63)
+		return -EINVAL;
+
+	ice_ptp_free_tx_slot(dev, (uint8_t)slot_id);
+	return 0;
+}
+
 static int
 ice_timesync_enable(struct rte_eth_dev *dev)
 {
@@ -7239,6 +7433,11 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 	/* Set the end time with a delay of 10 microseconds */
 	end_time = rte_get_timer_cycles() + (rte_get_timer_hz() / 100000);
 
+	/*
+	 * ptp_tx_index is a static slot set in ice_ptp_init_info(); it is NOT
+	 * allocated via ice_ptp_alloc_tx_slot() so the bitmap must not be
+	 * touched.
+	 */
 	do {
 		ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready);
 		if (ret) {
@@ -7246,11 +7445,15 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 			return -1;
 		}
 
-		if ((tstamp_ready & BIT_ULL(0)) == 0 && rte_get_timer_cycles() > end_time) {
+		if (!(tstamp_ready & BIT_ULL(ad->ptp_tx_index)) &&
+		    rte_get_timer_cycles() > end_time) {
 			PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp");
+			if (hw->phy_model == ICE_PHY_E810)
+				(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block,
+							   ad->ptp_tx_index);
 			return -1;
 		}
-	} while ((tstamp_ready & BIT_ULL(0)) == 0);
+	} while (!(tstamp_ready & BIT_ULL(ad->ptp_tx_index)));
 
 	ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index, &tstamp);
 	if (ret || tstamp == 0) {
@@ -7261,6 +7464,9 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 	ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, (tstamp >> 8) & mask);
 	*timestamp = rte_ns_to_timespec(ts_ns);
 
+	if (hw->phy_model == ICE_PHY_E810)
+		(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index);
+
 	return 0;
 }
 
drivers/net/intel/ice/ice_ethdev.h +2 -0
index 7ee3ea8a70..d5fed14fae 100644
@@ -684,6 +684,8 @@ struct ice_adapter {
 	/* For PTP */
 	uint8_t ptp_tx_block;
 	uint8_t ptp_tx_index;
+	/* Atomic bitmask of in-use TX timestamp slots (bit N = slot N occupied). */
+	RTE_ATOMIC(uint64_t)ts_slot_bitmap;
 	bool ptp_ena;
 	bool txpp_ena;	/* For TxPP */
 	uint64_t time_hw;
drivers/net/intel/ice/ice_rxtx.c +10 -1
index c4b5454c53..25e51099e5 100644
@@ -3038,10 +3038,19 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
 	uint64_t *qw0, uint64_t *qw1)
 {
+	const struct rte_eth_timesync_tx_slot_info *ts_info;
 	uint16_t cd_l2tag2 = 0;
 	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
 	uint32_t cd_tunneling_params = 0;
-	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+	uint64_t ptp_tx_index;
+
+	/* A zero dynflag means the port is not using per-packet slots. */
+	ts_info = rte_eth_timesync_tx_slot_info_get(txq->port_id);
+	if (ol_flags & ts_info->dynflag)
+		ptp_tx_index = *RTE_MBUF_DYNFIELD(tx_pkt, ts_info->offset,
+				uint32_t *);
+	else
+		ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
 
 	if (ice_calc_context_desc(ol_flags) == 0)
 		return 0;
Signature · 1 line
2.55.0
#20 lore raw

RFC PATCH v4 3/3 app/testpmd: add Tx timestamp capabilities command

In reply to Rajesh Kumar

Add "show port <port_id> tx_timestamp_caps" to report the Tx timestamp slot capabilities of a port: the slot type reported by the driver and the number of available slots.

When the port supports per-packet slots, the command also performs an allocate and release round-trip so the slot management API can be exercised from the command line.

---
 app/test-pmd/cmdline.c | 79 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
app/test-pmd/cmdline.c +79 -0
index 10ee7c5179..66276cee58 100644
@@ -14213,6 +14213,84 @@ static cmdline_parse_inst_t cmd_set_dev_led = {
 	},
 };
 
+/* *** show port tx_timestamp capabilities *** */
+struct cmd_show_port_tx_ts_caps_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t tx_timestamp_caps;
+};
+
+static void cmd_show_port_tx_ts_caps_parsed(void *parsed_result,
+					    __rte_unused struct cmdline *cl,
+					    __rte_unused void *data)
+{
+	struct cmd_show_port_tx_ts_caps_result *res = parsed_result;
+	struct rte_eth_timesync_tx_ts_caps caps;
+	uint32_t slot_id;
+	int ret;
+
+	ret = rte_eth_timesync_tx_timestamp_slot_get_capabilities(
+			res->port_id, &caps);
+	if (ret == -ENOTSUP) {
+		printf("Port %u: TX timestamp slot API not supported\n",
+		       res->port_id);
+		return;
+	}
+	if (ret < 0) {
+		printf("Port %u: get capabilities failed (%d)\n",
+		       res->port_id, ret);
+		return;
+	}
+
+	printf("Port %u TX timestamp capabilities:\n", res->port_id);
+	printf("  Type      : %s\n",
+	       caps.type == RTE_ETH_TIMESYNC_TX_TS_PER_PACKET ? "per-packet" :
+	       caps.type == RTE_ETH_TIMESYNC_TX_TS_SINGLE_REG ? "single-reg" :
+	       "none");
+	printf("  Max slots : %u\n", caps.max_slots);
+
+	if (caps.type != RTE_ETH_TIMESYNC_TX_TS_PER_PACKET)
+		return;
+
+	/* Quick alloc/release round-trip to prove the API works */
+	ret = rte_eth_timesync_tx_timestamp_slot_alloc(res->port_id, &slot_id);
+	if (ret == 0) {
+		printf("  Alloc test: slot_id=%u OK\n", slot_id);
+		ret = rte_eth_timesync_tx_timestamp_slot_release(
+				res->port_id, slot_id);
+		printf("  Release   : %s\n", ret == 0 ? "OK" : "FAILED");
+	} else {
+		printf("  Alloc test: failed (%d)\n", ret);
+	}
+}
+
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 show, "show");
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 port, "port");
+static cmdline_parse_token_num_t cmd_show_port_tx_ts_caps_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+			      port_id, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 tx_timestamp_caps, "tx_timestamp_caps");
+
+static cmdline_parse_inst_t cmd_show_port_tx_ts_caps = {
+	.f = cmd_show_port_tx_ts_caps_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> tx_timestamp_caps",
+	.tokens = {
+		(void *)&cmd_show_port_tx_ts_caps_show,
+		(void *)&cmd_show_port_tx_ts_caps_port,
+		(void *)&cmd_show_port_tx_ts_caps_port_id,
+		(void *)&cmd_show_port_tx_ts_caps_keyword,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -14469,6 +14547,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
 	&cmd_set_port_cman_config,
 	&cmd_config_tx_affinity_map,
 	&cmd_set_dev_led,
+	&cmd_show_port_tx_ts_caps,
 	NULL,
 };
 
Signature · 1 line
2.55.0
#21 lore raw

v5 cover ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx, with a helper that stamps a slot handle onto an mbuf.
* Registration and process-local reset of the cached dynfield state.
* An ice PMD implementation using the 64 per-port PHY timestamp slots.
* A testpmd command to report the slot capabilities of a port.
* Programming guide documentation, split into a patch describing the pre-existing clock/Rx timesync API and a patch describing the new Tx timestamp slot feature.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register.

Changes since v4:

* Fixed review comments and AI observation.
* Consolidated the Tx timestamp slot API naming onto a single rte_eth_timesync_tx_slot_{caps,alloc,read,release,stamp} prefix, replacing the previous mix of tx_timestamp_slot_*, tx_ts_*, and tx_slot_* spellings across the public API, PMD ops, and the ice implementation.
* Dropped the per-port cached slot-info array in favor of a single process-local dynfield offset/dynflag pair.
* Split the programming guide documentation out of the ethdev patch into two dedicated patches: one documenting the pre-existing clock/Rx timesync API, and one documenting the new Tx timestamp slot feature, so review of the new functionality is not mixed with review of already-existing behavior.
* Fixed inconsistent TX/Tx casing in comments, log messages, and documentation to consistently use "Tx".

Comments and suggestions on the interface and the ice implementation are welcome.

Rajesh Kumar (5):
ethdev: add Tx timestamp slot management APIs
doc: describe ethdev timesync clock and Rx timestamp API
doc: describe ethdev Tx timestamp slot API net/ice: support per-packet Tx timestamp slots app/testpmd: add Tx timestamp capabilities command

 app/test-pmd/cmdline.c                    |  79 ++++++++
 doc/guides/nics/features.rst              |  15 +-
 doc/guides/prog_guide/ethdev/index.rst    |   1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 219 +++++++++++++++++++++
 doc/guides/rel_notes/release_26_11.rst    |   7 +
 drivers/net/intel/ice/ice_ethdev.c        | 211 ++++++++++++++++++++-
 drivers/net/intel/ice/ice_ethdev.h        |   2 +
 drivers/net/intel/ice/ice_rxtx.c          |   9 +-
 lib/ethdev/ethdev_driver.h                |  28 +++
 lib/ethdev/rte_ethdev.c                   | 151 ++++++++++++++-
 lib/ethdev/rte_ethdev.h                   | 220 ++++++++++++++++++++++
 11 files changed, 933 insertions(+), 9 deletions(-)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
Signature · 1 line
2.55.0
#22 lore raw

RFC PATCH v5 1/5 ethdev: add Tx timestamp slot management APIs

Extend ethdev timesync with a capability model for selecting between shared-register and per-packet Tx timestamping.

Add public and PMD interfaces to query timestamp capabilities, allocate timestamp slots, retrieve timestamps asynchronously, and release slots. Slots have port-global scope and can be used across Tx queues.

Add a dual-domain timestamp structure for reporting adjusted PHC time and raw hardware time independently through validity flags.

Add APIs to register and unregister the mbuf dynamic field and dynflag used to pass slot handles to the Tx datapath. Add helpers to associate a slot handle with an mbuf before transmission.

Keep the legacy Tx timestamp API for shared-register hardware.

Programming guide documentation for the new slot API is added in a following patch.

---
 doc/guides/nics/features.rst           |  15 +-
 doc/guides/rel_notes/release_26_11.rst |   7 +
 lib/ethdev/ethdev_driver.h             |  28 ++++
 lib/ethdev/rte_ethdev.c                | 151 ++++++++++++++++-
 lib/ethdev/rte_ethdev.h                | 220 +++++++++++++++++++++++++
 5 files changed, 415 insertions(+), 6 deletions(-)
doc/guides/nics/features.rst +11 -4
index 0b0c69e7cd..4d96184a14 100644
@@ -692,14 +692,21 @@ Timesync
 
 Supports IEEE1588/802.1AS timestamping.
 
-* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``
+* **[implements] eth_dev_ops**: ``timesync_enable``, ``timesync_disable``,
   ``timesync_read_rx_timestamp``, ``timesync_read_tx_timestamp``,
+  ``timesync_tx_slot_get_caps``, ``timesync_tx_slot_alloc``,
+  ``timesync_tx_slot_read``, ``timesync_tx_slot_release``,
   ``timesync_adjust_time``, ``timesync_adjust_freq``,
   ``timesync_read_time``, ``timesync_write_time``.
 * **[related]    API**: ``rte_eth_timesync_enable()``, ``rte_eth_timesync_disable()``,
-  ``rte_eth_timesync_read_rx_timestamp()``,
-  ``rte_eth_timesync_read_tx_timestamp``, ``rte_eth_timesync_adjust_time()``,
-  ``rte_eth_timesync_adjust_freq()``,
+  ``rte_eth_timesync_read_rx_timestamp()``, ``rte_eth_timesync_read_tx_timestamp()``,
+  ``rte_eth_timesync_tx_slot_caps()``,
+  ``rte_eth_timesync_tx_slot_alloc()``,
+  ``rte_eth_timesync_tx_slot_read()``,
+  ``rte_eth_timesync_tx_slot_release()``,
+  ``rte_eth_timesync_tx_slot_dynfield_register()``,
+  ``rte_eth_timesync_tx_slot_stamp()``,
+  ``rte_eth_timesync_adjust_time()``, ``rte_eth_timesync_adjust_freq()``,
   ``rte_eth_timesync_read_time()``, ``rte_eth_timesync_write_time()``.
 
 
doc/guides/rel_notes/release_26_11.rst +7 -0
index c8cc86295d..b97e019043 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **ethdev: Added experimental per-packet Tx timestamp slot APIs.**
+
+  Added slot-based Tx timestamp allocation, mbuf stamping, and per-packet
+  timestamp reads for timesync-capable Ethernet devices. The new APIs support
+  both shared-register and slot-bank usage models through the
+  ``rte_eth_timesync_tx_slot_*`` interface family.
+
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +28 -0
index 0f336f9567..b6597987b2 100644
@@ -795,6 +795,26 @@ typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
 						struct timespec *timestamp);
 
+/** @internal Query Tx timestamp hardware capability (single-register vs per-packet slot bank). */
+typedef int (*eth_timesync_tx_slot_get_caps_t)(struct rte_eth_dev *dev,
+		struct rte_eth_timesync_tx_slot_caps *caps);
+
+/** @internal Allocate a per-packet Tx timestamp slot handle. */
+typedef int (*eth_timesync_tx_slot_alloc_t)(struct rte_eth_dev *dev,
+		uint32_t *slot_id);
+
+/** @internal Read a dual-domain Tx timestamp by slot handle. */
+typedef int (*eth_timesync_tx_slot_read_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+
+/** @internal Release a previously allocated Tx timestamp slot handle. */
+typedef int (*eth_timesync_tx_slot_release_t)(struct rte_eth_dev *dev,
+		uint32_t slot_id);
+
+extern int rte_eth_timesync_tx_slot_dynfield_offset;
+extern uint64_t rte_eth_timesync_tx_slot_dynflag;
+
 /** @internal Function used to adjust the device clock. */
 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
 
@@ -1561,6 +1581,14 @@ struct eth_dev_ops {
 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
 	/** Read the IEEE1588/802.1AS Tx timestamp */
 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+	/** Query Tx timestamp hardware capability (single-reg vs per-packet) */
+	eth_timesync_tx_slot_get_caps_t timesync_tx_slot_get_caps;
+	/** Allocate a Tx timestamp slot handle */
+	eth_timesync_tx_slot_alloc_t timesync_tx_slot_alloc;
+	/** Read a Tx timestamp using a slot handle */
+	eth_timesync_tx_slot_read_t timesync_tx_slot_read;
+	/** Release a Tx timestamp slot handle */
+	eth_timesync_tx_slot_release_t timesync_tx_slot_release;
 	/** Adjust the device clock */
 	eth_timesync_adjust_time   timesync_adjust_time;
 	/** Adjust the clock frequency */
lib/ethdev/rte_ethdev.c +149 -2

181 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +220 -0

238 lines not on this page · raw message

Signature · 1 line
2.55.0
#23 lore raw

RFC PATCH v5 2/5 doc: describe ethdev timesync clock and Rx timestamp API

In reply to Rajesh Kumar

Add a programming guide page for the ethdev IEEE 1588 / PTP timesync API, covering PHC clock management and receive timestamp extraction.

This describes existing, previously undocumented API and does not introduce any new functionality.

---
 doc/guides/prog_guide/ethdev/index.rst    |  1 +
 doc/guides/prog_guide/ethdev/timesync.rst | 72 +++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst
doc/guides/prog_guide/ethdev/index.rst +1 -0
index 392ced0a2e..bc21f28091 100644
@@ -13,3 +13,4 @@ Ethernet Device Library
     traffic_metering_and_policing
     traffic_management
     qos_framework
+    timesync
doc/guides/prog_guide/ethdev/timesync.rst new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.55.0
#24 lore raw

RFC PATCH v5 3/5 doc: describe ethdev Tx timestamp slot API

In reply to Rajesh Kumar

Document the Tx timestamp capability model, the per-packet slot lifecycle, and the application workflow introduced for slot-based transmit timestamping.

---
 doc/guides/prog_guide/ethdev/timesync.rst | 147 ++++++++++++++++++++++
 1 file changed, 147 insertions(+)
doc/guides/prog_guide/ethdev/timesync.rst +147 -0
index 59d660eba8..f11eaf0557 100644
@@ -57,6 +57,129 @@ Rx Timestamp Extraction Workflow
       Stored in a registered mbuf dynamic field (e.g. ``rte_mbuf_dyn_rx_timestamp_register()``).
 
 
+Transmit (Tx) Timestamping Architectures
+----------------------------------------
+
+The framework supports two hardware transmit timestamping architectures:
+
+* **Single Shared Register** (``RTE_ETH_TIMESYNC_TX_SLOT_SINGLE_REG``):
+  The hardware contains a single shared transmit timestamp latch register.
+  Only one outbound packet can be timestamped at a time across the entire port.
+  The application calls ``rte_eth_timesync_read_tx_timestamp(port_id, &ts)`` to retrieve the departure time.
+
+* **Per-Packet Slot Bank** (``RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET``):
+  The hardware provides a bank of independent transmit timestamp slots or descriptors.
+  Multiple outbound PTP packets can be timestamped concurrently and correlated asynchronously on a per-packet basis using slot handles.
+
+
+Dual-Domain Timestamps
+~~~~~~~~~~~~~~~~~~~~~~
+
+When retrieving transmit timestamps using slot handles, the API returns a dual-domain timestamp structure:
+
+.. code-block:: c
+
+    struct rte_eth_timesync_dual_domain_timestamp {
+        int64_t adjusted_ns; /**< PHC adjusted time (wall-clock nanoseconds) */
+        int64_t raw_ns;      /**< Free-running hardware cycle counter or raw nanoseconds */
+        uint32_t valid_mask; /**< Validity bits for the adjusted/raw domains */
+        uint32_t reserved;   /**< Reserved for future use, must be zero */
+    };
+
+* **Adjusted Domain** (``RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_ADJUSTED_VALID``):
+  Represents the wall-clock time after frequency adjustments (``rte_eth_timesync_adjust_freq``) or phase steps (``rte_eth_timesync_adjust_time``) have been applied.
+
+* **Raw Domain** (``RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_RAW_VALID``):
+  Represents the unadjusted free-running hardware cycle counter or raw timestamp.
+  This domain is required when correlating adjusted wall-clock time with the underlying hardware timebase or when performing cross-timestamp analysis.
+
+
+Per-Packet Tx Timestamp Workflow
+--------------------------------
+
+To use per-packet transmit timestamping, applications follow this sequence:
+
+1. **Query Port Capabilities**
+   Determine whether the PMD supports slot-based per-packet timestamping:
+
+   .. code-block:: c
+
+          struct rte_eth_timesync_tx_slot_caps caps;
+
+          ret = rte_eth_timesync_tx_slot_caps(port_id, &caps);
+          if (ret == 0 && caps.type == RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET) {
+                printf("Port %u supports per-packet timestamping with %u max slots\n",
+                           port_id, caps.max_slots);
+          }
+
+2. **Register Mbuf Dynamic Fields**
+   Register the dynamic field and dynamic flag used to pass slot handles to the Tx datapath:
+
+   .. code-block:: c
+
+       ret = rte_eth_timesync_tx_slot_dynfield_register();
+       if (ret < 0) {
+           /* Dynamic field space exhausted or registration failed */
+       }
+
+   .. note::
+
+      ``rte_eth_timesync_tx_slot_dynfield_register()`` must be called explicitly before ``rte_pktmbuf_pool_create()``.
+      It is **not** called automatically by ``rte_eth_timesync_enable()``.
+      Dynamic fields and flags remain registered until process shutdown; DPDK does not support unregistering them.
+
+3. **Allocate a Timestamp Slot**
+   Before transmitting a PTP packet requiring a transmit timestamp, allocate a slot handle:
+
+   .. code-block:: c
+
+       uint32_t slot_id;
+
+       ret = rte_eth_timesync_tx_slot_alloc(port_id, &slot_id);
+       if (ret != 0) {
+           /* Handle allocation error (e.g. -ENOSPC if all slots are in flight) */
+       }
+
+4. **Stamp the Mbuf**
+   Attach the allocated slot handle to the mbuf:
+
+   .. code-block:: c
+
+         ret = rte_eth_timesync_tx_slot_stamp(slot_id, mbuf);
+         if (ret != 0) {
+            rte_eth_timesync_tx_slot_release(port_id, slot_id);
+            /* The dynfield setup was not completed or an argument is invalid */
+         } else {
+            mbuf->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST;
+         }
+
+5. **Transmit the Packet**
+   Send the packet via ``rte_eth_tx_burst()`` as usual.
+
+6. **Poll for Timestamp Completion**
+   Read the captured timestamp using the allocated slot handle:
+
+   .. code-block:: c
+
+       struct rte_eth_timesync_dual_domain_timestamp ts;
+
+       ret = rte_eth_timesync_tx_slot_read(port_id, slot_id, &ts);
+       if (ret == 0) {
+           /* Timestamp is ready */
+           if (ts.valid_mask & RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_ADJUSTED_VALID) {
+               /* Process ts.adjusted_ns */
+           }
+       } else if (ret == -EAGAIN) {
+           /* Timestamp hardware processing is still pending; retry later */
+       }
+
+7. **Release the Slot**
+   After successfully reading the timestamp or timing out, release the slot handle:
+
+   .. code-block:: c
+
+          rte_eth_timesync_tx_slot_release(port_id, slot_id);
+
 PMD Implementation Requirements
 -------------------------------
 
@@ -70,3 +193,27 @@ To support full timesync capabilities, a Poll Mode Driver (PMD) implements the f
 2. Rx Timestamping (``timesync_read_rx_timestamp``)
 
    Configures Rx filters to latch incoming PTP arrival times and flags received mbufs with ``RTE_MBUF_F_RX_IEEE1588_PTP``.
+
+3. Tx Slot Capability Reporting (``timesync_tx_slot_get_caps``)
+
+   Reports ``RTE_ETH_TIMESYNC_TX_SLOT_SINGLE_REG`` or ``RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET`` in ``caps->type`` and sets ``caps->max_slots``.
+
+4. Slot Allocation & Release
+   (``timesync_tx_slot_alloc`` / ``timesync_tx_slot_release``)
+
+   Maintains a port-global pool or bitmap of hardware timestamp slots.
+   ``timesync_tx_slot_alloc`` returns an opaque port-unique slot handle and returns ``-ENOSPC`` when no slots are free.
+   ``timesync_tx_slot_release`` clears hardware slot state and returns the handle to the free pool.
+   Passing an invalid or already-released handle should return ``-EINVAL``.
+
+5. Tx Datapath Integration
+
+   Checks if ``RTE_MBUF_F_TX_IEEE1588_TMST`` is set on ``mbuf->ol_flags``.
+   For per-packet slot mode, retrieves ``slot_id`` from mbuf dynamic field via ``*RTE_MBUF_DYNFIELD(m, dynfield_offset, uint32_t *)``.
+   Configures hardware Tx descriptors to capture departure timestamps into the specified slot.
+
+6. Tx Slot Timestamp Retrieval
+   (``timesync_tx_slot_read``)
+
+   Queries hardware slot or descriptor completion ring corresponding to ``slot_id``.
+   Populates ``struct rte_eth_timesync_dual_domain_timestamp`` and returns ``0`` when ready, or ``-EAGAIN`` if pending.
Signature · 1 line
2.55.0
#25 lore raw

RFC PATCH v5 4/5 net/ice: support per-packet Tx timestamp slots

In reply to Rajesh Kumar

The ice PHY provides 64 Tx timestamp slots per port, but the driver only ever used a single static slot (ptp_tx_index), which limits PTP Tx timestamping to one in-flight packet at a time.

Implement the ethdev Tx timestamp slot management ops on top of an atomic per-adapter slot bitmap:

- timesync_tx_slot_get_caps reports the per-packet slot type and the number of slots,
- timesync_tx_slot_alloc reserves a free slot using a compare-exchange loop; on E822 the 64 quad slots are split evenly between the PFs sharing the quad so allocations never overlap,
- timesync_tx_slot_read polls the PHY ready bitmap for the given slot and returns the adjusted timestamp,
- timesync_tx_slot_release clears the PHY timestamp (E810) and frees the bitmap bit.

The Tx context descriptor now takes the timestamp index from the mbuf dynamic field registered by the ethdev layer when the packet carries the Tx timestamp slot dynamic flag, and falls back to the legacy static index otherwise.

While at it, make the legacy single-slot read path use ptp_tx_index instead of a hardcoded slot 0, and clear the PHY timestamp on E810 after a read or a timeout so a stale entry cannot block later requests.

---
 drivers/net/intel/ice/ice_ethdev.c | 211 ++++++++++++++++++++++++++++-
 drivers/net/intel/ice/ice_ethdev.h |   2 +
 drivers/net/intel/ice/ice_rxtx.c   |   9 +-
 3 files changed, 219 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +209 -2
index 76b8ff0a72..485842300d 100644
@@ -196,6 +196,14 @@ static int ice_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
 					  uint32_t flags);
 static int ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 					  struct timespec *timestamp);
+static int ice_timesync_tx_slot_alloc(struct rte_eth_dev *dev,
+						uint32_t *slot_id);
+static int ice_timesync_tx_slot_get_caps(struct rte_eth_dev *dev,
+					       struct rte_eth_timesync_tx_slot_caps *caps);
+static int ice_timesync_tx_slot_read(struct rte_eth_dev *dev, uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp);
+static int ice_timesync_tx_slot_release(struct rte_eth_dev *dev,
+						  uint32_t slot_id);
 static int ice_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
 static int ice_timesync_adjust_freq(struct rte_eth_dev *dev, int64_t ppm);
 static int ice_timesync_read_time(struct rte_eth_dev *dev,
@@ -340,6 +348,10 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
 	.timesync_enable              = ice_timesync_enable,
 	.timesync_read_rx_timestamp   = ice_timesync_read_rx_timestamp,
 	.timesync_read_tx_timestamp   = ice_timesync_read_tx_timestamp,
+	.timesync_tx_slot_alloc = ice_timesync_tx_slot_alloc,
+	.timesync_tx_slot_get_caps  = ice_timesync_tx_slot_get_caps,
+	.timesync_tx_slot_read  = ice_timesync_tx_slot_read,
+	.timesync_tx_slot_release = ice_timesync_tx_slot_release,
 	.timesync_adjust_time         = ice_timesync_adjust_time,
 	.timesync_adjust_freq         = ice_timesync_adjust_freq,
 	.timesync_read_time           = ice_timesync_read_time,
@@ -7157,6 +7169,189 @@ static int ice_ptp_write_init(struct ice_hw *hw)
 	return ice_ptp_init_time(hw, ns, true);
 }
 
+/*
+ * Allocate one Tx timestamp slot from the per-port 64-slot bitmap using CAS.
+ * Returns slot index [0..max-1] or -ENOSPC if all slots are taken.
+ * For E822, max is capped so PFs sharing a quad use non-overlapping ranges.
+ */
+static int
+ice_ptp_alloc_tx_slot(struct ice_adapter *ad)
+{
+	uint64_t old, new_bm, range_mask, free_in_range;
+	uint8_t slot, max_slots, base_slot;
+	bool swapped;
+
+	/*
+	 * E822: multiple PFs share one quad's 64 slots.
+	 * Divide evenly: each PF occupies (64 / ports_per_quad) slots starting
+	 * at (pf_offset_in_quad * slots_per_pf).
+	 */
+	if (ad->hw.phy_model == ICE_PHY_E822) {
+		uint8_t ppq = ICE_PORTS_PER_QUAD;
+		uint8_t slots_per_pf = 64 / ppq;
+		uint8_t pf_offset = ad->hw.pf_id % ppq;
+
+		base_slot = pf_offset * slots_per_pf;
+		max_slots = slots_per_pf;
+	} else {
+		/* E810, E830, ETH56G: full 64 slots per PF BAR / per lport */
+		base_slot = 0;
+		max_slots = 64;
+	}
+
+	range_mask = (max_slots == 64) ? UINT64_MAX :
+		     (((uint64_t)1 << max_slots) - 1) << base_slot;
+
+	do {
+		old = rte_atomic_load_explicit(&ad->ts_slot_bitmap,
+					       rte_memory_order_relaxed);
+		free_in_range = ~old & range_mask;
+		if (free_in_range == 0)
+			return -ENOSPC;
+
+		slot = (uint8_t)rte_ctz64(free_in_range);
+		new_bm = old | RTE_BIT64(slot);
+		swapped = rte_atomic_compare_exchange_weak_explicit(&ad->ts_slot_bitmap,
+				&old, new_bm, rte_memory_order_acquire,
+				rte_memory_order_relaxed);
+	} while (!swapped);
+
+	return slot;
+}
+
+/* Release a Tx timestamp slot back to the bitmap. */
+static void
+ice_ptp_release_tx_slot(struct ice_adapter *ad, uint8_t slot)
+{
+	rte_atomic_fetch_and_explicit(&ad->ts_slot_bitmap, ~RTE_BIT64(slot),
+				      rte_memory_order_release);
+}
+
+/* Allocate a Tx timestamp slot from the per-port bitmap for the per-packet slot API. */
+static int
+ice_get_next_tx_desc_idx(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *ad;
+	int slot;
+
+	if (dev == NULL)
+		return -EINVAL;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	slot = ice_ptp_alloc_tx_slot(ad);
+	if (slot < 0) {
+		PMD_DRV_LOG(DEBUG, "PTP Tx: all 64 timestamp slots busy");
+		return slot;
+	}
+
+	/*
+	 * Do NOT update ptp_tx_index: that field belongs to the legacy
+	 * single-inflight path and is set statically in ice_ptp_init_info().
+	 */
+	return slot;
+}
+
+static int
+ice_ptp_read_tx_dual_timestamp(struct rte_eth_dev *dev, uint8_t slot,
+			       struct rte_eth_timesync_dual_domain_timestamp *dual)
+{
+	struct ice_adapter *ad;
+	struct ice_hw *hw;
+	uint64_t tstamp_ready, tstamp, adjusted_ns;
+	int ret;
+
+	if (dev == NULL || dual == NULL)
+		return -EINVAL;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready);
+	if (ret)
+		return -EAGAIN;
+
+	if (!(tstamp_ready & RTE_BIT64(slot)))
+		return -EAGAIN;
+
+	ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, slot, &tstamp);
+	if (ret || tstamp == 0)
+		return -EAGAIN;
+
+	adjusted_ns = ice_tstamp_convert_32b_64b(hw, ad, 1,
+			(tstamp >> 8) & 0xFFFFFFFF);
+
+	dual->adjusted_ns = (int64_t)adjusted_ns;
+	dual->raw_ns = 0;
+	dual->valid_mask = RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_ADJUSTED_VALID;
+
+	return 0;
+}
+
+static void
+ice_ptp_free_tx_slot(struct rte_eth_dev *dev, uint8_t slot)
+{
+	struct ice_adapter *ad;
+	struct ice_hw *hw;
+
+	if (dev == NULL)
+		return;
+
+	ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->phy_model == ICE_PHY_E810)
+		(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block, slot);
+	ice_ptp_release_tx_slot(ad, slot);
+}
+
+static int
+ice_timesync_tx_slot_get_caps(struct rte_eth_dev *dev __rte_unused,
+				    struct rte_eth_timesync_tx_slot_caps *caps)
+{
+	caps->type = RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET;
+	caps->max_slots = 64;
+	return 0;
+}
+
+static int
+ice_timesync_tx_slot_alloc(struct rte_eth_dev *dev,
+				     uint32_t *slot_id)
+{
+	int idx;
+
+	if (dev == NULL || slot_id == NULL)
+		return -EINVAL;
+
+	idx = ice_get_next_tx_desc_idx(dev);
+	if (idx < 0)
+		return idx;
+
+	*slot_id = (uint32_t)(uint16_t)idx;
+	return 0;
+}
+
+static int
+ice_timesync_tx_slot_read(struct rte_eth_dev *dev, uint32_t slot_id,
+		struct rte_eth_timesync_dual_domain_timestamp *timestamp)
+{
+	if (dev == NULL || timestamp == NULL || slot_id > 63)
+		return -EINVAL;
+
+	memset(timestamp, 0, sizeof(*timestamp));
+
+	return ice_ptp_read_tx_dual_timestamp(dev, (uint8_t)slot_id, timestamp);
+}
+
+static int
+ice_timesync_tx_slot_release(struct rte_eth_dev *dev, uint32_t slot_id)
+{
+	if (dev == NULL || slot_id > 63)
+		return -EINVAL;
+
+	ice_ptp_free_tx_slot(dev, (uint8_t)slot_id);
+	return 0;
+}
+
 static int
 ice_timesync_enable(struct rte_eth_dev *dev)
 {
@@ -7239,6 +7434,11 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 	/* Set the end time with a delay of 10 microseconds */
 	end_time = rte_get_timer_cycles() + (rte_get_timer_hz() / 100000);
 
+	/*
+	 * ptp_tx_index is a static slot set in ice_ptp_init_info(); it is NOT
+	 * allocated via ice_ptp_alloc_tx_slot() so the bitmap must not be
+	 * touched.
+	 */
 	do {
 		ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready);
 		if (ret) {
@@ -7246,11 +7446,15 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 			return -1;
 		}
 
-		if ((tstamp_ready & BIT_ULL(0)) == 0 && rte_get_timer_cycles() > end_time) {
+		if (!(tstamp_ready & BIT_ULL(ad->ptp_tx_index)) &&
+		    rte_get_timer_cycles() > end_time) {
 			PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp");
+			if (hw->phy_model == ICE_PHY_E810)
+				(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block,
+							   ad->ptp_tx_index);
 			return -1;
 		}
-	} while ((tstamp_ready & BIT_ULL(0)) == 0);
+	} while (!(tstamp_ready & BIT_ULL(ad->ptp_tx_index)));
 
 	ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index, &tstamp);
 	if (ret || tstamp == 0) {
@@ -7261,6 +7465,9 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 	ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, (tstamp >> 8) & mask);
 	*timestamp = rte_ns_to_timespec(ts_ns);
 
+	if (hw->phy_model == ICE_PHY_E810)
+		(void)ice_clear_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index);
+
 	return 0;
 }
 
drivers/net/intel/ice/ice_ethdev.h +2 -0
index 7ee3ea8a70..a5ad9bd504 100644
@@ -684,6 +684,8 @@ struct ice_adapter {
 	/* For PTP */
 	uint8_t ptp_tx_block;
 	uint8_t ptp_tx_index;
+	/* Atomic bitmask of in-use Tx timestamp slots (bit N = slot N occupied). */
+	RTE_ATOMIC(uint64_t)ts_slot_bitmap;
 	bool ptp_ena;
 	bool txpp_ena;	/* For TxPP */
 	uint64_t time_hw;
drivers/net/intel/ice/ice_rxtx.c +8 -1
index c4b5454c53..c2ce34226a 100644
@@ -3041,7 +3041,14 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 	uint16_t cd_l2tag2 = 0;
 	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
 	uint32_t cd_tunneling_params = 0;
-	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+	uint64_t ptp_tx_index;
+
+	if (ol_flags & rte_eth_timesync_tx_slot_dynflag)
+		ptp_tx_index = *RTE_MBUF_DYNFIELD(tx_pkt,
+				rte_eth_timesync_tx_slot_dynfield_offset,
+				uint32_t *);
+	else
+		ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
 
 	if (ice_calc_context_desc(ol_flags) == 0)
 		return 0;
Signature · 1 line
2.55.0
#26 lore raw

RFC PATCH v5 5/5 app/testpmd: add Tx timestamp capabilities command

In reply to Rajesh Kumar

Add "show port <port_id> tx_timestamp_caps" to report the Tx timestamp slot capabilities of a port: the slot type reported by the driver and the number of available slots.

When the port supports per-packet slots, the command also performs an allocate and release round-trip so the slot management API can be exercised from the command line.

---
 app/test-pmd/cmdline.c | 79 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
app/test-pmd/cmdline.c +79 -0
index 10ee7c5179..54a1c4ba36 100644
@@ -14213,6 +14213,84 @@ static cmdline_parse_inst_t cmd_set_dev_led = {
 	},
 };
 
+/* *** show port tx_timestamp capabilities *** */
+struct cmd_show_port_tx_ts_caps_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t tx_timestamp_caps;
+};
+
+static void cmd_show_port_tx_ts_caps_parsed(void *parsed_result,
+					    __rte_unused struct cmdline *cl,
+					    __rte_unused void *data)
+{
+	struct cmd_show_port_tx_ts_caps_result *res = parsed_result;
+	struct rte_eth_timesync_tx_slot_caps caps;
+	uint32_t slot_id;
+	int ret;
+
+	ret = rte_eth_timesync_tx_slot_caps(
+			res->port_id, &caps);
+	if (ret == -ENOTSUP) {
+		printf("Port %u: Tx timestamp slot API not supported\n",
+		       res->port_id);
+		return;
+	}
+	if (ret < 0) {
+		printf("Port %u: get capabilities failed (%d)\n",
+		       res->port_id, ret);
+		return;
+	}
+
+	printf("Port %u Tx timestamp capabilities:\n", res->port_id);
+	printf("  Type      : %s\n",
+	       caps.type == RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET ? "per-packet" :
+	       caps.type == RTE_ETH_TIMESYNC_TX_SLOT_SINGLE_REG ? "single-reg" :
+	       "none");
+	printf("  Max slots : %u\n", caps.max_slots);
+
+	if (caps.type != RTE_ETH_TIMESYNC_TX_SLOT_PER_PACKET)
+		return;
+
+	/* Quick alloc/release round-trip to prove the API works */
+	ret = rte_eth_timesync_tx_slot_alloc(res->port_id, &slot_id);
+	if (ret == 0) {
+		printf("  Alloc test: slot_id=%u OK\n", slot_id);
+		ret = rte_eth_timesync_tx_slot_release(
+				res->port_id, slot_id);
+		printf("  Release   : %s\n", ret == 0 ? "OK" : "FAILED");
+	} else {
+		printf("  Alloc test: failed (%d)\n", ret);
+	}
+}
+
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 show, "show");
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 port, "port");
+static cmdline_parse_token_num_t cmd_show_port_tx_ts_caps_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+			      port_id, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_port_tx_ts_caps_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tx_ts_caps_result,
+				 tx_timestamp_caps, "tx_timestamp_caps");
+
+static cmdline_parse_inst_t cmd_show_port_tx_ts_caps = {
+	.f = cmd_show_port_tx_ts_caps_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> tx_timestamp_caps",
+	.tokens = {
+		(void *)&cmd_show_port_tx_ts_caps_show,
+		(void *)&cmd_show_port_tx_ts_caps_port,
+		(void *)&cmd_show_port_tx_ts_caps_port_id,
+		(void *)&cmd_show_port_tx_ts_caps_keyword,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -14469,6 +14547,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
 	&cmd_set_port_cman_config,
 	&cmd_config_tx_affinity_map,
 	&cmd_set_dev_led,
+	&cmd_show_port_tx_ts_caps,
 	NULL,
 };
 
Signature · 1 line
2.55.0
#27 lore raw

Re: [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs

In reply to Rajesh Kumar

Hi all,

This is a gentle reminder to review RFC patch series v5 ("ethdev: add Tx timestamp slot APIs").

Regards,
Rajesh

Quoted 70 lines · Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx, with a helper that stamps a slot handle onto an mbuf.
* Registration and process-local reset of the cached dynfield state.
* An ice PMD implementation using the 64 per-port PHY timestamp slots.
* A testpmd command to report the slot capabilities of a port.
* Programming guide documentation, split into a patch describing the pre-existing clock/Rx timesync API and a patch describing the new Tx timestamp slot feature.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register.

Changes since v4:

* Fixed review comments and AI observation.
* Consolidated the Tx timestamp slot API naming onto a single rte_eth_timesync_tx_slot_{caps,alloc,read,release,stamp} prefix, replacing the previous mix of tx_timestamp_slot_*, tx_ts_*, and tx_slot_* spellings across the public API, PMD ops, and the ice implementation.
* Dropped the per-port cached slot-info array in favor of a single process-local dynfield offset/dynflag pair.
* Split the programming guide documentation out of the ethdev patch into two dedicated patches: one documenting the pre-existing clock/Rx timesync API, and one documenting the new Tx timestamp slot feature, so review of the new functionality is not mixed with review of already-existing behavior.
* Fixed inconsistent TX/Tx casing in comments, log messages, and documentation to consistently use "Tx".

Comments and suggestions on the interface and the ice implementation are welcome.

Rajesh Kumar (5):
ethdev: add Tx timestamp slot management APIs
doc: describe ethdev timesync clock and Rx timestamp API
doc: describe ethdev Tx timestamp slot API net/ice: support per-packet Tx timestamp slots app/testpmd: add Tx timestamp capabilities command

  app/test-pmd/cmdline.c                    |  79 ++++++++
  doc/guides/nics/features.rst              |  15 +-
  doc/guides/prog_guide/ethdev/index.rst    |   1 +
  doc/guides/prog_guide/ethdev/timesync.rst | 219 +++++++++++++++++++++
  doc/guides/rel_notes/release_26_11.rst    |   7 +
  drivers/net/intel/ice/ice_ethdev.c        | 211 ++++++++++++++++++++-
  drivers/net/intel/ice/ice_ethdev.h        |   2 +
  drivers/net/intel/ice/ice_rxtx.c          |   9 +-
  lib/ethdev/ethdev_driver.h                |  28 +++
  lib/ethdev/rte_ethdev.c                   | 151 ++++++++++++++-
  lib/ethdev/rte_ethdev.h                   | 220 ++++++++++++++++++++++
  11 files changed, 933 insertions(+), 9 deletions(-)

create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst

#28 lore raw

Re: [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs

Hi Stephen,
I wanted to quickly check if you have any further comments or feedback on this v5 series? If you are satisfied with the current changes, we can move forward to the next steps for this patch.

Regards,

Rajesh

Quoted 78 lines · Rajesh

Hi all,

This is a gentle reminder to review RFC patch series v5 ("ethdev: add Tx timestamp slot APIs").

Regards,
Rajesh

Quoted 70 lines · Rajesh Kumar

The ethdev timesync API currently exposes Tx timestamps through a shared hardware register. This requires applications to serialize timestamped packets and does not allow correlation when multiple packets are in flight.

This RFC proposes an ethdev interface for hardware with independent Tx timestamp slots. The interface reports the supported timestamping mechanism, provides a port-global slot lifecycle, and lets applications poll each slot asynchronously after transmission.

The proposal includes the following components:

* Capability reporting for shared-register and per-packet timestamping.
* Slot allocation, asynchronous timestamp retrieval, and slot release.
* A dual-domain timestamp structure for adjusted PHC and raw hardware time.
* Mbuf dynamic field and dynflag support for passing slot handles to Tx, with a helper that stamps a slot handle onto an mbuf.
* Registration and process-local reset of the cached dynfield state.
* An ice PMD implementation using the 64 per-port PHY timestamp slots.
* A testpmd command to report the slot capabilities of a port.
* Programming guide documentation, split into a patch describing the pre-existing clock/Rx timesync API and a patch describing the new Tx timestamp slot feature.

The legacy rte_eth_timesync_read_tx_timestamp() API remains available on devices using a shared timestamp register.

Changes since v4:

* Fixed review comments and AI observation.
* Consolidated the Tx timestamp slot API naming onto a single rte_eth_timesync_tx_slot_{caps,alloc,read,release,stamp} prefix, replacing the previous mix of tx_timestamp_slot_*, tx_ts_*, and tx_slot_* spellings across the public API, PMD ops, and the ice implementation.
* Dropped the per-port cached slot-info array in favor of a single process-local dynfield offset/dynflag pair.
* Split the programming guide documentation out of the ethdev patch into two dedicated patches: one documenting the pre-existing clock/Rx timesync API, and one documenting the new Tx timestamp slot feature, so review of the new functionality is not mixed with review of already-existing behavior.
* Fixed inconsistent TX/Tx casing in comments, log messages, and documentation to consistently use "Tx".

Comments and suggestions on the interface and the ice implementation are welcome.

Rajesh Kumar (5):
   ethdev: add Tx timestamp slot management APIs
   doc: describe ethdev timesync clock and Rx timestamp API
   doc: describe ethdev Tx timestamp slot API net/ice: support per-packet Tx timestamp slots app/testpmd: add Tx timestamp capabilities command

  app/test-pmd/cmdline.c                    |  79 ++++++++ doc/guides/nics/features.rst              |  15 +- doc/guides/prog_guide/ethdev/index.rst    |   1 + doc/guides/prog_guide/ethdev/timesync.rst | 219 +++++++++++++++++++++ doc/guides/rel_notes/release_26_11.rst    |   7 + drivers/net/intel/ice/ice_ethdev.c        | 211 ++++++++++++++++++++- drivers/net/intel/ice/ice_ethdev.h        |   2 + drivers/net/intel/ice/ice_rxtx.c          |   9 +- lib/ethdev/ethdev_driver.h                |  28 +++ lib/ethdev/rte_ethdev.c                   | 151 ++++++++++++++- lib/ethdev/rte_ethdev.h                   | 220 ++++++++++++++++++++++

  11 files changed, 933 insertions(+), 9 deletions(-)

  create mode 100644 doc/guides/prog_guide/ethdev/timesync.rst

#29 lore raw

Re: [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs

Quoted 11 lines · Rajesh

Hi Stephen,
I wanted to quickly check if you have any further comments or feedback on this v5 series?
If you are satisfied with the current changes, we can move forward to the next steps for this patch.

Regards,

Rajesh

On 21-09-2026

Lots of open issues from AI review.
The biggest issue is that this overlaps with existing metering API and seems specific to Intel NIC's. I strongly discourage API's that can only be used on one vendor NIC.

Series: [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs

Applied to main 49bb9a5 (release_26_11.rst conflict only). Each commit builds with -Dwerror=true (net/intel/ice, test-pmd); no bisect issues.

Series-level:

The main problem is in the ice implementation. Slot state is never cleaned up before a slot is handed out, so the read path can return a timestamp that belongs to an earlier packet as if it were the current one (patch 4, Error).

The legacy static index and the slot allocator also overlap on ice.

On the API side, the caller has to set two separate mbuf flags for one action. The caps query returns -ENOTSUP on every PMD except ice, so it cannot be used to choose a mechanism as the doc says.

The patch 1 commit message and the cover letter describe an unregister / "process-local reset" API that is not in this version.

Patch 1/5 ethdev: add Tx timestamp slot management APIs

Warning:

- The commit message says "Add APIs to register and unregister the mbuf dynamic field", and the cover letter lists "process-local reset". Only rte_eth_timesync_tx_slot_dynfield_register() exists.

- rte_eth_timesync_tx_slot_dynfield_register() falls back to rte_mbuf_dynfield_lookup() / rte_mbuf_dynflag_lookup() after a registration failure. Register already returns the existing offset when the name and params match, including in a secondary process. The only extra case the lookup covers is EEXIST with different params, and there it accepts a field of the wrong size or alignment. It also returns -ENOTSUP for every failure, losing rte_errno (ENOMEM, EEXIST). Drop both lookups and return -rte_errno.

- The register doc says "Must be called before the first rte_pktmbuf_pool_create()". rte_mbuf_dyn.h says "The registration can be done at any moment"; pool creation has no bearing on it. The same wrong claim appears in the patch 3 note.

- rte_eth_timesync_tx_slot_caps() returns -ENOTSUP for every in-tree PMD except ice, including all PMDs that implement timesync_read_tx_timestamp. Nothing ever reports RTE_ETH_TIMESYNC_TX_SLOT_SINGLE_REG, so "Applications use this to select the mechanism supported by the port" does not hold. Either have ethdev report SINGLE_REG when timesync_tx_slot_get_caps is NULL and timesync_read_tx_timestamp is set, or drop SINGLE_REG.

- rte_eth_timesync_tx_slot_stamp() sets the dynflag but not RTE_MBUF_F_TX_IEEE1588_TMST. The patch 3 example has to set TMST separately. If the application forgets it, ice takes the "else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)" path, no timestamp is requested, and the slot read returns -EAGAIN forever. stamp() should set both flags.

- The release note says the new APIs "support both shared-register and slot-bank usage models through the rte_eth_timesync_tx_slot_* interface family". The shared-register model is still served only by rte_eth_timesync_read_tx_timestamp().

- There is no functional test. dynfield_register() and stamp() are pure software and can be tested in app/test without hardware.

Info:

- The read and release doxygen says "is undefined behaviour - PMDs should return -EINVAL"; pick one. Those two lines (rte_ethdev.h 5448, 5472) also use non-ASCII em-dashes. The release doc still refers to "stamp_mbuf", the old function name.

- Drop "This function does not make the PMD hardware lifecycle safe by itself." It gives the reader nothing to act on (also in patch 2).

- The new wrappers have no trace points. The existing timesync calls do, e.g. rte_eth_trace_timesync_read_tx_timestamp().

- Unrelated changes: a blank line removed before rte_eth_add_rx_callback, and the log text reworded in rte_eth_timesync_read_tx_timestamp().

- The definitions of alloc, release, dynfield_register and stamp put the return type on the same line as the name. caps and read in the same patch follow DPDK style.

- Nothing in the series sets raw_ns or RTE_ETH_TIMESYNC_DUAL_DOMAIN_TIMESTAMP_RAW_VALID. Consider leaving them out until a PMD produces them.

- The dynfield name "rte_eth_timesync_tx_slot" does not follow the rte_<libname>_dynfield_<name> convention in rte_mbuf_dyn.h.

Patch 2/5 doc: describe ethdev timesync clock and Rx timestamp API

Info:

- The commit message says the patch documents existing behaviour only. The "must ensure no Tx timestamp operations are in flight before disabling" requirement is new in patch 1; move it to patch 3.

- The flags argument of rte_eth_timesync_read_rx_timestamp() is not explained. ice uses it as the Rx queue index.

Patch 3/5 doc: describe ethdev Tx timestamp slot API

Warning:

- "* **Single Shared Register** (...):" and "* **Adjusted Domain**" are term/description bullet lists. Use RST definition lists. The same applies to the numbered "1. **Clock Control & Adjustment**:" list in patch 2.

Info:

- Indentation is inconsistent in the step 1 and step 4 code examples.

- Document how late a slot read may happen. ice extends a 32-bit ns value against the current PHC time, so the result is only correct within about 2.1 s of capture (see patch 4).

Patch 4/5 net/ice: support per-packet Tx timestamp slots

Error:

- Stale timestamps are returned as valid.

E810 has no ready register: ice_get_phy_tx_tstamp_ready_e810() does "*tstamp_ready = 0xFFFFFFFFFFFFFFFF;". In ice_ptp_read_tx_dual_timestamp() the ready-bit test therefore never fires, and "if (ret || tstamp == 0)" is the only readiness check.

Nothing clears a slot before it is handed out. ice_ptp_alloc_tx_slot() only sets the bitmap bit. ice_timesync_enable() does not reset the PHY timestamp memory. ice_timesync_disable() clears index 0 only:
"ice_clear_phy_tstamp(hw, lport, 0);".

So a slot can still hold a value from a process that exited without releasing it, or one the hardware wrote after the application timed out and released the slot. The next owner reads that value as its own, before its packet is even sent.

On E822 and ETH56G, release does not touch the PHY at all ("if (hw->phy_model == ICE_PHY_E810)"). A timestamp that arrives after a timeout leaves the ready bit set for the next owner.

Fix: in timesync_enable, reset this PF's slot range in PHY memory and clear ts_slot_bitmap. In alloc, discard any entry already present in the chosen slot.

Warning:

- The legacy index overlaps the allocator. ice_ptp_init_info() sets "ad->ptp_tx_index = 0;" on E810, E830 and ETH56G, and base_slot on E822. "slot = (uint8_t)rte_ctz64(free_in_range);" therefore hands out the legacy slot first.

A TMST packet without the dynflag uses ad->ptp_tx_index and lands in that same slot. On E810, ice_timesync_read_tx_timestamp() now also clears that slot after reading it. Reserve the legacy bit in ts_slot_bitmap at init.

- "caps->max_slots = 64;" is unconditional, but the allocator limits E822 to "64 / ppq" slots per PF. The debug log "all 64 timestamp slots busy" is wrong on E822 for the same reason. Compute the range once, store it in the adapter, and use it for caps, alloc, read and release.

- Read and release only check "slot_id > 63".

Releasing an unallocated or already-released slot clears a bit that another thread may now own, and on E810 zeroes its PHY entry. The ethdev header asks PMDs to return -EINVAL in that case.

On E822, reading a slot outside this PF's range reads another PF's quad entry. Per the ice_clear_phy_tstamp_e822() comment, that read auto-clears the entry, so this PF steals the other PF's timestamp.

Check the slot against the PF range and the bitmap. rte_atomic_fetch_and_explicit() returns the old value for the ownership test.

- "if (ret) return -EAGAIN;" after ice_get_phy_tx_tstamp_ready() and ice_read_phy_tstamp() turns sideband and register failures into "retry". The caller then polls forever. Return -EIO.

- ice_timesync_tx_slot_alloc() does not check ad->ptp_ena. With timesync disabled, or with txpp_ena set (ice_timesync_enable() returns 0 without enabling), alloc succeeds and read returns -EAGAIN forever.

- The E810 ice_clear_phy_tstamp() call added to the timeout branch of ice_timesync_read_tx_timestamp() is unreachable. tstamp_ready is all ones on E810, so
"!(tstamp_ready & BIT_ULL(ad->ptp_tx_index))" is never true. The "clear ... after ... a timeout" fix claimed in the commit message does not happen.

- No release note entry under "Updated Intel ice driver".

- ice_timesync_tx_slot_alloc() -> ice_get_next_tx_desc_idx() -> ice_ptp_alloc_tx_slot() repeats the dev, slot_id and dual NULL checks at every level, after ethdev has already validated them. ice_get_next_tx_desc_idx is also misnamed; it allocates a slot, not a descriptor index. Collapse the layers.

Info:

- get_context_desc() evaluates
"if (ol_flags & rte_eth_timesync_tx_slot_dynflag)" for every packet in the scalar path, before the ice_calc_context_desc() == 0 early return. That is an exported-variable load (via the GOT in a shared build) per packet. Move the lookup into the TMST branch.

- Pre-existing: TSYN is in the "else if" after TSO, so TMST is ignored on TSO packets. With slots, the allocated slot then stays at -EAGAIN.

- Pre-existing: the vector Tx paths, including the AVX2 and AVX512 ctx offload paths, never set CI_TX_CTX_DESC_TSYN.

Tx path selection does not consider ptp_ena, while Rx does (ice_set_rx_function). caps still reports PER_PACKET, so a stamped packet on a vector path never gets a timestamp.

- Pre-existing: ice_tstamp_convert_32b_64b(hw, ad, 1, ...) writes the shared ad->time_hw without synchronization. The slot read adds a concurrent writer alongside the Rx path.

- On E810 the legacy read now hits "Failed to read phy timestamp" at ERR on every poll until the hardware writes the slot. ptpclient and ieee1588fwd both poll in loops, so this floods the log. Log at DEBUG and return -EAGAIN.

- "(uint32_t)(uint16_t)idx" double cast. Magic 64 and 63 should be a define. Missing space in "RTE_ATOMIC(uint64_t)ts_slot_bitmap;".

Patch 5/5 app/testpmd: add Tx timestamp capabilities command

Warning:

- The "show" command calls rte_eth_timesync_tx_slot_alloc() and release(). A show command should not change device state; on E810 the release zeroes a PHY entry. If a forwarding engine holds every slot, the output is "Alloc test: failed (-28)". Drop the round-trip.

- testpmd_funcs.rst and the testpmd help text are not updated.

- stamp, read and dynfield_register cannot be reached from testpmd. ieee1588fwd is the natural place to use the slot API when the port reports PER_PACKET.

Info:

- There is no port_id_is_invalid(res->port_id, ENABLED_WARN) check. Print errors with strerror(-ret).