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