|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 06:42:45 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

Reviewing the DPDK patch series for iavf PHC (Precision Time Protocol Hardware Clock) synchronization changes.

git sha: series.patch (v2 1/2 and 2/2)
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>

Subject: [PATCH v2 1/2] net/iavf: remove PHC polling from Rx datapath
         [PATCH v2 2/2] net/iavf: reuse device alarm for PHC sync

The series removes periodic PHC read/update checks from the hot path
(scalar and vector Rx paths) and consolidates PHC synchronization into
the existing device alarm handler, with pause/resume controls around
queue reconfiguration.

> 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);
> +		}
> +	} else {
> +		adapter->phc_sync_ticks = 0;
> +	}

Does this code dereference rx_queues[0] without checking if it's still
valid? The helper iavf_phc_sync_alarm_needed() checks if rx_queues[0]
is NULL, but does that guarantee it remains valid during the alarm
callback execution? Can a queue reconfiguration free rx_queues[0]
between the check in iavf_phc_sync_alarm_needed() and the dereference
in iavf_dev_alarm_handler()?

> +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 the check on adapter->closed prevent races during shutdown? Is
there any lock protection between checking adapter->closed and accessing
the rx_queues array?

> +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);
> +	adapter->phc_sync_paused = false;
> +	adapter->phc_sync_ticks = 0;
> +}
> +
> +void
> +iavf_phc_sync_alarm_stop(struct rte_eth_dev *dev)
> +{
> +	struct iavf_adapter *adapter;
> +
> +	if (dev == NULL || dev->data == NULL || dev->data->dev_private == NULL)
> +		return;
> +
> +	adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> +	adapter->phc_sync_paused = true;
> +	adapter->phc_sync_ticks = 0;
> +}

Does this pattern of paused flag protect against concurrent alarm
execution? Can the alarm callback fire between setting phc_sync_paused
and the actual queue teardown in iavf_dev_stop()?

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

Does this ordering prevent race conditions? In the else branch, can
iavf_dev_alarm_handler() fire and access rx_queues[0] after calling
rte_eal_alarm_set() but before calling iavf_phc_sync_alarm_start()
completes the reconfiguration?

Does stopping the PHC sync alarm before canceling the device alarm in
the else branch create a window where the alarm fires but phc_sync_paused
is already true, preventing necessary PHC updates during reconfiguration?


More information about the test-report mailing list