summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/udpgso_bench.sh
blob: 4df1cd8d69d244725662f0f5123162c4ef47f4c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Run a series of udpgso benchmarks

GREEN='\033[0;92m'
RED='\033[0;31m'
NC='\033[0m' # No Color

wake_children() {
	local -r jobs="$(jobs -p)"

	if [[ "${jobs}" != "" ]]; then
		kill -1 ${jobs} 2>/dev/null
	fi
}
trap wake_children EXIT

run_one() {
	local -r args=$@

	./udpgso_bench_rx &
	./udpgso_bench_rx -t &

	./udpgso_bench_tx ${args}
}

run_in_netns() {
	local -r args=$@

	./in_netns.sh $0 __subprocess ${args}
}

run_udp() {
	local -r args=$@
	local errors=0

	echo "udp"
	run_in_netns ${args}
	errors=$(( $errors + $? ))

	echo "udp gso"
	run_in_netns ${args} -S 0
	errors=$(( $errors + $? ))

	echo "udp gso zerocopy"
	run_in_netns ${args} -S 0 -z
	errors=$(( $errors + $? ))

	echo "udp gso timestamp"
	run_in_netns ${args} -S 0 -T
	errors=$(( $errors + $? ))

	echo "udp gso zerocopy audit"
	run_in_netns ${args} -S 0 -z -a
	errors=$(( $errors + $? ))

	echo "udp gso timestamp audit"
	run_in_netns ${args} -S 0 -T -a
	errors=$(( $errors + $? ))

	echo "udp gso zerocopy timestamp audit"
	run_in_netns ${args} -S 0 -T -z -a
	errors=$(( $errors + $? ))

	return $errors
}

run_tcp() {
	local -r args=$@
	local errors=0

	echo "tcp"
	run_in_netns ${args} -t
	errors=$(( $errors + $? ))

	echo "tcp zerocopy"
	run_in_netns ${args} -t -z
	errors=$(( $errors + $? ))

	# excluding for now because test fails intermittently
	# add -P option to include poll() to reduce possibility of lost messages
	#echo "tcp zerocopy audit"
	#run_in_netns ${args} -t -z -P -a
	#errors=$(( $errors + $? ))

	return $errors
}

run_all() {
	local -r core_args="-l 3"
	local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
	local -r ipv6_args="${core_args} -6 -D ::1"
	local errors=0

	echo "ipv4"
	run_tcp "${ipv4_args}"
	errors=$(( $errors + $? ))
	run_udp "${ipv4_args}"
	errors=$(( $errors + $? ))

	echo "ipv6"
	run_tcp "${ipv4_args}"
	errors=$(( $errors + $? ))
	run_udp "${ipv6_args}"
	errors=$(( $errors + $? ))

	return $errors
}

if [[ $# -eq 0 ]]; then
	run_all
	if [ $? -ne 0 ]; then
		echo -e "$(basename $0): ${RED}FAIL${NC}"
		exit 1
	fi

	echo -e "$(basename $0): ${GREEN}PASS${NC}"
elif [[ $1 == "__subprocess" ]]; then
	shift
	run_one $@
else
	run_in_netns $@
fi