From e7cd2514ea506f06bd4f7b13a9b62afd60f9c73b Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 14 Dec 2007 22:28:14 +0800 Subject: [CRYPTO] chainiv: Avoid lock spinning where possible This patch makes chainiv avoid spinning by postponing requests on lock contention if the user allows the use of asynchronous algorithms. If a synchronous algorithm is requested then we behave as before. This should improve IPsec performance on SMP when two CPUs attempt to transmit over the same SA. Currently one of them will spin doing nothing waiting for the other CPU to finish its encryption. This patch makes it postpone the request and get on with other work. If only one CPU is transmitting for a given SA, then we will process the request synchronously as before. Signed-off-by: Herbert Xu --- include/crypto/internal/skcipher.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index 0053f34764ff..2ba42cd7d6aa 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h @@ -70,6 +70,19 @@ static inline struct crypto_ablkcipher *skcipher_geniv_cipher( return crypto_ablkcipher_crt(geniv)->base; } +static inline int skcipher_enqueue_givcrypt( + struct crypto_queue *queue, struct skcipher_givcrypt_request *request) +{ + return ablkcipher_enqueue_request(queue, &request->creq); +} + +static inline struct skcipher_givcrypt_request *skcipher_dequeue_givcrypt( + struct crypto_queue *queue) +{ + return container_of(ablkcipher_dequeue_request(queue), + struct skcipher_givcrypt_request, creq); +} + static inline void *skcipher_givcrypt_reqctx( struct skcipher_givcrypt_request *req) { -- cgit v1.2.3-59-g8ed1b