DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Rajesh Kumar <rajesh3.kumar@intel.com>
Cc: dev@dpdk.org, thomas@monjalon.net, bruce.richardson@intel.com,
	andrew.rybchenko@oktetlabs.ru, aman.deep.singh@intel.com
Subject: Re: [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs
Date: Mon, 30 Nov 2026 16:52:09 -0800	[thread overview]
Message-ID: <20261130165209.31c1d442@phoenix.local> (raw)
In-Reply-To: <20260908073206.1236372-1-rajesh3.kumar@intel.com>

On Tue,  8 Sep 2026 13:02:01 +0530
Rajesh Kumar <rajesh3.kumar@intel.com> 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.
> 
> 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.

This needs a rebase onto 27.03 and more support before it is ready for merge.
Examples:
	- more than one driver, ideally from different vendor
          concern is that ethdev API might need to change.
        - need something to exercise datapath, maybe ieee1588fwd or some
          statistics on tx latency in forward or test-pmd

AI comments:
Subject: Re: [RFC PATCH v5 0/5] ethdev: per-packet Tx timestamp slots

Series applies to main and builds with -Dwerror=true at each commit
(net/ice, testpmd).

Series-level

Warning: only one driver (ice) implements the new ops. An ethdev API
should not be shaped by one vendor's hardware. igc (i225/i226) has
four Tx timestamp registers and is an obvious second user; show the
API works there before this leaves RFC.

Warning: nothing exercises the datapath. The testpmd command only does
alloc/release. Convert app/test-pmd/ieee1588fwd.c (still on
rte_eth_timesync_read_tx_timestamp) to use the slot API when the port
reports PER_PACKET, so stamp, Tx and read are tested end to end.


[PATCH 1/5] ethdev: add Tx timestamp slot management APIs

Warning: rte_eth_timesync_tx_slot_stamp() sets only the dynflag. ice
builds the context descriptor only when RTE_MBUF_F_TX_IEEE1588_TMST
is set, so a stamped mbuf without it is sent untimestamped and the
slot never completes. Patch 3 works around this by having the app set
TMST by hand. Two flags for one request is a trap; set both:

	m->ol_flags |= rte_eth_timesync_tx_slot_dynflag |
		       RTE_MBUF_F_TX_IEEE1588_TMST;

Warning: the lookup fallback in dynfield_register() is wrong.
rte_mbuf_dynfield_register() and rte_mbuf_dynflag_register() already
return the existing offset/bit when the same name and parameters are
registered. They fail with EEXIST only when the name exists with a
different size or alignment, and then the lookup hands back an
incompatible field. Also return the real error, not -ENOTSUP:

	offset = rte_mbuf_dynfield_register(&slot_dynfield);
	if (offset < 0)
		return -rte_errno;
	bit = rte_mbuf_dynflag_register(&slot_dynflag);
	if (bit < 0)
		return -rte_errno;
	rte_eth_timesync_tx_slot_dynfield_offset = offset;
	rte_eth_timesync_tx_slot_dynflag = RTE_BIT64(bit);

Warning: the doxygen for dynfield_register() says it must be called
before rte_pktmbuf_pool_create(). Dynfields are a layout reservation;
pool creation order does not matter. Drop that paragraph (and the
matching note in patch 3).

Warning: the raw domain in rte_eth_timesync_dual_domain_timestamp has
no user; ice sets raw_ns = 0 and only ADJUSTED_VALID. Drop raw_ns and
valid_mask until a driver can fill them, and return the timestamp in
the same form as the existing API (struct timespec), or plain ns.

Warning: slot lifetime across rte_eth_timesync_disable(), dev_stop,
dev_close and reset is not defined. State that disable/close releases
all slots and that stale handles return -EINVAL afterwards. The added
disable text ("does not make the PMD hardware lifecycle safe by
itself") says nothing a user can act on; replace it with that rule.

Warning: read/release doxygen says passing a bad handle is undefined
behaviour and then that PMDs should return -EINVAL. Pick one: require
-EINVAL. The same comments use non-ASCII em-dashes; use ASCII.

Warning: commit message says "register and unregister" and "helpers";
there is no unregister and one helper.

Info: no trace points. Every other timesync API has an
rte_eth_trace_timesync_* point; add them for the new calls.

Info: unrelated churn: blank line removed after
rte_eth_dev_rx_intr_disable(), and the reworded log message in
rte_eth_timesync_read_tx_timestamp(). Drop both.

Info: alloc, release, dynfield_register and stamp put the return type
on the same line as the name; DPDK style has it on its own line.

Info: op is timesync_tx_slot_get_caps, API is
rte_eth_timesync_tx_slot_caps. Use the same name. Release doxygen
refers to "stamp_mbuf", an old name.

Info: the offset/flag globals are per process. A secondary that does
not call dynfield_register() sees dynflag 0, and ice silently uses the
legacy index for its packets. Document that secondaries must call it.


[PATCH 2/5] doc: describe ethdev timesync clock and Rx timestamp API

Warning: the commit message says this documents existing API only,
but the disable paragraph is about the new Tx slot API. Move it to
patch 3.

Warning: the Rx section omits RTE_MBUF_F_RX_IEEE1588_TMST, which is
the flag that says a timestamp was latched; RX_IEEE1588_PTP only says
the packet is PTP. rte_mbuf_dyn_rx_timestamp_register() belongs to
RTE_ETH_RX_OFFLOAD_TIMESTAMP, which is not the timesync PHC path;
remove it from this page.


[PATCH 3/5] doc: describe ethdev Tx timestamp slot API

Warning: step 7 tells the app to release a slot after a timeout. If
the packet is still queued, the hardware writes the timestamp after
the slot has been handed to the next owner, who reads the wrong
value. Document when release is safe, and require the PMD to discard
a late timestamp on release (see patch 4).

Info: code blocks use 6, 9 and 10 space indents. Use one indent.
Step 4 sets RTE_MBUF_F_TX_IEEE1588_TMST by hand; drop it once the
stamp helper sets it.


[PATCH 4/5] net/ice: support per-packet Tx timestamp slots

Error: on E822, get_caps reports max_slots = 64, but the allocator
limits each PF to 64 / ICE_PORTS_PER_QUAD = 16. Report what alloc can
actually return.

Error: legacy and slot paths share a register. ptp_tx_index is 0 on
E810/E830/ETH56G and (pf_id % 4) * 16 on E822, which is exactly the
first slot ice_ptp_alloc_tx_slot() returns. Any TMST packet without
the dynflag (testpmd ieee1588fwd, or a legacy caller on the same
port) lands in a slot owned by a slot-API user. Reserve it at init:

	rte_atomic_store_explicit(&ad->ts_slot_bitmap,
		RTE_BIT64(ad->ptp_tx_index), rte_memory_order_relaxed);

and report max_slots - 1.

Error: release clears the PHY slot only on E810. On E822 the ready
bit stays set until the slot is read, so a slot released without a
successful read (timeout, dropped packet) gives the next owner the
previous packet's timestamp. ice_clear_phy_tstamp() already handles
E822 (read to clear) and ETH56G; call it for every PHY model and
ignore ICE_ERR_NOT_SUPPORTED. The same applies to the new timeout
clear in the legacy path.

Error: E810 has no ready bitmap; ice_get_phy_tx_tstamp_ready_e810()
returns all ones. tx_slot_read() then returns whatever nonzero value
is in the register, including a stale one left by the kernel driver or
a previous DPDK run, before the packet is even sent. Clear all slots
in this PF's range in timesync_enable, or check the timestamp valid
bit as the kernel driver does.

Warning: the legacy fix (poll ptp_tx_index instead of bit 0) is a real
bug on E822 PF 1-3, where the old code polls slot 0's ready bit and
reads slot 16*N. It is in 24.11 and 25.11. Split it, with the E810
clear-after-read, into its own patch:

	Fixes: b55051d1c59d ("net/ice: fix reading invalid PHY timestamp")
	Cc: stable@dpdk.org

Warning: read and release check only slot_id > 63. They do not check
that the slot is allocated or inside this PF's E822 range. Releasing
an unallocated slot returns 0 and on E810 clears a register in use by
someone else. Return -EINVAL as the API says:

	uint64_t bit = RTE_BIT64(slot_id);

	if (slot_id >= ICE_PTP_TX_SLOTS)
		return -EINVAL;
	if (!(rte_atomic_fetch_and_explicit(&ad->ts_slot_bitmap, ~bit,
			rte_memory_order_release) & bit))
		return -EINVAL;

(clear the PHY slot before freeing the bit), and a load-and-test of
the bit in read.

Warning: hardware access failures in ice_ptp_read_tx_dual_timestamp()
are returned as -EAGAIN, so the app polls forever on a dead sideband.
Return -EIO for errors from ice_get_phy_tx_tstamp_ready() and
ice_read_phy_tstamp(); keep -EAGAIN for "not ready".

Warning: the slot bitmap is never reset on timesync_disable or
dev_close, so slots leak across restart. Reset it (with the reserved
legacy bit) where ptp_ena is cleared.

Warning: in get_context_desc() the slot id comes from an
application-writable mbuf field and goes into the descriptor with only
the 18-bit TSO_LEN mask. Mask it to the 64-slot range. Also move the
dynflag test after the ice_calc_context_desc() early return so
non-PTP packets do not load the global.

Info: ice_get_next_tx_desc_idx() wraps ice_ptp_alloc_tx_slot() and
adds nothing; the name is also misleading. Drop it. The dev == NULL
checks in the new ops are dead; ethdev validated the port.

Info: 64 appears in five places. Add a define (ICE_PTP_TX_SLOTS).
"*slot_id = (uint32_t)(uint16_t)idx" needs only one cast.


[PATCH 5/5] app/testpmd: add Tx timestamp capabilities command

Warning: a "show" command must not change state. The alloc/release
round trip fails when all slots are in use and races with forwarding.
Remove it; exercise the API from ieee1588fwd instead.

Warning: the new command is not documented in
doc/guides/testpmd_app_ug/testpmd_funcs.rst or in the help text.

Info: max_slots is printed when type is not PER_PACKET, where the API
says it is not valid.

  parent reply	other threads:[~2026-12-01  0:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 19:24 [RFC 0/1] ethdev: per-packet Tx timestamp slot management Rajesh Kumar
2026-08-17 19:24 ` [RFC 1/1] ethdev: add per-packet Tx timestamp slot APIs Rajesh Kumar
2026-08-20  4:51   ` Naga Harish K, S V
2026-08-18  2:23 ` [RFC 0/1] ethdev: per-packet Tx timestamp slot management Stephen Hemminger
2026-08-20  4:41 ` Naga Harish K, S V
2026-08-27 11:09   ` Kumar, Rajesh
2026-08-27 12:13 ` [RFC PATCH v2 0/1] ethdev: add Tx timestamp slot APIs Rajesh Kumar
2026-08-27 12:13   ` [RFC PATCH v3 1/1] ethdev: add Tx timestamp slot management APIs Rajesh Kumar
2026-08-27 12:18 ` [RFC PATCH v3 0/1] ethdev: add Tx timestamp slot APIs Rajesh Kumar
2026-08-27 12:21 ` Rajesh Kumar
2026-08-27 12:21   ` [RFC PATCH v3 1/1] ethdev: add Tx timestamp slot management APIs Rajesh Kumar
2026-08-27 21:45     ` Stephen Hemminger
2026-09-02  5:51     ` [RFC PATCH v4 0/3] ethdev: add Tx timestamp slot APIs Rajesh Kumar
2026-09-02  5:51       ` [RFC PATCH v4 1/3] ethdev: add Tx timestamp slot management APIs Rajesh Kumar
2026-09-02 14:13         ` Stephen Hemminger
2026-09-08  7:25           ` Kumar, Rajesh
2026-09-02  5:51       ` [RFC PATCH v4 2/3] net/ice: support per-packet Tx timestamp slots Rajesh Kumar
2026-09-02  5:51       ` [RFC PATCH v4 3/3] app/testpmd: add Tx timestamp capabilities command Rajesh Kumar
2026-09-08  7:32     ` [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs Rajesh Kumar
2026-09-08  7:32       ` [RFC PATCH v5 1/5] ethdev: add Tx timestamp slot management APIs Rajesh Kumar
2026-09-08  7:32       ` [RFC PATCH v5 2/5] doc: describe ethdev timesync clock and Rx timestamp API Rajesh Kumar
2026-09-08  7:32       ` [RFC PATCH v5 3/5] doc: describe ethdev Tx timestamp slot API Rajesh Kumar
2026-09-08  7:32       ` [RFC PATCH v5 4/5] net/ice: support per-packet Tx timestamp slots Rajesh Kumar
2026-09-08  7:32       ` [RFC PATCH v5 5/5] app/testpmd: add Tx timestamp capabilities command Rajesh Kumar
2026-09-21 15:00       ` [RFC PATCH v5 0/5] ethdev: add Tx timestamp slot APIs Kumar, Rajesh
2026-10-06 10:28         ` Kumar, Rajesh
2026-10-06 14:16           ` Stephen Hemminger
2026-12-01  0:52       ` Stephen Hemminger [this message]
2026-08-27 12:34 ` [RFC PATCH v2 0/1] " Rajesh Kumar
2026-08-27 12:34   ` [RFC PATCH v2 1/1] ethdev: add Tx timestamp slot management APIs Rajesh Kumar
2026-09-02 14:16   ` [RFC PATCH v2 0/1] ethdev: add Tx timestamp slot APIs Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130165209.31c1d442@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=aman.deep.singh@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=rajesh3.kumar@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox