-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathsetup_environment.sh
executable file
·129 lines (111 loc) · 4.25 KB
/
setup_environment.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# openNetVM
# https://sdnfv.github.io
#
# OpenNetVM is distributed under the following BSD LICENSE:
#
# Copyright(c)
# 2015-2017 George Washington University
# 2015-2017 University of California Riverside
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# A script to configure your environment each boot
# Loads the uio kernel modules, shows NIC status
# CONFIGURATION (via environment variable):
# - Ensure that $RTE_SDK and $RTE_TARGET are set (see install docs)
# - Set ONVM_NIC to the name of the interface you want to bind (default p2p1)
# - Can set ONVM_NIC_PCI to the PCI address of the interface (default 07:00.0)
set -e
DPDK_DEVBIND=$RTE_SDK/usertools/dpdk-devbind.py # for DPDK 17 and up
#DPDK_DEVBIND=$RTE_SDK/tools/dpdk-devbind.py # for DPDK 16.11
#DPK_DEVBIND=#RTE_SDK/tools/dpdk_nic_bind.py # for DPDK 2.2 D
# Confirm environment variables
if [ -z "$RTE_TARGET" ]; then
echo "Please export \$RTE_TARGET"
exit 1
fi
if [ -z "$RTE_SDK" ]; then
echo "Please export \$RTE_SDK"
exit 1
fi
# Grab scripts parent directory location
onvm_home_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ >/dev/null 2>&1 && pwd )"
if [ -z "$ONVM_HOME" ]; then
echo "Please export \$ONVM_HOME and set it to $onvm_home_dir"
exit 1
fi
# Source DPDK helper functions
. "$ONVM_HOME"/scripts/dpdk_helper_scripts.sh
# Disable ASLR
sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
# Setup/Check for free HugePages if the user wants to
if [ -z "$ONVM_SKIP_HUGEPAGES" ]; then
# hp_count is assigned in ./dpdk_helper_scripts.sh
# shellcheck disable=SC2154
set_numa_pages "$hp_count"
fi
# Verify sudo access
sudo -v
# Load uio kernel modules
grep -m 1 "igb_uio" /proc/modules | cat
if [ "${PIPESTATUS[0]}" != 0 ]; then
echo "Loading uio kernel modules"
sleep 1
cd "$RTE_SDK"/"$RTE_TARGET"/kmod
sudo modprobe uio
sudo insmod igb_uio.ko
else
echo "IGB UIO module already loaded."
fi
# dpdk_nic_bind.py has been changed to dpdk-devbind.py to be compatible with DPDK 16.11
echo "Checking NIC status"
sleep 1
$DPDK_DEVBIND --status
echo "Binding NIC status"
if [ -z "$ONVM_NIC_PCI" ];then
for id in $($DPDK_DEVBIND --status | grep -v Active | grep -e "10G" -e "10-Gigabit" | grep unused=igb_uio | cut -f 1 -d " ")
do
read -r -p "Bind interface $id to DPDK? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]];then
echo "Binding $id to dpdk"
sudo "$DPDK_DEVBIND" -b igb_uio "$id"
fi
done
else
# Auto binding example format: export ONVM_NIC_PCI=" 07:00.0 07:00.1 "
for nic_id in $ONVM_NIC_PCI
do
echo "Binding $nic_id to DPDK"
sudo "$DPDK_DEVBIND" -b igb_uio "$nic_id"
done
fi
echo "Finished Binding"
$DPDK_DEVBIND --status
sudo bash "$ONVM_HOME"/scripts/no_hyperthread.sh
echo "Environment setup complete."