summaryrefslogtreecommitdiffstats
path: root/scripts/trex-cfg
blob: aaaa2a327c38f40a4cd9cce5676e893493fb37fc (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
#! /bin/bash

# exit code is Important should be
# -1 : don't continue 
# 0  : no errors - no need to load mlx share object
# 32  : no errors - mlx share object should be loaded (returned by dpdk_setup_ports.py)

SYS=`uname -r`
if [ -f /etc/debian_version ]; then
    OS=debian  
elif [ -f /etc/redhat-release ]; then
    OS=redhat
    systemctl stop firewalld.service &> /dev/null
else
    OS=unknown
fi    

MACHINE_TYPE=`uname -m`
if [ ${MACHINE_TYPE} != 'x86_64' ]; then
  echo "ERROR, only 64bit operating systems are supported, please reinstall x86 64 bit OS"
  exit -1
fi



if [ -d /mnt/huge ]; then
  echo >> /dev/null
else
  echo "Creating huge node"
  mkdir -p /mnt/huge
fi

if ! mount | grep hugetlbfs >> /dev/null ; then 
    mount -t hugetlbfs nodev /mnt/huge  
fi  


for file in /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages ; do
    if [ -e $file ] ; then 
        if [ "$(cat $file)" != "2048" ] ; then
          echo 2048 > $file
        fi  
    fi
done

PATH=$PATH:/sbin:/usr/sbin

if ! lsmod | grep -q igb_uio  ;  then
    echo "Loading kernel drivers for the first time"
    modprobe uio
    if [ $? -ne 0 ]; then
        echo "Failed inserting uio module, please check if it is installed"
        exit -1
    fi
    km=ko/$SYS/igb_uio.ko
    if [ ! -e $km ]; then
        echo "ERROR: We don't have precompiled igb_uio.ko module for your kernel version"
        echo Will try compiling automatically.
        {
            cd ko/src &&
            make &&
            make install &&
            cd -
        } &> /dev/null || {
            echo -e "Automatic compilation failed.\n"
            echo "You can try compiling yourself, using the following commands:"
            echo "  \$cd ko/src  "
            echo "  \$make  "
            echo "  \$make install  "
            echo -e "  \$cd -  \n"
            echo -e "Then, try to run TRex again.\n"
            echo 'Note: you might need additional Linux packages for that:'
            echo '  * yum based (Fedora, CentOS, RedHat):'
            echo '        sudo yum install kernel-devel-`uname -r`'
            echo '        sudo yum group install "Development tools"'
            echo '  * apt based (Ubuntu):'
            echo '        sudo apt install linux-headers-`uname -r`'
            echo '        sudo apt install build-essential'
            exit -1
        }
        echo Success.
    fi
    if [ -e $km ]; then
        insmod $km
        if [ $? -ne 0 ]; then
            echo "Failed inserting igb_uio module"
            exit -1
        fi
    fi
fi

# try to bind the ports from the configuration file (new DPDK)
PARENT_ARGS="$0 $@"

source find_python.sh
$PYTHON ./dpdk_setup_ports.py --parent "$PARENT_ARGS"