From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id E5F248093 for ; Tue, 9 Dec 2014 04:44:01 +0100 (CET) Received: by mail-pa0-f45.google.com with SMTP id lj1so6541031pab.32 for ; Mon, 08 Dec 2014 19:44:01 -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=NL6dQRDptHAlekV3Y9f3SFiynGgsL6nFggNOtmId/bT0m+IeD/pxGtFauXXQFxmM1f Bv/f8uTj5ePkqcsHMUvBr+a2Z7Skr4PvWCubfryHtuQH/RNOaEWarvFzbnXklHH7OAS0 vINYHRdyCLU6c+Wvxdoda/saACw6gc79+0CpraOGm3/zttF6Ov2h/vh6r78Oc7fnEefX hTAwmaZ7E3rbKuFUUf18a47Wyjo6nAAbKQoWJqvU4o77/JT1PzfIPkvgM+W7aitQuc5i CGpr/KbXrOie+uSbJndXIkiawTxbeomWIBjt2mR0BipFCGKeOUECcWLpW5NGuHyzBr7d QDvg== X-Gm-Message-State: ALoCoQnC2VACbXbMdKVgLo2Qv6P4lRObLNepPiZDZxLPKMZwUdH95Wt+mZ4GPuy1S0uz2LY5gQZ4 X-Received: by 10.68.213.138 with SMTP id ns10mr1489526pbc.50.1418096641125; Mon, 08 Dec 2014 19:44:01 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id xx2sm2185pab.17.2014.12.08.19.43.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 19:44:00 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 12:42:43 +0900 Message-Id: <1418096571-27531-21-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418096571-27531-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418096571-27531-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 v2 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: , X-List-Received-Date: Tue, 09 Dec 2014 03:44:02 -0000 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) -- 1.9.1