From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so1.wedos.net (wes1-so1.wedos.net [46.28.106.15]) by dpdk.org (Postfix) with ESMTP id A24155687 for ; Mon, 13 Jun 2016 15:07:33 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so1.wedos.net (Postfix) with ESMTPSA id 3rStNj2c2tzC5x; Mon, 13 Jun 2016 15:07:33 +0200 (CEST) From: Jan Viktorin To: dev@dpdk.org Cc: Jan Viktorin , Anatoly Burakov , David Marchand , Keith Wiles , Santosh Shukla , Stephen Hemminger , Shreyansh Jain Date: Mon, 13 Jun 2016 15:02:05 +0200 Message-Id: <1465822926-23742-16-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1465822926-23742-1-git-send-email-viktorin@rehivetech.com> References: <1465822926-23742-1-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1461937456-22943-1-git-send-email-viktorin@rehivetech.com> References: <1461937456-22943-1-git-send-email-viktorin@rehivetech.com> Subject: [dpdk-dev] [PATCH v2 15/16] vfio: initialize vfio out of the PCI subsystem X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 13:07:34 -0000 The VFIO does not depend on the PCI anymore so it can be initialized out of the PCI subsystem. Signed-off-by: Jan Viktorin --- lib/librte_eal/linuxapp/eal/eal.c | 31 ++++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 17 +--------------- lib/librte_eal/linuxapp/eal/eal_pci_init.h | 3 --- lib/librte_eal/linuxapp/eal/eal_vfio.h | 3 +++ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 8aafd51..92225cf 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -82,6 +82,7 @@ #include "eal_filesystem.h" #include "eal_hugepages.h" #include "eal_options.h" +#include "eal_vfio.h" #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) @@ -723,6 +724,31 @@ rte_eal_iopl_init(void) #endif } +#ifdef VFIO_PRESENT +static int rte_eal_vfio_setup(void) +{ + if (internal_config.no_pci) + return 0; + + pci_vfio_enable(); + + if (pci_vfio_is_enabled()) { + + /* if we are primary process, create a thread to communicate with + * secondary processes. the thread will use a socket to wait for + * requests from secondary process to send open file descriptors, + * because VFIO does not allow multiple open descriptors on a group or + * VFIO container. + */ + if (internal_config.process_type == RTE_PROC_PRIMARY && + vfio_mp_sync_setup() < 0) + return -1; + } + + return 0; +} +#endif + /* Launch threads, called at application init(). */ int rte_eal_init(int argc, char **argv) @@ -788,6 +814,11 @@ rte_eal_init(int argc, char **argv) if (rte_eal_pci_init() < 0) rte_panic("Cannot init PCI\n"); +#ifdef VFIO_PRESENT + if (rte_eal_vfio_setup() < 0) + rte_panic("Cannot init VFIO\n"); +#endif + #ifdef RTE_LIBRTE_IVSHMEM if (rte_eal_ivshmem_init() < 0) rte_panic("Cannot init IVSHMEM\n"); diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 732e21c..1ca4c1f 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -730,21 +730,6 @@ rte_eal_pci_init(void) RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__); return -1; } -#ifdef VFIO_PRESENT - pci_vfio_enable(); - - if (pci_vfio_is_enabled()) { - - /* if we are primary process, create a thread to communicate with - * secondary processes. the thread will use a socket to wait for - * requests from secondary process to send open file descriptors, - * because VFIO does not allow multiple open descriptors on a group or - * VFIO container. - */ - if (internal_config.process_type == RTE_PROC_PRIMARY && - vfio_mp_sync_setup() < 0) - return -1; - } -#endif + return 0; } diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h b/lib/librte_eal/linuxapp/eal/eal_pci_init.h index cdfdada..9eb9cb7 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h +++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h @@ -64,9 +64,6 @@ int pci_uio_ioport_unmap(struct rte_pci_ioport *p); #ifdef VFIO_PRESENT -int pci_vfio_enable(void); -int pci_vfio_is_enabled(void); - /* access config space */ int pci_vfio_read_config(const struct rte_intr_handle *intr_handle, void *buf, size_t len, off_t offs); diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index 884884c..43960eb 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -143,6 +143,9 @@ int vfio_setup_device(const char *sysfs_base, const char *dev_addr, int vfio_enable(const char *modname); int vfio_is_enabled(const char *modname); +int pci_vfio_enable(void); +int pci_vfio_is_enabled(void); + #define SOCKET_REQ_CONTAINER 0x100 #define SOCKET_REQ_GROUP 0x200 #define SOCKET_OK 0x0 -- 2.8.0