From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 9F2FF1BA4B for ; Thu, 26 Oct 2017 00:39:19 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id r196so4735353wmf.2 for ; Wed, 25 Oct 2017 15:39:19 -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=ryN6kBrL7adnvTFhgif8J1YxqaR+4Eb5DcLItYhjUSw=; b=ZtATUEY1UlbUe7b6gr+AvAgl3dfUBu0jTag48bLFzrlY6i0QNt5CcE1HofhT/xL6B9 FzF2rXpmQRlQVFTPSMqyUVI3Wpp8MW6eLwhJ1NF1dK2/LiCvYmvxnQUxOyh7nYm1RDfO rNno4JDh5+czvAg3lmbJjgOBcNlsJLL0LuVhz7NHAg7suh9Q6DMw8iepblriXT96oUMS xBu6GjuUqzHKj0a8FTpZNRqaHU4CkiW189CA6JA5KrCNAIg2FKylzH1TB6ZV0zT7okYS VZFDLrd+UyNG2FtcVSvbn/45kVxbrbShLrt2zfx12QAlQSTi4lec/AmR56kNJJ0FSNWC MVwQ== 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=ryN6kBrL7adnvTFhgif8J1YxqaR+4Eb5DcLItYhjUSw=; b=Jkt4n5edhry7XA8/HVeOuv6/fTJp5T2O8qf8B2NLdAcawfPFLP2g1al1LPnqdUWikn xY1Tdv/4NPscdg2rXDXRFiFqhEC1LpmDwoq7UyjlVwzzlvJnCm4qQvKvFMhVeSitEdfo QqDvr17OuPyHTpfBA1WgR/v0bd7fJBBaqLcC0h7adRN97Rp+3mrnvHu/dv2u5FWtt8xD cCIvLxcjaYtvTXoWYo85Nb2hX4M1mZHoijiYrl3jIgWZgJI16AKSoDbwAlzhZR6f9xvj n96t7qZf+Bxsn3soMnAB0iWJFt+MlprdHdjbmeQbyodKhOi7kbIs0H9hfCAerdBWtu1v pKKA== X-Gm-Message-State: AMCzsaWzsiGMUtGhyPrZQAMlRzZLWssps5VNHrZz24nOgaQsqyoTaLXL lClSw5KyQO31Vh6HSum0t2T7oXnh X-Google-Smtp-Source: ABhQp+R9WOwG2zTwzUwLqL7FElaQNo6KmxasWT+wferi7uRzfzaR5j0GhvUs72/qJIANbJaiItsn5Q== X-Received: by 10.28.214.134 with SMTP id n128mr3362154wmg.59.1508971158675; Wed, 25 Oct 2017 15:39:18 -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 r63sm4466124wmg.13.2017.10.25.15.39.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Oct 2017 15:39:17 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 26 Oct 2017 00:38:29 +0200 Message-Id: <2afdb38b745b3626ccb5f52867f51577d768ce95.1508970254.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 v7 07/25] eal: expose vfio symbols 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: , X-List-Received-Date: Wed, 25 Oct 2017 22:39:19 -0000 The following symbols are used by vfio implementations within the PCI bus. They need to be publicly available for the PCI bus to be outside the EAL. + vfio_enable; + vfio_is_enabled; + vfio_noiommu_is_enabled; + vfio_release_device; + vfio_setup_device; PCI-related files (either source or private headers) do not rely on private EAL vfio header and only need the public one henceforth. This is preparing moving the PCI bus outside the EAL. Signed-off-by: Gaetan Rivet --- drivers/bus/fslmc/fslmc_vfio.h | 2 + lib/librte_eal/bsdapp/eal/eal.c | 41 ++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/include/rte_vfio.h | 130 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 1 + lib/librte_eal/linuxapp/eal/eal_interrupts.c | 1 + lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_init.h | 4 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_vfio.c | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.h | 17 ---- lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 1 + lib/librte_eal/rte_eal_version.map | 5 + 13 files changed, 187 insertions(+), 22 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_vfio.h diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h index 5470a41..b442dc0 100644 --- a/drivers/bus/fslmc/fslmc_vfio.h +++ b/drivers/bus/fslmc/fslmc_vfio.h @@ -34,6 +34,8 @@ #ifndef _FSLMC_VFIO_H_ #define _FSLMC_VFIO_H_ +#include + #include "eal_vfio.h" #define DPAA2_MC_DPNI_DEVID 7 diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index d54a280..af15812 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -739,3 +739,44 @@ rte_eal_vfio_intr_mode(void) { return RTE_INTR_MODE_NONE; } + +/* dummy forward declaration. */ +struct vfio_device_info; + +/* dummy prototypes. */ +int vfio_setup_device(const char *sysfs_base, const char *dev_addr, + int *vfio_dev_fd, struct vfio_device_info *device_info); +int vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd); +int vfio_enable(const char *modname); +int vfio_is_enabled(const char *modname); +int vfio_noiommu_is_enabled(void); + +int vfio_setup_device(__rte_unused const char *sysfs_base, + __rte_unused const char *dev_addr, + __rte_unused int *vfio_dev_fd, + __rte_unused struct vfio_device_info *device_info) +{ + return -1; +} + +int vfio_release_device(__rte_unused const char *sysfs_base, + __rte_unused const char *dev_addr, + __rte_unused int fd) +{ + return -1; +} + +int vfio_enable(__rte_unused const char *modname) +{ + return -1; +} + +int vfio_is_enabled(__rte_unused const char *modname) +{ + return 0; +} + +int vfio_noiommu_is_enabled(void) +{ + return 0; +} diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 6f5b3f3..64ff811 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -43,7 +43,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h -INC += rte_bitmap.h +INC += rte_bitmap.h rte_vfio.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h new file mode 100644 index 0000000..731c3a3 --- /dev/null +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -0,0 +1,130 @@ +/*- + * 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_VFIO_H_ +#define _RTE_VFIO_H_ + +#include + +/** + * Setup vfio_cfg for the device identified by its address. + * It discovers the configured I/O MMU groups or sets a new one for the device. + * If a new groups is assigned, the DMA mapping is performed. + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param sysfs_base + * sysfs path prefix. + * + * @param dev_addr + * device location. + * + * @param vfio_dev_fd + * VFIO fd. + * + * @param device_info + * Device information. + * + * @return + * 0 on success. + * <0 on failure. + * >1 if the device cannot be managed this way. + */ +int vfio_setup_device(const char *sysfs_base, const char *dev_addr, + int *vfio_dev_fd, struct vfio_device_info *device_info); + +/** + * Release a device mapped to a VFIO-managed I/O MMU group. + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param sysfs_base + * sysfs path prefix. + * + * @param dev_addr + * device location. + * + * @param fd + * VFIO fd. + * + * @return + * 0 on success. + * <0 on failure. + */ +int vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd); + +/** + * Enable a VFIO-related kmod. + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param modname + * kernel module name. + * + * @return + * 0 on success. + * <0 on failure. + */ +int vfio_enable(const char *modname); + +/** + * Check whether a VFIO-related kmod is enabled. + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param modname + * kernel module name. + * + * @return + * !0 if true. + * 0 otherwise. + */ +int vfio_is_enabled(const char *modname); + +/** + * Whether VFIO NOIOMMU mode is enabled. + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @return + * !0 if true. + * 0 otherwise. + */ +int vfio_noiommu_is_enabled(void); + +#endif /* _RTE_VFIO_H_ */ diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 18a07b0..bee3bbe 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -77,6 +77,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_thread.h" diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 3e9ac41..6df63d4 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_vfio.h" diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index b4dbf95..8682ee6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -41,11 +41,11 @@ #include #include #include +#include #include "eal_filesystem.h" #include "eal_private.h" #include "eal_pci_init.h" -#include "eal_vfio.h" /** * @file diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h b/lib/librte_eal/linuxapp/eal/eal_pci_init.h index ae2980d..a20783d 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h +++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h @@ -34,7 +34,7 @@ #ifndef EAL_PCI_INIT_H_ #define EAL_PCI_INIT_H_ -#include "eal_vfio.h" +#include /** IO resource type: */ #define IORESOURCE_IO 0x00000100 @@ -72,7 +72,7 @@ void pci_uio_ioport_write(struct rte_pci_ioport *p, const void *data, size_t len, off_t offset); int pci_uio_ioport_unmap(struct rte_pci_ioport *p); -#ifdef VFIO_PRESENT +#ifdef RTE_EAL_VFIO /* access config space */ int pci_vfio_read_config(const struct rte_intr_handle *intr_handle, diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index d407c87..d498df6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -44,10 +44,10 @@ #include #include #include +#include #include "eal_filesystem.h" #include "eal_pci_init.h" -#include "eal_vfio.h" #include "eal_private.h" /** diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index 3f56967..5bbcdf9 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "eal_filesystem.h" #include "eal_vfio.h" diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index 4bab363..3fd433c 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -192,27 +192,10 @@ vfio_get_group_fd(int iommu_group_no); int clear_group(int vfio_group_fd); -/** - * Setup vfio_cfg for the device identified by its address. It discovers - * the configured I/O MMU groups or sets a new one for the device. If a new - * groups is assigned, the DMA mapping is performed. - * Returns 0 on success, a negative value on failure and a positive value in - * case the given device cannot be managed this way. - */ -int vfio_setup_device(const char *sysfs_base, const char *dev_addr, - int *vfio_dev_fd, struct vfio_device_info *device_info); - -int vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd); - -int vfio_enable(const char *modname); -int vfio_is_enabled(const char *modname); - int pci_vfio_is_enabled(void); int vfio_mp_sync_setup(void); -int vfio_noiommu_is_enabled(void); - #define SOCKET_REQ_CONTAINER 0x100 #define SOCKET_REQ_GROUP 0x200 #define SOCKET_CLR_GROUP 0x300 diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c index 537beeb..598df12 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c @@ -52,6 +52,7 @@ #include #include #include +#include #include "eal_filesystem.h" #include "eal_pci_init.h" diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 9f06d23..262211a 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -252,5 +252,10 @@ DPDK_17.11 { rte_memcpy_ptr; rte_pci_get_iommu_class; rte_pci_match; + vfio_enable; + vfio_is_enabled; + vfio_noiommu_is_enabled; + vfio_release_device; + vfio_setup_device; } DPDK_17.08; -- 2.1.4