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 97D7B42C3E; Tue, 6 Jun 2023 12:03:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B08E342D12; Tue, 6 Jun 2023 12:03:22 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) by mails.dpdk.org (Postfix) with ESMTP id 021A342D12 for ; Tue, 6 Jun 2023 12:03:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtKGpdms21ba5NqUHrn44BE9F1krF76+104JlUB5cg6dIv3VkWxc5TzRN5SpNKBeSwNTGgPRdPTk7gu/OUvhedA3Mptrjm8m3f1VKxp8MZg7NYFM0tXKgHj4OkRaYtWLos240uAtxMs8JNbNRHJjP9K/WiCCi1FmjFmdT18PcoFFfo6mypv8Jy4Y3KCmK7yrpTzkFDdXWMy6SYZjtkvUm8lMrS4sNrNyrxgDm8duaa7K9dHq2Cv1W444ZyHR7iN2dL4hUU+M32LFtcSnPwCucnJL19DO8PqGSd8if1hnwrimnE2AzkbyCMMwVl2i9lhYWW0bkw2PIjxDiKuEZcBJPw== 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=khWdjEXjPSstadxktGWZ0sRg54xs1Rju1WHnVQoOndo=; b=X7MsLRNJsox6U0sYSXoiZFu4oxSGicmMQLfc942oRwvUGhtEC9Jr3rs5JJZsA3oRqWIJRJH9r1pabI2Q3vGHu8kxcoq3CuFoLIkDSKn52VYTpcoD9vTOmBF2+5OC0f61nDKE1lFukA0o4+2TCxlEoHWrPIPh1WQMJSG6GAvPXAwF13hE5e2lVqG5mjuTNplAyewhwyWLLN3fTKehM9qKlTGQVCype4AVYj8dMBhD+tMgFsCKtwSYWADzlj8rY66MZMZXdm0PjmQFcKWKdthdpNJhsleaJ7VlLJnnOOa4jVtRSOboPqVjYDh+o5Oi3jYQlogsVuoSI7SsFwXNBBhOxw== 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=khWdjEXjPSstadxktGWZ0sRg54xs1Rju1WHnVQoOndo=; b=XLj0HYRAx/ElK1e0vdZBjiikFoJ7de0zXJj/U/5YO2p5zyzHR7u6LeTT7VWlDLcxzAxgOsStEPdJ9bWirpVKMWct7uT1HafJK3ugtY9+Vnc9nL9LwAeoe2GpreKSpKlFw7LusE+lHOm1TSS3R0Doh7gmlYc3NbmNUfQR1BSgr2Q= Received: from MW4PR04CA0066.namprd04.prod.outlook.com (2603:10b6:303:6b::11) by SA1PR12MB8857.namprd12.prod.outlook.com (2603:10b6:806:38d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 10:03:18 +0000 Received: from CO1NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::f0) by MW4PR04CA0066.outlook.office365.com (2603:10b6:303:6b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Tue, 6 Jun 2023 10:03:18 +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 CO1NAM11FT070.mail.protection.outlook.com (10.13.175.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 10:03:17 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.2375.34; Tue, 6 Jun 2023 05:03:17 -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 05:03:14 -0500 From: Nipun Gupta To: , , , , , CC: , , , Nipun Gupta Subject: [PATCH v7 2/4] bus/cdx: add DMA map and unmap support Date: Tue, 6 Jun 2023 15:32:56 +0530 Message-ID: <20230606100258.26532-3-nipun.gupta@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230606100258.26532-1-nipun.gupta@amd.com> References: <20230124140746.594066-1-nipun.gupta@amd.com> <20230606100258.26532-1-nipun.gupta@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT070:EE_|SA1PR12MB8857:EE_ X-MS-Office365-Filtering-Correlation-Id: 852fbf00-7e0c-4ee0-0444-08db66754061 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hoHFPV44D64klW+Tkn29nThWr78RPD+SiVa5vUgfei9Tv/DttXC1HYXe7BUvEsSXIXt9wSxwsM4KBarMf/9F+9XT1+bP0DXJQHbJbEvtnRIqwwXMgDqlv0ojXpc1RxcXW/Y4901UTfsU2KDFCxr9wOw3UAjKlgZorYatsp2Vw5SBRhKrt2xHQKKAX14xhgSPzP2WKXASz0gtKNuFxu+whCUQFeYs645x+eleQga6zMPn/wP5egxitfaWZYpBMgakHSQ9A/W7J+uEoxPQLTjfil96f89mZ5kcejw0nxk/ueTUNGrSBUsyJQbjfoa6hpiTk2apez3IxWugRHT9sLyMPx6kMJzRsQF3cIPK8wmFnJ6yh3+qH359e0RPuR9GobxnbqFw0pTxE6IB9LiRLs4ZJJSo8B3emAftSD3D6QnmiUhYIr0JurC/mGZnNTBcAZSWBgz2ggb9O+a3eqXTEiOj0YCjqrxeBgnmdshKs7zqk45UjMNfoFbDE818TRUpmBFNx2+dR5a+JL0cVOsaD01bMPRCCbdbI7NNqZI65aa8LM6nfCgkwRp8dsWLCYCYSLA5JDcO6go553yHTt7pY3QBQcdDmeLoawDVQhZPDEIFNn+qhxe4VsysJzF88Bx0VIqK1Wc0vk5u2JSvvrKdLH6WvzPWWmKBuJPebFBndvtaJtiqM33wp4cl3bZOfE5zu8Dt0tqeRWWPRdB0AxT+NRhlCNZjSY7YKUHeRCGu0cn1al0zPoE8UvNXyA91UegLiX3pYwJH+VsAcMlAWEkH8HO6SA== 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)(136003)(376002)(39860400002)(346002)(396003)(451199021)(36840700001)(40470700004)(46966006)(6666004)(86362001)(5660300002)(186003)(26005)(110136005)(40460700003)(36756003)(44832011)(2906002)(8936002)(316002)(40480700001)(8676002)(41300700001)(356005)(4326008)(82740400003)(70586007)(81166007)(70206006)(54906003)(82310400005)(2616005)(478600001)(1076003)(36860700001)(47076005)(426003)(336012)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 10:03:17.8801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 852fbf00-7e0c-4ee0-0444-08db66754061 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: CO1NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8857 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 9386cb7a0a..9ad8f73424 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