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 577C942D59; Mon, 26 Jun 2023 12:40:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4870142D30; Mon, 26 Jun 2023 12:40:21 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 2C9734067B for ; Mon, 26 Jun 2023 12:40:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lp9mygM+4Hy70vILEzTzB1xU+StYcnFyrnOOvTgTerfqAY8s+XLxR4e+HIX1k3n3Ufq5gLfITqpGLTGlrcfCXgl2lM0cay93pGVY/Q6RVOEDpq8X49JPTcmwVRtfPpTdgwDw/+i1pxkTIXynKnQyz45Zb6eF61JjjNKzJDtt5c6riVMQo8sSv2Ztem+vZSQsY4wvQS83wHKzTraVOb6LL32jR+276ULJ/UUFyNrll+DGevTlBo4qwkfA5/adaR49PcnOTx4BSAy+QueyMl3cOk2AJgx61zqjh5bmdFw426uuEcPEftp6l4ImNGi08GJd/yQeAHTibhqK8LMfMiCAAA== 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=5OV781BVIdLxbPu4sXZisYL9NMoilWXu1hJNU5JOUtQ=; b=HpRBdBvaVn3P8nSkX5uB+g1RSAXXrAvC3DdLRngOPx7r0gNZ2p2PpbETi2P1cDxbXulTeqPWALXgMNQXnKQrMeCiSithpGV3P74VwSOgY+1rKsELj8K/ur9yzZaO0HUvOm2mJ5kOpygTOuRfYkHHczpqk6hZ2RgPtpPpXloTEJ7RvsITibxxCcCwmDui36SUNzjhphExSWOBi6I9UzR2wqaRm7L5BmxLDe7eNBjCXWdxPwWka/2l7Wcm9inCLZFQeKz3go7aGUuDp0PrpcZouZ/QWA9RVCQ4k6sMuKcmHVZBfRC9kype/dJObSit14W9AjR5LXWsEnXkhk+dI0LwJQ== 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=5OV781BVIdLxbPu4sXZisYL9NMoilWXu1hJNU5JOUtQ=; b=Td4OtaKFmitGB/GHG8wukuyB4cZgNWhjLz4cczwRtKN3gUBt2jVbibEM/TvUuY9agpikSvMp9+C6pxC+RnhVpMJOqNP/ZkT4Dzr3U4p6jUgaMpCLmL3S0XUat25jsK0xAOU+zyBUvnX2u80AS+aWBW4hpGGuUi/11YJwTD15dxo= Received: from BN8PR16CA0029.namprd16.prod.outlook.com (2603:10b6:408:4c::42) by MN2PR12MB4343.namprd12.prod.outlook.com (2603:10b6:208:26f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Mon, 26 Jun 2023 10:40:16 +0000 Received: from BN8NAM11FT103.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::b2) by BN8PR16CA0029.outlook.office365.com (2603:10b6:408:4c::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.33 via Frontend Transport; Mon, 26 Jun 2023 10:40:16 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT103.mail.protection.outlook.com (10.13.176.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.47 via Frontend Transport; Mon, 26 Jun 2023 10:40:15 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 26 Jun 2023 05:40:15 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Mon, 26 Jun 2023 03:40:15 -0700 Received: from xhdipdslab59.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Mon, 26 Jun 2023 05:40:13 -0500 From: Abhijit Gangurde To: , CC: , , , Abhijit Gangurde Subject: [PATCH] bus/cdx: provide driver flag for optional resource mapping Date: Mon, 26 Jun 2023 16:09:58 +0530 Message-ID: <20230626103958.3139-1-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT103:EE_|MN2PR12MB4343:EE_ X-MS-Office365-Filtering-Correlation-Id: e86580bd-91f5-4afa-e4bc-08db7631baa2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SJyCa1cyek5gXSmRZLuAYaMJWGod6eAYxX+lYAC6czpbTXEqg4lMl4nsG8SyS2a/u18xuphvSwP88PqN5suImhf1MrjW3nQ0hoszQF+FCoExfoSnMfx1s1XmMEtyuEMaMSeh1kPOdK9Pg6yjYIi15le3OKgwacowcKCQJ38fX4qQKaOSo0tz7A7LiLN3uRB2x2l5B+Z5xJNIrGeq8Iu3G8cXLjP4n+Ycb+ZTg9uqoHPigmRraIiCVg8o4AD+GLf7cglRRJ+6YzqeaQ3eRX6GYHR+Ty3maJfziHU98YS2m0DQhq1AVhASAaZn5iTZUkuVd8FXyfRGJAsc8p5xbPciNHxegF1iTdQP++My/kBFMdZLZ8QBfxkQww0bpOVIFcO/Xode5fEAMVa8L6RuNyGfyPLlWczXSKoY32rEqrMwD3bAp7KlMIis7fHYU15c2A0m7nG5oH9hgJcU2nPr7hcdS6n/PqbAGh6EREFjkRTaNOe1G3rXn6oinEPg1bTCywmS0+xN4+I3UloRD0pPp6s2RUoV6+2hgaMtDEE/+0Rf8TY7xL6dne7Myux/bQX2V3gigqcSo8i4vBP8mDHbNaPqE7K8CCBF5LbkgvtZ5/pdKyt2BqG+75A8s3wKCJcaetRAw/1RBtOJ+mFELDYnUSIcVYcCImkBt3fAJwaAYcS68iKU2pyjq9NlY5NZ2BsA3Sgv+zRam/elIYSpJthF5t4uFXh5vFUibW4Y0v5zdWlRDikOZ6cCvZgV5kAMjj8ke/4GUMrGEYS3eXkl6xVjV1UOkg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(82310400005)(47076005)(478600001)(6666004)(54906003)(2616005)(426003)(110136005)(83380400001)(336012)(26005)(186003)(1076003)(2906002)(5660300002)(70206006)(44832011)(40460700003)(36756003)(356005)(4326008)(6636002)(40480700001)(82740400003)(70586007)(81166007)(316002)(86362001)(8936002)(8676002)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2023 10:40:15.9301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e86580bd-91f5-4afa-e4bc-08db7631baa2 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT103.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4343 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 --- drivers/bus/cdx/bus_cdx_driver.h | 26 ++--------------- drivers/bus/cdx/cdx.c | 11 ++++--- drivers/bus/cdx/rte_bus_cdx.h | 50 ++++++++++++++++++++++++++++++++ drivers/bus/cdx/version.map | 11 +++++-- 4 files changed, 69 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 28bbf92ed5..47dc4eabe7 100644 --- a/drivers/bus/cdx/cdx.c +++ b/drivers/bus/cdx/cdx.c @@ -74,6 +74,7 @@ #include #include #include +#include #include @@ -380,10 +381,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..b9280b5f7f --- /dev/null +++ b/drivers/bus/cdx/rte_bus_cdx.h @@ -0,0 +1,50 @@ +/* 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. + */ +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 + */ +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..cc7b1f821b 100644 --- a/drivers/bus/cdx/version.map +++ b/drivers/bus/cdx/version.map @@ -1,9 +1,16 @@ -INTERNAL { +DPDK_23 { 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