All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio
@ 2018-01-26 19:27 Jakub Kicinski
  2018-01-26 19:27 ` [PATCH iproute2-next 1/2] tc: red: JSON-ify RED output Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2018-01-26 19:27 UTC (permalink / raw)
  To: dsahern, stephen; +Cc: oss-drivers, netdev, Quentin Monnet, Jakub Kicinski

Hi!

This small series adds support for JSON output for prio and RED qdiscs.

Jakub Kicinski (2):
  tc: red: JSON-ify RED output
  tc: prio: JSON-ify prio output

 include/json_print.h |  1 +
 lib/json_print.c     |  1 +
 lib/json_writer.c    |  4 ----
 tc/q_prio.c          | 12 ++++++++----
 tc/q_red.c           | 41 ++++++++++++++++++++++++++---------------
 5 files changed, 36 insertions(+), 23 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH iproute2-next 1/2] tc: red: JSON-ify RED output
  2018-01-26 19:27 [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio Jakub Kicinski
@ 2018-01-26 19:27 ` Jakub Kicinski
  2018-01-26 19:27 ` [PATCH iproute2-next 2/2] tc: prio: JSON-ify prio output Jakub Kicinski
  2018-01-26 21:01 ` [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2018-01-26 19:27 UTC (permalink / raw)
  To: dsahern, stephen; +Cc: oss-drivers, netdev, Quentin Monnet, Jakub Kicinski

Make JSON output work with RED Qdiscs.  Float/double printing
helpers have to be added/uncommented to print the probability.
Since TC stats in general are not split out to a separate object
the xstats printed by this patch are not separated either.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/json_print.h |  1 +
 lib/json_print.c     |  1 +
 lib/json_writer.c    |  4 ----
 tc/q_red.c           | 41 ++++++++++++++++++++++++++---------------
 4 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/include/json_print.h b/include/json_print.h
index dc4d2bb3ba59..2ca7830adbd6 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -64,6 +64,7 @@ _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(hex, unsigned int);
 _PRINT_FUNC(0xhex, unsigned int);
 _PRINT_FUNC(lluint, unsigned long long int);
+_PRINT_FUNC(float, double);
 #undef _PRINT_FUNC
 
 #endif /* _JSON_PRINT_H_ */
diff --git a/lib/json_print.c b/lib/json_print.c
index aa527af652c5..6518ba98f5bf 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -120,6 +120,7 @@ _PRINT_FUNC(int, int);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(uint, uint64_t);
 _PRINT_FUNC(lluint, unsigned long long int);
+_PRINT_FUNC(float, double);
 #undef _PRINT_FUNC
 
 void print_color_string(enum output_type type,
diff --git a/lib/json_writer.c b/lib/json_writer.c
index 6b77d288cce2..f3eeaf7bc479 100644
--- a/lib/json_writer.c
+++ b/lib/json_writer.c
@@ -209,12 +209,10 @@ void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num)
 	jsonw_printf(self, fmt, num);
 }
 
-#ifdef notused
 void jsonw_float(json_writer_t *self, double num)
 {
 	jsonw_printf(self, "%g", num);
 }
-#endif
 
 void jsonw_hu(json_writer_t *self, unsigned short num)
 {
@@ -249,13 +247,11 @@ void jsonw_bool_field(json_writer_t *self, const char *prop, bool val)
 	jsonw_bool(self, val);
 }
 
-#ifdef notused
 void jsonw_float_field(json_writer_t *self, const char *prop, double val)
 {
 	jsonw_name(self, prop);
 	jsonw_float(self, val);
 }
-#endif
 
 void jsonw_float_field_fmt(json_writer_t *self,
 			   const char *prop,
diff --git a/tc/q_red.c b/tc/q_red.c
index 1949558f14f9..40ba7c3e07c1 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -183,23 +183,34 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	    RTA_PAYLOAD(tb[TCA_RED_MAX_P]) >= sizeof(__u32))
 		max_P = rta_getattr_u32(tb[TCA_RED_MAX_P]);
 
-	fprintf(f, "limit %s min %s max %s ",
-		sprint_size(qopt->limit, b1),
-		sprint_size(qopt->qth_min, b2),
-		sprint_size(qopt->qth_max, b3));
+	print_uint(PRINT_JSON, "limit", NULL, qopt->limit);
+	print_string(PRINT_FP, NULL, "limit %s ", sprint_size(qopt->limit, b1));
+	print_uint(PRINT_JSON, "min", NULL, qopt->qth_min);
+	print_string(PRINT_FP, NULL, "min %s ", sprint_size(qopt->qth_min, b2));
+	print_uint(PRINT_JSON, "max", NULL, qopt->qth_max);
+	print_string(PRINT_FP, NULL, "max %s ", sprint_size(qopt->qth_max, b3));
+
 	if (qopt->flags & TC_RED_ECN)
-		fprintf(f, "ecn ");
+		print_bool(PRINT_ANY, "ecn", "ecn ", true);
+	else
+		print_bool(PRINT_ANY, "ecn", NULL, false);
 	if (qopt->flags & TC_RED_HARDDROP)
-		fprintf(f, "harddrop ");
+		print_bool(PRINT_ANY, "harddrop", "harddrop ", true);
+	else
+		print_bool(PRINT_ANY, "harddrop", NULL, false);
 	if (qopt->flags & TC_RED_ADAPTATIVE)
