diff options
author | Petr Machata <petrm@nvidia.com> | 2022-04-22 10:30:56 +0200 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-04-27 20:12:42 -0600 |
commit | af5e7955273e47ee40b83f0b04c1879fe7ad92ae (patch) | |
tree | 9515696665e1256bc958acc494d608136f46eb76 | |
parent | 0517a2fd66ae30bd037ddc9ac2358146e6a7bfb7 (diff) | |
download | iproute2-af5e7955273e47ee40b83f0b04c1879fe7ad92ae.tar.gz |
ipstats: Add a group "offload", subgroup "cpu_hit"
Add a new group, "offload", for showing counters from the
IFLA_STATS_LINK_OFFLOAD_XSTATS nest, and a subgroup "cpu_hit" for the
IFLA_OFFLOAD_XSTATS_CPU_HIT stats suite.
For example:
# ip stats show dev swp1 group offload subgroup cpu_hit
4178: swp1: group offload subgroup cpu_hit
RX: bytes packets errors dropped missed mcast
45522 353 0 0 0 0
TX: bytes packets errors dropped carrier collsns
46054 355 0 0 0 0
# ip -j stats show dev swp1 group offload subgroup cpu_hit | jq
[
{
"ifindex": 4178,
"ifname": "swp1",
"group": "offload",
"subgroup": "cpu_hit",
"stats64": {
"rx": {
"bytes": 45522,
"packets": 353,
"errors": 0,
"dropped": 0,
"over_errors": 0,
"multicast": 0
},
"tx": {
"bytes": 46054,
"packets": 355,
"errors": 0,
"dropped": 0,
"carrier_errors": 0,
"collisions": 0
}
}
}
]
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r-- | ip/ipstats.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ip/ipstats.c b/ip/ipstats.c index e4f97dddd..283fba4e1 100644 --- a/ip/ipstats.c +++ b/ip/ipstats.c @@ -165,6 +165,42 @@ static int ipstats_show_64(struct ipstats_stat_show_attrs *attrs, } static void +ipstats_stat_desc_pack_cpu_hit(struct ipstats_stat_dump_filters *filters, + const struct ipstats_stat_desc *desc) +{ + ipstats_stat_desc_enable_bit(filters, + IFLA_STATS_LINK_OFFLOAD_XSTATS, + IFLA_OFFLOAD_XSTATS_CPU_HIT); +} + +static int ipstats_stat_desc_show_cpu_hit(struct ipstats_stat_show_attrs *attrs, + const struct ipstats_stat_desc *desc) +{ + print_nl(); + return ipstats_show_64(attrs, + IFLA_STATS_LINK_OFFLOAD_XSTATS, + IFLA_OFFLOAD_XSTATS_CPU_HIT); +} + +static const struct ipstats_stat_desc ipstats_stat_desc_offload_cpu_hit = { + .name = "cpu_hit", + .kind = IPSTATS_STAT_DESC_KIND_LEAF, + .pack = &ipstats_stat_desc_pack_cpu_hit, + .show = &ipstats_stat_desc_show_cpu_hit, +}; + +static const struct ipstats_stat_desc *ipstats_stat_desc_offload_subs[] = { + &ipstats_stat_desc_offload_cpu_hit, +}; + +static const struct ipstats_stat_desc ipstats_stat_desc_offload_group = { + .name = "offload", + .kind = IPSTATS_STAT_DESC_KIND_GROUP, + .subs = ipstats_stat_desc_offload_subs, + .nsubs = ARRAY_SIZE(ipstats_stat_desc_offload_subs), +}; + +static void ipstats_stat_desc_pack_link(struct ipstats_stat_dump_filters *filters, const struct ipstats_stat_desc *desc) { @@ -189,6 +225,7 @@ static const struct ipstats_stat_desc ipstats_stat_desc_toplev_link = { static const struct ipstats_stat_desc *ipstats_stat_desc_toplev_subs[] = { &ipstats_stat_desc_toplev_link, + &ipstats_stat_desc_offload_group, }; static const struct ipstats_stat_desc ipstats_stat_desc_toplev_group = { |