2 # SPDX-License-Identifier: GPL-2.0
4 lib_dir
=$
(dirname $0)/..
/..
/..
/net
/forwarding
8 immediate_hw_stats_test
10 disabled_hw_stats_test
14 source $lib_dir/tc_common.sh
15 source $lib_dir/lib.sh
16 source $lib_dir/devlink_lib.sh
20 simple_if_init
$h1 192.0.2.1/24
25 simple_if_fini
$h1 192.0.2.1/24
30 simple_if_init
$swp1 192.0.2.2/24
31 tc qdisc add dev
$swp1 clsact
36 tc qdisc del dev
$swp1 clsact
37 simple_if_fini
$swp1 192.0.2.2/24
45 local action_hw_stats
=$2
47 local expected_packet_count
=$4
49 local orig_occ
=$
(devlink_resource_get
"counters" "flow" | jq
'.["occ"]')
51 tc filter add dev
$swp1 ingress protocol ip pref
1 handle
101 flower \
52 skip_sw dst_ip
192.0.2.2 action drop
$action_hw_stats
53 check_err $?
"Failed to add rule with $name hw_stats"
55 local new_occ
=$
(devlink_resource_get
"counters" "flow" | jq
'.["occ"]')
56 local expected_occ
=$
((orig_occ
+ occ_delta
))
57 [ "$new_occ" == "$expected_occ" ]
58 check_err $?
"Expected occupancy of $expected_occ, got $new_occ"
60 $MZ $h1 -c 1 -p 64 -a $h1mac -b $swp1mac -A 192.0.2.1 -B 192.0.2.2 \
63 tc_check_packets
"dev $swp1 ingress" 101 $expected_packet_count
64 check_err $?
"Did not match incoming packet"
66 tc filter del dev
$swp1 ingress protocol ip pref
1 handle
101 flower
68 log_test
"$name hw_stats"
71 default_hw_stats_test
()
73 hw_stats_test
"default" "" 2 1
76 immediate_hw_stats_test
()
78 hw_stats_test
"immediate" "hw_stats immediate" 2 1
81 delayed_hw_stats_test
()
85 tc filter add dev
$swp1 ingress protocol ip pref
1 handle
101 flower \
86 skip_sw dst_ip
192.0.2.2 action drop hw_stats delayed
87 check_fail $?
"Unexpected success in adding rule with delayed hw_stats"
89 log_test
"delayed hw_stats"
92 disabled_hw_stats_test
()
94 hw_stats_test
"disabled" "hw_stats disabled" 0 0
103 swp1mac
=$
(mac_get
$swp1)
121 check_tc_action_hw_stats_support