From patchwork Mon Dec 11 16: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: 121426 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2979648qgn; Mon, 11 Dec 2017 08:07:41 -0800 (PST) X-Google-Smtp-Source: ACJfBovvE6Ud+CaatsymeDB5Z08GPZsgZYALNVVfRGEwG56gXyTBZ7wEbS/nAj0qidhoViw7rBOw X-Received: by 10.200.24.25 with SMTP id q25mr1211754qtj.266.1513008461852; Mon, 11 Dec 2017 08:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513008461; cv=none; d=google.com; s=arc-20160816; b=LHqopX7oxLZ/ZAXHyFbdS7BJnp1vdvFybiSpdrzShMJ48R8B1LhG0+zjt0p2mkIP5Z kUx9lZRD1Bea6RzyXTd2rNLM3BwuHysO+1u1eAFyJZglQGZx3lZBqweX3VaUGgQEL4U8 ubFCsayY4lFobEK1iC6w9DRKlCa+1XNvP5IEwLUaDJRithys9akP0Av7z9HfAzdR+nzN QdPRhclFMcuAsiqTRKPPywOr63Dj0eQnlkyU7bx0vp5GVXwpil/k01ViHyQCv0u5PUrH i5uVDYZh6k7l3fgqjel9PqL00tXKSZlT31ZwExmo6k91LEDZbL2PS5k+Tk8+l207MG1g xPFQ== 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=LfvJ9Yb3UvR3ygy77fKLNvDedBgPvPbj3uiCfsRDdqs=; b=ocSnSSHS0tIRoQnSZu1qV1MlJtTrJ7DHKMOddjrDjcUw3dAiT3pRZ5NISzrfQqMEl9 fVKPMQOEOps1+Sz1asbGv3LHoiWQF/H+ZkouL3HzlwQzcfGjMpwd3BlgKZU1ajPf1Tnr 2LJxe1eujUF5c2zA4mZgJVziWhHIlW3ReYCwYiM9hGXoIabOo+5s4DC5eon9Cj5ShRT7 LjR58wdocYMOZm39K+zuwCcZP4Ugs5ARhKXIEDoki74NVI7y6Jw9MOOUl4Tgqlxnf+bA KeYbBBk3dh19Q0Mt+NAcshVvqExy6qQ65zd5vjW5CsjOsJObbXxdIaKQOuU6CsZySGZA eZIw== 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 b145si2698340qkg.444.2017.12.11.08.07.41; Mon, 11 Dec 2017 08:07:41 -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 7D19F6096D; Mon, 11 Dec 2017 16:07:41 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED 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 CA6236098B; Mon, 11 Dec 2017 16:01:08 +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 E991C60953; Mon, 11 Dec 2017 16:00:35 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 144576093D for ; Mon, 11 Dec 2017 16:00:18 +0000 (UTC) Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 08291703E4D for ; Mon, 11 Dec 2017 19:00:17 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback19j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id UJhZIxGfrQ-0G1Khubo; Mon, 11 Dec 2017 19:00:16 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id BifhbGdIDb-0GTKNBOF; Mon, 11 Dec 2017 19:00:16 +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, 11 Dec 2017 19:00:05 +0300 Message-Id: <1513008012-9231-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513008012-9231-1-git-send-email-odpbot@yandex.ru> References: <1513008012-9231-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 335 Subject: [lng-odp] [PATCH API-NEXT v1 7/14] 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 Reviewed-and-tested-by: Matias Elo --- /** Email created from pull request 335 (muvarov:devel/api-next_master_merge) ** https://github.com/Linaro/odp/pull/335 ** Patch: https://github.com/Linaro/odp/pull/335.patch ** Base sha: 630d8422564ebf4991b468cb38a29e9483fc2ec2 ** Merge commit sha: 2de2af9eca01b713e51c66fee7a5c7e535502f85 **/ 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..471bbcd51 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([dpdk], + [AS_HELP_STRING([--enable-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