From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by dpdk.org (Postfix) with ESMTP id 80F0D4C57 for ; Wed, 21 Jun 2017 01:29:54 +0200 (CEST) Received: by mail-wr0-f171.google.com with SMTP id c11so55993334wrc.3 for ; Tue, 20 Jun 2017 16:29:54 -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=vVQjpLhNbjleHEDvy7A8Z9k9s2oXuTxCY6TrGLOXMocRKs3QEemnlo85i+IJvFtPH2 xJY76fbmZY37QinO3diwktr0nQFr06NYmYbvMrbb7/aHn/kglEiv5Y4qR67HIs8ymJIG BZ8Vt6u+ZCvt1ZJ++TXLHTJfNOM88NjPLf6vlWGcZkoh6JZ7kQx39Qoe5cocaV9a6bex wf+3dkmQzMttBQHQKsdHKlHisJKehSgAY0hvohFpEcGTK5JUPeca1H+xSO/nGHjY7yLC KR7oWuzzYLaGoJglunNTSaDjoEbXPvV0nia3T3CxF3Zn9DMJP2/LpdvSp6Yu72pmHbLX PLtA== 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=HXK9454oNQ/Q5sefBHVkQzkKAMBrytpSX6wUEtmCcbVx+Gb9rGb/Z1hcjMHbcm5VsM 4/5/Nx11U6Y4mt9L63F8FMhZb23ZrAZbBdV3mo68SHLzHJFsFjPb3y1IfdiD086pRcZY JQPbSez2NdaPwInu9BVw5FAgsHzd35h/2chbrcvPCngfnSFF4HsDh4vtfBGibmoORtj3 NpO3LiwWHf8v3cTDHxIqBWqZa44Q89k54XzGmgwNW1a1gIuU4K9VJirRy3a1wfA2I8PZ acys6kqTKZbU2fxLpyCvUj0Kmud0maRmCf2Rl1xrJFFP0TACqhb650svjx7ZzW+vcLWA 2eFg== X-Gm-Message-State: AKS2vOw8ogSZbKLJ+H/rKTlGkonlm0RyceHRCtY5TQ7SXgIX5zwxND1L DzZzOGLmTvJJwgbLsZ4= X-Received: by 10.223.147.98 with SMTP id 89mr21107300wro.103.1498001394016; Tue, 20 Jun 2017 16:29:54 -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 l127sm8592248wml.26.2017.06.20.16.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:29:53 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Jun 2017 01:29:28 +0200 Message-Id: <7a8fafb7f2fbc550b008f7e537270411c736e1c2.1497999601.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 7/9] 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: Tue, 20 Jun 2017 23:29:55 -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