When init, all ctxs will call wd_blkpool_new, Only nosva case will get a pointer, while sva case get NULL.
When uninit, delete blkpool and related resources.
Signed-off-by: Zhangfei Gao zhangfei.gao@linaro.org --- include/wd_alg_common.h | 9 +++++++++ wd_util.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h index fd77426..951995f 100644 --- a/include/wd_alg_common.h +++ b/include/wd_alg_common.h @@ -136,12 +136,21 @@ struct wd_soft_ctx { void *priv; };
+enum wd_blkpool_mode { + BLKPOOL_MODE_MEMCPY, + BLKPOOL_MODE_USER, + BLKPOOL_MODE_MAX, +}; + struct wd_ctx_internal { handle_t ctx; __u8 op_type; __u8 ctx_mode; __u16 sqn; pthread_spinlock_t lock; + void *blkpool; + __u8 blkpool_mode; + handle_t h_sgl_pool; };
struct wd_ctx_config_internal { diff --git a/wd_util.c b/wd_util.c index 9675098..949d467 100644 --- a/wd_util.c +++ b/wd_util.c @@ -12,6 +12,7 @@ #include <string.h> #include <ctype.h> #include "wd_sched.h" +#include "wd_bmm.h" #include "wd_util.h"
#define WD_ASYNC_DEF_POLL_NUM 1 @@ -247,6 +248,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, WD_ERR("failed to init ctxs lock!\n"); goto err_out; } + ctxs[i].blkpool = wd_blkpool_new(ctxs[i].ctx); }
in->ctxs = ctxs; @@ -298,8 +300,13 @@ void wd_clear_ctx_config(struct wd_ctx_config_internal *in) { __u32 i;
- for (i = 0; i < in->ctx_num; i++) + for (i = 0; i < in->ctx_num; i++) { + if (in->ctxs[i].blkpool) { + wd_blkpool_destroy_sglpool(in->ctxs[i].blkpool, in->ctxs[i].h_sgl_pool); + wd_blkpool_delete(in->ctxs[i].blkpool); + } pthread_spin_destroy(&in->ctxs[i].lock); + }
in->priv = NULL; in->ctx_num = 0;