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 2DCF342DCC; Wed, 5 Jul 2023 08:52:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCE08406BC; Wed, 5 Jul 2023 08:52:57 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2057.outbound.protection.outlook.com [40.107.243.57]) by mails.dpdk.org (Postfix) with ESMTP id 9CDEC40150 for ; Wed, 5 Jul 2023 08:52:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ex8PRYobcwnURkVUb9XWUZoJ0J4b0DzCKXn0CImGNxCx2S6lNaP6k7TRajQFQhcrrK2XUtLod9S/6bvbZ45t54F+9H1N/H9ctb5QYufmyEBSfNcydcIUnSTuEHQ4LxDZjwNmVz7ZY+DuYHyVy4tYawlJBNco1KVxttCPHxy/ZSj25QYwhL7qlIsEPIch1AWHWUtKQ4IrJo0ee3b/4HEmGGLpLRVVb7wXD52BFBAUXtLslJmANqp7l1HvuGDmbjlJs7dwimS+0aVRrwYRY0hUjSmBbjN5Q7E20vg0IvJGPmVIUTZ3w7bRbszhJvP+T2gL0ri2Puud1oke236pBEz5Wg== 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=F/nqVTy973fUbdukAhbx0lUT0PJyJQO+cd4gll+Wl6g=; b=Gr9QuiTz7HMEoxiASThMCMRloJ+atoY6r2bBkuQpqIebka41anz1wEWgM1MVxtdH0uzkWsw5AdKazFfKuyeZGMag7cxz3oCeZASL4uxCQcTb1RiO5kiF5brErtVN4LN+lC2yEWNG+8rql0b2zXFk2KKBPXHKJNp9BkhEyccTuqxoQZaIGPRLaVx0nRtN5yhtypxAzsNNPjhiX/emB9hJYF4DzOsQBVgs4NfQS9GCu5xb5djHDcDAATTE9GmLxFMXvuXigkKVIDZbQEpeDG4FJCSnRMMb85M9RK2Nhe6vuyMhB5fgLd+VCoSW3/Htwqo1hRX0Q7FW250NpM0UaJ2vrA== 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=F/nqVTy973fUbdukAhbx0lUT0PJyJQO+cd4gll+Wl6g=; b=vZttwoRjZAXCf4KSPYYdg8pWOxmxMN7iLXVrT099g9HJ7u3q3eCXfuEb9BsxMabgfXe5/YswXDUWCKDveM2nIHXnP9yy74J/6Kzd8gQtHQYAZ1e7jz6QM90OklcBsxAlCv+Qu68Ajo+rfofFtP/5/VvqnnLq7h7vdeAZwBq+Txc= Received: from BN8PR04CA0053.namprd04.prod.outlook.com (2603:10b6:408:d4::27) by SJ1PR12MB6171.namprd12.prod.outlook.com (2603:10b6:a03:45a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Wed, 5 Jul 2023 06:52:54 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::c1) by BN8PR04CA0053.outlook.office365.com (2603:10b6:408:d4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 06:52:53 +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 BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.45 via Frontend Transport; Wed, 5 Jul 2023 06:52:53 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Wed, 5 Jul 2023 01:52:53 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 4 Jul 2023 23:52:53 -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; Wed, 5 Jul 2023 01:52:51 -0500 From: Abhijit Gangurde To: , CC: , , , , Abhijit Gangurde Subject: [PATCH v2] bus/cdx: provide driver flag for optional resource mapping Date: Wed, 5 Jul 2023 12:22:35 +0530 Message-ID: <20230705065235.4767-1-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230626103958.3139-1-abhijit.gangurde@amd.com> References: <20230626103958.3139-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: BN8NAM11FT010:EE_|SJ1PR12MB6171:EE_ X-MS-Office365-Filtering-Correlation-Id: 818b6ba0-4fc8-496e-6b09-08db7d247511 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rG1vXA4+j5lxDRqXW3rmYo2P0bTYBLUnMco2WMFhPE8JE4HteL96ta2JR1Ihs1I14apFlIuEFdkrqWRm6I2/RpjMuSFtOH4g4zucND7fHnQlmasULPlQVh7N8JeE+bTNYLS26n/n8OczDmOrnRroEmdGcT+Q/1hS1SyccoOrH2Tf9KHrMV4SIcMnpYtl62198NBTJPl66A9aksQEV64aNrFTEjItkJ9gMXnzybRKbnKP2wrwjcj2oxhfKc+zbe7wOOle+zwOxWS2fD2Le3xNyuEKw1duZT/JyPY6fHl2Oc5bazeAQIQzxyvuINJJNsmLFiO4n5a6V3uBzWtECz7CaqLnb5QxOzsClwdRj7hcLgnZU2VuBcM6DTXKJ28/AeEvBMalsN8N+D1uS0jb5wXySg+Hgu4K3CZvfvC8eH/lN8T6HVTrujDNLeCobt2zpoHAuXwUTVeG2d8oCW47+lbYm/xvZBKwi/EHxo5QeV7j7CkFxesPtX+1bCRfzOaDBPw/+cAk4mYl1gviOcyq0eRKda/ExSLYFEd2qRb7WWnpCIjc3m6ZkEfyb93xE4GvK6cNseUmB1YKWDtle6RGjPm9K38teA4YmB0XeR92deT9HsFKHQiyiVXga78CY2/7BDyP9uSk5QNVaUyWQufl9FRO2ll0eUoBwAxwwQ9wOTrsE8aoh+8bvZMgiwRDIqhny9slBfbgFPEJM3br1VWSGWpc99TCZaRRDDvyfOpAPxlUkBxiKtj0oayVw9zShZGtH3Lon+UI2/BMZH6bNpVCcn8hVg== 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)(39860400002)(136003)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(426003)(40460700003)(83380400001)(47076005)(2616005)(2906002)(336012)(356005)(81166007)(82740400003)(36860700001)(40480700001)(36756003)(8936002)(8676002)(110136005)(82310400005)(5660300002)(86362001)(54906003)(41300700001)(4326008)(70206006)(70586007)(6666004)(478600001)(186003)(6636002)(1076003)(44832011)(316002)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 06:52:53.9115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 818b6ba0-4fc8-496e-6b09-08db7d247511 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: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6171 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 --- 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 | 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..80acd668c0 --- /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