[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180710210558.20278-15-stephen@networkplumber.org>
Date: Tue, 10 Jul 2018 14:05:41 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <sthemmin@...rosoft.com>,
Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH v2 iproute2-next 14/31] tc/sfb: implement JSON output
From: Stephen Hemminger <sthemmin@...rosoft.com>
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
tc/q_sfb.c | 56 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff --git a/tc/q_sfb.c b/tc/q_sfb.c
index 7f48c6e0ef39..d58ce71f83ce 100644
--- a/tc/q_sfb.c
+++ b/tc/q_sfb.c
@@ -153,14 +153,20 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (RTA_PAYLOAD(tb[TCA_SFB_PARMS]) < sizeof(*qopt))
return -1;
- fprintf(f,
- "limit %d max %d target %d\n"
- " increment %.5f decrement %.5f penalty rate %d burst %d (%ums %ums)",
- qopt->limit, qopt->max, qopt->bin_size,
- (double)qopt->increment / SFB_MAX_PROB,
- (double)qopt->decrement / SFB_MAX_PROB,
- qopt->penalty_rate, qopt->penalty_burst,
- qopt->rehash_interval, qopt->warmup_time);
+ print_uint(PRINT_ANY, "limit", "limit %u", qopt->limit);
+ print_uint(PRINT_ANY, "max", " max %u", qopt->max);
+ print_uint(PRINT_ANY, "target", " target %u", qopt->bin_size);
+ print_string(PRINT_FP, NULL, "%s", _SL_);
+
+ print_float(PRINT_ANY, "increment", " increment %.5f",
+ (double)qopt->increment / SFB_MAX_PROB);
+ print_float(PRINT_ANY, "decrement", " decrement %.5f",
+ (double)qopt->decrement / SFB_MAX_PROB);
+ print_uint(PRINT_ANY, "penalty_rate", " penalty rate %u",
+ qopt->penalty_rate);
+ print_uint(PRINT_ANY, "penalty_burst", " burst %u", qopt->penalty_burst);
+ print_uint(PRINT_ANY, "rehash", " (%ums", qopt->rehash_interval);
+ print_uint(PRINT_ANY, "warmup", " %ums)", qopt->warmup_time);
return 0;
}
@@ -168,24 +174,30 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
static int sfb_print_xstats(struct qdisc_util *qu, FILE *f,
struct rtattr *xstats)
{
- struct tc_sfb_xstats *st;
+ struct tc_sfb_xstats *st;
- if (xstats == NULL)
- return 0;
+ if (xstats == NULL)
+ return 0;
- if (RTA_PAYLOAD(xstats) < sizeof(*st))
- return -1;
+ if (RTA_PAYLOAD(xstats) < sizeof(*st))
+ return -1;
- st = RTA_DATA(xstats);
- fprintf(f,
- " earlydrop %u penaltydrop %u bucketdrop %u queuedrop %u childdrop %u marked %u\n"
- " maxqlen %u maxprob %.5f avgprob %.5f ",
- st->earlydrop, st->penaltydrop, st->bucketdrop, st->queuedrop, st->childdrop,
- st->marked,
- st->maxqlen, (double)st->maxprob / SFB_MAX_PROB,
- (double)st->avgprob / SFB_MAX_PROB);
+ st = RTA_DATA(xstats);
+ print_uint(PRINT_ANY, "earlydrop", " earlydrop %u", st->earlydrop);
+ print_uint(PRINT_ANY, "penaltydrop", "penaltydrop %u", st->penaltydrop);
+ print_uint(PRINT_ANY, "bucketdrop", "bucketdrop %u", st->bucketdrop);
+ print_uint(PRINT_ANY, "queuedrop", "queuedrop %u", st->queuedrop);
+ print_uint(PRINT_ANY, "childdrop", "childdrop %u", st->childdrop);
+ print_uint(PRINT_ANY, "marked", "marked %u", st->marked);
+ print_uint(PRINT_ANY, "maxqlen", " maxqlen %u", st->maxqlen);
+ print_string(PRINT_FP, NULL, "%s", _SL_);
+
+ print_float(PRINT_ANY, "maxprob", " maxprob %.5f",
+ (double)st->maxprob / SFB_MAX_PROB);
+ print_float(PRINT_ANY, "avgprob", " avgprob %.5f",
+ (double)st->avgprob / SFB_MAX_PROB);
- return 0;
+ return 0;
}
struct qdisc_util sfb_qdisc_util = {
--
2.18.0
Powered by blists - more mailing lists