In the multi-process scenario, queue id of each process starts from 0. As a result, statistics are collected on the same queue, and the real queue ID needs to be used. In the asynchronous scenario, the number of packets that are sent busy is counted. As a result, the number of packets that are sent is greater than the actual number.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- drv/hisi_comp.c | 1 + drv/hisi_hpre.c | 1 + drv/hisi_qm_udrv.c | 1 + drv/hisi_sec.c | 1 + include/hisi_qm_udrv.h | 1 + include/wd_alg_common.h | 1 + include/wd_util.h | 9 ++++++--- wd_aead.c | 4 ++-- wd_cipher.c | 4 ++-- wd_comp.c | 4 ++-- wd_dh.c | 4 ++-- wd_digest.c | 4 ++-- wd_ecc.c | 4 ++-- wd_rsa.c | 4 ++-- 14 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c index 01e2ad8..18d0163 100644 --- a/drv/hisi_comp.c +++ b/drv/hisi_comp.c @@ -799,6 +799,7 @@ static int hisi_zip_init(void *conf, void *priv) h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx); if (unlikely(!h_qp)) goto out; + config->ctxs[i].sqn = qm_priv.sqn; }
hisi_zip_sqe_ops_adapt(h_qp); diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c index 83b2a7d..62a2cb6 100644 --- a/drv/hisi_hpre.c +++ b/drv/hisi_hpre.c @@ -484,6 +484,7 @@ static int hpre_init_qm_priv(struct wd_ctx_config_internal *config, WD_ERR("failed to alloc qp!\n"); goto out; } + config->ctxs[i].sqn = qm_priv->sqn; }
return 0; diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c index a3b5dc1..8210bf4 100644 --- a/drv/hisi_qm_udrv.c +++ b/drv/hisi_qm_udrv.c @@ -265,6 +265,7 @@ static int his_qm_set_qp_ctx(handle_t h_ctx, struct hisi_qm_priv *config, return ret; } q_info->sqn = qp_ctx.id; + config->sqn = qp_ctx.id;
ret = wd_ctx_set_io_cmd(h_ctx, UACCE_CMD_QM_SET_QP_INFO, &qp_cfg); if (ret < 0) { diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 0cba9ad..bcedfa6 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -3043,6 +3043,7 @@ int hisi_sec_init(void *conf, void *priv) h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx); if (!h_qp) goto out; + config->ctxs[i].sqn = qm_priv.sqn; } memcpy(&sec_ctx->config, config, sizeof(struct wd_ctx_config_internal)); hisi_sec_driver_adapter((struct hisi_qp *)h_qp); diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h index 32f8183..b94e8e2 100644 --- a/include/hisi_qm_udrv.h +++ b/include/hisi_qm_udrv.h @@ -49,6 +49,7 @@ struct hisi_qm_priv { __u8 qp_mode; __u16 sqe_size; __u16 op_type; + __u16 sqn; /* index of ctxs */ __u32 idx; bool epoll_en; diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h index 5d8e863..f69f00a 100644 --- a/include/wd_alg_common.h +++ b/include/wd_alg_common.h @@ -100,6 +100,7 @@ struct wd_ctx_internal { handle_t ctx; __u8 op_type; __u8 ctx_mode; + __u16 sqn; pthread_spinlock_t lock; };
diff --git a/include/wd_util.h b/include/wd_util.h index 163b18d..9ef2328 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -499,19 +499,22 @@ int wd_get_lib_file_path(char *lib_file, char *lib_path, bool is_dir);
/** * wd_dfx_msg_cnt() - Message counter interface for ctx - * @msg: Shared memory addr. + * @config: Ctx configuration in global setting. * @numSize: Number of elements. * @index: Indicates the CTX index. */ -static inline void wd_dfx_msg_cnt(unsigned long *msg, __u32 numsize, __u32 idx) +static inline void wd_dfx_msg_cnt(struct wd_ctx_config_internal *config, + __u32 numsize, __u32 idx) { + __u16 sqn; bool ret;
ret = wd_need_info(); if (idx > numsize || !ret) return;
- msg[idx]++; + sqn = config->ctxs[idx].sqn; + config->msg_cnt[sqn]++; }
#ifdef __cplusplus diff --git a/wd_aead.c b/wd_aead.c index a14234a..0967dda 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -739,7 +739,7 @@ int wd_do_aead_sync(handle_t h_sess, struct wd_aead_req *req) if (unlikely(ret)) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx; ret = send_recv_sync(ctx, &msg); req->state = msg.result; @@ -772,7 +772,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
msg_id = wd_get_msg_from_pool(&wd_aead_setting.pool, @@ -793,6 +792,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_aead_env_config, idx); if (ret) goto fail_with_msg; diff --git a/wd_cipher.c b/wd_cipher.c index a8ebeea..1344119 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -619,7 +619,7 @@ int wd_do_cipher_sync(handle_t h_sess, struct wd_cipher_req *req) if (unlikely(ret)) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
ret = send_recv_sync(ctx, &msg); @@ -651,7 +651,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req) return ret;
ctx = config->ctxs + idx; - wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
msg_id = wd_get_msg_from_pool(&wd_cipher_setting.pool, idx, (void **)&msg); @@ -671,6 +670,7 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_cipher_env_config, idx); if (ret) goto fail_with_msg; diff --git a/wd_comp.c b/wd_comp.c index 2239e33..f48938a 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -558,7 +558,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess, if (unlikely(ret)) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
msg_handle.send = wd_comp_setting.driver->send; @@ -809,7 +809,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req) if (unlikely(ret)) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg); @@ -827,6 +826,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_comp_env_config, idx); if (unlikely(ret)) goto fail_with_msg; diff --git a/wd_dh.c b/wd_dh.c index 7feb7ee..6aebb8c 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -345,7 +345,7 @@ int wd_do_dh_sync(handle_t sess, struct wd_dh_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_dh_msg)); @@ -391,7 +391,6 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_dh_setting.pool, idx, (void **)&msg); @@ -411,6 +410,7 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_dh_env_config, idx); if (ret) goto fail_with_msg; diff --git a/wd_digest.c b/wd_digest.c index df9f656..df2c286 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -609,7 +609,7 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req) if (unlikely(ret)) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx; ret = send_recv_sync(ctx, dsess, &msg); req->state = msg.result; @@ -642,7 +642,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
msg_id = wd_get_msg_from_pool(&wd_digest_setting.pool, idx, @@ -663,6 +662,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_digest_env_config, idx); if (ret) goto fail_with_msg; diff --git a/wd_ecc.c b/wd_ecc.c index da717a8..6c055c8 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -1548,7 +1548,7 @@ int wd_do_ecc_sync(handle_t h_sess, struct wd_ecc_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_ecc_msg)); @@ -2227,7 +2227,6 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_ecc_setting.pool, idx, (void **)&msg); @@ -2247,6 +2246,7 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_ecc_env_config, idx); if (ret) goto fail_with_msg; diff --git a/wd_rsa.c b/wd_rsa.c index 60c2836..fff6067 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -407,7 +407,7 @@ int wd_do_rsa_sync(handle_t h_sess, struct wd_rsa_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); + wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_rsa_msg)); @@ -453,7 +453,6 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) if (ret) return ret;
- wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx); ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_rsa_setting.pool, idx, (void **)&msg); @@ -473,6 +472,7 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) goto fail_with_msg; }
+ wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); ret = wd_add_task_to_async_queue(&wd_rsa_env_config, idx); if (ret) goto fail_with_msg;