summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2014-06-26 13:48:23 +0200
committerAdrian Dudau <adrian.dudau@enea.com>2014-06-26 13:48:23 +0200
commit1b6242fc583a6b871304fb995af6dc211b58f69b (patch)
treeb5d434d90dedae24792906aa304897c23a134386
downloadmeta-ip-1b6242fc583a6b871304fb995af6dc211b58f69b.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>
-rw-r--r--README41
-rw-r--r--conf/layer.conf13
-rw-r--r--images-append/enea-image-demo.bbappend3
-rw-r--r--images-append/enea-image-test-bash.bbappend5
-rw-r--r--recipes-append/pciutils/pciutils_3.2.1.bbappend8
-rw-r--r--recipes-core/numactl/numactl-2.0.9/Makefile.patch63
-rwxr-xr-xrecipes-core/numactl/numactl-2.0.9/regress1-parser63
-rwxr-xr-xrecipes-core/numactl/numactl-2.0.9/run-ptest5
-rw-r--r--recipes-core/numactl/numactl_2.0.9.bb52
-rw-r--r--recipes-core/numad/numad-0.6/Makefile.patch50
-rw-r--r--recipes-core/numad/numad-0.6/numad.conf.patch14
-rw-r--r--recipes-core/numad/numad-0.6/numad.init.patch85
-rwxr-xr-xrecipes-core/numad/numad-0.6/run-ptest20
-rw-r--r--recipes-core/numad/numad-0.6/test.patch175
-rw-r--r--recipes-core/numad/numad_0.6.bb51
-rw-r--r--recipes-core/packagegroups/packagegroup-enea-ip.bb18
-rw-r--r--recipes-kernel/linux/linux-yocto_3.10.bbappend4
-rw-r--r--recipes-kernel/linux/linux-yocto_3.14.bbappend4
-rw-r--r--recipes-networking/dpdk/dpdk_git.bb139
-rw-r--r--recipes-networking/dpdk/files/igb_ethdev_loopback.patch96
-rw-r--r--recipes-networking/dpdk/files/l2fwd-lpbk/Makefile51
-rw-r--r--recipes-networking/dpdk/files/l2fwd-lpbk/main.c929
-rw-r--r--recipes-networking/dpdk/files/l2fwd-lpbk/main.h45
-rw-r--r--recipes-networking/dpdk/files/machine-flags.patch12
-rw-r--r--recipes-networking/dpdk/files/maketest.patch41
-rw-r--r--recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x206
-rw-r--r--recipes-networking/dpdk/files/run-ptest195
-rw-r--r--recipes-networking/dpdk/files/runtest.patch20
-rw-r--r--recipes-networking/dpdk/files/unbreak-makefiles.patch87
-rw-r--r--recipes-networking/openvswitchdpdk/files/0001-openvswitchdpdk-enabled-ptest.patch380
-rw-r--r--recipes-networking/openvswitchdpdk/files/configure-fix.patch12
-rw-r--r--recipes-networking/openvswitchdpdk/files/makefile-install-rule.patch22
-rwxr-xr-xrecipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller279
-rw-r--r--recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller-setup29
-rw-r--r--recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch110
-rw-r--r--recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch-setup16
-rw-r--r--recipes-networking/openvswitchdpdk/files/ovs-ctl-dpdk.patch123
-rw-r--r--recipes-networking/openvswitchdpdk/files/qemu-makefile.patch26
-rw-r--r--recipes-networking/openvswitchdpdk/files/qemu-options-hx.patch30
-rw-r--r--recipes-networking/openvswitchdpdk/files/qemu-pixman-config.patch26
-rw-r--r--recipes-networking/openvswitchdpdk/files/run-ptest8
-rw-r--r--recipes-networking/openvswitchdpdk/openvswitchdpdk_0.10.0.bb248
-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
46 files changed, 4138 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..c2593c0
--- /dev/null
+++ b/README
@@ -0,0 +1,41 @@
1Enea Linux IP support
2=================================
3
4This layer provides IP support and related tools to Enea Linux.
5
6Supported Platforms
7-------------------
8
9
10Dependencies
11------------
12meta-enea:
13 URI: git://git.enea.com/linux/meta-enea.git
14 branch: master
15
16meta-virtualization:
17 URI: git://git.yoctoproject.org/meta-virtualization
18 branch: master
19
20meta-openembedded:
21 URI: git://git.openembedded.org/meta-openembedded
22 branch: master
23 layers: meta-oe
24 meta-networking
25 meta-filesystems
26
27meta-eca:
28 URI git://git.yoctoproject.org/meta-eca
29 branch: master
30 layers: meta-eca
31
32Maintenance
33-----------
34
35Maintainers: Enea Linux <linux@enea.com>
36
37
38License
39-------
40
41Same as meta-enea
diff --git a/conf/layer.conf b/conf/layer.conf
new file mode 100644
index 0000000..23f4c8e
--- /dev/null
+++ b/conf/layer.conf
@@ -0,0 +1,13 @@
1# We have a packages directory, add to BBFILES
2BBPATH .= ":${LAYERDIR}"
3
4BBFILES += "${LAYERDIR}/recipes-*/*/*.bb*"
5BBFILES += "${LAYERDIR}/images/*.bb*"
6BBFILES += "${LAYERDIR}/images-append/*.bb*"
7
8BBFILE_COLLECTIONS += "enea-ip"
9BBFILE_PATTERN_enea-ip := "^${LAYERDIR}/"
10BBFILE_PRIORITY_enea-ip = "7"
11LAYERDEPENDS_enea-ip = "enea"
12
13BB_DANGLINGAPPENDS_WARNONLY = "yes"
diff --git a/images-append/enea-image-demo.bbappend b/images-append/enea-image-demo.bbappend
new file mode 100644
index 0000000..39c0377
--- /dev/null
+++ b/images-append/enea-image-demo.bbappend
@@ -0,0 +1,3 @@
1IMAGE_INSTALL += " \
2 packagegroup-enea-ip \
3 "
diff --git a/images-append/enea-image-test-bash.bbappend b/images-append/enea-image-test-bash.bbappend
new file mode 100644
index 0000000..900e60c
--- /dev/null
+++ b/images-append/enea-image-test-bash.bbappend
@@ -0,0 +1,5 @@
1IMAGE_FSTYPES += "cpio.gz"
2
3IMAGE_INSTALL += " \
4 packagegroup-enea-ip \
5 "
diff --git a/recipes-append/pciutils/pciutils_3.2.1.bbappend b/recipes-append/pciutils/pciutils_3.2.1.bbappend
new file mode 100644
index 0000000..67d18b3
--- /dev/null
+++ b/recipes-append/pciutils/pciutils_3.2.1.bbappend
@@ -0,0 +1,8 @@
1#use this instead of busybox.lspci
2
3inherit update-alternatives
4
5ALTERNATIVE_${PN} += "lspci"
6ALTERNATIVE_LINK_NAME[lspci] = "/usr/bin/lspci"
7ALTERNATIVE_TARGET[lspci] = "/usr/sbin/lspci"
8ALTERNATIVE_PRIORITY[lspci] = "100"
diff --git a/recipes-core/numactl/numactl-2.0.9/Makefile.patch b/recipes-core/numactl/numactl-2.0.9/Makefile.patch
new file mode 100644
index 0000000..3c6d3e2
--- /dev/null
+++ b/recipes-core/numactl/numactl-2.0.9/Makefile.patch
@@ -0,0 +1,63 @@
1Add 'test-install' rule.
2Do not use getlibdir for 'prefix' variable.
3Echo 'SKIP' result for ptest when run on sigle node machine.
4
5Signed-off-by: Radu Patriu <radu.patriu@enea.com>
6Upstream-Status: Pending
7
8Index: numactl-2.0.9-orig/Makefile
9===================================================================
10--- numactl-2.0.9-orig.orig/Makefile 2013-10-09 00:34:57.000000000 +0300
11+++ numactl-2.0.9-orig/Makefile 2014-02-07 20:27:21.951902184 +0200
12@@ -42,7 +42,7 @@
13 else
14 prefix := $(PREFIX)
15 endif
16-libdir := ${prefix}/$(shell ./getlibdir)
17+libdir := ${prefix}/lib
18 docdir := ${prefix}/share/doc
19
20 all: numactl migratepages migspeed libnuma.so numademo numamon memhog \
21@@ -197,9 +197,9 @@
22 .depend:
23 ${CC} -MM -DDEPS_RUN -I. ${SOURCES} > .depend.X && mv .depend.X .depend
24
25-include .depend
26+# include .depend
27
28-Makefile: .depend
29+# Makefile: .depend
30
31 .PHONY: test regress1 regress2
32
33@@ -215,3 +215,18 @@
34
35 # test: all regress1 regress2 test_numademo regress3
36 test: all regress1 regress2 test_numademo
37+
38+TEST_DESTDIR ?= ${prefix}/lib/numactl/ptest
39+TEST_FILES = bind_range distance migrate_pages nodemap prefered README regress2 shmtest \
40+ checkaffinity ftok move_pages node-parse printcpu realloc_test regress-io tbitmap \
41+ checktopology mbind_mig_pages mynode pagesize randmap regress runltp tshared
42+TEST_FRAME = Makefile getlibdir numactl numademo
43+
44+test-install:
45+ install -d ${TEST_DESTDIR}/test
46+ for file in ${TEST_FILES}; do \
47+ install test/$${file} ${TEST_DESTDIR}/test; \
48+ done
49+ for file in ${TEST_FRAME}; do \
50+ install $${file} ${TEST_DESTDIR}; \
51+ done
52Index: numactl-2.0.9-orig/test/regress
53===================================================================
54--- numactl-2.0.9-orig.orig/test/regress 2013-10-09 00:34:58.000000000 +0300
55+++ numactl-2.0.9-orig/test/regress 2014-02-07 20:27:01.151901373 +0200
56@@ -73,6 +73,7 @@
57 if [ $numnodes -lt 2 ] ; then
58 echo "need at least two nodes with at least $NEEDPAGES each of"
59 echo "free memory for mempolicy regression tests"
60+ echo '========SKIP'
61 exit 1
62 fi
63 }
diff --git a/recipes-core/numactl/numactl-2.0.9/regress1-parser b/recipes-core/numactl/numactl-2.0.9/regress1-parser
new file mode 100755
index 0000000..d8e9dea
--- /dev/null
+++ b/recipes-core/numactl/numactl-2.0.9/regress1-parser
@@ -0,0 +1,63 @@
1#!/bin/sh
2
3test_pattern="=>testing "
4test_fail="==FAILED"
5test_skip="==SKIP"
6test_log="regress1.log"
7test_suite="regress1"
8
9test_name=""
10failed="0"
11skiped="0"
12
13while read line
14do
15 substring=${line#$test_pattern*}
16# echo "sub>"$substring"<"
17 if [ "$substring" != "$line" ];
18 then
19 if [ "$test_name" != "" ];
20 then
21 if [ "$failed" = "1" ];
22 then
23 echo "FAIL: $test_name"
24 else
25 echo "PASS: $test_name"
26 fi
27 fi
28 test_name=$substring
29# echo "name>"$test_name"<"
30 failed="0"
31 fi
32
33 if [ "${line#*$test_fail}" != "$line" ];
34 then
35 failed="1"
36 fi
37
38 if [ "${line#*$test_skip}" != "$line" ];
39 then
40 skiped="1"
41 fi
42
43done < $test_log
44
45if [ "$skiped" = "1" ];
46then
47 echo "SKIP: $test_suite"
48 exit 1
49fi
50
51
52if [ "$test_name" = "" ];
53then
54 echo "FAIL: $test_suite"
55 exit 1
56fi
57
58if [ "$failed" = "1" ];
59then
60 echo "FAIL: $test_name"
61else
62 echo "PASS: $test_name"
63fi
diff --git a/recipes-core/numactl/numactl-2.0.9/run-ptest b/recipes-core/numactl/numactl-2.0.9/run-ptest
new file mode 100755
index 0000000..1d5292e
--- /dev/null
+++ b/recipes-core/numactl/numactl-2.0.9/run-ptest
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3make regress1 >regress1.log 2>&1
4./regress1-parser
5make -k regress2 >regress2.log 2>&1 && echo "PASS: regress2" || echo "FAIL: regress2"
diff --git a/recipes-core/numactl/numactl_2.0.9.bb b/recipes-core/numactl/numactl_2.0.9.bb
new file mode 100644
index 0000000..a7fee35
--- /dev/null
+++ b/recipes-core/numactl/numactl_2.0.9.bb
@@ -0,0 +1,52 @@
1SUMMARY = "Simple NUMA policy support"
2DESCRIPTION = 'It consists of a numactl program to run \
3other programs with a specific NUMA policy and a libnuma shared library \
4("NUMA API") to set NUMA policy in applications.'
5HOMEPAGE = "http://oss.sgi.com/projects/libnuma/"
6SECTION = "console/utils"
7
8RDEPENDS_numactl = "libnuma"
9
10LICENSE = "GPLv2 & LGPLv2.1"
11LICENSE_libnuma = "GPLv2"
12LICENSE_numactl = "LGPLv2.1"
13
14LIC_FILES_CHKSUM = "file://libnuma.c;beginline=1;endline=17;md5=17362df5a5de121a289afcac0d30a9c6 \
15 file://numactl.c;beginline=1;endline=16;md5=0c0a67367b1246f7643d6bc2bfe469de"
16
17SRC_URI = "ftp://oss.sgi.com/www/projects/libnuma/download/numactl-2.0.9.tar.gz \
18 file://Makefile.patch \
19 file://regress1-parser \
20 file://run-ptest"
21
22SRC_URI[md5sum] = "136685c8eaf9d6569c351fe1d453b30c"
23SRC_URI[sha256sum] = "9ca033e6c14c0f26c20379b0cf9299429fd5a354a79c3c7880fd41ef69f7751c"
24
25S = "${WORKDIR}/numactl-${PV}"
26
27EXTRA_OEMAKE = "PREFIX=${D}/usr TEST_DESTDIR=${D}${PTEST_PATH}"
28
29do_install () {
30 oe_runmake install
31 rmdir ${D}/usr/share/man/man2
32}
33
34PACKAGES = "libnuma-dbg ${PN}-dbg ${PN} ${PN}-doc libnuma-staticdev libnuma libnuma-dev libnuma-doc"
35
36FILES_libnuma-dbg = "${libdir}/.debug"
37FILES_libnuma-staticdev = "${libdir}/*.a"
38FILES_libnuma = "${libdir}/libnuma.so.*"
39FILES_libnuma-dev = "${libdir} ${includedir}"
40FILES_libnuma-doc = "${mandir}/man3"
41
42FILES_${PN}-dbg = "${bindir}/.debug /usr/src/debug"
43FILES_${PN} = "${bindir}"
44FILES_${PN}-doc = "${mandir}/man8"
45
46inherit ptest
47RDEPENDS_${PN}-ptest += "make"
48
49do_install_ptest () {
50 oe_runmake test-install
51 install ${WORKDIR}/regress1-parser ${D}${PTEST_PATH}
52}
diff --git a/recipes-core/numad/numad-0.6/Makefile.patch b/recipes-core/numad/numad-0.6/Makefile.patch
new file mode 100644
index 0000000..f6a564d
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/Makefile.patch
@@ -0,0 +1,50 @@
1Add 'test-install' rule.
2Allow 'prefix' variable to be overloaded.
3
4Signed-off-by: Radu Patriu <radu.patriu@enea.com>
5Upstream-Status: Pending
6
7Index: numad/Makefile
8===================================================================
9--- numad.orig/Makefile 2014-05-13 00:17:16.094991993 +0300
10+++ numad/Makefile 2014-05-13 00:22:22.318986948 +0300
11@@ -22,21 +22,23 @@
12 BENCH_CFLAGS += -ftree-vectorize
13 endif
14
15-CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o
16+CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o test.o test
17
18-SOURCES := numad.c
19+SOURCES := numad.c test.c
20
21-prefix := /usr
22+prefix ?= /usr
23 docdir := ${prefix}/share/doc
24
25 all: numad
26
27 numad: numad.o -lpthread -lrt
28
29+test: test.o -lnuma
30+
31 AR ?= ar
32 RANLIB ?= ranlib
33
34-.PHONY: install all clean html depend
35+.PHONY: install all clean html depend -lpthread -lrt -lnuma
36
37 # BB_FIXME MANPAGES := numa.3 numactl.8 numastat.8 migratepages.8 migspeed.8
38
39@@ -46,6 +48,11 @@
40 install -m 0755 numad ${prefix}/bin
41 install -m 0644 numad.8 ${prefix}/share/man/man8
42
43+TEST_DESTDIR ?= ${prefix}/lib/numad/ptest
44+test-install: test
45+ install -d ${TEST_DESTDIR}
46+ install test ${TEST_DESTDIR}
47+
48 clean:
49 rm -f ${CLEANFILES}
50 @rm -rf html
diff --git a/recipes-core/numad/numad-0.6/numad.conf.patch b/recipes-core/numad/numad-0.6/numad.conf.patch
new file mode 100644
index 0000000..0b63ca0
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/numad.conf.patch
@@ -0,0 +1,14 @@
1Add DIRECTORY_MOUNT_POINT to configuration file.
2
3Signed-off-by: Radu Patriu <radu.patriu@enea.com>
4Upstream-Status: Pending
5
6Index: numad/numad.conf
7===================================================================
8--- numad.orig/numad.conf 2014-03-13 17:12:38.000000000 +0200
9+++ numad/numad.conf 2014-03-13 17:40:39.417851081 +0200
10@@ -3,3 +3,4 @@
11 # Default INTERVAL is 15
12 # modify below to change it
13 INTERVAL=15
14+DIRECTORY_MOUNT_POINT="/sys/fs/cgroup/cpuset"
diff --git a/recipes-core/numad/numad-0.6/numad.init.patch b/recipes-core/numad/numad-0.6/numad.init.patch
new file mode 100644
index 0000000..c95f8d6
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/numad.init.patch
@@ -0,0 +1,85 @@
1Fix source functions path.
2Use start-stop-daemon.
3
4Signed-off-by: Radu Patriu <radu.patriu@enea.com>
5Upstream-Status: Pending
6
7Index: numad/numad.init
8===================================================================
9--- numad.orig/numad.init 2014-03-13 15:27:26.000000000 +0200
10+++ numad/numad.init 2014-03-13 16:39:13.089952014 +0200
11@@ -6,13 +6,13 @@
12 ### BEGIN INIT INFO
13 # Provides: numad
14 # Required-Start: cgconfig
15-# Required-Stop:
16-# Should-Start:
17-# Should-Stop:
18-# Default-Start:
19-# Default-Stop:
20+# Required-Stop:
21+# Should-Start:
22+# Should-Stop:
23+# Default-Start:
24+# Default-Stop:
25 # Short-Description: numad control
26-# Description:
27+# Description:
28 ### END INIT INFO
29
30 if [ $(id -u) -ne 0 ]; then
31@@ -21,7 +21,7 @@
32 fi
33
34 # Source function library.
35-. /etc/rc.d/init.d/functions
36+. /etc/init.d/functions
37
38 exec="/usr/bin/numad"
39 prog="numad"
40@@ -29,32 +29,36 @@
41
42 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
43
44-lockfile=/var/lock/subsys/$prog
45-base=${0##*/}
46-
47 start() {
48 [ -x $exec ] || exit 5
49 [ -f $config ] || exit 6
50 echo -n $"Starting $prog: "
51 . $config
52- daemon "$exec -i $INTERVAL"
53+ start-stop-daemon --start --quiet --exec $exec -- -i $INTERVAL -D $DIRECTORY_MOUNT_POINT
54 retval=$?
55- echo
56- [ $retval -eq 0 ] && touch $lockfile
57+ if [ $retval -eq 0 ] ; then
58+ echo "OK"
59+ else
60+ echo "FAIL"
61+ fi
62 return $retval
63 }
64
65 stop() {
66 echo -n $"Stopping $prog: "
67- killproc $prog
68+ start-stop-daemon --stop --quiet --exec $exec
69 retval=$?
70- echo
71- [ $retval -eq 0 ] && rm -f $lockfile
72+ if [ $retval -eq 0 ] ; then
73+ echo "OK"
74+ else
75+ echo "FAIL"
76+ fi
77 return $retval
78 }
79
80 restart() {
81 stop
82+ sleep 1
83 start
84 }
85
diff --git a/recipes-core/numad/numad-0.6/run-ptest b/recipes-core/numad/numad-0.6/run-ptest
new file mode 100755
index 0000000..5c49181
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/run-ptest
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3CPUSET_PATH="/tmp/numad-cpuset"
4
5/etc/init.d/numad.init status
6STATUS=$?
7/etc/init.d/numad.init stop
8mkdir $CPUSET_PATH; mount -t cgroup -ocpuset cpuset $CPUSET_PATH
9./test 2>&1&
10TEST_PID=$!
11sleep 2
12numad -d -S 0 -u 50 -i 5:5 -p $TEST_PID -D $CPUSET_PATH
13wait
14numad -i 0
15sleep 1
16umount $CPUSET_PATH ; rmdir $CPUSET_PATH
17if [ "$STATUS" = "0" ]; then
18 /etc/init.d/numad.init start
19fi
20
diff --git a/recipes-core/numad/numad-0.6/test.patch b/recipes-core/numad/numad-0.6/test.patch
new file mode 100644
index 0000000..762790c
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/test.patch
@@ -0,0 +1,175 @@
1Test output format: ptest style (PASS, FAIL, SKIP)
2Description: Allocate memory from a node other than
3the current CPU is running on. Wait for numad to modify
4memory and CPU policy binding the process to run and allocate on
5the same node.
6Dependencies: libnuma
7
8Signed-off-by: Radu Patriu <radu.patriu@enea.com>
9Upstream-Status: Pending
10
11Index: numa-test/test.c
12===================================================================
13--- /dev/null 1970-01-01 00:00:00.000000000 +0000
14+++ numa-test/test.c 2014-02-18 17:22:49.952290472 +0200
15@@ -0,0 +1,160 @@
16+#define _GNU_SOURCE
17+#include <sched.h>
18+#include <stdio.h>
19+#include <unistd.h>
20+#include <ctype.h>
21+#include <sys/time.h>
22+#include <sched.h>
23+#include <numa.h>
24+
25+#define TIMEOUT (1000 * 60) /*60 seconds*/
26+#define LOOP_TIME (1000 * 5) /*5 seconds*/
27+#define MEM_POLICY_CHANGED 1
28+#define NODE_POLICY_CHANGED 2
29+#define TEST_DONE (MEM_POLICY_CHANGED | NODE_POLICY_CHANGED)
30+
31+#define TEST_PASS 0
32+#define TEST_FAIL 1
33+#define TEST_SKIP 2
34+
35+#define MEM_SIZE 0.3 /* 30 % node memory */
36+
37+unsigned int numa_bitmask_weight(const struct bitmask *bmp);
38+
39+void print_bitmask(struct bitmask *mask)
40+{
41+ /*assume 32 max nodes*/
42+ printf("0x%08lx", *(mask->maskp));
43+}
44+
45+int test()
46+{
47+ int i, j, total_nodes, total_mem_nodes, total_cpus, prefered_node;
48+ struct bitmask *allowed_mem_nodes, *allowed_nodes, *cpu_mask, *mem_bind, *bit_mask;
49+ long long mem_size, page_size;
50+ unsigned char *mem;
51+ struct timeval start, end, res;
52+ int local_node, local_cpu, other_node, test_complete;
53+
54+ allowed_mem_nodes = numa_allocate_nodemask();
55+ allowed_nodes = numa_allocate_nodemask();
56+ mem_bind = numa_allocate_nodemask();
57+ cpu_mask = numa_allocate_cpumask();
58+ if (!(allowed_mem_nodes && allowed_nodes && mem_bind && cpu_mask)) {
59+ printf("Error: numa_allocate failed\n");
60+ return TEST_FAIL;
61+ }
62+
63+ total_nodes = numa_max_node() + 1;
64+ printf("total_nodes %d\n", total_nodes);
65+
66+ total_mem_nodes = numa_num_configured_nodes();
67+ printf("total_mem_nodes %d\n", total_mem_nodes);
68+
69+ total_cpus = numa_num_configured_cpus();
70+ printf("total_cpus %d\n", total_cpus);
71+
72+ page_size = numa_pagesize();
73+ printf("page_size %llu\n", page_size);
74+
75+ i = 0;
76+ test_complete = 0;
77+ gettimeofday(&start, NULL);
78+ do {
79+ printf("\n\n\nLoop %d\n", i);
80+
81+ bit_mask = numa_get_mems_allowed();
82+ if (i && !numa_bitmask_equal(bit_mask, allowed_mem_nodes)) {
83+ printf("\nInfo: memory policy modified\n\n");
84+ test_complete |= MEM_POLICY_CHANGED;
85+ }
86+ copy_bitmask_to_bitmask(bit_mask, allowed_mem_nodes);
87+ printf("allowed_mem_nodes "); print_bitmask(allowed_mem_nodes); printf("\n");
88+ if ((0 == i) && (1 == numa_bitmask_weight(allowed_mem_nodes))) {
89+ printf("Error: need at least two memory nodes\n");
90+ return TEST_SKIP;
91+ }
92+
93+ bit_mask = numa_get_run_node_mask();
94+ if (i && !numa_bitmask_equal(bit_mask, allowed_nodes)) {
95+ printf("\nInfo: node/cpu policy modified\n\n");
96+ test_complete |= NODE_POLICY_CHANGED;
97+ }
98+ copy_bitmask_to_bitmask(bit_mask, allowed_nodes);
99+ printf("allowed_nodes "); print_bitmask(allowed_nodes); printf("\n");
100+
101+ prefered_node = numa_preferred();
102+ printf("prefered_node %d\n", prefered_node);
103+
104+ bit_mask = numa_get_membind();
105+ copy_bitmask_to_bitmask(bit_mask, mem_bind);
106+ printf("mem_bind "); print_bitmask(mem_bind); printf("\n");
107+
108+ if (numa_sched_getaffinity(0, cpu_mask) < 0) {
109+ printf("Error: numa_sched_getaffinity failed\n");
110+ return TEST_FAIL;
111+ }
112+ printf("sched_affinity "); print_bitmask(cpu_mask); printf("\n");
113+
114+ other_node = -1;
115+ local_cpu = sched_getcpu();
116+ local_node = numa_node_of_cpu(local_cpu);
117+ for (j = 0; j < total_mem_nodes; ++j)
118+ if (numa_bitmask_isbitset(allowed_mem_nodes, j) && (j != local_node))
119+ other_node = j;
120+
121+ printf("running on node %d, cpu %d\n", local_node, local_cpu);
122+ printf("alloc memory from node %d\n", other_node);
123+
124+ mem_size = numa_node_size64(other_node, NULL) * MEM_SIZE;
125+ printf("test_mem_size %llu\n", mem_size);
126+
127+ /* avoid mbind: Invalid argument */
128+ if (TEST_DONE == test_complete)
129+ return TEST_PASS;
130+
131+ mem = numa_alloc_onnode(mem_size, other_node);
132+ if (!mem) {
133+ printf("Error: numa_alloc_onnode failed for node %d\n", other_node);
134+ return TEST_FAIL;
135+ }
136+
137+ gettimeofday(&end, NULL);
138+ /* do some work */
139+ do {
140+ struct timeval now;
141+ memcpy(mem, mem + mem_size/2, mem_size/2);
142+ gettimeofday(&now, NULL);
143+ timersub(&now, &end, &res);
144+ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < LOOP_TIME);
145+
146+ numa_free(mem, mem_size);
147+ ++i;
148+ gettimeofday(&end, NULL);
149+ timersub(&end, &start, &res);
150+ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < TIMEOUT);
151+
152+ return TEST_FAIL;
153+}
154+
155+int main()
156+{
157+ if (numa_available() < 0) {
158+ printf("Error: numa not available\n");
159+ printf("SKIP: numad\n");
160+ return 0;
161+ }
162+
163+ switch(test()) {
164+ case TEST_PASS:
165+ printf("PASS: numad\n");
166+ break;
167+ case TEST_SKIP:
168+ printf("FAIL: numad\n");
169+ break;
170+ default:
171+ printf("FAIL: numad\n");
172+ }
173+
174+ return 0;
175+}
diff --git a/recipes-core/numad/numad_0.6.bb b/recipes-core/numad/numad_0.6.bb
new file mode 100644
index 0000000..a6e8ad6
--- /dev/null
+++ b/recipes-core/numad/numad_0.6.bb
@@ -0,0 +1,51 @@
1SUMMARY = "NUMA load distributing daemon"
2DESCRIPTION = 'A user-level daemon that monitors NUMA topology and processes resource \
3consumption to facilitate good NUMA resource access of applications/virtual machines \
4to improve performance and minimize cost of remote memory latencies.'
5HOMEPAGE = "https://git.fedorahosted.org/git/numad.git"
6SECTION = "console/utils"
7
8LICENSE = "LGPLv2.1"
9
10LIC_FILES_CHKSUM = "file://numad.c;beginline=1;endline=19;md5=fc770296e974bef07ddd7033725c8e29"
11
12SRC_URI = "git://git.fedorahosted.org/git/numad.git;protocol=https;branch=master \
13 file://Makefile.patch \
14 file://test.patch \
15 file://run-ptest \
16 file://numad.init.patch \
17 file://numad.conf.patch"
18
19SRCREV = "b621838bf9c8203e87137eca28e19bcc381cde2a"
20
21S = "${WORKDIR}/git"
22
23#clear .LIBPATTERNS instead of using VPATH="${STAGING_LIBDIR}:${STAGING_DIR_HOST}/${base_libdir}"
24EXTRA_OEMAKE = 'prefix=${D}/usr TEST_DESTDIR=${D}${PTEST_PATH} .LIBPATTERNS=""'
25
26do_install () {
27 oe_runmake install
28 install -d ${D}${sysconfdir}/init.d
29 install -m 0755 ${S}/numad.init ${D}${sysconfdir}/init.d
30 install -m 0644 ${S}/numad.conf ${D}${sysconfdir}
31}
32
33inherit update-rc.d ptest
34
35DEPENDS_${PN}-ptest += "numactl"
36RDEPENDS_${PN}-ptest += "libnuma"
37
38INITSCRIPT_NAME = "numad.init"
39#INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ."
40INITSCRIPT_PARAMS = "stop 20 5 2 . stop 20 0 1 6 ."
41
42#wait for numa.h
43do_compile_ptest_base[depends] += "numactl:do_populate_sysroot"
44
45do_install_ptest () {
46 oe_runmake test-install
47}
48
49do_compile_ptest () {
50 oe_runmake test
51}
diff --git a/recipes-core/packagegroups/packagegroup-enea-ip.bb b/recipes-core/packagegroups/packagegroup-enea-ip.bb
new file mode 100644
index 0000000..8cd980d
--- /dev/null
+++ b/recipes-core/packagegroups/packagegroup-enea-ip.bb
@@ -0,0 +1,18 @@
1DESCRIPTION = "Package group for IP"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
4 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
5PR = "r0"
6
7inherit packagegroup
8
9RDEPENDS_${PN} = "\
10 numactl \
11 numad \
12 dpdk \
13 oftest \
14 openvswitchdpdk-oftest-ptest \
15 openvswitch \
16 openvswitchdpdk \
17 openvswitchdpdk-qemu \
18 "
diff --git a/recipes-kernel/linux/linux-yocto_3.10.bbappend b/recipes-kernel/linux/linux-yocto_3.10.bbappend
new file mode 100644
index 0000000..dc182c7
--- /dev/null
+++ b/recipes-kernel/linux/linux-yocto_3.10.bbappend
@@ -0,0 +1,4 @@
1SRC_URI += " \
2 file://cfg/00044-numa.cfg \
3 file://cfg/00045-pci-stub.cfg \
4 "
diff --git a/recipes-kernel/linux/linux-yocto_3.14.bbappend b/recipes-kernel/linux/linux-yocto_3.14.bbappend
new file mode 100644
index 0000000..dc182c7
--- /dev/null
+++ b/recipes-kernel/linux/linux-yocto_3.14.bbappend
@@ -0,0 +1,4 @@
1SRC_URI += " \
2 file://cfg/00044-numa.cfg \
3 file://cfg/00045-pci-stub.cfg \
4 "
diff --git a/recipes-networking/dpdk/dpdk_git.bb b/recipes-networking/dpdk/dpdk_git.bb
new file mode 100644
index 0000000..ed4c2b3
--- /dev/null
+++ b/recipes-networking/dpdk/dpdk_git.bb
@@ -0,0 +1,139 @@
1SUMMARY = "DPDK"
2DESCRIPTION = "DPDK - a novel framework for fast packet I/O"
3HOMEPAGE = "http://dpdk.org"
4SECTION = "devel"
5LICENSE = "GPLv2 | LGPLv2 | BSD"
6LIC_FILES_CHKSUM = "file://LICENSE.GPL;md5=751419260aa954499f7abaabaa882bbe \
7 file://LICENSE.LGPL;md5=4fbd65380cdd255951079008b364516c \
8 file://lib/librte_eal/common/include/rte_version.h;beginline=1;endline=33;md5=ab6d502a4a25ded2bbabf031720bd1f4"
9
10PR = "r1"
11PV = "1.6.0"
12DEPENDS += "virtual/kernel"
13
14inherit module-base
15
16addtask make_scripts after do_patch before do_compile
17do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
18do_make_scripts[deptask] = "do_populate_sysroot"
19
20SRCREV = "v1.6.0r1"
21SRC_URI = "git://dpdk.org/git/dpdk;protocol=http;branch=1.6.0 \
22 file://unbreak-makefiles.patch \
23 file://runtest.patch \
24 file://run-ptest \
25 file://igb_ethdev_loopback.patch \
26 file://l2fwd-lpbk \
27 file://machine-flags.patch \
28 file://rte_kni_module_1_6.patch.x \
29 "
30
31DPDK_TARGET_DEFAULT = "${TARGET_ARCH}-default-linuxapp-gcc"
32DPDK_TARGET_IVSHMEM = "${TARGET_ARCH}-ivshmem-linuxapp-gcc"
33
34DPDK_BUILD_DIR = "build"
35DPDK_VAR_O = "${S}/${DPDK_BUILD_DIR}"
36DPDK_VAR_DESTDIR = "${WORKDIR}/install"
37
38DPDK_SRC_PATH = "/usr/src/dpdk"
39DPDK_INSTALL_PATH = "/opt/dpdk"
40
41S = "${WORKDIR}/git"
42B = "${S}"
43
44PACKAGES = "${PN}-dbg ${PN} ${PN}-mk ${PN}-scripts"
45PACKAGES += "${PN}-default-dbg ${PN}-default-staticdev ${PN}-default"
46
47RDEPENDS_${PN} += "pciutils"
48RDEPENDS_${PN}-default = "${PN}-mk ${PN}-scripts ${PN}-default-staticdev pciutils"
49RRECOMMENDS_${PN} += "kernel-module-uio kernel-module-pci-stub"
50
51FILES_${PN} = "${DPDK_SRC_PATH}"
52FILES_${PN}-dbg = "/usr/src/debug"
53FILES_${PN}-mk = "${DPDK_INSTALL_PATH}/mk"
54FILES_${PN}-scripts = "${DPDK_INSTALL_PATH}/scripts"
55
56FILES_${PN}-default = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc"
57FILES_${PN}-default-dbg = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/app/.debug"
58FILES_${PN}-default-staticdev = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/lib"
59
60do_compile() {
61 cd ${S} && oe_runmake install \
62 RTE_KERNELDIR=${STAGING_KERNEL_DIR} \
63 RTE_MACHINE=default \
64 prefix="" \
65 V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \
66 O=${DPDK_VAR_O} \
67 T=${DPDK_TARGET_DEFAULT} \
68 DESTDIR=${DPDK_VAR_DESTDIR} \
69 MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}"
70
71 #patched version of IVSHMEM target for OVS-DPDK - installed to staging only
72 cd ${S} && git apply ${WORKDIR}/rte_kni_module_1_6.patch.x && \
73 oe_runmake install \
74 RTE_KERNELDIR=${STAGING_KERNEL_DIR} \
75 RTE_MACHINE=default \
76 prefix="" \
77 V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \
78 O=${DPDK_VAR_O} \
79 T=${DPDK_TARGET_IVSHMEM} \
80 DESTDIR=${DPDK_VAR_DESTDIR} \
81 MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}" \
82 EXTRA_CFLAGS=-fPIC && \
83 git apply --reverse ${WORKDIR}/rte_kni_module_1_6.patch.x \
84}
85
86do_install() {
87 # dpdk
88 install -d ${D}${DPDK_SRC_PATH}
89 cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\
90 cpio --null -pdlu ${D}${DPDK_SRC_PATH}
91
92 # install sources to staging
93 cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\
94 cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_SRC_PATH}
95
96 # install build to staging
97 cd ${DPDK_VAR_DESTDIR} && find . -print0 | cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH}
98
99 # install build output - skip OVS-DPDK IVSHMEM
100 install -d ${D}${DPDK_INSTALL_PATH}
101 cd ${DPDK_VAR_DESTDIR} && find . -depth -not -path "./${DPDK_TARGET_IVSHMEM}*" -print0 |\
102 cpio --null -pdlu ${D}${DPDK_INSTALL_PATH}
103
104 # add "scripts" directory to build output and staging, relpath.sh is needed by makefiles
105 cp -r ${S}/scripts ${D}${DPDK_INSTALL_PATH}
106 cp -r ${S}/scripts ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH}
107 # relpath.sh use of $prefix breaks openvswitch
108 sed -i 's/prefix/path_prefix/g' ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH}/scripts/relpath.sh
109}
110
111COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux.*)'
112
113#test default target
114
115inherit ptest
116
117RDEPENDS_${PN}-ptest += "\
118 make \
119 python-pexpect \
120 ${PN}-default \
121 ${PN} \
122 "
123
124do_compile_ptest () {
125 cd ${WORKDIR}/l2fwd-lpbk && oe_runmake RTE_SDK="${DPDK_VAR_DESTDIR}" \
126 RTE_TARGET="${DPDK_TARGET_DEFAULT}" RTE_ARCH="${TARGET_ARCH}"
127 sed -i 's|RTE_SDK=.*|RTE_SDK=${DPDK_INSTALL_PATH}|g' ${WORKDIR}/run-ptest
128 sed -i 's|RTE_TARGET=.*|RTE_TARGET=${DPDK_TARGET_DEFAULT}|g' ${WORKDIR}/run-ptest
129 sed -i 's|RTE_ARCH=.*|RTE_ARCH=${TARGET_ARCH}|g' ${WORKDIR}/run-ptest
130}
131
132do_install_ptest () {
133 #install l2fwd loopback app
134 install ${WORKDIR}/l2fwd-lpbk/build/app/l2fwd-lpbk ${D}${PTEST_PATH}
135
136 #install original test file to be used by autotest.py
137 install ${DPDK_VAR_O}/${DPDK_TARGET_DEFAULT}/app/test ${D}${PTEST_PATH}
138}
139
diff --git a/recipes-networking/dpdk/files/igb_ethdev_loopback.patch b/recipes-networking/dpdk/files/igb_ethdev_loopback.patch
new file mode 100644
index 0000000..6b979ca
--- /dev/null
+++ b/recipes-networking/dpdk/files/igb_ethdev_loopback.patch
@@ -0,0 +1,96 @@
1Index: dpdk/lib/librte_pmd_e1000/igb_ethdev.c
2===================================================================
3--- dpdk.orig/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:35:49.267083184 +0200
4+++ dpdk/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:36:23.015082260 +0200
5@@ -701,50 +701,67 @@
6 E1000_WRITE_REG(hw, E1000_EITR(0), 0xFFFF);
7 }
8
9- /* Setup link speed and duplex */
10- switch (dev->data->dev_conf.link_speed) {
11- case ETH_LINK_SPEED_AUTONEG:
12+ if (dev->data->dev_conf.lpbk_mode == 1) {
13+ uint32_t reg;
14+
15+ reg = E1000_READ_REG(hw, E1000_RCTL);
16+ reg |= E1000_RCTL_LBM_MAC;
17+ E1000_WRITE_REG(hw, E1000_RCTL, reg);
18+
19+ reg = E1000_READ_REG(hw, E1000_CTRL);
20+ reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_FD |
21+ E1000_CTRL_SPD_1000);
22+ E1000_WRITE_REG(hw, E1000_CTRL, reg);
23+
24+ reg = E1000_READ_REG(hw, E1000_EEER);
25+ reg |= (1 << 28);
26+ E1000_WRITE_REG(hw, E1000_EEER, reg);
27+ } else {
28+ /* Setup link speed and duplex */
29+ switch (dev->data->dev_conf.link_speed) {
30+ case ETH_LINK_SPEED_AUTONEG:
31 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
32- hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
33+ hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
34 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
35- hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
36+ hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
37 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
38- hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
39+ hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
40 else
41- goto error_invalid_config;
42+ goto error_invalid_config;
43 break;
44- case ETH_LINK_SPEED_10:
45+ case ETH_LINK_SPEED_10:
46 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
47- hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
48+ hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
49 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
50- hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
51+ hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
52 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
53- hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
54+ hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
55 else
56- goto error_invalid_config;
57+ goto error_invalid_config;
58 break;
59- case ETH_LINK_SPEED_100:
60+ case ETH_LINK_SPEED_100:
61 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
62- hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
63+ hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
64 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
65- hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
66+ hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
67 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
68- hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
69+ hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
70 else
71- goto error_invalid_config;
72+ goto error_invalid_config;
73 break;
74- case ETH_LINK_SPEED_1000:
75+ case ETH_LINK_SPEED_1000:
76 if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) ||
77- (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
78- hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
79+ (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
80+ hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
81 else
82- goto error_invalid_config;
83+ goto error_invalid_config;
84 break;
85- case ETH_LINK_SPEED_10000:
86- default:
87+ case ETH_LINK_SPEED_10000:
88+ default:
89 goto error_invalid_config;
90+ }
91+ e1000_setup_link(hw);
92 }
93- e1000_setup_link(hw);
94
95 /* check if lsc interrupt feature is enabled */
96 if (dev->data->dev_conf.intr_conf.lsc != 0)
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile
new file mode 100644
index 0000000..72d56b7
--- /dev/null
+++ b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile
@@ -0,0 +1,51 @@
1# BSD LICENSE
2#
3# Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in
14# the documentation and/or other materials provided with the
15# distribution.
16# * Neither the name of Intel Corporation nor the names of its
17# contributors may be used to endorse or promote products derived
18# from this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32
33ifeq ($(RTE_SDK),)
34$(error "Please define RTE_SDK environment variable")
35endif
36
37# Default target, can be overriden by command line or environment
38RTE_TARGET ?= x86_64-default-linuxapp-gcc
39
40include $(RTE_SDK)/mk/rte.vars.mk
41
42# binary name
43APP = l2fwd-lpbk
44
45# all source are stored in SRCS-y
46SRCS-y := main.c
47
48CFLAGS += -O3
49CFLAGS += $(WERROR_FLAGS)
50
51include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.c b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c
new file mode 100644
index 0000000..ff22b66
--- /dev/null
+++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c
@@ -0,0 +1,929 @@
1/*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include <stdint.h>
38#include <inttypes.h>
39#include <sys/types.h>
40#include <sys/queue.h>
41#include <netinet/in.h>
42#include <setjmp.h>
43#include <stdarg.h>
44#include <ctype.h>
45#include <errno.h>
46#include <getopt.h>
47
48#include <rte_common.h>
49#include <rte_log.h>
50#include <rte_memory.h>
51#include <rte_memcpy.h>
52#include <rte_memzone.h>
53#include <rte_tailq.h>
54#include <rte_eal.h>
55#include <rte_per_lcore.h>
56#include <rte_launch.h>
57#include <rte_atomic.h>
58#include <rte_cycles.h>
59#include <rte_prefetch.h>
60#include <rte_lcore.h>
61#include <rte_per_lcore.h>
62#include <rte_branch_prediction.h>
63#include <rte_interrupts.h>
64#include <rte_pci.h>
65#include <rte_random.h>
66#include <rte_debug.h>
67#include <rte_ether.h>
68#include <rte_ethdev.h>
69#include <rte_ring.h>
70#include <rte_mempool.h>
71#include <rte_mbuf.h>
72#include <rte_byteorder.h>
73#include <rte_hexdump.h>
74
75#include "main.h"
76
77#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
78
79#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
80#define NB_MBUF 8192
81
82/*
83 * RX and TX Prefetch, Host, and Write-back threshold values should be
84 * carefully set for optimal performance. Consult the network
85 * controller's datasheet and supporting DPDK documentation for guidance
86 * on how these parameters should be set.
87 */
88#define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */
89#define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */
90#define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */
91
92/*
93 * These default values are optimized for use with the Intel(R) 82599 10 GbE
94 * Controller and the DPDK ixgbe PMD. Consider using other values for other
95 * network controllers and/or network drivers.
96 */
97#define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */
98#define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */
99#define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */
100
101#define MAX_PKT_BURST 32
102#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
103
104/*
105 * Configurable number of RX/TX ring descriptors
106 */
107#define RTE_TEST_RX_DESC_DEFAULT 128
108#define RTE_TEST_TX_DESC_DEFAULT 512
109static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
110static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
111
112/* ethernet addresses of ports */
113static struct ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS];
114
115/* mask of enabled ports */
116static uint32_t l2fwd_enabled_port_mask = 0;
117
118/* list of enabled ports */
119static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS];
120
121static unsigned int l2fwd_rx_queue_per_lcore = 1;
122
123#define MIN_TX_SIZE 64
124#define MAX_TX_SIZE 2048
125static int l2fwd_tx_size = MIN_TX_SIZE;
126
127#define MAX_TX_COUNT 128
128static int l2fwd_tx_count = 0;
129
130static int l2fwd_loopback = 0;
131
132struct mbuf_table {
133 unsigned len;
134 struct rte_mbuf *m_table[MAX_PKT_BURST];
135};
136
137#define MAX_RX_QUEUE_PER_LCORE 16
138#define MAX_TX_QUEUE_PER_PORT 16
139struct lcore_queue_conf {
140 unsigned n_rx_port;
141 unsigned rx_port_list[MAX_RX_QUEUE_PER_LCORE];
142 struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS];
143
144} __rte_cache_aligned;
145struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
146
147static struct rte_eth_conf port_conf = {
148 .rxmode = {
149 .split_hdr_size = 0,
150 .header_split = 0, /**< Header Split disabled */
151 .hw_ip_checksum = 0, /**< IP checksum offload disabled */
152 .hw_vlan_filter = 0, /**< VLAN filtering disabled */
153 .jumbo_frame = 0, /**< Jumbo Frame Support disabled */
154 .hw_strip_crc = 0, /**< CRC stripped by hardware */
155 },
156 .txmode = {
157 .mq_mode = ETH_MQ_TX_NONE,
158 },
159};
160
161static const struct rte_eth_rxconf rx_conf = {
162 .rx_thresh = {
163 .pthresh = RX_PTHRESH,
164 .hthresh = RX_HTHRESH,
165 .wthresh = RX_WTHRESH,
166 },
167};
168
169static const struct rte_eth_txconf tx_conf = {
170 .tx_thresh = {
171 .pthresh = TX_PTHRESH,
172 .hthresh = TX_HTHRESH,
173 .wthresh = TX_WTHRESH,
174 },
175 .tx_free_thresh = 0, /* Use PMD default values */
176 .tx_rs_thresh = 0, /* Use PMD default values */
177};
178
179struct rte_mempool * l2fwd_pktmbuf_pool = NULL;
180
181/* Per-port statistics struct */
182struct l2fwd_port_statistics {
183 uint64_t tx;
184 uint64_t rx;
185 uint64_t dropped;
186 uint64_t loop;
187} __rte_cache_aligned;
188struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
189
190/* A tsc-based timer responsible for triggering statistics printout */
191#define MAX_TIMER_PERIOD 86400 /* 1 day max */
192static int64_t timer_period;
193static uint64_t tsc_hz;
194
195static void l2fwd_init_time(void)
196{
197 tsc_hz = rte_get_tsc_hz();
198 timer_period = 10 * rte_get_tsc_hz(); /* default period is 10 seconds */
199}
200
201/* Print out statistics on packets dropped */
202static void
203print_stats(void)
204{
205 uint64_t total_packets_dropped, total_packets_tx, total_packets_rx;
206 unsigned portid;
207 static uint64_t count = 0;
208 const char clr[] = { 27, '[', '2', 'J', '\0' };
209 const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
210
211 total_packets_dropped = 0;
212 total_packets_tx = 0;
213 total_packets_rx = 0;
214
215 /* Clear screen and move to top left */
216 printf("%s%s", clr, topLeft);
217
218 printf("\nPort statistics ====================================");
219
220 for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
221 /* skip disabled ports */
222 if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
223 continue;
224 printf("\nStatistics for port %u ------------------------------"
225 "\nPackets sent: %24"PRIu64
226 "\nPackets received: %20"PRIu64
227 "\nPackets dropped: %21"PRIu64
228 "\nLoop count : %21"PRIu64,
229 portid,
230 port_statistics[portid].tx,
231 port_statistics[portid].rx,
232 port_statistics[portid].dropped,
233 port_statistics[portid].loop);
234
235 total_packets_dropped += port_statistics[portid].dropped;
236 total_packets_tx += port_statistics[portid].tx;
237 total_packets_rx += port_statistics[portid].rx;
238 }
239 printf("\nAggregate statistics ==============================="
240 "\nTotal packets sent: %18"PRIu64
241 "\nTotal packets received: %14"PRIu64
242 "\nTotal packets dropped: %15"PRIu64
243 "\nPeriod: %"PRIu64,
244 total_packets_tx,
245 total_packets_rx,
246 total_packets_dropped,
247 count
248 );
249 printf("\n====================================================\n");
250
251 count++;
252}
253
254/* Send the burst of packets on an output interface */
255static int
256l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port)
257{
258 struct rte_mbuf **m_table;
259 unsigned ret;
260 unsigned queueid =0;
261
262 m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
263
264 ret = rte_eth_tx_burst(port, (uint16_t) queueid, m_table, (uint16_t) n);
265 port_statistics[port].tx += ret;
266 if (unlikely(ret < n)) {
267 port_statistics[port].dropped += (n - ret);
268 do {
269 rte_pktmbuf_free(m_table[ret]);
270 } while (++ret < n);
271 }
272
273 return 0;
274}
275
276/* Enqueue packets for TX and prepare them to be sent */
277static int
278l2fwd_send_packet(struct rte_mbuf *m, uint8_t port)
279{
280 unsigned lcore_id, len;
281 struct lcore_queue_conf *qconf;
282
283 lcore_id = rte_lcore_id();
284
285 qconf = &lcore_queue_conf[lcore_id];
286 len = qconf->tx_mbufs[port].len;
287 qconf->tx_mbufs[port].m_table[len] = m;
288 len++;
289
290 /* enough pkts to be sent */
291 if (unlikely(len == MAX_PKT_BURST)) {
292 l2fwd_send_burst(qconf, MAX_PKT_BURST, port);
293 len = 0;
294 }
295
296 qconf->tx_mbufs[port].len = len;
297 return 0;
298}
299
300static void
301l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid)
302{
303 struct ether_hdr *eth;
304 void *tmp;
305 unsigned dst_port;
306
307 dst_port = l2fwd_dst_ports[portid];
308
309 eth = rte_pktmbuf_mtod(m, struct ether_hdr *);
310 /* 02:00:00:00:00:xx */
311 tmp = &eth->d_addr.addr_bytes[0];
312 *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dst_port << 40);
313
314 /* src addr */
315 ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], &eth->s_addr);
316
317 l2fwd_send_packet(m, (uint8_t) dst_port);
318}
319
320static inline void
321copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
322{
323 rte_memcpy(((char *) pkt->pkt.data + offset), buf, (size_t) len);
324}
325
326static int
327l2fwd_tx(void)
328{
329 uint8_t portid;
330
331 for (portid = 0; portid < RTE_MAX_ETHPORTS; ++portid) {
332 struct rte_mbuf *tx_mbuf[MAX_TX_COUNT];
333 int pkt;
334 unsigned queueid = 0;
335
336 if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
337 continue;
338
339 for (pkt = 0; pkt < l2fwd_tx_count; ++pkt) {
340
341 tx_mbuf[pkt] = rte_pktmbuf_alloc(l2fwd_pktmbuf_pool);
342 if (!tx_mbuf[pkt])
343 rte_exit(EXIT_FAILURE,
344 "rte_pktmbuf_alloc failed.\n");
345
346 /* minimum ethernet header
347 without this the 82599 will drop the packet if IXGBE_FCTRL_SBP is not set
348 */
349 {
350 struct ether_hdr *eth_hdr;
351 /*struct ipv4_hdr *ipv4_hdr;*/
352 struct ether_addr mac_addr;
353
354 eth_hdr = rte_pktmbuf_mtod(tx_mbuf[pkt], struct ether_hdr*);
355
356 rte_eth_macaddr_get(portid, &mac_addr);
357#if 1
358 mac_addr.addr_bytes[0] = 0;
359 mac_addr.addr_bytes[1] = 2;
360#endif
361 ether_addr_copy(&mac_addr, &eth_hdr->s_addr);
362 ether_addr_copy(&mac_addr, &eth_hdr->d_addr);
363 eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
364
365 /*ipv4_hdr = (struct ipv4_hdr*)&eth_hdr[1];*/
366
367 tx_mbuf[pkt]->pkt.data_len = l2fwd_tx_size;
368 tx_mbuf[pkt]->pkt.pkt_len = l2fwd_tx_size;
369#if 0
370 rte_hexdump(NULL, rte_pktmbuf_mtod(tx_mbuf[pkt], void*), l2fwd_tx_size);
371#endif
372 }
373 }
374
375 if(rte_eth_tx_burst(portid, queueid, tx_mbuf, l2fwd_tx_count) != l2fwd_tx_count)
376 rte_exit(EXIT_FAILURE, "Incomplete Tx for port %u\n", portid);
377
378 RTE_LOG(INFO, L2FWD, "sent %u packets on port %u\n", l2fwd_tx_count, portid);
379 }
380
381 return 0;
382}
383
384/* main processing loop */
385static void
386l2fwd_main_loop(void)
387{
388 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
389 struct rte_mbuf *m;
390 unsigned lcore_id;
391 uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
392 unsigned i, j, portid, nb_rx;
393 struct lcore_queue_conf *qconf;
394 const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
395
396 prev_tsc = 0;
397 timer_tsc = 0;
398
399 lcore_id = rte_lcore_id();
400 qconf = &lcore_queue_conf[lcore_id];
401
402 if (qconf->n_rx_port == 0) {
403 RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
404 return;
405 }
406
407 RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id);
408
409 for (i = 0; i < qconf->n_rx_port; i++) {
410
411 portid = qconf->rx_port_list[i];
412 RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id,
413 portid);
414 }
415
416 while (1) {
417 cur_tsc = rte_rdtsc();
418
419 /*
420 * TX burst queue drain
421 */
422 diff_tsc = cur_tsc - prev_tsc;
423 if (unlikely(diff_tsc > drain_tsc)) {
424 for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
425 if (qconf->tx_mbufs[portid].len == 0)
426 continue;
427 l2fwd_send_burst(&lcore_queue_conf[lcore_id],
428 qconf->tx_mbufs[portid].len,
429 (uint8_t) portid);
430 qconf->tx_mbufs[portid].len = 0;
431 }
432 /* if timer is enabled */
433 if (timer_period > 0) {
434
435 /* advance the timer */
436 timer_tsc += diff_tsc;
437
438 /* if timer has reached its timeout */
439 if (unlikely(timer_tsc >= (uint64_t) timer_period)) {
440
441 /* do this only on master core */
442 if (lcore_id == rte_get_master_lcore()) {
443 print_stats();
444 /* reset the timer */
445 timer_tsc = 0;
446 }
447 }
448 }
449
450 prev_tsc = cur_tsc;
451 }
452
453 /*
454 * Read packet from RX queues
455 */
456 for (i = 0; i < qconf->n_rx_port; i++) {
457 portid = qconf->rx_port_list[i];
458 nb_rx = rte_eth_rx_burst((uint8_t) portid, 0,
459 pkts_burst, MAX_PKT_BURST);
460
461 port_statistics[portid].rx += nb_rx;
462 port_statistics[portid].loop++;
463
464 for (j = 0; j < nb_rx; j++) {
465 m = pkts_burst[j];
466 rte_prefetch0(rte_pktmbuf_mtod(m, void *));
467 l2fwd_simple_forward(m, portid);
468
469#if 0
470 rte_hexdump(NULL, rte_pktmbuf_mtod(pkts_burst[j], void*), pkts_burst[j]->pkt.data_len);
471#endif
472
473 }
474 }
475 }
476}
477
478static int
479l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy)
480{
481 l2fwd_main_loop();
482 return 0;
483}
484
485/* display usage */
486static void
487l2fwd_usage(const char *prgname)
488{
489 printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n"
490 " -p PORTMASK: hexadecimal bitmask of ports to configure\n"
491 " -q NQ: number of queue (=ports) per lcore (default is 1)\n"
492 " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n"
493 " -t TX: number of packets to send before forwarding (0 to disable, 0 default, 128 maximum)\n"
494 " -l LOOPBACK: loopback mode \n"
495 " -s SIZE: size of packets to be sent (64 default/minimum, 2048 maximum)\n",
496 prgname);
497}
498
499static int
500l2fwd_parse_portmask(const char *portmask)
501{
502 char *end = NULL;
503 unsigned long pm;
504
505 /* parse hexadecimal string */
506 pm = strtoul(portmask, &end, 16);
507 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
508 return -1;
509
510 if (pm == 0)
511 return -1;
512
513 return pm;
514}
515
516static int
517l2fwd_parse_tx_packet_count(const char *q_arg)
518{
519 char *end = NULL;
520 int n;
521
522 /* parse number string */
523 n = strtol(q_arg, &end, 10);
524 if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
525 return -1;
526 if (n > MAX_TX_COUNT)
527 return -1;
528
529 return n;
530}
531
532static int
533l2fwd_parse_tx_packet_size(const char *q_arg)
534{
535 char *end = NULL;
536 int n;
537
538 /* parse number string */
539 n = strtol(q_arg, &end, 10);
540 if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
541 return -1;
542 if (n < MIN_TX_SIZE)
543 return -1;
544 if (n > MAX_TX_SIZE)
545 return -1;
546
547 return n;
548}
549
550static unsigned int
551l2fwd_parse_nqueue(const char *q_arg)
552{
553 char *end = NULL;
554 unsigned long n;
555
556 /* parse hexadecimal string */
557 n = strtoul(q_arg, &end, 10);
558 if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
559 return 0;
560 if (n == 0)
561 return 0;
562 if (n >= MAX_RX_QUEUE_PER_LCORE)
563 return 0;
564
565 return n;
566}
567
568static int
569l2fwd_parse_timer_period(const char *q_arg)
570{
571 char *end = NULL;
572 int n;
573
574 /* parse number string */
575 n = strtol(q_arg, &end, 10);
576 if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
577 return -1;
578 if (n >= MAX_TIMER_PERIOD)
579 return -1;
580
581 return n;
582}
583
584/* Parse the argument given in the command line of the application */
585static int
586l2fwd_parse_args(int argc, char **argv)
587{
588 int opt, ret;
589 char **argvopt;
590 int option_index;
591 char *prgname = argv[0];
592 static struct option lgopts[] = {
593 {NULL, 0, 0, 0}
594 };
595
596 argvopt = argv;
597
598 while ((opt = getopt_long(argc, argvopt, "p:q:T:t:s:l",
599 lgopts, &option_index)) != EOF) {
600
601 switch (opt) {
602 /* portmask */
603 case 'p':
604 l2fwd_enabled_port_mask = l2fwd_parse_portmask(optarg);
605 if (l2fwd_enabled_port_mask == 0) {
606 printf("invalid portmask\n");
607 l2fwd_usage(prgname);
608 return -1;
609 }
610 break;
611
612 /* nqueue */
613 case 'q':
614 l2fwd_rx_queue_per_lcore = l2fwd_parse_nqueue(optarg);
615 if (l2fwd_rx_queue_per_lcore == 0) {
616 printf("invalid queue number\n");
617 l2fwd_usage(prgname);
618 return -1;
619 }
620 break;
621
622 /* timer period */
623 case 'T':
624 timer_period = l2fwd_parse_timer_period(optarg) * tsc_hz;
625 if (timer_period < 0) {
626 printf("invalid timer period\n");
627 l2fwd_usage(prgname);
628 return -1;
629 }
630 break;
631
632 case 't':
633 l2fwd_tx_count = l2fwd_parse_tx_packet_count(optarg);
634 if (l2fwd_tx_count < 0) {
635 printf("invalid tx packet count\n");
636 l2fwd_usage(prgname);
637 return -1;
638 }
639 break;
640
641 case 's':
642 l2fwd_tx_size = l2fwd_parse_tx_packet_size(optarg);
643 if (l2fwd_tx_size < 0) {
644 printf("invalid tx packet size\n");
645 l2fwd_usage(prgname);
646 return -1;
647 }
648 break;
649
650 case 'l':
651 l2fwd_loopback = 1;
652 break;
653
654 /* long options */
655 case 0:
656 l2fwd_usage(prgname);
657 return -1;
658
659 default:
660 l2fwd_usage(prgname);
661 return -1;
662 }
663 }
664
665 if (optind >= 0)
666 argv[optind-1] = prgname;
667
668 ret = optind-1;
669 optind = 0; /* reset getopt lib */
670 return ret;
671}
672
673/* Check the link status of all ports in up to 9s, and print them finally */
674static void
675check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
676{
677#define CHECK_INTERVAL 100 /* 100ms */
678#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
679 uint8_t portid, count, all_ports_up, print_flag = 0;
680 struct rte_eth_link link;
681
682 printf("\nChecking link status");
683 fflush(stdout);
684 for (count = 0; count <= MAX_CHECK_TIME; count++) {
685 all_ports_up = 1;
686 for (portid = 0; portid < port_num; portid++) {
687 if ((port_mask & (1 << portid)) == 0)
688 continue;
689 memset(&link, 0, sizeof(link));
690 rte_eth_link_get_nowait(portid, &link);
691 /* print link status if flag set */
692 if (print_flag == 1) {
693 if (link.link_status)
694 printf("Port %d Link Up - speed %u "
695 "Mbps - %s\n", (uint8_t)portid,
696 (unsigned)link.link_speed,
697 (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
698 ("full-duplex") : ("half-duplex\n"));
699 else
700 printf("Port %d Link Down\n",
701 (uint8_t)portid);
702 continue;
703 }
704 /* clear all_ports_up flag if any link down */
705 if (link.link_status == 0) {
706 all_ports_up = 0;
707 break;
708 }
709 }
710 /* after finally printing all link status, get out */
711 if (print_flag == 1)
712 break;
713
714 if (all_ports_up == 0) {
715 printf(".");
716 fflush(stdout);
717 rte_delay_ms(CHECK_INTERVAL);
718 }
719
720 /* set the print_flag if all ports up or timeout */
721 if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
722 print_flag = 1;
723 printf("done\n");
724 }
725 }
726}
727
728int
729MAIN(int argc, char **argv)
730{
731 struct lcore_queue_conf *qconf;
732 struct rte_eth_dev_info dev_info;
733 int ret;
734 uint8_t nb_ports;
735 uint8_t nb_ports_available;
736 uint8_t portid, last_port;
737 unsigned lcore_id, rx_lcore_id;
738 unsigned nb_ports_in_mask = 0;
739
740 setlinebuf(stdout);
741 setlinebuf(stderr);
742
743 /* init EAL */
744 ret = rte_eal_init(argc, argv);
745 if (ret < 0)
746 rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
747
748 l2fwd_init_time();
749
750 argc -= ret;
751 argv += ret;
752
753 /* parse application arguments (after the EAL ones) */
754 ret = l2fwd_parse_args(argc, argv);
755 if (ret < 0)
756 rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n");
757
758 /* create the mbuf pool */
759 l2fwd_pktmbuf_pool =
760 rte_mempool_create("mbuf_pool", NB_MBUF,
761 MBUF_SIZE, 32,
762 sizeof(struct rte_pktmbuf_pool_private),
763 rte_pktmbuf_pool_init, NULL,
764 rte_pktmbuf_init, NULL,
765 rte_socket_id(), 0);
766 if (l2fwd_pktmbuf_pool == NULL)
767 rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n");
768
769 /* init driver(s) */
770 if (rte_pmd_init_all() < 0)
771 rte_exit(EXIT_FAILURE, "Cannot init pmd\n");
772
773 if (rte_eal_pci_probe() < 0)
774 rte_exit(EXIT_FAILURE, "Cannot probe PCI\n");
775
776 nb_ports = rte_eth_dev_count();
777 if (nb_ports == 0)
778 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
779
780 if (nb_ports > RTE_MAX_ETHPORTS)
781 nb_ports = RTE_MAX_ETHPORTS;
782
783 /* reset l2fwd_dst_ports */
784 for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
785 l2fwd_dst_ports[portid] = 0;
786 last_port = 0;
787
788 /*
789 * Each logical core is assigned a dedicated TX queue on each port.
790 */
791 for (portid = 0; portid < nb_ports; portid++) {
792 /* skip ports that are not enabled */
793 if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
794 continue;
795
796 if (l2fwd_loopback) {
797 l2fwd_dst_ports[portid] = portid;
798 continue;
799 }
800
801 if (nb_ports_in_mask % 2) {
802 l2fwd_dst_ports[portid] = last_port;
803 l2fwd_dst_ports[last_port] = portid;
804 }
805 else
806 last_port = portid;
807
808 nb_ports_in_mask++;
809
810 rte_eth_dev_info_get(portid, &dev_info);
811 }
812 if (!l2fwd_loopback && (nb_ports_in_mask % 2)) {
813 printf("Notice: odd number of ports in portmask.\n");
814 l2fwd_dst_ports[last_port] = last_port;
815 }
816
817 rx_lcore_id = 0;
818 qconf = NULL;
819
820 /* Initialize the port/queue configuration of each logical core */
821 for (portid = 0; portid < nb_ports; portid++) {
822 /* skip ports that are not enabled */
823 if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
824 continue;
825
826 /* get the lcore_id for this port */
827 while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
828 lcore_queue_conf[rx_lcore_id].n_rx_port ==
829 l2fwd_rx_queue_per_lcore) {
830 rx_lcore_id++;
831 if (rx_lcore_id >= RTE_MAX_LCORE)
832 rte_exit(EXIT_FAILURE, "Not enough cores\n");
833 }
834
835 if (qconf != &lcore_queue_conf[rx_lcore_id])
836 /* Assigned a new logical core in the loop above. */
837 qconf = &lcore_queue_conf[rx_lcore_id];
838
839 qconf->rx_port_list[qconf->n_rx_port] = portid;
840 qconf->n_rx_port++;
841 printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid);
842 }
843
844 nb_ports_available = nb_ports;
845
846 if (l2fwd_loopback)
847 port_conf.lpbk_mode = 1;
848
849 /* Initialise each port */
850 for (portid = 0; portid < nb_ports; portid++) {
851 /* skip ports that are not enabled */
852 if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
853 printf("Skipping disabled port %u\n", (unsigned) portid);
854 nb_ports_available--;
855 continue;
856 }
857 /* init port */
858 printf("Initializing port %u... ", (unsigned) portid);
859 fflush(stdout);
860
861 ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
862 if (ret < 0)
863 rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
864 ret, (unsigned) portid);
865
866 rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]);
867
868 /* init one RX queue */
869 fflush(stdout);
870 ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
871 rte_eth_dev_socket_id(portid), &rx_conf,
872 l2fwd_pktmbuf_pool);
873 if (ret < 0)
874 rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n",
875 ret, (unsigned) portid);
876
877 /* init one TX queue on each port */
878 fflush(stdout);
879 ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
880 rte_eth_dev_socket_id(portid), &tx_conf);
881 if (ret < 0)
882 rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n",
883 ret, (unsigned) portid);
884
885 /* Start device */
886 ret = rte_eth_dev_start(portid);
887 if (ret < 0)
888 rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n",
889 ret, (unsigned) portid);
890
891 printf("done: \n");
892
893 rte_eth_promiscuous_enable(portid);
894
895 printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
896 (unsigned) portid,
897 l2fwd_ports_eth_addr[portid].addr_bytes[0],
898 l2fwd_ports_eth_addr[portid].addr_bytes[1],
899 l2fwd_ports_eth_addr[portid].addr_bytes[2],
900 l2fwd_ports_eth_addr[portid].addr_bytes[3],
901 l2fwd_ports_eth_addr[portid].addr_bytes[4],
902 l2fwd_ports_eth_addr[portid].addr_bytes[5]);
903
904 /* initialize port stats */
905 memset(&port_statistics, 0, sizeof(port_statistics));
906 }
907
908 if (!nb_ports_available) {
909 rte_exit(EXIT_FAILURE,
910 "All available ports are disabled. Please set portmask.\n");
911 }
912
913 if(!l2fwd_loopback)
914 check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
915
916 if (l2fwd_tx_count)
917 l2fwd_tx();
918
919 /* launch per-lcore init on every lcore */
920 rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER);
921
922 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
923 if (rte_eal_wait_lcore(lcore_id) < 0)
924 return -1;
925 }
926
927 return 0;
928}
929
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.h b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h
new file mode 100644
index 0000000..93dca37
--- /dev/null
+++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h
@@ -0,0 +1,45 @@
1/*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _MAIN_H_
35#define _MAIN_H_
36
37#ifdef RTE_EXEC_ENV_BAREMETAL
38#define MAIN _main
39#else
40#define MAIN main
41#endif
42
43int MAIN(int argc, char **argv);
44
45#endif /* _MAIN_H_ */
diff --git a/recipes-networking/dpdk/files/machine-flags.patch b/recipes-networking/dpdk/files/machine-flags.patch
new file mode 100644
index 0000000..a6998fd
--- /dev/null
+++ b/recipes-networking/dpdk/files/machine-flags.patch
@@ -0,0 +1,12 @@
1Index: dpdk/mk/machine/native/rte.vars.mk
2===================================================================
3--- dpdk.orig/mk/machine/native/rte.vars.mk 2014-04-25 18:53:11.422348174 +0300
4+++ dpdk/mk/machine/native/rte.vars.mk 2014-04-25 18:52:44.042348924 +0300
5@@ -55,4 +55,6 @@
6 # CPU_LDFLAGS =
7 # CPU_ASFLAGS =
8
9-MACHINE_CFLAGS = -march=native
10+MACHINE_CFLAGS_ALT ?= -march=native
11+
12+MACHINE_CFLAGS = $(MACHINE_CFLAGS_ALT)
diff --git a/recipes-networking/dpdk/files/maketest.patch b/recipes-networking/dpdk/files/maketest.patch
new file mode 100644
index 0000000..cae679a
--- /dev/null
+++ b/recipes-networking/dpdk/files/maketest.patch
@@ -0,0 +1,41 @@
1Update test makefiles.
2
3Signed-off-by: Costin Popescu <costin.popescu@enea.com>
4Upstream-Status: Pending
5
6diff --git a/mk/rte.sdkroot.mk b/mk/rte.sdkroot.mk
7index 29af6a5..59bf972 100644
8--- a/mk/rte.sdkroot.mk
9+++ b/mk/rte.sdkroot.mk
10@@ -101,6 +101,10 @@ testall:
11 install uninstall:
12 $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkinstall.mk $@
13
14+.PHONY: test-install
15+test-install:
16+ $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdktest.mk $@
17+
18 .PHONY: doc help
19 doc: doc-all
20 help: doc-help
21diff --git a/mk/rte.sdktest.mk b/mk/rte.sdktest.mk
22index b2c043e..015aab5 100644
23--- a/mk/rte.sdktest.mk
24+++ b/mk/rte.sdktest.mk
25@@ -82,3 +82,16 @@ coverage:
26 else \
27 echo "No test found, please do a 'make build' first, or specify O=" ;\
28 fi
29+
30+test-install:
31+ install -d $(TEST_DESTDIR)/app/test
32+ install -d $(TEST_DESTDIR)/mk
33+ install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc
34+ install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app
35+ install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/.config $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc
36+ install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/Makefile $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc
37+ install $(DPDK_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/app/* $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app/
38+ install $(DPDK_SRC_PATH)/app/test/*.py $(TEST_DESTDIR)/app/test
39+ install $(DPDK_SRC_PATH)/Makefile $(TEST_DESTDIR)
40+ cp -r $(DPDK_SRC_PATH)/mk/* $(TEST_DESTDIR)/mk
41+ echo "make test O=$(TARGET_ARCH)-default-linuxapp-gcc" >> $(TEST_DESTDIR)/maketest
diff --git a/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x b/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x
new file mode 100644
index 0000000..48b1849
--- /dev/null
+++ b/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x
@@ -0,0 +1,206 @@
1--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
2+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
3@@ -101,6 +101,7 @@ struct rte_kni_device_info {
4
5 /* mbuf size */
6 unsigned mbuf_size;
7+ uint64_t mempool_size;
8 };
9
10 #define KNI_DEVICE "kni"
11--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
12+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
13@@ -21,6 +21,19 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
14
15 #define KNI_MAX_DEVICES 32
16
17+#define PCI_VENDOR_ID_IVSHMEM 0x1AF4
18+#define PCI_DEVICE_ID_IVSHMEM 0x1110
19+#define BAR2 2
20+#define IVSHMEM_MAGIC 0x0BADC0DE
21+#define IVSHMEM_METADATA_SIZE 0x4000
22+#define KNI_FIFO_COUNT_MAX 1024
23+#define KNI_FIFO_SIZE ((KNI_FIFO_COUNT_MAX) * sizeof(void *) + \
24+ sizeof(struct rte_kni_fifo))
25+
26+#define get_virt_addr(x) get_virt_addr_by_size(x,KNI_FIFO_SIZE)
27+#define get_virt_addr_by_size(x,s) (has_ivshmem_metadata ? \
28+ ioremap(x, s) : phys_to_virt(x))
29+
30 extern void kni_net_rx(struct kni_dev *kni);
31 extern void kni_net_init(struct net_device *dev);
32 extern void kni_net_config_lo_mode(char *lo_str);
33@@ -47,6 +60,8 @@ static int kni_thread_single(void *unused);
34 /* KNI processing for multiple kernel thread mode */
35 static int kni_thread_multiple(void *param);
36
37+static int kni_has_ivshmem_metadata(void);
38+
39 static struct file_operations kni_fops = {
40 .owner = THIS_MODULE,
41 .open = kni_open,
42@@ -72,6 +87,7 @@ static unsigned multiple_kthread_on = 0;
43
44 static volatile unsigned long device_in_use; /* device in use flag */
45 static struct task_struct *kni_kthread;
46+static int has_ivshmem_metadata = 0;
47
48 /* kni list lock */
49 static DECLARE_RWSEM(kni_list_lock);
50@@ -100,6 +116,10 @@ kni_init(void)
51 /* Configure the lo mode according to the input parameter */
52 kni_net_config_lo_mode(lo_mode);
53
54+ has_ivshmem_metadata = kni_has_ivshmem_metadata();
55+ KNI_PRINT("IVSHMEM metadata %s \n",
56+ has_ivshmem_metadata ? "found" : "NOT found");
57+
58 KNI_PRINT("######## DPDK kni module loaded ########\n");
59
60 return 0;
61@@ -178,6 +198,19 @@ kni_release(struct inode *inode, struct file *file)
62 #endif
63 kni_dev_remove(dev);
64 list_del(&dev->list);
65+
66+ if (has_ivshmem_metadata) {
67+ KNI_PRINT("iounmapping KNI FIFOs for device '%s'\n", dev->name);
68+ iounmap(dev->tx_q);
69+ iounmap(dev->rx_q);
70+ iounmap(dev->alloc_q);
71+ iounmap(dev->free_q);
72+ iounmap(dev->req_q);
73+ iounmap(dev->resp_q);
74+ iounmap(dev->sync_kva);
75+ iounmap(dev->mbuf_kva);
76+ }
77+
78 }
79 up_write(&kni_list_lock);
80
81@@ -339,17 +372,17 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param)
82 strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE);
83
84 /* Translate user space info into kernel space info */
85- kni->tx_q = phys_to_virt(dev_info.tx_phys);
86- kni->rx_q = phys_to_virt(dev_info.rx_phys);
87- kni->alloc_q = phys_to_virt(dev_info.alloc_phys);
88- kni->free_q = phys_to_virt(dev_info.free_phys);
89+ kni->tx_q = get_virt_addr(dev_info.tx_phys);
90+ kni->rx_q = get_virt_addr(dev_info.rx_phys);
91+ kni->alloc_q = get_virt_addr(dev_info.alloc_phys);
92+ kni->free_q = get_virt_addr(dev_info.free_phys);
93
94- kni->req_q = phys_to_virt(dev_info.req_phys);
95- kni->resp_q = phys_to_virt(dev_info.resp_phys);
96+ kni->req_q = get_virt_addr(dev_info.req_phys);
97+ kni->resp_q = get_virt_addr(dev_info.resp_phys);
98 kni->sync_va = dev_info.sync_va;
99- kni->sync_kva = phys_to_virt(dev_info.sync_phys);
100+ kni->sync_kva = get_virt_addr(dev_info.sync_phys);
101
102- kni->mbuf_kva = phys_to_virt(dev_info.mbuf_phys);
103+ kni->mbuf_kva = get_virt_addr_by_size(dev_info.mbuf_phys, dev_info.mempool_size);
104 kni->mbuf_va = dev_info.mbuf_va;
105
106 #ifdef RTE_KNI_VHOST
107@@ -552,6 +585,40 @@ kni_compat_ioctl(struct inode *inode,
108 return -EINVAL;
109 }
110
111+static int
112+kni_has_ivshmem_metadata(void)
113+{
114+ struct pci_dev *ivshm_dev = NULL;
115+ phys_addr_t ivshmem_metadata_addr = 0;
116+ void *ivshmem_metadata = NULL;
117+ int ivshmem_magic_number;
118+
119+ ivshm_dev = pci_get_device(PCI_VENDOR_ID_IVSHMEM, PCI_DEVICE_ID_IVSHMEM,
120+ NULL);
121+
122+ if (ivshm_dev == NULL) {
123+ printk("No IVSHMEM device found!\n");
124+ return 0;
125+ }
126+
127+ /* IVSHMEM metadata will be received at the very last 4K of the BAR2 */
128+ ivshmem_metadata_addr = (pci_resource_end(ivshm_dev, BAR2)
129+ - IVSHMEM_METADATA_SIZE) + 1;
130+
131+ ivshmem_metadata = ioremap(ivshmem_metadata_addr, IVSHMEM_METADATA_SIZE);
132+ if (ivshmem_metadata == NULL) {
133+ printk("Could not ioremap IVSHMEM metadata\n");
134+ return 0;
135+ }
136+
137+ /* The first sizeof(int) bytes contain the magic number that tells us
138+ * ivshmem_metadata is coming from the host */
139+ ivshmem_magic_number = ((int*) ivshmem_metadata)[0];
140+ iounmap(ivshmem_metadata);
141+ return !!(ivshmem_magic_number == IVSHMEM_MAGIC);
142+}
143+
144+
145 module_init(kni_init);
146 module_exit(kni_exit);
147
148--- a/lib/librte_eal/linuxapp/kni/kni_net.c
149+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
150@@ -50,15 +50,16 @@ kni_net_open(struct net_device *dev)
151 struct rte_kni_request req;
152 struct kni_dev *kni = netdev_priv(dev);
153
154- if (kni->lad_dev)
155- memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
156- else
157- /*
158- * Generate random mac address. eth_random_addr() is the newer
159- * version of generating mac address in linux kernel.
160- */
161- random_ether_addr(dev->dev_addr);
162-
163+ if (!is_valid_ether_addr(dev->dev_addr)) {
164+ if (kni->lad_dev)
165+ memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
166+ else
167+ /*
168+ * Generate random mac address. eth_random_addr() is the newer
169+ * version of generating mac address in linux kernel.
170+ */
171+ random_ether_addr(dev->dev_addr);
172+ }
173 netif_start_queue(dev);
174
175 memset(&req, 0, sizeof(req));
176@@ -459,6 +460,22 @@ kni_net_tx_timeout (struct net_device *dev)
177 return;
178 }
179
180+static int
181+kni_set_mac_address(struct net_device *dev, void *addr_ptr)
182+{
183+ struct sockaddr *addr = addr_ptr;
184+
185+ if (netif_running(dev))
186+ return -EBUSY;
187+
188+ if (!is_valid_ether_addr(addr->sa_data))
189+ return -EADDRNOTAVAIL;
190+
191+ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
192+
193+ return 0;
194+}
195+
196 /*
197 * Ioctl commands
198 */
199@@ -608,6 +625,7 @@ static const struct net_device_ops kni_net_netdev_ops = {
200 .ndo_do_ioctl = kni_net_ioctl,
201 .ndo_get_stats = kni_net_stats,
202 .ndo_tx_timeout = kni_net_tx_timeout,
203+ .ndo_set_mac_address = kni_set_mac_address,
204 };
205
206 void
diff --git a/recipes-networking/dpdk/files/run-ptest b/recipes-networking/dpdk/files/run-ptest
new file mode 100644
index 0000000..76fd407
--- /dev/null
+++ b/recipes-networking/dpdk/files/run-ptest
@@ -0,0 +1,195 @@
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]
8
9#check hugetlbfs mount
10echo -n "Mounting hugepages..."
11mount | grep "nodev on /mnt/huge type hugetlbfs"
12if [ $? -ne 0 ]; then
13 mkdir -p /mnt/huge
14 mount -t hugetlbfs nodev /mnt/huge
15fi
16echo "OK!"
17
18#increase hugepages for all nodes
19echo -n "Allocating hugepages..."
20#get hugepages sizes
21hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"`
22#calculate huge pages number to get the equivalent of 1024 pages of 2MB
23huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}`
24#get hugepages no
25hp=0
26#Find out if this is a NUMA machine
27ls /sys/devices/system/node/node* > /dev/null 2>&1
28if [ $? -ne 0 ]; then
29 hp=`cat /proc/sys/vm/nr_hugepages`
30 hptest=`expr $hp + $huge_pages_no`
31 echo $hptest > /proc/sys/vm/nr_hugepages
32else
33 hparray=()
34 nodes=`ls /sys/devices/system/node | grep node | wc -l`
35 for (( i=0; $i<$nodes; i++ ))
36 do
37 hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages`
38 hptest=`expr $hp + $huge_pages_no`
39 echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages
40 hparray+=("$hp")
41 done
42fi
43echo "OK!"
44echo "Allocated ${huge_pages_no} x ${hp_sz}kB"
45
46#run l2fwd loopback test
47DEVS=("I350" "82599")
48PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py
49IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko
50RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko
51
52rmmod rte_kni > /dev/null 2>&1
53rmmod igb_uio > /dev/null 2>&1
54modprobe uio && insmod ${IGB_UIO}
55
56#insert igb_uio, needed by some dpdk tests
57if [ $? -ne 0 ]; then
58 echo "FAIL: uio/igb_uio load"
59 DEVS=()
60else
61 echo "PASS: uio/igb_uio load"
62fi
63
64#insert rte_kni driver in loopback mode, needed by KNI tests
65insmod ${RTE_KNI} lo_mode=lo_mode_fifo
66
67if [ $? -ne 0 ]; then
68 echo "FAIL: rte_kni load"
69 DEVS=()
70else
71 echo "PASS: rte_kni load"
72fi
73
74#bind devices to igb_uio, needed by some dpdk tests
75drvarray=()
76pciarray=()
77for dev in ${DEVS[@]}
78do
79 DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
80 if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
81 continue
82 fi
83
84 DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
85 DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
86 DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
87 DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
88
89 echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
90
91 if [ ! -z ${DEV_ETH} ]; then
92 ifconfig ${DEV_ETH} down
93 fi
94
95 ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
96 drvarray+=("${DEV_DRV}")
97 pciarray+=("${DEV_PCI_ADDR}")
98done
99
100#run dpdk tests
101python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET}
102
103#bind devices to initial drivers
104for ((i=0;i<${#pciarray[@]};i++));
105do
106 echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}"
107 ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}
108done
109
110for dev in ${DEVS[@]}
111do
112 DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
113 if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
114 echo "SKIP: l2fwd-lpbk ($dev)"
115 continue
116 fi
117
118 DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
119 DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
120 DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
121 DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
122
123 echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
124
125 if [ ! -z ${DEV_ETH} ]; then
126 ifconfig ${DEV_ETH} down
127 fi
128
129 ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
130
131 ./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 &
132 APP_PID=$!
133 sleep 20
134 kill $APP_PID
135
136 DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
137 DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
138 DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
139
140
141 echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP"
142
143 STATUS=0
144
145 case "$dev" in
146 "I350")
147 if [ ${DEV_SENT} -lt 13000000 ]; then
148 STATUS=1
149 fi
150 ;;
151 "82599")
152 if [ ${DEV_SENT} -lt 110000000 ]; then
153 STATUS=1
154 fi
155 ;;
156 esac
157
158 if [ ${STATUS} -ne 0 ]; then
159 echo "FAIL: l2fwd-lpbk (low throughput)"
160 fi
161
162 if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then
163 echo "FAIL: l2fwd-lpbk (dropped packets)"
164 STATUS=1
165 fi
166
167 if [ ${STATUS} -eq 0 ]; then
168 echo "PASS: l2fwd-lpbk ($dev)"
169 fi
170
171 ${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR}
172done
173
174if [ ! -z ${DEVS} ]; then
175 rmmod rte_kni > /dev/null 2>&1
176 rmmod igb_uio > /dev/null 2>&1
177 rmmod uio > /dev/null 2>&1
178fi
179
180echo -n "Freeing hugepages..."
181#Find out if this is a NUMA machine
182ls /sys/devices/system/node/node* > /dev/null 2>&1
183if [ $? -ne 0 ]; then
184 echo $hp > /proc/sys/vm/nr_hugepages
185else
186 i=0
187 for hp in ${hparray[@]}
188 do
189 echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages"
190 ((i++))
191 done
192fi
193echo "OK!"
194rm -rf /mnt/huge/*
195
diff --git a/recipes-networking/dpdk/files/runtest.patch b/recipes-networking/dpdk/files/runtest.patch
new file mode 100644
index 0000000..0432fb7
--- /dev/null
+++ b/recipes-networking/dpdk/files/runtest.patch
@@ -0,0 +1,20 @@
1Adapt test output.
2
3Signed-off-by: Costin Popescu <costin.popescu@enea.com>
4Upstream-Status: Pending
5
6diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
7index af225ff..33b776a 100644
8--- a/app/test/autotest_runner.py
9+++ b/app/test/autotest_runner.py
10@@ -267,6 +267,10 @@ class AutotestRunner:
11 # if test failed and it wasn't a "start" test
12 if test_result < 0 and not i == 0:
13 self.fails += 1
14+ if test_result < 0:
15+ print "FAIL: %s" % test_name
16+ else:
17+ print "PASS: %s" % test_name
18
19 # collect logs
20 self.log_buffers.append(log)
diff --git a/recipes-networking/dpdk/files/unbreak-makefiles.patch b/recipes-networking/dpdk/files/unbreak-makefiles.patch
new file mode 100644
index 0000000..f96dd68
--- /dev/null
+++ b/recipes-networking/dpdk/files/unbreak-makefiles.patch
@@ -0,0 +1,87 @@
1Fix makefiles.
2
3Signed-off-by: Costin Popescu <costin.popescu@enea.com>
4Upstream-Status: Pending
5
6diff --git a/mk/rte.app.mk b/mk/rte.app.mk
7index d90a0b0..93f1dd9 100644
8--- a/mk/rte.app.mk
9+++ b/mk/rte.app.mk
10@@ -203,6 +203,7 @@ endif
11
12 ifeq ($(LINK_USING_CC),1)
13 comma := ,
14+LDFLAGS := $(patsubst -Wl$(comma)%,%,$(LDFLAGS))
15 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
16 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
17 override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
18diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk
19index a163272..9fb07d8 100644
20--- a/mk/target/generic/rte.vars.mk
21+++ b/mk/target/generic/rte.vars.mk
22@@ -107,7 +107,7 @@ ifeq ($(KERNELRELEASE),)
23 include $(RTE_SDK)/mk/rte.cpuflags.mk
24
25 # merge all CFLAGS
26-CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS)
27+CFLAGS += $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS)
28 CFLAGS += $(TARGET_CFLAGS) $(EXTERNAL_LIB_CFLAGS)
29
30 # merge all LDFLAGS
31@@ -115,7 +115,7 @@ LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFL
32 LDFLAGS += $(TARGET_LDFLAGS)
33
34 # merge all ASFLAGS
35-ASFLAGS := $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS)
36+ASFLAGS += $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS)
37 ASFLAGS += $(TARGET_ASFLAGS)
38
39 # add default include and lib paths
40diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
41index 0edb93f..adba7d4 100644
42--- a/mk/toolchain/gcc/rte.vars.mk
43+++ b/mk/toolchain/gcc/rte.vars.mk
44@@ -40,21 +40,20 @@
45 # examples for RTE_TOOLCHAIN: gcc, icc
46 #
47
48-CC = $(CROSS)gcc
49-CPP = $(CROSS)cpp
50-# for now, we don't use as but nasm.
51-# AS = $(CROSS)as
52-AS = nasm
53-AR = $(CROSS)ar
54-LD = $(CROSS)ld
55-OBJCOPY = $(CROSS)objcopy
56-OBJDUMP = $(CROSS)objdump
57-STRIP = $(CROSS)strip
58-READELF = $(CROSS)readelf
59-GCOV = $(CROSS)gcov
60+CC ?= $(CROSS)gcc
61+CPP ?= $(CROSS)cpp
62+AS ?= $(CROSS)as
63+#AS ?= nasm
64+AR ?= $(CROSS)ar
65+LD ?= $(CROSS)ld
66+OBJCOPY ?= $(CROSS)objcopy
67+OBJDUMP ?= $(CROSS)objdump
68+STRIP ?= $(CROSS)strip
69+READELF ?= $(CROSS)readelf
70+GCOV ?= $(CROSS)gcov
71
72-HOSTCC = gcc
73-HOSTAS = as
74+HOSTCC ?= gcc
75+HOSTAS ?= as
76
77 TOOLCHAIN_ASFLAGS =
78 TOOLCHAIN_CFLAGS =
79@@ -68,7 +67,7 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
80 endif
81 endif
82
83-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
84+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
85 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
86 WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
87 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
diff --git a/recipes-networking/openvswitchdpdk/files/0001-openvswitchdpdk-enabled-ptest.patch b/recipes-networking/openvswitchdpdk/files/0001-openvswitchdpdk-enabled-ptest.patch
new file mode 100644
index 0000000..10f0df8
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/0001-openvswitchdpdk-enabled-ptest.patch
@@ -0,0 +1,380 @@
1From 1ea34b3e5bf1d386b9931f11dee89bc03f224852 Mon Sep 17 00:00:00 2001
2From: Radu Patriu <radu.patriu@enea.com>
3Date: Tue, 6 May 2014 13:02:10 +0000
4Subject: [PATCH] openvswitchdpdk: enabled ptest
5
6Signed-off-by: Radu Patriu <radu.patriu@enea.com>
7---
8 openvswitch/Makefile.am | 1 +
9 openvswitch/test.mk | 47 ++++++++++++++++++++++++++++++++++++
10 openvswitch/tests/dpdk-datapath.at | 48 ++++++++++++++++++-------------------
11 openvswitch/tests/dpdk-link.at | 2 +-
12 openvswitch/tests/dpif-dpdk.at | 30 +++++++++++------------
13 openvswitch/tests/flowgen.pl | 0
14 openvswitch/tests/netdev-dpdk.at | 2 +-
15 openvswitch/tests/ofproto-macros.at | 2 +-
16 openvswitch/tests/ovs-vport.at | 10 ++++----
17 9 files changed, 95 insertions(+), 47 deletions(-)
18 create mode 100644 openvswitch/test.mk
19 mode change 100644 => 100755 openvswitch/tests/flowgen.pl
20
21diff --git a/openvswitch/Makefile.am b/openvswitch/Makefile.am
22index d0edfa2..107ca89 100644
23--- a/openvswitch/Makefile.am
24+++ b/openvswitch/Makefile.am
25@@ -311,3 +311,4 @@ include xenserver/automake.mk
26 include python/automake.mk
27 include python/compat/automake.mk
28 include tutorial/automake.mk
29+include test.mk
30\ No newline at end of file
31diff --git a/openvswitch/test.mk b/openvswitch/test.mk
32new file mode 100644
33index 0000000..10f3629
34--- /dev/null
35+++ b/openvswitch/test.mk
36@@ -0,0 +1,47 @@
37+TEST_DEST ?= ${prefix}/lib/openvswitchdpdk/ptest
38+TEST_ROOT ?= ${prefix}/lib/openvswitchdpdk/ptest
39+TEST_DEPEND =
40+
41+if HAVE_OPENSSL
42+TEST_DEPEND += $(TESTPKI_FILES)
43+endif
44+
45+test-install: $(TEST_DEPEND)
46+ @list='$(noinst_PROGRAMS) $(EXTRA_DIST) $(dist_check_SCRIPTS) $(TEST_DEPEND) tests/atlocal tests/atconfig' ;\
47+ install -d $(TEST_DEST)/tests ;\
48+ install -d $(TEST_DEST)/python ;\
49+ install -d $(TEST_DEST)/python/ovs ;\
50+ install -d $(TEST_DEST)/python/ovs/db ;\
51+ install -d $(TEST_DEST)/python/ovs/unixctl ;\
52+ install -d $(TEST_DEST)/vswitchd ;\
53+ install vswitchd/vswitch.ovsschema $(TEST_DEST)/vswitchd ;\
54+ install -d $(TEST_DEST)/debian ;\
55+ install debian/ovs-monitor-ipsec $(TEST_DEST)/debian ;\
56+ install -d $(TEST_DEST)/build-aux ;\
57+ install build-aux/check-structs $(TEST_DEST)/build-aux ;\
58+ install -d $(TEST_DEST)/xenserver ;\
59+ install xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync $(TEST_DEST)/xenserver ;\
60+ install xenserver/opt_xensource_libexec_interface-reconfigure $(TEST_DEST)/xenserver ;\
61+ install xenserver/opt_xensource_libexec_InterfaceReconfigure.py $(TEST_DEST)/xenserver ;\
62+ install xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py $(TEST_DEST)/xenserver ;\
63+ install xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py $(TEST_DEST)/xenserver ;\
64+ for p in $$list ; do \
65+ echo $$p ;\
66+ p=$${p#./} ;\
67+ pre=$${p#tests\/} ;\
68+ if test $$pre != $$p ; then \
69+ echo installing $$p to $(TEST_DEST)/tests/$$pre ;\
70+ install $$p $(TEST_DEST)/tests/$$pre ;\
71+ continue ;\
72+ fi ;\
73+ pre=$${p#python\/ovs\/} ;\
74+ if test $$pre != $$p ; then \
75+ echo installing $$p to $(TEST_DEST)/python/ovs/$$pre ;\
76+ install $$p $(TEST_DEST)/python/ovs/$$pre ;\
77+ continue ;\
78+ fi; \
79+ done ;\
80+ sed -i 's|abs_builddir=.*|abs_builddir='"'"'$(TEST_ROOT)/tests'"'"'|g' $(TEST_DEST)/tests/atconfig
81+ sed -i 's|abs_srcdir=.*|abs_srcdir='"'"'$(TEST_ROOT)/tests'"'"'|g' $(TEST_DEST)/tests/atconfig
82+ sed -i 's|abs_top_srcdir=.*|abs_top_srcdir='"'"'$(TEST_ROOT)'"'"'|g' $(TEST_DEST)/tests/atconfig
83+ sed -i 's|abs_top_builddir=.*|abs_top_builddir='"'"'$(TEST_ROOT)'"'"'|g' $(TEST_DEST)/tests/atconfig
84diff --git a/openvswitch/tests/dpdk-datapath.at b/openvswitch/tests/dpdk-datapath.at
85index 5472ae3..16c5f3d 100644
86--- a/openvswitch/tests/dpdk-datapath.at
87+++ b/openvswitch/tests/dpdk-datapath.at
88@@ -28,47 +28,47 @@
89 m4_define([OVDK_CHECK_ACTION_EXECUTE],
90 [AT_BANNER([action_execute unit tests - dpdk datapath])
91 AT_SETUP([execute an output action])
92-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output], [0], [ignore], [])
93+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output], [0], [ignore], [])
94 AT_CLEANUP
95
96 AT_SETUP([execute an output action with invalid parameters])
97-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output__invalid_params], [0], [ignore], [])
98+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output__invalid_params], [0], [ignore], [])
99 AT_CLEANUP
100
101 AT_SETUP([execute a corrupt action])
102-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output__corrupt_action], [0], [ignore], [])
103+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_output__corrupt_action], [0], [ignore], [])
104 AT_CLEANUP
105
106 AT_SETUP([execute a drop action])
107-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_drop], [0], [ignore], [])
108+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_drop], [0], [ignore], [])
109 AT_CLEANUP
110
111 AT_SETUP([execute a pop VLAN action])
112-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_pop_vlan], [0], [ignore], [])
113+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_pop_vlan], [0], [ignore], [])
114 AT_CLEANUP
115
116 AT_SETUP([execute a set ethernet action])
117-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_set_ethernet], [0], [ignore], [])
118+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_set_ethernet], [0], [ignore], [])
119 AT_CLEANUP
120
121 AT_SETUP([execute a set ipv4 action])
122-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_set_ipv4], [0], [ignore], [])
123+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_set_ipv4], [0], [ignore], [])
124 AT_CLEANUP
125
126 AT_SETUP([execute a push VLAN vid action])
127-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_push_vlan__vid], [0], [ignore], [])
128+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_push_vlan__vid], [0], [ignore], [])
129 AT_CLEANUP
130
131 AT_SETUP([execute a push VLAN pcp action])
132-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_push_vlan__pcp], [0], [ignore], [])
133+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_push_vlan__pcp], [0], [ignore], [])
134 AT_CLEANUP
135
136 AT_SETUP([execute multiple actions with three output actions])
137-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_multiple_actions__three_output], [0], [ignore], [])
138+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_multiple_actions__three_output], [0], [ignore], [])
139 AT_CLEANUP
140
141 AT_SETUP([execute multiple actions with a pop vlan and output action])
142-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_multiple_actions__pop_vlan_and_output], [0], [ignore], [])
143+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- action_execute_multiple_actions__pop_vlan_and_output], [0], [ignore], [])
144 AT_CLEANUP
145 ])
146
147@@ -77,31 +77,31 @@ AT_CLEANUP
148 m4_define([OVDK_CHECK_FLOW_TABLE],
149 [AT_BANNER([flow table unit tests - dpdk datapath])
150 AT_SETUP([add a flow to the flow table])
151-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_add_flow], [0], [ignore], [])
152+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_add_flow], [0], [ignore], [])
153 AT_CLEANUP
154
155 AT_SETUP([delete a flow from the flow table])
156-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_del_flow], [0], [ignore], [])
157+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_del_flow], [0], [ignore], [])
158 AT_CLEANUP
159
160 AT_SETUP([delete all flows from the flow table])
161-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_del_all], [0], [ignore], [])
162+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_del_all], [0], [ignore], [])
163 AT_CLEANUP
164
165 AT_SETUP([get a flow from the flow table])
166-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_flow], [0], [ignore], [])
167+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_flow], [0], [ignore], [])
168 AT_CLEANUP
169
170 AT_SETUP([modify a flow in the flow table])
171-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_mod_flow], [0], [ignore], [])
172+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_mod_flow], [0], [ignore], [])
173 AT_CLEANUP
174
175 AT_SETUP([get the first flow from the flow table])
176-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_first_flow], [0], [ignore], [])
177+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_first_flow], [0], [ignore], [])
178 AT_CLEANUP
179
180 AT_SETUP([get the next flow from the flow table])
181-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_next_flow], [0], [ignore], [])
182+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- flow_table_get_next_flow], [0], [ignore], [])
183 AT_CLEANUP
184 ])
185
186@@ -110,27 +110,27 @@ AT_CLEANUP
187 m4_define([OVDK_CHECK_STATS],
188 [AT_BANNER([stats unit tests - dpdk datapath])
189 AT_SETUP([increment stats for all vports])
190-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_increment], [0], [ignore], [])
191+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_increment], [0], [ignore], [])
192 AT_CLEANUP
193
194 AT_SETUP([get stats for all vports])
195-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_get], [0], [ignore], [])
196+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_get], [0], [ignore], [])
197 AT_CLEANUP
198
199 AT_SETUP([clear stats for all vports])
200-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_clear], [0], [ignore], [])
201+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vport_xxx_clear], [0], [ignore], [])
202 AT_CLEANUP
203
204 AT_SETUP([increment stats for the vswitch])
205-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_increment], [0], [ignore], [])
206+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_increment], [0], [ignore], [])
207 AT_CLEANUP
208
209 AT_SETUP([get stats for the vswitch])
210-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_get], [0], [ignore], [])
211+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_get], [0], [ignore], [])
212 AT_CLEANUP
213
214 AT_SETUP([clear stats for the vswitch])
215-AT_CHECK([sudo -E $srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_clear], [0], [ignore], [])
216+AT_CHECK([$srcdir/dpdk/test-datapath -c 1 -n 4 -- stats_vswitch_clear], [0], [ignore], [])
217 AT_CLEANUP
218 ])
219
220diff --git a/openvswitch/tests/dpdk-link.at b/openvswitch/tests/dpdk-link.at
221index accfde9..c119668 100644
222--- a/openvswitch/tests/dpdk-link.at
223+++ b/openvswitch/tests/dpdk-link.at
224@@ -29,7 +29,7 @@
225 m4_define([CHECK_DPDK_LINK],
226 [AT_BANNER([dpdk-link tests])
227 AT_SETUP([Check negative cases for dpdk-link.c])
228-AT_CHECK([sudo -E $srcdir/test-dpdk-link -c 1 -n 4], [0], [ignore], [])
229+AT_CHECK([$srcdir/test-dpdk-link -c 1 -n 4], [0], [ignore], [])
230 AT_CLEANUP
231 ])
232
233diff --git a/openvswitch/tests/dpif-dpdk.at b/openvswitch/tests/dpif-dpdk.at
234index 55b3505..b62d146 100644
235--- a/openvswitch/tests/dpif-dpdk.at
236+++ b/openvswitch/tests/dpif-dpdk.at
237@@ -2,63 +2,63 @@ m4_define([CHECK_DPIF_DPDK],
238
239 [AT_BANNER([Test dpif-dpdk.c ])
240 AT_SETUP([Test dpif_dpdk_get_stats])
241-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_get_stats], [0], [ignore], [])
242+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_get_stats], [0], [ignore], [])
243 AT_CLEANUP
244
245 AT_SETUP([Test dpif_dpdk_port_add])
246-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_add], [0], [ignore], [ignore])
247+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_add], [0], [ignore], [ignore])
248 AT_CLEANUP
249
250 AT_SETUP([Test dpif_dpdk_port_del])
251-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_del], [0], [ignore], [])
252+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_del], [0], [ignore], [])
253 AT_CLEANUP
254
255 AT_SETUP([Test dpif_dpdk_port_query_by_number])
256-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_query_by_number], [0], [ignore], [ignore])
257+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_query_by_number], [0], [ignore], [ignore])
258 AT_CLEANUP
259
260 AT_SETUP([Test dpif_dpdk_port_query_by_name])
261-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_query_by_name], [0], [ignore], [ignore])
262+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_query_by_name], [0], [ignore], [ignore])
263 AT_CLEANUP
264
265 AT_SETUP([Test dpif_dpdk_get_max_ports])
266-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_get_max_ports], [0], [ignore], [])
267+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_get_max_ports], [0], [ignore], [])
268 AT_CLEANUP
269
270 AT_SETUP([Test dpif_dpdk_port_dump_start])
271-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_start], [0], [ignore], [])
272+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_start], [0], [ignore], [])
273 AT_CLEANUP
274
275 AT_SETUP([Test dpif_dpdk_port_dump_next])
276-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_next], [0], [ignore], [])
277+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_next], [0], [ignore], [])
278 AT_CLEANUP
279
280 AT_SETUP([Test dpif_dpdk_port_dump_done])
281-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_done], [0], [ignore], [])
282+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_dump_done], [0], [ignore], [])
283 AT_CLEANUP
284
285 AT_SETUP([Test dpif_dpdk_port_poll])
286-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_poll], [0], [ignore], [])
287+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_poll], [0], [ignore], [])
288 AT_CLEANUP
289
290 AT_SETUP([Test dpif_dpdk_port_poll_wait])
291-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_poll_wait], [0], [ignore], [])
292+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_port_poll_wait], [0], [ignore], [])
293 AT_CLEANUP
294
295 AT_SETUP([Test dpif_dpdk_flow_put])
296-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_put], [0], [ignore], [])
297+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_put], [0], [ignore], [])
298 AT_CLEANUP
299
300 AT_SETUP([Test dpif_dpdk_flow_del])
301-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_del], [0], [ignore], [])
302+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_del], [0], [ignore], [])
303 AT_CLEANUP
304
305 AT_SETUP([Test dpif_dpdk_flow_dump_start])
306-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_dump_start], [0], [ignore], [])
307+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_dump_start], [0], [ignore], [])
308 AT_CLEANUP
309
310 AT_SETUP([Test dpif_dpdk_flow_dump_next])
311-AT_CHECK([sudo -E $srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_dump_next], [0], [ignore], [])
312+AT_CHECK([$srcdir/test-dpif-dpdk -c 1 -n 4 -- --dpif_dpdk_flow_dump_next], [0], [ignore], [])
313 AT_CLEANUP
314 ])
315 CHECK_DPIF_DPDK([])
316diff --git a/openvswitch/tests/flowgen.pl b/openvswitch/tests/flowgen.pl
317old mode 100644
318new mode 100755
319diff --git a/openvswitch/tests/netdev-dpdk.at b/openvswitch/tests/netdev-dpdk.at
320index df4cd89..d314e3c 100644
321--- a/openvswitch/tests/netdev-dpdk.at
322+++ b/openvswitch/tests/netdev-dpdk.at
323@@ -3,7 +3,7 @@ m4_define([CHECK_DPIF_DPDK],
324 [AT_BANNER([Test netdev-dpdk.c ])
325
326 AT_SETUP([Test netdev_dpdk_change_seq])
327-AT_CHECK([sudo -E $srcdir/test-netdev-dpdk --netdev_dpdk_test_change_seq], [0], [ignore], [])
328+AT_CHECK([$srcdir/test-netdev-dpdk --netdev_dpdk_test_change_seq], [0], [ignore], [])
329 AT_CLEANUP
330
331 ])
332diff --git a/openvswitch/tests/ofproto-macros.at b/openvswitch/tests/ofproto-macros.at
333index 839d41f..ef291dd 100644
334--- a/openvswitch/tests/ofproto-macros.at
335+++ b/openvswitch/tests/ofproto-macros.at
336@@ -73,7 +73,7 @@ m4_define([OVS_VSWITCHD_START],
337 AT_CHECK([ovs-vsctl --no-wait init])
338
339 dnl Start ovs-vswitchd.
340- AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy$3 --disable-system --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
341+ AT_CHECK([ovs-vswitchd -c 1 -n 4 -- --detach --no-chdir --pidfile --enable-dummy$3 --disable-system --log-file -vvconn -vofproto_dpif], [0], [ignore], [stderr])
342 AT_CAPTURE_FILE([ovs-vswitchd.log])
343 AT_CHECK([[sed < stderr '
344 /vlog|INFO|opened log file/d
345diff --git a/openvswitch/tests/ovs-vport.at b/openvswitch/tests/ovs-vport.at
346index 5f6857c..19d87cc 100644
347--- a/openvswitch/tests/ovs-vport.at
348+++ b/openvswitch/tests/ovs-vport.at
349@@ -6,23 +6,23 @@ m4_define([OVDK_CHECK_LIBVPORT],
350 [AT_BANNER([libvport/ovs-vport unit tests - dpdk datapath])
351
352 AT_SETUP([check vports are valid])
353-AT_CHECK([sudo -E $srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- valid_vport], [0], [ignore], [])
354+AT_CHECK([$srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- valid_vport], [0], [ignore], [])
355 AT_CLEANUP
356
357 AT_SETUP([check client rings are found])
358-AT_CHECK([sudo -E $srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- vport_client_lookup], [0], [ignore], [])
359+AT_CHECK([$srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- vport_client_lookup], [0], [ignore], [])
360 AT_CLEANUP
361
362 AT_SETUP([check kni fifos are found])
363-AT_CHECK([sudo -E $srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- vport_kni_lookup], [0], [ignore], [])
364+AT_CHECK([$srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- vport_kni_lookup], [0], [ignore], [])
365 AT_CLEANUP
366
367 AT_SETUP([check packet mempool is found])
368-AT_CHECK([sudo -E $srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- lookup_packet_mempool], [0], [ignore], [])
369+AT_CHECK([$srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- lookup_packet_mempool], [0], [ignore], [])
370 AT_CLEANUP
371
372 AT_SETUP([check port names are valid])
373-AT_CHECK([sudo -E $srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- is_vport_name_valid], [0], [ignore], [])
374+AT_CHECK([$srcdir/dpdk/test-ovs-vport -c 1 -n 4 -- is_vport_name_valid], [0], [ignore], [])
375 AT_CLEANUP
376
377 ])
378--
3791.8.5.2
380
diff --git a/recipes-networking/openvswitchdpdk/files/configure-fix.patch b/recipes-networking/openvswitchdpdk/files/configure-fix.patch
new file mode 100644
index 0000000..187e8a0
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/configure-fix.patch
@@ -0,0 +1,12 @@
1Index: files/configure.ac
2===================================================================
3--- files.orig/openvswitch/configure.ac 2014-03-26 16:49:44.000000000 +0200
4+++ files/openvswitch/configure.ac 2014-04-18 16:47:28.163114309 +0300
5@@ -47,6 +47,7 @@
6 AC_SEARCH_LIBS([clock_gettime], [rt])
7 AC_SEARCH_LIBS([timer_create], [rt])
8 AC_SEARCH_LIBS([pthread_sigmask], [pthread])
9+AC_SEARCH_LIBS([dlopen], [dl])
10 AC_FUNC_STRERROR_R
11
12 OVS_CHECK_ESX
diff --git a/recipes-networking/openvswitchdpdk/files/makefile-install-rule.patch b/recipes-networking/openvswitchdpdk/files/makefile-install-rule.patch
new file mode 100644
index 0000000..2609870
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/makefile-install-rule.patch
@@ -0,0 +1,22 @@
1Index: dpdk-ovs/openvswitch/datapath/dpdk/Makefile
2===================================================================
3--- dpdk-ovs.orig/openvswitch/datapath/dpdk/Makefile 2014-04-18 14:06:01.219379540 +0300
4+++ dpdk-ovs/openvswitch/datapath/dpdk/Makefile 2014-04-22 16:24:27.009689498 +0300
5@@ -77,3 +77,6 @@
6
7 clean-vport_ut:
8 $(MAKE) -f Makefile.vport_ut clean
9+
10+install:
11+
12Index: dpdk-ovs/openvswitch/datapath/dpdk/fd_link/Makefile
13===================================================================
14--- dpdk-ovs.orig/openvswitch/datapath/dpdk/fd_link/Makefile 2014-04-18 14:06:01.219379540 +0300
15+++ dpdk-ovs/openvswitch/datapath/dpdk/fd_link/Makefile 2014-04-22 16:24:24.185689575 +0300
16@@ -53,3 +53,6 @@
17
18 check-recursive:
19 $(warning "This target is not implemented")
20+
21+install:
22+
diff --git a/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller
new file mode 100755
index 0000000..fdd5a46
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller
@@ -0,0 +1,279 @@
1#!/bin/sh
2#
3# Copyright (c) 2011 Nicira Networks Inc.
4# Copyright (c) 2007, 2009 Javier Fernandez-Sanguino <jfs@debian.org>
5#
6# This is free software; you may redistribute it and/or modify
7# it under the terms of the GNU General Public License as
8# published by the Free Software Foundation; either version 2,
9# or (at your option) any later version.
10#
11# This is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License with
17# the Debian operating system, in /usr/share/common-licenses/GPL; if
18# not, write to the Free Software Foundation, Inc., 59 Temple Place,
19# Suite 330, Boston, MA 02111-1307 USA
20#
21### BEGIN INIT INFO
22# Provides: openvswitch-controller
23# Required-Start: $network $local_fs $remote_fs
24# Required-Stop: $remote_fs
25# Should-Start: $named
26# Should-Stop:
27# Default-Start: 2 3 4 5
28# Default-Stop: 0 1 6
29# Short-Description: Open vSwitch controller
30### END INIT INFO
31
32INSTALLPREFIX=
33
34if [ -n "$INSTALLPREFIX" ]
35then
36 PATH=$INSTALLPREFIX/sbin:$INSTALLPREFIX/bin:$PATH
37fi
38
39DAEMON=$INSTALLPREFIX/bin/ovs-controller # Introduce the server's location here
40NAME=ovs-controller # Introduce the short server's name here
41DESC=ovs-controller # Introduce a short description here
42LOGDIR=$INSTALLPREFIX/var/log/openvswitch # Log directory to use
43
44PIDFILE=$INSTALLPREFIX/var/run/openvswitch/$NAME.pid
45
46test -x $DAEMON || exit 0
47
48. /lib/lsb/init-functions
49
50# Default options, these can be overriden by the information
51# at /etc/default/openvswitchdpdk-controller
52DAEMON_OPTS="" # Additional options given to the server
53
54DODTIME=10 # Time to wait for the server to die, in seconds
55 # If this value is set too low you might not
56 # let some servers to die gracefully and
57 # 'restart' will not work
58
59LOGFILE=$LOGDIR/$NAME.log # Server logfile
60#DAEMONUSER= # User to run the daemons as. If this value
61 # is set start-stop-daemon will chuid the server
62
63# Include defaults if available
64default=/etc/default/openvswitchdpdk-controller
65if [ -f $default ] ; then
66 . $default
67fi
68
69# Check that the user exists (if we set a user)
70# Does the user exist?
71if [ -n "$DAEMONUSER" ] ; then
72 if getent passwd | grep -q "^$DAEMONUSER:"; then
73 # Obtain the uid and gid
74 DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
75 DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
76 else
77 log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
78 exit 1
79 fi
80fi
81
82
83set -e
84
85running_pid() {
86# Check if a given process pid's cmdline matches a given name
87 pid=$1
88 name=$2
89 [ -z "$pid" ] && return 1
90 [ ! -d /proc/$pid ] && return 1
91 cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
92 # Is this the expected server
93 [ "$cmd" != "$name" ] && return 1
94 return 0
95}
96
97running() {
98# Check if the process is running looking at /proc
99# (works for all users)
100
101 # No pidfile, probably no daemon present
102 [ ! -f "$PIDFILE" ] && return 1
103 pid=`cat $PIDFILE`
104 running_pid $pid $DAEMON || return 1
105 return 0
106}
107
108start_server() {
109 if [ -z "$LISTEN" ]; then
110 echo "$default: No connection methods configured, controller disabled" >&2
111 exit 0
112 fi
113
114 if [ ! -d $INSTALLPREFIX/var/run/openvswitch ]; then
115 install -d -m 755 -o root -g root $INSTALLPREFIX/var/run/openvswitch
116 fi
117
118 SSL_OPTS=
119 case $LISTEN in
120 *ssl*)
121 : ${PRIVKEY:=$INSTALLPREFIX/etc/openvswitch-controller/privkey.pem}
122 : ${CERT:=$INSTALLPREFIX/etc/openvswitch-controller/cert.pem}
123 : ${CACERT:=$INSTALLPREFIX/etc/openvswitch-controller/cacert.pem}
124 if test ! -e "$PRIVKEY" || test ! -e "$CERT" ||
125 test ! -e "$CACERT"; then
126 if test ! -e "$PRIVKEY"; then
127 echo "$PRIVKEY: private key missing" >&2
128 fi
129 if test ! -e "$CERT"; then
130 echo "$CERT: certificate for private key missing" >&2
131 fi
132 if test ! -e "$CACERT"; then
133 echo "$CACERT: CA certificate missing" >&2
134 fi
135 exit 1
136 fi
137 SSL_OPTS="--private-key=$PRIVKEY --certificate=$CERT --ca-cert=$CACERT"
138 ;;
139 esac
140
141# Start the process using the wrapper
142 if [ -z "$DAEMONUSER" ] ; then
143 start-stop-daemon --start --pidfile $PIDFILE \
144 --exec $DAEMON -- --detach --pidfile=$PIDFILE \
145 $LISTEN $DAEMON_OPTS $SSL_OPTS
146 errcode=$?
147 else
148# if we are using a daemonuser then change the user id
149 start-stop-daemon --start --quiet --pidfile $PIDFILE \
150 --chuid $DAEMONUSER --exec $DAEMON -- \
151 --detach --pidfile=$PIDFILE $LISTEN $DAEMON_OPTS \
152 $SSL_OPTS
153 errcode=$?
154 fi
155 return $errcode
156}
157
158stop_server() {
159# Stop the process using the wrapper
160 if [ -z "$DAEMONUSER" ] ; then
161 start-stop-daemon --stop --quiet --pidfile $PIDFILE \
162 --exec $DAEMON
163 errcode=$?
164 else
165# if we are using a daemonuser then look for process that match
166 start-stop-daemon --stop --quiet --pidfile $PIDFILE \
167 --user $DAEMONUSER --exec $DAEMON
168 errcode=$?
169 fi
170
171 return $errcode
172}
173
174reload_server() {
175 [ ! -f "$PIDFILE" ] && return 1
176 pid=`cat $PIDFILE` # This is the daemon's pid
177 # Send a SIGHUP
178 kill -1 $pid
179 return $?
180}
181
182force_stop() {
183# Force the process to die killing it manually
184 [ ! -e "$PIDFILE" ] && return
185 if running ; then
186 kill -15 $pid
187 # Is it really dead?
188 sleep "$DODTIME"
189 if running ; then
190 kill -9 $pid
191 sleep "$DODTIME"
192 if running ; then
193 echo "Cannot kill $NAME (pid=$pid)!"
194 exit 1
195 fi
196 fi
197 fi
198 rm -f $PIDFILE
199}
200
201
202case "$1" in
203 start)
204 log_begin_msg "Starting $DESC " "$NAME"
205 # Check if it's running first
206 if running ; then
207 log_warning_msg "apparently already running"
208 log_end_msg 0
209 exit 0
210 fi
211 if start_server && running ; then
212 # It's ok, the server started and is running
213 log_end_msg 0
214 else
215 # Either we could not start it or it is not running
216 # after we did
217 # NOTE: Some servers might die some time after they start,
218 # this code does not try to detect this and might give
219 # a false positive (use 'status' for that)
220 log_end_msg 1
221 fi
222 ;;
223 stop)
224 log_begin_msg "Stopping $DESC" "$NAME"
225 if running ; then
226 # Only stop the server if we see it running
227 stop_server
228 log_end_msg $?
229 else
230 # If it's not running don't do anything
231 log_warning_msg "apparently not running"
232 log_end_msg 0
233 exit 0
234 fi
235 ;;
236 force-stop)
237 # First try to stop gracefully the program
238 $0 stop
239 if running; then
240 # If it's still running try to kill it more forcefully
241 log_begin_msg "Stopping (force) $DESC" "$NAME"
242 force_stop
243 log_end_msg $?
244 fi
245 ;;
246 restart|force-reload)
247 log_begin_msg "Restarting $DESC" "$NAME"
248 stop_server
249 # Wait some sensible amount, some server need this
250 [ -n "$DODTIME" ] && sleep $DODTIME
251 start_server
252 running
253 log_end_msg $?
254 ;;
255 status)
256
257 log_begin_msg "Checking status of $DESC" "$NAME"
258 if running ; then
259 log_begin_msg "running"
260 log_end_msg 0
261 else
262 log_warning_msg "apparently not running"
263 log_end_msg 1
264 exit 1
265 fi
266 ;;
267 # Use this if the daemon cannot reload
268 reload)
269 log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
270 log_warning_msg "cannot re-read the config file (use restart)."
271 ;;
272 *)
273 N=/etc/init.d/openvswitchdpdk-controller
274 echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
275 exit 1
276 ;;
277esac
278
279exit 0
diff --git a/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller-setup b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller-setup
new file mode 100644
index 0000000..507a85e
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-controller-setup
@@ -0,0 +1,29 @@
1# This is a POSIX shell fragment -*- sh -*-
2
3# LISTEN: What OpenFlow connection methods should the controller listen on?
4#
5# This is a space-delimited list of connection methods:
6#
7# * "pssl:[PORT]": Listen for SSL connections on the specified PORT
8# (default: 6633). The private key, certificate, and CA certificate
9# must be specified below.
10#
11# * "ptcp:[PORT]": Listen for TCP connections on the specified PORT
12# (default: 6633). Not recommended for security reasons.
13#
14LISTEN="ptcp:"
15
16# PRIVKEY: Name of file containing controller's private key.
17# Required if SSL enabled.
18PRIVKEY=$INSTALLPREFIX/etc/openvswitch-controller/privkey.pem
19
20# CERT: Name of file containing certificate for private key.
21# Required if SSL enabled.
22CERT=$INSTALLPREFIX/etc/openvswitch-controller/cert.pem
23
24# CACERT: Name of file containing switch CA certificate.
25# Required if SSL enabled.
26CACERT=$INSTALLPREFIX/etc/openvswitch-controller/cacert.pem
27
28# Additional options to pass to controller, e.g. "--hub"
29DAEMON_OPTS=""
diff --git a/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch
new file mode 100644
index 0000000..051d4d7
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch
@@ -0,0 +1,110 @@
1#! /bin/sh
2#
3# Copyright (C) 2011 Nicira Networks, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at:
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17### BEGIN INIT INFO
18# Provides: openvswitch-switch
19# Required-Start: $network $named $remote_fs $syslog
20# Required-Stop: $remote_fs
21# Default-Start: 2 3 4 5
22# Default-Stop: 0 1 6
23# Short-Description: Open vSwitch switch
24### END INIT INFO
25
26
27INSTALLPREFIX=
28
29if [ -n "$INSTALLPREFIX" ]
30then
31 PATH=$INSTALLPREFIX/sbin:$INSTALLPREFIX/bin:$PATH
32fi
33
34(test -x $INSTALLPREFIX/sbin/ovs-vswitchd && test -x $INSTALLPREFIX/sbin/ovsdb-server) || exit 0
35
36. $INSTALLPREFIX/share/openvswitch/scripts/ovs-lib
37test -e /etc/default/openvswitchdpdk-switch && . /etc/default/openvswitchdpdk-switch
38
39if test X"$BRCOMPAT" = Xyes && test ! -x $INSTALLPREFIX/sbin/ovs-brcompatd; then
40 BRCOMPAT=no
41 log_warning_msg "ovs-brcompatd missing, disabling bridge compatibility"
42fi
43
44ovs_ctl () {
45 set $INSTALLPREFIX/share/openvswitch/scripts/ovs-ctl "$@"
46 if test X"$BRCOMPAT" = Xyes; then
47 set "$@" --brcompat
48 fi
49 "$@"
50}
51
52load_kmod () {
53 ovs_ctl load-kmod || exit $?
54}
55
56start () {
57 if ovs_ctl load-kmod; then
58 :
59 else
60 echo "Module has probably not been built for this kernel."
61 if ! test -d $INSTALLPREFIX/share/doc/openvswitch-datapath-source; then
62 echo "Install the openvswitch-datapath-source package, then read"
63 else
64 echo "For instructions, read"
65 fi
66 echo "$INSTALLPREFIX/share/doc/openvswitch-datapath-source/README.Debian"
67 fi
68 set ovs_ctl ${1-start} --system-id=random
69 if test X"$FORCE_COREFILES" != X; then
70 set "$@" --force-corefiles="$FORCE_COREFILES"
71 fi
72 "$@" || exit $?
73
74 ovs_ctl --protocol=gre enable-protocol
75}
76
77stop () {
78 ovs_ctl stop
79}
80
81case $1 in
82 start)
83 start
84 ;;
85 stop | force-stop)
86 stop
87 ;;
88 reload | force-reload)
89 # The OVS daemons keep up-to-date.
90 ;;
91 restart)
92 stop
93 start
94 ;;
95 status)
96 ovs_ctl status
97 ;;
98 force-reload-kmod)
99 start force-reload-kmod
100 ;;
101 load-kmod)
102 load_kmod
103 ;;
104 *)
105 echo "Usage: $0 {start|stop|restart|force-reload|status|force-stop|force-reload-kmod|load-kmod}" >&2
106 exit 1
107 ;;
108esac
109
110exit 0
diff --git a/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch-setup b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch-setup
new file mode 100644
index 0000000..84cea1f
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/openvswitchdpdk-switch-setup
@@ -0,0 +1,16 @@
1# This is a POSIX shell fragment -*- sh -*-
2
3# FORCE_COREFILES: If 'yes' then core files will be enabled.
4# FORCE_COREFILES=yes
5
6# BRCOMPAT: If 'yes' and the openvswitch-brcompat package is installed, then
7# Linux bridge compatibility will be enabled.
8# BRCOMPAT=yes
9
10#modify according to platform
11export OVS_DPDK_PARAMS=${OVS_DPDK_PARAMS:-"@OVS_DPDK_PARAMS_DEFAULT"}
12export OVS_VSWITCHD_PARAMS=${OVS_VSWITCHD_PARAMS:-"@OVS_VSWITCHD_PARAMS_DEFAULT"}
13#for debugging redirect to a regular file - this should be done temporary
14#if permanent logging is required a service like logrotate is recommended to limit the size of the log file
15export OVS_DPDK_LOG=${OVS_DPDK_LOG:-"@OVS_DPDK_LOG_DEFAULT"}
16
diff --git a/recipes-networking/openvswitchdpdk/files/ovs-ctl-dpdk.patch b/recipes-networking/openvswitchdpdk/files/ovs-ctl-dpdk.patch
new file mode 100644
index 0000000..bbe7a32
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/ovs-ctl-dpdk.patch
@@ -0,0 +1,123 @@
1Add ovs-vswitchd dpdk parameters and ovs_dpdk daemon calls.
2
3Signed-off-by: Radu Patriu <radu.patriu@enea.com>
4Upstream-Status: Pending
5
6Index: git/openvswitch/utilities/ovs-ctl.in
7===================================================================
8--- git.orig/openvswitch/utilities/ovs-ctl.in 2014-05-22 14:48:48.505319435 +0300
9+++ git/openvswitch/utilities/ovs-ctl.in 2014-05-22 15:05:46.437302665 +0300
10@@ -13,6 +13,15 @@
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14+#OVS_DPDK_PARAMS_DEFAULT to be replaced by install script
15+OVS_DPDK_PARAMS=${OVS_DPDK_PARAMS:-"@OVS_DPDK_PARAMS_DEFAULT"}
16+
17+#OVS_VSWITCHD_PARAMS_DEFAULT to be replaced by install script
18+OVS_VSWITCHD_PARAMS=${OVS_VSWITCHD_PARAMS:-"@OVS_VSWITCHD_PARAMS_DEFAULT"}
19+
20+#OVS_DPDK_LOG_DEFAULT to be replaced by install script
21+OVS_DPDK_LOG=${OVS_DPDK_LOG:-"@OVS_DPDK_LOG_DEFAULT"}
22+
23 case $0 in
24 */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;;
25 *) dir0=./ ;;
26@@ -106,7 +115,7 @@
27 set_system_ids () {
28 set ovs_vsctl set Open_vSwitch .
29
30- OVS_VERSION=`ovs-vswitchd --version | sed 's/.*) //;1q'`
31+ OVS_VERSION=`ovs-vswitchd -c 0x01 -n 4 --proc-type=auto -m 4 -- --version | sed -n 's/ovs-vswitchd (Open vSwitch) \(.*\)/\1/p'`
32 set "$@" ovs-version="$OVS_VERSION"
33
34 case $SYSTEM_ID in
35@@ -215,9 +224,39 @@
36 db:Open_vSwitch,Open_vSwitch,manager_options
37 }
38
39+start_dpdk () {
40+ if daemon_is_running ovs_dpdk; then
41+ log_success_msg "ovs_dpdk is already running"
42+ else
43+ modprobe uio
44+ test -e /sys/module/igb_uio || insmod $datadir/../openvswitchdpdk/kmod/igb_uio.ko
45+ test -e /sys/module/rte_kni || insmod $datadir/../openvswitchdpdk/kmod/rte_kni.ko
46+ rm -f $rundir/ovs_dpdk.pid
47+ start-stop-daemon --start --quiet --background --make-pidfile --pidfile $rundir/ovs_dpdk.pid --exec /bin/sh -- -c "exec ovs_dpdk $OVS_DPDK_PARAMS >> $OVS_DPDK_LOG 2>&1"
48+ #wait for ovs_dpdk to initialize before starting ovs-vswitchd
49+ sleep 10
50+ fi
51+}
52+
53+stop_dpdk () {
54+ pid=`cat "$rundir/ovs_dpdk.pid"`
55+ rtemaps=`test -e /proc/$pid/maps && cat /proc/$pid/maps | grep -o '/.*rtemap_.*$'`
56+
57+ stop_daemon ovs_dpdk
58+
59+ #try to clean
60+ for rtemap in $rtemaps
61+ do
62+ rm -f $rtemap
63+ done
64+ rm -f $rundir/ovs_dpdk.pid
65+}
66+
67 start_forwarding () {
68 check_force_cores
69
70+ start_dpdk
71+
72 insert_mod_if_required || return 1
73
74 if daemon_is_running ovs-vswitchd; then
75@@ -230,9 +269,9 @@
76 ulimit -n 7500
77
78 # Start ovs-vswitchd.
79- set ovs-vswitchd unix:"$DB_SOCK"
80+ set ovs-vswitchd $OVS_VSWITCHD_PARAMS -- unix:"$DB_SOCK"
81 set "$@" -vconsole:emer -vsyslog:err -vfile:info
82- if test X"$MLOCKALL" != Xno; then
83+ if test -"$MLOCKALL" != Xno; then
84 set "$@" --mlockall
85 fi
86 start_daemon "$OVS_VSWITCHD_PRIORITY" "$OVS_VSWITCHD_WRAPPER" "$@"
87@@ -249,6 +288,7 @@
88
89 stop_forwarding () {
90 stop_daemon ovs-vswitchd
91+ stop_dpdk
92 }
93
94 ## ----------------- ##
95@@ -505,8 +545,10 @@
96 MLOCKALL=yes
97 OVSDB_SERVER_PRIORITY=-10
98 OVS_VSWITCHD_PRIORITY=-10
99+ OVS_DPDK_PRIORITY=-10
100 OVSDB_SERVER_WRAPPER=
101 OVS_VSWITCHD_WRAPPER=
102+ OVS_DPDK_WRAPPER=
103
104 DB_FILE=$dbdir/conf.db
105 DB_SOCK=$rundir/db.sock
106@@ -601,6 +643,8 @@
107 data files: @pkgdatadir@ (--pkgdatadir, OVS_PKGDATADIR)
108 user binaries: @bindir@ (--bindir, OVS_BINDIR)
109 system binaries: @sbindir@ (--sbindir, OVS_SBINDIR)
110+ ovs_dpdk params: OVS_DPDK_PARAMS (env only)
111+ ovs-vswitchd dpdk params: OVS_VSWITCHD_PARAMS (env only)
112
113 Please report bugs to bugs@openvswitch.org (see REPORTING-BUGS for details).
114 EOF
115@@ -622,7 +666,7 @@
116 }
117
118 daemons () {
119- echo ovsdb-server ovs-vswitchd
120+ echo ovsdb-server ovs-vswitchd ovs_dpdk
121 }
122
123 set_defaults
diff --git a/recipes-networking/openvswitchdpdk/files/qemu-makefile.patch b/recipes-networking/openvswitchdpdk/files/qemu-makefile.patch
new file mode 100644
index 0000000..0ef50da
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/qemu-makefile.patch
@@ -0,0 +1,26 @@
1From 7f073eec0d100bddaba59c693505713974a2d4bb Mon Sep 17 00:00:00 2001
2From: Huimin She <huimin.she@enea.com>
3Date: Tue, 22 Apr 2014 22:58:11 +0200
4Subject: [PATCH] Add -ldl to qemu Makefile
5
6Signed-off-by: Huimin She <huimin.she@enea.com>
7---
8 qemu/Makefile.target | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/qemu/Makefile.target b/qemu/Makefile.target
12index 760da1e..72b58d7 100644
13--- a/qemu/Makefile.target
14+++ b/qemu/Makefile.target
15@@ -117,7 +117,7 @@ obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o
16 obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
17 obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o
18 obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o
19-LIBS+=-lz
20+LIBS+=-lz -ldl
21
22 # xen support
23 obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
24--
251.8.3.2
26
diff --git a/recipes-networking/openvswitchdpdk/files/qemu-options-hx.patch b/recipes-networking/openvswitchdpdk/files/qemu-options-hx.patch
new file mode 100644
index 0000000..d847d9e
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/qemu-options-hx.patch
@@ -0,0 +1,30 @@
1diff --git a/qemu/qemu-options.hx b/qemu/qemu-options.hx
2index 9d7131a..1000d49 100644
3--- a/qemu/qemu-options.hx
4+++ b/qemu/qemu-options.hx
5@@ -2075,18 +2075,13 @@ QEMU supports using either local sheepdog devices or remote networked
6 devices.
7
8 Syntax for specifying a sheepdog device
9-@table @list
10-``sheepdog:<vdiname>''
11-
12-``sheepdog:<vdiname>:<snapid>''
13-
14-``sheepdog:<vdiname>:<tag>''
15-
16-``sheepdog:<host>:<port>:<vdiname>''
17-
18-``sheepdog:<host>:<port>:<vdiname>:<snapid>''
19-
20-``sheepdog:<host>:<port>:<vdiname>:<tag>''
21+@table @code
22+@item sheepdog:<vdiname>
23+@item sheepdog:<vdiname>:<snapid>
24+@item sheepdog:<vdiname>:<tag>
25+@item sheepdog:<host>:<port>:<vdiname>
26+@item sheepdog:<host>:<port>:<vdiname>:<snapid>
27+@item sheepdog:<host>:<port>:<vdiname>:<tag>
28 @end table
29
30 Example
diff --git a/recipes-networking/openvswitchdpdk/files/qemu-pixman-config.patch b/recipes-networking/openvswitchdpdk/files/qemu-pixman-config.patch
new file mode 100644
index 0000000..266b42a
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/qemu-pixman-config.patch
@@ -0,0 +1,26 @@
1From 1976f44e3b14653421f67d7d050586348f3d3fa1 Mon Sep 17 00:00:00 2001
2From: Huimin She <huimin.she@enea.com>
3Date: Tue, 29 Apr 2014 10:00:30 +0200
4Subject: [PATCH] Add --host for qemu/pixman configure
5
6Signed-off-by: Huimin She <huimin.she@enea.com>
7---
8 qemu/Makefile | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/qemu/Makefile b/qemu/Makefile
12index 0d9099a..88b470f 100644
13--- a/qemu/Makefile
14+++ b/qemu/Makefile
15@@ -131,7 +131,7 @@ subdir-pixman: pixman/Makefile
16 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,)
17
18 pixman/Makefile: $(SRC_PATH)/pixman/configure
19- (cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static)
20+ (cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static --host $(HOST_SYS))
21
22 $(SRC_PATH)/pixman/configure:
23 (cd $(SRC_PATH)/pixman; autoreconf -v --install)
24--
251.8.3.2
26
diff --git a/recipes-networking/openvswitchdpdk/files/run-ptest b/recipes-networking/openvswitchdpdk/files/run-ptest
new file mode 100644
index 0000000..3bf83b6
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/files/run-ptest
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3INSTALLPREFIX=
4
5PATH=$INSTALLPREFIX/sbin:$INSTALLPREFIX/bin:$PATH
6
7./tests/testsuite --am-fmt -C tests AUTOTEST_PATH=utilities:vswitchd:ovsdb:tests
8
diff --git a/recipes-networking/openvswitchdpdk/openvswitchdpdk_0.10.0.bb b/recipes-networking/openvswitchdpdk/openvswitchdpdk_0.10.0.bb
new file mode 100644
index 0000000..d6cde8d
--- /dev/null
+++ b/recipes-networking/openvswitchdpdk/openvswitchdpdk_0.10.0.bb
@@ -0,0 +1,248 @@
1SUMMARY = "DPDK vSwitch"
2DESCRIPTION = "DPDK vSwitch is a fork of Open vSwitch. It re-creates the kernel forwarding module (data plane) \
3by building the switching logic on top of the DPDK library to significantly boost packet switching throughput"
4HOMEPAGE = "https://01.org/packet-processing"
5SECTION = "networking"
6LICENSE = "Apache-2 & GPLv2 & LGPLv2.1 & BSD"
7LIC_FILES_CHKSUM = "file://openvswitch/COPYING;md5=eef486aeb68ddde5446062140eeda540 \
8 file://qemu/COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
9 file://qemu/COPYING.LIB;md5=79ffa0ec772fa86740948cb7327a0cc7 \
10 file://guest/ovs_client/ovs_client.c;beginline=1;endline=33;md5=8485efe01bb0513caf69f8bbec5617a0 \
11 "
12PV = "0.10.0"
13
14PACKAGES =+ "${PN}-controller ${PN}-switch ${PN}-pki ${PN}-qemu"
15
16DEPENDS += "dpdk virtual/kernel libtool glib-2.0 expect fuse python perl"
17
18RDEPENDS_${PN} += "util-linux-uuidgen util-linux-libuuid coreutils \
19 python perl perl-module-strict sed gawk grep ${PN}-switch ${PN}-controller"
20RRECOMMENDS_${PN} += "kernel-module-openvswitch kernel-module-uio kernel-module-pci-stub"
21
22RDEPENDS_${PN}-ptest += "python-logging python-syslog python-argparse python-io \
23 python-fcntl python-shell python-lang python-xml python-math \
24 python-datetime python-netclient python sed ${PN}"
25
26RDEPENDS_${PN}-pki = "${PN}"
27ALLOW_EMPTY_${PN}-pki = "1"
28
29RDEPENDS_${PN}-controller += "${PN} lsb ${PN}-pki"
30RDEPENDS_${PN}-switch = "${PN} openssl procps util-linux-uuidgen"
31
32OVS_PREFIX = "/opt/${PN}"
33
34FILES_${PN}-controller = "${sysconfdir}/init.d/openvswitchdpdk-controller \
35 ${sysconfdir}/default/openvswitchdpdk-controller \
36 ${OVS_PREFIX}/bin/ovs-controller \
37 "
38
39FILES_${PN}-doc += "/share/man"
40
41FILES_${PN} += "/share"
42
43FILES_${PN}-switch = "${sysconfdir}/init.d/openvswitchdpdk-switch \
44 ${sysconfdir}/default/openvswitchdpdk-switch"
45
46FILES_${PN}-qemu = "${QEMU_INSTALL_PATH}"
47
48inherit module-base update-rc.d
49
50INITSCRIPT_PACKAGES = "${PN}-switch ${PN}-controller"
51INITSCRIPT_NAME_${PN}-switch = "openvswitchdpdk-switch"
52#to enable at startup use bbappend recipe with INITSCRIPT_PARAMS_${PN}-switch = "defaults 71"
53INITSCRIPT_PARAMS_${PN}-switch = "stop 20 5 2 . stop 20 0 1 6 ."
54
55INITSCRIPT_NAME_${PN}-controller = "openvswitchdpdk-controller"
56#to enable at startup use bbappend recipe with INITSCRIPT_PARAMS_${PN}-controller = "defaults 72"
57INITSCRIPT_PARAMS_${PN}-controller = "stop 20 5 2 . stop 20 0 1 6 ."
58
59# Release 0.10.0
60SRCREV = "28318e4004a9010b8bc15ff7e8ac5d886ea47857"
61SRC_URI = "git://github.com/01org/dpdk-ovs;branch=master \
62 file://configure-fix.patch \
63 file://makefile-install-rule.patch \
64 file://qemu-makefile.patch \
65 file://openvswitchdpdk-switch \
66 file://openvswitchdpdk-switch-setup \
67 file://openvswitchdpdk-controller \
68 file://openvswitchdpdk-controller-setup \
69 file://qemu-pixman-config.patch \
70 file://qemu-options-hx.patch \
71 file://0001-openvswitchdpdk-enabled-ptest.patch \
72 file://run-ptest \
73 file://ovs-ctl-dpdk.patch \
74 "
75
76S = "${WORKDIR}/git"
77B = "${S}"
78OVS_S_DIR = "${S}/openvswitch"
79QEMU_S_DIR = "${S}/qemu"
80
81# Install this modified qemu to a different place than the normal qemu
82QEMU_INSTALL_PATH = "/opt/dpdk-ovs-qemu"
83
84SRC_URI[md5sum] = "8d354e5f730292f126f29f85448cfc2d"
85SRC_URI[sha256sum] = "6256f9ca96716686030e4456e97eacc2f31b3169e65a1455f73ffafd78f7828a"
86
87export RTE_SDK = "${STAGING_DIR_HOST}/opt/dpdk"
88export RTE_TARGET = "x86_64-ivshmem-linuxapp-gcc"
89
90OVS_CONFIG_OPTS = "--build=${BUILD_SYS} \
91 --host=${HOST_SYS} \
92 --target=${TARGET_SYS} \
93 --prefix=${OVS_PREFIX} \
94 --disable-silent-rules \
95 --disable-ssl \
96 "
97
98QEMU_CONFIG_OPTS = "--prefix=${QEMU_INSTALL_PATH} \
99 --with-confsuffix="" \
100 --mandir=${QEMU_INSTALL_PATH}/share/man \
101 --docdir=${QEMU_INSTALL_PATH}/share/doc \
102 --datadir=${QEMU_INSTALL_PATH}/share \
103 --sysconfdir=${QEMU_INSTALL_PATH}/usr/etc \
104 --bindir=${QEMU_INSTALL_PATH}/bin \
105 --libdir=${QEMU_INSTALL_PATH}/lib \
106 --libexecdir=${QEMU_INSTALL_PATH}/libexec \
107 --includedir=${QEMU_INSTALL_PATH}/include \
108 --localstatedir=${QEMU_INSTALL_PATH}/var \
109 --enable-kvm \
110 --dpdkdir=${RTE_SDK} \
111 --extra-cflags="-Wno-poison-system-directories" \
112 --target-list=x86_64-softmmu \
113 --disable-strip \
114 "
115
116PACKAGESPLITFUNCS_prepend = "split_ovs_packages "
117
118#append OVS_PREFIX to all FILES_* in PACKAGES except for ptest, qemu, switch
119# and controller(includes exception, see FILES_${PN}-controller) packages
120python split_ovs_packages () {
121 pkgs = d.getVar('PACKAGES', True)
122 for pkg in pkgs.split():
123 if (pkg.endswith('-ptest') or pkg.endswith('-qemu') or
124 pkg.endswith('-switch') or pkg.endswith('-controller')):
125 continue
126 files = d.getVar('FILES_%s' % pkg, True)
127 if files is None:
128 continue
129 files = [d.getVar('OVS_PREFIX', True) + file for file in files.split()]
130 files = ' '.join(files)
131 d.setVar('FILES_%s' % pkg, files)
132}
133
134do_configure () {
135 cd ${OVS_S_DIR} && ./boot.sh && ./configure ${OVS_CONFIG_OPTS}
136 cd ${QEMU_S_DIR} && ./configure ${QEMU_CONFIG_OPTS}
137}
138
139do_compile () {
140 cd ${OVS_S_DIR} && oe_runmake
141 cd ${S}/guest/ovs_client && oe_runmake
142 cd ${S}/guest/kni/kni_client && oe_runmake
143
144 # unset the environment variables, so that oe_runmake will not override them
145 unset bindir mandir docdir sysconfdir datadir libdir libexecdir includedir localstatedir
146 cd ${QEMU_S_DIR} && oe_runmake
147}
148
149#use simple quotes in the definition of the following "OVS_" prefixed variables
150OVS_DPDK_PARAMS_DEFAULT = "-c 0x0f -n 4 --proc-type=primary --huge-dir /mnt/huge -- -p 0x03 -k 2 -n 4 --stats=1 --vswitchd=1 --client_switching_core=0 --config='(0,0,2),(1,0,3)'"
151OVS_VSWITCHD_PARAMS_DEFAULT = "-c 0x10 -n 4 --proc-type=secondary"
152#for debugging redirect to a regular file - this should be done temporary
153#if permanent logging is required a service like logrotate is recommended to limit the size of the log file
154OVS_DPDK_LOG_DEFAULT = "/dev/null"
155
156do_install () {
157 cd ${OVS_S_DIR} && oe_runmake DESTDIR=${D} install
158 install ${OVS_S_DIR}/datapath/dpdk/build/app/ovs_dpdk ${D}/${OVS_PREFIX}${base_bindir}
159 install -d ${D}/${OVS_PREFIX}/share/${PN}/kmod
160 install -m 644 ${OVS_S_DIR}/datapath/dpdk/fd_link/fd_link.ko ${D}/${OVS_PREFIX}/share/${PN}/kmod
161 install -m 644 ${RTE_SDK}/${RTE_TARGET}/kmod/*.ko ${D}/${OVS_PREFIX}/share/${PN}/kmod
162 install ${S}/guest/kni/kni_client/build/kni_client ${D}/${OVS_PREFIX}${base_bindir}
163 install ${S}/guest/ovs_client/build/ovs_client ${D}/${OVS_PREFIX}${base_bindir}
164
165 install -d ${D}/${sysconfdir}/default/
166 install -m 660 ${WORKDIR}/openvswitchdpdk-switch-setup ${D}/${sysconfdir}/default/openvswitchdpdk-switch
167 install -m 660 ${WORKDIR}/openvswitchdpdk-controller-setup ${D}/${sysconfdir}/default/openvswitchdpdk-controller
168
169 install -d ${D}/${sysconfdir}/init.d/
170 install -m 755 ${WORKDIR}/openvswitchdpdk-controller ${D}/${sysconfdir}/init.d/openvswitchdpdk-controller
171 sed -i 's|INSTALLPREFIX=|INSTALLPREFIX=${OVS_PREFIX}|g' ${D}/${sysconfdir}/init.d/openvswitchdpdk-controller
172 install -m 755 ${WORKDIR}/openvswitchdpdk-switch ${D}/${sysconfdir}/init.d/openvswitchdpdk-switch
173 sed -i 's|INSTALLPREFIX=|INSTALLPREFIX=${OVS_PREFIX}|g' ${D}/${sysconfdir}/init.d/openvswitchdpdk-switch
174
175 # Add DPDK default parameters to /etc/default/openvswitchdpdk-switch
176 sed -i "s|@OVS_DPDK_PARAMS_DEFAULT|${OVS_DPDK_PARAMS_DEFAULT}|g" ${D}/${sysconfdir}/default/openvswitchdpdk-switch
177 sed -i "s|@OVS_VSWITCHD_PARAMS_DEFAULT|${OVS_VSWITCHD_PARAMS_DEFAULT}|g" ${D}/${sysconfdir}/default/openvswitchdpdk-switch
178 sed -i "s|@OVS_DPDK_LOG_DEFAULT|${OVS_DPDK_LOG_DEFAULT}|g" ${D}/${sysconfdir}/default/openvswitchdpdk-switch
179
180 # Add DPDK default parameters to ovs-ctl
181 sed -i "s|@OVS_DPDK_PARAMS_DEFAULT|${OVS_DPDK_PARAMS_DEFAULT}|g" ${D}/${OVS_PREFIX}/share/openvswitch/scripts/ovs-ctl
182 sed -i "s|@OVS_VSWITCHD_PARAMS_DEFAULT|${OVS_VSWITCHD_PARAMS_DEFAULT}|g" ${D}/${OVS_PREFIX}/share/openvswitch/scripts/ovs-ctl
183 sed -i "s|@OVS_DPDK_LOG_DEFAULT|${OVS_DPDK_LOG_DEFAULT}|g" ${D}/${OVS_PREFIX}/share/openvswitch/scripts/ovs-ctl
184
185 install -d ${D}/${OVS_PREFIX}${sysconfdir}/openvswitch-controller
186
187 # unset the environment variables, so that oe_runmake will not override them
188 unset bindir mandir docdir sysconfdir datadir libdir libexecdir includedir localstatedir
189
190 export STRIP="true"
191 install -d ${D}/${QEMU_INSTALL_PATH}/bin
192 cd ${QEMU_S_DIR} && oe_runmake DESTDIR=${D} install
193
194 # silence QA error: architecture did not match
195 rm -f ${D}/${QEMU_INSTALL_PATH}/share/openbios*
196 rm -f ${D}/${QEMU_INSTALL_PATH}/share/palcode-clipper
197}
198
199pkg_postinst_${PN}-pki () {
200 # can't do this offline
201 if [ "x$D" != "x" ]; then
202 exit 1
203 fi
204 if test ! -d $D/${OVS_PREFIX}/share/${PN}/pki; then
205 ${OVS_PREFIX}/${base_bindir}/ovs-pki init --dir=$D/${OVS_PREFIX}/share/${PN}/pki
206 fi
207}
208
209pkg_postinst_${PN}-controller () {
210 # can't do this offline
211 if [ "x$D" != "x" ]; then
212 exit 1
213 fi
214
215 if test ! -d $D/${OVS_PREFIX}/share/${PN}/pki; then
216 ${OVS_PREFIX}/${base_bindir}/ovs-pki init --dir=$D/${OVS_PREFIX}/share/${PN}/pki
217 fi
218
219 cd $D/${OVS_PREFIX}${sysconfdir}/openvswitch-controller
220 if ! test -e cacert.pem; then
221 ln -s $D/${OVS_PREFIX}/share/${PN}/pki/switchca/cacert.pem cacert.pem
222 fi
223 if ! test -e privkey.pem || ! test -e cert.pem; then
224 oldumask=$(umask)
225 umask 077
226 ${OVS_PREFIX}/${base_bindir}/ovs-pki req+sign --dir=$D/${OVS_PREFIX}/share/${PN}/pki tmp controller >/dev/null
227 mv tmp-privkey.pem privkey.pem
228 mv tmp-cert.pem cert.pem
229 mv tmp-req.pem req.pem
230 chmod go+r cert.pem req.pem
231 umask $oldumask
232 fi
233}
234
235inherit ptest
236
237EXTRA_OEMAKE += "TEST_DEST=${D}${PTEST_PATH} TEST_ROOT=${PTEST_PATH}"
238
239do_install_ptest() {
240 cd ${OVS_S_DIR} && oe_runmake test-install
241 sed -i 's|INSTALLPREFIX=|INSTALLPREFIX=${OVS_PREFIX}|g' ${D}${PTEST_PATH}/run-ptest
242}
243
244# for qemu/pixman configuration
245export HOST_SYS
246
247INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
248INSANE_SKIP_${PN} = "installed-vs-shipped"
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