|SUCCESS| [v2] net/idpf: harden PTP frequency adjustment

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Apr 7 17:29:08 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162887

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-07

Reviewing the patch against DPDK coding standards and contribution guidelines.

Commit: [SHA from patch file]
Author: Soumyadeep Hore <soumyadeep.hore at intel.com>
Subject: [PATCH v2] net/idpf: harden PTP frequency adjustment

This patch simplifies the PTP frequency adjustment calculation by using
128-bit arithmetic instead of complex scaling logic to avoid overflow.

> diff --git a/drivers/net/intel/idpf/idpf_ethdev.c b/drivers/net/intel/idpf/idpf_ethdev.c
> index 5e57a45775..23a2af6332 100644
> --- a/drivers/net/intel/idpf/idpf_ethdev.c
> +++ b/drivers/net/intel/idpf/idpf_ethdev.c
> @@ -1005,42 +1005,14 @@ idpf_timesync_adjust_freq(struct rte_eth_dev *dev, int64_t ppm)

[ ... ]

> +	uint64_t incval;
> +	__int128 diff;

Does this code use a non-portable type? The __int128 type is a GCC
extension and may not be available on all platforms. DPDK supports
multiple compilers and architectures. Does this introduce a portability
concern for non-GCC compilers or 32-bit platforms?

> +	/* ppm is scaled by 2^16 to match Linux adjfine. */
>  	incval = ptp->base_incval;
> -
> -	if (ppm < 0) {
> -		negative = true;
> -		ppm = -ppm;
> -	}
> -
> -	/* can incval * ppm overflow ? */
> -	if (rte_log2_u64(incval) + rte_log2_u64(ppm) > 62) {
> -		rem = ppm % divisor;
> -		div = ppm / divisor;
> -		diff = div * incval;
> -		ppm = rem;
> -
> -		shift = rte_log2_u64(incval) + rte_log2_u64(ppm) - 62;
> -		if (shift > 0) {
> -			/* drop precision */
> -			ppm >>= shift;
> -			divisor >>= shift;
> -		}
> -	}
> -
> -	if (divisor)
> -		diff = diff + incval * ppm / divisor;
> -
> -	if (negative)
> -		incval -= diff;
> -	else
> -		incval += diff;
> +	diff = ((__int128)incval * ppm) / (1000000LL << 16);
> +	incval += (int64_t)diff;

Does this code handle overflow correctly when casting diff back to
int64_t? If the 128-bit result exceeds the range of int64_t, can this
cause undefined behavior or produce incorrect results?

Can the addition incval += (int64_t)diff overflow? The incval is uint64_t
but diff is cast to int64_t. If diff is negative and large in magnitude,
does this wrap around correctly, or can it produce unexpected values?

Does this code validate that the final incval remains within acceptable
hardware limits before passing it to idpf_ptp_adj_dev_clk_fine()? The
original code preserved the sign handling explicitly. Does the simplified
version maintain the same semantics for negative ppm values?


More information about the test-report mailing list