From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by dpdk.org (Postfix) with ESMTP id 15C087F7C for ; Thu, 20 Nov 2014 09:57:39 +0100 (CET) Received: by mail-pa0-f48.google.com with SMTP id rd3so2160383pab.35 for ; Thu, 20 Nov 2014 01:08:07 -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=qiWjcYcU7fLTff3ND6wovBpt16E2ElCaXxhiQzeb9OM=; b=M1H0cY8Z/Te7O9PXkE5+NqrXPDimsQ2YooqLEFr89hPKrz4gWWw8rSNdHrFDT8EJiU xb863fg8iFZzq6hFV+Tn0D/Ber5qhT27pkdnYmTtelEmJy/x4/3h1hV8cHIpCZrehTT7 Cy7Gv/w3kAdMjZQwwlhsUjVw6I/GUD/8qkdTAtXll0TcGuesgd4XSyCTt5Fue/fplckm eRlRgaYR74PvR3sTKXsBLNHhkOAvIQBPXjoomkjt2wpDCEZt0xbSb1FhqY3ZHwfPu9Nu 5u4yRcB68j8AVr5v+hDAu44Qr3+5vb1AuNhmJ2z1JhEnwA+370CT8hPf7NBaDEoR4fdh GVLQ== X-Gm-Message-State: ALoCoQn1PZY7Ifmf1Tlat7x3ZxYEz4Evy5MhzhUKMnMWDirHnYzu5rQgiDV4MwwObSQhv7xv2YlV X-Received: by 10.66.234.100 with SMTP id ud4mr19445328pac.36.1416474487782; Thu, 20 Nov 2014 01:08:07 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id a6sm1432407pbu.64.2014.11.20.01.08.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 01:08:07 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 20 Nov 2014 18:06:34 +0900 Message-Id: <1416474399-16851-21-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1416474399-16851-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 20/25] 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: Thu, 20 Nov 2014 08:57:39 -0000 The function is used for closing the specified driver and device. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/common/include/eal_private.h | 11 ++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 58 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/lib/librte_eal/common/include/eal_private.h b/lib/librte_eal/common/include/eal_private.h index a1127ab..b2776cc 100644 --- a/lib/librte_eal/common/include/eal_private.h +++ b/lib/librte_eal/common/include/eal_private.h @@ -176,6 +176,17 @@ 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. + * + * @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 0317366..fbfef40 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -599,6 +599,64 @@ 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; + + 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