Lines Matching defs:areq

23 static bool sun8i_ss_need_fallback(struct skcipher_request *areq)
25 struct scatterlist *in_sg = areq->src;
26 struct scatterlist *out_sg = areq->dst;
29 if (areq->cryptlen == 0 || areq->cryptlen % 16)
32 if (sg_nents(areq->src) > 8 || sg_nents(areq->dst) > 8)
35 sg = areq->src;
45 sg = areq->dst;
57 in_sg = areq->src;
58 out_sg = areq->dst;
70 static int sun8i_ss_cipher_fallback(struct skcipher_request *areq)
72 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
74 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
85 skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags,
86 areq->base.complete, areq->base.data);
87 skcipher_request_set_crypt(&rctx->fallback_req, areq->src, areq->dst,
88 areq->cryptlen, areq->iv);
96 static int sun8i_ss_setup_ivs(struct skcipher_request *areq)
98 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
101 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
102 struct scatterlist *sg = areq->src;
104 unsigned int len = areq->cryptlen;
113 offset = areq->cryptlen - ivsize;
114 scatterwalk_map_and_copy(sf->biv, areq->src, offset,
125 memcpy(sf->iv[0], areq->iv, ivsize);
159 static int sun8i_ss_cipher(struct skcipher_request *areq)
161 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
164 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
178 crypto_tfm_alg_name(areq->base.tfm),
179 areq->cryptlen,
180 rctx->op_dir, areq->iv, crypto_skcipher_ivsize(tfm),
199 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) {
200 err = sun8i_ss_setup_ivs(areq);
204 if (areq->src == areq->dst) {
205 nr_sgs = dma_map_sg(ss->dev, areq->src, sg_nents(areq->src),
214 nr_sgs = dma_map_sg(ss->dev, areq->src, sg_nents(areq->src),
221 nr_sgd = dma_map_sg(ss->dev, areq->dst, sg_nents(areq->dst),
230 len = areq->cryptlen;
232 sg = areq->src;
240 areq->cryptlen, i, rctx->t_src[i].len, sg->offset, todo);
252 len = areq->cryptlen;
254 sg = areq->dst;
262 areq->cryptlen, i, rctx->t_dst[i].len, sg->offset, todo);
274 err = sun8i_ss_run_task(ss, rctx, crypto_tfm_alg_name(areq->base.tfm));
277 if (areq->src == areq->dst) {
278 dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL);
280 dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_TO_DEVICE);
281 dma_unmap_sg(ss->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE);
285 if (areq->iv && ivsize > 0) {
291 offset = areq->cryptlen - ivsize;
293 memcpy(areq->iv, sf->biv, ivsize);
296 scatterwalk_map_and_copy(areq->iv, areq->dst, offset,
309 static int sun8i_ss_handle_cipher_request(struct crypto_engine *engine, void *areq)
312 struct skcipher_request *breq = container_of(areq, struct skcipher_request, base);
322 int sun8i_ss_skdecrypt(struct skcipher_request *areq)
324 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
326 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
333 if (sun8i_ss_need_fallback(areq))
334 return sun8i_ss_cipher_fallback(areq);
340 return crypto_transfer_skcipher_request_to_engine(engine, areq);
343 int sun8i_ss_skencrypt(struct skcipher_request *areq)
345 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
347 struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
354 if (sun8i_ss_need_fallback(areq))
355 return sun8i_ss_cipher_fallback(areq);
361 return crypto_transfer_skcipher_request_to_engine(engine, areq);