Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dpll: expose fractional frequency offset in ppt

Currently, the dpll subsystem exports the fractional frequency offset
(FFO) in parts per million (ppm). This granularity is insufficient for
high-precision synchronization scenarios which often require parts per
trillion (ppt) resolution.

Add a new netlink attribute DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT
to expose the FFO in ppt.

Update the dpll netlink core to expect the driver-provided FFO value
to be in ppt. To maintain backward compatibility with existing userspace
tools, populate the legacy DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET
attribute by dividing the new ppt value by 1,000,000.

Update the zl3073x and mlx5 drivers to provide the FFO value in ppt:
- zl3073x: adjust the fixed-point calculation to produce ppt (10^12)
instead of ppm (10^6).
- mlx5: scale the existing ppm value by 1,000,000.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://patch.msgid.link/20260126162253.27890-1-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ivan Vecera and committed by
Jakub Kicinski
bc443c25 b3827c91

+27 -4
+11
Documentation/netlink/specs/dpll.yaml
··· 446 446 doc: | 447 447 Granularity of phase adjustment, in picoseconds. The value of 448 448 phase adjustment must be a multiple of this granularity. 449 + - 450 + name: fractional-frequency-offset-ppt 451 + type: sint 452 + doc: | 453 + The FFO (Fractional Frequency Offset) of the pin with respect to 454 + the nominal frequency. 455 + Value = (frequency_measured - frequency_nominal) / frequency_nominal 456 + Value is in PPT (parts per trillion, 10^-12). 457 + Note: This attribute provides higher resolution than the standard 458 + fractional-frequency-offset (which is in PPM). 449 459 450 460 - 451 461 name: pin-parent-device ··· 638 628 - phase-adjust-max 639 629 - phase-adjust 640 630 - fractional-frequency-offset 631 + - fractional-frequency-offset-ppt 641 632 - esync-frequency 642 633 - esync-frequency-supported 643 634 - esync-pulse
+9 -1
drivers/dpll/dpll_netlink.c
··· 389 389 return 0; 390 390 return ret; 391 391 } 392 - return nla_put_sint(msg, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET, ffo); 392 + /* Put the FFO value in PPM to preserve compatibility with older 393 + * programs. 394 + */ 395 + ret = nla_put_sint(msg, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET, 396 + div_s64(ffo, 1000000)); 397 + if (ret) 398 + return -EMSGSIZE; 399 + return nla_put_sint(msg, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT, 400 + ffo); 393 401 } 394 402 395 403 static int
+5 -2
drivers/dpll/zl3073x/core.c
··· 710 710 if (rc) 711 711 return rc; 712 712 713 - /* Convert to ppm -> ffo = (10^6 * value) / 2^32 */ 714 - zldev->ref[i].ffo = mul_s64_u64_shr(value, 1000000, 32); 713 + /* Convert to ppt 714 + * ffo = (10^12 * value) / 2^32 715 + * ffo = ( 5^12 * value) / 2^20 716 + */ 717 + zldev->ref[i].ffo = mul_s64_u64_shr(value, 244140625, 20); 715 718 } 716 719 717 720 return 0;
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/dpll.c
··· 136 136 { 137 137 if (!synce_status->oper_freq_measure) 138 138 return -ENODATA; 139 - *ffo = synce_status->frequency_diff; 139 + *ffo = 1000000LL * synce_status->frequency_diff; 140 140 return 0; 141 141 } 142 142
+1
include/uapi/linux/dpll.h
··· 253 253 DPLL_A_PIN_ESYNC_PULSE, 254 254 DPLL_A_PIN_REFERENCE_SYNC, 255 255 DPLL_A_PIN_PHASE_ADJUST_GRAN, 256 + DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT, 256 257 257 258 __DPLL_A_PIN_MAX, 258 259 DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)