From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0087.outbound.protection.outlook.com [104.47.42.87]) by dpdk.org (Postfix) with ESMTP id EDA95F91E for ; Mon, 26 Dec 2016 14:21:32 +0100 (CET) Received: from BN6PR03CA0037.namprd03.prod.outlook.com (10.175.124.23) by CY4PR03MB2471.namprd03.prod.outlook.com (10.168.165.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11; Mon, 26 Dec 2016 13:21:28 +0000 Received: from BN1BFFO11OLC003.protection.gbl (2a01:111:f400:7c10::1:113) by BN6PR03CA0037.outlook.office365.com (2603:10b6:404:10c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11 via Frontend Transport; Mon, 26 Dec 2016 13:21:28 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; 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 BN1BFFO11OLC003.mail.protection.outlook.com (10.58.145.14) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.789.10 via Frontend Transport; Mon, 26 Dec 2016 13:21:28 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uBQDKVCX029786; Mon, 26 Dec 2016 06:21:24 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Mon, 26 Dec 2016 18:54:00 +0530 Message-ID: <1482758645-23057-8-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482758645-23057-1-git-send-email-shreyansh.jain@nxp.com> References: <1482756644-13726-1-git-send-email-shreyansh.jain@nxp.com> <1482758645-23057-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131272320887793485; (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)(336005)(39450400003)(39840400002)(39400400002)(39850400002)(39380400002)(39410400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(106466001)(33646002)(2351001)(105606002)(86362001)(69596002)(50986999)(48376002)(2906002)(50466002)(76176999)(4326007)(47776003)(5660300001)(38730400001)(68736007)(8676002)(81166006)(50226002)(81156014)(8936002)(8656002)(626004)(92566002)(77096006)(5003940100001)(104016004)(110136003)(6916009)(6666003)(2950100002)(97736004)(189998001)(36756003)(356003)(305945005)(85426001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2471; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11OLC003; 1:sP7oM2w68+GmYX2fboK/r0W9h6dSpAO/G56yBkyHn3oOeGk84H2xjS6YxpuRxsDJ2sHsk4eDKjubhEsUCj3Qoz54yImsE0EH1qJbaK6KN9YBQBl1sMvWcMByF5e8IRo6oGgDpVoAt6c/p0k/QV/pwU6PIwIz/c5n+Zyr27UmCxyn3MRdZaRW7XO+spoFyk7ochM94dHp4HkHpepAxs7ZvtFSD3Ah8Jc3UY0DQtmChQalzLVq7GQUz1trImsKKs9LaRXhjdEUkJ9g2gd/NZDlkmj7xd5aekvgEz+S3Vc6OU+YUS3WU6UDzH5d33G1PgSIfmtoeSPizF58HI4F4f7ZZ/Z22twAmwdoq3q4HNGUsVR2w6y+t6qM5XdCWtGFv2JyuS8Vk2pdYzpwogE3iKrrBlopyBTn2O13XGerxczms68jYXyzxonyrSZ3+v66qgRwxTcAonU1Jb6SkFfRzKWZH9uMW3mZCfhuaPf78EtBSRrh70s03JVU5YLyfVTzLbVv2d7GKk/eyLjNxmtTDtAGguau25R4YBb59dZDsw7WzR0sanObsrPbwnSUtCZzHsVF2yzq3dIhNHM+jsdAQspSZ18rXxAmPJCvg75/msfEWe/9PLkjBYOK1GN74J5V/Bw4PxLaQKOOykXXpcpg5PgCUpTGHtYIJ1ma/JMAuCPBLi+HtOXyH51IBC2FfhKOTaKO1gvq6nFy2F9CxYxSakQT18tBRDSFE+XWxaf2DLUoZQI= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b660b058-bac4-4acb-45f0-08d42d9219d0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR03MB2471; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2471; 3:5WQL909polj4KaiJVoB4B+gupg7eJuhncDC+WWOXk6z3T0u3vlayoPlGaSKIpQTdrP2RRqfr2fQkkSqToRd/Tw/FR1ZNy8dApoZkBefrbOcHGTkeUAPOpjS02QIuTZctDAo8K8NILDkNdkP86xrRfBFTmMkGH5EKhkNzhpTmf3L46ZYVhx+5cUHSdcPFIs+7VTZdRw1Q2UhkJqHiDRx+bR7/sYpK9PXkfLoTcyTmn8p81386SV/xFQYmt59elRg+L10alSARFSiDzLhF+5gfrURlxIWpf7g+RQDDYpc+e2qxpUsq+QuHdAlknAaLDZSb5ij4BNkSrs15ZTe9j9CwwvSEbv8Crb7Rme/mLb+VExTGbjG9koakKzM8BcQOD1r5 X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2471; 25:d+rMkCb2JX1ag7neh90uCh/NoDtDrmc6hF+zxAVsarm6clqzP5pz1tt6X+4HbI38IOaVljrPkC4SOAR8dYyW6cPwANCP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ispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13017025)(13024025)(13023025)(13015025)(13018025)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123563025)(20161123565025); SRVR:CY4PR03MB2471; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2471; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2471; 4:ZtX+NcQBbKXVxAIsqpuoMBt4cBm2SavYXiSciKa35wP4W675pL4nkYyKPozeuhb6u7ns4u/7fs715A4T/P2DV6hRkFNN5ciPBznOMFebmrqDVQABn3f/dfv7W8L76q7KiR4AryHUl38DQMBbqZ0ojzxD7t4AlhtETNaaG6R/+QQsEvnhjWeV/vX1PDL+fowv2E2CmwxgDX0GP2u9f/JMpYK9i/7FMYHW/1aGnP4jlRF/mMyq7kkxhShZ3GJmDbk+zAvd63nhWzCFcjUdqd1by0nTjatF78/DAcAZ5mdceb9OmTN+EB2O9IkQhHDTC1xm5wc8DrSnnuOVmVTZ5e593C62tW9N+1qiJkFCF4UfYl0r9hzCCs/iJiSL3bTd9BFK5df1YsZPTIhic21J4nK8yyl6QmXLyF6vA8FcvqYtQG3dQ1l4e9qAznZi1jlbvP0JsEbAn26TUmVXzb0KX285JtWiup/ZKvvPFy1ZCzj6vSXHUTwr/Np7PiO68ZhGuF1Jz/04mzhVLDoPjR0Va7Ga6jCZhOkCvYq7p8gNqw8lvvon3mjQmKDday335gOIifoax5unwKdhTCFbJmlUvMyie0O+hyAlziARNPlnaffYOiLrjwHbdhxWWV3iOY4NyixPaPcSY95P8rJIbI9eQoxV1QbDfYi2Qrk0OfB7i2QbjM+x8wV0F1g2BtxL2QB0FvkgSkLiG1W/qnuczZUhkLKksLt+1yON0aOJE+R+BIGe1tXcuB7Q+AfT+M8bIzDlyGgT X-Forefront-PRVS: 016885DD9B X-Microsoft-Exchange-Diagnostics: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J5NBrP4wPDGdrh2wZf+PGJdB7U48099a4n8LEeWbTT1r9daRkP9vi09d2Y/Vo4ddO/nV1Hu4wf1460hfyLHJfEgvuwz6cimYSm0DFCwk9aB7cCETlbm/Il8SiAqh/Cr9+qHfMK1qTuXbq12sJW9xcZqwP9UucybZjmu+VYjD4aXTUUx1XgzR2nlp0H; 24:eCK9BXTQQDdyvQieDRW8odMZm8cvJHgcpcOboQ1DxlLn0Q3vq338l0vpmYVwmReyccDus70P1MrbIG5iDkqywg8s/BKPUe7U8W/bdjw9lfM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2471; 7:n1fqU6+PFkyQDUr7PtBe/cOKovicQzgykI4av8/izf0Et36ueXyaehywd85kkMbZk6yNxcibRCUHm5dp61OVtRPzoGmR7Lpo813BGiwmuSFFXfPW2wkzJitQAv9Ftw7Dw21buFxbqyLbIcFH6HT6UUWgklpxxoJVUBISeCQ7ssH57LKGdJe0DyyHjLCpLAj73K7f9f6AVGiLOtZXuYJBFnA8X8nU2sIYk+guEbzRCnt6tNb+s2qrgAKLM8Gihc/xmSYaIDr7tSmUUu4myu/azmiUogXYJf6vibodEp0Zfgg3RFNZFKGYNjjZm35v4yldKI8MNsUIgYpY7o04vXflc4x4ktCYaUwANAMJBvbxUajQvUfpSe1/3oMBoErKWEqq7wqUVa7hUlYCNNnymhYqysjJ300cPVuJ/SYKm99P2y/3F215RYkXFj+TH1jU808aiApfWXkSOVcZaW9K4OJ8wA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2016 13:21:28.4985 (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: CY4PR03MB2471 Subject: [dpdk-dev] [PATCH v5 07/12] pci: split match and probe function 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: Mon, 26 Dec 2016 13:21:33 -0000 Matching of PCI device address and driver ID table is being done at two discreet locations duplicating the code. (rte_eal_pci_probe_one_driver and rte_eal_pci_detach_dev). Splitting the matching function into rte_eal_pci_match. Signed-off-by: Shreyansh Jain -- v2: - Change default return in match function --- lib/librte_eal/common/eal_common_pci.c | 176 ++++++++++++++++++-------------- lib/librte_eal/common/include/rte_pci.h | 15 +++ 2 files changed, 114 insertions(+), 77 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 33485bc..f466448 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -152,71 +152,106 @@ pci_unmap_resource(void *requested_addr, size_t size) requested_addr); } -/* - * If vendor/device ID match, call the probe() function of the - * driver. - */ -static int -rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) +int +rte_eal_pci_match(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev) { - int ret; + int match = 1; const struct rte_pci_id *id_table; - for (id_table = dr->id_table; id_table->vendor_id != 0; id_table++) { + if (!pci_drv || !pci_dev || !pci_drv->id_table) { + RTE_LOG(DEBUG, EAL, "Invalid PCI Driver object\n"); + return -1; + } + for (id_table = pci_drv->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 && + if (id_table->vendor_id != pci_dev->id.vendor_id && id_table->vendor_id != PCI_ANY_ID) continue; - if (id_table->device_id != dev->id.device_id && + if (id_table->device_id != pci_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) + if (id_table->subsystem_vendor_id != + pci_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) + if (id_table->subsystem_device_id != + pci_dev->id.subsystem_device_id && + id_table->subsystem_device_id != PCI_ANY_ID) continue; - if (id_table->class_id != dev->id.class_id && + if (id_table->class_id != pci_dev->id.class_id && id_table->class_id != RTE_CLASS_ANY_ID) continue; - struct rte_pci_addr *loc = &dev->addr; + match = 0; + break; + } - RTE_LOG(INFO, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", - loc->domain, loc->bus, loc->devid, loc->function, - dev->device.numa_node); + return match; +} - /* no initialization when blacklisted, return without error */ - if (dev->device.devargs != NULL && - dev->device.devargs->type == - RTE_DEVTYPE_BLACKLISTED_PCI) { - RTE_LOG(INFO, EAL, " Device is blacklisted, not initializing\n"); - return 1; - } +/* + * If vendor/device ID match, call the probe() function of the + * driver. + */ +static int +rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, + struct rte_pci_device *dev) +{ + int ret; + struct rte_pci_addr *loc; - RTE_LOG(INFO, EAL, " probe driver: %x:%x %s\n", dev->id.vendor_id, - dev->id.device_id, dr->driver.name); + if ((dr == NULL) || (dev == NULL)) + return -EINVAL; - if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { - /* map resources for devices that use igb_uio */ - ret = rte_eal_pci_map_device(dev); - if (ret != 0) - return ret; - } + loc = &dev->addr; - /* reference driver structure */ - dev->driver = dr; + RTE_LOG(INFO, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", + loc->domain, loc->bus, loc->devid, loc->function, + dev->device.numa_node); - /* call the driver probe() function */ - ret = dr->probe(dr, dev); - if (ret) - dev->driver = NULL; + /* no initialization when blacklisted, return without error */ + if (dev->device.devargs != NULL && + dev->device.devargs->type == + RTE_DEVTYPE_BLACKLISTED_PCI) { + RTE_LOG(INFO, EAL, " Device is blacklisted, not" + " initializing\n"); + return 1; + } - return ret; + /* The device is not blacklisted; Check if driver supports it */ + ret = rte_eal_pci_match(dr, dev); + if (ret) { + /* Match of device and driver failed */ + RTE_LOG(DEBUG, EAL, "Driver (%s) doesn't match the device\n", + dr->driver.name); + return 1; } - /* return positive value if driver doesn't support this device */ - return 1; + + RTE_LOG(INFO, EAL, " probe driver: %x:%x %s\n", dev->id.vendor_id, + dev->id.device_id, dr->driver.name); + + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { + /* map resources for devices that use igb_uio */ + ret = rte_eal_pci_map_device(dev); + if (ret != 0) + return ret; + } + + /* reference driver structure */ + dev->driver = dr; + + /* call the driver probe() function */ + ret = dr->probe(dr, dev); + if (ret) { + RTE_LOG(DEBUG, EAL, "Driver (%s) probe failed.\n", + dr->driver.name); + dev->driver = NULL; + } + + return ret; } /* @@ -227,51 +262,38 @@ static int rte_eal_pci_detach_dev(struct rte_pci_driver *dr, struct rte_pci_device *dev) { - const struct rte_pci_id *id_table; + int ret; + struct rte_pci_addr *loc; 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; + ret = rte_eal_pci_match(dr, dev); + if (ret) { + /* Device and driver don't match */ + return 1; + } - 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); + loc = &dev->addr; - 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, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", + loc->domain, loc->bus, loc->devid, + loc->function, dev->device.numa_node); - if (dr->remove && (dr->remove(dev) < 0)) - return -1; /* negative value is an error */ + RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, + dev->id.device_id, dr->driver.name); - /* clear driver structure */ - dev->driver = NULL; + if (dr->remove && (dr->remove(dev) < 0)) + return -1; /* negative value is an error */ - if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) - /* unmap resources for devices that use igb_uio */ - rte_eal_pci_unmap_device(dev); + /* clear driver structure */ + dev->driver = NULL; - return 0; - } + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) + /* unmap resources for devices that use igb_uio */ + rte_eal_pci_unmap_device(dev); - /* return positive value if driver doesn't support this device */ - return 1; + return 0; } /* diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 87cad59..34ff3d1 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -373,6 +373,21 @@ rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, int rte_eal_pci_scan(void); /** + * Match the PCI Driver and Device using the ID Table + * + * @param pci_drv + * PCI driver from which ID table would be extracted + * @param pci_dev + * PCI device to match against the driver + * @return + * 0 for successful match + * !0 for unsuccessful match + */ +int +rte_eal_pci_match(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev); + +/** * Probe the PCI bus for registered drivers. * * Scan the content of the PCI bus, and call the probe() function for -- 2.7.4