From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id AC363326B for ; Thu, 8 Jun 2017 01:53:46 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id 7so127735825wmo.1 for ; Wed, 07 Jun 2017 16:53:46 -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=OKQun0Grwd/LO9QK7qn52kibgXLSzJ1LAuk3OYTB9WzoTwlGLy8H5H7qv7uvKe/svs bP+hOMiWrSu7oZ0dggovHAFaH5ch/phWwnfpJFEwQxZa8I20ZhwoY9pVUpBHSmMLH9Ca ExY88gp7dALJz6aV4HIGZEDGjWEj2hALlRWYe2oH2lL5avlLei4mCzSuycIX/iVHsCcU AYJziTtLXf97kpL9vo3bopSNGP32UIDUqsJNsgi4TVJCYb1V0jbJNdKRZdGPeaG8+RXA fmhuQeiX2nkNPbMoSji5TEq7u1hpsJ1OeWQKQ2iySWgu8qASpFSYNYv9w1z4Z/CT4Pcy C4Dg== 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=RRq/hxtEp4VUsOH7wJSU2AQ8F6/JRZFpLHkNH/ADbhKcaDpR9TN/EhmD7iRq5puNcM k2nV5hpMKPMPeZgchz6/xawHYhC1tGCQ3c1uSqNnnL9Uq6mO4QkXCx2RB2WDfpFuJkZp C+FfjJ1givCg/BKtgkFKpmcQxfMPv/pFtAbOnSef5ArQzTQ3ySCBAIlGZ42UwDmEIsBn 4F6iQb2zVu8V3yoiRJNjmsY3Mne3vWRxvq82tGpJGgmd9A+e0vJe2IZYa9HZcmiXsdd4 wVoiPZEDbdWqKDJdqor2laVafPxT+xyKlBY0Rwza6K6S20qCWqvPkn80Ktj/V68Pa6jc sPxg== X-Gm-Message-State: AODbwcCJo5Ja6PgpbFosFDDj7Twjmle+Rwpiv7h2paK+EA9VsUFminZ/ PRPTJ5JtZA+mtb/mbuM= X-Received: by 10.28.62.199 with SMTP id l190mr1430097wma.13.1496879626065; Wed, 07 Jun 2017 16:53:46 -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 z23sm4589942wrz.0.2017.06.07.16.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:53:45 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:53:21 +0200 Message-Id: <1d79bf2ce0babe9e0bced86a62ba5ff1493caf91.1496876710.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 v3 07/10] 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: Wed, 07 Jun 2017 23:53:47 -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