crypto: qat - Remove x86 dependency on QAT drivers
v3 cover crypto: qat - Remove x86 dependency on QAT drivers
The QAT acceleration card can be very helpfull for some tasks like dealing with IPSEC but it is currently restricted to be used only on x86 machine. Looking at the code we didn't see any reasons why those drivers might not work on other architectures. We've successfully built all of them on x86, arm64, arm32, mips64, powerpc64, riscv64 and sparc64.
We also have tested the driver with an Intel Corporation C62x Chipset QuickAssist Technology (rev 04) PCIe card on an arm64 server. After the numa patch, it works with the AF_ALG crypto userland interface, allowing us to encrypt some data with cbc for instance. We've also successfully created some VF, bound them to DPDK, and used the card this way, thus showing some real life usecases of x86 do work on arm64 too.
Changelog v1 ... v2:
- Add COMPILE_TEST to Kconfig
Changelog v2 ... v3:
- Add the Crypto tag to the commit header
Andre Przywara (1):
crypto: qat - replace get_current_node() with numa_node_id()
Yoan Picchi (1):
crypto: qat - Removes the x86 dependency on the QAT drivers
drivers/crypto/qat/Kconfig | 14 +++++++------- drivers/crypto/qat/qat_common/adf_common_drv.h | 5 ----- drivers/crypto/qat/qat_common/qat_algs.c | 4 ++-- drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++-- 4 files changed, 11 insertions(+), 16 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 crypto: qat - replace get_current_node() with numa_node_id()
From: Andre Przywara <[email protected]>
Currently the QAT driver code uses a self-defined wrapper function called get_current_node() when it wants to learn the current NUMA node. This implementation references the topology_physical_package_id[] array, which more or less coincidentally contains the NUMA node id, at least on x86.
Because this is not universal, and Linux offers a direct function to learn the NUMA node ID, replace that function with a call to numa_node_id(), which would work everywhere.
This fixes the QAT driver operation on arm64 machines.
--- drivers/crypto/qat/qat_common/adf_common_drv.h | 5 ----- drivers/crypto/qat/qat_common/qat_algs.c | 4 ++-- drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +0 -5
@@ -49,11 +49,6 @@ struct service_hndl {struct list_head list; }; -static inline int get_current_node (void ) -{ -return topology_physical_package_id (raw_smp_processor_id ()); -} -int adf_service_register (struct service_hndl *service);int adf_service_unregister (struct service_hndl *service);
drivers/crypto/qat/qat_common/qat_algs.c +2 -2
@@ -618,7 +618,7 @@ static int qat_alg_aead_newkey(struct crypto_aead *tfm, const u8 *key, {struct qat_alg_aead_ctx *ctx =crypto_aead_ctx (tfm);struct qat_crypto_instance *inst =NULL ; -int node =get_current_node (); +int node =numa_node_id ();struct device *dev;int ret;
@@ -1042,7 +1042,7 @@ static int qat_alg_skcipher_newkey(struct qat_alg_skcipher_ctx *ctx, {struct qat_crypto_instance *inst =NULL ;struct device *dev; -int node =get_current_node (); +int node =numa_node_id ();int ret; inst =qat_crypto_get_instance_node (node);
drivers/crypto/qat/qat_common/qat_asym_algs.c +2 -2
@@ -480,7 +480,7 @@ static int qat_dh_init_tfm(struct crypto_kpp *tfm) {struct qat_dh_ctx *ctx =kpp_tfm_ctx (tfm);struct qat_crypto_instance *inst = -qat_crypto_get_instance_node (get_current_node ()); +qat_crypto_get_instance_node (numa_node_id ());if (!inst)return -EINVAL ;
@@ -1218,7 +1218,7 @@ static int qat_rsa_init_tfm(struct crypto_akcipher *tfm) {struct qat_rsa_ctx *ctx =akcipher_tfm_ctx (tfm);struct qat_crypto_instance *inst = -qat_crypto_get_instance_node (get_current_node ()); +qat_crypto_get_instance_node (numa_node_id ());if (!inst)return -EINVAL ;
Signature · 1 line
2.25.1
PATCH v3 2/2 crypto: qat - Removes the x86 dependency on the QAT drivers
In reply to Yoan PicchiThis dependency looks outdated. After the previous patch, we have been able to use this driver to encrypt some data and to create working VF on arm64. We have not tested it yet on any big endian machine, hence the new dependency
--- drivers/crypto/qat/Kconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/crypto/qat/Kconfig +7 -7
@@ -17,7 +17,7 @@ config CRYPTO_DEV_QAT config CRYPTO_DEV_QAT_DH895xCC tristate "Support for Intel(R) DH895xCC" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select CRYPTO_DEV_QAT help Support for Intel(R) DH895xcc with Intel(R) QuickAssist Technology
@@ -28,7 +28,7 @@ config CRYPTO_DEV_QAT_DH895xCC config CRYPTO_DEV_QAT_C3XXX tristate "Support for Intel(R) C3XXX" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select CRYPTO_DEV_QAT help Support for Intel(R) C3xxx with Intel(R) QuickAssist Technology
@@ -39,7 +39,7 @@ config CRYPTO_DEV_QAT_C3XXX config CRYPTO_DEV_QAT_C62X tristate "Support for Intel(R) C62X" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select CRYPTO_DEV_QAT help Support for Intel(R) C62x with Intel(R) QuickAssist Technology
@@ -50,7 +50,7 @@ config CRYPTO_DEV_QAT_C62X config CRYPTO_DEV_QAT_4XXX tristate "Support for Intel(R) QAT_4XXX" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select CRYPTO_DEV_QAT help Support for Intel(R) QuickAssist Technology QAT_4xxx
@@ -61,7 +61,7 @@ config CRYPTO_DEV_QAT_4XXX config CRYPTO_DEV_QAT_DH895xCCVF tristate "Support for Intel(R) DH895xCC Virtual Function" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select PCI_IOV select CRYPTO_DEV_QAT
@@ -74,7 +74,7 @@ config CRYPTO_DEV_QAT_DH895xCCVF config CRYPTO_DEV_QAT_C3XXXVF tristate "Support for Intel(R) C3XXX Virtual Function" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select PCI_IOV select CRYPTO_DEV_QAT help
@@ -86,7 +86,7 @@ config CRYPTO_DEV_QAT_C3XXXVF config CRYPTO_DEV_QAT_C62XVF tristate "Support for Intel(R) C62X Virtual Function" - depends on X86 && PCI + depends on PCI && (!CPU_BIG_ENDIAN || COMPILE_TEST) select PCI_IOV select CRYPTO_DEV_QAT help
Signature · 1 line
2.25.1
Herbert Xu
maintainerQuoted 22 lines · Yoan Picchi
The QAT acceleration card can be very helpfull for some tasks like dealing with IPSEC but it is currently restricted to be used only on x86 machine. Looking at the code we didn't see any reasons why those drivers might not work on other architectures. We've successfully built all of them on x86, arm64, arm32, mips64, powerpc64, riscv64 and sparc64.
We also have tested the driver with an Intel Corporation C62x Chipset QuickAssist Technology (rev 04) PCIe card on an arm64 server. After the numa patch, it works with the
AF_ALGcrypto userland interface, allowing us to encrypt some data with cbc for instance. We've also successfully created some VF, bound them to DPDK, and used the card this way, thus showing some real life usecases of x86 do work on arm64 too.Changelog v1 ... v2:
- AddCOMPILE_TESTtoKconfigChangelog v2 ... v3:
- Add the Crypto tag to the commit headerAndre Przywara (1):
crypto: qat - replaceget_current_node()withnuma_node_id()
Quoted 8 lines
Yoan Picchi (1):
crypto: qat - Removes the x86 dependency on the QAT driversdrivers/crypto/qat/Kconfig | 14 +++++++------- drivers/crypto/qat/qat_common/adf_common_drv.h | 5 ----- drivers/crypto/qat/qat_common/qat_algs.c | 4 ++-- drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++-- 4 files changed, 11 insertions(+), 16 deletions(-)
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