crypto: qat - Add userspace access to QAT services
RFC PATCH 2/4 crypto: qat - Add PKE firmware
In reply to Tadeusz StrukAdd PKE firmware header file and code that loads the PKE firmware.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 4 + drivers/crypto/qat/qat_common/adf_accel_engine.c | 44 ++++++++- drivers/crypto/qat/qat_common/adf_ctl_drv.c | 1 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h | 99 +++++++++++++++++++++ 4 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h
drivers/crypto/qat/qat_common/adf_accel_devices.h +4 -0
@@ -182,6 +182,10 @@ struct icp_qat_fw_loader_handle;struct adf_fw_loader_data {struct icp_qat_fw_loader_handle *fw_loader;const struct firmware *uof_fw; +const struct firmware *mmp_fw; +char *mmp_vaddr; +dma_addr_t mmp_addr; +size_t mmp_fw_size; };struct adf_accel_dev {
drivers/crypto/qat/qat_common/adf_accel_engine.c +40 -4
72 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_ctl_drv.c +1 -0
@@ -486,5 +486,6 @@ module_init(adf_register_ctl_device_driver);module_exit (adf_unregister_ctl_device_driver);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_AUTHOR ("Intel" ); +MODULE_FIRMWARE ("qat_mmp.bin" );MODULE_DESCRIPTION ("Intel(R) QuickAssist Technology" );MODULE_ALIAS ("intel_qat" );
drivers/crypto/qat/qat_common/icp_qat_fw_pke.h new file +99 -0
99 lines not on this page · raw message
cover crypto: qat - Add userspace access to QAT services
Hi,
This series adds support for user space access to QAT services. Intel (R) Quick Assist Technology provides acceleration for symmetric, asymmetric cryptography and compression. Many of these algorithms like RSA, DSA, Diffie–Hellman, Elliptic Curve are very computational expensive and accelerating is highly desirable. This patch series implement a new qat_sym and qat_asym PF_ALG interface that allows access acceleration HW from user space thorough a QAT library available from 01.org website. User space applications can use the QAT services through QAT API. The QAT user space library creates job description requests, and sends it through qat socket to QAT driver. The driver validates the request, remaps user virtual memory (for symmetric ciphers) or copies the input parameters (for public key crypto) and sends it to the acceleration hardware. The data is then processed and the library is notified when it is ready by calling select on the socket.
---
Tadeusz Struk (4):
crytpo: qat - Fix 64 bytes requests
crypto: qat - Add PKE firmware
crypto: qat - Add userspace instances
crypto: qat - Add new algif interface for userspace
drivers/crypto/qat/Kconfig | 9 drivers/crypto/qat/qat_common/Makefile | 3 drivers/crypto/qat/qat_common/adf_accel_devices.h | 19 drivers/crypto/qat/qat_common/adf_accel_engine.c | 42 + drivers/crypto/qat/qat_common/adf_cfg_strings.h | 1 drivers/crypto/qat/qat_common/adf_common_drv.h | 39 + drivers/crypto/qat/qat_common/adf_ctl_drv.c | 13 .../qat/qat_common/adf_transport_access_macros.h | 9 drivers/crypto/qat/qat_common/algif_qat.c | 532 +++++++++++++ drivers/crypto/qat/qat_common/algif_qat_asym.c | 791 ++++++++++++++++++++ drivers/crypto/qat/qat_common/icp_qat_fw_pke.h | 99 +++ drivers/crypto/qat/qat_common/qat_algs.c | 22 - drivers/crypto/qat/qat_common/qat_bufs.h | 65 ++ drivers/crypto/qat/qat_common/qat_crypto.c | 189 +++-- drivers/crypto/qat/qat_common/qat_crypto_user.c | 251 ++++++ drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 86 -- 16 files changed, 1997 insertions(+), 173 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/algif_qat.c create mode 100644 drivers/crypto/qat/qat_common/algif_qat_asym.c create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h create mode 100644 drivers/crypto/qat/qat_common/qat_bufs.h create mode 100644 drivers/crypto/qat/qat_common/qat_crypto_user.c
RFC PATCH 1/4 crytpo: qat - Fix 64 bytes requests
Fix invalid inflights calculation for 64byte PKE requests that will be sent from userspace.
--- .../qat/qat_common/adf_transport_access_macros.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_transport_access_macros.h +6 -3
@@ -83,14 +83,14 @@#define ADF_MAX_RING_SIZE ADF_RING_SIZE_4M#define ADF_DEFAULT_RING_SIZE ADF_RING_SIZE_16K -/* Valid internal msg size values internal */ +/* Valid internal msg size values */ #define ADF_MSG_SIZE_32 0x01#define ADF_MSG_SIZE_64 0x02#define ADF_MSG_SIZE_128 0x04#define ADF_MIN_MSG_SIZE ADF_MSG_SIZE_32#define ADF_MAX_MSG_SIZE ADF_MSG_SIZE_128 -/* Size to bytes conversion macros for ring and msg values */ +/* Size to bytes conversion macros for ring and msg size values */ #define ADF_MSG_SIZE_TO_BYTES (SIZE ) (SIZE << 5)#define ADF_BYTES_TO_MSG_SIZE (SIZE ) (SIZE >> 5)#define ADF_SIZE_TO_RING_SIZE_IN_BYTES (SIZE ) ((1 << (SIZE - 1)) << 7)
@@ -100,8 +100,11 @@#define ADF_RING_SIZE_BYTES_MIN (SIZE ) ((SIZE < ADF_RING_SIZE_4K) ? \ ADF_RING_SIZE_4K : SIZE)#define ADF_RING_SIZE_MODULO (SIZE ) (SIZE + 0x6) +#define ADF_SIZE_TO_POW (SIZE ) ((((SIZE & 0x4) >> 1) | ((SIZE & 0x4) >> 2) | \ + SIZE) & ~0x4) +/* Max outstanding requests */ #define ADF_MAX_INFLIGHTS (RING_SIZE ,MSG_SIZE ) \ - ((((1 << (RING_SIZE - 1)) << 4) >> MSG_SIZE) - 1) + ((((1 << (RING_SIZE - 1)) << 3) >> ADF_SIZE_TO_POW(MSG_SIZE)) - 1)#define BUILD_RING_CONFIG (size) \ ((ADF_RING_NEAR_WATERMARK_0 << ADF_RING_CONFIG_NEAR_FULL_WM) \ | (ADF_RING_NEAR_WATERMARK_0 << ADF_RING_CONFIG_NEAR_EMPTY_WM) \
RFC PATCH 4/4 crypto: qat - Add new algif interface for userspace
In reply to Tadeusz StrukAdd new socket algif interface for userspace for symmetric and asymmetric crypto.
--- drivers/crypto/qat/Kconfig | 9 drivers/crypto/qat/qat_common/Makefile | 3 drivers/crypto/qat/qat_common/adf_common_drv.h | 18 + drivers/crypto/qat/qat_common/adf_ctl_drv.c | 12 drivers/crypto/qat/qat_common/algif_qat.c | 532 ++++++++++++++++ drivers/crypto/qat/qat_common/algif_qat_asym.c | 791 ++++++++++++++++++++++++ drivers/crypto/qat/qat_common/qat_algs.c | 22 - drivers/crypto/qat/qat_common/qat_bufs.h | 65 ++ 8 files changed, 1432 insertions(+), 20 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/algif_qat.c create mode 100644 drivers/crypto/qat/qat_common/algif_qat_asym.c create mode 100644 drivers/crypto/qat/qat_common/qat_bufs.h
drivers/crypto/qat/Kconfig +9 -0
@@ -21,3 +21,12 @@ config CRYPTO_DEV_QAT_DH895xCC To compile this as a module, choose M here: the module will be called qat_dh895xcc. + +config CRYPTO_DEV_QAT_USERSPACE + bool "Support for userspace access to Intel(R) QAT (EXPERIMENTAL)" + depends on CRYPTO_DEV_QAT && CRYPTO_USER_API + default n + help + Support for userspace access to Intel(R) QuickAssist Technology + acceleration. + If unsure, say N.
drivers/crypto/qat/qat_common/Makefile +3 -0
@@ -12,3 +12,6 @@ intel_qat-objs := adf_cfg.o \ qat_hal.o intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o +intel_qat-$(CONFIG_CRYPTO_DEV_QAT_USERSPACE) += algif_qat.o \ + algif_qat_asym.o \ + qat_crypto_user.o
drivers/crypto/qat/qat_common/adf_common_drv.h +18 -0
@@ -136,6 +136,8 @@ struct qat_crypto_instance *qat_crypto_get_kernel_instance(void);struct qat_crypto_instance *qat_crypto_get_user_instance (void );void qat_crypto_put_instance (struct qat_crypto_instance *inst);void qat_alg_callback (void *resp); +void qat_user_callback (void *resp); +void qat_user_asym_callback (void *resp);int qat_algs_init (void );void qat_algs_exit (void );int qat_algs_register (void );
@@ -192,10 +194,26 @@ void qat_uclo_del_uof_obj(struct icp_qat_fw_loader_handle *handle);int qat_uclo_map_uof_obj (struct icp_qat_fw_loader_handle *handle,void *addr_ptr,int mem_size);#ifdef CONFIG_CRYPTO_DEV_QAT_USERSPACE +int algif_qat_init (void ); +void algif_qat_exit (void ); +int algif_qat_asym_init (void ); +void algif_qat_asym_exit (void );int qat_crypto_configure_user_instances (struct adf_accel_dev *accel_dev);int qat_crypto_create_user_instances (struct adf_accel_dev *accel_dev);void qat_crypto_free_user_instances (struct adf_accel_dev *accel_dev);#else +static inline int algif_qat_init (void ) +{ +return 0 ; +} + +#define algif_qat_exit () do {} while (0) +static inline int algif_qat_asym_init (void ) +{ +return 0 ; +} + +#define algif_qat_asym_exit () do {} while (0)static inline int qat_crypto_configure_user_instances (struct adf_accel_dev *dev) {return 0 ;
drivers/crypto/qat/qat_common/adf_ctl_drv.c +12 -0
@@ -460,8 +460,18 @@ static int __init adf_register_ctl_device_driver(void)if (qat_crypto_register ()) goto err_crypto_register; +if (algif_qat_init ()) + goto err_algif; + +if (algif_qat_asym_init ()) + goto err_all; +return 0 ; +err_all: +algif_qat_exit (); +err_algif: +qat_crypto_unregister (); err_crypto_register:adf_exit_aer (); err_aer:
@@ -479,6 +489,8 @@ static void __exit adf_unregister_ctl_device_driver(void)adf_exit_aer ();qat_crypto_unregister ();qat_algs_exit (); +algif_qat_exit (); +algif_qat_asym_exit ();mutex_destroy (&adf_ctl_lock); }
drivers/crypto/qat/qat_common/algif_qat.c new file +532 -0
532 lines not on this page · raw message
drivers/crypto/qat/qat_common/algif_qat_asym.c new file +791 -0
791 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_algs.c +2 -20
@@ -62,6 +62,7 @@#include "icp_qat_hw.h" #include "icp_qat_fw.h" #include "icp_qat_fw_la.h" +#include "qat_bufs.h" #define QAT_AES_HW_CONFIG_ENC (alg) \ ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
@@ -75,19 +76,6 @@static atomic_t active_dev; -struct qat_alg_buf { -uint32_t len; -uint32_t resrvd; -uint64_t addr; -} __packed; - -struct qat_alg_buf_list { -uint64_t resrvd; -uint32_t num_bufs; -uint32_t num_mapped_bufs; -struct qat_alg_buf bufers[]; -} __packed__aligned(64) ; -/* Common content descriptor */ struct qat_alg_cd { union {
@@ -123,11 +111,6 @@ struct qat_alg_session_ctx {spinlock_t lock;/* protects qat_alg_session_ctx struct */ }; -static int get_current_node (void ) -{ -return cpu_data (current_thread_info ()->cpu).phys_proc_id; -} -static int qat_get_inter_state_size (enum icp_qat_hw_auth_algo qat_hash_alg) {switch (qat_hash_alg) {
@@ -500,9 +483,8 @@ static int qat_alg_setkey(struct crypto_aead *tfm, const uint8_t *key, sizeof(struct icp_qat_fw_la_bulk_req)); }else {/* new key */ -int node =get_current_node ();struct qat_crypto_instance *inst = -qat_crypto_get_instance_node (node); +qat_crypto_get_kernel_instance ();if (!inst) {spin_unlock (&ctx->lock);return -EINVAL ;
drivers/crypto/qat/qat_common/qat_bufs.h new file +65 -0
65 lines not on this page · raw message
RFC PATCH 3/4 crypto: qat - Add userspace instances
In reply to Tadeusz StrukAdd code that creates and manages userspace crypto instances.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 15 + drivers/crypto/qat/qat_common/adf_cfg_strings.h | 1 drivers/crypto/qat/qat_common/adf_common_drv.h | 21 ++ drivers/crypto/qat/qat_common/qat_crypto.c | 189 ++++++++++------ drivers/crypto/qat/qat_common/qat_crypto_user.c | 251 +++++++++++++++++++++ drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 86 ------- 6 files changed, 417 insertions(+), 146 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/qat_crypto_user.c
drivers/crypto/qat/qat_common/adf_accel_devices.h +15 -0
@@ -176,6 +176,18 @@ struct adf_hw_device_data {#define GET_MAX_BANKS (accel_dev) (GET_HW_DATA(accel_dev)->num_banks)#define GET_MAX_ACCELENGINES (accel_dev) (GET_HW_DATA(accel_dev)->num_engines)#define accel_to_pci_dev (accel_ptr) accel_ptr->accel_pci_dev.pci_dev +#define GET_INST (accel_dev) (&accel_dev->crypto_list) +#ifdef CONFIG_CRYPTO_DEV_QAT_USERSPACE +#define GET_USER_INST (accel_dev) (&accel_dev->crypto_user_list) +#else +static LIST_HEAD (empty); +static inline struct list_head *__get_empty_list (void ) +{ +return ∅ +} + +#define GET_USER_INST (accel_dev) __get_empty_list() +#endif struct adf_admin_comms ;struct icp_qat_fw_loader_handle ;
@@ -195,6 +207,9 @@ struct adf_accel_dev {struct adf_fw_loader_data *fw_loader;struct adf_admin_comms *admin;struct list_head crypto_list; +#ifdef CONFIG_CRYPTO_DEV_QAT_USERSPACE +struct list_head crypto_user_list; +#endif unsigned long status;atomic_t ref_count;struct dentry *debugfs_dir;
drivers/crypto/qat/qat_common/adf_cfg_strings.h +1 -0
@@ -49,6 +49,7 @@#define ADF_GENERAL_SEC "GENERAL"#define ADF_KERNEL_SEC "KERNEL" +#define ADF_USER_SEC "USER"#define ADF_ACCEL_SEC "Accelerator"#define ADF_NUM_CY "NumberCyInstances"#define ADF_NUM_DC "NumberDcInstances"
drivers/crypto/qat/qat_common/adf_common_drv.h +20 -1
@@ -131,7 +131,9 @@ int adf_init_etr_data(struct adf_accel_dev *accel_dev);void adf_cleanup_etr_data (struct adf_accel_dev *accel_dev);int qat_crypto_register (void );int qat_crypto_unregister (void ); -struct qat_crypto_instance *qat_crypto_get_instance_node (int node); +int qat_crypto_configure_instances (struct adf_accel_dev *accel_dev); +struct qat_crypto_instance *qat_crypto_get_kernel_instance (void ); +struct qat_crypto_instance *qat_crypto_get_user_instance (void );void qat_crypto_put_instance (struct qat_crypto_instance *inst);void qat_alg_callback (void *resp);int qat_algs_init (void );
@@ -189,4 +191,21 @@ int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle);void qat_uclo_del_uof_obj (struct icp_qat_fw_loader_handle *handle);int qat_uclo_map_uof_obj (struct icp_qat_fw_loader_handle *handle,void *addr_ptr,int mem_size); +#ifdef CONFIG_CRYPTO_DEV_QAT_USERSPACE +int qat_crypto_configure_user_instances (struct adf_accel_dev *accel_dev); +int qat_crypto_create_user_instances (struct adf_accel_dev *accel_dev); +void qat_crypto_free_user_instances (struct adf_accel_dev *accel_dev); +#else +static inline int qat_crypto_configure_user_instances (struct adf_accel_dev *dev) +{ +return 0 ; +} + +static inline int qat_crypto_create_user_instances (struct adf_accel_dev *dev) +{ +return 0 ; +} + +#define qat_crypto_free_user_instances (dev) do {} while (0) +#endif #endif
drivers/crypto/qat/qat_common/qat_crypto.c +125 -64
288 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_crypto_user.c new file +251 -0
251 lines not on this page · raw message
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +5 -81
107 lines not on this page · raw message
Herbert Xu
maintainerRe: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
In reply to Tadeusz StrukQuoted 4 lines · Tadeusz Struk
Add new socket algif interface for userspace for symmetric and asymmetric crypto.
Signed-off-by Tadeusz Struk <[email protected]>
No this is not acceptable. algif is meant to expose generic algorithms to user-space not a specific hardware implementation.
Cheers,
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
Re: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Hi Herbert,
Quoted 6 lines · Herbert Xu
Quoted 4 lines
Add new socket algif interface for userspace for symmetric and asymmetric
Quoted 3 lines
crypto.
Signed-off-by Tadeusz Struk <[email protected]>No this is not acceptable. algif is meant to expose generic algorithms to user-space not a specific hardware implementation.
Yes, I know that PF_ALG wasn't designed to expose hardware specific implementation, but the problem is that currently there is no interface that allows using HW acceleration for algorithms such as RSA, DSA, or Diffie-Hellman.
Using PF_ALG works perfectly for this purpose. I can get around 130K RSA decrypt operations per second with 1024 bits modulus. This also scales very well for more accelerators.PF_ALG meant to be crypto interface for user space and this is what I'm using it for here :) Is there any way I can make it (more) acceptable? Regards,
Tadeusz
Herbert Xu
maintainerRe: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Quoted 10 lines · Tadeusz Struk
Yes, I know that
PF_ALGwasn't designed to expose hardware specific implementation, but the problem is that currently there is no interface that allows using HW acceleration for algorithms such as RSA, DSA, or Diffie-Hellman.
UsingPF_ALGworks perfectly for this purpose. I can get around 130K RSA decrypt operations per second with 1024 bits modulus. This also scales very well for more accelerators.PF_ALGmeant to be crypto interface for user space and this is what I'm using it for here :) Is there any way I can make it (more) acceptable?
I see. What we need to do is first fold the current asymmetric crypto code under crypto/asymmetric into the crypto API properly and then export that through algif.
You can then simply implement a hardware driver for such algorithms as you currently do for other crypto API algorithms.
I'll try to work on that.
Cheers,
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
Re: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Quoted 8 lines · Herbert Xu
I see. What we need to do is first fold the current asymmetric crypto code under
crypto/asymmetricinto the crypto API properly and then export that through algif.You can then simply implement a hardware driver for such algorithms as you currently do for other crypto API algorithms.
I'll try to work on that.
What about aead? Using my algif_qat I can build a single request to HW that preforms both encryption and authentication in one go, ever for things like aes-cbc-hmac-sha1. This allows me to get great performance of authenticated encryption from user space.
Regards,
Tadeusz
Herbert Xu
maintainerRe: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Quoted 5 lines · Tadeusz Struk
What about aead? Using my
algif_qatI can build a single request to HW that preforms both encryption and authentication in one go, ever for things like aes-cbc-hmac-sha1. This allows me to get great performance of authenticated encryption from user space.
aead is simpler as it's already part of the API so we just need to add algif_aead.
Cheers,
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
Re: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Hi Herbert,
Quoted 7 lines · Herbert Xu
Quoted 5 lines · Tadeusz Struk
What about aead? Using my
algif_qatI can build a single request to HW that preforms both encryption and authentication in one go, ever for things like aes-cbc-hmac-sha1. This allows me to get great performance of authenticated encryption from user space.
Quoted 5 lines
aead is simpler as it's already part of the API so we just need to add
algif_aead.Cheers,
For the asymmetric crypto below are the operations and algorithms the QAT HW can accelerate.
* DH:
1. Diffie-Hellman phase 1 operations as defined in the PKCS #3 standard.
2. Diffie-Hellman phase 2 operations as defined in the PKCS #3 standard.
* DSA:
1. Generate DSA P Parameter - performs FIPS 186-3 Appendix A.1.1.2 steps 11.4 (c = X mod 2q) and 11.5 (p = X - (c - 1)), and 11.7 (Test whether p is prime)
2. Generate DSA G Parameter - performs FIPS 186-3 Appendix A.2.1, steps 1 (e = (p - 1)/q), 3 g = h^e mod p, and 4
3. Generate DSA Y Parameter - performs FIPS 186-3 section 4.1 (y = g^x mod p)
4. Generate DSA R Signature - performs FIPS 186-3 Section 4.6: r = (g^k mod p) mod q
5. Generate DSA S Signature - performs FIPS 186-3 Section 4.6: s = (k^-1(z + xr)) mod q
6. Generate DSA R and S Signatures - performs FIPS 186-3 Section 4.6: r = (g^k mod p) mod q, s = (k^-1(z + xr)) mod q
7. Verify DSA R and S signatures - performs FIPS 186-3 Section 4.7:
w = (s')^-1 mod q
u1 = (zw) mod q
u2 = ((r')w) mod q
v = (((g)^u1 (y)^u2) mod p) mod q
* RSA:
1. Generate RSA keys - as specified in the PKCS #1 V2.1 standard
2. Perform the RSA encrypt (verify) primitive
3. Perform the RSA decrypt (sign) primitive
* EC:
1. Elliptic Curve Point Multiplication as defined in ANSI X9.63 Annex D.3.2
2. Elliptic Curve Point Verification as defined in ANSI X9.62 Annex A.4.2 steps a, b and c.
3. ECDH Point Multiplication as defined in ANSI X9.63 2001 section 5.4
4. ECDSA generate signature R as per ANSI X9.62 2005 section 7.3
5. ECDSA generate signature S as per ANSI X9.62 2005 section 7.3.
6. ECDSA generate signature R & S as per ANSI X9.62 2005 section 7.3.
7. ECDSA Verify as per ANSI X9.62 2005 section 7.4
* The QAT HW can also perform modular exponentiation operation: r = (base ^ exponent) mod modulus, and modular inversion operation: r = (1/A) mod modulus
* It can also probabilistically test if a number is prime using GCD, Fermat, Miller-Rabin, and Lucas testing methods using all combinations of these methods:
(1x GCD) + (1x Fermat) + (up to 50x Miller-Rabin rounds) + (1x Lucas)
* and it can also accelerate SSL, TLS and TLSv2 key generation and MGF1 as per RFC3447, and Extended Mask Generation Function.
Are you planning to add all of these to the API?
Maybe it will be easier to add a generic af_alg_type e.g "af_direct" for the HW drivers to use to implement HW specific functionality for the stuff that is not yet (or never will) on the API?
I can try to put something together.
Regards,
Tadeusz
Re: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
In reply to Herbert XuHi,
Quoted 7 lines · Herbert Xu
Quoted 5 lines · Tadeusz Struk
What about aead? Using my
algif_qatI can build a single request to HW that preforms both encryption and authentication in one go, ever for things like aes-cbc-hmac-sha1. This allows me to get great performance of authenticated encryption from user space.
Quoted 5 lines
aead is simpler as it's already part of the API so we just need to add
algif_aead.Cheers,
Another thing is that the algif_skcipher works in kind of synchronous way:
------- ----------
| app |--write()--> | socket | --> build_sgl()
------- ---------- |
<----------------------------------/
------- ---------- ------
| app |--read()---> | socket | --send_to_hw()--> | HW |
------- ---------- | ------
| |
| |<-------------------------------wait() <--------/
What I do in the algif_qat is this:
------- ---------- ------
| app |--write()--> | socket | --send_to_hw()--> | HW |
------- ---------- | ------
<----------------------------------/ |
<-------------------------/
------- ----------
| app |--read()---> | socket |
------- ----------
|<--------------------/
This way I can get much higher throughput than with algif_skcipher. Regards,
Tadeusz
Herbert Xu
maintainerRe: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Quoted 2 lines · Tadeusz Struk
This way I can get much higher throughput than with
algif_skcipher.
Yes that's a worthy optimisation. See if you can change the current implementation (without changing the interface) to achieve this.
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
Re: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Hi Herbert,
Quoted 4 lines · Herbert Xu
Quoted 1 line
Quoted 1 line
This way I can get much higher throughput than with
algif_skcipher.Yes that's a worthy optimisation. See if you can change the current implementation (without changing the interface) to achieve this.
Ok, I'll have a look. What about the asymmetric algorithms? Regards,
Tadeusz
Herbert Xu
maintainerRe: [PATCH RFC 4/4] crypto: qat - Add new algif interface for userspace
Quoted 7 lines · Tadeusz Struk
Hi Herbert,
Quoted 4 lines · Herbert Xu
Quoted 1 line
Quoted 1 line
This way I can get much higher throughput than with
algif_skcipher.Yes that's a worthy optimisation. See if you can change the current implementation (without changing the interface) to achieve this.
Ok, I'll have a look. What about the asymmetric algorithms?
I will be taking a look at them but it'll be a while before I get some free time to do so.
Cheers,
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