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 AC83DA04B0; Fri, 7 Aug 2020 19:47:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BB782C39; Fri, 7 Aug 2020 19:47:11 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id C66CA2BF2 for ; Fri, 7 Aug 2020 19:47:08 +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 077HjgYo000436; Fri, 7 Aug 2020 10:47:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=pfpt0818; bh=VTS1JJzupGe0f/60Gihkc7OpN6JqYbSsZhGH3mSgDR4=; b=gxBU8qdwJKIrhVN6fLiNkpvSO+iJEhqtebtJgr9Qjfw8W3MDEWThNYP4p0KPh7hX3eYp MjPzZaN1yownrYLsCk/UN+trC4RcnhZsXJLXLNDuPcHPmtUwOlXgQDJeyDDR/BBKgkza puM8SluBMFyX7DMeCRy2GJhDvn/hq+SqE01hKY0f7pXb4NM6tcGL563WTyRBz2UQhT3K 3TvAtKR6kI1yXvIdxdSfngHrQTJsc1vk9CJ+nus7vZCQviYqI32lR5LjLGw03I4xrkmY /PdHKgayPgD2x1yNHFuOLFjKBKOa86NRewLcFhZYMe+6NYlvresoKtRh+YROLpQy74rn /Q== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 32n6ch2srq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 07 Aug 2020 10:47:07 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 7 Aug 2020 10:47:06 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 7 Aug 2020 10:47:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXbTBpjnhctMBW5Qgsoc0W7R7/6hVm+xKHLkYCjQDVPNuMiB12Xfy1VYt3nDm/jjYVCanHuPC/eD5TZfwuTEKbh0TKWrOKNGKO0U/9oIRgucMwEHo2FkWMxpRLyX10r0Ee4oHYqiPfPVsy0P07h05VdgdGvnNXzohv7ca2rgJLoXNzsS8EQakjJsbYExGdaDAioUEmSr1TGSzgEbtQt3Ha0r3gaGJHzWTASe78Anh95Z8NMkUvBdK3jdfOlmSRCdMoxE9kUnJakThm9/Xr1cNxDSelOEI8uDJXKxh3eM1dDGYHMg6Ah4OC9f0FInL1z/76I6HszQtGhOz613ZJdkIw== 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=VTS1JJzupGe0f/60Gihkc7OpN6JqYbSsZhGH3mSgDR4=; b=N+SePNBSuwh59u0zjUBTVJxLF8mzXaW+Cwr5wbMLh9nlZ9+aHhpV7VN9qG2gmTjO7YX+lCjvLYBVl0+SDNBhLfY6aJHhEYD5T8Snk//atLf9i+6WQT0eSfoD+EvQeoAGmeaIl/dljc7G51OxjSMVH/Py22LxPgQ3Kj6gkU/k+qpsuC98PoLa/7pDMSW+k9N+sBar/XPpySimwb27qzw1T9emEA+z5E07ROGaEV0PxHokSHcvhyMzAaw2tZ4ncz/japB9wGwy5vtENb4CQzvHTY6Ruj3VJJFUFVOX/iL2kDl8UuQKh4HtDKlFRJTTOjt3F87p0NxaAwxmnZlrDHJ1Hg== 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=VTS1JJzupGe0f/60Gihkc7OpN6JqYbSsZhGH3mSgDR4=; b=C9rkcOOR3XF5V2Y3zRps2MX5c/Es2V2+G/D00nnRY6+JaW0lJ+iwCmQfwgKk3dNlmfpzpyNxI6L7XL41R/F3jfcpvM0y9m4khkHhCaNkC1sEkWEFKBv4O/ivHVH/cNHZYg2bdkZpAZtemkno63ZAeG7nLQ1ow16WeDJgQN1iCuw= Received: from DM6PR18MB2394.namprd18.prod.outlook.com (2603:10b6:5:188::20) by DM5PR18MB2310.namprd18.prod.outlook.com (2603:10b6:4:b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17; Fri, 7 Aug 2020 17:47:05 +0000 Received: from DM6PR18MB2394.namprd18.prod.outlook.com ([fe80::2d71:e8ff:3751:eb2a]) by DM6PR18MB2394.namprd18.prod.outlook.com ([fe80::2d71:e8ff:3751:eb2a%3]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 17:47:05 +0000 Date: Fri, 7 Aug 2020 23:16:06 +0530 From: Nithin Dabilpuram To: Manish Chopra CC: , , , , , , , , , , , , Message-ID: <20200807174606.GA11173@outlook.office365.com> References: <20200730144221.29051-1-manishc@marvell.com> <20200730144221.29051-2-manishc@marvell.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200730144221.29051-2-manishc@marvell.com> User-Agent: Mutt/1.12.2 (34cd43c) (2019-09-21) X-ClientProxiedBy: BM1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::26) To DM6PR18MB2394.namprd18.prod.outlook.com (2603:10b6:5:188::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from outlook.office365.com (115.113.156.2) by BM1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Fri, 7 Aug 2020 17:47:01 +0000 X-Originating-IP: [115.113.156.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc56ede9-04c7-4481-d10a-08d83af9e5e3 X-MS-TrafficTypeDiagnostic: DM5PR18MB2310: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sLrUomwUaThgsjmuvnEDHIDl7R+OKebleU4ls71nl9UsSmvzJrUd9+iiQJMgSAQ7m9/YmtSCCuKxkZS/rk5JGsJAyHh9/A7lYZLeglRZbtuRgohwmbzWGLVjLi1SJyhwrXvXYQcusFvp301jYAn+qO1UgQ915BkI/VLJycoaSj4S2Q18F0YSXt4/EzDsZGtGnhvFgThmHTEI+wlzyvJLo7JTI0pX3vp1TcsCce9NG+MW2Kgfp325Q6uW/T03UQJul4qDPG6FXApxOva8tvOlZX22LbJP5WMmumW2LjP0ZsquPOUkVtSIrIQuA7hl7/bmSOb7NOHFuEXCDSyKJDvCJeIkH3h0vt/qL8XvEXnWIpI09brqDEPezTlavAcC6tN2qmEQMYgX78f/MtWYMyz1Xg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR18MB2394.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(39860400002)(136003)(376002)(346002)(186003)(26005)(6506007)(956004)(66946007)(7696005)(52116002)(33656002)(478600001)(55236004)(66476007)(66556008)(9686003)(2906002)(16526019)(1076003)(8676002)(6636002)(8936002)(30864003)(5660300002)(316002)(4326008)(55016002)(86362001)(6862004)(83380400001)(37363001)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: u64uqwXYuZvKb4HqtwDJeMvPDsqoq2IzuGDd+V5Z8wdn4IZ9kTqLWC/nRGbn7q531EoRejmwSInt1TDXADZu2Eqn2HhlZldU75p5nMPeMMpPF1+/3hM9TdfPXx8xMG4Im5xINXS0uY0VKQL8TOu03aGayowFR1UA7oyFDThyzQN6Ni29nwyWlESXMs2fxZ2N4EBIFYdpM1s1W3BlGLX5nXfmyJQ9478amHOUmeqYYxCbhJZDWs+/z9R78aS4bWeeCAr+gCxe7toFox9zbw97uh4CxSQz8hTdSZTU/sB9j3BHtSr9pxjxLtVv1gx8kLQ+GmRI3Qt/5K3L7p5v52JjbOoUeDRh8itmtFLz7jYBsTS/R8ghTs+QIz7t+vi/KPZUDrjt/rp+j4NyMaLEWXaPdWz8iBw/ZENq+EgYIKgxjtcJsERYwWf4rtuXQB+60WHnrmdoP+38c/fc11XFWfw6Ws2KhUO5GPhNOW3SvydV+hb0yb4Edv4+9fJiAzIYfnFNzceVUW5k3qnRHLiAoIiSJsBgk6U3/uRHxOuMOczvsi51J4nkI4j1PGVQb8S07k2cFfUbOLJVW5tE5shGqDapaJbHplfAHAculutl8wRVOsamNgAzwtBz7h0/O65+Ygdn/gKZ1qaNfDRjR+v4bFeOAA== X-MS-Exchange-CrossTenant-Network-Message-Id: fc56ede9-04c7-4481-d10a-08d83af9e5e3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR18MB2394.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 17:47:05.5213 (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: auLgG2vMUgUrZ6YZTxjjsV2ePKBwltepozKigr3pD96mBZqhZI5ihFUPelWV8hqQi64yIL1LXhcE22TCmdmS7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR18MB2310 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-07_15:2020-08-06, 2020-08-07 signatures=0 Subject: Re: [dpdk-dev] [PATCH v5 1/6] drivers: add generic API to find PCI extended cap 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" On Thu, Jul 30, 2020 at 07:42:16AM -0700, Manish Chopra wrote: > By adding generic API, this patch removes individual > functions/defines implemented by drivers to find extended > PCI capabilities. > > Signed-off-by: Manish Chopra > Signed-off-by: Igor Russkikh > --- > drivers/bus/pci/pci_common.c | 43 ++++++++++++++++++ > drivers/bus/pci/rte_bus_pci.h | 20 +++++++++ > drivers/bus/pci/rte_bus_pci_version.map | 6 +++ > drivers/net/ice/ice_ethdev.c | 51 +--------------------- > drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 48 +------------------- > drivers/raw/ifpga/ifpga_rawdev.c | 17 +++----- > lib/librte_pci/rte_pci.h | 16 +++++++ > 7 files changed, 95 insertions(+), 106 deletions(-) > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c > index a8e5fd52c..98c1f8155 100644 > --- a/drivers/bus/pci/pci_common.c > +++ b/drivers/bus/pci/pci_common.c > @@ -665,6 +665,49 @@ rte_pci_get_iommu_class(void) > return iova_mode; > } > > +off_t > +rte_pci_find_next_ext_capability(struct rte_pci_device *dev, uint32_t cap) > +{ Shouldn't it be named rte_pci_find_ext_capability() as it doesn't take start position from where to search ? > + off_t offset = RTE_PCI_CFG_SPACE_SIZE; > + uint32_t header; > + int ttl; > + > + /* minimum 8 bytes per capability */ > + ttl = (RTE_PCI_CFG_SPACE_EXP_SIZE - RTE_PCI_CFG_SPACE_SIZE) / 8; > + > + if (rte_pci_read_config(dev, &header, 4, offset) < 0) { > + RTE_LOG(ERR, EAL, "error in reading extended capabilities\n"); > + return -1; > + } > + > + /* > + * If we have no capabilities, this is indicated by cap ID, > + * cap version and next pointer all being 0. > + */ > + if (header == 0) > + return 0; > + > + while (ttl != 0) { > + if (RTE_PCI_EXT_CAP_ID(header) == cap) > + return offset; > + > + offset = RTE_PCI_EXT_CAP_NEXT(header); > + > + if (offset < RTE_PCI_CFG_SPACE_SIZE) > + break; > + > + if (rte_pci_read_config(dev, &header, 4, offset) < 0) { > + RTE_LOG(ERR, EAL, > + "error in reading extended capabilities\n"); > + return -1; > + } > + > + ttl--; > + } > + > + return 0; > +} > + > struct rte_pci_bus rte_pci_bus = { > .bus = { > .scan = rte_pci_scan, > diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h > index 29bea6d70..f11af3762 100644 > --- a/drivers/bus/pci/rte_bus_pci.h > +++ b/drivers/bus/pci/rte_bus_pci.h > @@ -224,6 +224,26 @@ void rte_pci_unmap_device(struct rte_pci_device *dev); > */ > void rte_pci_dump(FILE *f); > > +/** > + * Find device's extended PCI capability. > + * > + * @param dev > + * A pointer to rte_pci_device structure. > + * > + * @param cap > + * Extended capability to be found, which can be any from > + * RTE_PCI_EXT_CAP_ID_*, defined in librte_pci. > + * > + * @return > + * > 0: The offset of the next matching extended capability structure > + * within the device's PCI configuration space. > + * < 0: An error in PCI config space read. > + * = 0: Device does not support it. > + */ > +__rte_experimental > +off_t rte_pci_find_next_ext_capability(struct rte_pci_device *dev, > + uint32_t cap); > + > /** > * Register a PCI driver. > * > diff --git a/drivers/bus/pci/rte_bus_pci_version.map b/drivers/bus/pci/rte_bus_pci_version.map > index 012d817e1..b5322660d 100644 > --- a/drivers/bus/pci/rte_bus_pci_version.map > +++ b/drivers/bus/pci/rte_bus_pci_version.map > @@ -16,3 +16,9 @@ DPDK_20.0 { > > local: *; > }; > + > +EXPERIMENTAL { > + global: > + > + rte_pci_find_next_ext_capability; > +}; > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c > index 7dd3fcd27..6c8cbea5c 100644 > --- a/drivers/net/ice/ice_ethdev.c > +++ b/drivers/net/ice/ice_ethdev.c > @@ -1730,53 +1730,6 @@ ice_pf_setup(struct ice_pf *pf) > return 0; > } > > -/* PCIe configuration space setting */ > -#define PCI_CFG_SPACE_SIZE 256 > -#define PCI_CFG_SPACE_EXP_SIZE 4096 > -#define PCI_EXT_CAP_ID(header) (int)((header) & 0x0000ffff) > -#define PCI_EXT_CAP_NEXT(header) (((header) >> 20) & 0xffc) > -#define PCI_EXT_CAP_ID_DSN 0x03 > - > -static int > -ice_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap) > -{ > - uint32_t header; > - int ttl; > - int pos = PCI_CFG_SPACE_SIZE; > - > - /* minimum 8 bytes per capability */ > - ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; > - > - if (rte_pci_read_config(dev, &header, 4, pos) < 0) { > - PMD_INIT_LOG(ERR, "ice error reading extended capabilities\n"); > - return -1; > - } > - > - /* > - * If we have no capabilities, this is indicated by cap ID, > - * cap version and next pointer all being 0. > - */ > - if (header == 0) > - return 0; > - > - while (ttl-- > 0) { > - if (PCI_EXT_CAP_ID(header) == cap) > - return pos; > - > - pos = PCI_EXT_CAP_NEXT(header); > - > - if (pos < PCI_CFG_SPACE_SIZE) > - break; > - > - if (rte_pci_read_config(dev, &header, 4, pos) < 0) { > - PMD_INIT_LOG(ERR, "ice error reading extended capabilities\n"); > - return -1; > - } > - } > - > - return 0; > -} > - > /* > * Extract device serial number from PCIe Configuration Space and > * determine the pkg file path according to the DSN. > @@ -1784,12 +1737,12 @@ ice_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap) > static int > ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file) > { > - int pos; > + off_t pos; > char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE]; > uint32_t dsn_low, dsn_high; > memset(opt_ddp_filename, 0, ICE_MAX_PKG_FILENAME_SIZE); > > - pos = ice_pci_find_next_ext_capability(pci_dev, PCI_EXT_CAP_ID_DSN); > + pos = rte_pci_find_next_ext_capability(pci_dev, RTE_PCI_EXT_CAP_ID_DSN); > > if (pos) { > rte_pci_read_config(pci_dev, &dsn_low, 4, pos + 4); > diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > index 0b9db974e..dbab4f8cb 100644 > --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > @@ -746,59 +746,15 @@ nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp) > return 0; > } > > -#define PCI_CFG_SPACE_SIZE 256 > -#define PCI_CFG_SPACE_EXP_SIZE 4096 > -#define PCI_EXT_CAP_ID(header) (int)(header & 0x0000ffff) > -#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) > -#define PCI_EXT_CAP_ID_DSN 0x03 > -static int > -nfp_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap) > -{ > - uint32_t header; > - int ttl; > - int pos = PCI_CFG_SPACE_SIZE; > - > - /* minimum 8 bytes per capability */ > - ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; > - > - if (rte_pci_read_config(dev, &header, 4, pos) < 0) { > - printf("nfp error reading extended capabilities\n"); > - return -1; > - } > - > - /* > - * If we have no capabilities, this is indicated by cap ID, > - * cap version and next pointer all being 0. > - */ > - if (header == 0) > - return 0; > - > - while (ttl-- > 0) { > - if (PCI_EXT_CAP_ID(header) == cap) > - return pos; > - > - pos = PCI_EXT_CAP_NEXT(header); > - if (pos < PCI_CFG_SPACE_SIZE) > - break; > - > - if (rte_pci_read_config(dev, &header, 4, pos) < 0) { > - printf("nfp error reading extended capabilities\n"); > - return -1; > - } > - } > - > - return 0; > -} > - > static int > nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp) > { > uint16_t tmp; > uint8_t serial[6]; > int serial_len = 6; > - int pos; > + off_t pos; > > - pos = nfp_pci_find_next_ext_capability(dev, PCI_EXT_CAP_ID_DSN); > + pos = rte_pci_find_next_ext_capability(dev, RTE_PCI_EXT_CAP_ID_DSN); > if (pos <= 0) { > printf("PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\n"); > return -1; > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c > index cc25c662b..07aef4f6e 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.c > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > @@ -41,12 +41,6 @@ > #include "ifpga_rawdev.h" > #include "ipn3ke_rawdev_api.h" > > -#define RTE_PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */ > -#define RTE_PCI_CFG_SPACE_SIZE 256 > -#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 > -#define RTE_PCI_EXT_CAP_ID(header) (int)(header & 0x0000ffff) > -#define RTE_PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) > - > #define PCI_VENDOR_ID_INTEL 0x8086 > /* PCI Device ID */ > #define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD > @@ -86,8 +80,8 @@ ifpga_rawdev_allocate(struct rte_rawdev *rawdev); > static int set_surprise_link_check_aer( > struct ifpga_rawdev *ifpga_rdev, int force_disable); > static int ifpga_pci_find_next_ext_capability(unsigned int fd, > - int start, int cap); > -static int ifpga_pci_find_ext_capability(unsigned int fd, int cap); > + int start, uint32_t cap); > +static int ifpga_pci_find_ext_capability(unsigned int fd, uint32_t cap); > > struct ifpga_rawdev * > ifpga_rawdev_get(const struct rte_rawdev *rawdev) > @@ -144,8 +138,8 @@ ifpga_rawdev_allocate(struct rte_rawdev *rawdev) > return dev; > } > > -static int ifpga_pci_find_next_ext_capability(unsigned int fd, > -int start, int cap) > +static int > +ifpga_pci_find_next_ext_capability(unsigned int fd, int start, uint32_t cap) > { > uint32_t header; > int ttl; > @@ -183,7 +177,8 @@ int start, int cap) > return 0; > } > > -static int ifpga_pci_find_ext_capability(unsigned int fd, int cap) > +static int > +ifpga_pci_find_ext_capability(unsigned int fd, uint32_t cap) > { > return ifpga_pci_find_next_ext_capability(fd, 0, cap); > } > diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h > index a03235da1..fec51e15a 100644 > --- a/lib/librte_pci/rte_pci.h > +++ b/lib/librte_pci/rte_pci.h > @@ -22,6 +22,22 @@ extern "C" { > #include > #include > > + > +/* > + * Conventional PCI and PCI-X Mode 1 devices have 256 bytes of > + * configuration space. PCI-X Mode 2 and PCIe devices have 4096 bytes of > + * configuration space. > + */ > +#define RTE_PCI_CFG_SPACE_SIZE 256 > +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 > + > +/* Extended Capabilities (PCI-X 2.0 and Express) */ > +#define RTE_PCI_EXT_CAP_ID(header) (header & 0x0000ffff) > +#define RTE_PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) > + > +#define RTE_PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */ > +#define RTE_PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */ > + > /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ > #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 > #define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X") > -- > 2.17.1 >