Skip to contentSkip to conversation

rte_driver/device infrastructure

PATCH In review Jan Viktorin 3 participants 21 messages Jul 8, 2016 – Jul 15, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover rte_driver/device infrastructure

Hello,

based on the discussions with Shreyansh, I propose a patchset with the important EAL changes. It is incomplete and I suppose to extend and change certain things in the foreseeable future.

Important notes:

* pmd_type is removed
* introduced rte_vdev_driver inheriting rte_driver
* PMD_REGISTER_DRIVER is replaced by RTE_EAL_VDRV_REGISTER
* rte_driver/device integrated into rte_pci_driver/device
* all drivers and devices are in 2 lists - general and bus-specific

Shreyansh, I hope I do not duplicate your work. I tried to avoid touching pmd_type but it quite complicated... There is also an initial generalization of rte_pci_resource. More such generalizations are to be done.

The init/uninit functions cannot be generalized easily, I think. Both PCI and VDEV have different requirements.

No idea about hotplug...

The patchset is based on (all rebased on top of 34d279):

[PATCH v5 00/17] Prepare for rte_device / rte_driver

Thanks anybody for some quick review and notes.

Regards
Jan

--

Jan Viktorin (15):
eal: extract vdev infra
eal: no need to test for PMD_VDEV anymore
eal: do not call init for PMD_PDEV drivers
drivers: convert PMD_VDEV drivers to use rte_vdev_driver
eal: move init/uninit to rte_vdev_driver
eal: remove PMD_REGISTER_DRIVER
eal: get rid of pmd_type
eal: define macro container_of
eal: rte_pci.h includes rte_dev.h
eal: rename and move rte_pci_resource
eal/pci: inherit rte_driver by rte_pci_driver
eal: call rte_eal_driver_register
eal: introduce rte_device
eal/pci: inherit rte_device by rte_pci_device eal/pci: insert rte_device on scan

 app/test/test_pci.c                        |  10 ++-
 app/test/virtual_pmd.c                     |   6 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   |  13 ++--
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  13 ++--
 drivers/crypto/kasumi/rte_kasumi_pmd.c     |  13 ++--
 drivers/crypto/null/null_crypto_pmd.c      |  13 ++--
 drivers/crypto/qat/rte_qat_cryptodev.c     |   4 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c     |  13 ++--
 drivers/net/af_packet/rte_eth_af_packet.c  |  11 ++--
 drivers/net/bnx2x/bnx2x_ethdev.c           |   8 ++-
 drivers/net/bonding/rte_eth_bond_pmd.c     |  11 ++--
 drivers/net/cxgbe/cxgbe_ethdev.c           |   4 +-
 drivers/net/cxgbe/sge.c                    |   6 +-
 drivers/net/e1000/em_ethdev.c              |   4 +-
 drivers/net/e1000/igb_ethdev.c             |   8 ++-
 drivers/net/ena/ena_ethdev.c               |   4 +-
 drivers/net/enic/enic_ethdev.c             |   4 +-
 drivers/net/fm10k/fm10k_ethdev.c           |  10 +--
 drivers/net/i40e/i40e_ethdev.c             |   4 +-
 drivers/net/i40e/i40e_ethdev_vf.c          |   4 +-
 drivers/net/i40e/i40e_fdir.c               |   2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c           |   8 ++-
 drivers/net/mlx4/mlx4.c                    |   4 +-
 drivers/net/mlx5/mlx5.c                    |   4 +-
 drivers/net/mpipe/mpipe_tilegx.c           |  20 +++---
 drivers/net/nfp/nfp_net.c                  |   4 +-
 drivers/net/null/rte_eth_null.c            |  11 ++--
 drivers/net/pcap/rte_eth_pcap.c            |  11 ++--
 drivers/net/qede/qede_ethdev.c             |   4 ++
 drivers/net/ring/rte_eth_ring.c            |  11 ++--
 drivers/net/szedata2/rte_eth_szedata2.c    |   8 ++-
 drivers/net/vhost/rte_eth_vhost.c          |  11 ++--
 drivers/net/virtio/virtio_ethdev.c         |   6 +-
 drivers/net/virtio/virtio_pci.c            |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   7 +-
 drivers/net/vmxnet3/vmxnet3_rxtx.c         |   2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |  11 ++--
 lib/librte_cryptodev/rte_cryptodev.c       |   6 +-
 lib/librte_eal/bsdapp/eal/Makefile         |   1 +
 lib/librte_eal/common/Makefile             |   2 +-
 lib/librte_eal/common/eal_common_dev.c     |  67 +++----------------
 lib/librte_eal/common/eal_common_pci.c     |  20 +++---
 lib/librte_eal/common/eal_common_vdev.c    | 100 +++++++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_common.h |  16 +++++
 lib/librte_eal/common/include/rte_dev.h    |  54 +++++++++-------
 lib/librte_eal/common/include/rte_pci.h    |  20 ++----
 lib/librte_eal/common/include/rte_vdev.h   |  96 +++++++++++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile       |   1 +
 lib/librte_eal/linuxapp/eal/eal_ivshmem.c  |   2 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c      |   7 +-
 lib/librte_ether/rte_ethdev.c              |  16 +++--
 51 files changed, 468 insertions(+), 229 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_vdev.c
 create mode 100644 lib/librte_eal/common/include/rte_vdev.h
Signature · 1 line
2.9.0
#1 lore raw

PATCH 1/15 eal: extract vdev infra

Move all PMD_VDEV-specific code into a separate module and header file to not polute the generic code anymore. There is now a list of virtual devices available.

The rte_vdev_driver integrates the original rte_driver inside (C inheritance). The rte_driver will be however change in the future to serve as a common base for all other types of drivers.

The existing PMDs (PMD_VDEV) are to be modified later (there is no change for them at the moment).

There is however a inconsistency. The functions rte_eal_vdev_init and rte_eal_vdev_uninit are still placed in the rte_dev.h (instead of the rte_vdev.h).

---
 lib/librte_eal/bsdapp/eal/Makefile       |   1 +
 lib/librte_eal/common/Makefile           |   2 +-
 lib/librte_eal/common/eal_common_dev.c   |  54 +---------------
 lib/librte_eal/common/eal_common_vdev.c  | 104 +++++++++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h  |   1 +
 lib/librte_eal/common/include/rte_vdev.h |  83 ++++++++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile     |   1 +
 7 files changed, 192 insertions(+), 54 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_vdev.c
 create mode 100644 lib/librte_eal/common/include/rte_vdev.h
lib/librte_eal/bsdapp/eal/Makefile +1 -0
index 698fa0a..b7e94a4 100644
@@ -69,6 +69,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
lib/librte_eal/common/Makefile +1 -1
index f5ea0ee..dac7ce7 100644
@@ -38,7 +38,7 @@ INC += rte_pci_dev_ids.h rte_per_lcore.h rte_random.h
 INC += rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_version.h
 INC += rte_eal_memconfig.h rte_malloc_heap.h
-INC += rte_hexdump.h rte_devargs.h rte_dev.h
+INC += rte_hexdump.h rte_devargs.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
 
lib/librte_eal/common/eal_common_dev.c +1 -53

72 lines not on this page · raw message

lib/librte_eal/common/eal_common_vdev.c new file +104 -0

104 lines not on this page · raw message

lib/librte_eal/common/include/rte_dev.h +1 -0
index b1c0520..2aeb752 100644
@@ -210,6 +210,7 @@ static void devinitfn_ ##d(void)\
 	rte_eal_driver_register(&d);\
 }
 
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_vdev.h new file +83 -0

83 lines not on this page · raw message

lib/librte_eal/linuxapp/eal/Makefile +1 -0
index 30b30f3..9553e97 100644
@@ -85,6 +85,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
Signature · 1 line
2.9.0
#2 lore raw

Re: [PATCH v1 01/15] eal: extract vdev infra

Hi Jan,

Some comments.

Quoted 32 lines · Jan Viktorin

Move all PMD_VDEV-specific code into a separate module and header file to not polute the generic code anymore. There is now a list of virtual devices available.

The rte_vdev_driver integrates the original rte_driver inside (C inheritance). The rte_driver will be however change in the future to serve as a common base for all other types of drivers.

The existing PMDs (PMD_VDEV) are to be modified later (there is no change for them at the moment).

There is however a inconsistency. The functions rte_eal_vdev_init and rte_eal_vdev_uninit are still placed in the rte_dev.h (instead of the rte_vdev.h).

---
 lib/librte_eal/bsdapp/eal/Makefile       |   1 +
 lib/librte_eal/common/Makefile           |   2 +-
 lib/librte_eal/common/eal_common_dev.c   |  54 +---------------
 lib/librte_eal/common/eal_common_vdev.c  | 104 +++++++++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h  |   1 +
 lib/librte_eal/common/include/rte_vdev.h |  83 ++++++++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile     |   1 +
 7 files changed, 192 insertions(+), 54 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_vdev.c
 create mode 100644 lib/librte_eal/common/include/rte_vdev.h
lib/librte_eal/bsdapp/eal/Makefile +0 -0
index 698fa0a..b7e94a4 100644

[...]

Quoted 60 lines
lib/librte_eal/common/eal_common_vdev.c new file +54 -0
new file mode 100644
index 0000000..ea83c41
@@ -0,0 +1,104 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. 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 RehiveTech 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.
+ */
+
+#include <string.h>
+#include <sys/queue.h>
+#include <rte_vdev.h>
+
+struct vdev_driver_list vdev_driver_list =
+	TAILQ_HEAD_INITIALIZER(vdev_driver_list);
+
+/* register a driver */
+void
+rte_eal_vdrv_register(struct rte_vdev_driver *driver)
+{
+	TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
+}
+
+/* unregister a driver */
+void
+rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
+{
+	TAILQ_REMOVE(&vdev_driver_list, driver, next);
+}
+
+int

lib/librte_eal/common/eal_common_vdev.c line 64

Quoted 10 lines
lib/librte_eal/common/eal_common_vdev.c new file +10 -0
+rte_eal_vdev_init(const char *name, const char *args)
+{
+	struct rte_vdev_driver *driver;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
+		if (driver->driver.type != PMD_VDEV)
+			continue;

Now that two separate lists for vdev and pdev exist, we don't need this check anymore. In fact, PMD_VDEV might not even exist.

Quoted 16 lines
lib/librte_eal/common/eal_common_vdev.c new file +16 -0
+
+		/*
+		 * search a driver prefix in virtual device name.
+		 * For example, if the driver is pcap PMD, driver->name
+		 * will be "eth_pcap", but "name" will be "eth_pcapN".
+		 * So use strncmp to compare.
+		 */
+		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
+			return driver->driver.init(name, args);
+	}
+
+	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+	return -EINVAL;
+}
+
+int

lib/librte_eal/common/eal_common_vdev.c line 90

Quoted 10 lines
lib/librte_eal/common/eal_common_vdev.c new file +10 -0
+rte_eal_vdev_uninit(const char *name)
+{
+	struct rte_vdev_driver *driver;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
+		if (driver->driver.type != PMD_VDEV)
+			continue;

Same as above, redundant check.

Quoted 19 lines
lib/librte_eal/common/eal_common_vdev.c new file +14 -0
+
+		/*
+		 * search a driver prefix in virtual device name.
+		 * For example, if the driver is pcap PMD, driver->name
+		 * will be "eth_pcap", but "name" will be "eth_pcapN".
+		 * So use strncmp to compare.
+		 */
+		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
+			return driver->driver.uninit(name);
+	}
+
+	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+	return -EINVAL;
+}
lib/librte_eal/common/include/rte_dev.h +0 -0
index b1c0520..2aeb752 100644

lib/librte_eal/common/include/rte_dev.h static void devinitfn_ ##d(void)\ · line 213

Quoted 4 lines
lib/librte_eal/common/include/rte_dev.h +1 -0
@@ -210,6 +210,7 @@ static void devinitfn_ ##d(void)\
 	rte_eal_driver_register(&d);\
 }
 
+

Probably a stray newline.

Quoted 71 lines
lib/librte_eal/common/include/rte_dev.h +0 -0
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_vdev.h new file +62 -0
new file mode 100644
index 0000000..523bd92
@@ -0,0 +1,83 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. 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 RehiveTech 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_VDEV_H
+#define RTE_VDEV_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/queue.h>
+#include <rte_dev.h>
+
+/** Double linked list of virtual device drivers. */
+TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
+
+/**
+ * A virtual device driver abstraction.
+ */
+struct rte_vdev_driver {
+	TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
+	struct rte_driver driver;          /**< Inherited general driver. */
+};
+
+/**
+ * Register a virtual device driver.
+ *
+ * @param driver
+ *   A pointer to a rte_vdev_driver structure describing the driver
+ *   to be registered.
+ */
+void rte_eal_vdrv_register(struct rte_vdev_driver *driver);
+

lib/librte_eal/common/include/rte_vdev.h line 72

Quoted 10 lines
lib/librte_eal/common/include/rte_vdev.h new file +10 -0
+/**
+ * Unregister a virtual device driver.
+ *
+ * @param driver
+ *   A pointer to a rte_vdev_driver structure describing the driver
+ *   to be unregistered.
+ */
+void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver);
+
+#define RTE_EAL_VDRV_REGISTER(d)\

In the recent commits, I noticed that macros have taken the (name, driver) format. PMD_REGISTER_DRIVER() (now redundant), DRIVER_REGISTER_PCI_TABLE() ... etc It might be better to stick to the same format.

Quoted 24 lines
lib/librte_eal/common/include/rte_vdev.h new file +11 -0
+RTE_INIT(vdrvinitfn_ ##d);\
+static void vdrvinitfn_ ##d(void)\
+{\
+	rte_eal_vdrv_register(&d);\
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
lib/librte_eal/linuxapp/eal/Makefile +1 -0
index 30b30f3..9553e97 100644
@@ -85,6 +85,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
#3 lore raw

Re: [PATCH v1 01/15] eal: extract vdev infra

Quoted 22 lines · On Mon, 11 Jul 2016 18:59:48 +0530 Shreyansh jain <[email protected]>…

Hi Jan,

Some comments.

Quoted 17 lines · Jan Viktorin

Move all PMD_VDEV-specific code into a separate module and header file to not polute the generic code anymore. There is now a list of virtual devices available.

The rte_vdev_driver integrates the original rte_driver inside (C inheritance). The rte_driver will be however change in the future to serve as a common base for all other types of drivers.

The existing PMDs (PMD_VDEV) are to be modified later (there is no change for them at the moment).

There is however a inconsistency. The functions rte_eal_vdev_init and rte_eal_vdev_uninit are still placed in the rte_dev.h (instead of the rte_vdev.h).

---

[...]

Quoted 14 lines
Quoted 14 lines
lib/librte_eal/common/eal_common_vdev.c new file +14 -0
+
+/* unregister a driver */
+void
+rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
+{
+	TAILQ_REMOVE(&vdev_driver_list, driver, next);
+}
+
+int
+rte_eal_vdev_init(const char *name, const char *args)
+{
+	struct rte_vdev_driver *driver;
+
+	if (name == NULL)
Quoted 8 lines

lib/librte_eal/common/eal_common_vdev.c line 64

Quoted 5 lines
lib/librte_eal/common/eal_common_vdev.c new file +5 -0
+		return -EINVAL;
+
+	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
+		if (driver->driver.type != PMD_VDEV)
+			continue;  

Now that two separate lists for vdev and pdev exist, we don't need this check anymore. In fact, PMD_VDEV might not even exist.

Solved already in the next 2 patches.

Quoted 21 lines
Quoted 21 lines
lib/librte_eal/common/eal_common_vdev.c new file +20 -0
+
+		/*
+		 * search a driver prefix in virtual device name.
+		 * For example, if the driver is pcap PMD, driver->name
+		 * will be "eth_pcap", but "name" will be "eth_pcapN".
+		 * So use strncmp to compare.
+		 */
+		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
+			return driver->driver.init(name, args);
+	}
+
+	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+	return -EINVAL;
+}
+
+int
+rte_eal_vdev_uninit(const char *name)
+{
+	struct rte_vdev_driver *driver;
+
Quoted 8 lines

lib/librte_eal/common/eal_common_vdev.c line 64

Quoted 6 lines
lib/librte_eal/common/eal_common_vdev.c new file +6 -0
+	if (name == NULL)
+		return -EINVAL;
+
+	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
+		if (driver->driver.type != PMD_VDEV)
+			continue;  

Same as above, redundant check.

Solved already in the next 2 patches.

Quoted 23 lines
Quoted 23 lines
lib/librte_eal/common/eal_common_vdev.c new file +14 -0
+
+		/*
+		 * search a driver prefix in virtual device name.
+		 * For example, if the driver is pcap PMD, driver->name
+		 * will be "eth_pcap", but "name" will be "eth_pcapN".
+		 * So use strncmp to compare.
+		 */
+		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
+			return driver->driver.uninit(name);
+	}
+
+	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+	return -EINVAL;
+}
lib/librte_eal/common/include/rte_dev.h +0 -0
index b1c0520..2aeb752 100644
@@ -210,6 +210,7 @@ static void devinitfn_ ##d(void)\
 	rte_eal_driver_register(&d);\
 }
 
Quoted 3 lines

lib/librte_eal/common/include/rte_dev.h static void devinitfn_ ##d(void)\ · line 213

Quoted 1 line
lib/librte_eal/common/include/rte_dev.h +1 -0
+  

Probably a stray newline.

Will fix.

Quoted 10 lines
Quoted 10 lines
lib/librte_eal/common/include/rte_dev.h +0 -0
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_vdev.h new file +0 -0
new file mode 100644
index 0000000..523bd92
@@ -0,0 +1,83 @@

[...]

Quoted 6 lines
Quoted 6 lines

+/**
+ * Unregister a virtual device driver.
+ *
+ * @param driver
+ * A pointer to a rte_vdev_driver structure describing the driver
+ * to be unregistered.

Quoted 8 lines

lib/librte_eal/common/include/rte_vdev.h line 72

Quoted 4 lines

+ */

lib/librte_eal/common/include/rte_vdev.h new file +3 -0
+void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver);
+
+#define RTE_EAL_VDRV_REGISTER(d)\  

In the recent commits, I noticed that macros have taken the (name, driver) format. PMD_REGISTER_DRIVER() (now redundant), DRIVER_REGISTER_PCI_TABLE() ... etc It might be better to stick to the same format.

Yes, I will change this when rebasing.

Thanks
Jan

