From patchwork Wed Jun 7 23:58:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 25150 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 90F6C6841; Thu, 8 Jun 2017 01:59:26 +0200 (CEST) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id E1A4E37A2 for ; Thu, 8 Jun 2017 01:59:21 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id g76so11993880wrd.1 for ; Wed, 07 Jun 2017 16:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=iuV9h3SzAC0avHDApoTFpq5B15sKqXVQKjadjmbnWko=; b=Ht7zCESwX2ysopQrFPlyYRiRjIdeCQSQWXRbJpabAQkiqMR6JkvPD8+F0cgqj5Sszp BEWwAmsQvkJC6e79yMandcD2j96wcLZx/H06CVVV4ut5OmO9mI3rAKyQwxTa2fPJpZkL i0ebtoYFt1GRkJKeixzpcQiPqyWkeOX5X8rhkUQsLjQrNKf6hvNIkZ50MnCSxsDDi2fu lKDT7RHXkOPvXSFomCFkpLOfEIBBjtzx/nSRogFAZv+2OIU/oWDICE5qDbaM1xEN/Hgx Z+oUk5EfhUC8U61HwNxTpnnsyVLbaAfeegoyoWWu78f7p4yLeLOOXRjaagHFH3aGbUOD jbdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=iuV9h3SzAC0avHDApoTFpq5B15sKqXVQKjadjmbnWko=; b=SaN/TRxx8QME/E4rSSty0RaIuOPkJIkJHehxZNq6NUrl1Bdzfhk1OcY22LqqG6X83Z 96X8Y0oUkEr8MwH7LeZeiGoVgDMvzQVM9qzGLYCyTdaUMV0hSypX7Vw6cnxz3rYsXvt3 g463LQ/EruuDicZ+rfdcUAwx9FH+zpgdjlkJ0CJ3OUewhxusOFKY90stljbSV30jSJKs S409zH76/jnVqo1YkJss6T+KdFdAaoLmtGG6ZukXORwvY0T+L4D2kGfT3Y9f6WrnZVcS YnVopj15Ygo28JRAgBfPB0sK5A70zT0AvpJ+Yh67HKU1tS9xQ98PTWIRnLRY/NhQPucT ZSIg== X-Gm-Message-State: AODbwcAX6uGlf/M9Qb4vFVsflr5WbGhDuOFto5yFqVF7JE5wkAj7SpK/ Uyys3/JBLpIsIB0DR4Y= X-Received: by 10.223.154.233 with SMTP id a96mr22570695wrc.139.1496879960981; Wed, 07 Jun 2017 16:59:20 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id p78sm3035416wmg.5.2017.06.07.16.59.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:59:19 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:58:57 +0200 Message-Id: <8ed62d2d6f8715cf3e2f1c4ead64b0ca94d8c070.1496877060.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 01/12] eal: expose rte_eal_using_phys_addrs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This function was previously private to the EAL layer. Other subsystems requires it, such as the PCI bus. This function is only exposed for linuxapps. In order not to force other components to include stdbool, which is incompatible with several NIC drivers, the return type has been changed from bool to int. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_private.h | 11 ----- lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal_memory.c | 3 +- lib/librte_eal/linuxapp/eal/eal_pci.c | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + lib/librte_eal/linuxapp/eal/rte_memory_linux.h | 64 +++++++++++++++++++++++++ 6 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 lib/librte_eal/linuxapp/eal/rte_memory_linux.h diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 6d2206a..b7e4cc6 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -327,17 +327,6 @@ int rte_eal_hugepage_init(void); */ int rte_eal_hugepage_attach(void); -/** - * Returns true if the system is able to obtain - * physical addresses. Return false if using DMA - * addresses through an IOMMU. - * - * Drivers based on uio will not load unless physical - * addresses are obtainable. It is only possible to get - * physical addresses when running as a privileged user. - */ -bool rte_eal_using_phys_addrs(void); - /* * Validate a bus name. * diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 640afd0..530e286 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -131,4 +131,6 @@ INC := rte_interrupts.h rte_kni_common.h rte_dom0_common.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include/exec-env := \ $(addprefix include/exec-env/,$(INC)) +SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include += rte_memory_linux.h + include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 9c9baf6..7a02dcd 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -70,6 +70,7 @@ #include "eal_internal_cfg.h" #include "eal_filesystem.h" #include "eal_hugepages.h" +#include "rte_memory_linux.h" #define PFN_MASK_SIZE 8 @@ -1443,7 +1444,7 @@ rte_eal_hugepage_attach(void) return -1; } -bool +int rte_eal_using_phys_addrs(void) { return phys_addrs_available; diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 595622b..9d5b051 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -45,6 +45,7 @@ #include "eal_filesystem.h" #include "eal_private.h" #include "eal_pci_init.h" +#include "rte_memory_linux.h" /** * @file diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 19eec05..6a677fc 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -209,5 +209,6 @@ DPDK_17.08 { rte_bus_from_dev; rte_eal_devargs_clone; rte_eal_devargs_rmv; + rte_eal_using_phys_addrs; } DPDK_17.05; diff --git a/lib/librte_eal/linuxapp/eal/rte_memory_linux.h b/lib/librte_eal/linuxapp/eal/rte_memory_linux.h new file mode 100644 index 0000000..0400711 --- /dev/null +++ b/lib/librte_eal/linuxapp/eal/rte_memory_linux.h @@ -0,0 +1,64 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 6WIND S.A. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of 6WIND nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_MEMORY_LINUX_H_ +#define _RTE_MEMORY_LINUX_H_ + +/** + * @file + * + * Memory-related Linux-specific RTE API. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Drivers based on uio will not load unless physical + * addresses are obtainable. It is only possible to get + * physical addresses when running as a privileged user. + * + * @return + * 1 if the system is able to obtain physical addresses. + * 0 if using DMA addresses through an IOMMU. + */ +int rte_eal_using_phys_addrs(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MEMORY_LINUX_H_ */