Skip to contentSkip to conversation

testsuite: dpdk: Add l2fwd example which is based on DPDK.

PATCH In review Hongzhan Chen 2 participants 2 messages Feb 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 testsuite: dpdk: Add l2fwd example which is based on DPDK.

The L2 Forwarding sample application(l2fwd) is a simple example of packet processing using the Data Plane Development Kit (DPDK).

After init DPDK and configure ports and prealloc and mmap enough memory for ingress and egress with making use of DPDK API, it is possible to implement real-time network application in xenomai to receive or transmit packets via sharing the resources with DPDK when there is no activities that may cause switch to secondary domain again.

The RT network application may inherit merits brought by both DPDK and Xenomai even though there is limitations in it.

configure.ac +17 -0
index 3ce34048e..3a90fc201 100644
@@ -848,6 +848,17 @@ AC_ARG_ENABLE(libtraceevent_plugin,
 AC_MSG_RESULT(${libtraceevent_plugin:-no})
 AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
 
+dpdktest=
+AC_MSG_CHECKING(whether dpdktest should be built)
+AC_ARG_ENABLE(dpdktest,
+	      AS_HELP_STRING([--enable-dpdktest], [build dpdktest]),
+	[case "$enableval" in
+	y | yes) dpdktest=y ;;
+	*) unset dpdktest ;;
+	esac])
+AC_MSG_RESULT(${dpdktest:-no})
+AM_CONDITIONAL(XENO_DPDKTEST, [test x$dpdktest = xy])
+
 if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
 	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
 fi
@@ -856,6 +867,10 @@ if test x$kernelshark_plugin = xy; then
 	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
 fi
 
+if test x$dpdktest = xy; then
+	PKG_CHECK_MODULES(LIBDPDK, libdpdk)
+fi
+
 AC_MSG_CHECKING([for test source generation])
 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
