Skip to content

Commit c8b4b47

Browse files
zaiboxuherbertx
authored andcommitted
crypto: hisilicon - add HiSilicon HPRE accelerator
The HiSilicon HPRE accelerator implements RSA and DH algorithms. It uses Hisilicon QM as interface to CPU. This patch provides PCIe driver to the accelerator and registers its algorithms to crypto akcipher and kpp interfaces. Signed-off-by: Zaibo Xu <xuzaibo@huawei.com> Signed-off-by: Hui Tang <tanghui20@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent a92a00f commit c8b4b47

File tree

6 files changed

+1702
-0
lines changed

6 files changed

+1702
-0
lines changed

drivers/crypto/hisilicon/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ config CRYPTO_DEV_HISI_ZIP
3131
select SG_SPLIT
3232
help
3333
Support for HiSilicon ZIP Driver
34+
35+
config CRYPTO_DEV_HISI_HPRE
36+
tristate "Support for HISI HPRE accelerator"
37+
depends on PCI && PCI_MSI
38+
depends on ARM64 || (COMPILE_TEST && 64BIT)
39+
select CRYPTO_DEV_HISI_QM
40+
select CRYPTO_DH
41+
select CRYPTO_RSA
42+
help
43+
Support for HiSilicon HPRE(High Performance RSA Engine)
44+
accelerator, which can accelerate RSA and DH algorithms.

drivers/crypto/hisilicon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hpre/
23
obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += sec/
34
obj-$(CONFIG_CRYPTO_DEV_HISI_QM) += hisi_qm.o
45
hisi_qm-objs = qm.o sgl.o
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hisi_hpre.o
2+
hisi_hpre-objs = hpre_main.o hpre_crypto.o
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2019 HiSilicon Limited. */
3+
#ifndef __HISI_HPRE_H
4+
#define __HISI_HPRE_H
5+
6+
#include <linux/list.h>
7+
#include "../qm.h"
8+
9+
#define HPRE_SQE_SIZE sizeof(struct hpre_sqe)
10+
#define HPRE_PF_DEF_Q_NUM 64
11+
#define HPRE_PF_DEF_Q_BASE 0
12+
#define HPRE_CLUSTERS_NUM 4
13+
14+
struct hpre {
15+
struct hisi_qm qm;
16+
struct list_head list;
17+
unsigned long status;
18+
};
19+
20+
enum hpre_alg_type {
21+
HPRE_ALG_NC_NCRT = 0x0,
22+
HPRE_ALG_NC_CRT = 0x1,
23+
HPRE_ALG_KG_STD = 0x2,
24+
HPRE_ALG_KG_CRT = 0x3,
25+
HPRE_ALG_DH_G2 = 0x4,
26+
HPRE_ALG_DH = 0x5,
27+
};
28+
29+
struct hpre_sqe {
30+
__le32 dw0;
31+
__u8 task_len1;
32+
__u8 task_len2;
33+
__u8 mrttest_num;
34+
__u8 resv1;
35+
__le64 key;
36+
__le64 in;
37+
__le64 out;
38+
__le16 tag;
39+
__le16 resv2;
40+
#define _HPRE_SQE_ALIGN_EXT 7
41+
__le32 rsvd1[_HPRE_SQE_ALIGN_EXT];
42+
};
43+
44+
struct hpre *hpre_find_device(int node);
45+
int hpre_algs_register(void);
46+
void hpre_algs_unregister(void);
47+
48+
#endif

0 commit comments

Comments
 (0)