From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38D9E42E40; Tue, 11 Jul 2023 07:52:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7E2340A7D; Tue, 11 Jul 2023 07:52:36 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by mails.dpdk.org (Postfix) with ESMTP id EC8FE4003C for ; Tue, 11 Jul 2023 07:52:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dwXyVDhlK0dfKNxdzCYDF/WZ6bM1WdSCvg7puFSBPWz918EvQKWEGFk+aJJU1O4CEihCgGrIykK0HErZ5fyZf6h5yfwlDmE04Fcec6B0AiKCHhUmpcu08rDDg7DS/BNqxaAOv10ZH5xkqbZxGD42dNkRFCgq6yLi44oVLz3tYCMc1UEnMLcqw6F5t5MtgP9nqcwES6r0A40Z0k4z6SM3nga3tzScSso263OdMNRlZOedHIfX0HiKIpsb5MxQzk7bMvR2mV1fR5E31AxQuf6YSE4T2IHp6RyRuiLBTRVrU2A1zpaLV7hw9NRVRUtn34WHoygVpud9ebqTMkHv+Dwpng== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wYEu4trf+dpuB2nj7J/Q3z2LQ2EgrIUUAZY6Bp9Fss0=; b=ML15RfQTo/PiyXnTdIjah+VY+v6owRgnxt6OL5jPYydwHB0vrS/0gllRxYGQIIPumM/b0DYEyjKPKUponjOYbhOQqOz6ZEU7uMiJqxrm5ezXBXlT72v4C4FGJrpx7QBOcr2s3EKFp/IRa6xoK5FcVCWqfWnlarJP7CBc2+nKaGn3sI/QHFtIEbsjL492UUOjjOh743R6ACR2uC1Av5iYvmAUaAexNON++NiHRDpOhOpee7CZb5gLGBw74e5v601IEw6PpDA4M0Xrt6wXa+0i3MyOSgL9gPIiNBfDxFdmNW8moea0/lWJzk/tAVOx9Rqz40+PEuhhHQ/jIwYGa7JJVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wYEu4trf+dpuB2nj7J/Q3z2LQ2EgrIUUAZY6Bp9Fss0=; b=VxcNgss5Np3zOem1FxNYx5LKrDi0/OMB4W3/nU6+hdkx7X2kbZ07QbWXTGUqwRe5VI65ew3kkGW0WffPCyJlk23UZ6RxR363BpKdbpqC1VEhbcKrfuKgyqricPRMk4WFn1gAFSgffQAA+grcEAoQrslJYWYNmha6SVFdp5vcm4A= Received: from DS7PR05CA0019.namprd05.prod.outlook.com (2603:10b6:5:3b9::24) by DS7PR12MB6046.namprd12.prod.outlook.com (2603:10b6:8:85::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 05:52:32 +0000 Received: from DM6NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::28) by DS7PR05CA0019.outlook.office365.com (2603:10b6:5:3b9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20 via Frontend Transport; Tue, 11 Jul 2023 05:52:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT107.mail.protection.outlook.com (10.13.172.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.20 via Frontend Transport; Tue, 11 Jul 2023 05:52:32 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 11 Jul 2023 00:52:31 -0500 Received: from xhdipdslab59.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 11 Jul 2023 00:52:29 -0500 From: Abhijit Gangurde To: , CC: , , , , Abhijit Gangurde Subject: [PATCH v3] bus/cdx: provide driver flag for optional resource mapping Date: Tue, 11 Jul 2023 11:21:47 +0530 Message-ID: <20230711055147.872889-1-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230705065235.4767-1-abhijit.gangurde@amd.com> References: <20230705065235.4767-1-abhijit.gangurde@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT107:EE_|DS7PR12MB6046:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f9fa873-b6a0-4786-1b67-08db81d30526 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +edG8lfQPsAzeIiuL/GaBm8SPGB4vMkRmOJrBHBq/I4rO5sXoGmWkzj8j/2dciQHb7ITKgLazA1/ujaTXCxG4XAf+gWtYGNFQkPGr1+m7FmrsadlEazL2GDcJaGMu4LTZGKxt6fkqvykeflXm35mFrvMvTOQ6Wq71XyYzAxuaO6guIGgxUsjcVTRpJCGcgulp/Q6sTc9WXquS/h9ZJXxX+m6xM1gHkPXTmcU7jQK3xD9cVgih7l1Xe9i+YszpB8nBYKYCpNMbTdIdaKTGePgM5Dhk4nLqGsXeoMTaX0Xgub1RkNsRs1UHjuyzae69viooAsR2B6ZQXPVjflLUwBH4e9r/NShtI6+jsisBw1jIUqNTHK3dI4V62V4+T2TxVXS/oKD/8sS2luP4jpkjIFkPt0a+6oXOO1+ki+U79GqY/jn4MNfO2uXXSOgVye4T8d897y4+5huwU7WLsAWH463fuTgt43KF8jo+UmJgWtWxA3f3lJklSiLlYeF6Y1LR/aOohNDPQRnVORGL8m9sbhwcovb69cV9DL2Q+KgfZwULrAAYwyBEf2T5Y6jL9HE6LBrREXowskbEfOKeBKQQXqOHvpL/vppqz38Y6a15FBGkPKnpFWWuFBLhaxFL2xETgyYFaVSsEc8faSSC5+ZOdXp4m73hDwQjmedQiU/yQXDuecwIYlArnfAXDBkPr3R+ffa4IoFsRimoDcNoaKqiRt6t1NZQol50GvnkMp1uU5I2/sdgR1k2JXeCwON5qfOjr379rFZOuVsXQcuCiauqOJD0g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199021)(46966006)(36840700001)(40470700004)(478600001)(6666004)(110136005)(54906003)(36860700001)(47076005)(2616005)(426003)(83380400001)(36756003)(86362001)(40460700003)(40480700001)(2906002)(70206006)(82310400005)(70586007)(1076003)(26005)(186003)(336012)(81166007)(82740400003)(356005)(8936002)(6636002)(316002)(41300700001)(5660300002)(44832011)(8676002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 05:52:32.6741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f9fa873-b6a0-4786-1b67-08db81d30526 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6046 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Provide driver flag which gives an option to map the cdx device resource before probing the device driver. Also, make rte_cdx_map_device() API as public to map device resource separately. Signed-off-by: Abhijit Gangurde --- v3: - Changed APIs to __rte_experimental. v2: - Corrected _RTE_BUS_CDX_H_ to RTE_BUS_CDX_H - Improved code comments. drivers/bus/cdx/bus_cdx_driver.h | 26 ++-------------- drivers/bus/cdx/cdx.c | 11 ++++--- drivers/bus/cdx/rte_bus_cdx.h | 52 ++++++++++++++++++++++++++++++++ drivers/bus/cdx/version.map | 11 +++++-- 4 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 drivers/bus/cdx/rte_bus_cdx.h diff --git a/drivers/bus/cdx/bus_cdx_driver.h b/drivers/bus/cdx/bus_cdx_driver.h index fcacdb5896..1571131417 100644 --- a/drivers/bus/cdx/bus_cdx_driver.h +++ b/drivers/bus/cdx/bus_cdx_driver.h @@ -37,6 +37,9 @@ struct rte_cdx_bus; static const char DRV_EXP_TAG(name, cdx_tbl_export)[] __rte_used = \ RTE_STR(table) +/** Device needs resource mapping */ +#define RTE_CDX_DRV_NEED_MAPPING 0x0001 + /** * A structure describing an ID for a CDX driver. Each driver provides a * table of these IDs for each device that it supports. @@ -107,29 +110,6 @@ struct rte_cdx_driver { uint32_t drv_flags; /**< Flags RTE_CDX_DRV_*. */ }; -/** - * Map the CDX device resources in user space virtual memory address. - * - * @param dev - * A pointer to a rte_cdx_device structure describing the device - * to use. - * - * @return - * 0 on success, <0 on error. - */ -__rte_internal -int rte_cdx_map_device(struct rte_cdx_device *dev); - -/** - * Unmap this device. - * - * @param dev - * A pointer to a rte_cdx_device structure describing the device - * to use. - */ -__rte_internal -void rte_cdx_unmap_device(struct rte_cdx_device *dev); - /** * Register a CDX driver. * diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c index f9526e08cc..fc8d3b668b 100644 --- a/drivers/bus/cdx/cdx.c +++ b/drivers/bus/cdx/cdx.c @@ -74,6 +74,7 @@ #include #include #include +#include #include @@ -383,10 +384,12 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr, CDX_BUS_DEBUG(" probe device %s using driver: %s", dev_name, dr->driver.name); - ret = cdx_vfio_map_resource(dev); - if (ret != 0) { - CDX_BUS_ERR("CDX map device failed: %d", ret); - goto error_map_device; + if (dr->drv_flags & RTE_CDX_DRV_NEED_MAPPING) { + ret = cdx_vfio_map_resource(dev); + if (ret != 0) { + CDX_BUS_ERR("CDX map device failed: %d", ret); + goto error_map_device; + } } /* call the driver probe() function */ diff --git a/drivers/bus/cdx/rte_bus_cdx.h b/drivers/bus/cdx/rte_bus_cdx.h new file mode 100644 index 0000000000..4ca12f90c4 --- /dev/null +++ b/drivers/bus/cdx/rte_bus_cdx.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2023, Advanced Micro Devices, Inc. + */ + +#ifndef RTE_BUS_CDX_H +#define RTE_BUS_CDX_H + +/** + * @file + * CDX device & driver interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward declarations */ +struct rte_cdx_device; + +/** + * Map the CDX device resources in user space virtual memory address. + * + * Note that driver should not call this function when flag + * RTE_CDX_DRV_NEED_MAPPING is set, as EAL will do that for + * you when it's on. + * + * @param dev + * A pointer to a rte_cdx_device structure describing the device + * to use. + * + * @return + * 0 on success, negative on error and positive if no driver + * is found for the device. + */ +__rte_experimental +int rte_cdx_map_device(struct rte_cdx_device *dev); + +/** + * Unmap this device. + * + * @param dev + * A pointer to a rte_cdx_device structure describing the device + * to use. + */ +__rte_experimental +void rte_cdx_unmap_device(struct rte_cdx_device *dev); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_BUS_CDX_H */ diff --git a/drivers/bus/cdx/version.map b/drivers/bus/cdx/version.map index 0a15d39ae8..4ce444572b 100644 --- a/drivers/bus/cdx/version.map +++ b/drivers/bus/cdx/version.map @@ -1,9 +1,16 @@ -INTERNAL { +EXPERIMENTAL { global: rte_cdx_map_device; - rte_cdx_register; rte_cdx_unmap_device; + + local: *; +}; + +INTERNAL { + global: + + rte_cdx_register; rte_cdx_unregister; rte_cdx_vfio_intr_disable; rte_cdx_vfio_intr_enable; -- 2.25.1