|SUCCESS| [v3,2/2] net/iavf: reuse device alarm for PHC sync
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Tue Apr 7 05:02:39 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162860
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-07
Commit: (from patch header)
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Subject: [PATCH v3 1/2] net/iavf: remove PHC polling from Rx datapath
This patch removes periodic PHC read/update checks from scalar and
vector flex RX paths, keeping timestamp conversion based on queue PHC
state.
> 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
[ ... ]
> @@ -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);
>
> *RTE_MBUF_DYNFIELD(rxm,
> iavf_timestamp_dynfield_offset,
The code removes the update to rxq->hw_time_update after updating
rxq->phc_time from the descriptor timestamp. Does this mean the
hw_time_update field becomes stale, and if later checked elsewhere,
might incorrectly indicate that a PHC sync is needed when it isn't?
> @@ -1755,7 +1734,6 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts,
> 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);
Same concern here in the scattered receive path.
> diff --git a/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c b/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
> index db0462f0f5..c91123ead4 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
> +++ b/drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c
[ ... ]
> @@ -514,19 +514,8 @@ _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);
> - }
> - }
After removing the is_tsinit flag and the time-based check, does the
code always assume rxq->phc_time is valid? If rxq->phc_time has never
been updated by the alarm handler (patch 2/2), does this code use an
uninitialized or zero phc_time in the vector path?
> @@ -1152,14 +1141,9 @@ _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);
> - }
> + rxq->phc_time = iavf_tstamp_convert_32b_64b(rxq->phc_time,
> + *RTE_MBUF_DYNFIELD(rx_pkts[i + 0],
> + iavf_timestamp_dynfield_offset, uint32_t *));
This code now always calls iavf_tstamp_convert_32b_64b() on every
burst. Does this change the behavior if rxq->phc_time was not recently
updated by the alarm? Could stale phc_time cause incorrect timestamp
expansion?
[ ... ]
---
Commit: (from patch header)
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Subject: [PATCH v3 2/2] net/iavf: reuse device alarm for PHC sync
This patch reuses the existing iavf device alarm cadence to drive
periodic PHC sync instead of a dedicated PHC alarm callback.
> diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
> index 403c61e2e8..e30fd710f0 100644
> --- a/drivers/net/intel/iavf/iavf.h
> +++ b/drivers/net/intel/iavf/iavf.h
[ ... ]
> @@ -383,6 +384,9 @@ struct iavf_adapter {
> enum iavf_rx_func_type rx_func_type;
> enum iavf_tx_func_type tx_func_type;
> uint16_t fdir_ref_cnt;
> + rte_spinlock_t phc_sync_lock;
> + uint16_t phc_sync_ticks;
> + bool phc_sync_paused;
The new fields are added without updating the struct's documentation.
Should these fields have comments explaining their purpose?
> diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
> index 1eca20bc9a..9c9a5a6b47 100644
> --- a/drivers/net/intel/iavf/iavf_ethdev.c
> +++ b/drivers/net/intel/iavf/iavf_ethdev.c
[ ... ]
> @@ -2705,9 +2715,13 @@ void
> iavf_dev_alarm_handler(void *param)
> {
> struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
> + struct iavf_adapter *adapter;
> + const uint16_t phc_sync_ticks_max = RTE_MAX((uint16_t)1,
> + (uint16_t)(IAVF_PHC_SYNC_ALARM_INTERVAL_US / IAVF_ALARM_INTERVAL));
> if (dev == NULL || dev->data == NULL || dev->data->dev_private == NULL)
> return;
The declaration ordering does not follow the reverse-christmas-tree
style expected in DPDK. Should the variable declarations be reordered?
> + adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
A statement appears before a variable declaration. Does this code
violate C89 variable declaration rules?
> @@ -2723,10 +2737,121 @@ iavf_dev_alarm_handler(void *param)
>
> iavf_enable_irq0(hw);
>
> + rte_spinlock_lock(&adapter->phc_sync_lock);
> + if (!adapter->phc_sync_paused &&
> + iavf_phc_sync_alarm_needed(dev)) {
> + uint16_t phc_sync_ticks =
> + ++adapter->phc_sync_ticks;
> +
> + if (phc_sync_ticks >= phc_sync_ticks_max) {
> + struct ci_rx_queue *sync_rxq;
> + uint64_t sw_cur_time;
> +
> + adapter->phc_sync_ticks = 0;
> + sync_rxq = iavf_phc_sync_rxq_get(dev);
> + if (sync_rxq != NULL && iavf_get_phc_time(sync_rxq) == 0) {
> + sw_cur_time = rte_get_timer_cycles() /
> + (rte_get_timer_hz() / 1000);
> + iavf_phc_sync_update_all_rxq(dev,
> + sync_rxq->phc_time, sw_cur_time);
> + } else if (sync_rxq != NULL) {
> + PMD_DRV_LOG(ERR, "get physical time failed");
> + }
Does the spinlock remain held during iavf_get_phc_time(), which may
involve virtchnl messaging? Could this lock be held for an extended
period if the PF is slow to respond?
> + }
> + } else {
> + adapter->phc_sync_ticks = 0;
> + }
> + rte_spinlock_unlock(&adapter->phc_sync_lock);
[ ... ]
> +static struct ci_rx_queue *
> +iavf_phc_sync_rxq_get(struct rte_eth_dev *dev)
> +{
> + struct ci_rx_queue *rxq;
> + uint16_t i;
> +
> + for (i = 0; i < dev->data->nb_rx_queues; i++) {
> + rxq = dev->data->rx_queues[i];
> + if (rxq != NULL)
> + return rxq;
> + }
> +
> + return NULL;
> +}
This function accesses dev->data->rx_queues[] without locking. Does
this code have a race with queue reconfiguration paths that might NULL
out or reallocate the queue array?
> +static void
> +iavf_phc_sync_update_all_rxq(struct rte_eth_dev *dev,
> + uint64_t phc_time,
> + uint64_t sw_cur_time)
> +{
> + struct ci_rx_queue *rxq;
> + uint16_t i;
> +
> + for (i = 0; i < dev->data->nb_rx_queues; i++) {
> + rxq = dev->data->rx_queues[i];
> + if (rxq == NULL)
> + continue;
> +
> + rxq->phc_time = phc_time;
> + rxq->hw_time_update = sw_cur_time;
> + }
> +}
This function writes rxq->phc_time and rxq->hw_time_update without
locking. Does this code race with the rx burst functions reading these
fields in patch 1/2?
> diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
> index 08dd6f2d7f..79ef4cec56 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);
> } else {
> + iavf_phc_sync_alarm_stop(dev);
> rte_eal_alarm_cancel(iavf_dev_alarm_handler, 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);
> }
Does the code call iavf_phc_sync_alarm_start() regardless of the
success or failure of iavf_execute_vf_cmd_safe()? Should PHC sync
remain stopped if the queue reconfiguration failed?
More information about the test-report
mailing list