Unify the software ctx and hardware ctx in uadk and merge them on the scheduler. Realize the function of software and hardware calculation together
Signed-off-by: Longfang Liu liulongfang@huawei.com --- include/wd_alg.h | 23 +- include/wd_alg_common.h | 58 +++- include/wd_sched.h | 1 + include/wd_util.h | 18 +- wd_alg.c | 63 ++-- wd_util.c | 725 +++++++++++++++++++++++++--------------- 6 files changed, 573 insertions(+), 315 deletions(-)
diff --git a/include/wd_alg.h b/include/wd_alg.h index 4c9f422..afdab7e 100644 --- a/include/wd_alg.h +++ b/include/wd_alg.h @@ -62,14 +62,23 @@ extern "C" { # define HWCAP2_RNG (1 << 16) #endif
-enum alg_dev_type { - UADK_ALG_SOFT = 0x0, +enum alg_priority { + UADK_ALG_HW = 0x0, UADK_ALG_CE_INSTR = 0x1, UADK_ALG_SVE_INSTR = 0x2, - UADK_ALG_HW = 0x3 + UADK_ALG_SOFT = 0x3 };
-/* +enum alg_drv_type { + ALG_DRV_HW = 0x0, + ALG_DRV_CE_INS, + ALG_DRV_SVE_INS, + ALG_DRV_SOFT, + ALG_DRV_INS, + ALG_DRV_FB, +}; + +/** * @drv_name: name of the current device driver * @alg_name: name of the algorithm supported by the driver * @priority: priority of the type of algorithm supported by the driver @@ -107,6 +116,7 @@ struct wd_alg_driver { int op_type_num; int priv_size; handle_t fallback; + int init_state;
int (*init)(void *conf, void *priv); void (*exit)(void *priv); @@ -155,7 +165,7 @@ struct wd_alg_list { * * Returns the applied algorithm driver, non means error. */ -struct wd_alg_driver *wd_request_drv(const char *alg_name, bool hw_mask); +struct wd_alg_driver *wd_request_drv(const char *alg_name, int drv_type); void wd_release_drv(struct wd_alg_driver *drv);
/* @@ -165,8 +175,7 @@ void wd_release_drv(struct wd_alg_driver *drv); * * Return check result. */ -bool wd_drv_alg_support(const char *alg_name, - struct wd_alg_driver *drv); +bool wd_drv_alg_support(const char *alg_name, void *param);
/* * wd_enable_drv() - Re-enable use of the current device driver. diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h index fd77426..079dfb9 100644 --- a/include/wd_alg_common.h +++ b/include/wd_alg_common.h @@ -41,6 +41,14 @@ extern "C" {
/* Key size of digest */ #define MAX_HMAC_KEY_SIZE 128U +#define MAX_SOFT_QUEUE_LENGTH 1024U + +/* + * The maximum number of queue types + * required for similar algorithms + */ +#define MAX_CTX_OP_TYPE 4U +#define STATUS_ENABLE (void *)0x1
enum alg_task_type { TASK_MIX = 0x0, @@ -60,7 +68,27 @@ enum wd_init_type { WD_TYPE_V2, };
-/* +struct wd_soft_sqe { + __u8 used; + __u8 result; + __u8 complete; + __u32 id; +}; + +/** + * default queue length set to 1024 + */ +struct wd_soft_ctx { + pthread_spinlock_t slock; + __u32 head; + struct wd_soft_sqe qfifo[MAX_SOFT_QUEUE_LENGTH]; + pthread_spinlock_t rlock; + __u32 tail; + __u32 run_num; + void *priv; +}; + +/** * struct wd_ctx - Define one ctx and related type. * @ctx: The ctx itself. * @op_type: Define the operation type of this specific ctx. @@ -72,6 +100,7 @@ struct wd_ctx { handle_t ctx; __u8 op_type; __u8 ctx_mode; + __u8 ctx_type; };
/* @@ -103,16 +132,31 @@ struct wd_ctx_config { struct wd_cap_config *cap; };
-/* +/* 0x0 mean calloc init value */ +enum wd_ctx_property { + UADK_CTX_HW = 0x0, + UADK_CTX_CE_INS = 0x1, + UADK_CTX_SVE_INS = 0x2, + UADK_CTX_SOFT = 0x3, + UADK_CTX_MAX +}; + +/** * struct wd_ctx_nums - Define the ctx sets numbers. * @sync_ctx_num: The ctx numbers which are used for sync mode for each * ctx sets. * @async_ctx_num: The ctx numbers which are used for async mode for each * ctx sets. + * @ctx_prop: Indicates the properties of the current queue + * @ctx_begin: The encoding starting position of the current device ctx + * @other_ctx: Other types of queues configured */ struct wd_ctx_nums { __u32 sync_ctx_num; __u32 async_ctx_num; + __u8 ctx_prop; + __u16 ctx_begin; + struct wd_ctx_nums *other_ctx; };
/* @@ -132,16 +176,16 @@ struct wd_ctx_params { struct wd_cap_config *cap; };
-struct wd_soft_ctx { - void *priv; -}; - struct wd_ctx_internal { - handle_t ctx; __u8 op_type; __u8 ctx_mode; + __u8 ctx_type; + __u8 ctx_used; + handle_t ctx; // if ctx is first will cause problem __u16 sqn; pthread_spinlock_t lock; + struct wd_alg_driver *drv; + void *drv_priv; };
struct wd_ctx_config_internal { diff --git a/include/wd_sched.h b/include/wd_sched.h index be541c6..5a69cb9 100644 --- a/include/wd_sched.h +++ b/include/wd_sched.h @@ -32,6 +32,7 @@ struct sched_params { __u8 mode; __u32 begin; __u32 end; + int ctx_prop; };
typedef int (*user_poll_func)(__u32 pos, __u32 expect, __u32 *count); diff --git a/include/wd_util.h b/include/wd_util.h index e870776..bee7f29 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -124,13 +124,14 @@ struct wd_msg_handle {
struct wd_init_attrs { __u32 sched_type; - const char *alg; - struct wd_alg_driver *driver; + __u32 task_type; + char *alg; struct wd_sched *sched; struct wd_ctx_params *ctx_params; struct wd_ctx_config *ctx_config; wd_alg_init alg_init; wd_alg_poll_ctx alg_poll_ctx; + struct wd_alg_driver *driver; //stub for old code };
/* @@ -171,6 +172,9 @@ void wd_clear_ctx_config(struct wd_ctx_config_internal *in); */ void wd_memset_zero(void *data, __u32 size);
+int wd_ctx_drv_config(char *alg_name, struct wd_ctx_config_internal *ctx_config); +void wd_ctx_drv_deconfig(struct wd_ctx_config_internal *ctx_config); + /* * wd_init_async_request_pool() - Init async message pools. * @pool: Pointer of message pool. @@ -450,6 +454,10 @@ static inline void wd_alg_clear_init(enum wd_status *status) * * Return 0 if succeed and other error number if fail. */ +int wd_ctx_param_init_nw(struct wd_ctx_params *ctx_params, + struct wd_ctx_params *user_ctx_params, + char *alg, int task_type, enum wd_type type, + int max_op_type); int wd_ctx_param_init(struct wd_ctx_params *ctx_params, struct wd_ctx_params *user_ctx_params, struct wd_alg_driver *driver, @@ -470,12 +478,12 @@ void wd_alg_attrs_uninit(struct wd_init_attrs *attrs); /** * wd_alg_drv_bind() - Request the ctxs and initialize the sched_domain * with the given devices list, ctxs number and numa mask. - * @task_type: the type of task specified by the current algorithm. + * @ctx_type: the type of ctx specified by the current algorithm. * @alg_name: the name of the algorithm specified by the task. * * Return device driver if succeed and other NULL if fail. */ -struct wd_alg_driver *wd_alg_drv_bind(int task_type, const char *alg_name); +struct wd_alg_driver *wd_alg_drv_bind(__u8 ctx_prop, char *alg_name); void wd_alg_drv_unbind(struct wd_alg_driver *drv);
/** @@ -487,6 +495,8 @@ void wd_alg_drv_unbind(struct wd_alg_driver *drv); * * Return 0 if succeed and other error number if fail. */ +int wd_alg_init_driver_nw(struct wd_ctx_config_internal *config); +void wd_alg_uninit_driver_nw(struct wd_ctx_config_internal *config); int wd_alg_init_driver(struct wd_ctx_config_internal *config, struct wd_alg_driver *driver, void **drv_priv); void wd_alg_uninit_driver(struct wd_ctx_config_internal *config, diff --git a/wd_alg.c b/wd_alg.c index a33f5d6..bedbfc6 100644 --- a/wd_alg.c +++ b/wd_alg.c @@ -12,7 +12,7 @@ #include <sys/auxv.h>
#include "wd.h" -#include "wd_alg.h" +#include "wd_alg_common.h"
#define SYS_CLASS_DIR "/sys/class/uacce" #define SVA_FILE_NAME "flags" @@ -271,21 +271,26 @@ struct wd_alg_list *wd_get_alg_head(void) return &alg_list_head; }
-bool wd_drv_alg_support(const char *alg_name, - struct wd_alg_driver *drv) +bool wd_drv_alg_support(const char *alg_name, void *param) { + struct wd_ctx_config_internal *config = param; struct wd_alg_list *head = &alg_list_head; struct wd_alg_list *pnext = head->next; + struct wd_alg_driver *drv; + __u32 i;
- if (!alg_name || !drv) + if (!alg_name || !config) return false;
- while (pnext) { - if (!strcmp(alg_name, pnext->alg_name) && - !strcmp(drv->drv_name, pnext->drv_name)) { - return true; + for (i = 0; i < config->ctx_num; i++) { + drv = config->ctxs[i].drv; + while (pnext) { + if (!strcmp(alg_name, pnext->alg_name) && + !strcmp(drv->drv_name, pnext->drv_name)) { + return true; + } + pnext = pnext->next; } - pnext = pnext->next; }
return false; @@ -331,7 +336,7 @@ void wd_disable_drv(struct wd_alg_driver *drv) pthread_mutex_unlock(&mutex); }
-struct wd_alg_driver *wd_request_drv(const char *alg_name, bool hw_mask) +struct wd_alg_driver *wd_request_drv(const char *alg_name, int drv_type) { struct wd_alg_list *head = &alg_list_head; struct wd_alg_list *pnext = head->next; @@ -352,18 +357,32 @@ struct wd_alg_driver *wd_request_drv(const char *alg_name, bool hw_mask) /* Check the list to get an best driver */ pthread_mutex_lock(&mutex); while (pnext) { - /* hw_mask true mean not to used hardware dev */ - if ((hw_mask && pnext->drv->calc_type == UADK_ALG_HW) || - (!hw_mask && pnext->drv->calc_type != UADK_ALG_HW)) { - pnext = pnext->next; - continue; - } - - if (!strcmp(alg_name, pnext->alg_name) && pnext->available && - pnext->drv->priority > tmp_priority) { - tmp_priority = pnext->drv->priority; - select_node = pnext; - drv = pnext->drv; + if (!strcmp(alg_name, pnext->alg_name) && pnext->available) { + /* HW driver mean to used hardware dev */ + if (drv_type == ALG_DRV_HW && pnext->drv->calc_type == UADK_ALG_HW) + select_node = pnext; + /* CE driver mean to used CE dev */ + else if (drv_type == ALG_DRV_CE_INS && pnext->drv->calc_type == UADK_ALG_CE_INSTR) + select_node = pnext; + /* SVE driver mean to used SVE dev */ + else if (drv_type == ALG_DRV_SVE_INS && pnext->drv->calc_type == UADK_ALG_SVE_INSTR) + select_node = pnext; + /* INS driver mean to used CE and SVE dev */ + else if (drv_type == ALG_DRV_INS && (pnext->drv->calc_type == UADK_ALG_CE_INSTR || + pnext->drv->calc_type == UADK_ALG_SVE_INSTR)) + select_node = pnext; + /* Soft driver mean to used Soft, CE and SVE dev */ + else if (drv_type == ALG_DRV_SOFT && pnext->drv->calc_type != UADK_ALG_HW) + select_node = pnext; + /* Fallback driver mean to used Soft or CE dev */ + else if (drv_type == ALG_DRV_FB && (pnext->drv->calc_type == UADK_ALG_SOFT || + pnext->drv->calc_type == UADK_ALG_CE_INSTR)) + select_node = pnext; + + if (select_node && select_node->drv->priority > tmp_priority) { + drv = select_node->drv; + tmp_priority = select_node->drv->priority; + } } pnext = pnext->next; } diff --git a/wd_util.c b/wd_util.c index a0a4304..848ff15 100644 --- a/wd_util.c +++ b/wd_util.c @@ -168,6 +168,7 @@ static void clone_ctx_to_internal(struct wd_ctx *ctx, ctx_in->ctx = ctx->ctx; ctx_in->op_type = ctx->op_type; ctx_in->ctx_mode = ctx->ctx_mode; + ctx_in->ctx_type = ctx->ctx_type; }
static int wd_shm_create(struct wd_ctx_config_internal *in) @@ -236,9 +237,8 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
for (i = 0; i < cfg->ctx_num; i++) { if (!cfg->ctxs[i].ctx) { - WD_ERR("invalid: ctx is NULL!\n"); - ret = -WD_EINVAL; - goto err_out; + WD_ERR("invalid: ctx<%u> is NULL!\n", i); + break; } clone_ctx_to_internal(cfg->ctxs + i, ctxs + i); ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED); @@ -1790,7 +1790,7 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx) }
ctx = config->ctxs + idx; - if (ctx->ctx_mode != mode) { + if (ctx->ctx_type == UADK_CTX_HW && ctx->ctx_mode != mode) { WD_ERR("invalid: ctx(%u) mode is %hhu!\n", idx, ctx->ctx_mode); return -WD_EINVAL; } @@ -1889,6 +1889,38 @@ int wd_init_param_check(struct wd_ctx_config *config, struct wd_sched *sched) return 0; }
+int wd_alg_try_init(enum wd_status *status) +{ + enum wd_status expected; + __u32 count = 0; + bool ret; + + /* + * Here is aimed to protect the security of the initialization interface + * in the multi-thread scenario. Only one thread can get the WD_INITING + * status to initialize algorithm. Other thread will wait for the result. + * And the algorithm initialization interfaces is a liner process. + * So the initing thread will return a result to notify other thread go on. + */ + do { + expected = WD_UNINIT; + ret = __atomic_compare_exchange_n(status, &expected, WD_INITING, true, + __ATOMIC_RELAXED, __ATOMIC_RELAXED); + if (expected == WD_INIT) { + WD_ERR("The algorithm has been initialized!\n"); + return -WD_EEXIST; + } + usleep(WD_INIT_SLEEP_UTIME); + + if (US2S(WD_INIT_SLEEP_UTIME * ++count) >= WD_INIT_RETRY_TIMEOUT) { + WD_ERR("The algorithm initialize wait timeout!\n"); + return -WD_ETIMEDOUT; + } + } while (!ret); + + return 0; +} + static void wd_get_alg_type(const char *alg_name, char *alg_type) { int i; @@ -1937,6 +1969,7 @@ static int wd_alg_init_fallback(struct wd_alg_driver *fb_driver) return -WD_EINVAL; }
+ WD_ERR("debug: call function: %s!\n", __func__); fb_driver->init(NULL, NULL);
return 0; @@ -1952,12 +1985,20 @@ static void wd_alg_uninit_fallback(struct wd_alg_driver *fb_driver) fb_driver->exit(NULL); }
-int wd_alg_init_driver(struct wd_ctx_config_internal *config, - struct wd_alg_driver *driver, void **drv_priv) +static int wd_ctx_init_driver(struct wd_ctx_config_internal *config, + struct wd_ctx_internal *ctx_config) { - void *priv; + struct wd_alg_driver *driver = ctx_config->drv; + void *priv = ctx_config->drv_priv; int ret;
+ if (!driver) + return 0; + + /* Prevent repeated initialization */ + if (driver->init_state) + return 0; + if (!driver->priv_size) { WD_ERR("invalid: driver priv ctx size is zero!\n"); return -WD_EINVAL; @@ -1980,6 +2021,7 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, WD_ERR("driver init failed.\n"); goto err_alloc; } + driver->init_state = 1;
if (driver->fallback) { ret = wd_alg_init_fallback((struct wd_alg_driver *)driver->fallback); @@ -1988,21 +2030,30 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, WD_ERR("soft alg driver init failed.\n"); } } - *drv_priv = priv;
return 0;
err_alloc: free(priv); + ctx_config->drv_priv = NULL; return ret; }
-void wd_alg_uninit_driver(struct wd_ctx_config_internal *config, - struct wd_alg_driver *driver, void **drv_priv) +static void wd_ctx_uninit_driver(struct wd_ctx_config_internal *config, + struct wd_ctx_internal *ctx_config) { - void *priv = *drv_priv; + struct wd_alg_driver *driver = ctx_config->drv; + void *priv = ctx_config->drv_priv; + + if (!driver) + return; + + /* Prevent repeated uninitialization */ + if (!driver->init_state) + return;
driver->exit(priv); + driver->init_state = 0; /* Ctx config just need clear once */ wd_clear_ctx_config(config);
@@ -2011,8 +2062,51 @@ void wd_alg_uninit_driver(struct wd_ctx_config_internal *config,
if (priv) { free(priv); - *drv_priv = NULL; + ctx_config->drv_priv = NULL; + } +} + +int wd_alg_init_driver(struct wd_ctx_config_internal *config, + struct wd_alg_driver *driver, void **drv_priv) +{ + return 0; +} + +int wd_alg_init_driver_nw(struct wd_ctx_config_internal *config) +{ + __u32 i, j; + int ret; + + WD_ERR("debug: call function: %s!\n", __func__); + for (i = 0; i < config->ctx_num; i++) { + if (!config->ctxs[i].ctx) + continue; + ret = wd_ctx_init_driver(config, &config->ctxs[i]); + if (ret) + goto init_err; } + + return 0; + +init_err: + for (j = 0; j < i; j++) + wd_ctx_uninit_driver(config, &config->ctxs[j]); + + return ret; +} + +void wd_alg_uninit_driver(struct wd_ctx_config_internal *config, + struct wd_alg_driver *driver, void **drv_priv) +{ +} + +void wd_alg_uninit_driver_nw(struct wd_ctx_config_internal *config) +{ + __u32 i; + + for (i = 0; i < config->ctx_num; i++) + wd_ctx_uninit_driver(config, &config->ctxs[i]); + }
void wd_dlclose_drv(void *dlh_list) @@ -2140,6 +2234,14 @@ int wd_ctx_param_init(struct wd_ctx_params *ctx_params, struct wd_ctx_params *user_ctx_params, struct wd_alg_driver *driver, enum wd_type type, int max_op_type) +{ + return 0; +} + +int wd_ctx_param_init_nw(struct wd_ctx_params *ctx_params, + struct wd_ctx_params *user_ctx_params, + char *alg, int task_type, enum wd_type type, + int max_op_type) { const char *env_name = wd_env_name[type]; const char *var_s; @@ -2153,9 +2255,9 @@ int wd_ctx_param_init(struct wd_ctx_params *ctx_params,
/* Only hw driver support environment variable */ var_s = secure_getenv(env_name); - if (var_s && strlen(var_s) && driver->calc_type == UADK_ALG_HW) { + if (var_s && strlen(var_s) && task_type <= TASK_HW) { /* environment variable has the highest priority */ - ret = wd_env_set_ctx_nums(driver->alg_name, env_name, var_s, + ret = wd_env_set_ctx_nums(alg, env_name, var_s, ctx_params, max_op_type); if (ret) { WD_ERR("fail to init ctx nums from %s!\n", env_name); @@ -2166,33 +2268,28 @@ int wd_ctx_param_init(struct wd_ctx_params *ctx_params, /* environment variable is not set, try to use user_ctx_params first */ if (user_ctx_params) { copy_bitmask_to_bitmask(user_ctx_params->bmp, ctx_params->bmp); - ctx_params->cap = user_ctx_params->cap; - ctx_params->ctx_set_num = user_ctx_params->ctx_set_num; - ctx_params->op_type_num = user_ctx_params->op_type_num; - if (ctx_params->op_type_num > (__u32)max_op_type) { + if (user_ctx_params->op_type_num > (__u32)max_op_type) { WD_ERR("fail to check user op type numbers.\n"); numa_free_nodemask(ctx_params->bmp); return -WD_EINVAL; } + ctx_params->cap = user_ctx_params->cap; + ctx_params->ctx_set_num = user_ctx_params->ctx_set_num; + ctx_params->op_type_num = user_ctx_params->op_type_num;
return 0; } - - /* user_ctx_params is also not set, use driver's defalut queue_num */ - numa_bitmask_setall(ctx_params->bmp); - for (i = 0; i < driver->op_type_num; i++) { - ctx_params->ctx_set_num[i].sync_ctx_num = driver->queue_num; - ctx_params->ctx_set_num[i].async_ctx_num = driver->queue_num; - } }
- ctx_params->op_type_num = driver->op_type_num; - if (ctx_params->op_type_num > (__u32)max_op_type) { - WD_ERR("fail to check driver op type numbers.\n"); - numa_free_nodemask(ctx_params->bmp); - return -WD_EAGAIN; + /* user_ctx_params is also not set, use defalut queue_num max_op_type */ + numa_bitmask_setall(ctx_params->bmp); + for (i = 0; i < max_op_type; i++) { + ctx_params->ctx_set_num[i].sync_ctx_num = max_op_type; + ctx_params->ctx_set_num[i].async_ctx_num = max_op_type; }
+ ctx_params->op_type_num = max_op_type; + return 0; }
@@ -2291,6 +2388,7 @@ void *wd_dlopen_drv(const char *cust_lib_dir) node->dlhandle = dlopen(lib_path, RTLD_NODELETE | RTLD_NOW); if (!node->dlhandle) { free(node); + WD_ERR("UADK driver so open failed, error number: %s\n", dlerror()); /* there are many other files need to skip */ continue; } @@ -2319,48 +2417,57 @@ free_list: return NULL; }
-struct wd_alg_driver *wd_alg_drv_bind(int task_type, const char *alg_name) +struct wd_alg_driver *wd_alg_drv_bind(__u8 ctx_prop, char *alg_name) { - struct wd_alg_driver *set_driver = NULL; + struct wd_alg_driver *fb_drv; struct wd_alg_driver *drv;
- /* Get alg driver and dev name */ - switch (task_type) { - case TASK_INSTR: - drv = wd_request_drv(alg_name, true); + /* Get alg driver from ctx type and alg name */ + switch (ctx_prop) { + case UADK_CTX_HW: + drv = wd_request_drv(alg_name, ALG_DRV_HW); if (!drv) { - WD_ERR("no soft %s driver support\n", alg_name); + WD_ERR("no HW %s driver support\n", alg_name); return NULL; } - set_driver = drv; - set_driver->fallback = 0; + + fb_drv = wd_request_drv(alg_name, ALG_DRV_SOFT); + if (!fb_drv) + drv->fallback = 0; + else + drv->fallback = (handle_t)fb_drv; + break; - case TASK_HW: - case TASK_MIX: - drv = wd_request_drv(alg_name, false); + case UADK_CTX_CE_INS: + drv = wd_request_drv(alg_name, ALG_DRV_CE_INS); if (!drv) { - WD_ERR("no HW %s driver support\n", alg_name); + WD_ERR("no CE instr soft %s driver support\n", alg_name); return NULL; } - set_driver = drv; - set_driver->fallback = 0; - if (task_type == TASK_MIX) { - drv = wd_request_drv(alg_name, true); - if (!drv) { - set_driver->fallback = 0; - WD_ERR("no soft %s driver support\n", alg_name); - } else { - set_driver->fallback = (handle_t)drv; - WD_ERR("successful to get soft driver\n"); - } + drv->fallback = 0; + break; + case UADK_CTX_SVE_INS: + drv = wd_request_drv(alg_name, ALG_DRV_SVE_INS); + if (!drv) { + WD_ERR("no SVE instr soft %s driver support\n", alg_name); + return NULL; + } + drv->fallback = 0; + break; + case UADK_CTX_SOFT: + drv = wd_request_drv(alg_name, ALG_DRV_SOFT); + if (!drv) { + WD_ERR("no instr soft %s driver support\n", alg_name); + return NULL; } + drv->fallback = 0; break; default: - WD_ERR("task type error.\n"); - return NULL; + WD_ERR("ctx type error: %d.\n", ctx_prop); + return WD_ERR_PTR(-WD_ENODEV); }
- return set_driver; + return drv; }
void wd_alg_drv_unbind(struct wd_alg_driver *drv) @@ -2376,45 +2483,100 @@ void wd_alg_drv_unbind(struct wd_alg_driver *drv) wd_release_drv(drv); }
-int wd_alg_try_init(enum wd_status *status) +static __u32 wd_ctxs_idx_init(struct wd_init_attrs *attrs, int numa_cnt, int task_type) { - enum wd_status expected; + struct wd_ctx_params *ctx_params = attrs->ctx_params; + int end = ctx_params->op_type_num; + struct wd_ctx_nums *ptr_ctx; __u32 count = 0; - bool ret; + int i, uidx;
- do { - expected = WD_UNINIT; - ret = __atomic_compare_exchange_n(status, &expected, WD_INITING, true, - __ATOMIC_RELAXED, __ATOMIC_RELAXED); - if (expected == WD_INIT) { - WD_ERR("The algorithm has been initialized!\n"); - return -WD_EEXIST; - } - usleep(WD_INIT_SLEEP_UTIME); + if (ctx_params->op_type_num > MAX_CTX_OP_TYPE) { + WD_ERR("invalid: max ctx op type<%u> is wrong!\n", ctx_params->op_type_num); + return 0; + }
- if (US2S(WD_INIT_SLEEP_UTIME * ++count) >= WD_INIT_RETRY_TIMEOUT) { - WD_ERR("The algorithm initialize wait timeout!\n"); - return -WD_ETIMEDOUT; + for (uidx = 0; uidx < UADK_CTX_MAX; uidx++) { + /* If it is a soft computing task, do not use HW queue */ + if (task_type == TASK_INSTR && uidx == UADK_CTX_HW) + continue; + for (i = 0; i < end; i++) { + ptr_ctx = &ctx_params->ctx_set_num[i]; + while (ptr_ctx) { + if (ptr_ctx->ctx_prop == uidx) { + ptr_ctx->ctx_begin = count; + if (uidx == UADK_CTX_HW) { + count += ptr_ctx->sync_ctx_num * numa_cnt; + count += ptr_ctx->async_ctx_num * numa_cnt; + } else { + count += ptr_ctx->sync_ctx_num; + count += ptr_ctx->async_ctx_num; + } + WD_ERR("optype<%u>, prop<%u>, begin<%u>, synx<%u>, async<%u>\n", + i, ptr_ctx->ctx_prop, ptr_ctx->ctx_begin, ptr_ctx->sync_ctx_num, ptr_ctx->async_ctx_num); + } + ptr_ctx = ptr_ctx->other_ctx; + } } - } while (!ret); + }
- return 0; + return count; }
-static __u32 wd_get_ctx_numbers(struct wd_ctx_params ctx_params, int end) +static struct wd_ctx_nums *wd_get_ctx_ptr(struct wd_ctx_params *ctx_params, + __u32 op_type, int ctx_prop) { - __u32 count = 0; - int i; + struct wd_ctx_nums *ptr_ctx;
- for (i = 0; i < end; i++) { - count += ctx_params.ctx_set_num[i].sync_ctx_num; - count += ctx_params.ctx_set_num[i].async_ctx_num; + if (op_type > ctx_params->op_type_num) + return NULL; + + ptr_ctx = &ctx_params->ctx_set_num[op_type]; + while (ptr_ctx) { + if (ptr_ctx->ctx_prop == ctx_prop) + return ptr_ctx; + ptr_ctx = ptr_ctx->other_ctx; }
- return count; + return NULL; +} + +void wd_ctx_drv_deconfig(struct wd_ctx_config_internal *ctx_config) +{ + __u32 i; + + // wd_dlclose_drv after this + for (i = 0; i < ctx_config->ctx_num; i++) + wd_alg_drv_unbind(ctx_config->ctxs[i].drv); + +} + +int wd_ctx_drv_config(char *alg_name, struct wd_ctx_config_internal *ctx_config) +{ + __u32 i, j; + + // wd_dlopen_drv before this + WD_ERR("debug: call function: %s!\n", __func__); + for (i = 0; i < ctx_config->ctx_num; i++) { + ctx_config->ctxs[i].drv = wd_alg_drv_bind(ctx_config->ctxs[i].ctx_type, alg_name); + if (WD_IS_ERR(ctx_config->ctxs[i].drv)) { + continue; + } else if (!ctx_config->ctxs[i].drv) { + WD_ERR("failed to bind %s driver.\n", alg_name); + goto bind_err; + } + } + + return 0; + +bind_err: + for (j = 0; j < i; j++) { + wd_alg_drv_unbind(ctx_config->ctxs[j].drv); + } + return -WD_EINVAL; }
-static struct uacce_dev_list *wd_get_usable_list(struct uacce_dev_list *list, struct bitmask *bmp) +struct uacce_dev_list *wd_get_usable_list(struct uacce_dev_list *list, struct bitmask *bmp) { struct uacce_dev_list *p, *node, *result = NULL; struct uacce_dev *dev; @@ -2464,7 +2626,7 @@ out_free_list: return result; }
-static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *list, +static int wd_init_hw_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *list, __u32 idx, int numa_id, __u32 op_type) { struct wd_ctx_nums ctx_nums = attrs->ctx_params->ctx_set_num[op_type]; @@ -2508,6 +2670,7 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l ctx_config->ctxs[i].ctx_mode = ((i - idx) < ctx_nums.sync_ctx_num) ? CTX_MODE_SYNC : CTX_MODE_ASYNC; + ctx_config->ctxs[i].ctx_type = UADK_CTX_HW; }
return 0; @@ -2535,6 +2698,7 @@ static int wd_instance_sched_set(struct wd_sched *sched, struct wd_ctx_nums ctx_ sparams.type = op_type; sparams.mode = i; sparams.begin = idx + ctx_nums.sync_ctx_num * i; + sparams.ctx_prop = UADK_CTX_HW; end = idx - 1 + ctx_nums.sync_ctx_num + ctx_nums.async_ctx_num * i; if (end < 0 || sparams.begin > (__u32)end) continue; @@ -2549,7 +2713,7 @@ out: return ret; }
-static int wd_init_ctx_and_sched(struct wd_init_attrs *attrs, struct bitmask *bmp, +static int wd_hw_ctx_and_sched(struct wd_init_attrs *attrs, struct bitmask *bmp, struct uacce_dev_list *list) { struct wd_ctx_params *ctx_params = attrs->ctx_params; @@ -2563,7 +2727,7 @@ static int wd_init_ctx_and_sched(struct wd_init_attrs *attrs, struct bitmask *bm continue; for (j = 0; j < op_type_num; j++) { ctx_nums = ctx_params->ctx_set_num[j]; - ret = wd_init_ctx_set(attrs, list, idx, i, j); + ret = wd_init_hw_ctx_set(attrs, list, idx, i, j); if (ret) goto free_ctxs; ret = wd_instance_sched_set(attrs->sched, ctx_nums, idx, i, j); @@ -2592,30 +2756,118 @@ static void wd_init_device_nodemask(struct uacce_dev_list *list, struct bitmask } }
-static int wd_alg_ctx_init(struct wd_init_attrs *attrs) +static int wd_alg_other_ctx_init(struct wd_init_attrs *attrs, int ctx_prop) +{ + struct wd_ctx_config *ctx_config = attrs->ctx_config; + struct wd_ctx_params *ctx_params = attrs->ctx_params; + struct wd_ctx_nums *ptr_ctxs; + struct wd_soft_ctx *sfctx; + struct sched_params sparams; + __u32 begin, end, ctx_num; + int sync_type, ret; + __u32 i, j, k; + + WD_ERR("debug: call function: %s!\n", __func__); + for (i = 0; i < ctx_params->op_type_num; i++) { + ptr_ctxs = wd_get_ctx_ptr(ctx_params, i, ctx_prop); + if (!ptr_ctxs) + continue; + + for (sync_type = CTX_MODE_SYNC; sync_type < CTX_MODE_MAX; sync_type++) { + if (sync_type == CTX_MODE_SYNC) { + ctx_num = ptr_ctxs->sync_ctx_num; + begin = ptr_ctxs->ctx_begin; + } else { + ctx_num = ptr_ctxs->async_ctx_num; + begin = ptr_ctxs->ctx_begin + ptr_ctxs->sync_ctx_num; + } + if (ctx_num == 0) + continue; + + end = begin + ctx_num; + for (j = begin; j < end; j++) { + ctx_config->ctxs[j].op_type = i; + ctx_config->ctxs[j].ctx_mode = sync_type; + ctx_config->ctxs[j].ctx_type = ctx_prop; + sfctx = calloc(1, sizeof(struct wd_soft_ctx)); + if (!sfctx) { + WD_ERR("failed to alloc ctx!\n"); + goto ctx_err; + } + ctx_config->ctxs[j].ctx = (handle_t)sfctx; + pthread_spin_init(&sfctx->slock, PTHREAD_PROCESS_SHARED); + pthread_spin_init(&sfctx->rlock, PTHREAD_PROCESS_SHARED); + } + + memset(&sparams, 0x0, sizeof(struct sched_params)); + sparams.begin = begin; + sparams.end = end - 1; + sparams.mode = sync_type; + sparams.numa_id = 0; + sparams.ctx_prop = ctx_prop; + ret = wd_sched_rr_instance(attrs->sched, &sparams); + if (ret) { + WD_ERR("fail to instance scheduler.\n"); + goto ctx_err; + } + } + } + + return WD_SUCCESS; + +ctx_err: + for (k = j; k >= begin; k--) { + free((struct wd_soft_ctx *)ctx_config->ctxs[k].ctx); + ctx_config->ctxs[k].ctx = 0; + } + + return -WD_ENOMEM; +} + +static int wd_alg_other_init(struct wd_init_attrs *attrs) +{ + struct wd_ctx_config *ctx_config = attrs->ctx_config; + struct wd_ctx_params *ctx_params = attrs->ctx_params; + __u32 ctx_set_num, op_type_num; + + WD_ERR("debug: call function: %s!\n", __func__); + op_type_num = ctx_params->op_type_num; + ctx_set_num = wd_ctxs_idx_init(attrs, 1, attrs->task_type); + if (!ctx_set_num || !op_type_num) { + WD_ERR("invalid: ctx_set_num is %u, op_type_num is %u!\n", + ctx_set_num, op_type_num); + return -WD_EINVAL; + } + + ctx_config->ctx_num = ctx_set_num; + ctx_config->ctxs = calloc(ctx_config->ctx_num, sizeof(struct wd_ctx)); + if (!ctx_config->ctxs) { + WD_ERR("failed to alloc ctxs!\n"); + return -WD_ENOMEM; + } + + return 0; +} + +static int wd_alg_hw_ctx_init(struct wd_init_attrs *attrs) { struct wd_ctx_config *ctx_config = attrs->ctx_config; struct wd_ctx_params *ctx_params = attrs->ctx_params; struct bitmask *used_bmp = ctx_params->bmp; struct uacce_dev_list *list, *used_list = NULL; + char alg_type[CRYPTO_MAX_ALG_NAME]; __u32 ctx_set_num, op_type_num; int numa_cnt, ret;
- list = wd_get_accel_list(attrs->alg); + WD_ERR("debug: call function: %s!\n", __func__); + wd_get_alg_type(attrs->alg, alg_type); + + list = wd_get_accel_list(alg_type); if (!list) { WD_ERR("failed to get devices!\n"); return -WD_ENODEV; }
- op_type_num = ctx_params->op_type_num; - ctx_set_num = wd_get_ctx_numbers(*ctx_params, op_type_num); - if (!ctx_set_num || !op_type_num) { - WD_ERR("invalid: ctx_set_num is %u, op_type_num is %u!\n", - ctx_set_num, op_type_num); - ret = -WD_EINVAL; - goto out_freelist; - } - /* * Not every numa has a device. Therefore, the first thing is to * filter the devices in the selected numa node, and the second @@ -2629,7 +2881,6 @@ static int wd_alg_ctx_init(struct wd_init_attrs *attrs) }
wd_init_device_nodemask(used_list, used_bmp); - numa_cnt = numa_bitmask_weight(used_bmp); if (!numa_cnt) { ret = numa_cnt; @@ -2637,7 +2888,17 @@ static int wd_alg_ctx_init(struct wd_init_attrs *attrs) goto out_freeusedlist; }
- ctx_config->ctx_num = ctx_set_num * numa_cnt; + op_type_num = ctx_params->op_type_num; + ctx_set_num = wd_ctxs_idx_init(attrs, numa_cnt, attrs->task_type); + WD_ERR("ctx sum num is: %u, op_type num is: %u!\n", ctx_set_num, op_type_num); + if (!ctx_set_num || !op_type_num) { + WD_ERR("invalid: ctx_set_num is %u, op_type_num is %u!\n", + ctx_set_num, op_type_num); + ret = -WD_EINVAL; + goto out_freelist; + } + + ctx_config->ctx_num = ctx_set_num; ctx_config->ctxs = calloc(ctx_config->ctx_num, sizeof(struct wd_ctx)); if (!ctx_config->ctxs) { ret = -WD_ENOMEM; @@ -2645,226 +2906,154 @@ static int wd_alg_ctx_init(struct wd_init_attrs *attrs) goto out_freeusedlist; }
- ret = wd_init_ctx_and_sched(attrs, used_bmp, used_list); + ret = wd_hw_ctx_and_sched(attrs, used_bmp, used_list); if (ret) free(ctx_config->ctxs);
out_freeusedlist: wd_free_list_accels(used_list); + out_freelist: wd_free_list_accels(list);
return ret; }
-static int wd_alg_ce_ctx_init(struct wd_init_attrs *attrs) -{ - struct wd_ctx_config *ctx_config = attrs->ctx_config; - - ctx_config->ctx_num = 1; - ctx_config->ctxs = calloc(ctx_config->ctx_num, sizeof(struct wd_ctx)); - if (!ctx_config->ctxs) { - WD_ERR("failed to alloc ctxs!\n"); - return -WD_ENOMEM; - } - - ctx_config->ctxs[0].ctx = (handle_t)calloc(1, sizeof(struct wd_ce_ctx)); - if (!ctx_config->ctxs[0].ctx) { - free(ctx_config->ctxs); - return -WD_ENOMEM; - } - - return WD_SUCCESS; -} - -static void wd_alg_ce_ctx_uninit(struct wd_ctx_config *ctx_config) +static void wd_alg_ctxs_uninit(struct wd_ctx_config *ctx_config) { __u32 i;
for (i = 0; i < ctx_config->ctx_num; i++) { if (ctx_config->ctxs[i].ctx) { - free((struct wd_ce_ctx *)ctx_config->ctxs[i].ctx); + if (ctx_config->ctxs[i].ctx_type == UADK_CTX_HW) + wd_release_ctx(ctx_config->ctxs[i].ctx); + else + free((struct wd_soft_ctx *)ctx_config->ctxs[i].ctx); ctx_config->ctxs[i].ctx = 0; } }
- free(ctx_config->ctxs); -} - -static void wd_alg_ctx_uninit(struct wd_ctx_config *ctx_config) -{ - __u32 i; - - for (i = 0; i < ctx_config->ctx_num; i++) { - if (ctx_config->ctxs[i].ctx) { - wd_release_ctx(ctx_config->ctxs[i].ctx); - ctx_config->ctxs[i].ctx = 0; - } + if (ctx_config->ctxs) { + free(ctx_config->ctxs); + ctx_config->ctxs = 0; } - - free(ctx_config->ctxs); -} - -static int wd_alg_init_sve_ctx(struct wd_ctx_config *ctx_config) -{ - struct wd_soft_ctx *ctx_sync, *ctx_async; - - ctx_config->ctx_num = WD_SOFT_CTX_NUM; - ctx_config->ctxs = calloc(ctx_config->ctx_num, sizeof(struct wd_ctx)); - if (!ctx_config->ctxs) - return -WD_ENOMEM; - - ctx_sync = calloc(1, sizeof(struct wd_soft_ctx)); - if (!ctx_sync) - goto free_ctxs; - - ctx_config->ctxs[WD_SOFT_SYNC_CTX].op_type = 0; - ctx_config->ctxs[WD_SOFT_SYNC_CTX].ctx_mode = CTX_MODE_SYNC; - ctx_config->ctxs[WD_SOFT_SYNC_CTX].ctx = (handle_t)ctx_sync; - - ctx_async = calloc(1, sizeof(struct wd_soft_ctx)); - if (!ctx_async) - goto free_ctx_sync; - - ctx_config->ctxs[WD_SOFT_ASYNC_CTX].op_type = 0; - ctx_config->ctxs[WD_SOFT_ASYNC_CTX].ctx_mode = CTX_MODE_ASYNC; - ctx_config->ctxs[WD_SOFT_ASYNC_CTX].ctx = (handle_t)ctx_async; - - return 0; - -free_ctx_sync: - free(ctx_sync); -free_ctxs: - free(ctx_config->ctxs); - return -WD_ENOMEM; -} - -static void wd_alg_uninit_sve_ctx(struct wd_ctx_config *ctx_config) -{ - free((struct wd_soft_ctx *)ctx_config->ctxs[WD_SOFT_ASYNC_CTX].ctx); - free((struct wd_soft_ctx *)ctx_config->ctxs[WD_SOFT_SYNC_CTX].ctx); - free(ctx_config->ctxs); }
int wd_alg_attrs_init(struct wd_init_attrs *attrs) { wd_alg_poll_ctx alg_poll_func = attrs->alg_poll_ctx; wd_alg_init alg_init_func = attrs->alg_init; - __u32 sched_type = attrs->sched_type; struct wd_ctx_config *ctx_config = NULL; struct wd_sched *alg_sched = NULL; - char alg_type[CRYPTO_MAX_ALG_NAME]; - int driver_type = UADK_ALG_HW; - const char *alg = attrs->alg; - int ret = -WD_EINVAL; + struct wd_alg_driver *drv = NULL; + char *alg_name = attrs->alg; + __u32 op_type_num; + int ret = 0;
if (!attrs->ctx_params) return -WD_EINVAL;
- if (attrs->driver) - driver_type = attrs->driver->calc_type; - - switch (driver_type) { - case UADK_ALG_SOFT: - case UADK_ALG_CE_INSTR: - ctx_config = calloc(1, sizeof(*ctx_config)); - if (!ctx_config) { - WD_ERR("fail to alloc ctx config\n"); - return -WD_ENOMEM; - } - attrs->ctx_config = ctx_config; + WD_ERR("debug: call function: %s!\n", __func__); + ctx_config = calloc(1, sizeof(*ctx_config)); + if (!ctx_config) { + WD_ERR("fail to alloc ctx config\n"); + return -WD_ENOMEM; + } + attrs->ctx_config = ctx_config;
- /* Use default sched_type to alloc scheduler */ - alg_sched = wd_sched_rr_alloc(SCHED_POLICY_NONE, 1, 1, alg_poll_func); - if (!alg_sched) { - WD_ERR("fail to alloc scheduler\n"); - goto out_ctx_config; - } + /* Get op_type_num */ + op_type_num = attrs->ctx_params->op_type_num; + if (!op_type_num) + goto out_ctx_config;
- attrs->sched = alg_sched; + /* Use default sched_type to alloc scheduler */ + alg_sched = wd_sched_rr_alloc(attrs->sched_type, op_type_num, + numa_max_node() + 1, alg_poll_func); + if (!alg_sched) { + WD_ERR("fail to alloc scheduler\n"); + goto out_ctx_config; + } + attrs->sched = alg_sched;
- ret = wd_alg_ce_ctx_init(attrs); + /* Initialize queues according to task type */ + switch (attrs->task_type) { + case TASK_HW: + ret = wd_alg_hw_ctx_init(attrs); if (ret) { - WD_ERR("fail to init ce ctx\n"); + WD_ERR("fail to init HW ctx\n"); goto out_freesched; }
- ret = alg_init_func(ctx_config, alg_sched); - if (ret) - goto out_pre_init; - break; - case UADK_ALG_SVE_INSTR: - /* Use default sched_type to alloc scheduler */ - alg_sched = wd_sched_rr_alloc(SCHED_POLICY_SINGLE, 1, 1, alg_poll_func); - if (!alg_sched) { - WD_ERR("fail to alloc scheduler\n"); - return -WD_EINVAL; - } - attrs->sched = alg_sched; - - ctx_config = calloc(1, sizeof(*ctx_config)); - if (!ctx_config) { - WD_ERR("fail to alloc ctx config\n"); - goto out_freesched; - } - attrs->ctx_config = ctx_config; - - ret = wd_alg_init_sve_ctx(ctx_config); - if (ret) { - WD_ERR("fail to init sve ctx!\n"); - goto out_freesched; - } - - ctx_config->cap = attrs->ctx_params->cap; - ret = alg_init_func(ctx_config, alg_sched); + case TASK_MIX: + ret = wd_alg_hw_ctx_init(attrs); if (ret) { - wd_alg_uninit_sve_ctx(ctx_config); + WD_ERR("fail to init mix HW ctx\n"); goto out_freesched; } - break; - case UADK_ALG_HW: - wd_get_alg_type(alg, alg_type); - attrs->alg = alg_type; - - ctx_config = calloc(1, sizeof(*ctx_config)); - if (!ctx_config) { - WD_ERR("fail to alloc ctx config\n"); - return -WD_ENOMEM; - } - attrs->ctx_config = ctx_config;
- alg_sched = wd_sched_rr_alloc(sched_type, attrs->ctx_params->op_type_num, - numa_max_node() + 1, alg_poll_func); - if (!alg_sched) { - WD_ERR("fail to instance scheduler\n"); - goto out_ctx_config; + WD_ERR("debug: call function: %s!\n", __func__); + drv = wd_request_drv(alg_name, ALG_DRV_SOFT); + if (drv == NULL) { + WD_ERR("fail to find soft driver.\n"); + break; + } else if (drv->calc_type == UADK_ALG_CE_INSTR) { + ret = wd_alg_other_ctx_init(attrs, UADK_CTX_CE_INS); + if (ret) { + WD_ERR("fail to init ce ctx\n"); + goto out_ctx_init; + } + } else if (drv->calc_type == UADK_ALG_SVE_INSTR) { + ret = wd_alg_other_ctx_init(attrs, UADK_CTX_SVE_INS); + if (ret) { + WD_ERR("fail to init sve ctx\n"); + goto out_ctx_init; + } } - attrs->sched = alg_sched;
- ret = wd_alg_ctx_init(attrs); + break; + /* Only pure soft queues */ + case TASK_INSTR: + ret = wd_alg_other_init(attrs); if (ret) { - WD_ERR("fail to init ctx\n"); + WD_ERR("fail to init other ctx.\n"); goto out_freesched; }
- ctx_config->cap = attrs->ctx_params->cap; - ret = alg_init_func(ctx_config, alg_sched); - if (ret) - goto out_pre_init; + drv = wd_request_drv(alg_name, ALG_DRV_SOFT); + if (drv == NULL) { + WD_ERR("fail to find soft driver.\n"); + goto out_ctx_init; + } else if (drv->calc_type == UADK_ALG_CE_INSTR) { + ret = wd_alg_other_ctx_init(attrs, UADK_CTX_CE_INS); + if (ret) { + WD_ERR("fail to init ce ctx\n"); + goto out_ctx_init; + } + } else if (drv->calc_type == UADK_ALG_SVE_INSTR) { + ret = wd_alg_other_ctx_init(attrs, UADK_CTX_SVE_INS); + if (ret) { + WD_ERR("fail to init sve ctx\n"); + goto out_ctx_init; + } + } break; default: - WD_ERR("driver type error: %d\n", driver_type); + WD_ERR("driver type error: %d\n", drv->calc_type); return -WD_EINVAL; }
+ ctx_config->cap = attrs->ctx_params->cap; + ret = alg_init_func(ctx_config, alg_sched); + if (ret) + goto out_ctx_init; + + WD_ERR("---->ctx nums: %u\n", ctx_config->ctx_num); + return 0;
-out_pre_init: - if (driver_type == UADK_ALG_CE_INSTR || driver_type == UADK_ALG_SOFT) - wd_alg_ce_ctx_uninit(ctx_config); - else - wd_alg_ctx_uninit(ctx_config); +out_ctx_init: + wd_alg_ctxs_uninit(ctx_config); out_freesched: wd_sched_rr_release(alg_sched); out_ctx_config: @@ -2877,27 +3066,13 @@ void wd_alg_attrs_uninit(struct wd_init_attrs *attrs) { struct wd_ctx_config *ctx_config = attrs->ctx_config; struct wd_sched *alg_sched = attrs->sched; - int driver_type = attrs->driver->calc_type;
if (!ctx_config) { wd_sched_rr_release(alg_sched); return; }
- switch (driver_type) { - case UADK_ALG_SOFT: - case UADK_ALG_CE_INSTR: - wd_alg_ce_ctx_uninit(ctx_config); - break; - case UADK_ALG_SVE_INSTR: - wd_alg_uninit_sve_ctx(ctx_config); - break; - case UADK_ALG_HW: - wd_alg_ctx_uninit(ctx_config); - break; - default: - break; - } + wd_alg_ctxs_uninit(ctx_config);
free(ctx_config); wd_sched_rr_release(alg_sched);