From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v5 07/12] vdev: implement hotplug functionality Date: Mon, 26 Jun 2017 02:22:05 +0200 Message-ID: References: Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 602FA378E for ; Mon, 26 Jun 2017 02:22:33 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id r103so131768896wrb.0 for ; Sun, 25 Jun 2017 17:22:33 -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" Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 52528ef..22e4640 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -38,11 +38,13 @@ #include #include +#include #include #include #include #include #include +#include /** Double linked list of virtual device drivers. */ TAILQ_HEAD(vdev_device_list, rte_vdev_device); @@ -350,10 +352,44 @@ vdev_find_device(rte_dev_cmp_t cmp, const void *data) return NULL; } +static struct rte_device * +vdev_plug(struct rte_devargs *da) +{ + struct rte_vdev_device *dev; + int ret; + + ret = rte_vdev_init(da->virt.drv_name, da->args); + if (ret) { + rte_errno = -ret; + return NULL; + } + dev = find_vdev(da->virt.drv_name); + return &dev->device; +} + +static int +vdev_unplug(struct rte_device *dev) +{ + struct rte_devargs *da; + int ret; + + da = dev->devargs; + if (da == NULL) { + rte_errno = EINVAL; + return -1; + } + ret = rte_vdev_uninit(da->virt.drv_name); + if (ret) + rte_errno = -ret; + return ret; +} + static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, .find_device = vdev_find_device, + .plug = vdev_plug, + .unplug = vdev_unplug, }; RTE_INIT(rte_vdev_bus_register); -- 2.1.4