forked from mtcp-stack/mtcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_mtcp_dpdk_env.sh
executable file
·72 lines (64 loc) · 1.73 KB
/
setup_mtcp_dpdk_env.sh
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
#!/usr/bin/env bash
GREEN='\033[0;32m'
NC='\033[0m'
# Get to script directory
cd $(dirname ${BASH_SOURCE[0]})/
# First download dpdk
if [ -z "$(ls -A $PWD/dpdk)" ]; then
printf "${GREEN}Cloning dpdk...\n $NC"
git submodule init
git submodule update
fi
# Setup dpdk source for compilation
if [ "$#" -ne 1 ];
then
export RTE_SDK=$PWD/dpdk
else
export RTE_SDK=$1
fi
printf "${GREEN}Running dpdk_setup.sh...\n $NC"
if grep "ldflags.txt" $RTE_SDK/mk/rte.app.mk > /dev/null
then
:
else
sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' $RTE_SDK/mk/rte.app.mk
fi
# Compile dpdk and configure system
if [ -f $RTE_SDK/usertools/dpdk-setup.sh ]; then
bash $RTE_SDK/usertools/dpdk-setup.sh
else
bash $RTE_SDK/tools/setup.sh
fi
# Print the user message
cd $RTE_SDK
CONFIG_NUM=1
for cfg in config/defconfig_* ; do
cfg=${cfg/config\/defconfig_/}
if [ -d "$cfg" ]; then
printf "Setting RTE_TARGET as $cfg\n"
export RTE_TARGET=$cfg
fi
let "CONFIG_NUM+=1"
done
cd -
printf "Set ${GREEN}RTE_SDK$NC env variable as $RTE_SDK\n"
printf "Set ${GREEN}RTE_TARGET$NC env variable as $RTE_TARGET\n"
# Check if you are using an Intel NIC
while true; do
read -p "Are you using an Intel NIC (y/n)? " response
case $response in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
done
# Create interfaces
printf "Creating ${GREEN}dpdk$NC interface entries\n"
cd dpdk-iface-kmod
make
if lsmod | grep dpdk_iface &> /dev/null ; then
:
else
sudo insmod ./dpdk_iface.ko
fi
sudo -E make run
cd ..