From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C63CA00C5; Thu, 28 Jul 2022 17:28:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C39242BDE; Thu, 28 Jul 2022 17:28:16 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1396E40151 for ; Thu, 28 Jul 2022 17:28:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659022092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A2rRZD3vW3lZqbMZyrmY88899Zg1jjfwQuh44IWSHi8=; b=IEcZq4UEj/S2QuxZu8g40Cv0rE0DKc/FpFEPd484JA4V4xaqhhyGUJAQYGHIPjJFf1RNWX jPWxiJ/AZ/LwZMiagaWLceYavedS0CuMv7dSg5SXQOitHHYVClvx4EcODvAdSTN54WqnbF vAbVyq+mvScXwTwBCRY/RSLAZIoqpdc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-byWfaWG3NguLaI22F0pBmg-1; Thu, 28 Jul 2022 11:28:09 -0400 X-MC-Unique: byWfaWG3NguLaI22F0pBmg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 459BD185A7BA; Thu, 28 Jul 2022 15:28:09 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.195.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 570571415118; Thu, 28 Jul 2022 15:28:08 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Stephen Hemminger , Long Li , Ray Kinsella Subject: [RFC v3 18/26] bus/vmbus: make driver-only headers private Date: Thu, 28 Jul 2022 17:26:32 +0200 Message-Id: <20220728152640.547725-19-david.marchand@redhat.com> In-Reply-To: <20220728152640.547725-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> <20220728152640.547725-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The vmbus bus interface is for drivers only. Mark as internal and move the header in the driver headers list. While at it, cleanup the code: - fix indentation, - remove unneeded reference to bus specific singleton object, - remove unneeded list head structure type, - reorder the definitions and macro manipulating the bus singleton object, - remove inclusion of rte_bus.h and fix the code that relied on implicit inclusion, Signed-off-by: David Marchand --- Changes since RFC v2: - squashed cleanup for this bus code from other patches, - updated release notes, --- doc/guides/rel_notes/release_22_11.rst | 2 +- drivers/bus/vmbus/bus_vmbus_driver.h | 106 +++++++++++++++++++++++++ drivers/bus/vmbus/linux/vmbus_uio.c | 1 - drivers/bus/vmbus/meson.build | 1 + drivers/bus/vmbus/private.h | 20 ++++- drivers/bus/vmbus/rte_bus_vmbus.h | 104 ------------------------ drivers/bus/vmbus/version.map | 9 ++- drivers/bus/vmbus/vmbus_bufring.c | 1 - drivers/bus/vmbus/vmbus_channel.c | 1 - drivers/bus/vmbus/vmbus_common.c | 3 - drivers/bus/vmbus/vmbus_common_uio.c | 1 - drivers/net/netvsc/hn_ethdev.c | 3 +- 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 +- 16 files changed, 140 insertions(+), 120 deletions(-) create mode 100644 drivers/bus/vmbus/bus_vmbus_driver.h diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index f726a901e6..c55ee19bc2 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -85,7 +85,7 @@ API Changes ======================================================= * drivers: Registering a driver on the ``auxiliary``, ``ifpga``, ``pci``, - ``vdev`` buses has been marked as an internal API. + ``vdev``, ``vmbus`` buses has been marked as an internal API. External users may still register their driver using the associated driver headers (see ``enable_driver_sdk`` meson option). 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 +#include +#include + +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/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 5db70f8e0d..26edef342d 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include 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 658303bc27..3d233fa83c 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -8,13 +8,31 @@ #include #include + +#include +#include #include #include #include -#include + +/** + * 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 a24bad831d..03894a5d46 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -27,89 +27,12 @@ extern "C" { #include #include #include -#include #include /* Forward declarations */ struct rte_vmbus_device; struct rte_vmbus_driver; -struct rte_vmbus_bus; 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, - 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; - struct rte_vmbus_bus *bus; /**< VM bus reference. */ - vmbus_probe_t *probe; /**< Device Probe function. */ - vmbus_remove_t *remove; /**< Device Remove function. */ - - const rte_uuid_t *id_table; /**< ID table. */ -}; - - -/** - * 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 @@ -378,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. * @@ -395,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 84db31b6e9..430781b29b 100644 --- a/drivers/bus/vmbus/version.map +++ b/drivers/bus/vmbus/version.map @@ -16,13 +16,18 @@ DPDK_23 { 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/bus/vmbus/vmbus_bufring.c b/drivers/bus/vmbus/vmbus_bufring.c index c4aa07b307..c78619dc44 100644 --- a/drivers/bus/vmbus/vmbus_bufring.c +++ b/drivers/bus/vmbus/vmbus_bufring.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index 9bd01679c3..5549fd0944 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index 367727367e..03b39c82b7 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -235,7 +234,6 @@ rte_vmbus_register(struct rte_vmbus_driver *driver) "Registered driver %s", driver->driver.name); TAILQ_INSERT_TAIL(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = &rte_vmbus_bus; } /* unregister vmbus driver */ @@ -243,7 +241,6 @@ void rte_vmbus_unregister(struct rte_vmbus_driver *driver) { TAILQ_REMOVE(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to VMBUS bus */ diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 882a24f869..4d4613513c 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "private.h" diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 787139c0b2..188d92ffac 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include #include #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 #include #include -#include +#include #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 #include #include -#include +#include #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 #include #include -#include +#include #include #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 #include #include -#include +#include #include #include #include -- 2.36.1