public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Victor Nogueira <victor@mojatatu.com>
To: stephen@networkplumber.org, dsahern@kernel.org
Cc: jhs@mojatatu.com, deren.teo@outlook.com, andrew@lunn.ch,
	netdev@vger.kernel.org
Subject: [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC
Date: Tue,  3 Mar 2026 10:07:31 -0300	[thread overview]
Message-ID: <20260303130733.540278-2-victor@mojatatu.com> (raw)
In-Reply-To: <20260303130733.540278-1-victor@mojatatu.com>

Since qdisc core already assumes all qdiscs are able to output JSON,
add JSON output support to HFSC.

Fixes: c91d262f414d ("tc: jsonify qdisc core")
Reported-by: Deren Teo <deren.teo@outlook.com>
Closes: https://lore.kernel.org/netdev/SI2PPF4F82E9256898C9826AF17C3AE8AD9F467A@SI2PPF4F82E9256.apcprd04.prod.outlook.com/
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
 tc/q_hfsc.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index aed7130c..f68e8351 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -108,7 +108,8 @@ hfsc_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	qopt = RTA_DATA(opt);
 
 	if (qopt->defcls != 0)
-		fprintf(f, "default %x ", qopt->defcls);
+		print_0xhex(PRINT_ANY, "default", " default %#llx ",
+			    qopt->defcls);
 
 	return 0;
 }
@@ -124,13 +125,15 @@ hfsc_print_xstats(const struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
 		return -1;
 	st = RTA_DATA(xstats);
 
-	fprintf(f, " period %u ", st->period);
+	print_uint(PRINT_ANY, "period", " period %u ", st->period);
 	if (st->work != 0)
-		fprintf(f, "work %llu bytes ", (unsigned long long) st->work);
+		print_lluint(PRINT_ANY, "work", "work %llu bytes ",
+			     (unsigned long long)st->work);
 	if (st->rtwork != 0)
-		fprintf(f, "rtwork %llu bytes ", (unsigned long long) st->rtwork);
-	fprintf(f, "level %u ", st->level);
-	fprintf(f, "\n");
+		print_lluint(PRINT_ANY, "rtwork", "rtwork %llu bytes ",
+			     (unsigned long long)st->rtwork);
+	print_uint(PRINT_ANY, "level", " level %u ", st->level);
+	print_string(PRINT_FP, NULL, "%s", _SL_);
 
 	return 0;
 }
@@ -211,12 +214,16 @@ hfsc_parse_class_opt(const struct qdisc_util *qu, int argc, char **argv,
 static void
 hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc)
 {
+	unsigned int d_time = tc_core_ktime2time(sc->d);
 	SPRINT_BUF(b1);
 
-	fprintf(f, "%s ", name);
-	tc_print_rate(PRINT_FP, NULL, "m1 %s ", sc->m1);
-	fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
-	tc_print_rate(PRINT_FP, NULL, "m2 %s ", sc->m2);
+	open_json_object(name);
+	print_string(PRINT_FP, NULL, "%s ", name);
+	tc_print_rate(PRINT_ANY, "m1", "m1 %s ", sc->m1);
+	print_string(PRINT_FP, NULL, "d %s ", sprint_time(d_time, b1));
+	print_uint(PRINT_JSON, "d", NULL, d_time);
+	tc_print_rate(PRINT_ANY, "m2", "m2 %s ", sc->m2);
+	close_json_object();
 }
 
 static int
-- 
2.53.0


  reply	other threads:[~2026-03-03 13:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
2026-03-03 13:07 ` Victor Nogueira [this message]
2026-03-03 13:07 ` [PATCH iproute2 v2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
2026-03-03 13:07 ` [PATCH iproute2 v2 3/3] tc: Add JSON output support to multiq Victor Nogueira
2026-03-07  1:20 ` [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs patchwork-bot+netdevbpf

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=20260303130733.540278-2-victor@mojatatu.com \
    --to=victor@mojatatu.com \
    --cc=andrew@lunn.ch \
    --cc=deren.teo@outlook.com \
    --cc=dsahern@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --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