Lines Matching refs:areq
24 static int sun8i_ce_cipher_need_fallback(struct skcipher_request *areq) in sun8i_ce_cipher_need_fallback() argument
26 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_cipher_need_fallback()
34 if (sg_nents_for_len(areq->src, areq->cryptlen) > MAX_SG || in sun8i_ce_cipher_need_fallback()
35 sg_nents_for_len(areq->dst, areq->cryptlen) > MAX_SG) { in sun8i_ce_cipher_need_fallback()
40 if (areq->cryptlen < crypto_skcipher_ivsize(tfm)) { in sun8i_ce_cipher_need_fallback()
45 if (areq->cryptlen == 0) { in sun8i_ce_cipher_need_fallback()
50 if (areq->cryptlen % 16) { in sun8i_ce_cipher_need_fallback()
55 len = areq->cryptlen; in sun8i_ce_cipher_need_fallback()
56 sg = areq->src; in sun8i_ce_cipher_need_fallback()
71 len = areq->cryptlen; in sun8i_ce_cipher_need_fallback()
72 sg = areq->dst; in sun8i_ce_cipher_need_fallback()
89 static int sun8i_ce_cipher_fallback(struct skcipher_request *areq) in sun8i_ce_cipher_fallback() argument
91 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_cipher_fallback()
93 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ce_cipher_fallback()
109 skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags, in sun8i_ce_cipher_fallback()
110 areq->base.complete, areq->base.data); in sun8i_ce_cipher_fallback()
111 skcipher_request_set_crypt(&rctx->fallback_req, areq->src, areq->dst, in sun8i_ce_cipher_fallback()
112 areq->cryptlen, areq->iv); in sun8i_ce_cipher_fallback()
122 struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); in sun8i_ce_cipher_prepare() local
123 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_cipher_prepare()
126 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ce_cipher_prepare()
138 int ns = sg_nents_for_len(areq->src, areq->cryptlen); in sun8i_ce_cipher_prepare()
139 int nd = sg_nents_for_len(areq->dst, areq->cryptlen); in sun8i_ce_cipher_prepare()
144 crypto_tfm_alg_name(areq->base.tfm), in sun8i_ce_cipher_prepare()
145 areq->cryptlen, in sun8i_ce_cipher_prepare()
146 rctx->op_dir, areq->iv, crypto_skcipher_ivsize(tfm), in sun8i_ce_cipher_prepare()
166 cet->t_dlen = cpu_to_le32(areq->cryptlen); in sun8i_ce_cipher_prepare()
168 cet->t_dlen = cpu_to_le32(areq->cryptlen / 4); in sun8i_ce_cipher_prepare()
196 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) { in sun8i_ce_cipher_prepare()
199 offset = areq->cryptlen - ivsize; in sun8i_ce_cipher_prepare()
200 scatterwalk_map_and_copy(chan->backup_iv, areq->src, in sun8i_ce_cipher_prepare()
203 memcpy(chan->bounce_iv, areq->iv, ivsize); in sun8i_ce_cipher_prepare()
214 if (areq->src == areq->dst) { in sun8i_ce_cipher_prepare()
215 nr_sgs = dma_map_sg(ce->dev, areq->src, ns, DMA_BIDIRECTIONAL); in sun8i_ce_cipher_prepare()
223 nr_sgs = dma_map_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); in sun8i_ce_cipher_prepare()
229 nr_sgd = dma_map_sg(ce->dev, areq->dst, nd, DMA_FROM_DEVICE); in sun8i_ce_cipher_prepare()
237 len = areq->cryptlen; in sun8i_ce_cipher_prepare()
238 for_each_sg(areq->src, sg, nr_sgs, i) { in sun8i_ce_cipher_prepare()
243 areq->cryptlen, i, cet->t_src[i].len, sg->offset, todo); in sun8i_ce_cipher_prepare()
252 len = areq->cryptlen; in sun8i_ce_cipher_prepare()
253 for_each_sg(areq->dst, sg, nr_sgd, i) { in sun8i_ce_cipher_prepare()
258 areq->cryptlen, i, cet->t_dst[i].len, sg->offset, todo); in sun8i_ce_cipher_prepare()
267 chan->timeout = areq->cryptlen; in sun8i_ce_cipher_prepare()
273 if (areq->src == areq->dst) { in sun8i_ce_cipher_prepare()
274 dma_unmap_sg(ce->dev, areq->src, ns, DMA_BIDIRECTIONAL); in sun8i_ce_cipher_prepare()
277 dma_unmap_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); in sun8i_ce_cipher_prepare()
278 dma_unmap_sg(ce->dev, areq->dst, nd, DMA_FROM_DEVICE); in sun8i_ce_cipher_prepare()
282 if (areq->iv && ivsize > 0) { in sun8i_ce_cipher_prepare()
285 offset = areq->cryptlen - ivsize; in sun8i_ce_cipher_prepare()
287 memcpy(areq->iv, chan->backup_iv, ivsize); in sun8i_ce_cipher_prepare()
290 scatterwalk_map_and_copy(areq->iv, areq->dst, offset, in sun8i_ce_cipher_prepare()
305 struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); in sun8i_ce_cipher_unprepare() local
306 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_cipher_unprepare()
309 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ce_cipher_unprepare()
322 if (areq->src == areq->dst) { in sun8i_ce_cipher_unprepare()
323 dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL); in sun8i_ce_cipher_unprepare()
326 dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_TO_DEVICE); in sun8i_ce_cipher_unprepare()
327 dma_unmap_sg(ce->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE); in sun8i_ce_cipher_unprepare()
330 if (areq->iv && ivsize > 0) { in sun8i_ce_cipher_unprepare()
333 offset = areq->cryptlen - ivsize; in sun8i_ce_cipher_unprepare()
335 memcpy(areq->iv, chan->backup_iv, ivsize); in sun8i_ce_cipher_unprepare()
338 scatterwalk_map_and_copy(areq->iv, areq->dst, offset, in sun8i_ce_cipher_unprepare()
347 static void sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq) in sun8i_ce_cipher_run() argument
349 struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); in sun8i_ce_cipher_run()
358 sun8i_ce_cipher_unprepare(engine, areq); in sun8i_ce_cipher_run()
364 int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) in sun8i_ce_cipher_do_one() argument
366 int err = sun8i_ce_cipher_prepare(engine, areq); in sun8i_ce_cipher_do_one()
371 sun8i_ce_cipher_run(engine, areq); in sun8i_ce_cipher_do_one()
375 int sun8i_ce_skdecrypt(struct skcipher_request *areq) in sun8i_ce_skdecrypt() argument
377 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_skdecrypt()
379 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ce_skdecrypt()
384 if (sun8i_ce_cipher_need_fallback(areq)) in sun8i_ce_skdecrypt()
385 return sun8i_ce_cipher_fallback(areq); in sun8i_ce_skdecrypt()
391 return crypto_transfer_skcipher_request_to_engine(engine, areq); in sun8i_ce_skdecrypt()
394 int sun8i_ce_skencrypt(struct skcipher_request *areq) in sun8i_ce_skencrypt() argument
396 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ce_skencrypt()
398 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ce_skencrypt()
403 if (sun8i_ce_cipher_need_fallback(areq)) in sun8i_ce_skencrypt()
404 return sun8i_ce_cipher_fallback(areq); in sun8i_ce_skencrypt()
410 return crypto_transfer_skcipher_request_to_engine(engine, areq); in sun8i_ce_skencrypt()