]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/q_gred.c
vdpa: add .gitignore
[mirror_iproute2.git] / tc / q_gred.c
index e297b866c76e82bcd7607b91bd27c0b1351c9f52..89aeb086038f39d2dddfa46eb5575c383128dc24 100644 (file)
 
 static void explain(void)
 {
-       fprintf(stderr, "Usage: tc qdisc { add | replace | change } ... gred setup vqs NUMBER\n");
-       fprintf(stderr, "           default DEFAULT_VQ [ grio ] [ limit BYTES ] [ecn] [harddrop]\n");
-       fprintf(stderr, "       tc qdisc change ... gred vq VQ [ prio VALUE ] limit BYTES\n");
-       fprintf(stderr, "           min BYTES max BYTES avpkt BYTES [ burst PACKETS ]\n");
-       fprintf(stderr, "           [ probability PROBABILITY ] [ bandwidth KBPS ] [ecn] [harddrop]\n");
+       fprintf(stderr,
+               "Usage: tc qdisc { add | replace | change } ... gred setup vqs NUMBER\n"
+               "           default DEFAULT_VQ [ grio ] [ limit BYTES ] [ecn] [harddrop]\n"
+               "       tc qdisc change ... gred vq VQ [ prio VALUE ] limit BYTES\n"
+               "           min BYTES max BYTES avpkt BYTES [ burst PACKETS ]\n"
+               "           [ probability PROBABILITY ] [ bandwidth KBPS ] [ecn] [harddrop]\n");
 }
 
 static int init_gred(struct qdisc_util *qu, int argc, char **argv,
@@ -372,18 +373,11 @@ gred_print_stats(struct tc_gred_info *info, struct tc_gred_qopt *qopt)
 {
        __u64 bytes = info ? info->bytes : qopt->bytesin;
 
-       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));
+       print_size(PRINT_ANY, "qave", "average %s ", qopt->qave);
+       print_size(PRINT_ANY, "backlog", "current %s ", qopt->backlog);
 
        if (!is_json_context())
                printf("\n  Dropped packets: ");
@@ -414,9 +408,7 @@ gred_print_stats(struct tc_gred_info *info, struct tc_gred_qopt *qopt)
                printf("\n  Total packets: ");
 
        print_uint(PRINT_ANY, "packets", "%u ", qopt->packets);
-
-       print_uint(PRINT_JSON, "bytes", NULL, bytes);
-       print_string(PRINT_FP, NULL, "(%s) ", sprint_size(bytes, b1));
+       print_size(PRINT_ANY, "bytes", "(%s) ", bytes);
 }
 
 static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
@@ -430,8 +422,6 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
        __u32 *limit = NULL;
        unsigned int i;
 
-       SPRINT_BUF(b1);
-
        if (opt == NULL)
                return 0;
 
@@ -469,11 +459,8 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
        else
                print_bool(PRINT_ANY, "grio", NULL, false);
 
-       if (limit) {
-               print_uint(PRINT_JSON, "limit", NULL, *limit);
-               print_string(PRINT_FP, NULL, "limit %s ",
-                            sprint_size(*limit, b1));
-       }
+       if (limit)
+               print_size(PRINT_ANY, "limit", "limit %s ", *limit);
 
        tc_red_print_flags(sopt->flags);
 
@@ -486,18 +473,9 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 
                print_uint(PRINT_ANY, "vq", "\n vq %u ", qopt->DP);
                print_hhu(PRINT_ANY, "prio", "prio %hhu ", qopt->prio);
-
-               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, b1));
-
-               print_uint(PRINT_JSON, "max", NULL, qopt->qth_max);
-               print_string(PRINT_FP, NULL, "max %s ",
-                            sprint_size(qopt->qth_max, b1));
+               print_size(PRINT_ANY, "limit", "limit %s ", qopt->limit);
+               print_size(PRINT_ANY, "min", "min %s ", qopt->qth_min);
+               print_size(PRINT_ANY, "max", "max %s ", qopt->qth_max);
 
                if (infos[i].flags_present)
                        tc_red_print_flags(infos[i].flags);