~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/tc_action_hw_stats.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 lib_dir=$(dirname $0)/../../../net/forwarding
  5 
  6 ALL_TESTS="
  7         default_hw_stats_test
  8         immediate_hw_stats_test
  9         delayed_hw_stats_test
 10         disabled_hw_stats_test
 11 "
 12 NUM_NETIFS=2
 13 
 14 source $lib_dir/tc_common.sh
 15 source $lib_dir/lib.sh
 16 source $lib_dir/devlink_lib.sh
 17 
 18 h1_create()
 19 {
 20         simple_if_init $h1 192.0.2.1/24
 21 }
 22 
 23 h1_destroy()
 24 {
 25         simple_if_fini $h1 192.0.2.1/24
 26 }
 27 
 28 switch_create()
 29 {
 30         simple_if_init $swp1 192.0.2.2/24
 31         tc qdisc add dev $swp1 clsact
 32 }
 33 
 34 switch_destroy()
 35 {
 36         tc qdisc del dev $swp1 clsact
 37         simple_if_fini $swp1 192.0.2.2/24
 38 }
 39 
 40 hw_stats_test()
 41 {
 42         RET=0
 43 
 44         local name=$1
 45         local action_hw_stats=$2
 46         local occ_delta=$3
 47         local expected_packet_count=$4
 48 
 49         local orig_occ=$(devlink_resource_get "counters" "flow" | jq '.["occ"]')
 50 
 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"
 54 
 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"
 59 
 60         $MZ $h1 -c 1 -p 64 -a $h1mac -b $swp1mac -A 192.0.2.1 -B 192.0.2.2 \
 61                 -t ip -q
 62 
 63         tc_check_packets "dev $swp1 ingress" 101 $expected_packet_count
 64         check_err $? "Did not match incoming packet"
 65 
 66         tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
 67 
 68         log_test "$name hw_stats"
 69 }
 70 
 71 default_hw_stats_test()
 72 {
 73         hw_stats_test "default" "" 2 1
 74 }
 75 
 76 immediate_hw_stats_test()
 77 {
 78         hw_stats_test "immediate" "hw_stats immediate" 2 1
 79 }
 80 
 81 delayed_hw_stats_test()
 82 {
 83         RET=0
 84 
 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"
 88 
 89         log_test "delayed hw_stats"
 90 }
 91 
 92 disabled_hw_stats_test()
 93 {
 94         hw_stats_test "disabled" "hw_stats disabled" 0 0
 95 }
 96 
 97 setup_prepare()
 98 {
 99         h1=${NETIFS[p1]}
100         swp1=${NETIFS[p2]}
101 
102         h1mac=$(mac_get $h1)
103         swp1mac=$(mac_get $swp1)
104 
105         vrf_prepare
106 
107         h1_create
108         switch_create
109 }
110 
111 cleanup()
112 {
113         pre_cleanup
114 
115         switch_destroy
116         h1_destroy
117 
118         vrf_cleanup
119 }
120 
121 check_tc_action_hw_stats_support
122 
123 trap cleanup EXIT
124 
125 setup_prepare
126 setup_wait
127 
128 tests_run
129 
130 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php