-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathngc_tcp_test.sh
executable file
·241 lines (217 loc) · 9.12 KB
/
ngc_tcp_test.sh
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
# NGC Certification TCP test v2.3
# Owner: amira@nvidia.com
#
set -eE
trap 'printf "Error in function %s, on line %d.\n" "${FUNCNAME[1]}" "${BASH_LINENO[0]}"' ERR
if (($# < 4)); then
echo "usage: $0 [<client username>@]<client trusted ip> <client ib device1>[,<client ib device2>,...] [<server username>@]<server trusted ip> <server ib device1>[,<server ib device2>,...] [--duplex=<'HALF','FULL'>] [--change_mtu=<'CHANGE','DONT_CHANGE'>] [--duration=<sec>] [--max_proc=<number>]"
echo " duplex - options: HALF,FULL, default: HALF"
echo " change_mtu - options: CHANGE,DONT_CHANGE, default: CHANGE"
echo " duration - time in seconds, default: 120"
echo " max_proc - use up to max_proc of process for each port"
echo " disable_ro - add this flag as workaround for Sapphire Rapid CPU that missing/disabled the following tuning in BIOS (Socket Configuration > IIO Configuration > Socket# Configuration > PE# Restore RO Write Perf > Enabled)"
echo " You will need to restart the driver and re run again"
echo " allow_core_zero - allow binding process on core 0, default:false"
echo " neighbor_levels - in case there is no enough cores on NIC numa, specify the number of closet neighbor numa to collect cores form it, default:2"
echo " --ipsec: Enable IPsec packet offload (full-offload) on the Arm cores."
exit 1
fi
scriptdir="$(dirname "$0")"
source "${scriptdir}/common.sh"
source "${scriptdir}/ipsec_full_offload_setup.sh"
while [ $# -gt 0 ]
do
case "${1}" in
--duplex=*)
DUPLEX="${1#*=}"
shift
;;
--change_mtu=*)
CHANGE_MTU="${1#*=}"
shift
;;
--duration=*)
TEST_DURATION="${1#*=}"
shift
;;
--max_proc=*)
MAX_PROC="${1#*=}"
shift
;;
--disable_ro)
DISABLE_RO=true
shift
;;
--allow_core_zero)
ALLOW_CORE_ZERO=true
shift
;;
--neighbor_levels=*)
NEIGHBOR_LEVELS="${1#*=}"
shift
;;
--ipsec)
IPSEC=true
shift
;;
--*)
fatal "Unknown option ${1}"
;;
*)
POSITIONAL_ARGS+=("${1}")
shift
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}"
CLIENT_TRUSTED="${1}"
CLIENT_DEVICES=(${2//,/ })
SERVER_TRUSTED="${3}"
SERVER_DEVICES=(${4//,/ })
IS_CLIENT_SPR=false
IS_SERVER_SPR=false
TIME_STAMP=$(date +%s)
[[ "$DUPLEX" == "FULL" ]] && DUPLEX=true || DUPLEX=false
[ -n "${CHANGE_MTU}" ] || CHANGE_MTU="CHANGE"
[ -n "${DISABLE_RO}" ] || DISABLE_RO=false
[ -n "${TEST_DURATION}" ] || TEST_DURATION="120"
[ -n "${MAX_PROC}" ] || MAX_PROC="32"
[ -n "${ALLOW_CORE_ZERO}" ] || ALLOW_CORE_ZERO=false
[ -n "${NEIGHBOR_LEVELS}" ] || NEIGHBOR_LEVELS=1
CLIENT_CORE_USAGES_FILE="/tmp/ngc_client_core_usages.log"
SERVER_CORE_USAGES_FILE="/tmp/ngc_server_core_usages.log"
if [ "$DISABLE_RO" = true ]
then
log "Apply WA for Sapphire system - please apply the following tuning in BIOS - Socket Configuration > IIO Configuration > Socket# Configuration > PE# Restore RO Write Perf > Enabled instead of using this WA" WARNING
sleep 2
fi
if [ "${#SERVER_DEVICES[@]}" -ne "${#CLIENT_DEVICES[@]}" ]
then
fatal "The number of server and client devices must be equal."
fi
NUM_DEVS=${#SERVER_DEVICES[@]}
case "${DUPLEX}" in
"true")
(( MAX_PROC > (NUM_DEVS * 2 + 1) )) || fatal "max_proc is set too low."
;;
"false")
(( MAX_PROC > (NUM_DEVS + 1) )) || fatal "max_proc is set too low."
;;
esac
#Check if interfaces are in namespace and if it is a local loopback create namespaces
read -ra DEVICES_NS <<< $(manage_namespaces)
#init the arrays SERVER_IPS,CLIENT_IPS,SERVER_NETDEVS,CLIENT_NETDEVS
get_ips_and_ifs
[ -n "${IPSEC}" ] || IPSEC=false
if [ "$IPSEC" = true ]
then
LOCAL_BF=(${5//,/ })
LOCAL_BF_device=(${6//,/ })
REMOTE_BF=(${7//,/ })
REMOTE_BF_device=(${8//,/ })
CHANGE_MTU=DONT_CHANGE
NUM_BF_DEVS=${#LOCAL_BF[@]}
PASS_CRITERION=0.85
#---------------------Configure IPsec full offload--------------------
if [ -z "${MTU_SIZE}" ]; then
for dev in "${CLIENT_DEVICES[@]}"
do
echo "$dev"
net_name="$(ssh "${CLIENT_TRUSTED}" "ls -1 /sys/class/infiniband/${dev}/device/net/ | head -1")"
mtu_sizes+=("$(ssh "${CLIENT_TRUSTED}" "ip a show ${net_name} | awk '/mtu/{print \$5}'")")
echo "$mtu_sizes"
done
MTU_SIZE="$(get_min_val ${mtu_sizes[@]})"
echo "MTU_SIZE"
echo "$MTU_SIZE"
fi
index=0
for ((; index<NUM_BF_DEVS; index++))
do
# IPsec full-offload configuration flow:
update_mlnx_bf_conf ${LOCAL_BF[index]}
update_mlnx_bf_conf ${REMOTE_BF[index]}
generate_next_ip # Generate local_IP & remote_IP
set_mtu ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} $(( MTU_SIZE + 400 ))
set_ip ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} "${local_IP}/24" ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} "${remote_IP}/24"
in_key=$(generete_key)
out_key=$(generete_key)
in_reqid=$(generete_req)
out_reqid=$(generete_req)
set_representor ${LOCAL_BF_device[index]} ${REMOTE_BF_device[index]}
set_ipsec_rules ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} "${local_IP}" "${remote_IP}" ${in_key} ${out_key} ${in_reqid} ${out_reqid} "offload packet"
set_ipsec_rules ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} "${remote_IP}" "${local_IP}" ${out_key} ${in_key} ${out_reqid} ${in_reqid} "offload packet"
ovs_configure ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${representor1} "${local_IP}" "${remote_IP}" "${index}"
ovs_configure ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${representor2} "${remote_IP}" "${local_IP}" "${index}"
done
for ((index1=0; index1<NUM_DEVS; index1++))
do
set_ip ${CLIENT_TRUSTED} ${CLIENT_NETDEVS[index1]} "${CLIENT_IPS[index1]}/${CLIENT_IPS_MASK[index1]}" ${SERVER_TRUSTED} ${SERVER_NETDEVS[index1]} "${SERVER_IPS[index1]}/${SERVER_IPS_MASK[index1]}"
done
fi
server_1_prefix="$(get_command_prefix 0)"
LINK_TYPE="$(ssh "${SERVER_TRUSTED}" "${server_1_prefix} cat /sys/class/net/${SERVER_NETDEVS[0]}/type")"
[ $CHANGE_MTU = "CHANGE" ] && change_mtu
min_l=$(get_min_channels)
opt_proc=$((min_l<MAX_PROC ? min_l : MAX_PROC))
#try collect 2 more cores than needed incase we need to ditch core 0 (this is why we need opt_proc+2)
read -ra CORES_ARRAY <<< $(get_cores_for_devices $1 $2 $3 $4 $((opt_proc+2)))
#NUM_CORES_PER_DEVICE will be the actual cores that need to be used
NUM_CORES_PER_DEVICE=$(( ${#CORES_ARRAY[@]}/(${#CLIENT_DEVICES[@]}*2) ))
log "Number of cores per device to be used is $NUM_CORES_PER_DEVICE, if duplex then half of them will act as servers and half as clients."
log "${CORES_ARRAY[*]}"
if [ "$DUPLEX" = true ]
then
log "Running Full duplex."
NUM_INST=$((NUM_CORES_PER_DEVICE/2))
else
log "Running half duplex."
NUM_INST=${NUM_CORES_PER_DEVICE}
fi
BASE_TCP_POTR=10000
FORCE_EXIT=false
#Set number of cores to use and apply tuning according to #core and list of cores
#Expected global params :
#CLIENT_TRUSTED,CLIENT_DEVICES,SERVER_TRUSTED,SERVER_DEVICES,NUM_INST,opt_proc,CORES_ARRAY
tune_tcp
#Relaxed ordring was disabled - user need to restart the driver so that the change take affect.
[ "${FORCE_EXIT}" != "true" ] || fatal "Please restart driver after disabling relaxed ordering (RO), and run the script again."
#Run server side
run_iperf_servers
sleep 2
#Run client side
run_iperf_clients
#Post traffic -collect stats
collect_stats
#wait for traffic to finish
wait
sleep 1
#Print statistics
print_stats $SERVER_TRUSTED
print_stats $CLIENT_TRUSTED
#Collect the output
collect_BW
#---------------------Revert IPsec full offload configuration--------------------
if [ "$IPSEC" = true ]
then
index=0
for ((; index<NUM_BF_DEVS; index++))
do
# IPsec full-offload configuration *flush* flow:
set_representor ${LOCAL_BF_device[index]} ${REMOTE_BF_device[index]}
ovs_configure_revert ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${representor1} "${index}"
ovs_configure_revert ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${representor2} "${index}"
remove_ipsec_rules ${LOCAL_BF[index]}
remove_ipsec_rules ${REMOTE_BF[index]}
flush_ip ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]}
set_mtu ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${MTU_SIZE}
update_mlnx_bf_conf_revert ${LOCAL_BF[index]}
update_mlnx_bf_conf_revert ${REMOTE_BF[index]}
for ((index1=0; index1<NUM_DEVS; index1++))
do
set_ip ${CLIENT_TRUSTED} ${CLIENT_NETDEVS[index1]} "${CLIENT_IPS[index1]}/${CLIENT_IPS_MASK[index1]}" ${SERVER_TRUSTED} ${SERVER_NETDEVS[index1]} "${SERVER_IPS[index1]}/${SERVER_IPS_MASK[index1]}"
done
done
fi
delete_namespaces_from_host ${SERVER_TRUSTED} ${SERVER_DEVICES} ${DEVICES_NS}