[RFC,v2,v2,11/29] drivers/bus: hide specific structures

Message ID 20220709082644.664675-12-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Bus and device cleanup for 22.11 |

Commit Message

David Marchand July 9, 2022, 8:26 a.m. UTC
  Now that there is no bus specific object referenced in the driver
objects, we can hide rte_dpaa_bus, rte_fslmc_bus, rte_pci_bus,
rte_vmbus_bus specific structures into their bus code.

While at it:
- move enumerators only used in the bus code itself,
- remove unneeded list head structure type,
- reorder the definitions and macro manipulating the bus singleton object,
- remove inclusion of rte_bus.h and update code that relied on it,

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since RFC v1:
- dropped kni UT and ethtool example changes after new cleanup was added,
- cleaned ifgpa and vdev bus,

---
 app/test-pmd/testpmd.h                    |  1 +
 drivers/bus/auxiliary/private.h           | 28 +++++++++++------------
 drivers/bus/auxiliary/rte_bus_auxiliary.h |  1 -
 drivers/bus/dpaa/dpaa_bus.c               |  8 +++++++
 drivers/bus/dpaa/rte_dpaa_bus.h           | 13 -----------
 drivers/bus/fslmc/fslmc_bus.c             |  1 +
 drivers/bus/fslmc/fslmc_vfio.c            |  2 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dprc.c  |  1 +
 drivers/bus/fslmc/private.h               | 27 ++++++++++++++++++++++
 drivers/bus/fslmc/rte_fslmc.h             | 20 ----------------
 drivers/bus/ifpga/ifpga_bus.c             |  4 ++--
 drivers/bus/ifpga/rte_bus_ifpga.h         |  6 -----
 drivers/bus/pci/bsd/pci.c                 |  2 --
 drivers/bus/pci/linux/pci.c               |  3 ---
 drivers/bus/pci/private.h                 | 18 ++++++++++++++-
 drivers/bus/pci/rte_bus_pci.h             | 22 ------------------
 drivers/bus/pci/windows/pci.c             |  1 +
 drivers/bus/pci/windows/pci_netuio.c      |  1 +
 drivers/bus/vdev/rte_bus_vdev.h           |  3 ---
 drivers/bus/vdev/vdev.c                   |  6 ++---
 drivers/bus/vmbus/private.h               | 18 +++++++++++++++
 drivers/bus/vmbus/rte_bus_vmbus.h         | 20 ----------------
 drivers/bus/vmbus/vmbus_common.c          |  1 -
 drivers/common/mlx5/mlx5_common_pci.c     |  1 +
 drivers/net/bonding/rte_eth_bond_args.c   |  1 +
 drivers/net/mlx5/linux/mlx5_os.c          |  1 +
 drivers/net/netvsc/hn_ethdev.c            |  1 +
 27 files changed, 97 insertions(+), 114 deletions(-)
 create mode 100644 drivers/bus/fslmc/private.h
  

Patch

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index fb2f5195d3..8694c65539 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -8,6 +8,7 @@ 
 #include <stdbool.h>
 
 #include <rte_pci.h>
+#include <rte_bus.h>
 #include <rte_bus_pci.h>
 #ifdef RTE_LIB_GRO
 #include <rte_gro.h>
diff --git a/drivers/bus/auxiliary/private.h b/drivers/bus/auxiliary/private.h
index d22e83cf7a..d97e8c694e 100644
--- a/drivers/bus/auxiliary/private.h
+++ b/drivers/bus/auxiliary/private.h
@@ -9,9 +9,10 @@ 
 #include <stdio.h>
 #include <sys/queue.h>
 
+#include <rte_bus.h>
+
 #include "rte_bus_auxiliary.h"
 
-extern struct rte_auxiliary_bus auxiliary_bus;
 extern int auxiliary_bus_logtype;
 
 #define AUXILIARY_LOG(level, ...) \
@@ -19,27 +20,24 @@  extern int auxiliary_bus_logtype;
 		RTE_FMT("auxiliary bus: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 			RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/* Auxiliary bus iterators */
-#define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \
-		TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next)
-
-#define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \
-		TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next)
-
-/* List of auxiliary devices. */
-TAILQ_HEAD(rte_auxiliary_device_list, rte_auxiliary_device);
-/* List of auxiliary drivers. */
-TAILQ_HEAD(rte_auxiliary_driver_list, rte_auxiliary_driver);
-
 /*
  * Structure describing the auxiliary bus
  */
 struct rte_auxiliary_bus {
 	struct rte_bus bus;                  /* Inherit the generic class */
-	struct rte_auxiliary_device_list device_list;  /* List of devices */
-	struct rte_auxiliary_driver_list driver_list;  /* List of drivers */
+	TAILQ_HEAD(, rte_auxiliary_device) device_list;  /* List of devices */
+	TAILQ_HEAD(, rte_auxiliary_driver) driver_list;  /* List of drivers */
 };
 
