Skip to contentSkip to conversation

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

PATCH Superseded Hongzhan Chen 2 participants 6 messages Jan 18, 2023 – Feb 2, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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).

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 +8 -1
index 4932f6d33..4f9c50a82 100644
@@ -10,10 +10,17 @@ SUBDIRS += 		\
 	xeno-test
 endif
 
+if XENO_DPDKTEST
+SUBDIRS += 		\
+	dpdk
+
+endif
+
 DIST_SUBDIRS =		\
 	clocktest	\
+	dpdk		\
 	gpiotest	\
-	gpiobench   \
+	gpiobench   	\
 	latency		\
 	smokey		\
 	spitest		\
testsuite/dpdk/Makefile.am new file +6 -0
new file mode 100644
index 000000000..7ab3f8b8b
@@ -0,0 +1,6 @@
+
+SUBDIRS = 		\
+	l2fwd
+
+DIST_SUBDIRS =		\
+	l2fwd
testsuite/dpdk/README new file +94 -0

94 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 +1066 -0

1,066 lines not on this page · raw message

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

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

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"). Some words on the threading model (or limitations of it) would surely be good as well ("how can I integrate this pattern into a real application?").

Regarding the patch itself, you should go over it again and eliminate debugging left-overs as well as unrelated changes (there is one at least in testsuite/Makefile.am). The way of the integration looks fine to me in principle.

BTW, what prevents the usage of the VFIO driver so far?

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#2 lore raw
Quoted 20 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Thursday, January 19, 2023 1:44 AM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 3 lines · Hongzhan Chen

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

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"). Some words on the threading model (or limitations of it) would surely be good as well ("how can I integrate this pattern into a real application?").

Quoted 6 lines

Regarding the patch itself, you should go over it again and eliminate debugging left-overs as well as unrelated changes (there is one at least in testsuite/Makefile.am). The way of the integration looks fine to me in principle.

BTW, what prevents the usage of the VFIO driver so far?

I have not looked into and tried VFIO driver so far. Last time you told me that we may need to
develop or port VFIO related drivers if we want to use VFIO-based dpdk in Xenomai but UIO-based
does not such issue. I maybe misunderstood what you guided. If the main difference between uio and vfio is that vfio is capable of programming the platform's IOMMU as described in [1], after vfio init, there is no linux syscall involved during receiving and transmitting packets just as UIO case, we can do same thing for VFIO with ported l2fwd.

Regards

Hongzhan Chen

[1]: https://spdk.io/doc/userspace.html#:~:text=The%20primary%20difference%20between%20uio,User%20Space%20for%20full%20details.

Quoted 6 lines

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

#3 lore raw
Quoted 25 lines · Hongzhan
Quoted 25 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Thursday, January 19, 2023 1:44 AM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 3 lines · Hongzhan Chen

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

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"). Some words on the threading model (or limitations of it) would surely be good as well ("how can I integrate this pattern into a real application?").

Regarding the patch itself, you should go over it again and eliminate debugging left-overs as well as unrelated changes (there is one at least in testsuite/Makefile.am). The way of the integration looks fine to me in principle.

Quoted 5 lines
Quoted 1 line

BTW, what prevents the usage of the VFIO driver so far?

I have not looked into and tried VFIO driver so far. Last time you told me that we may need to
develop or port VFIO related drivers if we want to use VFIO-based dpdk in Xenomai but UIO-based
does not such issue. I maybe misunderstood what you guided. If the main difference between uio and vfio is that vfio is capable of programming the platform's IOMMU as described in [1], after vfio init, there is no linux syscall involved during receiving and transmitting packets just as UIO case, we can do same thing for VFIO with ported l2fwd.

I haven't looked into VFIO myself, but the key question is whether some userspace activity in the primary domain could trigger mapping activity of the driver in the secondary one. If not, VFIO should be fine. If so, and that was the case for some RTnet drivers, we would need to avoid that. I was just wondering if you explored the path already and could share your experience.

Jan

Quoted 13 lines

Regards

Hongzhan Chen

[1]: https://spdk.io/doc/userspace.html#:~:text=The%20primary%20difference%20between%20uio,User%20Space%20for%20full%20details.

Quoted 6 lines

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#4 lore raw
Quoted 48 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, January 31, 2023 3:27 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 6 lines · Hongzhan
Quoted 6 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Thursday, January 19, 2023 1:44 AM
To: Chen, Hongzhan <[email protected]>;

[email protected]

Quoted 14 lines
Quoted 14 lines

Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 3 lines · Hongzhan Chen

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

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"). Some words on the threading model (or limitations of it) would surely be good as well ("how can I integrate this pattern into a real application?").

Quoted 8 lines
Quoted 6 lines

Regarding the patch itself, you should go over it again and eliminate debugging left-overs as well as unrelated changes (there is one at least in testsuite/Makefile.am). The way of the integration looks fine to me in principle.

BTW, what prevents the usage of the VFIO driver so far?

I have not looked into and tried VFIO driver so far. Last time you told me

that we may need to

Quoted 1 line

develop or port VFIO related drivers if we want to use VFIO-based dpdk in

Xenomai but UIO-based

Quoted 1 line

does not such issue. I maybe misunderstood what you guided. If the main

difference between uio and vfio is that vfio is capable of programming the platform's IOMMU as described in [1], after vfio init, there is no linux syscall involved during receiving and transmitting packets just as UIO case, we can do same thing for VFIO with ported l2fwd.

Quoted 6 lines

I haven't looked into VFIO myself, but the key question is whether some userspace activity in the primary domain could trigger mapping activity of the driver in the secondary one. If not, VFIO should be fine. If so, and that was the case for some RTnet drivers, we would need to avoid that. I was just wondering if you explored the path already and could share your experience.

According to my test, the patch works [1] on I255 NIC with vfio-pci module & iommu=pt & intel_iommu=on & VT-D enabled in BIOS. There is no mapping
activities found during receiving and transmitting packets at least in main loop of the l2fwd case after run about 17 hours and I checked with strace log[2].

Regards

Hongzhan Chen

[1]: cat /proc/xenomai/sched/stat

CPU  PID    MSW        CSW        XSC        PF    STAT       %CPU  NAME
  0  0      0          3          0          0     00218000  100.0  [ROOT/0]
  1  0      0          72641414   0          0     00218000   99.9  [ROOT/1]
  2  0      0          0          0          0     00218000  100.0  [ROOT/2]
  3  0      0          0          0          0     00218000  100.0  [ROOT/3]
  4  0      0          1          0          0     00218000  100.0  [ROOT/4]
  5  0      0          2          0          0     00218000  100.0  [ROOT/5]
  5  935    1          1          5          0     002680c0    0.0  l2fwd
  1  954    6718       13436      6722       0     00268042    0.0  display-935
  1  955    1          67171569   67178287   0     00248044    0.1  l2fwd

[2]: Strace log:

