|
|
d8fb9e |
From 74fa5754e5a7cc140a7b586d22d9e7e7272ed28b Mon Sep 17 00:00:00 2001
|
|
|
d8fb9e |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
d8fb9e |
Date: Tue, 21 Apr 2020 14:53:23 +0200
|
|
|
d8fb9e |
Subject: [PATCH] tc_util: Add support for showing TCA_STATS_BASIC_HW
|
|
|
d8fb9e |
statistics
|
|
|
d8fb9e |
|
|
|
d8fb9e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1637437
|
|
|
d8fb9e |
Upstream Status: iproute2.git commit 5ac138324e31c
|
|
|
d8fb9e |
Conflicts: adjust the code to make it compile due to missing
|
|
|
d8fb9e |
commit c91d262f414d2 ("tc: jsonify qdisc core")
|
|
|
d8fb9e |
|
|
|
d8fb9e |
commit 5ac138324e31c75edc65c69cedcf699fb624c113
|
|
|
d8fb9e |
Author: Eelco Chaudron <echaudro@redhat.com>
|
|
|
d8fb9e |
Date: Tue Oct 2 03:27:18 2018 -0400
|
|
|
d8fb9e |
|
|
|
d8fb9e |
tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
|
|
|
d8fb9e |
|
|
|
d8fb9e |
Add support for showing hardware specific counters to easy
|
|
|
d8fb9e |
troubleshooting hardware offload.
|
|
|
d8fb9e |
|
|
|
d8fb9e |
$ tc -s filter show dev enp3s0np0 parent ffff:
|
|
|
d8fb9e |
filter protocol ip pref 1 flower chain 0
|
|
|
d8fb9e |
filter protocol ip pref 1 flower chain 0 handle 0x1
|
|
|
d8fb9e |
eth_type ipv4
|
|
|
d8fb9e |
dst_ip 2.0.0.0
|
|
|
d8fb9e |
src_ip 1.0.0.0
|
|
|
d8fb9e |
ip_flags nofrag
|
|
|
d8fb9e |
in_hw
|
|
|
d8fb9e |
action order 1: mirred (Egress Redirect to device eth1) stolen
|
|
|
d8fb9e |
index 1 ref 1 bind 1 installed 0 sec used 0 sec
|
|
|
d8fb9e |
Action statistics:
|
|
|
d8fb9e |
Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 requeues 0)
|
|
|
d8fb9e |
Sent software 187542 bytes 4077 pkt
|
|
|
d8fb9e |
Sent hardware 534697200 bytes 8911620 pkt
|
|
|
d8fb9e |
backlog 0b 0p requeues 0
|
|
|
d8fb9e |
cookie 89173e6a44447001becfd486bda17e29
|
|
|
d8fb9e |
|
|
|
d8fb9e |
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
|
|
|
d8fb9e |
Signed-off-by: David Ahern <dsahern@gmail.com>
|
|
|
d8fb9e |
---
|
|
|
d8fb9e |
tc/tc_util.c | 35 +++++++++++++++++++++++++++++++++++
|
|
|
d8fb9e |
1 file changed, 35 insertions(+)
|
|
|
d8fb9e |
|
|
|
d8fb9e |
diff --git a/tc/tc_util.c b/tc/tc_util.c
|
|
|
d8fb9e |
index e115e5a70e3a1..ecc6fa1cca5f1 100644
|
|
|
d8fb9e |
--- a/tc/tc_util.c
|
|
|
d8fb9e |
+++ b/tc/tc_util.c
|
|
|
d8fb9e |
@@ -693,6 +693,38 @@ void print_tm(FILE *f, const struct tcf_t *tm)
|
|
|
d8fb9e |
fprintf(f, " expires %u sec", (unsigned int)(tm->expires/hz));
|
|
|
d8fb9e |
}
|
|
|
d8fb9e |
|
|
|
d8fb9e |
+static void print_tcstats_basic_hw(FILE *f, struct rtattr **tbs, char *prefix)
|
|
|
d8fb9e |
+{
|
|
|
d8fb9e |
+ struct gnet_stats_basic bs_hw;
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ if (!tbs[TCA_STATS_BASIC_HW])
|
|
|
d8fb9e |
+ return;
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ memcpy(&bs_hw, RTA_DATA(tbs[TCA_STATS_BASIC_HW]),
|
|
|
d8fb9e |
+ MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC_HW]), sizeof(bs_hw)));
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ if (bs_hw.bytes == 0 && bs_hw.packets == 0)
|
|
|
d8fb9e |
+ return;
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ if (tbs[TCA_STATS_BASIC]) {
|
|
|
d8fb9e |
+ struct gnet_stats_basic bs;
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]),
|
|
|
d8fb9e |
+ MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]),
|
|
|
d8fb9e |
+ sizeof(bs)));
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
|
|
|
d8fb9e |
+ fprintf(f, "%s", prefix);
|
|
|
d8fb9e |
+ fprintf(f, "Sent software %llu bytes", bs.bytes - bs_hw.bytes);
|
|
|
d8fb9e |
+ fprintf(f, " %u pkt", bs.packets - bs_hw.packets);
|
|
|
d8fb9e |
+ }
|
|
|
d8fb9e |
+ }
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
+ fprintf(f, "%s", prefix);
|
|
|
d8fb9e |
+ fprintf(f, "Sent hardware %llu bytes", bs_hw.bytes);
|
|
|
d8fb9e |
+ fprintf(f, " %u pkt", bs_hw.packets);
|
|
|
d8fb9e |
+}
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats)
|
|
|
d8fb9e |
{
|
|
|
d8fb9e |
SPRINT_BUF(b1);
|
|
|
d8fb9e |
@@ -716,6 +748,9 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
|
|
d8fb9e |
q.drops, q.overlimits, q.requeues);
|
|
|
d8fb9e |
}
|
|
|
d8fb9e |
|
|
|
d8fb9e |
+ if (tbs[TCA_STATS_BASIC_HW])
|
|
|
d8fb9e |
+ print_tcstats_basic_hw(fp, tbs, prefix);
|
|
|
d8fb9e |
+
|
|
|
d8fb9e |
if (tbs[TCA_STATS_RATE_EST64]) {
|
|
|
d8fb9e |
struct gnet_stats_rate_est64 re = {0};
|
|
|
d8fb9e |
|
|
|
d8fb9e |
--
|
|
|
d8fb9e |
2.25.3
|
|
|
d8fb9e |
|