Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD993606A31A for ; Tue, 1 Dec 2026 00:52:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=DjkcN/Ia Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 365DD40289; Tue, 1 Dec 2026 01:52:16 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTPS id 32F0340285 for ; Tue, 1 Dec 2026 01:52:15 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-cdb684859cbso6440947a12.1 for ; Mon, 30 Nov 2026 16:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796086333; x=1796691133; darn=dpdk.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=TmWdzRu32cETD5Hel/+VJHyeDN7ddBCr7BdFCJrHwrA=; b=DjkcN/Iagj2A+gY10fcW3ft7qOP427H84ltUrnKdDobKi1c9rJJKQ05ITq1L+eQ7vJ RtrT3lyRoWedzkPcYj9UHEot80DAao15OgjXk2krZtrfLrcWlstLW4BoUj1ImbSrFg9J mHKFvDmoBGzA5lEJ+8hhPLIvxL3lcnPG51Vju8z2zwK3MvY3LAjQHQxRTMF1hR0sahEu xCI+xJOH0ylQQ3J5y6xhDfuffoKfCEmmEsL5c6RKIPnu1QZL0FExuezLL1pOnIAfWjIP K3vpiZ7ihgIEqzJVfgYRDyumn1/6XIGAXNN/QhZdPSClNE+MFJ/uF0GsXkJ2PuPMYNGm rMRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796086333; x=1796691133; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TmWdzRu32cETD5Hel/+VJHyeDN7ddBCr7BdFCJrHwrA=; b=PxYiD9vp9lcRj1+rIImkezlCJzjEEXFNzrDXUyQLP7eMAES1NNO9W/Qeilh0RZcs7b A88VeCkQTDmmn6Ql1DJNHvc/X4QnLhojl/U9QuEBAODp3q2crd3b/wZnL8O0Rgn7BqN2 /L4isxicgiKnTEoCUVoeUJWkRI6p6Vqt8o9jBJX7QMO3OGIIgCiW+btWVs3UlPkDRJ7P ijiEUrYDuXmzZyCptvatwFYJ3Nam9Mkn1dDhgjqtz5ltHtfCi6yETw5o6EiqPyZ5lUyS WIvpkvmQbapWTkWghsKtr7CdpZdbNQ43Kz2WOvzVqJmflCxUiCaAEMOqqdWrUQGOqW2X NKCA== X-Gm-Message-State: APuU4Z+cUJSm5O6fWDfHoOj9A7h9KFrNMVg3ubmrH1+/fB0rGuw/gxox mpk7t6l63wr0tUR6nUJNayDf0FoX82+2fnQ+mCnruxIS4dambHOSBYt8IWu+BweOUS8= X-Gm-Gg: AZFdTZdfbXKSW7tmOFgnod5dpXUhsXEI89c+Z/IouRMLmd8wldUu9sBe1U/mn3GmK8e ZcXG8CXPRCR7Fz0UIBXUUaPz62oUU3TwWRc6Kup8AATIqaJXLIN1r/GBbtDHT9DgEKDTKd5EJau JavyaoCaI36mKP9oy/s8YxIoIEjWBOtchtBSKohd8so1j5TQSi9YhfGCBHODdhrtcHAmEILaP0G mYQ9SRE/mTMBSBzT8NLNzojaapDS85RF3hzgUxriorF3H3gMkA7PbHo8ZIM/36IXYfxJE333ejK MfUFIGfsxiE9wq6h+aMr5LZz95gdw8ahJP8eHvBddUIxTjHnH8hiBVdF02B0MXjmlHfhQ3H9gCc 8806R1W/rk2mhnDGouZkEBYPrCo2OFhbuUqdFLcyBOZ09pidb9oZBVjqUF1m2J0KADT249MDvwl HpUvqyDip2VQYZGABKjhAVHe0Qq2ig7k2G72dT3/ss/V8MLjNfyqa2HkvI/tMC8Zhbvd4kT1AHv n89sQ/nBBEMM350lf13tUUA1Qi14WV+Vc/OB+ZPYg4T8F9B5i9bwN7+IT8tFibicqlbvvS/VtCr TndKMjE5IKM7wkQzD1a2TDZEJcBlSt4xb3R3zw9u3QG3GvYp7eOBl6a0k9ec5ECgLr26Uww= X-Received: by 2002:a17:90b:3912:b0:3b3:b632:7f1b with SMTP id 98e67ed59e1d1-3b41c9b2be0mr38216237a91.12.1796086333075; Mon, 30 Nov 2026 16:52:13 -0800 (PST) Received: from phoenix.local (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41abb2076sm55552219a91.2.2026.11.30.16.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 16:52:12 -0800 (PST) Date: Mon, 30 Nov 2026 16:52:09 -0800 From: Stephen Hemminger To: Rajesh Kumar 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 Message-ID: <20261130165209.31c1d442@phoenix.local> In-Reply-To: <20260908073206.1236372-1-rajesh3.kumar@intel.com> References: <20260827122200.339388-2-rajesh3.kumar@intel.com> <20260908073206.1236372-1-rajesh3.kumar@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, 8 Sep 2026 13:02:01 +0530 Rajesh Kumar 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.