Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / drivers / net / hw / hw_stats_l3_gre.sh
bloba94d92e1abce6a4ae1ffdd4feca912dc8938fb2e
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test L3 stats on IP-in-IP GRE tunnel without key.
6 # This test uses flat topology for IP tunneling tests. See ipip_lib.sh for more
7 # details.
9 ALL_TESTS="
10 ping_ipv4
11 test_stats_rx
12 test_stats_tx
14 NUM_NETIFS=6
15 lib_dir=$(dirname "$0")
16 source "$lib_dir"/../../../net/forwarding/lib.sh
17 source "$lib_dir"/../../../net/forwarding/ipip_lib.sh
18 source "$lib_dir"/../../../net/forwarding/tc_common.sh
20 setup_prepare()
22 h1=${NETIFS[p1]}
23 ol1=${NETIFS[p2]}
25 ul1=${NETIFS[p3]}
26 ul2=${NETIFS[p4]}
28 ol2=${NETIFS[p5]}
29 h2=${NETIFS[p6]}
31 ol1mac=$(mac_get $ol1)
33 forwarding_enable
34 vrf_prepare
35 h1_create
36 h2_create
37 sw1_flat_create gre $ol1 $ul1
38 sw2_flat_create gre $ol2 $ul2
39 ip stats set dev g1a l3_stats on
40 ip stats set dev g2a l3_stats on
43 cleanup()
45 pre_cleanup
47 ip stats set dev g1a l3_stats off
48 ip stats set dev g2a l3_stats off
50 sw2_flat_destroy $ol2 $ul2
51 sw1_flat_destroy $ol1 $ul1
52 h2_destroy
53 h1_destroy
55 vrf_cleanup
56 forwarding_restore
59 ping_ipv4()
61 RET=0
63 ping_test $h1 192.0.2.18 " gre flat"
66 send_packets_ipv4()
68 # Send 21 packets instead of 20, because the first one might trap and go
69 # through the SW datapath, which might not bump the HW counter.
70 $MZ $h1 -c 21 -d 20msec -p 100 \
71 -a own -b $ol1mac -A 192.0.2.1 -B 192.0.2.18 \
72 -q -t udp sp=54321,dp=12345
75 test_stats()
77 local dev=$1; shift
78 local dir=$1; shift
80 local a
81 local b
83 RET=0
85 a=$(hw_stats_get l3_stats $dev $dir packets)
86 send_packets_ipv4
87 b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
88 hw_stats_get l3_stats $dev $dir packets)
89 check_err $? "Traffic not reflected in the counter: $a -> $b"
91 log_test "Test $dir packets: $prot"
94 test_stats_tx()
96 test_stats g1a tx
99 test_stats_rx()
101 test_stats g2a rx
104 trap cleanup EXIT
106 setup_prepare
107 setup_wait
109 tests_run
111 exit $EXIT_STATUS