Feature/hw timestamp -- userspace/dpdk/ena: add HW RX timestamp support #372
Open
RichardLeeY wants to merge 3 commits into
Open
Feature/hw timestamp -- userspace/dpdk/ena: add HW RX timestamp support #372RichardLeeY wants to merge 3 commits into
RichardLeeY wants to merge 3 commits into
Conversation
Port hardware timestamp support from the kernel ENA driver to the DPDK PMD. The ENA NIC writes per-packet nanosecond timestamps into extended completion descriptors, but the DPDK PMD previously ignored these fields (labeled reserved_w6/reserved_w7). Changes across the ena_com HAL layer: - ena_admin_defs.h: add ENA_ADMIN_HW_TIMESTAMP feature ID 31, enums for version/tx/rx support, and feature descriptor struct - ena_eth_io_defs.h: rename reserved_w6/w7 to timestamp_low/high in rx cdesc_ext, add tx cdesc_ext struct - ena_com.h: add use_extended_tx/rx_cdesc flags, use_extended_cdesc in create_io_ctx, declare hw timestamping functions - ena_com.c: conditional extended cdesc allocation in init_io_cq, implement hw_timestamping_supported/get/set functions - ena_eth_com.h: add timestamp field to rx_ctx, add cdesc helpers - ena_eth_com.c: extract timestamp from extended rx cdesc Changes in the PMD ethdev layer: - ena_ethdev.h: add hw_ts state fields to adapter struct - ena_ethdev.c: query HW timestamp support at init, advertise RTE_ETH_RX_OFFLOAD_TIMESTAMP capability, enable via admin command in dev_configure, allocate extended cdescs for RX queues, populate mbuf dynfield with HW timestamp, disable on close Tested: builds cleanly against DPDK 25.03 (meson, 0 errors). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes from security/performance/robustness review of the HW RX timestamp feature: - Add explicit has_timestamp flag in ena_com_rx_ctx so a legitimate timestamp value of 0 is no longer dropped as "no timestamp". - Zero-init has_timestamp and timestamp in the per-packet RX loop to avoid stale stack data being written to the mbuf dynfield. - Remove the wrong unlikely() hint from the extended-cdesc branch in ena_com_rx_pkt(); when the feature is enabled this is the common path and the hint caused consistent mispredicts. - Cache hw_ts_enabled, dynfield offset and dynflag bit in struct ena_ring so the RX fast path avoids an adapter pointer-chase and cold-cacheline load per packet. - Check rx_ring->hw_ts_enabled first in ena_rx_mbuf_prepare so the feature-off path short-circuits before touching has_timestamp. - Add rollback in ena_dev_configure: if dynfield/dynflag registration fails after HW timestamping was enabled on the device, disable it again and reset driver state so the device and driver no longer disagree on cdesc size. - Disable HW timestamping on the device when the user reconfigures without the offload, to keep cdesc sizes consistent across dev_configure cycles. - Reject RTE_ETH_TX_OFFLOAD_TIMESTAMP in dev_configure instead of silently ignoring it; TX HW timestamping is not implemented. - Hoist the dynfield/dynflag descriptor statics out of function scope for readability. - Clear per-ring hw_ts_enabled and adapter dynfield state in ena_close to keep state consistent across reset cycles. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port hardware RX timestamp support from the kernel ENA driver to the DPDK PMD. The ENA NIC writes per-packet nanosecond timestamps into extended completion descriptors, but the DPDK PMD previously ignored these fields (labeled
reserved_w6/reserved_w7).This PR wires the feature through the
ena_comHAL and the DPDK ethdev layer so applications can opt in viaRTE_ETH_RX_OFFLOAD_TIMESTAMPand read the HW timestamp from the standard mbuf dynfield.Changes
ena_comHALena_admin_defs.h: addENA_ADMIN_HW_TIMESTAMPfeature ID 31 with version/TX/RX enums and feature descriptor struct.ena_eth_io_defs.h: renamereserved_w6/w7totimestamp_low/highin RX extended cdesc; add TX extended cdesc struct.ena_com.[ch]: adduse_extended_tx_cdesc/use_extended_rx_cdescflags anduse_extended_cdescin create_io_ctx; allocate extended cdescs conditionally ininit_io_cq; implementhw_timestamping_supported/get/sethelpers.ena_eth_com.[ch]: extract timestamp from the extended RX cdesc into a newtimestamp+has_timestamppair onena_com_rx_ctx.DPDK PMD (ethdev layer)
RTE_ETH_RX_OFFLOAD_TIMESTAMPcapability.dev_configureand populate the mbuf dynfield + dynflag from the cdesc timestamp in the RX path.RTE_ETH_TX_OFFLOAD_TIMESTAMPexplicitly (TX HW timestamping is not implemented).dev_configure: if dynfield/dynflag registration fails after the feature was enabled on the device, disable it so cdesc sizes stay consistent with the driver.ena_closeso state stays consistent across reset cycles.hw_ts_enabled, dynfield offset and dynflag bit instruct ena_ringso the RX fast path avoids an adapter pointer-chase per packet.Correctness notes
has_timestampis an explicit flag so a legitimate timestamp value of0is not dropped.has_timestamp/timestampare zero-initialized in the per-packet RX loop to avoid stale stack data.ena_com_rx_pkt()is no longer markedunlikely()— when the feature is enabled this is the common path.Test plan
meson/ninjabuild against DPDK 25.03: 0 errors, 0 warnings.RTE_MBUF_DYNFIELD_TIMESTAMP_NAME.-ENOTSUPcleanly.dev_configure→dev_configurewithout the offload correctly disables the feature on-device.