From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id CBC2B7CEC for ; Wed, 24 May 2017 17:05:46 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id b84so67768441wmh.0 for ; Wed, 24 May 2017 08:05: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=U/bgdh9oqGmltJwjIkvZVsc+sNPLcCVhIrE8QViQ3hw=; b=ynNkIolPDMWCizL7Uy7qKGK+yHF4AvoemCW+SpQkn5lTf8Btc4zdAJhlKU1aSLrFFH UJzLTPkSWsdqhht9QcFgsdj64uCf8/D+Ni8LTrxzCAenxxzpDtosYqhT41eHmMKk+NYk uZQxZ5rF7an2HudJOLrv70QN3HxEO3/6Ltcp9BM9G0vW9Zpjpkna2Yb76Ykj9Uo1xou7 tYtZRtRrvzo41qZuQX6Ala9La3ehLwfK3ZyQoBZdz9eZ2Ol5KIBSnAt4dzkgDbmpTVwV SXl+Bzjqsy7Zf6CSkvXs8EhRFlFgyGm0Ln4G3mI+YImfVgZeWK2+ci7puvQIpO122pQB V2FA== 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=U/bgdh9oqGmltJwjIkvZVsc+sNPLcCVhIrE8QViQ3hw=; b=Y6i6nubDUdDIOojICC9sB4IbswsbnqQbj5H8NfDrwq6LVT86at7cE/v+9HWu0lK91Q rcZbTUfeR5zMIgxVzmvcBLFlapocBUF10PAJX+b1fA08JZWaLcS3LYDpgjTRRbgp2Xt+ 5TuVLzDw+J1i8qrqpf6AFrRtKrickkUpWLGJg1eZfaVt5zQJJXfoFN6wFdsJfGFu73sH JXRwKorORZ7Hp34HTKQWCYHkI6fEVjVwwhZ9OMzKNdF9Cg1/2Obm3C8QZvw+9wepN0fZ w0erpgwWD4d5yvyP3Yu0LAPNi/ef/HDCByHpz1+n6+D1TFVFcbIadgVes9Ba27l3TugR yl6A== X-Gm-Message-State: AODbwcCYPvMOmESLxdaW1QQITwYFDYTJs9qOSYqgHg9Z1IU5tZWgZQYp 9tFGeb3skvMYrjLaK7k= X-Received: by 10.28.198.13 with SMTP id w13mr6225069wmf.9.1495638345814; Wed, 24 May 2017 08:05:45 -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 25sm4076017wrz.8.2017.05.24.08.05.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:05:45 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Wed, 24 May 2017 17:05:01 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 9/9] 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: Wed, 24 May 2017 15:05:47 -0000 From: Jan Blunck 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 | 11 +++++++ lib/librte_ether/rte_ethdev.c | 3 +- 4 files changed, 39 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 21640d6..150b0f7 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 c2d0f8d..829d7f3 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -100,6 +100,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->detach) { + RTE_LOG(ERR, EAL, "Bus function not supported\n"); + return -ENOTSUP; + } + + ret = bus->detach(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; @@ -110,8 +134,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"); @@ -124,20 +146,5 @@ 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->detach) { - RTE_LOG(ERR, EAL, "Bus function not supported\n"); - return -ENOTSUP; - } - - ret = bus->detach(dev); - if (ret) - RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", - name); - return ret; + return rte_eal_device_detach(dev); } diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index de20c06..7092b16 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -123,6 +123,17 @@ struct rte_mem_resource { void *addr; /**< Virtual address, NULL when not mapped. */ }; +/* FIXME: Forward declare */ +struct rte_device; + +/** + * 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); + /** * A structure describing a device driver. */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 83898a8..ff4f5ab 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -440,7 +440,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.1.4