Skip to content

Commit 1d19058

Browse files
lizhiherbertx
authored andcommitted
crypto: hisilicon/hpre - adapt ECDH for high-performance cores
Only the ECDH with NIST P-256 meets requirements. The algorithm will be scheduled first for high-performance cores. The key step is to config resv1 field of BD. Signed-off-by: lizhi <lizhi206@huawei.com> Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 07bb097 commit 1d19058

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/crypto/hisilicon/hpre/hpre_crypto.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct hpre_ctx;
3939
#define HPRE_DFX_SEC_TO_US 1000000
4040
#define HPRE_DFX_US_TO_NS 1000
4141

42+
#define HPRE_ENABLE_HPCORE_SHIFT 7
43+
4244
/* due to nist p521 */
4345
#define HPRE_ECC_MAX_KSZ 66
4446

@@ -131,6 +133,8 @@ struct hpre_ctx {
131133
};
132134
/* for ecc algorithms */
133135
unsigned int curve_id;
136+
/* for high performance core */
137+
u8 enable_hpcore;
134138
};
135139

136140
struct hpre_asym_request {
@@ -1619,6 +1623,8 @@ static int hpre_ecdh_compute_value(struct kpp_request *req)
16191623
}
16201624

16211625
msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) | HPRE_ALG_ECC_MUL);
1626+
msg->resv1 = ctx->enable_hpcore << HPRE_ENABLE_HPCORE_SHIFT;
1627+
16221628
ret = hpre_send(ctx, msg);
16231629
if (likely(!ret))
16241630
return -EINPROGRESS;
@@ -1653,6 +1659,7 @@ static int hpre_ecdh_nist_p256_init_tfm(struct crypto_kpp *tfm)
16531659
struct hpre_ctx *ctx = kpp_tfm_ctx(tfm);
16541660

16551661
ctx->curve_id = ECC_CURVE_NIST_P256;
1662+
ctx->enable_hpcore = 1;
16561663

16571664
kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + hpre_align_pd());
16581665

0 commit comments

Comments
 (0)