@@ -61,6 +61,7 @@ struct comp_test_data {
uint16_t max_sgl_segs;
uint32_t total_segs;
+ uint8_t lz4_flags;
enum rte_comp_huffman huffman_enc;
enum comp_operation test_op;
enum rte_comp_algorithm test_algo;
@@ -27,6 +27,7 @@
#define CPERF_OPTYPE ("operation")
#define CPERF_ALGO ("algo")
#define CPERF_HUFFMAN_ENC ("huffman-enc")
+#define CPERF_LZ4_FLAGS ("lz4-flags")
#define CPERF_LEVEL ("compress-level")
#define CPERF_WINDOW_SIZE ("window-sz")
#define CPERF_EXTERNAL_MBUFS ("external-mbufs")
@@ -57,10 +58,11 @@ usage(char *progname)
" compressed/decompressed (default: 10000)\n"
" --operation [comp/decomp/comp_and_decomp]: perform test on\n"
" compression, decompression or both operations\n"
- " --algo [null/deflate/lzs]: perform test on algorithm\n"
- " null(DMA), deflate or lzs (default: deflate)\n"
+ " --algo [null/deflate/lzs/lz4]: perform test on algorithm\n"
+ " null(DMA), deflate, lzs or lz4 (default: deflate)\n"
" --huffman-enc [fixed/dynamic/default]: Huffman encoding\n"
" (default: dynamic)\n"
+ " --lz4-flags N: flags to configure LZ4 algorithm (default: 0)\n"
" --compress-level N: compression level, which could be a single value, list or range\n"
" (default: range between 1 and 9)\n"
" --window-sz N: base two log value of compression window size\n"
@@ -153,6 +155,23 @@ parse_uint16_t(uint16_t *value, const char *arg)
return 0;
}
+static int
+parse_uint8_t(uint8_t *value, const char *arg)
+{
+ uint32_t val = 0;
+ int ret = parse_uint32_t(&val, arg);
+
+ if (ret < 0)
+ return ret;
+
+ if (val > UINT8_MAX)
+ return -ERANGE;
+
+ *value = (uint8_t) val;
+
+ return 0;
+}
+
static int
parse_range(const char *arg, uint8_t *min, uint8_t *max, uint8_t *inc)
{
@@ -488,6 +507,10 @@ parse_algo(struct comp_test_data *test_data, const char *arg)
{
"lzs",
RTE_COMP_ALGO_LZS
+ },
+ {
+ "lz4",
+ RTE_COMP_ALGO_LZ4
}
};
@@ -533,6 +556,19 @@ parse_huffman_enc(struct comp_test_data *test_data, const char *arg)
return 0;
}
+static int
+parse_lz4_flags(struct comp_test_data *test_data, const char *arg)
+{
+ int ret = parse_uint8_t(&test_data->lz4_flags, arg);
+
+ if (ret) {
+ RTE_LOG(ERR, USER1, "Failed to parse LZ4 flags\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static int
parse_level(struct comp_test_data *test_data, const char *arg)
{
@@ -607,6 +643,7 @@ static struct option lgopts[] = {
{ CPERF_OPTYPE, required_argument, 0, 0 },
{ CPERF_ALGO, required_argument, 0, 0 },
{ CPERF_HUFFMAN_ENC, required_argument, 0, 0 },
+ { CPERF_LZ4_FLAGS, required_argument, 0, 0 },
{ CPERF_LEVEL, required_argument, 0, 0 },
{ CPERF_WINDOW_SIZE, required_argument, 0, 0 },
{ CPERF_EXTERNAL_MBUFS, 0, 0, 0 },
@@ -630,6 +667,7 @@ comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data)
{ CPERF_OPTYPE, parse_op_type },
{ CPERF_ALGO, parse_algo },
{ CPERF_HUFFMAN_ENC, parse_huffman_enc },
+ { CPERF_LZ4_FLAGS, parse_lz4_flags },
{ CPERF_LEVEL, parse_level },
{ CPERF_WINDOW_SIZE, parse_window_sz },
{ CPERF_EXTERNAL_MBUFS, parse_external_mbufs },
@@ -682,6 +720,7 @@ comp_perf_options_default(struct comp_test_data *test_data)
test_data->pool_sz = 8192;
test_data->max_sgl_segs = 16;
test_data->num_iter = 10000;
+ test_data->lz4_flags = 0;
test_data->huffman_enc = RTE_COMP_HUFFMAN_DYNAMIC;
test_data->test_op = COMPRESS_DECOMPRESS;
test_data->test_algo = RTE_COMP_ALGO_DEFLATE;
@@ -194,13 +194,16 @@ main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type)
.type = RTE_COMP_COMPRESS,
.compress = {
.algo = test_data->test_algo,
- .deflate.huffman = test_data->huffman_enc,
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
+ xform.compress.deflate.huffman = test_data->huffman_enc;
+ else if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.compress.lz4.flags = test_data->lz4_flags;
input_bufs = mem->decomp_bufs;
output_bufs = mem->comp_bufs;
out_seg_sz = test_data->out_seg_sz;
@@ -214,6 +217,8 @@ main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type)
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.decompress.lz4.flags = test_data->lz4_flags;
input_bufs = mem->comp_bufs;
output_bufs = mem->decomp_bufs;
out_seg_sz = test_data->seg_sz;
@@ -85,13 +85,16 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type)
.type = RTE_COMP_COMPRESS,
.compress = {
.algo = test_data->test_algo,
- .deflate.huffman = test_data->huffman_enc,
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
+ xform.compress.deflate.huffman = test_data->huffman_enc;
+ else if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.compress.lz4.flags = test_data->lz4_flags;
input_bufs = mem->decomp_bufs;
output_bufs = mem->comp_bufs;
out_seg_sz = test_data->out_seg_sz;
@@ -105,6 +108,8 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type)
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.decompress.lz4.flags = test_data->lz4_flags;
input_bufs = mem->comp_bufs;
output_bufs = mem->decomp_bufs;
out_seg_sz = test_data->seg_sz;
@@ -88,13 +88,16 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.type = RTE_COMP_COMPRESS,
.compress = {
.algo = test_data->test_algo,
- .deflate.huffman = test_data->huffman_enc,
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
+ xform.compress.deflate.huffman = test_data->huffman_enc;
+ else if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.compress.lz4.flags = test_data->lz4_flags;
output_data_ptr = ctx->mem.compressed_data;
output_data_sz = &ctx->comp_data_sz;
input_bufs = mem->decomp_bufs;
@@ -110,6 +113,8 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.hash_algo = RTE_COMP_HASH_ALGO_NONE
}
};
+ if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
+ xform.decompress.lz4.flags = test_data->lz4_flags;
output_data_ptr = ctx->mem.decompressed_data;
output_data_sz = &ctx->decomp_data_sz;
input_bufs = mem->comp_bufs;
@@ -86,6 +86,23 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
return -1;
}
break;
+ case RTE_COMP_ALGO_LZ4:
+ /* LZ4 flags */
+ if ((test_data->lz4_flags & RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM) &&
+ (comp_flags & RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM) == 0) {
+ RTE_LOG(ERR, USER1,
+ "Compress device does not support LZ4 block with checksum\n");
+ return -1;
+ }
+
+ if ((test_data->lz4_flags &
+ RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE) &&
+ (comp_flags & RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE) == 0) {
+ RTE_LOG(ERR, USER1,
+ "Compress device does not support LZ4 independent blocks\n");
+ return -1;
+ }
+ break;
case RTE_COMP_ALGO_LZS:
case RTE_COMP_ALGO_NULL:
break;
@@ -61,6 +61,7 @@ New Features
* Added support for ``RTE_COMP_ALGO_LZ4``.
* Added support for ``RTE_COMP_CHECKSUM_XXHASH32``.
+ * Added support for ``lz4`` in test-compress-perf algo options.
* **Allowed test single compress operation in test-compress-perf.**
@@ -84,10 +84,13 @@ Application Options
``--operation [comp/decomp/comp_and_decomp]``: perform test on compression, decompression or both operations
- ``--algo [null/deflate/lzs]`` : perform test on algorithm null(DMA), Deflate or lzs (default: Deflate)
+ ``--algo [null/deflate/lzs/lz4]`` : perform test on algorithm null(DMA), Deflate, lzs or lz4 (default: Deflate)
``--huffman-enc [fixed/dynamic/default]``: Huffman encoding (default: dynamic)
+ ``--lz4-flags N``: flags to for LZ4 parameters,
+ see `LZ4 Frame Descriptor <https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md#frame-descriptor>`_ (default: no flags)
+
``--compress-level N``: compression level, which could be a single value, list or range (default: range between 1 and 9)
``--window-sz N``: base two log value of compression window size (default: max supported by PMD)