|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:34:03 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

Reviewing the patch series against DPDK coding standards and contribution
guidelines.

Commit: (from patch series v3)
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);

Does this removal create a scenario where rxq->hw_time_update becomes stale?
In iavf_recv_pkts_flex_rxd()->timestamp handling, the code updates
rxq->phc_time but no longer updates rxq->hw_time_update. Can the downstream
timestamp conversion logic still depend on hw_time_update being current?

> 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);
> -		}
> -	}

Does removing the is_tsinit logic break the initial PHC synchronization after
queue startup? The original code calls iavf_get_phc_time() when is_tsinit is
true in _iavf_recv_raw_pkts_vec_avx2_flex_rxd(). Does the alarm-based approach
in patch 2/2 guarantee the first PHC read happens before the first packet
arrives with a timestamp?

> @@ -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 *));

Does this unconditional call to iavf_tstamp_convert_32b_64b() handle the case
where rxq->phc_time was never initialized by the alarm handler? If phc_time is
zero or stale, can this produce incorrect timestamps?

---

Commit: (from patch series v3)
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
> @@ -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

Per DPDK coding standards, magic numbers should have explanatory comments. Can
you add a comment explaining why 200ms was chosen for the PHC sync interval?

> @@ -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;

Does the phc_sync_lock protect all three of these new fields? The spinlock
usage in iavf_dev_alarm_handler() suggests it does, but does the
iavf_phc_sync_update_all_rxq() function need lock protection when it modifies
rxq->phc_time and rxq->hw_time_update? Can those fields be accessed
concurrently from RX burst functions?

> 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));

The multi-line macro invocation should have the second line indented to align
arguments according to DPDK coding style. Can you adjust the indentation?

>  	if (dev == NULL || dev->data == NULL || dev->data->dev_private == NULL)
>  		return;
>  
> +	adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);

Per DPDK coding style, variable declarations should be at the start of the
function block, with a blank line separating them from code. Can you move this
declaration to the top of the function?

> @@ -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) {

The DPDK coding style requires explicit comparisons for non-boolean values.
Can you change "== 0" to an explicit success check, such as comparing against
a defined error code constant?

> +				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);

Does holding phc_sync_lock while calling iavf_phc_sync_update_all_rxq() create
a potential deadlock? Can iavf_phc_sync_update_all_rxq()->rxq access conflict
with concurrent RX burst operations that also touch rxq->phc_time?

> +			} else if (sync_rxq != NULL) {
> +				PMD_DRV_LOG(ERR, "get physical time failed");
> +			}

Per DPDK coding style, braces should not be used for single-statement blocks.
Can you remove the braces around the PMD_DRV_LOG statement?

> +static void
> +iavf_phc_sync_update_all_rxq(struct rte_eth_dev *dev,
> +				     uint64_t phc_time,
> +				     uint64_t sw_cur_time)

The indentation of the continuation lines should align the parameters with the
opening parenthesis. Can you adjust the alignment?

> +{
> +	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;
> +	}
> +}

Does this function need memory barriers or atomic operations? The RX burst
functions read rxq->phc_time and rxq->hw_time_update without locks. Can this
create a race where the burst function sees a new phc_time with an old
hw_time_update, or vice versa?

> +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)
> +		return false;
> +
> +	if (iavf_phc_sync_rxq_get(dev) == NULL)
> +		return false;

Per DPDK coding style, NULL comparisons should be explicit. Can you change
"== NULL" to "!= NULL" with an inverted condition, or use "if (!rxq)" pattern?

> +
> +	return true;
> +}
> +
> +void
> +iavf_phc_sync_alarm_start(struct rte_eth_dev *dev)
> +{
> +	struct iavf_adapter *adapter;
> +
> +	if (!iavf_phc_sync_alarm_needed(dev))
> +		return;
> +
> +	adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> +	rte_spinlock_lock(&adapter->phc_sync_lock);
> +	adapter->phc_sync_paused = false;
> +	adapter->phc_sync_ticks = 0;
> +	rte_spinlock_unlock(&adapter->phc_sync_lock);
> +}

Does iavf_phc_sync_alarm_start() need to initialize rxq->phc_time and
rxq->hw_time_update to ensure valid initial values? If the first alarm tick
takes 200ms, can RX bursts receive timestamped packets with uninitialized PHC
state?

> 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


More information about the test-report mailing list