#!/bin/sh export RTE_SDK=/opt/dpdk export RTE_TARGET=x86_64-default-linuxapp-gcc export RTE_ARCH=x86_64 RTE_SRC=/usr/src/dpdk HUGE_PAGES_MEM=2097152 #[1024 * 2048kB] #check hugetlbfs mount echo -n "Mounting hugepages..." mount | grep "nodev on /mnt/huge type hugetlbfs" if [ $? -ne 0 ]; then mkdir -p /mnt/huge mount -t hugetlbfs nodev /mnt/huge fi echo "OK!" #increase hugepages for all nodes echo -n "Allocating hugepages..." #get hugepages sizes hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"` #calculate huge pages number to get the equivalent of 1024 pages of 2MB huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}` #get hugepages no hp=0 #Find out if this is a NUMA machine ls /sys/devices/system/node/node* > /dev/null 2>&1 if [ $? -ne 0 ]; then hp=`cat /proc/sys/vm/nr_hugepages` hptest=`expr $hp + $huge_pages_no` echo $hptest > /proc/sys/vm/nr_hugepages else hparray=() nodes=`ls /sys/devices/system/node | grep node | wc -l` for (( i=0; $i<$nodes; i++ )) do hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages` hptest=`expr $hp + $huge_pages_no` echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages hparray+=("$hp") done fi echo "OK!" echo "Allocated ${huge_pages_no} x ${hp_sz}kB" #run l2fwd loopback test DEVS=("I350" "82599") PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko rmmod rte_kni > /dev/null 2>&1 rmmod igb_uio > /dev/null 2>&1 modprobe uio && insmod ${IGB_UIO} #insert igb_uio, needed by some dpdk tests if [ $? -ne 0 ]; then echo "FAIL: uio/igb_uio load" DEVS=() else echo "PASS: uio/igb_uio load" fi #insert rte_kni driver in loopback mode, needed by KNI tests insmod ${RTE_KNI} lo_mode=lo_mode_fifo if [ $? -ne 0 ]; then echo "FAIL: rte_kni load" DEVS=() else echo "PASS: rte_kni load" fi #bind devices to igb_uio, needed by some dpdk tests drvarray=() pciarray=() for dev in ${DEVS[@]} do DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then continue fi DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" if [ ! -z ${DEV_ETH} ]; then ifconfig ${DEV_ETH} down fi ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} drvarray+=("${DEV_DRV}") pciarray+=("${DEV_PCI_ADDR}") done #run dpdk tests python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET} #bind devices to initial drivers for ((i=0;i<${#pciarray[@]};i++)); do echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}" ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]} done for dev in ${DEVS[@]} do DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then echo "SKIP: l2fwd-lpbk ($dev)" continue fi DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" if [ ! -z ${DEV_ETH} ]; then ifconfig ${DEV_ETH} down fi ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} ./l2fwd-lpbk -c 0xff -n 2 --use-device=${DEV_PCI_ADDR} -- -p 0x1 -t 128 -s 64 -T 10 -l > ${DEV_PCI_ADDR}.log 2>&1 & APP_PID=$! sleep 20 kill $APP_PID DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP" STATUS=0 case "$dev" in "I350") if [ ${DEV_SENT} -lt 13000000 ]; then STATUS=1 fi ;; "82599") if [ ${DEV_SENT} -lt 110000000 ]; then STATUS=1 fi ;; esac if [ ${STATUS} -ne 0 ]; then echo "FAIL: l2fwd-lpbk (low throughput)" fi if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then echo "FAIL: l2fwd-lpbk (dropped packets)" STATUS=1 fi if [ ${STATUS} -eq 0 ]; then echo "PASS: l2fwd-lpbk ($dev)" fi ${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR} done if [ ! -z ${DEVS} ]; then rmmod rte_kni > /dev/null 2>&1 rmmod igb_uio > /dev/null 2>&1 rmmod uio > /dev/null 2>&1 fi echo -n "Freeing hugepages..." #Find out if this is a NUMA machine ls /sys/devices/system/node/node* > /dev/null 2>&1 if [ $? -ne 0 ]; then echo $hp > /proc/sys/vm/nr_hugepages else i=0 for hp in ${hparray[@]} do echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages" ((i++)) done fi echo "OK!" rm -rf /mnt/huge/*