diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2022-11-25 05:36:41 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2022-12-02 11:12:40 +0100 |
commit | 4ac3377645e98d319cb5404e72d40a4aa69d252c (patch) | |
tree | 9bad2e880c1455e916479652ca206d2245a593fa | |
parent | crypto: api - Increase MAX_ALGAPI_ALIGNMASK to 127 (diff) | |
download | linux-4ac3377645e98d319cb5404e72d40a4aa69d252c.tar.xz linux-4ac3377645e98d319cb5404e72d40a4aa69d252c.zip |
crypto: akcipher - Add ctx helpers with DMA alignment
This patch adds helpers to access the akcipher context structure and
request context structure with an added alignment for DMA access.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | include/crypto/internal/akcipher.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/crypto/internal/akcipher.h b/include/crypto/internal/akcipher.h index 1474a2d890fc..aaf1092b93b8 100644 --- a/include/crypto/internal/akcipher.h +++ b/include/crypto/internal/akcipher.h @@ -33,15 +33,37 @@ static inline void *akcipher_request_ctx(struct akcipher_request *req) return req->__ctx; } +static inline void *akcipher_request_ctx_dma(struct akcipher_request *req) +{ + unsigned int align = crypto_dma_align(); + + if (align <= crypto_tfm_ctx_alignment()) + align = 1; + + return PTR_ALIGN(akcipher_request_ctx(req), align); +} + static inline void akcipher_set_reqsize(struct crypto_akcipher *akcipher, unsigned int reqsize) { akcipher->reqsize = reqsize; } +static inline void akcipher_set_reqsize_dma(struct crypto_akcipher *akcipher, + unsigned int reqsize) +{ + reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1); + akcipher->reqsize = reqsize; +} + static inline void *akcipher_tfm_ctx(struct crypto_akcipher *tfm) { - return tfm->base.__crt_ctx; + return crypto_tfm_ctx(&tfm->base); +} + +static inline void *akcipher_tfm_ctx_dma(struct crypto_akcipher *tfm) +{ + return crypto_tfm_ctx_dma(&tfm->base); } static inline void akcipher_request_complete(struct akcipher_request *req, |