t-rex-64 revision e8b47ff2
1#! /bin/bash
2if [ "$(id -u)" != 0 ]; then
3  echo 'Error: Please run as root (sudo etc.)'
4  exit -1
5fi
6
7INPUT_ARGS=${@//[]/-} # replace bizarre minuses with normal one
8
9./trex-cfg $INPUT_ARGS
10RESULT=$?
11if [ $RESULT -ne 0 ]; then
12  exit $RESULT
13fi
14
15pci_desc_re='^(\S+) - (.+)$'
16source find_python.sh
17while read line
18do
19    if [[ "$line" =~ $pci_desc_re ]]; then
20        pci_name="pci$(echo ${BASH_REMATCH[1]} | tr ':' '_' | tr '.' '_')" # make alphanumeric name
21        export $pci_name="${BASH_REMATCH[2]}"
22    fi
23done <<< "$($PYTHON dpdk_setup_ports.py --dump-pci-description)"
24
25cd $(dirname $0)
26export LD_LIBRARY_PATH=$PWD
27
28
29if [ -t 0 ] && [ -t 1 ]; then
30    export is_tty=true
31    saveterm="$(stty -g)"
32else
33    export is_tty=false
34fi
35
36# if we have a new core run optimized trex 
37if  grep -q avx /proc/cpuinfo ; then
38    ./_$(basename $0) $INPUT_ARGS
39    RESULT=$?
40    if [ $RESULT -eq 132 ]; then
41        echo " WARNING this program is optimized for the new Intel processors.  "
42        echo " try the ./t-rex-64-o application that should work for any Intel processor but might be slower. "
43        echo " try to run t-rex-64-o .. "
44        ./_t-rex-64-o $INPUT_ARGS
45        RESULT=$?
46    fi
47else
48        ./_t-rex-64-o $INPUT_ARGS
49        RESULT=$?
50fi
51
52if $is_tty; then
53    stty $saveterm
54fi
55
56if [ $RESULT -ne 0 ]; then
57  exit $RESULT
58fi
59
60
61