forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/testing/selftests/net/udpgso_bench.sh
....@@ -3,6 +3,49 @@
33 #
44 # Run a series of udpgso benchmarks
55
6
+readonly GREEN='\033[0;92m'
7
+readonly YELLOW='\033[0;33m'
8
+readonly RED='\033[0;31m'
9
+readonly NC='\033[0m' # No Color
10
+readonly TESTPORT=8000
11
+
12
+readonly KSFT_PASS=0
13
+readonly KSFT_FAIL=1
14
+readonly KSFT_SKIP=4
15
+
16
+num_pass=0
17
+num_err=0
18
+num_skip=0
19
+
20
+kselftest_test_exitcode() {
21
+ local -r exitcode=$1
22
+
23
+ if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
24
+ num_pass=$(( $num_pass + 1 ))
25
+ elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
26
+ num_skip=$(( $num_skip + 1 ))
27
+ else
28
+ num_err=$(( $num_err + 1 ))
29
+ fi
30
+}
31
+
32
+kselftest_exit() {
33
+ echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
34
+
35
+ if [[ $num_err -ne 0 ]]; then
36
+ echo -e "$(basename $0): ${RED}FAIL${NC}"
37
+ exit ${KSFT_FAIL}
38
+ fi
39
+
40
+ if [[ $num_skip -ne 0 ]]; then
41
+ echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
42
+ exit ${KSFT_SKIP}
43
+ fi
44
+
45
+ echo -e "$(basename $0): ${GREEN}PASS${NC}"
46
+ exit ${KSFT_PASS}
47
+}
48
+
649 wake_children() {
750 local -r jobs="$(jobs -p)"
851
....@@ -14,17 +57,33 @@
1457
1558 run_one() {
1659 local -r args=$@
60
+ local nr_socks=0
61
+ local i=0
62
+ local -r timeout=10
1763
18
- ./udpgso_bench_rx &
19
- ./udpgso_bench_rx -t &
64
+ ./udpgso_bench_rx -p "$TESTPORT" &
65
+ ./udpgso_bench_rx -p "$TESTPORT" -t &
2066
21
- ./udpgso_bench_tx ${args}
67
+ # Wait for the above test program to get ready to receive connections.
68
+ while [ "$i" -lt "$timeout" ]; do
69
+ nr_socks="$(ss -lnHi | grep -c "\*:${TESTPORT}")"
70
+ [ "$nr_socks" -eq 2 ] && break
71
+ i=$((i + 1))
72
+ sleep 1
73
+ done
74
+ if [ "$nr_socks" -ne 2 ]; then
75
+ echo "timed out while waiting for udpgso_bench_rx"
76
+ exit 1
77
+ fi
78
+
79
+ ./udpgso_bench_tx -p "$TESTPORT" ${args}
2280 }
2381
2482 run_in_netns() {
2583 local -r args=$@
2684
2785 ./in_netns.sh $0 __subprocess ${args}
86
+ kselftest_test_exitcode $?
2887 }
2988
3089 run_udp() {
....@@ -34,7 +93,22 @@
3493 run_in_netns ${args}
3594
3695 echo "udp gso"
37
- run_in_netns ${args} -S
96
+ run_in_netns ${args} -S 0
97
+
98
+ echo "udp gso zerocopy"
99
+ run_in_netns ${args} -S 0 -z
100
+
101
+ echo "udp gso timestamp"
102
+ run_in_netns ${args} -S 0 -T
103
+
104
+ echo "udp gso zerocopy audit"
105
+ run_in_netns ${args} -S 0 -z -a
106
+
107
+ echo "udp gso timestamp audit"
108
+ run_in_netns ${args} -S 0 -T -a
109
+
110
+ echo "udp gso zerocopy timestamp audit"
111
+ run_in_netns ${args} -S 0 -T -z -a
38112 }
39113
40114 run_tcp() {
....@@ -45,10 +119,15 @@
45119
46120 echo "tcp zerocopy"
47121 run_in_netns ${args} -t -z
122
+
123
+ # excluding for now because test fails intermittently
124
+ # add -P option to include poll() to reduce possibility of lost messages
125
+ #echo "tcp zerocopy audit"
126
+ #run_in_netns ${args} -t -z -P -a
48127 }
49128
50129 run_all() {
51
- local -r core_args="-l 4"
130
+ local -r core_args="-l 3"
52131 local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
53132 local -r ipv6_args="${core_args} -6 -D ::1"
54133
....@@ -57,12 +136,13 @@
57136 run_udp "${ipv4_args}"
58137
59138 echo "ipv6"
60
- run_tcp "${ipv4_args}"
139
+ run_tcp "${ipv6_args}"
61140 run_udp "${ipv6_args}"
62141 }
63142
64143 if [[ $# -eq 0 ]]; then
65144 run_all
145
+ kselftest_exit
66146 elif [[ $1 == "__subprocess" ]]; then
67147 shift
68148 run_one $@