From: Chenghai Huang <huangchenghai2@huawei.com> Replace magic expt=1 with ENGINE_SYNC_POLL_NUM in engine files and PROV_SYNC_POLL_NUM in provider files, both defined as 1U to match the __u32 expt type. Provider uses its own macro to avoid coupling with engine's uadk.h header. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> --- src/uadk.h | 2 ++ src/uadk_aead.c | 8 ++++---- src/uadk_cipher.c | 8 ++++---- src/uadk_dh.c | 6 +++--- src/uadk_digest.c | 6 +++--- src/uadk_pkey.c | 6 +++--- src/uadk_prov.h | 2 ++ src/uadk_prov_aead.c | 3 +-- src/uadk_prov_cipher.c | 3 +-- src/uadk_prov_dh.c | 3 +-- src/uadk_prov_digest.c | 3 +-- src/uadk_prov_hmac.c | 3 +-- src/uadk_prov_pkey.c | 2 +- src/uadk_prov_rsa.c | 3 +-- src/uadk_rsa.c | 6 +++--- 15 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/uadk.h b/src/uadk.h index a6db774..b190233 100644 --- a/src/uadk.h +++ b/src/uadk.h @@ -24,6 +24,8 @@ #define ENGINE_SEND_MAX_CNT 90000000 #define ENGINE_RECV_MAX_CNT 60000000 #define ENGINE_ENV_RECV_MAX_CNT 60000000 +/* Number of packets polled in one synchronous completion check */ +#define ENGINE_SYNC_POLL_NUM 1U #define UADK_UNINIT 0 #define UADK_INIT_SUCCESS 1 #define UADK_INIT_FAIL 2 diff --git a/src/uadk_aead.c b/src/uadk_aead.c index b88d034..c4f83a2 100644 --- a/src/uadk_aead.c +++ b/src/uadk_aead.c @@ -78,10 +78,10 @@ static EVP_CIPHER *uadk_aes_256_gcm; static int uadk_e_aead_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { @@ -99,10 +99,10 @@ static int uadk_e_aead_env_poll(void *ctx) static int uadk_e_aead_poll(void *ctx) { struct aead_priv_ctx *priv = (struct aead_priv_ctx *) ctx; + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret, idx; if (priv->req.op_type == WD_CIPHER_ENCRYPTION_DIGEST) diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index 2b1537c..091c636 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -307,10 +307,10 @@ static int sched_single_poll_policy(handle_t h_sched_ctx, static int uadk_e_cipher_poll(void *ctx) { struct cipher_priv_ctx *priv = (struct cipher_priv_ctx *) ctx; + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret, idx; if (priv->req.op_type == WD_CIPHER_ENCRYPTION) @@ -335,10 +335,10 @@ static int uadk_e_cipher_poll(void *ctx) static int uadk_e_cipher_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_dh.c b/src/uadk_dh.c index ab8a305..d5b1912 100644 --- a/src/uadk_dh.c +++ b/src/uadk_dh.c @@ -208,9 +208,9 @@ static void uadk_e_dh_set_status(void) static int uadk_e_dh_poll(void *ctx) { + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - int expt = 1; int idx = 1; int ret; @@ -282,10 +282,10 @@ static struct dh_res_config dh_res_config = { static int uadk_e_dh_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_digest.c b/src/uadk_digest.c index e18b25b..c5b8c99 100644 --- a/src/uadk_digest.c +++ b/src/uadk_digest.c @@ -394,9 +394,9 @@ static int sched_single_poll_policy(handle_t h_sched_ctx, static int uadk_e_digest_poll(void *ctx) { + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - int expt = 1; int ret = 0; do { @@ -416,10 +416,10 @@ static int uadk_e_digest_poll(void *ctx) static int uadk_e_digest_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_pkey.c b/src/uadk_pkey.c index 1fbee88..b2cfe48 100644 --- a/src/uadk_pkey.c +++ b/src/uadk_pkey.c @@ -119,9 +119,9 @@ static void uadk_e_ecc_set_status(void) static int uadk_ecc_poll(void *ctx) { + __u32 expt = ENGINE_SYNC_POLL_NUM; unsigned int recv = 0; __u64 rx_cnt = 0; - int expt = 1; int ret; do { @@ -173,10 +173,10 @@ static void uadk_e_ecc_set_support_state(int alg_tag, int value) static int uadk_e_ecc_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_prov.h b/src/uadk_prov.h index 41c61b6..ac71fe0 100644 --- a/src/uadk_prov.h +++ b/src/uadk_prov.h @@ -31,6 +31,8 @@ #define PROV_SEND_MAX_CNT 90000000 #define PROV_RECV_MAX_CNT 60000000 #define PROV_SCH_RECV_MAX_CNT 60000000 +/* Number of packets polled in one synchronous completion check */ +#define PROV_SYNC_POLL_NUM 1U #define UADK_P_SUCCESS 1 #define UADK_P_FAIL 0 #define UADK_DO_SOFT (-0xE0) diff --git a/src/uadk_prov_aead.c b/src/uadk_prov_aead.c index 83a7510..3747708 100644 --- a/src/uadk_prov_aead.c +++ b/src/uadk_prov_aead.c @@ -161,10 +161,9 @@ static EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in) static int uadk_aead_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c index 5c9dfe8..38ab088 100644 --- a/src/uadk_prov_cipher.c +++ b/src/uadk_prov_cipher.c @@ -444,10 +444,9 @@ static int uadk_prov_cipher_dev_init(struct cipher_priv_ctx *priv); static int uadk_cipher_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 recv_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_prov_dh.c b/src/uadk_prov_dh.c index bd403d7..d7d490d 100644 --- a/src/uadk_prov_dh.c +++ b/src/uadk_prov_dh.c @@ -648,10 +648,9 @@ static void uadk_prov_dh_cb(void *req_t) static int uadk_prov_dh_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_prov_digest.c b/src/uadk_prov_digest.c index 3334662..23c0c53 100644 --- a/src/uadk_prov_digest.c +++ b/src/uadk_prov_digest.c @@ -293,10 +293,9 @@ static void uadk_digest_reset(struct digest_priv_ctx *priv) static int uadk_digest_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - __u32 expt = 1; int ret; do { diff --git a/src/uadk_prov_hmac.c b/src/uadk_prov_hmac.c index 83b0809..53544f3 100644 --- a/src/uadk_prov_hmac.c +++ b/src/uadk_prov_hmac.c @@ -295,10 +295,9 @@ static void uadk_hmac_reset(struct hmac_priv_ctx *priv) static int uadk_hmac_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - __u32 expt = 1; int ret; do { diff --git a/src/uadk_prov_pkey.c b/src/uadk_prov_pkey.c index 0d392ca..2ff54ae 100644 --- a/src/uadk_prov_pkey.c +++ b/src/uadk_prov_pkey.c @@ -443,9 +443,9 @@ err: int uadk_prov_ecc_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; unsigned int recv = 0; __u64 rx_cnt = 0; - int expt = 1; int ret; do { diff --git a/src/uadk_prov_rsa.c b/src/uadk_prov_rsa.c index 208db37..5beece9 100644 --- a/src/uadk_prov_rsa.c +++ b/src/uadk_prov_rsa.c @@ -184,10 +184,9 @@ int rsa_fill_pubkey(struct rsa_pubkey_param *pubkey_param, static int uadk_rsa_env_poll(void *ctx) { + __u32 expt = PROV_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c index e692ea7..a96d1b9 100644 --- a/src/uadk_rsa.c +++ b/src/uadk_rsa.c @@ -728,9 +728,9 @@ static void uadk_e_rsa_set_status(void) static int uadk_e_rsa_poll(void *ctx) { + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - int expt = 1; int ret; do { @@ -766,10 +766,10 @@ static struct rsa_res_config rsa_res_config = { static int uadk_e_rsa_env_poll(void *ctx) { + /* Poll one packet currently */ + __u32 expt = ENGINE_SYNC_POLL_NUM; __u64 rx_cnt = 0; __u32 recv = 0; - /* Poll one packet currently */ - int expt = 1; int ret; do { -- 2.43.0