dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, stable@dpdk.org
Subject: [PATCH 1/2] net/pcap: fix Rx timestamp in secondary process
Date: Sat, 14 Nov 2026 10:57:00 -0800	[thread overview]
Message-ID: <20261114185701.833180-1-stephen@networkplumber.org> (raw)

The offset and flag of the Rx timestamp dynamic field are the same
in all processes, but the driver keeps them in static variables
which are only set in dev_configure. A secondary process does not
configure the port, so its copy of the offset is still -1 while the
shared device data says the offload is enabled. The Rx burst then
stores the timestamp over buf_addr of the mbuf.

Move the offset and flag into the device private data, which is
shared with secondary processes.

Bugzilla ID: 2128
Fixes: 32fd14bf07f8 ("net/pcap: support nanosecond timestamp precision")
Cc: stable@dpdk.org

Reported-by: Anthropic OSS Scanner (ANT-2026-80N5ICNL)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/pcap/pcap_ethdev.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 1e114e0008..b89f4a0c2e 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -60,9 +60,6 @@ static struct timespec start_time;
 static uint64_t start_cycles;
 static uint64_t hz;
 
-static uint64_t timestamp_rx_dynflag;
-static int timestamp_dynfield_offset = -1;
-
 struct queue_stat {
 	volatile unsigned long pkts;
 	volatile unsigned long bytes;
@@ -122,6 +119,8 @@ struct pmd_internals {
 	bool rx_scatter;
 	bool timestamp_offloading;
 	bool lsc_active;
+	int timestamp_dynfield_offset;
+	uint64_t timestamp_rx_dynflag;
 };
 
 struct pmd_process_private {
@@ -268,6 +267,7 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	int i;
 	struct pcap_rx_queue *pcap_q = queue;
+	struct pmd_internals *internals = rte_eth_devices[pcap_q->port_id].data->dev_private;
 	uint32_t rx_bytes = 0;
 
 	if (unlikely(nb_pkts == 0))
@@ -296,9 +296,9 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			struct timespec ts;
 
 			timespec_get(&ts, TIME_UTC);
-			*RTE_MBUF_DYNFIELD(bufs[i], timestamp_dynfield_offset,
+			*RTE_MBUF_DYNFIELD(bufs[i], internals->timestamp_dynfield_offset,
 					   rte_mbuf_timestamp_t *) = rte_timespec_to_ns(&ts);
-			bufs[i]->ol_flags |= timestamp_rx_dynflag;
+			bufs[i]->ol_flags |= internals->timestamp_rx_dynflag;
 		}
 
 		rx_bytes += bufs[i]->data_len;
@@ -420,10 +420,10 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			uint64_t ns = (uint64_t)header->ts.tv_sec * NSEC_PER_SEC
 				+  header->ts.tv_usec;
 
-			*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset,
+			*RTE_MBUF_DYNFIELD(mbuf, internals->timestamp_dynfield_offset,
 					   rte_mbuf_timestamp_t *) = ns;
 
-			mbuf->ol_flags |= timestamp_rx_dynflag;
+			mbuf->ol_flags |= internals->timestamp_rx_dynflag;
 		}
 
 		mbuf->port = pcap_q->port_id;
@@ -1027,9 +1027,9 @@ eth_dev_configure(struct rte_eth_dev *dev)
 	internals->rx_scatter = !!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_SCATTER);
 	internals->timestamp_offloading = !!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP);
 
-	if (internals->timestamp_offloading && timestamp_rx_dynflag == 0) {
-		int ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
-							     &timestamp_rx_dynflag);
+	if (internals->timestamp_offloading && internals->timestamp_rx_dynflag == 0) {
+		int ret = rte_mbuf_dyn_rx_timestamp_register(&internals->timestamp_dynfield_offset,
+							     &internals->timestamp_rx_dynflag);
 		if (ret != 0) {
 			PMD_LOG(ERR, "Failed to register Rx timestamp field/flag");
 			return ret;
-- 
2.53.0


             reply	other threads:[~2026-11-14 18:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:57 Stephen Hemminger [this message]
2026-11-14 18:57 ` [PATCH 2/2] net/pcap: handle > 64K packets in capture file 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=20261114185701.833180-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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;
as well as URLs for NNTP newsgroup(s).