All of lore.kernel.org
 help / color / mirror / Atom feed
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 <talshn@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 6/7] bus/pci: introduce Windows support with stubs
Date: Thu,  7 May 2020 15:16:45 +0300	[thread overview]
Message-ID: <20200507121646.624-7-talshn@mellanox.com> (raw)
In-Reply-To: <20200507121646.624-1-talshn@mellanox.com>

From: Tal Shnaiderman <talshn@mellanox.com>

Addition of stub eal and bus/pci functions to compile
bus/pci for Windows.

Signed-off-by: Tal Shnaiderman <talshn@mellanox.com>
---
 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 <bluca@debian.org>
 
+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 <stdlib.h>
 #include <stdio.h>
 #include <sys/queue.h>
-#include <sys/mman.h>
-
 #include <rte_errno.h>
 #include <rte_interrupts.h>
 #include <rte_log.h>
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 <rte_errno.h>
+#include <rte_log.h>
+
+#include <rte_string_fns.h>
+#include <rte_eal_memconfig.h>
+
+#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;
+}
-- 
2.16.1.windows.4


  parent reply	other threads:[~2020-05-07 12:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 12:16 [dpdk-dev] [PATCH v3 0/7] Windows bus/pci support talshn
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 1/7] eal: move OS common functions to single file talshn
2020-05-07 23:26   ` Dmitry Kozlyuk
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 2/7] pci: use OS generic memory mapping functions talshn
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 3/7] pci: build on Windows talshn
2020-05-07 23:27   ` Dmitry Kozlyuk
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 4/7] drivers: ignore pmdinfogen generation for Windows talshn
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 5/7] drivers: fix incorrect meson import folder " talshn
2020-05-07 12:16 ` talshn [this message]
2020-05-07 12:16 ` [dpdk-dev] [PATCH v3 7/7] bus/pci: support Windows with bifurcated drivers talshn
2020-05-07 22:50   ` Dmitry Kozlyuk
2020-05-07 23:06     ` Dmitry Kozlyuk
2020-05-10  9:52     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200507121646.624-7-talshn@mellanox.com \
    --to=talshn@mellanox.com \
    --cc=anatoly.burakov@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=grive@u256.net \
    --cc=navasile@linux.microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=ranjit.menon@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.