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 57C10A0093; Sun, 2 Jan 2022 08:07:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 737BF406FF; Sun, 2 Jan 2022 08:07:06 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) by mails.dpdk.org (Postfix) with ESMTP id E972F41145 for ; Sun, 2 Jan 2022 08:07:04 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d18SCcC9/pa7HeWB7M4X6B4iUphYkM6umEQUex4RzxJfnGH1I+VNycatZRbcYJpto17SHc5fE7h5bQq5CM+fU148zkG04r1VP1FbKhf0fRYwl8soL9FTblV5I4ntopJ2G5KwL017PXEL/ZEpKeqTonA5Cjx2LXIs5R99uIciTwvySJlQPxOlLNpHr8yD+Q4uW1P5rOOUdcjzlgv1MqnvkQGyv4m6KHRJvzw0y0SQC1R2QrWBUleD/4yDVHLbQn9tMjiVi3tsH5DwJ+GDBRzF/X3XXn5hqvEGMvHzBy+dT93mi6edHe30Ob773Yeq91mL0WhJd5OnDqCtCDHF7w/WLQ== 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=OP0vx9dw8ftr97wXAZs+NJfH+skIMSpJExNrM0ugv7c=; b=QALA6+mlQLXHa7mFuI2u9Y1oinX/WAUfKGDnnhuszab9yAQfMJlZOx3H9CxEHFZMCVeaTcRHbWbVqT28Y3G0s9oinb9ML/DJccdMutnTmGIzY+6FyL3TYTpXYkeeC3CbEsFSjuyu7AapGdIqScjsOXS15O6t4OqM+K7HFtm8gS3I1TZFynAdHDHlfAzbWyRhqlyRmeWhj1WHU0WYr5EaXtuzP+OGLsuYrQm91N31aqvKAIut+KFqItEc2VVfJlbU1isB9c509Fvdz/MLwSBgeWA5jhonW4PpGOxFWTEVwNwxq7XXMqaWQaTwwlXHW8p/md8tR57qYjKvum0GL1gK4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=OP0vx9dw8ftr97wXAZs+NJfH+skIMSpJExNrM0ugv7c=; b=STaJfBPyP07WsuVCNZqI3n+kSdwRKM6AvEAgGfnzoUxOdu2xDQlHE4Vy0leUKbJJkidkX/0q854dKNBXlr9tRXLU17p+wnwcePa/vOxph3bJnNAHxK/DdD2jQrbrxBak9znRXeNbz4QzhTpA8B8QyOHJtVR8va3MhN601pKB7S4SJy9xpXCMACiQDIV9yOm2Wy7bGYI1nNT2ChdXI6g5hThVpJ31l/TYfwp9qpZXzUKJBqWTkBQGsHEMbjKMMIpclGhAtgJ9mwMOUlGki2ZTKiXbUIsXYNkSgxPyo+MkIbDDiZGUp05HIK0czHi2DABi5Z8sHeVi3HJkVxxxcop8Bw== Received: from DM5PR07CA0127.namprd07.prod.outlook.com (2603:10b6:3:13e::17) by DM5PR12MB2359.namprd12.prod.outlook.com (2603:10b6:4:b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Sun, 2 Jan 2022 07:07:02 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13e:cafe::aa) by DM5PR07CA0127.outlook.office365.com (2603:10b6:3:13e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13 via Frontend Transport; Sun, 2 Jan 2022 07:07:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Sun, 2 Jan 2022 07:07:02 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 2 Jan 2022 07:07:01 +0000 Received: from nvidia.com (172.20.187.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Sat, 1 Jan 2022 23:06:59 -0800 From: To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Michael Baum Subject: [RFC 2/3] common/mlx5: add shared PD support Date: Sun, 2 Jan 2022 09:06:37 +0200 Message-ID: <20220102070638.2211160-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220102070638.2211160-1-michaelba@nvidia.com> References: <20220102070638.2211160-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: HQMAIL107.nvidia.com (172.20.187.13) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: daf375ac-ac4e-4f11-71fe-08d9cdbe79e4 X-MS-TrafficTypeDiagnostic: DM5PR12MB2359:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:17; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f27QRoZ4Gj5XcSur1b/+1xuW3kXIY1XQvo3TLRKBi7Igq2R/pY66ZGCGMv9gyIgUkpeebDgF5o5gbffJl3OvQHuo4rOxj61kJ3rsnnX/cfA6EFMVIXaUtEJzOkNorIT9QJuB68kLxWdKHXFaYUP8L992CrD+k5O6L+SqvyyQqxAQ+pw2UheNwpx1Gh0PVoyaCPEHSbeKnJs0CUmLBoWAZ39Ah4XO6cD5HtR4qXgPATv0XfzY8oi82jfmn7K/Q8DgzambHNg2XKUsSF8r94BEUA5qLEosx7x/OLNXIXgbe9FJ+fc+3iD14RTyu6kAfNzBG5Nofsa0fxzjy1y4Gkh3Nl4vSdekjnfB4U4LwLjGUimy29ML5C/k79jgFG4F9NzbM53FaCMDEz6feU50jeELZ0I+m6LVFLSHktDzXUN3dc+9tD1XnkkRM0zzB3oq0iQsJryLgjCLVMpt31zAyFdCuMtByKSdRst4aTdiEF3uAopJP08BMTcY1qGZLJSOsyt0olwA0YIgEaSzzBaeTBUP7TVA1ei52vFCEnF2xjf2OM6Ih5CMh0cqRgm9iGCa/sqr75DKqvvpIU9Ttlw0WkmmCt6uSoONnDW2Mn4Mm0BQ9q6iPcUSx55gs1z3qMty1Vc7fZov8ff7zhsG0O78g5fqAb2eBQa16VPwxwpioyj+CcSvfe0lEXYMGCjvsnIv0L4y754rCFCeow+Tau7u/tL4IHW3uPiPmKUzF8DreFuyPdXf43GRjT3zl0AEGcctn4U3f5fQT26O2SNp9gDu51TlJYpeDzS2TFy6cRLlXHTr5S3F+8rlz1Sp4yi3FKO3IVar7IE0e4MjR3/auxgyFHY1sQ== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(36840700001)(40470700002)(46966006)(6666004)(6286002)(316002)(2906002)(36756003)(36860700001)(7696005)(81166007)(8676002)(4326008)(107886003)(26005)(70206006)(40460700001)(47076005)(16526019)(8936002)(186003)(70586007)(508600001)(2616005)(1076003)(6916009)(86362001)(336012)(5660300002)(54906003)(356005)(55016003)(82310400004)(83380400001)(2876002)(30864003)(426003)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2022 07:07:02.0412 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daf375ac-ac4e-4f11-71fe-08d9cdbe79e4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2359 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 From: Michael Baum Add option to probe common device using import CTX/PD functions instead of create functions. This option requires accepting the context FD and the PD handle as devargs. Signed-off-by: Michael Baum --- drivers/common/mlx5/linux/mlx5_common_os.c | 160 +++++++++++++++++-- drivers/common/mlx5/linux/mlx5_common_os.h | 6 - drivers/common/mlx5/mlx5_common.c | 32 ++-- drivers/common/mlx5/mlx5_common.h | 6 +- drivers/common/mlx5/windows/mlx5_common_os.c | 29 +++- drivers/common/mlx5/windows/mlx5_common_os.h | 1 - 6 files changed, 196 insertions(+), 38 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 0d3e24e04e..a8226e987f 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -416,7 +416,7 @@ mlx5_glue_constructor(void) * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -int +static int mlx5_os_pd_create(struct mlx5_common_device *cdev) { #ifdef HAVE_IBV_FLOW_DV_SUPPORT @@ -450,6 +450,65 @@ mlx5_os_pd_create(struct mlx5_common_device *cdev) #endif /* HAVE_IBV_FLOW_DV_SUPPORT */ } +/** + * Import Protection Domain object according to given pdn. + * + * @param[out] cdev + * Pointer to the mlx5 device. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_os_pd_import(struct mlx5_common_device *cdev) +{ + struct mlx5_common_dev_config *config = &cdev->config; + + cdev->pd = mlx5_glue->import_pd(cdev->ctx, config->pd_handle); + if (cdev->pd == NULL) { + DRV_LOG(ERR, "Failed to import PD."); + return errno ? -errno : -ENOMEM; + } + cdev->pdn = config->pd_handle; + return 0; +} + +/** + * Prepare 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_prepare(struct mlx5_common_device *cdev) +{ + if (cdev->config.pd_handle == MLX5_ARG_UNSET) + return mlx5_os_pd_create(cdev); + else + return mlx5_os_pd_import(cdev); +} + +/** + * Release Protection Domain object. + * + * @param[out] cdev + * Pointer to the mlx5 device. + * + * @return + * 0 on success, a negative errno value otherwise. + */ +int +mlx5_os_pd_release(struct mlx5_common_device *cdev) +{ + if (cdev->config.pd_handle == MLX5_ARG_UNSET) + return mlx5_glue->dealloc_pd(cdev->pd); + mlx5_glue->unimport_pd(cdev->pd); + return 0; +} + static struct ibv_device * mlx5_os_get_ibv_device(const struct rte_pci_addr *addr) { @@ -648,28 +707,28 @@ mlx5_restore_doorbell_mapping_env(int value) /** * Function API to open IB device. * - * * @param cdev * Pointer to the mlx5 device. * @param classes * Chosen classes come from device arguments. * * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. + * Pointer to ibv_context on success, NULL otherwise and rte_errno is set. */ -int -mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes) +static struct ibv_context * +mlx5_open_device(struct mlx5_common_device *cdev, uint32_t classes) { struct ibv_device *ibv; struct ibv_context *ctx = NULL; int dbmap_env; + MLX5_ASSERT(cdev->config.device_fd == MLX5_ARG_UNSET); if (classes & MLX5_CLASS_VDPA) ibv = mlx5_vdpa_get_ibv_dev(cdev->dev); else ibv = mlx5_os_get_ibv_dev(cdev->dev); if (!ibv) - return -rte_errno; + return NULL; DRV_LOG(INFO, "Dev information matches for device \"%s\".", ibv->name); /* * Configure environment variable "MLX5_BF_SHUT_UP" before the device @@ -682,29 +741,104 @@ mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes) ctx = mlx5_glue->dv_open_device(ibv); if (ctx) { cdev->config.devx = 1; - DRV_LOG(DEBUG, "DevX is supported."); } else if (classes == MLX5_CLASS_ETH) { /* The environment variable is still configured. */ ctx = mlx5_glue->open_device(ibv); if (ctx == NULL) goto error; - DRV_LOG(DEBUG, "DevX is NOT supported."); } else { goto error; } /* The device is created, no need for environment. */ mlx5_restore_doorbell_mapping_env(dbmap_env); - /* Hint libmlx5 to use PMD allocator for data plane resources */ - mlx5_set_context_attr(cdev->dev, ctx); - cdev->ctx = ctx; - return 0; + return ctx; error: rte_errno = errno ? errno : ENODEV; /* The device creation is failed, no need for environment. */ mlx5_restore_doorbell_mapping_env(dbmap_env); DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name); - return -rte_errno; + return NULL; } + +/** + * Function API to import IB device. + * + * @param cdev + * Pointer to the mlx5 device. + * + * @return + * Pointer to ibv_context on success, NULL otherwise and rte_errno is set. + */ +static struct ibv_context * +mlx5_import_device(struct mlx5_common_device *cdev) +{ + struct ibv_context *ctx = NULL; + + MLX5_ASSERT(cdev->config.device_fd != MLX5_ARG_UNSET); + ctx = mlx5_glue->import_device(cdev->config.device_fd); + if (!ctx) { + DRV_LOG(ERR, "Failed to import device for fd=%d.", + cdev->config.device_fd); + rte_errno = errno; + } + return ctx; +} + +/** + * Function API to prepare IB device. + * + * @param cdev + * Pointer to the mlx5 device. + * @param classes + * Chosen classes come from device arguments. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes) +{ + + struct ibv_context *ctx = NULL; + + if (cdev->config.device_fd == MLX5_ARG_UNSET) + ctx = mlx5_open_device(cdev, classes); + else + ctx = mlx5_import_device(cdev); + if (ctx == NULL) + return -rte_errno; + /* Hint libmlx5 to use PMD allocator for data plane resources */ + mlx5_set_context_attr(cdev->dev, ctx); + cdev->ctx = ctx; + return 0; +} + +/** + * Query HCA attributes. + * For remote context, it is check if DevX is supported. + * + * @param cdev + * Pointer to mlx5 device structure. + * + * @return + * 0 on success, a negative value otherwise. + */ +int +mlx5_os_query_hca_attr(struct mlx5_common_device *cdev) +{ + int ret; + + ret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr); + if (ret) { + if (cdev->config.device_fd == MLX5_ARG_UNSET) { + rte_errno = ENOTSUP; + return -rte_errno; + } + cdev->config.devx = 0; + } + return 0; +} + int mlx5_get_device_guid(const struct rte_pci_addr *dev, uint8_t *guid, size_t len) { diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index 83066e752d..246e8b2784 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -203,12 +203,6 @@ mlx5_os_get_devx_uar_page_id(void *uar) #endif } -static inline int -mlx5_os_dealloc_pd(void *pd) -{ - return mlx5_glue->dealloc_pd(pd); -} - __rte_internal static inline void * mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index f1650f94c6..bd7f0021d5 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -133,6 +133,10 @@ mlx5_common_args_check_handler(const char *key, const char *val, void *opaque) config->mr_mempool_reg_en = !!tmp; } else if (strcmp(key, "sys_mem_en") == 0) { config->sys_mem_en = !!tmp; + } else if (strcmp(key, "device_fd") == 0) { + config->device_fd = !!tmp; + } else if (strcmp(key, "pd_handle") == 0) { + config->pd_handle = !!tmp; } return 0; } @@ -160,6 +164,8 @@ mlx5_common_config_get(struct rte_devargs *devargs, config->mr_mempool_reg_en = 1; config->sys_mem_en = 0; config->dbnc = MLX5_ARG_UNSET; + config->device_fd = MLX5_ARG_UNSET; + config->pd_handle = MLX5_ARG_UNSET; if (devargs == NULL) return 0; kvlist = rte_kvargs_parse(devargs->args, NULL); @@ -492,7 +498,7 @@ static void mlx5_dev_hw_global_release(struct mlx5_common_device *cdev) { if (cdev->pd != NULL) { - claim_zero(mlx5_os_dealloc_pd(cdev->pd)); + claim_zero(mlx5_os_pd_release(cdev)); cdev->pd = NULL; } if (cdev->ctx != NULL) { @@ -522,19 +528,23 @@ mlx5_dev_hw_global_prepare(struct mlx5_common_device *cdev, uint32_t classes) if (ret < 0) return ret; /* Allocate Protection Domain object and extract its pdn. */ - ret = mlx5_os_pd_create(cdev); + ret = mlx5_os_pd_prepare(cdev); if (ret) goto error; - /* All actions taken below are relevant only when DevX is supported */ - if (cdev->config.devx == 0) - return 0; - /* Query HCA attributes. */ - ret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr); - if (ret) { - DRV_LOG(ERR, "Unable to read HCA capabilities."); - rte_errno = ENOTSUP; - goto error; + /* + * TODO: write it again... + * All actions taken below are relevant only when DevX is supported + */ + if (cdev->config.devx || cdev->config.device_fd != MLX5_ARG_UNSET) { + /* Query HCA attributes. */ + ret = mlx5_os_query_hca_attr(cdev); + if (ret) { + DRV_LOG(ERR, "Unable to read HCA capabilities."); + rte_errno = ENOTSUP; + goto error; + } } + DRV_LOG(DEBUG, "DevX is %ssupported.", cdev->config.devx ? "" : "NOT "); return 0; error: mlx5_dev_hw_global_release(cdev); diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index e8809844af..78c8a29740 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -414,6 +414,8 @@ void mlx5_common_init(void); struct mlx5_common_dev_config { struct mlx5_hca_attr hca_attr; /* HCA attributes. */ int dbnc; /* Skip doorbell register write barrier. */ + int device_fd; /* Device file descriptor for importation. */ + int pd_handle; /* Protection Domain handle for importation. */ unsigned int devx:1; /* Whether devx interface is available or not. */ unsigned int sys_mem_en:1; /* The default memory allocator. */ unsigned int mr_mempool_reg_en:1; @@ -507,7 +509,9 @@ mlx5_devx_uar_release(struct mlx5_uar *uar); /* 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); +int mlx5_os_query_hca_attr(struct mlx5_common_device *cdev); +int mlx5_os_pd_prepare(struct mlx5_common_device *cdev); +int mlx5_os_pd_release(struct mlx5_common_device *cdev); /* mlx5 PMD wrapped MR struct. */ struct mlx5_pmd_wrapped_mr { diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index 162c7476cc..d8410f57c1 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -25,21 +25,38 @@ mlx5_glue_constructor(void) { } +/** + * Query HCA attributes. + * + * @param cdev + * Pointer to mlx5 device structure. + * + * @return + * 0 on success, a negative value otherwise. + */ +int +mlx5_os_query_hca_attr(struct mlx5_common_device *cdev) +{ + return mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr); +} + /** * Release PD. Releases a given mlx5_pd object * - * @param[in] pd - * Pointer to mlx5_pd. + * @param[in] cdev + * Pointer to the mlx5 device. * * @return * Zero if pd is released successfully, negative number otherwise. */ int -mlx5_os_dealloc_pd(void *pd) +mlx5_os_pd_release(struct mlx5_common_device *cdev) { + struct mlx5_pd *pd = cdev->pd; + if (!pd) return -EINVAL; - mlx5_devx_cmd_destroy(((struct mlx5_pd *)pd)->obj); + mlx5_devx_cmd_destroy(pd->obj); mlx5_free(pd); return 0; } @@ -47,14 +64,14 @@ mlx5_os_dealloc_pd(void *pd) /** * Allocate Protection Domain object and extract its pdn using DV API. * - * @param[out] dev + * @param[out] cdev * Pointer to the mlx5 device. * * @return * 0 on success, a negative value otherwise. */ int -mlx5_os_pd_create(struct mlx5_common_device *cdev) +mlx5_os_pd_prepare(struct mlx5_common_device *cdev) { struct mlx5_pd *pd; diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h index 3afce56cd9..a6a1b6890f 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.h +++ b/drivers/common/mlx5/windows/mlx5_common_os.h @@ -248,7 +248,6 @@ mlx5_os_devx_subscribe_devx_event(void *eventc, return -ENOTSUP; } -int mlx5_os_dealloc_pd(void *pd); __rte_internal void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access); __rte_internal -- 2.25.1