* [PATCH] net/af_xdp: add Rx metadata and dynamic timestamping support
@ 2026-06-23 21:53 Mark Blasko
2026-06-23 22:06 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Mark Blasko @ 2026-06-23 21:53 UTC (permalink / raw)
To: dev, Ciara Loftus, Maryam Tahhan
Cc: Mark Blasko, Joshua Washington, Jasper Tran O'Leary
Enable dynamic RX timestamping in the AF_XDP Poll Mode Driver.
This extracts the ingress timestamp prepended to the packet
headroom by the XDP program and populates it in the mbuf.
Signed-off-by: Mark Blasko <blasko@google.com>
Reviewed-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Jasper Tran O'Leary <jtranoleary@google.com>
---
doc/guides/rel_notes/release_26_07.rst | 5 +++
drivers/net/af_xdp/rte_eth_af_xdp.c | 56 +++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index 6eba91a5e9..727442258f 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -63,6 +63,11 @@ New Features
``rte_eal_init`` and the application is responsible for probing each device,
* ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
+* **Updated AF_XDP ethernet driver.**
+
+ * Added support for dynamic RX metadata and timestamping offload
+ (``RTE_ETH_RX_OFFLOAD_TIMESTAMP``).
+
* **Added LinkData sxe2 ethernet driver.**
Added network driver for the LinkData network adapters.
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 2cdb533276..c90e232d57 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -62,6 +62,13 @@
#define PF_XDP AF_XDP
#endif
+struct af_xdp_rx_metadata {
+ uint64_t rx_timestamp;
+};
+
+static int timestamp_dynfield_offset = -1;
+static uint64_t timestamp_dynflag;
+
RTE_LOG_REGISTER_DEFAULT(af_xdp_logtype, NOTICE);
#define RTE_LOGTYPE_NET_AF_XDP af_xdp_logtype
@@ -144,6 +151,7 @@ struct pkt_rx_queue {
struct pollfd fds[1];
int xsk_queue_idx;
int busy_budget;
+ bool rx_timestamp_enabled;
};
struct tx_stats {
@@ -398,6 +406,20 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
rte_pktmbuf_pkt_len(bufs[i]) = len;
rte_pktmbuf_data_len(bufs[i]) = len;
+
+ if (rxq->rx_timestamp_enabled &&
+ timestamp_dynfield_offset >= 0) {
+ struct af_xdp_rx_metadata *meta;
+
+ meta = (struct af_xdp_rx_metadata *)
+ ((char *)rte_pktmbuf_mtod(bufs[i], void *) -
+ sizeof(struct af_xdp_rx_metadata));
+ *RTE_MBUF_DYNFIELD(bufs[i],
+ timestamp_dynfield_offset,
+ uint64_t *) = meta->rx_timestamp;
+ bufs[i]->ol_flags |= timestamp_dynflag;
+ }
+
rx_bytes += len;
}
@@ -457,6 +479,18 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
len = desc->len;
pkt = xsk_umem__get_data(rxq->umem->mz->addr, addr);
+ if (rxq->rx_timestamp_enabled &&
+ timestamp_dynfield_offset >= 0) {
+ struct af_xdp_rx_metadata *meta;
+
+ meta = (struct af_xdp_rx_metadata *)((char *)pkt -
+ sizeof(struct af_xdp_rx_metadata));
+ *RTE_MBUF_DYNFIELD(mbufs[i],
+ timestamp_dynfield_offset,
+ uint64_t *) = meta->rx_timestamp;
+ mbufs[i]->ol_flags |= timestamp_dynflag;
+ }
+
rte_memcpy(rte_pktmbuf_mtod(mbufs[i], void *), pkt, len);
rte_ring_enqueue(umem->buf_ring, (void *)addr);
rte_pktmbuf_pkt_len(mbufs[i]) = len;
@@ -743,6 +777,23 @@ eth_dev_start(struct rte_eth_dev *dev)
{
uint16_t i;
+ if (dev->data->dev_conf.rxmode.offloads &
+ RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+ int rc;
+
+ rc = rte_mbuf_dyn_rx_timestamp_register(
+ ×tamp_dynfield_offset,
+ ×tamp_dynflag);
+ if (rc) {
+ AF_XDP_LOG_LINE(ERR,
+ "Failed to register mbuf timestamp field");
+ return rc;
+ }
+ AF_XDP_LOG_LINE(INFO,
+ "Registered mbuf timestamp field, offset: %d",
+ timestamp_dynfield_offset);
+ }
+
dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -870,6 +921,8 @@ eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
dev_info->max_rx_queues = internals->queue_cnt;
dev_info->max_tx_queues = internals->queue_cnt;
+ dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
dev_info->max_rx_pktlen = getpagesize() -
@@ -1873,7 +1926,8 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
process_private->rxq_xsk_fds[rx_queue_id] = rxq->fds[0].fd;
rxq->port = dev->data->port_id;
-
+ rxq->rx_timestamp_enabled = !!(dev->data->dev_conf.rxmode.offloads &
+ RTE_ETH_RX_OFFLOAD_TIMESTAMP);
dev->data->rx_queues[rx_queue_id] = rxq;
return 0;
--
2.55.0.rc0.799.gd6f94ed593-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/af_xdp: add Rx metadata and dynamic timestamping support
2026-06-23 21:53 [PATCH] net/af_xdp: add Rx metadata and dynamic timestamping support Mark Blasko
@ 2026-06-23 22:06 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-06-23 22:06 UTC (permalink / raw)
To: Mark Blasko
Cc: dev, Ciara Loftus, Maryam Tahhan, Joshua Washington,
Jasper Tran O'Leary
On Tue, 23 Jun 2026 21:53:24 +0000
Mark Blasko <blasko@google.com> wrote:
> + if (rxq->rx_timestamp_enabled &&
> + timestamp_dynfield_offset >= 0) {
> + struct af_xdp_rx_metadata *meta;
> +
> + meta = (struct af_xdp_rx_metadata *)
> + ((char *)rte_pktmbuf_mtod(bufs[i], void *) -
> + sizeof(struct af_xdp_rx_metadata));
> + *RTE_MBUF_DYNFIELD(bufs[i],
> + timestamp_dynfield_offset,
> + uint64_t *) = meta->rx_timestamp;
> + bufs[i]->ol_flags |= timestamp_dynflag;
> + }
> +
Why does XDP time stamp need to be different than how other drivers
already do timestamps. See AF_PACKET and TAP device?
Should not be driver specific here.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-23 22:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 21:53 [PATCH] net/af_xdp: add Rx metadata and dynamic timestamping support Mark Blasko
2026-06-23 22:06 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox