From patchwork Sat Jul 15 17:56:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 26945 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1876E5688; Sat, 15 Jul 2017 19:57:05 +0200 (CEST) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id 0F2932A5D for ; Sat, 15 Jul 2017 19:56:59 +0200 (CEST) Received: by mail-wm0-f54.google.com with SMTP id f67so49031802wmh.1 for ; Sat, 15 Jul 2017 10:56: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=swuOETYV2iheihbFuj1hJDStCDQ5VKHoOuI6l2svA5w=; b=nnG3Zr4wDzx8VmVZbctjIeSFA3qnBTtzqumFOL4cX1N4kXO8/7JIVVOv5b1hbeQIov XRXPYiXHx3ZtM16ZBBMvnZuGmcoyCKkSiHFpw7600Fwc3av3PPxEuRfbawzKXKjtVpck KSbW2Xvce0UKroAtax6F0JV7HjKJwO7ZP0tVXbyMSuQPkgpWvpPz0kcUuGqMt2+n1Aaw zGSbYSSzfOKA7DFZ2LE7PeznriXXlQzGYsrtqt+TnRRli9RpTLkIBVJsGeqzAyME02v9 VG6QkTBcaMx/my8sxt8Mfi7S7vrSQQ4ITrFZN6U5TC9Hq4L8uQbL8xM2n5j91I9VclFp tYOA== 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=swuOETYV2iheihbFuj1hJDStCDQ5VKHoOuI6l2svA5w=; b=gT72sNDIPSNZXVexuPCoVOkNEWvOMKDpymZbwK3fHD9qEx7vlK07ULzgCA3aK+8JaG rUNwacd4r20sIakfY2qzD2ksWX7RkyTXFgkfJ40wypt/jKAnNqeLnmscLUBEJpijW2of S+C7386bq0yaUeEM2Roab2MFoXntL6Qgfed6atSDr6Nmx8vww//BHSq/Uj2gbtacoQxB RE/UABurjHvQx6MEuUpOBOi7wdUNkukv//5U1a6l07ycKIlgEuyr7HhPNLNgXG6qRkIc e48nJ9zbD6Ms1vOpnPrjnMdFy6uoatLPSrtE+Pa4kCPEq+DPAz1KJQWp7IgVWcNBT6Zu XVjQ== X-Gm-Message-State: AIVw111CcCHB481SRxN6VUgzGrNpg+mJ1mtPcZBV3gotBxkzQ0eM1lF3 4rOtolUJSXEqEt+96BE= X-Received: by 10.28.133.209 with SMTP id h200mr1590530wmd.20.1500141419156; Sat, 15 Jul 2017 10:56:59 -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 79sm2479445wmj.2.2017.07.15.10.56.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Jul 2017 10:56:57 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sat, 15 Jul 2017 19:56:35 +0200 Message-Id: <86dc328887222ac3591a5d280196922e986a59d2.1499964391.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 v4 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: , 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 e00dda9..85cf3fc 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -319,12 +319,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); } @@ -332,7 +334,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 fc24298..29f5a52 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) {