[PATCH net-next v2 1/3] dpll: add frequency monitoring to netlink spec

Ivan Vecera posted 3 patches 2 days, 15 hours ago
There is a newer version of this series
[PATCH net-next v2 1/3] dpll: add frequency monitoring to netlink spec
Posted by Ivan Vecera 2 days, 15 hours ago
Add DPLL_A_FREQUENCY_MONITOR device attribute to allow control over
the frequency monitor feature. The attribute uses the existing
dpll_feature_state enum (enable/disable) and is present in both
device-get reply and device-set request.

Add DPLL_A_PIN_MEASURED_FREQUENCY pin attribute to expose the measured
input frequency in Hz. The attribute is present in the pin-get reply.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst     | 18 ++++++++++++++++++
 Documentation/netlink/specs/dpll.yaml | 17 +++++++++++++++++
 drivers/dpll/dpll_nl.c                |  5 +++--
 include/uapi/linux/dpll.h             |  2 ++
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 83118c728ed90..f38e7012e8c0a 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -250,6 +250,22 @@ in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute.
   ``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature
   =============================== ========================
 
+Frequency monitor
+=================
+
+Some DPLL devices may offer the capability to measure the actual
+frequency of all available input pins. The attribute and current feature state
+shall be included in the response message of the ``DPLL_CMD_DEVICE_GET``
+command for supported DPLL devices. In such cases, users can also control
+the feature using the ``DPLL_CMD_DEVICE_SET`` command by setting the
+``enum dpll_feature_state`` values for the attribute.
+Once enabled the measured input frequency for each input pin shall be
+returned in the ``DPLL_A_PIN_MEASURED_FREQUENCY`` attribute.
+
+  =============================== ========================
+  ``DPLL_A_FREQUENCY_MONITOR``    attr state of a feature
+  =============================== ========================
+
 Embedded SYNC
 =============
 
@@ -411,6 +427,8 @@ according to attribute purpose.
       ``DPLL_A_PIN_STATE``             attr state of pin on the parent
                                        pin
     ``DPLL_A_PIN_CAPABILITIES``        attr bitmask of pin capabilities
+    ``DPLL_A_PIN_MEASURED_FREQUENCY``  attr measured frequency of
+                                       an input pin in Hz
   ==================================== ==================================
 
   ==================================== =================================
diff --git a/Documentation/netlink/specs/dpll.yaml b/Documentation/netlink/specs/dpll.yaml
index 3dd48a32f7837..80292b0f2b488 100644
--- a/Documentation/netlink/specs/dpll.yaml
+++ b/Documentation/netlink/specs/dpll.yaml
@@ -319,6 +319,13 @@ attribute-sets:
         name: phase-offset-avg-factor
         type: u32
         doc: Averaging factor applied to calculation of reported phase offset.
+      -
+        name: frequency-monitor
+        type: u32
+        enum: feature-state
+        doc: Receive or request state of frequency monitor feature.
+          If enabled, dpll device shall measure all currently available
+          inputs for their actual input frequency.
   -
     name: pin
     enum-name: dpll_a_pin
@@ -456,6 +463,13 @@ attribute-sets:
           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
+        doc: |
+          The measured frequency of the input pin in Hz.
+          This is the actual frequency being received on the pin,
+          as measured by the dpll device hardware.
 
   -
     name: pin-parent-device
@@ -544,6 +558,7 @@ operations:
             - type
             - phase-offset-monitor
             - phase-offset-avg-factor
+            - frequency-monitor
 
       dump:
         reply: *dev-attrs
@@ -563,6 +578,7 @@ operations:
             - mode
             - phase-offset-monitor
             - phase-offset-avg-factor
+            - frequency-monitor
     -
       name: device-create-ntf
       doc: Notification about device appearing
@@ -643,6 +659,7 @@ operations:
             - esync-frequency-supported
             - esync-pulse
             - reference-sync
+            - measured-frequency
 
       dump:
         request:
diff --git a/drivers/dpll/dpll_nl.c b/drivers/dpll/dpll_nl.c
index a2b22d4921142..1e652340a5d73 100644
--- a/drivers/dpll/dpll_nl.c
+++ b/drivers/dpll/dpll_nl.c
@@ -43,11 +43,12 @@ static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = {
 };
 
 /* DPLL_CMD_DEVICE_SET - do */
