From 1b6242fc583a6b871304fb995af6dc211b58f69b Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 26 Jun 2014 13:48:23 +0200 Subject: initial commit for Enea Linux 4.0 Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau --- recipes-test/oftest/oftest_git.bb | 27 ++ recipes-test/openvswitchdpdk-oftest/files/README | 3 + .../openvswitchdpdk-oftest/files/run-ptest | 284 +++++++++++++++++++++ .../openvswitchdpdk-oftest.bb | 20 ++ 4 files changed, 334 insertions(+) create mode 100644 recipes-test/oftest/oftest_git.bb create mode 100644 recipes-test/openvswitchdpdk-oftest/files/README create mode 100644 recipes-test/openvswitchdpdk-oftest/files/run-ptest create mode 100644 recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb (limited to 'recipes-test') diff --git a/recipes-test/oftest/oftest_git.bb b/recipes-test/oftest/oftest_git.bb new file mode 100644 index 0000000..299c693 --- /dev/null +++ b/recipes-test/oftest/oftest_git.bb @@ -0,0 +1,27 @@ +SUMMARY = "OFTest" +DESCRIPTION = "OFTest - an OpenFlow test framework for switches" +HOMEPAGE = "http://www.projectfloodlight.org/oftest" +SECTION = "networking" +LICENSE = "BSD" +LIC_FILES_CHKSUM = "file://LICENSE;md5=7ad8e1e5f1c3d0004a6d449dbce36efe" + +PR = "1" +PV = "0" +RDEPENDS_${PN} = "python-scapy" + +inherit autotools + +SRCREV = "47544e410531732ee3603c5dfd255770009a9d96" +SRC_URI = "git://github.com/floodlight/oftest \ + " + +S = "${WORKDIR}/git" +B = "${S}" + +PACKAGES = "${PN}" +FILES_${PN} += "/opt/${PN}" + +do_install() { + install -d ${D}/opt/${PN} + cp -r ${S}/* ${D}/opt/${PN} +} diff --git a/recipes-test/openvswitchdpdk-oftest/files/README b/recipes-test/openvswitchdpdk-oftest/files/README new file mode 100644 index 0000000..cba3589 --- /dev/null +++ b/recipes-test/openvswitchdpdk-oftest/files/README @@ -0,0 +1,3 @@ +This ptest is intended to test DPDK OVS with OFTest framework. +It requires both DPDK-OVS and OFTest to be installed. + diff --git a/recipes-test/openvswitchdpdk-oftest/files/run-ptest b/recipes-test/openvswitchdpdk-oftest/files/run-ptest new file mode 100644 index 0000000..c08f224 --- /dev/null +++ b/recipes-test/openvswitchdpdk-oftest/files/run-ptest @@ -0,0 +1,284 @@ +#!/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] +DEVS=("I350" "82599") +PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py +OVS_PREFIX=/opt/openvswitchdpdk +IGB_UIO=$OVS_PREFIX/share/openvswitchdpdk/kmod/igb_uio.ko +RTE_KNI=$OVS_PREFIX/share/openvswitchdpdk/kmod/rte_kni.ko + +#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" + +#Insert igb_uio and rte_kni modules +echo "Inserting kernel modules" +rmmod openvswitch 2>/dev/null +rmmod -f rte_kni 2>/dev/null +rmmod -f igb_uio 2>/dev/null +rmmod -f uio 2>/dev/null +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 +insmod ${RTE_KNI} + +if [ $? -ne 0 ]; then + echo "FAIL: rte_kni load" + DEVS=() +else + echo "PASS: rte_kni load" +fi + +#bind devices to igb_uio, needed by dpdk-ovs tests +search_str="" +len=${#DEVS[@]} +tmp=$len +for dev in ${DEVS[@]} +do + tmp=$[$tmp-1] + if [ $tmp -gt 0 ]; then + search_str+="${dev}\|" + else + search_str+=${dev} + fi +done + +#Get devices with link and bind to igb_uio +drvarray=() +pciarray=() +tmp=1 +len=`${PCI_UTIL} --status|grep ${search_str}|grep -v -i 'active'|wc -l` +while [[ $tmp -le $len ]] +do + DEV_INFO=`${PCI_UTIL} --status|grep ${search_str}|grep -v -i 'active'|sed -n ${tmp}p` + tmp=$[$tmp+1] + DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` + DEV_ETH=`echo ${DEV_INFO}|grep if=|sed -r "s/.*if=([^ ]*).*/\1/"` + if [ "${DEV_ETH}" == "" ]; then + echo "Skipping device ${DEV_PCI_ADDR}" + continue + fi + ifconfig ${DEV_ETH} up + sleep 1 + ifconfig ${DEV_ETH}|grep RUNNING>/dev/null + if [ $? -ne 0 ]; then + echo "Skipping device ${DEV_ETH}" + continue + fi + DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` + DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` + pciarray+=("${DEV_PCI_ADDR}") + drvarray+=("${DEV_DRV}") + echo -n "Binding device ${DEV_PCI_ADDR}..." + ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} + echo "OK!" +done + +# Pre test cleanup +rm -f $OVS_PREFIX/etc/openvswitch/conf.db +mkdir -p $OVS_PREFIX/var/run/openvswitch 2>/dev/null +mkdir -p $OVS_PREFIX/etc/openvswitch 2>/dev/null + +# Create OVS schema +echo -n "Create OVS schema..." +$OVS_PREFIX/bin/ovsdb-tool create $OVS_PREFIX/etc/openvswitch/conf.db $OVS_PREFIX/share/openvswitch/vswitch.ovsschema + +sleep 2 +echo "OK!" + +#Start DB server +echo -n "Start DB server..." +$OVS_PREFIX/sbin/ovsdb-server --remote=punix:$OVS_PREFIX/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options > ovsdb-server.log 2>&1 & +ovsdb_server_pid=$! + +sleep 2 +echo "OK!" + +#init DB +echo -n "Init DB..." +$OVS_PREFIX/bin/ovs-vsctl --no-wait init + +sleep 2 +echo "OK!" + +#Configure DB +echo -n "Configure DB..." +$OVS_PREFIX/bin/ovs-vsctl --no-wait del-br br0 +$OVS_PREFIX/bin/ovs-vsctl --no-wait add-br br0 -- set Bridge br0 datapath_type=dpdk + +#Configure switch to use an OpenFlow controller and disable -n-band management +$OVS_PREFIX/bin/ovs-vsctl --no-wait set-controller br0 tcp:127.0.0.1:6653 +$OVS_PREFIX/bin/ovs-vsctl --no-wait set Bridge br0 other_config:disable-in-band=true + +#Add ports to switch +$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_64 -- set Interface ovs_dpdk_64 type=dpdkveth ofport_request=64 +$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_65 -- set Interface ovs_dpdk_65 type=dpdkveth ofport_request=65 +$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_66 -- set Interface ovs_dpdk_66 type=dpdkveth ofport_request=66 +$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_67 -- set Interface ovs_dpdk_67 type=dpdkveth ofport_request=67 + +sleep 2 +echo "OK!" + +#Start DPDK OVS +echo -n "Start DPDK OVS..." +$OVS_PREFIX/bin/ovs_dpdk -c 0x0f -n 4 --proc-type=primary --socket-mem 1024,1024 -- -p 0x03 -n 2 -v 4 --stats=1 --client_switching_core=1 --config="(0,0,2),(1,0,3)" > ovs_dpdk.log 2>&1 & +ovs_dpdk_pid=$! + +s=0 +delta=5 +tmo=120 +while [[ $s -lt $tmo ]] +do + echo -n "." + sleep $delta + if grep --quiet "APP: Client switching core is" ovs_dpdk.log; then + echo OK! + break + fi + s=$[$s+$delta] +done + +if [ $s -lt $tmo ]; then + echo PASS: Starting DPDK vSwitch + #Start DPDK OVS daemon + echo -n "Start DPDK OVS daemon..." + $OVS_PREFIX/sbin/ovs-vswitchd -c 0x10 --proc-type=secondary > ovs-vswitchd.log 2>&1 & + ovs_vswitchd_pid=$! + s=0 + delta=5 + tmo=120 + while [[ $s -lt $tmo ]] + do + echo -n "." + sleep $delta + if grep --quiet "EAL: Master core" ovs-vswitchd.log; then + echo OK! + break + fi + s=$[$s+$delta] + done + + if [ $s -lt $tmo ]; then + echo PASS: Starting DPDK vSwitch daemon + #Cleanup flows + $OVS_PREFIX/bin/ovs-ofctl del-flows br0 + sleep 40 + + #Configure all interfaces up and promiscuous + ifconfig vEth0 up + ifconfig vEth1 up + ifconfig vEth2 up + ifconfig vEth3 up + ifconfig vEth0 promisc + #ifconfig vEth1 promisc + #ifconfig vEth2 promisc + #ifconfig vEth3 promisc + tcpdump -i vEth0 & + #tcpdump -i vEth2 & + #tcpdump -i vEth3 & + + #Start OFTest + echo -n "Start OFTest..." + cd /opt/oftest/ + ./oft -i 64@vEth0 -i 65@vEth1 -i 66@vEth2 -i 67@vEth3 flow_matches 2>&1 | \ + grep "\.\.\." | sed -r "s/(.*) ... (FAIL)/\2: \1/" | sed -r "s/(.*) ... (ok)/PASS: \1/" + + sleep 2 + echo "Kill processes..." + kill -9 $ovs_vswitchd_pid 2>&1 > /dev/null + sleep 1 + else + echo NOK! + echo FAIL: Starting DPDK vSwitch daemon + cd /opt/oftest/ + ./oft --list-test-names | sed -r "s/(.*)/SKIP: \1/" + echo "Kill processes..." + fi +else + echo NOK! + echo FAIL: Starting DPDK vSwitch + cd /opt/oftest/ + ./oft --list-test-names | sed -r "s/(.*)/SKIP: \1/" + echo "Kill processes..." +fi + +kill -9 $ovs_dpdk_pid 2>&1 > /dev/null +sleep 1 +kill -9 $ovsdb_server_pid 2>&1 > /dev/null +sleep 1 + +#bind devices to initial drivers +for ((i=0;i<${#pciarray[@]};i++)); +do + echo -n "Restoring device ${pciarray[$i]} ..." + ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]} + echo "OK!" +done + +rmmod rte_kni +rmmod igb_uio + +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/* + +echo "Test done!" + diff --git a/recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb b/recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb new file mode 100644 index 0000000..e4b27d3 --- /dev/null +++ b/recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb @@ -0,0 +1,20 @@ +SUMMARY = "DPDK vSwitch - OFTest" +DESCRIPTION = "OFTest based testing for DPDK vSwitch" +LICENSE = "BSD" +LIC_FILES_CHKSUM = "file://README;md5=6b96a2f1b1ba742aadcc58002f3e9351 \ + " +RDEPENDS_${PN} = "oftest openvswitchdpdk dpdk python-scapy" + +PR = "r0" +PV = "1.0" + +SRC_REV = "1.0-r0" +SRC_URI = "file://README \ + file://run-ptest \ + " + +S = "${WORKDIR}" +B = "${S}" + +inherit ptest + -- cgit v1.2.3-54-g00ecf