tc: red: JSON-ify RED output
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> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
db9fd71038
commit
097415d510
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
41
tc/q_red.c
41
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue