From: Matias Elo <matias....@nokia.com> Changes: - Function rte_set_log_level() is now deprecated. Replace it with rte_log_set_global_level(). - New dependency added to libnuma. - Pcap-based virtual devices are renamed to net_pcap. - DPDK pktio devices cannot be restarted after calling rte_eth_dev_close(). Move rte_eth_dev_close() calls to global terminate from odp_pktio_close().
Signed-off-by: Matias Elo <matias....@nokia.com> --- /** Email created from pull request 252 (matiaselo:dev/bump_dpdk_version) ** https://github.com/Linaro/odp/pull/252 ** Patch: https://github.com/Linaro/odp/pull/252.patch ** Base sha: e826613858543e50a2ec74598f8c2c6fd4bfa064 ** Merge commit sha: 3e4a6ab683ceb7278183c2b126c3ec6db2a1ccc8 **/ .travis.yml | 3 +- DEPENDENCIES | 6 ++- platform/linux-generic/m4/odp_dpdk.m4 | 2 +- platform/linux-generic/pktio/dpdk.c | 48 ++++++++++++++++------ .../test/validation/api/pktio/pktio_run_dpdk.sh | 2 +- scripts/build-pktio-dpdk | 8 +++- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbaad1460..5eff94265 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,7 @@ addons: - clang-3.8 - automake autoconf libtool libssl-dev graphviz mscgen - libpcap-dev + - libnuma-dev # coverity_scan: # project: # name: "$TRAVIS_REPO_SLUG" @@ -150,7 +151,7 @@ install: - gem install asciidoctor # DPDK pktio. Note that cache must be purged if dpdk version changes. - - DPDK_VERS="17.02" + - DPDK_VERS="17.08" - | CACHED_DPDK_VERS=`fgrep Version dpdk/pkg/dpdk.spec | cut -d " " -f 2` if [ "${CACHED_DPDK_VERS}" != "${DPDK_VERS}" ]; then diff --git a/DEPENDENCIES b/DEPENDENCIES index e309b3391..68c7b8be5 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -160,13 +160,17 @@ Prerequisites for building the OpenDataPlane (ODP) API Use DPDK for ODP packet I/O. + DPDK pktio adds a depency to NUMA library. + # Debian/Ubuntu + $ sudo apt-get install libnuma-dev + Note: only packet I/O is accelerated with DPDK. Use https://git.linaro.org/lng/odp-dpdk.git for fully accelerated odp dpdk platform. 3.4.1 Building DPDK and ODP with DPDK pktio support - DPDK packet I/O has been tested to work with DPDK v17.02. + DPDK packet I/O has been tested to work with DPDK v17.08. Follow steps in ./scripts/build-pktio-dpdk diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4 index 9d90bbabd..1e8fa2de9 100644 --- a/platform/linux-generic/m4/odp_dpdk.m4 +++ b/platform/linux-generic/m4/odp_dpdk.m4 @@ -52,7 +52,7 @@ then AC_DEFINE_UNQUOTED([ODP_DPDK_ZERO_COPY], [$zero_copy], [Define to 1 to enable DPDK zero copy support]) - DPDK_LIBS="-L$DPDK_PATH/lib -ldpdk -lpthread -ldl -lpcap -lm" + DPDK_LIBS="-L$DPDK_PATH/lib -ldpdk -lpthread -ldl -lpcap -lm -lnuma" AC_SUBST([DPDK_CPPFLAGS]) AC_SUBST([DPDK_LIBS]) AC_SUBST([DPDK_PMDS]) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 931cc711c..de9295c41 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -924,12 +924,6 @@ static int dpdk_close(pktio_entry_t *pktio_entry) rte_pktmbuf_free(pkt_dpdk->rx_cache[i].s.pkt[idx++]); } - if (pktio_entry->s.state != PKTIO_STATE_OPENED) - rte_eth_dev_close(pkt_dpdk->port_id); - - if (!ODP_DPDK_ZERO_COPY) - rte_mempool_free(pkt_dpdk->pkt_pool); - return 0; } @@ -1016,7 +1010,7 @@ static int dpdk_pktio_init(void) } ODP_DBG("rte_eal_init OK\n"); - rte_set_log_level(RTE_LOG_WARNING); + rte_log_set_global_level(RTE_LOG_WARNING); i = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &original_cpuset); @@ -1059,6 +1053,28 @@ static int dpdk_pktio_init_local(void) return 0; } +static void dpdk_mempool_free(struct rte_mempool *mp, void *arg ODP_UNUSED) +{ + rte_mempool_free(mp); +} + +static int dpdk_pktio_term(void) +{ + uint8_t port_id; + + if (!dpdk_initialized) + return 0; + + RTE_ETH_FOREACH_DEV(port_id) { + rte_eth_dev_close(port_id); + } + + if (!ODP_DPDK_ZERO_COPY) + rte_mempool_walk(dpdk_mempool_free, NULL); + + return 0; +} + static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { @@ -1244,11 +1260,17 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, pkt_pool = pool_create(pool_entry); } else { snprintf(pool_name, sizeof(pool_name), "pktpool_%s", netdev); - pkt_pool = rte_pktmbuf_pool_create(pool_name, - DPDK_NB_MBUF, - DPDK_MEMPOOL_CACHE_SIZE, 0, - DPDK_MBUF_BUF_SIZE, - rte_socket_id()); + /* Check if the pool exists already */ + pkt_pool = rte_mempool_lookup(pool_name); + if (pkt_pool == NULL) { + unsigned cache_size = DPDK_MEMPOOL_CACHE_SIZE; + + pkt_pool = rte_pktmbuf_pool_create(pool_name, + DPDK_NB_MBUF, + cache_size, 0, + DPDK_MBUF_BUF_SIZE, + rte_socket_id()); + } } if (pkt_pool == NULL) { ODP_ERR("Cannot init mbuf packet pool\n"); @@ -1557,7 +1579,7 @@ const pktio_if_ops_t dpdk_pktio_ops = { .name = "dpdk", .init_global = dpdk_pktio_init_global, .init_local = dpdk_pktio_init_local, - .term = NULL, + .term = dpdk_pktio_term, .open = dpdk_open, .close = dpdk_close, .start = dpdk_start, diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh index 14759142d..24194cbc9 100755 --- a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh +++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh @@ -74,7 +74,7 @@ run() if [ "$ODP_PKTIO_IF0" = "" ]; then setup_pktio_env clean - export ODP_PKTIO_DPDK_PARAMS="--no-pci --vdev eth_pcap0,iface=$IF0 --vdev eth_pcap1,iface=$IF1" + export ODP_PKTIO_DPDK_PARAMS="--no-pci --vdev net_pcap0,iface=$IF0 --vdev net_pcap1,iface=$IF1" export ODP_PKTIO_IF0=0 export ODP_PKTIO_IF1=1 fi diff --git a/scripts/build-pktio-dpdk b/scripts/build-pktio-dpdk index 6c6830ac0..97916c1e1 100755 --- a/scripts/build-pktio-dpdk +++ b/scripts/build-pktio-dpdk @@ -10,7 +10,13 @@ if [ "$?" != "0" ]; then echo "Error: pcap is not installed. You may need to install libpcap-dev" fi -git -c advice.detachedHead=false clone -q --depth=1 --single-branch --branch=v17.02 http://dpdk.org/git/dpdk dpdk +echo '#include "numa.h"' | cpp -H -o /dev/null 2>&1 +if [ "$?" != "0" ]; then + echo "Error: NUMA library is not installed. You need to install libnuma-dev" + exit 1 +fi + +git -c advice.detachedHead=false clone -q --depth=1 --single-branch --branch=v17.08 http://dpdk.org/git/dpdk dpdk pushd dpdk git log --oneline --decorate