@@ -1004,6 +1019,8 @@ AC_CONFIG_FILES([ \
 	lib/trank/Makefile \
 	testsuite/Makefile \
 	testsuite/latency/Makefile \
+	testsuite/dpdk/Makefile \
+	testsuite/dpdk/l2fwd/Makefile \
 	testsuite/switchtest/Makefile \
 	testsuite/gpiotest/Makefile \
 	testsuite/gpiobench/Makefile \
testsuite/Makefile.am +5 -1
index 4932f6d33..fdda466e8 100644
@@ -10,10 +10,14 @@ SUBDIRS += 		\
 	xeno-test
 endif
 
+SUBDIRS += 		\
+	dpdk
+
 DIST_SUBDIRS =		\
 	clocktest	\
+	dpdk		\
 	gpiotest	\
-	gpiobench   \
+	gpiobench   	\
 	latency		\
 	smokey		\
 	spitest		\
testsuite/dpdk/Makefile.am new file +8 -0
new file mode 100644
index 000000000..ddc47a67c
@@ -0,0 +1,8 @@
+SUBDIRS =
+
+if XENO_DPDKTEST
+SUBDIRS += l2fwd
+endif
+
+DIST_SUBDIRS =	\
+	l2fwd
testsuite/dpdk/README new file +167 -0

167 lines not on this page · raw message

testsuite/dpdk/l2fwd/Makefile.am new file +24 -0
new file mode 100644
index 000000000..b7a87f953
@@ -0,0 +1,24 @@
+testdir = @XENO_TEST_DIR@
+
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
+test_PROGRAMS = l2fwd
+
+l2fwd_SOURCES = l2fwd.c
+
+l2fwd_CPPFLAGS = 		\
+	$(XENO_USER_CFLAGS)	\
+	$(LIBDPDK_CFLAGS)	\
+	-I$(top_srcdir)/include
+
+l2fwd_LDFLAGS =	\
+	@XENO_AUTOINIT_LDFLAGS@	\
+	$(XENO_POSIX_WRAPPERS)	\
+	$(LIBDPDK_LIBS)
+
+l2fwd_LDADD =		\
+	@XENO_CORE_LDADD@	\
+	@XENO_USER_LDADD@	\
+	-lpthread -lrt -lm -ldl -lnuma -lrte_eal \
+	-lrte_mempool -lrte_meter -lrte_mbuf \
+	-lrte_ring -lrte_net -lrte_ethdev
testsuite/dpdk/l2fwd/l2fwd.c new file +1047 -0

1,047 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw
Quoted 145 lines · Hongzhan Chen

The L2 Forwarding sample application(l2fwd) is a simple example of packet processing using the Data Plane Development Kit (DPDK).

After init DPDK and configure ports and prealloc and mmap enough memory for ingress and egress with making use of DPDK API, it is possible to implement real-time network application in xenomai to receive or transmit packets via sharing the resources with DPDK when there is no activities that may cause switch to secondary domain again.

The RT network application may inherit merits brought by both DPDK and Xenomai even though there is limitations in it.

configure.ac +17 -0
index 3ce34048e..3a90fc201 100644
@@ -848,6 +848,17 @@ AC_ARG_ENABLE(libtraceevent_plugin,
 AC_MSG_RESULT(${libtraceevent_plugin:-no})
 AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
 
+dpdktest=
+AC_MSG_CHECKING(whether dpdktest should be built)
+AC_ARG_ENABLE(dpdktest,
+	      AS_HELP_STRING([--enable-dpdktest], [build dpdktest]),
+	[case "$enableval" in
+	y | yes) dpdktest=y ;;
+	*) unset dpdktest ;;
+	esac])
+AC_MSG_RESULT(${dpdktest:-no})
+AM_CONDITIONAL(XENO_DPDKTEST, [test x$dpdktest = xy])
+
 if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
 	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
 fi
@@ -856,6 +867,10 @@ if test x$kernelshark_plugin = xy; then
 	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
 fi
 
+if test x$dpdktest = xy; then
+	PKG_CHECK_MODULES(LIBDPDK, libdpdk)
+fi
+
 AC_MSG_CHECKING([for test source generation])
 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
@@ -1004,6 +1019,8 @@ AC_CONFIG_FILES([ \
 	lib/trank/Makefile \
 	testsuite/Makefile \
 	testsuite/latency/Makefile \
+	testsuite/dpdk/Makefile \
+	testsuite/dpdk/l2fwd/Makefile \
 	testsuite/switchtest/Makefile \
 	testsuite/gpiotest/Makefile \
 	testsuite/gpiobench/Makefile \
testsuite/Makefile.am +5 -1
index 4932f6d33..fdda466e8 100644
@@ -10,10 +10,14 @@ SUBDIRS += 		\
 	xeno-test
 endif
 
+SUBDIRS += 		\
+	dpdk
+
 DIST_SUBDIRS =		\
 	clocktest	\
+	dpdk		\
 	gpiotest	\
-	gpiobench   \
+	gpiobench   	\
 	latency		\
 	smokey		\
 	spitest		\
testsuite/dpdk/Makefile.am new file +8 -0
new file mode 100644
index 000000000..ddc47a67c
@@ -0,0 +1,8 @@
+SUBDIRS =
+
+if XENO_DPDKTEST
+SUBDIRS += l2fwd
+endif
+
+DIST_SUBDIRS =	\
+	l2fwd
testsuite/dpdk/README new file +46 -0
new file mode 100644
index 000000000..f430ce907
@@ -0,0 +1,167 @@
+
+What is it?
+=============
+
+  The modules under this folder include examples that ported from DPDK[1].
+It shows possibility that implement real-time network application in xenomai
+to receive or transmit packets with sharing the resources created by DPDK
+without modifying DPDK itself.
+
+Dependencies & Limitations
+================================
+
+  If you want to run these examples under Xenomai, you would have to install
+DPDK at first on your system. Please refer to [2] to get dpdk started guide.
+
+  In addtion, we just validated examples with uio_pci_generic on NIC i210 and
+vfio-pci on NIC i225 and limited X86 boards with dpdk-stable-21.11.2.
+
+  1. Functional limitations
+
+     1.1  Parameters --trace
+	We cannot pass --trace to DPDK so far because it conflicts with Xenomai
+     usage so that we cannot use trace function for DPDK in the examples.
+
+     1.2 Multiple thread
+	In DPDK ,the term "lcore" refers to an EAL thread, which is really a
+     Linux/FreeBSD pthread. "EAL pthreads" are created and managed by EAL and
+     execute the tasks ssued by remote_launch. In each EAL pthread, there is a
+     TLS (Thread Local Storage) called _lcore_id for unique identification.
+     As EAL pthreads usually bind 1:1 to the physical CPU, the _lcore_id is
+     typically equal to the CPU ID. But RT threads created through Xenomai is
+     not managed by EAL. They are not "EAL pthreads". For these unregistered
+     non-EAL pthreads, rte_lcore_id() will not return a valid number. We have to
+     find a way to bind 1:1 to the physical CPU for RT threads but avoid using
+     rte_lcore_id() in multiple RT thread model to use resources shared by DPDK.
+        In addtion, because Xenomai has not supported cgroup, we can not make use
+     of such cpu set to bind RT threads.
+
+
+  2. Performance limitation
+
+     2.1 non-available rte_mempool cache
+	In the example, the RT thread created through Xenomai is not managed by
+     EAL, the put/get operations of rte_mempool will bypass the default mempool
+     cache and there is a performance penalty because of this bypass. Please
+     refer to section "4.3.5 Known Issues" of [3] for more details.

testsuite/dpdk/README line 56

Quoted 10 lines
testsuite/dpdk/README new file +10 -0
+
+     2.2 polling limitation
+        In addition, in dpdk PMD mode, the performance of receiving or sending
+     packets depends on polling capability of caller. But when the caller is
+     xenomai thread, it can not dominate cpu too much time in primary mode(out-of-band).
+     When enable CONFIG_XENO_OPT_WATCHDOG, the default XENO_OPT_WATCHDOG_TIMEOUT is 4s.
+     That means xenomai thread cannot dominate CPU more than 4s or else watchdog will be
+     triggerred to avoid frozen Linux as discussed in [4]. This polling limitation may
+     also result in performance loss.
+

I do not find my first comment on the first version fully addressed yet:

"Can you elaborate a bit on the envisioned use cases here and go more into details in the accompanied documentation? The latter only describes the "how", not at all the "why" (or "which use cases")."

To make it more concrete: How would and application look like that wants to implement a real-time controller talking to I/O devices over some industrial Ethernet protocol? IOW, how to convert that benchmark example here into a production case?

Thanks,
Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux