From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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=q39ENitJyx0dG3TLf/t9e9/Cf8pxgOKI/4a0uHDob79IHV4zgHVMaGzfIZM+FP51QI nzrRlbanQoQpa8ihUwbLunY3E4Wrb1c0b4RzPMTzak8VLBjhorVaSbUZPOPLD3WoKogu rp7gMnpNY08aCkmhGIDP6jXvTybBeOQ4KeJX57yWLFc3o28EvnF9NhqnR2AvALm3Y+bj e2lGFnXoK+tfQadZdNv4Z4IAFZ/fK3klgnNEtc6Y47mBEyD6mKsSzVNe/poZf3D+jJIO OThTUPC/IkrqcXYF6nHcq2O9sDVSc8TAmQsgLVbks94bWuKikqaVG/4hbuvBhi4Hw/RI O93Q== 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=JFLIVCcnzQC+cJjRXEM7x7hKnFjfKeE8gQnOgIHY6Wgyzx4XPButEFSLL/c2rgys4g kVt56YS9MITtY1mSrmcPQD8dOwW2aeqpt+DmO4+So8XwfDLL8olm8SK1Rh7Aaf7sX9LE ohRbDQ8qSlehWqIqzDea0HO8t5qDQDiHVsJCDGfbBjo8ud1FLOiKB6MyQSIlEwT/7Boo J+2FNn6EJ4t/FvljgfUV3jKXxQuYf/TCZR22u44+X6LsY3hpfd/2DbHhZYOQMv839hMI aF64e770YnzxuT8jZj3/fcfVWF/0fuskGlNZ7qYF01g+nzKblEzS8Qf/g3/nNR6N+z+E AgFA== X-Gm-Message-State: AIVw1112Io1y7+yXNmaG+0d3WD1jOkdqJvW2vEE6pa5R9toOBfJUiU2A UdtYnAiWCP/+y1qanGg= X-Received: by 10.28.31.203 with SMTP id f194mr372345wmf.44.1499728765290; Mon, 10 Jul 2017 16:19:25 -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 j190sm43773wmd.22.2017.07.10.16.19.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 16:19:24 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 11 Jul 2017 01:19:00 +0200 Message-Id: <4baa44f76517c871e69d9c18f4b73acbcd013238.1499728330.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 v2 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: Mon, 10 Jul 2017 23:19:26 -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