net/ena: add Rx HW timestamping support
PATCH 7/21 net/ena: add Rx HW timestamping support
Add support for retrieving HW timestamps for Rx packets with nanosecond resolution.
The feature is supported on platforms that set RTE_ETH_RX_OFFLOAD_TIMESTAMP flag in rx_offload_capa, and is configurable through setting RTE_ETH_RX_OFFLOAD_TIMESTAMP in dev_conf rxmode offloads.
Signed-off-by Amit Bernstein <[email protected]>
Signed-off-by Shai Brandes <[email protected]>
Reviewed-by Yosef Raisman <[email protected]>
--- doc/guides/nics/ena.rst | 4 + doc/guides/rel_notes/release_25_11.rst | 4 + drivers/net/ena/base/ena_com.c | 80 ++++++++++++++++++- drivers/net/ena/base/ena_com.h | 32 ++++++++ .../net/ena/base/ena_defs/ena_admin_defs.h | 44 ++++++++++ .../net/ena/base/ena_defs/ena_eth_io_defs.h | 8 +- drivers/net/ena/base/ena_eth_com.c | 15 ++++ drivers/net/ena/base/ena_eth_com.h | 10 ++- drivers/net/ena/ena_ethdev.c | 79 +++++++++++++++++- drivers/net/ena/ena_ethdev.h | 18 +++++ 10 files changed, 285 insertions(+), 9 deletions(-)
doc/guides/nics/ena.rst +4 -0
@@ -32,6 +32,7 @@ Supported features * Watchdog (requires handling of timers in the application) * Device reset upon failure * Rx interrupts +* Rx HW packet timestamping Overview --------
@@ -55,6 +56,9 @@ Receive-side scaling (RSS) is supported for multi-core scaling. Some of the ENA devices support a working mode called Low-latency Queue (LLQ), which saves several more microseconds. +Rx hardware timestamping is available in the ENA driver on platforms that +support this feature + Management Interface --------------------
doc/guides/rel_notes/release_25_11.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Amazon ENA (Elastic Network Adapter) net driver.** + + * Added support for retrieving HW timestamps for Rx packets with nanosecond resolution. + * **Added speed 800G.** Added Ethernet link speed for 800 Gb/s as it is well standardized in IEEE,
drivers/net/ena/base/ena_com.c +78 -2
92 lines not on this page · raw message
drivers/net/ena/base/ena_com.h +32 -0
@@ -1155,6 +1155,38 @@ static inline void ena_com_disable_adaptive_moderation(struct ena_com_dev *ena_d ena_dev->adaptive_coalescing = false; } +/* ena_com_hw_timestamping_supported - query whether HW timestamping is +* supported by the device +* @ena_dev: ENA communication layer struct +* +* @return - true if the feature is supported or false otherwise +*/ +bool ena_com_hw_timestamping_supported (struct ena_com_dev *ena_dev); + +/* ena_com_get_hw_timestamping_support - query HW timestamping support options +* in the device +* @ena_dev: ENA communication layer struct +* @tx_support: Will hold the TX side supported options +* @rx_support: Will hold the RX side supported options +* +* @return - 0 on success, negative value on failure. +*/ +int ena_com_get_hw_timestamping_support (struct ena_com_dev *ena_dev, +u8 *tx_support, +u8 *rx_support); + +/* ena_com_set_hw_timestamping_configuration - set HW timestamping configuration +* +* @ena_dev: ENA communication layer struct +* @tx_enable: Enable/Disable TX HW timestamping +* @rx_enable: Enable/Disable RX HW timestamping +* +* @return - 0 on success, negative value on failure. +*/ +int ena_com_set_hw_timestamping_configuration (struct ena_com_dev *ena_dev, +u8 tx_enable, +u8 rx_enable); +bool ena_com_indirection_table_config_supported (struct ena_com_dev *ena_dev);/* ena_com_get_cap - query whether device supports a capability. * @ena_dev: ENA communication layer struct
drivers/net/ena/base/ena_defs/ena_admin_defs.h +44 -0
74 lines not on this page · raw message
drivers/net/ena/base/ena_defs/ena_eth_io_defs.h +4 -4
@@ -166,9 +166,9 @@ struct ena_eth_io_tx_cdesc {struct ena_eth_io_tx_cdesc_ext {struct ena_eth_io_tx_cdesc base; -uint32_t reserved_w2; +uint32_t timestamp_low; -uint32_t reserved_w3; +uint32_t timestamp_high; };struct ena_eth_io_rx_desc {
@@ -263,9 +263,9 @@ struct ena_eth_io_rx_cdesc_ext {uint16_t reserved16; -uint32_t reserved_w6; +uint32_t timestamp_low; -uint32_t reserved_w7; +uint32_t timestamp_high; };struct ena_eth_io_intr_reg {
drivers/net/ena/base/ena_eth_com.c +15 -0
@@ -56,6 +56,11 @@ void ena_com_dump_single_rx_cdesc(struct ena_com_io_cq *io_cq,ENA_FIELD_GET (desc->base.status, (uint32_t )ENA_ETH_IO_RX_CDESC_BASE_MBZ17_MASK , ENA_ETH_IO_RX_CDESC_BASE_MBZ17_SHIFT)); +if (unlikely (ena_com_is_extended_rx_cdesc (io_cq))) +ena_trc_err (ena_com_io_cq_to_ena_dev (io_cq), +"RX descriptor timestamp %" ENA_PRIu64"(nsec)" , + (uint64_t )desc->timestamp_low | + (uint64_t )desc->timestamp_high <<32 ); } }
@@ -74,6 +79,12 @@ void ena_com_dump_single_tx_cdesc(struct ena_com_io_cq *io_cq,ENA_FIELD_GET (desc->base.flags, (uint32_t )ENA_ETH_IO_TX_CDESC_MBZ6_MASK , ENA_ETH_IO_TX_CDESC_MBZ6_SHIFT)); + +if (unlikely (ena_com_is_extended_tx_cdesc (io_cq))) +ena_trc_err (ena_com_io_cq_to_ena_dev (io_cq), +"TX descriptor timestamp %" ENA_PRIu64"(nsec)" , + (uint64_t )desc->timestamp_low | + (uint64_t )desc->timestamp_high <<32 ); } }
@@ -683,6 +694,10 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,/* Get rx flags from the last pkt */ ena_com_rx_set_flags (ena_rx_ctx, cdesc); +if (unlikely (ena_com_is_extended_rx_cdesc (io_cq))) + ena_rx_ctx->timestamp = (u64 )cdesc->timestamp_low | + (u64 )cdesc->timestamp_high <<32 ; + ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq), "l3_proto %d l4_proto %d l3_csum_err %d l4_csum_err %d hash %d frag %d cdesc_status %x\n", ena_rx_ctx->l3_proto,
drivers/net/ena/base/ena_eth_com.h +8 -2
@@ -60,6 +60,7 @@ struct ena_com_rx_ctx {u16 descs;u16 max_bufs;u8 pkt_offset; +u64 timestamp; }; int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,
@@ -234,8 +235,9 @@ static inline void ena_com_cq_inc_head(struct ena_com_io_cq *io_cq) io_cq->phase ^=1 ; } -static inline int ena_com_tx_comp_req_id_get (struct ena_com_io_cq *io_cq, -u16 *req_id) +static inline int ena_com_tx_comp_metadata_get (struct ena_com_io_cq *io_cq, +u16 *req_id, +u64 *hw_timestamp) {struct ena_com_dev *dev =ena_com_io_cq_to_ena_dev (io_cq);struct ena_eth_io_tx_cdesc_ext *cdesc;
@@ -279,6 +281,10 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,return ENA_COM_INVAL ; } +if (unlikely (ena_com_is_extended_tx_cdesc (io_cq))) + *hw_timestamp = (u64 )cdesc->timestamp_low | + (u64 )cdesc->timestamp_high <<32 ; +ena_com_cq_inc_head (io_cq);return 0 ;
drivers/net/ena/ena_ethdev.c +78 -1
133 lines not on this page · raw message
drivers/net/ena/ena_ethdev.h +18 -0
@@ -141,6 +141,18 @@ struct ena_stats_rx {u64 unknown_error; }; +struct ena_timestamp_config { +u8 hw_tx_supported; +u8 hw_rx_supported; +}; + +struct ena_timestamp_mbuf { +/* Dynamic mbuf timestamp flag */ +uint64_t rx_flag; +/* Dynamic mbuf timestamp field offset */ +int offset; +}; +struct __rte_cache_aligned ena_ring {u16 next_to_use;u16 next_to_clean;
@@ -199,6 +211,9 @@ struct __rte_cache_aligned ena_ring {unsigned int numa_socket_id;uint32_t missing_tx_completion_threshold; + +/* Dynamic mbuf params for HW timestamping */ +struct ena_timestamp_mbuf ts_mbuf; };enum ena_adapter_state {
@@ -350,6 +365,9 @@ struct ena_adapter {uint64_t control_path_poll_interval;bool enable_frag_bypass; + +/* HW timestamp support by the device */ +struct ena_timestamp_config ts;/* * Helper variables for holding the information about the supported * metrics.
Signature · 1 line
2.17.1