-static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_PHASE_OFFSET_AVG_FACTOR + 1] = {
+static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_FREQUENCY_MONITOR + 1] = {
 	[DPLL_A_ID] = { .type = NLA_U32, },
 	[DPLL_A_MODE] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
 	[DPLL_A_PHASE_OFFSET_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
 	[DPLL_A_PHASE_OFFSET_AVG_FACTOR] = { .type = NLA_U32, },
+	[DPLL_A_FREQUENCY_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
 };
 
 /* DPLL_CMD_PIN_ID_GET - do */
@@ -115,7 +116,7 @@ static const struct genl_split_ops dpll_nl_ops[] = {
 		.doit		= dpll_nl_device_set_doit,
 		.post_doit	= dpll_post_doit,
 		.policy		= dpll_device_set_nl_policy,
-		.maxattr	= DPLL_A_PHASE_OFFSET_AVG_FACTOR,
+		.maxattr	= DPLL_A_FREQUENCY_MONITOR,
 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
diff --git a/include/uapi/linux/dpll.h b/include/uapi/linux/dpll.h
index de0005f28e5c5..2e75d547716ea 100644
--- a/include/uapi/linux/dpll.h
+++ b/include/uapi/linux/dpll.h
@@ -218,6 +218,7 @@ enum dpll_a {
 	DPLL_A_CLOCK_QUALITY_LEVEL,
 	DPLL_A_PHASE_OFFSET_MONITOR,
 	DPLL_A_PHASE_OFFSET_AVG_FACTOR,
+	DPLL_A_FREQUENCY_MONITOR,
 
 	__DPLL_A_MAX,
 	DPLL_A_MAX = (__DPLL_A_MAX - 1)
@@ -254,6 +255,7 @@ enum dpll_a_pin {
 	DPLL_A_PIN_REFERENCE_SYNC,
 	DPLL_A_PIN_PHASE_ADJUST_GRAN,
 	DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT,
+	DPLL_A_PIN_MEASURED_FREQUENCY,
 
 	__DPLL_A_PIN_MAX,
 	DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)
-- 
2.52.0
Re: [PATCH net-next v2 1/3] dpll: add frequency monitoring to netlink spec
Posted by Jakub Kicinski 23 hours ago
On Mon, 30 Mar 2026 12:55:03 +0200 Ivan Vecera wrote:
> Add DPLL_A_FREQUENCY_MONITOR device attribute to allow control over
> the frequency monitor feature. The attribute uses the existing
> dpll_feature_state enum (enable/disable) and is present in both
> device-get reply and device-set request.
> 
> Add DPLL_A_PIN_MEASURED_FREQUENCY pin attribute to expose the measured
> input frequency in Hz. The attribute is present in the pin-get reply.


> +      -
> +        name: frequency-monitor
> +        type: u32
> +        enum: feature-state
> +        doc: Receive or request state of frequency monitor feature.

reads a bit clunkily - how about:

	Current or desired state of the frequency monitor feature.

?

> +          If enabled, dpll device shall measure all currently available
> +          inputs for their actual input frequency.
>    -
>      name: pin
>      enum-name: dpll_a_pin
> @@ -456,6 +463,13 @@ attribute-sets:
>            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
> +        doc: |
> +          The measured frequency of the input pin in Hz.
> +          This is the actual frequency being received on the pin,
> +          as measured by the dpll device hardware.

If we make this a u64 should it be fixed point? Seems dubious that we'd
ever be able to measure >4Ghz frequencies, much more likely that we'd 
want sub-1 precision ? So let's say this is fixed point 34.30 ?
Re: [PATCH net-next v2 1/3] dpll: add frequency monitoring to netlink spec
Posted by Ivan Vecera 20 hours ago
Hi Kuba,

On 4/1/26 5:05 AM, Jakub Kicinski wrote:
> On Mon, 30 Mar 2026 12:55:03 +0200 Ivan Vecera wrote:
>> Add DPLL_A_FREQUENCY_MONITOR device attribute to allow control over
>> the frequency monitor feature. The attribute uses the existing
>> dpll_feature_state enum (enable/disable) and is present in both
>> device-get reply and device-set request.
>>
>> Add DPLL_A_PIN_MEASURED_FREQUENCY pin attribute to expose the measured
>> input frequency in Hz. The attribute is present in the pin-get reply.
> 
> 
>> +      -
>> +        name: frequency-monitor
>> +        type: u32
>> +        enum: feature-state
>> +        doc: Receive or request state of frequency monitor feature.
> 
> reads a bit clunkily - how about:
> 
> 	Current or desired state of the frequency monitor feature.
> 
> ?

Agreed, will update.

> 
>> +          If enabled, dpll device shall measure all currently available
>> +          inputs for their actual input frequency.
>>     -
>>       name: pin
>>       enum-name: dpll_a_pin
>> @@ -456,6 +463,13 @@ attribute-sets:
>>             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
>> +        doc: |
>> +          The measured frequency of the input pin in Hz.
>> +          This is the actual frequency being received on the pin,
>> +          as measured by the dpll device hardware.
> 
> If we make this a u64 should it be fixed point? Seems dubious that we'd
> ever be able to measure >4Ghz frequencies, much more likely that we'd
> want sub-1 precision ? So let's say this is fixed point 34.30 ?
> 
Good point. I'm going with a decimal divider (1000) instead of 34.30, 
following the same approach as DPLL_PHASE_OFFSET_DIVIDER. The value
is now in millihertz (mHz) with a DPLL_PIN_MEASURED_FREQUENCY_DIVIDER
constant for userspace to extract integer and fractional parts.

Thanks,
Ivan
Re: [PATCH net-next v2 1/3] dpll: add frequency monitoring to netlink spec
Posted by Vadim Fedorenko 1 day, 15 hours ago
On 30/03/2026 11:55, Ivan Vecera wrote:
> Add DPLL_A_FREQUENCY_MONITOR device attribute to allow control over
> the frequency monitor feature. The attribute uses the existing
> dpll_feature_state enum (enable/disable) and is present in both
> device-get reply and device-set request.
> 
> Add DPLL_A_PIN_MEASURED_FREQUENCY pin attribute to expose the measured
> input frequency in Hz. The attribute is present in the pin-get reply.
> 
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>