diff mbox series

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

Message ID 20230607154504.4085041-1-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 559ffd9e21bf6d29d704cea3dbe38fbaac310f43
Delegated to: David Ahern
Headers show
Series [v2,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, 3:45 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>
---
v1->v2:
- s/st/tb/ for consistency with the rest of q_taprio.c
- name counters tx_overruns and window_drops for consistency with the
  printing style of other Qdiscs

 tc/q_taprio.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org June 9, 2023, 10 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Wed,  7 Jun 2023 18:45:04 +0300 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [v2,iproute2-next] tc/taprio: print the offload xstats
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=559ffd9e21bf

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tc/q_taprio.c b/tc/q_taprio.c
index bc29710c4686..65d0a30bd67f 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 *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,
 };