All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: dsahern@gmail.com, stephen@networkplumber.org
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH iproute2-next 5/8] tc: gred: separate out stats printing
Date: Mon, 19 Nov 2018 15:03:32 -0800	[thread overview]
Message-ID: <20181119230335.11771-6-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20181119230335.11771-1-jakub.kicinski@netronome.com>

Printing GRED statistics is long and deserves a function on its own.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
 tc/q_gred.c | 67 +++++++++++++++++++++++++++--------------------------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/tc/q_gred.c b/tc/q_gred.c
index 768b77ba3b0d..501437bc5abe 100644
--- a/tc/q_gred.c
+++ b/tc/q_gred.c
@@ -265,6 +265,38 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
 	return 0;
 }
 
+static void gred_print_stats(struct tc_gred_qopt *qopt)
+{
+	SPRINT_BUF(b1);
+
+	if (!is_json_context())
+		printf("\n  Queue size: ");
+
+	print_uint(PRINT_JSON, "qave", NULL, qopt->qave);
+	print_string(PRINT_FP, NULL, "average %s ",
+		     sprint_size(qopt->qave, b1));
+
+	print_uint(PRINT_JSON, "backlog", NULL, qopt->backlog);
+	print_string(PRINT_FP, NULL, "current %s ",
+		     sprint_size(qopt->backlog, b1));
+
+	if (!is_json_context())
+		printf("\n  Dropped packets: ");
+
+	print_uint(PRINT_ANY, "forced_drop", "forced %u ", qopt->forced);
+	print_uint(PRINT_ANY, "prob_drop", "early %u ", qopt->early);
+	print_uint(PRINT_ANY, "pdrop", "pdrop %u ", qopt->pdrop);
+	print_uint(PRINT_ANY, "other", "other %u ", qopt->other);
+
+	if (!is_json_context())
+		printf("\n  Total packets: ");
+
+	print_uint(PRINT_ANY, "packets", "%u ", qopt->packets);
+
+	print_uint(PRINT_JSON, "bytes", NULL, qopt->bytesin);
+	print_string(PRINT_FP, NULL, "(%s) ", sprint_size(qopt->bytesin, b1));
+}
+
 static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	struct rtattr *tb[TCA_GRED_MAX + 1];
@@ -348,39 +380,8 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 			print_uint(PRINT_ANY, "Scell_log", "Scell_log %u ",
 				   qopt->Scell_log);
 		}
-		if (show_stats) {
-			if (!is_json_context())
-				printf("\n  Queue size: ");
-
-			print_uint(PRINT_JSON, "qave", NULL, qopt->qave);
-			print_string(PRINT_FP, NULL, "average %s ",
-				     sprint_size(qopt->qave, b1));
-
-			print_uint(PRINT_JSON, "backlog", NULL, qopt->backlog);
-			print_string(PRINT_FP, NULL, "current %s ",
-				     sprint_size(qopt->backlog, b1));
-
-			if (!is_json_context())
-				printf("\n  Dropped packets: ");
-
-			print_uint(PRINT_ANY, "forced_drop", "forced %u ",
-				   qopt->forced);
-			print_uint(PRINT_ANY, "prob_drop", "early %u ",
-				   qopt->early);
-			print_uint(PRINT_ANY, "pdrop", "pdrop %u ",
-				   qopt->pdrop);
-			print_uint(PRINT_ANY, "other", "other %u ",
-				   qopt->other);
-
-			if (!is_json_context())
-				printf("\n  Total packets: ");
-
-			print_uint(PRINT_ANY, "packets", "%u ", qopt->packets);
-
-			print_uint(PRINT_JSON, "bytes", NULL, qopt->bytesin);
-			print_string(PRINT_FP, NULL, "(%s) ",
-				     sprint_size(qopt->bytesin, b1));
-		}
+		if (show_stats)
+			gred_print_stats(qopt);
 		close_json_object();
 	}
 	close_json_array(PRINT_JSON, "vqs");
-- 
2.17.1

  parent reply	other threads:[~2018-11-20  9:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 23:03 [PATCH iproute2-next 0/8] tc: gred: JSON-ify and support per-vq config Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 1/8] tc: gred: remove unclear comment Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 2/8] json: add %hhu helpers Jakub Kicinski
2018-11-20  1:18   ` Stephen Hemminger
2018-11-20  1:40     ` Jakub Kicinski
2018-11-20 23:18       ` David Ahern
2018-11-19 23:03 ` [PATCH iproute2-next 3/8] tc: move RED flag printing to helper Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 4/8] tc: gred: jsonify GRED output Jakub Kicinski
2018-11-19 23:03 ` Jakub Kicinski [this message]
2018-11-19 23:03 ` [PATCH iproute2-next 6/8] tc: gred: use extended stats if available Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 7/8] tc: gred: support controlling RED flags Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 8/8] tc: gred: allow controlling and dumping per-DP " Jakub Kicinski
2018-11-24 15:26 ` [PATCH iproute2-next 0/8] tc: gred: JSON-ify and support per-vq config David Ahern

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=20181119230335.11771-6-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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 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.