After the uadk framework updates the heterogeneous scheduling function, the internal implementation functions of the hash-agg algorithm need to be adapted and modified.
Signed-off-by: Longfang Liu liulongfang@huawei.com --- wd_agg.c | 80 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 34 deletions(-)
diff --git a/wd_agg.c b/wd_agg.c index 7a4b17c..5cf21d3 100644 --- a/wd_agg.c +++ b/wd_agg.c @@ -32,7 +32,6 @@ struct wd_agg_setting { struct wd_ctx_config_internal config; struct wd_sched sched; struct wd_async_msg_pool pool; - struct wd_alg_driver *driver; void *priv; void *dlhandle; void *dlh_list; @@ -382,6 +381,26 @@ static int wd_agg_init_sess_priv(struct wd_agg_sess *sess, struct wd_agg_sess_se return WD_SUCCESS; }
+static int wd_agg_drv_ops(struct wd_agg_sess *sess, void *param) +{ + struct wd_ctx_config_internal *config = param; + struct wd_alg_driver *drv; + __u32 i; + int ret; + + for (i = 0; i < config->ctx_num; i++) { + drv = config->ctxs[i].drv; + if (!drv) + continue; + + ret = drv->get_extend_ops(&sess->ops); + if (!ret) + return 0; + } + + return -WD_EINVAL; +} + handle_t wd_agg_alloc_sess(struct wd_agg_sess_setup *setup) { __u32 out_agg_cols_num = 0; @@ -401,7 +420,7 @@ handle_t wd_agg_alloc_sess(struct wd_agg_sess_setup *setup) sess->agg_conf.out_cols_num = out_agg_cols_num;
sess->alg_name = wd_agg_alg_name; - ret = wd_drv_alg_support(sess->alg_name, wd_agg_setting.driver); + ret = wd_drv_alg_support(sess->alg_name, &wd_agg_setting.config); if (!ret) { WD_ERR("failed to support agg algorithm: %s!\n", sess->alg_name); goto err_sess; @@ -415,7 +434,7 @@ handle_t wd_agg_alloc_sess(struct wd_agg_sess_setup *setup) goto err_sess; }
- ret = wd_agg_setting.driver->get_extend_ops(&sess->ops); + ret = wd_agg_drv_ops(sess, &wd_agg_setting.config); if (ret) { WD_ERR("failed to get agg extend ops!\n"); goto err_sess; @@ -592,15 +611,10 @@ static int wd_agg_alg_init(struct wd_ctx_config *config, struct wd_sched *sched) if (ret < 0) goto out_clear_sched;
- ret = wd_alg_init_driver(&wd_agg_setting.config, wd_agg_setting.driver, - &wd_agg_setting.priv); - if (ret) - goto out_clear_pool; + wd_agg_setting.priv = STATUS_ENABLE;
return WD_SUCCESS;
-out_clear_pool: - wd_uninit_async_request_pool(&wd_agg_setting.pool); out_clear_sched: wd_clear_sched(&wd_agg_setting.sched); out_clear_ctx_config: @@ -617,12 +631,9 @@ static int wd_agg_alg_uninit(void)
/* Uninit async request pool */ wd_uninit_async_request_pool(&wd_agg_setting.pool); - /* Unset config, sched, driver */ wd_clear_sched(&wd_agg_setting.sched); - - wd_alg_uninit_driver(&wd_agg_setting.config, wd_agg_setting.driver, - &wd_agg_setting.priv); + wd_agg_setting.priv = NULL;
return WD_SUCCESS; } @@ -660,20 +671,12 @@ int wd_agg_init(char *alg, __u32 sched_type, int task_type, struct wd_ctx_params while (ret != 0) { memset(&wd_agg_setting.config, 0, sizeof(struct wd_ctx_config_internal));
- /* Get alg driver and dev name */ - wd_agg_setting.driver = wd_alg_drv_bind(task_type, alg); - if (!wd_agg_setting.driver) { - WD_ERR("failed to bind %s driver.\n", alg); - goto out_dlopen; - } - + /* Init ctx param and prepare for ctx request */ agg_ctx_params.ctx_set_num = &agg_ctx_num; - ret = wd_ctx_param_init(&agg_ctx_params, ctx_params, wd_agg_setting.driver, + ret = wd_ctx_param_init_nw(&agg_ctx_params, ctx_params, alg, task_type, WD_AGG_TYPE, 1); if (ret) { if (ret == -WD_EAGAIN) { - wd_disable_drv(wd_agg_setting.driver); - wd_alg_drv_unbind(wd_agg_setting.driver); continue; } goto out_driver; @@ -681,15 +684,13 @@ int wd_agg_init(char *alg, __u32 sched_type, int task_type, struct wd_ctx_params
wd_agg_init_attrs.alg = alg; wd_agg_init_attrs.sched_type = sched_type; - wd_agg_init_attrs.driver = wd_agg_setting.driver; + wd_agg_init_attrs.task_type = task_type; wd_agg_init_attrs.ctx_params = &agg_ctx_params; wd_agg_init_attrs.alg_init = wd_agg_alg_init; wd_agg_init_attrs.alg_poll_ctx = wd_agg_poll_ctx; ret = wd_alg_attrs_init(&wd_agg_init_attrs); if (ret) { if (ret == -WD_ENODEV) { - wd_disable_drv(wd_agg_setting.driver); - wd_alg_drv_unbind(wd_agg_setting.driver); wd_ctx_param_uninit(&agg_ctx_params); continue; } @@ -697,17 +698,27 @@ int wd_agg_init(char *alg, __u32 sched_type, int task_type, struct wd_ctx_params goto out_params_uninit; } } + ret = wd_ctx_drv_config(alg, &wd_agg_setting.config); + if (ret) + goto out_uninit_nolock; + + ret = wd_alg_init_driver_nw(&wd_agg_setting.config); + if (ret) + goto out_drv_deconfig;
wd_alg_set_init(&wd_agg_setting.status); wd_ctx_param_uninit(&agg_ctx_params);
return WD_SUCCESS;
+out_drv_deconfig: + wd_ctx_drv_deconfig(&wd_agg_setting.config); +out_uninit_nolock: + wd_agg_alg_uninit(); + wd_alg_attrs_uninit(&wd_agg_init_attrs); out_params_uninit: wd_ctx_param_uninit(&agg_ctx_params); out_driver: - wd_alg_drv_unbind(wd_agg_setting.driver); -out_dlopen: wd_agg_close_driver(); out_uninit: wd_alg_clear_init(&wd_agg_setting.status); @@ -722,8 +733,9 @@ void wd_agg_uninit(void) if (ret) return;
- wd_alg_attrs_uninit(&wd_agg_init_attrs); - wd_alg_drv_unbind(wd_agg_setting.driver); + wd_alg_uninit_driver_nw(&wd_agg_setting.config); + wd_ctx_drv_deconfig(&wd_agg_setting.config); + wd_agg_close_driver(); wd_agg_setting.dlh_list = NULL; wd_alg_clear_init(&wd_agg_setting.status); @@ -1096,8 +1108,8 @@ static int wd_agg_sync_job(struct wd_agg_sess *sess, struct wd_agg_req *req, wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
- msg_handle.send = wd_agg_setting.driver->send; - msg_handle.recv = wd_agg_setting.driver->recv; + msg_handle.send = ctx->drv->send; + msg_handle.recv = ctx->drv->recv;
pthread_spin_lock(&ctx->lock); ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, msg, NULL, config->epoll_en); @@ -1201,7 +1213,7 @@ static int wd_agg_async_job(struct wd_agg_sess *sess, struct wd_agg_req *req, bo else fill_request_msg_output(msg, req, sess, false); msg->tag = msg_id; - ret = wd_agg_setting.driver->send(ctx->ctx, msg); + ret = ctx->drv->send(ctx->ctx, msg); if (unlikely(ret < 0)) { if (ret != -WD_EBUSY) WD_ERR("wd agg async send err!\n"); @@ -1528,7 +1540,7 @@ static int wd_agg_poll_ctx(__u32 idx, __u32 expt, __u32 *count) ctx = config->ctxs + idx;
do { - ret = wd_agg_setting.driver->recv(ctx->ctx, &resp_msg); + ret = ctx->drv->recv(ctx->ctx, &resp_msg); if (ret == -WD_EAGAIN) { return ret; } else if (unlikely(ret < 0)) {