From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v2 1/8] vdev: implement plug operation Date: Tue, 11 Jul 2017 01:19:00 +0200 Message-ID: <4baa44f76517c871e69d9c18f4b73acbcd013238.1499728330.git.gaetan.rivet@6wind.com> References: Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id D975D374C for ; Tue, 11 Jul 2017 01:19:25 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id c11so159265724wrc.3 for ; Mon, 10 Jul 2017 16:19:25 -0700 (PDT) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This method must be implemented to allow using a unified, generic API to hotplug devices, including virtual ones. VDEV devices actually exist unattached after performing a scan on the rte_devargs list. As such it makes sense to be able to perform a device hotplug afterward. Finally, missing this generic interface forces the EAL to be dependent on vdev-specific API, which hinders the plan of moving the vdev bus to drivers/bus. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 12 +++++++----- lib/librte_eal/common/include/rte_vdev.h | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 2ca0cdb..79bb795 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -316,12 +316,14 @@ vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, } static int +vdev_plug(struct rte_device *dev, const char *args __rte_unused) +{ + return vdev_probe_all_drivers(RTE_DEV_TO_VDEV(dev)); +} + +static int vdev_unplug(struct rte_device *dev) { - /* - * The virtual bus doesn't support 'unattached' devices so this is - * actually equal to hotplugging removal of it. - */ return rte_vdev_uninit(dev->name); } @@ -329,7 +331,7 @@ static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, .find_device = vdev_find_device, - /* .plug = NULL, see comment on vdev_unplug */ + .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse, }; diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 3c07b76..639e6d6 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -46,6 +46,13 @@ struct rte_vdev_device { struct rte_device device; /**< Inherit core device */ }; +/** + * @internal + * Helper macro for drivers that need to convert to struct rte_vdev_device. + */ +#define RTE_DEV_TO_VDEV(ptr) \ + container_of(ptr, struct rte_vdev_device, device) + static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) { -- 2.1.4