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 492EB42C46; Wed, 7 Jun 2023 06:24:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 27E2742D17; Wed, 7 Jun 2023 06:24:54 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) by mails.dpdk.org (Postfix) with ESMTP id 1D04940A84 for ; Wed, 7 Jun 2023 06:24:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTQ0pbnE+QqgA//mkEOUi3exE9fcY2/1AgQDi5QxJ97Eq1DgovHyvozXPuLu/9B3qEnvBCrP6l8dKEj6sDvl9cF0q3i6p+TNWRB+LwUG2b+61D6imbfMa6umB1RH6MnO1sH5hN8xdR1s4L9RjoZ29K8hhlqEZZPRZ6Z7/Shcd8+U1YRO2CQCDIrglrL5KIAWNUJo8uvX3vNTQ1xYk7cvzKdjT1u2PveP0Il6EMMpJBTf9wN6Szo/HoznXgJqe81K/Ki+9D2mUnSCDbCdqHGEpczJjvV/sKa05RDnYkKlVRhi/yLbY+xGuCAF1c1R7NuaCfSVBeLRam+AQnOpunGd9g== 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=prYhMKF16BYiz/RWDcLgUEsFA2ITZByZjDF3CWWlDgQ=; b=Rh0pdy58Sc6zbaV1CaZ85BKDuzKQh+kNkkEnXNIYWWZFpmifvrVxwYC5jbUAcYOTK6LNDA3lNgZ8fYqx+SDdXd1S087Rzr0++YvvdhQVqNFwGaPJEAQhY2kqqW2ZJxnvh0TFO/W98AEgrbgdq8ez3cU1I0ALpqTDIM/8mr+7oqm8pbo1WTHH9LW58WFPTVb0vYh3NQrQR0EFWEpt9K24G+0RMky/S8rDELskMPs3AP58QQmS3MOzJpViGqIP6Yr4eEq94x/CoDH+2wWrAju3on9zw6Q+EinDX+CxN8VUAKuRmFnhsYZCi9gGW64oUI/2bvrOGoKcxX1BnqcHXUbvnA== 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=prYhMKF16BYiz/RWDcLgUEsFA2ITZByZjDF3CWWlDgQ=; b=BGCdQBeIqxIEjXECi7+gEY9nkflAQUk+ugOi4RDO6YqMwXM/h2dh0dd7pXlMOPSilrFn8hPImxqHbN83nHfnmZVQsxcgyDSxC04fFmn3Qj7A0xBhzPjbI3nAp0YYASxL3WW2R7qhkaMA0ggjblaB/xZwFrx6i5rf42zjVjstmrs= Received: from CYZPR11CA0011.namprd11.prod.outlook.com (2603:10b6:930:8d::20) by LV8PR12MB9153.namprd12.prod.outlook.com (2603:10b6:408:185::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Wed, 7 Jun 2023 04:24:49 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:8d:cafe::96) by CYZPR11CA0011.outlook.office365.com (2603:10b6:930:8d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Wed, 7 Jun 2023 04:24:49 +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 CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.13 via Frontend Transport; Wed, 7 Jun 2023 04:24:48 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.2375.34; Tue, 6 Jun 2023 23:24:48 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 6 Jun 2023 23:24:47 -0500 Received: from xhdipdslab41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 6 Jun 2023 23:24:45 -0500 From: Nipun Gupta To: , , , , , CC: , , , Nipun Gupta Subject: [PATCH v8 2/4] bus/cdx: add DMA map and unmap support Date: Wed, 7 Jun 2023 09:54:23 +0530 Message-ID: <20230607042425.30714-3-nipun.gupta@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230607042425.30714-1-nipun.gupta@amd.com> References: <20230124140746.594066-1-nipun.gupta@amd.com> <20230607042425.30714-1-nipun.gupta@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|LV8PR12MB9153:EE_ X-MS-Office365-Filtering-Correlation-Id: a387093f-f5c5-4675-52dc-08db670f21a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PhLA9tUnJ4jRsP+7WMhnihTYK9EmGFSuKMW8l7biSoCoEuNXii+pZ0iT3Rih7JgytiGMrTPCc/KYmRYNr1zljzTDzwhkUf8VFJrT85Aq1n3ZyrWZ1026KGdFFmJhSsmqLj33VwXSk5Q1XW9DAjtr1BizEXQcce1tLztb2EzgpR/YwGOAy6I+l0eCDnaDhIhjswif2qlvxE5QZVxyncZVKqAsxMVt4mWe94We7RZKrbZRz5Lnm7V+879Xt7EuI3OO1z+/U7A4erY0SbNPY0oPdgW/Ay7qpFI5WGCQlBNAnE8rZUSc6q2zoVJVaGyj4NvDwHEm/Uaq5BKyX9hw6EE802x9Vu1G7KmR8K3b1EPBuElRNiM3/ZWysUT6lk5lIb8/yTnC+TPzL1MYErRVNMFmns/NF+rKVEWfbvS0ls8Ys7WP8g3H9RuCSZRpnq4AdP8J52yFQ+b0fUOkdp8PS3KjlqhZLl4iQyPZvNFcIc34YIOW5MySMl97pKaCKnCW7/kW1MvC4T0F/7YO3jSfhiKmSZI4UEfRqCKif5JTpbB8hkvmoJbU+MFdMh3uc0t7ohU74mn+SSINvmrODZ7KhO/OtRQvV6DE6Ji/oNZsngjbtJgMrmFvOZ04pSHXaZb68Ht1gq9WubVVL5utIVMZUZlWf22ezq+aECps+nEymAqaymItmqUcyLc/o+WLM0PgqF5w6ioPfHUgK1jrxXvngeKO1YyGc3Q+pgReTDarSmaBo1BMu4Ks6iEk40Kt0kUoht7LUJ+QVBEhp4m8UmqQSQ5h6A== 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)(136003)(396003)(39860400002)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(54906003)(110136005)(40460700003)(478600001)(40480700001)(44832011)(8936002)(8676002)(2906002)(36756003)(5660300002)(86362001)(82310400005)(4326008)(81166007)(70206006)(70586007)(356005)(316002)(82740400003)(2616005)(1076003)(41300700001)(26005)(47076005)(36860700001)(186003)(336012)(6666004)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 04:24:48.8772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a387093f-f5c5-4675-52dc-08db670f21a5 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: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9153 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 AMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class. Signed-off-by: Nipun Gupta Acked-by: Ferruh Yigit --- drivers/bus/cdx/cdx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c index 38515e7fda..0c6bac3a44 100644 --- a/drivers/bus/cdx/cdx.c +++ b/drivers/bus/cdx/cdx.c @@ -488,12 +488,42 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, return NULL; } +static int +cdx_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) +{ + RTE_SET_USED(dev); + + return rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD, + (uintptr_t)addr, iova, len); +} + +static int +cdx_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) +{ + RTE_SET_USED(dev); + + return rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD, + (uintptr_t)addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class(void) +{ + if (TAILQ_EMPTY(&rte_cdx_bus.device_list)) + return RTE_IOVA_DC; + + return RTE_IOVA_VA; +} + struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.driver_list), -- 2.17.1