On Sun, 28 Jun 2026 17:50:03 -0700
Mark Blasko <[email protected]> wrote:
> In AF_PACKET, the PMD reads the timestamp from socket ring headers
> because the kernel stack processes the packet and allocates a socket
> buffer. Since the kernel stack and socket buffer allocation are bypassed
> in AF_XDP, UMEM frames are given directly to the PMD, which
> means the kernel never generates these socket headers. Also, it
> looks like the TAP PMD doesn't support RX timestamps.
>
> Since the location of metadata in the UMEM headroom is determined
> by the XDP program, the current driver implementation is coupled to
> a specific XDP program layout. As an alternative, we could just
> plumb the entire metadata headroom to the DPDK application and let
> the application parse it based on whatever XDP program is in use.
> That would couple the application and the XDP program, but would
> at least decouple the driver and the XDP program.
Sorry if I was not clear enough before.
The DPDK PMD provides an abstraction to applications to avoid exposing
as many details as possible. Whenever possible a PMD should follow
precedent and implement functions in a manner similar to other drivers.
The method of expressing received timestamps was never well described
in DPDK documentation. The convention is:
- A dynamic field in mbuf is used for the timestamp.
- All drivers using timestamp should register the same field
using rte_mbuf_dyn_rx_timestamp_register.
- The mbuf field is filled inside the rx_burst processing.
- The timestamp dynamic field is a 64 bit unsigned number rolling
clock value.
- A PMD providing timestamp, must also define a readclock ethdev dev ops
so that application can compute the number of ticks in timestamp per
time interval.
- A PMD providing timestamp must advertise that in offload flags.
- Timestamp should only be inserted if the Rx timestamp offload flag
is set during configuration.
When I read this was a little confused about meta data in mbuf.
Would have been clearer with a simple helper:
static inline void
af_xdp_rx_timestamp(struct rte_mbuf *m)
{
const struct af_xdp_rx_metadata *meta
= rte_pktmbuf_mtod_offset(m, struct af_xdp_rx_metadata,
-(int)sizeof(*meta));
*RTE_MBUF_DYNFIELD(m, timestamp_dynfield_offset, uint64_t *) =
meta->rx_timestamp;
m->ol_flags |= timestamp_dynflag;
}
If you are going to do Rx timestamp then a simple readclock ethdev op
is also needed to tell the application what the units are.
But there are bigger issues with this patch:
1. The patch assumes metadata is always present in XDP receive but device
used by XDP may not implement it. There is no capability checking.
The DPDK PMD ends up advertising RTE_ETH_RX_OFFLOAD_TIMESTAMP
unconditionally even if underling kernel device doesn't do it.
2. The format of metadata is not a documented contract between kernel
device implementing XDP and the DPDK.
3. The XDP documentation says you need to check for metadata
in each frame.
4. There are no head bounds checks; must check that there is
packet headroom is configured with enough space for metadata.
I am sure AI will find several more things but need fixing
before ready to merge.