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 0F6045A98 for ; Fri, 30 Jun 2017 20:20:16 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id p204so9336733wmg.1 for ; Fri, 30 Jun 2017 11:20:16 -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=WrSjxXC7zUMnvsH1doPSJXJwv5bpv7b2xnXmf4X4JAQ=; b=oeN87OgbAks2+1p8Oz6vjnzGeHnGxXudGfqZ76Gat22diOG2D0KTrf6xfwOm/EYZZP WjQMiIJzBAO7nv9JGt1tajq20ffjXRpk/KpAJUEp14Mm0gksEVoGiGIVd8zmYNuhWRYI 7g56QSu4WcQ03m2KiDQOWWEdbDdAEnt82NNdFl6oqviqTcQ2Y9vgmUG6ZZHVW5GNjG2T xBGNByXefUQH6Xv6ntKpogx8frJf/V2rXamDa63LJhUhiOENJ9D1OLFChEo98v9l4o9q OKmlK1eJlCUlhY7bqpVCGSHcNvaF1LOu9RljhDaDMzVaZbQ+lzen49xEBR+GIMNNsMLn T0GA== 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=WrSjxXC7zUMnvsH1doPSJXJwv5bpv7b2xnXmf4X4JAQ=; b=CuMQbYr8Gj2OIOsiRGHZHCCqBWMiOKSQSbB8osSerw41BbVhsHA8mh5hKzihM0PXwr +554YKRIfzmjpggIj3TNFI3KFUs2rD9oxhh4dbz8xKDl2488hQbYJfZNSRtXYK87LcxV JH2SCZQofdUfh/xvVxdYvwRQvRwhUqs0dEDbzeWkXkUZmHXx+VwcsA5W2F6cSIy+bd6z kWN7plTcTMbghqJwYs2CbDmGvdi7K+z+KHgGZ2bh/ULgPkp08KZJzWUvz1xZLbkK0cVm 5hw9SZC3xR/B3aZEIcREvfZl6MKiJgv2UdHlrSDqNC1lJisB+MSA6YraSfewha8QeErC 6y7Q== X-Gm-Message-State: AKS2vOyfSg3PA5kjviUhBb+pNXgQfu1BQQFX9i9oohKUd3ahEWOJG+fC tomQuabxJErEw/dD X-Received: by 10.80.168.70 with SMTP id j64mr4395777edc.110.1498846816290; Fri, 30 Jun 2017 11:20:16 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:15 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Fri, 30 Jun 2017 20:19:42 +0200 Message-Id: <20170630181943.23929-14-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v8 13/14] 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: Fri, 30 Jun 2017 18:20:17 -0000 This is changing the API of rte_eal_dev_detach(). Signed-off-by: Jan Blunck --- app/test-pmd/testpmd.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 32 +++++++++++++++++++------------- lib/librte_eal/common/include/rte_dev.h | 7 +++---- lib/librte_ether/rte_ethdev.c | 3 ++- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index b29328a..86d494b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1824,7 +1824,7 @@ rmv_event_callback(void *arg) else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI) rte_pci_device_name(&da->pci.addr, name, sizeof(name)); printf("removing device %s\n", name); - rte_eal_dev_detach(name); + rte_eal_dev_detach(dev->device); dev->state = RTE_ETH_DEV_UNUSED; } diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 3606332..ede68e4 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -90,27 +90,33 @@ int rte_eal_dev_attach(const char *name, const char *devargs) return -EINVAL; } -int rte_eal_dev_detach(const char *name) +int rte_eal_dev_detach(struct rte_device *dev) { - struct rte_pci_addr addr; + struct rte_bus *bus; + int ret; - if (name == NULL) { + if (dev == NULL) { RTE_LOG(ERR, EAL, "Invalid device provided.\n"); return -EINVAL; } - if (eal_parse_pci_DomBDF(name, &addr) == 0) { - if (rte_pci_detach(&addr) < 0) - goto err; - } else { - if (rte_vdev_uninit(name)) - goto err; + bus = rte_bus_find_by_device(dev); + if (bus == NULL) { + RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", + dev->name); + return -EINVAL; } - return 0; -err: - RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name); - return -EINVAL; + if (bus->unplug == NULL) { + 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; } 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 a0d67d0..9f2765d 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -183,13 +183,12 @@ int rte_eal_dev_attach(const char *name, const char *devargs); /** * Detach a device from its driver. * - * @param name - * Same description as for rte_eal_dev_attach(). - * Here, eal will call the driver detaching function. + * @param dev + * A pointer to a rte_device structure. * @return * 0 on success, negative on error. */ -int rte_eal_dev_detach(const char *name); +int rte_eal_dev_detach(struct rte_device *dev); /** * @warning diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 81a45c0..6554378 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_dev_detach(rte_eth_devices[0].device); if (ret < 0) goto err; -- 2.9.4