5 # Copyright(c) 2010-2014 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.
35 # Run with "source /path/to/setup.sh"
39 # Change to DPDK directory ( <this-script's-dir>/.. ), and export it as RTE_SDK
41 cd $(dirname ${BASH_SOURCE[0]})/..
43 echo "------------------------------------------------------------------------------"
44 echo " RTE_SDK exported as $RTE_SDK"
45 echo "------------------------------------------------------------------------------"
48 # Application EAL parameters for setting memory options (amount/channels/ranks).
53 # Sets QUIT variable so script will finish.
61 # Sets up environmental variables for ICC.
65 DEFAULT_PATH=/opt/intel/bin/iccvars.sh
67 shpath=`which iccvars.sh 2> /dev/null`
68 if [ $? -eq 0 ] ; then
69 echo "Loading iccvars.sh from $shpath for $param"
71 elif [ -f $DEFAULT_PATH ] ; then
72 echo "Loading iccvars.sh from $DEFAULT_PATH for $param"
73 source $DEFAULT_PATH $param
75 echo "## ERROR: cannot find 'iccvars.sh' script to set up ICC."
76 echo "## To fix, please add the directory that contains"
77 echo "## iccvars.sh to your 'PATH' environment variable."
83 # Sets RTE_TARGET and does a "make install".
88 export RTE_TARGET=${TARGETS[option]}
90 compiler=${RTE_TARGET##*-}
91 if [ "$compiler" == "icc" ] ; then
92 platform=${RTE_TARGET%%-*}
93 if [ "$platform" == "x86_64" ] ; then
99 if [ "$QUIT" == "0" ] ; then
100 make install T=${RTE_TARGET}
102 echo "------------------------------------------------------------------------------"
103 echo " RTE_TARGET exported as $RTE_TARGET"
104 echo "------------------------------------------------------------------------------"
108 # Uninstall all targets.
116 # Creates hugepage filesystem.
120 echo "Creating /mnt/huge and mounting as hugetlbfs"
121 sudo mkdir -p /mnt/huge
123 grep -s '/mnt/huge' /proc/mounts > /dev/null
124 if [ $? -ne 0 ] ; then
125 sudo mount -t hugetlbfs nodev /mnt/huge
130 # Removes hugepage filesystem.
134 echo "Unmounting /mnt/huge and removing directory"
135 grep -s '/mnt/huge' /proc/mounts > /dev/null
136 if [ $? -eq 0 ] ; then
137 sudo umount /mnt/huge
140 if [ -d /mnt/huge ] ; then
146 # Unloads igb_uio.ko.
148 remove_igb_uio_module()
150 echo "Unloading any existing DPDK UIO module"
151 /sbin/lsmod | grep -s igb_uio > /dev/null
152 if [ $? -eq 0 ] ; then
153 sudo /sbin/rmmod igb_uio
158 # Loads new igb_uio.ko (and uio module if needed).
160 load_igb_uio_module()
162 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
163 echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
164 echo " To fix, please try to rebuild target."
168 remove_igb_uio_module
170 /sbin/lsmod | grep -s uio > /dev/null
171 if [ $? -ne 0 ] ; then
172 if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then
173 echo "Loading uio module"
174 sudo /sbin/modprobe uio
178 # UIO may be compiled into kernel, so it may not be an error if it can't
181 echo "Loading DPDK UIO module"
182 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
183 if [ $? -ne 0 ] ; then
184 echo "## ERROR: Could not load kmod/igb_uio.ko."
190 # Unloads the rte_kni.ko module.
194 echo "Unloading any existing DPDK KNI module"
195 /sbin/lsmod | grep -s rte_kni > /dev/null
196 if [ $? -eq 0 ] ; then
197 sudo /sbin/rmmod rte_kni
202 # Loads the rte_kni.ko module.
206 # Check that the KNI module is already built.
207 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then
208 echo "## ERROR: Target does not have the DPDK KNI Module."
209 echo " To fix, please try to rebuild target."
213 # Unload existing version if present.
216 # Now try load the KNI module.
217 echo "Loading DPDK KNI module"
218 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko
219 if [ $? -ne 0 ] ; then
220 echo "## ERROR: Could not load kmod/rte_kni.ko."
226 # Removes all reserved hugepages.
231 for d in /sys/devices/system/node/node? ; do
232 echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
234 echo "Removing currently reserved hugepages"
249 echo " Input the number of 2MB pages"
250 echo " Example: to have 128MB of hugepages available, enter '64' to"
251 echo " reserve 64 * 2MB pages"
252 echo -n "Number of pages: "
255 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
257 echo "Reserving hugepages"
265 # Creates hugepages on specific NUMA nodes.
272 echo " Input the number of 2MB pages for each node"
273 echo " Example: to have 128MB of hugepages available per node,"
274 echo " enter '64' to reserve 64 * 2MB pages on each node"
277 for d in /sys/devices/system/node/node? ; do
279 echo -n "Number of pages for $node: "
281 echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
283 echo "Reserving hugepages"
291 # Run unit test application.
296 echo " Enter hex bitmask of cores to execute test app on"
297 echo " Example: to execute app on cores 0 to 7, enter 0xff"
301 sudo ${RTE_TARGET}/app/test -c $Bitmask $EAL_PARAMS
305 # Run unit testpmd application.
310 echo " Enter hex bitmask of cores to execute testpmd app on"
311 echo " Example: to execute app on cores 0 to 7, enter 0xff"
315 sudo ${RTE_TARGET}/app/testpmd -c $Bitmask $EAL_PARAMS -- -i
319 # Print hugepage information.
323 grep -i huge /proc/meminfo
327 # Calls igb_uio_bind.py --status to show the NIC and what they
328 # are all bound to, in terms of drivers.
332 if /sbin/lsmod | grep -q igb_uio ; then
333 ${RTE_SDK}/tools/igb_uio_bind.py --status
335 echo "# Please load the 'igb_uio' kernel module before querying or "
336 echo "# adjusting NIC device bindings"
341 # Uses igb_uio_bind.py to move devices to work with igb_uio
345 if /sbin/lsmod | grep -q igb_uio ; then
346 ${RTE_SDK}/tools/igb_uio_bind.py --status
348 echo -n "Enter PCI address of device to bind to IGB UIO driver: "
350 sudo ${RTE_SDK}/tools/igb_uio_bind.py -b igb_uio $PCI_PATH && echo "OK"
352 echo "# Please load the 'igb_uio' kernel module before querying or "
353 echo "# adjusting NIC device bindings"
358 # Uses igb_uio_bind.py to move devices to work with kernel drivers again
362 ${RTE_SDK}/tools/igb_uio_bind.py --status
364 echo -n "Enter PCI address of device to bind to IGB UIO driver: "
367 echo -n "Enter name of kernel driver to bind the device to: "
369 sudo ${RTE_SDK}/tools/igb_uio_bind.py -b $DRV $PCI_PATH && echo "OK"
373 # Options for building a target. Note that this step MUST be first as it sets
374 # up TARGETS[] starting from 1, and this is accessed in setup_target using the
375 # user entered option.
379 TITLE="Select the DPDK environment to build"
381 for cfg in config/defconfig_* ; do
382 cfg=${cfg/config\/defconfig_/}
383 TEXT[$CONFIG_NUM]="$cfg"
384 TARGETS[$CONFIG_NUM]=$cfg
385 FUNC[$CONFIG_NUM]="setup_target"
391 # Options for setting up environment.
395 TITLE="Setup linuxapp environment"
397 TEXT[1]="Insert IGB UIO module"
398 FUNC[1]="load_igb_uio_module"
400 TEXT[2]="Insert KNI module"
401 FUNC[2]="load_kni_module"
403 TEXT[3]="Setup hugepage mappings for non-NUMA systems"
404 FUNC[3]="set_non_numa_pages"
406 TEXT[4]="Setup hugepage mappings for NUMA systems"
407 FUNC[4]="set_numa_pages"
409 TEXT[5]="Display current Ethernet device settings"
412 TEXT[6]="Bind Ethernet device to IGB UIO module"
417 # Options for running applications.
421 TITLE="Run test application for linuxapp environment"
423 TEXT[1]="Run test application (\$RTE_TARGET/app/test)"
424 FUNC[1]="run_test_app"
426 TEXT[2]="Run testpmd application in interactive mode (\$RTE_TARGET/app/testpmd)"
427 FUNC[2]="run_testpmd_app"
437 TEXT[1]="List hugepage info from /proc/meminfo"
438 FUNC[1]="grep_meminfo"
443 # Options for cleaning up the system
447 TITLE="Uninstall and system cleanup"
449 TEXT[1]="Uninstall all targets"
450 FUNC[1]="uninstall_targets"
452 TEXT[2]="Unbind NICs from IGB UIO driver"
453 FUNC[2]="unbind_nics"
455 TEXT[3]="Remove IGB UIO module"
456 FUNC[3]="remove_igb_uio_module"
458 TEXT[4]="Remove KNI module"
459 FUNC[4]="remove_kni_module"
461 TEXT[5]="Remove hugepage mappings"
462 FUNC[5]="clear_huge_pages"
465 STEPS[1]="step1_func"
466 STEPS[2]="step2_func"
467 STEPS[3]="step3_func"
468 STEPS[4]="step4_func"
469 STEPS[5]="step5_func"
473 while [ "$QUIT" == "0" ]; do
476 for s in $(seq ${#STEPS[@]}) ; do
479 echo "----------------------------------------------------------"
480 echo " Step $s: ${TITLE}"
481 echo "----------------------------------------------------------"
483 for i in $(seq ${#TEXT[@]}) ; do
484 echo "[$OPTION_NUM] ${TEXT[i]}"
485 OPTIONS[$OPTION_NUM]=${FUNC[i]}
489 # Clear TEXT and FUNC arrays before next step
496 echo "[$OPTION_NUM] Exit Script"
497 OPTIONS[$OPTION_NUM]="quit"
502 ${OPTIONS[our_entry]} ${our_entry}
504 echo -n "Press enter to continue ..."; read