This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 6ea708c0f9f36b9a90f463dd1f7e0332f82e079b (commit) via 534667daec58ce8b2e417709e788934bea6f8f09 (commit) from f3cf9c3583364af7625679d0021c4d55c3414994 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 6ea708c0f9f36b9a90f463dd1f7e0332f82e079b Author: Matias Elo matias.elo@nokia.com Date: Fri Mar 2 14:32:14 2018 +0200
validation: pktio: remove pktio_test_send_failure test
pktio_test_send_failure() tries to transmit a packet which is larger than odp_pktout_maxlen. ODP API doesn't guarantee what happens when one tries to send an oversized packet, so remove the test.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index f5bb2e26..e82a9683 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -1723,206 +1723,6 @@ static void pktio_test_start_stop(void) odp_event_free(ev); }
-/* - * This is a pre-condition check that the pktio_test_send_failure() - * test case can be run. If the TX interface max frame len is larger that the - * biggest packet we can allocate then the test won't be able to - * attempt to send packets larger than the max len, so skip the test. - */ -static int pktio_check_send_failure(void) -{ - odp_pktio_t pktio_tx; - uint32_t maxlen; - odp_pktio_param_t pktio_param; - int iface_idx = 0; - const char *iface = iface_name[iface_idx]; - odp_pool_capability_t pool_capa; - - if (odp_pool_capability(&pool_capa) < 0) { - fprintf(stderr, "%s: pool capability failed\n", __func__); - return ODP_TEST_INACTIVE; - }; - - memset(&pktio_param, 0, sizeof(pktio_param)); - - pktio_param.in_mode = ODP_PKTIN_MODE_DIRECT; - - pktio_tx = odp_pktio_open(iface, pool[iface_idx], &pktio_param); - if (pktio_tx == ODP_PKTIO_INVALID) { - fprintf(stderr, "%s: failed to open pktio\n", __func__); - return ODP_TEST_INACTIVE; - } - - /* read the maxlen from the transmit interface */ - maxlen = odp_pktout_maxlen(pktio_tx); - - odp_pktio_close(pktio_tx); - - /* Failure test supports only single segment */ - if (pool_capa.pkt.max_seg_len && - pool_capa.pkt.max_seg_len < maxlen + 32) - return ODP_TEST_INACTIVE; - - return ODP_TEST_ACTIVE; -} - -static void pktio_test_send_failure(void) -{ - odp_pktio_t pktio_tx, pktio_rx; - odp_packet_t pkt_tbl[TX_BATCH_LEN]; - uint32_t pkt_seq[TX_BATCH_LEN]; - int ret, i, alloc_pkts; - uint32_t maxlen; - odp_pool_param_t pool_params; - odp_pool_t pkt_pool; - int long_pkt_idx = TX_BATCH_LEN / 2; - pktio_info_t info_rx; - odp_pktout_queue_t pktout; - odp_pool_capability_t pool_capa; - - pktio_tx = create_pktio(0, ODP_PKTIN_MODE_DIRECT, - ODP_PKTOUT_MODE_DIRECT); - if (pktio_tx == ODP_PKTIO_INVALID) { - CU_FAIL("failed to open pktio"); - return; - } - - CU_ASSERT_FATAL(odp_pktout_queue(pktio_tx, &pktout, 1) == 1); - - /* read maxlen from the transmit interface */ - maxlen = odp_pktout_maxlen(pktio_tx); - - ret = odp_pktio_start(pktio_tx); - CU_ASSERT_FATAL(ret == 0); - - _pktio_wait_linkup(pktio_tx); - - CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0); - - if (pool_capa.pkt.max_seg_len && - pool_capa.pkt.max_seg_len < maxlen + 32) { - CU_FAIL("Max packet seg length is too small."); - return; - } - - /* configure the pool so that we can generate test packets larger - * than the interface max transmit length */ - odp_pool_param_init(&pool_params); - pool_params.pkt.len = maxlen + 32; - pool_params.pkt.seg_len = pool_params.pkt.len; - pool_params.pkt.num = TX_BATCH_LEN + 1; - pool_params.type = ODP_POOL_PACKET; - pkt_pool = odp_pool_create("pkt_pool_oversize", &pool_params); - CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID); - - if (num_ifaces > 1) { - pktio_rx = create_pktio(1, ODP_PKTIN_MODE_DIRECT, - ODP_PKTOUT_MODE_DIRECT); - ret = odp_pktio_start(pktio_rx); - CU_ASSERT_FATAL(ret == 0); - - _pktio_wait_linkup(pktio_rx); - } else { - pktio_rx = pktio_tx; - } - - /* generate a batch of packets with a single overly long packet - * in the middle */ - for (i = 0; i < TX_BATCH_LEN; ++i) { - uint32_t pkt_len; - - if (i == long_pkt_idx) - pkt_len = pool_params.pkt.len; - else - pkt_len = PKT_LEN_NORMAL; - - pkt_tbl[i] = odp_packet_alloc(pkt_pool, pkt_len); - if (pkt_tbl[i] == ODP_PACKET_INVALID) - break; - - pkt_seq[i] = pktio_init_packet(pkt_tbl[i]); - - pktio_pkt_set_macs(pkt_tbl[i], pktio_tx, pktio_rx); - if (pktio_fixup_checksums(pkt_tbl[i]) != 0) { - odp_packet_free(pkt_tbl[i]); - break; - } - - if (pkt_seq[i] == TEST_SEQ_INVALID) { - odp_packet_free(pkt_tbl[i]); - break; - } - } - alloc_pkts = i; - - if (alloc_pkts == TX_BATCH_LEN) { - /* try to send the batch with the long packet in the middle, - * the initial short packets should be sent successfully */ - odp_errno_zero(); - ret = odp_pktout_send(pktout, pkt_tbl, TX_BATCH_LEN); - CU_ASSERT(ret == long_pkt_idx); - if (ret != long_pkt_idx) - goto cleanup; - CU_ASSERT(odp_errno() == 0); - - info_rx.id = pktio_rx; - info_rx.inq = ODP_QUEUE_INVALID; - info_rx.in_mode = ODP_PKTIN_MODE_DIRECT; - - i = wait_for_packets(&info_rx, pkt_tbl, pkt_seq, ret, - TXRX_MODE_MULTI, ODP_TIME_SEC_IN_NS); - - if (i == ret) { - /* now try to send starting with the too-long packet - * and verify it fails */ - odp_errno_zero(); - ret = odp_pktout_send(pktout, - &pkt_tbl[long_pkt_idx], - TX_BATCH_LEN - long_pkt_idx); - CU_ASSERT(ret == -1); - CU_ASSERT(odp_errno() != 0); - } else { - CU_FAIL("failed to receive transmitted packets\n"); - } - - /* now reduce the size of the long packet and attempt to send - * again - should work this time */ - i = long_pkt_idx; - odp_packet_pull_tail(pkt_tbl[i], - odp_packet_len(pkt_tbl[i]) - - PKT_LEN_NORMAL); - pkt_seq[i] = pktio_init_packet(pkt_tbl[i]); - - pktio_pkt_set_macs(pkt_tbl[i], pktio_tx, pktio_rx); - ret = pktio_fixup_checksums(pkt_tbl[i]); - CU_ASSERT_FATAL(ret == 0); - - CU_ASSERT_FATAL(pkt_seq[i] != TEST_SEQ_INVALID); - ret = odp_pktout_send(pktout, &pkt_tbl[i], TX_BATCH_LEN - i); - CU_ASSERT_FATAL(ret == (TX_BATCH_LEN - i)); - - i = wait_for_packets(&info_rx, &pkt_tbl[i], &pkt_seq[i], ret, - TXRX_MODE_MULTI, ODP_TIME_SEC_IN_NS); - CU_ASSERT(i == ret); - } else { - CU_FAIL("failed to generate test packets\n"); - } - - for (i = 0; i < alloc_pkts; ++i) { - if (pkt_tbl[i] != ODP_PACKET_INVALID) - odp_packet_free(pkt_tbl[i]); - } - -cleanup: - if (pktio_rx != pktio_tx) { - CU_ASSERT(odp_pktio_stop(pktio_rx) == 0); - CU_ASSERT(odp_pktio_close(pktio_rx) == 0); - } - CU_ASSERT(odp_pktio_stop(pktio_tx) == 0); - CU_ASSERT(odp_pktio_close(pktio_tx) == 0); - CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); -} - static void pktio_test_recv_on_wonly(void) { odp_pktio_t pktio; @@ -2221,8 +2021,6 @@ odp_testinfo_t pktio_suite_unsegmented[] = { ODP_TEST_INFO(pktio_test_recv_tmo), ODP_TEST_INFO(pktio_test_recv_mq_tmo), ODP_TEST_INFO(pktio_test_recv_mtu), - ODP_TEST_INFO_CONDITIONAL(pktio_test_send_failure, - pktio_check_send_failure), ODP_TEST_INFO(pktio_test_mtu), ODP_TEST_INFO(pktio_test_promisc), ODP_TEST_INFO(pktio_test_mac), @@ -2247,8 +2045,6 @@ odp_testinfo_t pktio_suite_segmented[] = { ODP_TEST_INFO(pktio_test_recv), ODP_TEST_INFO(pktio_test_recv_multi), ODP_TEST_INFO(pktio_test_recv_mtu), - ODP_TEST_INFO_CONDITIONAL(pktio_test_send_failure, - pktio_check_send_failure), ODP_TEST_INFO_NULL };
commit 534667daec58ce8b2e417709e788934bea6f8f09 Author: Matias Elo matias.elo@nokia.com Date: Wed Feb 21 17:19:12 2018 +0200
linux-gen: add runtime configuration file
Enables changing ODP runtime configuration options by using an optional configuration file (libconfig). Path to the conf file is passed using environment variable ODP_CONF_FILE. If ODP_CONF_FILE or a particular option is not set, hardcoded default values are used instead. An template configuration file is provided in config/odp-linux.conf.
Runtime configuration is initially used by DPDK pktio to set NIC options.
Adds new dependency to libconfig library.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/.travis.yml b/.travis.yml index 167c7319..a03b2904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ addons: - gcc - clang-3.8 - automake autoconf libtool libssl-dev graphviz mscgen + - libconfig-dev - codespell - libpcap-dev - libnuma-dev @@ -253,7 +254,7 @@ script: # Run all tests only for default configuration - if [ -z "$CROSS_ARCH" ] ; then if [ -n "$CONF" ] ; then - sudo LD_LIBRARY_PATH="$HOME/cunit-install/$CROSS_ARCH/lib:$LD_LIBRARY_PATH" ODP_SHM_DIR=/dev/shm/odp make check ; + sudo ODP_CONFIG_FILE="`pwd`/config/odp-linux-generic.conf" LD_LIBRARY_PATH="$HOME/cunit-install/$CROSS_ARCH/lib:$LD_LIBRARY_PATH" ODP_SHM_DIR=/dev/shm/odp make check ; else sudo ODP_SCHEDULER=basic LD_LIBRARY_PATH="$HOME/cunit-install/$CROSS_ARCH/lib:$LD_LIBRARY_PATH" ODP_SHM_DIR=/dev/shm/odp make check ; sudo ODP_SCHEDULER=sp LD_LIBRARY_PATH="$HOME/cunit-install/$CROSS_ARCH/lib:$LD_LIBRARY_PATH" ODP_SHM_DIR=/dev/shm/odp make check ; diff --git a/DEPENDENCIES b/DEPENDENCIES index 6f374ca9..b6765fec 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -19,7 +19,7 @@ Prerequisites for building the OpenDataPlane (ODP) API
3. Required libraries
- Libraries currently required to link: openssl, libatomic + Libraries currently required to link: openssl, libatomic, libconfig
3.1 OpenSSL native compile
diff --git a/Makefile.am b/Makefile.am index dab8ca8c..89388a19 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ SUBDIRS = \
@DX_RULES@
-EXTRA_DIST = bootstrap CHANGELOG config/README +EXTRA_DIST = bootstrap CHANGELOG config/README config/odp-$(with_platform).conf
distcheck-hook: if test -n "$(DX_CLEANFILES)" ; \ diff --git a/config/README b/config/README index 3f433610..9d6b87b4 100644 --- a/config/README +++ b/config/README @@ -1,2 +1,12 @@ ODP configuration options ------------------------- + +Runtime configuration options can be passed to an ODP instance by +setting ODP_CONFIG_FILE environment variable to point to a libconfig +format configuration file. A template configuration file with default +values is provided in config/odp-linux-generic.conf. The values set in +config/odp-linux-generic.conf are hardcoded during configure/build +phase. If ODP_CONFIG_FILE is not set at runtime, hardcoded default +values are used instead of any configuration file. A configuration file +passed using ODP_CONFIG_FILE doesn't have to include all available +options. The missing options are replaced with hardcoded default values. diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf new file mode 100644 index 00000000..15e65d00 --- /dev/null +++ b/config/odp-linux-generic.conf @@ -0,0 +1,32 @@ +# ODP runtime configuration options +# +# This template configuration file (odp-linux-generic.conf) is hardcoded +# during configure/build phase and the values defined here are used if +# optional ODP_CONFIG_FILE is not set. This configuration file MUST +# include all configuration options. +# +# ODP_CONFIG_FILE can be used to override default values and it doesn't +# have to include all available options. The missing options are +# replaced with hardcoded default values. +# +# The options defined here are implementation specific and valid option +# values should be checked from the implementation code. +# +# See libconfig syntax: https://hyperrealm.github.io/libconfig/libconfig_manual.html#Configuration-F... + +# Mandatory fields +odp_implementation = "linux-generic" +config_file_version = "0.0.1" + +# DPDK pktio options +pktio_dpdk: { + # Default options + num_rx_desc = 128 + num_tx_desc = 512 + rx_drop_en = 0 + + # Driver specific options (use PMD names from DPDK) + net_ixgbe: { + rx_drop_en = 1 + } +} diff --git a/m4/odp_libconfig.m4 b/m4/odp_libconfig.m4 new file mode 100644 index 00000000..18275f07 --- /dev/null +++ b/m4/odp_libconfig.m4 @@ -0,0 +1,20 @@ +# ODP_LIBCONFIG +# ------------- +AC_DEFUN([ODP_LIBCONFIG], +[dnl +########################################################################## +# Check for libconfig availability +########################################################################## +PKG_CHECK_MODULES([LIBCONFIG], [libconfig]) + +########################################################################## +# Create a header file odp_libconfig_config.h which containins null +# terminated hex dump of odp-linux.conf +########################################################################## +AC_CONFIG_COMMANDS([platform/${with_platform}/include/odp_libconfig_config.h], +[mkdir -p platform/${with_platform}/include + (cd ${srcdir}/config ; xxd -i odp-${with_platform}.conf) | \ + sed 's/([[0-9a-f]])$/\0, 0x00/' > \ + platform/${with_platform}/include/odp_libconfig_config.h], + [with_platform=$with_platform]) +]) # ODP_LIBCONFIG diff --git a/platform/Makefile.inc b/platform/Makefile.inc index bb23a4cb..9df96b12 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -3,6 +3,9 @@ include $(top_srcdir)/Makefile.inc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libodp-linux.pc
+configdir = $(sysconfdir)/odp +config_DATA = $(top_srcdir)/config/odp-$(with_platform).conf + VPATH = $(srcdir) $(builddir) lib_LTLIBRARIES = $(LIB)/libodp-linux.la
diff --git a/platform/linux-generic/.gitignore b/platform/linux-generic/.gitignore index fd5ade7e..16e788a9 100644 --- a/platform/linux-generic/.gitignore +++ b/platform/linux-generic/.gitignore @@ -1 +1,2 @@ libodp-linux.pc +odp_libconfig_config.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index c35c0bfe..7e57994d 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -5,6 +5,7 @@ include $(top_srcdir)/platform/Makefile.inc
AM_CPPFLAGS = $(ODP_INCLUDES) AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/include +AM_CPPFLAGS += -I$(top_builddir)/platform/$(with_platform)/include AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch/@ARCH_DIR@ AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch/default @@ -13,6 +14,12 @@ AM_CPPFLAGS += $(OPENSSL_CPPFLAGS) AM_CPPFLAGS += $(DPDK_CPPFLAGS) AM_CPPFLAGS += $(NETMAP_CPPFLAGS)
+AM_CFLAGS += $(LIBCONFIG_CFLAGS) + +DISTCLEANFILES = include/odp_libconfig_config.h +include/odp_libconfig_config.h: $(top_srcdir)/config/odp-$(with_platform).conf $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + if !ODP_ABI_COMPAT odpapiplatincludedir= $(includedir)/odp/api/plat odpapiplatinclude_HEADERS = \ @@ -94,6 +101,7 @@ noinst_HEADERS = \ include/odp_forward_typedefs_internal.h \ include/odp_internal.h \ include/odp_ipsec_internal.h \ + include/odp_libconfig_internal.h \ include/odp_llqueue.h \ include/odp_macros_internal.h \ include/odp_name_table_internal.h \ @@ -131,6 +139,9 @@ noinst_HEADERS = \ include/protocols/thash.h \ include/protocols/udp.h
+nodist_noinst_HEADERS = \ + include/odp_libconfig_config.h + __LIB__libodp_linux_la_SOURCES = \ _fdserver.c \ _ishm.c \ @@ -154,6 +165,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_ipsec.c \ odp_ipsec_events.c \ odp_ipsec_sad.c \ + odp_libconfig.c \ odp_name_table.c \ odp_packet.c \ odp_packet_flags.c \ @@ -287,6 +299,7 @@ endif
__LIB__libodp_linux_la_LIBADD = $(ATOMIC_LIBS) __LIB__libodp_linux_la_LIBADD += $(OPENSSL_LIBS) +__LIB__libodp_linux_la_LIBADD += $(LIBCONFIG_LIBS) __LIB__libodp_linux_la_LIBADD += $(DPDK_LIBS_LIBODP) __LIB__libodp_linux_la_LIBADD += $(PTHREAD_LIBS) __LIB__libodp_linux_la_LIBADD += $(TIMER_LIBS) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index ff8e4176..153c787e 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -23,6 +23,7 @@ extern "C" { #include <odp_errno_define.h> #include <stdio.h> #include <sys/types.h> +#include <libconfig.h>
#define MAX_CPU_NUMBER 128 #define UID_MAXLEN 30 @@ -55,10 +56,14 @@ struct odp_global_data_s { odp_cpumask_t control_cpus; odp_cpumask_t worker_cpus; int num_cpus_installed; + config_t libconfig_default; + config_t libconfig_runtime; + };
enum init_stage { NO_INIT = 0, /* No init stages completed */ + LIBCONFIG_INIT, CPUMASK_INIT, TIME_INIT, SYSINFO_INIT, diff --git a/platform/linux-generic/include/odp_libconfig_internal.h b/platform/linux-generic/include/odp_libconfig_internal.h new file mode 100644 index 00000000..04291775 --- /dev/null +++ b/platform/linux-generic/include/odp_libconfig_internal.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Common libconfig functions + */ + +#ifndef ODP_LIBCONFIG_INTERNAL_H_ +#define ODP_LIBCONFIG_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int _odp_libconfig_init_global(void); +int _odp_libconfig_term_global(void); + +int _odp_libconfig_lookup_int(const char *path, int *value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/include/odp_packet_dpdk.h index 94fe376a..7600b57e 100644 --- a/platform/linux-generic/include/odp_packet_dpdk.h +++ b/platform/linux-generic/include/odp_packet_dpdk.h @@ -21,8 +21,6 @@ #define DPDK_NB_MBUF 16384 #define DPDK_MBUF_BUF_SIZE RTE_MBUF_DEFAULT_BUF_SIZE #define DPDK_MEMPOOL_CACHE_SIZE 64 -#define DPDK_NM_RX_DESC 128 -#define DPDK_NM_TX_DESC 512
ODP_STATIC_ASSERT((DPDK_NB_MBUF % DPDK_MEMPOOL_CACHE_SIZE == 0) && (DPDK_MEMPOOL_CACHE_SIZE <= RTE_MEMPOOL_CACHE_MAX_SIZE) && @@ -33,6 +31,13 @@ ODP_STATIC_ASSERT((DPDK_NB_MBUF % DPDK_MEMPOOL_CACHE_SIZE == 0) && /* Minimum RX burst size */ #define DPDK_MIN_RX_BURST 4
+/** DPDK runtime configuration options */ +typedef struct { + int num_rx_desc; + int num_tx_desc; + int rx_drop_en; +} dpdk_opt_t; + /** Cache for storing packets */ struct pkt_cache_t { /** array for storing extra RX packets */ @@ -64,6 +69,7 @@ typedef struct ODP_ALIGNED_CACHE { odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */ /** cache for storing extra RX packets */ pkt_cache_t rx_cache[PKTIO_MAX_QUEUES]; + dpdk_opt_t opt; } pkt_dpdk_t;
#endif diff --git a/platform/linux-generic/libodp-linux.pc.in b/platform/linux-generic/libodp-linux.pc.in index 5125f83a..66ac78f0 100644 --- a/platform/linux-generic/libodp-linux.pc.in +++ b/platform/linux-generic/libodp-linux.pc.in @@ -6,6 +6,7 @@ includedir=@includedir@ Name: libodp-linux Description: The ODP packet processing engine Version: @PKGCONFIG_VERSION@ +Requires.private: libconfig Libs: -L${libdir} -lodp-linux Libs.private: @OPENSSL_STATIC_LIBS@ @DPDK_LIBS@ @PCAP_LIBS@ @PTHREAD_LIBS@ @TIMER_LIBS@ -lpthread @ATOMIC_LIBS@ Cflags: -I${includedir} diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index 7fa3652e..d2ddd495 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -6,6 +6,7 @@ ODP_ATOMIC ODP_PTHREAD ODP_TIMER ODP_OPENSSL +ODP_LIBCONFIG m4_include([platform/linux-generic/m4/odp_pcap.m4]) m4_include([platform/linux-generic/m4/odp_netmap.m4]) m4_include([platform/linux-generic/m4/odp_dpdk.m4]) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 19003b6a..0cd66ca3 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -12,6 +12,7 @@ #include <unistd.h> #include <odp_internal.h> #include <odp_schedule_if.h> +#include <odp_libconfig_internal.h> #include <string.h> #include <stdio.h> #include <linux/limits.h> @@ -48,6 +49,12 @@ int odp_init_global(odp_instance_t *instance, odp_global_data.abort_fn = params->abort_fn; }
+ if (_odp_libconfig_init_global()) { + ODP_ERR("ODP runtime config init failed.\n"); + goto init_failed; + } + stage = LIBCONFIG_INIT; + if (odp_cpumask_init_global(params)) { ODP_ERR("ODP cpumask init failed.\n"); goto init_failed; @@ -306,6 +313,13 @@ int _odp_term_global(enum init_stage stage) } /* Fall through */
+ case LIBCONFIG_INIT: + if (_odp_libconfig_term_global()) { + ODP_ERR("ODP runtime config term failed.\n"); + rc = -1; + } + /* Fall through */ + case NO_INIT: ; } diff --git a/platform/linux-generic/odp_libconfig.c b/platform/linux-generic/odp_libconfig.c new file mode 100644 index 00000000..3b3b3170 --- /dev/null +++ b/platform/linux-generic/odp_libconfig.c @@ -0,0 +1,99 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include <stdlib.h> +#include <string.h> +#include <libconfig.h> + +#include <odp/api/version.h> +#include <odp_internal.h> +#include <odp_debug_internal.h> +#include <odp_libconfig_internal.h> +#include <odp_libconfig_config.h> + +#define CONF_STR_NAME ((const char *)odp_linux_generic_conf) + +extern struct odp_global_data_s odp_global_data; + +int _odp_libconfig_init_global(void) +{ + const char *filename; + const char *vers; + const char *vers_rt; + const char *ipml; + const char *ipml_rt; + config_t *config = &odp_global_data.libconfig_default; + config_t *config_rt = &odp_global_data.libconfig_runtime; + + config_init(config); + config_init(config_rt); + + if (!config_read_string(config, CONF_STR_NAME)) { + ODP_ERR("Failed to read default config: %s(%d): %s\n", + config_error_file(config), config_error_line(config), + config_error_text(config)); + goto fail; + } + + filename = getenv("ODP_CONFIG_FILE"); + if (filename == NULL) + return 0; + + if (!config_read_file(config_rt, filename)) { + ODP_ERR("Failed to read config file: %s(%d): %s\n", + config_error_file(config_rt), + config_error_line(config_rt), + config_error_text(config_rt)); + goto fail; + } + + /* Check runtime configuration's implementation name and version */ + if (!config_lookup_string(config, "odp_implementation", &ipml) || + !config_lookup_string(config_rt, "odp_implementation", &ipml_rt)) { + ODP_ERR("Configuration missing 'odp_implementation' field\n"); + goto fail; + } + if (!config_lookup_string(config, "config_file_version", &vers) || + !config_lookup_string(config_rt, "config_file_version", &vers_rt)) { + ODP_ERR("Configuration missing 'config_file_version' field\n"); + goto fail; + } + if (strcmp(vers, vers_rt) || strcmp(ipml, ipml_rt)) { + ODP_ERR("Runtime configuration mismatch\n"); + goto fail; + } + + return 0; +fail: + config_destroy(config); + config_destroy(config_rt); + return -1; +} + +int _odp_libconfig_term_global(void) +{ + config_destroy(&odp_global_data.libconfig_default); + config_destroy(&odp_global_data.libconfig_runtime); + + return 0; +} + +int _odp_libconfig_lookup_int(const char *path, int *value) +{ + int ret_def = CONFIG_FALSE; + int ret_rt = CONFIG_FALSE; + + ret_def = config_lookup_int(&odp_global_data.libconfig_default, path, + value); + + /* Runtime option overrides default value */ + ret_rt = config_lookup_int(&odp_global_data.libconfig_runtime, path, + value); + + return (ret_def == CONFIG_TRUE || ret_rt == CONFIG_TRUE) ? 1 : 0; +} diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index a31b0dbb..7b9fed72 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -24,6 +24,7 @@ #include <odp_classification_internal.h> #include <odp_packet_dpdk.h> #include <odp_debug_internal.h> +#include <odp_libconfig_internal.h>
#include <protocols/eth.h>
@@ -93,6 +94,64 @@ void refer_constructors(void) } #endif
+static int lookup_opt(const char *path, const char *drv_name, int *val) +{ + const char *base = "pktio_dpdk"; + char opt_path[256]; + int ret = 0; + + /* Default option */ + snprintf(opt_path, sizeof(opt_path), "%s.%s", base, path); + ret += _odp_libconfig_lookup_int(opt_path, val); + + /* Driver specific option overrides default option */ + snprintf(opt_path, sizeof(opt_path), "%s.%s.%s", base, drv_name, path); + ret += _odp_libconfig_lookup_int(opt_path, val); + + if (ret == 0) + ODP_ERR("Unable to find DPDK configuration option: %s\n", path); + return ret; +} + +static int init_options(pktio_entry_t *pktio_entry, + const struct rte_eth_dev_info *dev_info) +{ + dpdk_opt_t *opt = &pktio_entry->s.pkt_dpdk.opt; + + if (!lookup_opt("num_rx_desc", dev_info->driver_name, + &opt->num_rx_desc)) + return -1; + if (opt->num_rx_desc < dev_info->rx_desc_lim.nb_min || + opt->num_rx_desc > dev_info->rx_desc_lim.nb_max || + opt->num_rx_desc % dev_info->rx_desc_lim.nb_align) { + ODP_ERR("Invalid number of RX descriptors\n"); + return -1; + } + + if (!lookup_opt("num_tx_desc", dev_info->driver_name, + &opt->num_tx_desc)) + return -1; + if (opt->num_tx_desc < dev_info->tx_desc_lim.nb_min || + opt->num_tx_desc > dev_info->tx_desc_lim.nb_max || + opt->num_tx_desc % dev_info->tx_desc_lim.nb_align) { + ODP_ERR("Invalid number of TX descriptors\n"); + return -1; + } + + if (!lookup_opt("rx_drop_en", dev_info->driver_name, + &opt->rx_drop_en)) + return -1; + opt->rx_drop_en = !!opt->rx_drop_en; + + ODP_PRINT("DPDK interface (%s): %" PRIu16 "\n", dev_info->driver_name, + pktio_entry->s.pkt_dpdk.port_id); + ODP_PRINT(" num_rx_desc: %d\n", opt->num_rx_desc); + ODP_PRINT(" num_tx_desc: %d\n", opt->num_tx_desc); + ODP_PRINT(" rx_drop_en: %d\n", opt->rx_drop_en); + + return 0; +} + /** * Calculate valid cache size for DPDK packet pool */ @@ -1337,6 +1396,12 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,
dpdk_init_capability(pktio_entry, &dev_info);
+ /* Initialize runtime options */ + if (init_options(pktio_entry, &dev_info)) { + ODP_ERR("Initializing runtime options failed\n"); + return -1; + } + mtu = dpdk_mtu_get(pktio_entry); if (mtu == 0) { ODP_ERR("Failed to read interface MTU\n"); @@ -1464,7 +1529,8 @@ static int dpdk_start(pktio_entry_t *pktio_entry) pktio_entry->s.chksum_insert_ena = 1; }
- ret = rte_eth_tx_queue_setup(port_id, i, DPDK_NM_TX_DESC, + ret = rte_eth_tx_queue_setup(port_id, i, + pkt_dpdk->opt.num_tx_desc, rte_eth_dev_socket_id(port_id), txconf); if (ret < 0) { @@ -1476,9 +1542,10 @@ static int dpdk_start(pktio_entry_t *pktio_entry) /* Init RX queues */ rte_eth_dev_info_get(port_id, &dev_info); rxconf = &dev_info.default_rxconf; - rxconf->rx_drop_en = 1; + rxconf->rx_drop_en = pkt_dpdk->opt.rx_drop_en; for (i = 0; i < pktio_entry->s.num_in_queue; i++) { - ret = rte_eth_rx_queue_setup(port_id, i, DPDK_NM_RX_DESC, + ret = rte_eth_rx_queue_setup(port_id, i, + pkt_dpdk->opt.num_rx_desc, rte_eth_dev_socket_id(port_id), rxconf, pkt_dpdk->pkt_pool); if (ret < 0) { diff --git a/platform/linux-generic/test/ring/Makefile.am b/platform/linux-generic/test/ring/Makefile.am index 3f774342..999beed4 100644 --- a/platform/linux-generic/test/ring/Makefile.am +++ b/platform/linux-generic/test/ring/Makefile.am @@ -16,6 +16,8 @@ PRELDADD += $(LIBCUNIT_COMMON)
AM_CPPFLAGS += -I$(top_srcdir)/platform/linux-generic/include
+AM_CFLAGS += $(LIBCONFIG_CFLAGS) + TESTNAME = linux-generic-ring
TESTENV = tests-$(TESTNAME).env
-----------------------------------------------------------------------
Summary of changes: .travis.yml | 3 +- DEPENDENCIES | 2 +- Makefile.am | 2 +- config/README | 10 + config/odp-linux-generic.conf | 32 ++++ m4/odp_libconfig.m4 | 20 ++ platform/Makefile.inc | 3 + platform/linux-generic/.gitignore | 1 + platform/linux-generic/Makefile.am | 13 ++ platform/linux-generic/include/odp_internal.h | 5 + .../linux-generic/include/odp_libconfig_internal.h | 29 +++ platform/linux-generic/include/odp_packet_dpdk.h | 10 +- platform/linux-generic/libodp-linux.pc.in | 1 + platform/linux-generic/m4/configure.m4 | 1 + platform/linux-generic/odp_init.c | 14 ++ platform/linux-generic/odp_libconfig.c | 99 ++++++++++ platform/linux-generic/pktio/dpdk.c | 73 +++++++- platform/linux-generic/test/ring/Makefile.am | 2 + test/validation/api/pktio/pktio.c | 204 --------------------- 19 files changed, 312 insertions(+), 212 deletions(-) create mode 100644 config/odp-linux-generic.conf create mode 100644 m4/odp_libconfig.m4 create mode 100644 platform/linux-generic/include/odp_libconfig_internal.h create mode 100644 platform/linux-generic/odp_libconfig.c
hooks/post-receive