Skip to content

Commit c8ebb83

Browse files
committed
digest: async mode switch to sw for small packets
hw v2 does not support msg->in_bytes = 0, refer drv/hisi_sec.c: digest_bd2_type_check if (type == HASH_SINGLE_BLOCK) { WD_ERR("hardware v2 not supports 0 size in block hash!\n"); return -WD_EINVAL; } But Nginx does send packets with in_bytes=0, sync mode is OK since it switches to sw, while async mode will fail. Fixed by switching to sw for small packets in async mode too, Though only in_bytes=0 matters. Signed-off-by: Zhangfei Gao <[email protected]>
1 parent f015022 commit c8ebb83

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/uadk_digest.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,13 @@ static int do_digest_async(struct digest_priv_ctx *priv, struct async_op *op)
811811
return ret;
812812
}
813813

814+
if (priv->req.in_bytes <= priv->switch_threshold &&
815+
priv->state == SEC_DIGEST_INIT) {
816+
/* hw v2 does not support in_bytes=0, ans switch to sw
817+
* refer digest_bd2_type_check
818+
*/
819+
return 0;
820+
}
814821
cb_param = malloc(sizeof(struct uadk_e_cb_info));
815822
if (!cb_param) {
816823
fprintf(stderr, "failed to alloc cb_param.\n");
@@ -897,18 +904,18 @@ static int uadk_e_digest_final(EVP_MD_CTX *ctx, unsigned char *digest)
897904

898905
ret = do_digest_sync(priv);
899906
if (!ret)
900-
goto sync_err;
907+
goto hw_err;
901908
} else {
902909
ret = do_digest_async(priv, op);
903910
if (!ret)
904-
goto clear;
911+
goto hw_err;
905912
}
906913
memcpy(digest, priv->req.out, priv->req.out_bytes);
907914

908915
free(op);
909916
return 1;
910917

911-
sync_err:
918+
hw_err:
912919
if (priv->state == SEC_DIGEST_INIT) {
913920
ret = uadk_e_digest_soft_work(priv, priv->req.in_bytes, digest);
914921
} else {

0 commit comments

Comments
 (0)