From patchwork Tue Dec 9 06:30:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1876 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D1B56806B; Tue, 9 Dec 2014 07:31:39 +0100 (CET) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 77FFC8079 for ; Tue, 9 Dec 2014 07:31:36 +0100 (CET) Received: by mail-pd0-f170.google.com with SMTP id v10so6676365pde.15 for ; Mon, 08 Dec 2014 22:31:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uXt/1cNxTPtKdBH98VUPG978D4NvgSsQVWq5OwleSwo=; b=cg2UdKLPIlOLa+ET85f1eddpyC808J90YErvjOSvu1322gkMOTfdevRToGoce4Yob7 hgHO8rCQlFq5805O03ZmFKUizQigd9DRZNlXArCd3rThJPGVyMx4lScDWc0r9SOtzQu3 5kGvBz9hSlmyUQm0hd+wufFk5J/lDpyjh2+x2soFXf2A+OjHlA+cJb41ogddmF+z+NqD QbqRb/M1y+fsyC80GN7YxHRW1kO1MBsc2jc+2MmvwPBh8JPqOBri0tJRMdJpEie4xriS PFuukdDWkfj6+ape6W7K9uQHV/+TLSEr8hNgiTcwAYSC/7WJfYNbT9Z2aNDM1I4HnPgX 1nvA== X-Gm-Message-State: ALoCoQngGmKxcRvRY7XvcthLWkOt6dngbRnKOVcF0/VZX508oKoI2WkY1fv9GnJrCMd6Sm7+ZCKF X-Received: by 10.70.22.208 with SMTP id g16mr27283590pdf.141.1418106695855; Mon, 08 Dec 2014 22:31:35 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id f12sm403088pat.43.2014.12.08.22.31.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 22:31:35 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 15:30:21 +0900 Message-Id: <1418106629-22227-21-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH v3 20/28] eal/pci: Add rte_eal_pci_close_one_driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The function is used for closing the specified driver and device. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/common/eal_private.h | 15 +++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index a1127ab..f892ac4 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -176,6 +176,21 @@ int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev); /** + * Munmap memory for single PCI device + * + * This function is private to EAL. + * + * @param dr + * The pointer to the pci driver structure + * @param dev + * The pointer to the pci device structure + * @return + * 0 on success, negative on error + */ +int rte_eal_pci_close_one_driver(struct rte_pci_driver *dr, + struct rte_pci_device *dev); + +/** * Init tail queues for non-EAL library structures. This is to allow * the rings, mempools, etc. lists to be shared among multiple processes * diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 8d683f5..93456f3 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -616,6 +616,67 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d return 1; } +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP) +/* + * If vendor/device ID match, call the devshutdown() function of the + * driver. + */ +int +rte_eal_pci_close_one_driver(struct rte_pci_driver *dr, + struct rte_pci_device *dev) +{ + struct rte_pci_id *id_table; + + if ((dr == NULL) || (dev == NULL)) + return -EINVAL; + + for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) { + + /* check if device's identifiers match the driver's ones */ + if (id_table->vendor_id != dev->id.vendor_id && + id_table->vendor_id != PCI_ANY_ID) + continue; + if (id_table->device_id != dev->id.device_id && + id_table->device_id != PCI_ANY_ID) + continue; + if (id_table->subsystem_vendor_id != + dev->id.subsystem_vendor_id && + id_table->subsystem_vendor_id != PCI_ANY_ID) + continue; + if (id_table->subsystem_device_id != + dev->id.subsystem_device_id && + id_table->subsystem_device_id != PCI_ANY_ID) + continue; + + struct rte_pci_addr *loc = &dev->addr; + + RTE_LOG(DEBUG, EAL, + "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", + loc->domain, loc->bus, loc->devid, + loc->function, dev->numa_node); + + RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", + dev->id.vendor_id, dev->id.device_id, + dr->name); + + /* call the driver devshutdown() function */ + if (dr->devshutdown && (dr->devshutdown(dr, dev) < 0)) + return -1; /* negative value is an error */ + + /* clear driver structure */ + dev->driver = NULL; + + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) + /* unmap resources for devices that use igb_uio */ + pci_unmap_device(dev); + + return 0; + } + /* return positive value if driver is not found */ + return 1; +} +#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */ + /* Init the PCI EAL subsystem */ int rte_eal_pci_init(void)