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 2551AA0C41; Tue, 19 Oct 2021 22:57:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88F2741171; Tue, 19 Oct 2021 22:57:02 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2074.outbound.protection.outlook.com [40.107.236.74]) by mails.dpdk.org (Postfix) with ESMTP id 134A04115B for ; Tue, 19 Oct 2021 22:56:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TCanoHOBrCNebYF/K9GRft+F8NtBM3FndNlIP+Oot5Mnm5fJYrl8SricaRKLQ0ugDvUPDPZ+g5yRn1uul7SNfcjVPW10hRCxuTIjqBwRnaxNZ9K7HDiH0qIk3G0fJrtJejfZAYgfjK7yLtSnDEuFxPRLkBE/T691YUivDFXQUEN7NIgUPlYMAzeZf+5BFnbNUjo4kzCExw4kkAKnN18bU+kXq8rxVap8GulDF/kEkvh3Na9CxcxmpMxRvUbtfWtsE1vtzKcTZAMaD48kLJSceyZEtgn8rdJas3fAB4qepj16j+x1hM0RRpwKYH77V7JxXfztt/rIq9ZCnw6luJ2V0g== 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=tMV44nWYltVaHxq73kxSXlw0d2FCEe8oeUs6KPkoxos=; b=MM7WRbmRdaQUedQb2rTnK0R+QrfLG7rs/ZNAYRaQe0KmmsAcjie2F+MD36MBqAjMbHnw45ISnICFRsrsCWsKY6mlxCYn9YMAtIEZeEW/2e6+HQnUJ8Vzv/RL7Jvlw7SWJBpHkUInRM1VeG3XmQEZK0rYD97QxaqVeWtwWo1dEd/zFbFqYxhbCyKI+Zxl9vIJh4hnV0YLFTLRXiBJC2FcQJBO0c8yhNLBn5tgjZzJfbg/07sRtAfVHK/EcZocH3eevMuf7f4J3rI1AR6WZVILSghdmL9nTc7AjOLeR4j0wGXJ0dT4iFw+MddYuFOp4Z0RfJrp/k7yZ7oVr1l1GzaqEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=tMV44nWYltVaHxq73kxSXlw0d2FCEe8oeUs6KPkoxos=; b=Crl37RkXeF4vKdwEwQcb7ETJf9pnfeT9EiI3PWwqHFBYajjmdyvG6KMWLcED0ImA3FDtz+o2/83dOCZ+40/gdlbgDxLU/bOs1fy9jlrbu8/zm7AjsMrXZKgDzX1hIzblnEc+wNVTsannhi7Bel/toy3oqUFUlmkweImMZDJ41YSWai/R0hnaL6jtNy404TTpQR4O64+26eVGJVFYNDXcE/hcVJShDbUxFxvrgE3J8kGqHRHLyBJTIoCMnz3FhIqs1CFN3o8VEGY6IVvVQ7BvdkDXGBkIQLQwS13oXgo47VIV35g1xktQR+EUD0/LPUfR0UWPly4OHxh9MoMgCmMLfg== Received: from BN9PR03CA0910.namprd03.prod.outlook.com (2603:10b6:408:107::15) by DM6PR12MB4153.namprd12.prod.outlook.com (2603:10b6:5:212::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 20:56:42 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::4c) by BN9PR03CA0910.outlook.office365.com (2603:10b6:408:107::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17 via Frontend Transport; Tue, 19 Oct 2021 20:56:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 20:56:42 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 19 Oct 2021 20:56:40 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Date: Tue, 19 Oct 2021 23:55:54 +0300 Message-ID: <20211019205602.3188203-11-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019205602.3188203-1-michaelba@nvidia.com> References: <20211006220350.2357487-1-michaelba@nvidia.com> <20211019205602.3188203-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: 46b3ae7b-a636-4fb7-38aa-08d99342f44a X-MS-TrafficTypeDiagnostic: DM6PR12MB4153: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qXlNIaevas+aNj24m8ylharhce/PFJdfC43n647/+GB/I6i7Qt9XNRvKAGLD68YISiqXTvaUVtC4hmOwNeJ+lyGcyV8k9flXj04QPAD7UR4YMUs2xM0mF9uW6yLlRYt2c/oQRivZSG6kTfg9dqXZWjUu+q49Ery1c9qMgMBExQOLEGCqoT58TA8IrX2+tqBVOn55O4NdeorkvVhWY976ZXr5r0iNbOu7GXWAMgJipnzheWjFQukLdFJYJDCXuQOVYIaVFhN9mupl47QAGp6nLvZMhO0AdsJKpIHoWM3kn92IJ4dHJ+1TW89qMfV4dvRFcNsNEheuBfWCzzBFh0rb1SRg3DN2wQr/YMtafDdp5lwCowIY1PJHJi7ZUVSXRdb2+v1OwX4O0d4eJThy25vMsxDytvTHLhZYOwNMXuP2GR1YvXgYVrHqlM1xyqQUx4caJ0kps0ngu8Z8Arzwh9o2PcDC8WOHOTtgzRTzMdUap/bGF7giGDt3HArGBNNSFwxF2LX7uQX1fA2OohnopsQ2gMS4zPZI7WXYIkqhUxFEPbr4C6JA576O68ujhVrzhkN5yyWGLI6UqQfLWrHi1iSGIE6rIUa8fOR+58XZMEbhzh0mMUih9jD5Nk0FBx4gVFFuh2g7Z5qmjD+A9/KPiixv6eIJlFkr2BQLGkWVQTpTRUPtErHujkoH/LvsOzPPuGsthrnrYddia9/WiG6pVm2+Cw== 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)(46966006)(36840700001)(30864003)(36756003)(316002)(86362001)(54906003)(8936002)(70206006)(82310400003)(83380400001)(356005)(6666004)(7636003)(47076005)(2616005)(336012)(36860700001)(6916009)(16526019)(6286002)(186003)(107886003)(426003)(5660300002)(2876002)(1076003)(7696005)(2906002)(26005)(55016002)(4326008)(70586007)(508600001)(8676002)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 20:56:42.3556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46b3ae7b-a636-4fb7-38aa-08d99342f44a 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: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4153 Subject: [dpdk-dev] [PATCH v3 10/18] common/mlx5: share the protection domain object 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 Create shared Protection Domain in common area and add it and its PDN as fields of common device structure. Use this Protection Domain in all drivers and remove the PD and PDN fields from their private structure. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_common_os.c | 43 ++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 8 --- drivers/common/mlx5/mlx5_common.c | 11 ++++ drivers/common/mlx5/mlx5_common.h | 3 + drivers/common/mlx5/version.map | 2 - drivers/common/mlx5/windows/mlx5_common_os.c | 59 ++++++++++---------- drivers/common/mlx5/windows/mlx5_common_os.h | 3 - drivers/compress/mlx5/mlx5_compress.c | 58 +++---------------- drivers/crypto/mlx5/mlx5_crypto.c | 56 +++---------------- drivers/crypto/mlx5/mlx5_crypto.h | 2 - drivers/crypto/mlx5/mlx5_crypto_dek.c | 2 +- drivers/net/mlx5/linux/mlx5_mp_os.c | 2 +- drivers/net/mlx5/linux/mlx5_os.c | 37 +----------- drivers/net/mlx5/linux/mlx5_verbs.c | 14 ++--- drivers/net/mlx5/mlx5.c | 27 +++------ drivers/net/mlx5/mlx5.h | 3 - drivers/net/mlx5/mlx5_devx.c | 4 +- drivers/net/mlx5/mlx5_flow.c | 2 +- drivers/net/mlx5/mlx5_flow_aso.c | 17 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 17 +++--- drivers/net/mlx5/mlx5_mr.c | 12 ++-- drivers/net/mlx5/mlx5_rxq.c | 4 +- drivers/net/mlx5/mlx5_trigger.c | 3 +- drivers/net/mlx5/mlx5_txpp.c | 4 +- drivers/net/mlx5/windows/mlx5_os.c | 21 ------- drivers/regex/mlx5/mlx5_regex.c | 10 ---- drivers/regex/mlx5/mlx5_regex.h | 21 ------- drivers/regex/mlx5/mlx5_regex_control.c | 6 +- drivers/regex/mlx5/mlx5_regex_fastpath.c | 13 ++--- drivers/vdpa/mlx5/mlx5_vdpa.c | 38 +------------ drivers/vdpa/mlx5/mlx5_vdpa.h | 2 - drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 2 +- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 6 +- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 2 +- 35 files changed, 167 insertions(+), 349 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 341822cf71..8db3fe790a 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -406,6 +406,49 @@ mlx5_glue_constructor(void) mlx5_glue = NULL; } +/** + * Allocate Protection Domain object and extract its pdn using DV API. + * + * @param[out] cdev + * Pointer to the mlx5 device. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_os_pd_create(struct mlx5_common_device *cdev) +{ +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + struct mlx5dv_obj obj; + struct mlx5dv_pd pd_info; + int ret; +#endif + + cdev->pd = mlx5_glue->alloc_pd(cdev->ctx); + if (cdev->pd == NULL) { + DRV_LOG(ERR, "Failed to allocate PD."); + return errno ? -errno : -ENOMEM; + } + if (cdev->config.devx == 0) + return 0; +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + obj.pd.in = cdev->pd; + obj.pd.out = &pd_info; + ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); + if (ret != 0) { + DRV_LOG(ERR, "Fail to get PD object info."); + mlx5_glue->dealloc_pd(cdev->pd); + cdev->pd = NULL; + return -errno; + } + cdev->pdn = pd_info.pdn; + return 0; +#else + DRV_LOG(ERR, "Cannot get pdn - no DV support."); + return -ENOTSUP; +#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ +} + static struct ibv_device * mlx5_os_get_ibv_device(const struct rte_pci_addr *addr) { diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index 0e605c3a9e..c2957f91ec 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -203,14 +203,6 @@ mlx5_os_get_devx_uar_page_id(void *uar) #endif } -__rte_internal -static inline void * -mlx5_os_alloc_pd(void *ctx) -{ - return mlx5_glue->alloc_pd(ctx); -} - -__rte_internal static inline int mlx5_os_dealloc_pd(void *pd) { diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 5786b5c0b9..ec246c15f9 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -320,6 +320,10 @@ mlx5_dev_to_pci_str(const struct rte_device *dev, char *addr, size_t size) static void mlx5_dev_hw_global_release(struct mlx5_common_device *cdev) { + if (cdev->pd != NULL) { + claim_zero(mlx5_os_dealloc_pd(cdev->pd)); + cdev->pd = NULL; + } if (cdev->ctx != NULL) { claim_zero(mlx5_glue->close_device(cdev->ctx)); cdev->ctx = NULL; @@ -346,7 +350,14 @@ mlx5_dev_hw_global_prepare(struct mlx5_common_device *cdev, uint32_t classes) ret = mlx5_os_open_device(cdev, classes); if (ret < 0) return ret; + /* Allocate Protection Domain object and extract its pdn. */ + ret = mlx5_os_pd_create(cdev); + if (ret) + goto error; return 0; +error: + mlx5_dev_hw_global_release(cdev); + return ret; } static void diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 066860045a..d72002ca3c 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -346,6 +346,8 @@ struct mlx5_common_device { TAILQ_ENTRY(mlx5_common_device) next; uint32_t classes_loaded; void *ctx; /* Verbs/DV/DevX context. */ + void *pd; /* Protection Domain. */ + uint32_t pdn; /* Protection Domain Number. */ struct mlx5_common_dev_config config; /* Device configuration. */ }; @@ -447,5 +449,6 @@ mlx5_dev_is_pci(const struct rte_device *dev); /* mlx5_common_os.c */ int mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes); +int mlx5_os_pd_create(struct mlx5_common_device *cdev); #endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 24925fc4e4..44c4593888 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -135,8 +135,6 @@ INTERNAL { mlx5_nl_vlan_vmwa_create; # WINDOWS_NO_EXPORT mlx5_nl_vlan_vmwa_delete; # WINDOWS_NO_EXPORT - mlx5_os_alloc_pd; - mlx5_os_dealloc_pd; mlx5_os_dereg_mr; mlx5_os_reg_mr; mlx5_os_umem_dereg; diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index b7178cbbcf..4d0f1e92e3 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -25,35 +25,6 @@ mlx5_glue_constructor(void) { } -/** - * Allocate PD. Given a DevX context object - * return an mlx5-pd object. - * - * @param[in] ctx - * Pointer to context. - * - * @return - * The mlx5_pd if pd is valid, NULL and errno otherwise. - */ -void * -mlx5_os_alloc_pd(void *ctx) -{ - struct mlx5_pd *ppd = mlx5_malloc(MLX5_MEM_ZERO, sizeof(struct mlx5_pd), - 0, SOCKET_ID_ANY); - if (!ppd) - return NULL; - - struct mlx5_devx_obj *obj = mlx5_devx_cmd_alloc_pd(ctx); - if (!obj) { - mlx5_free(ppd); - return NULL; - } - ppd->obj = obj; - ppd->pdn = obj->id; - ppd->devx_ctx = ctx; - return ppd; -} - /** * Release PD. Releases a given mlx5_pd object * @@ -73,6 +44,36 @@ mlx5_os_dealloc_pd(void *pd) return 0; } +/** + * Allocate Protection Domain object and extract its pdn using DV API. + * + * @param[out] dev + * Pointer to the mlx5 device. + * + * @return + * 0 on success, a negative value otherwise. + */ +int +mlx5_os_pd_create(struct mlx5_common_device *cdev) +{ + struct mlx5_pd *pd; + + pd = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pd), 0, SOCKET_ID_ANY); + if (!pd) + return -1; + struct mlx5_devx_obj *obj = mlx5_devx_cmd_alloc_pd(cdev->ctx); + if (!obj) { + mlx5_free(pd); + return -1; + } + pd->obj = obj; + pd->pdn = obj->id; + pd->devx_ctx = cdev->ctx; + cdev->pd = pd; + cdev->pdn = pd->pdn; + return 0; +} + /** * Detect if a devx_device_bdf object has identical DBDF values to the * rte_pci_addr found in bus/pci probing. diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h index 3756e1959b..c99645aefd 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.h +++ b/drivers/common/mlx5/windows/mlx5_common_os.h @@ -248,9 +248,6 @@ mlx5_os_devx_subscribe_devx_event(void *eventc, return -ENOTSUP; } -__rte_internal -void *mlx5_os_alloc_pd(void *ctx); -__rte_internal int mlx5_os_dealloc_pd(void *pd); __rte_internal void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access); diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 246a9c994b..4c8e67c4df 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -38,11 +38,9 @@ struct mlx5_compress_priv { struct rte_compressdev *compressdev; struct mlx5_common_device *cdev; /* Backend mlx5 device. */ void *uar; - uint32_t pdn; /* Protection Domain number. */ uint8_t min_block_size; uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */ /* Minimum huffman block size supported by the device. */ - struct ibv_pd *pd; struct rte_compressdev_config dev_config; LIST_HEAD(xform_list, mlx5_compress_xform) xform_list; rte_spinlock_t xform_sl; @@ -190,7 +188,7 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, .uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar), }; struct mlx5_devx_qp_attr qp_attr = { - .pd = priv->pdn, + .pd = priv->cdev->pdn, .uar_index = mlx5_os_get_devx_uar_page_id(priv->uar), .user_index = qp_id, }; @@ -230,7 +228,7 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp->priv = priv; qp->ops = (struct rte_comp_op **)RTE_ALIGN((uintptr_t)(qp + 1), RTE_CACHE_LINE_SIZE); - if (mlx5_common_verbs_reg_mr(priv->pd, opaq_buf, qp->entries_n * + if (mlx5_common_verbs_reg_mr(priv->cdev->pd, opaq_buf, qp->entries_n * sizeof(struct mlx5_gga_compress_opaque), &qp->opaque_mr) != 0) { rte_free(opaq_buf); @@ -469,8 +467,8 @@ mlx5_compress_addr2mr(struct mlx5_compress_priv *priv, uintptr_t addr, if (likely(lkey != UINT32_MAX)) return lkey; /* Take slower bottom-half on miss. */ - return mlx5_mr_addr2mr_bh(priv->pd, 0, &priv->mr_scache, mr_ctrl, addr, - !!(ol_flags & EXT_ATTACHED_MBUF)); + return mlx5_mr_addr2mr_bh(priv->cdev->pd, 0, &priv->mr_scache, mr_ctrl, + addr, !!(ol_flags & EXT_ATTACHED_MBUF)); } static __rte_always_inline uint32_t @@ -691,12 +689,8 @@ mlx5_compress_dequeue_burst(void *queue_pair, struct rte_comp_op **ops, } static void -mlx5_compress_hw_global_release(struct mlx5_compress_priv *priv) +mlx5_compress_uar_release(struct mlx5_compress_priv *priv) { - if (priv->pd != NULL) { - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); - priv->pd = NULL; - } if (priv->uar != NULL) { mlx5_glue->devx_free_uar(priv->uar); priv->uar = NULL; @@ -704,46 +698,12 @@ mlx5_compress_hw_global_release(struct mlx5_compress_priv *priv) } static int -mlx5_compress_pd_create(struct mlx5_compress_priv *priv) +mlx5_compress_uar_prepare(struct mlx5_compress_priv *priv) { -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret; - - priv->pd = mlx5_glue->alloc_pd(priv->cdev->ctx); - if (priv->pd == NULL) { - DRV_LOG(ERR, "Failed to allocate PD."); - return errno ? -errno : -ENOMEM; - } - obj.pd.in = priv->pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret != 0) { - DRV_LOG(ERR, "Fail to get PD object info."); - mlx5_glue->dealloc_pd(priv->pd); - priv->pd = NULL; - return -errno; - } - priv->pdn = pd_info.pdn; - return 0; -#else - (void)priv; - DRV_LOG(ERR, "Cannot get pdn - no DV support."); - return -ENOTSUP; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -} - -static int -mlx5_compress_hw_global_prepare(struct mlx5_compress_priv *priv) -{ - if (mlx5_compress_pd_create(priv) != 0) - return -1; priv->uar = mlx5_devx_alloc_uar(priv->cdev->ctx, -1); if (priv->uar == NULL || mlx5_os_get_devx_uar_reg_addr(priv->uar) == NULL) { rte_errno = errno; - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); DRV_LOG(ERR, "Failed to allocate UAR."); return -1; } @@ -839,14 +799,14 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev) priv->compressdev = compressdev; priv->min_block_size = att.compress_min_block_size; priv->qp_ts_format = att.qp_ts_format; - if (mlx5_compress_hw_global_prepare(priv) != 0) { + if (mlx5_compress_uar_prepare(priv) != 0) { rte_compressdev_pmd_destroy(priv->compressdev); return -1; } if (mlx5_mr_btree_init(&priv->mr_scache.cache, MLX5_MR_BTREE_CACHE_N * 2, rte_socket_id()) != 0) { DRV_LOG(ERR, "Failed to allocate shared cache MR memory."); - mlx5_compress_hw_global_release(priv); + mlx5_compress_uar_release(priv); rte_compressdev_pmd_destroy(priv->compressdev); rte_errno = ENOMEM; return -rte_errno; @@ -881,7 +841,7 @@ mlx5_compress_dev_remove(struct mlx5_common_device *cdev) rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB", NULL); mlx5_mr_release_cache(&priv->mr_scache); - mlx5_compress_hw_global_release(priv); + mlx5_compress_uar_release(priv); rte_compressdev_pmd_destroy(priv->compressdev); } return 0; diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 10ac633c77..b22b7836e1 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -333,8 +333,8 @@ mlx5_crypto_addr2mr(struct mlx5_crypto_priv *priv, uintptr_t addr, if (likely(lkey != UINT32_MAX)) return lkey; /* Take slower bottom-half on miss. */ - return mlx5_mr_addr2mr_bh(priv->pd, 0, &priv->mr_scache, mr_ctrl, addr, - !!(ol_flags & EXT_ATTACHED_MBUF)); + return mlx5_mr_addr2mr_bh(priv->cdev->pd, 0, &priv->mr_scache, mr_ctrl, + addr, !!(ol_flags & EXT_ATTACHED_MBUF)); } static __rte_always_inline uint32_t @@ -610,7 +610,7 @@ mlx5_crypto_indirect_mkeys_prepare(struct mlx5_crypto_priv *priv, struct mlx5_umr_wqe *umr; uint32_t i; struct mlx5_devx_mkey_attr attr = { - .pd = priv->pdn, + .pd = priv->cdev->pdn, .umr_en = 1, .crypto_en = 1, .set_remote_rw = 1, @@ -664,7 +664,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, DRV_LOG(ERR, "Failed to create CQ."); goto error; } - attr.pd = priv->pdn; + attr.pd = priv->cdev->pdn; attr.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar); attr.cqn = qp->cq_obj.cq->id; attr.rq_size = 0; @@ -754,12 +754,8 @@ static struct rte_cryptodev_ops mlx5_crypto_ops = { }; static void -mlx5_crypto_hw_global_release(struct mlx5_crypto_priv *priv) +mlx5_crypto_uar_release(struct mlx5_crypto_priv *priv) { - if (priv->pd != NULL) { - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); - priv->pd = NULL; - } if (priv->uar != NULL) { mlx5_glue->devx_free_uar(priv->uar); priv->uar = NULL; @@ -767,47 +763,13 @@ mlx5_crypto_hw_global_release(struct mlx5_crypto_priv *priv) } static int -mlx5_crypto_pd_create(struct mlx5_crypto_priv *priv) +mlx5_crypto_uar_prepare(struct mlx5_crypto_priv *priv) { -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret; - - priv->pd = mlx5_glue->alloc_pd(priv->cdev->ctx); - if (priv->pd == NULL) { - DRV_LOG(ERR, "Failed to allocate PD."); - return errno ? -errno : -ENOMEM; - } - obj.pd.in = priv->pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret != 0) { - DRV_LOG(ERR, "Fail to get PD object info."); - mlx5_glue->dealloc_pd(priv->pd); - priv->pd = NULL; - return -errno; - } - priv->pdn = pd_info.pdn; - return 0; -#else - (void)priv; - DRV_LOG(ERR, "Cannot get pdn - no DV support."); - return -ENOTSUP; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -} - -static int -mlx5_crypto_hw_global_prepare(struct mlx5_crypto_priv *priv) -{ - if (mlx5_crypto_pd_create(priv) != 0) - return -1; priv->uar = mlx5_devx_alloc_uar(priv->cdev->ctx, -1); if (priv->uar) priv->uar_addr = mlx5_os_get_devx_uar_reg_addr(priv->uar); if (priv->uar == NULL || priv->uar_addr == NULL) { rte_errno = errno; - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); DRV_LOG(ERR, "Failed to allocate UAR."); return -1; } @@ -1011,14 +973,14 @@ mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) priv->login_obj = login; priv->crypto_dev = crypto_dev; priv->qp_ts_format = attr.qp_ts_format; - if (mlx5_crypto_hw_global_prepare(priv) != 0) { + if (mlx5_crypto_uar_prepare(priv) != 0) { rte_cryptodev_pmd_destroy(priv->crypto_dev); return -1; } if (mlx5_mr_btree_init(&priv->mr_scache.cache, MLX5_MR_BTREE_CACHE_N * 2, rte_socket_id()) != 0) { DRV_LOG(ERR, "Failed to allocate shared cache MR memory."); - mlx5_crypto_hw_global_release(priv); + mlx5_crypto_uar_release(priv); rte_cryptodev_pmd_destroy(priv->crypto_dev); rte_errno = ENOMEM; return -rte_errno; @@ -1066,7 +1028,7 @@ mlx5_crypto_dev_remove(struct mlx5_common_device *cdev) rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB", NULL); mlx5_mr_release_cache(&priv->mr_scache); - mlx5_crypto_hw_global_release(priv); + mlx5_crypto_uar_release(priv); rte_cryptodev_pmd_destroy(priv->crypto_dev); claim_zero(mlx5_devx_cmd_destroy(priv->login_obj)); } diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index 14dd3b9c9a..27ae9cff2c 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -23,10 +23,8 @@ struct mlx5_crypto_priv { struct rte_cryptodev *crypto_dev; void *uar; /* User Access Region. */ volatile uint64_t *uar_addr; - uint32_t pdn; /* Protection Domain number. */ uint32_t max_segs_num; /* Maximum supported data segs. */ uint8_t qp_ts_format; /* Whether QP supports timestamp formats. */ - struct ibv_pd *pd; struct mlx5_hlist *dek_hlist; /* Dek hash list. */ struct rte_cryptodev_config dev_config; struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */ diff --git a/drivers/crypto/mlx5/mlx5_crypto_dek.c b/drivers/crypto/mlx5/mlx5_crypto_dek.c index 94f21ec036..de0d2545d1 100644 --- a/drivers/crypto/mlx5/mlx5_crypto_dek.c +++ b/drivers/crypto/mlx5/mlx5_crypto_dek.c @@ -94,7 +94,7 @@ mlx5_crypto_dek_create_cb(void *tool_ctx __rte_unused, void *cb_ctx) struct mlx5_crypto_dek *dek = rte_zmalloc(__func__, sizeof(*dek), RTE_CACHE_LINE_SIZE); struct mlx5_devx_dek_attr dek_attr = { - .pd = ctx->priv->pdn, + .pd = ctx->priv->cdev->pdn, .key_purpose = MLX5_CRYPTO_KEY_PURPOSE_AES_XTS, .has_keytag = 1, }; diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c index 35b2dfd3b2..286a7caf36 100644 --- a/drivers/net/mlx5/linux/mlx5_mp_os.c +++ b/drivers/net/mlx5/linux/mlx5_mp_os.c @@ -90,7 +90,7 @@ mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer) switch (param->type) { case MLX5_MP_REQ_CREATE_MR: mp_init_msg(&priv->mp_id, &mp_res, param->type); - lkey = mlx5_mr_create_primary(priv->sh->pd, + lkey = mlx5_mr_create_primary(cdev->pd, &priv->sh->share_cache, &entry, param->args.addr, cdev->config.mr_ext_memseg_en); diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 6b02decaec..36927e0dcc 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -785,7 +785,7 @@ mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev) .wq_type = IBV_WQT_RQ, .max_wr = 1, .max_sge = 1, - .pd = priv->sh->pd, + .pd = priv->sh->cdev->pd, .cq = cq, }); if (wq) { @@ -2711,41 +2711,6 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) return mlx5_os_auxiliary_probe(cdev); } -/** - * Extract pdn of PD object using DV API. - * - * @param[in] pd - * Pointer to the verbs PD object. - * @param[out] pdn - * Pointer to the PD object number variable. - * - * @return - * 0 on success, error value otherwise. - */ -int -mlx5_os_get_pdn(void *pd, uint32_t *pdn) -{ -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret = 0; - - obj.pd.in = pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret) { - DRV_LOG(DEBUG, "Fail to get PD object info"); - return ret; - } - *pdn = pd_info.pdn; - return 0; -#else - (void)pd; - (void)pdn; - return -ENOTSUP; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -} - /** * Install shared asynchronous device events handler. * This function is implemented to support event sharing diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 981fc2ee7c..fb10dd0839 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -289,7 +289,7 @@ mlx5_rxq_ibv_wq_create(struct rte_eth_dev *dev, uint16_t idx) .max_wr = wqe_n >> rxq_data->sges_n, /* Max number of scatter/gather elements in a WR. */ .max_sge = 1 << rxq_data->sges_n, - .pd = priv->sh->pd, + .pd = priv->sh->cdev->pd, .cq = rxq_obj->ibv_cq, .comp_mask = IBV_WQ_FLAGS_CVLAN_STRIPPING | 0, .create_flags = (rxq_data->vlan_strip ? @@ -627,7 +627,7 @@ mlx5_ibv_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, - .pd = priv->sh->pd, + .pd = priv->sh->cdev->pd, }, &qp_init_attr); #else @@ -648,7 +648,7 @@ mlx5_ibv_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, - .pd = priv->sh->pd, + .pd = priv->sh->cdev->pd, }); #endif if (!qp) { @@ -741,7 +741,7 @@ mlx5_rxq_ibv_obj_drop_create(struct rte_eth_dev *dev) .wq_type = IBV_WQT_RQ, .max_wr = 1, .max_sge = 1, - .pd = priv->sh->pd, + .pd = priv->sh->cdev->pd, .cq = rxq->ibv_cq, }); if (!rxq->wq) { @@ -807,7 +807,7 @@ mlx5_ibv_drop_action_create(struct rte_eth_dev *dev) .rx_hash_fields_mask = 0, }, .rwq_ind_tbl = ind_tbl, - .pd = priv->sh->pd + .pd = priv->sh->cdev->pd }); if (!hrxq->qp) { DRV_LOG(DEBUG, "Port %u cannot allocate QP for drop queue.", @@ -895,7 +895,7 @@ mlx5_txq_ibv_qp_create(struct rte_eth_dev *dev, uint16_t idx) qp_attr.qp_type = IBV_QPT_RAW_PACKET, /* Do *NOT* enable this, completions events are managed per Tx burst. */ qp_attr.sq_sig_all = 0; - qp_attr.pd = priv->sh->pd; + qp_attr.pd = priv->sh->cdev->pd; qp_attr.comp_mask = IBV_QP_INIT_ATTR_PD; if (txq_data->inlen_send) qp_attr.cap.max_inline_data = txq_ctrl->max_inline_data; @@ -1117,7 +1117,7 @@ mlx5_rxq_ibv_obj_dummy_lb_create(struct rte_eth_dev *dev) &(struct ibv_qp_init_attr_ex){ .qp_type = IBV_QPT_RAW_PACKET, .comp_mask = IBV_QP_INIT_ATTR_PD, - .pd = sh->pd, + .pd = sh->cdev->pd, .send_cq = sh->self_lb.ibv_cq, .recv_cq = sh->self_lb.ibv_cq, .cap.max_recv_wr = 1, diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 6c50c43951..1bb490c5e7 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1109,7 +1109,7 @@ mlx5_dev_ctx_shared_mempool_unregister(struct mlx5_dev_ctx_shared *sh, mlx5_mp_id_init(&mp_id, 0); if (mlx5_mr_mempool_unregister(&sh->share_cache, mp, &mp_id) < 0) DRV_LOG(WARNING, "Failed to unregister mempool %s for PD %p: %s", - mp->name, sh->pd, rte_strerror(rte_errno)); + mp->name, sh->cdev->pd, rte_strerror(rte_errno)); } /** @@ -1129,10 +1129,11 @@ mlx5_dev_ctx_shared_mempool_register_cb(struct rte_mempool *mp, void *arg) int ret; mlx5_mp_id_init(&mp_id, 0); - ret = mlx5_mr_mempool_register(&sh->share_cache, sh->pd, mp, &mp_id); + ret = mlx5_mr_mempool_register(&sh->share_cache, sh->cdev->pd, mp, + &mp_id); if (ret < 0 && rte_errno != EEXIST) DRV_LOG(ERR, "Failed to register existing mempool %s for PD %p: %s", - mp->name, sh->pd, rte_strerror(rte_errno)); + mp->name, sh->cdev->pd, rte_strerror(rte_errno)); } /** @@ -1171,10 +1172,11 @@ mlx5_dev_ctx_shared_mempool_event_cb(enum rte_mempool_event event, switch (event) { case RTE_MEMPOOL_EVENT_READY: mlx5_mp_id_init(&mp_id, 0); - if (mlx5_mr_mempool_register(&sh->share_cache, sh->pd, mp, + if (mlx5_mr_mempool_register(&sh->share_cache, sh->cdev->pd, mp, &mp_id) < 0) DRV_LOG(ERR, "Failed to register new mempool %s for PD %p: %s", - mp->name, sh->pd, rte_strerror(rte_errno)); + mp->name, sh->cdev->pd, + rte_strerror(rte_errno)); break; case RTE_MEMPOOL_EVENT_DESTROY: mlx5_dev_ctx_shared_mempool_unregister(sh, mp); @@ -1306,18 +1308,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, sh->port[i].ih_port_id = RTE_MAX_ETHPORTS; sh->port[i].devx_ih_port_id = RTE_MAX_ETHPORTS; } - sh->pd = mlx5_os_alloc_pd(sh->cdev->ctx); - if (sh->pd == NULL) { - DRV_LOG(ERR, "PD allocation failure"); - err = ENOMEM; - goto error; - } if (sh->devx) { - err = mlx5_os_get_pdn(sh->pd, &sh->pdn); - if (err) { - DRV_LOG(ERR, "Fail to extract pdn from PD"); - goto error; - } sh->td = mlx5_devx_cmd_create_td(sh->cdev->ctx); if (!sh->td) { DRV_LOG(ERR, "TD allocation failure"); @@ -1405,8 +1396,6 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, mlx5_glue->devx_free_uar(sh->devx_rx_uar); if (sh->tx_uar) mlx5_glue->devx_free_uar(sh->tx_uar); - if (sh->pd) - claim_zero(mlx5_os_dealloc_pd(sh->pd)); mlx5_free(sh); MLX5_ASSERT(err > 0); rte_errno = err; @@ -1487,8 +1476,6 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh) mlx5_glue->devx_free_uar(sh->tx_uar); sh->tx_uar = NULL; } - if (sh->pd) - claim_zero(mlx5_os_dealloc_pd(sh->pd)); if (sh->tis) claim_zero(mlx5_devx_cmd_destroy(sh->tis)); if (sh->td) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2c92b2ce13..7048f7bd1c 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1140,8 +1140,6 @@ struct mlx5_dev_ctx_shared { uint32_t max_port; /* Maximal IB device port index. */ struct mlx5_bond_info bond; /* Bonding information. */ struct mlx5_common_device *cdev; /* Backend mlx5 device. */ - void *pd; /* Protection Domain. */ - uint32_t pdn; /* Protection Domain number. */ uint32_t tdn; /* Transport Domain number. */ char ibdev_name[MLX5_FS_NAME_MAX]; /* SYSFS dev name. */ char ibdev_path[MLX5_FS_PATH_MAX]; /* SYSFS dev path for secondary */ @@ -1769,7 +1767,6 @@ void mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev); struct rte_pci_driver; int mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *dev_attr); void mlx5_os_free_shared_dr(struct mlx5_priv *priv); -int mlx5_os_get_pdn(void *pd, uint32_t *pdn); int mlx5_os_net_probe(struct mlx5_common_device *cdev); void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh); void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh); diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 1fb835cb0d..b98b82bf79 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -276,7 +276,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx) rq_attr.wq_attr.end_padding_mode = priv->config.hw_padding ? MLX5_WQ_END_PAD_MODE_ALIGN : MLX5_WQ_END_PAD_MODE_NONE; - rq_attr.wq_attr.pd = priv->sh->pdn; + rq_attr.wq_attr.pd = priv->sh->cdev->pdn; rq_attr.counter_set_id = priv->counter_set_id; /* Create RQ using DevX API. */ return mlx5_devx_rq_create(priv->sh->cdev->ctx, &rxq_ctrl->obj->rq_obj, @@ -994,7 +994,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx, .tis_lst_sz = 1, .tis_num = priv->sh->tis->id, .wq_attr = (struct mlx5_devx_wq_attr){ - .pd = priv->sh->pdn, + .pd = priv->sh->cdev->pdn, .uar_page = mlx5_os_get_devx_uar_page_id(priv->sh->tx_uar), }, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index abe8a0d7fe..a4d85f4a8f 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7639,7 +7639,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh) mkey_attr.addr = (uintptr_t)mem; mkey_attr.size = size; mkey_attr.umem_id = mlx5_os_get_umem_id(mem_mng->umem); - mkey_attr.pd = sh->pdn; + mkey_attr.pd = sh->cdev->pdn; mkey_attr.relaxed_ordering_write = sh->cmng.relaxed_ordering_write; mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read; mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->cdev->ctx, &mkey_attr); diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c index 49eec7a6b6..17e3f2a300 100644 --- a/drivers/net/mlx5/mlx5_flow_aso.c +++ b/drivers/net/mlx5/mlx5_flow_aso.c @@ -103,7 +103,7 @@ mlx5_aso_reg_mr(struct mlx5_dev_ctx_shared *sh, size_t length, DRV_LOG(ERR, "Failed to create ASO bits mem for MR."); return -1; } - ret = sh->share_cache.reg_mr_cb(sh->pd, mr->addr, length, mr); + ret = sh->share_cache.reg_mr_cb(sh->cdev->pd, mr->addr, length, mr); if (ret) { DRV_LOG(ERR, "Failed to create direct Mkey."); mlx5_free(mr->addr); @@ -317,8 +317,9 @@ mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh, sq_desc_n, &sh->aso_age_mng->aso_sq.mr, 0)) return -1; if (mlx5_aso_sq_create(cdev->ctx, &sh->aso_age_mng->aso_sq, 0, - sh->tx_uar, sh->pdn, MLX5_ASO_QUEUE_LOG_DESC, - sh->sq_ts_format)) { + sh->tx_uar, cdev->pdn, + MLX5_ASO_QUEUE_LOG_DESC, + sh->sq_ts_format)) { mlx5_aso_dereg_mr(sh, &sh->aso_age_mng->aso_sq.mr); return -1; } @@ -326,8 +327,9 @@ mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh, break; case ASO_OPC_MOD_POLICER: if (mlx5_aso_sq_create(cdev->ctx, &sh->mtrmng->pools_mng.sq, 0, - sh->tx_uar, sh->pdn, MLX5_ASO_QUEUE_LOG_DESC, - sh->sq_ts_format)) + sh->tx_uar, cdev->pdn, + MLX5_ASO_QUEUE_LOG_DESC, + sh->sq_ts_format)) return -1; mlx5_aso_mtr_init_sq(&sh->mtrmng->pools_mng.sq); break; @@ -337,8 +339,9 @@ mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh, &sh->ct_mng->aso_sq.mr, 0)) return -1; if (mlx5_aso_sq_create(cdev->ctx, &sh->ct_mng->aso_sq, 0, - sh->tx_uar, sh->pdn, MLX5_ASO_QUEUE_LOG_DESC, - sh->sq_ts_format)) { + sh->tx_uar, cdev->pdn, + MLX5_ASO_QUEUE_LOG_DESC, + sh->sq_ts_format)) { mlx5_aso_dereg_mr(sh, &sh->ct_mng->aso_sq.mr); return -1; } diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 7bd4518ca4..1b2d837ddb 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6467,12 +6467,10 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) * NULL otherwise and rte_errno is set. */ static struct mlx5_aso_mtr_pool * -flow_dv_mtr_pool_create(struct rte_eth_dev *dev, - struct mlx5_aso_mtr **mtr_free) +flow_dv_mtr_pool_create(struct rte_eth_dev *dev, struct mlx5_aso_mtr **mtr_free) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_aso_mtr_pools_mng *pools_mng = - &priv->sh->mtrmng->pools_mng; + struct mlx5_aso_mtr_pools_mng *pools_mng = &priv->sh->mtrmng->pools_mng; struct mlx5_aso_mtr_pool *pool = NULL; struct mlx5_devx_obj *dcs = NULL; uint32_t i; @@ -6480,7 +6478,8 @@ flow_dv_mtr_pool_create(struct rte_eth_dev *dev, log_obj_size = rte_log2_u32(MLX5_ASO_MTRS_PER_POOL >> 1); dcs = mlx5_devx_cmd_create_flow_meter_aso_obj(priv->sh->cdev->ctx, - priv->sh->pdn, log_obj_size); + priv->sh->cdev->pdn, + log_obj_size); if (!dcs) { rte_errno = ENODATA; return NULL; @@ -6502,8 +6501,7 @@ flow_dv_mtr_pool_create(struct rte_eth_dev *dev, pools_mng->n_valid++; for (i = 1; i < MLX5_ASO_MTRS_PER_POOL; ++i) { pool->mtrs[i].offset = i; - LIST_INSERT_HEAD(&pools_mng->meters, - &pool->mtrs[i], next); + LIST_INSERT_HEAD(&pools_mng->meters, &pool->mtrs[i], next); } pool->mtrs[0].offset = 0; *mtr_free = &pool->mtrs[0]; @@ -11956,7 +11954,7 @@ flow_dv_age_pool_create(struct rte_eth_dev *dev, uint32_t i; obj = mlx5_devx_cmd_create_flow_hit_aso_obj(priv->sh->cdev->ctx, - priv->sh->pdn); + priv->sh->cdev->pdn); if (!obj) { rte_errno = ENODATA; DRV_LOG(ERR, "Failed to create flow_hit_aso_obj using DevX."); @@ -12384,7 +12382,8 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev, uint32_t log_obj_size = rte_log2_u32(MLX5_ASO_CT_ACTIONS_PER_POOL); obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, - priv->sh->pdn, log_obj_size); + priv->sh->cdev->pdn, + log_obj_size); if (!obj) { rte_errno = ENODATA; DRV_LOG(ERR, "Failed to create conn_track_offload_obj using DevX."); diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index f16f4f6a67..4d884f7295 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -84,7 +84,7 @@ mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr) struct mlx5_mr_ctrl *mr_ctrl = &txq->mr_ctrl; struct mlx5_priv *priv = txq_ctrl->priv; - return mlx5_mr_addr2mr_bh(priv->sh->pd, &priv->mp_id, + return mlx5_mr_addr2mr_bh(priv->sh->cdev->pd, &priv->mp_id, &priv->sh->share_cache, mr_ctrl, addr, priv->sh->cdev->config.mr_ext_memseg_en); } @@ -180,7 +180,7 @@ mlx5_mr_update_ext_mp_cb(struct rte_mempool *mp, void *opaque, return; DRV_LOG(DEBUG, "port %u register MR for chunk #%d of mempool (%s)", dev->data->port_id, mem_idx, mp->name); - mr = mlx5_create_mr_ext(sh->pd, addr, len, mp->socket_id, + mr = mlx5_create_mr_ext(sh->cdev->pd, addr, len, mp->socket_id, sh->share_cache.reg_mr_cb); if (!mr) { DRV_LOG(WARNING, @@ -196,8 +196,8 @@ mlx5_mr_update_ext_mp_cb(struct rte_mempool *mp, void *opaque, mlx5_mr_insert_cache(&sh->share_cache, mr); rte_rwlock_write_unlock(&sh->share_cache.rwlock); /* Insert to the local cache table */ - mlx5_mr_addr2mr_bh(sh->pd, &priv->mp_id, &sh->share_cache, mr_ctrl, - addr, priv->sh->cdev->config.mr_ext_memseg_en); + mlx5_mr_addr2mr_bh(sh->cdev->pd, &priv->mp_id, &sh->share_cache, + mr_ctrl, addr, sh->cdev->config.mr_ext_memseg_en); } /** @@ -256,8 +256,8 @@ mlx5_net_dma_map(struct rte_device *rte_dev, void *addr, } priv = dev->data->dev_private; sh = priv->sh; - mr = mlx5_create_mr_ext(sh->pd, (uintptr_t)addr, len, SOCKET_ID_ANY, - sh->share_cache.reg_mr_cb); + mr = mlx5_create_mr_ext(sh->cdev->pd, (uintptr_t)addr, len, + SOCKET_ID_ANY, sh->share_cache.reg_mr_cb); if (!mr) { DRV_LOG(WARNING, "port %u unable to dma map", dev->data->port_id); diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 247f36e5d7..43ea890d2b 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1242,8 +1242,8 @@ mlx5_mprq_alloc_mp(struct rte_eth_dev *dev) rte_errno = ENOMEM; return -rte_errno; } - ret = mlx5_mr_mempool_register(&priv->sh->share_cache, priv->sh->pd, - mp, &priv->mp_id); + ret = mlx5_mr_mempool_register(&priv->sh->share_cache, + priv->sh->cdev->pd, mp, &priv->mp_id); if (ret < 0 && rte_errno != EEXIST) { ret = rte_errno; DRV_LOG(ERR, "port %u failed to register a mempool for Multi-Packet RQ", diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index e93647aafd..cf4fbd3c9f 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -149,7 +149,8 @@ mlx5_rxq_mempool_register(struct mlx5_rxq_ctrl *rxq_ctrl) for (s = 0; s < rxq_ctrl->rxq.rxseg_n; s++) { mp = rxq_ctrl->rxq.rxseg[s].mp; ret = mlx5_mr_mempool_register(&priv->sh->share_cache, - priv->sh->pd, mp, &priv->mp_id); + priv->sh->cdev->pd, mp, + &priv->mp_id); if (ret < 0 && rte_errno != EEXIST) return ret; rte_mempool_mem_iter(mp, mlx5_rxq_mempool_register_cb, diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c index 6dd362c48a..fb7b36197c 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -232,7 +232,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh) .tis_lst_sz = 1, .tis_num = sh->tis->id, .wq_attr = (struct mlx5_devx_wq_attr){ - .pd = sh->pdn, + .pd = sh->cdev->pdn, .uar_page = mlx5_os_get_devx_uar_page_id(sh->tx_uar), }, .ts_format = mlx5_ts_format_conv(sh->sq_ts_format), @@ -444,7 +444,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh) sq_attr.packet_pacing_rate_limit_index = sh->txpp.pp_id; sq_attr.wq_attr.cd_slave = 1; sq_attr.wq_attr.uar_page = mlx5_os_get_devx_uar_page_id(sh->tx_uar); - sq_attr.wq_attr.pd = sh->pdn; + sq_attr.wq_attr.pd = sh->cdev->pdn; sq_attr.ts_format = mlx5_ts_format_conv(sh->sq_ts_format); ret = mlx5_devx_sq_create(sh->cdev->ctx, &wq->sq_obj, log2above(wq->sq_size), diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index e1010beeb5..e927defbf1 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -965,25 +965,4 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, *dereg_mr_cb = mlx5_os_dereg_mr; } -/** - * Extract pdn of PD object using DevX - * - * @param[in] pd - * Pointer to the DevX PD object. - * @param[out] pdn - * Pointer to the PD object number variable. - * - * @return - * 0 on success, error value otherwise. - */ -int -mlx5_os_get_pdn(void *pd, uint32_t *pdn) -{ - if (!pd) - return -EINVAL; - - *pdn = ((struct mlx5_pd *)pd)->pdn; - return 0; -} - const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0}; diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index f915a9d047..54d3e64f43 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -187,12 +187,6 @@ mlx5_regex_dev_probe(struct mlx5_common_device *cdev) rte_errno = ENOMEM; goto error; } - priv->pd = mlx5_glue->alloc_pd(priv->cdev->ctx); - if (!priv->pd) { - DRV_LOG(ERR, "can't allocate pd."); - rte_errno = ENOMEM; - goto error; - } priv->regexdev->dev_ops = &mlx5_regexdev_ops; priv->regexdev->enqueue = mlx5_regexdev_enqueue; #ifdef HAVE_MLX5_UMR_IMKEY @@ -230,8 +224,6 @@ mlx5_regex_dev_probe(struct mlx5_common_device *cdev) return 0; error: - if (priv->pd) - mlx5_glue->dealloc_pd(priv->pd); if (priv->uar) mlx5_glue->devx_free_uar(priv->uar); if (priv->regexdev) @@ -264,8 +256,6 @@ mlx5_regex_dev_remove(struct mlx5_common_device *cdev) NULL); if (priv->mr_scache.cache.table) mlx5_mr_release_cache(&priv->mr_scache); - if (priv->pd) - mlx5_glue->dealloc_pd(priv->pd); if (priv->uar) mlx5_glue->devx_free_uar(priv->uar); if (priv->regexdev) diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h index 1d19067513..c128b7acbb 100644 --- a/drivers/regex/mlx5/mlx5_regex.h +++ b/drivers/regex/mlx5/mlx5_regex.h @@ -68,7 +68,6 @@ struct mlx5_regex_priv { MLX5_RXP_EM_COUNT]; uint32_t nb_engines; /* Number of RegEx engines. */ struct mlx5dv_devx_uar *uar; /* UAR object. */ - struct ibv_pd *pd; TAILQ_ENTRY(mlx5_regex_priv) mem_event_cb; /**< Called by memory event callback. */ struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */ @@ -79,26 +78,6 @@ struct mlx5_regex_priv { uint32_t mmo_regex_sq_cap:1; }; -#ifdef HAVE_IBV_FLOW_DV_SUPPORT -static inline int -regex_get_pdn(void *pd, uint32_t *pdn) -{ - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret = 0; - - obj.pd.in = pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret) { - DRV_LOG(DEBUG, "Fail to get PD object info"); - return ret; - } - *pdn = pd_info.pdn; - return 0; -} -#endif - /* mlx5_regex.c */ int mlx5_regex_start(struct rte_regexdev *dev); int mlx5_regex_stop(struct rte_regexdev *dev); diff --git a/drivers/regex/mlx5/mlx5_regex_control.c b/drivers/regex/mlx5/mlx5_regex_control.c index fa95ce72c9..1136de1d7e 100644 --- a/drivers/regex/mlx5/mlx5_regex_control.c +++ b/drivers/regex/mlx5/mlx5_regex_control.c @@ -138,21 +138,17 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, struct mlx5_devx_qp_attr attr = { .cqn = qp->cq.cq_obj.cq->id, .uar_index = priv->uar->page_id, + .pd = priv->cdev->pdn, .ts_format = mlx5_ts_format_conv(priv->qp_ts_format), .user_index = q_ind, }; struct mlx5_regex_hw_qp *qp_obj = &qp->qps[q_ind]; - uint32_t pd_num = 0; int ret; qp_obj->log_nb_desc = log_nb_desc; qp_obj->qpn = q_ind; qp_obj->ci = 0; qp_obj->pi = 0; - ret = regex_get_pdn(priv->pd, &pd_num); - if (ret) - return ret; - attr.pd = pd_num; attr.rq_size = 0; attr.sq_size = RTE_BIT32(MLX5_REGEX_WQE_LOG_NUM(priv->has_umr, log_nb_desc)); diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c index f9d79d3549..575b639752 100644 --- a/drivers/regex/mlx5/mlx5_regex_fastpath.c +++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c @@ -138,8 +138,8 @@ mlx5_regex_addr2mr(struct mlx5_regex_priv *priv, struct mlx5_mr_ctrl *mr_ctrl, if (likely(lkey != UINT32_MAX)) return lkey; /* Take slower bottom-half on miss. */ - return mlx5_mr_addr2mr_bh(priv->pd, 0, &priv->mr_scache, mr_ctrl, addr, - !!(mbuf->ol_flags & EXT_ATTACHED_MBUF)); + return mlx5_mr_addr2mr_bh(priv->cdev->pd, 0, &priv->mr_scache, mr_ctrl, + addr, !!(mbuf->ol_flags & EXT_ATTACHED_MBUF)); } @@ -639,7 +639,7 @@ setup_qps(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *queue) static int setup_buffers(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp) { - struct ibv_pd *pd = priv->pd; + struct ibv_pd *pd = priv->cdev->pd; uint32_t i; int err; @@ -746,12 +746,7 @@ mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id) if (priv->has_umr) { #ifdef HAVE_IBV_FLOW_DV_SUPPORT - if (regex_get_pdn(priv->pd, &attr.pd)) { - err = -rte_errno; - DRV_LOG(ERR, "Failed to get pdn."); - mlx5_regexdev_teardown_fastpath(priv, qp_id); - return err; - } + attr.pd = priv->cdev->pdn; #endif for (i = 0; i < qp->nb_desc; i++) { attr.klm_num = MLX5_REGEX_MAX_KLM_NUM; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 2468202ceb..fe68ab0252 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -188,37 +188,6 @@ mlx5_vdpa_features_set(int vid) return 0; } -static int -mlx5_vdpa_pd_create(struct mlx5_vdpa_priv *priv) -{ -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - priv->pd = mlx5_glue->alloc_pd(priv->cdev->ctx); - if (priv->pd == NULL) { - DRV_LOG(ERR, "Failed to allocate PD."); - return errno ? -errno : -ENOMEM; - } - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret = 0; - - obj.pd.in = priv->pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret) { - DRV_LOG(ERR, "Fail to get PD object info."); - mlx5_glue->dealloc_pd(priv->pd); - priv->pd = NULL; - return -errno; - } - priv->pdn = pd_info.pdn; - return 0; -#else - (void)priv; - DRV_LOG(ERR, "Cannot get pdn - no DV support."); - return -ENOTSUP; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -} - static int mlx5_vdpa_mtu_set(struct mlx5_vdpa_priv *priv) { @@ -289,10 +258,6 @@ mlx5_vdpa_dev_close(int vid) mlx5_vdpa_virtqs_release(priv); mlx5_vdpa_event_qp_global_release(priv); mlx5_vdpa_mem_dereg(priv); - if (priv->pd) { - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); - priv->pd = NULL; - } priv->configured = 0; priv->vid = 0; /* The mutex may stay locked after event thread cancel - initiate it. */ @@ -320,8 +285,7 @@ mlx5_vdpa_dev_config(int vid) if (mlx5_vdpa_mtu_set(priv)) DRV_LOG(WARNING, "MTU cannot be set on device %s.", vdev->device->name); - if (mlx5_vdpa_pd_create(priv) || mlx5_vdpa_mem_register(priv) || - mlx5_vdpa_err_event_setup(priv) || + if (mlx5_vdpa_mem_register(priv) || mlx5_vdpa_err_event_setup(priv) || mlx5_vdpa_virtqs_prepare(priv) || mlx5_vdpa_steer_setup(priv) || mlx5_vdpa_cqe_event_setup(priv)) { mlx5_vdpa_dev_close(vid); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index 1fe57c72b8..d9a68e701e 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -131,8 +131,6 @@ struct mlx5_vdpa_priv { struct mlx5_common_device *cdev; /* Backend mlx5 device. */ int vid; /* vhost device id. */ struct mlx5_hca_vdpa_attr caps; - uint32_t pdn; /* Protection Domain number. */ - struct ibv_pd *pd; uint32_t gpa_mkey_index; struct ibv_mr *null_mr; struct rte_vhost_memory *vmem; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c index 979a2abd41..47f9afe855 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c @@ -593,7 +593,7 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, return -1; if (mlx5_vdpa_cq_create(priv, log_desc_n, callfd, &eqp->cq)) return -1; - attr.pd = priv->pdn; + attr.pd = priv->cdev->pdn; attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format); eqp->fw_qp = mlx5_devx_cmd_create_qp(priv->cdev->ctx, &attr); if (!eqp->fw_qp) { diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c index 0b0ffeb07d..3e8d9eb9a2 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c @@ -39,7 +39,7 @@ mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base, struct mlx5_devx_mkey_attr mkey_attr = { .addr = (uintptr_t)log_base, .size = log_size, - .pd = priv->pdn, + .pd = priv->cdev->pdn, .pg_access = 1, }; struct mlx5_devx_virtq_attr attr = { diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c index c5cdb3abd7..f551a094cd 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c @@ -193,7 +193,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) if (!mem) return -rte_errno; priv->vmem = mem; - priv->null_mr = mlx5_glue->alloc_null_mr(priv->pd); + priv->null_mr = mlx5_glue->alloc_null_mr(priv->cdev->pd); if (!priv->null_mr) { DRV_LOG(ERR, "Failed to allocate null MR."); ret = -errno; @@ -220,7 +220,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) 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->pdn; + mkey_attr.pd = priv->cdev->pdn; mkey_attr.pg_access = 1; entry->mkey = mlx5_devx_cmd_mkey_create(priv->cdev->ctx, &mkey_attr); @@ -268,7 +268,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) } mkey_attr.addr = (uintptr_t)(mem->regions[0].guest_phys_addr); mkey_attr.size = mem_size; - mkey_attr.pd = priv->pdn; + mkey_attr.pd = priv->cdev->pdn; mkey_attr.umem_id = 0; /* Must be zero for KLM mode. */ mkey_attr.log_entity_size = mode == MLX5_MKC_ACCESS_MODE_KLM_FBS ? diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c index 5ef31de834..cfd50d92f5 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c @@ -322,7 +322,7 @@ mlx5_vdpa_virtq_setup(struct mlx5_vdpa_priv *priv, int index) attr.mkey = priv->gpa_mkey_index; attr.tis_id = priv->tiss[(index / 2) % priv->num_lag_ports]->id; attr.queue_index = index; - attr.pd = priv->pdn; + attr.pd = priv->cdev->pdn; attr.hw_latency_mode = priv->hw_latency_mode; attr.hw_max_latency_us = priv->hw_max_latency_us; attr.hw_max_pending_comp = priv->hw_max_pending_comp; -- 2.25.1