1#! /bin/bash 2 3############################ Common Utilities ################################ 4FL_PCAP=1 5FL_DPDK=2 6FL_NETMAP=3 7 8# vercomp returns 0 (=), 1 (>), or 2 (<) 9vercomp () { 10 if [[ $1 == $2 ]] 11 then 12 return 0 13 fi 14 local IFS=. 15 local i ver1=($1) ver2=($2) 16 # fill empty fields in ver1 with zeros 17 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) 18 do 19 ver1[i]=0 20 done 21 for ((i=0; i<${#ver1[@]}; i++)) 22 do 23 if [[ -z ${ver2[i]} ]] 24 then 25 # fill empty fields in ver2 with zeros 26 ver2[i]=0 27 fi 28 if ((10#${ver1[i]} > 10#${ver2[i]})) 29 then 30 return 1 31 fi 32 if ((10#${ver1[i]} < 10#${ver2[i]})) 33 then 34 return 2 35 fi 36 done 37 return 0 38} 39 40# valid_ip_addr returns 1 for valid ip address 41valid_ip_addr() 42{ 43 local ip=$1 44 local stat=1 45 46 if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then 47 OIFS=$IFS 48 IFS='.' 49 ip=($ip) 50 IFS=$OIFS 51 [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ 52 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] 53 stat=$? 54 fi 55 return $stat 56} 57 58# Create a mos.conf file 59create_config() 60{ 61 cd $CUR_DIR 62 mkdir -p $2 63 CONF_FILE=$2/mos.conf 64 CONF_MASTER_FILE=$2/mos-master.conf 65 CONF_SLAVE_FILE=$2/mos-slave.conf 66 67 echo 68 echo "----------------------------------------" 69 echo "Creating mos.conf file in $2" 70 echo "----------------------------------------" 71 72 if [ -f $CONF_FILE ]; then 73 echo 74 echo "The config file $2/mos.conf already exists." 75 echo "Skip writing a new config file.." 76 return 77 fi 78 79 # Get the number of CPUs and translate it into CPU mask 80 let "z=2**$(nproc)-1" 81 CPU_MASK=$(printf '0x%04X\n' $z) 82 83 # Get # of CPU sockets 84 let "sockets=$(cat /proc/cpuinfo | grep "physical id" | awk '{print $4}' | sort -ur | head -n 1) + 1" 85 86 # Get the number of memory channels 87 command -v dmidecode >/dev/null && 88 let "NUM_MEMCH=($(sudo dmidecode -t 17 | grep -c 'Size:')-$(sudo dmidecode -t 17 | grep -c 'Size: No Module'))/$sockets" || 89 { echo "dmidecode command not found. setting num_mem_ch = 4"; let "NUM_MEMCH=4"; } 90 91 # Get the number of interfaces 92 counter=0 93 if [[ $1 == $FL_DPDK ]]; then 94 cd /sys/module/igb_uio/drivers/pci:igb_uio/ 95 DEV_NAME="dpdk" 96 elif [[ ( $1 != $FL_PCAP ) && ( $1 != $FL_NETMAP ) ]]; then 97 echo "invalid function call 1" 98 exit 1 99 fi 100 for i in * 101 do 102 if [[ $i == *":"* ]] 103 then 104 let "counter=$counter + 1" 105 fi 106 done 107 cd $CUR_DIR 108 109 # Write up a new configuration file 110 if [[ $1 == $FL_PCAP ]]; then 111 cat .standalone-template.conf > $CONF_FILE 112 DEVLIST=`ifconfig -s | grep -Eo '^[^ ]+' | tail -n+2` 113 for dev in $DEVLIST; do 114 printf "Found $dev. Press y to select [y/N]: " 115 read option 116 if [[ "$option" == y* ]]; then 117 DEVICE="\n\t\t$dev" 118 DEVICEMASK="__coremask__devicemask" 119 FMT=$(printf 's/__devicemask/%s %s/g' $DEVICE $DEVICEMASK) 120 sed -i -e "$FMT" $CONF_FILE 121 122 DEVICE="$dev""__devicelist" 123 FMT=$(printf 's/__devicelist/ %s/g' $DEVICE) 124 sed -i -e "$FMT" $CONF_FILE 125 fi 126 done 127 sed -i -e 's/__devicemask//g' $CONF_FILE 128 sed -i -e 's/__devicelist//g' $CONF_FILE 129 sed -i -e 's/__coremask/0x0001/g' $CONF_FILE 130 sed -i -e 's/__num_memch//g' $CONF_FILE 131 sed -i -e 's/__forward/1/g' $CONF_FILE 132 sed -i -e 's/__multiprocess//g' $CONF_FILE 133 134 elif [[ $1 == $FL_NETMAP ]]; then 135 if [ "$3" = "epserver" ] || [ "$3" = "epwget" ] ; then 136 cat .end-template.conf > $CONF_FILE 137 else 138 cat .standalone-template.conf > $CONF_FILE 139 fi 140 141 DEVLIST=`ifconfig -s | grep -Eo '^[^ ]+' | tail -n+2` 142 for dev in $DEVLIST; do 143 printf "Found $dev. Press y to select [y/N]: " 144 read option 145 if [[ "$option" == y* ]]; then 146 DEVICE="\n\t\t$dev" 147 DEVICEMASK="__coremask__devicemask" 148 FMT=$(printf 's/__devicemask/%s %s/g' $DEVICE $DEVICEMASK) 149 sed -i -e "$FMT" $CONF_FILE 150 151 DEVICE="$dev""__devicelist" 152 FMT=$(printf 's/__devicelist/ %s/g' $DEVICE) 153 sed -i -e "$FMT" $CONF_FILE 154 fi 155 done 156 sed -i -e 's/__devicemask//g' $CONF_FILE 157 sed -i -e 's/__devicelist//g' $CONF_FILE 158 sed -i -e 's/__coremask/'$CPU_MASK'/g' $CONF_FILE 159 sed -i -e 's/__num_memch//g' $CONF_FILE 160 sed -i -e 's/__forward/1/g' $CONF_FILE 161 sed -i -e 's/__app/'$3'/g' $CONF_FILE 162 sed -i -e 's/__multiprocess//g' $CONF_FILE 163 164 if [ "$3" = "nat" ] ; then 165 sed -i -e 's/\# tcp_tw_interval = 30/tcp_tw_interval = 30/g' $CONF_FILE 166 fi 167 else 168 if [ "$3" = "epserver" ] || [ "$3" = "epwget" ] ; then 169 cat .end-template.conf > $CONF_FILE 170 cat .end-template.conf > $CONF_MASTER_FILE 171 cat .end-template.conf > $CONF_SLAVE_FILE 172 else 173 cat .standalone-template.conf > $CONF_FILE 174 fi 175 start=0 176 while [ $start -lt $counter ] 177 do 178 DEVICE="\n\t\t$DEV_NAME$(($start))" 179 DEVICEMASK="__coremask__devicemask" 180 FMT=$(printf 's/__devicemask/%s %s/g' $DEVICE $DEVICEMASK) 181 sed -i -e "$FMT" $CONF_FILE 182 183 DEVICE="$DEV_NAME$(($start))__devicelist" 184 FMT=$(printf 's/__devicelist/ %s/g' $DEVICE) 185 sed -i -e "$FMT" $CONF_FILE 186 187 let "start=$start + 1" 188 done 189 sed -i -e 's/__devicemask//g' $CONF_FILE 190 sed -i -e 's/__devicelist//g' $CONF_FILE 191 sed -i -e 's/__coremask/'$CPU_MASK'/g' $CONF_FILE 192 sed -i -e 's/__forward/1/g' $CONF_FILE 193 sed -i -e 's/__app/'$3'/g' $CONF_FILE 194 195 if [ "$3" = "nat" ] ; then 196 sed -i -e 's/\# tcp_tw_interval = 30/tcp_tw_interval = 30/g' $CONF_FILE 197 fi 198 199 if [[ $1 == $FL_DPDK ]]; then 200 FMT=$(printf 's/__num_memch/%snb_mem_channels = %d%s/g' '# number of memory channels per socket [mandatory for DPDK]\n\t' $NUM_MEMCH '\n') 201 sed -i -e "$FMT" $CONF_FILE 202 if [ "$3" = "epserver" ] || [ "$3" = "epwget" ] ; then 203 cp $CONF_FILE $CONF_MASTER_FILE 204 cp $CONF_FILE $CONF_SLAVE_FILE 205 sed -i -e 's/__multiprocess/multiprocess = 0 master/g' $CONF_MASTER_FILE 206 sed -i -e 's/__multiprocess/multiprocess = slave/g' $CONF_SLAVE_FILE 207 fi 208 else 209 echo "invalid function call 2" 210 exit 1 211 fi 212 213 sed -i -e 's/__multiprocess//g' $CONF_FILE 214 fi 215 echo 216 cat $CONF_FILE 217} 218 219create_makefile() 220{ 221 cd $CUR_DIR/samples 222 for d in * ; do 223 if [ -f $CUR_DIR/samples/$d/Makefile.in ]; then 224 cp $CUR_DIR/samples/$d/Makefile.in $CUR_DIR/samples/$d/Makefile 225 if [[ $1 == $FL_DPDK ]]; then 226 FMT=$(printf 's/__IO_LIB_ARGS/LIBS += -m64 -g -pthread -lrt -march=native -Wl,-export-dynamic -L..\/..\/drivers\/dpdk\/lib -Wl,-lnuma -Wl,-lmtcp -Wl,-lpthread -Wl,-lrt -Wl,-ldl -Wl,$(shell cat ..\/..\/drivers\/dpdk\/lib\/ldflags.txt)/g') 227 elif [[ $1 == $FL_PCAP ]]; then 228 FMT=$(printf 's/__IO_LIB_ARGS/GCC_OPT += -D__thread="" -DBE_RESILIENT_TO_PACKET_DROP\\nINC += -DENABLE_PCAP\\nLIBS += -lpcap/g') 229 elif [[ $1 == $FL_NETMAP ]]; then 230 FMT=$(printf 's/__IO_LIB_ARGS/GCC_OPT += -DENABLE_NETMAP/g') 231 fi 232 sed -i -e "$FMT" $CUR_DIR/samples/$d/Makefile 233 fi 234 done 235} 236 237# Setup MOS library 238setup_mos_library() { 239 echo "Start building up the MOS library" 240 cd $CUR_DIR 241 242 if [[ $1 == $FL_DPDK ]]; then 243 mkdir -p $DPDK_DIR 244 rmdir $DPDK_DIR/include $DPDK_DIR/lib 2> /dev/null 245 rm $DPDK_DIR/include $DPDK_DIR/lib 2> /dev/null 246 ln -s $CUR_DIR/$RTE_SDK/$RTE_TARGET/include $DPDK_DIR/include 247 ln -s $CUR_DIR/$RTE_SDK/$RTE_TARGET/lib $DPDK_DIR/lib 248 cd $CUR_DIR/scripts/ 249 ./configure --enable-dpdk 250 elif [[ $1 == $FL_PCAP ]]; then 251 cd $CUR_DIR/scripts/ 252 ./configure --enable-pcap 253 elif [[ $1 == $FL_NETMAP ]]; then 254 cd $CUR_DIR/scripts/ 255 ./configure --enable-netmap 256 fi 257 cd $CUR_DIR/core/src 258 make clean;make 259 cd $CUR_DIR 260 create_makefile $1 261 echo 262 echo "----------------------------------------------------------" 263 echo "Done with MOS library setup" 264 echo "----------------------------------------------------------" 265 echo 266} 267 268############################################################################# 269 270############################### DPDK Utilities ############################## 271# Creates hugepage filesystem. 272create_mnt_huge() 273{ 274 echo "Creating /mnt/huge and mounting as hugetlbfs" 275 sudo mkdir -p /mnt/huge 276 277 grep -s '/mnt/huge' /proc/mounts > /dev/null 278 if [ $? -ne 0 ] ; then 279 sudo mount -t hugetlbfs nodev /mnt/huge 280 fi 281} 282 283# Removes hugepage filesystem. 284remove_mnt_huge() 285{ 286 echo "Unmounting /mnt/huge and removing directory" 287 grep -s '/mnt/huge' /proc/mounts > /dev/null 288 if [ $? -eq 0 ] ; then 289 sudo umount /mnt/huge 290 fi 291 292 if [ -d /mnt/huge ] ; then 293 sudo rm -R /mnt/huge 294 fi 295} 296 297# Unloads igb_uio.ko. 298remove_igb_uio_module() 299{ 300 echo "Unloading any existing DPDK UIO module" 301 /sbin/lsmod | grep -s igb_uio > /dev/null 302 if [ $? -eq 0 ] ; then 303 sudo /sbin/rmmod igb_uio 304 fi 305} 306 307# Loads new igb_uio.ko (and uio module if needed). 308load_igb_uio_module() 309{ 310 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then 311 echo "## ERROR: Target does not have the DPDK UIO Kernel Module." 312 echo " To fix, please try to rebuild target." 313 return 314 fi 315 316 remove_igb_uio_module 317 318 /sbin/lsmod | grep -s uio > /dev/null 319 if [ $? -ne 0 ] ; then 320 modinfo uio > /dev/null 321 if [ $? -eq 0 ]; then 322 echo "Loading uio module" 323 sudo /sbin/modprobe uio 324 fi 325 fi 326 327 # UIO may be compiled into kernel, so it may not be an error if it can't 328 # be loaded. 329 echo "Loading DPDK UIO module" 330 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko 331 if [ $? -ne 0 ] ; then 332 echo "## ERROR: Could not load kmod/igb_uio.ko." 333 quit 334 fi 335} 336 337# Removes all reserved hugepages. 338clear_numa_pages() 339{ 340 echo > .echo_tmp 341 for d in /sys/devices/system/node/node? ; do 342 echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp 343 done 344 echo "Removing currently reserved hugepages" 345 sudo sh .echo_tmp 346 rm -f .echo_tmp 347 348 remove_mnt_huge 349} 350# Removes all reserved hugepages. 351clear_non_numa_pages() 352{ 353 echo > .echo_tmp 354 echo "echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp 355 echo "Removing currently reserved hugepages" 356 sudo sh .echo_tmp 357 rm -f .echo_tmp 358 remove_mnt_huge 359} 360 361# 362# Creates hugepages. 363# 364set_non_numa_pages_default() 365{ 366 clear_non_numa_pages 367 echo > .echo_tmp 368 echo "Number of pages : 1024" 369 370 Pages=1024 371 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp 372 373 echo "Reserving hugepages" 374 sudo sh .echo_tmp 375 rm -f .echo_tmp 376 377 create_mnt_huge 378} 379 380# 381# Creates hugepages. 382# 383set_non_numa_pages() 384{ 385 386 clear_non_numa_pages 387 388 echo "" 389 echo " Input the number of 2MB pages" 390 echo " Example: to have 128MB of hugepages available, enter '64' to" 391 echo " reserve 64 * 2MB pages" 392 echo -n "Number of pages: " 393 read Pages 394 395 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp 396 397 echo "Reserving hugepages" 398 sudo sh .echo_tmp 399 rm -f .echo_tmp 400 401 create_mnt_huge 402 403} 404 405# Creates hugepages on specific NUMA nodes. 406set_numa_pages_default() 407{ 408 clear_numa_pages 409 echo > .echo_tmp 410 for d in /sys/devices/system/node/node? ; do 411 node=$(basename $d) 412 echo "Number of pages for $node: 1024" 413 Pages=1024 414 echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp 415 done 416 echo "Reserving hugepages" 417 sudo sh .echo_tmp 418 rm -f .echo_tmp 419 420 create_mnt_huge 421} 422 423# Creates hugepages on specific NUMA nodes. 424set_numa_pages() 425{ 426 clear_numa_pages 427 echo "" 428 echo " Input the number of 2MB pages for each node" 429 echo " Example: to have 128MB of hugepages available per node," 430 echo " enter '64' to reserve 64 * 2MB pages on each node" 431 432 echo > .echo_tmp 433 for d in /sys/devices/system/node/node? ; do 434 node=$(basename $d) 435 echo -n "Number of pages for $node: " 436 read Pages 437 echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp 438 done 439 echo "Reserving hugepages" 440 sudo sh .echo_tmp 441 rm -f .echo_tmp 442 443 create_mnt_huge 444} 445 446# Uses dpdk-devbind.py to move devices to work with igb_uio 447bind_nics_to_igb_uio() 448{ 449 if /sbin/lsmod | grep -q igb_uio ; then 450 ${RTE_SDK}/usertools/dpdk-devbind.py --status 451 echo "" 452 echo "Enter PCI address of device(s) to bind to IGB UIO driver (e.g., \"04:00.0 04:00.1\")." 453 echo -n "> " 454 read PCI_PATH 455 456 457 sudo ${RTE_SDK}/usertools/dpdk-devbind.py -b igb_uio $PCI_PATH && echo "OK" 458 else 459 echo "# Please load the 'igb_uio' kernel module before querying or " 460 echo "# adjusting NIC device bindings" 461 fi 462} 463 464# 465# Uses dpdk-devbind.py to move devices to work with kernel drivers again 466# 467unbind_nics() 468{ 469 DEVLIST=`ifconfig -s | grep -Eo '^[^ ]+' | tail -n+2` 470 for dev in $DEVLIST 471 do 472 echo $dev 473 if [[ "$dev" == dpdk* ]]; then 474 sudo ifconfig $dev down 475 fi 476 done 477 478 ${RTE_SDK}/usertools/dpdk-devbind.py --status 479 echo "" 480 echo -n "Enter PCI address of device to unbind: " 481 read PCI_PATH 482 echo "" 483 echo -n "Enter name of kernel driver to bind the device to: " 484 read DRV 485 sudo ${RTE_SDK}/usertools/dpdk-devbind.py -b $DRV $PCI_PATH && echo "OK" 486} 487 488# Brings up the interface of DPDK devices up 489setup_iface_dpdk() 490{ 491 # Create & configure /dev/dpdk-iface 492 sudo rm -rf /dev/dpdk-iface 493 sudo mknod /dev/dpdk-iface c 1110 0 494 sudo chmod 666 /dev/dpdk-iface 495 496 # First check whether igb_uio module is already loaded 497 MODULE="igb_uio" 498 499 if sudo lsmod | grep "$MODULE" &> /dev/null ; then 500 echo "$MODULE is loaded!" 501 else 502 echo "$MODULE is not loaded!" 503 exit 1 504 fi 505 506 # set ip address for dpdk-enabled interfaces in the system 507 list=`basename -a /sys/class/net/dpdk*` 508 for if_name in ${list//\\n/ }; do 509 510 while [ 1 ]; do 511 echo 512 echo "[$if_name] enter IP address[/mask] (e.g., 10.0.0.1[/24])" 513 echo -n "> " 514 read line 515 ip_addr=`echo $line | awk -F '/' '{print $1}'` 516 mask=`echo $line | awk -F '/' '{print $2}'` 517 valid_ip_addr $ip_addr 518 if [ $? -eq 0 ]; then 519 break 520 fi 521 echo "invalid IP address!" # continue 522 done 523 524 if [ "$mask" == "" ];then 525 echo "sudo /sbin/ifconfig $if_name $ip_addr up" 526 sudo /sbin/ifconfig $if_name $ip_addr up 527 else 528 echo "sudo /sbin/ifconfig $if_name $ip_addr/$mask up" 529 sudo /sbin/ifconfig $if_name $ip_addr/$mask up 530 fi 531 done 532 533} 534############################################################################# 535 536############################### DPDK ######################################## 537step0_func_dpdk() 538{ 539 if [ -d "/sys/devices/system/node" ]; then 540 set_numa_pages_default 541 else 542 set_non_numa_pages_default 543 fi 544 545 step2_func_dpdk 546 step3_func_dpdk 547 step4_func_dpdk 548} 549step1_func_dpdk() 550{ 551 if [ -d "/sys/devices/system/node" ]; then 552 set_numa_pages 553 else 554 set_non_numa_pages 555 fi 556} 557step2_func_dpdk() 558{ 559 load_igb_uio_module 560 bind_nics_to_igb_uio 561} 562step3_func_dpdk() 563{ 564 setup_iface_dpdk $last_octet 565} 566step4_func_dpdk() 567{ 568 cd $CUR_DIR/samples 569 for d in * ; do 570 create_config $FL_DPDK "samples/$d/config" $d 571 done 572 echo 573 echo "------------------------------------------------" 574 echo "Done with configuration file setup." 575 echo "Use the arp command to add static ARP entries" 576 echo "------------------------------------------------" 577} 578step5_func_dpdk() 579{ 580 unbind_nics 581} 582step6_func_dpdk() 583{ 584 echo 585 exit 1 586} 587############################################################################# 588 589############################### PCAP ######################################## 590step0_func_pcap() 591{ 592 cd $CUR_DIR/samples 593 for d in * ; do 594 if [ -d $CUR_DIR/samples/$d/config ]; then 595 create_config $FL_PCAP "samples/$d/config" $d 596 fi 597 done 598 echo 599 echo "------------------------------------------------" 600 echo "Done with configuration file setup." 601 echo "Use the arp command to add static ARP entries" 602 echo "------------------------------------------------" 603 exit 1 604} 605############################################################################# 606 607############################## NETMAP ####################################### 608step0_func_netmap() 609{ 610 cd $CUR_DIR/samples 611 for d in * ; do 612 if [ -d $CUR_DIR/samples/$d/config ]; then 613 create_config $FL_NETMAP "samples/$d/config" $d 614 fi 615 done 616 echo 617 echo "------------------------------------------------" 618 echo "Done with configuration file setup." 619 echo "Use the arp command to add static ARP entries" 620 echo "------------------------------------------------" 621 exit 1 622} 623############################################################################# 624 625############################# Main Script ################################### 626export CUR_DIR=$PWD 627kerver=$(uname -r) 628 629if [ "$1" == "--compile-dpdk" ]; then 630 vercomp $kerver "2.6.33" 631 # if kernel version < 2.6.33 632 if [ "$?" == "2" ]; then 633 echo "[note] current kerner version ("$kerver") does not support DPDK" 634 exit 1 635 fi 636 # Build and install DPDK library 637 export DPDK_DIR="drivers/dpdk" 638 export RTE_SDK="drivers/dpdk-17.08" 639 export RTE_TARGET="x86_64-native-linuxapp-gcc" 640 export DESTDIR="." 641 echo 642 echo "Selected DPDK library to be used for MOS" 643 echo "----------------------------------------------------------" 644 echo " RTE_SDK exported as $RTE_SDK" 645 echo " RTE_TARGET exported as $RTE_TARGET" 646 echo "----------------------------------------------------------" 647 echo 648 echo -n "Press enter to continue ..."; read 649 cd $RTE_SDK 650 make install T=$RTE_TARGET 651 echo 652 echo -n "Done with DPDK setup. Press enter to start MOS setup ..."; read 653 # Build and compile MOS library 654 setup_mos_library $FL_DPDK 655 656elif [ "$1" == "--compile-pcap" ]; then 657 setup_mos_library $FL_PCAP 658 659elif [ "$1" == "--compile-netmap" ]; then 660 setup_mos_library $FL_NETMAP 661 662elif [ "$1" == "--run-dpdk" ]; then 663 export DPDK_DIR="drivers/dpdk" 664 export RTE_SDK="drivers/dpdk-17.08" 665 export RTE_TARGET="x86_64-native-linuxapp-gcc" 666 while [ 1 ]; do 667 clear 668 echo 669 echo "----------------------------------------------------------" 670 echo " Full setup (from start)" 671 echo "----------------------------------------------------------" 672 echo "[0] Full setup for running mOS with DPDK" 673 echo 674 echo "----------------------------------------------------------" 675 echo " Step-by-step setup for running mOS with DPDK" 676 echo "----------------------------------------------------------" 677 echo "[1] Setup hugepage mappings" 678 echo "[2] Load and bind Ethernet devices to IGB_UIO module" 679 echo "[3] Bring the interfaces up (DPDK devices)" 680 echo "[4] Create new MOS configuration files for sample apps" 681 echo "[5] Unbind dpdk-registered NICs" 682 echo 683 echo "[6] Exit script" 684 echo 685 echo -n "Option: " 686 read entry 687 if [ "$entry" ]; then 688 step"$entry"_func_dpdk 689 echo 690 echo -n "Press enter to continue ..."; read 691 fi 692 done 693 694elif [ "$1" == "--run-pcap" ]; then 695 while [ 1 ]; do 696 clear 697 echo 698 echo "----------------------------------------------------------" 699 echo " Full setup (from start)" 700 echo "----------------------------------------------------------" 701 step0_func_pcap 702 echo 703 echo -n "Press enter to continue ..."; read 704 done 705 706elif [ "$1" == "--run-netmap" ]; then 707 while [ 1 ]; do 708 clear 709 echo 710 echo "----------------------------------------------------------" 711 echo " Full setup (from start)" 712 echo "----------------------------------------------------------" 713 step0_func_netmap 714 echo 715 echo -n "Press enter to continue ..."; read 716 done 717 718elif [ "$1" == "--cleanup" ]; then 719 find | grep mos.conf | xargs rm -f 720 find | grep log__* | xargs rm -f 721 722 for d in $CUR_DIR/samples/* ; do 723 cd $d 724 make clean > /dev/null 2> /dev/null 725 cd .. 726 done 727 cd .. 728 cd core/src 729 make clean > /dev/null 2> /dev/null 730 cd bpf 731 rm -rf *.o 732 cd .. 733 rm -rf .*.d 734 rm -f Makefile 735 cd ../.. 736 find ./samples/ -name 'Makefile' | xargs rm -f 737 rm -f scripts/config.log scripts/config.status 738else 739 echo "[error] please specify one of the following options" 740 echo "--compile-dpdk : compile and build mOS library with dpdk" 741 echo "--compile-pcap : compile and build mOS library with pcap" 742 echo "--compile-netmap : compile and build mOS library with netmap" 743 echo "--run-dpdk : setup environments and configurations for running applications with dpdk" 744 echo "--run-pcap : setup environments and configurations for running applications with pcap" 745 echo "--run-netmap : setup environments and configurations for running applications with netmap" 746 echo "--cleanup : delete all binaries, config and Makefiles" 747fi 748