Update DPDK to v17.11
[csit.git] / tests / dpdk / dpdk_scripts / install_dpdk.sh
1 #!/bin/bash
2
3 set -x
4
5 # Setting variables
6 DPDK_VERSION=dpdk-17.11
7 DPDK_DIR=${DPDK_VERSION}
8 DPDK_PACKAGE=${DPDK_DIR}.tar.xz
9 ROOTDIR=/tmp/openvpp-testing
10 PWDDIR=$(pwd)
11
12 # Download the DPDK package
13 cd ${ROOTDIR}
14 wget "fast.dpdk.org/rel/${DPDK_PACKAGE}" || \
15     { echo "Failed to download $DPDK_PACKAGE"; exit 1; }
16 tar xJvf ${DPDK_PACKAGE} || \
17     { echo "Failed to extract $DPDK_PACKAGE"; exit 1; }
18
19 # Compile the DPDK
20 cd ./${DPDK_DIR}
21 sudo sed -i 's/^CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n/CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=y/g' ./config/common_base
22 make install T=x86_64-native-linuxapp-gcc -j || \
23     { echo "Failed to compile $DPDK_VERSION"; exit 1; }
24 cd ${PWDDIR}
25
26 # Compile the l3fwd
27 export RTE_SDK=${ROOTDIR}/${DPDK_DIR}/
28 export RTE_TARGET=x86_64-native-linuxapp-gcc
29 cd ${RTE_SDK}/examples/l3fwd
30 sudo sed -i 's/^#define RTE_TEST_RX_DESC_DEFAULT 128/#define RTE_TEST_RX_DESC_DEFAULT 2048/g' ./main.c
31 sudo sed -i 's/^#define RTE_TEST_TX_DESC_DEFAULT 512/#define RTE_TEST_TX_DESC_DEFAULT 2048/g' ./main.c
32 make -j || \
33     { echo "Failed to compile l3fwd"; exit 1; }
34 cd ${PWDDIR}
35
36 # Check and setup the hugepages
37 SYS_HUGEPAGE=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages)
38 echo "  SYS_HUGEPAGE = ${SYS_HUGEPAGE}"
39 if [ ${SYS_HUGEPAGE} -lt 4096 ]; then
40     echo "  It is not enough, should be at least 4096"
41     MOUNT=$(mount | grep /mnt/huge)
42     while [ "${MOUNT}" != "" ]
43     do
44         sudo umount /mnt/huge
45         sleep 1
46         MOUNT=$(mount | grep /mnt/huge)
47     done
48
49     echo 2048 | sudo tee /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
50     echo 2048 | sudo tee /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
51
52     echo "  Mounting hugepages"
53     sudo mkdir -p /mnt/huge
54     sudo mount -t hugetlbfs nodev /mnt/huge/ || \
55         { echo "Failed to mount hugepages"; exit 1; }
56 fi
57
58 # Check and set the max map count
59 SYS_MAP=$(cat /proc/sys/vm/max_map_count)
60
61 if [ ${SYS_MAP} -lt 200000 ]; then
62     echo 200000 | sudo tee /proc/sys/vm/max_map_count
63 fi