From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FBC235F5E1 for ; Fri, 1 May 2026 10:21:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777630865; cv=none; b=bawPnHMX6zjDKvHqgTFAuKHjC+ew07xv+LBtpFGtCKXVHB6ZXHmih/kZuZ+EY5Cxp23VLd6VXfbrGEXGx/cj0xstwUpt451jbhbphJWROwJfA/a2gHYIjLbepu2EznFKb1+rItqYRHWAqrJFuZ05wXlPpYMndbdH2m1shHU5Ytk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777630865; c=relaxed/simple; bh=NCYNNj0NkWufPkTKepkaNoi0XCTKn7czxRfDgkWXBxQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=M+Y93MlSPpe3hbmtd7dlo1/oPmPqtIIRw4mwXjZpvydCf5thjN7o6J1dgl72ibOScbiGK/NDvJ6uy5lUUem2LC1mlbHddqdLBe/H6aJBWvdn8SIdJ/pQH8q0qQzA4lqVpJsZKYTFql2nCUWDrCfOVqt27qyQW+JtafhT5/fjycA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pr3YyRNn; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ocpc0e8U; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pr3YyRNn"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ocpc0e8U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777630863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vz5A+6KeKGlFq8Cv2o15HFYqhPuxMdf0UtE/NQ9yOcM=; b=Pr3YyRNnieBrU8zJ3//fXurxk2T3dkuMzrOviITOkrnNsl/+dlHj/hggbvweXTLtxTYWsr islFBwZq4gfevvbpF+jqpytCmqkoQT2aIv/O22jeiw2+9Jga7J74AU9Xyg9h/xT29wPmj6 39dbljQPEwILlc9oQNCf3Wb6dLP22y0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-d7aeFf7bPqmEgcCncCDmPg-1; Fri, 01 May 2026 06:21:01 -0400 X-MC-Unique: d7aeFf7bPqmEgcCncCDmPg-1 X-Mimecast-MFC-AGG-ID: d7aeFf7bPqmEgcCncCDmPg_1777630861 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-488c2a4e257so13395115e9.3 for ; Fri, 01 May 2026 03:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777630860; x=1778235660; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vz5A+6KeKGlFq8Cv2o15HFYqhPuxMdf0UtE/NQ9yOcM=; b=ocpc0e8UIj0bn+ipeQfe/aasl4s0unHIY0klDnzzPq0ahSKY2YFh2GQNaBHv1ig40x rM6E2COBBDVuw5QJrsPJKDDa4HD4xu9MOA+s3Cnl1RmKVNzbnrFerJ7NoQ4BR25hzn6r UtgNVdb6lVQPqtsuTVejwSjvKpKeNkH+OcWPs6Aw6Cx5dgjDPSkrvlIgaEy4DTJaYYgv K8rhaWTyK1BiVFvCjMyyetUJ0d+vwWy4psOB7YZbkHvSiGzrzOYpfw66IsLlmf/g2+0f yM/+LZzR2BVmdSY4R2IqVHmA0Y9Of+pgjkS/F0l49nbBkPCmkPT+wy1DCXwbFCPyadxA UQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777630860; x=1778235660; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vz5A+6KeKGlFq8Cv2o15HFYqhPuxMdf0UtE/NQ9yOcM=; b=FSRCcudOu0FIDWK714pKZXImBegjzgb+yD20CveLfXkEDhXH9piUcx3bqY9GcmWanG uEHiAZ6WfZULld1cG+1DYsozU98gtmCWokhytckuU5xvsHKgnSMgBTx9RutqgY97RqB2 5TUUN0BmnTEz0fddHBnRozsTqShSlzpd4vX845TR9XBI4NOMH/9BQqXGr2ulqixAlkwK oEDXpJtwVbgFZzuGD8wOgEu3EgDRTmA+c6NUQEMaAa7Hqb1hLjU9KXUJzjHPuc5IyyzZ 43SktxVpQXrdcG+y5SnezOY7xoPiLZHK5vqQC7gk9GhVT+qXlD58qv+ZKZqLjMUY/3Km Rd4g== X-Forwarded-Encrypted: i=1; AFNElJ+lPaIsbBJVtA9oBJ5P0F9WJdgmqmxX1D14ESephBoRnFCxiiTYAUU/QjktvMKD6v/WJwSnJi8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1Ak/BwU1vvdOjLzSh70SeTO/FahY9Smjv8dsj/dOCPQNvXa/l pSgXWOHmlLEY3228PLYsy+vtSXP6/5R+DrMi5G0l9fY35a0wgnUtHkOnyKbXHJzecbjEmg1ntg+ hFqwACPA0Pvrkv7/jGCnFtSRGkxhKiJI9IzUI4AVsQMkM3Qb+FwLzfoYbrg== X-Gm-Gg: AeBDies5LrDCMIFdDXlZqD+b/USc0OU07b2qhdzTCBAASj4WEkOX34F5QI5pxB1T/xN STe57+xiZ7oc3Wh+g1E8Po5ztRasEYuwjVwHxK9iSu7jclfWQuUyQ5EZFQdl9pyHgz2EssnJNyh qYMTZCtY+4YFk9I+2hHRyGXQJjyHP6VGMhjDfvH/LUNmSLQ1oOy6pk2ncN1xMcdM87lEztz8t71 mCypsfksvXsbdpWUfKH6ViFYKpWff0GY/JsIUBNJ9lDMMPe03RBYPwURyGpe3LZEJDlei3iranF IW6SQGUCavgvKc55LE2Nb7T2D4sCiaIZn3I6O/DsfT90poKIvQzs4Cz44yZvQsUKeR8qZJTO26a Mc5gcsCSWY70bSXmvx899DOaakH1OVyM= X-Received: by 2002:a05:600c:190d:b0:488:a824:fdff with SMTP id 5b1f17b1804b1-48a8eb9a81fmr40080635e9.22.1777630860452; Fri, 01 May 2026 03:21:00 -0700 (PDT) X-Received: by 2002:a05:600c:190d:b0:488:a824:fdff with SMTP id 5b1f17b1804b1-48a8eb9a81fmr40080165e9.22.1777630859951; Fri, 01 May 2026 03:20:59 -0700 (PDT) Received: from [192.168.2.83] ([46.175.183.46]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a822bf3ffsm133020005e9.7.2026.05.01.03.20.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2026 03:20:59 -0700 (PDT) Message-ID: Date: Fri, 1 May 2026 12:20:58 +0200 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH iproute2-next 2/2] dpll: add frequency monitoring support To: Ivan Vecera , netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger References: <20260428152115.2815860-1-ivecera@redhat.com> <20260428152115.2815860-3-ivecera@redhat.com> Content-Language: en-US From: Petr Oros In-Reply-To: <20260428152115.2815860-3-ivecera@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/28/26 17:21, Ivan Vecera wrote: > Add support for the new frequency monitoring feature from the kernel > patch series "dpll: add actual frequency monitoring feature". This > includes: > > - DPLL_A_FREQUENCY_MONITOR device attribute (enable/disable) > - DPLL_A_PIN_MEASURED_FREQUENCY pin attribute displayed as fractional Hz > using DPLL_PR_MEASURED_FREQUENCY macro (kernel reports in mHz) > - device set: frequency-monitor { enable | disable } > - Refactor phase-offset-monitor to use new dpll_parse_attr_feature_state > helper shared with frequency-monitor > - Update man page and bash-completion > > Signed-off-by: Ivan Vecera > --- > bash-completion/dpll | 4 +-- > dpll/dpll.c | 62 ++++++++++++++++++++++++++++++++++---------- > man/man8/dpll.8 | 19 ++++++++++++-- > 3 files changed, 68 insertions(+), 17 deletions(-) > > diff --git a/bash-completion/dpll b/bash-completion/dpll > index 542b99c2fce2..7ddcf529d429 100644 > --- a/bash-completion/dpll > +++ b/bash-completion/dpll > @@ -100,7 +100,7 @@ _dpll_device() > COMPREPLY=( $( compgen -W "automatic manual" -- "$cur" ) ) > return 0 > ;; > - phase-offset-monitor) > + phase-offset-monitor|frequency-monitor) > COMPREPLY=( $( compgen -W "enable disable true false 0 1" -- "$cur" ) ) > return 0 > ;; > @@ -110,7 +110,7 @@ _dpll_device() > ;; > *) > COMPREPLY=( $( compgen -W "id mode phase-offset-monitor \ > - phase-offset-avg-factor" -- "$cur" ) ) > + phase-offset-avg-factor frequency-monitor" -- "$cur" ) ) > return 0 > ;; > esac > diff --git a/dpll/dpll.c b/dpll/dpll.c > index e8056ff6a24b..6d8c0cbb8a34 100644 > --- a/dpll/dpll.c > +++ b/dpll/dpll.c > @@ -313,6 +313,26 @@ static int dpll_parse_attr_str(struct dpll *dpll, struct nlmsghdr *nlh, > return 0; > } > > +static int dpll_parse_attr_feature_state(struct dpll *dpll, > + struct nlmsghdr *nlh, > + const char *arg_name, int attr_id) > +{ > + const char *str = dpll_argv_next(dpll); > + bool val; > + > + if (!str) { > + pr_err("%s requires an argument\n", arg_name); > + return -EINVAL; > + } > + if (str_to_bool(str, &val)) { > + pr_err("invalid %s value: %s (use enable/disable)\n", > + arg_name, str); > + return -EINVAL; > + } > + mnl_attr_put_u32(nlh, attr_id, val ? 1 : 0); > + return 0; > +} > + > static int dpll_parse_attr_enum(struct dpll *dpll, struct nlmsghdr *nlh, > const char *arg_name, int attr_id, > int (*parse_func)(struct dpll *, __u32 *)) > @@ -425,6 +445,21 @@ static __s64 mnl_attr_get_sint(const struct nlattr *attr) > } \ > } while (0) > > +/* Measured frequency - JSON prints raw mHz value, FP prints fractional Hz */ > +#define DPLL_PR_MEASURED_FREQUENCY(tb, attr_id) \ > + do { \ > + if (tb[attr_id]) { \ > + __u64 val = mnl_attr_get_u64(tb[attr_id]); \ > + lldiv_t d = lldiv(val, \ > + DPLL_PIN_MEASURED_FREQUENCY_DIVIDER); \ > + print_lluint(PRINT_JSON, "measured-frequency", \ > + NULL, val); \ > + print_s64(PRINT_FP, NULL, \ > + " measured-frequency: %lld.", d.quot); \ > + print_s64(PRINT_FP, NULL, "%03lld Hz\n", d.rem); \ > + } \ > + } while (0) > + > /* Generic version with custom format */ > #define DPLL_PR_ENUM_STR_FMT(tb, attr_id, name, format_str, name_func) \ > do { \ > @@ -657,6 +692,7 @@ static void cmd_device_help(void) > pr_err(" dpll device set id DEVICE_ID [ mode { automatic | manual } ]\n"); > pr_err(" [ phase-offset-monitor { enable | disable } ]\n"); > pr_err(" [ phase-offset-avg-factor NUM ]\n"); > + pr_err(" [ frequency-monitor { enable | disable } ]\n"); > pr_err(" dpll device id-get [ module-name NAME ] [ clock-id ID ] [ type TYPE ]\n"); > } > > @@ -1058,6 +1094,10 @@ static void dpll_device_print_attrs(const struct nlmsghdr *nlh, > str_enable_disable); > DPLL_PR_UINT(tb, DPLL_A_PHASE_OFFSET_AVG_FACTOR, > "phase-offset-avg-factor"); > + DPLL_PR_ENUM_STR_FMT(tb, DPLL_A_FREQUENCY_MONITOR, > + "frequency-monitor", > + " frequency-monitor: %s\n", > + str_enable_disable); > } > > /* Netlink callback - device get (single device) */ > @@ -1219,25 +1259,20 @@ static int cmd_device_set(struct dpll *dpll) > dpll_parse_mode)) > return -EINVAL; > } else if (dpll_argv_match(dpll, "phase-offset-monitor")) { > - const char *str = dpll_argv_next(dpll); > - bool val; > - > - if (!str) { > - pr_err("phase-offset-monitor requires an argument\n"); > - return -EINVAL; > - } > - if (str_to_bool(str, &val)) { > - pr_err("invalid phase-offset-monitor value: %s (use enable/disable)\n", > - str); > + if (dpll_parse_attr_feature_state(dpll, nlh, > + "phase-offset-monitor", > + DPLL_A_PHASE_OFFSET_MONITOR)) > return -EINVAL; > - } > - mnl_attr_put_u32(nlh, DPLL_A_PHASE_OFFSET_MONITOR, > - val ? 1 : 0); > } else if (dpll_argv_match(dpll, "phase-offset-avg-factor")) { > if (dpll_parse_attr_u32(dpll, nlh, > "phase-offset-avg-factor", > DPLL_A_PHASE_OFFSET_AVG_FACTOR)) > return -EINVAL; > + } else if (dpll_argv_match(dpll, "frequency-monitor")) { > + if (dpll_parse_attr_feature_state(dpll, nlh, > + "frequency-monitor", > + DPLL_A_FREQUENCY_MONITOR)) > + return -EINVAL; > } else { > pr_err("unknown option: %s\n", dpll_argv(dpll)); > return -EINVAL; > @@ -1601,6 +1636,7 @@ static void dpll_pin_print_attrs(struct nlattr **tb) > DPLL_PR_ENUM_STR(tb, DPLL_A_PIN_TYPE, "type", dpll_pin_type_name); > DPLL_PR_U64_FMT(tb, DPLL_A_PIN_FREQUENCY, "frequency", > " frequency: %" PRIu64 " Hz\n"); > + DPLL_PR_MEASURED_FREQUENCY(tb, DPLL_A_PIN_MEASURED_FREQUENCY); > > dpll_pin_print_freq_supported(tb[DPLL_A_PIN_FREQUENCY_SUPPORTED]); > > diff --git a/man/man8/dpll.8 b/man/man8/dpll.8 > index 89f17af74923..59ec4208f251 100644 > --- a/man/man8/dpll.8 > +++ b/man/man8/dpll.8 > @@ -111,7 +111,7 @@ Temperature (if supported) > Type (PPS or EEC) > .RE > > -.SS dpll device set id ID [ mode { automatic | manual } ] [ phase-offset-monitor { enable | disable } ] [ phase-offset-avg-factor FACTOR ] > +.SS dpll device set id ID [ mode { automatic | manual } ] [ phase-offset-monitor { enable | disable } ] [ phase-offset-avg-factor FACTOR ] [ frequency-monitor { enable | disable } ] > > Configure DPLL device parameters. > > @@ -140,6 +140,14 @@ When enabled, the kernel continuously measures and reports phase differences. > Set the averaging factor (1-255) applied to phase offset calculations. > Higher values provide smoother but slower-responding measurements. > > +.TP > +.BI frequency-monitor " { enable | disable | true | false | 0 | 1 }" > +Enable or disable frequency monitoring on the device. When enabled, the > +kernel continuously measures and reports actual pin frequencies, which can > +be read via the > +.B measured-frequency > +field in pin show output. > + > .SS dpll device id-get [ module-name NAME ] [ clock-id ID ] [ type TYPE ] > > Retrieve the device ID based on identifying attributes. Useful for scripting > @@ -233,7 +241,9 @@ Board label (hardware label from device tree or ACPI) > .IP \[bu] > Pin type (mux, ext, synce-eth-port, int-oscillator, gnss) > .IP \[bu] > -Frequency and supported frequency ranges > +Configured frequency and supported frequency ranges > +.IP \[bu] > +Measured frequency in Hz (when frequency monitoring is enabled) > .IP \[bu] > Capabilities (state-can-change, priority-can-change, direction-can-change) > .IP \[bu] > @@ -372,6 +382,11 @@ Press Ctrl+C to stop monitoring. > .B dpll device set id 0 phase-offset-monitor enable > .fi > > +.SS Enable frequency monitoring on device 0 > +.nf > +.B dpll device set id 0 frequency-monitor enable > +.fi > + > .SS Show all EEC devices > .nf > .B dpll device show type eec Reviewed-by: Petr Oros