|SUCCESS| [v4,2/2] net/iavf: reuse device alarm for PHC sync
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Sat May 9 01:50:32 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163829
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-05-08
Commit: Not available from patch file
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Subject: [PATCH v4 1/2] net/iavf: remove PHC polling from Rx datapath
This patch removes periodic PHC read/update checks from the Rx datapath
to avoid hot-path polling overhead while preserving timestamp conversion
functionality.
> diff --git a/drivers/net/intel/iavf/iavf_rxtx.c b/drivers/net/intel/iavf/iavf_rxtx.c
> index 4ff6c18dc4..fabccc89bf 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx.c
> +++ b/drivers/net/intel/iavf/iavf_rxtx.c
> @@ -1507,16 +1507,6 @@ iavf_recv_pkts_flex_rxd(void *rx_queue,
> rx_ring = rxq->rx_flex_ring;
> ptype_tbl = rxq->iavf_vsi->adapter->ptype_tbl;
>
> - if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
> - uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
> -
> - if (sw_cur_time - rxq->hw_time_update > 4) {
> - if (iavf_get_phc_time(rxq))
> - PMD_DRV_LOG(ERR, "get physical time failed");
> - rxq->hw_time_update = sw_cur_time;
> - }
> - }
> -
The removal of this PHC update block means that if the alarm-based sync
(introduced in patch 2/2) is delayed or not running, the rxq->phc_time
value could become stale. Does this code handle the case where
phc_time is significantly out of date and the 32-to-64-bit timestamp
conversion wraps incorrectly?
[ ... ]
> @@ -1585,7 +1575,6 @@ iavf_recv_pkts_flex_rxd(void *rx_queue,
> rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
>
> rxq->phc_time = ts_ns;
> - rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
Does the removal of hw_time_update here ensure the periodic alarm in
patch 2/2 still detects the need to update phc_time, or could this
cause synchronization issues between descriptor-based time updates and
the alarm-driven sync?
[ ... ]
> diff --git a/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c b/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
> index db0462f0f5..9349646d55 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
> +++ b/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
> @@ -514,18 +514,10 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct ci_rx_queue *rxq,
> if (!(rxdp->wb.status_error0 &
> rte_cpu_to_le_32(1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
> return 0;
> - bool is_tsinit = false;
> uint8_t inflection_point = 0;
> __m256i hw_low_last = _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, rxq->phc_time);
> if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
> - uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
> -
> - if (unlikely(sw_cur_time - rxq->hw_time_update > 4)) {
> - hw_low_last = _mm256_setzero_si256();
> - is_tsinit = 1;
> - } else {
> - hw_low_last = _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, rxq->phc_time);
> - }
> + hw_low_last = _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, rxq->phc_time);
> }
[ ... ]
> @@ -1152,10 +1144,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct ci_rx_queue *rxq,
> *RTE_MBUF_DYNFIELD(rx_pkts[i + 7],
> iavf_timestamp_dynfield_offset, uint32_t *) = _mm256_extract_epi32(ts_low1, 7);
>
> - if (unlikely(is_tsinit)) {
> + {
> uint32_t in_timestamp;
> - if (iavf_get_phc_time(rxq))
> - PMD_DRV_LOG(ERR, "get physical time failed");
> in_timestamp = *RTE_MBUF_DYNFIELD(rx_pkts[i + 0],
> iavf_timestamp_dynfield_offset, uint32_t *);
> rxq->phc_time = iavf_tstamp_convert_32b_64b(rxq->phc_time, in_timestamp);
Does this code always call iavf_tstamp_convert_32b_64b() now, even when
phc_time might be uninitialized or stale? Could this result in incorrect
timestamp conversions?
[ ... ]
---
Commit: Not available from patch file
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Subject: [PATCH v4 2/2] net/iavf: reuse device alarm for PHC sync
This patch integrates periodic PHC synchronization into the existing
device alarm callback instead of using a dedicated alarm.
> diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
> index 403c61e2e8..2f1779d47b 100644
> --- a/drivers/net/intel/iavf/iavf.h
> +++ b/drivers/net/intel/iavf/iavf.h
> @@ -76,6 +76,7 @@
> #define IAVF_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */
>
> #define IAVF_ALARM_INTERVAL 50000 /* us */
> +#define IAVF_PHC_SYNC_ALARM_INTERVAL_US 200000
[ ... ]
> @@ -383,6 +384,8 @@ struct iavf_adapter {
> enum iavf_rx_func_type rx_func_type;
> enum iavf_tx_func_type tx_func_type;
> uint16_t fdir_ref_cnt;
> + uint8_t phc_sync_ticks;
> + bool phc_sync_paused;
Is phc_sync_ticks protected by a lock when accessed from multiple
threads, or could concurrent access to this field cause races between
iavf_dev_alarm_handler() and control path functions?
[ ... ]
> diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
> index 1eca20bc9a..02272d45c1 100644
> --- a/drivers/net/intel/iavf/iavf_ethdev.c
> +++ b/drivers/net/intel/iavf/iavf_ethdev.c
[ ... ]
> @@ -2723,10 +2731,70 @@ iavf_dev_alarm_handler(void *param)
>
> iavf_enable_irq0(hw);
>
> + if (iavf_phc_sync_alarm_needed(dev) && !adapter->phc_sync_paused) {
> + adapter->phc_sync_ticks++;
> + if (adapter->phc_sync_ticks >=
> + IAVF_PHC_SYNC_ALARM_INTERVAL_US / IAVF_ALARM_INTERVAL) {
> + struct ci_rx_queue *rxq = dev->data->rx_queues[0];
> +
> + adapter->phc_sync_ticks = 0;
> + if (iavf_get_phc_time(rxq) == 0)
> + rxq->hw_time_update = rte_get_timer_cycles() /
> + (rte_get_timer_hz() / 1000);
Does this code handle timer wrap at rte_get_timer_cycles()? Could a
wrap cause hw_time_update to appear "older" than expected in other code
paths comparing timestamps?
[ ... ]
> +static bool
> +iavf_phc_sync_alarm_needed(struct rte_eth_dev *dev)
> +{
> + struct iavf_adapter *adapter;
> +
> + adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> +
> + if (adapter->closed || adapter->stopped)
> + return false;
> +
> + if (!(dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP))
> + return false;
> +
> + if (dev->data->nb_rx_queues == 0 || dev->data->rx_queues[0] == NULL)
> + return false;
Does this function guarantee that rx_queues[0] remains valid throughout
the alarm handler's execution, or could a queue reconfiguration race
cause a use-after-free when iavf_dev_alarm_handler() accesses rxq?
> +
> + return true;
> +}
[ ... ]
More information about the test-report
mailing list