forked from cisco-system-traffic-generator/trex-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t-rex-64
executable file
·109 lines (87 loc) · 2.53 KB
/
t-rex-64
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
#! /bin/bash
if [ "$(id -u)" != 0 ]; then
echo 'Error: Please run as root (sudo etc.)'
exit -1
fi
INPUT_ARGS=${@//[]/-} # replace bizarre minuses with normal one
EXTRA_INPUT_ARGS=""
ARCH=$(uname -m)
./trex-cfg $INPUT_ARGS
RESULT=$?
if [ $RESULT -eq 255 ]; then
echo "ERROR encountered while configuring TRex system"
exit $RESULT
elif [ $RESULT -eq 2 ]; then
echo "ERROR encountered while configuring TRex system"
exit $RESULT
elif [ $RESULT -eq 64 ]; then
EXTRA_INPUT_ARGS="--ntacc-so"
elif [ $RESULT -eq 48 ]; then
EXTRA_INPUT_ARGS="--mlx4-so --mlx5-so"
elif [ $RESULT -eq 32 ]; then
EXTRA_INPUT_ARGS="--mlx5-so"
elif [ $RESULT -eq 16 ]; then
EXTRA_INPUT_ARGS="--mlx4-so"
elif [ $RESULT -eq 128 ]; then
EXTRA_INPUT_ARGS="--bnxt-so"
elif [ $RESULT -ne 0 ]; then
echo "Bad return status from trex-cfg ($RESULT)"
echo "Configuration failed"
exit $RESULT
fi
if [[ ! "$INPUT_ARGS" =~ "--help" ]]; then
pci_desc_re='^(\S+) - (.+)$'
source find_python.sh --local
while read line
do
if [[ "$line" =~ $pci_desc_re ]]; then
pci_name="pci$(echo ${BASH_REMATCH[1]} | tr ':' '_' | tr '.' '_')" # make alphanumeric name
export $pci_name="${BASH_REMATCH[2]}"
fi
done <<< "$($PYTHON dpdk_setup_ports.py --dump-pci-description)"
fi
cd $(dirname $0)
export LD_LIBRARY_PATH=$PWD
if [ -t 0 ] && [ -t 1 ]; then
saveterm="$(stty -g)"
fi
function bird_preparation {
BIRD_PID="$(pgrep trex_bird)"
if [[ -n "$BIRD_PID" ]]; then
kill $BIRD_PID
fi
mkdir -p "/tmp/trex-bird"
chmod -R 777 "/tmp/trex-bird"
}
function cleanup {
bird_preparation
if [[ ! -z "$saveterm" ]]; then
stty $saveterm
fi
./dpdk_setup_ports.py --cleanup-servers --parent="$INPUT_ARGS"
}
trap cleanup EXIT
# if we have a new core run optimized trex
if [[ "$ARCH" == "x86_64" ]] ; then
FLAG='avx'
elif [[ "$ARCH" == "aarch64" ]] ; then
FLAG='evtstrm'
elif [[ "$ARCH" == "ppc64le" ]] ; then
FLAG='POWER9'
fi
bird_preparation
if grep -q $FLAG /proc/cpuinfo ; then
./_$(basename $0) $INPUT_ARGS $EXTRA_INPUT_ARGS
RESULT=$?
if [ $RESULT -eq 132 ]; then
echo " WARNING this program is optimized for the new Intel processors. "
echo " try the ./t-rex-64-o application that should work for any Intel processor but might be slower. "
echo " try to run t-rex-64-o .. "
./_t-rex-64-o $INPUT_ARGS $EXTRA_INPUT_ARGS
RESULT=$?
fi
else
./_t-rex-64-o $INPUT_ARGS $EXTRA_INPUT_ARGS
RESULT=$?
fi
exit $RESULT