From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Petr Oros <poros@redhat.com>, David Ahern <dsahern@kernel.org>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next v3 1/2] dpll: add ps unit to phase-related pin attributes
Date: Mon, 4 May 2026 18:30:13 +0200 [thread overview]
Message-ID: <20260504163014.416317-2-ivecera@redhat.com> (raw)
In-Reply-To: <20260504163014.416317-1-ivecera@redhat.com>
Display phase-adjust-min, phase-adjust-max and phase-adjust values
with ps unit. Add DPLL_PR_PHASE_OFFSET macro that properly formats
phase-offset as fractional picoseconds by dividing the raw kernel
value by DPLL_PHASE_OFFSET_DIVIDER.
Reviewed-by: Petr Oros <poros@redhat.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
Changes:
v3 - macro DPLL_PR_PHASE_OFFSET replaced by function
dpll_pr_phase_offset
---
dpll/dpll.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/dpll/dpll.c b/dpll/dpll.c
index b6ba3283e0ba..1c5d2b1b7f28 100644
--- a/dpll/dpll.c
+++ b/dpll/dpll.c
@@ -455,6 +455,24 @@ static void dpll_pr_multi_enum_str(const struct nlmsghdr *nlh, int attr_id,
print_nl();
}
+/* Phase offset - JSON prints raw sub-ps value, FP prints fractional ps */
+static void dpll_pr_phase_offset(struct nlattr *attr)
+{
+ __s64 val;
+ lldiv_t d;
+
+ if (!attr)
+ return;
+
+ val = mnl_attr_get_sint(attr);
+ d = lldiv(llabs(val), DPLL_PHASE_OFFSET_DIVIDER);
+ print_s64(PRINT_JSON, "phase-offset", NULL, val);
+ print_string(PRINT_FP, NULL, " phase-offset %s",
+ val < 0 ? "-" : "");
+ print_s64(PRINT_FP, NULL, "%lld.", d.quot);
+ print_s64(PRINT_FP, NULL, "%03lld ps", d.rem);
+}
+
/* Print frequency range (or single value if min==max) */
static void dpll_pr_freq_range(__u64 freq_min, __u64 freq_max)
{
@@ -1507,8 +1525,7 @@ static void dpll_pin_print_parent_devices(struct nlattr *attr)
" prio %u");
DPLL_PR_ENUM_STR_FMT(tb_parent, DPLL_A_PIN_STATE, "state",
" state %s", dpll_pin_state_name);
- DPLL_PR_SINT_FMT(tb_parent, DPLL_A_PIN_PHASE_OFFSET,
- "phase-offset", " phase-offset %" PRId64);
+ dpll_pr_phase_offset(tb_parent[DPLL_A_PIN_PHASE_OFFSET]);
print_nl();
close_json_object();
@@ -1592,10 +1609,13 @@ static void dpll_pin_print_attrs(struct nlattr **tb)
dpll_pin_print_capabilities(tb[DPLL_A_PIN_CAPABILITIES]);
- DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST_MIN, "phase-adjust-min");
- DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST_MAX, "phase-adjust-max");
+ DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST_MIN, "phase-adjust-min",
+ " phase-adjust-min: %d ps\n");
+ DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST_MAX, "phase-adjust-max",
+ " phase-adjust-max: %d ps\n");
DPLL_PR_UINT(tb, DPLL_A_PIN_PHASE_ADJUST_GRAN, "phase-adjust-gran");
- DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST, "phase-adjust");
+ DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST, "phase-adjust",
+ " phase-adjust: %d ps\n");
if (json || !tb[DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT])
DPLL_PR_SINT(tb, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET,
--
2.53.0
next prev parent reply other threads:[~2026-05-04 16:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 16:30 [PATCH iproute2-next v3 0/2] dpll: phase unit display and frequency monitoring Ivan Vecera
2026-05-04 16:30 ` Ivan Vecera [this message]
2026-05-04 16:30 ` [PATCH iproute2-next v3 2/2] dpll: add frequency monitoring support Ivan Vecera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260504163014.416317-2-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=poros@redhat.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox