Add initial support for building ODP with DPDK pktio.
Reviewed-by: Petri Savolainen <[email protected]>
Signed-off-by: Matias Elo <[email protected]>
---
DEPENDENCIES | 54 ++++++++++++
platform/linux-generic/Makefile.am | 2 +
platform/linux-generic/include/odp_packet_dpdk.h | 19 +++++
.../linux-generic/include/odp_packet_io_internal.h | 3 +
platform/linux-generic/m4/configure.m4 | 1 +
platform/linux-generic/m4/odp_dpdk.m4 | 43 ++++++++++
platform/linux-generic/pktio/dpdk.c | 96 ++++++++++++++++++++++
platform/linux-generic/pktio/io_ops.c | 3 +
8 files changed, 221 insertions(+)
create mode 100644 platform/linux-generic/include/odp_packet_dpdk.h
create mode 100644 platform/linux-generic/m4/odp_dpdk.m4
create mode 100644 platform/linux-generic/pktio/dpdk.c
diff --git a/DEPENDENCIES b/DEPENDENCIES
index c2711d5..fe7df40 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -154,6 +154,60 @@ Prerequisites for building the OpenDataPlane (ODP) API
netmap kernel module is loaded. If socket I/O is desired instead, it can be
activated by setting the environment variable ODP_PKTIO_DISABLE_NETMAP.
+3.4 DPDK (optional)
+
+ Use DPDK for ODP packet I/O.
+
+3.4.1 Building DPDK
+
+ DPDK packet I/O has been tested to work with DPDK v2.2.0.
+
+ # Checkout DPDK code
+ $ git clone http://dpdk.org/git/dpdk
+ $ cd dpdk
+ $ git checkout v2.2.0
+
+ # Make and edit DPDK configuration
+ $ make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc
+ $ cd x86_64-native-linuxapp-gcc
+ $ sed -ri 's,(CONFIG_RTE_BUILD_COMBINE_LIBS=).*,\1y,' .config
+ # To use I/O without DPDK supported NIC's enable pcap pmd:
+ $ sed -ri 's,(CONFIG_RTE_LIBRTE_PMD_PCAP=).*,\1y,' .config
+ $ cd ..
+
+ # Build DPDK
+ $ make install T=x86_64-native-linuxapp-gcc EXTRA_CFLAGS="-fPIC"
+
+3.4.2 Setup system
+
+ # Load DPDK modules
+ $ sudo /sbin/modprobe uio
+ $ cd <dpdk-dir>
+ $ sudo insmod x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+
+ Reserve and mount hugepages and bind supported interfaces to DPDK modules
+ following the DPDK documentation. ODP DPDK packet I/O has been tested with
+ 512 x 2MB hugepages. All this can be done with the DPDK setup script
+ (<dpdk-dir>/tools/setup.sh).
+
+3.4.3 Building ODP
+
+ $ cd <odp_dir>
+ $ ./bootstrap
+ $ ./configure --with-dpdk-path=<dpdk_dir>/x86_64-native-linuxapp-gcc
+ $ make
+
+3.4.4 Running ODP with DPDK I/O
+
+ ODP applications will try use DPDK for packet I/O by default. If some other
+ I/O type is desired instead, DPDK I/O can be disabled by setting the
+ environment variable ODP_PKTIO_DISABLE_DPDK.
+
+ DPDK interfaces are accessed using indices. For example, two first DPDK
+ interfaces can be used with the odp_l2fwd example as follows:
+ $ cd <odp_dir>
+ $ sudo ./test/performance/odp_l2fwd -i 0,1 -c 2 -m 0
+
4.0 Packages needed to build API tests
Cunit test framework version 2.1-3 is required
diff --git a/platform/linux-generic/Makefile.am
b/platform/linux-generic/Makefile.am
index b1b15a7..00c8ac9 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -107,6 +107,7 @@ noinst_HEADERS = \
${srcdir}/include/odp_packet_io_queue.h \
${srcdir}/include/odp_packet_io_ring_internal.h \
${srcdir}/include/odp_packet_netmap.h \
+ ${srcdir}/include/odp_packet_dpdk.h \
${srcdir}/include/odp_packet_socket.h \
${srcdir}/include/odp_packet_tap.h \
${srcdir}/include/odp_pkt_queue_internal.h \
@@ -145,6 +146,7 @@ __LIB__libodp_la_SOURCES = \
pktio/pktio_common.c \
pktio/loop.c \
pktio/netmap.c \
+ pktio/dpdk.c \
pktio/socket.c \
pktio/socket_mmap.c \
pktio/sysfs.c \
diff --git a/platform/linux-generic/include/odp_packet_dpdk.h
b/platform/linux-generic/include/odp_packet_dpdk.h
new file mode 100644
index 0000000..cc02fd7
--- /dev/null
+++ b/platform/linux-generic/include/odp_packet_dpdk.h
@@ -0,0 +1,19 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_PACKET_DPDK_H
+#define ODP_PACKET_DPDK_H
+
+#include <odp/api/packet_io.h>
+#include <odp/api/pool.h>
+
+/** Packet IO using DPDK interface */
+typedef struct {
+ odp_pool_t pool; /**< pool to alloc packets from */
+ odp_pktio_capability_t capa; /**< interface capabilities */
+} pkt_dpdk_t;
+
+#endif
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h
b/platform/linux-generic/include/odp_packet_io_internal.h
index eb7efa9..3486854 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -33,6 +33,7 @@ extern "C" {
#include <odp_packet_socket.h>
#include <odp_packet_netmap.h>
#include <odp_packet_tap.h>
+#include <odp_packet_dpdk.h>
#define PKTIO_NAME_LEN 256
@@ -118,6 +119,7 @@ struct pktio_entry {
pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap
* API for IO */
pkt_netmap_t pkt_nm; /**< using netmap API for IO */
+ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */
#ifdef HAVE_PCAP
pkt_pcap_t pkt_pcap; /**< Using pcap for IO */
#endif
@@ -260,6 +262,7 @@ int single_send_queue(pktio_entry_t *entry, int index,
odp_packet_t packets[],
int num);
extern const pktio_if_ops_t netmap_pktio_ops;
+extern const pktio_if_ops_t dpdk_pktio_ops;
extern const pktio_if_ops_t sock_mmsg_pktio_ops;
extern const pktio_if_ops_t sock_mmap_pktio_ops;
extern const pktio_if_ops_t loopback_pktio_ops;
diff --git a/platform/linux-generic/m4/configure.m4
b/platform/linux-generic/m4/configure.m4
index 46aaf40..2ac4799 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -19,6 +19,7 @@ AC_LINK_IFELSE(
m4_include([platform/linux-generic/m4/odp_pthread.m4])
m4_include([platform/linux-generic/m4/odp_openssl.m4])
m4_include([platform/linux-generic/m4/odp_netmap.m4])
+m4_include([platform/linux-generic/m4/odp_dpdk.m4])
m4_include([platform/linux-generic/m4/odp_pcap.m4])
AC_CONFIG_FILES([platform/linux-generic/Makefile
diff --git a/platform/linux-generic/m4/odp_dpdk.m4
b/platform/linux-generic/m4/odp_dpdk.m4
new file mode 100644
index 0000000..7fa3387
--- /dev/null
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -0,0 +1,43 @@
+##########################################################################
+# Enable DPDK support
+##########################################################################
+AC_ARG_ENABLE([dpdk_support],
+ [ --enable-dpdk-support include dpdk IO support],
+ [if test x$enableval = xyes; then
+ dpdk_support=yes
+ fi])
+
+##########################################################################
+# Set optional DPDK path
+##########################################################################
+AC_ARG_WITH([dpdk-path],
+AC_HELP_STRING([--with-dpdk-path=DIR path to dpdk build directory],
+ [(or in the default path if not specified).]),
+ [DPDK_PATH=$withval
+ AM_CPPFLAGS="$AM_CPPFLAGS -msse4.2 -isystem $DPDK_PATH/include"
+ AM_LDFLAGS="$AM_LDFLAGS -L$DPDK_PATH/lib"
+ LIBS="$LIBS -ldpdk -ldl -lpcap"
+ dpdk_support=yes],[])
+
+##########################################################################
+# Save and set temporary compilation flags
+##########################################################################
+OLD_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
+
+##########################################################################
+# Check for DPDK availability
+##########################################################################
+if test x$dpdk_support = xyes
+then
+ AC_CHECK_HEADERS([rte_config.h], [],
+ [AC_MSG_FAILURE(["can't find DPDK header"])])
+ ODP_CFLAGS="$ODP_CFLAGS -DODP_PKTIO_DPDK"
+else
+ dpdk_support=no
+fi
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+CPPFLAGS=$OLD_CPPFLAGS
diff --git a/platform/linux-generic/pktio/dpdk.c
b/platform/linux-generic/pktio/dpdk.c
new file mode 100644
index 0000000..ca008ed
--- /dev/null
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -0,0 +1,96 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifdef ODP_PKTIO_DPDK
+
+#include <odp_posix_extensions.h>
+
+#include <odp_packet_io_internal.h>
+#include <odp_packet_dpdk.h>
+#include <odp_debug_internal.h>
+
+#include <rte_config.h>
+
+static int dpdk_close(pktio_entry_t *pktio_entry ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_open(odp_pktio_t id ODP_UNUSED,
+ pktio_entry_t *pktio_entry ODP_UNUSED,
+ const char *netdev ODP_UNUSED,
+ odp_pool_t pool ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_start(pktio_entry_t *pktio_entry ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_stop(pktio_entry_t *pktio_entry ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_recv_queue(pktio_entry_t *pktio_entry ODP_UNUSED,
+ int index ODP_UNUSED,
+ odp_packet_t pkt_table[] ODP_UNUSED,
+ int num ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_recv(pktio_entry_t *pktio_entry ODP_UNUSED,
+ odp_packet_t pkt_table[] ODP_UNUSED,
+ unsigned num ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_send_queue(pktio_entry_t *pktio_entry ODP_UNUSED,
+ int index ODP_UNUSED,
+ odp_packet_t pkt_table[] ODP_UNUSED,
+ int num ODP_UNUSED)
+{
+ return 0;
+}
+
+static int dpdk_send(pktio_entry_t *pktio_entry ODP_UNUSED,
+ odp_packet_t pkt_table[] ODP_UNUSED,
+ unsigned num ODP_UNUSED)
+{
+ return 0;
+}
+
+const pktio_if_ops_t dpdk_pktio_ops = {
+ .name = "dpdk",
+ .init_global = NULL,
+ .init_local = NULL,
+ .term = NULL,
+ .open = dpdk_open,
+ .close = dpdk_close,
+ .start = dpdk_start,
+ .stop = dpdk_stop,
+ .recv = dpdk_recv,
+ .send = dpdk_send,
+ .recv_queue = dpdk_recv_queue,
+ .send_queue = dpdk_send_queue,
+ .link_status = NULL,
+ .mtu_get = NULL,
+ .promisc_mode_set = NULL,
+ .promisc_mode_get = NULL,
+ .mac_get = NULL,
+ .capability = NULL,
+ .input_queues_config = NULL,
+ .output_queues_config = NULL,
+ .in_queues = NULL,
+ .pktin_queues = NULL,
+ .pktout_queues = NULL
+};
+
+#endif /* ODP_PKTIO_DPDK */
diff --git a/platform/linux-generic/pktio/io_ops.c
b/platform/linux-generic/pktio/io_ops.c
index 972c2d7..15aa160 100644
--- a/platform/linux-generic/pktio/io_ops.c
+++ b/platform/linux-generic/pktio/io_ops.c
@@ -12,6 +12,9 @@
* Array must be NULL terminated */
const pktio_if_ops_t * const pktio_if_ops[] = {
&loopback_pktio_ops,
+#ifdef ODP_PKTIO_DPDK
+ &dpdk_pktio_ops,
+#endif
#ifdef ODP_NETMAP
&netmap_pktio_ops,
#endif
--
1.9.1
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp