From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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=jXByANtx3TEjYBUjtago4EcMGw60iEUk7leDf0mIijk=; b=M7Pd7sqD1ybUvK5qU/xXCfDqkdyRzbzcXmmKl2FmitPZWQ5QNBSDvLWTT4AAQbxNAs q9KfRjFYrfGGF2pma38uFcGPCs2OgWkpBxGOkS00XnrjqDxAGZa/ZrJu0mcNEknMhI4C VRlSE6XVSrpWYToZQkpMPhNU1aLxH54d7qmD2QKZUeJwUkEJz+gRAqi/DGNgckT+8mq0 aESHc2cZr1DN/iW96DEHHo8pob+xm46AAXQrtVlzwUevb4XpTGoB1CIF9AC5pCiZNoAr PrBl9Xv9BJfMJK9ZFnfpB9XFEBjfTvWL1EXJAsWoJueG1zHq4AjPtV5ehHTfvXPWNKgj cuuw== 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=jXByANtx3TEjYBUjtago4EcMGw60iEUk7leDf0mIijk=; b=rUalwei2f+zAUwqx1bR3WsnAOdmVl/WS9rzmKpztLvsXVLjV2N4Bjr4gzolRKQ3OUh qU9wmgQe4i9QkiaHx5CGSVmRMzDr46jUj+TTBABrgo6FevgiTHHNgbljwrItcvehCzaI sN1yMm5N44aEZ442hDq0PQ/JPdMjItcHZcaYvMffi2I1NUUUGjimDlMa6gInUD+q4eoh RGjSU2zq/XZaSf5H5x1fYFY8fnvnUGls4SGp8hADHzwOTZphA9GItQheerpTm5atfPcE /QvkEBEdCmLb0yuP0T1cq4nuP4Cab/T7xcjVji8Q9UDT7HTnlp27m7dHOoS9hRNt+Ttl fFjQ== X-Gm-Message-State: AKS2vOwrmvkBH7Ut7Yvo6ShGTLx1tnwfEaKFgGg0Zd9Ev4Wbm3muMZq/ aqfbirkxeCPhZn1qs58= X-Received: by 10.223.135.68 with SMTP id 4mr1285145wrz.141.1498436552847; Sun, 25 Jun 2017 17:22:32 -0700 (PDT) Received: from bidouze.dev.6wind.com ([62.23.145.78]) by smtp.gmail.com with ESMTPSA id 19sm16061626wrx.26.2017.06.25.17.22.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:31 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:05 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 07/12] vdev: implement hotplug functionality 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, 26 Jun 2017 00:22:34 -0000 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