Add a command line option `algo` to select the compress algorithm supported by the compress API: null (DMA), deflate and lzs.
Default for deflate. Signed-off-by: Matan Azrad <ma...@nvidia.com> Signed-off-by: Michael Baum <michae...@nvidia.com> --- app/test-compress-perf/comp_perf_options.h | 2 + .../comp_perf_options_parse.c | 40 ++++++++++++++++++- .../comp_perf_test_cyclecount.c | 4 +- .../comp_perf_test_throughput.c | 4 +- .../comp_perf_test_verify.c | 4 +- app/test-compress-perf/main.c | 38 +++++++++++------- doc/guides/rel_notes/release_23_03.rst | 4 ++ doc/guides/tools/comp_perf.rst | 2 + 8 files changed, 76 insertions(+), 22 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h index d00b299247..5e5227a700 100644 --- a/app/test-compress-perf/comp_perf_options.h +++ b/app/test-compress-perf/comp_perf_options.h @@ -63,6 +63,8 @@ struct comp_test_data { enum rte_comp_huffman huffman_enc; enum comp_operation test_op; + enum rte_comp_algorithm test_algo; + int window_sz; struct range_list level_lst; uint8_t level; diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c index 7a992bf43e..97ddff87ef 100644 --- a/app/test-compress-perf/comp_perf_options_parse.c +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -25,6 +25,7 @@ #define CPERF_MAX_SGL_SEGS ("max-num-sgl-segs") #define CPERF_NUM_ITER ("num-iter") #define CPERF_OPTYPE ("operation") +#define CPERF_ALGO ("algo") #define CPERF_HUFFMAN_ENC ("huffman-enc") #define CPERF_LEVEL ("compress-level") #define CPERF_WINDOW_SIZE ("window-sz") @@ -56,6 +57,8 @@ 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" " --huffman-enc [fixed/dynamic/default]: Huffman encoding\n" " (default: dynamic)\n" " --compress-level N: compression level, which could be a single value, list or range\n" @@ -470,6 +473,36 @@ parse_op_type(struct comp_test_data *test_data, const char *arg) return 0; } +static int +parse_algo(struct comp_test_data *test_data, const char *arg) +{ + struct name_id_map algo_namemap[] = { + { + "null", + RTE_COMP_ALGO_NULL + }, + { + "deflate", + RTE_COMP_ALGO_DEFLATE + }, + { + "lzs", + RTE_COMP_ALGO_LZS + } + }; + + int id = get_str_key_id_mapping(algo_namemap, + RTE_DIM(algo_namemap), arg); + if (id < 0) { + RTE_LOG(ERR, USER1, "Invalid algorithm specified\n"); + return -1; + } + + test_data->test_algo = (enum rte_comp_algorithm)id; + + return 0; +} + static int parse_huffman_enc(struct comp_test_data *test_data, const char *arg) { @@ -491,7 +524,7 @@ parse_huffman_enc(struct comp_test_data *test_data, const char *arg) int id = get_str_key_id_mapping(huffman_namemap, RTE_DIM(huffman_namemap), arg); if (id < 0) { - RTE_LOG(ERR, USER1, "Invalid Huffmane encoding specified\n"); + RTE_LOG(ERR, USER1, "Invalid Huffman encoding specified\n"); return -1; } @@ -507,7 +540,7 @@ parse_level(struct comp_test_data *test_data, const char *arg) /* * Try parsing the argument as a range, if it fails, - * arse it as a list + * parse it as a list */ if (parse_range(arg, &test_data->level_lst.min, &test_data->level_lst.max, @@ -572,6 +605,7 @@ static struct option lgopts[] = { { CPERF_MAX_SGL_SEGS, required_argument, 0, 0}, { CPERF_NUM_ITER, required_argument, 0, 0 }, { CPERF_OPTYPE, required_argument, 0, 0 }, + { CPERF_ALGO, required_argument, 0, 0 }, { CPERF_HUFFMAN_ENC, required_argument, 0, 0 }, { CPERF_LEVEL, required_argument, 0, 0 }, { CPERF_WINDOW_SIZE, required_argument, 0, 0 }, @@ -594,6 +628,7 @@ comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data) { CPERF_MAX_SGL_SEGS, parse_max_num_sgl_segs }, { CPERF_NUM_ITER, parse_num_iter }, { CPERF_OPTYPE, parse_op_type }, + { CPERF_ALGO, parse_algo }, { CPERF_HUFFMAN_ENC, parse_huffman_enc }, { CPERF_LEVEL, parse_level }, { CPERF_WINDOW_SIZE, parse_window_sz }, @@ -649,6 +684,7 @@ comp_perf_options_default(struct comp_test_data *test_data) test_data->num_iter = 10000; test_data->huffman_enc = RTE_COMP_HUFFMAN_DYNAMIC; test_data->test_op = COMPRESS_DECOMPRESS; + test_data->test_algo = RTE_COMP_ALGO_DEFLATE; test_data->window_sz = -1; test_data->level_lst.min = RTE_COMP_LEVEL_MIN; test_data->level_lst.max = RTE_COMP_LEVEL_MAX; diff --git a/app/test-compress-perf/comp_perf_test_cyclecount.c b/app/test-compress-perf/comp_perf_test_cyclecount.c index ce6c4d7605..81c3d30038 100644 --- a/app/test-compress-perf/comp_perf_test_cyclecount.c +++ b/app/test-compress-perf/comp_perf_test_cyclecount.c @@ -193,7 +193,7 @@ main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_COMPRESS, .compress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .deflate.huffman = test_data->huffman_enc, .level = test_data->level, .window_size = test_data->window_sz, @@ -208,7 +208,7 @@ main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_DECOMPRESS, .decompress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .chksum = RTE_COMP_CHECKSUM_NONE, .window_size = test_data->window_sz, .hash_algo = RTE_COMP_HASH_ALGO_NONE diff --git a/app/test-compress-perf/comp_perf_test_throughput.c b/app/test-compress-perf/comp_perf_test_throughput.c index c9f8237626..2545ee9925 100644 --- a/app/test-compress-perf/comp_perf_test_throughput.c +++ b/app/test-compress-perf/comp_perf_test_throughput.c @@ -84,7 +84,7 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_COMPRESS, .compress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .deflate.huffman = test_data->huffman_enc, .level = test_data->level, .window_size = test_data->window_sz, @@ -99,7 +99,7 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_DECOMPRESS, .decompress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .chksum = RTE_COMP_CHECKSUM_NONE, .window_size = test_data->window_sz, .hash_algo = RTE_COMP_HASH_ALGO_NONE diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c index 7d6b6abecd..88f4f41851 100644 --- a/app/test-compress-perf/comp_perf_test_verify.c +++ b/app/test-compress-perf/comp_perf_test_verify.c @@ -87,7 +87,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_COMPRESS, .compress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .deflate.huffman = test_data->huffman_enc, .level = test_data->level, .window_size = test_data->window_sz, @@ -104,7 +104,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type) xform = (struct rte_comp_xform) { .type = RTE_COMP_DECOMPRESS, .decompress = { - .algo = RTE_COMP_ALGO_DEFLATE, + .algo = test_data->test_algo, .chksum = RTE_COMP_CHECKSUM_NONE, .window_size = test_data->window_sz, .hash_algo = RTE_COMP_HASH_ALGO_NONE diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c index bbb4c7917b..d049527ba1 100644 --- a/app/test-compress-perf/main.c +++ b/app/test-compress-perf/main.c @@ -57,29 +57,39 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) { const struct rte_compressdev_capabilities *cap; - cap = rte_compressdev_capability_get(cdev_id, - RTE_COMP_ALGO_DEFLATE); + cap = rte_compressdev_capability_get(cdev_id, test_data->test_algo); if (cap == NULL) { RTE_LOG(ERR, USER1, - "Compress device does not support DEFLATE\n"); + "Compress device does not support %u algorithm\n", + test_data->test_algo); return -1; } uint64_t comp_flags = cap->comp_feature_flags; - /* Huffman encoding */ - if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED && - (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) { - RTE_LOG(ERR, USER1, - "Compress device does not supported Fixed Huffman\n"); - return -1; - } + /* Algorithm type */ + switch (test_data->test_algo) { + case RTE_COMP_ALGO_DEFLATE: + /* Huffman encoding */ + if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED && + (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) { + RTE_LOG(ERR, USER1, + "Compress device does not supported Fixed Huffman\n"); + return -1; + } - if (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC && - (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) { - RTE_LOG(ERR, USER1, - "Compress device does not supported Dynamic Huffman\n"); + if (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC && + (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) { + RTE_LOG(ERR, USER1, + "Compress device does not supported Dynamic Huffman\n"); + return -1; + } + break; + case RTE_COMP_ALGO_LZS: + case RTE_COMP_ALGO_NULL: + break; + default: return -1; } diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 15fa8e812b..da345ded48 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -89,6 +89,10 @@ New Features Enable the application options for testing only compress and only decompress. +* **Added algo option in test-compress-perf.** + + Added support for testing other algorithms except for DEFLAT. + Removed Items ------------- diff --git a/doc/guides/tools/comp_perf.rst b/doc/guides/tools/comp_perf.rst index 9d2f4dbe4a..cf9035cc23 100644 --- a/doc/guides/tools/comp_perf.rst +++ b/doc/guides/tools/comp_perf.rst @@ -84,6 +84,8 @@ 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) + ``--huffman-enc [fixed/dynamic/default]``: Huffman encoding (default: dynamic) ``--compress-level N``: compression level, which could be a single value, list or range (default: range between 1 and 9) -- 2.25.1