summaryrefslogtreecommitdiffstats
path: root/recipes-test
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
committerAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
commit1b6242fc583a6b871304fb995af6dc211b58f69b (patch)
treeb5d434d90dedae24792906aa304897c23a134386 /recipes-test
downloadmeta-ip-daisy-enea.tar.gz
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-test')
-rw-r--r--recipes-test/oftest/oftest_git.bb27
-rw-r--r--recipes-test/openvswitchdpdk-oftest/files/README3
-rw-r--r--recipes-test/openvswitchdpdk-oftest/files/run-ptest284
-rw-r--r--recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb20
4 files changed, 334 insertions, 0 deletions
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 @@
1SUMMARY = "OFTest"
2DESCRIPTION = "OFTest - an OpenFlow test framework for switches"
3HOMEPAGE = "http://www.projectfloodlight.org/oftest"
4SECTION = "networking"
5LICENSE = "BSD"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=7ad8e1e5f1c3d0004a6d449dbce36efe"
7
8PR = "1"
9PV = "0"
10RDEPENDS_${PN} = "python-scapy"
11
12inherit autotools
13
14SRCREV = "47544e410531732ee3603c5dfd255770009a9d96"
15SRC_URI = "git://github.com/floodlight/oftest \
16 "
17
18S = "${WORKDIR}/git"
19B = "${S}"
20
21PACKAGES = "${PN}"
22FILES_${PN} += "/opt/${PN}"
23
24do_install() {
25 install -d ${D}/opt/${PN}
26 cp -r ${S}/* ${D}/opt/${PN}
27}
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 @@
1This ptest is intended to test DPDK OVS with OFTest framework.
2It requires both DPDK-OVS and OFTest to be installed.
3
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 @@
1#!/bin/sh
2
3export RTE_SDK=/opt/dpdk
4export RTE_TARGET=x86_64-default-linuxapp-gcc
5export RTE_ARCH=x86_64
6RTE_SRC=/usr/src/dpdk
7HUGE_PAGES_MEM=2097152 #[1024 * 2048kB]
8DEVS=("I350" "82599")
9PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py
10OVS_PREFIX=/opt/openvswitchdpdk
11IGB_UIO=$OVS_PREFIX/share/openvswitchdpdk/kmod/igb_uio.ko
12RTE_KNI=$OVS_PREFIX/share/openvswitchdpdk/kmod/rte_kni.ko
13
14#check hugetlbfs mount
15echo -n "Mounting hugepages..."
16mount | grep "nodev on /mnt/huge type hugetlbfs"
17if [ $? -ne 0 ]; then
18 mkdir -p /mnt/huge
19 mount -t hugetlbfs nodev /mnt/huge
20fi
21echo "OK!"
22
23#increase hugepages for all nodes
24echo -n "Allocating hugepages..."
25#get hugepages sizes
26hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"`
27#calculate huge pages number to get the equivalent of 1024 pages of 2MB
28huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}`
29#get hugepages no
30hp=0
31#Find out if this is a NUMA machine
32ls /sys/devices/system/node/node* > /dev/null 2>&1
33if [ $? -ne 0 ]; then
34 hp=`cat /proc/sys/vm/nr_hugepages`
35 hptest=`expr $hp + $huge_pages_no`
36 echo $hptest > /proc/sys/vm/nr_hugepages
37else
38 hparray=()
39 nodes=`ls /sys/devices/system/node | grep node | wc -l`
40 for (( i=0; $i<$nodes; i++ ))
41 do
42 hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages`
43 hptest=`expr $hp + $huge_pages_no`
44 echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages
45 hparray+=("$hp")
46 done
47fi
48echo "OK!"
49echo "Allocated ${huge_pages_no} x ${hp_sz}kB"
50
51#Insert igb_uio and rte_kni modules
52echo "Inserting kernel modules"
53rmmod openvswitch 2>/dev/null
54rmmod -f rte_kni 2>/dev/null
55rmmod -f igb_uio 2>/dev/null
56rmmod -f uio 2>/dev/null
57modprobe uio
58insmod ${IGB_UIO}
59#insert igb_uio, needed by some dpdk tests
60if [ $? -ne 0 ]; then
61 echo "FAIL: uio/igb_uio load"
62 DEVS=()
63else
64 echo "PASS: uio/igb_uio load"
65fi
66
67#insert rte_kni driver in loopback mode, needed by KNI tests
68#insmod ${RTE_KNI} lo_mode=lo_mode_fifo
69insmod ${RTE_KNI}
70
71if [ $? -ne 0 ]; then
72 echo "FAIL: rte_kni load"
73 DEVS=()
74else
75 echo "PASS: rte_kni load"
76fi
77
78#bind devices to igb_uio, needed by dpdk-ovs tests
79search_str=""
80len=${#DEVS[@]}
81tmp=$len
82for dev in ${DEVS[@]}
83do
84 tmp=$[$tmp-1]
85 if [ $tmp -gt 0 ]; then
86 search_str+="${dev}\|"
87 else
88 search_str+=${dev}
89 fi
90done
91
92#Get devices with link and bind to igb_uio
93drvarray=()
94pciarray=()
95tmp=1
96len=`${PCI_UTIL} --status|grep ${search_str}|grep -v -i 'active'|wc -l`
97while [[ $tmp -le $len ]]
98do
99 DEV_INFO=`${PCI_UTIL} --status|grep ${search_str}|grep -v -i 'active'|sed -n ${tmp}p`
100 tmp=$[$tmp+1]
101 DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
102 DEV_ETH=`echo ${DEV_INFO}|grep if=|sed -r "s/.*if=([^ ]*).*/\1/"`
103 if [ "${DEV_ETH}" == "" ]; then
104 echo "Skipping device ${DEV_PCI_ADDR}"
105 continue
106 fi
107 ifconfig ${DEV_ETH} up
108 sleep 1
109 ifconfig ${DEV_ETH}|grep RUNNING>/dev/null
110 if [ $? -ne 0 ]; then
111 echo "Skipping device ${DEV_ETH}"
112 continue
113 fi
114 DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
115 DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
116 pciarray+=("${DEV_PCI_ADDR}")
117 drvarray+=("${DEV_DRV}")
118 echo -n "Binding device ${DEV_PCI_ADDR}..."
119 ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
120 echo "OK!"
121done
122
123# Pre test cleanup
124rm -f $OVS_PREFIX/etc/openvswitch/conf.db
125mkdir -p $OVS_PREFIX/var/run/openvswitch 2>/dev/null
126mkdir -p $OVS_PREFIX/etc/openvswitch 2>/dev/null
127
128# Create OVS schema
129echo -n "Create OVS schema..."
130$OVS_PREFIX/bin/ovsdb-tool create $OVS_PREFIX/etc/openvswitch/conf.db $OVS_PREFIX/share/openvswitch/vswitch.ovsschema
131
132sleep 2
133echo "OK!"
134
135#Start DB server
136echo -n "Start DB server..."
137$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 &
138ovsdb_server_pid=$!
139
140sleep 2
141echo "OK!"
142
143#init DB
144echo -n "Init DB..."
145$OVS_PREFIX/bin/ovs-vsctl --no-wait init
146
147sleep 2
148echo "OK!"
149
150#Configure DB
151echo -n "Configure DB..."
152$OVS_PREFIX/bin/ovs-vsctl --no-wait del-br br0
153$OVS_PREFIX/bin/ovs-vsctl --no-wait add-br br0 -- set Bridge br0 datapath_type=dpdk
154
155#Configure switch to use an OpenFlow controller and disable -n-band management
156$OVS_PREFIX/bin/ovs-vsctl --no-wait set-controller br0 tcp:127.0.0.1:6653
157$OVS_PREFIX/bin/ovs-vsctl --no-wait set Bridge br0 other_config:disable-in-band=true
158
159#Add ports to switch
160$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_64 -- set Interface ovs_dpdk_64 type=dpdkveth ofport_request=64
161$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_65 -- set Interface ovs_dpdk_65 type=dpdkveth ofport_request=65
162$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_66 -- set Interface ovs_dpdk_66 type=dpdkveth ofport_request=66
163$OVS_PREFIX/bin/ovs-vsctl --no-wait add-port br0 ovs_dpdk_67 -- set Interface ovs_dpdk_67 type=dpdkveth ofport_request=67
164
165sleep 2
166echo "OK!"
167
168#Start DPDK OVS
169echo -n "Start DPDK OVS..."
170$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 &
171ovs_dpdk_pid=$!
172
173s=0
174delta=5
175tmo=120
176while [[ $s -lt $tmo ]]
177do
178 echo -n "."
179 sleep $delta
180 if grep --quiet "APP: Client switching core is" ovs_dpdk.log; then
181 echo OK!
182 break
183 fi
184 s=$[$s+$delta]
185done
186
187if [ $s -lt $tmo ]; then
188 echo PASS: Starting DPDK vSwitch
189 #Start DPDK OVS daemon
190 echo -n "Start DPDK OVS daemon..."
191 $OVS_PREFIX/sbin/ovs-vswitchd -c 0x10 --proc-type=secondary > ovs-vswitchd.log 2>&1 &
192 ovs_vswitchd_pid=$!
193 s=0
194 delta=5
195 tmo=120
196 while [[ $s -lt $tmo ]]
197 do
198 echo -n "."
199 sleep $delta
200 if grep --quiet "EAL: Master core" ovs-vswitchd.log; then
201 echo OK!
202 break
203 fi
204 s=$[$s+$delta]
205 done
206
207 if [ $s -lt $tmo ]; then
208 echo PASS: Starting DPDK vSwitch daemon
209 #Cleanup flows
210 $OVS_PREFIX/bin/ovs-ofctl del-flows br0
211 sleep 40
212
213 #Configure all interfaces up and promiscuous
214 ifconfig vEth0 up
215 ifconfig vEth1 up
216 ifconfig vEth2 up
217 ifconfig vEth3 up
218 ifconfig vEth0 promisc
219 #ifconfig vEth1 promisc
220 #ifconfig vEth2 promisc
221 #ifconfig vEth3 promisc
222 tcpdump -i vEth0 &
223 #tcpdump -i vEth2 &
224 #tcpdump -i vEth3 &
225
226 #Start OFTest
227 echo -n "Start OFTest..."
228 cd /opt/oftest/
229 ./oft -i 64@vEth0 -i 65@vEth1 -i 66@vEth2 -i 67@vEth3 flow_matches 2>&1 | \
230 grep "\.\.\." | sed -r "s/(.*) ... (FAIL)/\2: \1/" | sed -r "s/(.*) ... (ok)/PASS: \1/"
231
232 sleep 2
233 echo "Kill processes..."
234 kill -9 $ovs_vswitchd_pid 2>&1 > /dev/null
235 sleep 1
236 else
237 echo NOK!
238 echo FAIL: Starting DPDK vSwitch daemon
239 cd /opt/oftest/
240 ./oft --list-test-names | sed -r "s/(.*)/SKIP: \1/"
241 echo "Kill processes..."
242 fi
243else
244 echo NOK!
245 echo FAIL: Starting DPDK vSwitch
246 cd /opt/oftest/
247 ./oft --list-test-names | sed -r "s/(.*)/SKIP: \1/"
248 echo "Kill processes..."
249fi
250
251kill -9 $ovs_dpdk_pid 2>&1 > /dev/null
252sleep 1
253kill -9 $ovsdb_server_pid 2>&1 > /dev/null
254sleep 1
255
256#bind devices to initial drivers
257for ((i=0;i<${#pciarray[@]};i++));
258do
259 echo -n "Restoring device ${pciarray[$i]} ..."
260 ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}
261 echo "OK!"
262done
263
264rmmod rte_kni
265rmmod igb_uio
266
267echo -n "Freeing hugepages..."
268#Find out if this is a NUMA machine
269ls /sys/devices/system/node/node* > /dev/null 2>&1
270if [ $? -ne 0 ]; then
271 echo $hp > /proc/sys/vm/nr_hugepages
272else
273 i=0
274 for hp in ${hparray[@]}
275 do
276 echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages"
277 ((i++))
278 done
279fi
280echo "OK!"
281rm -rf /mnt/huge/*
282
283echo "Test done!"
284
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 @@
1SUMMARY = "DPDK vSwitch - OFTest"
2DESCRIPTION = "OFTest based testing for DPDK vSwitch"
3LICENSE = "BSD"
4LIC_FILES_CHKSUM = "file://README;md5=6b96a2f1b1ba742aadcc58002f3e9351 \
5 "
6RDEPENDS_${PN} = "oftest openvswitchdpdk dpdk python-scapy"
7
8PR = "r0"
9PV = "1.0"
10
11SRC_REV = "1.0-r0"
12SRC_URI = "file://README \
13 file://run-ptest \
14 "
15
16S = "${WORKDIR}"
17B = "${S}"
18
19inherit ptest
20