dpll: rework fractional frequency offset reporting
Subsystems (8)
Ivan Vecera
maintainerv2 cover dpll: rework fractional frequency offset reporting
Rework how the fractional frequency offset (FFO) is reported in the DPLL subsystem.
The fractional-frequency-offset-ppt attribute is moved from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset (which is already per-parent) and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
The two FFO contexts are distinguished in the ffo_get callback:
dpll=NULL for the top-level RX vs TX symbol rate offset and a valid dpll pointer for the nested pin vs DPLL offset.
Patch 1 restructures the DPLL subsystem netlink handling, updates the YAML spec and driver-api documentation, and adds NULL guards to mlx5 and zl3073x drivers.
Patch 2 implements the nested FFO for zl3073x using the dpll_df_offset_x register with ref_ofst=1, providing 2^-48 resolution. The old per-reference frequency measurement is removed as it was redundant with measured-frequency.
Ivan Vecera (2):
dpll: move fractional-frequency-offset-ppt under pin-parent-device
dpll: zl3073x: report FFO as DPLL vs input reference offset
Documentation/driver-api/dpll.rst | 16 +++++++ Documentation/netlink/specs/dpll.yaml | 11 +++-- drivers/dpll/dpll_netlink.c | 34 ++++++++++---- drivers/dpll/dpll_nl.c | 1 + drivers/dpll/zl3073x/chan.c | 31 ++++++++++++- drivers/dpll/zl3073x/chan.h | 14 ++++++ drivers/dpll/zl3073x/core.c | 45 ------------------- drivers/dpll/zl3073x/dpll.c | 34 +++++++------- drivers/dpll/zl3073x/ref.h | 14 ------ drivers/dpll/zl3073x/regs.h | 15 +++++++ .../net/ethernet/mellanox/mlx5/core/dpll.c | 4 ++ 11 files changed, 126 insertions(+), 93 deletions(-)
Signature · 1 line
2.53.0
Ivan Vecera
maintainerPATCH v2 1/2 dpll: move fractional-frequency-offset-ppt under pin-parent-device
Move the fractional-frequency-offset-ppt attribute from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset which is already per-parent and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
The top-level fractional-frequency-offset attribute (in PPM) remains unchanged for backward compatibility.
Distinguish the two contexts in the ffo_get callback by passing dpll=NULL for the top-level (rx vs tx symbol rate) call and a valid dpll pointer for the nested (pin vs parent DPLL) call. Update mlx5 and zl3073x drivers to return -ENODATA for the nested context they do not yet support.
Add documentation for both FFO attributes to dpll.rst.
--- Documentation/driver-api/dpll.rst | 16 +++++++++ Documentation/netlink/specs/dpll.yaml | 11 +++--- drivers/dpll/dpll_netlink.c | 34 ++++++++++++++----- drivers/dpll/dpll_nl.c | 1 + drivers/dpll/zl3073x/dpll.c | 4 +++ .../net/ethernet/mellanox/mlx5/core/dpll.c | 4 +++ 6 files changed, 56 insertions(+), 14 deletions(-)
Documentation/driver-api/dpll.rst +16 -0
@@ -258,6 +258,22 @@ in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute. ``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature =============================== ======================== +Fractional frequency offset +=========================== + +The fractional frequency offset (FFO) represents the frequency difference +between a pin and its parent DPLL device. It is reported in the +``DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT`` attribute nested under +the parent device, in parts per trillion (PPT, 10^-12). + +This is analogous to ``DPLL_A_PIN_PHASE_OFFSET`` but in the frequency +domain. It is typically reported only for the currently active input pin. + +The top-level ``DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET`` attribute (in PPM) +represents the RX vs TX symbol rate offset on the media associated with +the pin (e.g. for SyncE ethernet ports) and is independent of the +per-parent FFO PPT attribute. + Frequency monitor =================
Documentation/netlink/specs/dpll.yaml +5 -6
@@ -492,12 +492,10 @@ attribute-sets: name: fractional-frequency-offset-ppt type: sint doc: | - The FFO (Fractional Frequency Offset) of the pin with respect to - the nominal frequency. - Value = (frequency_measured - frequency_nominal) / frequency_nominal + The FFO (Fractional Frequency Offset) between a pin and its + parent DPLL device, similar to phase-offset but in frequency + domain. Value is in PPT (parts per trillion, 10^-12). - Note: This attribute provides higher resolution than the standard - fractional-frequency-offset (which is in PPM). - name: measured-frequency type: u64
@@ -534,6 +532,8 @@ attribute-sets: name: operstate - name: phase-offset + - + name: fractional-frequency-offset-ppt - name: pin-parent-pin subset-of: pin
@@ -703,7 +703,6 @@ operations: - phase-adjust-max - phase-adjust - fractional-frequency-offset - - fractional-frequency-offset-ppt - esync-frequency - esync-frequency-supported - esync-pulse
drivers/dpll/dpll_netlink.c +26 -8
@@ -418,6 +418,27 @@ dpll_msg_add_phase_offset(struct sk_buff *msg, struct dpll_pin *pin,static int dpll_msg_add_ffo (struct sk_buff *msg,struct dpll_pin *pin,struct dpll_pin_ref *ref,struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +s64 ffo; +int ret; + +if (!ops->ffo_get) +return 0 ; + ret = ops->ffo_get (pin,dpll_pin_on_dpll_priv (ref->dpll, pin), +NULL ,NULL , &ffo, extack); +if (ret) { +if (ret == -ENODATA ) +return 0 ; +return ret; + } +return nla_put_sint (msg,DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET , +div_s64 (ffo,1000000 )); +} + +static int dpll_msg_add_ffo_ppt (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref, +struct netlink_ext_ack *extack) {const struct dpll_pin_ops *ops =dpll_pin_ops (ref);struct dpll_device *dpll = ref->dpll;
@@ -433,14 +454,8 @@ static int dpll_msg_add_ffo(struct sk_buff *msg, struct dpll_pin *pin,return 0 ;return ret; } -/* Put the FFO value in PPM to preserve compatibility with older -* programs. -*/ - ret =nla_put_sint (msg,DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET , -div_s64 (ffo,1000000 )); -if (ret) -return -EMSGSIZE ; -return nla_put_sint (msg,DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT , +return nla_put_sint (msg, +DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT , ffo); }
@@ -686,6 +701,9 @@ dpll_msg_add_pin_dplls(struct sk_buff *msg, struct dpll_pin *pin,if (ret) goto nest_cancel; ret =dpll_msg_add_phase_offset (msg, pin, ref, extack); +if (ret) + goto nest_cancel; + ret =dpll_msg_add_ffo_ppt (msg, pin, ref, extack);if (ret) goto nest_cancel;nla_nest_end (msg, attr);
drivers/dpll/dpll_nl.c +1 -0
@@ -19,6 +19,7 @@ const struct nla_policy dpll_pin_parent_device_nl_policy[DPLL_A_PIN_OPERSTATE + [DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3), [DPLL_A_PIN_OPERSTATE] = NLA_POLICY_RANGE(NLA_U32, 1, 4), [DPLL_A_PIN_PHASE_OFFSET] = { .type = NLA_S64, }, + [DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT] = { .type = NLA_SINT, }, };const struct nla_policy dpll_pin_parent_pin_nl_policy[DPLL_A_PIN_STATE +1 ] = {
drivers/dpll/zl3073x/dpll.c +4 -0
@@ -299,6 +299,10 @@ zl3073x_dpll_input_pin_ffo_get(const struct dpll_pin *dpll_pin, void *pin_priv, {struct zl3073x_dpll_pin *pin = pin_priv; +/* Only rx vs tx symbol rate FFO is supported */ +if (dpll) +return -ENODATA ; + *ffo = pin->freq_offset;return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +4 -0
@@ -306,6 +306,10 @@ static int mlx5_dpll_ffo_get(const struct dpll_pin *pin, void *pin_priv,struct mlx5_dpll *mdpll = pin_priv;int err; +/* Only rx vs tx symbol rate FFO is supported */ +if (dpll) +return -ENODATA ; + err =mlx5_dpll_synce_status_get (mdpll->mdev, &synce_status);if (err)return err;
Signature · 1 line
2.53.0
Jiri Pirko
maintainerRe: [PATCH net-next v2 1/2] dpll: move fractional-frequency-offset-ppt under pin-parent-device
Quoted 8 lines · Thu, Apr 30, 2026 at 07:36:10PM +0200, [email protected] wrote:
Move the fractional-frequency-offset-ppt attribute from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset which is already per-parent and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
The top-level fractional-frequency-offset attribute (in PPM) remains unchanged for backward compatibility.
That is odd. The ppt one was added just for higher precision but was semantically the same. Now you change it. Could you still treat both the same?
Quoted 9 lines
Distinguish the two contexts in the
ffo_getcallback by passing dpll=NULL for the top-level (rx vs tx symbol rate) call and a valid dpll pointer for the nested (pin vs parent DPLL) call. Update mlx5 and zl3073x drivers to return-ENODATAfor the nested context they do not yet support.Add documentation for both FFO attributes to
dpll.rst.
[..]
Ivan Vecera
maintainerRe: [PATCH net-next v2 1/2] dpll: move fractional-frequency-offset-ppt under pin-parent-device
Hi Jiri,
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Thu, Apr 30, 2026 at 07:36:10PM +0200, [email protected] wrote:
Move the fractional-frequency-offset-ppt attribute from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset which is already per-parent and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
Quoted 7 lines
Quoted 2 lines
The top-level fractional-frequency-offset attribute (in PPM) remains unchanged for backward compatibility.
That is odd. The ppt one was added just for higher precision but was semantically the same. Now you change it. Could you still treat both the same?
WDYM?
Keep fractional-frequency-offset-ppt at the top-level and add both fractional-frequency-offset and fractional-frequency-offset-ppt into pin-parent-device nested attribute set?
Thanks,
Ivan
Jiri Pirko
maintainerRe: [PATCH net-next v2 1/2] dpll: move fractional-frequency-offset-ppt under pin-parent-device
Quoted 17 lines · Mon, May 04, 2026 at 11:36:19AM +0200, [email protected] wrote:
Hi Jiri,
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Thu, Apr 30, 2026 at 07:36:10PM +0200, [email protected] wrote:
Move the fractional-frequency-offset-ppt attribute from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset which is already per-parent and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
Quoted 7 lines
Quoted 2 lines
The top-level fractional-frequency-offset attribute (in PPM) remains unchanged for backward compatibility.
That is odd. The ppt one was added just for higher precision but was semantically the same. Now you change it. Could you still treat both the same?
Quoted 5 lines
WDYM?
Keep fractional-frequency-offset-ppt at the top-level and add both fractional-frequency-offset and fractional-frequency-offset-ppt into pin-parent-device nested attribute set?
Since both are the same, only different unit, it would make sense to treat them both the same. That prevents from user confusion, hopefully.
Quoted 4 lines
Thanks,
Ivan
Ivan Vecera
maintainerRe: [PATCH net-next v2 1/2] dpll: move fractional-frequency-offset-ppt under pin-parent-device
Quoted 18 lines · Jiri Pirko
Quoted 17 lines · Mon, May 04, 2026 at 11:36:19AM +0200, [email protected] wrote:
Hi Jiri,
Quoted 14 lines · Jiri Pirko
Quoted 8 lines · Thu, Apr 30, 2026 at 07:36:10PM +0200, [email protected] wrote:
Move the fractional-frequency-offset-ppt attribute from the top-level pin attributes into the pin-parent-device nested attribute set. This makes it consistent with phase-offset which is already per-parent and clarifies that FFO PPT represents the frequency difference between a pin and its parent DPLL device.
The top-level fractional-frequency-offset attribute (in PPM) remains unchanged for backward compatibility.
That is odd. The ppt one was added just for higher precision but was semantically the same. Now you change it. Could you still treat both the same?
Quoted 9 lines
Quoted 5 lines
WDYM?
Keep fractional-frequency-offset-ppt at the top-level and add both fractional-frequency-offset and fractional-frequency-offset-ppt into pin-parent-device nested attribute set?
Since both are the same, only different unit, it would make sense to treat them both the same. That prevents from user confusion, hopefully.
Agree... will update in v3.
Thanks,
Ivan
Ivan Vecera
maintainerPATCH v2 2/2 dpll: zl3073x: report FFO as DPLL vs input reference offset
In reply to Ivan VeceraReplace the per-reference frequency offset measurement (which was redundant with measured-frequency) with a direct read of the DPLL's delta frequency offset vs its tracked input reference.
The new implementation uses the dpll_df_offset_x register with ref_ofst=1 via the dpll_df_read_x semaphore mechanism. This provides 2^-48 resolution (~3.5 fE) and reports the actual frequency difference between the DPLL and its active input.
FFO is now reported only for the active input pin in the nested (pin vs parent DPLL) context. Top-level FFO returns -ENODATA.
Rewrite ffo_check to compare the cached df_offset converted to PPT instead of using the old per-reference measurement. Remove the ref_ffo_update periodic measurement and the ref ffo field since they are no longer needed.
--- drivers/dpll/zl3073x/chan.c | 31 +++++++++++++++++++++++-- drivers/dpll/zl3073x/chan.h | 14 ++++++++++++ drivers/dpll/zl3073x/core.c | 45 ------------------------------------- drivers/dpll/zl3073x/dpll.c | 34 ++++++++++++---------------- drivers/dpll/zl3073x/ref.h | 14 ------------ drivers/dpll/zl3073x/regs.h | 15 +++++++++++++ 6 files changed, 72 insertions(+), 81 deletions(-)
drivers/dpll/zl3073x/chan.c +29 -2
@@ -18,6 +18,7 @@int zl3073x_chan_state_update (struct zl3073x_dev *zldev,u8 index) {struct zl3073x_chan *chan = &zldev->chan[index]; +u64 val;int rc; rc = zl3073x_read_u8(zldev, ZL_REG_DPLL_MON_STATUS(index),
@@ -25,8 +26,34 @@ int zl3073x_chan_state_update(struct zl3073x_dev *zldev, u8 index)if (rc)return rc; -return zl3073x_read_u8 (zldev,ZL_REG_DPLL_REFSEL_STATUS (index), - &chan->refsel_status); + rc =zl3073x_read_u8 (zldev,ZL_REG_DPLL_REFSEL_STATUS (index), + &chan->refsel_status); +if (rc) +return rc; + +/* Read df_offset vs tracked reference */ + rc =zl3073x_poll_zero_u8 (zldev,ZL_REG_DPLL_DF_READ (index), +ZL_DPLL_DF_READ_SEM ); +if (rc) +return rc; + + rc =zl3073x_write_u8 (zldev,ZL_REG_DPLL_DF_READ (index), +ZL_DPLL_DF_READ_SEM |ZL_DPLL_DF_READ_REF_OFST ); +if (rc) +return rc; + + rc =zl3073x_poll_zero_u8 (zldev,ZL_REG_DPLL_DF_READ (index), +ZL_DPLL_DF_READ_SEM ); +if (rc) +return rc; + + rc =zl3073x_read_u48 (zldev,ZL_REG_DPLL_DF_OFFSET (index), &val); +if (rc) +return rc; + + chan->df_offset =sign_extend64 (val,47 ); + +return 0 ; }/**
drivers/dpll/zl3073x/chan.h +14 -0
@@ -17,6 +17,7 @@ struct zl3073x_dev;* @ref_prio: reference priority registers (4 bits per ref, P/N packed) * @mon_status: monitor status register value * @refsel_status: reference selection status register value +* @df_offset: frequency offset vs tracked reference in 2^-48 steps */ struct zl3073x_chan { struct_group(cfg,
@@ -26,6 +27,7 @@ struct zl3073x_chan {struct_group (stat, u8 mon_status; u8 refsel_status; + s64 df_offset; ); };
@@ -37,6 +39,18 @@ int zl3073x_chan_state_set(struct zl3073x_dev *zldev, u8 index,int zl3073x_chan_state_update (struct zl3073x_dev *zldev,u8 index); +/** +* zl3073x_chan_df_offset_get - get cached df_offset vs tracked reference +* @chan: pointer to channel state +* +* Return: frequency offset in 2^-48 steps +*/ +static inline s64 +zl3073x_chan_df_offset_get (const struct zl3073x_chan *chan) +{ +return chan->df_offset; +} +/** * zl3073x_chan_mode_get - get DPLL channel operating mode * @chan: pointer to channel state
drivers/dpll/zl3073x/core.c +0 -45
57 lines not on this page · raw message
drivers/dpll/zl3073x/dpll.c +14 -20
@@ -299,8 +299,12 @@ zl3073x_dpll_input_pin_ffo_get(const struct dpll_pin *dpll_pin, void *pin_priv, {struct zl3073x_dpll_pin *pin = pin_priv; -/* Only rx vs tx symbol rate FFO is supported */ -if (dpll) +/* Only nested FFO (pin vs parent DPLL) is supported */ +if (!dpll) +return -ENODATA ; + +/* Report FFO only for the active pin */ +if (pin->operstate !=DPLL_PIN_OPERSTATE_ACTIVE )return -ENODATA ; *ffo = pin->freq_offset;
@@ -1733,37 +1737,27 @@ zl3073x_dpll_pin_phase_offset_check(struct zl3073x_dpll_pin *pin) }/** -* zl3073x_dpll_pin_ffo_check - check for pin fractional frequency offset change +* zl3073x_dpll_pin_ffo_check - check for FFO change on active pin * @pin: pin to check * -* Check for the given pin's fractional frequency change. -* -* Return: true on fractional frequency offset change, false otherwise +* Return: true on change, false otherwise */ static bool zl3073x_dpll_pin_ffo_check (struct zl3073x_dpll_pin *pin) {struct zl3073x_dpll *zldpll = pin->dpll; -struct zl3073x_dev *zldev = zldpll->dev; -const struct zl3073x_ref *ref; -u8 ref_id; +const struct zl3073x_chan *chan;s64 ffo; -/* Get reference monitor status */ - ref_id =zl3073x_input_pin_ref_get (pin->id); - ref =zl3073x_ref_state_get (zldev, ref_id); - -/* Do not report ffo changes if the reference monitor report errors */ -if (!zl3073x_ref_is_status_ok (ref)) +if (pin->operstate !=DPLL_PIN_OPERSTATE_ACTIVE )return false; -/* Compare with previous value */ - ffo =zl3073x_ref_ffo_get (ref); + chan =zl3073x_chan_state_get (zldpll->dev, zldpll->id); + ffo =mul_s64_u64_shr (zl3073x_chan_df_offset_get (chan), +244140625 ,36 ); +if (pin->freq_offset != ffo) { -dev_dbg (zldev->dev,"%s freq offset changed: %lld -> %lld\n" , - pin->label, pin->freq_offset, ffo); pin->freq_offset = ffo; -return true; }
drivers/dpll/zl3073x/ref.h +0 -14
@@ -22,7 +22,6 @@ struct zl3073x_dev;* @freq_ratio_n: FEC mode divisor * @sync_ctrl: reference sync control * @config: reference config -* @ffo: current fractional frequency offset * @meas_freq: measured input frequency in Hz * @mon_status: reference monitor status */
@@ -40,7 +39,6 @@ struct zl3073x_ref {u8 config; );struct_group (stat,/* Status */ - s64 ffo; u32 meas_freq; u8 mon_status; );
@@ -58,18 +56,6 @@ int zl3073x_ref_state_update(struct zl3073x_dev *zldev, u8 index);int zl3073x_ref_freq_factorize (u32 freq,u16 *base,u16 *mult); -/** -* zl3073x_ref_ffo_get - get current fractional frequency offset -* @ref: pointer to ref state -* -* Return: the latest measured fractional frequency offset -*/ -static inline s64 -zl3073x_ref_ffo_get (const struct zl3073x_ref *ref) -{ -return ref->ffo; -} -/** * zl3073x_ref_meas_freq_get - get measured input frequency * @ref: pointer to ref state
drivers/dpll/zl3073x/regs.h +15 -0
@@ -164,6 +164,11 @@#define ZL_DPLL_MODE_REFSEL_MODE_NCO 4#define ZL_DPLL_MODE_REFSEL_REF GENMASK(7, 4) +#define ZL_REG_DPLL_DF_READ (_idx) \ + ZL_REG_IDX(_idx, 5, 0x28, 1, ZL3073X_MAX_CHANNELS, 1) +#define ZL_DPLL_DF_READ_SEM BIT(4) +#define ZL_DPLL_DF_READ_REF_OFST BIT(3) +#define ZL_REG_DPLL_MEAS_CTRL ZL_REG(5, 0x50, 1)#define ZL_DPLL_MEAS_CTRL_EN BIT(0)#define ZL_DPLL_MEAS_CTRL_AVG_FACTOR GENMASK(7, 4)
@@ -176,6 +181,16 @@#define ZL_REG_DPLL_PHASE_ERR_DATA (_idx) \ ZL_REG_IDX(_idx, 5, 0x55, 6, ZL3073X_MAX_CHANNELS, 6) +/******************************* +* Register Pages 6-7, DPLL Data +*******************************/ + +#define ZL_REG_DPLL_DF_OFFSET_03 (_idx) \ + ZL_REG_IDX(_idx, 6, 0x00, 6, 4, 0x20) +#define ZL_REG_DPLL_DF_OFFSET_4 ZL_REG(7, 0x00, 6) +#define ZL_REG_DPLL_DF_OFFSET (_idx) \ + ((_idx) < 4 ? ZL_REG_DPLL_DF_OFFSET_03(_idx) : ZL_REG_DPLL_DF_OFFSET_4) +/*********************************** * Register Page 9, Synth and Output ***********************************/
Signature · 1 line
2.53.0