|SUCCESS| [v2,2/2] net/iavf: reuse device alarm for PHC sync
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu Apr 2 10:31:32 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162823
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-02
git commit: [PATCH v2 1/2] net/iavf: remove PHC polling from Rx datapath
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Remove periodic PHC read/update checks from scalar and vector flex
RX paths, keeping timestamp conversion based on queue PHC state.
This avoids hot-path PHC polling overhead and preserves the latency
fix for RX timestamp-enabled traffic.
> 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;
> - }
> - }
> -
Does the removal of the periodic PHC update from the Rx hot path leave a
time window where rxq->phc_time becomes stale? If packets with timestamps
arrive before the new alarm-based sync runs, could this code produce
incorrect timestamp conversions in iavf_tstamp_convert_32b_64b()?
> @@ -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 removing hw_time_update here break the synchronization logic that the
alarm callback in patch 2/2 expects? The alarm sets hw_time_update, but
this receive path no longer maintains it.
[ ... ]
> 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);
> }
Removing is_tsinit eliminates the reinitialization path. Does the vector
code now risk using stale phc_time values when timestamping resumes after
a long pause?
> @@ -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 replacing the conditional with an unconditional block change the
intended logic? The original code only called iavf_get_phc_time() and
updated phc_time when is_tsinit was true.
[ ... ]
---
git commit: [PATCH v2 2/2] net/iavf: reuse device alarm for PHC sync
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Reuse existing iavf device alarm cadence to drive periodic PHC sync
instead of a dedicated PHC alarm callback.
Keep PHC start/stop hooks as pause/resume controls around queue
reconfiguration and device lifecycle paths.
> 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
>
> /* The overhead from MTU to max frame size.
> * Considering QinQ packet, the VLAN tag needs to be counted twice.
> @@ -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;
Does the uint8_t phc_sync_ticks overflow when the alarm ticks exceed 255?
The interval ratio is 200000/50000 = 4, but does this code handle scenarios
where the alarm runs many times?
> struct iavf_devargs devargs;
> bool mac_primary_set;
> };
> 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 dereference dev->data->rx_queues[0] without verifying the
pointer is valid? The iavf_phc_sync_alarm_needed() checks rx_queues[0]
for NULL, but does the alarm handler have a race where queues could be
freed between the check and the dereference?
> +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;
> +
> + return true;
> +}
Does checking nb_rx_queues and rx_queues[0] create a TOCTOU issue with the
dereference in iavf_dev_alarm_handler()? Can rx_queues be freed or
reallocated between this check and the later use?
> diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
> index 08dd6f2d7f..82943472e1 100644
> --- a/drivers/net/intel/iavf/iavf_vchnl.c
> +++ b/drivers/net/intel/iavf/iavf_vchnl.c
> @@ -2133,12 +2133,16 @@ iavf_request_queues(struct rte_eth_dev *dev, uint16_t num)
> args.out_size = IAVF_AQ_BUF_SZ;
>
> if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
> + iavf_phc_sync_alarm_stop(dev);
> err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
> + iavf_phc_sync_alarm_start(dev);
Does restarting the PHC sync alarm immediately after iavf_execute_vf_cmd_safe()
create a race where the alarm fires before the new queue configuration is
fully applied?
> } else {
> rte_eal_alarm_cancel(iavf_dev_alarm_handler, dev);
> + iavf_phc_sync_alarm_stop(dev);
> err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
> rte_eal_alarm_set(IAVF_ALARM_INTERVAL,
> iavf_dev_alarm_handler, dev);
> + iavf_phc_sync_alarm_start(dev);
> }
More information about the test-report
mailing list