From patchwork Mon Jan 9 07:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 121716 X-Patchwork-Delegate: thomas@monjalon.net 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 344B94237B; Mon, 9 Jan 2023 08:59:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CAC6542D2B; Mon, 9 Jan 2023 08:59:08 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2080.outbound.protection.outlook.com [40.107.102.80]) by mails.dpdk.org (Postfix) with ESMTP id 8BB5642D13 for ; Mon, 9 Jan 2023 08:59:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVa3LLijgXAJXbXzRxB25fVubimbpgLqM3Z1Pz7jUgZjMuREsgt4ingHgZuipY4En985T79hK4HXlzyLDmrVC8zl2bZuDg8Wn0nWmoeiAyFR+Kj3cKMIZnQuYbqoYFf3Blmucw2Eel7ISSo4e3XmArG/cK9EFkWxLPJQLKcljJC8g4CJGs0MwRzwJb9QIK1jfusgyOLC0Xf2e1SOyjtdsazkhHSsfmhKv/b0OR+ZbLxgJraw7hj7cnD5tpfDE1qyENipuyC0ELU7yq5jJGwXCtnDiruQUNDHdtC1IMzNPEe1WBxb+kvbio3eKMkJ7Z1srYJcDNcfxooAe0O/HWtMgg== 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=yUS7DL8b1ygvipA1kxrwnPYZoiyAQFB1k0RDwzzCMbQ=; b=dlsm0qjBCa9qgUUquruzr1Gi+RNFF5LwpPLvwjIsO3ehVSQFiVLs51MCYOIlz9r/8KfpXFfRi4zQzOJl3KlDz/eE+Npp4o6urHEmsdcH17+0mMCHYqgrhGXz4doa5hL9pSC0TNPhR1vLVpbFwUYmVb9W6n9avp92jbyIFJTBRsC4SarXN7Lqy3t44aAiDokm5QOzMOc8MbOY4G3rxxrb0Eo4LLz/cANugp1yjHr1Fz4BA0uAW5JiihBU/N9KO9VV5Bp4M4Yam6Z6UIlTZyx2Zh27/skpDkzLQkuoe1M6gOAEczbffSA/K/GZudS3k7FcNJyPCPjB7HFrAtgzh826Eg== 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=yUS7DL8b1ygvipA1kxrwnPYZoiyAQFB1k0RDwzzCMbQ=; b=UgU/cLTUxtLQa2UXFIQCga3QpNmpyKdlj/Pg4qxZX1RrKl0qdowAllOfMtvUpmJSNoAD50TiBPERZmOcDdx0+bvM7PxWA0aq43ZUSzbtKGq0Qfij+gl0UsJOZqmZzolLdywjad69UVuOplpviK+1FURYZmUWf34D+IDTAniUDMk45fe72EFaJwWXlRsOYIfuVKYKS/g4t8AWdAk67nF3GJYG48qIFzvw2whU3lpWXHDxZt1B7nigfM4G28KCkZdIW2/dpyK/dlEqQzjMhwYyb4vDquNN5OuVP/EZDi1qcLo89nsoD87+atKZe0O26rO4IDKURPujgc/NRZOOV7cFdA== Received: from MW2PR16CA0047.namprd16.prod.outlook.com (2603:10b6:907:1::24) by MW4PR12MB7013.namprd12.prod.outlook.com (2603:10b6:303:218::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Mon, 9 Jan 2023 07:59:05 +0000 Received: from CO1NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::a0) by MW2PR16CA0047.outlook.office365.com (2603:10b6:907:1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 07:59:05 +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 CO1NAM11FT035.mail.protection.outlook.com (10.13.175.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 07:59:05 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 8 Jan 2023 23:58:54 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 8 Jan 2023 23:58:53 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36 via Frontend Transport; Sun, 8 Jan 2023 23:58:52 -0800 From: Michael Baum To: CC: Matan Azrad , Akhil Goyal , "Thomas Monjalon" Subject: [PATCH 3/7] compress/mlx5: support new metadata layout added in BF3 Date: Mon, 9 Jan 2023 09:58:34 +0200 Message-ID: <20230109075838.2508039-4-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109075838.2508039-1-michaelba@nvidia.com> References: <20230109075838.2508039-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT035:EE_|MW4PR12MB7013:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ebb7cb8-0bdb-4369-5a0a-08daf217614b 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: SsA3/uOYLYcZaCPKqzFMjHk7FAGojIIaboYwztrXDdo5iCg0WCi5RnaZHC3OrBdo/NjNO5FIdvOPZ5fQzmSTbLj2A8zKcTFReUSP8Qzk/iqtJiLhQxIoZ2YY9QT/dthjcHtWWokCBBplNSfeJ7xQQZRxIoBbcAQEoQ9Qh5OAwrMfQFa58KQqRIKPyspVYEoFiGGfi+GH0DVXSLX9MIK+lCuZGuqCcs5VhpXUoFq6FPLyZkdMWJEm9rtkQmbMHZZQTXNALBhi6tcoCRm5UgmmXd1XEfwm4kc3L1r2qv0YcQJtuOQYLnVbZFozPC5opVB9vIXD+1oWVQ+rE7axqDwk0bP2HWsxL2QKpXTVRp+v/gnuDApL6pdDFk5XaXHhPepPOGZi/iXCXUko6Bz7NtUpAKnyIQOAlQbwLmjijhisoyYYAfVJwIOOxI0CFcwxhbtTCupEsuGtdahjuPULcBV3kX2ftNzfUMU+wM1Ghm9BPGjajZVK4v/DseuVdillMO0rm+94fXo60Ubpw0TNvL7gCfsBFgB4uZ9KgZlNbvR6S1k5qqyL/9niNWja7kWq0tS3mRv3JrZ5PAQElQ+ZPTUeimCoKAtxZRtXBHvGxjWjOY4+YagwTXH/AUdjPsbSGh6W+UCjkOl6FUljn8S6HmiKYR943CroYoZK2YWi39lyU6WxZwMJ4PPwmYKaxd6HxHsVJzc34Uflpb6s3EiBzzkjOA== 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:(13230022)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(316002)(54906003)(6916009)(36756003)(82740400003)(356005)(8936002)(8676002)(70206006)(41300700001)(40480700001)(4326008)(70586007)(6286002)(86362001)(426003)(26005)(186003)(40460700003)(83380400001)(47076005)(2616005)(336012)(55016003)(7696005)(1076003)(82310400005)(6666004)(478600001)(36860700001)(2906002)(5660300002)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 07:59:05.5281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ebb7cb8-0bdb-4369-5a0a-08daf217614b 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: CO1NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7013 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 Commit [1] add support in Bluefield-3, but Bluefield-3 has different GGA opaque structure than Bluefield-2. This patch updates the PRM structure to include both versions, and culculate the relevant offset for each version in control path. Commit [1] 559014f232b4 ("compress/mlx5: add Bluefield-3 device ID") Signed-off-by: Michael Baum --- drivers/common/mlx5/mlx5_devx_cmds.c | 11 +++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + drivers/common/mlx5/mlx5_prm.h | 32 +++++++++++++++--------- drivers/compress/mlx5/mlx5_compress.c | 35 ++++++++++++++++++--------- 4 files changed, 56 insertions(+), 23 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 59cebb530f..8280785e2f 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -980,6 +980,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, compress_mmo_qp); attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr, decompress_mmo_qp); + /* + * Due to HW bug, we have 2 different 'gga_compress_opaque' versions. + * At this moment, Bluefield-2 uses old version and Bluefield-3 uses the + * new one. The following condition is equivalent to ask whether the + * device is Bluefield-3. + * Later, when FW exposes specific flag for it, this condition should be + * removed and 'gga_comp_opaq_new_version' field will read the PRM flag + * directly. + */ + if (attr->mmo_decompress_qp_en && !attr->mmo_compress_qp_en) + attr->gga_comp_opaq_new_version = 1; attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr, compress_min_block_size); attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size); diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index c94b9eac06..dac86e8a5b 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -260,6 +260,7 @@ struct mlx5_hca_attr { uint32_t mmo_dma_qp_en:1; uint32_t mmo_compress_qp_en:1; uint32_t mmo_decompress_qp_en:1; + uint32_t gga_comp_opaq_new_version:1; uint32_t mmo_regex_qp_en:1; uint32_t mmo_regex_sq_en:1; uint32_t compress_min_block_size:4; diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 2b5c43ee6e..c3a1ce11a4 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -607,17 +607,27 @@ struct mlx5_gga_wqe { struct mlx5_wqe_dseg scatter; } __rte_packed; -struct mlx5_gga_compress_opaque { - uint32_t syndrom; - uint32_t reserved0; - uint32_t scattered_length; - uint32_t gathered_length; - uint64_t scatter_crc; - uint64_t gather_crc; - uint32_t crc32; - uint32_t adler32; - uint8_t reserved1[216]; -} __rte_packed; +union mlx5_gga_compress_opaque { + struct { + uint32_t syndrome; + uint32_t reserved0; + uint32_t scattered_length; + union { + struct { + uint32_t reserved1[5]; + uint32_t crc32; + uint32_t adler32; + } v1 __rte_packed; + struct { + uint32_t crc32; + uint32_t adler32; + uint32_t crc32c; + uint32_t xxh32; + } v2 __rte_packed; + }; + } __rte_packed; + uint32_t data[64]; +}; struct mlx5_ifc_regexp_mmo_control_bits { uint8_t reserved_at_31[0x2]; diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index d38f247216..10a609e3ec 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -55,6 +55,7 @@ struct mlx5_compress_priv { uint32_t mmo_dma_sq:1; uint32_t mmo_dma_qp:1; uint32_t log_block_sz; + uint32_t crc32_opaq_offs; }; struct mlx5_compress_qp { @@ -157,7 +158,7 @@ mlx5_compress_init_qp(struct mlx5_compress_qp *qp) { volatile struct mlx5_gga_wqe *restrict wqe = (volatile struct mlx5_gga_wqe *)qp->qp.wqes; - volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; + volatile union mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u); const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS << MLX5_COMP_MODE_OFFSET); @@ -211,8 +212,8 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, goto err; } opaq_buf = rte_calloc(__func__, (size_t)1 << log_ops_n, - sizeof(struct mlx5_gga_compress_opaque), - sizeof(struct mlx5_gga_compress_opaque)); + sizeof(union mlx5_gga_compress_opaque), + sizeof(union mlx5_gga_compress_opaque)); if (opaq_buf == NULL) { DRV_LOG(ERR, "Failed to allocate opaque memory."); rte_errno = ENOMEM; @@ -225,7 +226,7 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp->ops = (struct rte_comp_op **)RTE_ALIGN((uintptr_t)(qp + 1), RTE_CACHE_LINE_SIZE); if (mlx5_common_verbs_reg_mr(priv->cdev->pd, opaq_buf, qp->entries_n * - sizeof(struct mlx5_gga_compress_opaque), + sizeof(union mlx5_gga_compress_opaque), &qp->opaque_mr) != 0) { rte_free(opaq_buf); DRV_LOG(ERR, "Failed to register opaque MR."); @@ -544,7 +545,7 @@ mlx5_compress_dump_err_objs(volatile uint32_t *cqe, volatile uint32_t *wqe, DRV_LOG(ERR, "%08X %08X %08X %08X", wqe[i], wqe[i + 1], wqe[i + 2], wqe[i + 3]); DRV_LOG(ERR, "\nError opaq:"); - for (i = 0; i < sizeof(struct mlx5_gga_compress_opaque) >> 2; i += 4) + for (i = 0; i < sizeof(union mlx5_gga_compress_opaque) >> 2; i += 4) DRV_LOG(ERR, "%08X %08X %08X %08X", opaq[i], opaq[i + 1], opaq[i + 2], opaq[i + 3]); } @@ -558,7 +559,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp, &qp->cq.cqes[idx]; volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *) qp->qp.wqes; - volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; + volatile union mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; volatile uint32_t *synd_word = RTE_PTR_ADD(cqe, MLX5_ERROR_CQE_SYNDROME_OFFSET); switch (*synd_word) { @@ -575,7 +576,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp, op->consumed = 0; op->produced = 0; op->output_chksum = 0; - op->debug_status = rte_be_to_cpu_32(opaq[idx].syndrom) | + op->debug_status = rte_be_to_cpu_32(opaq[idx].syndrome) | ((uint64_t)rte_be_to_cpu_32(cqe->syndrome) << 32); mlx5_compress_dump_err_objs((volatile uint32_t *)cqe, (volatile uint32_t *)&wqes[idx], @@ -590,13 +591,14 @@ mlx5_compress_dequeue_burst(void *queue_pair, struct rte_comp_op **ops, struct mlx5_compress_qp *qp = queue_pair; volatile struct mlx5_compress_xform *restrict xform; volatile struct mlx5_cqe *restrict cqe; - volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; + volatile union mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr; struct rte_comp_op *restrict op; const unsigned int cq_size = qp->entries_n; const unsigned int mask = cq_size - 1; uint32_t idx; uint32_t next_idx = qp->ci & mask; const uint16_t max = RTE_MIN((uint16_t)(qp->pi - qp->ci), nb_ops); + uint32_t crc32_idx = qp->priv->crc32_opaq_offs; uint16_t i = 0; int ret; @@ -629,17 +631,17 @@ mlx5_compress_dequeue_burst(void *queue_pair, struct rte_comp_op **ops, switch (xform->csum_type) { case RTE_COMP_CHECKSUM_CRC32: op->output_chksum = (uint64_t)rte_be_to_cpu_32 - (opaq[idx].crc32); + (opaq[idx].data[crc32_idx]); break; case RTE_COMP_CHECKSUM_ADLER32: op->output_chksum = (uint64_t)rte_be_to_cpu_32 - (opaq[idx].adler32); + (opaq[idx].data[crc32_idx + 1]); break; case RTE_COMP_CHECKSUM_CRC32_ADLER32: op->output_chksum = (uint64_t)rte_be_to_cpu_32 - (opaq[idx].crc32) | + (opaq[idx].data[crc32_idx]) | ((uint64_t)rte_be_to_cpu_32 - (opaq[idx].adler32) << 32); + (opaq[idx].data[crc32_idx + 1]) << 32); break; default: break; @@ -717,6 +719,7 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev, .socket_id = cdev->dev->numa_node, }; const char *ibdev_name = mlx5_os_get_ctx_device_name(cdev->ctx); + uint32_t crc32_opaq_offset; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { DRV_LOG(ERR, "Non-primary process type is not supported."); @@ -751,6 +754,14 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev, 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->gga_comp_opaq_new_version) + crc32_opaq_offset = offsetof(union mlx5_gga_compress_opaque, + v2.crc32); + else + crc32_opaq_offset = offsetof(union mlx5_gga_compress_opaque, + v1.crc32); + MLX5_ASSERT((crc32_opaq_offset % 4) == 0); + priv->crc32_opaq_offs = crc32_opaq_offset / 4; priv->cdev = cdev; priv->compressdev = compressdev; priv->min_block_size = attr->compress_min_block_size;