From patchwork Thu May 7 12:16:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69946 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51FA4A00C5; Thu, 7 May 2020 14:17:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3011A1DC1A; Thu, 7 May 2020 14:17:34 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E73ED1DC1A for ; Thu, 7 May 2020 14:17:32 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:30 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL4025911; Thu, 7 May 2020 15:17:30 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:40 +0300 Message-Id: <20200507121646.624-2-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 1/7] eal: move OS common functions to single file 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" From: Tal Shnaiderman Move common functions between Unix and Windows to eal_common_config.c. Those simple functions are getter functions for IOVA, configuration, Multi-process. Move rte_config and runtime_dir to be defined in a common file. Signed-off-by: Tal Shnaiderman --- lib/librte_eal/common/eal_common_config.c | 34 +++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 11 ++++++++++ lib/librte_eal/common/meson.build | 2 ++ lib/librte_eal/freebsd/eal.c | 34 ----------------------------- lib/librte_eal/linux/eal.c | 33 ---------------------------- lib/librte_eal/windows/eal.c | 36 ------------------------------- 6 files changed, 47 insertions(+), 103 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_config.c diff --git a/lib/librte_eal/common/eal_common_config.c b/lib/librte_eal/common/eal_common_config.c new file mode 100644 index 000000000..3a40df358 --- /dev/null +++ b/lib/librte_eal/common/eal_common_config.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Mellanox Technologies, Ltd + */ +#include + +#include + +/* platform-specific runtime dir */ +static char runtime_dir[PATH_MAX]; + +const char * +rte_eal_get_runtime_dir(void) +{ + return runtime_dir; +} + +/* Return a pointer to the configuration structure */ +struct rte_config * +rte_eal_get_configuration(void) +{ + return &rte_config; +} + +enum rte_iova_mode +rte_eal_iova_mode(void) +{ + return rte_eal_get_configuration()->iova_mode; +} + +enum rte_proc_type_t +rte_eal_process_type(void) +{ + return rte_config.process_type; +} diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 4a28274ec..733ee1906 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -13,6 +13,8 @@ #include #include +#include + /** * Structure storing internal configuration (per-lcore) */ @@ -60,6 +62,15 @@ struct rte_config { struct rte_mem_config *mem_config; } __rte_packed; + +/* early configuration structure, when memory config is not mmapped */ +static struct rte_mem_config early_mem_config; + +/* Address of global and public configuration */ +static struct rte_config rte_config = { + .mem_config = &early_mem_config, +}; + /** * Get the global configuration structure. * diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 9bb234009..83bac5884 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -21,6 +21,7 @@ if is_windows 'eal_common_string_fns.c', 'eal_common_tailqs.c', 'eal_common_thread.c', + 'eal_common_config.c', 'malloc_elem.c', 'malloc_heap.c', 'rte_malloc.c', @@ -57,6 +58,7 @@ sources += files( 'eal_common_trace_points.c', 'eal_common_trace_utils.c', 'eal_common_uuid.c', + 'eal_common_config.c', 'hotplug_mp.c', 'malloc_elem.c', 'malloc_heap.c', diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 540b7d38c..c293c2113 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -72,11 +72,6 @@ static struct flock wr_lock = { .l_len = sizeof(early_mem_config.memsegs), }; -/* Address of global and public configuration */ -static struct rte_config rte_config = { - .mem_config = &early_mem_config, -}; - /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; @@ -86,9 +81,6 @@ struct internal_config internal_config; /* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; -/* platform-specific runtime dir */ -static char runtime_dir[PATH_MAX]; - static const char *default_runtime_dir = "/var/run"; int @@ -151,13 +143,6 @@ eal_clean_runtime_dir(void) return 0; } - -const char * -rte_eal_get_runtime_dir(void) -{ - return runtime_dir; -} - /* Return user provided mbuf pool ops name */ const char * rte_eal_mbuf_user_pool_ops(void) @@ -165,19 +150,6 @@ rte_eal_mbuf_user_pool_ops(void) return internal_config.user_mbuf_pool_ops_name; } -/* Return a pointer to the configuration structure */ -struct rte_config * -rte_eal_get_configuration(void) -{ - return &rte_config; -} - -enum rte_iova_mode -rte_eal_iova_mode(void) -{ - return rte_eal_get_configuration()->iova_mode; -} - /* parse a sysfs (or other) file containing one integer value */ int eal_parse_sysfs_value(const char *filename, unsigned long *val) @@ -980,12 +952,6 @@ rte_eal_cleanup(void) return 0; } -enum rte_proc_type_t -rte_eal_process_type(void) -{ - return rte_config.process_type; -} - int rte_eal_has_pci(void) { return !internal_config.no_pci; diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index aa72d3650..b24cf034f 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -86,11 +86,6 @@ static struct flock wr_lock = { .l_len = sizeof(early_mem_config.memsegs), }; -/* Address of global and public configuration */ -static struct rte_config rte_config = { - .mem_config = &early_mem_config, -}; - /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; @@ -100,9 +95,6 @@ struct internal_config internal_config; /* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; -/* platform-specific runtime dir */ -static char runtime_dir[PATH_MAX]; - static const char *default_runtime_dir = "/var/run"; int @@ -241,12 +233,6 @@ eal_clean_runtime_dir(void) return -1; } -const char * -rte_eal_get_runtime_dir(void) -{ - return runtime_dir; -} - /* Return user provided mbuf pool ops name */ const char * rte_eal_mbuf_user_pool_ops(void) @@ -254,19 +240,6 @@ rte_eal_mbuf_user_pool_ops(void) return internal_config.user_mbuf_pool_ops_name; } -/* Return a pointer to the configuration structure */ -struct rte_config * -rte_eal_get_configuration(void) -{ - return &rte_config; -} - -enum rte_iova_mode -rte_eal_iova_mode(void) -{ - return rte_eal_get_configuration()->iova_mode; -} - /* parse a sysfs (or other) file containing one integer value */ int eal_parse_sysfs_value(const char *filename, unsigned long *val) @@ -1340,12 +1313,6 @@ rte_eal_cleanup(void) return 0; } -enum rte_proc_type_t -rte_eal_process_type(void) -{ - return rte_config.process_type; -} - int rte_eal_has_hugepages(void) { return ! internal_config.no_hugetlbfs; diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index a7ea78427..8ef7e60c1 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -31,36 +31,12 @@ static rte_usage_hook_t rte_application_usage_hook; */ static int mem_cfg_fd = -1; -/* early configuration structure, when memory config is not mmapped */ -static struct rte_mem_config early_mem_config; - -/* Address of global and public configuration */ -static struct rte_config rte_config = { - .mem_config = &early_mem_config, -}; - /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; /* internal configuration */ struct internal_config internal_config; -/* platform-specific runtime dir */ -static char runtime_dir[PATH_MAX]; - -const char * -rte_eal_get_runtime_dir(void) -{ - return runtime_dir; -} - -/* Return a pointer to the configuration structure */ -struct rte_config * -rte_eal_get_configuration(void) -{ - return &rte_config; -} - /* Detect if we are a primary or a secondary process */ enum rte_proc_type_t eal_proc_type_detect(void) @@ -93,24 +69,12 @@ eal_proc_type_detect(void) return ptype; } -enum rte_proc_type_t -rte_eal_process_type(void) -{ - return rte_config.process_type; -} - int rte_eal_has_hugepages(void) { return !internal_config.no_hugetlbfs; } -enum rte_iova_mode -rte_eal_iova_mode(void) -{ - return rte_config.iova_mode; -} - /* display usage */ static void eal_usage(const char *prgname) From patchwork Thu May 7 12:16:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69951 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19A9CA00C5; Thu, 7 May 2020 14:18:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EC0701DC6A; Thu, 7 May 2020 14:17:40 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 3CA051DC4C for ; Thu, 7 May 2020 14:17:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:30 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL5025911; Thu, 7 May 2020 15:17:30 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:41 +0300 Message-Id: <20200507121646.624-3-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 2/7] pci: use OS generic memory mapping functions 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" From: Tal Shnaiderman Changing all of PCIs Unix memory mapping to the new memory allocation API wrapper. Change all of PCI mapping function usage in bus/pci to support the new API. Signed-off-by: Tal Shnaiderman --- drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/linux/pci_uio.c | 2 +- drivers/bus/pci/linux/pci_vfio.c | 8 ++++---- drivers/bus/pci/pci_common_uio.c | 2 +- lib/librte_pci/rte_pci.c | 14 +++++++------- lib/librte_pci/rte_pci.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index ebbfeb13a..a01dd59f8 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -192,7 +192,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, mapaddr = pci_map_resource(NULL, fd, (off_t)offset, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); - if (mapaddr == MAP_FAILED) + if (mapaddr == NULL) goto error; maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr; diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 097dc1922..b62200153 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -345,7 +345,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, mapaddr = pci_map_resource(pci_map_addr, fd, 0, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); - if (mapaddr == MAP_FAILED) + if (mapaddr == NULL) goto error; pci_map_addr = RTE_PTR_ADD(mapaddr, diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index 64cd84a68..422e4b8d7 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -524,11 +524,11 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res, map_addr = pci_map_resource(bar_addr, vfio_dev_fd, memreg[0].offset, memreg[0].size, - MAP_FIXED); + RTE_MAP_FORCE_ADDRESS); } /* if there's a second part, try to map it */ - if (map_addr != MAP_FAILED + if (map_addr != NULL && memreg[1].offset && memreg[1].size) { void *second_addr = RTE_PTR_ADD(bar_addr, (uintptr_t)(memreg[1].offset - @@ -537,10 +537,10 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res, vfio_dev_fd, memreg[1].offset, memreg[1].size, - MAP_FIXED); + RTE_MAP_FORCE_ADDRESS); } - if (map_addr == MAP_FAILED || !map_addr) { + if (map_addr == NULL) { munmap(bar_addr, bar->size); bar_addr = MAP_FAILED; RTE_LOG(ERR, EAL, "Failed to map pci BAR%d\n", diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index f4dca9da9..793dfd0a7 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -58,7 +58,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev) "Cannot mmap device resource file %s to address: %p\n", uio_res->maps[i].path, uio_res->maps[i].addr); - if (mapaddr != MAP_FAILED) { + if (mapaddr != NULL) { /* unmap addrs correctly mapped */ for (j = 0; j < i; j++) pci_unmap_resource( diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index d1ab6b414..58e031dcf 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -138,14 +137,15 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, void *mapaddr; /* Map the PCI memory resource of device */ - mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE, - MAP_SHARED | additional_flags, fd, offset); - if (mapaddr == MAP_FAILED) { + mapaddr = rte_mem_map(requested_addr, size, + RTE_PROT_READ | RTE_PROT_WRITE, + RTE_MAP_SHARED | additional_flags, fd, offset); + if (mapaddr == NULL) { RTE_LOG(ERR, EAL, - "%s(): cannot mmap(%d, %p, 0x%zx, 0x%llx): %s (%p)\n", + "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n", __func__, fd, requested_addr, size, (unsigned long long)offset, - strerror(errno), mapaddr); + strerror(rte_errno), mapaddr); } else RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); @@ -160,7 +160,7 @@ pci_unmap_resource(void *requested_addr, size_t size) return; /* Unmap the PCI memory resource of device */ - if (munmap(requested_addr, size)) { + if (rte_mem_unmap(requested_addr, size)) { RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, %#zx): %s\n", __func__, requested_addr, size, strerror(errno)); diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h index 4087771c1..b721bbf58 100644 --- a/lib/librte_pci/rte_pci.h +++ b/lib/librte_pci/rte_pci.h @@ -159,7 +159,7 @@ int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr); * The additional flags for the mapping range. * @return * - On success, the function returns a pointer to the mapped area. - * - On error, the value MAP_FAILED is returned. + * - On error, NULL is returned. */ void *pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, int additional_flags); From patchwork Thu May 7 12:16:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69948 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9557A00C5; Thu, 7 May 2020 14:17:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 341D71DC4F; Thu, 7 May 2020 14:17:37 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E71E81DC19 for ; Thu, 7 May 2020 14:17:32 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:30 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL6025911; Thu, 7 May 2020 15:17:30 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:42 +0300 Message-Id: <20200507121646.624-4-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 3/7] pci: build on Windows 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" From: Tal Shnaiderman Added off_t in Windows header file as a supported type since it is needed by PCI. Signed-off-by: Tal Shnaiderman --- lib/librte_eal/windows/include/rte_os.h | 1 + lib/meson.build | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h index 62805a307..1c433b976 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -48,6 +48,7 @@ extern "C" { /* as in */ typedef long long ssize_t; +typedef long off_t; #ifndef RTE_TOOLCHAIN_GCC static inline int diff --git a/lib/meson.build b/lib/meson.build index e48efb519..ccb1426ff 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -35,7 +35,10 @@ libraries = [ 'flow_classify', 'bpf', 'graph', 'node', 'telemetry'] if is_windows - libraries = ['kvargs','eal'] # only supported libraries for windows + libraries = [ + 'kvargs','eal', + 'pci', + ] # only supported libraries for windows endif default_cflags = machine_args From patchwork Thu May 7 12:16:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69952 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 373E7A00C5; Thu, 7 May 2020 14:18:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C9181DC6E; Thu, 7 May 2020 14:17:42 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 4B3761DC4F for ; Thu, 7 May 2020 14:17:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:31 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL7025911; Thu, 7 May 2020 15:17:30 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:43 +0300 Message-Id: <20200507121646.624-5-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 4/7] drivers: ignore pmdinfogen generation for Windows 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" From: Tal Shnaiderman pmdinfogen generation is currently unsupported for Windows. The relevant part in meson.build is skipped. Signed-off-by: Tal Shnaiderman --- drivers/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/meson.build b/drivers/meson.build index dc293b270..09d2367dc 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -110,6 +110,7 @@ foreach class:dpdk_driver_classes dpdk_extra_ldflags += pkgconfig_extra_libs + if host_machine.system() != 'windows' # generate pmdinfo sources by building a temporary # lib and then running pmdinfogen on the contents of # that lib. The final lib reuses the object files and @@ -126,7 +127,7 @@ foreach class:dpdk_driver_classes '@OUTPUT@', pmdinfogen], output: out_filename, depends: [pmdinfogen, tmp_lib]) - + endif version_map = '@0@/@1@/@2@_version.map'.format( meson.current_source_dir(), drv_path, lib_name) From patchwork Thu May 7 12:16:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69949 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7FAC5A00C5; Thu, 7 May 2020 14:17:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 605F41DC56; Thu, 7 May 2020 14:17:38 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id F26ED1DC41 for ; Thu, 7 May 2020 14:17:32 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:31 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL8025911; Thu, 7 May 2020 15:17:31 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:44 +0300 Message-Id: <20200507121646.624-6-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 5/7] drivers: fix incorrect meson import folder for Windows 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" From: Tal Shnaiderman import library (/IMPLIB) in meson.build should use the 'drivers' and not 'libs' folder. The error is: fatal error LNK1149: output filename matches input filename. The fix uses the correct folder. Fixes: 5ed3766981 ("drivers: process shared link dependencies as for libs") Signed-off-by: Tal Shnaiderman --- drivers/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/meson.build b/drivers/meson.build index 09d2367dc..55c4c794d 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -165,7 +165,7 @@ foreach class:dpdk_driver_classes lk_deps = [version_map, def_file] if is_windows lk_args = ['-Wl,/def:' + def_file.full_path(), - '-Wl,/implib:lib\\' + implib] + '-Wl,/implib:drivers\\' + implib] else lk_args = ['-Wl,--version-script=' + version_map] # on unix systems check the output of the From patchwork Thu May 7 12:16:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69953 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DE84EA00C5; Thu, 7 May 2020 14:18:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F19D1DC5C; Thu, 7 May 2020 14:17:43 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 68BD21DC50 for ; Thu, 7 May 2020 14:17:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:31 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHUL9025911; Thu, 7 May 2020 15:17:31 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:45 +0300 Message-Id: <20200507121646.624-7-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 6/7] bus/pci: introduce Windows support with stubs 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" From: Tal Shnaiderman Addition of stub eal and bus/pci functions to compile bus/pci for Windows. Signed-off-by: Tal Shnaiderman --- drivers/baseband/meson.build | 4 + drivers/bus/ifpga/meson.build | 6 ++ drivers/bus/pci/meson.build | 14 ++- drivers/bus/pci/pci_common.c | 2 - drivers/bus/pci/windows/pci.c | 169 +++++++++++++++++++++++++++++++++++++ drivers/bus/vdev/meson.build | 6 ++ drivers/bus/vmbus/meson.build | 7 ++ drivers/common/meson.build | 4 + drivers/compress/meson.build | 4 + drivers/crypto/meson.build | 4 + drivers/event/meson.build | 4 + drivers/mempool/meson.build | 4 + drivers/meson.build | 4 - drivers/net/meson.build | 4 + drivers/raw/meson.build | 4 + drivers/vdpa/meson.build | 4 + lib/librte_eal/common/meson.build | 1 + lib/librte_eal/rte_eal_exports.def | 8 ++ lib/librte_eal/windows/eal.c | 27 +++++- lib/librte_eal/windows/eal_mp.c | 14 +++ 20 files changed, 283 insertions(+), 11 deletions(-) create mode 100644 drivers/bus/pci/windows/pci.c diff --git a/drivers/baseband/meson.build b/drivers/baseband/meson.build index 4d909f9a6..b299c3a06 100644 --- a/drivers/baseband/meson.build +++ b/drivers/baseband/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Luca Boccassi +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['null', 'turbo_sw', 'fpga_lte_fec', 'fpga_5gnr_fec'] config_flag_fmt = 'RTE_LIBRTE_PMD_BBDEV_@0@' diff --git a/drivers/bus/ifpga/meson.build b/drivers/bus/ifpga/meson.build index 4ea31f174..15339e065 100644 --- a/drivers/bus/ifpga/meson.build +++ b/drivers/bus/ifpga/meson.build @@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 Intel Corporation +if host_machine.system() == 'windows' + build = false + reason = 'not supported on Windows' + subdir_done() +endif + deps += ['pci', 'kvargs', 'rawdev'] install_headers('rte_bus_ifpga.h') sources = files('ifpga_common.c', 'ifpga_bus.c') diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build index b520bdfc1..31c492021 100644 --- a/drivers/bus/pci/meson.build +++ b/drivers/bus/pci/meson.build @@ -4,16 +4,22 @@ deps += ['pci'] install_headers('rte_bus_pci.h') sources = files('pci_common.c', - 'pci_common_uio.c', 'pci_params.c') if is_linux - sources += files('linux/pci.c', + sources += files('pci_common_uio.c', + 'linux/pci.c', 'linux/pci_uio.c', 'linux/pci_vfio.c') includes += include_directories('linux') -else - sources += files('bsd/pci.c') +endif +if host_machine.system() == 'bsd' + sources += files('pci_common_uio.c', + 'bsd/pci.c') includes += include_directories('bsd') endif +if host_machine.system() == 'windows' + sources += files('windows/pci.c') + includes += include_directories('windows') +endif deps += ['kvargs'] diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 3f5542076..1cc8d6c0f 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -10,8 +10,6 @@ #include #include #include -#include - #include #include #include diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c new file mode 100644 index 000000000..b1d34ae11 --- /dev/null +++ b/drivers/bus/pci/windows/pci.c @@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ +#include +#include + +#include +#include + +#include "private.h" + +/* The functions below are not implemented on Windows, + * but need to be defined for compilation purposes + */ + +/* Map pci device */ +int +rte_pci_map_device(struct rte_pci_device *dev __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return 0; +} + +/* Unmap pci device */ +void +rte_pci_unmap_device(struct rte_pci_device *dev __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ +} + +int +pci_update_device(const struct rte_pci_addr *addr __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return 0; +} + +/* Read PCI config space. */ +int +rte_pci_read_config(const struct rte_pci_device *dev __rte_unused, + void *buf __rte_unused, size_t len __rte_unused, + off_t offset __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return 0; +} + +/* Write PCI config space. */ +int +rte_pci_write_config(const struct rte_pci_device *dev __rte_unused, + const void *buf __rte_unused, size_t len __rte_unused, + off_t offset __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return 0; +} + +enum rte_iova_mode +pci_device_iova_mode(const struct rte_pci_driver *pdrv __rte_unused, + const struct rte_pci_device *pdev __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return RTE_IOVA_DC; +} + +int +rte_pci_ioport_map(struct rte_pci_device *dev __rte_unused, + int bar __rte_unused, struct rte_pci_ioport *p __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return -1; +} + + +void +rte_pci_ioport_read(struct rte_pci_ioport *p __rte_unused, + void *data __rte_unused, size_t len __rte_unused, + off_t offset __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ +} + +int +rte_pci_ioport_unmap(struct rte_pci_ioport *p __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return -1; +} + +bool +pci_device_iommu_support_va(const struct rte_pci_device *dev __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return false; +} + +void +rte_pci_ioport_write(struct rte_pci_ioport *p __rte_unused, + const void *data __rte_unused, size_t len __rte_unused, + off_t offset __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ +} + + +/* remap the PCI resource of a PCI device in anonymous virtual memory */ +int +pci_uio_remap_resource(struct rte_pci_device *dev __rte_unused) +{ + /* This function is not implemented on Windows. + * We really should short-circuit the call to these functions by + * clearing the RTE_PCI_DRV_NEED_MAPPING flag + * in the rte_pci_driver flags. + */ + return -1; +} +/* + * Scan the contents of the PCI bus + * and add all network class devices into the devices list. + */ +int +rte_pci_scan(void) +{ + return 0; +} diff --git a/drivers/bus/vdev/meson.build b/drivers/bus/vdev/meson.build index 967d54e4f..abaf36f1d 100644 --- a/drivers/bus/vdev/meson.build +++ b/drivers/bus/vdev/meson.build @@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if host_machine.system() == 'windows' + build = false + reason = 'not supported on Windows' + subdir_done() +endif + sources = files('vdev.c', 'vdev_params.c') install_headers('rte_bus_vdev.h') diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build index a68a1de9d..7c9865fe8 100644 --- a/drivers/bus/vmbus/meson.build +++ b/drivers/bus/vmbus/meson.build @@ -1,5 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause +if host_machine.system() == 'windows' + build = false + reason = 'not supported on Windows' + subdir_done() +endif + + install_headers('rte_bus_vmbus.h','rte_vmbus_reg.h') sources = files('vmbus_common.c', diff --git a/drivers/common/meson.build b/drivers/common/meson.build index ffd06e2c3..1cdcd95d6 100644 --- a/drivers/common/meson.build +++ b/drivers/common/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Cavium, Inc +if host_machine.system() == 'windows' + subdir_done() +endif + std_deps = ['eal'] drivers = ['cpt', 'dpaax', 'iavf', 'mlx5', 'mvep', 'octeontx', 'octeontx2', 'qat'] config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON' diff --git a/drivers/compress/meson.build b/drivers/compress/meson.build index 817ef3be4..e6c7d564e 100644 --- a/drivers/compress/meson.build +++ b/drivers/compress/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel Corporation +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['isal', 'octeontx', 'qat', 'zlib'] std_deps = ['compressdev'] # compressdev pulls in all other needed deps diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index 7fa1fbe26..2c591eaf0 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['aesni_gcm', 'aesni_mb', 'armv8', diff --git a/drivers/event/meson.build b/drivers/event/meson.build index 50d30c53f..264d4887f 100644 --- a/drivers/event/meson.build +++ b/drivers/event/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['dpaa', 'dpaa2', 'octeontx2', 'opdl', 'skeleton', 'sw', 'dsw'] if not (toolchain == 'gcc' and cc.version().version_compare('<4.8.6') and dpdk_conf.has('RTE_ARCH_ARM64')) diff --git a/drivers/mempool/meson.build b/drivers/mempool/meson.build index 7520e489f..0c6e70082 100644 --- a/drivers/mempool/meson.build +++ b/drivers/mempool/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['bucket', 'dpaa', 'dpaa2', 'octeontx', 'octeontx2', 'ring', 'stack'] std_deps = ['mempool'] config_flag_fmt = 'RTE_LIBRTE_@0@_MEMPOOL' diff --git a/drivers/meson.build b/drivers/meson.build index 55c4c794d..e11a1cd39 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_windows - subdir_done() -endif - # Defines the order in which the drivers are buit. dpdk_driver_classes = ['common', 'bus', diff --git a/drivers/net/meson.build b/drivers/net/meson.build index 266448ff2..7a6ea648f 100644 --- a/drivers/net/meson.build +++ b/drivers/net/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['af_packet', 'af_xdp', 'ark', diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build index bb5797760..334b14ac3 100644 --- a/drivers/raw/meson.build +++ b/drivers/raw/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018 NXP +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['dpaa2_cmdif', 'dpaa2_qdma', 'ifpga', 'ioat', 'ntb', 'octeontx2_dma', diff --git a/drivers/vdpa/meson.build b/drivers/vdpa/meson.build index e3ed54a25..7eedf826d 100644 --- a/drivers/vdpa/meson.build +++ b/drivers/vdpa/meson.build @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd +if host_machine.system() == 'windows' + subdir_done() +endif + drivers = ['ifc', 'mlx5',] std_deps = ['bus_pci', 'kvargs'] diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 83bac5884..2813f724a 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -7,6 +7,7 @@ if is_windows sources += files( 'eal_common_bus.c', 'eal_common_class.c', + 'eal_common_dev.c', 'eal_common_devargs.c', 'eal_common_errno.c', 'eal_common_fbarray.c', diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 854b83bcd..edbb6b277 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -2,6 +2,11 @@ EXPORTS __rte_panic rte_calloc rte_calloc_socket + per_lcore__rte_errno + rte_bus_register + rte_dev_is_probed + rte_devargs_next + rte_devargs_remove rte_eal_get_configuration rte_eal_has_hugepages rte_eal_init @@ -46,6 +51,9 @@ EXPORTS rte_memzone_reserve_aligned rte_memzone_reserve_bounded rte_memzone_walk + rte_strsplit + rte_vfio_container_dma_map + rte_vfio_container_dma_unmap rte_vlog rte_realloc rte_zmalloc diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 8ef7e60c1..31821be43 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -293,7 +293,7 @@ eal_file_lock(int fd, enum eal_flock_op op, enum eal_flock_mode mode) int rte_eal_init(int argc, char **argv) { - int i, fctret; + int i, fctret, bscan; rte_eal_log_init(NULL, 0); @@ -368,6 +368,13 @@ rte_eal_init(int argc, char **argv) eal_thread_init_master(rte_config.master_lcore); + bscan = rte_bus_scan(); + if (bscan < 0) { + rte_eal_init_alert("Cannot init PCI"); + rte_errno = ENODEV; + return -1; + } + RTE_LCORE_FOREACH_SLAVE(i) { /* @@ -396,3 +403,21 @@ rte_eal_init(int argc, char **argv) rte_eal_mp_wait_lcore(); return fctret; } + +int +rte_vfio_container_dma_map(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ + return -1; +} + +int +rte_vfio_container_dma_unmap(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ + return -1; +} diff --git a/lib/librte_eal/windows/eal_mp.c b/lib/librte_eal/windows/eal_mp.c index 16a5e8ba0..70061bea0 100644 --- a/lib/librte_eal/windows/eal_mp.c +++ b/lib/librte_eal/windows/eal_mp.c @@ -101,3 +101,17 @@ request_sync(void) EAL_LOG_STUB(); return 0; } + +int +eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req) +{ + RTE_SET_USED(req); + return 0; +} + +int +eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) +{ + RTE_SET_USED(req); + return 0; +} From patchwork Thu May 7 12:16:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Shnaiderman X-Patchwork-Id: 69947 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DC7EA00C5; Thu, 7 May 2020 14:17:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A11A1DC48; Thu, 7 May 2020 14:17:35 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id EDD291DC24 for ; Thu, 7 May 2020 14:17:32 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 May 2020 15:17:31 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 047CHULA025911; Thu, 7 May 2020 15:17:31 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, anatoly.burakov@intel.com, Tal Shnaiderman Date: Thu, 7 May 2020 15:16:46 +0300 Message-Id: <20200507121646.624-8-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200507121646.624-1-talshn@mellanox.com> References: <20200507121646.624-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v3 7/7] bus/pci: support Windows with bifurcated drivers 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" From: Tal Shnaiderman Uses SetupAPI.h functions to scan PCI tree. Uses DEVPKEY_Device_Numa_Node to get the PCI NUMA node. Uses SPDRP_BUSNUMBER and SPDRP_BUSNUMBER to get the BDF. scanning currently supports types RTE_KDRV_NONE. Signed-off-by: Tal Shnaiderman --- drivers/bus/pci/windows/pci.c | 225 ++++++++++++++++++++++++++- lib/librte_eal/windows/include/rte_windows.h | 1 + 2 files changed, 224 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index b1d34ae11..e8eff4f6f 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -1,14 +1,24 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright 2020 Mellanox Technologies, Ltd */ +#include #include #include - #include #include #include "private.h" +#include + +#define MAX_STR_TOKENS 8 +#define DEC 10 +#define HEX 16 +/* + * This code is used to simulate a PCI probe by parsing information in + * the registry hive for PCI devices. + */ + /* The functions below are not implemented on Windows, * but need to be defined for compilation purposes */ @@ -158,6 +168,184 @@ pci_uio_remap_resource(struct rte_pci_device *dev __rte_unused) */ return -1; } + +static +int get_device_pci_address(HDEVINFO hDevInfo, + PSP_DEVINFO_DATA pDeviceInfoData, struct rte_pci_addr *addr) +{ + BOOL bResult; + ULONG bus_num, dev_and_func; + + bResult = SetupDiGetDeviceRegistryProperty(hDevInfo, pDeviceInfoData, + SPDRP_BUSNUMBER, NULL, (PBYTE)&bus_num, sizeof(bus_num), NULL); + if (!bResult) + goto end; + + bResult = SetupDiGetDeviceRegistryProperty(hDevInfo, pDeviceInfoData, + SPDRP_ADDRESS, NULL, (PBYTE)&dev_and_func, sizeof(dev_and_func), + NULL); + if (!bResult) + goto end; + + addr->domain = 0; + addr->bus = bus_num; + addr->devid = dev_and_func >> 16; + addr->function = dev_and_func & 0xffff; + return 0; +end: + return GetLastError(); + +} + +static +int get_device_resource_info(HDEVINFO hDevInfo, + PSP_DEVINFO_DATA pDeviceInfoData, struct rte_pci_device *dev) +{ + int ret = -1; + DEVPROPTYPE uPropertyType; + DWORD uNumaNode; + BOOL bResult; + + switch (dev->kdrv) { + case RTE_KDRV_NONE: + /* Get NUMA node using DEVPKEY_Device_Numa_Node */ + bResult = SetupDiGetDevicePropertyW(hDevInfo, pDeviceInfoData, + &DEVPKEY_Device_Numa_Node, &uPropertyType, + (BYTE *)&uNumaNode, sizeof(uNumaNode), NULL, 0); + if (!bResult) { + ret = GetLastError(); + goto end; + } + dev->device.numa_node = uNumaNode; + /* mem_resource - Unneeded for RTE_KDRV_NONE */ + dev->mem_resource[0].phys_addr = 0; + dev->mem_resource[0].len = 0; + dev->mem_resource[0].addr = NULL; + break; + default: + ret = ERROR_NOT_SUPPORTED; + goto end; + } + + ret = ERROR_SUCCESS; +end: + return ret; +} +/* + * get_pci_hardware_info from the SPDRP_HARDWAREID output + */ +static int +get_pci_hardware_info(const char *buf, struct rte_pci_id *pci_id) +{ + int ids = 0; + unsigned int vendorID, deviceID, subvendorID = 0; + + ids = sscanf_s(buf, "PCI\\VEN_%x&DEV_%x&SUBSYS_%x", &vendorID, + &deviceID, &subvendorID); + if (ids != 3) + return -1; + + pci_id->vendor_id = vendorID; + pci_id->device_id = deviceID; + pci_id->subsystem_vendor_id = subvendorID >> 16; + pci_id->subsystem_device_id = subvendorID & 0xffff; + return 0; +} + +static void +get_kernel_driver_type(struct rte_pci_device *dev __rte_unused) +{ + /* + * If another kernel driver is supported the relevant checking + * functions should be here + */ + dev->kdrv = RTE_KDRV_NONE; +} + +static int +pci_scan_one(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDeviceInfoData) +{ + struct rte_pci_device *dev; + int ret = -1; + + dev = malloc(sizeof(struct rte_pci_device)); + if (dev == NULL) { + ret = -1; + goto end; + } + + memset(dev, 0, sizeof(*dev)); + + char strPCIDeviceInfo[PATH_MAX]; + BOOL bResult; + struct rte_pci_addr addr; + struct rte_pci_id pci_id; + + /* Retrieve PCI device IDs */ + bResult = SetupDiGetDeviceRegistryPropertyA(hDevInfo, pDeviceInfoData, + SPDRP_HARDWAREID, NULL, (BYTE *)&strPCIDeviceInfo, + sizeof(strPCIDeviceInfo), NULL); + + ret = get_pci_hardware_info((const char *)&strPCIDeviceInfo, &pci_id); + if (ret != 0) { + /* + * We won't add this device, but we want to continue + * looking for supported devices + */ + ret = ERROR_CONTINUE; + goto end; + } + + ret = get_device_pci_address(hDevInfo, pDeviceInfoData, &addr); + if (ret != 0) + goto end; + + dev->addr = addr; + dev->id = pci_id; + dev->max_vfs = 0; /* TODO: get max_vfs */ + + pci_name_set(dev); + + get_kernel_driver_type(dev); + + /* get resources */ + if (get_device_resource_info(hDevInfo, pDeviceInfoData, dev) + != ERROR_SUCCESS) { + goto end; + } + + /* device is valid, add in list (sorted) */ + if (TAILQ_EMPTY(&rte_pci_bus.device_list)) { + rte_pci_add_device(dev); + } else { + struct rte_pci_device *dev2 = NULL; + int ret; + + TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { + ret = rte_pci_addr_cmp(&dev->addr, &dev2->addr); + if (ret > 0) { + continue; + } else if (ret < 0) { + rte_pci_insert_device(dev2, dev); + } else { /* already registered */ + dev2->kdrv = dev->kdrv; + dev2->max_vfs = dev->max_vfs; + memmove(dev2->mem_resource, dev->mem_resource, + sizeof(dev->mem_resource)); + free(dev); + } + return 0; + } + rte_pci_add_device(dev); + } + + return 0; +end: + if (dev) + free(dev); + return ret; +} + /* * Scan the contents of the PCI bus * and add all network class devices into the devices list. @@ -165,5 +353,38 @@ pci_uio_remap_resource(struct rte_pci_device *dev __rte_unused) int rte_pci_scan(void) { - return 0; + DWORD DeviceIndex = 0, FoundDevice = 0; + HDEVINFO hDevInfo = NULL; + SP_DEVINFO_DATA DeviceInfoData = { 0 }; + int ret = -1; + + hDevInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, + DIGCF_PRESENT); + if (hDevInfo == INVALID_HANDLE_VALUE) { + RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n"); + goto end; + } + + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + DeviceIndex = 0; + + while (SetupDiEnumDeviceInfo(hDevInfo, DeviceIndex, &DeviceInfoData)) { + DeviceIndex++; + ret = pci_scan_one(hDevInfo, &DeviceInfoData); + if (ret == ERROR_SUCCESS) + FoundDevice++; + else if (ret != ERROR_CONTINUE) + goto end; + + memset(&DeviceInfoData, 0, sizeof(SP_DEVINFO_DATA)); + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + } + + RTE_LOG(ERR, EAL, "PCI scan found %lu devices\n", FoundDevice); + ret = (FoundDevice != 0) ? 0 : -1; +end: + if (hDevInfo != INVALID_HANDLE_VALUE) + SetupDiDestroyDeviceInfoList(hDevInfo); + + return ret; } diff --git a/lib/librte_eal/windows/include/rte_windows.h b/lib/librte_eal/windows/include/rte_windows.h index 899ed7d87..725ac4f9b 100644 --- a/lib/librte_eal/windows/include/rte_windows.h +++ b/lib/librte_eal/windows/include/rte_windows.h @@ -25,6 +25,7 @@ #include #include #include +#include /* Have GUIDs defined. */ #ifndef INITGUID