Skip to content

Commit

Permalink
crypto: kpp - Add ctx helpers with DMA alignment
Browse files Browse the repository at this point in the history
This patch adds helpers to access the kpp context structure and
request context structure with an added alignment for DMA access.

Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Dec 2, 2022
1 parent 4ac3377 commit a5a4924
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion include/crypto/internal/kpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,37 @@ static inline void *kpp_request_ctx(struct kpp_request *req)
return req->__ctx;
}

static inline void *kpp_request_ctx_dma(struct kpp_request *req)
{
unsigned int align = crypto_dma_align();

if (align <= crypto_tfm_ctx_alignment())
align = 1;

return PTR_ALIGN(kpp_request_ctx(req), align);
}

static inline void kpp_set_reqsize(struct crypto_kpp *kpp,
unsigned int reqsize)
{
kpp->reqsize = reqsize;
}

static inline void kpp_set_reqsize_dma(struct crypto_kpp *kpp,
unsigned int reqsize)
{
reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1);
kpp->reqsize = reqsize;
}

static inline void *kpp_tfm_ctx(struct crypto_kpp *tfm)
{
return tfm->base.__crt_ctx;
return crypto_tfm_ctx(&tfm->base);
}

static inline void *kpp_tfm_ctx_dma(struct crypto_kpp *tfm)
{
return crypto_tfm_ctx_dma(&tfm->base);
}

static inline void kpp_request_complete(struct kpp_request *req, int err)
Expand Down

0 comments on commit a5a4924

Please sign in to comment.