+extern struct rte_auxiliary_bus auxiliary_bus;
+
+/* Auxiliary bus iterators */
+#define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \
+	TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next)
+
+#define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \
+	TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next)
+
 /*
  * Test whether the auxiliary device exist.
  */
diff --git a/drivers/bus/auxiliary/rte_bus_auxiliary.h b/drivers/bus/auxiliary/rte_bus_auxiliary.h
index b19696e5e6..3b3dbc866a 100644
--- a/drivers/bus/auxiliary/rte_bus_auxiliary.h
+++ b/drivers/bus/auxiliary/rte_bus_auxiliary.h
@@ -25,7 +25,6 @@  extern "C" {
 #include <rte_debug.h>
 #include <rte_interrupts.h>
 #include <rte_dev.h>
-#include <rte_bus.h>
 #include <rte_kvargs.h>
 
 #define RTE_BUS_AUXILIARY_NAME "auxiliary"
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 2c286d5817..ad4ea156a6 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -43,6 +43,14 @@ 
 #include <fsl_bman.h>
 #include <netcfg.h>
 
+struct rte_dpaa_bus {
+	struct rte_bus bus;
+	TAILQ_HEAD(, rte_dpaa_device) device_list;
+	TAILQ_HEAD(, rte_dpaa_driver) driver_list;
+	int device_count;
+	int detected;
+};
+
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h
index 5e8f32dfbf..69c759c68b 100644
--- a/drivers/bus/dpaa/rte_dpaa_bus.h
+++ b/drivers/bus/dpaa/rte_dpaa_bus.h
@@ -6,7 +6,6 @@ 
 #ifndef __RTE_DPAA_BUS_H__
 #define __RTE_DPAA_BUS_H__
 
-#include <rte_bus.h>
 #include <rte_mbuf_dyn.h>
 #include <rte_mempool.h>
 #include <dpaax_iova_table.h>
@@ -73,24 +72,12 @@  extern unsigned int dpaa_svr_family;
 struct rte_dpaa_device;
 struct rte_dpaa_driver;
 
-/* DPAA Device and Driver lists for DPAA bus */
-TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device);
-TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver);
-
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
 	FSL_DPAA_QDMA
 };
 
-struct rte_dpaa_bus {
-	struct rte_bus bus;
-	struct rte_dpaa_device_list device_list;
-	struct rte_dpaa_driver_list driver_list;
-	int device_count;
-	int detected;
-};
-
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index f112d2afeb..8498f5321a 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -16,6 +16,7 @@ 
 #include <ethdev_driver.h>
 #include <rte_mbuf_dyn.h>
 
+#include "private.h"
 #include <rte_fslmc.h>
 #include <fslmc_vfio.h>
 #include "fslmc_logs.h"
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 3d4e71a80a..b172c84d52 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -29,9 +29,9 @@ 
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
-#include <rte_bus.h>
 #include <rte_eal_memconfig.h>
 
+#include "private.h"
 #include "rte_fslmc.h"
 #include "fslmc_vfio.h"
 #include "fslmc_logs.h"
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c
index ca1d0304d5..28780717bd 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c
@@ -12,6 +12,7 @@ 
 #include <rte_malloc.h>
 #include <rte_dev.h>
 
+#include "private.h"
 #include <fslmc_logs.h>
 #include <rte_fslmc.h>
 #include <mc/fsl_dprc.h>
