5 # Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in
16 # the documentation and/or other materials provided with the
18 # * Neither the name of Intel Corporation nor the names of its
19 # contributors may be used to endorse or promote products derived
20 # from this software without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 # Run with "source /path/to/setup.sh"
40 # Change to DPDK directory ( <this-script's-dir>/.. ), and export it as RTE_SDK
42 cd $(dirname ${BASH_SOURCE[0]})/..
44 echo "------------------------------------------------------------------------------"
45 echo " RTE_SDK exported as $RTE_SDK"
46 echo "------------------------------------------------------------------------------"
49 # Application EAL parameters for setting memory options (amount/channels/ranks).
54 # Sets QUIT variable so script will finish.
62 # Sets up envronment variables for ICC.
66 DEFAULT_PATH=/opt/intel/bin/iccvars.sh
68 shpath=`which iccvars.sh 2> /dev/null`
69 if [ $? -eq 0 ] ; then
70 echo "Loading iccvars.sh from $shpath for $param"
72 elif [ -f $DEFAULT_PATH ] ; then
73 echo "Loading iccvars.sh from $DEFAULT_PATH for $param"
74 source $DEFAULT_PATH $param
76 echo "## ERROR: cannot find 'iccvars.sh' script to set up ICC."
77 echo "## To fix, please add the directory that contains"
78 echo "## iccvars.sh to your 'PATH' environment variable."
84 # Sets RTE_TARGET and does a "make install".
89 export RTE_TARGET=${TARGETS[option]}
91 compiler=${RTE_TARGET##*-}
92 if [ "$compiler" == "icc" ] ; then
93 platform=${RTE_TARGET%%-*}
94 if [ "$platform" == "x86_64" ] ; then
100 if [ "$QUIT" == "0" ] ; then
101 make install T=${RTE_TARGET}
103 echo "------------------------------------------------------------------------------"
104 echo " RTE_TARGET exported as $RTE_TARGET"
105 echo "------------------------------------------------------------------------------"
109 # Uninstall all targets.
117 # Creates hugepage filesystem.
121 echo "Creating /mnt/huge and mounting as hugetlbfs"
122 sudo mkdir -p /mnt/huge
124 grep -s '/mnt/huge' /proc/mounts > /dev/null
125 if [ $? -ne 0 ] ; then
126 sudo mount -t hugetlbfs nodev /mnt/huge
131 # Removes hugepage filesystem.
135 echo "Unmounting /mnt/huge and removing directory"
136 grep -s '/mnt/huge' /proc/mounts > /dev/null
137 if [ $? -eq 0 ] ; then
138 sudo umount /mnt/huge
141 if [ -d /mnt/huge ] ; then
147 # Unloads igb_uio.ko.
149 remove_igb_uio_module()
151 echo "Unloading any existing DPDK UIO module"
152 /sbin/lsmod | grep -s igb_uio > /dev/null
153 if [ $? -eq 0 ] ; then
154 sudo /sbin/rmmod igb_uio
159 # Loads new igb_uio.ko (and uio module if needed).
161 load_igb_uio_module()
163 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
164 echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
165 echo " To fix, please try to rebuild target."
169 remove_igb_uio_module
171 /sbin/lsmod | grep -s uio > /dev/null
172 if [ $? -ne 0 ] ; then
173 if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then
174 echo "Loading uio module"
175 sudo /sbin/modprobe uio
179 # UIO may be compiled into kernel, so it may not be an error if it can't
182 echo "Loading DPDK UIO module"
183 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
184 if [ $? -ne 0 ] ; then
185 echo "## ERROR: Could not load kmod/igb_uio.ko."
191 # Removes all reserved hugepages.
196 for d in /sys/devices/system/node/node? ; do
197 echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
199 echo "Removing currently reserved hugepages"
214 echo " Input the number of 2MB pages"
215 echo " Example: to have 128MB of hugepages available, enter '64' to"
216 echo " reserve 64 * 2MB pages"
217 echo -n "Number of pages: "
220 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
222 echo "Reserving hugepages"
230 # Creates hugepages on specific NUMA nodes.
237 echo " Input the number of 2MB pages for each node"
238 echo " Example: to have 128MB of hugepages available per node,"
239 echo " enter '64' to reserve 64 * 2MB pages on each node"
242 for d in /sys/devices/system/node/node? ; do
244 echo -n "Number of pages for $node: "
246 echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
248 echo "Reserving hugepages"
256 # Run unit test application.
261 echo " Enter hex bitmask of cores to execute test app on"
262 echo " Example: to execute app on cores 0 to 7, enter 0xff"
266 sudo ${RTE_TARGET}/app/test -c $Bitmask $EAL_PARAMS
270 # Run unit testpmd application.
275 echo " Enter hex bitmask of cores to execute testpmd app on"
276 echo " Example: to execute app on cores 0 to 7, enter 0xff"
280 sudo ${RTE_TARGET}/app/testpmd -c $Bitmask $EAL_PARAMS -- -i
284 # Print hugepage information.
288 grep -i huge /proc/meminfo
292 # List all hugepage file references
300 # Options for building a target. Note that this step MUST be first as it sets
301 # up TARGETS[] starting from 1, and this is accessed in setup_target using the
302 # user entered option.
306 TITLE="Select the DPDK environment to build"
308 for cfg in config/defconfig_* ; do
309 cfg=${cfg/config\/defconfig_/}
310 TEXT[$CONFIG_NUM]="$cfg"
311 TARGETS[$CONFIG_NUM]=$cfg
312 FUNC[$CONFIG_NUM]="setup_target"
318 # Options for setting up environment.
322 TITLE="Setup linuxapp environment"
324 TEXT[1]="Insert IGB UIO module"
325 FUNC[1]="load_igb_uio_module"
327 TEXT[2]="Setup hugepage mappings for non-NUMA systems"
328 FUNC[2]="set_non_numa_pages"
330 TEXT[3]="Setup hugepage mappings for NUMA systems"
331 FUNC[3]="set_numa_pages"
335 # Options for running applications.
339 TITLE="Run test application for linuxapp environment"
341 TEXT[1]="Run test application (\$RTE_TARGET/app/test)"
342 FUNC[1]="run_test_app"
344 TEXT[2]="Run testpmd application in interactive mode (\$RTE_TARGET/app/testpmd)"
345 FUNC[2]="run_testpmd_app"
355 TEXT[1]="List hugepage info from /proc/meminfo"
356 FUNC[1]="grep_meminfo"
358 TEXT[2]="List hugepage files in /mnt/huge"
359 FUNC[2]="ls_mnt_huge"
363 # Options for cleaning up the system
367 TITLE="Uninstall and system cleanup"
369 TEXT[1]="Uninstall all targets"
370 FUNC[1]="uninstall_targets"
372 TEXT[2]="Remove IGB UIO module"
373 FUNC[2]="remove_igb_uio_module"
375 TEXT[3]="Remove hugepage mappings"
376 FUNC[3]="clear_huge_pages"
379 STEPS[1]="step1_func"
380 STEPS[2]="step2_func"
381 STEPS[3]="step3_func"
382 STEPS[4]="step4_func"
383 STEPS[5]="step5_func"
387 while [ "$QUIT" == "0" ]; do
390 for s in $(seq ${#STEPS[@]}) ; do
393 echo "----------------------------------------------------------"
394 echo " Step $s: ${TITLE}"
395 echo "----------------------------------------------------------"
397 for i in $(seq ${#TEXT[@]}) ; do
398 echo "[$OPTION_NUM] ${TEXT[i]}"
399 OPTIONS[$OPTION_NUM]=${FUNC[i]}
403 # Clear TEXT and FUNC arrays before next step
410 echo "[$OPTION_NUM] Exit Script"
411 OPTIONS[$OPTION_NUM]="quit"
416 ${OPTIONS[our_entry]} ${our_entry}
418 echo -n "Press enter to continue ..."; read