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