selftests: mlxsw: tc_police_scale: Make test more robust
authorAmit Cohen <amcohen@nvidia.com>
Wed, 2 Mar 2022 16:14:46 +0000 (18:14 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Mar 2022 16:14:01 +0000 (08:14 -0800)
commitdc9752075341e7beb653e37c6f4a3723074dc8bc
tree74b61a0b744d204f03d18d3ecafa71451c93c9c1
parent10b6bb62ae1a49ee818fc479cf57b8900176773e
selftests: mlxsw: tc_police_scale: Make test more robust

The test adds tc filters and checks how many of them were offloaded by
grepping for 'in_hw'.

iproute2 commit f4cd4f127047 ("tc: add skip_hw and skip_sw to control
action offload") added offload indication to tc actions, producing the
following output:

 $ tc filter show dev swp2 ingress
 ...
 filter protocol ipv6 pref 1000 flower chain 0 handle 0x7c0
   eth_type ipv6
   dst_ip 2001:db8:1::7bf
   skip_sw
   in_hw in_hw_count 1
         action order 1:  police 0x7c0 rate 10Mbit burst 100Kb mtu 2Kb action drop overhead 0b
         ref 1 bind 1
         not_in_hw
         used_hw_stats immediate

The current grep expression matches on both 'in_hw' and 'not_in_hw',
resulting in incorrect results.

Fix that by using JSON output instead.

Fixes: 5061e773264b ("selftests: mlxsw: Add scale test for tc-police")
Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/drivers/net/mlxsw/tc_police_scale.sh