Quoted 26 lines
Quoted 25 lines
lib/librte_eal/common/include/rte_vdev.h new file +11 -0
+RTE_INIT(vdrvinitfn_ ##d);\
+static void vdrvinitfn_ ##d(void)\
+{\
+	rte_eal_vdrv_register(&d);\
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
lib/librte_eal/linuxapp/eal/Makefile +1 -0
index 30b30f3..9553e97 100644
@@ -85,6 +85,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
#4 lore raw

PATCH 2/15 eal: no need to test for PMD_VDEV anymore

In reply to Jan Viktorin

All devices in the rte_eal_vdev_init/uninit are always virtual devices.

---
 lib/librte_eal/common/eal_common_vdev.c | 6 ------
 1 file changed, 6 deletions(-)
lib/librte_eal/common/eal_common_vdev.c +0 -6
index ea83c41..5a74da8 100644
@@ -60,9 +60,6 @@ rte_eal_vdev_init(const char *name, const char *args)
 		return -EINVAL;
 
 	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
-		if (driver->driver.type != PMD_VDEV)
-			continue;
-
 		/*
 		 * search a driver prefix in virtual device name.
 		 * For example, if the driver is pcap PMD, driver->name
@@ -86,9 +83,6 @@ rte_eal_vdev_uninit(const char *name)
 		return -EINVAL;
 
 	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
-		if (driver->driver.type != PMD_VDEV)
-			continue;
-
 		/*
 		 * search a driver prefix in virtual device name.
 		 * For example, if the driver is pcap PMD, driver->name
Signature · 1 line
2.9.0
#5 lore raw

PATCH 3/15 eal: do not call init for PMD_PDEV drivers

In reply to Jan Viktorin

There is no way how to call an init on a PMD_PDEV driver as those drivers are all PCI drivers and they do not register any rte_driver with EAL. We can drop the loop over PMD_PDEV drivers entirely.

---
 lib/librte_eal/common/eal_common_dev.c | 8 --------
 1 file changed, 8 deletions(-)
lib/librte_eal/common/eal_common_dev.c +0 -8
index f9b3d1d..f4c880c 100644
@@ -67,7 +67,6 @@ int
 rte_eal_dev_init(void)
 {
 	struct rte_devargs *devargs;
-	struct rte_driver *driver;
 
 	/*
 	 * Note that the dev_driver_list is populated here
@@ -89,13 +88,6 @@ rte_eal_dev_init(void)
 		}
 	}
 
-	/* Once the vdevs are initalized, start calling all the pdev drivers */
-	TAILQ_FOREACH(driver, &dev_driver_list, next) {
-		if (driver->type != PMD_PDEV)
-			continue;
-		/* PDEV drivers don't get passed any parameters */
-		driver->init(NULL, NULL);
-	}
 	return 0;
 }
 
Signature · 1 line
2.9.0
#6 lore raw

PATCH 4/15 drivers: convert PMD_VDEV drivers to use rte_vdev_driver

In reply to Jan Viktorin

All PMD_VDEV drivers can now use rte_vdev_driver instead of the rte_driver (which is embedded in the rte_vdev_driver).

---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 16 +++++++++-------
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 16 +++++++++-------
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 16 +++++++++-------
 drivers/crypto/null/null_crypto_pmd.c      | 16 +++++++++-------
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 16 +++++++++-------
 drivers/net/af_packet/rte_eth_af_packet.c  | 16 +++++++++-------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 16 +++++++++-------
 drivers/net/mpipe/mpipe_tilegx.c           | 26 +++++++++++++++-----------
 drivers/net/null/rte_eth_null.c            | 16 +++++++++-------
 drivers/net/pcap/rte_eth_pcap.c            | 16 +++++++++-------
 drivers/net/ring/rte_eth_ring.c            | 16 +++++++++-------
 drivers/net/vhost/rte_eth_vhost.c          | 16 +++++++++-------
 drivers/net/xenvirt/rte_eth_xenvirt.c      | 16 +++++++++-------
 13 files changed, 123 insertions(+), 95 deletions(-)
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +9 -7
index 2987ef6..e6720e8 100644
@@ -37,7 +37,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -514,11 +514,13 @@ aesni_gcm_uninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver aesni_gcm_pmd_drv = {
-	.name = CRYPTODEV_NAME_AESNI_GCM_PMD,
-	.type = PMD_VDEV,
-	.init = aesni_gcm_init,
-	.uninit = aesni_gcm_uninit
+static struct rte_vdev_driver aesni_gcm_pmd_drv = {
+	.driver = {
+		.name = CRYPTODEV_NAME_AESNI_GCM_PMD,
+		.type = PMD_VDEV,
+		.init = aesni_gcm_init,
+		.uninit = aesni_gcm_uninit
+	},
 };
 
-PMD_REGISTER_DRIVER(aesni_gcm_pmd_drv);
+RTE_EAL_VDRV_REGISTER(aesni_gcm_pmd_drv);
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +9 -7
index 6554fc4..6c6420b 100644
@@ -34,7 +34,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -714,11 +714,13 @@ cryptodev_aesni_mb_uninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver cryptodev_aesni_mb_pmd_drv = {
-	.name = CRYPTODEV_NAME_AESNI_MB_PMD,
-	.type = PMD_VDEV,
-	.init = cryptodev_aesni_mb_init,
-	.uninit = cryptodev_aesni_mb_uninit
+static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
+	.driver = {
+		.name = CRYPTODEV_NAME_AESNI_MB_PMD,
+		.type = PMD_VDEV,
+		.init = cryptodev_aesni_mb_init,
+		.uninit = cryptodev_aesni_mb_uninit
+	},
 };
 
-PMD_REGISTER_DRIVER(cryptodev_aesni_mb_pmd_drv);
+RTE_EAL_VDRV_REGISTER(cryptodev_aesni_mb_pmd_drv);
drivers/crypto/kasumi/rte_kasumi_pmd.c +9 -7
index 0bf415d..91181c4 100644
@@ -35,7 +35,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 #include <rte_kvargs.h>
@@ -648,11 +648,13 @@ cryptodev_kasumi_uninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver cryptodev_kasumi_pmd_drv = {
-	.name = CRYPTODEV_NAME_KASUMI_PMD,
-	.type = PMD_VDEV,
-	.init = cryptodev_kasumi_init,
-	.uninit = cryptodev_kasumi_uninit
+static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
+	.driver = {
+		.name = CRYPTODEV_NAME_KASUMI_PMD,
+		.type = PMD_VDEV,
+		.init = cryptodev_kasumi_init,
+		.uninit = cryptodev_kasumi_uninit
+	},
 };
 
-PMD_REGISTER_DRIVER(cryptodev_kasumi_pmd_drv);
+RTE_EAL_VDRV_REGISTER(cryptodev_kasumi_pmd_drv);
drivers/crypto/null/null_crypto_pmd.c +9 -7
index bdaf13c..a015ee5 100644
@@ -33,7 +33,7 @@
 #include <rte_common.h>
 #include <rte_config.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 
 #include "null_crypto_pmd_private.h"
@@ -268,11 +268,13 @@ cryptodev_null_uninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver cryptodev_null_pmd_drv = {
-	.name = CRYPTODEV_NAME_NULL_PMD,
-	.type = PMD_VDEV,
-	.init = cryptodev_null_init,
-	.uninit = cryptodev_null_uninit
+static struct rte_vdev_driver cryptodev_null_pmd_drv = {
+	.driver = {
+		.name = CRYPTODEV_NAME_NULL_PMD,
+		.type = PMD_VDEV,
+		.init = cryptodev_null_init,
+		.uninit = cryptodev_null_uninit
+	},
 };
 
-PMD_REGISTER_DRIVER(cryptodev_null_pmd_drv);
+RTE_EAL_VDRV_REGISTER(cryptodev_null_pmd_drv);
drivers/crypto/snow3g/rte_snow3g_pmd.c +9 -7
index 6d59de7..060e819 100644
@@ -35,7 +35,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 #include <rte_kvargs.h>
@@ -639,11 +639,13 @@ cryptodev_snow3g_uninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver cryptodev_snow3g_pmd_drv = {
-	.name = CRYPTODEV_NAME_SNOW3G_PMD,
-	.type = PMD_VDEV,
-	.init = cryptodev_snow3g_init,
-	.uninit = cryptodev_snow3g_uninit
+static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
+	.driver = {
+		.name = CRYPTODEV_NAME_SNOW3G_PMD,
+		.type = PMD_VDEV,
+		.init = cryptodev_snow3g_init,
+		.uninit = cryptodev_snow3g_uninit
+	},
 };
 
-PMD_REGISTER_DRIVER(cryptodev_snow3g_pmd_drv);
+RTE_EAL_VDRV_REGISTER(cryptodev_snow3g_pmd_drv);
drivers/net/af_packet/rte_eth_af_packet.c +9 -7
index 36ac102..a42e1b4 100644
@@ -40,7 +40,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
@@ -871,11 +871,13 @@ rte_pmd_af_packet_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_af_packet_drv = {
-	.name = "eth_af_packet",
-	.type = PMD_VDEV,
-	.init = rte_pmd_af_packet_devinit,
-	.uninit = rte_pmd_af_packet_devuninit,
+static struct rte_vdev_driver pmd_af_packet_drv = {
+	.driver = {
+		.name = "eth_af_packet",
+		.type = PMD_VDEV,
+		.init = rte_pmd_af_packet_devinit,
+		.uninit = rte_pmd_af_packet_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_af_packet_drv);
+RTE_EAL_VDRV_REGISTER(pmd_af_packet_drv);
drivers/net/bonding/rte_eth_bond_pmd.c +9 -7
index 129f04b..01e94b8 100644
@@ -42,7 +42,7 @@
 #include <rte_ip_frag.h>
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_alarm.h>
 #include <rte_cycles.h>
 
@@ -2504,11 +2504,13 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static struct rte_driver bond_drv = {
-	.name = "eth_bond",
-	.type = PMD_VDEV,
-	.init = bond_init,
-	.uninit = bond_uninit,
+static struct rte_vdev_driver bond_drv = {
+	.driver = {
+		.name = "eth_bond",
+		.type = PMD_VDEV,
+		.init = bond_init,
+		.uninit = bond_uninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(bond_drv);
+RTE_EAL_VDRV_REGISTER(bond_drv);
drivers/net/mpipe/mpipe_tilegx.c +15 -11
index 9de556e..fd8c7a4 100644
@@ -33,7 +33,7 @@
 #include <unistd.h>
 
 #include <rte_eal.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
@@ -1623,20 +1623,24 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	return 0;
 }
 
-static struct rte_driver pmd_mpipe_xgbe_drv = {
-	.name = "xgbe",
-	.type = PMD_VDEV,
-	.init = rte_pmd_mpipe_devinit,
+static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
+	.driver = {
+		.name = "xgbe",
+		.type = PMD_VDEV,
+		.init = rte_pmd_mpipe_devinit,
+	},
 };
 
-static struct rte_driver pmd_mpipe_gbe_drv = {
-	.name = "gbe",
-	.type = PMD_VDEV,
-	.init = rte_pmd_mpipe_devinit,
+static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
+	.driver = {
+		.name = "gbe",
+		.type = PMD_VDEV,
+		.init = rte_pmd_mpipe_devinit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_mpipe_xgbe_drv);
-PMD_REGISTER_DRIVER(pmd_mpipe_gbe_drv);
+RTE_EAL_VDRV_REGISTER(pmd_mpipe_xgbe_drv);
+RTE_EAL_VDRV_REGISTER(pmd_mpipe_gbe_drv);
 
 static void __attribute__((constructor, used))
 mpipe_init_contexts(void)
drivers/net/null/rte_eth_null.c +9 -7
index e6c74a6..56370c9 100644
@@ -35,7 +35,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
 
@@ -682,11 +682,13 @@ rte_pmd_null_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_null_drv = {
-	.name = "eth_null",
-	.type = PMD_VDEV,
-	.init = rte_pmd_null_devinit,
-	.uninit = rte_pmd_null_devuninit,
+static struct rte_vdev_driver pmd_null_drv = {
+	.driver = {
+		.name = "eth_null",
+		.type = PMD_VDEV,
+		.init = rte_pmd_null_devinit,
+		.uninit = rte_pmd_null_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_null_drv);
+RTE_EAL_VDRV_REGISTER(pmd_null_drv);
drivers/net/pcap/rte_eth_pcap.c +9 -7
index 2d00d04..d59d9bb 100644
@@ -40,7 +40,7 @@
 #include <rte_string_fns.h>
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 
 #include <net/if.h>
 
@@ -1083,11 +1083,13 @@ rte_pmd_pcap_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_pcap_drv = {
-	.name = "eth_pcap",
-	.type = PMD_VDEV,
-	.init = rte_pmd_pcap_devinit,
-	.uninit = rte_pmd_pcap_devuninit,
+static struct rte_vdev_driver pmd_pcap_drv = {
+	.driver = {
+		.name = "eth_pcap",
+		.type = PMD_VDEV,
+		.init = rte_pmd_pcap_devinit,
+		.uninit = rte_pmd_pcap_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_pcap_drv);
+RTE_EAL_VDRV_REGISTER(pmd_pcap_drv);
drivers/net/ring/rte_eth_ring.c +9 -7
index b78d1cf..ff15cfd 100644
@@ -38,7 +38,7 @@
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
 #include <rte_string_fns.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_errno.h>
 
@@ -623,11 +623,13 @@ rte_pmd_ring_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_ring_drv = {
-	.name = "eth_ring",
-	.type = PMD_VDEV,
-	.init = rte_pmd_ring_devinit,
-	.uninit = rte_pmd_ring_devuninit,
+static struct rte_vdev_driver pmd_ring_drv = {
+	.driver = {
+		.name = "eth_ring",
+		.type = PMD_VDEV,
+		.init = rte_pmd_ring_devinit,
+		.uninit = rte_pmd_ring_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_ring_drv);
+RTE_EAL_VDRV_REGISTER(pmd_ring_drv);
drivers/net/vhost/rte_eth_vhost.c +9 -7
index 4e99360..f10944b 100644
@@ -41,7 +41,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_virtio_net.h>
 #include <rte_spinlock.h>
@@ -917,11 +917,13 @@ rte_pmd_vhost_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_vhost_drv = {
-	.name = "eth_vhost",
-	.type = PMD_VDEV,
-	.init = rte_pmd_vhost_devinit,
-	.uninit = rte_pmd_vhost_devuninit,
+static struct rte_vdev_driver pmd_vhost_drv = {
+	.driver = {
+		.name = "eth_vhost",
+		.type = PMD_VDEV,
+		.init = rte_pmd_vhost_devinit,
+		.uninit = rte_pmd_vhost_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_vhost_drv);
+RTE_EAL_VDRV_REGISTER(pmd_vhost_drv);
drivers/net/xenvirt/rte_eth_xenvirt.c +9 -7
index 72861d8..1e1a876 100644
@@ -53,7 +53,7 @@
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <cmdline_parse.h>
 #include <cmdline_parse_etheraddr.h>
 
@@ -756,11 +756,13 @@ rte_pmd_xenvirt_devuninit(const char *name)
 	return 0;
 }
 
-static struct rte_driver pmd_xenvirt_drv = {
-	.name = "eth_xenvirt",
-	.type = PMD_VDEV,
-	.init = rte_pmd_xenvirt_devinit,
-	.uninit = rte_pmd_xenvirt_devuninit,
+static struct rte_vdev_driver pmd_xenvirt_drv = {
+	.driver = {
+		.name = "eth_xenvirt",
+		.type = PMD_VDEV,
+		.init = rte_pmd_xenvirt_devinit,
+		.uninit = rte_pmd_xenvirt_devuninit,
+	},
 };
 
-PMD_REGISTER_DRIVER(pmd_xenvirt_drv);
+RTE_EAL_VDRV_REGISTER(pmd_xenvirt_drv);
Signature · 1 line
2.9.0
#7 lore raw

PATCH 5/15 eal: move init/uninit to rte_vdev_driver

In reply to Jan Viktorin

These functions are virtual-device specific and they are never called for any PCI driver (after introducing RTE_EAL_PCI_REGISTER, there is no way to do it). All affected drivers are updated.

The prototypes are renamed to rte_vdev_init_t and rte_vdev_uninit_t.

---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   |  4 ++--
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  4 ++--
 drivers/crypto/kasumi/rte_kasumi_pmd.c     |  4 ++--
 drivers/crypto/null/null_crypto_pmd.c      |  4 ++--
 drivers/crypto/snow3g/rte_snow3g_pmd.c     |  4 ++--
 drivers/net/af_packet/rte_eth_af_packet.c  |  4 ++--
 drivers/net/bonding/rte_eth_bond_pmd.c     |  4 ++--
 drivers/net/mpipe/mpipe_tilegx.c           |  4 ++--
 drivers/net/null/rte_eth_null.c            |  4 ++--
 drivers/net/pcap/rte_eth_pcap.c            |  4 ++--
 drivers/net/ring/rte_eth_ring.c            |  4 ++--
 drivers/net/vhost/rte_eth_vhost.c          |  4 ++--
 drivers/net/xenvirt/rte_eth_xenvirt.c      |  4 ++--
 lib/librte_eal/common/eal_common_vdev.c    |  4 ++--
 lib/librte_eal/common/include/rte_dev.h    | 12 ------------
 lib/librte_eal/common/include/rte_vdev.h   | 15 ++++++++++++++-
 16 files changed, 42 insertions(+), 41 deletions(-)
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +2 -2
index e6720e8..6e45293 100644
@@ -518,9 +518,9 @@ static struct rte_vdev_driver aesni_gcm_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_AESNI_GCM_PMD,
 		.type = PMD_VDEV,
-		.init = aesni_gcm_init,
-		.uninit = aesni_gcm_uninit
 	},
+	.init = aesni_gcm_init,
+	.uninit = aesni_gcm_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(aesni_gcm_pmd_drv);
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +2 -2
index 6c6420b..e7cdcfd 100644
@@ -718,9 +718,9 @@ static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_AESNI_MB_PMD,
 		.type = PMD_VDEV,
-		.init = cryptodev_aesni_mb_init,
-		.uninit = cryptodev_aesni_mb_uninit
 	},
+	.init = cryptodev_aesni_mb_init,
+	.uninit = cryptodev_aesni_mb_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(cryptodev_aesni_mb_pmd_drv);
drivers/crypto/kasumi/rte_kasumi_pmd.c +2 -2
index 91181c4..792184a 100644
@@ -652,9 +652,9 @@ static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_KASUMI_PMD,
 		.type = PMD_VDEV,
-		.init = cryptodev_kasumi_init,
-		.uninit = cryptodev_kasumi_uninit
 	},
+	.init = cryptodev_kasumi_init,
+	.uninit = cryptodev_kasumi_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(cryptodev_kasumi_pmd_drv);
drivers/crypto/null/null_crypto_pmd.c +2 -2
index a015ee5..5250e3f 100644
@@ -272,9 +272,9 @@ static struct rte_vdev_driver cryptodev_null_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_NULL_PMD,
 		.type = PMD_VDEV,
-		.init = cryptodev_null_init,
-		.uninit = cryptodev_null_uninit
 	},
+	.init = cryptodev_null_init,
+	.uninit = cryptodev_null_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(cryptodev_null_pmd_drv);
drivers/crypto/snow3g/rte_snow3g_pmd.c +2 -2
index 060e819..6dc9a2e 100644
@@ -643,9 +643,9 @@ static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_SNOW3G_PMD,
 		.type = PMD_VDEV,
-		.init = cryptodev_snow3g_init,
-		.uninit = cryptodev_snow3g_uninit
 	},
+	.init = cryptodev_snow3g_init,
+	.uninit = cryptodev_snow3g_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(cryptodev_snow3g_pmd_drv);
drivers/net/af_packet/rte_eth_af_packet.c +2 -2
index a42e1b4..66aaf99 100644
@@ -875,9 +875,9 @@ static struct rte_vdev_driver pmd_af_packet_drv = {
 	.driver = {
 		.name = "eth_af_packet",
 		.type = PMD_VDEV,
-		.init = rte_pmd_af_packet_devinit,
-		.uninit = rte_pmd_af_packet_devuninit,
 	},
+	.init = rte_pmd_af_packet_devinit,
+	.uninit = rte_pmd_af_packet_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_af_packet_drv);
drivers/net/bonding/rte_eth_bond_pmd.c +2 -2
index 01e94b8..801a481 100644
@@ -2508,9 +2508,9 @@ static struct rte_vdev_driver bond_drv = {
 	.driver = {
 		.name = "eth_bond",
 		.type = PMD_VDEV,
-		.init = bond_init,
-		.uninit = bond_uninit,
 	},
+	.init = bond_init,
+	.uninit = bond_uninit,
 };
 
 RTE_EAL_VDRV_REGISTER(bond_drv);
drivers/net/mpipe/mpipe_tilegx.c +2 -2
index fd8c7a4..fe7c0c6 100644
@@ -1627,16 +1627,16 @@ static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
 	.driver = {
 		.name = "xgbe",
 		.type = PMD_VDEV,
-		.init = rte_pmd_mpipe_devinit,
 	},
+	.init = rte_pmd_mpipe_devinit,
 };
 
 static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
 	.driver = {
 		.name = "gbe",
 		.type = PMD_VDEV,
-		.init = rte_pmd_mpipe_devinit,
 	},
+	.init = rte_pmd_mpipe_devinit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_mpipe_xgbe_drv);
drivers/net/null/rte_eth_null.c +2 -2
index 56370c9..85c4526 100644
@@ -686,9 +686,9 @@ static struct rte_vdev_driver pmd_null_drv = {
 	.driver = {
 		.name = "eth_null",
 		.type = PMD_VDEV,
-		.init = rte_pmd_null_devinit,
-		.uninit = rte_pmd_null_devuninit,
 	},
+	.init = rte_pmd_null_devinit,
+	.uninit = rte_pmd_null_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_null_drv);
drivers/net/pcap/rte_eth_pcap.c +2 -2
index d59d9bb..934b77f 100644
@@ -1087,9 +1087,9 @@ static struct rte_vdev_driver pmd_pcap_drv = {
 	.driver = {
 		.name = "eth_pcap",
 		.type = PMD_VDEV,
-		.init = rte_pmd_pcap_devinit,
-		.uninit = rte_pmd_pcap_devuninit,
 	},
+	.init = rte_pmd_pcap_devinit,
+	.uninit = rte_pmd_pcap_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_pcap_drv);
drivers/net/ring/rte_eth_ring.c +2 -2
index ff15cfd..95245be 100644
@@ -627,9 +627,9 @@ static struct rte_vdev_driver pmd_ring_drv = {
 	.driver = {
 		.name = "eth_ring",
 		.type = PMD_VDEV,
-		.init = rte_pmd_ring_devinit,
-		.uninit = rte_pmd_ring_devuninit,
 	},
+	.init = rte_pmd_ring_devinit,
+	.uninit = rte_pmd_ring_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_ring_drv);
drivers/net/vhost/rte_eth_vhost.c +2 -2
index f10944b..1c8b33d 100644
@@ -921,9 +921,9 @@ static struct rte_vdev_driver pmd_vhost_drv = {
 	.driver = {
 		.name = "eth_vhost",
 		.type = PMD_VDEV,
-		.init = rte_pmd_vhost_devinit,
-		.uninit = rte_pmd_vhost_devuninit,
 	},
+	.init = rte_pmd_vhost_devinit,
+	.uninit = rte_pmd_vhost_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_vhost_drv);
drivers/net/xenvirt/rte_eth_xenvirt.c +2 -2
index 1e1a876..b97246b 100644
@@ -760,9 +760,9 @@ static struct rte_vdev_driver pmd_xenvirt_drv = {
 	.driver = {
 		.name = "eth_xenvirt",
 		.type = PMD_VDEV,
-		.init = rte_pmd_xenvirt_devinit,
-		.uninit = rte_pmd_xenvirt_devuninit,
 	},
+	.init = rte_pmd_xenvirt_devinit,
+	.uninit = rte_pmd_xenvirt_devuninit,
 };
 
 RTE_EAL_VDRV_REGISTER(pmd_xenvirt_drv);
lib/librte_eal/common/eal_common_vdev.c +2 -2
index 5a74da8..7e7ddd1 100644
@@ -67,7 +67,7 @@ rte_eal_vdev_init(const char *name, const char *args)
 		 * So use strncmp to compare.
 		 */
 		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
-			return driver->driver.init(name, args);
+			return driver->init(name, args);
 	}
 
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
@@ -90,7 +90,7 @@ rte_eal_vdev_uninit(const char *name)
 		 * So use strncmp to compare.
 		 */
 		if (!strncmp(driver->driver.name, name, strlen(driver->driver.name)))
-			return driver->driver.uninit(name);
+			return driver->uninit(name);
 	}
 
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
lib/librte_eal/common/include/rte_dev.h +0 -12
index 2aeb752..63fc454 100644
@@ -105,16 +105,6 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 TAILQ_HEAD(rte_driver_list, rte_driver);
 
 /**
- * Initialization function called for each device driver once.
- */
-typedef int (rte_dev_init_t)(const char *name, const char *args);
-
-/**
- * Uninitilization function called for each device driver once.
- */
-typedef int (rte_dev_uninit_t)(const char *name);
-
-/**
  * Driver type enumeration
  */
 enum pmd_type {
@@ -129,8 +119,6 @@ struct rte_driver {
 	TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
 	enum pmd_type type;		   /**< PMD Driver type */
 	const char *name;                   /**< Driver name. */
-	rte_dev_init_t *init;              /**< Device init. function. */
-	rte_dev_uninit_t *uninit;          /**< Device uninit. function. */
 };
 
 /**
lib/librte_eal/common/include/rte_vdev.h +14 -1
index 523bd92..709aa2e 100644
@@ -43,12 +43,25 @@ extern "C" {
 /** Double linked list of virtual device drivers. */
 TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
 
+
+/**
+ * Initialization function called for each device driver once.
+ */
+typedef int (rte_vdev_init_t)(const char *name, const char *args);
+
+/**
+ * Uninitilization function called for each device driver once.
+ */
+typedef int (rte_vdev_uninit_t)(const char *name);
+
 /**
  * A virtual device driver abstraction.
  */
 struct rte_vdev_driver {
 	TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
-	struct rte_driver driver;          /**< Inherited general driver. */
+	struct rte_driver driver;      /**< Inherited general driver. */
+	rte_vdev_init_t *init;         /**< Virtual device init. function. */
+	rte_vdev_uninit_t *uninit;     /**< Virtual device uninit. function. */
 };
 
 /**
Signature · 1 line
2.9.0
#8 lore raw

PATCH 6/15 eal: remove PMD_REGISTER_DRIVER

In reply to Jan Viktorin

All devices register themselfs by calling a kind of RTE_EAL_*_REGISTER. The PMD_REGISTER_DRIVER is not used anymore.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ------------
 1 file changed, 12 deletions(-)
lib/librte_eal/common/include/rte_dev.h +0 -12
index 63fc454..2fa85f7 100644
@@ -191,16 +191,4 @@ int rte_eal_dev_attach(const char *name, const char *devargs);
  */
 int rte_eal_dev_detach(const char *name);
 
-#define PMD_REGISTER_DRIVER(d)\
-RTE_INIT(devinitfn_ ##d);\
-static void devinitfn_ ##d(void)\
-{\
-	rte_eal_driver_register(&d);\
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* _RTE_VDEV_H_ */
Signature · 1 line
2.9.0
#9 lore raw

PATCH 7/15 eal: get rid of pmd_type

In reply to Jan Viktorin

There is no need to determine a PMD type any more. The PMD_VDEV devices has its own list of drivers. And all PMD_PDEV are PCI devices using a different way of registering themselfs.

---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 1 -
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 1 -
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 1 -
 drivers/crypto/null/null_crypto_pmd.c      | 1 -
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 1 -
 drivers/net/af_packet/rte_eth_af_packet.c  | 1 -
 drivers/net/bonding/rte_eth_bond_pmd.c     | 1 -
 drivers/net/mpipe/mpipe_tilegx.c           | 2 --
 drivers/net/null/rte_eth_null.c            | 1 -
 drivers/net/pcap/rte_eth_pcap.c            | 1 -
 drivers/net/ring/rte_eth_ring.c            | 1 -
 drivers/net/vhost/rte_eth_vhost.c          | 1 -
 drivers/net/xenvirt/rte_eth_xenvirt.c      | 1 -
 lib/librte_eal/common/include/rte_dev.h    | 9 ---------
 14 files changed, 23 deletions(-)
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +0 -1
index 6e45293..dfa1001 100644
@@ -517,7 +517,6 @@ aesni_gcm_uninit(const char *name)
 static struct rte_vdev_driver aesni_gcm_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_AESNI_GCM_PMD,
-		.type = PMD_VDEV,
 	},
 	.init = aesni_gcm_init,
 	.uninit = aesni_gcm_uninit,
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +0 -1
index e7cdcfd..3265f83 100644
@@ -717,7 +717,6 @@ cryptodev_aesni_mb_uninit(const char *name)
 static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_AESNI_MB_PMD,
-		.type = PMD_VDEV,
 	},
 	.init = cryptodev_aesni_mb_init,
 	.uninit = cryptodev_aesni_mb_uninit,
drivers/crypto/kasumi/rte_kasumi_pmd.c +0 -1
index 792184a..c39b0a1 100644
@@ -651,7 +651,6 @@ cryptodev_kasumi_uninit(const char *name)
 static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_KASUMI_PMD,
-		.type = PMD_VDEV,
 	},
 	.init = cryptodev_kasumi_init,
 	.uninit = cryptodev_kasumi_uninit,
drivers/crypto/null/null_crypto_pmd.c +0 -1
index 5250e3f..5ad8b86 100644
@@ -271,7 +271,6 @@ cryptodev_null_uninit(const char *name)
 static struct rte_vdev_driver cryptodev_null_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_NULL_PMD,
-		.type = PMD_VDEV,
 	},
 	.init = cryptodev_null_init,
 	.uninit = cryptodev_null_uninit,
drivers/crypto/snow3g/rte_snow3g_pmd.c +0 -1
index 6dc9a2e..9fc5c64 100644
@@ -642,7 +642,6 @@ cryptodev_snow3g_uninit(const char *name)
 static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
 	.driver = {
 		.name = CRYPTODEV_NAME_SNOW3G_PMD,
-		.type = PMD_VDEV,
 	},
 	.init = cryptodev_snow3g_init,
 	.uninit = cryptodev_snow3g_uninit,
drivers/net/af_packet/rte_eth_af_packet.c +0 -1
index 66aaf99..9d0c6d3 100644
@@ -874,7 +874,6 @@ rte_pmd_af_packet_devuninit(const char *name)
 static struct rte_vdev_driver pmd_af_packet_drv = {
 	.driver = {
 		.name = "eth_af_packet",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_af_packet_devinit,
 	.uninit = rte_pmd_af_packet_devuninit,
drivers/net/bonding/rte_eth_bond_pmd.c +0 -1
index 801a481..a3846e6 100644
@@ -2507,7 +2507,6 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 static struct rte_vdev_driver bond_drv = {
 	.driver = {
 		.name = "eth_bond",
-		.type = PMD_VDEV,
 	},
 	.init = bond_init,
 	.uninit = bond_uninit,
drivers/net/mpipe/mpipe_tilegx.c +0 -2
index fe7c0c6..9d5cc6d 100644
@@ -1626,7 +1626,6 @@ rte_pmd_mpipe_devinit(const char *ifname,
 static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
 	.driver = {
 		.name = "xgbe",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_mpipe_devinit,
 };
@@ -1634,7 +1633,6 @@ static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
 static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
 	.driver = {
 		.name = "gbe",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_mpipe_devinit,
 };
drivers/net/null/rte_eth_null.c +0 -1
index 85c4526..39eb5d0 100644
@@ -685,7 +685,6 @@ rte_pmd_null_devuninit(const char *name)
 static struct rte_vdev_driver pmd_null_drv = {
 	.driver = {
 		.name = "eth_null",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_null_devinit,
 	.uninit = rte_pmd_null_devuninit,
drivers/net/pcap/rte_eth_pcap.c +0 -1
index 934b77f..be5a21a 100644
@@ -1086,7 +1086,6 @@ rte_pmd_pcap_devuninit(const char *name)
 static struct rte_vdev_driver pmd_pcap_drv = {
 	.driver = {
 		.name = "eth_pcap",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_pcap_devinit,
 	.uninit = rte_pmd_pcap_devuninit,
drivers/net/ring/rte_eth_ring.c +0 -1
index 95245be..cdb2efd 100644
@@ -626,7 +626,6 @@ rte_pmd_ring_devuninit(const char *name)
 static struct rte_vdev_driver pmd_ring_drv = {
 	.driver = {
 		.name = "eth_ring",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_ring_devinit,
 	.uninit = rte_pmd_ring_devuninit,
drivers/net/vhost/rte_eth_vhost.c +0 -1
index 1c8b33d..9a1c4ac 100644
@@ -920,7 +920,6 @@ rte_pmd_vhost_devuninit(const char *name)
 static struct rte_vdev_driver pmd_vhost_drv = {
 	.driver = {
 		.name = "eth_vhost",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_vhost_devinit,
 	.uninit = rte_pmd_vhost_devuninit,
drivers/net/xenvirt/rte_eth_xenvirt.c +0 -1
index b97246b..38d7a68 100644
@@ -759,7 +759,6 @@ rte_pmd_xenvirt_devuninit(const char *name)
 static struct rte_vdev_driver pmd_xenvirt_drv = {
 	.driver = {
 		.name = "eth_xenvirt",
-		.type = PMD_VDEV,
 	},
 	.init = rte_pmd_xenvirt_devinit,
 	.uninit = rte_pmd_xenvirt_devuninit,
lib/librte_eal/common/include/rte_dev.h +0 -9
index 2fa85f7..225257e 100644
@@ -105,19 +105,10 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 TAILQ_HEAD(rte_driver_list, rte_driver);
 
 /**
- * Driver type enumeration
- */
-enum pmd_type {
-	PMD_VDEV = 0,
-	PMD_PDEV = 1,
-};
-
-/**
  * A structure describing a device driver.
  */
 struct rte_driver {
 	TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
-	enum pmd_type type;		   /**< PMD Driver type */
 	const char *name;                   /**< Driver name. */
 };
 
Signature · 1 line
2.9.0
#10 lore raw

PATCH 8/15 eal: define macro container_of

In reply to Jan Viktorin
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +16 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
Signature · 1 line
2.9.0
#11 lore raw

PATCH 9/15 eal: rte_pci.h includes rte_dev.h

In reply to Jan Viktorin

Further refactoring and generalization of PCI infrastructure will require access to the rte_dev.h contents.

---
 lib/librte_eal/common/include/rte_pci.h | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/common/include/rte_pci.h +1 -0
index eed6b56..ec77cbc 100644
@@ -84,6 +84,7 @@ extern "C" {
 
 #include <rte_debug.h>
 #include <rte_interrupts.h>
+#include <rte_dev.h>
 
 TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */
 TAILQ_HEAD(pci_driver_list, rte_pci_driver); /**< PCI drivers in D-linked Q. */
Signature · 1 line
2.9.0
#12 lore raw

PATCH 10/15 eal: rename and move rte_pci_resource

In reply to Jan Viktorin

There is no need to have a custom memory resource representation for each infrastructure (PCI, ...) as it would always have the same members.

---
 drivers/net/szedata2/rte_eth_szedata2.c   |  4 ++--
 lib/librte_eal/common/include/rte_dev.h   |  9 +++++++++
 lib/librte_eal/common/include/rte_pci.h   | 11 +----------
 lib/librte_eal/linuxapp/eal/eal_ivshmem.c |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/szedata2/rte_eth_szedata2.c +2 -2
index 6815dbb..d925bc6 100644
@@ -1416,7 +1416,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 	int ret;
 	uint32_t szedata2_index;
 	struct rte_pci_addr *pci_addr = &dev->pci_dev->addr;
-	struct rte_pci_resource *pci_rsc =
+	struct rte_mem_resource *pci_rsc =
 		&dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER];
 	char rsc_filename[PATH_MAX];
 	void *pci_resource_ptr = NULL;
@@ -1473,7 +1473,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 
 	rte_eth_copy_pci_info(dev, dev->pci_dev);
 
-	/* mmap pci resource0 file to rte_pci_resource structure */
+	/* mmap pci resource0 file to rte_mem_resource structure */
 	if (dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].phys_addr ==
 			0) {
 		RTE_LOG(ERR, PMD, "Missing resource%u file\n",
lib/librte_eal/common/include/rte_dev.h +9 -0
index 225257e..2a0d326 100644
@@ -100,6 +100,15 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 	} \
 } while (0)
 
+/**
+ * A generic memory resource representation.
+ */
+struct rte_mem_resource {
+	uint64_t phys_addr; /**< Physical address, 0 if not resource. */
+	uint64_t len;       /**< Length of the resource. */
+	void *addr;         /**< Virtual address, NULL when not mapped. */
+};
+
 
 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
lib/librte_eal/common/include/rte_pci.h +1 -10
index ec77cbc..950ea89 100644
@@ -111,15 +111,6 @@ const char *pci_get_sysfs_path(void);
 /** Default sysfs path for PCI device search. */
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
-/**
- * A structure describing a PCI resource.
- */
-struct rte_pci_resource {
-	uint64_t phys_addr;   /**< Physical address, 0 if no resource. */
-	uint64_t len;         /**< Length of the resource. */
-	void *addr;           /**< Virtual address, NULL when not mapped. */
-};
-
 /** Maximum number of PCI resources. */
 #define PCI_MAX_RESOURCE 6
 
@@ -163,7 +154,7 @@ struct rte_pci_device {
 	TAILQ_ENTRY(rte_pci_device) next;       /**< Next probed PCI device. */
 	struct rte_pci_addr addr;               /**< PCI location. */
 	struct rte_pci_id id;                   /**< PCI ID. */
-	struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI Memory Resource */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI Memory Resource */
 	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
 	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
lib/librte_eal/linuxapp/eal/eal_ivshmem.c +1 -1
index 67b3caf..20f9413 100644
@@ -834,7 +834,7 @@ rte_eal_ivshmem_obj_init(void)
 int rte_eal_ivshmem_init(void)
 {
 	struct rte_pci_device * dev;
-	struct rte_pci_resource * res;
+	struct rte_mem_resource * res;
 	int fd, ret;
 	char path[PATH_MAX];
 
Signature · 1 line
2.9.0
#13 lore raw

PATCH 11/15 eal/pci: inherit rte_driver by rte_pci_driver

In reply to Jan Viktorin
---
 app/test/test_pci.c                     | 10 +++++++---
 app/test/virtual_pmd.c                  |  2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c  |  4 +++-
 drivers/net/bnx2x/bnx2x_ethdev.c        |  8 ++++++--
 drivers/net/cxgbe/cxgbe_ethdev.c        |  4 +++-
 drivers/net/cxgbe/sge.c                 |  6 +++---
 drivers/net/e1000/em_ethdev.c           |  4 +++-
 drivers/net/e1000/igb_ethdev.c          |  8 ++++++--
 drivers/net/ena/ena_ethdev.c            |  4 +++-
 drivers/net/enic/enic_ethdev.c          |  4 +++-
 drivers/net/fm10k/fm10k_ethdev.c        |  4 +++-
 drivers/net/i40e/i40e_ethdev.c          |  4 +++-
 drivers/net/i40e/i40e_ethdev_vf.c       |  4 +++-
 drivers/net/i40e/i40e_fdir.c            |  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c        |  8 ++++++--
 drivers/net/mlx4/mlx4.c                 |  4 +++-
 drivers/net/mlx5/mlx5.c                 |  4 +++-
 drivers/net/nfp/nfp_net.c               |  4 +++-
 drivers/net/qede/qede_ethdev.c          |  4 ++++
 drivers/net/szedata2/rte_eth_szedata2.c |  4 +++-
 drivers/net/virtio/virtio_ethdev.c      |  6 ++++--
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  7 +++++--
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |  2 +-
 lib/librte_cryptodev/rte_cryptodev.c    |  4 ++--
 lib/librte_eal/common/eal_common_pci.c  |  4 ++--
 lib/librte_eal/common/include/rte_pci.h |  4 +++-
 lib/librte_ether/rte_ethdev.c           |  4 ++--
 27 files changed, 89 insertions(+), 38 deletions(-)
app/test/test_pci.c +7 -3
index 354a0ad..9be08f9 100644
@@ -78,14 +78,18 @@ struct rte_pci_id my_driver_id2[] = {
 };
 
 struct rte_pci_driver my_driver = {
-	.name = "test_driver",
+	.driver = {
+		.name = "test_driver",
+	},
 	.devinit = my_driver_init,
 	.id_table = my_driver_id,
 	.drv_flags = 0,
 };
 
 struct rte_pci_driver my_driver2 = {
-	.name = "test_driver2",
+	.driver = {
+		.name = "test_driver2",
+	},
 	.devinit = my_driver_init,
 	.id_table = my_driver_id2,
 	.drv_flags = 0,
@@ -95,7 +99,7 @@ static int
 my_driver_init(__attribute__((unused)) struct rte_pci_driver *dr,
 	       struct rte_pci_device *dev)
 {
-	printf("My driver init called in %s\n", dr->name);
+	printf("My driver init called in %s\n", dr->driver.name);
 	printf("%x:%x:%x.%d", dev->addr.domain, dev->addr.bus,
 	       dev->addr.devid, dev->addr.function);
 	printf(" - vendor:%x device:%x\n", dev->id.vendor_id, dev->id.device_id);
app/test/virtual_pmd.c +1 -1
index 8a1f0d0..56eeb99 100644
@@ -586,7 +586,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 		goto err;
 
 	pci_dev->numa_node = socket_id;
-	pci_drv->name = virtual_ethdev_driver_name;
+	pci_drv->driver.name = virtual_ethdev_driver_name;
 	pci_drv->id_table = id_table;
 
 	if (isr_support)
drivers/crypto/qat/rte_qat_cryptodev.c +3 -1
index 970970a..fab8bd8 100644
@@ -114,7 +114,9 @@ crypto_qat_dev_init(__attribute__((unused)) struct rte_cryptodev_driver *crypto_
 
 static struct rte_cryptodev_driver rte_qat_pmd = {
 	.pci_drv = {
-		.name = "rte_qat_pmd",
+		.driver = {
+			.name = "rte_qat_pmd",
+		},
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 		.devinit = rte_cryptodev_pci_probe,
drivers/net/bnx2x/bnx2x_ethdev.c +6 -2
index 5ab3c75..062a93f 100644
@@ -503,7 +503,9 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_bnx2x_pmd = {
 	.pci_drv = {
-		.name = "rte_bnx2x_pmd",
+		.driver = {
+			.name = "rte_bnx2x_pmd",
+		},
 		.id_table = pci_id_bnx2x_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 		.devinit = rte_eth_dev_pci_probe,
@@ -520,7 +522,9 @@ RTE_EAL_PCI_REGISTER(rte_bnx2x_pmd);
  */
 static struct eth_driver rte_bnx2xvf_pmd = {
 	.pci_drv = {
-		.name = "rte_bnx2xvf_pmd",
+		.driver = {
+			.name = "rte_bnx2xvf_pmd",
+		},
 		.id_table = pci_id_bnx2xvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/cxgbe/cxgbe_ethdev.c +3 -1
index 1389371..33934c3 100644
@@ -866,7 +866,9 @@ out_free_adapter:
 
 static struct eth_driver rte_cxgbe_pmd = {
 	.pci_drv = {
-		.name = "rte_cxgbe_pmd",
+		.driver = {
+			.name = "rte_cxgbe_pmd",
+		},
 		.id_table = cxgb4_pci_tbl,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/cxgbe/sge.c +3 -3
index ab5a842..c03c760 100644
@@ -1645,7 +1645,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->driver->pci_drv.name, fwevtq ? "fwq_ring" : "rx_ring",
+		 eth_dev->driver->pci_drv.driver.name, fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
@@ -1697,7 +1697,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->driver->pci_drv.name,
+			 eth_dev->driver->pci_drv.driver.name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1893,7 +1893,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->driver->pci_drv.name, "tx_ring",
+		 eth_dev->driver->pci_drv.driver.name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
drivers/net/e1000/em_ethdev.c +3 -1
index c67e67f..2de3075 100644
@@ -364,7 +364,9 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_em_pmd = {
 	.pci_drv = {
-		.name = "rte_em_pmd",
+		.driver = {
+			.name = "rte_em_pmd",
+		},
 		.id_table = pci_id_em_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
drivers/net/e1000/igb_ethdev.c +6 -2
index a523944..c414c03 100644
@@ -979,7 +979,9 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_igb_pmd = {
 	.pci_drv = {
-		.name = "rte_igb_pmd",
+		.driver = {
+			.name = "rte_igb_pmd",
+		},
 		.id_table = pci_id_igb_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
@@ -998,7 +1000,9 @@ RTE_EAL_PCI_REGISTER(rte_igb_pmd);
  */
 static struct eth_driver rte_igbvf_pmd = {
 	.pci_drv = {
-		.name = "rte_igbvf_pmd",
+		.driver = {
+			.name = "rte_igbvf_pmd",
+		},
 		.id_table = pci_id_igbvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/ena/ena_ethdev.c +3 -1
index dc32435..35fffc0 100644
@@ -1428,7 +1428,9 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 static struct eth_driver rte_ena_pmd = {
 	.pci_drv = {
-		.name = "rte_ena_pmd",
+		.driver = {
+			.name = "rte_ena_pmd",
+		},
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/enic/enic_ethdev.c +3 -1
index d5e395d..0eb7948 100644
@@ -657,7 +657,9 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_enic_pmd = {
 	.pci_drv = {
-		.name = "rte_enic_pmd",
+		.driver = {
+			.name = "rte_enic_pmd",
+		},
 		.id_table = pci_id_enic_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/fm10k/fm10k_ethdev.c +3 -1
index 8ec8f5e..4ffa66c 100644
@@ -3060,7 +3060,9 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
 
 static struct eth_driver rte_pmd_fm10k = {
 	.pci_drv = {
-		.name = "rte_pmd_fm10k",
+		.driver = {
+			.name = "rte_pmd_fm10k",
+		},
 		.id_table = pci_id_fm10k_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
drivers/net/i40e/i40e_ethdev.c +3 -1
index f2712ab..0eb82f8 100644
@@ -641,7 +641,9 @@ static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = {
 
 static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
-		.name = "rte_i40e_pmd",
+		.driver = {
+			.name = "rte_i40e_pmd",
+		},
 		.id_table = pci_id_i40e_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
drivers/net/i40e/i40e_ethdev_vf.c +3 -1
index 3411831..f67f9fa 100644
@@ -1552,7 +1552,9 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
  */
 static struct eth_driver rte_i40evf_pmd = {
 	.pci_drv = {
-		.name = "rte_i40evf_pmd",
+		.driver = {
+			.name = "rte_i40evf_pmd",
+		},
 		.id_table = pci_id_i40evf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/i40e/i40e_fdir.c +1 -1
index 8aa41e5..0a79dd1 100644
@@ -249,7 +249,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->driver->pci_drv.name,
+			eth_dev->driver->pci_drv.driver.name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
drivers/net/ixgbe/ixgbe_ethdev.c +6 -2
index dd521e8..82a81fa 100644
@@ -1489,7 +1489,9 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_ixgbe_pmd = {
 	.pci_drv = {
-		.name = "rte_ixgbe_pmd",
+		.driver = {
+			.name = "rte_ixgbe_pmd",
+		},
 		.id_table = pci_id_ixgbe_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
@@ -1508,7 +1510,9 @@ RTE_EAL_PCI_REGISTER(rte_ixgbe_pmd);
  */
 static struct eth_driver rte_ixgbevf_pmd = {
 	.pci_drv = {
-		.name = "rte_ixgbevf_pmd",
+		.driver = {
+			.name = "rte_ixgbevf_pmd",
+		},
 		.id_table = pci_id_ixgbevf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/mlx4/mlx4.c +3 -1
index ba42c33..310d98c 100644
@@ -5829,7 +5829,9 @@ static const struct rte_pci_id mlx4_pci_id_map[] = {
 
 static struct eth_driver mlx4_driver = {
 	.pci_drv = {
-		.name = MLX4_DRIVER_NAME,
+		.driver = {
+			.name = MLX4_DRIVER_NAME,
+		},
 		.id_table = mlx4_pci_id_map,
 		.devinit = mlx4_pci_devinit,
 		.drv_flags = RTE_PCI_DRV_INTR_LSC,
drivers/net/mlx5/mlx5.c +3 -1
index f6399fc..3f6509a 100644
@@ -638,7 +638,9 @@ static const struct rte_pci_id mlx5_pci_id_map[] = {
 
 static struct eth_driver mlx5_driver = {
 	.pci_drv = {
-		.name = MLX5_DRIVER_NAME,
+		.driver = {
+			.name = MLX5_DRIVER_NAME,
+		},
 		.id_table = mlx5_pci_id_map,
 		.devinit = mlx5_pci_devinit,
 		.drv_flags = RTE_PCI_DRV_INTR_LSC,
drivers/net/nfp/nfp_net.c +3 -1
index 951c8b4..69c2678 100644
@@ -2464,7 +2464,9 @@ static struct rte_pci_id pci_id_nfp_net_map[] = {
 
 static struct eth_driver rte_nfp_net_pmd = {
 	.pci_drv = {
-		.name = "rte_nfp_net_pmd",
+		.driver = {
+			.name = "rte_nfp_net_pmd",
+		},
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			     RTE_PCI_DRV_DETACHABLE,
drivers/net/qede/qede_ethdev.c +4 -0
index 4fcb54c..6d06f53 100644
@@ -1052,7 +1052,9 @@ static struct rte_pci_id pci_id_qede_map[] = {
 
 static struct eth_driver rte_qedevf_pmd = {
 	.pci_drv = {
+		.driver {
 		    .name = "rte_qedevf_pmd",
+		},
 		    .id_table = pci_id_qedevf_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
@@ -1066,7 +1068,9 @@ static struct eth_driver rte_qedevf_pmd = {
 
 static struct eth_driver rte_qede_pmd = {
 	.pci_drv = {
+		.driver = {
 		    .name = "rte_qede_pmd",
+		},
 		    .id_table = pci_id_qede_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
drivers/net/szedata2/rte_eth_szedata2.c +3 -1
index d925bc6..c0d6963 100644
@@ -1572,7 +1572,9 @@ static const struct rte_pci_id rte_szedata2_pci_id_table[] = {
 
 static struct eth_driver szedata2_eth_driver = {
 	.pci_drv = {
-		.name     = RTE_SZEDATA2_PCI_DRIVER_NAME,
+		.driver = {
+			.name = RTE_SZEDATA2_PCI_DRIVER_NAME,
+		},
 		.id_table = rte_szedata2_pci_id_table,
 		.devinit = rte_eth_dev_pci_probe,
 		.devuninit = rte_eth_dev_pci_remove,
drivers/net/virtio/virtio_ethdev.c +4 -2
index 9f5faf1..9c06c46 100644
@@ -1252,7 +1252,9 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
-		.name = "rte_virtio_pmd",
+		.driver = {
+			.name = "rte_virtio_pmd",
+		},
 		.id_table = pci_id_virtio_map,
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
 		.devinit = rte_eth_dev_pci_probe,
@@ -1473,7 +1475,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
 
-	dev_info->driver_name = dev->driver->pci_drv.name;
+	dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
 	dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
 	dev_info->min_rx_bufsize = VIRTIO_MIN_RX_BUFSIZE;
drivers/net/vmxnet3/vmxnet3_ethdev.c +5 -2
index 79c5f6d..a7438d1 100644
@@ -138,7 +138,8 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-					dev->driver->pci_drv.name, dev->data->port_id, post_string);
+			dev->driver->pci_drv.driver.name,
+			dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (mz)
@@ -329,7 +330,9 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_vmxnet3_pmd = {
 	.pci_drv = {
-		.name = "rte_vmxnet3_pmd",
+		.driver = {
+			.name = "rte_vmxnet3_pmd",
+		},
 		.id_table = pci_id_vmxnet3_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 		.devinit = rte_eth_dev_pci_probe,
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -1
index ccafc0c..536f0ac 100644
@@ -772,7 +772,7 @@ ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			dev->driver->pci_drv.name, ring_name,
+			dev->driver->pci_drv.driver.name, ring_name,
 			dev->data->port_id, queue_id);
 
 	mz = rte_memzone_lookup(z_name);
lib/librte_cryptodev/rte_cryptodev.c +2 -2
index 3b587e4..afb13d7 100644
@@ -370,7 +370,7 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 		return 0;
 
 	CDEV_LOG_ERR("driver %s: crypto_dev_init(vendor_id=0x%x device_id=0x%x)"
-			" failed", pci_drv->name,
+			" failed", pci_drv->driver.name,
 			(unsigned) pci_dev->id.vendor_id,
 			(unsigned) pci_dev->id.device_id);
 
@@ -781,7 +781,7 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
 
 	dev_info->pci_dev = dev->pci_dev;
 	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.name;
+		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 }
 
 
lib/librte_eal/common/eal_common_pci.c +2 -2
index d05dda4..3bcb059 100644
@@ -193,7 +193,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		}
 
 		RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
-				dev->id.device_id, dr->name);
+				dev->id.device_id, dr->driver.name);
 
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 			/* map resources for devices that use igb_uio */
@@ -253,7 +253,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 				loc->function, dev->numa_node);
 
 		RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
-				dev->id.device_id, dr->name);
+				dev->id.device_id, dr->driver.name);
 
 		if (dr->devuninit && (dr->devuninit(dev) < 0))
 			return -1;	/* negative value is an error */
lib/librte_eal/common/include/rte_pci.h +3 -1
index 950ea89..139d76f 100644
@@ -202,13 +202,15 @@ typedef int (pci_devuninit_t)(struct rte_pci_device *);
  */
 struct rte_pci_driver {
 	TAILQ_ENTRY(rte_pci_driver) next;       /**< Next in list. */
-	const char *name;                       /**< Driver name. */
+	struct rte_driver driver;               /**< Inherit the core driver. */
 	pci_devinit_t *devinit;                 /**< Device init. function. */
 	pci_devuninit_t *devuninit;             /**< Device uninit function. */
 	const struct rte_pci_id *id_table;	/**< ID table, NULL terminated. */
 	uint32_t drv_flags;                     /**< Flags contolling handling of device. */
 };
 
+#define to_pci_driver(drv) container_of((drv), struct rte_pci_driver, driver)
+
 /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device needs to be unbound even if no module is provided */
lib/librte_ether/rte_ethdev.c +2 -2
index 48c7254..f2e0716 100644
@@ -2562,7 +2562,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 dev->driver->pci_drv.name, ring_name,
+		 dev->driver->pci_drv.driver.name, ring_name,
 		 dev->data->port_id, queue_id);
 
 	mz = rte_memzone_lookup(z_name);
@@ -3216,7 +3216,7 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->name;
+	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 int
Signature · 1 line
2.9.0
#14 lore raw

PATCH 12/15 eal: call rte_eal_driver_register

In reply to Jan Viktorin

To register both vdev and pci drivers into the list of all rte_driver, we have to call rte_eal_driver_register explicitly.

---
 lib/librte_eal/common/eal_common_pci.c  | 2 ++
 lib/librte_eal/common/eal_common_vdev.c | 2 ++
 2 files changed, 4 insertions(+)
lib/librte_eal/common/eal_common_pci.c +2 -0
index 3bcb059..144479e 100644
@@ -468,11 +468,13 @@ void
 rte_eal_pci_register(struct rte_pci_driver *driver)
 {
 	TAILQ_INSERT_TAIL(&pci_driver_list, driver, next);
+	rte_eal_driver_register(&driver->driver);
 }
 
 /* unregister a driver */
 void
 rte_eal_pci_unregister(struct rte_pci_driver *driver)
 {
+	rte_eal_driver_unregister(&driver->driver);
 	TAILQ_REMOVE(&pci_driver_list, driver, next);
 }
lib/librte_eal/common/eal_common_vdev.c +2 -0
index 7e7ddd1..389db3e 100644
@@ -42,12 +42,14 @@ void
 rte_eal_vdrv_register(struct rte_vdev_driver *driver)
 {
 	TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
+	rte_eal_driver_register(&driver->driver);
 }
 
 /* unregister a driver */
 void
 rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
 {
+	rte_eal_driver_unregister(&driver->driver);
 	TAILQ_REMOVE(&vdev_driver_list, driver, next);
 }
 
Signature · 1 line
2.9.0
#15 lore raw

PATCH 13/15 eal: introduce rte_device

In reply to Jan Viktorin
---
 lib/librte_eal/common/eal_common_dev.c  | 13 +++++++++++++
 lib/librte_eal/common/include/rte_dev.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
lib/librte_eal/common/eal_common_dev.c +13 -0
index f4c880c..2c2a1bd 100644
@@ -48,6 +48,9 @@
 /** Global list of device drivers. */
 static struct rte_driver_list dev_driver_list =
 	TAILQ_HEAD_INITIALIZER(dev_driver_list);
+/** Global list of device drivers. */
+static struct rte_device_list dev_device_list =
+	TAILQ_HEAD_INITIALIZER(dev_device_list);
 
 /* register a driver */
 void
@@ -63,6 +66,16 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 	TAILQ_REMOVE(&dev_driver_list, driver, next);
 }
 
+void rte_eal_device_insert(struct rte_device *dev)
+{
+	TAILQ_INSERT_TAIL(&dev_device_list, dev, next);
+}
+
+void rte_eal_device_remove(struct rte_device *dev)
+{
+	TAILQ_REMOVE(&dev_device_list, dev, next);
+}
+
 int
 rte_eal_dev_init(void)
 {
lib/librte_eal/common/include/rte_dev.h +31 -0
index 2a0d326..d767012 100644
@@ -112,6 +112,37 @@ struct rte_mem_resource {
 
 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
+/** Double linked list of devices. */
+TAILQ_HEAD(rte_device_list, rte_device);
+
+/* Forward declaration */
+struct rte_driver;
+
+/**
+ * A structure describing a generic device.
+ */
+struct rte_device {
+	TAILQ_ENTRY(rte_device) next; /**< Next device */
+	struct rte_driver *driver;    /**< Associated driver */
+	int numa_node;                /**< NUMA node connection */
+	struct rte_devargs *devargs;  /**< Device user arguments */
+};
+
+/**
+ * Insert a device detected by a bus scanning.
+ *
+ * @param dev
+ *   A pointer to a rte_device structure describing the detected device.
+ */
+void rte_eal_device_insert(struct rte_device *dev);
+
+/**
+ * Remove a device (e.g. when being unplugged).
+ *
+ * @param dev
+ *   A pointer to a rte_device structure describing the device to be removed.
+ */
+void rte_eal_device_remove(struct rte_device *dev);
 
 /**
  * A structure describing a device driver.
Signature · 1 line
2.9.0
#16 lore raw

PATCH 14/15 eal/pci: inherit rte_device by rte_pci_device

In reply to Jan Viktorin
---
 app/test/virtual_pmd.c                  |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c        |  6 +++---
 drivers/net/virtio/virtio_pci.c         |  2 +-
 lib/librte_cryptodev/rte_cryptodev.c    |  2 +-
 lib/librte_eal/common/eal_common_pci.c  | 14 +++++++-------
 lib/librte_eal/common/include/rte_pci.h |  4 +---
 lib/librte_eal/linuxapp/eal/eal_pci.c   |  4 ++--
 lib/librte_ether/rte_ethdev.c           | 14 +++++++++-----
 8 files changed, 26 insertions(+), 24 deletions(-)
app/test/virtual_pmd.c +2 -2
index 56eeb99..4831113 100644
@@ -585,7 +585,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	if (eth_dev == NULL)
 		goto err;
 
-	pci_dev->numa_node = socket_id;
+	pci_dev->device.numa_node = socket_id;
 	pci_drv->driver.name = virtual_ethdev_driver_name;
 	pci_drv->id_table = id_table;
 
@@ -626,7 +626,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	eth_dev->dev_ops = &dev_private->dev_ops;
 
 	eth_dev->pci_dev = pci_dev;
-	eth_dev->pci_dev->driver = &eth_drv->pci_drv;
+	eth_dev->pci_dev->device.driver = &eth_drv->pci_drv.driver;
 
 	eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
 	eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
drivers/net/fm10k/fm10k_ethdev.c +3 -3
index 4ffa66c..4230a75 100644
@@ -675,7 +675,7 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
 		/* Enable use of FTAG bit in TX descriptor, PFVTCTL
 		 * register is read-only for VF.
 		 */
-		if (fm10k_check_ftag(dev->pci_dev->devargs)) {
+		if (fm10k_check_ftag(dev->pci_dev->device.devargs)) {
 			if (hw->mac.type == fm10k_mac_pf) {
 				FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i),
 						FM10K_PFVTCTL_FTAG_DESC_ENABLE);
@@ -2734,7 +2734,7 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
 	int use_sse = 1;
 	uint16_t tx_ftag_en = 0;
 
-	if (fm10k_check_ftag(dev->pci_dev->devargs))
+	if (fm10k_check_ftag(dev->pci_dev->device.devargs))
 		tx_ftag_en = 1;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -2767,7 +2767,7 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)
 	uint16_t i, rx_using_sse;
 	uint16_t rx_ftag_en = 0;
 
-	if (fm10k_check_ftag(dev->pci_dev->devargs))
+	if (fm10k_check_ftag(dev->pci_dev->device.devargs))
 		rx_ftag_en = 1;
 
 	/* In order to allow Vector Rx there are a few configuration
drivers/net/virtio/virtio_pci.c +1 -1
index 9c9a3dd..6fbfa39 100644
@@ -719,7 +719,7 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw,
 	PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
 	if (legacy_virtio_resource_init(dev, hw, dev_flags) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
-		    dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) {
+		    dev->device.devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
lib/librte_cryptodev/rte_cryptodev.c +1 -1
index afb13d7..d2a2a60 100644
@@ -401,7 +401,7 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (cryptodev == NULL)
 		return -ENODEV;
 
-	cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver;
+	cryptodrv = (const struct rte_cryptodev_driver *)to_pci_driver(pci_dev->device.driver);
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
lib/librte_eal/common/eal_common_pci.c +7 -7
index 144479e..66ceba6 100644
@@ -183,11 +183,11 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 
 		RTE_LOG(INFO, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
 				loc->domain, loc->bus, loc->devid, loc->function,
-				dev->numa_node);
+				dev->device.numa_node);
 
 		/* no initialization when blacklisted, return without error */
-		if (dev->devargs != NULL &&
-			dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (dev->device.devargs != NULL &&
+			dev->device.devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
 			RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not initializing\n");
 			return 1;
 		}
@@ -208,7 +208,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		}
 
 		/* reference driver structure */
-		dev->driver = dr;
+		dev->device.driver = &dr->driver;
 
 		/* call the driver devinit() function */
 		return dr->devinit(dr, dev);
@@ -250,7 +250,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 
 		RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
 				loc->domain, loc->bus, loc->devid,
-				loc->function, dev->numa_node);
+				loc->function, dev->device.numa_node);
 
 		RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
 				dev->id.device_id, dr->driver.name);
@@ -259,7 +259,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 			return -1;	/* negative value is an error */
 
 		/* clear driver structure */
-		dev->driver = NULL;
+		dev->device.driver = NULL;
 
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
 			/* unmap resources for devices that use igb_uio */
@@ -415,7 +415,7 @@ rte_eal_pci_probe(void)
 		/* set devargs in PCI structure */
 		devargs = pci_devargs_lookup(dev);
 		if (devargs != NULL)
-			dev->devargs = devargs;
+			dev->device.devargs = devargs;
 
 		/* probe all or only whitelisted devices */
 		if (probe_all)
lib/librte_eal/common/include/rte_pci.h +1 -3
index 139d76f..2f78ec4 100644
@@ -152,14 +152,12 @@ enum rte_kernel_driver {
  */
 struct rte_pci_device {
 	TAILQ_ENTRY(rte_pci_device) next;       /**< Next probed PCI device. */
+	struct rte_device device;               /**< Inherited device. */
 	struct rte_pci_addr addr;               /**< PCI location. */
 	struct rte_pci_id id;                   /**< PCI ID. */
 	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI Memory Resource */
 	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
-	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
-	int numa_node;                          /**< NUMA node connection */
-	struct rte_devargs *devargs;            /**< Device user arguments */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 };
 
lib/librte_eal/linuxapp/eal/eal_pci.c +2 -2
index 0a368c5..6f1a28a 100644
@@ -350,13 +350,13 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 		 dirname);
 	if (access(filename, R_OK) != 0) {
 		/* if no NUMA support, set default to 0 */
-		dev->numa_node = 0;
+		dev->device.numa_node = 0;
 	} else {
 		if (eal_parse_sysfs_value(filename, &tmp) < 0) {
 			free(dev);
 			return -1;
 		}
-		dev->numa_node = tmp;
+		dev->device.numa_node = tmp;
 	}
 
 	/* parse resources */
lib/librte_ether/rte_ethdev.c +9 -5
index f2e0716..be12687 100644
@@ -303,7 +303,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	if (eth_dev == NULL)
 		return -ENODEV;
 
-	eth_drv = (const struct eth_driver *)pci_dev->driver;
+	eth_drv = (const struct eth_driver *)to_pci_driver(pci_dev->device.driver);
 
 	/* Invoke PMD device uninit function */
 	if (*eth_drv->eth_dev_uninit) {
@@ -3202,21 +3202,25 @@ rte_eth_dev_get_dcb_info(uint8_t port_id,
 void
 rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev)
 {
+	struct rte_pci_driver *pci_drv;
+
 	if ((eth_dev == NULL) || (pci_dev == NULL)) {
 		RTE_PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n",
 				eth_dev, pci_dev);
 		return;
 	}
 
+	pci_drv = to_pci_driver(pci_dev->device.driver);
+
 	eth_dev->data->dev_flags = 0;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_DETACHABLE)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_DETACHABLE)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
-	eth_dev->data->numa_node = pci_dev->numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
+	eth_dev->data->numa_node = pci_dev->device.numa_node;
+	eth_dev->data->drv_name = pci_dev->device.driver->name;
 }
 
 int
Signature · 1 line
2.9.0
#17 lore raw

PATCH 15/15 eal/pci: insert rte_device on scan

In reply to Jan Viktorin
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_eal/linuxapp/eal/eal_pci.c +3 -0
index 6f1a28a..ab08a16 100644
@@ -390,6 +390,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	} else {
 		struct rte_pci_device *dev2;
@@ -402,6 +403,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 
 			if (ret < 0) {
 				TAILQ_INSERT_BEFORE(dev2, dev, next);
+				rte_eal_device_insert(&dev->device);
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
@@ -411,6 +413,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 			}
 			return 0;
 		}
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
 
Signature · 1 line
2.9.0
#18 lore raw
In reply to Jan Viktorin

Hi Jan,

Quoted 14 lines · Jan Viktorin

Hello,

based on the discussions with Shreyansh, I propose a patchset with the important EAL changes. It is incomplete and I suppose to extend and change certain things in the foreseeable future.

Important notes:

* pmd_type is removed
* introduced rte_vdev_driver inheriting rte_driver
* PMD_REGISTER_DRIVER is replaced by RTE_EAL_VDRV_REGISTER
* rte_driver/device integrated into rte_pci_driver/device
* all drivers and devices are in 2 lists - general and bus-specific

Quoted 3 lines

Shreyansh, I hope I do not duplicate your work. I tried to avoid touching pmd_type but it quite complicated... There is also an initial generalization of rte_pci_resource. More such generalizations are to be done.

My mistake - I didn't even notice this email somehow. In fact, I noticed right when I was about to send the v6 - while searching for my old conversation. I will look through these patches and remove any conflicting change (as much as possible) - I don't think it there would much conflicts except the VDEV area. And, cursory look shows not much duplication - don't worry.

Quoted 7 lines

The init/uninit functions cannot be generalized easily, I think. Both PCI and VDEV have different requirements.

No idea about hotplug...

Quoted 6 lines

The patchset is based on (all rebased on top of 34d279):

[PATCH v5 00/17] Prepare for rte_device / rte_driver

Thanks anybody for some quick review and notes.

Added to my list of todo. I will review and reply soon.

Quoted 3 lines

Regards
Jan

-
Shreyansh

[...]

#19 lore raw
In reply to Jan Viktorin

2016-07-08 21:09, Jan Viktorin:

Quoted 14 lines

Hello,

based on the discussions with Shreyansh, I propose a patchset with the important EAL changes. It is incomplete and I suppose to extend and change certain things in the foreseeable future.

Important notes:

* pmd_type is removed
* introduced rte_vdev_driver inheriting rte_driver
* PMD_REGISTER_DRIVER is replaced by RTE_EAL_VDRV_REGISTER
* rte_driver/device integrated into rte_pci_driver/device
* all drivers and devices are in 2 lists - general and bus-specific

Quoted 8 lines

Shreyansh, I hope I do not duplicate your work. I tried to avoid touching pmd_type but it quite complicated... There is also an initial generalization of rte_pci_resource. More such generalizations are to be done.

The init/uninit functions cannot be generalized easily, I think. Both PCI and VDEV have different requirements.

No idea about hotplug...

Please could you give a clear overview of how you split the work in your respective series?

I take the opportunity to put my notes about some initial targets of this refactoring:

module/drivers
attached to 1 bus: pci_driver or vdev_driver
rte_device = device resources / embedded in pci/vdev_driver
attached to n device interfaces (ethdev, crypto)
1 device resource -> n device interfaces
hotplug resource -> lookup drivers list
per-bus lists or 1 list?
devinit/devuninit generalized and moved to rte_driver
-> rename to probe/remove
crypto.dev_type could be dropped
drv_flags should be moved to rte_driver
intr_init can be moved earlier in init, before affinity set
devices
unique_device_name -> standard naming?
difference with port_id ? -> device id for ethdev
should be unique_resource_name -> 1 EAL resource may match several devices
ethdev manage an interface, eal manage a hardware resource, device object in between? need for bus object?
no need of driver object, module object?
devargs, intr_handle, numa_node should be moved to rte_device
hotplug notification to do
notify free-able ressource?
remove blacklist at EAL level and let application handle it
devargs still in hotplug function, must be moved in separate API
devargs
new API
new command line parameters

#20 lore raw
Quoted 19 lines · On Fri, 15 Jul 2016 15:19:14 +0200 Thomas Monjalon <[email protected]>…

2016-07-08 21:09, Jan Viktorin:

Quoted 18 lines

Hello,

based on the discussions with Shreyansh, I propose a patchset with the important EAL changes. It is incomplete and I suppose to extend and change certain things in the foreseeable future.

Important notes:

* pmd_type is removed
* introduced rte_vdev_driver inheriting rte_driver
* PMD_REGISTER_DRIVER is replaced by RTE_EAL_VDRV_REGISTER
* rte_driver/device integrated into rte_pci_driver/device
* all drivers and devices are in 2 lists - general and bus-specific

Shreyansh, I hope I do not duplicate your work. I tried to avoid touching pmd_type but it quite complicated... There is also an initial generalization of rte_pci_resource. More such generalizations are to be done.

Quoted 7 lines
Quoted 4 lines

The init/uninit functions cannot be generalized easily, I think. Both PCI and VDEV have different requirements.

No idea about hotplug...

Please could you give a clear overview of how you split the work in your respective series?

Yes, it's a bit messy... My quick summary follows.

Quoted 6 lines

I take the opportunity to put my notes about some initial targets of this refactoring:

module/drivers
attached to 1 bus: pci_driver or vdev_driver

pci_driver is done by Shreyansh/David
vdev_driver is done by myself

Quoted 1 line

rte_device = device resources / embedded in pci/vdev_driver

Extraction of rte_device is done by myself

Quoted 2 lines
		attached to n device interfaces (ethdev, crypto)
	1 device resource -> n device interfaces

I am not sure, what those two points means exactly.

Quoted 2 lines
	hotplug resource -> lookup drivers list
		per-bus lists or 1 list?

Not sure. At least partially done by Shreyansh/David.

Quoted 2 lines
	devinit/devuninit generalized and moved to rte_driver
		-> rename to probe/remove  

Some renames done by Shreyansh/David.

There will be no move. The vdev_driver has different kind of init/uninit then PCI. So I cannot see a simple way how to generalize this.

I'll do the final init->probe, uninit->remove renames.

Quoted 1 line

crypto.dev_type could be dropped

I am not sure about this.

Quoted 1 line

drv_flags should be moved to rte_driver

I'll do.

Quoted 2 lines

intr_init can be moved earlier in init, before affinity set
devices

Done by Shreyansh/David.

Quoted 1 line
	unique_device_name -> standard naming?

Done for PCI: rte_eal_pci_device_name by Shreyansh/David.

Quoted 1 line
		difference with port_id ? -> device id for ethdev

Not sure.

Quoted 1 line
		should be unique_resource_name -> 1 EAL resource may match several devices

Not sure.

Quoted 1 line

ethdev manage an interface, eal manage a hardware resource, device object in between?

Not sure about the question.

Quoted 1 line

need for bus object?

I don't think so at this stage.

Quoted 1 line

no need of driver object, module object?

The current rte_driver will not exist. Same for any kind of module.

Quoted 1 line

devargs, intr_handle, numa_node should be moved to rte_device

Yes, done by myself.

Quoted 8 lines

hotplug notification to do
notify free-able ressource?
remove blacklist at EAL level and let application handle it devargs still in hotplug function, must be moved in separate API
devargs
new API
new command line parameters

Signature · 4 lines
   Jan Viktorin                  E-mail: [email protected]
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic