From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id C0DEC58CD for ; Sun, 9 Jul 2017 03:46:07 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id c11so93720587wrc.3 for ; Sat, 08 Jul 2017 18:46:07 -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=tQQ1VjFY6KUPY6oP4+s5F06+SVs2aCeanKxUFUJCWOE=; b=Ov1gWTEk3rl++i85OFqbrL9DWoOZDiRsKL5rYR9MfW0BZw/PoU6ItBecREvPb9B1mR GJaG+HEn/1DWoVmsIeAszQQvk+mJUJppCktcJWy7xkV8GSFNUPyErg+OcwKCkUgKaJLH WplZPM/J3zDhep/xXdzfX/3RgN+UqZpD9jxtds7FkDki5DwxvMLKPzITLGuwFzyKM7nU rnnIplqlCeZyXgkXfuaD/nWcSmn99IdbrAuKUIuzSD9hzRGmVAlqnRAUP3DToyo9wnbi 8S1NxAI7eYCGeK+8Ih7vPgHFpASNdQlwQxM2I8BsRDf0tu497nn8iIbLfq92fwRd+Lld PayQ== 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=tQQ1VjFY6KUPY6oP4+s5F06+SVs2aCeanKxUFUJCWOE=; b=PNwetcZfDMAGgDQ+aO39DSsZf6WX9+J893UursZHBXpQ0gTh5gAtQMWrk7wx7ZCL0A 3nKy7aZ9Z0/fKlTM5QrN4qOIQcQPalpb+Q6QFqRY3UHxDeWx9gSgwkwa8Cij3dRICDZM XA1gOtpsX5oeqUL+VRjIk/hIiyASWL3Qg91+nhifbz6vzsAk3NdTVs+DxPUKnQAYHrs0 xisd3mhz3jgnsD03hg0NPKE7W7UwhR/ofSJKKjx8mcO4L67gTmumqT54zf5OMLx1hi+y t8Nqh8snvjG0VcNK/LbufkjZCx6fE//MYpkP6oRiu6X0R/+8L0o6V6A8kALjlRMv53FY bZLQ== X-Gm-Message-State: AIVw111BbNxuxSoudOHF7LK/xoJGer1bNzzVCI0aLOvMV4DUAWI6MLRc fekRwNH6oNEEuZExPLA= X-Received: by 10.223.151.216 with SMTP id t24mr4314565wrb.40.1499564767200; Sat, 08 Jul 2017 18:46:07 -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 h130sm2430609wmd.34.2017.07.08.18.46.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 08 Jul 2017 18:46:06 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sun, 9 Jul 2017 03:45:44 +0200 Message-Id: <050ea7480426c18c158efb45e4beeca9262c890f.1499563730.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 8/9] 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: Sun, 09 Jul 2017 01:46:08 -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 5d81ca8..f8b48b5 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -354,12 +354,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); } @@ -367,7 +369,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