[RFC,v2,v2,25/29] bus/vmbus: make driver-only headers private

Message ID 20220709082644.664675-26-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
  The vmbus bus interface is for drivers only.
Mark as internal and move the header on the driver headers list.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/vmbus/bus_vmbus_driver.h | 106 +++++++++++++++++++++++++++
 drivers/bus/vmbus/meson.build        |   1 +
 drivers/bus/vmbus/private.h          |   2 +-
 drivers/bus/vmbus/rte_bus_vmbus.h    |  83 ---------------------
 drivers/bus/vmbus/version.map        |   9 ++-
 drivers/net/netvsc/hn_ethdev.c       |   2 +-
 drivers/net/netvsc/hn_nvs.c          |   2 +-
 drivers/net/netvsc/hn_rndis.c        |   2 +-
 drivers/net/netvsc/hn_rxtx.c         |   2 +-
 drivers/net/netvsc/hn_vf.c           |   2 +-
 10 files changed, 120 insertions(+), 91 deletions(-)
 create mode 100644 drivers/bus/vmbus/bus_vmbus_driver.h
  

Patch

diff --git a/drivers/bus/vmbus/bus_vmbus_driver.h b/drivers/bus/vmbus/bus_vmbus_driver.h
new file mode 100644
index 0000000000..3424e791c9
--- /dev/null
+++ b/drivers/bus/vmbus/bus_vmbus_driver.h
@@ -0,0 +1,106 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018, Microsoft Corporation.
+ * All Rights Reserved.
+ */
+
+#ifndef BUS_VMBUS_DRIVER_H
+#define BUS_VMBUS_DRIVER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_bus_vmbus.h>
+#include <rte_compat.h>
+#include <rte_dev.h>
+
+struct vmbus_channel;
+struct vmbus_mon_page;
+
+/** Maximum number of VMBUS resources. */
+enum hv_uio_map {
+	HV_TXRX_RING_MAP = 0,
+	HV_INT_PAGE_MAP,
+	HV_MON_PAGE_MAP,
+	HV_RECV_BUF_MAP,
+	HV_SEND_BUF_MAP
+};
+#define VMBUS_MAX_RESOURCE 5
+
+/**
+ * A structure describing a VMBUS device.
+ */
+struct rte_vmbus_device {
+	RTE_TAILQ_ENTRY(rte_vmbus_device) next; /**< Next probed VMBUS device */
+	const struct rte_vmbus_driver *driver; /**< Associated driver */
+	struct rte_device device;              /**< Inherit core device */
+	rte_uuid_t device_id;		       /**< VMBUS device id */
+	rte_uuid_t class_id;		       /**< VMBUS device type */
+	uint32_t relid;			       /**< id for primary */
+	uint8_t monitor_id;		       /**< monitor page */
+	int uio_num;			       /**< UIO device number */
+	uint32_t *int_page;		       /**< VMBUS interrupt page */
+	struct vmbus_channel *primary;	       /**< VMBUS primary channel */
+	struct vmbus_mon_page *monitor_page;   /**< VMBUS monitor page */
+
+	struct rte_intr_handle *intr_handle;    /**< Interrupt handle */
+	struct rte_mem_resource resource[VMBUS_MAX_RESOURCE];
+};
+
+/**
+ * Initialization function for the driver called during VMBUS probing.
+ */
+typedef int (vmbus_probe_t)(struct rte_vmbus_driver *,
+			    struct rte_vmbus_device *);
+
+/**
+ * Initialization function for the driver called during hot plugging.
+ */
+typedef int (vmbus_remove_t)(struct rte_vmbus_device *);
+
+/**
+ * A structure describing a VMBUS driver.
+ */
+struct rte_vmbus_driver {
+	RTE_TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */
+	struct rte_driver driver;
+	vmbus_probe_t *probe;               /**< Device Probe function. */
+	vmbus_remove_t *remove;             /**< Device Remove function. */
+
+	const rte_uuid_t *id_table;	    /**< ID table. */
+};
+
+/**
+ * Register a VMBUS driver.
+ *
+ * @param driver
+ *   A pointer to a rte_vmbus_driver structure describing the driver
+ *   to be registered.
+ */
+__rte_internal
+void rte_vmbus_register(struct rte_vmbus_driver *driver);
+
+/**
+ * Unregister a VMBUS driver.
+ *
+ * @param driver
+ *   A pointer to a rte_vmbus_driver structure describing the driver
+ *   to be unregistered.
+ */
+__rte_internal
+void rte_vmbus_unregister(struct rte_vmbus_driver *driver);
+
+/** Helper for VMBUS device registration from driver instance */
+#define RTE_PMD_REGISTER_VMBUS(nm, vmbus_drv)		\
+	RTE_INIT(vmbusinitfn_ ##nm)			\
+	{						\
+		(vmbus_drv).driver.name = RTE_STR(nm);	\
+		rte_vmbus_register(&vmbus_drv);		\
+	}						\
+	RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUS_VMBUS_DRIVER_H */
diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build
index 3892cbf67f..34988d1d84 100644
--- a/drivers/bus/vmbus/meson.build
+++ b/drivers/bus/vmbus/meson.build
@@ -8,6 +8,7 @@  endif
 
 
 headers = files('rte_bus_vmbus.h','rte_vmbus_reg.h')
+driver_sdk_headers = files('bus_vmbus_driver.h')
 
 sources = files(
         'vmbus_bufring.c',
diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h
index 600530c4f6..e33424675c 100644
--- a/drivers/bus/vmbus/private.h
+++ b/drivers/bus/vmbus/private.h
@@ -10,10 +10,10 @@ 
 #include <sys/uio.h>
 
 #include <bus_driver.h>
+#include <bus_vmbus_driver.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
diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h
index 763c077623..03894a5d46 100644
--- a/drivers/bus/vmbus/rte_bus_vmbus.h
+++ b/drivers/bus/vmbus/rte_bus_vmbus.h
@@ -27,68 +27,12 @@  extern "C" {
 #include <rte_uuid.h>
 #include <rte_debug.h>
 #include <rte_interrupts.h>
-#include <rte_dev.h>
 #include <rte_vmbus_reg.h>
 
 /* Forward declarations */
 struct rte_vmbus_device;
 struct rte_vmbus_driver;
 struct vmbus_channel;
-struct vmbus_mon_page;
-
-/** Maximum number of VMBUS resources. */
-enum hv_uio_map {
-	HV_TXRX_RING_MAP = 0,
-	HV_INT_PAGE_MAP,
-	HV_MON_PAGE_MAP,
-	HV_RECV_BUF_MAP,
-	HV_SEND_BUF_MAP
-};
-#define VMBUS_MAX_RESOURCE 5
-
-/**
- * A structure describing a VMBUS device.
- */
-struct rte_vmbus_device {
-	RTE_TAILQ_ENTRY(rte_vmbus_device) next; /**< Next probed VMBUS device */
-	const struct rte_vmbus_driver *driver; /**< Associated driver */
-	struct rte_device device;              /**< Inherit core device */
-	rte_uuid_t device_id;		       /**< VMBUS device id */
-	rte_uuid_t class_id;		       /**< VMBUS device type */
-	uint32_t relid;			       /**< id for primary */
-	uint8_t monitor_id;		       /**< monitor page */
-	int uio_num;			       /**< UIO device number */
-	uint32_t *int_page;		       /**< VMBUS interrupt page */
-	struct vmbus_channel *primary;	       /**< VMBUS primary channel */
-	struct vmbus_mon_page *monitor_page;   /**< VMBUS monitor page */
-
-	struct rte_intr_handle *intr_handle;    /**< Interrupt handle */
-	struct rte_mem_resource resource[VMBUS_MAX_RESOURCE];
-};
-
-/**
- * Initialization function for the driver called during VMBUS probing.
- */
-typedef int (vmbus_probe_t)(struct rte_vmbus_driver *,
-			    struct rte_vmbus_device *);
-
-/**
- * Initialization function for the driver called during hot plugging.
- */
-typedef int (vmbus_remove_t)(struct rte_vmbus_device *);
-
-/**
- * A structure describing a VMBUS driver.
- */
-struct rte_vmbus_driver {
-	RTE_TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */
-	struct rte_driver driver;
-	vmbus_probe_t *probe;               /**< Device Probe function. */
-	vmbus_remove_t *remove;             /**< Device Remove function. */
-
-	const rte_uuid_t *id_table;	    /**< ID table. */
-};
-
 
 /**
  * Scan the content of the VMBUS bus, and the devices in the devices
@@ -357,15 +301,6 @@  void rte_vmbus_set_latency(const struct rte_vmbus_device *dev,
 			   const struct vmbus_channel *chan,
 			   uint32_t latency);
 
-/**
- * Register a VMBUS driver.
- *
- * @param driver
- *   A pointer to a rte_vmbus_driver structure describing the driver
- *   to be registered.
- */
-void rte_vmbus_register(struct rte_vmbus_driver *driver);
-
 /**
  * For debug dump contents of ring buffer.
  *
@@ -374,24 +309,6 @@  void rte_vmbus_register(struct rte_vmbus_driver *driver);
  */
 void rte_vmbus_chan_dump(FILE *f, const struct vmbus_channel *chan);
 
-/**
- * Unregister a VMBUS driver.
- *
- * @param driver
- *   A pointer to a rte_vmbus_driver structure describing the driver
- *   to be unregistered.
- */
-void rte_vmbus_unregister(struct rte_vmbus_driver *driver);
-
-/** Helper for VMBUS device registration from driver instance */
-#define RTE_PMD_REGISTER_VMBUS(nm, vmbus_drv)		\
-	RTE_INIT(vmbusinitfn_ ##nm)			\
-	{						\
-		(vmbus_drv).driver.name = RTE_STR(nm);	\
-		rte_vmbus_register(&vmbus_drv);		\
-	}						\
-	RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/bus/vmbus/version.map b/drivers/bus/vmbus/version.map
index 3cadec7fae..fb7bed747d 100644
--- a/drivers/bus/vmbus/version.map
+++ b/drivers/bus/vmbus/version.map
@@ -16,13 +16,18 @@  DPDK_22 {
 	rte_vmbus_map_device;
 	rte_vmbus_max_channels;
 	rte_vmbus_probe;
-	rte_vmbus_register;
 	rte_vmbus_scan;
 	rte_vmbus_set_latency;
 	rte_vmbus_sub_channel_index;
 	rte_vmbus_subchan_open;
 	rte_vmbus_unmap_device;
-	rte_vmbus_unregister;
 
 	local: *;
 };
+
+INTERNAL {
+	global:
+
+	rte_vmbus_register;
+	rte_vmbus_unregister;
+};
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 0aedecd358..ccc06bdda6 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -32,7 +32,7 @@ 
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <bus_driver.h>
-#include <rte_bus_vmbus.h>
+#include <bus_vmbus_driver.h>
 #include <rte_alarm.h>
 
 #include "hn_logs.h"
diff --git a/drivers/net/netvsc/hn_nvs.c b/drivers/net/netvsc/hn_nvs.c
index b90280c9ff..817fb06dfb 100644
--- a/drivers/net/netvsc/hn_nvs.c
+++ b/drivers/net/netvsc/hn_nvs.c
@@ -29,7 +29,7 @@ 
 #include <rte_memory.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
-#include <rte_bus_vmbus.h>
+#include <bus_vmbus_driver.h>
 
 #include "hn_logs.h"
 #include "hn_var.h"
diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 1b63b27e0c..20f75a17b0 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -27,7 +27,7 @@ 
 #include <rte_memory.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
-#include <rte_bus_vmbus.h>
+#include <bus_vmbus_driver.h>
 
 #include "hn_logs.h"
 #include "hn_var.h"
diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 909c07a4ab..61cf374224 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -27,7 +27,7 @@ 
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <rte_net.h>
-#include <rte_bus_vmbus.h>
+#include <bus_vmbus_driver.h>
 #include <rte_spinlock.h>
 
 #include "hn_logs.h"
diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c
index cce0a79edb..40981706d5 100644
--- a/drivers/net/netvsc/hn_vf.c
+++ b/drivers/net/netvsc/hn_vf.c
@@ -19,7 +19,7 @@ 
 #include <ethdev_driver.h>
 #include <rte_lcore.h>
 #include <rte_memory.h>
-#include <rte_bus_vmbus.h>
+#include <bus_vmbus_driver.h>
 #include <rte_pci.h>
 #include <bus_pci_driver.h>
 #include <rte_log.h>