From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 4379E7CC3 for ; Wed, 12 Jul 2017 01:25:59 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id k67so9799517wrc.2 for ; Tue, 11 Jul 2017 16:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=jB0FIT/2TkKRiNPr2YXwZNZq0U7Agwdgmhn68k8tAls=; b=xGOK9Ui0rFhXftCXxEVkPYs1Ml8y2aStBQnPLwVEHBJ+N1IUFqlZyaxOT7Kx1alYxq w56n4Ig+cDGk/o8x7Q9rUaXzmEUJlLaAR14ZoFY42QhbkPAfCTiEgdWmOaBpyhusVw+O tzpwyMdSor67tZ0gA0LGEt2UQW51FMGqcoO7R+u5sXWnKwB5iqRtbx64vZOxRzhaAFCA Lf4cbNddJowigcKkZ1yZz/jVz1ct2bdxG4rb4iVWG6jVfIRb7lhYBa4LnvBaKMCCB7qI Lmq9O7UcPpfpop8LYMJLevHMsbrBPoTle4HuPZ6J6Ztim98HCgIO7JAONH//QJ9/VYyJ 8Phg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=jB0FIT/2TkKRiNPr2YXwZNZq0U7Agwdgmhn68k8tAls=; b=Llj/imm8kuzPTYos1aLqm544gOcSdSvAMT7wFZJIQ7mvlTYcMbTZ9WYUAJ9qVdX44v 7Ryp9vii7qKfiqxfWFoB7wIeu4n52W6wwGSz4LunP2kvQIfKVnCu4jXe9RdWAFLACKh5 1WkywktNGq7e5AA5QLW83lF+SoHHl7OoUvd9bc6WqtexRO0Wb5+dI3wPjdPJWn86Sspl ibXN6VuStzb9cO2nMTXn1fJLLfbWMBFY9HcdTaEn6GZewOp9lG6uQmOBm+2ciBIv8Wnd fyLU5s6/O4Bbm1maaVhRr8wGXOiQoYR+K9AzzNNkGN03JyEQQV0UKGGhJ/pBE1IR9vqA kZ5A== X-Gm-Message-State: AIVw111AJYQNRDgFowR2GdDRc+1NZYt8dEnQG3pWFZ+ZRQVkIak9DeTb zFR59uqCnWaEKMt+X/o= X-Received: by 10.28.182.137 with SMTP id g131mr426853wmf.95.1499815558464; Tue, 11 Jul 2017 16:25:58 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 66sm407576wmj.29.2017.07.11.16.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 16:25:57 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 12 Jul 2017 01:25:35 +0200 Message-Id: <6bbc9296e7cf46a791e363ae766ae5b60e0fd450.1499814957.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 1/8] vdev: implement plug operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jul 2017 23:25:59 -0000 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