diff options
Diffstat (limited to 'recipes-test/openvswitchdpdk-oftest')
-rw-r--r-- | recipes-test/openvswitchdpdk-oftest/files/README | 3 | ||||
-rw-r--r-- | recipes-test/openvswitchdpdk-oftest/files/run-ptest | 284 | ||||
-rw-r--r-- | recipes-test/openvswitchdpdk-oftest/openvswitchdpdk-oftest.bb | 20 |
3 files changed, 307 insertions, 0 deletions
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 @@ | |||
1 | This ptest is intended to test DPDK OVS with OFTest framework. | ||
2 | It 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 | |||
3 | export RTE_SDK=/opt/dpdk | ||
4 | export RTE_TARGET=x86_64-default-linuxapp-gcc | ||
5 | export RTE_ARCH=x86_64 | ||
6 | RTE_SRC=/usr/src/dpdk | ||
7 | HUGE_PAGES_MEM=2097152 #[1024 * 2048kB] | ||
8 | DEVS=("I350" "82599") | ||
9 | PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py | ||
10 | OVS_PREFIX=/opt/openvswitchdpdk | ||
11 | IGB_UIO=$OVS_PREFIX/share/openvswitchdpdk/kmod/igb_uio.ko | ||
12 | RTE_KNI=$OVS_PREFIX/share/openvswitchdpdk/kmod/rte_kni.ko | ||
13 | |||
14 | #check hugetlbfs mount | ||
15 | echo -n "Mounting hugepages..." | ||
16 | mount | grep "nodev on /mnt/huge type hugetlbfs" | ||
17 | if [ $? -ne 0 ]; then | ||
18 | mkdir -p /mnt/huge | ||
19 | mount -t hugetlbfs nodev /mnt/huge | ||
20 | fi | ||
21 | echo "OK!" | ||
22 | |||
23 | #increase hugepages for all nodes | ||
24 | echo -n "Allocating hugepages..." | ||
25 | #get hugepages sizes | ||
26 | hp_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 | ||
28 | huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}` | ||
29 | #get hugepages no | ||
30 | hp=0 | ||
31 | #Find out if this is a NUMA machine | ||
32 | ls /sys/devices/system/node/node* > /dev/null 2>&1 | ||
33 | if [ $? -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 | ||
37 | else | ||
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 | ||
47 | fi | ||
48 | echo "OK!" | ||
49 | echo "Allocated ${huge_pages_no} x ${hp_sz}kB" | ||
50 | |||
51 | #Insert igb_uio and rte_kni modules | ||
52 | echo "Inserting kernel modules" | ||
53 | rmmod openvswitch 2>/dev/null | ||
54 | rmmod -f rte_kni 2>/dev/null | ||
55 | rmmod -f igb_uio 2>/dev/null | ||
56 | rmmod -f uio 2>/dev/null | ||
57 | modprobe uio | ||
58 | insmod ${IGB_UIO} | ||
59 | #insert igb_uio, needed by some dpdk tests | ||
60 | if [ $? -ne 0 ]; then | ||
61 | echo "FAIL: uio/igb_uio load" | ||
62 | DEVS=() | ||
63 | else | ||
64 | echo "PASS: uio/igb_uio load" | ||
65 | fi | ||
66 | |||
67 | #insert rte_kni driver in loopback mode, needed by KNI tests | ||
68 | #insmod ${RTE_KNI} lo_mode=lo_mode_fifo | ||
69 | insmod ${RTE_KNI} | ||
70 | |||
71 | if [ $? -ne 0 ]; then | ||
72 | echo "FAIL: rte_kni load" | ||
73 | DEVS=() | ||
74 | else | ||
75 | echo "PASS: rte_kni load" | ||
76 | fi | ||
77 | |||
78 | #bind devices to igb_uio, needed by dpdk-ovs tests | ||
79 | search_str="" | ||
80 | len=${#DEVS[@]} | ||
81 | tmp=$len | ||
82 | for dev in ${DEVS[@]} | ||
83 | do | ||
84 | tmp=$[$tmp-1] | ||
85 | if [ $tmp -gt 0 ]; then | ||
86 | search_str+="${dev}\|" | ||
87 | else | ||
88 | search_str+=${dev} | ||
89 | fi | ||
90 | done | ||
91 | |||
92 | #Get devices with link and bind to igb_uio | ||
93 | drvarray=() | ||
94 | pciarray=() | ||
95 | tmp=1 | ||
96 | len=`${PCI_UTIL} --status|grep ${search_str}|grep -v -i 'active'|wc -l` | ||
97 | while [[ $tmp -le $len ]] | ||
98 | do | ||
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!" | ||
121 | done | ||
122 | |||
123 | # Pre test cleanup | ||
124 | rm -f $OVS_PREFIX/etc/openvswitch/conf.db | ||
125 | mkdir -p $OVS_PREFIX/var/run/openvswitch 2>/dev/null | ||
126 | mkdir -p $OVS_PREFIX/etc/openvswitch 2>/dev/null | ||
127 | |||
128 | # Create OVS schema | ||
129 | echo -n "Create OVS schema..." | ||
130 | $OVS_PREFIX/bin/ovsdb-tool create $OVS_PREFIX/etc/openvswitch/conf.db $OVS_PREFIX/share/openvswitch/vswitch.ovsschema | ||
131 | |||
132 | sleep 2 | ||
133 | echo "OK!" | ||
134 | |||
135 | #Start DB server | ||
136 | echo -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 & | ||
138 | ovsdb_server_pid=$! | ||
139 | |||
140 | sleep 2 | ||
141 | echo "OK!" | ||
142 | |||
143 | #init DB | ||
144 | echo -n "Init DB..." | ||
145 | $OVS_PREFIX/bin/ovs-vsctl --no-wait init | ||
146 | |||
147 | sleep 2 | ||
148 | echo "OK!" | ||
149 | |||
150 | #Configure DB | ||
151 | echo -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 | |||
165 | sleep 2 | ||
166 | echo "OK!" | ||
167 | |||
168 | #Start DPDK OVS | ||
169 | echo -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 & | ||
171 | ovs_dpdk_pid=$! | ||
172 | |||
173 | s=0 | ||
174 | delta=5 | ||
175 | tmo=120 | ||
176 | while [[ $s -lt $tmo ]] | ||
177 | do | ||
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] | ||
185 | done | ||
186 | |||
187 | if [ $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 | ||
243 | else | ||
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..." | ||
249 | fi | ||
250 | |||
251 | kill -9 $ovs_dpdk_pid 2>&1 > /dev/null | ||
252 | sleep 1 | ||
253 | kill -9 $ovsdb_server_pid 2>&1 > /dev/null | ||
254 | sleep 1 | ||
255 | |||
256 | #bind devices to initial drivers | ||
257 | for ((i=0;i<${#pciarray[@]};i++)); | ||
258 | do | ||
259 | echo -n "Restoring device ${pciarray[$i]} ..." | ||
260 | ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]} | ||
261 | echo "OK!" | ||
262 | done | ||
263 | |||
264 | rmmod rte_kni | ||
265 | rmmod igb_uio | ||
266 | |||
267 | echo -n "Freeing hugepages..." | ||
268 | #Find out if this is a NUMA machine | ||
269 | ls /sys/devices/system/node/node* > /dev/null 2>&1 | ||
270 | if [ $? -ne 0 ]; then | ||
271 | echo $hp > /proc/sys/vm/nr_hugepages | ||
272 | else | ||
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 | ||
279 | fi | ||
280 | echo "OK!" | ||
281 | rm -rf /mnt/huge/* | ||
282 | |||
283 | echo "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 @@ | |||
1 | SUMMARY = "DPDK vSwitch - OFTest" | ||
2 | DESCRIPTION = "OFTest based testing for DPDK vSwitch" | ||
3 | LICENSE = "BSD" | ||
4 | LIC_FILES_CHKSUM = "file://README;md5=6b96a2f1b1ba742aadcc58002f3e9351 \ | ||
5 | " | ||
6 | RDEPENDS_${PN} = "oftest openvswitchdpdk dpdk python-scapy" | ||
7 | |||
8 | PR = "r0" | ||
9 | PV = "1.0" | ||
10 | |||
11 | SRC_REV = "1.0-r0" | ||
12 | SRC_URI = "file://README \ | ||
13 | file://run-ptest \ | ||
14 | " | ||
15 | |||
16 | S = "${WORKDIR}" | ||
17 | B = "${S}" | ||
18 | |||
19 | inherit ptest | ||
20 | |||