-		fprintf(f, "adaptive ");
+		print_bool(PRINT_ANY, "adaptive", "adaptive ", true);
+	else
+		print_bool(PRINT_ANY, "adaptive", NULL, false);
 	if (show_details) {
-		fprintf(f, "ewma %u ", qopt->Wlog);
+		print_uint(PRINT_ANY, "ewma", "ewma %u ", qopt->Wlog);
 		if (max_P)
-			fprintf(f, "probability %lg ", max_P / pow(2, 32));
+			print_float(PRINT_ANY, "probability",
+				    "probability %lg ", max_P / pow(2, 32));
 		else
-			fprintf(f, "Plog %u ", qopt->Plog);
-		fprintf(f, "Scell_log %u", qopt->Scell_log);
+			print_uint(PRINT_ANY, "Plog", "Plog %u ", qopt->Plog);
+		print_uint(PRINT_ANY, "Scell_log", "Scell_log %u",
+			   qopt->Scell_log);
 	}
 	return 0;
 }
@@ -216,10 +227,10 @@ static int red_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstat
 		return -1;
 
 	st = RTA_DATA(xstats);
-	fprintf(f, "  marked %u early %u pdrop %u other %u",
-		st->marked, st->early, st->pdrop, st->other);
-	return 0;
-
+	print_uint(PRINT_ANY, "marked", "  marked %u ", st->marked);
+	print_uint(PRINT_ANY, "early", "early %u ", st->early);
+	print_uint(PRINT_ANY, "pdrop", "pdrop %u ", st->pdrop);
+	print_uint(PRINT_ANY, "other", "other %u ", st->other);
 #endif
 	return 0;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH iproute2-next 2/2] tc: prio: JSON-ify prio output
  2018-01-26 19:27 [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio Jakub Kicinski
  2018-01-26 19:27 ` [PATCH iproute2-next 1/2] tc: red: JSON-ify RED output Jakub Kicinski
@ 2018-01-26 19:27 ` Jakub Kicinski
  2018-01-26 21:01 ` [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2018-01-26 19:27 UTC (permalink / raw)
  To: dsahern, stephen; +Cc: oss-drivers, netdev, Quentin Monnet, Jakub Kicinski

Make JSON output work with prio Qdiscs.  This will also make
other qdiscs which reuse the print_qopt work, like mqprio or
pfifo_fast.

Note that there is a double space between "priomap" and first
prio number.  Keep this original behaviour.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tc/q_prio.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tc/q_prio.c b/tc/q_prio.c
index 358cf06cca0a..8ef7cfa260d5 100644
--- a/tc/q_prio.c
+++ b/tc/q_prio.c
@@ -107,13 +107,17 @@ int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 					sizeof(*qopt)))
 		return -1;
 
-	fprintf(f, "bands %u priomap ", qopt->bands);
+	print_uint(PRINT_ANY, "bands", "bands %u ", qopt->bands);
+	open_json_array(PRINT_ANY, "priomap ");
 	for (i = 0; i <= TC_PRIO_MAX; i++)
-		fprintf(f, " %d", qopt->priomap[i]);
+		print_uint(PRINT_ANY, NULL, " %d", qopt->priomap[i]);
+	close_json_array(PRINT_ANY, "");
 
 	if (tb[TCA_PRIO_MQ])
-		fprintf(f, " multiqueue: %s ",
-			rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off");
+		print_string(PRINT_FP, NULL, " multiqueue: %s ",
+			     rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off");
+	print_bool(PRINT_JSON, "multiqueue", NULL,
+		   tb[TCA_PRIO_MQ] && rta_getattr_u8(tb[TCA_PRIO_MQ]));
 
 	return 0;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio
  2018-01-26 19:27 [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio Jakub Kicinski
  2018-01-26 19:27 ` [PATCH iproute2-next 1/2] tc: red: JSON-ify RED output Jakub Kicinski
  2018-01-26 19:27 ` [PATCH iproute2-next 2/2] tc: prio: JSON-ify prio output Jakub Kicinski
@ 2018-01-26 21:01 ` David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2018-01-26 21:01 UTC (permalink / raw)
  To: Jakub Kicinski, stephen; +Cc: oss-drivers, netdev, Quentin Monnet

On 1/26/18 12:27 PM, Jakub Kicinski wrote:
> Hi!
> 
> This small series adds support for JSON output for prio and RED qdiscs.
> 
> Jakub Kicinski (2):
>   tc: red: JSON-ify RED output
>   tc: prio: JSON-ify prio output
> 
>  include/json_print.h |  1 +
>  lib/json_print.c     |  1 +
>  lib/json_writer.c    |  4 ----
>  tc/q_prio.c          | 12 ++++++++----
>  tc/q_red.c           | 41 ++++++++++++++++++++++++++---------------
>  5 files changed, 36 insertions(+), 23 deletions(-)
> 

Series applied to iproute2-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-26 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 19:27 [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio Jakub Kicinski
2018-01-26 19:27 ` [PATCH iproute2-next 1/2] tc: red: JSON-ify RED output Jakub Kicinski
2018-01-26 19:27 ` [PATCH iproute2-next 2/2] tc: prio: JSON-ify prio output Jakub Kicinski
2018-01-26 21:01 ` [PATCH iproute2-next 0/2] tc: qdisc: provide JSON output for RED and prio David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.