13:36:14.266949 futex(0x7ffed97d59b8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1675258579, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = 0
13:36:14.266984 sched_get_priority_min(SCHED_FIFO) = 1
13:36:14.267004 sched_get_priority_max(SCHED_FIFO) = 99
13:36:14.267028 mmap(NULL, 69632, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f1e13fef000
13:36:14.267102 mprotect(0x7f1e13ff0000, 65536, PROT_READ|PROT_WRITE) = 0
13:36:14.267347 clone(child_stack=0x7f1e13ffddf0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f1e13fff9d0, tls=0x7f1e13fff700, child_tidptr=0x7f1e13fff9d0) = 955 13:36:14.267380 sched_setaffinity(955, 128, [1]) = 0
13:36:14.267422 futex(0x7ffed97d59b8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1675258579, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Resource temporarily unavailable)
13:36:14.267480 rt_sigtimedwait([HUP INT ALRM TERM], {si_signo=SIGINT, si_code=SI_KERNEL}, NULL, 8) = 2 (SIGINT)
08:16:50.286528 getpid() = 935
08:16:50.286556 tgkill(935, 954, SIGRTMIN) = 0
08:16:50.286586 getpid() = 935

Quoted 23 lines

Jan

Quoted 6 lines

Regards

Hongzhan Chen

[1]:

https://spdk.io/doc/userspace.html#:~:text=The%20primary%20difference%2
0between%20uio,User%20Space%20for%20full%20details.

Quoted 7 lines
Quoted 6 lines

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

--
Siemens AG, Technology
Competence Center Embedded Linux

#5 lore raw
Quoted 59 lines

-----Original Message-----
From: Chen, Hongzhan <[email protected]>
Sent: Thursday, February 2, 2023 8:37 AM
To: Kiszka, Jan <[email protected]>; [email protected]
Subject: RE: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 7 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, January 31, 2023 3:27 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based on DPDK.

Quoted 9 lines
Quoted 6 lines · Hongzhan
Quoted 6 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Thursday, January 19, 2023 1:44 AM
To: Chen, Hongzhan <[email protected]>;

[email protected]

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH] testsuite: dpdk: Add l2fwd example which is based

on

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

DPDK.

Quoted 3 lines · Hongzhan Chen

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

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"). Some words on the threading model (or limitations of it) would surely be good as well ("how can I integrate this pattern into a real application?").

Regarding the patch itself, you should go over it again and eliminate debugging left-overs as well as unrelated changes (there is one at least in testsuite/Makefile.am). The way of the integration looks fine to me in principle.

BTW, what prevents the usage of the VFIO driver so far?

Quoted 8 lines
Quoted 1 line

I have not looked into and tried VFIO driver so far. Last time you told me

that we may need to

Quoted 1 line

develop or port VFIO related drivers if we want to use VFIO-based dpdk in

Xenomai but UIO-based

Quoted 1 line

does not such issue. I maybe misunderstood what you guided. If the main

difference between uio and vfio is that vfio is capable of programming the platform's IOMMU as described in [1], after vfio init, there is no linux syscall involved during receiving and transmitting packets just as UIO case, we can

do

Quoted 2 lines

same thing for VFIO with ported l2fwd.

Quoted 8 lines
Quoted 6 lines

I haven't looked into VFIO myself, but the key question is whether some userspace activity in the primary domain could trigger mapping activity of the driver in the secondary one. If not, VFIO should be fine. If so, and that was the case for some RTnet drivers, we would need to avoid that. I was just wondering if you explored the path already and could share your experience.

According to my test, the patch works [1] on I255 NIC with vfio-pci module &

Sorry , typo, it is on I225

./dpdk-devbind.py -s

Network devices using DPDK-compatible driver
============================================
0000:03:00.0 'Device 15f2' drv=vfio-pci unused=

Regards

Hongzhan Chen

Quoted 74 lines

iommu=pt
& intel_iommu=on & VT-D enabled in BIOS. There is no mapping activities found during receiving and transmitting packets at least in main loop of the l2fwd case after run about 17 hours and I checked with strace log[2].

Regards

Hongzhan Chen

[1]: cat /proc/xenomai/sched/stat

CPU PID MSW CSW XSC PF STAT %CPU NAME

 0  0      0          3          0          0     00218000  100.0  [ROOT/0]
 1  0      0          72641414   0          0     00218000   99.9  [ROOT/1]
 2  0      0          0          0          0     00218000  100.0  [ROOT/2]
 3  0      0          0          0          0     00218000  100.0  [ROOT/3]
 4  0      0          1          0          0     00218000  100.0  [ROOT/4]
 5  0      0          2          0          0     00218000  100.0  [ROOT/5]
 5  935    1          1          5          0     002680c0    0.0  l2fwd
 1  954    6718       13436      6722       0     00268042    0.0  display-935
 1  955    1          67171569   67178287   0     00248044    0.1  l2fwd

[2]: Strace log:

13:36:14.266949 futex(0x7ffed97d59b8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1675258579, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = 0 13:36:14.266984 sched_get_priority_min(SCHED_FIFO) = 1 13:36:14.267004 sched_get_priority_max(SCHED_FIFO) = 99 13:36:14.267028 mmap(NULL, 69632, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f1e13fef000 13:36:14.267102 mprotect(0x7f1e13ff0000, 65536, PROT_READ|PROT_WRITE) = 0
13:36:14.267347 clone(child_stack=0x7f1e13ffddf0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD |CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CL EARTID, parent_tidptr=0x7f1e13fff9d0, tls=0x7f1e13fff700, child_tidptr=0x7f1e13fff9d0) = 955
13:36:14.267380 sched_setaffinity(955, 128, [1]) = 0 13:36:14.267422 futex(0x7ffed97d59b8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1675258579, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Resource temporarily unavailable)
13:36:14.267480 rt_sigtimedwait([HUP INT ALRM TERM], {si_signo=SIGINT, si_code=SI_KERNEL}, NULL, 8) = 2 (SIGINT)
08:16:50.286528 getpid() = 935
08:16:50.286556 tgkill(935, 954, SIGRTMIN) = 0
08:16:50.286586 getpid() = 935

Quoted 10 lines

Jan

Quoted 6 lines

Regards

Hongzhan Chen

[1]:

https://spdk.io/doc/userspace.html#:~:text=The%20primary%20difference%

2

Quoted 13 lines

0between%20uio,User%20Space%20for%20full%20details.

Quoted 7 lines
Quoted 6 lines

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

--
Siemens AG, Technology
Competence Center Embedded Linux