Lines Matching refs:areq
23 static bool sun8i_ss_need_fallback(struct skcipher_request *areq) in sun8i_ss_need_fallback() argument
25 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_need_fallback()
28 struct scatterlist *in_sg = areq->src; in sun8i_ss_need_fallback()
29 struct scatterlist *out_sg = areq->dst; in sun8i_ss_need_fallback()
33 if (areq->cryptlen == 0 || areq->cryptlen % 16) { in sun8i_ss_need_fallback()
38 if (sg_nents_for_len(areq->src, areq->cryptlen) > 8 || in sun8i_ss_need_fallback()
39 sg_nents_for_len(areq->dst, areq->cryptlen) > 8) { in sun8i_ss_need_fallback()
44 len = areq->cryptlen; in sun8i_ss_need_fallback()
45 sg = areq->src; in sun8i_ss_need_fallback()
59 len = areq->cryptlen; in sun8i_ss_need_fallback()
60 sg = areq->dst; in sun8i_ss_need_fallback()
76 in_sg = areq->src; in sun8i_ss_need_fallback()
77 out_sg = areq->dst; in sun8i_ss_need_fallback()
89 static int sun8i_ss_cipher_fallback(struct skcipher_request *areq) in sun8i_ss_cipher_fallback() argument
91 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_cipher_fallback()
93 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ss_cipher_fallback()
109 skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags, in sun8i_ss_cipher_fallback()
110 areq->base.complete, areq->base.data); in sun8i_ss_cipher_fallback()
111 skcipher_request_set_crypt(&rctx->fallback_req, areq->src, areq->dst, in sun8i_ss_cipher_fallback()
112 areq->cryptlen, areq->iv); in sun8i_ss_cipher_fallback()
120 static int sun8i_ss_setup_ivs(struct skcipher_request *areq) in sun8i_ss_setup_ivs() argument
122 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_setup_ivs()
125 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ss_setup_ivs()
126 struct scatterlist *sg = areq->src; in sun8i_ss_setup_ivs()
128 unsigned int len = areq->cryptlen; in sun8i_ss_setup_ivs()
137 offset = areq->cryptlen - ivsize; in sun8i_ss_setup_ivs()
138 scatterwalk_map_and_copy(sf->biv, areq->src, offset, in sun8i_ss_setup_ivs()
149 memcpy(sf->iv[0], areq->iv, ivsize); in sun8i_ss_setup_ivs()
183 static int sun8i_ss_cipher(struct skcipher_request *areq) in sun8i_ss_cipher() argument
185 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_cipher()
188 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ss_cipher()
197 int nsgs = sg_nents_for_len(areq->src, areq->cryptlen); in sun8i_ss_cipher()
198 int nsgd = sg_nents_for_len(areq->dst, areq->cryptlen); in sun8i_ss_cipher()
204 crypto_tfm_alg_name(areq->base.tfm), in sun8i_ss_cipher()
205 areq->cryptlen, in sun8i_ss_cipher()
206 rctx->op_dir, areq->iv, crypto_skcipher_ivsize(tfm), in sun8i_ss_cipher()
225 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) { in sun8i_ss_cipher()
226 err = sun8i_ss_setup_ivs(areq); in sun8i_ss_cipher()
230 if (areq->src == areq->dst) { in sun8i_ss_cipher()
231 nr_sgs = dma_map_sg(ss->dev, areq->src, nsgs, DMA_BIDIRECTIONAL); in sun8i_ss_cipher()
239 nr_sgs = dma_map_sg(ss->dev, areq->src, nsgs, DMA_TO_DEVICE); in sun8i_ss_cipher()
245 nr_sgd = dma_map_sg(ss->dev, areq->dst, nsgd, DMA_FROM_DEVICE); in sun8i_ss_cipher()
253 len = areq->cryptlen; in sun8i_ss_cipher()
255 sg = areq->src; in sun8i_ss_cipher()
263 areq->cryptlen, i, rctx->t_src[i].len, sg->offset, todo); in sun8i_ss_cipher()
275 len = areq->cryptlen; in sun8i_ss_cipher()
277 sg = areq->dst; in sun8i_ss_cipher()
285 areq->cryptlen, i, rctx->t_dst[i].len, sg->offset, todo); in sun8i_ss_cipher()
297 err = sun8i_ss_run_task(ss, rctx, crypto_tfm_alg_name(areq->base.tfm)); in sun8i_ss_cipher()
300 if (areq->src == areq->dst) { in sun8i_ss_cipher()
301 dma_unmap_sg(ss->dev, areq->src, nsgs, DMA_BIDIRECTIONAL); in sun8i_ss_cipher()
303 dma_unmap_sg(ss->dev, areq->src, nsgs, DMA_TO_DEVICE); in sun8i_ss_cipher()
304 dma_unmap_sg(ss->dev, areq->dst, nsgd, DMA_FROM_DEVICE); in sun8i_ss_cipher()
308 if (areq->iv && ivsize > 0) { in sun8i_ss_cipher()
314 offset = areq->cryptlen - ivsize; in sun8i_ss_cipher()
316 memcpy(areq->iv, sf->biv, ivsize); in sun8i_ss_cipher()
319 scatterwalk_map_and_copy(areq->iv, areq->dst, offset, in sun8i_ss_cipher()
332 int sun8i_ss_handle_cipher_request(struct crypto_engine *engine, void *areq) in sun8i_ss_handle_cipher_request() argument
335 struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); in sun8i_ss_handle_cipher_request()
345 int sun8i_ss_skdecrypt(struct skcipher_request *areq) in sun8i_ss_skdecrypt() argument
347 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_skdecrypt()
349 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ss_skdecrypt()
356 if (sun8i_ss_need_fallback(areq)) in sun8i_ss_skdecrypt()
357 return sun8i_ss_cipher_fallback(areq); in sun8i_ss_skdecrypt()
363 return crypto_transfer_skcipher_request_to_engine(engine, areq); in sun8i_ss_skdecrypt()
366 int sun8i_ss_skencrypt(struct skcipher_request *areq) in sun8i_ss_skencrypt() argument
368 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); in sun8i_ss_skencrypt()
370 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); in sun8i_ss_skencrypt()
377 if (sun8i_ss_need_fallback(areq)) in sun8i_ss_skencrypt()
378 return sun8i_ss_cipher_fallback(areq); in sun8i_ss_skencrypt()
384 return crypto_transfer_skcipher_request_to_engine(engine, areq); in sun8i_ss_skencrypt()