From patchwork Tue Feb 21 07:07:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 124278 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA55641CFA; Tue, 21 Feb 2023 08:08:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E961431B2; Tue, 21 Feb 2023 08:08:39 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by mails.dpdk.org (Postfix) with ESMTP id B894C43175 for ; Tue, 21 Feb 2023 08:08:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sio4QWpb5zxaXplLEklSfUhv43Z10fh5RpA/RP/wHx75GKR5tTjCkfkPW7TbHtRqmDr4Rjut16Z3MSIC2x2isZpQbgMdeVhVfoErnmdURO53csw9ez+tMDwCpJd8LS9S+5b8CrreqmH3n/d1KnbRFZSM5hq/Vj5BgXhiZZ09Qy+Rz17XeO5YjU1QcthmEvnUYKLm77BuyUIPUSUl4g3RXITelMvgrW0e7wafXokCQFVqKi0s3UxRK4UuIKPAIyNTeQZRMmpXjbZtIKMsWDxNr1ISN10d4JDe87O0bnjI+olDtaWA5/BdTZkbt4TINypSgaZM5KSFMbWHLQhc6byUbg== 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=HVhtNSTLXk6kPuHMgEPtmQPo6HqqH7CiIqJYcAZDGTc=; b=BTikve/7uId4+RwD9eYtZlj7p76VfvNkufEJd/pD8Vn4VnFmuMhNVtUA1Mk4dAZPAnysLW0p15nv5lQeNxalPIOLcFdC+tLK8L02kDLQ+UWmP5oBtjHrHfDpxxyw/hemUmxgqIowBc7VdOnhskjSd0H926VtNEKVxd4paeNFATGv67doTp0Sw+1dtSHTpJ02fGx5ssCKzf251Fz9ImVT8Bj+irtJpI1+ycD+/5sBxikUiToxyuid8oB5mDtd3/RihO04jHeZchhZcWwuIBRCowaFwZwOl390iLq6Al/WLD2pOShcg7MCP07Z7DzGJqYSWp7Xzq0WOuSqim3iEcMkbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=HVhtNSTLXk6kPuHMgEPtmQPo6HqqH7CiIqJYcAZDGTc=; b=QT/6fCF/ZIKtsWkqgtuVVZWu9+dQV9ctatawSIVCI+3VzdjsBBAA/3vLMT1du9OOQga44H9ce9iRsnsJzW5296Ex1r89AtDIdGvJ6SQPtr0STKnmckl9pBUHBiz9bLRzw5pu7+7s6grqdacXKWzgPnTRgcu+6YyLbuF+oXXatV3fFU2tEymcpq5n0skOfIfZ6scdvMJG0EmXsCNK1yZSmeYWSo51HoLxuCFSrAvXva+4l9oXTxzb6uNGlP7IQz0/2LAzeH/9a2t7uRcuonna31MBZtWvIc5EvHnlPDSGk4wov9cjCWzGIZpykh/7qBfnieqUaoEgsE2hgMe9KvOY/A== Received: from BN9PR03CA0741.namprd03.prod.outlook.com (2603:10b6:408:110::26) by PH7PR12MB6657.namprd12.prod.outlook.com (2603:10b6:510:212::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.21; Tue, 21 Feb 2023 07:08:31 +0000 Received: from BN8NAM11FT083.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110:cafe::18) by BN9PR03CA0741.outlook.office365.com (2603:10b6:408:110::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20 via Frontend Transport; Tue, 21 Feb 2023 07:08:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT083.mail.protection.outlook.com (10.13.177.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.17 via Frontend Transport; Tue, 21 Feb 2023 07:08:31 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 20 Feb 2023 23:08:14 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 20 Feb 2023 23:08:14 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36 via Frontend Transport; Mon, 20 Feb 2023 23:08:12 -0800 From: Michael Baum To: CC: Matan Azrad , Akhil Goyal , "Thomas Monjalon" Subject: [PATCH v3 6/8] compress/mlx5: add xform validate function Date: Tue, 21 Feb 2023 09:07:54 +0200 Message-ID: <20230221070756.3070819-7-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230221070756.3070819-1-michaelba@nvidia.com> References: <20230202162537.1067595-1-michaelba@nvidia.com> <20230221070756.3070819-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT083:EE_|PH7PR12MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: a42d8cbd-75b0-4d82-4309-08db13da708c X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6/fO/3KWKpTassIGCZE48a2rrJVy6G6wvCMcqT3atY0x8xcXiqhIVHJZMsLiVzCb+oTBLBx44lEfMo04LwOTBpPGfupjedOQ8AgMq8PNeA0GJ4hhFqO9dMVVAjcSqzd+Xx6kZ+0xYDEwbtZz1q8Xd4kmpxbKhGop8kYLIrkwAAK5W5IBQQV5c4oDEi6+unHiKrhqaViMH8G9epo6fGxnjnq4iATNAoTk1KHLmAgwcK6FA+ce0QShZVyO8FiN5cMmnoMxJzWkuExmUflDvjpVtWagJHNWvf0lxSQDZLMXljFQqIGBmJ5VxRILNQNGaugbySvTjgpu5Q2MUmhB5SYYuuQEwQVKmcTyxv3PhQdz1JbXMhXgtP3cnEubL3v4Xr+eZLnEO3DOPvMMVsumL3SfQ+R2/qsWzHqrh5opiw2AcDH8SKpN2cpgKBgLnkYvrOCmAUKOgzOkqr3uls0ML/qdaFBs58j2GewcEM5T2/DeX13lfkaWKi4HpCs8M3YW50a30CboMnAG0LJ5zeDEg1JCB8KIw9gTUEfqmFOoJvHbImfQnfP8PQyTmqG/dkl+HFQcSNkGkcQgPbTbEzHLG9iIFna9UxBxwyH5zEne/p3wfz9x6opxS8htSMKEHViXnf5xeNirV5baJydXsqG/0IXwY10GUygPCM120b/qlvaD0+qPOzb28q30dzGtZzuBPD5S X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199018)(36840700001)(40470700004)(46966006)(426003)(40460700003)(47076005)(478600001)(7696005)(336012)(82310400005)(7636003)(82740400003)(86362001)(2906002)(36860700001)(356005)(316002)(54906003)(41300700001)(36756003)(5660300002)(8936002)(83380400001)(55016003)(40480700001)(70586007)(70206006)(6916009)(8676002)(4326008)(2616005)(6666004)(6286002)(186003)(26005)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2023 07:08:31.3064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a42d8cbd-75b0-4d82-4309-08db13da708c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT083.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6657 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 Separate the xform validations from create function into new function. The new function checks caps directly from HCA attr structure, so all capabilities in priv structure were removed. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/compress/mlx5/mlx5_compress.c | 75 +++++++++++++++------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 1802a7ba52..3ea3447f11 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -45,13 +45,6 @@ struct mlx5_compress_priv { struct rte_compressdev_config dev_config; LIST_HEAD(xform_list, mlx5_compress_xform) xform_list; rte_spinlock_t xform_sl; - /* HCA caps */ - uint32_t mmo_decomp_sq:1; - uint32_t mmo_decomp_qp:1; - uint32_t mmo_comp_sq:1; - uint32_t mmo_comp_qp:1; - uint32_t mmo_dma_sq:1; - uint32_t mmo_dma_qp:1; uint32_t log_block_sz; uint32_t crc32_opaq_offs; }; @@ -178,6 +171,7 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, uint32_t max_inflight_ops, int socket_id) { struct mlx5_compress_priv *priv = dev->data->dev_private; + struct mlx5_hca_attr *attr = &priv->cdev->config.hca_attr; struct mlx5_compress_qp *qp; struct mlx5_devx_cq_attr cq_attr = { .uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar.obj), @@ -238,12 +232,11 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, goto err; } qp_attr.cqn = qp->cq.cq->id; - qp_attr.ts_format = - mlx5_ts_format_conv(priv->cdev->config.hca_attr.qp_ts_format); + qp_attr.ts_format = mlx5_ts_format_conv(attr->qp_ts_format); qp_attr.num_of_receive_wqes = 0; qp_attr.num_of_send_wqbbs = RTE_BIT32(log_ops_n); - qp_attr.mmo = priv->mmo_decomp_qp || priv->mmo_comp_qp || - priv->mmo_dma_qp; + qp_attr.mmo = attr->mmo_compress_qp_en || attr->mmo_dma_qp_en || + attr->decomp_deflate_v1_en || attr->decomp_deflate_v2_en; ret = mlx5_devx_qp_create(priv->cdev->ctx, &qp->qp, qp_attr.num_of_send_wqbbs * MLX5_WQE_SIZE, &qp_attr, socket_id); @@ -276,21 +269,17 @@ mlx5_compress_xform_free(struct rte_compressdev *dev, void *xform) } static int -mlx5_compress_xform_create(struct rte_compressdev *dev, - const struct rte_comp_xform *xform, - void **private_xform) +mlx5_compress_xform_validate(const struct rte_comp_xform *xform, + const struct mlx5_hca_attr *attr) { - struct mlx5_compress_priv *priv = dev->data->dev_private; - struct mlx5_compress_xform *xfrm; - uint32_t size; - switch (xform->type) { case RTE_COMP_COMPRESS: if (xform->compress.algo == RTE_COMP_ALGO_NULL && - !priv->mmo_dma_qp && !priv->mmo_dma_sq) { + !attr->mmo_dma_qp_en && !attr->mmo_dma_sq_en) { DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?"); return -ENOTSUP; - } else if (!priv->mmo_comp_qp && !priv->mmo_comp_sq) { + } else if (!attr->mmo_compress_qp_en && + !attr->mmo_compress_sq_en) { DRV_LOG(ERR, "Not enough capabilities to support compress operation, maybe old FW/OFED version?"); return -ENOTSUP; } @@ -304,12 +293,24 @@ mlx5_compress_xform_create(struct rte_compressdev *dev, } break; case RTE_COMP_DECOMPRESS: - if (xform->decompress.algo == RTE_COMP_ALGO_NULL && - !priv->mmo_dma_qp && !priv->mmo_dma_sq) { - DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?"); - return -ENOTSUP; - } else if (!priv->mmo_decomp_qp && !priv->mmo_decomp_sq) { - DRV_LOG(ERR, "Not enough capabilities to support decompress operation, maybe old FW/OFED version?"); + switch (xform->decompress.algo) { + case RTE_COMP_ALGO_NULL: + if (!attr->mmo_dma_qp_en && !attr->mmo_dma_sq_en) { + DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?"); + return -ENOTSUP; + } + break; + case RTE_COMP_ALGO_DEFLATE: + if (!attr->decomp_deflate_v1_en && + !attr->decomp_deflate_v2_en && + !attr->mmo_decompress_sq_en) { + DRV_LOG(ERR, "Not enough capabilities to support decompress DEFLATE algorithm, maybe old FW/OFED version?"); + return -ENOTSUP; + } + break; + default: + DRV_LOG(ERR, "Algorithm %u is not supported.", + xform->decompress.algo); return -ENOTSUP; } if (xform->decompress.hash_algo != RTE_COMP_HASH_ALGO_NONE) { @@ -321,7 +322,22 @@ mlx5_compress_xform_create(struct rte_compressdev *dev, DRV_LOG(ERR, "Xform type should be compress/decompress"); return -ENOTSUP; } + return 0; +} + +static int +mlx5_compress_xform_create(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, + void **private_xform) +{ + struct mlx5_compress_priv *priv = dev->data->dev_private; + struct mlx5_compress_xform *xfrm; + uint32_t size; + int ret; + ret = mlx5_compress_xform_validate(xform, &priv->cdev->config.hca_attr); + if (ret < 0) + return ret; xfrm = rte_zmalloc_socket(__func__, sizeof(*xfrm), 0, priv->dev_config.socket_id); if (xfrm == NULL) @@ -747,13 +763,6 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev, compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; priv = compressdev->data->dev_private; priv->log_block_sz = devarg_prms.log_block_sz; - priv->mmo_decomp_sq = attr->mmo_decompress_sq_en; - priv->mmo_decomp_qp = - attr->decomp_deflate_v1_en | attr->decomp_deflate_v2_en; - priv->mmo_comp_sq = attr->mmo_compress_sq_en; - priv->mmo_comp_qp = attr->mmo_compress_qp_en; - priv->mmo_dma_sq = attr->mmo_dma_sq_en; - priv->mmo_dma_qp = attr->mmo_dma_qp_en; if (attr->decomp_deflate_v2_en) crc32_opaq_offset = offsetof(union mlx5_gga_compress_opaque, v2.crc32);