diff mbox series

[iproute2-next] tc/taprio: print the offload xstats

Message ID 20230607125441.3819767-1-vladimir.oltean@nxp.com (mailing list archive)
State Superseded
Delegated to: David Ahern
Headers show
Series [iproute2-next] tc/taprio: print the offload xstats | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Vladimir Oltean June 7, 2023, 12:54 p.m. UTC
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>
---
 tc/q_taprio.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Stephen Hemminger June 7, 2023, 3:13 p.m. UTC | #1
On Wed,  7 Jun 2023 15:54:41 +0300
Vladimir Oltean <vladimir.oltean@nxp.com> wrote:

> +static int taprio_print_xstats(struct qdisc_util *qu, FILE *f,
> +			       struct rtattr *xstats)
> +{
> +	struct rtattr *st[TCA_TAPRIO_OFFLOAD_STATS_MAX + 1], *nla;
> +
> +	if (!xstats)
> +		return 0;
> +
> +	parse_rtattr_nested(st, TCA_TAPRIO_OFFLOAD_STATS_MAX, xstats);
> +
> +	nla = st[TCA_TAPRIO_OFFLOAD_STATS_WINDOW_DROPS];
> +	if (nla)
> +		print_lluint(PRINT_ANY, "window-drops", " Window drops: %llu",
> +			     rta_getattr_u64(nla));
> +
> +	nla = st[TCA_TAPRIO_OFFLOAD_STATS_TX_OVERRUNS];
> +	if (nla)
> +		print_lluint(PRINT_ANY, "tx-overruns", " Transmit overruns: %llu",
> +			     rta_getattr_u64(nla));
> +

Ok, but the choice of wording here is off. It makes taprio stats different
in style than other qdisc. The convention in other qdisc is not to use upper case,
and use a one word key.

In other words, not "window-drops", " Window drops: %llu" but instead
      "window_drops", " window_drops %llu",
Vladimir Oltean June 7, 2023, 3:33 p.m. UTC | #2
On Wed, Jun 07, 2023 at 08:13:35AM -0700, Stephen Hemminger wrote:
> Ok, but the choice of wording here is off. It makes taprio stats different
> in style than other qdisc. The convention in other qdisc is not to use upper case,
> and use a one word key.
> 
> In other words, not "window-drops", " Window drops: %llu" but instead
>       "window_drops", " window_drops %llu",

Ok. v2 coming.
diff mbox series

Patch

diff --git a/tc/q_taprio.c b/tc/q_taprio.c
index bc29710c4686..359c4c03b8c6 100644
--- a/tc/q_taprio.c
+++ b/tc/q_taprio.c
@@ -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 *st[TCA_TAPRIO_OFFLOAD_STATS_MAX + 1], *nla;
+
+	if (!xstats)
+		return 0;
+
+	parse_rtattr_nested(st, TCA_TAPRIO_OFFLOAD_STATS_MAX, xstats);
+
+	nla = st[TCA_TAPRIO_OFFLOAD_STATS_WINDOW_DROPS];
+	if (nla)
+		print_lluint(PRINT_ANY, "window-drops", " Window drops: %llu",
+			     rta_getattr_u64(nla));
+
+	nla = st[TCA_TAPRIO_OFFLOAD_STATS_TX_OVERRUNS];
+	if (nla)
+		print_lluint(PRINT_ANY, "tx-overruns", " Transmit 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,
 };