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 B4AC342BF1; Mon, 5 Jun 2023 15:27:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A56C64021F; Mon, 5 Jun 2023 15:27:22 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by mails.dpdk.org (Postfix) with ESMTP id EF57F4003C for ; Mon, 5 Jun 2023 15:27:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Onfk5MveEp15/gY7e8E+x4LjS59SZKqqhQitK5l6JVZz23F+mHKhW/BqhRpmozUlPV4r7qFJPbPiJI2DMTbNv+Sg/qGwNKuA7bGob4e89awcL1hizw0w7auQz8TrgS9w0jfF3chSDfrxj2cn5cZt6GcH2f8m8Dr2PY3LUPLSGzJrg97V6vUsbE+7Igj+g0+50KwvRVIRLbP/0d8bLKs20BB/Py7qxxSPLDyuMEmLwhKm/YUTmIyUD82liSunuJlVUQApJihgP1/2bGAPeF5ynUXJjoVHZZGSyjW88OMq/PBVHjVMPRzn0SgdfHfITOQnsxfogRmjwTJt+CNssSIwHw== 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=boBOlggTlBYndkTP9q2T1bYEuSsK235HOmv7EAmWpl0DiPcvy1OnF5Ene3fJxqph/iJikFkpzic8k86aSykXLV0xjN0bIYGeEwv7I4BchTupP+O+DTm0w+nyjiJXKhD8wwte0V6hJx3+Jec0WPEa/gdv1MQKnzzfamlE212kNX2gAK0tG8yAxDLHICwpnljOCIEaNSbdnIG81am8s/0qoKXXZrssSyhJ6mjC56C+tNOCoUNlnnN+LHRNdVIoSY/3RCRB2xuK0aDH3R+fq/D7fTJO4R5KF7RxonK994e/YNyup40gBVqeYon9X7/jcSVQTOE1ZOTf1dkL9pHi1fgGGg== 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=vDlebP33phU2Hrk40XprpXMGFUwtkuABTFJ76FoIQi+cYWqqdcykpjlF27tL1nktJCtL6/1gU5DQYkBUqewloOqEWzmAOaCJM+YgWVjIg4yg5MBfYQiYVukwN9Zu0sQtRlGKec6v+89ltfW2/pma9c5irzyIgebta1njDj7lei0= Received: from DM6PR14CA0053.namprd14.prod.outlook.com (2603:10b6:5:18f::30) by SA1PR12MB7174.namprd12.prod.outlook.com (2603:10b6:806:2b1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Mon, 5 Jun 2023 13:27:19 +0000 Received: from DM6NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::8f) by DM6PR14CA0053.outlook.office365.com (2603:10b6:5:18f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Mon, 5 Jun 2023 13:27:19 +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 DM6NAM11FT041.mail.protection.outlook.com (10.13.172.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.33 via Frontend Transport; Mon, 5 Jun 2023 13:27:18 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Mon, 5 Jun 2023 08:27:14 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 5 Jun 2023 08:26:38 -0500 Received: from xhdipdslab41.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 5 Jun 2023 08:26:35 -0500 From: Nipun Gupta To: , , , , , CC: , , , Nipun Gupta Subject: [PATCH v6 2/4] bus/cdx: add DMA map and unmap support Date: Mon, 5 Jun 2023 18:56:22 +0530 Message-ID: <20230605132624.8626-3-nipun.gupta@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230605132624.8626-1-nipun.gupta@amd.com> References: <20230124140746.594066-1-nipun.gupta@amd.com> <20230605132624.8626-1-nipun.gupta@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT041:EE_|SA1PR12MB7174:EE_ X-MS-Office365-Filtering-Correlation-Id: e18b8b1d-4071-445b-2472-08db65c89622 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X3RgkH55teLEneI4kzy8groHpArfWes/mFwF+zKmDeDNgtaG98rQ4FLB1nSJtILjnP+XEwA/uyOUOw7GUGYM0/UTtg/8hggPrrYBb7XDIALDZNL8iOtDTtATf5+vJgNvm0MGsYM88OflQKfRF+4b767cl7ES2/OIWkSM3mX0mE3/NVa6NkUzts7qsiNbNSyuZdNY2gGQ+/1PIMlquru6xXFsOtJvKCDmnIeFgT6qDk6wPoSkNWhHoDwJUN9KuOIfdIg0d+VwnDbDZfcUi/ARefWKEOjbW7trEhDTNjlg30XpQhKwYXuFvY7GQ8TrsecIbz+YlQP+Fr1yxYfjjgw7xm6CXcR9xa+D+PcwfptFDoJE6OzO6p/Ya7a8Z3pxHWKvH1WmMYE7KN4HAsjUmZxfUjPc71A77pNGSLGfPqAi95dwvHo5LNhP1v8ROUk+qqcROR/xJhLHhChMClht8tHjPZ6uAU47dBgqfPvaPX6YETKPVQsyzPR9424G4v9LTxk9q9OByI6mxm3jpwLnYUO15+OTV1P2dThv6Z9kkFFYvh8XrPF9OZmKhYX962AArg3RVuTCMDimAO49cMUINb/KpXsKd/vNG8wjSJfqjeDq0X9siHdIoBu3uNyBSqM5YTlgZCacQ6itaQYRlbkObF4lJ1S9COSejnYqPu+JQorZW6qNV/i3U+qlQizkbF04XLpv7mwZc7I/mFlCla7Kwq231AF/hDjtTTjC9IHYfM7MGyAz3wxwUUrVV7iGT3QzdrKLg0eq2DWbjO6DFiq82Urv1w== 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)(376002)(396003)(136003)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(47076005)(336012)(426003)(82740400003)(44832011)(110136005)(54906003)(40480700001)(478600001)(8676002)(8936002)(41300700001)(316002)(70586007)(70206006)(356005)(81166007)(5660300002)(86362001)(40460700003)(4326008)(36756003)(6666004)(2906002)(36860700001)(82310400005)(186003)(1076003)(26005)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2023 13:27:18.8960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e18b8b1d-4071-445b-2472-08db65c89622 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: DM6NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7174 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