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 v2 1/2] dpll: add ps unit to phase-related pin attributes
Date: Sun, 3 May 2026 17:13:51 +0200 [thread overview]
Message-ID: <20260503151352.136509-2-ivecera@redhat.com> (raw)
In-Reply-To: <20260503151352.136509-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>
---
dpll/dpll.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/dpll/dpll.c b/dpll/dpll.c
index b6ba3283e0ba..e8056ff6a24b 100644
--- a/dpll/dpll.c
+++ b/dpll/dpll.c
@@ -410,6 +410,21 @@ static __s64 mnl_attr_get_sint(const struct nlattr *attr)
} \
} while (0)
+/* Phase offset - JSON prints raw sub-ps value, FP prints fractional ps */
+#define DPLL_PR_PHASE_OFFSET(tb, attr_id) \
+ do { \
+ if (tb[attr_id]) { \
+ __s64 val = mnl_attr_get_sint(tb[attr_id]); \
+ lldiv_t 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); \
+ } \
+ } while (0)
+
/* Generic version with custom format */
#define DPLL_PR_ENUM_STR_FMT(tb, attr_id, name, format_str, name_func) \
do { \
@@ -1507,8 +1522,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 +1606,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-03 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 15:13 [PATCH iproute2-next v2 0/2] dpll: phase unit display and frequency monitoring Ivan Vecera
2026-05-03 15:13 ` Ivan Vecera [this message]
2026-05-03 22:34 ` [PATCH iproute2-next v2 1/2] dpll: add ps unit to phase-related pin attributes Stephen Hemminger
2026-05-04 6:48 ` Ivan Vecera
2026-05-03 15:13 ` [PATCH iproute2-next v2 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=20260503151352.136509-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