DPDK patches and discussions
 help / color / mirror / Atom feed
From: Raja Zidane <rzidane@nvidia.com>
To: <dev@dpdk.org>
Cc: <matan@nvidia.com>
Subject: [RFC] compress/mlx5: add support for LZ4 decompress
Date: Sun, 10 Apr 2022 21:26:22 +0300	[thread overview]
Message-ID: <20220410182622.8828-1-rzidane@nvidia.com> (raw)

LZ4 decompress will be supported starting from BlueField3.

Add LZ4 params struct to RTE XFORM struct.
Add case to check for LZ4 algo, and pass params from RTE XFORM.

Signed-off-by: Raja Zidane <rzidane@nvidia.com>
---
 drivers/common/mlx5/mlx5_prm.h        |  6 +++++
 drivers/compress/mlx5/mlx5_compress.c | 29 +++++++++++++++++++++++
 lib/compressdev/rte_comp.h            | 34 +++++++++++++++++++++++----
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 2ded67e85e..b89bf922b8 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -548,9 +548,15 @@ struct mlx5_rdma_write_wqe {
 #define	MLX5_OPC_MOD_MMO_DECOMP 0x3u
 #define	MLX5_OPC_MOD_MMO_DMA 0x1u
 
+#define WQE_GGA_DECOMP_DEFLATE 0x0u
+#define WQE_GGA_DECOMP_SNAPPY 0x1u
+#define WQE_GGA_DECOMP_LZ4 0x2u
+
 #define WQE_GGA_COMP_WIN_SIZE_OFFSET 12u
 #define WQE_GGA_COMP_BLOCK_SIZE_OFFSET 16u
 #define WQE_GGA_COMP_DYNAMIC_SIZE_OFFSET 20u
+#define WQE_GGA_DECOMP_PARAMS_OFFSET 20u
+#define WQE_GGA_DECOMP_TYPE_OFFSET 8u
 #define MLX5_GGA_COMP_WIN_SIZE_UNITS 1024u
 #define MLX5_GGA_COMP_WIN_SIZE_MAX (32u * MLX5_GGA_COMP_WIN_SIZE_UNITS)
 #define MLX5_GGA_COMP_LOG_BLOCK_SIZE_MAX 15u
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 82b871bd86..4994e38ab6 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -298,6 +298,10 @@ mlx5_compress_xform_create(struct rte_compressdev *dev,
 			DRV_LOG(ERR, "Not enough capabilities to support compress operation, maybe old FW/OFED version?");
 			return -ENOTSUP;
 		}
+		if (xform->compress.algo == RTE_COMP_ALGO_LZ4) {
+			DRV_LOG(ERR, "LZ4 compression is not supported.");
+			return -ENOTSUP;
+		}
 		if (xform->compress.level == RTE_COMP_LEVEL_NONE) {
 			DRV_LOG(ERR, "Non-compressed block is not supported.");
 			return -ENOTSUP;
@@ -371,6 +375,31 @@ mlx5_compress_xform_create(struct rte_compressdev *dev,
 		case RTE_COMP_ALGO_DEFLATE:
 			xfrm->opcode += MLX5_OPC_MOD_MMO_DECOMP <<
 							WQE_CSEG_OPC_MOD_OFFSET;
+			xfrm->gga_ctrl1 += WQE_GGA_DECOMP_DEFLATE <<
+						WQE_GGA_DECOMP_TYPE_OFFSET;
+			break;
+		case RTE_COMP_ALGO_LZ4:
+			xfrm->opcode += MLX5_OPC_MOD_MMO_DECOMP <<
+							WQE_CSEG_OPC_MOD_OFFSET;
+			xfrm->gga_ctrl1 += WQE_GGA_DECOMP_LZ4 <<
+						WQE_GGA_DECOMP_TYPE_OFFSET;
+			switch (xform->decompress.lz4.lz4) {
+			case RTE_COMP_LZ4_DATA_ONLY:
+				xfrm->gga_ctrl1 += 0u <<
+						WQE_GGA_DECOMP_PARAMS_OFFSET;
+				break;
+			case RTE_COMP_LZ4_BLOCK_WITHOUT_CHECKSUM:
+				xfrm->gga_ctrl1 += 1u <<
+						WQE_GGA_DECOMP_PARAMS_OFFSET;
+				break;
+			case RTE_COMP_LZ4_BLOCK_WITH_CHECKSUM:
+				xfrm->gga_ctrl1 += 2u <<
+						WQE_GGA_DECOMP_PARAMS_OFFSET;
+				break;
+			default:
+				xfrm->gga_ctrl1 += 0u <<
+						WQE_GGA_DECOMP_PARAMS_OFFSET;
+			}
 			break;
 		default:
 			goto err;
diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h
index 95306c5d03..2a0cd79873 100644
--- a/lib/compressdev/rte_comp.h
+++ b/lib/compressdev/rte_comp.h
@@ -109,6 +109,10 @@ enum rte_comp_algorithm {
 	/**< LZS compression algorithm
 	 * https://tools.ietf.org/html/rfc2395
 	 */
+	RTE_COMP_ALGO_LZ4,
+	/**< LZ4 compression algorithm
+	 * <rfc link>
+	 */
 	RTE_COMP_ALGO_LIST_END
 };
 
@@ -162,6 +166,14 @@ enum rte_comp_huffman {
 	/**< Use Dynamic Huffman codes */
 };
 
+enum rte_comp_lz4 {
+	RTE_COMP_LZ4_DEFAULT,
+	/**< PMD may choose which LZ4 codes to use */
+	RTE_COMP_LZ4_DATA_ONLY,
+	RTE_COMP_LZ4_BLOCK_WITHOUT_CHECKSUM,
+	RTE_COMP_LZ4_BLOCK_WITH_CHECKSUM,
+};
+
 /** Compression flush flags */
 enum rte_comp_flush_flag {
 	RTE_COMP_FLUSH_NONE,
@@ -215,6 +227,12 @@ struct rte_comp_deflate_params {
 	/**< Compression huffman encoding type */
 };
 
+/** Parameters specific to the lz4 algorithm */
+struct rte_comp_lz4_params {
+	enum rte_comp_lz4 lz4;
+	/**< Compression LZ4 encoding type */
+};
+
 /** Setup Data for compression */
 struct rte_comp_compress_xform {
 	enum rte_comp_algorithm algo;
@@ -222,6 +240,8 @@ struct rte_comp_compress_xform {
 	union {
 		struct rte_comp_deflate_params deflate;
 		/**< Parameters specific to the deflate algorithm */
+		struct rte_comp_lz4_params lz4;
+		/**< Parameters specific to the lz4 algorithm */
 	}; /**< Algorithm specific parameters */
 	int level;
 	/**< Compression level */
@@ -246,11 +266,15 @@ struct rte_comp_decompress_xform {
 	/**< Algorithm to use for decompression */
 	enum rte_comp_checksum_type chksum;
 	/**< Type of checksum to generate on the decompressed data */
-	uint8_t window_size;
-	/**< Base two log value of sliding window which was used to generate
-	 * compressed data. If window size can't be supported by the PMD then
-	 * setup of stream or private_xform should fail.
-	 */
+	union {
+		uint8_t window_size;
+		/**< Base two log value of sliding window which was used to generate
+		 * compressed data. If window size can't be supported by the PMD then
+		 * setup of stream or private_xform should fail.
+		 */
+		struct rte_comp_lz4_params lz4;
+		/**< Parameters specific to the lz4 algorithm */
+	};
 	enum rte_comp_hash_algorithm hash_algo;
 	/**< Hash algorithm to be used with decompress operation. Hash is always
 	 * done on plaintext.
-- 
2.21.0


                 reply	other threads:[~2022-04-10 18:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220410182622.8828-1-rzidane@nvidia.com \
    --to=rzidane@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).