diff --git a/drivers/bus/fslmc/private.h b/drivers/bus/fslmc/private.h
new file mode 100644
index 0000000000..80d4673ca8
--- /dev/null
+++ b/drivers/bus/fslmc/private.h
@@ -0,0 +1,27 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ *   Copyright 2016,2021 NXP
+ */
+
+#ifndef __PRIVATE_H__
+#define __PRIVATE_H__
+
+#include <rte_bus.h>
+
+#include <rte_fslmc.h>
+
+/*
+ * FSLMC bus
+ */
+struct rte_fslmc_bus {
+	struct rte_bus bus;     /**< Generic Bus object */
+	TAILQ_HEAD(, rte_dpaa2_device) device_list;
+				/**< FSLMC DPAA2 Device list */
+	TAILQ_HEAD(, rte_dpaa2_driver) driver_list;
+				/**< FSLMC DPAA2 Driver list */
+	int device_count[DPAA2_DEVTYPE_MAX];
+				/**< Count of all devices scanned */
+};
+
+extern struct rte_fslmc_bus rte_fslmc_bus;
+
+#endif /* __PRIVATE_H__ */
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index 9c3791635c..6bdee86aaf 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -29,7 +29,6 @@  extern "C" {
 #include <rte_debug.h>
 #include <rte_interrupts.h>
 #include <rte_dev.h>
-#include <rte_bus.h>
 #include <rte_tailq.h>
 #include <rte_devargs.h>
 #include <rte_mbuf.h>
@@ -69,15 +68,9 @@  dpaa2_seqn(struct rte_mbuf *mbuf)
 
 struct rte_dpaa2_driver;
 
-/* DPAA2 Device and Driver lists for FSLMC bus */
-TAILQ_HEAD(rte_fslmc_device_list, rte_dpaa2_device);
-TAILQ_HEAD(rte_fslmc_driver_list, rte_dpaa2_driver);
-
 #define RTE_DEV_TO_FSLMC_CONST(ptr) \
 	container_of(ptr, const struct rte_dpaa2_device, device)
 
-extern struct rte_fslmc_bus rte_fslmc_bus;
-
 enum rte_dpaa2_dev_type {
 	/* Devices backed by DPDK driver */
 	DPAA2_ETH,	/**< DPNI type device*/
@@ -152,19 +145,6 @@  struct rte_dpaa2_driver {
 	rte_dpaa2_remove_t remove;
 };
 
-/*
- * FSLMC bus
- */
-struct rte_fslmc_bus {
-	struct rte_bus bus;     /**< Generic Bus object */
-	struct rte_fslmc_device_list device_list;
-				/**< FSLMC DPAA2 Device list */
-	struct rte_fslmc_driver_list driver_list;
-				/**< FSLMC DPAA2 Driver list */
-	int device_count[DPAA2_DEVTYPE_MAX];
-				/**< Count of all devices scanned */
-};
-
 /**
  * Register a DPAA2 driver.
  *
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index e005f2cb70..5353dbdb01 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -37,9 +37,9 @@ 
  */
 static struct rte_bus rte_ifpga_bus;
 
-static struct ifpga_afu_dev_list ifpga_afu_dev_list =
+static TAILQ_HEAD(, rte_afu_device) ifpga_afu_dev_list =
 	TAILQ_HEAD_INITIALIZER(ifpga_afu_dev_list);
-static struct ifpga_afu_drv_list ifpga_afu_drv_list =
+static TAILQ_HEAD(, rte_afu_driver) ifpga_afu_drv_list =
 	TAILQ_HEAD_INITIALIZER(ifpga_afu_drv_list);
 
 
diff --git a/drivers/bus/ifpga/rte_bus_ifpga.h b/drivers/bus/ifpga/rte_bus_ifpga.h
index 682d565891..8792e23dd0 100644
--- a/drivers/bus/ifpga/rte_bus_ifpga.h
+++ b/drivers/bus/ifpga/rte_bus_ifpga.h
@@ -19,18 +19,12 @@  extern "C" {
 #include <rte_interrupts.h>
 #include <rte_spinlock.h>
 
-/** Name of Intel FPGA Bus */
 #define IFPGA_BUS_NAME ifpga
 
 /* Forward declarations */
 struct rte_afu_device;
 struct rte_afu_driver;
 
-/** Double linked list of Intel FPGA AFU device. */
-RTE_TAILQ_HEAD(ifpga_afu_dev_list, rte_afu_device);
-/** Double linked list of Intel FPGA AFU device drivers. */
-RTE_TAILQ_HEAD(ifpga_afu_drv_list, rte_afu_driver);
-
 #define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
 
 struct rte_afu_uuid {
diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
index 9a11f99ae3..bcd772427b 100644
--- a/drivers/bus/pci/bsd/pci.c
+++ b/drivers/bus/pci/bsd/pci.c
@@ -48,8 +48,6 @@ 
  * PCI probing under BSD.
  */
 
-extern struct rte_pci_bus rte_pci_bus;
-
 /* Map pci device */
 int
 rte_pci_map_device(struct rte_pci_device *dev)
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index e521459870..fa5d5e131d 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -6,7 +6,6 @@ 
 #include <dirent.h>
 
 #include <rte_log.h>
-#include <rte_bus.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_malloc.h>
@@ -24,8 +23,6 @@ 
  * PCI probing using Linux sysfs.
  */
 
-extern struct rte_pci_bus rte_pci_bus;
-
 static int
 pci_get_kernel_driver_by_path(const char *filename, char *dri_name,
 			      size_t len)
diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index 0fbef8e1d8..6ccec15655 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -8,12 +8,28 @@ 
 #include <stdbool.h>
 #include <stdio.h>
 
-#include <rte_bus_pci.h>
+#include <rte_bus.h>
 #include <rte_os_shim.h>
 #include <rte_pci.h>
 
+/**
+ * Structure describing the PCI bus
+ */
+struct rte_pci_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	RTE_TAILQ_HEAD(, rte_pci_device) device_list; /**< List of PCI devices */
+	RTE_TAILQ_HEAD(, rte_pci_driver) driver_list; /**< List of PCI drivers */
+};
+
 extern struct rte_pci_bus rte_pci_bus;
 
+/* PCI Bus iterators */
+#define FOREACH_DEVICE_ON_PCIBUS(p)	\
+	RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
+
+#define FOREACH_DRIVER_ON_PCIBUS(p)	\
+	RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
+
 struct rte_pci_driver;
 struct rte_pci_device;
 
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index 1913bc111c..01d834e3cc 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -25,7 +25,6 @@  extern "C" {
 #include <rte_debug.h>
 #include <rte_interrupts.h>
 #include <rte_dev.h>
-#include <rte_bus.h>
 #include <rte_pci.h>
 
 /** Pathname of PCI devices directory. */
@@ -35,18 +34,6 @@  const char *rte_pci_get_sysfs_path(void);
 struct rte_pci_device;
 struct rte_pci_driver;
 
-/** List of PCI devices */
-RTE_TAILQ_HEAD(rte_pci_device_list, rte_pci_device);
-/** List of PCI drivers */
-RTE_TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver);
-
-/* PCI Bus iterators */
-#define FOREACH_DEVICE_ON_PCIBUS(p)	\
-		RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
-
-#define FOREACH_DRIVER_ON_PCIBUS(p)	\
-		RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
-
 struct rte_devargs;
 
 enum rte_pci_kernel_driver {
@@ -169,15 +156,6 @@  struct rte_pci_driver {
 	uint32_t drv_flags;                /**< Flags RTE_PCI_DRV_*. */
 };
 
-/**
- * Structure describing the PCI bus
- */
-struct rte_pci_bus {
-	struct rte_bus bus;               /**< Inherit the generic class */
-	struct rte_pci_device_list device_list;  /**< List of PCI devices */
-	struct rte_pci_driver_list driver_list;  /**< List of PCI drivers */
-};
-
 /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device needs PCI BAR mapping with enabled write combining (wc) */
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 7bf091158b..f013b743b3 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -9,6 +9,7 @@ 
 #include <rte_log.h>
 #include <rte_eal.h>
 #include <rte_memory.h>
+#include <rte_bus_pci.h>
 
 #include "private.h"
 #include "pci_netuio.h"
diff --git a/drivers/bus/pci/windows/pci_netuio.c b/drivers/bus/pci/windows/pci_netuio.c
index 5460399eea..314bbcf547 100644
--- a/drivers/bus/pci/windows/pci_netuio.c
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -8,6 +8,7 @@ 
 #include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_eal.h>
+#include <rte_bus_pci.h>
 
 #ifdef __MINGW32__
 #include <ddk/ndisguid.h>
diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
index 5af6be009f..ce20faf649 100644
--- a/drivers/bus/vdev/rte_bus_vdev.h
+++ b/drivers/bus/vdev/rte_bus_vdev.h
@@ -51,9 +51,6 @@  rte_vdev_device_args(const struct rte_vdev_device *dev)
 	return "";
 }
 
-/** Double linked list of virtual device drivers. */
-RTE_TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
-
 /**
  * Probe function called for each virtual device driver once.
  */
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a8d8b2327e..804486d3ba 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -30,16 +30,14 @@ 
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
-/** Double linked list of virtual device drivers. */
-TAILQ_HEAD(vdev_device_list, rte_vdev_device);
 
-static struct vdev_device_list vdev_device_list =
+static TAILQ_HEAD(, rte_vdev_device) vdev_device_list =
 	TAILQ_HEAD_INITIALIZER(vdev_device_list);
 /* The lock needs to be recursive because a vdev can manage another vdev. */
 static rte_spinlock_recursive_t vdev_device_list_lock =
 	RTE_SPINLOCK_RECURSIVE_INITIALIZER;
 
-static struct vdev_driver_list vdev_driver_list =
+static TAILQ_HEAD(, rte_vdev_driver) vdev_driver_list =
 	TAILQ_HEAD_INITIALIZER(vdev_driver_list);
 
 struct vdev_custom_scan {
diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h
index 658303bc27..597ba18df9 100644
--- a/drivers/bus/vmbus/private.h
+++ b/drivers/bus/vmbus/private.h
@@ -8,13 +8,31 @@ 
 
 #include <stdbool.h>
 #include <sys/uio.h>
+
+#include <rte_bus.h>
 #include <rte_log.h>
 #include <rte_eal_paging.h>
 #include <rte_vmbus_reg.h>
 #include <rte_bus_vmbus.h>
 
+/**
+ * Structure describing the VM bus
+ */
+struct rte_vmbus_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	RTE_TAILQ_HEAD(, rte_vmbus_device) device_list; /**< List of devices */
+	RTE_TAILQ_HEAD(, rte_vmbus_driver) driver_list; /**< List of drivers */
+};
+
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
+/* VMBus iterators */
+#define FOREACH_DEVICE_ON_VMBUS(p)	\
+	RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next)
+
+#define FOREACH_DRIVER_ON_VMBUS(p)	\
+	RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next)
+
 extern int vmbus_logtype_bus;
 #define VMBUS_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, vmbus_logtype_bus, "%s(): " fmt "\n", \
diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h
index 8d6ba26028..763c077623 100644
--- a/drivers/bus/vmbus/rte_bus_vmbus.h
+++ b/drivers/bus/vmbus/rte_bus_vmbus.h
@@ -23,7 +23,6 @@  extern "C" {
 #include <stdint.h>
 #include <inttypes.h>
 
-#include <rte_bus.h>
 #include <rte_compat.h>
 #include <rte_uuid.h>
 #include <rte_debug.h>
@@ -37,16 +36,6 @@  struct rte_vmbus_driver;
 struct vmbus_channel;
 struct vmbus_mon_page;
 
-RTE_TAILQ_HEAD(rte_vmbus_device_list, rte_vmbus_device);
-RTE_TAILQ_HEAD(rte_vmbus_driver_list, rte_vmbus_driver);
-
-/* VMBus iterators */
-#define FOREACH_DEVICE_ON_VMBUS(p)	\
-	RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next)
-
-#define FOREACH_DRIVER_ON_VMBUS(p)	\
-	RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next)
-
 /** Maximum number of VMBUS resources. */
 enum hv_uio_map {
 	HV_TXRX_RING_MAP = 0,
@@ -101,15 +90,6 @@  struct rte_vmbus_driver {
 };
 
 
-/**
- * Structure describing the VM bus
- */
-struct rte_vmbus_bus {
-	struct rte_bus bus;               /**< Inherit the generic class */
-	struct rte_vmbus_device_list device_list;  /**< List of devices */
-	struct rte_vmbus_driver_list driver_list;  /**< List of drivers */
-};
-
 /**
  * Scan the content of the VMBUS bus, and the devices in the devices
  * list
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 0f2d878126..03b39c82b7 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -11,7 +11,6 @@ 
 #include <sys/mman.h>
 
 #include <rte_log.h>
-#include <rte_bus.h>
 #include <rte_eal.h>
 #include <rte_tailq.h>
 #include <rte_devargs.h>
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index 66626953f1..e708e23a7f 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -9,6 +9,7 @@ 
 #include <rte_errno.h>
 #include <rte_class.h>
 #include <rte_pci.h>
+#include <rte_bus.h>
 #include <rte_bus_pci.h>
 
 #include "mlx5_common_log.h"
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index 5406e1c934..b90757756a 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -4,6 +4,7 @@ 
 
 #include <rte_devargs.h>
 #include <rte_pci.h>
+#include <rte_bus.h>
 #include <rte_bus_pci.h>
 #include <rte_kvargs.h>
 
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 0741028dab..04b9614f5c 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -19,6 +19,7 @@ 
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 #include <rte_pci.h>
+#include <rte_bus.h>
 #include <rte_bus_pci.h>
 #include <rte_bus_auxiliary.h>
 #include <rte_common.h>
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 787139c0b2..308936ad9f 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -31,6 +31,7 @@ 
 #include <rte_memory.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
+#include <rte_bus.h>
 #include <rte_bus_vmbus.h>
 #include <rte_alarm.h>