Commit b5f755fb authored by Herbert Xu's avatar Herbert Xu

crypto: hash - Add ctx helpers with DMA alignment

This patch adds helpers to access the ahash context structure and
request context structure with an added alignment for DMA access.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f8e4d1d0
...@@ -140,6 +140,11 @@ static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) ...@@ -140,6 +140,11 @@ static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
return crypto_tfm_ctx(crypto_ahash_tfm(tfm)); return crypto_tfm_ctx(crypto_ahash_tfm(tfm));
} }
static inline void *crypto_ahash_ctx_dma(struct crypto_ahash *tfm)
{
return crypto_tfm_ctx_dma(crypto_ahash_tfm(tfm));
}
static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg) static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg)
{ {
return container_of(__crypto_hash_alg_common(alg), struct ahash_alg, return container_of(__crypto_hash_alg_common(alg), struct ahash_alg,
...@@ -152,6 +157,13 @@ static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm, ...@@ -152,6 +157,13 @@ static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm,
tfm->reqsize = reqsize; tfm->reqsize = reqsize;
} }
static inline void crypto_ahash_set_reqsize_dma(struct crypto_ahash *ahash,
unsigned int reqsize)
{
reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1);
ahash->reqsize = reqsize;
}
static inline struct crypto_instance *ahash_crypto_instance( static inline struct crypto_instance *ahash_crypto_instance(
struct ahash_instance *inst) struct ahash_instance *inst)
{ {
...@@ -175,6 +187,16 @@ static inline void *ahash_instance_ctx(struct ahash_instance *inst) ...@@ -175,6 +187,16 @@ static inline void *ahash_instance_ctx(struct ahash_instance *inst)
return crypto_instance_ctx(ahash_crypto_instance(inst)); return crypto_instance_ctx(ahash_crypto_instance(inst));
} }
static inline void *ahash_request_ctx_dma(struct ahash_request *req)
{
unsigned int align = crypto_dma_align();
if (align <= crypto_tfm_ctx_alignment())
align = 1;
return PTR_ALIGN(ahash_request_ctx(req), align);
}
static inline void ahash_request_complete(struct ahash_request *req, int err) static inline void ahash_request_complete(struct ahash_request *req, int err)
{ {
req->base.complete(&req->base, err); req->base.complete(&req->base, err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment