From patchwork Mon Dec 4 15:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120566 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4543279qgn; Mon, 4 Dec 2017 07:05:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMbDsoljCR1jcs/wU41jCE7S/i7/Y0/644ST1Vg0uzFYXsVlvUUJitmpRLWH2wmKeKwX603Z X-Received: by 10.237.41.37 with SMTP id s34mr22905868qtd.154.1512399925513; Mon, 04 Dec 2017 07:05:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512399925; cv=none; d=google.com; s=arc-20160816; b=gdfW27R8/Mxs1t9CPCh3TkWI9F8hhnSxc7OY7R1iwV8T+3ldOAKqEdJUPutavDx8xi TPOEqKXNz6RdKjWiWe68pOdcXx+zN814NDlK1Al2lD0xwB26bN6TRGs9BU28f/7iLPIs wL1giKkWtJok17V9U8P+Mw/e+GFatxusbjkrtX7BXm+hq2pw9wj7gtjKEq+gfGbo8Cdv Hbw54T/W8cKn90VvEXQAjEyOdRUt2HXvIpkzj//GLx6+b2m/plkpF8J96qiQ5CuN2E3r sbYRdwsPOYMVUjvgbHusT37nOv9E1ZuBNnkYghIcj6OoeS9BQ1aOusHa5RTjuYaDRuj0 bZVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=XTXA77FfWm+7OhJ0M9k1Wnge/oq6+moTBo97OwQQ/Dw=; b=RgJ3kHIx4njj7RHwhD1KGtWEsqxruVftJ1h/qIIt3GvJnWzW0r5n9oSxqqZn295oQq ZtaVGWXcCCvUn1R8wqxU6kKP732ZZII0KNLCkanEjHu6hLQMfYuLbSj/IkC315xfgp9O gPFHZen8DUmPTrKErYDmm2+Wt9P0ETi+GyDVLXnwTMUZ/cf3ZxkVKfoDpMk7eMFV7zfP smy9ZTRY40VRp/8f7Ce9k7XHfOIWI5Nrj9tdD0+ByK0EMB4S+RIVLKpb2+SqJeb2oO2d 7aTBAQP4S7cSpuXOQAEeONufLSMtHjEArSKEfNwlmy8ei009Drm5fyIOsMQqLSqBe0Oa ROlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id b65si12976347qkc.391.2017.12.04.07.05.10; Mon, 04 Dec 2017 07:05:25 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9278860810; Mon, 4 Dec 2017 15:05:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED, URIBL_DBL_ABUSE_SPAM autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id AD4426094A; Mon, 4 Dec 2017 15:00:49 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 193CF608AA; Mon, 4 Dec 2017 15:00:25 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id BD45060655 for ; Mon, 4 Dec 2017 15:00:18 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 2DCEA6A83134 for ; Mon, 4 Dec 2017 18:00:12 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id xFYlRj5vEK-0C8qYKMx; Mon, 04 Dec 2017 18:00:12 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Hseuacluka-0BEqUdQP; Mon, 04 Dec 2017 18:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 4 Dec 2017 18:00:05 +0300 Message-Id: <1512399608-12981-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512399608-12981-1-git-send-email-odpbot@yandex.ru> References: <1512399608-12981-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 321 Subject: [lng-odp] [PATCH v2 3/6] linux-gen: add support for using system-wide DPDK X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Support using distro-installed DPDK for Pkt I/O. Distributions (like Ubuntu, Debian, etc) start providing DPDK packages. It is wise to enable users to use distro-provided DPDK version rather than requiring to always compile it from sources. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 321 (lumag:dpdk-system-master) ** https://github.com/Linaro/odp/pull/321 ** Patch: https://github.com/Linaro/odp/pull/321.patch ** Base sha: 5329e5211c447b9b823149baf76112eedfeb07fb ** Merge commit sha: 280c62aa5d2ea89ff05e376a74d7c6bbd29f002f **/ m4/odp_dpdk.m4 | 43 ++++++++++++++++++++++++++++------- platform/linux-generic/m4/odp_dpdk.m4 | 28 +++++++++++++++++++---- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4 index 636170a7f..05e60cc06 100644 --- a/m4/odp_dpdk.m4 +++ b/m4/odp_dpdk.m4 @@ -16,6 +16,31 @@ AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive]) AC_SUBST([DPDK_PMDS]) ]) +# _ODP_DPDK_CHECK_LIB(LDFLAGS, [LIBS], [EXTRA_LIBS]) +# ---------------------------------- +# Check if one can use -ldpdk with provided set of libs +AC_DEFUN([_ODP_DPDK_CHECK_LIB], [dnl +########################################################################## +# Save and set temporary compilation flags +########################################################################## +OLD_LDFLAGS=$LDFLAGS +OLD_LIBS=$LIBS +LDFLAGS="$1 $LDFLAGS" +LIBS="$LIBS -ldpdk $2" + +AC_MSG_CHECKING([for rte_eal_init in -ldpdk $2]) +AC_LINK_IFELSE([AC_LANG_CALL([], [rte_eal_init])], + [AC_MSG_RESULT([yes]) + DPDK_LIBS="$1 -ldpdk $3 $2"], + [AC_MSG_RESULT([no])]) + +########################################################################## +# Restore old saved variables +########################################################################## +LDFLAGS=$OLD_LDFLAGS +LIBS=$OLD_LIBS +]) + # ODP_DPDK_CHECK(CPPFLAGS, LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) # ----------------------------------------------------------------------- # Check for DPDK availability @@ -23,10 +48,7 @@ AC_DEFUN([ODP_DPDK_CHECK], [dnl ########################################################################## # Save and set temporary compilation flags ########################################################################## -OLD_LDFLAGS=$LDFLAGS -OLD_LIBS=$LIBS OLD_CPPFLAGS=$CPPFLAGS -LDFLAGS="$2 $LDFLAGS" CPPFLAGS="$1 $CPPFLAGS" dpdk_check_ok=yes @@ -34,16 +56,21 @@ dpdk_check_ok=yes AC_CHECK_HEADERS([rte_config.h], [], [dpdk_check_ok=no]) -AC_CHECK_LIB([dpdk], [rte_eal_init], [], - [dpdk_check_ok=no], [-ldl -lpthread -lnuma]) +DPDK_LIBS="" +_ODP_DPDK_CHECK_LIB([$2]) +AS_IF([test "x$DPDK_LIBS" = "x"], + [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread], [-lm])]) +AS_IF([test "x$DPDK_LIBS" = "x"], + [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread -lnuma], [-lm])]) +AS_IF([test "x$DPDK_LIBS" = "x"], + [dpdk_check_ok=no]) AS_IF([test "x$dpdk_check_ok" != "xno"], - [m4_default([$3], [:])], + [AC_SUBST([DPDK_LIBS]) + m4_default([$3], [:])], [m4_default([$4], [:])]) ########################################################################## # Restore old saved variables ########################################################################## -LDFLAGS=$OLD_LDFLAGS -LIBS=$OLD_LIBS CPPFLAGS=$OLD_CPPFLAGS ]) diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4 index 91f76e2de..2beea365c 100644 --- a/platform/linux-generic/m4/odp_dpdk.m4 +++ b/platform/linux-generic/m4/odp_dpdk.m4 @@ -2,12 +2,27 @@ # Enable DPDK support ########################################################################## pktio_dpdk_support=no + +AC_ARG_ENABLE([pktio-dpdk], + [AS_HELP_STRING([--enable-pktio-dpdk], [enable DPDK support for Packet I/O])], + [pktio_dpdk_support=$enableval + DPDK_PATH=system]) + AC_ARG_WITH([dpdk-path], [AS_HELP_STRING([--with-dpdk-path=DIR], [path to dpdk build directory])], [DPDK_PATH="$withval" - DPDK_CPPFLAGS="-isystem $DPDK_PATH/include" - DPDK_LDFLAGS="-L$DPDK_PATH/lib" - pktio_dpdk_support=yes],[]) + pktio_dpdk_support=yes],[]) + +AS_IF([test "x$DPDK_PATH" = "xsystem"], + [DPDK_CPPFLAGS="-isystem/usr/include/dpdk" + DPDK_LDFLAGS="" + DPDK_PMD_PATH="`$CC --print-file-name=librte_pmd_null.a`" + DPDK_PMD_PATH="`dirname "$DPDK_PMD_PATH"`" + AS_IF([test "x$DPDK_PMD_PATH" = "x"], + [AC_MSG_FAILURE([Could not locate system DPDK PMD directory])])], + [DPDK_CPPFLAGS="-isystem $DPDK_PATH/include" + DPDK_LDFLAGS="-L$DPDK_PATH/lib" + DPDK_PMD_PATH="$DPDK_PATH/lib"]) ########################################################################## # Enable zero-copy DPDK pktio @@ -30,14 +45,17 @@ then ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [], [AC_MSG_FAILURE([can't find DPDK])]) - ODP_DPDK_PMDS([$DPDK_PATH/lib]) + ODP_DPDK_PMDS([$DPDK_PMD_PATH]) AC_DEFINE([ODP_PKTIO_DPDK], [1], [Define to 1 to enable DPDK packet I/O support]) AC_DEFINE_UNQUOTED([ODP_DPDK_ZERO_COPY], [$zero_copy], [Define to 1 to enable DPDK zero copy support]) - DPDK_LIBS="$DPDK_LDFLAGS -ldpdk -lpthread -ldl -lpcap -lm -lnuma" + if test -r "$DPDK_PMD_PATH/librte_pmd_pcap.a" && + ! test -r "$DPDK_PMD_PATH/librte_pmd_pcap.so" ; then + DPDK_LIBS="$DPDK_LIBS -lpcap" + fi AC_SUBST([DPDK_CPPFLAGS]) AC_SUBST([DPDK_LIBS]) else