]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: ipnexthop: Allow toggling collection of nexthop group HW statistics
authorPetr Machata <petrm@nvidia.com>
Thu, 14 Mar 2024 14:52:15 +0000 (15:52 +0100)
committerDavid Ahern <dsahern@kernel.org>
Fri, 15 Mar 2024 15:03:38 +0000 (15:03 +0000)
Besides SW datapath stats, the kernel also support collecting statistics
from HW datapath, for nexthop groups offloaded to HW. Since collection of
these statistics may consume HW resources, there is an interface to request
that the HW stats be recorded. Add this toggle to "ip nexthop".

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/ipnexthop.c
man/man8/ip-nexthop.8

index 6c5d524b104d825a80ab473b69c01a881090a675..8aa06de0557f0b3346507def00bf95720466c73d 100644 (file)
@@ -56,6 +56,7 @@ static void usage(void)
                "        [ encap ENCAPTYPE ENCAPHDR ] |\n"
                "        group GROUP [ fdb ] [ type TYPE [ TYPE_ARGS ] ] }\n"
                "GROUP := [ <id[,weight]>/<id[,weight]>/... ]\n"
+               "         [ hw_stats {off|on} ]\n"
                "TYPE := { mpath | resilient }\n"
                "TYPE_ARGS := [ RESILIENT_ARGS ]\n"
                "RESILIENT_ARGS := [ buckets BUCKETS ] [ idle_timer IDLE ]\n"
@@ -1102,6 +1103,17 @@ static int ipnh_modify(int cmd, unsigned int flags, int argc, char **argv)
                        if (rtnl_rtprot_a2n(&prot, *argv))
                                invarg("\"protocol\" value is invalid\n", *argv);
                        req.nhm.nh_protocol = prot;
+               } else if (!strcmp(*argv, "hw_stats")) {
+                       bool hw_stats;
+                       int ret;
+
+                       NEXT_ARG();
+                       hw_stats = parse_on_off("hw_stats", *argv, &ret);
+                       if (ret)
+                               return ret;
+
+                       addattr32(&req.n, sizeof(req), NHA_HW_STATS_ENABLE,
+                                 hw_stats);
                } else if (strcmp(*argv, "help") == 0) {
                        usage();
                } else {
index f81a5910bf22a49f667733e0c9512a385aa3941a..aad6869692b513910b178f87740157eb7a23c813 100644 (file)
@@ -68,6 +68,8 @@ ip-nexthop \- nexthop object management
 .BR fdb " ] | "
 .B  group
 .IR GROUP " [ "
+.BR hw_stats " { "
+.BR on " | " off " }  ] [ "
 .BR fdb " ] [ "
 .B type
 .IR TYPE " [ " TYPE_ARGS " ] ] }"