From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E3027A058A; Fri, 17 Apr 2020 10:30:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C239B1DEBB; Fri, 17 Apr 2020 10:30:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 5ACC51DE0F for ; Fri, 17 Apr 2020 10:30:09 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03H8PGNG027709; Fri, 17 Apr 2020 01:30:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=lVTz8hWlx2M0SAY9uS0FZQenZdAFT7sZNDCtCFsvqGw=; b=lLCXt99L+3zOZHULbr/l9IcGT1q7F1ToKcFBHcB348XmUmHnY7/xLZBRgp6BzQojvyNp mrLilWTaB1Y6ZLcn2hE5znRBsKk5AEpKMjMlTTKXzbo/zmf2eqxSlUHqdtnrMRqph6DJ YwmKyzXENXIzp36pGkY5S7Ui1xYf1tocEHdXlOk1eMLrSgilwfxpL1TXWrMDxglMZBAo 0dvlGuFA6182CmCB2CbKPUEMfSOjOtM7LbpnhoV5Yf1ONiBpfc52dyAleISg1ZGnq5HN oLy1Z7xc/nW9/3Dcw6pMVlKYl0vi/7AP44/1isyTKYbImflXJOn5FGBoCxqKf7svph53 kw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 30dn8guag1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2020 01:30:08 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Apr 2020 01:30:06 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.174) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 17 Apr 2020 01:30:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJ5S1mHyf9B+Udvjs6AH6e4NyiXIYhCCy9JjLspb8wYC3rI5+oFQNIvz/pj/qrkwa63SEi5RX6/q9V4/ZWSfuOQK5RIJyD2r53ADJEwj72vC96fEHIRMih/rFW29AKpu1LTWmdpFn5oJ0vJEpCm26lql+aOndlvX930uSf3DWxCFrx7UHlnaud/IoC17YnMGFfZ/1qteGOlREY3fJKfN0lOeI1aV/AyjUvZMzOEhDS4dwHyVNo/Y1MS9Y/fsoJlWfrsCwhZ0ECwYp20V9uLWYgT3JEfhvXrqwUCf2eZpgzjebNR/cbl8MmL84zOLJjt2UiU95vzj4jtoflmhoBlmSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lVTz8hWlx2M0SAY9uS0FZQenZdAFT7sZNDCtCFsvqGw=; b=HIoP1rXkgo+myC5GzXmqwMBUR67XGN+wfYFmAgw3R2nPNFv9rqNyfQbC2d302ko2Jk0o1VJydzxLhQhG66Lf4nppQQVACw4xBZI9eWRpW3DGi4R2P9Fhnoz5xaCz1Wep16O/f5rQekx4diG1BtIVSGqmE/cQGx2u/rGcZj6K/eXRQy85B05UIbMHtrJObcUM5wmyJC9mOWmAsk3NqoJCjrMU570m+yOG8e6EXCjcaEmBCsTrRCWAb4rWGGX+BMM89NzuPmMI+lfr5Xlp0RSjIsEqKcqYtOt4EikfF5mRTdneLUUfDFoRC1WGs/J47HUhjVngEyUBPwqE8SLvZ/hvww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lVTz8hWlx2M0SAY9uS0FZQenZdAFT7sZNDCtCFsvqGw=; b=R0VK3QO8uvRagLDSKBw7umaRz2aPC/zx2jm6A4iITB7bGb6L12vC+ZxKjCg7ExiPIK4iDQ+YNP4U4o0HZbCNeD/2e258nya9NZPdm/SSgycfCqug+oszJlSx5H6wSmMS1ZD2Cf/SRsJPO1J38AnwCxTWD0NVHAofxdLAQsJzW7E= Received: from BY5PR18MB3105.namprd18.prod.outlook.com (2603:10b6:a03:1a4::30) by BY5PR18MB3281.namprd18.prod.outlook.com (2603:10b6:a03:1a7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25; Fri, 17 Apr 2020 08:30:05 +0000 Received: from BY5PR18MB3105.namprd18.prod.outlook.com ([fe80::cc6:c7ae:dc40:7ddf]) by BY5PR18MB3105.namprd18.prod.outlook.com ([fe80::cc6:c7ae:dc40:7ddf%7]) with mapi id 15.20.2900.030; Fri, 17 Apr 2020 08:30:05 +0000 From: Sunil Kumar Kori To: Sunil Kumar Kori , "stephen@networkplumber.org" , "david.marchand@redhat.com" , Jerin Jacob Kollanukkaran CC: "dev@dpdk.org" Thread-Topic: [PATCH v2 1/1] bus/pci: optimise scanning with whitelist/blacklist Thread-Index: AQHWDL8BG4OVDRY9SUWyneA1iFrHNqh9CxNA Date: Fri, 17 Apr 2020 08:30:05 +0000 Message-ID: References: <20191216075501.15669-1-skori@marvell.com> <20200407092856.554-1-skori@marvell.com> In-Reply-To: <20200407092856.554-1-skori@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2401:4900:44e0:fe05:899a:4d2:4213:f516] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6362bca9-f715-4152-bca9-08d7e2a98839 x-ms-traffictypediagnostic: BY5PR18MB3281: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2201; x-forefront-prvs: 0376ECF4DD x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR18MB3105.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(396003)(346002)(39860400002)(136003)(366004)(478600001)(6506007)(33656002)(7696005)(81156014)(186003)(5660300002)(8676002)(71200400001)(55016002)(316002)(8936002)(76116006)(66556008)(64756008)(66446008)(66476007)(52536014)(9686003)(66946007)(2906002)(86362001)(4326008)(6636002)(110136005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: L4l0bK1Qrnq6mxUbUB8mL/fhmKjiiJuNQIwFSW7aKG/6w8AwBqueFkwn+PiSzB5+855ONFjI+LQzTClMmfR95h/11v2D19Pzfue1V11FOFeSZ4uDLqT6ACwGR3hH7IhChbc8Ixb2ZGkqQ5Ru82qez1uh8WTwKCpXqKGepIUUMklkcpcL1M4G39O3z9To3vMuJYtuwHTWC9aVl6LldOWMgJZH+bjr+Y8ZqQw/FgRebK9K9mwiojaQ4Om+AGUjXJTT3bSRoOTyT3YHomn77uH+tBvRzUhnPIS8mfZnPRhiiE/QjT6hCDIKwJQ1AZI2f2qM17Cgw4zU2+8tn/JMXRoxeDP81raNTi+zqSxCQZvW/McPL4Mul9u8BQ5383ZS8Tgt++aGHblvxwl8mL7RjJkkEaeK1X3G8k/+sjHnEpuyFJ+PiJ9e9oD1NsDtIWxweajD x-ms-exchange-antispam-messagedata: AE9JnFMiGJzG1P2OsVs+bXjv/tK7OGV0qY4+J4ztUGX8Lg+xVBhFJR22HJGRd2xxbs/nmAhz8evX3ft5wOd3CZZuFy2aCDnR2bbwHK0gqrJBqbytiImgrC+vrTw1hHlrHVcPK/g3kTMmqYC2ZdzPX3+DrEF4jOiA3zfkiTrU599406GXBRY5MCtac4YCDGm5yF9OhCX/WquZDysODF471Q== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6362bca9-f715-4152-bca9-08d7e2a98839 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2020 08:30:05.8040 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XZXJhAYuoVDbnHkKcYeqlvOG2gake9UM6KS4TlG9ipWbZdV6zxuv6Yv9AYk6G/nv+Y3TId1svzjxXbaYbSP8hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3281 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-17_03:2020-04-14, 2020-04-17 signatures=0 Subject: Re: [dpdk-dev] [PATCH v2 1/1] bus/pci: optimise scanning with whitelist/blacklist 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hello David and Stephen, I have uploaded second version of patch as per your suggestion.=20 Please have a look and ack if it looks okay. Regards Sunil Kumar Kori >-----Original Message----- >From: Sunil Kumar Kori >Sent: Tuesday, April 7, 2020 2:59 PM >To: stephen@networkplumber.org; david.marchand@redhat.com; Jerin Jacob >Kollanukkaran >Cc: dev@dpdk.org; Sunil Kumar Kori >Subject: [PATCH v2 1/1] bus/pci: optimise scanning with whitelist/blacklis= t > >rte_bus_scan API scans all the available PCI devices irrespective of white= or >black listing parameters then further devices are probed based on white or >black listing parameters. So unnecessary CPU cycles are wasted during >rte_pci_scan. > >For Octeontx2 platform with core frequency 2.4 Ghz, rte_bus_scan consumes >around 26ms to scan around 90 PCI devices but all may not be used by the >application. So for the application which uses 2 NICs, rte_bus_scan consum= es >few microseconds and rest time is saved with this patch. > >Patch restricts devices to be scanned as per below mentioned conditions: > - All devices will be scanned if no parameters are passed. > - Only white listed devices will be scanned if white list is available. > - All devices, except black listed, will be scanned if black list is > available. > >Signed-off-by: Sunil Kumar Kori >--- >v2: > - Added function to validate ignorance of device based on PCI address. > - Marked device validation function as experimental. > > drivers/bus/pci/bsd/pci.c | 15 ++++++++++- > drivers/bus/pci/linux/pci.c | 3 +++ > drivers/bus/pci/pci_common.c | 34 +++++++++++++++++++++++++ > drivers/bus/pci/private.h | 12 +++++++++ > drivers/bus/pci/rte_bus_pci_version.map | 5 ++++ > 5 files changed, 68 insertions(+), 1 deletion(-) > >diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index >ebbfeb13a..074f4556e 100644 >--- a/drivers/bus/pci/bsd/pci.c >+++ b/drivers/bus/pci/bsd/pci.c >@@ -338,6 +338,9 @@ rte_pci_scan(void) > .match_buf_len =3D sizeof(matches), > .matches =3D &matches[0], > }; >+ struct rte_pci_addr pci_addr; >+ >+ memset(&pci_addr, 0, sizeof(struct rte_pci_addr)); > > /* for debug purposes, PCI can be disabled */ > if (!rte_eal_has_pci()) >@@ -357,9 +360,19 @@ rte_pci_scan(void) > goto error; > } > >- for (i =3D 0; i < conf_io.num_matches; i++) >+ for (i =3D 0; i < conf_io.num_matches; i++) { >+ pci_addr.domain =3D matches[i].pc_sel.pc_domain; >+ pci_addr.bus =3D matches[i].pc_sel.pc_bus; >+ pci_addr.devid =3D matches[i].pc_sel.pc_dev; >+ pci_addr.function =3D matches[i].pc_sel.pc_func; >+ >+ /* Check that device should be ignored or not */ >+ if (pci_addr_ignore_device(&pci_addr)) >+ continue; >+ > if (pci_scan_one(fd, &matches[i]) < 0) > goto error; >+ } > > dev_count +=3D conf_io.num_matches; > } while(conf_io.status =3D=3D PCI_GETCONF_MORE_DEVS); diff --git >a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index >71b0a3053..92bdad826 100644 >--- a/drivers/bus/pci/linux/pci.c >+++ b/drivers/bus/pci/linux/pci.c >@@ -487,6 +487,9 @@ rte_pci_scan(void) > if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), >&addr) !=3D 0) > continue; > >+ if (pci_addr_ignore_device(&addr)) >+ continue; >+ > snprintf(dirname, sizeof(dirname), "%s/%s", > rte_pci_get_sysfs_path(), e->d_name); > >diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c >index 3f5542076..a350a1993 100644 >--- a/drivers/bus/pci/pci_common.c >+++ b/drivers/bus/pci/pci_common.c >@@ -589,6 +589,40 @@ pci_dma_unmap(struct rte_device *dev, void *addr, >uint64_t iova, size_t len) > return -1; > } > >+static struct rte_devargs * >+pci_addr_devargs_lookup(const struct rte_pci_addr *pci_addr) { >+ struct rte_devargs *devargs; >+ struct rte_pci_addr addr; >+ >+ RTE_EAL_DEVARGS_FOREACH("pci", devargs) { >+ devargs->bus->parse(devargs->name, &addr); >+ if (!rte_pci_addr_cmp(pci_addr, &addr)) >+ return devargs; >+ } >+ return NULL; >+} >+ >+bool >+pci_addr_ignore_device(const struct rte_pci_addr *pci_addr) { >+ struct rte_devargs *devargs =3D pci_addr_devargs_lookup(pci_addr); >+ >+ switch (rte_pci_bus.bus.conf.scan_mode) { >+ case RTE_BUS_SCAN_WHITELIST: >+ if (devargs && devargs->policy =3D=3D RTE_DEV_WHITELISTED) >+ return false; >+ break; >+ case RTE_BUS_SCAN_UNDEFINED: >+ case RTE_BUS_SCAN_BLACKLIST: >+ if (devargs =3D=3D NULL || >+ devargs->policy !=3D RTE_DEV_BLACKLISTED) >+ return false; >+ break; >+ } >+ return true; >+} >+ > static bool > pci_ignore_device(const struct rte_pci_device *dev) { diff --git >a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index >a205d4d9f..25075b806 100644 >--- a/drivers/bus/pci/private.h >+++ b/drivers/bus/pci/private.h >@@ -42,6 +42,18 @@ int rte_pci_scan(void); void pci_name_set(struct >rte_pci_device *dev); > >+/** >+ * Validate whether a device with given pci address should be ignored or = not. >+ * >+ * @param pci_addr >+ * PCI address of device to be validated >+ * @return >+ * 1: if device is to be ignored, >+ * 0: if device is to be scanned, >+ */ >+__rte_experimental >+bool pci_addr_ignore_device(const struct rte_pci_addr *pci_addr); >+ > /** > * Add a PCI device to the PCI Bus (append to PCI Device list). This func= tion > * also updates the bus references of the PCI Device (and the generic dev= ice >diff --git a/drivers/bus/pci/rte_bus_pci_version.map >b/drivers/bus/pci/rte_bus_pci_version.map >index 012d817e1..da4ae2640 100644 >--- a/drivers/bus/pci/rte_bus_pci_version.map >+++ b/drivers/bus/pci/rte_bus_pci_version.map >@@ -16,3 +16,8 @@ DPDK_20.0 { > > local: *; > }; >+ >+EXPERIMENTAL { >+ # added in 20.05 >+ pci_addr_ignore_device; >+}; >-- >2.17.1