From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0072.outbound.protection.outlook.com [104.47.33.72]) by dpdk.org (Postfix) with ESMTP id A74C637B8 for ; Sat, 3 Dec 2016 07:52:28 +0100 (CET) Received: from DM5PR03CA0011.namprd03.prod.outlook.com (10.175.104.21) by BY2PR0301MB0744.namprd03.prod.outlook.com (10.160.63.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Sat, 3 Dec 2016 06:52:27 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:172) by DM5PR03CA0011.outlook.office365.com (2603:10b6:3:118::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13 via Frontend Transport; Sat, 3 Dec 2016 06:52:26 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Sat, 3 Dec 2016 06:52:25 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:941; Count:13 Received: from [10.232.14.87] ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uB36qLr0030286; Fri, 2 Dec 2016 23:52:22 -0700 To: Ben Walker References: <1479929804-19614-1-git-send-email-benjamin.walker@intel.com> <1479931644-78960-1-git-send-email-benjamin.walker@intel.com> <1479931644-78960-7-git-send-email-benjamin.walker@intel.com> CC: From: Shreyansh Jain Message-ID: <4fb8991d-d026-5920-c951-466a9c14164a@nxp.com> Date: Sat, 3 Dec 2016 12:25:12 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1479931644-78960-7-git-send-email-benjamin.walker@intel.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131252215457001903; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(3190300001)(339900001)(336004)(189002)(199003)(24454002)(377454003)(97736004)(6666003)(64126003)(65956001)(81156014)(81166006)(8676002)(47776003)(8936002)(189998001)(65806001)(86362001)(229853002)(31696002)(69596002)(85426001)(39450400002)(38730400001)(305945005)(83506001)(36756003)(92566002)(50466002)(39380400001)(39400400001)(39410400001)(23746002)(5890100001)(2906002)(356003)(626004)(33646002)(230700001)(2950100002)(7846002)(77096006)(4326007)(50986999)(65826007)(104016004)(76176999)(54356999)(6916009)(5660300001)(106466001)(31686004)(68736007)(4001350100001)(110136003)(105606002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0744; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:NY6kpyVOYf1J0sNZEfv1yATzoxuJbZyePYtjoEv3BEqryhjDRl7M96gm71PeuK/dgWhC5KVBcym8kUWYXg1HQSFDUjU2lUfLKKalJ40C8DBIYWE0MpmJ66VHPpwSX/ghDYPX+h3qc6IMwXFIsqIax6af0U1f7rZNLRnTRKKJwbR281OU8hjqFCeDsxLUKoz10skpRZbyHJXbSOgHIO3+oEZeRN36AMp6/Yf0qzgSdBoZIbGu5NoSYGGBm6HwRY0qw0NG6PKGOmaYvd52cgPVFRWnfUaePXMfEpyJ84CkDQ1XVK1MYoAP5A4qe5/mWSDYT0dRnlXqz67WH+22a5zMLH8fhITUylgVRfwK4JqPB/FlpWYomw8nJ/j9bhVL6/26SE7mCx7l8K4BAVBRdZjEUoHEx28jEGMcwtqU0ohH09BK38Ss2pj01v7hYaaYN8Pwa7iEvB80/5K7aavFdPBmEfspZFvd18KTiCO2v1N4EyNldDyN7m8fFADkZobJPGQ4DjMG0wYpzqZYFE473HDaQNkbJfyB/+3o/Ml2D0wRcta58UGkj7uNLto3Ovi5EHYWwuZKplc8yuUlxTJzcEuduIqS/pHCwcd+/+UFrhUEhZRhUKKmb5oVz13Z1NV0clOJExXId4V8h3yzgb7YXrW3VaLABEWKLE0zV+z5ZacVVYg= X-MS-Office365-Filtering-Correlation-Id: 317c7db0-ac5c-4f27-26a7-08d41b48f0b0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0744; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 3:ShbXT5Ko48kqRptv08tNNloKIro6D8vBfAALKheg+gvnWWZS005drlk57+PjN4uix9G3Ei+pWKmX+MRHxc8oU5+oO3qknxnjsn30rnwpiDL4Rm3UVycYdYEuLGP1QmDMnStsZ3rDu+HOkj7QSlcZqRq9W7LdiGl/BqAr5sduxzajpBJ6bp4/8CvX7Y/Z+Pu4F6Qi2VcSo8Pp8zSZho/qlxCCQt1wiBDrTFazuDARYc7glBtneLcDtA72cgA9ZLSWftBva55PnObdd94C7Kmk1tF/d5lcwPzWev6QXZXaZjz1c8EUyHyTBHYOpydiCoJFFyMBJb5Nn0H2veLCtCLGQSDo4JZ24jCTbr2Vk0t46FaLPmAgTt0no7oBfJh57Ghi X-Microsoft-Exchange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I1ZvT2TNUgjR4YriOpF2GNl13R/uoBHQHyGa0EuELd79T8r/OgHOeSv+Rspn5myw4rTlFA62ztUZaXLH8FS1CyOwVaE/I+grhF+y+RNNpQg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13017025)(13023025)(13015025)(13024025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123561025)(20161123559025)(20161123556025)(20161123563025); SRVR:BY2PR0301MB0744; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0744; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 4:u/1x7svP3Vlvb/lYrGhxBBF/GBXDqSyvw9IUr3MSh3NqiHavD/Exv63A6wS6Sw26ZbvY+mdnJgD4/IS1zzz7kvFDBGmjNyil8LnizuYjm+Q3zoj/icEcvs7d65e+1qx3hY1tLWDSyR80hWJ1kNBEw7ANBnehsNGI5K6whVXCL8EJoOZ9K4rhYeEFGGOyanqw9oS99CydmC1O6/sZfyJGO7sCU5Z1wKKFz439EhooCblC/MH8mfT4BitK9mTQEelECaqJmWYCckxMtb01pj16INWg3kDOoPAXkSMSiz/Kf22FjkWx7hS4umBNa64s7LGI8bjoiusRwCsWbJQ5rk4igVtBZjYYlMtAZHM3Bu6HoqIfA0gcij0BfAZj1bGpZ/KX5FgSfxX6riJZzPJappmDXkKg53uz9zZpu/3IoDw99nxun8cgXZKoiOm8ANB3tyaZ5No2gEj6zbsBy7AEn7TLGhYtxvsa0lU9qXzwmGKpaQLICoSZURNBp8MbjoAjVkhE8UmQKT2lf0XM6e8pJ4QNR7k9UGuDeK/6C7wv22AUwEwd8FrNWjhAoyfGaxdINLwnXPZcStA1EbMBaQwvgp/WBKaIYBnjjSMl9nPYt1m17cEw7Rhm3a3GSOAeVizGHJ6/Tom/6TaW8VlaWmhbEx6aaPJYxvihMfPgZcvEgEpNkXLUIQ4qQL85wU3GM8CPy6zVgu8tgVN5tMVK92kHrS4SCFzW65hMWlLSROXKfW+sD25/mGMP1JZT/rUgIYCXDAar X-Forefront-PRVS: 0145758B1D X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; BY2PR0301MB0744; 23:JHu2W9bDMM8IW9MVCyHAjbk3ftVGEauHVuc?= =?Windows-1252?Q?zIvXhfXRTNUgHrQsSbOXEsFQqhIjfnM0Wgh04x+74KYH25QQ7EBxjDML?= =?Windows-1252?Q?slEqCh7nPlNOunGcVCb0lA4pYh7toiiqKArd7b/nhTsEm88zAGMsEcgp?= =?Windows-1252?Q?1/q6pSTd8V/DdTK4H7Ee7xuAxCtODizFWUKbMRWPv6dp9BBw2PSqOPDS?= =?Windows-1252?Q?Ct2T3/MpJP9TO02igO551UZl9j48lwJ9jpTX0r4ZN1OAINPBcHd/bwLc?= =?Windows-1252?Q?VkmpNcXNWptp/BBa0F0SWKG+0dDkHSOPkcmpZQqz/Hp64bxCzsFg0J4I?= =?Windows-1252?Q?PnMTAlEU3PWfvTtScIF6A4FcisBf7Zr2qrVlCxbmyxJ+RjeL8CbZdKbB?= =?Windows-1252?Q?pEBtpmiMMhmqZry2VCgXRhU4o141NOJFuOvHMk05LWOVYfxkqQScu8E2?= =?Windows-1252?Q?g8NaLVVkuPNLcXe4WXpYZ2e4Vbc65dMScNkzUkrBIm0RnXVOdTr/XW2L?= =?Windows-1252?Q?yTsN3M/7rGqPPb/AlX74Jy1Y9tU1iXZkPZi0Xv9ZYsgRXDgIp4XhzM4y?= =?Windows-1252?Q?b2Rdgxb0TlhP0tP1yq+Xqz5lYdtQIzm/dfhlLZ3bqjwfr4MGBn25mweD?= =?Windows-1252?Q?PPzoUIAs7eUPNU8Bs3qB/VnKupkWkY1OGafpa9XpOLZoDQW8ALNwNnU8?= =?Windows-1252?Q?aZzUdpPkCnriFGXGF/r0zKZeuJ7dVipDKhT0admRioe0Xvwby/dZ5+RF?= =?Windows-1252?Q?4OEeem8tkc3/dwXS1KBllD2OSigEbsk2kJmUH0ByFBa42v3GGRidsVpO?= =?Windows-1252?Q?xMs1WHS5jmQkl8EvvbUPmEXjzFG05jJQ3LiXW8zi0esY1CKJevDmOlzx?= =?Windows-1252?Q?r3r+wdg2B0tLMb8EAv/dbjM65iqAuM5A8a1oAp/AGauxYQ/NE/Lv7JE3?= =?Windows-1252?Q?lGvnSTSCCFaP8p4kiattTkgeOjeTYd1rXv5sayrFnv6OZHiZnsZW1qnV?= =?Windows-1252?Q?jJgfaocx37lDhszwbYmMZciooaMocwWWzTvXQYGQeK+DwEzUhGolJsoS?= =?Windows-1252?Q?luKFen96kWlkEjG0gMlDOMOD/loTHI8miw4FZwVidKOLF9X3PLRpGb/3?= =?Windows-1252?Q?SokXQTvAZBD3j2xSWZjf3i/abbVK9WxRioHWlrhGI5cAEUe96wB433qA?= =?Windows-1252?Q?hivcf9fGkfb5rWJWIRkJlgG5U9N5wfcKxsb/FUFc2zEGqR7HbyKdkcBh?= =?Windows-1252?Q?j2MWkuqriOBvnqRLEiapXIwI9KIDbjUyMJ5uGMjmF6erL31J/qh3uNwP?= =?Windows-1252?Q?CXKP70ugomoExH3Yfky0viHgRJRPpigDwPOn0N1Vc9gzHfQAPYZru6TR?= =?Windows-1252?Q?bl2gc1F5sceyO1LEsfmRrEnis+yPq1cC5Jwo70LJF3bYrlMaKZZF3DRF?= =?Windows-1252?Q?ZJW+XsDkgSybtWJ9PP+UECXsIQYDNgOXkPDZWuc7dXQJA2/LYF8cn2hl?= =?Windows-1252?Q?b3AQYrNlNgNMrtCbS8+ZsRu86Txaop6ycb1vK6w24vW+QmwYLMkf/LCX?= =?Windows-1252?Q?CLGGgzGyfUIN+Y5mzLehISpRm22h0Klcfp8LvkKSZlVieaArpb2MAhb3?= =?Windows-1252?Q?Vjg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 6:ZmaodjkqodPYTIdc2a4f6X1RyaNkiH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ukDlpf2rTUgCgPBcZ2mzWkKoO4jU9Owkqz/fL/riQIPzQH6rvGIrofherEZbUKMKHpnDww3uczllrzAWJCqhL8CodTk+AnF0M8oTJiGi3/pmrS3Tzb24u5b16w433qTCqzsBQjlxZkcni+LRetU9IX70D12+NcPy9H5XtGdsB9ry+/Adpby4eTlkyifmnZP5dZzhcAbWg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2016 06:52:25.3413 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0744 Subject: Re: [dpdk-dev] [PATCH v2 7/7] pci: Clarify interfaces for dynamic attach/detach of drivers 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: Sat, 03 Dec 2016 06:52:29 -0000 On Thursday 24 November 2016 01:37 AM, Ben Walker wrote: > There are now two functions - rte_eal_pci_attach_driver and > rte_eal_pci_detach_driver - that dynamically attempt to attach > and detach drivers from PCI devices. These only control > whether a registered PCI driver is loaded or not - they are > independent of whether the PCI device exists on the system. > > Signed-off-by: Ben Walker > --- > lib/librte_eal/common/eal_common_dev.c | 4 +- > lib/librte_eal/common/eal_common_pci.c | 109 +++++++++----------------------- > lib/librte_eal/common/include/rte_pci.h | 22 ++++--- > 3 files changed, 43 insertions(+), 92 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c > index 4f3b493..1c6834e 100644 > --- a/lib/librte_eal/common/eal_common_dev.c > +++ b/lib/librte_eal/common/eal_common_dev.c > @@ -114,7 +114,7 @@ int rte_eal_dev_attach(const char *name, const char *devargs) > } > > if (eal_parse_pci_DomBDF(name, &addr) == 0) { IMO, ideally all the PCI specific code should be within eal_common_pci. For example, the above function (eal_common_pci_DomBDF) shouldn't be part of the generic fn rte_eal_dev_attach. Somehow this should be hidden/closed with PCI specific files. In the eal_common_dev, rte_eal_dev_attach and rte_eal_dev_detach are directly referring to PCI as devices. isn't it? > - if (rte_eal_pci_probe_one(&addr) < 0) > + if (rte_eal_pci_attach_driver(&addr) < 0) > goto err; > > } else { > @@ -139,7 +139,7 @@ int rte_eal_dev_detach(const char *name) > } > > if (eal_parse_pci_DomBDF(name, &addr) == 0) { > - if (rte_eal_pci_detach(&addr) < 0) > + if (rte_eal_pci_detach_driver(&addr) < 0) > goto err; > } else { > if (rte_eal_vdev_uninit(name)) > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c > index d50a534..67c6ce6 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -228,59 +228,36 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d > return 1; > } > > -/* > - * If vendor/device ID match, call the remove() function of the > - * driver. > - */ > static int > -rte_eal_pci_detach_dev(struct rte_pci_driver *dr, > - struct rte_pci_device *dev) > +rte_eal_pci_remove_driver(struct rte_pci_device *dev) > { > - const struct rte_pci_id *id_table; > + struct rte_pci_driver *driver; > + struct rte_pci_addr *loc; > > - if ((dr == NULL) || (dev == NULL)) > - return -EINVAL; > + loc = &dev->addr; > + driver = dev->driver; > > - 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; > + if (driver == NULL) > + return 0; > > - RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", > - loc->domain, loc->bus, loc->devid, > - loc->function, dev->device.numa_node); > + RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", > + loc->domain, loc->bus, loc->devid, > + loc->function, dev->device.numa_node); > > - RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, > - dev->id.device_id, dr->driver.name); > + RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, > + dev->id.device_id, driver->driver.name); > > - if (dr->remove && (dr->remove(dev) < 0)) > - return -1; /* negative value is an error */ > + if (driver->remove && (driver->remove(dev) < 0)) > + return -1; /* negative value is an error */ > > - /* clear driver structure */ > - dev->driver = NULL; > + /* clear driver structure */ > + dev->driver = NULL; > > - if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) > - /* unmap resources for devices that use igb_uio */ > - rte_eal_pci_unmap_device(dev); > + if (driver->drv_flags & RTE_PCI_DRV_NEED_MAPPING) > + /* unmap resources for devices that use igb_uio */ > + rte_eal_pci_unmap_device(dev); > > - return 0; > - } > - > - /* return positive value if driver doesn't support this device */ > - return 1; > + return 0; > } > > /* > @@ -315,38 +292,11 @@ pci_probe_all_drivers(struct rte_pci_device *dev) > } > > /* > - * If vendor/device ID match, call the remove() function of all > - * registered driver for the given device. Return -1 if initialization > - * failed, return 1 if no driver is found for this device. > - */ > -static int > -pci_detach_all_drivers(struct rte_pci_device *dev) > -{ > - struct rte_pci_driver *dr = NULL; > - int rc = 0; > - > - if (dev == NULL) > - return -1; > - > - TAILQ_FOREACH(dr, &pci_driver_list, next) { > - rc = rte_eal_pci_detach_dev(dr, dev); > - if (rc < 0) > - /* negative value is an error */ > - return -1; > - if (rc > 0) > - /* positive value means driver doesn't support it */ > - continue; > - return 0; > - } > - return 1; > -} > - > -/* > * Find the pci device specified by pci address, then invoke probe function of > * the driver of the devive. > */ > int > -rte_eal_pci_probe_one(const struct rte_pci_addr *addr) > +rte_eal_pci_attach_driver(const struct rte_pci_addr *addr) > { > struct rte_pci_device *dev = NULL; > int ret = 0; > @@ -382,10 +332,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr) > * Detach device specified by its pci address. > */ > int > -rte_eal_pci_detach(const struct rte_pci_addr *addr) > +rte_eal_pci_detach_driver(const struct rte_pci_addr *addr) > { > struct rte_pci_device *dev = NULL; > - int ret = 0; > > if (addr == NULL) > return -1; > @@ -394,17 +343,17 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr) > if (rte_eal_compare_pci_addr(&dev->addr, addr)) > continue; > > - ret = pci_detach_all_drivers(dev); > - if (ret < 0) > - goto err_return; > + if (dev->driver == NULL) { > + /* The device at that address does not have a driver loaded */ > + return 0; > + } > + > + if (rte_eal_pci_remove_driver(dev) < 0) > + return -1; > > - TAILQ_REMOVE(&pci_device_list, dev, next); > - free(dev); > return 0; > } > - return -1; > > -err_return: > RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT > " cannot be used\n", dev->addr.domain, dev->addr.bus, > dev->addr.devid, dev->addr.function); > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h > index 2154a54..e304853 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -459,11 +459,14 @@ void *pci_map_resource(void *requested_addr, int fd, off_t offset, > void pci_unmap_resource(void *requested_addr, size_t size); > > /** > - * Probe the single PCI device. > + * Attempt to load the registered driver for the PCI device at addr. > * > - * Scan the content of the PCI bus, and find the pci device specified by pci > - * address, then call the probe() function for registered driver that has a > - * matching entry in its id_table for discovered device. > + * Find the pci device specified by addr, then call the probe() function > + * for each registered driver that has a matching entry in its id_table until > + * the correct driver is found. > + * > + * If the PCI address is known, this is considerably more efficient than > + * calling rte_eal_pci_probe. > * > * @param addr > * The PCI Bus-Device-Function address to probe. > @@ -471,14 +474,13 @@ void pci_unmap_resource(void *requested_addr, size_t size); > * - 0 on success. > * - Negative on error. > */ > -int rte_eal_pci_probe_one(const struct rte_pci_addr *addr); > +int rte_eal_pci_attach_driver(const struct rte_pci_addr *addr); > > /** > - * Close the single PCI device. > + * Unload the driver for the PCI device at addr. > * > - * Scan the content of the PCI bus, and find the pci device specified by pci > - * address, then call the remove() function for registered driver that has a > - * matching entry in its id_table for discovered device. > + * Find the pci device specified by addr, then call the remove() function > + * for the currently loaded driver. > * > * @param addr > * The PCI Bus-Device-Function address to close. > @@ -486,7 +488,7 @@ int rte_eal_pci_probe_one(const struct rte_pci_addr *addr); > * - 0 on success. > * - Negative on error. > */ > -int rte_eal_pci_detach(const struct rte_pci_addr *addr); > +int rte_eal_pci_detach_driver(const struct rte_pci_addr *addr); > > /** > * Dump the content of the PCI bus. >