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 5B804A0C4E; Mon, 8 Nov 2021 18:22:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B51FF4114A; Mon, 8 Nov 2021 18:21:58 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2089.outbound.protection.outlook.com [40.107.244.89]) by mails.dpdk.org (Postfix) with ESMTP id 48C6B4114A; Mon, 8 Nov 2021 18:21:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AY5LjcWAtq9BheH1kpL0WbFMcNTRA+gyDjO8bhCEuOW53TA5pXdovB/KwuZqtNO4WG6SjgIWfEE3FGbx9lmxMfM/D31nrY6V3mFg/The/G3RK30CVx1NjuRM5b8Zeic3sFJNy0jbnebBLfbSgNaFtblQYJYidmtYbVqcxziwNwySDorYPKkiUF+6ex2YI5aTdJLKnubiBb6PeJ08gdQlRKWFvjnqOllVYpI6rxeH3gr+MgnQkWF2lqFG7sc9nJe8+KE9XwLYkdygSZmtRoCuyNiOWUiGCwZXVLvkVtZjwnuVo/49P1yKafrANh1of7YZdRbTjcIZkAtaNcTuy3CjEQ== 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=DO/rcYttn5sV90gE4sGEueJVlZf6dKUCl+RAfD2Ounw=; b=Qdh6mDhR/on7edHetR7txMuKjpmc4wIuWHPzHt7pzD7YWuVPH0J5tL906ImCa7SRam8f3KLNSCI0YeU4TO//S/zOOmI7LNjV8S1Akkj4tl3Em0gINUD5Hne/5AnuLQVGCbPIlpAmSRnsDtOQrDWOGogU36Iant+wmKBrLSeTU41s2QBhDo2mWjA6TapidscI40uyz7v9hMSfa6wcMRdHDcZuPiWEmJCAO/jMa2D4tuvZ+01GDxMZbyM5VOiQDvY1myVCqIhac52NS54anC4nTySadLL23iNXt0agtLVOX75nX3t/gysWW4tyKAGHqdPbN5UpWz0BLCHB3VB9IgUrYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DO/rcYttn5sV90gE4sGEueJVlZf6dKUCl+RAfD2Ounw=; b=a8NqDk+E2UQ4kUfKntA+Hft8acbPRjllmiNCunmp9VLF/UgMLsi6maJCHgciNABf6VLyWzNUz/SZ/IIhD4RLZ9seF8XeXF6PCbjMIhmDk0NE6igywKyIfSHLQUsvYzhM9926zZv9Er0DpJ4mW9ZcFEDs0a0dPSXJHMigjxdngonvJslfbZeWvSLslJ16FopRWwIo+QkdJZdcR4Ktdo8Ws3DtNifti2max6Rrz6YcIZHB2P1hB/T8f9q+wReAsoLsnQ2BamPFCPTcI3e+ZOwPvUgX/jc9rwn1Dmv5oVnkng0QyBimBcfo1h6KIGCpE3NNFB0pEAA2QpaABmiEstH+Zg== Received: from BN9PR03CA0281.namprd03.prod.outlook.com (2603:10b6:408:f5::16) by DM6PR12MB4515.namprd12.prod.outlook.com (2603:10b6:5:2a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Mon, 8 Nov 2021 17:21:55 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::c9) by BN9PR03CA0281.outlook.office365.com (2603:10b6:408:f5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Mon, 8 Nov 2021 17:21:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 17:21:54 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov 2021 17:21:41 +0000 From: Matan Azrad To: Viacheslav Ovsiienko CC: , Thomas Monjalon , Michael Baum , Date: Mon, 8 Nov 2021 19:21:12 +0200 Message-ID: <20211108172113.2241853-5-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211108172113.2241853-1-matan@nvidia.com> References: <20211107152919.2158802-1-matan@nvidia.com> <20211108172113.2241853-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6fbd065b-a303-484c-f38d-08d9a2dc42dd X-MS-TrafficTypeDiagnostic: DM6PR12MB4515: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:130; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SBa4HYYUxtvK3kVk40eCuv+MIwoH5m6jgotEZOQKAgyXEVJSJ9GbY++iUf0puqpTZmv9ZPge5euTA/oQxNcgX2um8YGOpt61W0SAhLaqF935TXnOjCVVe9HkJgp3mSvzrJi1y5eSnqrDgyPRpqJuXmfdfVw49QhdHks7KXgW/sq3yfZdU5gfcY2ZYpnOsV5tnwW5RZZgJGFtj7ycST6oVWumVm/IP+FEAUKtdr0AanH79KZPaQjFFQSsmQlqsD272kxIVAFJHRbHaOIAGc3bnKcklFfr7KjKzaXO1AX0zGQYJe7LGeXjv0b/tQfqst8zIbopB2fQRBddo10UBmrndg3M1+DYaZZYnsHflp+e4xOZ3dNVB6+lJE0l+WI4f6WnbbyaBO+x4yibSRU0CPIjpBxKYteDVkZVTBx/O0q75wZoAOm5mE/lxwZFuev3WKvjubrZ/vLLEPX09/kspmTmnTmxsKLsA06ku2a+hQnGfpEoyt9pxF2dG6a7iuepVxwHnlLMa8hyhYPtm3eMyQ1q4yTD9aT2T2c0ya6lRSzlVzTSbRhqICZFhQEYolbukOez2JholdocMUcpnAccsqzgCxqwZqjSW62FQaVZC3oQRAF91b9/VOjVLjP8b4oByodt7/+Gn05rEzOHfZ3gg14hsAvibZnuhmbtyjEmORmA9hV8GE2GBQluqfryODlI2j2yAoVZtvZ4lZcivN0VffdhWw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(2906002)(26005)(426003)(86362001)(70586007)(2616005)(36860700001)(336012)(7636003)(356005)(16526019)(55016002)(83380400001)(316002)(82310400003)(8936002)(508600001)(1076003)(36906005)(186003)(6286002)(6666004)(6862004)(37006003)(70206006)(36756003)(6636002)(4326008)(8676002)(54906003)(47076005)(7696005)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 17:21:54.5724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fbd065b-a303-484c-f38d-08d9a2dc42dd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4515 Subject: [dpdk-dev] [PATCH v2 4/5] vdpa/mlx5: workaround guest MR registrations 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 Sender: "dev" From: Michael Baum Due to kernel issue in direct MKEY creation using the DevX API, this patch replaces the virtio MR creation to use Verbs API. Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions") Cc: stable@dpdk.org Signed-off-by: Michael Baum Signed-off-by: Matan Azrad --- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +++--- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 41 +++++++++---------------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index 3a7cf088b8..f290fb4895 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -59,10 +59,10 @@ struct mlx5_vdpa_event_qp { struct mlx5_vdpa_query_mr { SLIST_ENTRY(mlx5_vdpa_query_mr) next; - void *addr; - uint64_t length; - struct mlx5dv_devx_umem *umem; - struct mlx5_devx_obj *mkey; + union { + struct ibv_mr *mr; + struct mlx5_devx_obj *mkey; + }; int is_indirect; }; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c index d7707bbd91..b1b9053bff 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c @@ -23,9 +23,10 @@ mlx5_vdpa_mem_dereg(struct mlx5_vdpa_priv *priv) entry = SLIST_FIRST(&priv->mr_list); while (entry) { next = SLIST_NEXT(entry, next); - claim_zero(mlx5_devx_cmd_destroy(entry->mkey)); - if (!entry->is_indirect) - claim_zero(mlx5_glue->devx_umem_dereg(entry->umem)); + if (entry->is_indirect) + claim_zero(mlx5_devx_cmd_destroy(entry->mkey)); + else + claim_zero(mlx5_glue->dereg_mr(entry->mr)); SLIST_REMOVE(&priv->mr_list, entry, mlx5_vdpa_query_mr, next); rte_free(entry); entry = next; @@ -202,7 +203,6 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) goto error; } DRV_LOG(DEBUG, "Dump fill Mkey = %u.", priv->null_mr->lkey); - memset(&mkey_attr, 0, sizeof(mkey_attr)); for (i = 0; i < mem->nregions; i++) { reg = &mem->regions[i]; entry = rte_zmalloc(__func__, sizeof(*entry), 0); @@ -211,28 +211,15 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) DRV_LOG(ERR, "Failed to allocate mem entry memory."); goto error; } - entry->umem = mlx5_glue->devx_umem_reg(priv->cdev->ctx, - (void *)(uintptr_t)reg->host_user_addr, - reg->size, IBV_ACCESS_LOCAL_WRITE); - if (!entry->umem) { - DRV_LOG(ERR, "Failed to register Umem by Devx."); - ret = -errno; - goto error; - } - mkey_attr.addr = (uintptr_t)(reg->guest_phys_addr); - mkey_attr.size = reg->size; - mkey_attr.umem_id = entry->umem->umem_id; - mkey_attr.pd = priv->cdev->pdn; - mkey_attr.pg_access = 1; - entry->mkey = mlx5_devx_cmd_mkey_create(priv->cdev->ctx, - &mkey_attr); - if (!entry->mkey) { + entry->mr = mlx5_glue->reg_mr_iova(priv->cdev->pd, + (void *)(uintptr_t)(reg->host_user_addr), + reg->size, reg->guest_phys_addr, + IBV_ACCESS_LOCAL_WRITE); + if (!entry->mr) { DRV_LOG(ERR, "Failed to create direct Mkey."); ret = -rte_errno; goto error; } - entry->addr = (void *)(uintptr_t)(reg->host_user_addr); - entry->length = reg->size; entry->is_indirect = 0; if (i > 0) { uint64_t sadd; @@ -262,12 +249,13 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) for (k = 0; k < reg->size; k += klm_size) { klm_array[klm_index].byte_count = k + klm_size > reg->size ? reg->size - k : klm_size; - klm_array[klm_index].mkey = entry->mkey->id; + klm_array[klm_index].mkey = entry->mr->lkey; klm_array[klm_index].address = reg->guest_phys_addr + k; klm_index++; } SLIST_INSERT_HEAD(&priv->mr_list, entry, next); } + memset(&mkey_attr, 0, sizeof(mkey_attr)); mkey_attr.addr = (uintptr_t)(mem->regions[0].guest_phys_addr); mkey_attr.size = mem_size; mkey_attr.pd = priv->cdev->pdn; @@ -295,13 +283,8 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) priv->gpa_mkey_index = entry->mkey->id; return 0; error: - if (entry) { - if (entry->mkey) - mlx5_devx_cmd_destroy(entry->mkey); - if (entry->umem) - mlx5_glue->devx_umem_dereg(entry->umem); + if (entry) rte_free(entry); - } mlx5_vdpa_mem_dereg(priv); rte_errno = -ret; return ret; -- 2.25.1