crypto: hisilicon - add HPRE support
cover crypto: hisilicon - add HPRE support
This series adds HiSilicon high performance RSA engine(HPRE) driver in crypto subsystem. HPRE driver provides PCIe hardware device initiation with RSA and DH algorithms registered to Crypto. Meanwhile, some debug supporting of DebugFS is given.
Zaibo Xu (5):
crypto: hisilicon - add HiSilicon HPRE accelerator
crypto: hisilicon - add SRIOV support for HPRE
Documentation: Add debugfs doc for hisi_hpre
crypto: hisilicon: Add debugfs for HPRE
MAINTAINERS: Add maintainer for HiSilicon HPRE driver
Documentation/ABI/testing/debugfs-hisi-hpre | 57 ++ MAINTAINERS | 9 + drivers/crypto/hisilicon/Kconfig | 11 + drivers/crypto/hisilicon/Makefile | 1 + drivers/crypto/hisilicon/hpre/Makefile | 2 + drivers/crypto/hisilicon/hpre/hpre.h | 83 ++ drivers/crypto/hisilicon/hpre/hpre_crypto.c | 1137 +++++++++++++++++++++++++++ drivers/crypto/hisilicon/hpre/hpre_main.c | 1052 +++++++++++++++++++++++++ 8 files changed, 2352 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-hisi-hpre create mode 100644 drivers/crypto/hisilicon/hpre/Makefile create mode 100644 drivers/crypto/hisilicon/hpre/hpre.h create mode 100644 drivers/crypto/hisilicon/hpre/hpre_crypto.c create mode 100644 drivers/crypto/hisilicon/hpre/hpre_main.c
Signature · 1 line
2.8.1
PATCH 1/5 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.
--- drivers/crypto/hisilicon/Kconfig | 11 + drivers/crypto/hisilicon/Makefile | 1 + drivers/crypto/hisilicon/hpre/Makefile | 2 + drivers/crypto/hisilicon/hpre/hpre.h | 48 ++ drivers/crypto/hisilicon/hpre/hpre_crypto.c | 1137 +++++++++++++++++++++++++++ drivers/crypto/hisilicon/hpre/hpre_main.c | 503 ++++++++++++ 6 files changed, 1702 insertions(+) create mode 100644 drivers/crypto/hisilicon/hpre/Makefile create mode 100644 drivers/crypto/hisilicon/hpre/hpre.h create mode 100644 drivers/crypto/hisilicon/hpre/hpre_crypto.c create mode 100644 drivers/crypto/hisilicon/hpre/hpre_main.c
drivers/crypto/hisilicon/Kconfig +11 -0
@@ -31,3 +31,14 @@ config CRYPTO_DEV_HISI_ZIP select SG_SPLIT help Support for HiSilicon ZIP Driver + +config CRYPTO_DEV_HISI_HPRE + tristate "Support for HISI HPRE accelerator" + depends on PCI && PCI_MSI + depends on ARM64 || (COMPILE_TEST && 64BIT) + select CRYPTO_DEV_HISI_QM + select CRYPTO_DH + select CRYPTO_RSA + help + Support for HiSilicon HPRE(High Performance RSA Engine) + accelerator, which can accelerate RSA and DH algorithms.
drivers/crypto/hisilicon/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hpre/ obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += sec/ obj-$(CONFIG_CRYPTO_DEV_HISI_QM) += hisi_qm.o hisi_qm-objs = qm.o sgl.o
drivers/crypto/hisilicon/hpre/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hisi_hpre.o +hisi_hpre-objs = hpre_main.o hpre_crypto.o
drivers/crypto/hisilicon/hpre/hpre.h new file +48 -0
48 lines not on this page · raw message
drivers/crypto/hisilicon/hpre/hpre_crypto.c new file +1137 -0
1,137 lines not on this page · raw message
drivers/crypto/hisilicon/hpre/hpre_main.c new file +503 -0
503 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH 1/1 crypto: hisilicon: Fix misuse of GENMASK macro
Arguments are supposed to be ordered high then low.
---
Spotted when trying to introduce compile time checking that the order of the arguments to GENMASK are correct [0]. I have only compile tested the patch.
[0]: https://lore.kernel.org/lkml/[email protected]/
drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -2
@@ -116,8 +116,8 @@ static const struct hpre_hw_error hpre_hw_errors[] = { { .int_msk = BIT(7), .msg = "hpre_cltr2_htbt_tm_out_err" }, { .int_msk = BIT(8), .msg = "hpre_cltr3_htbt_tm_out_err" }, { .int_msk = BIT(9), .msg = "hpre_cltr4_htbt_tm_out_err" }, - { .int_msk = GENMASK(10, 15), .msg = "hpre_ooo_rdrsp_err" }, - { .int_msk = GENMASK(16, 21), .msg = "hpre_ooo_wrrsp_err" }, + { .int_msk = GENMASK(15, 10), .msg = "hpre_ooo_rdrsp_err" }, + { .int_msk = GENMASK(21, 16), .msg = "hpre_ooo_wrrsp_err" }, {/* sentinel */ } };
Signature · 1 line
2.23.0
Re: [PATCH] crypto: hisilicon: Fix misuse of GENMASK macro
Agree with you, thanks!
Zaibo
.
Quoted 29 lines · Rikard Falkeborn
Arguments are supposed to be ordered high then low.
Fixes c8b4b477079d ("crypto: hisilicon - add HiSilicon HPRE accelerator")Signed-off-by Rikard Falkeborn <[email protected]>---
Spotted when trying to introduce compile time checking that the order of the arguments to GENMASK are correct [0]. I have only compile tested the patch.[0]: https://lore.kernel.org/lkml/[email protected]/
drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/crypto/hisilicon/hpre/hpre_main.c +2
-2@@ -116,8 +116,8 @@ static const struct hpre_hw_error hpre_hw_errors[] = { { .int_msk = BIT(7), .msg = "hpre_cltr2_htbt_tm_out_err" }, { .int_msk = BIT(8), .msg = "hpre_cltr3_htbt_tm_out_err" }, { .int_msk = BIT(9), .msg = "hpre_cltr4_htbt_tm_out_err" }, - { .int_msk = GENMASK(10, 15), .msg = "hpre_ooo_rdrsp_err" }, - { .int_msk = GENMASK(16, 21), .msg = "hpre_ooo_wrrsp_err" }, + { .int_msk = GENMASK(15, 10), .msg = "hpre_ooo_rdrsp_err" }, + { .int_msk = GENMASK(21, 16), .msg = "hpre_ooo_wrrsp_err" }, {/* sentinel */ } };
Herbert Xu
maintainerRe: [PATCH] crypto: hisilicon: Fix misuse of GENMASK macro
In reply to Rikard FalkebornQuoted 9 lines · Rikard Falkeborn
Arguments are supposed to be ordered high then low.
Fixes c8b4b477079d ("crypto: hisilicon - add HiSilicon HPRE accelerator")Signed-off-by Rikard Falkeborn <[email protected]>---
Spotted when trying to introduce compile time checking that the order of the arguments to GENMASK are correct [0]. I have only compile tested the patch.
Quoted 4 lines
[0]: https://lore.kernel.org/lkml/[email protected]/
drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 2/5 crypto: hisilicon - add SRIOV support for HPRE
In reply to Zaibo XuHiSilicon HPRE engine supports PCI SRIOV. This patch enable this feature. User can enable VFs and pass through them to VM, same HPRE driver can work in VM to provide RSA and DH algorithms by crypto akcipher and kpp interfaces.
--- drivers/crypto/hisilicon/hpre/hpre.h | 1 + drivers/crypto/hisilicon/hpre/hpre_main.c | 139 ++++++++++++++++++++++++++++-- 2 files changed, 133 insertions(+), 7 deletions(-)
drivers/crypto/hisilicon/hpre/hpre.h +1 -0
@@ -14,6 +14,7 @@struct hpre {struct hisi_qm qm;struct list_head list; +u32 num_vfs;unsigned long status; };
drivers/crypto/hisilicon/hpre/hpre_main.c +132 -7
189 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH 3/5 Documentation: Add debugfs doc for hisi_hpre
In reply to Zaibo XuAdd debugfs descriptions for HiSilicon HPRE driver.
--- Documentation/ABI/testing/debugfs-hisi-hpre | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-hisi-hpre
Documentation/ABI/testing/debugfs-hisi-hpre new file +57 -0
@@ -0,0 +1,57 @@ +What: /sys/kernel/debug/hisi_hpre/<bdf>/cluster[0-3]/regs +Date: Sep 2019 +Contact: [email protected] +Description: Dump debug registers from the HPRE cluster. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/cluster[0-3]/cluster_ctrl +Date: Sep 2019 +Contact: [email protected] +Description: Write the HPRE core selection in the cluster into this file, + and then we can read the debug information of the core. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/rdclr_en +Date: Sep 2019 +Contact: [email protected] +Description: HPRE cores debug registers read clear control. 1 means enable + register read clear, otherwise 0. Writing to this file has no + functional effect, only enable or disable counters clear after + reading of these registers. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/current_qm +Date: Sep 2019 +Contact: [email protected] +Description: One HPRE controller has one PF and multiple VFs, each function + has a QM. Select the QM which below qm refers to. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/regs +Date: Sep 2019 +Contact: [email protected] +Description: Dump debug registers from the HPRE. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/qm_regs +Date: Sep 2019 +Contact: [email protected] +Description: Dump debug registers from the QM. + Available for PF and VF in host. VF in guest currently only + has one debug register. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/current_q +Date: Sep 2019 +Contact: [email protected] +Description: One QM may contain multiple queues. Select specific queue to + show its debug registers in above qm_regs. + Only available for PF. + +What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/clear_enable +Date: Sep 2019 +Contact: [email protected] +Description: QM debug registers(qm_regs) read clear control. 1 means enable + register read clear, otherwise 0. + Writing to this file has no functional effect, only enable or + disable counters clear after reading of these registers. + Only available for PF.
Signature · 1 line
2.8.1
PATCH 4/5 crypto: hisilicon: Add debugfs for HPRE
In reply to Zaibo XuHiSilicon HPRE engine driver uses debugfs to provide debug information, the usage can be found in /Documentation/ABI/testing/debugfs-hisi-hpre.
--- drivers/crypto/hisilicon/hpre/hpre.h | 36 ++- drivers/crypto/hisilicon/hpre/hpre_main.c | 426 +++++++++++++++++++++++++++++- 2 files changed, 460 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre.h +35 -1
@@ -9,11 +9,45 @@#define HPRE_SQE_SIZE sizeof(struct hpre_sqe)#define HPRE_PF_DEF_Q_NUM 64#define HPRE_PF_DEF_Q_BASE 0 -#define HPRE_CLUSTERS_NUM 4 + +enum { +HPRE_CLUSTER0 , +HPRE_CLUSTER1 , +HPRE_CLUSTER2 , +HPRE_CLUSTER3 , +HPRE_CLUSTERS_NUM , +}; + +enum hpre_ctrl_dbgfs_file { +HPRE_CURRENT_QM , +HPRE_CLEAR_ENABLE , +HPRE_CLUSTER_CTRL , +HPRE_DEBUG_FILE_NUM , +}; + +#define HPRE_DEBUGFS_FILE_NUM (HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM - 1) + +struct hpre_debugfs_file { +int index; +enum hpre_ctrl_dbgfs_file type; +spinlock_t lock; +struct hpre_debug *debug; +}; + +/* +* One HPRE controller has one PF and multiple VFs, some global configurations +* which PF has need this structure. +* Just relevant for PF. +*/ +struct hpre_debug { +struct dentry *debug_root; +struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM ]; +};struct hpre {struct hisi_qm qm;struct list_head list; +struct hpre_debug debug;u32 num_vfs;unsigned long status; };
drivers/crypto/hisilicon/hpre/hpre_main.c +425 -1
492 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH 5/5 MAINTAINERS: Add maintainer for HiSilicon HPRE driver
In reply to Zaibo XuHere adds maintainer information for high performance RSA engine (HPRE) driver.
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -7364,6 +7364,15 @@ F: include/uapi/linux/if_hippi.h F: net/802/hippi.c F: drivers/net/hippi/ +HISILICON HIGH PERFORMANCE RSA ENGINE DRIVER (HPRE) +M: Zaibo Xu <[email protected]> +L: [email protected] +S: Maintained +F: drivers/crypto/hisilicon/hpre/hpre_crypto.c +F: drivers/crypto/hisilicon/hpre/hpre_main.c +F: drivers/crypto/hisilicon/hpre/hpre.h +F: Documentation/ABI/testing/debugfs-hisi-hpre + HISILICON NETWORK SUBSYSTEM 3 DRIVER (HNS3) M: Yisen Zhuang <[email protected]> M: Salil Mehta <[email protected]>
Signature · 1 line
2.8.1
Hi,
Quoted 21 lines · Zaibo Xu
This series adds HiSilicon high performance RSA engine(HPRE) driver in crypto subsystem. HPRE driver provides PCIe hardware device initiation with RSA and DH algorithms registered to Crypto. Meanwhile, some debug supporting of DebugFS is given.
Zaibo Xu (5):
crypto: hisilicon - add HiSilicon HPRE accelerator
crypto: hisilicon - add SRIOV support for HPRE
Documentation: Add debugfs doc forhisi_hpre
crypto: hisilicon: Add debugfs for HPRE
MAINTAINERS: Add maintainer for HiSilicon HPRE driverDocumentation/ABI/testing/debugfs-hisi-hpre | 57 ++ MAINTAINERS | 9 + drivers/crypto/hisilicon/Kconfig | 11 + drivers/crypto/hisilicon/Makefile | 1 + drivers/crypto/hisilicon/hpre/Makefile | 2 + drivers/crypto/hisilicon/hpre/hpre.h | 83 ++ drivers/crypto/hisilicon/hpre/hpre_crypto.c | 1137 +++++++++++++++++++++++++++ drivers/crypto/hisilicon/hpre/hpre_main.c | 1052 +++++++++++++++++++++++++ 8 files changed, 2352 insertions(+)
Quoted 6 lines
create mode 100644
Documentation/ABI/testing/debugfs-hisi-hprecreate mode 100644drivers/crypto/hisilicon/hpre/Makefilecreate mode 100644drivers/crypto/hisilicon/hpre/hpre.hcreate mode 100644drivers/crypto/hisilicon/hpre/hpre_crypto.ccreate mode 100644drivers/crypto/hisilicon/hpre/hpre_main.c
Any comments for this version?
Best,
Zaibo
Herbert Xu
maintainerQuoted 12 lines · Zaibo Xu
This series adds HiSilicon high performance RSA engine(HPRE) driver in crypto subsystem. HPRE driver provides PCIe hardware device initiation with RSA and DH algorithms registered to Crypto. Meanwhile, some debug supporting of DebugFS is given.
Zaibo Xu (5):
crypto: hisilicon - add HiSilicon HPRE accelerator
crypto: hisilicon - add SRIOV support for HPRE
Documentation: Add debugfs doc forhisi_hpre
crypto: hisilicon: Add debugfs for HPRE
MAINTAINERS: Add maintainer for HiSilicon HPRE driver
Quoted 14 lines
Documentation/ABI/testing/debugfs-hisi-hpre | 57 ++ MAINTAINERS | 9 + drivers/crypto/hisilicon/Kconfig | 11 + drivers/crypto/hisilicon/Makefile | 1 + drivers/crypto/hisilicon/hpre/Makefile | 2 + drivers/crypto/hisilicon/hpre/hpre.h | 83 ++ drivers/crypto/hisilicon/hpre/hpre_crypto.c | 1137 +++++++++++++++++++++++++++ drivers/crypto/hisilicon/hpre/hpre_main.c | 1052 +++++++++++++++++++++++++ 8 files changed, 2352 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-hisi-hpre create mode 100644 drivers/crypto/hisilicon/hpre/Makefile create mode 100644 drivers/crypto/hisilicon/hpre/hpre.h create mode 100644 drivers/crypto/hisilicon/hpre/hpre_crypto.c create mode 100644 drivers/crypto/hisilicon/hpre/hpre_main.c
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt