]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc/taprio: print the offload xstats
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 7 Jun 2023 15:45:04 +0000 (18:45 +0300)
committerDavid Ahern <dsahern@kernel.org>
Fri, 9 Jun 2023 21:52:13 +0000 (15:52 -0600)
When the kernel reports offload counters through TCA_STATS2 ->
TCA_STATS_APP for the taprio qdisc, decode and print them.

Usage:

 # Global stats
 $ tc -s qdisc show dev eth0 root
 # Per-tc stats
 $ tc -s class show dev eth0

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
tc/q_taprio.c

index bc29710c46869f0d7e265e773dd819f7283cd42b..65d0a30bd67ffdead674c6d8c7312f5a63325c2f 100644 (file)
@@ -649,8 +649,32 @@ static int taprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
        return 0;
 }
 
+static int taprio_print_xstats(struct qdisc_util *qu, FILE *f,
+                              struct rtattr *xstats)
+{
+       struct rtattr *tb[TCA_TAPRIO_OFFLOAD_STATS_MAX + 1], *nla;
+
+       if (!xstats)
+               return 0;
+
+       parse_rtattr_nested(tb, TCA_TAPRIO_OFFLOAD_STATS_MAX, xstats);
+
+       nla = tb[TCA_TAPRIO_OFFLOAD_STATS_WINDOW_DROPS];
+       if (nla)
+               print_lluint(PRINT_ANY, "window_drops", " window_drops %llu",
+                            rta_getattr_u64(nla));
+
+       nla = tb[TCA_TAPRIO_OFFLOAD_STATS_TX_OVERRUNS];
+       if (nla)
+               print_lluint(PRINT_ANY, "tx_overruns", " tx_overruns %llu",
+                            rta_getattr_u64(nla));
+
+       return 0;
+}
+
 struct qdisc_util taprio_qdisc_util = {
        .id             = "taprio",
        .parse_qopt     = taprio_parse_opt,
        .print_qopt     = taprio_print_opt,
+       .print_xstats   = taprio_print_xstats,
 };