From: Longfang Liu <liulongfang@huawei.com> In the UADK no-SVA mode memory pool, queues are used to create memory pools, and algorithms are employed to find the required queues. However, a compression algorithm queue cannot simultaneously support both compression and decompression modes—a queue must be defined as either compression or decompression. Therefore, when allocating a memory pool, a queue of the corresponding type must be specified for use. To facilitate queue lookup for the memory pool, the algorithm name is distinguished by appending a "-comp" or "-decomp" suffix. Similarly, when users request a memory pool, the compression algorithm must also include the corresponding suffix for querying. Signed-off-by: Longfang Liu <liulongfang@huawei.com> --- include/wd_util.h | 4 ++++ wd_comp.c | 2 +- wd_util.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/wd_util.h b/include/wd_util.h index 3412741..56dd9ba 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -27,6 +27,10 @@ extern "C" { for ((i) = 0, (config_numa) = (config)->config_per_numa; \ (i) < (config)->numa_num; (config_numa)++, (i)++) +#define COMP_ALG "comp" +#define CTX_COMP_ALG "zlib-comp gzip-comp deflate-comp lz77_zstd-comp lz4-comp lz77_only-comp" +#define CTX_DECOMP_ALG "zlib-decomp gzip-decomp deflate-decomp lz77_zstd-decomp lz4-decomp lz77_only-decomp" + enum wd_status { WD_UNINIT, WD_INITING, diff --git a/wd_comp.c b/wd_comp.c index 112e92c..7a2b0bc 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -148,7 +148,7 @@ static int wd_comp_init_nolock(struct wd_ctx_config *config, struct wd_sched *sc if (ret < 0) return ret; - wd_comp_setting.config.alg_name = "zlib gzip deflate lz77_zstd lz4 lz77_only"; + wd_comp_setting.config.alg_name = COMP_ALG; ret = wd_init_ctx_config(&wd_comp_setting.config, config); if (ret < 0) return ret; diff --git a/wd_util.c b/wd_util.c index 043179f..707cdb5 100644 --- a/wd_util.c +++ b/wd_util.c @@ -242,6 +242,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, struct wd_ctx_config *cfg) { struct wd_ctx_internal *ctxs; + char *alg_name; __u32 i, j; int ret; @@ -274,7 +275,15 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, goto err_out; } - ret = wd_insert_ctx_list(cfg->ctxs[i].ctx, in->alg_name); + alg_name = in->alg_name; + if (strcmp(in->alg_name, COMP_ALG) == 0) { + if (cfg->ctxs[i].op_type == 0) + alg_name = CTX_COMP_ALG; + else + alg_name = CTX_DECOMP_ALG; + } + + ret = wd_insert_ctx_list(cfg->ctxs[i].ctx, alg_name); if (ret) { WD_ERR("failed to add ctx to mem list!\n"); goto err_out; -- 2.43.0