[v4,1/4] compressdev: add LZ4 algorithm support
Checks
Commit Message
Add support for LZ4 algorithm:
- Add Lz4 param structure to XFORM structures.
- Add capabilities flags for LZ4 params.
- Add xxHash-32 checksum and capabilities flag.
Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
doc/guides/compressdevs/features/default.ini | 7 ++
doc/guides/rel_notes/release_23_03.rst | 7 ++
lib/compressdev/rte_comp.c | 12 +++
lib/compressdev/rte_comp.h | 79 +++++++++++++++++++-
4 files changed, 103 insertions(+), 2 deletions(-)
@@ -20,8 +20,15 @@ OOP SGL In LB Out =
OOP LB In SGL Out =
Deflate =
LZS =
+LZ4 =
Adler32 =
Crc32 =
Adler32&Crc32 =
+xxHash32 =
Fixed =
Dynamic =
+LZ4 Dictionary ID =
+LZ4 Content Checksum =
+LZ4 Content Size =
+LZ4 Block Checksum =
+LZ4 Block Independence =
@@ -105,6 +105,13 @@ New Features
* Added support to capture packets at each graph node with packet metadata and
node name.
+* **Added LZ4 algorithm in Compressdev Library.**
+
+ Added new compression algorithm, including:
+
+ * Added support for ``RTE_COMP_ALGO_LZ4``.
+ * Added support for ``RTE_COMP_CHECKSUM_XXHASH32``.
+
Removed Items
-------------
@@ -39,6 +39,18 @@ rte_comp_get_feature_name(uint64_t flag)
return "HUFFMAN_FIXED";
case RTE_COMP_FF_HUFFMAN_DYNAMIC:
return "HUFFMAN_DYNAMIC";
+ case RTE_COMP_FF_XXHASH32_CHECKSUM:
+ return "XXHASH32_CHECKSUM";
+ case RTE_COMP_FF_LZ4_DICT_ID:
+ return "LZ4_DICT_ID";
+ case RTE_COMP_FF_LZ4_CONTENT_WITH_CHECKSUM:
+ return "LZ4_CONTENT_WITH_CHECKSUM";
+ case RTE_COMP_FF_LZ4_CONTENT_SIZE:
+ return "LZ4_CONTENT_SIZE";
+ case RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE:
+ return "LZ4_BLOCK_INDEPENDENCE";
+ case RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM:
+ return "LZ4_BLOCK_WITH_CHECKSUM";
default:
return NULL;
}
@@ -67,6 +67,18 @@ extern "C" {
/**< Fixed huffman encoding is supported */
#define RTE_COMP_FF_HUFFMAN_DYNAMIC (1ULL << 14)
/**< Dynamic huffman encoding is supported */
+#define RTE_COMP_FF_XXHASH32_CHECKSUM (1ULL << 15)
+/**< xxHash-32 Checksum is supported */
+#define RTE_COMP_FF_LZ4_DICT_ID (1ULL << 16)
+/**< LZ4 dictionary ID is supported */
+#define RTE_COMP_FF_LZ4_CONTENT_WITH_CHECKSUM (1ULL << 17)
+/**< LZ4 content with checksum is supported */
+#define RTE_COMP_FF_LZ4_CONTENT_SIZE (1ULL << 18)
+/**< LZ4 content size is supported */
+#define RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE (1ULL << 19)
+/**< LZ4 block independent is supported */
+#define RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM (1ULL << 20)
+/**< LZ4 block with checksum is supported */
/** Status of comp operation */
enum rte_comp_op_status {
@@ -109,6 +121,10 @@ enum rte_comp_algorithm {
/**< LZS compression algorithm
* https://tools.ietf.org/html/rfc2395
*/
+ RTE_COMP_ALGO_LZ4,
+ /**< LZ4 compression algorithm
+ * https://github.com/lz4/lz4
+ */
};
/** Compression Hash Algorithms */
@@ -147,9 +163,12 @@ enum rte_comp_checksum_type {
/**< Generates both Adler-32 and CRC32 checksums, concatenated.
* CRC32 is in the lower 32bits, Adler-32 in the upper 32 bits.
*/
+ RTE_COMP_CHECKSUM_XXHASH32,
+ /**< Generates a xxHash-32 checksum, as used by lz4.
+ * https://github.com/Cyan4973/xxHash/blob/dev/doc/xxhash_spec.md
+ */
};
-
/** Compression Huffman Type - used by DEFLATE algorithm */
enum rte_comp_huffman {
RTE_COMP_HUFFMAN_DEFAULT,
@@ -206,13 +225,63 @@ enum rte_comp_op_type {
*/
};
-
/** Parameters specific to the deflate algorithm */
struct rte_comp_deflate_params {
enum rte_comp_huffman huffman;
/**< Compression huffman encoding type */
};
+/**
+ * Dictionary ID flag
+ * If this flag is set, a 4-bytes Dict-ID field will be present, after the
+ * descriptor flags and the Content Size.
+ */
+#define RTE_COMP_LZ4_FLAG_DICT_ID (1 << 0)
+
+/**
+ * Content Checksum flag
+ * If this flag is set, a 32-bits content checksum will be appended after the
+ * EndMark.
+ */
+#define RTE_COMP_LZ4_FLAG_CONTENT_CHECKSUM (1 << 2)
+
+/**
+ * Content Size flag
+ * If this flag is set, the uncompressed size of data included within the frame
+ * will be present as an 8 bytes unsigned little-endian value, after the flags.
+ * Content Size usage is optional.
+ */
+#define RTE_COMP_LZ4_FLAG_CONTENT_SIZE (1 << 3)
+
+/**
+ * Block Checksum flag.
+ * If this flag is set, each data block will be followed by a 4-bytes checksum,
+ * calculated by using the xxHash-32 algorithm on the raw (compressed) data
+ * block. The intention is to detect data corruption (storage or transmission
+ * errors) immediately, before decoding. Block checksum usage is optional.
+ */
+#define RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM (1 << 4)
+
+/**
+ * Block Independence flag.
+ * If this flag is set to 1, blocks are independent.
+ * If this flag is set to 0, each block depends on previous ones (up to LZ4
+ * window size, which is 64 KB). In such case, it is necessary to decode all
+ * blocks in sequence.
+ * Block dependency improves compression ratio, especially for small blocks. On
+ * the other hand, it makes random access or multi-threaded decoding impossible.
+ */
+#define RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE (1 << 5)
+
+/** Parameters specific to the LZ4 algorithm */
+struct rte_comp_lz4_params {
+ uint8_t flags;
+ /**< Compression LZ4 parameter flags.
+ * Based on LZ4 standard flags:
+ * https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md#frame-descriptor
+ */
+};
+
/** Setup Data for compression */
struct rte_comp_compress_xform {
enum rte_comp_algorithm algo;
@@ -220,6 +289,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 */
@@ -249,6 +320,10 @@ struct rte_comp_decompress_xform {
* compressed data. If window size can't be supported by the PMD then
* setup of stream or private_xform should fail.
*/
+ union {
+ struct rte_comp_lz4_params lz4;
+ /**< Parameters specific to the LZ4 algorithm */
+ }; /**< Algorithm specific parameters */
enum rte_comp_hash_algorithm hash_algo;
/**< Hash algorithm to be used with decompress operation. Hash is always
* done on plaintext.