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.
34 # version: DPDK.L.1.2.3-3
37 # Run with "source /path/to/setup.sh"
41 # Change to DPDK directory ( <this-script's-dir>/.. ), and export it as RTE_SDK
43 cd $(dirname ${BASH_SOURCE[0]})/..
45 echo "------------------------------------------------------------------------------"
46 echo " RTE_SDK exported as $RTE_SDK"
47 echo "------------------------------------------------------------------------------"
50 # Application EAL parameters for setting memory options (amount/channels/ranks).
55 # Sets QUIT variable so script will finish.
63 # Sets up envronment variables for ICC.
67 DEFAULT_PATH=/opt/intel/bin/iccvars.sh
69 shpath=`which iccvars.sh 2> /dev/null`
70 if [ $? -eq 0 ] ; then
71 echo "Loading iccvars.sh from $shpath for $param"
73 elif [ -f $DEFAULT_PATH ] ; then
74 echo "Loading iccvars.sh from $DEFAULT_PATH for $param"
75 source $DEFAULT_PATH $param
77 echo "## ERROR: cannot find 'iccvars.sh' script to set up ICC."
78 echo "## To fix, please add the directory that contains"
79 echo "## iccvars.sh to your 'PATH' environment variable."
85 # Sets RTE_TARGET and does a "make install".
90 export RTE_TARGET=${TARGETS[option]}
92 compiler=${RTE_TARGET##*-}
93 if [ "$compiler" == "icc" ] ; then
94 platform=${RTE_TARGET%%-*}
95 if [ "$platform" == "x86_64" ] ; then
101 if [ "$QUIT" == "0" ] ; then
102 make install T=${RTE_TARGET}
104 echo "------------------------------------------------------------------------------"
105 echo " RTE_TARGET exported as $RTE_TARGET"
106 echo "------------------------------------------------------------------------------"
110 # Uninstall all targets.
118 # Creates hugepage filesystem.
122 echo "Creating /mnt/huge and mounting as hugetlbfs"
123 sudo mkdir -p /mnt/huge
125 grep -s '/mnt/huge' /proc/mounts > /dev/null
126 if [ $? -ne 0 ] ; then
127 sudo mount -t hugetlbfs nodev /mnt/huge
132 # Removes hugepage filesystem.
136 echo "Unmounting /mnt/huge and removing directory"
137 grep -s '/mnt/huge' /proc/mounts > /dev/null
138 if [ $? -eq 0 ] ; then
139 sudo umount /mnt/huge
142 if [ -d /mnt/huge ] ; then
148 # Unloads igb_uio.ko.
150 remove_igb_uio_module()
152 echo "Unloading any existing DPDK UIO module"
153 /sbin/lsmod | grep -s igb_uio > /dev/null
154 if [ $? -eq 0 ] ; then
155 sudo /sbin/rmmod igb_uio
160 # Loads new igb_uio.ko (and uio module if needed).
162 load_igb_uio_module()
164 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
165 echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
166 echo " To fix, please try to rebuild target."
170 remove_igb_uio_module
172 /sbin/lsmod | grep -s uio > /dev/null
173 if [ $? -ne 0 ] ; then
174 if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then
175 echo "Loading uio module"
176 sudo /sbin/modprobe uio
180 # UIO may be compiled into kernel, so it may not be an error if it can't
183 echo "Loading DPDK UIO module"
184 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
185 if [ $? -ne 0 ] ; then
186 echo "## ERROR: Could not load kmod/igb_uio.ko."
192 # Removes all reserved hugepages.
197 for d in /sys/devices/system/node/node? ; do
198 echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
200 echo "Removing currently reserved hugepages"
215 echo " Input the number of 2MB pages"
216 echo " Example: to have 128MB of hugepages available, enter '64' to"
217 echo " reserve 64 * 2MB pages"
218 echo -n "Number of pages: "
221 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
223 echo "Reserving hugepages"
231 # Creates hugepages on specific NUMA nodes.
238 echo " Input the number of 2MB pages for each node"
239 echo " Example: to have 128MB of hugepages available per node,"
240 echo " enter '64' to reserve 64 * 2MB pages on each node"
243 for d in /sys/devices/system/node/node? ; do
245 echo -n "Number of pages for $node: "
247 echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
249 echo "Reserving hugepages"
257 # Run unit test application.
262 echo " Enter hex bitmask of cores to execute test app on"
263 echo " Example: to execute app on cores 0 to 7, enter 0xff"
267 sudo ${RTE_TARGET}/app/test -c $Bitmask $EAL_PARAMS
271 # Run unit testpmd application.
276 echo " Enter hex bitmask of cores to execute testpmd app on"
277 echo " Example: to execute app on cores 0 to 7, enter 0xff"
281 sudo ${RTE_TARGET}/app/testpmd -c $Bitmask $EAL_PARAMS -- -i
285 # Print hugepage information.
289 grep -i huge /proc/meminfo
293 # List all hugepage file references
301 # Options for building a target. Note that this step MUST be first as it sets
302 # up TARGETS[] starting from 1, and this is accessed in setup_target using the
303 # user entered option.
307 TITLE="Select the DPDK environment to build"
309 for cfg in config/defconfig_* ; do
310 cfg=${cfg/config\/defconfig_/}
311 TEXT[$CONFIG_NUM]="$cfg"
312 TARGETS[$CONFIG_NUM]=$cfg
313 FUNC[$CONFIG_NUM]="setup_target"
319 # Options for setting up environment.
323 TITLE="Setup linuxapp environment"
325 TEXT[1]="Insert IGB UIO module"
326 FUNC[1]="load_igb_uio_module"
328 TEXT[2]="Setup hugepage mappings for non-NUMA systems"
329 FUNC[2]="set_non_numa_pages"
331 TEXT[3]="Setup hugepage mappings for NUMA systems"
332 FUNC[3]="set_numa_pages"
336 # Options for running applications.
340 TITLE="Run test application for linuxapp environment"
342 TEXT[1]="Run test application (\$RTE_TARGET/app/test)"
343 FUNC[1]="run_test_app"
345 TEXT[2]="Run testpmd application in interactive mode (\$RTE_TARGET/app/testpmd)"
346 FUNC[2]="run_testpmd_app"
356 TEXT[1]="List hugepage info from /proc/meminfo"
357 FUNC[1]="grep_meminfo"
359 TEXT[2]="List hugepage files in /mnt/huge"
360 FUNC[2]="ls_mnt_huge"
364 # Options for cleaning up the system
368 TITLE="Uninstall and system cleanup"
370 TEXT[1]="Uninstall all targets"
371 FUNC[1]="uninstall_targets"
373 TEXT[2]="Remove IGB UIO module"
374 FUNC[2]="remove_igb_uio_module"
376 TEXT[3]="Remove hugepage mappings"
377 FUNC[3]="clear_huge_pages"
380 STEPS[1]="step1_func"
381 STEPS[2]="step2_func"
382 STEPS[3]="step3_func"
383 STEPS[4]="step4_func"
384 STEPS[5]="step5_func"
388 while [ "$QUIT" == "0" ]; do
391 for s in $(seq ${#STEPS[@]}) ; do
394 echo "----------------------------------------------------------"
395 echo " Step $s: ${TITLE}"
396 echo "----------------------------------------------------------"
398 for i in $(seq ${#TEXT[@]}) ; do
399 echo "[$OPTION_NUM] ${TEXT[i]}"
400 OPTIONS[$OPTION_NUM]=${FUNC[i]}
404 # Clear TEXT and FUNC arrays before next step
411 echo "[$OPTION_NUM] Exit Script"
412 OPTIONS[$OPTION_NUM]="quit"
417 ${OPTIONS[our_entry]} ${our_entry}
419 echo -n "Press enter to continue ..."; read