Introduce the cypto engine framework
cover Introduce the cypto engine framework
Now block cipher engines need to implement and maintain their own queue/thread for processing requests, moreover currently helpers provided for only the queue itself (in crypto_enqueue_request() and crypto_dequeue_request()) but they don't help with the mechanics of driving the hardware (things like running the request immediately, DMA map it or providing a thread to process the queue in) even though a lot of that code really shouldn't vary that much from device to device.
This patch introduces the crypto engine framework to help the crypto hardware drivers to queue requests.
Baolin Wang (3):
crypto: Introduce crypto_queue_len() helper function
crypto: Introduce the block request crypto engine framework
crypto: omap-aes: Support crypto engine framework
crypto/Kconfig | 3 + crypto/Makefile | 1 + crypto/crypto_engine.c | 355 +++++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/Kconfig | 1 + drivers/crypto/omap-aes.c | 97 ++++++------- include/crypto/algapi.h | 74 ++++++++++ 6 files changed, 478 insertions(+), 53 deletions(-) create mode 100644 crypto/crypto_engine.c
Signature · 1 line
1.7.9.5
PATCH 1/3 crypto: Introduce crypto_queue_len() helper function
This patch introduces crypto_queue_len() helper function to help to get the queue length in the crypto queue list now.
--- include/crypto/algapi.h | 4 ++++ 1 file changed, 4 insertions(+)
include/crypto/algapi.h +4 -0
@@ -184,6 +184,10 @@ int crypto_enqueue_request(struct crypto_queue *queue, struct crypto_async_request *request);struct crypto_async_request *crypto_dequeue_request (struct crypto_queue *queue);int crypto_tfm_in_queue (struct crypto_queue *queue,struct crypto_tfm *tfm); +static inline unsigned int crypto_queue_len (struct crypto_queue *queue) +{ +return queue->qlen; +}/* These functions require the input/output to be aligned as u32. */ void crypto_inc (u8 *a,unsigned int size);
Signature · 1 line
1.7.9.5
PATCH 2/3 crypto: Introduce the block request crypto engine framework
In reply to Baolin WangNow block cipher engines need to implement and maintain their own queue/thread for processing requests, moreover currently helpers provided for only the queue itself (in crypto_enqueue_request() and crypto_dequeue_request()) but they don't help with the mechanics of driving the hardware (things like running the request immediately, DMA map it or providing a thread to process the queue in) even though a lot of that code really shouldn't vary that much from device to device.
Thus this patch provides a mechanism for pushing requests to the hardware as it becomes free that drivers could use. And this framework is patterned on the SPI code and has worked out well there.
(https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/
drivers/spi/spi.c?id=ffbbdd21329f3e15eeca6df2d4bc11c04d9d91c0)
--- crypto/Kconfig | 3 + crypto/Makefile | 1 + crypto/crypto_engine.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++ include/crypto/algapi.h | 70 ++++++++++ 4 files changed, 429 insertions(+) create mode 100644 crypto/crypto_engine.c
crypto/Kconfig +3 -0
@@ -227,6 +227,9 @@ config CRYPTO_GLUE_HELPER_X86 depends on X86 select CRYPTO_ALGAPI +config CRYPTO_ENGINE + tristate + comment "Authenticated Encryption with Associated Data" config CRYPTO_CCM
crypto/Makefile +1 -0
@@ -7,6 +7,7 @@ crypto-y := api.o cipher.o compress.o memneq.o obj-$(CONFIG_CRYPTO_WORKQUEUE) += crypto_wq.o +obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o obj-$(CONFIG_CRYPTO_FIPS) += fips.o crypto_algapi-$(CONFIG_PROC_FS) += proc.o
crypto/crypto_engine.c new file +355 -0
355 lines not on this page · raw message
include/crypto/algapi.h +70 -0
82 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/3 crypto: omap-aes: Support crypto engine framework
In reply to Baolin WangIntegrate with the newly added crypto engine to make the crypto hardware engine underutilized as each block needs to be processed before the crypto hardware can start working on the next block.
The requests from dm-crypt will be listed into engine queue and processed by engine automatically, so remove the 'queue' and 'queue_task' things in omap aes driver.
--- drivers/crypto/Kconfig | 1 + drivers/crypto/omap-aes.c | 97 ++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 53 deletions(-)
drivers/crypto/Kconfig +1 -0
@@ -293,6 +293,7 @@ config CRYPTO_DEV_OMAP_AES depends on ARCH_OMAP2 || ARCH_OMAP3 || ARCH_OMAP2PLUS select CRYPTO_AES select CRYPTO_BLKCIPHER + select CRYPTO_ENGINE help OMAP processors have AES module accelerator. Select this if you want to use the OMAP module for AES algorithms.
drivers/crypto/omap-aes.c +44 -53
178 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Herbert Xu
maintainerQuoted 10 lines · Baolin Wang
Now block cipher engines need to implement and maintain their own queue/thread for processing requests, moreover currently helpers provided for only the queue itself (in
crypto_enqueue_request()andcrypto_dequeue_request()) but they don't help with the mechanics of driving the hardware (things like running the request immediately, DMA map it or providing a thread to process the queue in) even though a lot of that code really shouldn't vary that much from device to device.This patch introduces the crypto engine framework to help the crypto hardware drivers to queue requests.
Very nice, 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
Quoted 9 lines · Herbert Xu
Quoted 8 lines · Baolin Wang
Now block cipher engines need to implement and maintain their own queue/thread for processing requests, moreover currently helpers provided for only the queue itself (in
crypto_enqueue_request()andcrypto_dequeue_request()) but they don't help with the mechanics of driving the hardware (things like running the request immediately, DMA map it or providing a thread to process the queue in) even though a lot of that code really shouldn't vary that much from device to device.
Quoted 4 lines
Quoted 2 lines
This patch introduces the crypto engine framework to help the crypto hardware drivers to queue requests.
Very nice, all applied. Thanks!
Thanks a lot!
Quoted 4 lines
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Signature · 2 lines
Baolin.wang Best Regards