From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 1BFBD7CAF for ; Thu, 29 Jun 2017 20:22:45 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id y5so4064671wmh.3 for ; Thu, 29 Jun 2017 11:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SFBLO6h2vL8UaXzrQ43ERLB3hXR58jazD4mz36DKRmY=; b=fhWwmyLNpTdsrUU04vYjMuyoEwOaVegqHIFnKF7of6pgtvb7R7tVS7OdStMNAxpng1 Ms5gMaDg0qXdplHxirufkjBIobpoujYdsR9N2OQXlwo/pOwTwy2eluiUa+40tAhWnnDb lGtBfLf4kFnWGewYAe+qbQcustDCRkRi6vBvvK5AvJDgfrfEzKCejLPjZEnb8pzd3gU2 9nlSlxvsaEhChcUCAUP3iDZhGfnLB8o15smhfXdQIfeZkDCupaYfCWFFEMd7e3DSJqm3 kHVsgRQbFIA2nBRkwWSGvnteVJ44nPjerBE9UKfPCaS0xtgM60Xu8xJrw8kxj8ovOxAL ANgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SFBLO6h2vL8UaXzrQ43ERLB3hXR58jazD4mz36DKRmY=; b=mXK9lm68c7fIPLcj5q8zS+tm4R3tSopubAWLxL1U/iv2lVUlgSBkKOvKatGrVmwpRs vH6SI4/I4th5L3pe8I1w9tbMCSTzVAORoBwKo8HQ3uGfx+iygDr0wxp99D8GmGCWhRSR clHX5S/UCQoCvgsiUpZYs+Id/K4PuvojJXCG8dY7lRPUVPcRQzqcApXgc3ksVv+JgOSV izkyb74t1n8vBicFES95N4kkcZJ+rYvEPE34Lb8RNtebOa5QiWF526gv3N+LgnZ4M5on m077EejxR6xweI2Q6fW7LqDeXxpEnhDLDps+E9Srjq20Np3WAd3mGBTEBLq7WQAbKqnU G9pA== X-Gm-Message-State: AKS2vOw4D9u1NLjXhHuA1VPGf+yEe8jKXYKDZuoOOFPAHNILrGAkNl9P +a+8+T8nlPIM48i4 X-Received: by 10.80.170.23 with SMTP id o23mr2667941edc.164.1498760564695; Thu, 29 Jun 2017 11:22:44 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:43 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:22:06 +0200 Message-Id: <20170629182206.1072-16-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 15/15] ethdev: Use embedded rte_device to detach driver 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: Thu, 29 Jun 2017 18:22:45 -0000 Signed-off-by: Jan Blunck --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_dev.c | 43 ++++++++++++++++----------- lib/librte_eal/common/include/rte_dev.h | 8 +++++ lib/librte_ether/rte_ethdev.c | 3 +- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index b7d26b2..df7abc5 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -162,6 +162,7 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_eal_device_detach; rte_bus_find; rte_bus_find_by_device; rte_bus_find_device; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 68c6b45..3f3bfdc 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -81,6 +81,30 @@ int rte_eal_dev_attach(const char *name, const char *devargs) return ret; } +int rte_eal_device_detach(struct rte_device *dev) +{ + struct rte_bus *bus; + int ret; + + bus = rte_bus_find_by_device(dev); + if (!bus) { + RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", + dev->name); + return -EINVAL; + } + + if (!bus->unplug) { + RTE_LOG(ERR, EAL, "Bus function not supported\n"); + return -ENOTSUP; + } + + ret = bus->unplug(dev); + if (ret) + RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", + dev->name); + return ret; +} + static int cmp_dev_name(const struct rte_device *dev, const void *_name) { const char *name = _name; @@ -91,8 +115,6 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) int rte_eal_dev_detach(const char *name) { struct rte_device *dev; - struct rte_bus *bus; - int ret; if (name == NULL) { RTE_LOG(ERR, EAL, "Invalid device provided.\n"); @@ -105,22 +127,7 @@ int rte_eal_dev_detach(const char *name) return -EINVAL; } - bus = rte_bus_find_by_device(dev); - if (!bus) { - RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", name); - return -EINVAL; - } - - if (!bus->unplug) { - RTE_LOG(ERR, EAL, "Bus function not supported\n"); - return -ENOTSUP; - } - - ret = bus->unplug(dev); - if (ret) - RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", - name); - return ret; + return rte_eal_device_detach(dev); } int rte_eal_hotplug_add(const char *busname, const char *devname, diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 95440eb..a3e6d7a 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -192,6 +192,14 @@ int rte_eal_dev_attach(const char *name, const char *devargs); int rte_eal_dev_detach(const char *name); /** + * Unplug the device from the device driver. + * + * @param dev + * A pointer to a rte_device structure. + */ +int rte_eal_device_detach(struct rte_device *dev); + +/** * Hotplug add a given device to a specific bus. * * @param busname diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 81a45c0..89addc6 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -439,7 +439,8 @@ rte_eth_dev_detach(uint8_t port_id, char *name) snprintf(name, sizeof(rte_eth_devices[port_id].data->name), "%s", rte_eth_devices[port_id].data->name); - ret = rte_eal_dev_detach(name); + + ret = rte_eal_device_detach(rte_eth_devices[0].device); if (ret < 0) goto err; -- 2.9.4